vendor: 20,052 bytes, lines 1-34
1var M3=Object.defineProperty;var O3=(t,e,n)=>e in t?M3(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Xx=(t,e,n)=>O3(t,typeof e!="symbol"?e+"":e,n);function F3(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in t)){const i=Object.getOwnPropertyDescriptor(r,s);i&&Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.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 a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).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)}})();function CI(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var NI={exports:{}},yv={},_I={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 Rf=Symbol.for("react.element"),z3=Symbol.for("react.portal"),$3=Symbol.for("react.fragment"),V3=Symbol.for("react.strict_mode"),U3=Symbol.for("react.profiler"),B3=Symbol.for("react.provider"),W3=Symbol.for("react.context"),H3=Symbol.for("react.forward_ref"),q3=Symbol.for("react.suspense"),G3=Symbol.for("react.memo"),Z3=Symbol.for("react.lazy"),NN=Symbol.iterator;function K3(t){return t===null||typeof t!="object"?null:(t=NN&&t[NN]||t["@@iterator"],typeof t=="function"?t:null)}var EI={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},SI=Object.assign,kI={};function Qu(t,e,n){this.props=t,this.context=e,this.refs=kI,this.updater=n||EI}Qu.prototype.isReactComponent={};Qu.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=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,t,e,"setState")};Qu.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function PI(){}PI.prototype=Qu.prototype;function Wb(t,e,n){this.props=t,this.context=e,this.refs=kI,this.updater=n||EI}var Hb=Wb.prototype=new PI;Hb.constructor=Wb;SI(Hb,Qu.prototype);Hb.isPureReactComponent=!0;var _N=Array.isArray,II=Object.prototype.hasOwnProperty,qb={current:null},TI={key:!0,ref:!0,__self:!0,__source:!0};function AI(t,e,n){var r,s={},i=null,a=null;if(e!=null)for(r in e.ref!==void 0&&(a=e.ref),e.key!==void 0&&(i=""+e.key),e)II.call(e,r)&&!TI.hasOwnProperty(r)&&(s[r]=e[r]);var l=arguments.length-2;if(l===1)s.children=n;else if(1<l){for(var c=Array(l),d=0;d<l;d++)c[d]=arguments[d+2];s.children=c}if(t&&t.defaultProps)for(r in l=t.defaultProps,l)s[r]===void 0&&(s[r]=l[r]);return{$$typeof:Rf,type:t,key:i,ref:a,props:s,_owner:qb.current}}function Y3(t,e){return{$$typeof:Rf,type:t.type,key:e,ref:t.ref,props:t.props,_owner:t._owner}}function Gb(t){return typeof t=="object"&&t!==null&&t.$$typeof===Rf}function Q3(t){var e={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(n){return e[n]})}var EN=/\/+/g;function Jx(t,e){return typeof t=="object"&&t!==null&&t.key!=null?Q3(""+t.key):e.toString(36)}function Tp(t,e,n,r,s){var i=typeof t;(i==="undefined"||i==="boolean")&&(t=null);var a=!1;if(t===null)a=!0;else switch(i){case"string":case"number":a=!0;break;case"object":switch(t.$$typeof){case Rf:case z3:a=!0}}if(a)return a=t,s=s(a),t=r===""?"."+Jx(a,0):r,_N(s)?(n="",t!=null&&(n=t.replace(EN,"$&/")+"/"),Tp(s,e,n,"",function(d){return d})):s!=null&&(Gb(s)&&(s=Y3(s,n+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(EN,"$&/")+"/")+t)),e.push(s)),1;if(a=0,r=r===""?".":r+":",_N(t))for(var l=0;l<t.length;l++){i=t[l];var c=r+Jx(i,l);a+=Tp(i,e,n,c,s)}else if(c=K3(t),typeof c=="function")for(t=c.call(t),l=0;!(i=t.next()).done;)i=i.value,c=r+Jx(i,l++),a+=Tp(i,e,n,c,s);else if(i==="object")throw e=String(t),Error("Objects are not valid as a React child (found: "+(e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)+"). If you meant to render a collection of children, use an array instead.");return a}function Lm(t,e,n){if(t==null)return t;var r=[],s=0;return Tp(t,r,"","",function(i){return e.call(n,i,s++)}),r}function X3(t){if(t._status===-1){var e=t._result;e=e(),e.then(function(n){(t._status===0||t._status===-1)&&(t._status=1,t._result=n)},function(n){(t._status===0||t._status===-1)&&(t._status=2,t._result=n)}),t._status===-1&&(t._status=0,t._result=e)}if(t._status===1)return t._result.default;throw t._result}var Xr={current:null},Ap={transition:null},J3={ReactCurrentDispatcher:Xr,ReactCurrentBatchConfig:Ap,ReactCurrentOwner:qb};function RI(){throw Error("act(...) is not supported in production builds of React.")}wt.Children={map:Lm,forEach:function(t,e,n){Lm(t,function(){e.apply(this,arguments)},n)},count:function(t){var e=0;return Lm(t,function(){e++}),e},toArray:function(t){return Lm(t,function(e){return e})||[]},only:function(t){if(!Gb(t))throw Error("React.Children.only expected to receive a single React element child.");return t}};wt.Component=Qu;wt.Fragment=$3;wt.Profiler=U3;wt.PureComponent=Wb;wt.StrictMode=V3;wt.Suspense=q3;wt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=J3;wt.act=RI;wt.cloneElement=function(t,e,n){if(t==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var r=SI({},t.props),s=t.key,i=t.ref,a=t._owner;if(e!=null){if(e.ref!==void 0&&(i=e.ref,a=qb.current),e.key!==void 0&&(s=""+e.key),t.type&&t.type.defaultProps)var l=t.type.defaultProps;for(c in e)II.call(e,c)&&!TI.hasOwnProperty(c)&&(r[c]=e[c]===void 0&&l!==void 0?l[c]:e[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){l=Array(c);for(var d=0;d<c;d++)l[d]=arguments[d+2];r.children=l}return{$$typeof:Rf,type:t.type,key:s,ref:i,props:r,_owner:a}};wt.createContext=function(t){return t={$$typeof:W3,_currentValue:t,_currentValue2:t,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},t.Provider={$$typeof:B3,_context:t},t.Consumer=t};wt.createElement=AI;wt.createFactory=function(t){var e=AI.bind(null,t);return e.type=t,e};wt.createRef=function(){return{current:null}};wt.forwardRef=function(t){return{$$typeof:H3,render:t}};wt.isValidElement=Gb;wt.lazy=function(t){return{$$typeof:Z3,_payload:{_status:-1,_result:t},_init:X3}};wt.memo=function(t,e){return{$$typeof:G3,type:t,compare:e===void 0?null:e}};wt.startTransition=function(t){var e=Ap.transition;Ap.transition={};try{t()}finally{Ap.transition=e}};wt.unstable_act=RI;wt.useCallback=function(t,e){return Xr.current.useCallback(t,e)};wt.useContext=function(t){return Xr.current.useContext(t)};wt.useDebugValue=function(){};wt.useDeferredValue=function(t){return Xr.current.useDeferredValue(t)};wt.useEffect=function(t,e){return Xr.current.useEffect(t,e)};wt.useId=function(){return Xr.current.useId()};wt.useImperativeHandle=function(t,e,n){return Xr.current.useImperativeHandle(t,e,n)};wt.useInsertionEffect=function(t,e){return Xr.current.useInsertionEffect(t,e)};wt.useLayoutEffect=function(t,e){return Xr.current.useLayoutEffect(t,e)};wt.useMemo=function(t,e){return Xr.current.useMemo(t,e)};wt.useReducer=function(t,e,n){return Xr.current.useReducer(t,e,n)};wt.useRef=function(t){return Xr.current.useRef(t)};wt.useState=function(t){return Xr.current.useState(t)};wt.useSyncExternalStore=function(t,e,n){return Xr.current.useSyncExternalStore(t,e,n)};wt.useTransition=function(){return Xr.current.useTransition()};wt.version="18.3.1";_I.exports=wt;var u=_I.exports;const Ce=CI(u),wv=F3({__proto__:null,default:Ce},[u]);/** 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 e5=u,t5=Symbol.for("react.element"),n5=Symbol.for("react.fragment"),r5=Object.prototype.hasOwnProperty,s5=e5.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o5={key:!0,ref:!0,__self:!0,__source:!0};function DI(t,e,n){var r,s={},i=null,a=null;n!==void 0&&(i=""+n),e.key!==void 0&&(i=""+e.key),e.ref!==void 0&&(a=e.ref);for(r in e)r5.call(e,r)&&!o5.hasOwnProperty(r)&&(s[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)s[r]===void 0&&(s[r]=e[r]);return{$$typeof:t5,type:t,key:i,ref:a,props:s,_owner:s5.current}}yv.Fragment=n5;yv.jsx=DI;yv.jsxs=DI;NI.exports=yv;var o=NI.exports,Dw={},LI={exports:{}},Is={},MI={exports:{}},OI={};/** 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(t){function e(D,F){var O=D.length;D.push(F);e:for(;0<O;){var Y=O-1>>>1,G=D[Y];if(0<s(G,F))D[Y]=F,D[O]=G,O=Y;else break e}}function n(D){return D.length===0?null:D[0]}function r(D){if(D.length===0)return null;var F=D[0],O=D.pop();if(O!==F){D[0]=O;e:for(var Y=0,G=D.length,q=G>>>1;Y<q;){var re=2*(Y+1)-1,U=D[re],ee=re+1,K=D[ee];if(0>s(U,O))ee<G&&0>s(K,U)?(D[Y]=K,D[ee]=O,Y=ee):(D[Y]=U,D[re]=O,Y=re);else if(ee<G&&0>s(K,O))D[Y]=K,D[ee]=O,Y=ee;else break e}}return F}function s(D,F){var O=D.sortIndex-F.sortIndex;return O!==0?O:D.id-F.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var a=Date,l=a.now();t.unstable_now=function(){return a.now()-l}}var c=[],d=[],h=1,f=null,p=3,g=!1,v=!1,x=!1,y=typeof setTimeout=="function"?setTimeout:null,b=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function j(D){for(var F=n(d);F!==null;){if(F.callback===null)r(d);else if(F.startTime<=D)r(d),F.sortIndex=F.expirationTime,e(c,F);else break;F=n(d)}}function E(D){if(x=!1,j(D),!v)if(n(c)!==null)v=!0,H(P);else{var F=n(d);F!==null&&W(E,F.startTime-D)}}function P(D,F){v=!1,x&&(x=!1,b(_),_=-1),g=!0;var O=p;try{for(j(F),f=n(c);f!==null&&(!(f.expirationTime>F)||D&&!I());){var Y=f.callback;if(typeof Y=="function"){f.callback=null,p=f.priorityLevel;var G=Y(f.expirationTime<=F);F=t.unstable_now(),typeof G=="function"?f.callback=G:f===n(c)&&r(c),j(F)}else r(c);f=n(c)}if(f!==null)var q=!0;else{var re=n(d);re!==null&&W(E,re.startTime-F),q=!1}return q}finally{f=null,p=O,g=!1}}var A=!1,N=null,_=-1,k=5,L=-1;function I(){return!(t.unstable_now()-L<k)}function S(){if(N!==null){var D=t.unstable_now();L=D;var F=!0;try{F=N(!0,D)}finally{F?T():(A=!1,N=null)}}else A=!1}var T;if(typeof w=="function")T=function(){w(S)};else if(typeof MessageChannel<"u"){var V=new MessageChannel,$=V.port2;V.port1.onmessage=S,T=function(){$.postMessage(null)}}else T=function(){y(S,0)};function H(D){N=D,A||(A=!0,T())}function W(D,F){_=y(function(){D(t.unstable_now())},F)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(D){D.callback=null},t.unstable_continueExecution=function(){v||g||(v=!0,H(P))},t.unstable_forceFrameRate=function(D){0>D||125<D?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):k=0<D?Math.floor(1e3/D):5},t.unstable_getCurrentPriorityLevel=function(){return p},t.unstable_getFirstCallbackNode=function(){return n(c)},t.unstable_next=function(D){switch(p){case 1:case 2:case 3:var F=3;break;default:F=p}var O=p;p=F;try{return D()}finally{p=O}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(D,F){switch(D){case 1:case 2:case 3:case 4:case 5:break;default:D=3}var O=p;p=D;try{return F()}finally{p=O}},t.unstable_scheduleCallback=function(D,F,O){var Y=t.unstable_now();switch(typeof O=="object"&&O!==null?(O=O.delay,O=typeof O=="number"&&0<O?Y+O:Y):O=Y,D){case 1:var G=-1;break;case 2:G=250;break;case 5:G=1073741823;break;case 4:G=1e4;break;default:G=5e3}return G=O+G,D={id:h++,callback:F,priorityLevel:D,startTime:O,expirationTime:G,sortIndex:-1},O>Y?(D.sortIndex=O,e(d,D),n(c)===null&&D===n(d)&&(x?(b(_),_=-1):x=!0,W(E,O-Y))):(D.sortIndex=G,e(c,D),v||g||(v=!0,H(P))),D},t.unstable_shouldYield=I,t.unstable_wrapCallback=function(D){var F=p;return function(){var O=p;p=F;try{return D.apply(this,arguments)}finally{p=O}}}})(OI);MI.exports=OI;var i5=MI.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 a5=u,Ss=i5;function _e(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n<arguments.length;n++)e+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+t+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var FI=new Set,Vh={};function dc(t,e){Pu(t,e),Pu(t+"Capture",e)}function Pu(t,e){for(Vh[t]=e,t=0;t<e.length;t++)FI.add(e[t])}var ki=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Lw=Object.prototype.hasOwnProperty,l5=/^[: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]*$/,SN={},kN={};function c5(t){return Lw.call(kN,t)?!0:Lw.call(SN,t)?!1:l5.test(t)?kN[t]=!0:(SN[t]=!0,!1)}function u5(t,e,n,r){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function d5(t,e,n,r){if(e===null||typeof e>"u"||u5(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function Jr(t,e,n,r,s,i,a){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=i,this.removeEmptyString=a}var jr={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){jr[t]=new Jr(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];jr[e]=new Jr(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){jr[t]=new Jr(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){jr[t]=new Jr(t,2,!1,t,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(t){jr[t]=new Jr(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){jr[t]=new Jr(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){jr[t]=new Jr(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){jr[t]=new Jr(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){jr[t]=new Jr(t,5,!1,t.toLowerCase(),null,!1,!1)});var Zb=/[\-:]([a-z])/g;function Kb(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Zb,Kb);jr[e]=new Jr(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Zb,Kb);jr[e]=new Jr(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Zb,Kb);jr[e]=new Jr(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){jr[t]=new Jr(t,1,!1,t.toLowerCase(),null,!1,!1)});jr.xlinkHref=new Jr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){jr[t]=new Jr(t,1,!1,t.toLowerCase(),null,!0,!0)});function Yb(t,e,n,r){var s=jr.hasOwnProperty(e)?jr[e]:null;(s!==null?s.type!==0:r||!(2<e.length)||e[0]!=="o"&&e[0]!=="O"||e[1]!=="n"&&e[1]!=="N")&&(d5(e,n,s,r)&&(n=null),r||s===null?c5(e)&&(n===null?t.removeAttribute(e):t.setAttribute(e,""+n)):s.mustUseProperty?t[s.propertyName]=n===null?s.type===3?!1:"":n:(e=s.attributeName,r=s.attributeNamespace,n===null?t.removeAttribute(e):(s=s.type,n=s===3||s===4&&n===!0?"":""+n,r?t.setAttributeNS(r,e,n):t.setAttribute(e,n))))}var Vi=a5.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Mm=Symbol.for("react.element"),Qc=Symbol.for("react.portal"),Xc=Symbol.for("react.fragment"),Qb=Symbol.for("react.strict_mode"),Mw=Symbol.for("react.profiler"),zI=Symbol.for("react.provider"),$I=Symbol.for("react.context"),Xb=Symbol.for("react.forward_ref"),Ow=Symbol.for("react.suspense"),Fw=Symbol.for("react.suspense_list"),Jb=Symbol.for("react.memo"),oa=Symbol.for("react.lazy"),VI=Symbol.for("react.offscreen"),PN=Symbol.iterator;function Dd(t){return t===null||typeof t!="object"?null:(t=PN&&t[PN]||t["@@iterator"],typeof t=="function"?t:null)}var Nn=Object.assign,ey;function sh(t){if(ey===void 0)try{throw Error()}catch(n){var e=n.stack.trim().match(/\n( *(at )?)/);ey=e&&e[1]||""}return` 34`+ey+t}var ty=!1;function ny(t,e){if(!t||ty)return"";ty=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(e)if(e=function(){throw Error()},Object.defineProperty(e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(e,[])}catch(d){var r=d}Reflect.construct(t,[],e)}else{try{e.call()}catch(d){r=d}t.call(e.prototype)}else{try{throw Error()}catch(d){r=d}t()}}
vendor: 14,007 bytes, lines 34-37
34catch(d){if(d&&r&&typeof d.stack=="string"){for(var s=d.stack.split(` 35`),i=r.stack.split(` 36`),a=s.length-1,l=i.length-1;1<=a&&0<=l&&s[a]!==i[l];)l--;for(;1<=a&&0<=l;a--,l--)if(s[a]!==i[l]){if(a!==1||l!==1)do if(a--,l--,0>l||s[a]!==i[l]){var c=` 37`+s[a].replace(" at new "," at ");return t.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",t.displayName)),c}while(1<=a&&0<=l);break}}}finally{ty=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?sh(t):""}function h5(t){switch(t.tag){case 5:return sh(t.type);case 16:return sh("Lazy");case 13:return sh("Suspense");case 19:return sh("SuspenseList");case 0:case 2:case 15:return t=ny(t.type,!1),t;case 11:return t=ny(t.type.render,!1),t;case 1:return t=ny(t.type,!0),t;default:return""}}function zw(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case Xc:return"Fragment";case Qc:return"Portal";case Mw:return"Profiler";case Qb:return"StrictMode";case Ow:return"Suspense";case Fw:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case $I:return(t.displayName||"Context")+".Consumer";case zI:return(t._context.displayName||"Context")+".Provider";case Xb:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Jb:return e=t.displayName||null,e!==null?e:zw(t.type)||"Memo";case oa:e=t._payload,t=t._init;try{return zw(t(e))}catch{}}return null}function f5(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return zw(e);case 8:return e===Qb?"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 e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Ma(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function UI(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function m5(t){var e=UI(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return s.call(this)},set:function(a){r=""+a,i.call(this,a)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Om(t){t._valueTracker||(t._valueTracker=m5(t))}function BI(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=UI(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function ng(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function $w(t,e){var n=e.checked;return Nn({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function IN(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=Ma(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function WI(t,e){e=e.checked,e!=null&&Yb(t,"checked",e,!1)}function Vw(t,e){WI(t,e);var n=Ma(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Uw(t,e.type,n):e.hasOwnProperty("defaultValue")&&Uw(t,e.type,Ma(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function TN(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Uw(t,e,n){(e!=="number"||ng(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var oh=Array.isArray;function uu(t,e,n,r){if(t=t.options,e){e={};for(var s=0;s<n.length;s++)e["$"+n[s]]=!0;for(n=0;n<t.length;n++)s=e.hasOwnProperty("$"+t[n].value),t[n].selected!==s&&(t[n].selected=s),s&&r&&(t[n].defaultSelected=!0)}else{for(n=""+Ma(n),e=null,s=0;s<t.length;s++){if(t[s].value===n){t[s].selected=!0,r&&(t[s].defaultSelected=!0);return}e!==null||t[s].disabled||(e=t[s])}e!==null&&(e.selected=!0)}}function Bw(t,e){if(e.dangerouslySetInnerHTML!=null)throw Error(_e(91));return Nn({},e,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function AN(t,e){var n=e.value;if(n==null){if(n=e.children,e=e.defaultValue,n!=null){if(e!=null)throw Error(_e(92));if(oh(n)){if(1<n.length)throw Error(_e(93));n=n[0]}e=n}e==null&&(e=""),n=e}t._wrapperState={initialValue:Ma(n)}}function HI(t,e){var n=Ma(e.value),r=Ma(e.defaultValue);n!=null&&(n=""+n,n!==t.value&&(t.value=n),e.defaultValue==null&&t.defaultValue!==n&&(t.defaultValue=n)),r!=null&&(t.defaultValue=""+r)}function RN(t){var e=t.textContent;e===t._wrapperState.initialValue&&e!==""&&e!==null&&(t.value=e)}function qI(t){switch(t){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 Ww(t,e){return t==null||t==="http://www.w3.org/1999/xhtml"?qI(e):t==="http://www.w3.org/2000/svg"&&e==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var Fm,GI=function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(e,n,r,s){MSApp.execUnsafeLocalFunction(function(){return t(e,n,r,s)})}:t}(function(t,e){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=e;else{for(Fm=Fm||document.createElement("div"),Fm.innerHTML="<svg>"+e.valueOf().toString()+"</svg>",e=Fm.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function Uh(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var bh={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},p5=["Webkit","ms","Moz","O"];Object.keys(bh).forEach(function(t){p5.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),bh[e]=bh[t]})});function ZI(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||bh.hasOwnProperty(t)&&bh[t]?(""+e).trim():e+"px"}function KI(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=ZI(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,s):t[n]=s}}var g5=Nn({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 Hw(t,e){if(e){if(g5[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(_e(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(_e(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(_e(61))}if(e.style!=null&&typeof e.style!="object")throw Error(_e(62))}}function qw(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){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 Gw=null;function ej(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Zw=null,du=null,hu=null;function DN(t){if(t=Mf(t)){if(typeof Zw!="function")throw Error(_e(280));var e=t.stateNode;e&&(e=_v(e),Zw(t.stateNode,t.type,e))}}function YI(t){du?hu?hu.push(t):hu=[t]:du=t}function QI(){if(du){var t=du,e=hu;if(hu=du=null,DN(t),e)for(t=0;t<e.length;t++)DN(e[t])}}function XI(t,e){return t(e)}function JI(){}var ry=!1;function e2(t,e,n){if(ry)return t(e,n);ry=!0;try{return XI(t,e,n)}finally{ry=!1,(du!==null||hu!==null)&&(JI(),QI())}}function Bh(t,e){var n=t.stateNode;if(n===null)return null;var r=_v(n);if(r===null)return null;n=r[e];e:switch(e){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)||(t=t.type,r=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!r;break e;default:t=!1}if(t)return null;if(n&&typeof n!="function")throw Error(_e(231,e,typeof n));return n}var Kw=!1;if(ki)try{var Ld={};Object.defineProperty(Ld,"passive",{get:function(){Kw=!0}}),window.addEventListener("test",Ld,Ld),window.removeEventListener("test",Ld,Ld)}catch{Kw=!1}function v5(t,e,n,r,s,i,a,l,c){var d=Array.prototype.slice.call(arguments,3);try{e.apply(n,d)}catch(h){this.onError(h)}}var jh=!1,rg=null,sg=!1,Yw=null,x5={onError:function(t){jh=!0,rg=t}};function y5(t,e,n,r,s,i,a,l,c){jh=!1,rg=null,v5.apply(x5,arguments)}function w5(t,e,n,r,s,i,a,l,c){if(y5.apply(this,arguments),jh){if(jh){var d=rg;jh=!1,rg=null}else throw Error(_e(198));sg||(sg=!0,Yw=d)}}function hc(t){var e=t,n=t;if(t.alternate)for(;e.return;)e=e.return;else{t=e;do e=t,e.flags&4098&&(n=e.return),t=e.return;while(t)}return e.tag===3?n:null}function t2(t){if(t.tag===13){var e=t.memoizedState;if(e===null&&(t=t.alternate,t!==null&&(e=t.memoizedState)),e!==null)return e.dehydrated}return null}function LN(t){if(hc(t)!==t)throw Error(_e(188))}function b5(t){var e=t.alternate;if(!e){if(e=hc(t),e===null)throw Error(_e(188));return e!==t?null:t}for(var n=t,r=e;;){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 LN(s),t;if(i===r)return LN(s),e;i=i.sibling}throw Error(_e(188))}if(n.return!==r.return)n=s,r=i;else{for(var a=!1,l=s.child;l;){if(l===n){a=!0,n=s,r=i;break}if(l===r){a=!0,r=s,n=i;break}l=l.sibling}if(!a){for(l=i.child;l;){if(l===n){a=!0,n=i,r=s;break}if(l===r){a=!0,r=i,n=s;break}l=l.sibling}if(!a)throw Error(_e(189))}}if(n.alternate!==r)throw Error(_e(190))}if(n.tag!==3)throw Error(_e(188));return n.stateNode.current===n?t:e}function n2(t){return t=b5(t),t!==null?r2(t):null}function r2(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var e=r2(t);if(e!==null)return e;t=t.sibling}return null}var s2=Ss.unstable_scheduleCallback,MN=Ss.unstable_cancelCallback,j5=Ss.unstable_shouldYield,C5=Ss.unstable_requestPaint,An=Ss.unstable_now,N5=Ss.unstable_getCurrentPriorityLevel,tj=Ss.unstable_ImmediatePriority,o2=Ss.unstable_UserBlockingPriority,og=Ss.unstable_NormalPriority,_5=Ss.unstable_LowPriority,i2=Ss.unstable_IdlePriority,bv=null,Go=null;function E5(t){if(Go&&typeof Go.onCommitFiberRoot=="function")try{Go.onCommitFiberRoot(bv,t,void 0,(t.current.flags&128)===128)}catch{}}var vo=Math.clz32?Math.clz32:P5,S5=Math.log,k5=Math.LN2;function P5(t){return t>>>=0,t===0?32:31-(S5(t)/k5|0)|0}var zm=64,$m=4194304;function ih(t){switch(t&-t){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 t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function ig(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,s=t.suspendedLanes,i=t.pingedLanes,a=n&268435455;if(a!==0){var l=a&~s;l!==0?r=ih(l):(i&=a,i!==0&&(r=ih(i)))}else a=n&~s,a!==0?r=ih(a):i!==0&&(r=ih(i));if(r===0)return 0;if(e!==0&&e!==r&&!(e&s)&&(s=r&-r,i=e&-e,s>=i||s===16&&(i&4194240)!==0))return e;if(r&4&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0<e;)n=31-vo(e),s=1<<n,r|=t[n],e&=~s;return r}function I5(t,e){switch(t){case 1:case 2:case 4:return e+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 e+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 T5(t,e){for(var n=t.suspendedLanes,r=t.pingedLanes,s=t.expirationTimes,i=t.pendingLanes;0<i;){var a=31-vo(i),l=1<<a,c=s[a];c===-1?(!(l&n)||l&r)&&(s[a]=I5(l,e)):c<=e&&(t.expiredLanes|=l),i&=~l}}function Qw(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function a2(){var t=zm;
vendor: 4,186 bytes, line 37
37return zm<<=1,!(zm&4194240)&&(zm=64),t}function sy(t){for(var e=[],n=0;31>n;n++)e.push(t);return e}function Df(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-vo(e),t[e]=n}function A5(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0<n;){var s=31-vo(n),i=1<<s;e[s]=0,r[s]=-1,t[s]=-1,n&=~i}}function nj(t,e){var n=t.entangledLanes|=e;for(t=t.entanglements;n;){var r=31-vo(n),s=1<<r;s&e|t[r]&e&&(t[r]|=e),n&=~s}}var Zt=0;function l2(t){return t&=-t,1<t?4<t?t&268435455?16:536870912:4:1}var c2,rj,u2,d2,h2,Xw=!1,Vm=[],ba=null,ja=null,Ca=null,Wh=new Map,Hh=new Map,ca=[],R5="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 ON(t,e){switch(t){case"focusin":case"focusout":ba=null;break;case"dragenter":case"dragleave":ja=null;break;case"mouseover":case"mouseout":Ca=null;break;case"pointerover":case"pointerout":Wh.delete(e.pointerId);break;case"gotpointercapture":case"lostpointercapture":Hh.delete(e.pointerId)}}function Md(t,e,n,r,s,i){return t===null||t.nativeEvent!==i?(t={blockedOn:e,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[s]},e!==null&&(e=Mf(e),e!==null&&rj(e)),t):(t.eventSystemFlags|=r,e=t.targetContainers,s!==null&&e.indexOf(s)===-1&&e.push(s),t)}function D5(t,e,n,r,s){switch(e){case"focusin":return ba=Md(ba,t,e,n,r,s),!0;case"dragenter":return ja=Md(ja,t,e,n,r,s),!0;case"mouseover":return Ca=Md(Ca,t,e,n,r,s),!0;case"pointerover":var i=s.pointerId;return Wh.set(i,Md(Wh.get(i)||null,t,e,n,r,s)),!0;case"gotpointercapture":return i=s.pointerId,Hh.set(i,Md(Hh.get(i)||null,t,e,n,r,s)),!0}return!1}function f2(t){var e=Il(t.target);if(e!==null){var n=hc(e);if(n!==null){if(e=n.tag,e===13){if(e=t2(n),e!==null){t.blockedOn=e,h2(t.priority,function(){u2(n)});return}}else if(e===3&&n.stateNode.current.memoizedState.isDehydrated){t.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Rp(t){if(t.blockedOn!==null)return!1;for(var e=t.targetContainers;0<e.length;){var n=Jw(t.domEventName,t.eventSystemFlags,e[0],t.nativeEvent);if(n===null){n=t.nativeEvent;var r=new n.constructor(n.type,n);Gw=r,n.target.dispatchEvent(r),Gw=null}else return e=Mf(n),e!==null&&rj(e),t.blockedOn=n,!1;e.shift()}return!0}function FN(t,e,n){Rp(t)&&n.delete(e)}function L5(){Xw=!1,ba!==null&&Rp(ba)&&(ba=null),ja!==null&&Rp(ja)&&(ja=null),Ca!==null&&Rp(Ca)&&(Ca=null),Wh.forEach(FN),Hh.forEach(FN)}function Od(t,e){t.blockedOn===e&&(t.blockedOn=null,Xw||(Xw=!0,Ss.unstable_scheduleCallback(Ss.unstable_NormalPriority,L5)))}function qh(t){function e(s){return Od(s,t)}if(0<Vm.length){Od(Vm[0],t);for(var n=1;n<Vm.length;n++){var r=Vm[n];r.blockedOn===t&&(r.blockedOn=null)}}for(ba!==null&&Od(ba,t),ja!==null&&Od(ja,t),Ca!==null&&Od(Ca,t),Wh.forEach(e),Hh.forEach(e),n=0;n<ca.length;n++)r=ca[n],r.blockedOn===t&&(r.blockedOn=null);for(;0<ca.length&&(n=ca[0],n.blockedOn===null);)f2(n),n.blockedOn===null&&ca.shift()}var fu=Vi.ReactCurrentBatchConfig,ag=!0;function M5(t,e,n,r){var s=Zt,i=fu.transition;fu.transition=null;try{Zt=1,sj(t,e,n,r)}finally{Zt=s,fu.transition=i}}function O5(t,e,n,r){var s=Zt,i=fu.transition;fu.transition=null;try{Zt=4,sj(t,e,n,r)}finally{Zt=s,fu.transition=i}}function sj(t,e,n,r){if(ag){var s=Jw(t,e,n,r);if(s===null)my(t,e,r,lg,n),ON(t,r);else if(D5(s,t,e,n,r))r.stopPropagation();else if(ON(t,r),e&4&&-1<R5.indexOf(t)){for(;s!==null;){var i=Mf(s);if(i!==null&&c2(i),i=Jw(t,e,n,r),i===null&&my(t,e,r,lg,n),i===s)break;s=i}s!==null&&r.stopPropagation()}else my(t,e,r,null,n)}}var lg=null;function Jw(t,e,n,r){if(lg=null,t=ej(r),t=Il(t),t!==null)if(e=hc(t),e===null)t=null;else if(n=e.tag,n===13){if(t=t2(e),t!==null)return t;t=null}else if(n===3){if(e.stateNode.current.memoizedState.isDehydrated)return e.tag===3?e.stateNode.containerInfo:null;t=null}else e!==t&&(t=null);return lg=t,null}
vendor: 10,401 bytes, line 37
37function m2(t){switch(t){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(N5()){case tj:return 1;case o2:return 4;case og:case _5:return 16;case i2:return 536870912;default:return 16}default:return 16}}var ga=null,oj=null,Dp=null;function p2(){if(Dp)return Dp;var t,e=oj,n=e.length,r,s="value"in ga?ga.value:ga.textContent,i=s.length;for(t=0;t<n&&e[t]===s[t];t++);var a=n-t;for(r=1;r<=a&&e[n-r]===s[i-r];r++);return Dp=s.slice(t,1<r?1-r:void 0)}function Lp(t){var e=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&e===13&&(t=13)):t=e,t===10&&(t=13),32<=t||t===13?t:0}function Um(){return!0}function zN(){return!1}function Ts(t){function e(n,r,s,i,a){this._reactName=n,this._targetInst=s,this.type=r,this.nativeEvent=i,this.target=a,this.currentTarget=null;for(var l in t)t.hasOwnProperty(l)&&(n=t[l],this[l]=n?n(i):i[l]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?Um:zN,this.isPropagationStopped=zN,this}return Nn(e.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Um)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Um)},persist:function(){},isPersistent:Um}),e}var Xu={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ij=Ts(Xu),Lf=Nn({},Xu,{view:0,detail:0}),F5=Ts(Lf),oy,iy,Fd,jv=Nn({},Lf,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:aj,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==Fd&&(Fd&&t.type==="mousemove"?(oy=t.screenX-Fd.screenX,iy=t.screenY-Fd.screenY):iy=oy=0,Fd=t),oy)},movementY:function(t){return"movementY"in t?t.movementY:iy}}),$N=Ts(jv),z5=Nn({},jv,{dataTransfer:0}),$5=Ts(z5),V5=Nn({},Lf,{relatedTarget:0}),ay=Ts(V5),U5=Nn({},Xu,{animationName:0,elapsedTime:0,pseudoElement:0}),B5=Ts(U5),W5=Nn({},Xu,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),H5=Ts(W5),q5=Nn({},Xu,{data:0}),VN=Ts(q5),G5={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Z5={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"},K5={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Y5(t){var e=this.nativeEvent;return e.getModifierState?e.getModifierState(t):(t=K5[t])?!!e[t]:!1}function aj(){return Y5}var Q5=Nn({},Lf,{key:function(t){if(t.key){var e=G5[t.key]||t.key;if(e!=="Unidentified")return e}return t.type==="keypress"?(t=Lp(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?Z5[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:aj,charCode:function(t){return t.type==="keypress"?Lp(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Lp(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),X5=Ts(Q5),J5=Nn({},jv,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),UN=Ts(J5),e6=Nn({},Lf,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:aj}),t6=Ts(e6),n6=Nn({},Xu,{propertyName:0,elapsedTime:0,pseudoElement:0}),r6=Ts(n6),s6=Nn({},jv,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),o6=Ts(s6),i6=[9,13,27,32],lj=ki&&"CompositionEvent"in window,Ch=null;ki&&"documentMode"in document&&(Ch=document.documentMode);var a6=ki&&"TextEvent"in window&&!Ch,g2=ki&&(!lj||Ch&&8<Ch&&11>=Ch),BN=" ",WN=!1;function v2(t,e){switch(t){case"keyup":return i6.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function x2(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Jc=!1;function l6(t,e){switch(t){case"compositionend":return x2(e);case"keypress":return e.which!==32?null:(WN=!0,BN);case"textInput":return t=e.data,t===BN&&WN?null:t;default:return null}}function c6(t,e){if(Jc)return t==="compositionend"||!lj&&v2(t,e)?(t=p2(),Dp=oj=ga=null,Jc=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1<e.char.length)return e.char;if(e.which)return String.fromCharCode(e.which)}return null;case"compositionend":return g2&&e.locale!=="ko"?null:e.data;default:return null}}var u6={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 HN(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e==="input"?!!u6[t.type]:e==="textarea"}function y2(t,e,n,r){YI(r),e=cg(e,"onChange"),0<e.length&&(n=new ij("onChange","change",null,n,r),t.push({event:n,listeners:e}))}var Nh=null,Gh=null;function d6(t){I2(t,0)}function Cv(t){var e=nu(t);if(BI(e))return t}function h6(t,e){if(t==="change")return e}var w2=!1;if(ki){var ly;if(ki){var cy="oninput"in document;if(!cy){var qN=document.createElement("div");qN.setAttribute("oninput","return;"),cy=typeof qN.oninput=="function"}ly=cy}else ly=!1;w2=ly&&(!document.documentMode||9<document.documentMode)}function GN(){Nh&&(Nh.detachEvent("onpropertychange",b2),Gh=Nh=null)}function b2(t){if(t.propertyName==="value"&&Cv(Gh)){var e=[];y2(e,Gh,t,ej(t)),e2(d6,e)}}function f6(t,e,n){t==="focusin"?(GN(),Nh=e,Gh=n,Nh.attachEvent("onpropertychange",b2)):t==="focusout"&&GN()}function m6(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return Cv(Gh)}function p6(t,e){if(t==="click")return Cv(e)}function g6(t,e){if(t==="input"||t==="change")return Cv(e)}function v6(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var wo=typeof Object.is=="function"?Object.is:v6;function Zh(t,e){if(wo(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;var n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var s=n[r];if(!Lw.call(e,s)||!wo(t[s],e[s]))return!1}return!0}function ZN(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function KN(t,e){var n=ZN(t);t=0;for(var r;n;){if(n.nodeType===3){if(r=t+n.textContent.length,t<=e&&r>=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=ZN(n)}}function j2(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?j2(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function C2(){for(var t=window,e=ng();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=ng(t.document)}return e}function cj(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function x6(t){var e=C2(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&j2(n.ownerDocument.documentElement,n)){if(r!==null&&cj(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!t.extend&&i>r&&(s=r,r=i,i=s),s=KN(n,i);var a=KN(n,r);s&&a&&(t.rangeCount!==1||t.anchorNode!==s.node||t.anchorOffset!==s.offset||t.focusNode!==a.node||t.focusOffset!==a.offset)&&(e=e.createRange(),e.setStart(s.node,s.offset),t.removeAllRanges(),i>r?(t.addRange(e),t.extend(a.node,a.offset)):(e.setEnd(a.node,a.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<e.length;n++)t=e[n],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var y6=ki&&"documentMode"in document&&11>=document.documentMode,eu=null,e0=null,_h=null,t0=!1;function YN(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;t0||eu==null||eu!==ng(r)||(r=eu,"selectionStart"in r&&cj(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,501 bytes, line 37
37sNode:r.focusNode,focusOffset:r.focusOffset}),_h&&Zh(_h,r)||(_h=r,r=cg(e0,"onSelect"),0<r.length&&(e=new ij("onSelect","select",null,e,n),t.push({event:e,listeners:r}),e.target=eu)))}function Bm(t,e){var n={};return n[t.toLowerCase()]=e.toLowerCase(),n["Webkit"+t]="webkit"+e,n["Moz"+t]="moz"+e,n}var tu={animationend:Bm("Animation","AnimationEnd"),animationiteration:Bm("Animation","AnimationIteration"),animationstart:Bm("Animation","AnimationStart"),transitionend:Bm("Transition","TransitionEnd")},uy={},N2={};ki&&(N2=document.createElement("div").style,"AnimationEvent"in window||(delete tu.animationend.animation,delete tu.animationiteration.animation,delete tu.animationstart.animation),"TransitionEvent"in window||delete tu.transitionend.transition);function Nv(t){if(uy[t])return uy[t];if(!tu[t])return t;var e=tu[t],n;for(n in e)if(e.hasOwnProperty(n)&&n in N2)return uy[t]=e[n];return t}var _2=Nv("animationend"),E2=Nv("animationiteration"),S2=Nv("animationstart"),k2=Nv("transitionend"),P2=new Map,QN="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 Ja(t,e){P2.set(t,e),dc(e,[t])}for(var dy=0;dy<QN.length;dy++){var hy=QN[dy],w6=hy.toLowerCase(),b6=hy[0].toUpperCase()+hy.slice(1);Ja(w6,"on"+b6)}Ja(_2,"onAnimationEnd");Ja(E2,"onAnimationIteration");Ja(S2,"onAnimationStart");Ja("dblclick","onDoubleClick");Ja("focusin","onFocus");Ja("focusout","onBlur");Ja(k2,"onTransitionEnd");Pu("onMouseEnter",["mouseout","mouseover"]);Pu("onMouseLeave",["mouseout","mouseover"]);Pu("onPointerEnter",["pointerout","pointerover"]);Pu("onPointerLeave",["pointerout","pointerover"]);dc("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));dc("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));dc("onBeforeInput",["compositionend","keypress","textInput","paste"]);dc("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));dc("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));dc("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ah="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(" "),j6=new Set("cancel close invalid load scroll toggle".split(" ").concat(ah));function XN(t,e,n){var r=t.type||"unknown-event";t.currentTarget=n,w5(r,e,void 0,t),t.currentTarget=null}function I2(t,e){e=(e&4)!==0;for(var n=0;n<t.length;n++){var r=t[n],s=r.event;r=r.listeners;e:{var i=void 0;if(e)for(var a=r.length-1;0<=a;a--){var l=r[a],c=l.instance,d=l.currentTarget;if(l=l.listener,c!==i&&s.isPropagationStopped())break e;XN(s,l,d),i=c}else for(a=0;a<r.length;a++){if(l=r[a],c=l.instance,d=l.currentTarget,l=l.listener,c!==i&&s.isPropagationStopped())break e;XN(s,l,d),i=c}}}if(sg)throw t=Yw,sg=!1,Yw=null,t}function fn(t,e){var n=e[i0];n===void 0&&(n=e[i0]=new Set);var r=t+"__bubble";n.has(r)||(T2(e,t,2,!1),n.add(r))}function fy(t,e,n){var r=0;e&&(r|=4),T2(n,t,r,e)}var Wm="_reactListening"+Math.random().toString(36).slice(2);function Kh(t){if(!t[Wm]){t[Wm]=!0,FI.forEach(function(n){n!=="selectionchange"&&(j6.has(n)||fy(n,!1,t),fy(n,!0,t))});var e=t.nodeType===9?t:t.ownerDocument;e===null||e[Wm]||(e[Wm]=!0,fy("selectionchange",!1,e))}}function T2(t,e,n,r){switch(m2(e)){case 1:var s=M5;break;case 4:s=O5;break;default:s=sj}n=s.bind(null,e,n,t),s=void 0,!Kw||e!=="touchstart"&&e!=="touchmove"&&e!=="wheel"||(s=!0),r?s!==void 0?t.addEventListener(e,n,{capture:!0,passive:s}):t.addEventListener(e,n,!0):s!==void 0?t.addEventListener(e,n,{passive:s}):t.addEventListener(e,n,!1)}function my(t,e,n,r,s){var i=r;if(!(e&1)&&!(e&2)&&r!==null)e:for(;;){if(r===null)return;var a=r.tag;if(a===3||a===4){var l=r.stateNode.containerInfo;
vendor: 5,317 bytes, lines 37-38
37if(l===s||l.nodeType===8&&l.parentNode===s)break;if(a===4)for(a=r.return;a!==null;){var c=a.tag;if((c===3||c===4)&&(c=a.stateNode.containerInfo,c===s||c.nodeType===8&&c.parentNode===s))return;a=a.return}for(;l!==null;){if(a=Il(l),a===null)return;if(c=a.tag,c===5||c===6){r=i=a;continue e}l=l.parentNode}}r=r.return}e2(function(){var d=i,h=ej(n),f=[];e:{var p=P2.get(t);if(p!==void 0){var g=ij,v=t;switch(t){case"keypress":if(Lp(n)===0)break e;case"keydown":case"keyup":g=X5;break;case"focusin":v="focus",g=ay;break;case"focusout":v="blur",g=ay;break;case"beforeblur":case"afterblur":g=ay;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":g=$N;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":g=$5;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":g=t6;break;case _2:case E2:case S2:g=B5;break;case k2:g=r6;break;case"scroll":g=F5;break;case"wheel":g=o6;break;case"copy":case"cut":case"paste":g=H5;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":g=UN}var x=(e&4)!==0,y=!x&&t==="scroll",b=x?p!==null?p+"Capture":null:p;x=[];for(var w=d,j;w!==null;){j=w;var E=j.stateNode;if(j.tag===5&&E!==null&&(j=E,b!==null&&(E=Bh(w,b),E!=null&&x.push(Yh(w,E,j)))),y)break;w=w.return}0<x.length&&(p=new g(p,v,null,n,h),f.push({event:p,listeners:x}))}}if(!(e&7)){e:{if(p=t==="mouseover"||t==="pointerover",g=t==="mouseout"||t==="pointerout",p&&n!==Gw&&(v=n.relatedTarget||n.fromElement)&&(Il(v)||v[Pi]))break e;if((g||p)&&(p=h.window===h?h:(p=h.ownerDocument)?p.defaultView||p.parentWindow:window,g?(v=n.relatedTarget||n.toElement,g=d,v=v?Il(v):null,v!==null&&(y=hc(v),v!==y||v.tag!==5&&v.tag!==6)&&(v=null)):(g=null,v=d),g!==v)){if(x=$N,E="onMouseLeave",b="onMouseEnter",w="mouse",(t==="pointerout"||t==="pointerover")&&(x=UN,E="onPointerLeave",b="onPointerEnter",w="pointer"),y=g==null?p:nu(g),j=v==null?p:nu(v),p=new x(E,w+"leave",g,n,h),p.target=y,p.relatedTarget=j,E=null,Il(h)===d&&(x=new x(b,w+"enter",v,n,h),x.target=j,x.relatedTarget=y,E=x),y=E,g&&v)t:{for(x=g,b=v,w=0,j=x;j;j=Lc(j))w++;for(j=0,E=b;E;E=Lc(E))j++;for(;0<w-j;)x=Lc(x),w--;for(;0<j-w;)b=Lc(b),j--;for(;w--;){if(x===b||b!==null&&x===b.alternate)break t;x=Lc(x),b=Lc(b)}x=null}else x=null;g!==null&&JN(f,p,g,x,!1),v!==null&&y!==null&&JN(f,y,v,x,!0)}}e:{if(p=d?nu(d):window,g=p.nodeName&&p.nodeName.toLowerCase(),g==="select"||g==="input"&&p.type==="file")var P=h6;else if(HN(p))if(w2)P=g6;else{P=m6;var A=f6}else(g=p.nodeName)&&g.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(P=p6);if(P&&(P=P(t,d))){y2(f,P,n,h);break e}A&&A(t,p,d),t==="focusout"&&(A=p._wrapperState)&&A.controlled&&p.type==="number"&&Uw(p,"number",p.value)}switch(A=d?nu(d):window,t){case"focusin":(HN(A)||A.contentEditable==="true")&&(eu=A,e0=d,_h=null);break;case"focusout":_h=e0=eu=null;break;case"mousedown":t0=!0;break;case"contextmenu":case"mouseup":case"dragend":t0=!1,YN(f,n,h);break;case"selectionchange":if(y6)break;case"keydown":case"keyup":YN(f,n,h)}var N;if(lj)e:{switch(t){case"compositionstart":var _="onCompositionStart";break e;case"compositionend":_="onCompositionEnd";break e;case"compositionupdate":_="onCompositionUpdate";break e}_=void 0}else Jc?v2(t,n)&&(_="onCompositionEnd"):t==="keydown"&&n.keyCode===229&&(_="onCompositionStart");_&&(g2&&n.locale!=="ko"&&(Jc||_!=="onCompositionStart"?_==="onCompositionEnd"&&Jc&&(N=p2()):(ga=h,oj="value"in ga?ga.value:ga.textContent,Jc=!0)),A=cg(d,_),0<A.length&&(_=new VN(_,t,null,n,h),f.push({event:_,listeners:A}),N?_.data=N:(N=x2(n),N!==null&&(_.data=N)))),(N=a6?l6(t,n):c6(t,n))&&(d=cg(d,"onBeforeInput"),0<d.length&&(h=new VN("onBeforeInput","beforeinput",null,n,h),f.push({event:h,listeners:d}),h.data=N))}I2(f,e)})}function Yh(t,e,n){return{instance:t,listener:e,currentTarget:n}}function cg(t,e){for(var n=e+"Capture",r=[];t!==null;){var s=t,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=Bh(t,n),i!=null&&r.unshift(Yh(t,i,s)),i=Bh(t,e),i!=null&&r.push(Yh(t,i,s))),t=t.return}return r}function Lc(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function JN(t,e,n,r,s){for(var i=e._reactName,a=[];n!==null&&n!==r;){var l=n,c=l.alternate,d=l.stateNode;if(c!==null&&c===r)break;l.tag===5&&d!==null&&(l=d,s?(c=Bh(n,i),c!=null&&a.unshift(Yh(n,c,l))):s||(c=Bh(n,i),c!=null&&a.push(Yh(n,c,l)))),n=n.return}a.length!==0&&t.push({event:e,listeners:a})}var C6=/\r\n?/g,N6=/\u0000|\uFFFD/g;function e_(t){return(typeof t=="string"?t:""+t).replace(C6,` 38`).replace(N6,"")}function Hm(t,e,n){if(e=e_(e),e_(t)!==e&&n)throw Error(_e(425))}function ug(){}var n0=null,r0=null;function s0(t,e){return t==="textarea"||t==="noscript"||typeof e.children=="string"||typeof e.children=="number"||typeof e.dangerouslySetInnerHTML=="object"&&e.dangerouslySetInnerHTML!==null&&e.dangerouslySetInnerHTML.__html!=null}var o0=typeof setTimeout=="function"?setTimeout:void 0,_6=typeof clearTimeout=="function"?clearTimeout:void 0,t_=typeof Promise=="function"?Promise:void 0,E6=typeof queueMicrotask=="function"?queueMicrotask:typeof t_<"u"?function(t){return t_.resolve(null).then(t).cat
vendor: 4,153 bytes, line 38
38ch(S6)}:o0;function S6(t){setTimeout(function(){throw t})}function py(t,e){var n=e,r=0;do{var s=n.nextSibling;if(t.removeChild(n),s&&s.nodeType===8)if(n=s.data,n==="/$"){if(r===0){t.removeChild(s),qh(e);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);qh(e)}function Na(t){for(;t!=null;t=t.nextSibling){var e=t.nodeType;if(e===1||e===3)break;if(e===8){if(e=t.data,e==="$"||e==="$!"||e==="$?")break;if(e==="/$")return null}}return t}function n_(t){t=t.previousSibling;for(var e=0;t;){if(t.nodeType===8){var n=t.data;if(n==="$"||n==="$!"||n==="$?"){if(e===0)return t;e--}else n==="/$"&&e++}t=t.previousSibling}return null}var Ju=Math.random().toString(36).slice(2),Vo="__reactFiber$"+Ju,Qh="__reactProps$"+Ju,Pi="__reactContainer$"+Ju,i0="__reactEvents$"+Ju,k6="__reactListeners$"+Ju,P6="__reactHandles$"+Ju;function Il(t){var e=t[Vo];if(e)return e;for(var n=t.parentNode;n;){if(e=n[Pi]||n[Vo]){if(n=e.alternate,e.child!==null||n!==null&&n.child!==null)for(t=n_(t);t!==null;){if(n=t[Vo])return n;t=n_(t)}return e}t=n,n=t.parentNode}return null}function Mf(t){return t=t[Vo]||t[Pi],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function nu(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(_e(33))}function _v(t){return t[Qh]||null}var a0=[],ru=-1;function el(t){return{current:t}}function pn(t){0>ru||(t.current=a0[ru],a0[ru]=null,ru--)}function on(t,e){ru++,a0[ru]=t.current,t.current=e}var Oa={},$r=el(Oa),ls=el(!1),Wl=Oa;function Iu(t,e){var n=t.type.contextTypes;if(!n)return Oa;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=e[i];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=s),s}function cs(t){return t=t.childContextTypes,t!=null}function dg(){pn(ls),pn($r)}function r_(t,e,n){if($r.current!==Oa)throw Error(_e(168));on($r,e),on(ls,n)}function A2(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in e))throw Error(_e(108,f5(t)||"Unknown",s));return Nn({},n,r)}function hg(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Oa,Wl=$r.current,on($r,t),on(ls,ls.current),!0}function s_(t,e,n){var r=t.stateNode;if(!r)throw Error(_e(169));n?(t=A2(t,e,Wl),r.__reactInternalMemoizedMergedChildContext=t,pn(ls),pn($r),on($r,t)):pn(ls),on(ls,n)}var gi=null,Ev=!1,gy=!1;function R2(t){gi===null?gi=[t]:gi.push(t)}function I6(t){Ev=!0,R2(t)}function tl(){if(!gy&&gi!==null){gy=!0;var t=0,e=Zt;try{var n=gi;for(Zt=1;t<n.length;t++){var r=n[t];do r=r(!0);while(r!==null)}gi=null,Ev=!1}catch(s){throw gi!==null&&(gi=gi.slice(t+1)),s2(tj,tl),s}finally{Zt=e,gy=!1}}return null}var su=[],ou=0,fg=null,mg=0,Os=[],Fs=0,Hl=null,xi=1,yi="";function bl(t,e){su[ou++]=mg,su[ou++]=fg,fg=t,mg=e}function D2(t,e,n){Os[Fs++]=xi,Os[Fs++]=yi,Os[Fs++]=Hl,Hl=t;var r=xi;t=yi;var s=32-vo(r)-1;r&=~(1<<s),n+=1;var i=32-vo(e)+s;if(30<i){var a=s-s%5;i=(r&(1<<a)-1).toString(32),r>>=a,s-=a,xi=1<<32-vo(e)+s|n<<s|r,yi=i+t}else xi=1<<i|n<<s|r,yi=t}function uj(t){t.return!==null&&(bl(t,1),D2(t,1,0))}function dj(t){for(;t===fg;)fg=su[--ou],su[ou]=null,mg=su[--ou],su[ou]=null;for(;t===Hl;)Hl=Os[--Fs],Os[Fs]=null,yi=Os[--Fs],Os[Fs]=null,xi=Os[--Fs],Os[Fs]=null}var _s=null,js=null,vn=!1,co=null;function L2(t,e){var n=zs(5,null,null,0);n.elementType="DELETED",n.stateNode=e,n.return=t,e=t.deletions,e===null?(t.deletions=[n],t.flags|=16):e.push(n)}function o_(t,e){switch(t.tag){case 5:var n=t.type;return e=e.nodeType!==1||n.toLowerCase()!==e.nodeName.toLowerCase()?null:e,e!==null?(t.stateNode=e,_s=t,js=Na(e.firstChild),!0):!1;case 6:return e=t.pendingProps===""||e.nodeType!==3?null:e,e!==null?(t.stateNode=e,_s=t,js=null,!0):!1;case 13:return e=e.nodeType!==8?null:e,e!==null?(n=Hl!==null?{id:xi,overflow:yi}:null,t.memoizedState={dehydrated:e,treeContext:n,retryLane:1073741824},n=zs(18,null,null,0),n.stateNode=e,n.return=t,t.child=n,_s=t,js=null,!0):!1;default:return!1}}function l0(t){return(t.mode&1)!==0&&(t.flags&128)===0}function c0(t){if(vn){var e=js;
vendor: 12,375 bytes, line 38
38if(e){var n=e;if(!o_(t,e)){if(l0(t))throw Error(_e(418));e=Na(n.nextSibling);var r=_s;e&&o_(t,e)?L2(r,n):(t.flags=t.flags&-4097|2,vn=!1,_s=t)}}else{if(l0(t))throw Error(_e(418));t.flags=t.flags&-4097|2,vn=!1,_s=t}}}function i_(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;_s=t}function qm(t){if(t!==_s)return!1;if(!vn)return i_(t),vn=!0,!1;var e;if((e=t.tag!==3)&&!(e=t.tag!==5)&&(e=t.type,e=e!=="head"&&e!=="body"&&!s0(t.type,t.memoizedProps)),e&&(e=js)){if(l0(t))throw M2(),Error(_e(418));for(;e;)L2(t,e),e=Na(e.nextSibling)}if(i_(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(_e(317));e:{for(t=t.nextSibling,e=0;t;){if(t.nodeType===8){var n=t.data;if(n==="/$"){if(e===0){js=Na(t.nextSibling);break e}e--}else n!=="$"&&n!=="$!"&&n!=="$?"||e++}t=t.nextSibling}js=null}}else js=_s?Na(t.stateNode.nextSibling):null;return!0}function M2(){for(var t=js;t;)t=Na(t.nextSibling)}function Tu(){js=_s=null,vn=!1}function hj(t){co===null?co=[t]:co.push(t)}var T6=Vi.ReactCurrentBatchConfig;function zd(t,e,n){if(t=n.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(_e(309));var r=n.stateNode}if(!r)throw Error(_e(147,t));var s=r,i=""+t;return e!==null&&e.ref!==null&&typeof e.ref=="function"&&e.ref._stringRef===i?e.ref:(e=function(a){var l=s.refs;a===null?delete l[i]:l[i]=a},e._stringRef=i,e)}if(typeof t!="string")throw Error(_e(284));if(!n._owner)throw Error(_e(290,t))}return t}function Gm(t,e){throw t=Object.prototype.toString.call(e),Error(_e(31,t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t))}function a_(t){var e=t._init;return e(t._payload)}function O2(t){function e(b,w){if(t){var j=b.deletions;j===null?(b.deletions=[w],b.flags|=16):j.push(w)}}function n(b,w){if(!t)return null;for(;w!==null;)e(b,w),w=w.sibling;return null}function r(b,w){for(b=new Map;w!==null;)w.key!==null?b.set(w.key,w):b.set(w.index,w),w=w.sibling;return b}function s(b,w){return b=ka(b,w),b.index=0,b.sibling=null,b}function i(b,w,j){return b.index=j,t?(j=b.alternate,j!==null?(j=j.index,j<w?(b.flags|=2,w):j):(b.flags|=2,w)):(b.flags|=1048576,w)}function a(b){return t&&b.alternate===null&&(b.flags|=2),b}function l(b,w,j,E){return w===null||w.tag!==6?(w=Cy(j,b.mode,E),w.return=b,w):(w=s(w,j),w.return=b,w)}function c(b,w,j,E){var P=j.type;return P===Xc?h(b,w,j.props.children,E,j.key):w!==null&&(w.elementType===P||typeof P=="object"&&P!==null&&P.$$typeof===oa&&a_(P)===w.type)?(E=s(w,j.props),E.ref=zd(b,w,j),E.return=b,E):(E=Up(j.type,j.key,j.props,null,b.mode,E),E.ref=zd(b,w,j),E.return=b,E)}function d(b,w,j,E){return w===null||w.tag!==4||w.stateNode.containerInfo!==j.containerInfo||w.stateNode.implementation!==j.implementation?(w=Ny(j,b.mode,E),w.return=b,w):(w=s(w,j.children||[]),w.return=b,w)}function h(b,w,j,E,P){return w===null||w.tag!==7?(w=Fl(j,b.mode,E,P),w.return=b,w):(w=s(w,j),w.return=b,w)}function f(b,w,j){if(typeof w=="string"&&w!==""||typeof w=="number")return w=Cy(""+w,b.mode,j),w.return=b,w;if(typeof w=="object"&&w!==null){switch(w.$$typeof){case Mm:return j=Up(w.type,w.key,w.props,null,b.mode,j),j.ref=zd(b,null,w),j.return=b,j;case Qc:return w=Ny(w,b.mode,j),w.return=b,w;case oa:var E=w._init;return f(b,E(w._payload),j)}if(oh(w)||Dd(w))return w=Fl(w,b.mode,j,null),w.return=b,w;Gm(b,w)}return null}function p(b,w,j,E){var P=w!==null?w.key:null;if(typeof j=="string"&&j!==""||typeof j=="number")return P!==null?null:l(b,w,""+j,E);if(typeof j=="object"&&j!==null){switch(j.$$typeof){case Mm:return j.key===P?c(b,w,j,E):null;case Qc:return j.key===P?d(b,w,j,E):null;case oa:return P=j._init,p(b,w,P(j._payload),E)}if(oh(j)||Dd(j))return P!==null?null:h(b,w,j,E,null);Gm(b,j)}return null}function g(b,w,j,E,P){if(typeof E=="string"&&E!==""||typeof E=="number")return b=b.get(j)||null,l(w,b,""+E,P);if(typeof E=="object"&&E!==null){switch(E.$$typeof){case Mm:return b=b.get(E.key===null?j:E.key)||null,c(w,b,E,P);case Qc:return b=b.get(E.key===null?j:E.key)||null,d(w,b,E,P);case oa:var A=E._init;return g(b,w,j,A(E._payload),P)}if(oh(E)||Dd(E))return b=b.get(j)||null,h(w,b,E,P,null);Gm(w,E)}return null}function v(b,w,j,E){for(var P=null,A=null,N=w,_=w=0,k=null;N!==null&&_<j.length;_++){N.index>_?(k=N,N=null):k=N.sibling;var L=p(b,N,j[_],E);if(L===null){N===null&&(N=k);break}t&&N&&L.alternate===null&&e(b,N),w=i(L,w,_),A===null?P=L:A.sibling=L,A=L,N=k}if(_===j.length)return n(b,N),vn&&bl(b,_),P;if(N===null){for(;_<j.length;_++)N=f(b,j[_],E),N!==null&&(w=i(N,w,_),A===null?P=N:A.sibling=N,A=N);return vn&&bl(b,_),P}for(N=r(b,N);_<j.length;_++)k=g(N,b,_,j[_],E),k!==null&&(t&&k.alternate!==null&&N.delete(k.key===null?_:k.key),w=i(k,w,_),A===null?P=k:A.sibling=k,A=k);return t&&N.forEach(function(I){return e(b,I)}),vn&&bl(b,_),P}function x(b,w,j,E){var P=Dd(j);if(typeof P!="function")throw Error(_e(150));if(j=P.call(j),j==null)throw Error(_e(151));for(var A=P=null,N=w,_=w=0,k=null,L=j.next();N!==null&&!L.done;_++,L=j.next()){N.index>_?(k=N,N=null):k=N.sibling;var I=p(b,N,L.value,E);if(I===null){N===null&&(N=k);break}t&&N&&I.alternate===null&&e(b,N),w=i(I,w,_),A===null?P=I:A.sibling=I,A=I,N=k}if(L.done)return n(b,N),vn&&bl(b,_),P;if(N===null){for(;!L.done;_++,L=j.next())L=f(b,L.value,E),L!==null&&(w=i(L,w,_),A===null?P=L:A.sibling=L,A=L);return vn&&bl(b,_),P}for(N=r(b,N);!L.done;_++,L=j.next())L=g(N,b,_,L.value,E),L!==null&&(t&&L.alternate!==null&&N.delete(L.key===null?_:L.key),w=i(L,w,_),A===null?P=L:A.sibling=L,A=L);return t&&N.forEach(function(S){return e(b,S)}),vn&&bl(b,_),P}function y(b,w,j,E){if(typeof j=="object"&&j!==null&&j.type===Xc&&j.key===null&&(j=j.props.children),typeof j=="object"&&j!==null){switch(j.$$typeof){case Mm:e:{for(var P=j.key,A=w;A!==null;){if(A.key===P){if(P=j.type,P===Xc){if(A.tag===7){n(b,A.sibling),w=s(A,j.props.children),w.return=b,b=w;break e}}else if(A.elementType===P||typeof P=="object"&&P!==null&&P.$$typeof===oa&&a_(P)===A.type){n(b,A.sibling),w=s(A,j.props),w.ref=zd(b,A,j),w.return=b,b=w;break e}n(b,A);break}else e(b,A);A=A.sibling}j.type===Xc?(w=Fl(j.props.children,b.mode,E,j.key),w.return=b,b=w):(E=Up(j.type,j.key,j.props,null,b.mode,E),E.ref=zd(b,w,j),E.return=b,b=E)}return a(b);case Qc:e:{for(A=j.key;w!==null;){if(w.key===A)if(w.tag===4&&w.stateNode.containerInfo===j.containerInfo&&w.stateNode.implementation===j.implementation){n(b,w.sibling),w=s(w,j.children||[]),w.return=b,b=w;break e}else{n(b,w);break}else e(b,w);w=w.sibling}w=Ny(j,b.mode,E),w.return=b,b=w}return a(b);case oa:return A=j._init,y(b,w,A(j._payload),E)}if(oh(j))return v(b,w,j,E);if(Dd(j))return x(b,w,j,E);Gm(b,j)}return typeof j=="string"&&j!==""||typeof j=="number"?(j=""+j,w!==null&&w.tag===6?(n(b,w.sibling),w=s(w,j),w.return=b,b=w):(n(b,w),w=Cy(j,b.mode,E),w.return=b,b=w),a(b)):n(b,w)}return y}var Au=O2(!0),F2=O2(!1),pg=el(null),gg=null,iu=null,fj=null;function mj(){fj=iu=gg=null}function pj(t){var e=pg.current;pn(pg),t._currentValue=e}function u0(t,e,n){for(;t!==null;){var r=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),t===n)break;t=t.return}}function mu(t,e){gg=t,fj=iu=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(as=!0),t.firstContext=null)}function Gs(t){var e=t._currentValue;if(fj!==t)if(t={context:t,memoizedValue:e,next:null},iu===null){if(gg===null)throw Error(_e(308));iu=t,gg.dependencies={lanes:0,firstContext:t}}else iu=iu.next=t;return e}var Tl=null;function gj(t){Tl===null?Tl=[t]:Tl.push(t)}function z2(t,e,n,r){var s=e.interleaved;return s===null?(n.next=n,gj(e)):(n.next=s.next,s.next=n),e.interleaved=n,Ii(t,r)}function Ii(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}var ia=!1;function vj(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function $2(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function _i(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function _a(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,Tt&2){var s=r.pending;return s===null?e.next=e:(e.next=s.next,s.next=e),r.pending=e,Ii(t,n)}return s=r.interleaved,s===null?(e.next=e,gj(r)):(e.next=s.next,s.next=e),r.interleaved=e,Ii(t,n)}function Mp(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,nj(t,n)}}function l_(t,e){var n=t.updateQueue,r=t.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?s=i=a:i=i.next=a,n=n.next}while(n!==null);i===null?s=i=e:i=i.next=e}else s=i=e;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function vg(t,e,n,r){var s=t.updateQueue;ia=!1;var i=s.firstBaseUpdate,a=s.lastBaseUpdate,l=s.shared.pending;if(l!==null){s.shared.pending=null;var c=l,d=c.next;c.next=null,a===null?i=d:a.next=d,a=c;var h=t.alternate;h!==null&&(h=h.updateQueue,l=h.lastBaseUpdate,l!==a&&(l===null?h.firstBaseUpdate=d:l.next=d,h.lastBaseUpdate=c))}if(i!==null){var f=s.baseState;a=0,h=d=c=null,l=i;do{var p=l.lane,g=l.eventTime;if((r&p)===p){h!==null&&(h=h.next={eventTime:g,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var v=t,x=l;switch(p=e,g=n,x.tag){case 1:if(v=x.payload,typeof v=="function"){f=v.call(g,f,p);break e}f=v;break e;case 3:v.flags=v.flags&-65537|128;case 0:if(v=x.payload,p=typeof v=="function"?v.call(g,f,p):v,p==null)break e;f=Nn({},f,p);break e;case 2:ia=!0}}l.callback!==null&&l.lane!==0&&(t.flags|=64,p=s.effects,p===null?s.effects=[l]:p.push(l))}else g={eventTime:g,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},h===null?(d=h=g,c=f):h=h.next=g,a|=p;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;p=l,l=p.next,p.next=null,s.lastBaseUpdate=p,s.shared.pending=null}}while(!0);if(h===null&&(c=f),s.baseState=c,s.firstBaseUpdate=d,s.lastBaseUpdate=h,e=s.shared.interleaved,e!==null){s=e;do a|=s.lane,s=s.next;while(s!==e)}else i===null&&(s.shared.lanes=0);Gl|=a,t.lanes=a,t.memoizedState=f}}function c_(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;e<t.length;e++){var r=t[e],s=r.callback;if(s!==null){if(r.callback=null,r=n,typeof s!="function")throw Error(_e(191,s));s.call(r)}}}var Of={},Zo=el(Of),Xh=el(Of),Jh=el(Of);function Al(t){if(t===Of)throw Error(_e(174));return t}function xj(t,e){switch(on(Jh,e),on(Xh,t),on(Zo,Of),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:Ww(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=Ww(e,t)}pn(Zo),on(Zo,e)}function Ru(){pn(Zo),pn(Xh),pn(Jh)}function V2(t){Al(Jh.current);var e=Al(Zo.current),n=Ww(e,t.type);e!==n&&(on(Xh,t),on(Zo,n))}function yj(t){Xh.current===t&&(pn(Zo),pn(Xh))}var wn=el(0);function xg(t){for(var e=t;e!==null;){if(e.tag===13){var n=e.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var vy=[];function wj(){for(var t=0;t<vy.length;t++)vy[t]._workInProgressVersionPrimary=null;vy.length=0}var Op=Vi.ReactCurrentDispatcher,xy=Vi.ReactCurrentBatchConfig,ql=0,Cn=null,Qn=null,lr=null,yg=!1,Eh=!1,ef=0,A6=0;function Pr(){throw Error(_e(321))}function bj(t,e){if(e===null)return!1;for(var n=0;n<e.length&&n<t.length;n++)if(!wo(t[n],e[n]))return!1;return!0}function jj(t,e,n,r,s,i){if(ql=i,Cn=e,e.memoizedState=null,e.updateQueue=null,e.lanes=0,Op.current=t===null||t.memoizedState===null?M6:O6,t=n(r,s),Eh){i=0;do{if(Eh=!1,ef=0,25<=i)throw Error(_e(301));i+=1,lr=Qn=null,e.updateQueue=null,Op.current=F6,t=n(r,s)}while(Eh)}
vendor: 6,000 bytes, line 38
38if(Op.current=wg,e=Qn!==null&&Qn.next!==null,ql=0,lr=Qn=Cn=null,yg=!1,e)throw Error(_e(300));return t}function Cj(){var t=ef!==0;return ef=0,t}function $o(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return lr===null?Cn.memoizedState=lr=t:lr=lr.next=t,lr}function Zs(){if(Qn===null){var t=Cn.alternate;t=t!==null?t.memoizedState:null}else t=Qn.next;var e=lr===null?Cn.memoizedState:lr.next;if(e!==null)lr=e,Qn=t;else{if(t===null)throw Error(_e(310));Qn=t,t={memoizedState:Qn.memoizedState,baseState:Qn.baseState,baseQueue:Qn.baseQueue,queue:Qn.queue,next:null},lr===null?Cn.memoizedState=lr=t:lr=lr.next=t}return lr}function tf(t,e){return typeof e=="function"?e(t):e}function yy(t){var e=Zs(),n=e.queue;if(n===null)throw Error(_e(311));n.lastRenderedReducer=t;var r=Qn,s=r.baseQueue,i=n.pending;if(i!==null){if(s!==null){var a=s.next;s.next=i.next,i.next=a}r.baseQueue=s=i,n.pending=null}if(s!==null){i=s.next,r=r.baseState;var l=a=null,c=null,d=i;do{var h=d.lane;if((ql&h)===h)c!==null&&(c=c.next={lane:0,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null}),r=d.hasEagerState?d.eagerState:t(r,d.action);else{var f={lane:h,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};c===null?(l=c=f,a=r):c=c.next=f,Cn.lanes|=h,Gl|=h}d=d.next}while(d!==null&&d!==i);c===null?a=r:c.next=l,wo(r,e.memoizedState)||(as=!0),e.memoizedState=r,e.baseState=a,e.baseQueue=c,n.lastRenderedState=r}if(t=n.interleaved,t!==null){s=t;do i=s.lane,Cn.lanes|=i,Gl|=i,s=s.next;while(s!==t)}else s===null&&(n.lanes=0);return[e.memoizedState,n.dispatch]}function wy(t){var e=Zs(),n=e.queue;if(n===null)throw Error(_e(311));n.lastRenderedReducer=t;var r=n.dispatch,s=n.pending,i=e.memoizedState;if(s!==null){n.pending=null;var a=s=s.next;do i=t(i,a.action),a=a.next;while(a!==s);wo(i,e.memoizedState)||(as=!0),e.memoizedState=i,e.baseQueue===null&&(e.baseState=i),n.lastRenderedState=i}return[i,r]}function U2(){}function B2(t,e){var n=Cn,r=Zs(),s=e(),i=!wo(r.memoizedState,s);if(i&&(r.memoizedState=s,as=!0),r=r.queue,Nj(q2.bind(null,n,r,t),[t]),r.getSnapshot!==e||i||lr!==null&&lr.memoizedState.tag&1){if(n.flags|=2048,nf(9,H2.bind(null,n,r,s,e),void 0,null),dr===null)throw Error(_e(349));ql&30||W2(n,e,s)}return s}function W2(t,e,n){t.flags|=16384,t={getSnapshot:e,value:n},e=Cn.updateQueue,e===null?(e={lastEffect:null,stores:null},Cn.updateQueue=e,e.stores=[t]):(n=e.stores,n===null?e.stores=[t]:n.push(t))}function H2(t,e,n,r){e.value=n,e.getSnapshot=r,G2(e)&&Z2(t)}function q2(t,e,n){return n(function(){G2(e)&&Z2(t)})}function G2(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!wo(t,n)}catch{return!0}}function Z2(t){var e=Ii(t,1);e!==null&&xo(e,t,1,-1)}function u_(t){var e=$o();return typeof t=="function"&&(t=t()),e.memoizedState=e.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:tf,lastRenderedState:t},e.queue=t,t=t.dispatch=L6.bind(null,Cn,t),[e.memoizedState,t]}function nf(t,e,n,r){return t={tag:t,create:e,destroy:n,deps:r,next:null},e=Cn.updateQueue,e===null?(e={lastEffect:null,stores:null},Cn.updateQueue=e,e.lastEffect=t.next=t):(n=e.lastEffect,n===null?e.lastEffect=t.next=t:(r=n.next,n.next=t,t.next=r,e.lastEffect=t)),t}function K2(){return Zs().memoizedState}function Fp(t,e,n,r){var s=$o();Cn.flags|=t,s.memoizedState=nf(1|e,n,void 0,r===void 0?null:r)}function Sv(t,e,n,r){var s=Zs();r=r===void 0?null:r;var i=void 0;if(Qn!==null){var a=Qn.memoizedState;if(i=a.destroy,r!==null&&bj(r,a.deps)){s.memoizedState=nf(e,n,i,r);return}}Cn.flags|=t,s.memoizedState=nf(1|e,n,i,r)}function d_(t,e){return Fp(8390656,8,t,e)}function Nj(t,e){return Sv(2048,8,t,e)}function Y2(t,e){return Sv(4,2,t,e)}function Q2(t,e){return Sv(4,4,t,e)}function X2(t,e){if(typeof e=="function")return t=t(),e(t),function(){e(null)};if(e!=null)return t=t(),e.current=t,function(){e.current=null}}function J2(t,e,n){return n=n!=null?n.concat([t]):null,Sv(4,4,X2.bind(null,e,t),n)}function _j(){}function eT(t,e){var n=Zs();e=e===void 0?null:e;var r=n.memoizedState;return r!==null&&e!==null&&bj(e,r[1])?r[0]:(n.memoizedState=[t,e],t)}function tT(t,e){var n=Zs();e=e===void 0?null:e;var r=n.memoizedState;return r!==null&&e!==null&&bj(e,r[1])?r[0]:(t=t(),n.memoizedState=[t,e],t)}function nT(t,e,n){return ql&21?(wo(n,e)||(n=a2(),Cn.lanes|=n,Gl|=n,t.baseState=!0),e):(t.baseState&&(t.baseState=!1,as=!0),t.memoizedState=n)}function R6(t,e){var n=Zt;Zt=n!==0&&4>n?n:4,t(!0);var r=xy.transition;xy.transition={};try{t(!1),e()}finally{Zt=n,xy.transition=r}}function rT(){return Zs().memoizedState}function D6(t,e,n){var r=Sa(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},sT(t))oT(e,n);else if(n=z2(t,e,n,r),n!==null){var s=Kr();xo(n,t,r,s),iT(n,e,r)}}function L6(t,e,n){var r=Sa(t),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(sT(t))oT(e,s);else{var i=t.alternate;if(t.lanes===0&&(i===null||i.lanes===0)&&(i=e.lastRenderedReducer,i!==null))try{var a=e.lastRenderedState,l=i(a,n);if(s.hasEagerState=!0,s.eagerState=l,wo(l,a)){var c=e.interleaved;c===null?(s.next=s,gj(e)):(s.next=c.next,c.next=s),e.interleaved=s;return}}catch{}finally{}n=z2(t,e,s,r),n!==null&&(s=Kr(),xo(n,t,r,s),iT(n,e,r))}}function sT(t){var e=t.alternate;return t===Cn||e!==null&&e===Cn}function oT(t,e){Eh=yg=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function iT(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,nj(t,n)}}var wg={readContext:Gs,useCallback:Pr,useContext:Pr,useEffect:Pr,useImperativeHandle:Pr,useInsertionEffect:Pr,useLayoutEffect:Pr,useMemo:Pr,useReducer:Pr,useRef:Pr,useState:Pr,useDebugValue:Pr,useDeferredValue:Pr,useTransition:Pr,useMutableSource:Pr,useSyncExternalStore:Pr,useId:Pr,unstable_isNewReconciler:!1},M6={readContext:Gs,useCallback:function(t,e){return $o().memoizedState=[t,e===void 0?null:e],t},useContext:Gs,useEffect:d_,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,Fp(4
vendor: 7,919 bytes, lines 38-40
38194308,4,X2.bind(null,e,t),n)},useLayoutEffect:function(t,e){return Fp(4194308,4,t,e)},useInsertionEffect:function(t,e){return Fp(4,2,t,e)},useMemo:function(t,e){var n=$o();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=$o();return e=n!==void 0?n(e):e,r.memoizedState=r.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},r.queue=t,t=t.dispatch=D6.bind(null,Cn,t),[r.memoizedState,t]},useRef:function(t){var e=$o();return t={current:t},e.memoizedState=t},useState:u_,useDebugValue:_j,useDeferredValue:function(t){return $o().memoizedState=t},useTransition:function(){var t=u_(!1),e=t[0];return t=R6.bind(null,t[1]),$o().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=Cn,s=$o();if(vn){if(n===void 0)throw Error(_e(407));n=n()}else{if(n=e(),dr===null)throw Error(_e(349));ql&30||W2(r,e,n)}s.memoizedState=n;var i={value:n,getSnapshot:e};return s.queue=i,d_(q2.bind(null,r,i,t),[t]),r.flags|=2048,nf(9,H2.bind(null,r,i,n,e),void 0,null),n},useId:function(){var t=$o(),e=dr.identifierPrefix;if(vn){var n=yi,r=xi;n=(r&~(1<<32-vo(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=ef++,0<n&&(e+="H"+n.toString(32)),e+=":"}else n=A6++,e=":"+e+"r"+n.toString(32)+":";return t.memoizedState=e},unstable_isNewReconciler:!1},O6={readContext:Gs,useCallback:eT,useContext:Gs,useEffect:Nj,useImperativeHandle:J2,useInsertionEffect:Y2,useLayoutEffect:Q2,useMemo:tT,useReducer:yy,useRef:K2,useState:function(){return yy(tf)},useDebugValue:_j,useDeferredValue:function(t){var e=Zs();return nT(e,Qn.memoizedState,t)},useTransition:function(){var t=yy(tf)[0],e=Zs().memoizedState;return[t,e]},useMutableSource:U2,useSyncExternalStore:B2,useId:rT,unstable_isNewReconciler:!1},F6={readContext:Gs,useCallback:eT,useContext:Gs,useEffect:Nj,useImperativeHandle:J2,useInsertionEffect:Y2,useLayoutEffect:Q2,useMemo:tT,useReducer:wy,useRef:K2,useState:function(){return wy(tf)},useDebugValue:_j,useDeferredValue:function(t){var e=Zs();return Qn===null?e.memoizedState=t:nT(e,Qn.memoizedState,t)},useTransition:function(){var t=wy(tf)[0],e=Zs().memoizedState;return[t,e]},useMutableSource:U2,useSyncExternalStore:B2,useId:rT,unstable_isNewReconciler:!1};function ao(t,e){if(t&&t.defaultProps){e=Nn({},e),t=t.defaultProps;for(var n in t)e[n]===void 0&&(e[n]=t[n]);return e}return e}function d0(t,e,n,r){e=t.memoizedState,n=n(r,e),n=n==null?e:Nn({},e,n),t.memoizedState=n,t.lanes===0&&(t.updateQueue.baseState=n)}var kv={isMounted:function(t){return(t=t._reactInternals)?hc(t)===t:!1},enqueueSetState:function(t,e,n){t=t._reactInternals;var r=Kr(),s=Sa(t),i=_i(r,s);i.payload=e,n!=null&&(i.callback=n),e=_a(t,i,s),e!==null&&(xo(e,t,s,r),Mp(e,t,s))},enqueueReplaceState:function(t,e,n){t=t._reactInternals;var r=Kr(),s=Sa(t),i=_i(r,s);i.tag=1,i.payload=e,n!=null&&(i.callback=n),e=_a(t,i,s),e!==null&&(xo(e,t,s,r),Mp(e,t,s))},enqueueForceUpdate:function(t,e){t=t._reactInternals;var n=Kr(),r=Sa(t),s=_i(n,r);s.tag=2,e!=null&&(s.callback=e),e=_a(t,s,r),e!==null&&(xo(e,t,r,n),Mp(e,t,r))}};function h_(t,e,n,r,s,i,a){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(r,i,a):e.prototype&&e.prototype.isPureReactComponent?!Zh(n,r)||!Zh(s,i):!0}function aT(t,e,n){var r=!1,s=Oa,i=e.contextType;return typeof i=="object"&&i!==null?i=Gs(i):(s=cs(e)?Wl:$r.current,r=e.contextTypes,i=(r=r!=null)?Iu(t,s):Oa),e=new e(n,i),t.memoizedState=e.state!==null&&e.state!==void 0?e.state:null,e.updater=kv,t.stateNode=e,e._reactInternals=t,r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=s,t.__reactInternalMemoizedMaskedChildContext=i),e}function f_(t,e,n,r){t=e.state,typeof e.componentWillReceiveProps=="function"&&e.componentWillReceiveProps(n,r),typeof e.UNSAFE_componentWillReceiveProps=="function"&&e.UNSAFE_componentWillReceiveProps(n,r),e.state!==t&&kv.enqueueReplaceState(e,e.state,null)}function h0(t,e,n,r){var s=t.stateNode;s.props=n,s.state=t.memoizedState,s.refs={},vj(t);var i=e.contextType;typeof i=="object"&&i!==null?s.context=Gs(i):(i=cs(e)?Wl:$r.current,s.context=Iu(t,i)),s.state=t.memoizedState,i=e.getDerivedStateFromProps,typeof i=="function"&&(d0(t,e,i,n),s.state=t.memoizedState),typeof e.getDerivedStateFromProps=="function"||typeof s.getSnapshotBeforeUpdate=="function"||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(e=s.state,typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount(),e!==s.state&&kv.enqueueReplaceState(s,s.state,null),vg(t,n,s,r),s.state=t.memoizedState),typeof s.componentDidMount=="function"&&(t.flags|=4194308)}function Du(t,e){try{var n="",r=e;do n+=h5(r),r=r.return;while(r);var s=n}catch(i){s=` 39Error generating stack: `+i.message+` 40`+i.stack}return{value:t,source:e,stack:s,digest:null}}function by(t,e,n){return{value:t,source:null,stack:n??null,digest:e??null}}function f0(t,e){try{console.error(e.value)}catch(n){setTimeout(function(){throw n})}}var z6=typeof WeakMap=="function"?WeakMap:Map;function lT(t,e,n){n=_i(-1,n),n.tag=3,n.payload={element:null};var r=e.value;return n.callback=function(){jg||(jg=!0,C0=r),f0(t,e)},n}function cT(t,e,n){n=_i(-1,n),n.tag=3;var r=t.type.getDerivedStateFromError;if(typeof r=="function"){var s=e.value;n.payload=function(){return r(s)},n.callback=function(){f0(t,e)}}var i=t.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){f0(t,e),typeof r!="function"&&(Ea===null?Ea=new Set([this]):Ea.add(this));var a=e.stack;this.componentDidCatch(e.value,{componentStack:a!==null?a:""})}),n}function m_(t,e,n){var r=t.pingCache;if(r===null){r=t.pingCache=new z6;var s=new Set;r.set(e,s)}else s=r.get(e),s===void 0&&(s=new Set,r.set(e,s));s.has(n)||(s.add(n),t=J6.bind(null,t,e,n),e.then(t,t))}function p_(t){do{var e;if((e=t.tag===13)&&(e=t.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return t;t=t.return}while(t!==null);return null}function g_(t,e,n,r,s){return t.mode&1?(t.flags|=65536,t.lanes=s,t):(t===e?t.flags|=65536:(t.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(e=_i(-1,1),e.tag=2,_a(n,e,1))),n.lanes|=1),t)}var $6=Vi.ReactCurrentOwner,as=!1;function Hr(t,e,n,r){e.child=t===null?F2(e,null,n,r):Au(e,t.child,n,r)}function v_(t,e,n,r,s){n=n.render;var i=e.ref;return mu(e,s),r=jj(t,e,n,r,i,s),n=Cj(),t!==null&&!as?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~s,Ti(t,e,s)):(vn&&n&&uj(e),e.flags|=1,Hr(t,e,r,s),e.child)}function x_(t,e,n,r,s){if(t===null){var i=n.type;return typeof i=="function"&&!Rj(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(e.tag=15,e.type=i,uT(t,e,i,r,s)):(t=Up(n.type,null,r,e,e.mode,s),t.ref=e.ref,t.return=e,e.child=t)}if(i=t.child,!(t.lanes&s)){var a=i.memoizedProps;if(n=n.compare,n=n!==null?n:Zh,n(a,r)&&t.ref===e.ref)return Ti(t,e,s)}return e.flags|=1,t=ka(i,r),t.ref=e.ref,t.return=e,e.child=t}function uT(t,e,n,r,s){if(t!==null){var i=t.memoizedProps;if(Zh(i,r)&&t.ref===e.ref)if(as=!1,e.pendingProps=r=i,(t.lanes&s)!==0)t.flags&131072&&(as=!0);else return e.lanes=t.lanes,Ti(t,e,s)}return m0(t,e,n,r,s)}function dT(t,e,n){var r=e.pendingProps,s=r.children,i=t!==null?t.memoizedState:null;if(r.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},on(lu,xs),xs|=n;else{if(!(n&1073741824))return t=i!==null?i.baseLanes|n:n,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,on(lu,xs),xs|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,on(lu,xs),xs|=r}else i!==null?(r=i.baseLanes|n,e.memoizedState=null):r=n,on(lu,xs),xs|=r;return Hr(t,e,s,n),e.child}function hT(t,e){var n=e.ref;(t===null&&n!==null||t!==null&&t.ref!==n)&&(e.flags|=512,e.flags|=2097152)}
vendor: 8,024 bytes, line 40
40function m0(t,e,n,r,s){var i=cs(n)?Wl:$r.current;return i=Iu(e,i),mu(e,s),n=jj(t,e,n,r,i,s),r=Cj(),t!==null&&!as?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~s,Ti(t,e,s)):(vn&&r&&uj(e),e.flags|=1,Hr(t,e,n,s),e.child)}function y_(t,e,n,r,s){if(cs(n)){var i=!0;hg(e)}else i=!1;if(mu(e,s),e.stateNode===null)zp(t,e),aT(e,n,r),h0(e,n,r,s),r=!0;else if(t===null){var a=e.stateNode,l=e.memoizedProps;a.props=l;var c=a.context,d=n.contextType;typeof d=="object"&&d!==null?d=Gs(d):(d=cs(n)?Wl:$r.current,d=Iu(e,d));var h=n.getDerivedStateFromProps,f=typeof h=="function"||typeof a.getSnapshotBeforeUpdate=="function";f||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==r||c!==d)&&f_(e,a,r,d),ia=!1;var p=e.memoizedState;a.state=p,vg(e,r,a,s),c=e.memoizedState,l!==r||p!==c||ls.current||ia?(typeof h=="function"&&(d0(e,n,h,r),c=e.memoizedState),(l=ia||h_(e,n,l,r,p,c,d))?(f||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(e.flags|=4194308)):(typeof a.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=r,e.memoizedState=c),a.props=r,a.state=c,a.context=d,r=l):(typeof a.componentDidMount=="function"&&(e.flags|=4194308),r=!1)}else{a=e.stateNode,$2(t,e),l=e.memoizedProps,d=e.type===e.elementType?l:ao(e.type,l),a.props=d,f=e.pendingProps,p=a.context,c=n.contextType,typeof c=="object"&&c!==null?c=Gs(c):(c=cs(n)?Wl:$r.current,c=Iu(e,c));var g=n.getDerivedStateFromProps;(h=typeof g=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==f||p!==c)&&f_(e,a,r,c),ia=!1,p=e.memoizedState,a.state=p,vg(e,r,a,s);var v=e.memoizedState;l!==f||p!==v||ls.current||ia?(typeof g=="function"&&(d0(e,n,g,r),v=e.memoizedState),(d=ia||h_(e,n,d,r,p,v,c)||!1)?(h||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(r,v,c),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(r,v,c)),typeof a.componentDidUpdate=="function"&&(e.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof a.componentDidUpdate!="function"||l===t.memoizedProps&&p===t.memoizedState||(e.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===t.memoizedProps&&p===t.memoizedState||(e.flags|=1024),e.memoizedProps=r,e.memoizedState=v),a.props=r,a.state=v,a.context=c,r=d):(typeof a.componentDidUpdate!="function"||l===t.memoizedProps&&p===t.memoizedState||(e.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===t.memoizedProps&&p===t.memoizedState||(e.flags|=1024),r=!1)}return p0(t,e,n,r,i,s)}function p0(t,e,n,r,s,i){hT(t,e);var a=(e.flags&128)!==0;if(!r&&!a)return s&&s_(e,n,!1),Ti(t,e,i);r=e.stateNode,$6.current=e;var l=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return e.flags|=1,t!==null&&a?(e.child=Au(e,t.child,null,i),e.child=Au(e,null,l,i)):Hr(t,e,l,i),e.memoizedState=r.state,s&&s_(e,n,!0),e.child}function fT(t){var e=t.stateNode;e.pendingContext?r_(t,e.pendingContext,e.pendingContext!==e.context):e.context&&r_(t,e.context,!1),xj(t,e.containerInfo)}function w_(t,e,n,r,s){return Tu(),hj(s),e.flags|=256,Hr(t,e,n,r),e.child}var g0={dehydrated:null,treeContext:null,retryLane:0};function v0(t){return{baseLanes:t,cachePool:null,transitions:null}}function mT(t,e,n){var r=e.pendingProps,s=wn.current,i=!1,a=(e.flags&128)!==0,l;if((l=a)||(l=t!==null&&t.memoizedState===null?!1:(s&2)!==0),l?(i=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(s|=1),on(wn,s&1),t===null)return c0(e),t=e.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?(e.mode&1?t.data==="$!"?e.lanes=8:e.lanes=1073741824:e.lanes=1,null):(a=r.children,t=r.fallback,i?(r=e.mode,i=e.child,a={mode:"hidden",children:a},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=a):i=Tv(a,r,0,null),t=Fl(t,r,n,null),i.return=e,t.return=e,i.sibling=t,e.child=i,e.child.memoizedState=v0(n),e.memoizedState=g0,t):Ej(e,a));if(s=t.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return V6(t,e,a,r,l,s,n);if(i){i=r.fallback,a=e.mode,s=t.child,l=s.sibling;var c={mode:"hidden",children:r.children};return!(a&1)&&e.child!==s?(r=e.child,r.childLanes=0,r.pendingProps=c,e.deletions=null):(r=ka(s,c),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?i=ka(l,i):(i=Fl(i,a,n,null),i.flags|=2),i.return=e,r.return=e,r.sibling=i,e.child=r,r=i,i=e.child,a=t.child.memoizedState,a=a===null?v0(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=t.childLanes&~n,e.memoizedState=g0,r}return i=t.child,t=i.sibling,r=ka(i,{mode:"visible",children:r.children}),!(e.mode&1)&&(r.lanes=n),r.return=e,r.sibling=null,t!==null&&(n=e.deletions,n===null?(e.deletions=[t],e.flags|=16):n.push(t)),e.child=r,e.memoizedState=null,r}function Ej(t,e){return e=Tv({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function Zm(t,e,n,r){return r!==null&&hj(r),Au(e,t.child,null,n),t=Ej(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function V6(t,e,n,r,s,i,a){if(n)return e.flags&256?(e.flags&=-257,r=by(Error(_e(422))),Zm(t,e,a,r)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(i=r.fallback,s=e.mode,r=Tv({mode:"visible",children:r.children},s,0,null),i=Fl(i,s,a,null),i.flags|=2,r.return=e,i.return=e,r.sibling=i,e.child=r,e.mode&1&&Au(e,t.child,null,a),e.child.memoizedState=v0(a),e.memoizedState=g0,i);if(!(e.mode&1))return Zm(t,e,a,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var l=r.dgst;return r=l,i=Error(_e(419)),r=by(i,r,void 0),Zm(t,e,a,r)}if(l=(a&t.childLanes)!==0,as||l){if(r=dr,r!==null){switch(a&-a){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|a)?0:s,s!==0&&s!==i.retryLane&&(i.retryLane=s,Ii(t,s),xo(r,t,s,-1))}return Aj(),r=by(Error(_e(421))),Zm(t,e,a,r)}return s.data==="$?"?(e.flags|=128,e.child=t.child,e=eF.bind(null,t),s._reactRetry=e,null):(t=i.treeContext,js=Na(s.nextSibling),_s=e,vn=!0,co=null,t!==null&&(Os[Fs++]=xi,Os[Fs++]=yi,Os[Fs++]=Hl,xi=t.id,yi=t.overflow,Hl=e),e=Ej(e,r.children),e.flags|=4096,e)}function b_(t,e,n){t.lanes|=e;var r=t.alternate;r!==null&&(r.lanes|=e),u0(t.return,e,n)}function jy(t,e,n,r,s){var i=t.memoizedState;i===null?t.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:s}:(i.isBackwards=e,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=s)}function pT(t,e,n){var r=e.pendingProps,s=r.revealOrder,i=r.tail;if(Hr(t,e,r.children,n),r=wn.current,r&2)r=r&1|2,e.flags|=128;else{if(t!==null&&t.flags&128)e:for(t=e.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&b_(t,n,e);else if(t.tag===19)b_(t,n,e);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}r&=1}if(on(wn,r),!(e.mode&1))e.memoizedState=null;else switch(s){case"forwards":for(n=e.child,s=null;n!==null;)t=n.alternate,t!==null&&xg(t)===null&&(s=n),n=n.sibling;n=s,n===null?(s=e.child,e.child=null):(s=n.sibling,n.sibling=null),jy(e,!1,s,n,i);break;case"backwards":for(n=null,s=e.child,e.child=null;s!==null;){if(t=s.alternate,t!==null&&xg(t)===null){e.child=s;break}t=s.sibling,s.sibling=n,n=s,s=t}jy(e,!0,n,null,i);break;case"together":jy(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function zp(t,e){!(e.mode&1)&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}
vendor: 5,610 bytes, line 40
40function Ti(t,e,n){if(t!==null&&(e.dependencies=t.dependencies),Gl|=e.lanes,!(n&e.childLanes))return null;if(t!==null&&e.child!==t.child)throw Error(_e(153));if(e.child!==null){for(t=e.child,n=ka(t,t.pendingProps),e.child=n,n.return=e;t.sibling!==null;)t=t.sibling,n=n.sibling=ka(t,t.pendingProps),n.return=e;n.sibling=null}return e.child}function U6(t,e,n){switch(e.tag){case 3:fT(e),Tu();break;case 5:V2(e);break;case 1:cs(e.type)&&hg(e);break;case 4:xj(e,e.stateNode.containerInfo);break;case 10:var r=e.type._context,s=e.memoizedProps.value;on(pg,r._currentValue),r._currentValue=s;break;case 13:if(r=e.memoizedState,r!==null)return r.dehydrated!==null?(on(wn,wn.current&1),e.flags|=128,null):n&e.child.childLanes?mT(t,e,n):(on(wn,wn.current&1),t=Ti(t,e,n),t!==null?t.sibling:null);on(wn,wn.current&1);break;case 19:if(r=(n&e.childLanes)!==0,t.flags&128){if(r)return pT(t,e,n);e.flags|=128}if(s=e.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),on(wn,wn.current),r)break;return null;case 22:case 23:return e.lanes=0,dT(t,e,n)}return Ti(t,e,n)}var gT,x0,vT,xT;gT=function(t,e){for(var n=e.child;n!==null;){if(n.tag===5||n.tag===6)t.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};x0=function(){};vT=function(t,e,n,r){var s=t.memoizedProps;if(s!==r){t=e.stateNode,Al(Zo.current);var i=null;switch(n){case"input":s=$w(t,s),r=$w(t,r),i=[];break;case"select":s=Nn({},s,{value:void 0}),r=Nn({},r,{value:void 0}),i=[];break;case"textarea":s=Bw(t,s),r=Bw(t,r),i=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(t.onclick=ug)}Hw(n,r);var a;n=null;for(d in s)if(!r.hasOwnProperty(d)&&s.hasOwnProperty(d)&&s[d]!=null)if(d==="style"){var l=s[d];for(a in l)l.hasOwnProperty(a)&&(n||(n={}),n[a]="")}else d!=="dangerouslySetInnerHTML"&&d!=="children"&&d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&d!=="autoFocus"&&(Vh.hasOwnProperty(d)?i||(i=[]):(i=i||[]).push(d,null));for(d in r){var c=r[d];if(l=s!=null?s[d]:void 0,r.hasOwnProperty(d)&&c!==l&&(c!=null||l!=null))if(d==="style")if(l){for(a in l)!l.hasOwnProperty(a)||c&&c.hasOwnProperty(a)||(n||(n={}),n[a]="");for(a in c)c.hasOwnProperty(a)&&l[a]!==c[a]&&(n||(n={}),n[a]=c[a])}else n||(i||(i=[]),i.push(d,n)),n=c;else d==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(i=i||[]).push(d,c)):d==="children"?typeof c!="string"&&typeof c!="number"||(i=i||[]).push(d,""+c):d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&(Vh.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&fn("scroll",t),i||l===c||(i=[])):(i=i||[]).push(d,c))}n&&(i=i||[]).push("style",n);var d=i;(e.updateQueue=d)&&(e.flags|=4)}};xT=function(t,e,n,r){n!==r&&(e.flags|=4)};function $d(t,e){if(!vn)switch(t.tailMode){case"hidden":e=t.tail;for(var n=null;e!==null;)e.alternate!==null&&(n=e),e=e.sibling;n===null?t.tail=null:n.sibling=null;break;case"collapsed":n=t.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?e||t.tail===null?t.tail=null:t.tail.sibling=null:r.sibling=null}}function Ir(t){var e=t.alternate!==null&&t.alternate.child===t.child,n=0,r=0;if(e)for(var s=t.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags&14680064,r|=s.flags&14680064,s.return=t,s=s.sibling;else for(s=t.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags,r|=s.flags,s.return=t,s=s.sibling;return t.subtreeFlags|=r,t.childLanes=n,e}function B6(t,e,n){var r=e.pendingProps;switch(dj(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ir(e),null;case 1:return cs(e.type)&&dg(),Ir(e),null;case 3:return r=e.stateNode,Ru(),pn(ls),pn($r),wj(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(t===null||t.child===null)&&(qm(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,co!==null&&(E0(co),co=null))),x0(t,e),Ir(e),null;case 5:yj(e);var s=Al(Jh.current);if(n=e.type,t!==null&&e.stateNode!=null)vT(t,e,n,r,s),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!r){if(e.stateNode===null)throw Error(_e(166));return Ir(e),null}if(t=Al(Zo.current),qm(e)){r=e.stateNode,n=e.type;var i=e.memoizedProps;switch(r[Vo]=e,r[Qh]=i,t=(e.mode&1)!==0,n){case"dialog":fn("cancel",r),fn("close",r);break;case"iframe":case"object":case"embed":fn("load",r);break;case"video":case"audio":for(s=0;s<ah.length;s++)fn(ah[s],r);break;case"source":fn("error",r);break;case"img":case"image":case"link":fn("error",r),fn("load",r);break;case"details":fn("toggle",r);break;case"input":IN(r,i),fn("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},fn("invalid",r);break;case"textarea":AN(r,i),fn("invalid",r)}Hw(n,i),s=null;for(var a in i)if(i.hasOwnProperty(a)){var l=i[a];a==="children"?typeof l=="string"?r.textContent!==l&&(i.suppressHydrationWarning!==!0&&Hm(r.textContent,l,t),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(i.suppressHydrationWarning!==!0&&Hm(r.textContent,l,t),s=["children",""+l]):Vh.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&fn("scroll",r)}switch(n){case"input":Om(r),TN(r,i,!0);break;case"textarea":Om(r),RN(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=ug)}r=s,e.updateQueue=r,r!==null&&(e.flags|=4)}else{a=s.nodeType===9?s:s.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=qI(n)),t==="http://www.w3.org/1999/xhtml"?n==="script"?(t=a.createElement("div"),t.innerHTML="<script><\/script>
40",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=a.createElement(n,{is:r.is}):(t=a.createElement(n),n==="select"&&(a=t,r.multiple?a.multiple=!0:r.size&&(a.size=r.size))):t=a.createElementNS(t,n),t[Vo]=e,t[Qh]=r,gT(t,e,!1,!1),e.stateNode=t;e:{switch(a=qw(n,r),n){case"dialog":fn("cancel",t),fn("close",t),s=r;break;case"iframe":case"object":case"embed":fn("load",t),s=r;break;case"video":case"audio":for(s=0;s<ah.length;s++)fn(ah[s],t);s=r;break;case"source":fn("error",t),s=r;break;case"img":case"image":case"link":fn("error",t),fn("load",t),s=r;break;case"details":fn("toggle",t),s=r;break;case"input":IN(t,r),s=$w(t,r),fn("invalid",t);break;case"option":s=r;break;case"select":t._wrapperState={wasMultiple:!!r.multiple},s=Nn({},r,{value:void 0}),fn("invalid",t);break;case"textarea":AN(t,r),s=Bw(t,r),fn("invalid",t);break;default:s=r}Hw(n,s),l=s;for(i in l)if(l.hasOwnProperty(i)){var c=l[i];i==="style"?KI(t,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&GI(t,c)):i==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Uh(t,c):typeof c=="number"&&Uh(t,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Vh.hasOwnProperty(i)?c!=null&&i==="onScroll"&&fn("scroll",t):c!=null&&Yb(t,i,c,a))}switch(n){case"input":Om(t),TN(t,r,!1);break;case"textarea":Om(t),RN(t);break;case"option":r.value!=null&&t.setAttribute("value",""+Ma(r.value));break;case"select":t.multiple=!!r.multiple,i=r.value,i!=null?uu(t,!!r.multiple,i,!1):r.defaultValue!=null&&uu(t,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(t.onclick=ug)}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&&(e.flags|=4)}e.ref!==null&&(e.flags|=512,e.flags|=2097152)}return Ir(e),null;case 6:if(t&&e.stateNode!=null)xT(t,e,t.memoizedProps,r);else{if(typeof r!="string"&&e.stateNode===null)throw Error(_e(166));if(n=Al(Jh.current),Al(Zo.current),qm(e)){if(r=e.stateNode,n=e.memoizedProps,r[Vo]=e,(i=r.nodeValue!==n)&&(t=_s,t!==null))switch(t.tag){case 3:Hm(r.nodeValue,n,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&Hm(r.nodeValue,n,(t.mode&1)!==0)}i&&(e.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Vo]=e,e.stateNode=r}return Ir(e),null;case 13:if(pn(wn),r=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(vn&&js!==null&&e.mode&1&&!(e.flags&128))M2(),Tu(),e.flags|=98560,i=!1;else if(i=qm(e),r!==null&&r.dehydrated!==null){if(t===null){if(!i)throw Error(_e(318));if(i=e.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(_e(317));i[Vo]=e}else Tu(),!(e.flags&128)&&(e.memoizedState=null),e.flags|=4;Ir(e),i=!1}else co!==null&&(E0(co),co=null),i=!0;if(!i)return e.flags&65536?e:null}return e.flags&128?(e.lanes=n,e):(r=r!==null,r!==(t!==null&&t.memoizedState!==null)&&r&&(e.child.flags|=8192,e.mode&1&&(t===null||wn.current&1?Jn===0&&(Jn=3):Aj())),e.updateQueue!==null&&(e.flags|=4),Ir(e),null);case 4:return Ru(),x0(t,e),t===null&&Kh(e.stateNode.containerInfo),Ir(e),null;
vendor: 27,982 bytes, line 40
40case 10:return pj(e.type._context),Ir(e),null;case 17:return cs(e.type)&&dg(),Ir(e),null;case 19:if(pn(wn),i=e.memoizedState,i===null)return Ir(e),null;if(r=(e.flags&128)!==0,a=i.rendering,a===null)if(r)$d(i,!1);else{if(Jn!==0||t!==null&&t.flags&128)for(t=e.child;t!==null;){if(a=xg(t),a!==null){for(e.flags|=128,$d(i,!1),r=a.updateQueue,r!==null&&(e.updateQueue=r,e.flags|=4),e.subtreeFlags=0,r=n,n=e.child;n!==null;)i=n,t=r,i.flags&=14680066,a=i.alternate,a===null?(i.childLanes=0,i.lanes=t,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,t=a.dependencies,i.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),n=n.sibling;return on(wn,wn.current&1|2),e.child}t=t.sibling}i.tail!==null&&An()>Lu&&(e.flags|=128,r=!0,$d(i,!1),e.lanes=4194304)}else{if(!r)if(t=xg(a),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),$d(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!vn)return Ir(e),null}else 2*An()-i.renderingStartTime>Lu&&n!==1073741824&&(e.flags|=128,r=!0,$d(i,!1),e.lanes=4194304);i.isBackwards?(a.sibling=e.child,e.child=a):(n=i.last,n!==null?n.sibling=a:e.child=a,i.last=a)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=An(),e.sibling=null,n=wn.current,on(wn,r?n&1|2:n&1),e):(Ir(e),null);case 22:case 23:return Tj(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?xs&1073741824&&(Ir(e),e.subtreeFlags&6&&(e.flags|=8192)):Ir(e),null;case 24:return null;case 25:return null}throw Error(_e(156,e.tag))}function W6(t,e){switch(dj(e),e.tag){case 1:return cs(e.type)&&dg(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Ru(),pn(ls),pn($r),wj(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return yj(e),null;case 13:if(pn(wn),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(_e(340));Tu()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return pn(wn),null;case 4:return Ru(),null;case 10:return pj(e.type._context),null;case 22:case 23:return Tj(),null;case 24:return null;default:return null}}var Km=!1,Dr=!1,H6=typeof WeakSet=="function"?WeakSet:Set,Fe=null;function au(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Sn(t,e,r)}else n.current=null}function y0(t,e,n){try{n()}catch(r){Sn(t,e,r)}}var j_=!1;function q6(t,e){if(n0=ag,t=C2(),cj(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.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 a=0,l=-1,c=-1,d=0,h=0,f=t,p=null;t:for(;;){for(var g;f!==n||s!==0&&f.nodeType!==3||(l=a+s),f!==i||r!==0&&f.nodeType!==3||(c=a+r),f.nodeType===3&&(a+=f.nodeValue.length),(g=f.firstChild)!==null;)p=f,f=g;for(;;){if(f===t)break t;if(p===n&&++d===s&&(l=a),p===i&&++h===r&&(c=a),(g=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=g}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(r0={focusedElem:t,selectionRange:n},ag=!1,Fe=e;Fe!==null;)if(e=Fe,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,Fe=t;else for(;Fe!==null;){e=Fe;try{var v=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(v!==null){var x=v.memoizedProps,y=v.memoizedState,b=e.stateNode,w=b.getSnapshotBeforeUpdate(e.elementType===e.type?x:ao(e.type,x),y);b.__reactInternalSnapshotBeforeUpdate=w}break;case 3:var j=e.stateNode.containerInfo;j.nodeType===1?j.textContent="":j.nodeType===9&&j.documentElement&&j.removeChild(j.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(_e(163))}}catch(E){Sn(e,e.return,E)}if(t=e.sibling,t!==null){t.return=e.return,Fe=t;break}Fe=e.return}return v=j_,j_=!1,v}function Sh(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&t)===t){var i=s.destroy;s.destroy=void 0,i!==void 0&&y0(e,n,i)}s=s.next}while(s!==r)}}function Pv(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function w0(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function yT(t){var e=t.alternate;e!==null&&(t.alternate=null,yT(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Vo],delete e[Qh],delete e[i0],delete e[k6],delete e[P6])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function wT(t){return t.tag===5||t.tag===3||t.tag===4}function C_(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||wT(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function b0(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=ug));else if(r!==4&&(t=t.child,t!==null))for(b0(t,e,n),t=t.sibling;t!==null;)b0(t,e,n),t=t.sibling}function j0(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(j0(t,e,n),t=t.sibling;t!==null;)j0(t,e,n),t=t.sibling}var mr=null,lo=!1;function Yi(t,e,n){for(n=n.child;n!==null;)bT(t,e,n),n=n.sibling}function bT(t,e,n){if(Go&&typeof Go.onCommitFiberUnmount=="function")try{Go.onCommitFiberUnmount(bv,n)}catch{}switch(n.tag){case 5:Dr||au(n,e);case 6:var r=mr,s=lo;mr=null,Yi(t,e,n),mr=r,lo=s,mr!==null&&(lo?(t=mr,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):mr.removeChild(n.stateNode));break;case 18:mr!==null&&(lo?(t=mr,n=n.stateNode,t.nodeType===8?py(t.parentNode,n):t.nodeType===1&&py(t,n),qh(t)):py(mr,n.stateNode));break;case 4:r=mr,s=lo,mr=n.stateNode.containerInfo,lo=!0,Yi(t,e,n),mr=r,lo=s;break;case 0:case 11:case 14:case 15:if(!Dr&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,a=i.destroy;i=i.tag,a!==void 0&&(i&2||i&4)&&y0(n,e,a),s=s.next}while(s!==r)}Yi(t,e,n);break;case 1:if(!Dr&&(au(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){Sn(n,e,l)}Yi(t,e,n);break;case 21:Yi(t,e,n);break;case 22:n.mode&1?(Dr=(r=Dr)||n.memoizedState!==null,Yi(t,e,n),Dr=r):Yi(t,e,n);break;default:Yi(t,e,n)}}function N_(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new H6),e.forEach(function(r){var s=tF.bind(null,t,r);n.has(r)||(n.add(r),r.then(s,s))})}}function so(t,e){var n=e.deletions;if(n!==null)for(var r=0;r<n.length;r++){var s=n[r];try{var i=t,a=e,l=a;e:for(;l!==null;){switch(l.tag){case 5:mr=l.stateNode,lo=!1;break e;case 3:mr=l.stateNode.containerInfo,lo=!0;break e;case 4:mr=l.stateNode.containerInfo,lo=!0;break e}l=l.return}if(mr===null)throw Error(_e(160));bT(i,a,s),mr=null,lo=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(d){Sn(s,e,d)}}if(e.subtreeFlags&12854)for(e=e.child;e!==null;)jT(e,t),e=e.sibling}function jT(t,e){var n=t.alternate,r=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(so(e,t),Oo(t),r&4){try{Sh(3,t,t.return),Pv(3,t)}catch(x){Sn(t,t.return,x)}try{Sh(5,t,t.return)}catch(x){Sn(t,t.return,x)}}break;case 1:so(e,t),Oo(t),r&512&&n!==null&&au(n,n.return);break;case 5:if(so(e,t),Oo(t),r&512&&n!==null&&au(n,n.return),t.flags&32){var s=t.stateNode;try{Uh(s,"")}catch(x){Sn(t,t.return,x)}}if(r&4&&(s=t.stateNode,s!=null)){var i=t.memoizedProps,a=n!==null?n.memoizedProps:i,l=t.type,c=t.updateQueue;if(t.updateQueue=null,c!==null)try{l==="input"&&i.type==="radio"&&i.name!=null&&WI(s,i),qw(l,a);var d=qw(l,i);for(a=0;a<c.length;a+=2){var h=c[a],f=c[a+1];h==="style"?KI(s,f):h==="dangerouslySetInnerHTML"?GI(s,f):h==="children"?Uh(s,f):Yb(s,h,f,d)}switch(l){case"input":Vw(s,i);break;case"textarea":HI(s,i);break;case"select":var p=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var g=i.value;g!=null?uu(s,!!i.multiple,g,!1):p!==!!i.multiple&&(i.defaultValue!=null?uu(s,!!i.multiple,i.defaultValue,!0):uu(s,!!i.multiple,i.multiple?[]:"",!1))}s[Qh]=i}catch(x){Sn(t,t.return,x)}}break;case 6:if(so(e,t),Oo(t),r&4){if(t.stateNode===null)throw Error(_e(162));s=t.stateNode,i=t.memoizedProps;try{s.nodeValue=i}catch(x){Sn(t,t.return,x)}}break;case 3:if(so(e,t),Oo(t),r&4&&n!==null&&n.memoizedState.isDehydrated)try{qh(e.containerInfo)}catch(x){Sn(t,t.return,x)}break;case 4:so(e,t),Oo(t);break;case 13:so(e,t),Oo(t),s=t.child,s.flags&8192&&(i=s.memoizedState!==null,s.stateNode.isHidden=i,!i||s.alternate!==null&&s.alternate.memoizedState!==null||(Pj=An())),r&4&&N_(t);break;case 22:if(h=n!==null&&n.memoizedState!==null,t.mode&1?(Dr=(d=Dr)||h,so(e,t),Dr=d):so(e,t),Oo(t),r&8192){if(d=t.memoizedState!==null,(t.stateNode.isHidden=d)&&!h&&t.mode&1)for(Fe=t,h=t.child;h!==null;){for(f=Fe=h;Fe!==null;){switch(p=Fe,g=p.child,p.tag){case 0:case 11:case 14:case 15:Sh(4,p,p.return);break;case 1:au(p,p.return);var v=p.stateNode;if(typeof v.componentWillUnmount=="function"){r=p,n=p.return;try{e=r,v.props=e.memoizedProps,v.state=e.memoizedState,v.componentWillUnmount()}catch(x){Sn(r,n,x)}}break;case 5:au(p,p.return);break;case 22:if(p.memoizedState!==null){E_(f);continue}}g!==null?(g.return=p,Fe=g):E_(f)}h=h.sibling}e:for(h=null,f=t;;){if(f.tag===5){if(h===null){h=f;try{s=f.stateNode,d?(i=s.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(l=f.stateNode,c=f.memoizedProps.style,a=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=ZI("display",a))}catch(x){Sn(t,t.return,x)}}}else if(f.tag===6){if(h===null)try{f.stateNode.nodeValue=d?"":f.memoizedProps}catch(x){Sn(t,t.return,x)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===t)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===t)break e;for(;f.sibling===null;){if(f.return===null||f.return===t)break e;h===f&&(h=null),f=f.return}h===f&&(h=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:so(e,t),Oo(t),r&4&&N_(t);break;case 21:break;default:so(e,t),Oo(t)}}function Oo(t){var e=t.flags;if(e&2){try{e:{for(var n=t.return;n!==null;){if(wT(n)){var r=n;break e}n=n.return}throw Error(_e(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(Uh(s,""),r.flags&=-33);var i=C_(t);j0(t,i,s);break;case 3:case 4:var a=r.stateNode.containerInfo,l=C_(t);b0(t,l,a);break;default:throw Error(_e(161))}}catch(c){Sn(t,t.return,c)}t.flags&=-3}e&4096&&(t.flags&=-4097)}function G6(t,e,n){Fe=t,CT(t)}function CT(t,e,n){for(var r=(t.mode&1)!==0;Fe!==null;){var s=Fe,i=s.child;if(s.tag===22&&r){var a=s.memoizedState!==null||Km;if(!a){var l=s.alternate,c=l!==null&&l.memoizedState!==null||Dr;l=Km;var d=Dr;if(Km=a,(Dr=c)&&!d)for(Fe=s;Fe!==null;)a=Fe,c=a.child,a.tag===22&&a.memoizedState!==null?S_(s):c!==null?(c.return=a,Fe=c):S_(s);for(;i!==null;)Fe=i,CT(i),i=i.sibling;Fe=s,Km=l,Dr=d}__(t)}else s.subtreeFlags&8772&&i!==null?(i.return=s,Fe=i):__(t)}}function __(t){for(;Fe!==null;){var e=Fe;if(e.flags&8772){var n=e.alternate;try{if(e.flags&8772)switch(e.tag){case 0:case 11:case 15:Dr||Pv(5,e);break;case 1:var r=e.stateNode;if(e.flags&4&&!Dr)if(n===null)r.componentDidMount();else{var s=e.elementType===e.type?n.memoizedProps:ao(e.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=e.updateQueue;i!==null&&c_(e,i,r);break;case 3:var a=e.updateQueue;if(a!==null){if(n=null,e.child!==null)switch(e.child.tag){case 5:n=e.child.stateNode;break;case 1:n=e.child.stateNode}c_(e,a,n)}break;case 5:var l=e.stateNode;if(n===null&&e.flags&4){n=l;var c=e.memoizedProps;switch(e.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(e.memoizedState===null){var d=e.alternate;if(d!==null){var h=d.memoizedState;if(h!==null){var f=h.dehydrated;f!==null&&qh(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(_e(163))}Dr||e.flags&512&&w0(e)}catch(p){Sn(e,e.return,p)}}if(e===t){Fe=null;break}if(n=e.sibling,n!==null){n.return=e.return,Fe=n;break}Fe=e.return}}function E_(t){for(;Fe!==null;){var e=Fe;if(e===t){Fe=null;break}var n=e.sibling;if(n!==null){n.return=e.return,Fe=n;break}Fe=e.return}}function S_(t){for(;Fe!==null;){var e=Fe;try{switch(e.tag){case 0:case 11:case 15:var n=e.return;try{Pv(4,e)}catch(c){Sn(e,n,c)}break;case 1:var r=e.stateNode;if(typeof r.componentDidMount=="function"){var s=e.return;try{r.componentDidMount()}catch(c){Sn(e,s,c)}}var i=e.return;try{w0(e)}catch(c){Sn(e,i,c)}break;case 5:var a=e.return;try{w0(e)}catch(c){Sn(e,a,c)}}}catch(c){Sn(e,e.return,c)}if(e===t){Fe=null;break}var l=e.sibling;if(l!==null){l.return=e.return,Fe=l;break}Fe=e.return}}var Z6=Math.ceil,bg=Vi.ReactCurrentDispatcher,Sj=Vi.ReactCurrentOwner,$s=Vi.ReactCurrentBatchConfig,Tt=0,dr=null,Bn=null,vr=0,xs=0,lu=el(0),Jn=0,rf=null,Gl=0,Iv=0,kj=0,kh=null,ss=null,Pj=0,Lu=1/0,mi=null,jg=!1,C0=null,Ea=null,Ym=!1,va=null,Cg=0,Ph=0,N0=null,$p=-1,Vp=0;function Kr(){return Tt&6?An():$p!==-1?$p:$p=An()}function Sa(t){return t.mode&1?Tt&2&&vr!==0?vr&-vr:T6.transition!==null?(Vp===0&&(Vp=a2()),Vp):(t=Zt,t!==0||(t=window.event,t=t===void 0?16:m2(t.type)),t):1}function xo(t,e,n,r){if(50<Ph)throw Ph=0,N0=null,Error(_e(185));Df(t,n,r),(!(Tt&2)||t!==dr)&&(t===dr&&(!(Tt&2)&&(Iv|=n),Jn===4&&ua(t,vr)),us(t,r),n===1&&Tt===0&&!(e.mode&1)&&(Lu=An()+500,Ev&&tl()))}function us(t,e){var n=t.callbackNode;T5(t,e);var r=ig(t,t===dr?vr:0);if(r===0)n!==null&&MN(n),t.callbackNode=null,t.callbackPriority=0;else if(e=r&-r,t.callbackPriority!==e){if(n!=null&&MN(n),e===1)t.tag===0?I6(k_.bind(null,t)):R2(k_.bind(null,t)),E6(function(){!(Tt&6)&&tl()}),n=null;else{switch(l2(r)){case 1:n=tj;break;case 4:n=o2;break;case 16:n=og;break;case 536870912:n=i2;break;default:n=og}n=TT(n,NT.bind(null,t))}t.callbackPriority=e,t.callbackNode=n}}function NT(t,e){if($p=-1,Vp=0,Tt&6)throw Error(_e(327));var n=t.callbackNode;if(pu()&&t.callbackNode!==n)return null;var r=ig(t,t===dr?vr:0);if(r===0)return null;if(r&30||r&t.expiredLanes||e)e=Ng(t,r);else{e=r;var s=Tt;Tt|=2;var i=ET();(dr!==t||vr!==e)&&(mi=null,Lu=An()+500,Ol(t,e));do try{Q6();break}catch(l){_T(t,l)}while(!0);mj(),bg.current=i,Tt=s,Bn!==null?e=0:(dr=null,vr=0,e=Jn)}if(e!==0){if(e===2&&(s=Qw(t),s!==0&&(r=s,e=_0(t,s))),e===1)throw n=rf,Ol(t,0),ua(t,r),us(t,An()),n;if(e===6)ua(t,r);else{if(s=t.current.alternate,!(r&30)&&!K6(s)&&(e=Ng(t,r),e===2&&(i=Qw(t),i!==0&&(r=i,e=_0(t,i))),e===1))throw n=rf,Ol(t,0),ua(t,r),us(t,An()),n;switch(t.finishedWork=s,t.finishedLanes=r,e){case 0:case 1:throw Error(_e(345));case 2:jl(t,ss,mi);break;case 3:if(ua(t,r),(r&130023424)===r&&(e=Pj+500-An(),10<e)){if(ig(t,0)!==0)break;if(s=t.suspendedLanes,(s&r)!==r){Kr(),t.pingedLanes|=t.suspendedLanes&s;break}t.timeoutHandle=o0(jl.bind(null,t,ss,mi),e);break}jl(t,ss,mi);break;case 4:if(ua(t,r),(r&4194240)===r)break;for(e=t.eventTimes,s=-1;0<r;){var a=31-vo(r);i=1<<a,a=e[a],a>s&&(s=a),r&=~i}if(r=s,r=An()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Z6(r/1960))-r,10<r){t.timeoutHandle=o0(jl.bind(null,t,ss,mi),r);break}jl(t,ss,mi);break;case 5:jl(t,ss,mi);break;default:throw Error(_e(329))}}}return us(t,An()),t.callbackNode===n?NT.bind(null,t):null}function _0(t,e){var n=kh;return t.current.memoizedState.isDehydrated&&(Ol(t,e).flags|=256),t=Ng(t,e),t!==2&&(e=ss,ss=n,e!==null&&E0(e)),t}function E0(t){ss===null?ss=t:ss.push.apply(ss,t)}function K6(t){for(var e=t;;){if(e.flags&16384){var n=e.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(!wo(i(),s))return!1}catch{return!1}}}if(n=e.child,e.subtreeFlags&16384&&n!==null)n.return=e,e=n;else{if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return!0;e=e.return}e.sibling.return=e.return,e=e.sibling}}return!0}function ua(t,e){for(e&=~kj,e&=~Iv,t.suspendedLanes|=e,t.pingedLanes&=~e,t=t.expirationTimes;0<e;){var n=31-vo(e),r=1<<n;t[n]=-1,e&=~r}}function k_(t){if(Tt&6)throw Error(_e(327));pu();var e=ig(t,0);if(!(e&1))return us(t,An()),null;var n=Ng(t,e);if(t.tag!==0&&n===2){var r=Qw(t);r!==0&&(e=r,n=_0(t,r))}if(n===1)throw n=rf,Ol(t,0),ua(t,e),us(t,An()),n;if(n===6)throw Error(_e(345));return t.finishedWork=t.current.alternate,t.finishedLanes=e,jl(t,ss,mi),us(t,An()),null}function Ij(t,e){var n=Tt;Tt|=1;try{return t(e)}finally{Tt=n,Tt===0&&(Lu=An()+500,Ev&&tl())}}function Zl(t){va!==null&&va.tag===0&&!(Tt&6)&&pu();var e=Tt;Tt|=1;var n=$s.transition,r=Zt;try{if($s.transition=null,Zt=1,t)return t()}finally{Zt=r,$s.transition=n,Tt=e,!(Tt&6)&&tl()}}function Tj(){xs=lu.current,pn(lu)}function Ol(t,e){t.finishedWork=null,t.finishedLanes=0;var n=t.timeoutHandle;if(n!==-1&&(t.timeoutHandle=-1,_6(n)),Bn!==null)for(n=Bn.return;n!==null;){var r=n;switch(dj(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&dg();break;case 3:Ru(),pn(ls),pn($r),wj();break;case 5:yj(r);break;case 4:Ru();break;case 13:pn(wn);break;case 19:pn(wn);break;case 10:pj(r.type._context);break;case 22:case 23:Tj()}n=n.return}if(dr=t,Bn=t=ka(t.current,null),vr=xs=e,Jn=0,rf=null,kj=Iv=Gl=0,ss=kh=null,Tl!==null){for(e=0;e<Tl.length;e++)if(n=Tl[e],r=n.interleaved,r!==null){n.interleaved=null;var s=r.next,i=n.pending;if(i!==null){var a=i.next;i.next=s,r.next=a}n.pending=r}Tl=null}return t}function _T(t,e){do{var n=Bn;try{if(mj(),Op.current=wg,yg){for(var r=Cn.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}yg=!1}if(ql=0,lr=Qn=Cn=null,Eh=!1,ef=0,Sj.current=null,n===null||n.return===null){Jn=1,rf=e,Bn=null;break}e:{var i=t,a=n.return,l=n,c=e;if(e=vr,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=c,h=l,f=h.tag;if(!(h.mode&1)&&(f===0||f===11||f===15)){var p=h.alternate;p?(h.updateQueue=p.updateQueue,h.memoizedState=p.memoizedState,h.lanes=p.lanes):(h.updateQueue=null,h.memoizedState=null)}var g=p_(a);if(g!==null){g.flags&=-257,g_(g,a,l,i,e),g.mode&1&&m_(i,d,e),e=g,c=d;var v=e.updateQueue;if(v===null){var x=new Set;x.add(c),e.updateQueue=x}else v.add(c);break e}else{if(!(e&1)){m_(i,d,e),Aj();break e}c=Error(_e(426))}}else if(vn&&l.mode&1){var y=p_(a);if(y!==null){!(y.flags&65536)&&(y.flags|=256),g_(y,a,l,i,e),hj(Du(c,l));break e}}i=c=Du(c,l),Jn!==4&&(Jn=2),kh===null?kh=[i]:kh.push(i),i=a;do{switch(i.tag){case 3:i.flags|=65536,e&=-e,i.lanes|=e;var b=lT(i,c,e);l_(i,b);break e;case 1:l=c;var w=i.type,j=i.stateNode;if(!(i.flags&128)&&(typeof w.getDerivedStateFromError=="function"||j!==null&&typeof j.componentDidCatch=="function"&&(Ea===null||!Ea.has(j)))){i.flags|=65536,e&=-e,i.lanes|=e;var E=cT(i,l,e);l_(i,E);break e}}i=i.return}while(i!==null)}kT(n)}catch(P){e=P,Bn===n&&n!==null&&(Bn=n=n.return);continue}break}while(!0)}function ET(){var t=bg.current;return bg.current=wg,t===null?wg:t}function Aj(){(Jn===0||Jn===3||Jn===2)&&(Jn=4),dr===null||!(Gl&268435455)&&!(Iv&268435455)||ua(dr,vr)}function Ng(t,e){var n=Tt;Tt|=2;var r=ET();(dr!==t||vr!==e)&&(mi=null,Ol(t,e));do try{Y6();break}catch(s){_T(t,s)}while(!0);if(mj(),Tt=n,bg.current=r,Bn!==null)throw Error(_e(261));return dr=null,vr=0,Jn}function Y6(){for(;Bn!==null;)ST(Bn)}function Q6(){for(;Bn!==null&&!j5();)ST(Bn)}function ST(t){var e=IT(t.alternate,t,xs);t.memoizedProps=t.pendingProps,e===null?kT(t):Bn=e,Sj.current=null}function kT(t){var e=t;do{var n=e.alternate;if(t=e.return,e.flags&32768){if(n=W6(n,e),n!==null){n.flags&=32767,Bn=n;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{Jn=6,Bn=null;return}}else if(n=B6(n,e,xs),n!==null){Bn=n;return}if(e=e.sibling,e!==null){Bn=e;return}Bn=e=t}while(e!==null);Jn===0&&(Jn=5)}function jl(t,e,n){var r=Zt,s=$s.transition;try{$s.transition=null,Zt=1,X6(t,e,n,r)}finally{$s.transition=s,Zt=r}return null}function X6(t,e,n,r){do pu();while(va!==null);if(Tt&6)throw Error(_e(327));n=t.finishedWork;var s=t.finishedLanes;if(n===null)return null;if(t.finishedWork=null,t.finishedLanes=0,n===t.current)throw Error(_e(177));t.callbackNode=null,t.callbackPriority=0;var i=n.lanes|n.childLanes;if(A5(t,i),t===dr&&(Bn=dr=null,vr=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Ym||(Ym=!0,TT(og,function(){return pu(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=$s.transition,$s.transition=null;var a=Zt;Zt=1;var l=Tt;Tt|=4,Sj.current=null,q6(t,n),jT(n,t),x6(r0),ag=!!n0,r0=n0=null,t.current=n,G6(n),C5(),Tt=l,Zt=a,$s.transition=i}else t.current=n;if(Ym&&(Ym=!1,va=t,Cg=s),i=t.pendingLanes,i===0&&(Ea=null),E5(n.stateNode),us(t,An()),e!==null)for(r=t.onRecoverableError,n=0;n<e.length;n++)s=e[n],r(s.value,{componentStack:s.stack,digest:s.digest});if(jg)throw jg=!1,t=C0,C0=null,t;return Cg&1&&t.tag!==0&&pu(),i=t.pendingLanes,i&1?t===N0?Ph++:(Ph=0,N0=t):Ph=0,tl(),null}function pu(){if(va!==null){var t=l2(Cg),e=$s.transition,n=Zt;try{if($s.transition=null,Zt=16>t?16:t,va===null)var r=!1;else{if(t=va,va=null,Cg=0,Tt&6)throw Error(_e(331));var s=Tt;for(Tt|=4,Fe=t.current;Fe!==null;){var i=Fe,a=i.child;if(Fe.flags&16){var l=i.deletions;if(l!==null){for(var c=0;c<l.length;c++){var d=l[c];for(Fe=d;Fe!==null;){var h=Fe;switch(h.tag){case 0:case 11:case 15:Sh(8,h,i)}var f=h.child;if(f!==null)f.return=h,Fe=f;else for(;Fe!==null;){h=Fe;var p=h.sibling,g=h.return;if(yT(h),h===d){Fe=null;break}if(p!==null){p.return=g,Fe=p;break}Fe=g}}}var v=i.alternate;if(v!==null){var x=v.child;if(x!==null){v.child=null;do{var y=x.sibling;x.sibling=null,x=y}while(x!==null)}}Fe=i}}if(i.subtreeFlags&2064&&a!==null)a.return=i,Fe=a;else e:for(;Fe!==null;){if(i=Fe,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Sh(9,i,i.return)}var b=i.sibling;if(b!==null){b.return=i.return,Fe=b;break e}Fe=i.return}}var w=t.current;for(Fe=w;Fe!==null;){a=Fe;var j=a.child;if(a.subtreeFlags&2064&&j!==null)j.return=a,Fe=j;else e:for(a=w;Fe!==null;){if(l=Fe,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:Pv(9,l)}}catch(P){Sn(l,l.return,P)}if(l===a){Fe=null;break e}var E=l.sibling;if(E!==null){E.return=l.return,Fe=E;break e}Fe=l.return}}if(Tt=s,tl(),Go&&typeof Go.onPostCommitFiberRoot=="function")try{Go.onPostCommitFiberRoot(bv,t)}catch{}r=!0}return r}finally{Zt=n,$s.transition=e}}return!1}function P_(t,e,n){e=Du(n,e),e=lT(t,e,1),t=_a(t,e,1),e=Kr(),t!==null&&(Df(t,1,e),us(t,e))}function Sn(t,e,n){if(t.tag===3)P_(t,t,n);else for(;e!==null;){if(e.tag===3){P_(e,t,n);break}else if(e.tag===1){var r=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Ea===null||!Ea.has(r))){t=Du(n,t),t=cT(e,t,1),e=_a(e,t,1),t=Kr(),e!==null&&(Df(e,1,t),us(e,t));break}}e=e.return}}function J6(t,e,n){var r=t.pingCache;r!==null&&r.delete(e),e=Kr(),t.pingedLanes|=t.suspendedLanes&n,dr===t&&(vr&n)===n&&(Jn===4||Jn===3&&(vr&130023424)===vr&&500>An()-Pj?Ol(t,0):kj|=n),us(t,e)}function PT(t,e){e===0&&(t.mode&1?(e=$m,$m<<=1,!($m&130023424)&&($m=4194304)):e=1);var n=Kr();t=Ii(t,e),t!==null&&(Df(t,e,n),us(t,n))}function eF(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),PT(t,n)}function tF(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,s=t.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(_e(314))}r!==null&&r.delete(e),PT(t,n)}var IT;IT=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||ls.current)as=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return as=!1,U6(t,e,n);as=!!(t.flags&131072)}else as=!1,vn&&e.flags&1048576&&D2(e,mg,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;zp(t,e),t=e.pendingProps;var s=Iu(e,$r.current);mu(e,n),s=jj(null,e,r,t,s,n);var i=Cj();return e.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,cs(r)?(i=!0,hg(e)):i=!1,e.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,vj(e),s.updater=kv,e.stateNode=s,s._reactInternals=e,h0(e,r,t,n),e=p0(null,e,r,!0,i,n)):(e.tag=0,vn&&i&&uj(e),Hr(null,e,s,n),e=e.child),e;case 16:r=e.elementType;e:{switch(zp(t,e),t=e.pendingProps,s=r._init,r=s(r._payload),e.type=r,s=e.tag=rF(r),t=ao(r,t),s){case 0:e=m0(null,e,r,t,n);break e;case 1:e=y_(null,e,r,t,n);break e;case 11:e=v_(null,e,r,t,n);break e;case 14:e=x_(null,e,r,ao(r.type,t),n);break e}throw Error(_e(306,r,""))}return e;case 0:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:ao(r,s),m0(t,e,r,s,n);case 1:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:ao(r,s),y_(t,e,r,s,n);case 3:e:{if(fT(e),t===null)throw Error(_e(387));r=e.pendingProps,i=e.memoizedState,s=i.element,$2(t,e),vg(e,r,null,n);var a=e.memoizedState;if(r=a.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},e.updateQueue.baseState=i,e.memoizedState=i,e.flags&256){s=Du(Error(_e(423)),e),e=w_(t,e,r,n,s);break e}else if(r!==s){s=Du(Error(_e(424)),e),e=w_(t,e,r,n,s);break e}else for(js=Na(e.stateNode.containerInfo.firstChild),_s=e,vn=!0,co=null,n=F2(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Tu(),r===s){e=Ti(t,e,n);break e}Hr(t,e,r,n)}e=e.child}return e;case 5:return V2(e),t===null&&c0(e),r=e.type,s=e.pendingProps,i=t!==null?t.memoizedProps:null,a=s.children,s0(r,s)?a=null:i!==null&&s0(r,i)&&(e.flags|=32),hT(t,e),Hr(t,e,a,n),e.child;case 6:return t===null&&c0(e),null;case 13:return mT(t,e,n);case 4:return xj(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=Au(e,null,r,n):Hr(t,e,r,n),e.child;case 11:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:ao(r,s),v_(t,e,r,s,n);case 7:return Hr(t,e,e.pendingProps,n),e.child;case 8:return Hr(t,e,e.pendingProps.children,n),e.child;case 12:return Hr(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(r=e.type._context,s=e.pendingProps,i=e.memoizedProps,a=s.value,on(pg,r._currentValue),r._currentValue=a,i!==null)if(wo(i.value,a)){if(i.children===s.children&&!ls.current){e=Ti(t,e,n);break e}}else for(i=e.child,i!==null&&(i.return=e);i!==null;){var l=i.dependencies;if(l!==null){a=i.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(i.tag===1){c=_i(-1,n&-n),c.tag=2;var d=i.updateQueue;if(d!==null){d=d.shared;var h=d.pending;h===null?c.next=c:(c.next=h.next,h.next=c),d.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),u0(i.return,n,e),l.lanes|=n;break}c=c.next}}else if(i.tag===10)a=i.type===e.type?null:i.child;else if(i.tag===18){if(a=i.return,a===null)throw Error(_e(341));a.lanes|=n,l=a.alternate,l!==null&&(l.lanes|=n),u0(a,n,e),a=i.sibling}else a=i.child;if(a!==null)a.return=i;else for(a=i;a!==null;){if(a===e){a=null;break}if(i=a.sibling,i!==null){i.return=a.return,a=i;break}a=a.return}i=a}Hr(t,e,s.children,n),e=e.child}return e;case 9:return s=e.type,r=e.pendingProps.children,mu(e,n),s=Gs(s),r=r(s),e.flags|=1,Hr(t,e,r,n),e.child;case 14:return r=e.type,s=ao(r,e.pendingProps),s=ao(r.type,s),x_(t,e,r,s,n);case 15:return uT(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:ao(r,s),zp(t,e),e.tag=1,cs(r)?(t=!0,hg(e)):t=!1,mu(e,n),aT(e,r,s),h0(e,r,s,n),p0(null,e,r,!0,t,n);case 19:return pT(t,e,n);case 22:return dT(t,e,n)}throw Error(_e(156,e.tag))};function TT(t,e){return s2(t,e)}function nF(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.t
vendor: 9,326 bytes, line 40
40ype=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,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 zs(t,e,n,r){return new nF(t,e,n,r)}function Rj(t){return t=t.prototype,!(!t||!t.isReactComponent)}function rF(t){if(typeof t=="function")return Rj(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Xb)return 11;if(t===Jb)return 14}return 2}function ka(t,e){var n=t.alternate;return n===null?(n=zs(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function Up(t,e,n,r,s,i){var a=2;if(r=t,typeof t=="function")Rj(t)&&(a=1);else if(typeof t=="string")a=5;else e:switch(t){case Xc:return Fl(n.children,s,i,e);case Qb:a=8,s|=8;break;case Mw:return t=zs(12,n,e,s|2),t.elementType=Mw,t.lanes=i,t;case Ow:return t=zs(13,n,e,s),t.elementType=Ow,t.lanes=i,t;case Fw:return t=zs(19,n,e,s),t.elementType=Fw,t.lanes=i,t;case VI:return Tv(n,s,i,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case zI:a=10;break e;case $I:a=9;break e;case Xb:a=11;break e;case Jb:a=14;break e;case oa:a=16,r=null;break e}throw Error(_e(130,t==null?t:typeof t,""))}return e=zs(a,n,e,s),e.elementType=t,e.type=r,e.lanes=i,e}function Fl(t,e,n,r){return t=zs(7,t,r,e),t.lanes=n,t}function Tv(t,e,n,r){return t=zs(22,t,r,e),t.elementType=VI,t.lanes=n,t.stateNode={isHidden:!1},t}function Cy(t,e,n){return t=zs(6,t,null,e),t.lanes=n,t}function Ny(t,e,n){return e=zs(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function sF(t,e,n,r,s){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=sy(0),this.expirationTimes=sy(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=sy(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Dj(t,e,n,r,s,i,a,l,c){return t=new sF(t,e,n,l,c),e===1?(e=1,i===!0&&(e|=8)):e=0,i=zs(3,null,null,e),t.current=i,i.stateNode=t,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},vj(i),t}function oF(t,e,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Qc,key:r==null?null:""+r,children:t,containerInfo:e,implementation:n}}function AT(t){if(!t)return Oa;t=t._reactInternals;e:{if(hc(t)!==t||t.tag!==1)throw Error(_e(170));var e=t;do{switch(e.tag){case 3:e=e.stateNode.context;break e;case 1:if(cs(e.type)){e=e.stateNode.__reactInternalMemoizedMergedChildContext;break e}}e=e.return}while(e!==null);throw Error(_e(171))}if(t.tag===1){var n=t.type;if(cs(n))return A2(t,n,e)}return e}function RT(t,e,n,r,s,i,a,l,c){return t=Dj(n,r,!0,t,s,i,a,l,c),t.context=AT(null),n=t.current,r=Kr(),s=Sa(n),i=_i(r,s),i.callback=e??null,_a(n,i,s),t.current.lanes=s,Df(t,s,r),us(t,r),t}function Av(t,e,n,r){var s=e.current,i=Kr(),a=Sa(s);return n=AT(n),e.context===null?e.context=n:e.pendingContext=n,e=_i(i,a),e.payload={element:t},r=r===void 0?null:r,r!==null&&(e.callback=r),t=_a(s,e,a),t!==null&&(xo(t,s,a,i),Mp(t,s,a)),a}function _g(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function I_(t,e){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var n=t.retryLane;t.retryLane=n!==0&&n<e?n:e}}function Lj(t,e){I_(t,e),(t=t.alternate)&&I_(t,e)}function iF(){return null}var DT=typeof reportError=="function"?reportError:function(t){console.error(t)};function Mj(t){this._internalRoot=t}Rv.prototype.render=Mj.prototype.render=function(t){var e=this._internalRoot;if(e===null)throw Error(_e(409));Av(t,e,null,null)};Rv.prototype.unmount=Mj.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var e=t.containerInfo;Zl(function(){Av(null,t,null,null)}),e[Pi]=null}};function Rv(t){this._internalRoot=t}Rv.prototype.unstable_scheduleHydration=function(t){if(t){var e=d2();t={blockedOn:null,target:t,priority:e};for(var n=0;n<ca.length&&e!==0&&e<ca[n].priority;n++);ca.splice(n,0,t),n===0&&f2(t)}};function Oj(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function Dv(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function T_(){}function aF(t,e,n,r,s){if(s){if(typeof r=="function"){var i=r;r=function(){var d=_g(a);i.call(d)}}var a=RT(e,r,t,0,null,!1,!1,"",T_);return t._reactRootContainer=a,t[Pi]=a.current,Kh(t.nodeType===8?t.parentNode:t),Zl(),a}for(;s=t.lastChild;)t.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var d=_g(c);l.call(d)}}var c=Dj(t,0,!1,null,null,!1,!1,"",T_);return t._reactRootContainer=c,t[Pi]=c.current,Kh(t.nodeType===8?t.parentNode:t),Zl(function(){Av(e,c,n,r)}),c}function Lv(t,e,n,r,s){var i=n._reactRootContainer;if(i){var a=i;if(typeof s=="function"){var l=s;s=function(){var c=_g(a);l.call(c)}}Av(e,a,t,s)}else a=aF(n,e,t,s,r);return _g(a)}c2=function(t){switch(t.tag){case 3:var e=t.stateNode;if(e.current.memoizedState.isDehydrated){var n=ih(e.pendingLanes);n!==0&&(nj(e,n|1),us(e,An()),!(Tt&6)&&(Lu=An()+500,tl()))}break;case 13:Zl(function(){var r=Ii(t,1);if(r!==null){var s=Kr();xo(r,t,1,s)}}),Lj(t,1)}};rj=function(t){if(t.tag===13){var e=Ii(t,134217728);if(e!==null){var n=Kr();xo(e,t,134217728,n)}Lj(t,134217728)}};u2=function(t){if(t.tag===13){var e=Sa(t),n=Ii(t,e);if(n!==null){var r=Kr();xo(n,t,e,r)}Lj(t,e)}};d2=function(){return Zt};h2=function(t,e){var n=Zt;try{return Zt=t,e()}finally{Zt=n}};Zw=function(t,e,n){switch(e){case"input":if(Vw(t,n),e=n.name,n.type==="radio"&&e!=null){for(n=t;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+e)+'][type="radio"]'),e=0;e<n.length;e++){var r=n[e];if(r!==t&&r.form===t.form){var s=_v(r);if(!s)throw Error(_e(90));BI(r),Vw(r,s)}}}break;case"textarea":HI(t,n);break;case"select":e=n.value,e!=null&&uu(t,!!n.multiple,e,!1)}};XI=Ij;JI=Zl;var lF={usingClientEntryPoint:!1,Events:[Mf,nu,_v,YI,QI,Ij]},Vd={findFiberByHostInstance:Il,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},cF={bundleType:Vd.bundleType,version:Vd.version,rendererPackageName:Vd.rendererPackageName,rendererConfig:Vd.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Vi.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=n2(t),t===null?null:t.stateNode},findFiberByHostInstance:Vd.findFiberByHostInstance||iF,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 Qm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Qm.isDisabled&&Qm.supportsFiber)try{bv=Qm.inject(cF),Go=Qm}catch{}}Is.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=lF;Is.createPortal=function(t,e){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Oj(e))throw Error(_e(200));return oF(t,e,null,n)};Is.createRoot=function(t,e){if(!Oj(t))throw Error(_e(299));var n=!1,r="",s=DT;return e!=null&&(e.unstable_strictMode===!0&&(n=!0),e.identifierPrefix!==void 0&&(r=e.identifierPrefix),e.onRecoverableError!==void 0&&(s=e.onRecoverableError)),e=Dj(t,1,!1,null,null,n,!1,r,s),t[Pi]=e.current,Kh(t.nodeType===8?t.parentNode:t),new Mj(e)};Is.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var e=t._reactInternals;if(e===void 0)throw typeof t.render=="function"?Error(_e(188)):(t=Object.keys(t).join(","),Error(_e(268,t)));return t=n2(e),t=t===null?null:t.stateNode,t};Is.flushSync=function(t){return Zl(t)};Is.hydrate=function(t,e,n){if(!Dv(e))throw Error(_e(200));return Lv(null,t,e,!0,n)};Is.hydrateRoot=function(t,e,n){if(!Oj(t))throw Error(_e(405));var r=n!=null&&n.hydratedSources||null,s=!1,i="",a=DT;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),e=RT(e,null,t,1,n??null,s,!1,i,a),t[Pi]=e.current,Kh(t),r)for(t=0;t<r.length;t++)n=r[t],s=n._getVersion,s=s(n._source),e.mutableSourceEagerHydrationData==null?e.mutableSourceEagerHydrationData=[n,s]:e.mutableSourceEagerHydrationData.push(n,s);return new Rv(e)};Is.render=function(t,e,n){if(!Dv(e))throw Error(_e(200));return Lv(null,t,e,!1,n)};Is.unmountComponentAtNode=function(t){if(!Dv(t))throw Error(_e(40
40));return t._reactRootContainer?(Zl(function(){Lv(null,null,t,!1,function(){t._reactRootContainer=null,t[Pi]=null})}),!0):!1};Is.unstable_batchedUpdates=Ij;Is.unstable_renderSubtreeIntoContainer=function(t,e,n,r){if(!Dv(n))throw Error(_e(200));if(t==null||t._reactInternals===void 0)throw Error(_e(38));return Lv(t,e,n,!1,r)};Is.version="18.3.1-next-f1338f8080-20240426";function LT(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(LT)}catch(t){console.error(t)}}LT(),LI.exports=Is;var ps=LI.exports;const Fj=CI(ps);var A_=ps;Dw.createRoot=A_.createRoot,Dw.hydrateRoot=A_.hydrateRoot;/** 41 * @remix-run/router v1.23.0 42 * 43 * Copyright (c) Remix Software Inc. 44 * 45 * This source code is licensed under the MIT license found in the 46 * LICENSE.md file in the root directory of this source tree. 47 * 48 * @license MIT 49 */function sf(){return sf=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},sf.apply(this,arguments)}var xa;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(xa||(xa={}));const R_="popstate";function uF(t){t===void 0&&(t={});function e(r,s){let{pathname:i,search:a,hash:l}=r.location;return S0("",{pathname:i,search:a,hash:l},s.state&&s.state.usr||null,s.state&&s.state.key||"default")}function n(r,s){return typeof s=="string"?s:Eg(s)}return hF(e,n,null,t)}function kn(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function zj(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function dF(){return Math.random().toString(36).substr(2,8)}function D_(t,e){return{usr:t.state,key:t.key,idx:e}}function S0(t,e,n,r){return n===void 0&&(n=null),sf({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?ed(e):e,{state:n,key:e&&e.key||r||dF()})}function Eg(t){let{pathname:e="/",search:n="",hash:r=""}=t;return n&&n!=="?"&&(e+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(e+=r.charAt(0)==="#"?r:"#"+r),e}function ed(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substr(n),t=t.substr(0,n));let r=t.indexOf("?");r>=0&&(e.search=t.substr(r),t=t.substr(0,r)),t&&(e.pathname=t)}return e}function hF(t,e,n,r){r===void 0&&(r={});let{window:s=document.defaultView,v5Compat:i=!1}=r,a=s.history,l=xa.Pop,c=null,d=h();d==null&&(d=0,a.replaceState(sf({},a.state,{idx:d}),""));function h(){return(a.state||{idx:null}).idx}function f(){l=xa.Pop;let y=h(),b=y==null?null:y-d;d=y,c&&c({action:l,location:x.location,delta:b})}function p(y,b){l=xa.Push;let w=S0(x.location,y,b);d=h()+1;let j=D_(w,d),E=x.createHref(w);try{a.pushState(j,"",E)}catch(P){if(P instanceof DOMException&&P.name==="DataCloneError")throw P;s.location.assign(E)}i&&c&&c({action:l,location:x.location,delta:1})}function g(y,b){l=xa.Replace;let w=S0(x.location,y,b);d=h();let j=D_(w,d),E=x.createHref(w);a.replaceState(j,"",E),i&&c&&c({action:l,location:x.location,delta:0})}function v(y){let b=s.location.origin!=="null"?s.location.origin:s.location.href,w=typeof y=="string"?y:Eg(y);return w=w.replace(/ $/,"%20"),kn(b,"No window.location.(origin|href) available to create URL for href: "+w),new URL(w,b)}let x={get action(){return l},get location(){return t(s,a)},listen(y){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(R_,f),c=y,()=>{s.removeEventListener(R_,f),c=null}},createHref(y){return e(s,y)},createURL:v,encodeLocation(y){let b=v(y);return{pathname:b.pathname,search:b.search,hash:b.hash}},push:p,replace:g,go(y){return a.go(y)}};return x}var L_;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(L_||(L_={}));function fF(t,e,n){return n===void 0&&(n="/"),mF(t,e,n)}function mF(t,e,n,r){let s=typeof e=="string"?ed(e):e,i=$j(s.pathname||"/",n);if(i==null)return null;let a=MT(t);pF(a);let l=null;for(let c=0;l==null&&c<a.length;++c){let d=kF(i);l=NF(a[c],d)}return l}function MT(t,e,n,r){e===void 0&&(e=[]),n===void 0&&(n=[]),r===void 0&&(r="");let s=(i,a,l)=>{let c={relativePath:l===void 0?i.path||"":l,caseSensitive:i.caseSensitive===!0,childrenIndex:a,route:i};c.relativePath.startsWith("/")&&(kn(c.relativePath.startsWith(r),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+r+'" is not val
49id. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(r.length));let d=Pa([r,c.relativePath]),h=n.concat(c);i.children&&i.children.length>0&&(kn(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+d+'".')),MT(i.children,e,h,d)),!(i.path==null&&!i.index)&&e.push({path:d,score:jF(d,i.index),routesMeta:h})};return t.forEach((i,a)=>{var l;if(i.path===""||!((l=i.path)!=null&&l.includes("?")))s(i,a);else for(let c of OT(i.path))s(i,a,c)}),e}function OT(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,s=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return s?[i,""]:[i];let a=OT(r.join("/")),l=[];return l.push(...a.map(c=>c===""?i:[i,c].join("/"))),s&&l.push(...a),l.map(c=>t.startsWith("/")&&c===""?"/":c)}function pF(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:CF(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const gF=/^:[\w-]+$/,vF=3,xF=2,yF=1,wF=10,bF=-2,M_=t=>t==="*";function jF(t,e){let n=t.split("/"),r=n.length;return n.some(M_)&&(r+=bF),e&&(r+=xF),n.filter(s=>!M_(s)).reduce((s,i)=>s+(gF.test(i)?vF:i===""?yF:wF),r)}function CF(t,e){return t.length===e.length&&t.slice(0,-1).every((r,s)=>r===e[s])?t[t.length-1]-e[e.length-1]:0}function NF(t,e,n){let{routesMeta:r}=t,s={},i="/",a=[];for(let l=0;l<r.length;++l){let c=r[l],d=l===r.length-1,h=i==="/"?e:e.slice(i.length)||"/",f=EF({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},h),p=c.route;if(!f)return null;
49Object.assign(s,f.params),a.push({params:s,pathname:Pa([i,f.pathname]),pathnameBase:AF(Pa([i,f.pathnameBase])),route:p}),f.pathnameBase!=="/"&&(i=Pa([i,f.pathnameBase]))}return a}function _F(t,e){e===void 0&&(e={});let n=t;n.endsWith("*")&&n!=="*"&&!n.endsWith("/*")&&(zj(!1,'Route path "'+n+'" will be treated as if it were '+('"'+n.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+n.replace(/\*$/,"/*")+'".')),n=n.replace(/\*$/,"/*"));const r=n.startsWith("/")?"/":"",s=a=>a==null?"":typeof a=="string"?a:String(a),i=n.split(/\/+/).map((a,l,c)=>{if(l===c.length-1&&a==="*")return s(e["*"]);const h=a.match(/^:([\w-]+)(\??)$/);if(h){const[,f,p]=h;let g=e[f];return kn(p==="?"||g!=null,'Missing ":'+f+'" param'),s(g)}return a.replace(/\?$/g,"")}).filter(a=>!!a);return r+i.join("/")}function EF(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=SF(t.path,t.caseSensitive,t.end),s=e.match(n);if(!s)return null;let i=s[0],a=i.replace(/(.)\/+$/,"$1"),l=s.slice(1);return{params:r.reduce((d,h,f)=>{let{paramName:p,isOptional:g}=h;if(p==="*"){let x=l[f]||"";a=i.slice(0,i.length-x.length).replace(/(.)\/+$/,"$1")}const v=l[f];return g&&!v?d[p]=void 0:d[p]=(v||"").replace(/%2F/g,"/"),d},{}),pathname:i,pathnameBase:a,pattern:t}}function SF(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!0),zj(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let r=[],s="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(a,l,c)=>(r.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(r.push({paramName:"*"}),s+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":t!==""&&t!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,e?void 0:"i"),r]}function kF(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return zj(!1,'The URL path "'+t+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+e+").")),t}}function $j(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,r=t.charAt(n);return r&&r!=="/"?null:t.slice(n)||"/"}function PF(t,e){e===void 0&&(e="/");let{pathname:n,search:r="",hash:s=""}=typeof t=="string"?ed(t):t;return{pathname:n?n.startsWith("/")?n:IF(n,e):e,search:RF(r),hash:DF(s)}}function IF(t,e){let n=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function _y(t,e,n,r){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+e+"` 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 TF(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function Vj(t,e){let n=TF(t);return e?n.map((r,s)=>s===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function Uj(t,e,n,r){r===void 0&&(r=!1);let s;typeof t=="string"?s=ed(t):(s=sf({},t),kn(!s.pathname||!s.pathname.includes("?"),_y("?","pathname","search",s)),kn(!s.pathname||!s.pathname.includes("#"),_y("#","pathname","hash",s)),kn(!s.search||!s.search.includes("#"),_y("#","search","hash",s)));let i=t===""||s.pathname==="",a=i?"/":s.pathname,l;if(a==null)l=n;else{let f=e.length-1;if(!r&&a.startsWith("..")){let p=a.split("/");for(;p[0]==="..";)p.shift(),f-=1;s.pathname=p.join("/")}l=f>=0?e[f]:"/"}let c=PF(s,l),d=a&&a!=="/"&&a.endsWith("/"),h=(i||a===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||h)&&(c.pathname+="/"),c}const Pa=t=>t.join("/").replace(/\/\/+/g,"/"),AF=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),RF=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,DF=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function LF(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const FT=["post","put","patch","delete"];new Set(FT);const MF=["get",...FT];new Set(MF);/** 50 * React Router v6.30.1 51 * 52 * Copyright (c) Remix Software Inc. 53 * 54 * This source code is licensed under the MIT license found in the 55 * LICENSE.md file in the root directory of this source tree. 56 * 57 * @license MIT 58 */function of(){return of=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},of.apply(this,arguments)}const Bj=u.createContext(null),OF=u.createContext(null),nl=u.createContext(null),Mv=u.createContext(null),oi=u.createContext({outlet:null,matches:[],isDataRoute:!1}),zT=u.createContext(null);function FF(t,e){let{relative:n}=e===void 0?{}:e;td()||kn(!1);let{basename:r,navigator:s}=u.useContext(nl),{hash:i,pathname:a,search:l}=VT(t,{relative:n}),c=a;return r!=="/"&&(c=a==="/"?r:Pa([r,a])),s.createHref({pathname:c,search:l,hash:i})}function td(){return u.useContext(Mv)!=null}function Ui(){return td()||kn(!1),u.useContext(Mv).location}function $T(t){u.useContext(nl).static||u.useLayoutEffect(t)}function qt(){let{isDataRoute:t}=u.useContext(oi);return t?JF():zF()}function zF(){td()||kn(!1);let t=u.useContext(Bj),{basename:e,future:n,navigator:r}=u.useContext(nl),{matches:s}=u.useContext(oi),{pathname:i}=Ui(),a=JSON.stringify(Vj(s,n.v7_relativeSplatPath)),l=u.useRef(!1);return $T(()=>{l.current=!0}),u.useCallback(function(d,h){if(h===void 0&&(h={}),!l.current)return;if(typeof d=="number"){r.go(d);return}let f=Uj(d,JSON.parse(a),i,h.relative==="path");t==null&&e!=="/"&&(f.pathname=f.pathname==="/"?e:Pa([e,f.pathname])),(h.replace?r.replace:r.push)(f,h.state,h)},[e,r,a,i,t])}const $F=u.createContext(null);function VF(t){let e=u.useContext(oi).outlet;return e&&u.createElement($F.Provider,{value:t},e)}function Ys(){let{matches:t}=u.useContext(oi),e=t[t.length-1];return e?e.params:{}}function VT(t,e){let{relative:n}=e===void 0?{}:e,{future:r}=u.useContext(nl),{matches:s}=u.useContext(oi),{pathname:i}=Ui(),a=JSON.stringify(Vj(s,r.v7_relativeSplatPath));return u.useMemo(()=>Uj(t,JSON.parse(a),i,n==="path"),[t,a,i,n])}function UF(t,e){return BF(t,e)}function BF(t,e,n,r){td()||kn(!1);let{navigator:s}=u.useContext(nl),{matches:i}=u.useContext(oi),a=i[i.length-1],l=a?a.params:{};a&&a.pathname;let c=a?a.pathnameBase:"/";a&&a.route;let d=Ui(),h;if(e){var f;let y=typeof e=="string"?ed(e):e;c==="/"||(f=y.pathname)!=null&&f.startsWith(c)||kn(!1),h=y}else h=d;let p=h.pathname||"/",g=p;if(c!=="/"){let y=c.replace(/^\//,"").split("/");g="/"+p.replace(/^\//,"").split("/").slice(y.length).join("/")}let v=fF(t,{pathname:g}),x=ZF(v&&v.map(y=>Object.assign({},y,{params:Object.assign({},l,y.params),pathname:Pa([c,s.encodeLocation?s.encodeLocation(y.pathname).pathname:y.pathname]),pathnameBase:y.pathnameBase==="/"?c:Pa([c,s.encodeLocation?s.encodeLocation(y.pathnameBase).pathname:y.pathnameBase])})),i,n,r);return e&&x?u.createElement(Mv.Provider,{value:{location:of({pathname:"/",search:"",hash:"",state:null,key:"default"},h),navigationType:xa.Pop}},x):x}function WF(){let t=XF(),e=LF(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return u.createElement(u.Fragment,null,u.createElement("h2",null,"Unexpected Application
58Error!"),u.createElement("h3",{style:{fontStyle:"italic"}},e),n?u.createElement("pre",{style:s},n):null,null)}const HF=u.createElement(WF,null);class qF extends u.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,n){return n.location!==e.location||n.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:n.error,location:n.location,revalidation:e.revalidation||n.revalidation}}componentDidCatch(e,n){console.error("React Router caught the following error during render",e,n)}render(){return this.state.error!==void 0?u.createElement(oi.Provider,{value:this.props.routeContext},u.createElement(zT.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function GF(t){let{routeContext:e,match:n,children:r}=t,s=u.useContext(Bj);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),u.createElement(oi.Provider,{value:e},r)}function ZF(t,e,n,r){var s;if(e===void 0&&(e=[]),n===void 0&&(n=null),r===void 0&&(r=null),t==null){var i;if(!n)return null;if(n.errors)t=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let a=t,l=(s=n)==null?void 0:s.errors;if(l!=null){let h=a.findIndex(f=>f.route.id&&(l==null?void 0:l[f.route.id])!==void 0);h>=0||kn(!1),a=a.slice(0,Math.min(a.length,h+1))}let c=!1,d=-1;if(n&&r&&r.v7_partialHydration)for(let h=0;h<a.length;h++){let f=a[h];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(d=h),f.route.id){let{loaderData:p,errors:g}=n,v=f.route.loader&&p[f.route.id]===void 0&&(!g||g[f.route.id]===void 0);if(f.route.lazy||v){c=!0,d>=0?a=a.slice(0,d+1):a=[a[0]];break}}}return a.reduceRight((h,f,p)=>{let g,v=!1,x=null,y=null;n&&(g=l&&f.route.id?l[f.route.id]:void 0,x=f.route.errorElement||HF,c&&(d<0&&p===0?(ez("route-fallback"),v=!0,y=null):d===p&&(v=!0,y=f.route.hydrateFallbackElement||null)));let b=e.concat(a.slice(0,p+1)),w=()=>{let j;return g?j=x:v?j=y:f.route.Component?j=u.createElement(f.route.Component,null):f.route.element?j=f.route.element:j=h,u.createElement(GF,{match:f,routeContext:{outlet:h,matches:b,isDataRoute:n!=null},children:j})};return n&&(f.route.ErrorBoundary||f.route.errorElement||p===0)?u.createElement(qF,{location:n.location,revalidation:n.revalidation,component:x,error:g,children:w(),routeContext:{outlet:null,matches:b,isDataRoute:!0}}):w()},null)}var UT=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(UT||{}),BT=function(t){return t.UseBlocker="useBlocker",t.UseLoaderData="useLoaderData",t.UseActionData="useActionData",t.UseRouteError="useRouteError",t.UseNavigation="useNavigation",t.UseRouteLoaderData="useRouteLoaderData",t.UseMatches="useMatches",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t.UseRouteId="useRouteId",t}(BT||{});function KF(t){let e=u.useContext(Bj);return e||kn(!1),e}function YF(t){let e=u.useContext(OF);return e||kn(!1),e}function QF(t){let e=u.useContext(oi);return e||kn(!1),e}function WT(t){let e=QF(),n=e.matches[e.matches.length-1];return n.route.id||kn(!1),n.route.id}function XF(){var t;let e=u.useContext(zT),n=YF(),r=WT();return e!==void 0?e:(t=n.errors)==null?void 0:t[r]}function JF(){let{router:t}=KF(UT.UseNavigateStable),e=WT(BT.UseNavigateStable),n=u.useRef(!1);return $T(()=>{n.current=!0}),u.useCallback(function(s,i){i===void 0&&(i={}),n.current&&(typeof s=="number"?t.navigate(s):t.navigate(s,of({fromRouteId:e},i)))},[t,e])}const O_={};function ez(t,e,n){O_[t]||(O_[t]=!0)}function tz(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Ms(t){let{to:e,replace:n,state:r,relative:s}=t;td()||kn(!1);let{future:i,static:a}=u.useContext(nl),{matches:l}=u.useContext(oi),{pathname:c}=Ui(),d=qt(),h=Uj(e,Vj(l,i.v7_relativeSplatPath),c,s==="path"),f=JSON.stringify(h);return u.useEffect(()=>d(JSON.parse(f),{replace:n,state:r,relative:s}),[d,f,s,n,r]),null}function nz(t){return VF(t.context)}function bt(t){kn(!1)}function rz(t){let{basename:e="/",children:n=null,location:r,navigationType:s=xa.Pop,navigator:i,static:a=!1,future:l}=t;td()&&kn(!1);let c=e.replace(/^\/*/,"/"),d=u.useMemo(()=>({basename:c,navigator:i,static:a,future:of({v7_relativeSplatPath:!1},l)}),[c,l,i,a]);typeof r=="string"&&(r=ed(r));let{pathname:h="/",search:f="",hash:p="",state:g=null,key:v="default"}=r,x=u.useMemo(()=>{let y=$j(h,c);return y==null?null:{location:{pathname:y,search:f,hash:p,state:g,key:v},navigationType:s}},[c,h,f,p,g,v,s]);return x==null?null:u.createElement(nl.Provider,{value:d},u.createElement(Mv.Provider,{children:n,value:x}))}function F_(t){let{children:e,location:n}=t;return UF(k0(e),n)}new Promise(()=>{});function k0(t,e){e===void 0&&(e=[]);let n=[];
58return u.Children.forEach(t,(r,s)=>{if(!u.isValidElement(r))return;let i=[...e,s];if(r.type===u.Fragment){n.push.apply(n,k0(r.props.children,i));return}r.type!==bt&&kn(!1),!r.props.index||!r.props.children||kn(!1);let a={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&&(a.children=k0(r.props.children,i)),n.push(a)}),n}/** 59 * React Router DOM v6.30.1 60 * 61 * Copyright (c) Remix Software Inc. 62 * 63 * This source code is licensed under the MIT license found in the 64 * LICENSE.md file in the root directory of this source tree. 65 * 66 * @license MIT 67 */function P0(){return P0=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},P0.apply(this,arguments)}function sz(t,e){if(t==null)return{};var n={},r=Object.keys(t),s,i;for(i=0;i<r.length;i++)s=r[i],!(e.indexOf(s)>=0)&&(n[s]=t[s]);return n}function oz(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function iz(t,e){return t.button===0&&(!e||e==="_self")&&!oz(t)}function I0(t){return t===void 0&&(t=""),new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((e,n)=>{let r=t[n];return e.concat(Array.isArray(r)?r.map(s=>[n,s]):[[n,r]])},[]))}function az(t,e){let n=I0(t);return e&&e.forEach((r,s)=>{n.has(s)||e.getAll(s).forEach(i=>{n.append(s,i)})}),n}const lz=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],cz="6";try{window.__reactRouterVersion=cz}catch{}const uz="startTransition",z_=wv[uz];function dz(t){let{basename:e,children:n,future:r,window:s}=t,i=u.useRef();i.current==null&&(i.current=uF({window:s,v5Compat:!0}));let a=i.current,[l,c]=u.useState({action:a.action,location:a.location}),{v7_startTransition:d}=r||{},h=u.useCallback(f=>{d&&z_?z_(()=>c(f)):c(f)},[c,d]);return u.useLayoutEffect(()=>a.listen(h),[a,h]),u.useEffect(()=>tz(r),[r]),u.createElement(rz,{basename:e,children:n,location:l.location,navigationType:l.action,navigator:a,future:r})}const hz=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",fz=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Fa=u.forwardRef(function(e,n){let{onClick:r,relative:s,reloadDocument:i,replace:a,state:l,target:c,to:d,preventScrollReset:h,viewTransition:f}=e,p=sz(e,lz),{basename:g}=u.useContext(nl),v,x=!1;if(typeof d=="string"&&fz.test(d)&&(v=d,hz))try{let j=new URL(window.location.href),E=d.startsWith("//")?new URL(j.protocol+d):new URL(d),P=$j(E.pathname,g);E.origin===j.origin&&P!=null?d=P+E.search+E.hash:x=!0}catch{}let y=FF(d,{relative:s}),b=mz(d,{replace:a,state:l,target:c,preventScrollReset:h,relative:s,viewTransition:f});function w(j){r&&r(j),j.defaultPrevented||b(j)}return u.createElement("a",P0({},p,{href:v||y,onClick:x||i?r:w,ref:n,target:c}))});var $_;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})($_||($_={}));var V_;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(V_||(V_={}));function mz(t,e){let{target:n,replace:r,state:s,preventScrollReset:i,relative:a,viewTransition:l}=e===void 0?{}:e,c=qt(),d=Ui(),h=VT(t,{relative:a});return u.useCallback(f=>{if(iz(f,n)){f.preventDefault();let p=r!==void 0?r:Eg(d)===Eg(h);c(t,{replace:p,state:s,preventScrollReset:i,relative:a,viewTransition:l})}},[d,c,h,r,s,n,t,i,a,l])}function pz(t){let e=u.useRef(I0(t)),n=u.useRef(!1),r=Ui(),s=u.useMemo(()=>az(r.search,n.current?null:e.current),[r.search]),i=qt(),a=u.useCallback((l,c)=>{const d=I0(typeof l=="function"?l(s):l);n.current=!0,i("?"+d,c)},[i,s]);return[s,a]}const xe={home:"/",login:"/connexion",signup:"/inscription",profile:"/profil",myCompany:"/ma-societe",zones:"/zones",zoneNew:"/zones/nouvelle",companies:"/societes",companyNew:"/societes/nouvelle",departments:"/departements",departmentNew:"/departements/nouveau",users:"/utilisateurs",contracts:"/contrats",premiumAccess:"/acces-premium",farmers:"/agriculteurs",sponsors:"/sponsors",sponsorNew:"/sponsors/nouveau",payment:"/paiement"},Rl="zones-de-battue",HT={infos:"infos",members:"membres",pois:"poi",paths:"chemins",zbattue:Rl,zautre:"autres-zones",battues:"battues",documents:"documents",messaging:"messagerie",subscription:"abonnement",notifications:"notifications",danger:"danger"};function qT(t){if(!t)return"infos";const e=Object.entries(HT).find(([,n])=>n===t);return e?e[0]:"infos"}function Sg(t,e){const n=HT[e]??e;return n==="infos"?t:`${t}/${n}`}const mt={zone:t=>`${xe.zones}/${t}`,zoneNewForCompany:t=>`${xe.zoneNew}?companyId=${t}`,company:(t,e="infos")=>Sg(`${xe.companies}/${t}`,e),myCompany:(t="infos")=>Sg(xe.myCompany,t),huntingZoneNew:t=>`${t}/${Rl}/nouvelle`,huntingZoneEdit:(t,e)=>`${t}/${Rl}/${e}/modifier`,department:t=>`${xe.departments}/${t}`,user:t=>`${xe.users}/${t}`,farmer:t=>`${xe.farmers}/${t}`,sponsor:t=>`${xe.sponsors}/${t}`,plot:t=>`/parcelles/${t}`,damage:t=>`/degats/${t}`,burrow:t=>`/terriers/${t}`,paymentReturn:t=>`${xe.payment}/${t}`},sn={myCompany:`${xe.myCompany}/:onglet?`,myCompanyHuntingZoneNew:`${xe.myCompany}/${Rl}/nouvelle`,myCompanyHuntingZoneEdit:`${xe.myCompany}/${Rl}
67/:zoneId/modifier`,zone:`${xe.zones}/:zoneId`,company:`${xe.companies}/:id/:onglet?`,companyHuntingZoneNew:`${xe.companies}/:companyId/${Rl}/nouvelle`,companyHuntingZoneEdit:`${xe.companies}/:companyId/${Rl}/:zoneId/modifier`,department:`${xe.departments}/:departmentId`,user:`${xe.users}/:userId`,farmer:`${xe.farmers}/:userId`,sponsor:`${xe.sponsors}/:id`,plot:"/parcelles/:plotId",damage:"/degats/:damageId",burrow:"/terriers/:burrowId",payment:`${xe.payment}/:statut`},gz=[{from:"/profile",to:xe.profile},{from:"/my-company",to:xe.myCompany},{from:"/my-company/hunting-zones/new",to:sn.myCompanyHuntingZoneNew},{from:"/my-company/hunting-zones/:zoneId/edit",to:sn.myCompanyHuntingZoneEdit},{from:"/zones/new",to:xe.zoneNew},{from:"/companies",to:xe.companies},{from:"/companies/new",to:xe.companyNew},{from:"/companies/:id",to:`${xe.companies}/:id`},{from:"/companies/:companyId/hunting-zones/new",to:sn.companyHuntingZoneNew},{from:"/companies/:companyId/hunting-zones/:zoneId/edit",to:sn.companyHuntingZoneEdit},{from:"/departments",to:xe.departments},{from:"/departments/new",to:xe.departmentNew},{from:"/departments/:departmentId",to:sn.department},{from:"/users",to:xe.users},{from:"/users/:userId",to:sn.user},{from:"/contracts",to:xe.contracts},{from:"/premium-access",to:xe.premiumAccess},{from:"/farmers",to:xe.farmers},{from:"/farmers/:userId",to:sn.farmer},{from:"/sponsors/new",to:xe.sponsorNew},{from:"/plots/:plotId",to:sn.plot},{from:"/damages/:damageId",to:sn.damage},{from:"/burrows/:burrowId",to:sn.burrow},{from:"/map",to:xe.home}],vz=[{from:"/login",to:xe.login},{from:"/signup",to:xe.signup}];var U_={};/** 68 * @license 69 * Copyright 2017 Google LLC 70 * 71 * Licensed under the Apache License, Version 2.0 (the "License"); 72 * you may not use this file except in compliance with the License. 73 * You may obtain a copy of the License at 74 * 75 * http://www.apache.org/licenses/LICENSE-2.0 76 * 77 * Unless required by applicable law or agreed to in writing, software 78 * distributed under the License is distributed on an "AS IS" BASIS, 79 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 80 * See the License for the specific language governing permissions and 81 * limitations under the License. 82 */const GT=function(t){const e=[];let n=0;for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);s<128?e[n++]=s:s<2048?(e[n++]=s>>6|192,e[n++]=s&63|128):(s&64512)===55296&&r+1<t.length&&(t.charCodeAt(r+1)&64512)===56320?(s=65536+((s&1023)<<10)+(t.charCodeAt(++r)&1023),e[n++]=s>>18|240,e[n++]=s>>12&63|128,e[n++]=s>>6&63|128,e[n++]=s&63|128):(e[n++]=s>>12|224,e[n++]=s>>6&63|128,e[n++]=s&63|128)}return e},xz=function(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n++];if(s<128)e[r++]=String.fromCharCode(s);else if(s>191&&s<224){const i=t[n++];e[r++]=String.fromCharCode((s&31)<<6|i&63)}else if(s>239&&s<365){const i=t[n++],a=t[n++],l=t[n++],c=((s&7)<<18|(i&63)<<12|(a&63)<<6|l&63)-65536;e[r++]=String.fromCharCode(55296+(c>>10)),e[r++]=String.fromCharCode(56320+(c&1023))}else{const i=t[n++],a=t[n++];e[r++]=String.fromCharCode((s&15)<<12|(i&63)<<6|a&63)}}return e.join("")},ZT={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(t,e){if(!Array.isArray(t))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let s=0;s<t.length;s+=3){const i=t[s],a=s+1<t.length,l=a?t[s+1]:0,c=s+2<t.length,d=c?t[s+2]:0,h=i>>2,f=(i&3)<<4|l>>4;let p=(l&15)<<2|d>>6,g=d&63;c||(g=64,a||(p=64)),r.push(n[h],n[f],n[p],n[g])}return r.join("")},encodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(GT(t),e)},decodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):xz(this.decodeStringToByteArray(t,e))},decodeStringToByteArray(t,e){this.init_();const n=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let s=0;s<t.length;){const i=n[t.charAt(s++)],l=s<t.length?n[t.charAt(s)]:0;++s;const d=s<t.length?n[t.charAt(s)]:64;++s;const f=s<t.length?n[t.charAt(s)]:64;if(++s,i==null||l==null||d==null||f==null)throw new yz;const p=i<<2|l>>4;if(r.push(p),d!==64){const g=l<<4&240|d>>2;if(r.push(g),f!==64){const v=d<<6&192|f;r.push(v)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let t=0;t<this.ENCODED_VALS.length;t++)this.byteToCharMap_[t]=this.ENCODED_VALS.charAt(t),this.charToByteMap_[this.byteToCharMap_[t]]=t,this.byteToCharMapWebSafe_[t]=this.ENCODED_VALS_WEBSAFE.charAt(t),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[t]]=t,t>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}};
82class yz extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const wz=function(t){const e=GT(t);return ZT.encodeByteArray(e,!0)},kg=function(t){return wz(t).replace(/\./g,"")},KT=function(t){try{return ZT.decodeString(t,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};/** 83 * @license 84 * Copyright 2022 Google LLC 85 * 86 * Licensed under the Apache License, Version 2.0 (the "License"); 87 * you may not use this file except in compliance with the License. 88 * You may obtain a copy of the License at 89 * 90 * http://www.apache.org/licenses/LICENSE-2.0 91 * 92 * Unless required by applicable law or agreed to in writing, software 93 * distributed under the License is distributed on an "AS IS" BASIS, 94 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 95 * See the License for the specific language governing permissions and 96 * limitations under the License. 97 */function bz(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}/** 98 * @license 99 * Copyright 2022 Google LLC 100 * 101 * Licensed under the Apache License, Version 2.0 (the "License"); 102 * you may not use this file except in compliance with the License. 103 * You may obtain a copy of the License at 104 * 105 * http://www.apache.org/licenses/LICENSE-2.0 106 * 107 * Unless required by applicable law or agreed to in writing, software 108 * distributed under the License is distributed on an "AS IS" BASIS, 109 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 110 * See the License for the specific language governing permissions and 111 * limitations under the License. 112 */const jz=()=>bz().__FIREBASE_DEFAULTS__,Cz=()=>{if(typeof process>"u"||typeof U_>"u")return;const t=U_.__FIREBASE_DEFAULTS__;if(t)return JSON.parse(t)},Nz=()=>{if(typeof document>"u")return;let t;try{t=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=t&&KT(t[1]);return e&&JSON.parse(e)},Ov=()=>{try{return jz()||Cz()||Nz()}catch(t){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${t}`);return}},YT=t=>{var e,n;return(n=(e=Ov())===null||e===void 0?void 0:e.emulatorHosts)===null||n===void 0?void 0:n[t]},Wj=t=>{const e=YT(t);if(!e)return;const n=e.lastIndexOf(":");if(n<=0||n+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const r=parseInt(e.substring(n+1),10);return e[0]==="["?[e.substring(1,n-1),r]:[e.substring(0,n),r]},QT=()=>{var t;return(t=Ov())===null||t===void 0?void 0:t.config},XT=t=>{var e;return(e=Ov())===null||e===void 0?void 0:e[`_${t}`]};/** 113 * @license 114 * Copyright 2017 Google LLC 115 * 116 * Licensed under the Apache License, Version 2.0 (the "License"); 117 * you may not use this file except in compliance with the License. 118 * You may obtain a copy of the License at 119 * 120 * http://www.apache.org/licenses/LICENSE-2.0 121 * 122 * Unless required by applicable law or agreed to in writing, software 123 * distributed under the License is distributed on an "AS IS" BASIS, 124 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 125 * See the License for the specific language governing permissions and 126 * limitations under the License. 127 */class _z{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,n)=>{this.resolve=e,this.reject=n})}wrapCallback(e){return(n,r)=>{n?this.reject(n):this.resolve(r),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(n):e(n,r))}}}/** 128 * @license 129 * Copyright 2021 Google LLC 130 * 131 * Licensed under the Apache License, Version 2.0 (the "License"); 132 * you may not use this file except in compliance with the License. 133 * You may obtain a copy of the License at 134 * 135 * http://www.apache.org/licenses/LICENSE-2.0 136 * 137 * Unless required by applicable law or agreed to in writing, software 138 * distributed under the License is distributed on an "AS IS" BASIS, 139 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 140 * See the License for the specific language governing permissions and 141 * limitations under the License. 142 */function JT(t,e){if(t.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const n={alg:"none",type:"JWT"},r=e||"demo-project",s=t.iat||0,i=t.sub||t.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const a=Object.assign({iss:`https://securetoken.google.com/${r}`,aud:r,iat:s,exp:s+3600,auth_time:s,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}}},t);
142return[kg(JSON.stringify(n)),kg(JSON.stringify(a)),""].join(".")}/** 143 * @license 144 * Copyright 2017 Google LLC 145 * 146 * Licensed under the Apache License, Version 2.0 (the "License"); 147 * you may not use this file except in compliance with the License. 148 * You may obtain a copy of the License at 149 * 150 * http://www.apache.org/licenses/LICENSE-2.0 151 * 152 * Unless required by applicable law or agreed to in writing, software 153 * distributed under the License is distributed on an "AS IS" BASIS, 154 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 155 * See the License for the specific language governing permissions and 156 * limitations under the License. 157 */function Vr(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function Ez(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(Vr())}function Sz(){var t;const e=(t=Ov())===null||t===void 0?void 0:t.forceEnvironment;if(e==="node")return!0;if(e==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function kz(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function Pz(){const t=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof t=="object"&&t.id!==void 0}function Iz(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function Tz(){const t=Vr();return t.indexOf("MSIE ")>=0||t.indexOf("Trident/")>=0}function Az(){return!Sz()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function Rz(){try{return typeof indexedDB=="object"}catch{return!1}}function Dz(){return new Promise((t,e)=>{try{let n=!0;const r="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(r);s.onsuccess=()=>{s.result.close(),n||self.indexedDB.deleteDatabase(r),t(!0)},s.onupgradeneeded=()=>{n=!1},s.onerror=()=>{var i;e(((i=s.error)===null||i===void 0?void 0:i.message)||"")}}catch(n){e(n)}})}/** 158 * @license 159 * Copyright 2017 Google LLC 160 * 161 * Licensed under the Apache License, Version 2.0 (the "License"); 162 * you may not use this file except in compliance with the License. 163 * You may obtain a copy of the License at 164 * 165 * http://www.apache.org/licenses/LICENSE-2.0 166 * 167 * Unless required by applicable law or agreed to in writing, software 168 * distributed under the License is distributed on an "AS IS" BASIS, 169 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 170 * See the License for the specific language governing permissions and 171 * limitations under the License. 172 */const Lz="FirebaseError";class Po extends Error{constructor(e,n,r){super(n),this.code=e,this.customData=r,this.name=Lz,Object.setPrototypeOf(this,Po.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,Ff.prototype.create)}}class Ff{constructor(e,n,r){this.service=e,this.serviceName=n,this.errors=r}create(e,...n){const r=n[0]||{},s=`${this.service}/${e}`,i=this.errors[e],a=i?Mz(i,r):"Error",l=`${this.serviceName}: ${a} (${s}).`;return new Po(s,l,r)}}function Mz(t,e){return t.replace(Oz,(n,r)=>{const s=e[r];return s!=null?String(s):`<${r}?>`})}const Oz=/\{\$([^}]+)}/g;function Fz(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function Pg(t,e){if(t===e)return!0;const n=Object.keys(t),r=Object.keys(e);for(const s of n){if(!r.includes(s))return!1;const i=t[s],a=e[s];if(B_(i)&&B_(a)){if(!Pg(i,a))return!1}else if(i!==a)return!1}for(const s of r)if(!n.includes(s))return!1;return!0}function B_(t){return t!==null&&typeof t=="object"}/** 173 * @license 174 * Copyright 2017 Google LLC 175 * 176 * Licensed under the Apache License, Version 2.0 (the "License"); 177 * you may not use this file except in compliance with the License. 178 * You may obtain a copy of the License at 179 * 180 * http://www.apache.org/licenses/LICENSE-2.0 181 * 182 * Unless required by applicable law or agreed to in writing, software 183 * distributed under the License is distributed on an "AS IS" BASIS, 184 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 185 * See the License for the specific language governing permissions and 186 * limitations under the License. 187 */function zf(t){const e=[];for(const[n,r]of Object.entries(t))Array.isArray(r)?r.forEach(s=>{e.push(encodeURIComponent(n)+"="+encodeURIComponent(s))}):e.push(encodeURIComponent(n)+"="+encodeURIComponent(r));return e.length?"&"+e.join("&"):""}function lh(t){const e={};return t.replace(/^\?/,"").split("&").forEach(r=>{if(r){const[s,i]=r.split("=");e[decodeURIComponent(s)]=decodeURIComponent(i)}}),e}function ch(t){const e=t.indexOf("?");if(!e)return"";const n=t.indexOf("#",e);return t.substring(e,n>0?n:void 0)}function zz(t,e){const n=new $z(t,e);return n.subscribe.bind(n)}class $z{constructor(e,n){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Prom
187ise.resolve(),this.finalized=!1,this.onNoObservers=n,this.task.then(()=>{e(this)}).catch(r=>{this.error(r)})}next(e){this.forEachObserver(n=>{n.next(e)})}error(e){this.forEachObserver(n=>{n.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,n,r){let s;if(e===void 0&&n===void 0&&r===void 0)throw new Error("Missing Observer.");Vz(e,["next","error","complete"])?s=e:s={next:e,error:n,complete:r},s.next===void 0&&(s.next=Ey),s.error===void 0&&(s.error=Ey),s.complete===void 0&&(s.complete=Ey);const i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?s.error(this.finalError):s.complete()}catch{}}),this.observers.push(s),i}unsubscribeOne(e){this.observers===void 0||this.observers[e]===void 0||(delete this.observers[e],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let n=0;n<this.observers.length;n++)this.sendOne(n,e)}sendOne(e,n){this.task.then(()=>{if(this.observers!==void 0&&this.observers[e]!==void 0)try{n(this.observers[e])}catch(r){typeof console<"u"&&console.error&&console.error(r)}})}close(e){this.finalized||(this.finalized=!0,e!==void 0&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function Vz(t,e){if(typeof t!="object"||t===null)return!1;for(const n of e)if(n in t&&typeof t[n]=="function")return!0;return!1}function Ey(){}/** 188 * @license 189 * Copyright 2021 Google LLC 190 * 191 * Licensed under the Apache License, Version 2.0 (the "License"); 192 * you may not use this file except in compliance with the License. 193 * You may obtain a copy of the License at 194 * 195 * http://www.apache.org/licenses/LICENSE-2.0 196 * 197 * Unless required by applicable law or agreed to in writing, software 198 * distributed under the License is distributed on an "AS IS" BASIS, 199 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 * See the License for the specific language governing permissions and 201 * limitations under the License. 202 */function tn(t){return t&&t._delegate?t._delegate:t}class Ai{constructor(e,n,r){this.name=e,this.instanceFactory=n,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}/** 203 * @license 204 * Copyright 2019 Google LLC 205 * 206 * Licensed under the Apache License, Version 2.0 (the "License"); 207 * you may not use this file except in compliance with the License. 208 * You may obtain a copy of the License at 209 * 210 * http://www.apache.org/licenses/LICENSE-2.0 211 * 212 * Unless required by applicable law or agreed to in writing, software 213 * distributed under the License is distributed on an "AS IS" BASIS, 214 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 215 * See the License for the specific language governing permissions and 216 * limitations under the License. 217 */const Cl="[DEFAULT]";/** 218 * @license 219 * Copyright 2019 Google LLC 220 * 221 * Licensed under the Apache License, Version 2.0 (the "License"); 222 * you may not use this file except in compliance with the License. 223 * You may obtain a copy of the License at 224 * 225 * http://www.apache.org/licenses/LICENSE-2.0 226 * 227 * Unless required by applicable law or agreed to in writing, software 228 * distributed under the License is distributed on an "AS IS" BASIS, 229 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 230 * See the License for the specific language governing permissions and 231 * limitations under the License. 232 */class Uz{constructor(e,n){this.name=e,this.container=n,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const n=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(n)){const r=new _z;if(this.instancesDeferred.set(n,r),this.isInitialized(n)||this.shouldAutoInitialize())try{const s=this.getOrInitializeService({instanceIdentifier:n});s&&r.resolve(s)}catch{}}return this.instancesDeferred.get(n).promise}getImmediate(e){var n;const r=this.normalizeInstanceIdentifier(e==null?void 0:e.identifier),s=(n=e==null?void 0:e.optional)!==null&&n!==void 0?n:!1;if(this.isInitialized(r)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:r})}catch(i){if(s)return null;throw i}else{if(s)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,!!this.shouldAutoInitialize()){if(Wz(e))try{this.getOrInitializeService({instanceIdentifier:Cl})}catch{}for(const[n,r]of this.instancesDeferred.entries()){const s=this.normalizeInstanceIdentifier(n);try{const i=this.getOrInitializeService({instanceIdentifier:s});r.resolve(i)}catch{}}}}clearInstance(e=Cl){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(n=>"INTERNAL"in n).map(n=>n.INTERNAL.delete()),...e.filter(n=>"_delete"in n).map(n=>n._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=Cl){return this.instances.has(e)}getOptions(e=Cl){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:n={}}=e,r=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(r))throw Error(`${this.name}(${r}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const s=this.getOrInitializeService({instanceIdentifier:r,options:n});for(const[i,a]of this.instancesDeferred.entries()){const l=this.normalizeInstanceIdentifier(i);r===l&&a.resolve(s)}return s}onInit(e,n){var r;const s=this.normalizeInstanceIdentifier(n),i=(r=this.onInitCallbacks.get(s))!==null&&r!==void 0?r:new Set;i.add(e),this.onInitCallbacks.set(s,i);const a=this.instances.get(s);return a&&e(a,s),()=>{i.delete(e)}}invokeOnInitCallbacks(e,n){const r=this.onInitCallbacks.get(n);if(r)for(const s of r)try{s(e,n)}catch{}}getOrInitializeService({instanceIdentifier:e,options:n={}}){let r=this.instances.get(e);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:Bz(e),options:n}),this.instances.set(e,r),this.instancesOptions.set(e,n),this.invokeOnInitCallbacks(r,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,r)}catch{}return r||null}normalizeInstanceIdentifier(e=Cl){return this.component?this.component.multipleInstances?e:Cl:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function Bz(t){return t===Cl?void 0:t}function Wz(t){return t.instantiationMode==="EAGER"}/** 233 * @license 234 * Copyright 2019 Google LLC 235 * 236 * Licensed under the Apache License, Version 2.0 (the "License");
237 * you may not use this file except in compliance with the License. 238 * You may obtain a copy of the License at 239 * 240 * http://www.apache.org/licenses/LICENSE-2.0 241 * 242 * Unless required by applicable law or agreed to in writing, software 243 * distributed under the License is distributed on an "AS IS" BASIS, 244 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 245 * See the License for the specific language governing permissions and 246 * limitations under the License. 247 */class Hz{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const n=this.getProvider(e.name);if(n.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);n.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const n=new Uz(e,this);return this.providers.set(e,n),n}getProviders(){return Array.from(this.providers.values())}}/** 248 * @license 249 * Copyright 2017 Google LLC 250 * 251 * Licensed under the Apache License, Version 2.0 (the "License"); 252 * you may not use this file except in compliance with the License. 253 * You may obtain a copy of the License at 254 * 255 * http://www.apache.org/licenses/LICENSE-2.0 256 * 257 * Unless required by applicable law or agreed to in writing, software 258 * distributed under the License is distributed on an "AS IS" BASIS, 259 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 260 * See the License for the specific language governing permissions and 261 * limitations under the License. 262 */var Nt;(function(t){t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT"})(Nt||(Nt={}));const qz={debug:Nt.DEBUG,verbose:Nt.VERBOSE,info:Nt.INFO,warn:Nt.WARN,error:Nt.ERROR,silent:Nt.SILENT},Gz=Nt.INFO,Zz={[Nt.DEBUG]:"log",[Nt.VERBOSE]:"log",[Nt.INFO]:"info",[Nt.WARN]:"warn",[Nt.ERROR]:"error"},Kz=(t,e,...n)=>{if(e<t.logLevel)return;const r=new Date().toISOString(),s=Zz[e];if(s)console[s](`[${r}] ${t.name}:`,...n);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class Hj{constructor(e){this.name=e,this._logLevel=Gz,this._logHandler=Kz,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in Nt))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?qz[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,Nt.DEBUG,...e),this._logHandler(this,Nt.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,Nt.VERBOSE,...e),this._logHandler(this,Nt.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,Nt.INFO,...e),this._logHandler(this,Nt.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,Nt.WARN,...e),this._logHandler(this,Nt.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,Nt.ERROR,...e),this._logHandler(this,Nt.ERROR,...e)}}const Yz=(t,e)=>e.some(n=>t instanceof n);let W_,H_;function Qz(){return W_||(W_=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Xz(){return H_||(H_=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const eA=new WeakMap,T0=new WeakMap,tA=new WeakMap,Sy=new WeakMap,qj=new WeakMap;function Jz(t){const e=new Promise((n,r)=>{const s=()=>{t.removeEventListener("success",i),t.removeEventListener("error",a)},i=()=>{n(Ia(t.result)),s()},a=()=>{r(t.error),s()};t.addEventListener("success",i),t.addEventListener("error",a)});return e.then(n=>{n instanceof IDBCursor&&eA.set(n,t)}).catch(()=>{}),qj.set(e,t),e}function e$(t){if(T0.has(t))return;const e=new Promise((n,r)=>{const s=()=>{t.removeEventListener("complete",i),t.removeEventListener("error",a),t.removeEventListener("abort",a)},i=()=>{n(),s()},a=()=>{r(t.error||new DOMException("AbortError","AbortError")),s()};t.addEventListener("complete",i),t.addEventListener("error",a),t.addEventListener("abort",a)});T0.set(t,e)}let A0={get(t,e,n){if(t instanceof IDBTransaction){if(e==="done")return T0.get(t);if(e==="objectStoreNames")return t.objectStoreNames||tA.get(t);if(e==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Ia(t[e])},set(t,e,n){return t[e]=n,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function t$(t){A0=t(A0)}function n$(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...n){const r=t.call(ky(this),e,...n);return tA.set(r,e.sort?e.sort():[e]),Ia(r)}:Xz().includes(t)?function(...e){return t.apply(ky(this),e),Ia(eA.get(this))}:function(...e){return Ia(t.apply(ky(this),e))}}
262function r$(t){return typeof t=="function"?n$(t):(t instanceof IDBTransaction&&e$(t),Yz(t,Qz())?new Proxy(t,A0):t)}function Ia(t){if(t instanceof IDBRequest)return Jz(t);if(Sy.has(t))return Sy.get(t);const e=r$(t);return e!==t&&(Sy.set(t,e),qj.set(e,t)),e}const ky=t=>qj.get(t);function s$(t,e,{blocked:n,upgrade:r,blocking:s,terminated:i}={}){const a=indexedDB.open(t,e),l=Ia(a);return r&&a.addEventListener("upgradeneeded",c=>{r(Ia(a.result),c.oldVersion,c.newVersion,Ia(a.transaction),c)}),n&&a.addEventListener("blocked",c=>n(c.oldVersion,c.newVersion,c)),l.then(c=>{i&&c.addEventListener("close",()=>i()),s&&c.addEventListener("versionchange",d=>s(d.oldVersion,d.newVersion,d))}).catch(()=>{}),l}const o$=["get","getKey","getAll","getAllKeys","count"],i$=["put","add","delete","clear"],Py=new Map;function q_(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(Py.get(e))return Py.get(e);const n=e.replace(/FromIndex$/,""),r=e!==n,s=i$.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(s||o$.includes(n)))return;const i=async function(a,...l){const c=this.transaction(a,s?"readwrite":"readonly");let d=c.store;return r&&(d=d.index(l.shift())),(await Promise.all([d[n](...l),s&&c.done]))[0]};return Py.set(e,i),i}t$(t=>({...t,get:(e,n,r)=>q_(e,n)||t.get(e,n,r),has:(e,n)=>!!q_(e,n)||t.has(e,n)}));/** 263 * @license 264 * Copyright 2019 Google LLC 265 * 266 * Licensed under the Apache License, Version 2.0 (the "License"); 267 * you may not use this file except in compliance with the License. 268 * You may obtain a copy of the License at 269 * 270 * http://www.apache.org/licenses/LICENSE-2.0 271 * 272 * Unless required by applicable law or agreed to in writing, software 273 * distributed under the License is distributed on an "AS IS" BASIS, 274 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 275 * See the License for the specific language governing permissions and 276 * limitations under the License. 277 */class a${constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(n=>{if(l$(n)){const r=n.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(n=>n).join(" ")}}function l$(t){const e=t.getComponent();return(e==null?void 0:e.type)==="VERSION"}const R0="@firebase/app",G_="0.10.13";/** 278 * @license 279 * Copyright 2019 Google LLC 280 * 281 * Licensed under the Apache License, Version 2.0 (the "License"); 282 * you may not use this file except in compliance with the License. 283 * You may obtain a copy of the License at 284 * 285 * http://www.apache.org/licenses/LICENSE-2.0 286 * 287 * Unless required by applicable law or agreed to in writing, software 288 * distributed under the License is distributed on an "AS IS" BASIS, 289 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 290 * See the License for the specific language governing permissions and 291 * limitations under the License. 292 */const Ri=new Hj("@firebase/app"),c$="@firebase/app-compat",u$="@firebase/analytics-compat",d$="@firebase/analytics",h$="@firebase/app-check-compat",f$="@firebase/app-check",m$="@firebase/auth",p$="@firebase/auth-compat",g$="@firebase/database",v$="@firebase/data-connect",x$="@firebase/database-compat",y$="@firebase/functions",w$="@firebase/functions-compat",b$="@firebase/installations",j$="@firebase/installations-compat",C$="@firebase/messaging",N$="@firebase/messaging-compat",_$="@firebase/performance",E$="@firebase/performance-compat",S$="@firebase/remote-config",k$="@firebase/remote-config-compat",P$="@firebase/storage",I$="@firebase/storage-compat",T$="@firebase/firestore",A$="@firebase/vertexai-preview",R$="@firebase/firestore-compat",D$="firebase",L$="10.14.1";/** 293 * @license 294 * Copyright 2019 Google LLC 295 * 296 * Licensed under the Apache License, Version 2.0 (the "License"); 297 * you may not use this file except in compliance with the License. 298 * You may obtain a copy of the License at 299 * 300 * http://www.apache.org/licenses/LICENSE-2.0 301 * 302 * Unless required by applicable law or agreed to in writing, software 303 * distributed under the License is distributed on an "AS IS" BASIS, 304 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 305 * See the License for the specific language governing permissions and 306 * limitations under the License. 307 */const D0="[DEFAULT]",M$={[R0]:"fire-core",[c$]:"fire-core-compat",[d$]:"fire-analytics",[u$]:"fire-analytics-compat",[f$]:"fire-app-check",[h$]:"fire-app-check-compat",[m$]:"fire-auth",[p$]:"fire-auth-compat",[g$]:"fire-rtdb",[v$]:"fire-data-connect",[x$]:"fire-rtdb-compat",[y$]:"fire-fn",[w$]:"fire-fn-compat",[b$]:"fire-iid",[j$]:"fire-iid-compat",[C$]:"fire-fcm",[N$]:"fire-fcm-compat",[_$]:"fire-perf",[E$]:"fire-perf-compat",[S$]:"fire-rc",[k$]:"fire-rc-compat",[P$]:"fire-g
307cs",[I$]:"fire-gcs-compat",[T$]:"fire-fst",[R$]:"fire-fst-compat",[A$]:"fire-vertex","fire-js":"fire-js",[D$]:"fire-js-all"};/** 308 * @license 309 * Copyright 2019 Google LLC 310 * 311 * Licensed under the Apache License, Version 2.0 (the "License"); 312 * you may not use this file except in compliance with the License. 313 * You may obtain a copy of the License at 314 * 315 * http://www.apache.org/licenses/LICENSE-2.0 316 * 317 * Unless required by applicable law or agreed to in writing, software 318 * distributed under the License is distributed on an "AS IS" BASIS, 319 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 320 * See the License for the specific language governing permissions and 321 * limitations under the License. 322 */const Ig=new Map,O$=new Map,L0=new Map;function Z_(t,e){try{t.container.addComponent(e)}catch(n){Ri.debug(`Component ${e.name} failed to register with FirebaseApp ${t.name}`,n)}}function za(t){const e=t.name;if(L0.has(e))return Ri.debug(`There were multiple attempts to register component ${e}.`),!1;L0.set(e,t);for(const n of Ig.values())Z_(n,t);for(const n of O$.values())Z_(n,t);return!0}function $f(t,e){const n=t.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),t.container.getProvider(e)}function wi(t){return t.settings!==void 0}/** 323 * @license 324 * Copyright 2019 Google LLC 325 * 326 * Licensed under the Apache License, Version 2.0 (the "License"); 327 * you may not use this file except in compliance with the License. 328 * You may obtain a copy of the License at 329 * 330 * http://www.apache.org/licenses/LICENSE-2.0 331 * 332 * Unless required by applicable law or agreed to in writing, software 333 * distributed under the License is distributed on an "AS IS" BASIS, 334 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 335 * See the License for the specific language governing permissions and 336 * limitations under the License. 337 */const F$={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invali
337d-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},Ta=new Ff("app","Firebase",F$);/** 338 * @license 339 * Copyright 2019 Google LLC 340 * 341 * Licensed under the Apache License, Version 2.0 (the "License"); 342 * you may not use this file except in compliance with the License. 343 * You may obtain a copy of the License at 344 * 345 * http://www.apache.org/licenses/LICENSE-2.0 346 * 347 * Unless required by applicable law or agreed to in writing, software 348 * distributed under the License is distributed on an "AS IS" BASIS, 349 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 350 * See the License for the specific language governing permissions and 351 * limitations under the License. 352 */class z${constructor(e,n,r){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},n),this._name=n.name,this._automaticDataCollectionEnabled=n.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new Ai("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw Ta.create("app-deleted",{appName:this._name})}}/** 353 * @license 354 * Copyright 2019 Google LLC 355 * 356 * Licensed under the Apache License, Version 2.0 (the "License"); 357 * you may not use this file except in compliance with the License. 358 * You may obtain a copy of the License at 359 * 360 * http://www.apache.org/licenses/LICENSE-2.0 361 * 362 * Unless required by applicable law or agreed to in writing, software 363 * distributed under the License is distributed on an "AS IS" BASIS, 364 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 365 * See the License for the specific language governing permissions and 366 * limitations under the License. 367 */const fc=L$;function nA(t,e={}){let n=t;typeof e!="object"&&(e={name:e});const r=Object.assign({name:D0,automaticDataCollectionEnabled:!1},e),s=r.name;if(typeof s!="string"||!s)throw Ta.create("bad-app-name",{appName:String(s)});if(n||(n=QT()),!n)throw Ta.create("no-options");const i=Ig.get(s);if(i){if(Pg(n,i.options)&&Pg(r,i.config))return i;throw Ta.create("duplicate-app",{appName:s})}const a=new Hz(s);for(const c of L0.values())a.addComponent(c);const l=new z$(n,r,a);return Ig.set(s,l),l}function Fv(t=D0){const e=Ig.get(t);if(!e&&t===D0&&QT())return nA();if(!e)throw Ta.create("no-app",{appName:t});return e}function Vs(t,e,n){var r;let s=(r=M$[t])!==null&&r!==void 0?r:t;n&&(s+=`-${n}`);const i=s.match(/\s|\//),a=e.match(/\s|\//);if(i||a){const l=[`Unable to register library "${s}" with version "${e}":`];i&&l.push(`library name "${s}" contains illegal characters (whitespace or "/")`),i&&a&&l.push("and"),a&&l.push(`version name "${e}" contains illegal characters (whitespace or "/")`),Ri.warn(l.join(" "));return}za(new Ai(`${s}-version`,()=>({library:s,version:e}),"VERSION"))}/** 368 * @license 369 * Copyright 2021 Google LLC 370 * 371 * Licensed under the Apache License, Version 2.0 (the "License"); 372 * you may not use this file except in compliance with the License. 373 * You may obtain a copy of the License at 374 * 375 * http://www.apache.org/licenses/LICENSE-2.0 376 * 377 * Unless required by applicable law or agreed to in writing, softw
377are 378 * distributed under the License is distributed on an "AS IS" BASIS, 379 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 380 * See the License for the specific language governing permissions and 381 * limitations under the License. 382 */const $$="firebase-heartbeat-database",V$=1,af="firebase-heartbeat-store";let Iy=null;function rA(){return Iy||(Iy=s$($$,V$,{upgrade:(t,e)=>{switch(e){case 0:try{t.createObjectStore(af)}catch(n){console.warn(n)}}}}).catch(t=>{throw Ta.create("idb-open",{originalErrorMessage:t.message})})),Iy}async function U$(t){try{const n=(await rA()).transaction(af),r=await n.objectStore(af).get(sA(t));return await n.done,r}catch(e){if(e instanceof Po)Ri.warn(e.message);else{const n=Ta.create("idb-get",{originalErrorMessage:e==null?void 0:e.message});Ri.warn(n.message)}}}async function K_(t,e){try{const r=(await rA()).transaction(af,"readwrite");await r.objectStore(af).put(e,sA(t)),await r.done}catch(n){if(n instanceof Po)Ri.warn(n.message);else{const r=Ta.create("idb-set",{originalErrorMessage:n==null?void 0:n.message});Ri.warn(r.message)}}}function sA(t){return`${t.name}!${t.options.appId}`}/** 383 * @license 384 * Copyright 2021 Google LLC 385 * 386 * Licensed under the Apache License, Version 2.0 (the "License"); 387 * you may not use this file except in compliance with the License. 388 * You may obtain a copy of the License at 389 * 390 * http://www.apache.org/licenses/LICENSE-2.0 391 * 392 * Unless required by applicable law or agreed to in writing, software 393 * distributed under the License is distributed on an "AS IS" BASIS, 394 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 395 * See the License for the specific language governing permissions and 396 * limitations under the License. 397 */const B$=1024,W$=30*24*60*60*1e3;class H${constructor(e){this.container=e,this._heartbeatsCache=null;const n=this.container.getProvider("app").getImmediate();this._storage=new G$(n),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r))}async triggerHeartbeat(){var e,n;try{const s=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),i=Y_();return((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,((n=this._heartbeatsCache)===null||n===void 0?void 0:n.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===i||this._heartbeatsCache.heartbeats.some(a=>a.date===i)?void 0:(this._heartbeatsCache.heartbeats.push({date:i,agent:s}),this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter(a=>{const l=new Date(a.date).valueOf();return Date.now()-l<=W$}),this._storage.overwrite(this._heartbeatsCache))}catch(r){Ri.warn(r)}}async getHeartbeatsHeader(){var e;try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";const n=Y_(),{heartbeatsToSend:r,unsentEntries:s}=q$(this._heartbeatsCache.heartbeats),i=kg(JSON.stringify({version:2,heartbeats:r}));return this._heartbeatsCache.lastSentHeartbeatDate=n,s.length>0?(this._heartbeatsCache.heartbeats=s,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),i}catch(n){return Ri.warn(n),""}}}function Y_(){return new Date().toISOString().substring(0,10)}function q$(t,e=B$){const n=[];let r=t.slice();for(const s of t){const i=n.find(a=>a.agent===s.agent);if(i){if(i.dates.push(s.date),Q_(n)>e){i.dates.pop();break}}else if(n.push({agent:s.agent,dates:[s.date]}),Q_(n)>e){n.pop();break}r=r.slice(1)}return{heartbeatsToSend:n,unsentEntries:r}}class G${constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return Rz()?Dz().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const n=await U$(this.app);return n!=null&&n.heartbeats?n:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){var n;if(await this._canUseIndexedDBPromise){const s=await this.read();return K_(this.app,{lastSentHeartbeatDate:(n=e.lastSentHeartbeatDate)!==null&&n!==void 0?n:s.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){var n;if(await this._canUseIndexedDBPromise){const s=await this.read();return K_(this.app,{lastSentHeartbeatDate:(n=e.lastSentHeartbeatDate)!==null&&n!==void 0?n:s.lastSentHeartbeatDate,heartbeats:[...s.heartbeats,...e.heartbeats]})}else return}}function Q_(t){return kg(JSON.stringify({version:2,heartbeats:t})).length}/** 398 * @license 399 * Copyright 2019 Google LLC 400 * 401 * Licensed under the Apache License, Version 2.0 (the "License");
402 * you may not use this file except in compliance with the License. 403 * You may obtain a copy of the License at 404 * 405 * http://www.apache.org/licenses/LICENSE-2.0 406 * 407 * Unless required by applicable law or agreed to in writing, software 408 * distributed under the License is distributed on an "AS IS" BASIS, 409 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 410 * See the License for the specific language governing permissions and 411 * limitations under the License. 412 */function Z$(t){za(new Ai("platform-logger",e=>new a$(e),"PRIVATE")),za(new Ai("heartbeat",e=>new H$(e),"PRIVATE")),Vs(R0,G_,t),Vs(R0,G_,"esm2017"),Vs("fire-js","")}Z$("");var Mr=function(){return Mr=Object.assign||function(e){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)&&(e[i]=n[i])}return e},Mr.apply(this,arguments)};function nd(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n}function oA(t,e,n){if(n||arguments.length===2)for(var r=0,s=e.length,i;r<s;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return t.concat(i||Array.prototype.slice.call(e))}function iA(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}const K$=iA,aA=new Ff("auth","Firebase",iA());/** 413 * @license 414 * Copyright 2020 Google LLC 415 * 416 * Licensed under the Apache License, Version 2.0 (the "License"); 417 * you may not use this file except in compliance with the License. 418 * You may obtain a copy of the License at 419 * 420 * http://www.apache.org/licenses/LICENSE-2.0 421 * 422 * Unless required by applicable law or agreed to in writing, software 423 * distributed under the License is distributed on an "AS IS" BASIS, 424 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 425 * See the License for the specific language governing permissions and 426 * limitations under the License. 427 */const Tg=new Hj("@firebase/auth");function Y$(t,...e){Tg.logLevel<=Nt.WARN&&Tg.warn(`Auth (${fc}): ${t}`,...e)}function Bp(t,...e){Tg.logLevel<=Nt.ERROR&&Tg.error(`Auth (${fc}): ${t}`,...e)}/** 428 * @license 429 * Copyright 2020 Google LLC 430 * 431 * Licensed under the Apache License, Version 2.0 (the "License"); 432 * you may not use this file except in compliance with the License. 433 * You may obtain a copy of the License at 434 * 435 * http://www.apache.org/licenses/LICENSE-2.0 436 * 437 * Unless required by applicable law or agreed to in writing, software 438 * distributed under the License is distributed on an "AS IS" BASIS, 439 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 440 * See the License for the specific language governing permissions and 441 * limitations under the License. 442 */function bo(t,...e){throw Gj(t,...e)}function Ko(t,...e){return Gj(t,...e)}function lA(t,e,n){const r=Object.assign(Object.assign({},K$()),{[e]:n});return new Ff("auth","Firebase",r).create(e,{appName:t.name})}function Aa(t){return lA(t,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function Gj(t,...e){if(typeof t!="string"){const n=e[0],r=[...e.slice(1)];return r[0]&&(r[0].appName=t.name),t._errorFactory.create(n,...r)}return aA.create(t,...e)}function rt(t,e,...n){if(!t)throw Gj(e,...n)}function bi(t){const e="INTERNAL ASSERTION FAILED: "+t;throw Bp(e),new Error(e)}function Di(t,e){t||bi(e)}/** 443 * @license 444 * Copyright 2020 Google LLC 445 * 446 * Licensed under the Apache License, Version 2.0 (the "License"); 447 * you may not use this file except in compliance with the License. 448 * You may obtain a copy of the License at 449 * 450 * http://www.apache.org/licenses/LICENSE-2.0 451 * 452 * Unless required by applicable law or agreed to in writing, softw
452are 453 * distributed under the License is distributed on an "AS IS" BASIS, 454 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 455 * See the License for the specific language governing permissions and 456 * limitations under the License. 457 */function M0(){var t;return typeof self<"u"&&((t=self.location)===null||t===void 0?void 0:t.href)||""}function Q$(){return X_()==="http:"||X_()==="https:"}function X_(){var t;return typeof self<"u"&&((t=self.location)===null||t===void 0?void 0:t.protocol)||null}/** 458 * @license 459 * Copyright 2020 Google LLC 460 * 461 * Licensed under the Apache License, Version 2.0 (the "License"); 462 * you may not use this file except in compliance with the License. 463 * You may obtain a copy of the License at 464 * 465 * http://www.apache.org/licenses/LICENSE-2.0 466 * 467 * Unless required by applicable law or agreed to in writing, software 468 * distributed under the License is distributed on an "AS IS" BASIS, 469 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 470 * See the License for the specific language governing permissions and 471 * limitations under the License. 472 */function X$(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(Q$()||Pz()||"connection"in navigator)?navigator.onLine:!0}function J$(){if(typeof navigator>"u")return null;const t=navigator;return t.languages&&t.languages[0]||t.language||null}/** 473 * @license 474 * Copyright 2020 Google LLC 475 * 476 * Licensed under the Apache License, Version 2.0 (the "License"); 477 * you may not use this file except in compliance with the License. 478 * You may obtain a copy of the License at 479 * 480 * http://www.apache.org/licenses/LICENSE-2.0 481 * 482 * Unless required by applicable law or agreed to in writing, software 483 * distributed under the License is distributed on an "AS IS" BASIS, 484 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 485 * See the License for the specific language governing permissions and 486 * limitations under the License. 487 */class Vf{constructor(e,n){this.shortDelay=e,this.longDelay=n,Di(n>e,"Short delay should be less than long delay!"),this.isMobile=Ez()||Iz()}get(){return X$()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}/** 488 * @license 489 * Copyright 2020 Google LLC 490 * 491 * Licensed under the Apache License, Version 2.0 (the "License"); 492 * you may not use this file except in compliance with the License. 493 * You may obtain a copy of the License at 494 * 495 * http://www.apache.org/licenses/LICENSE-2.0 496 * 497 * Unless required by applicable law or agreed to in writing, software 498 * distributed under the License is distributed on an "AS IS" BASIS, 499 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 500 * See the License for the specific language governing permissions and 501 * limitations under the License. 502 */function Zj(t,e){Di(t.emulator,"Emulator should always be set here");const{url:n}=t.emulator;return e?`${n}${e.startsWith("/")?e.slice(1):e}`:n}/** 503 * @license 504 * Copyright 2020 Google LLC 505 * 506 * Licensed under the Apache License, Version 2.0 (the "License"); 507 * you may not use this file except in compliance with the License. 508 * You may obtain a copy of the License at 509 * 510 * http://www.apache.org/licenses/LICENSE-2.0 511 * 512 * Unless required by applicable law or agreed to in writing, software 513 * distributed under the License is distributed on an "AS IS" BASIS, 514 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 515 * See the License for the specific language governing permissions and 516 * limitations under the License. 517 */class cA{static initialize(e,n,r){this.fetchImpl=e,n&&(this.headersImpl=n),r&&(this.responseImpl=r)}static fetch(){if(this.fetchImpl)return this.fetchImpl;if(typeof self<"u"&&"fetch"in self)return self.fetch;if(typeof globalThis<"u"&&globalThis.fetch)return globalThis.fetch;if(typeof fetch<"u")return fetch;bi("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static headers(){if(this.headersImpl)return this.headersImpl;if(typeof self<"u"&&"Headers"in self)return self.Headers;if(typeof globalThis<"u"&&globalThis.Headers)return globalThis.Headers;if(typeof Headers<"u")return Headers;bi("Could not find Headers implementation, make sure you call FetchProvi
517der.initialize() with an appropriate polyfill")}static response(){if(this.responseImpl)return this.responseImpl;if(typeof self<"u"&&"Response"in self)return self.Response;if(typeof globalThis<"u"&&globalThis.Response)return globalThis.Response;if(typeof Response<"u")return Response;bi("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}/** 518 * @license 519 * Copyright 2020 Google LLC 520 * 521 * Licensed under the Apache License, Version 2.0 (the "License"); 522 * you may not use this file except in compliance with the License. 523 * You may obtain a copy of the License at 524 * 525 * http://www.apache.org/licenses/LICENSE-2.0 526 * 527 * Unless required by applicable law or agreed to in writing, software 528 * distributed under the License is distributed on an "AS IS" BASIS, 529 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 530 * See the License for the specific language governing permissions and 531 * limitations under the License. 532 */const eV={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"};/** 533 * @license 534 * Copyright 2020 Google LLC 535 * 536 * Licensed under the Apache License, Version 2.0 (the "License"); 537 * you may not use this file except in compliance with the License. 538 * You may obtain a copy of the License at 539 * 540 * http://www.apache.org/licenses/LICENSE-2.0 541 * 542 * Unless required by applicable law or agreed to in writing, software 543 * distributed under the License is distributed on an "AS IS" BASIS, 544 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 545 * See the License for the specific language governing permissions and 546 * limitations under the License. 547 */const tV=new Vf(3e4,6e4);function rl(t,e){return t.tenantId&&!e.tenantId?Object.assign(Object.assign({},e),{tenantId:t.tenantId}):e}async function Bi(t,e,n,r,s={}){return uA(t,s,async()=>{let i={},a={};r&&(e==="GET"?a=r:i={body:JSON.stringify(r)});const l=zf(Object.assign({key:t.config.apiKey},a)).slice(1),c=await t._getAdditionalHeaders();c["Content-Type"]="application/json",t.languageCode&&(c["X-Firebase-Locale"]=t.languageCode);const d=Object.assign({method:e,headers:c},i);return kz()||(d.referrerPolicy="no-referrer"),cA.fetch()(dA(t,t.config.apiHost,n,l),d)})}async function uA(t,e,n){t._canInitEmulator=!1;const r=Object.assign(Object.assign({},eV),e);try{const s=new rV(t),i=await Promise.race([n(),s.promise]);s.clearNetworkTimeout();const a=await i.json();if("needConfirmation"in a)throw Xm(t,"account-exists-with-different-credential",a);if(i.ok&&!("errorMessage"in a))return a;{const l=i.ok?a.errorMessage:a.error.message,[c,d]=l.split(" : ");if(c==="FEDERATED_USER_ID_ALREADY_LINKED")throw Xm(t,"credential-already-in-use",a);if(c==="EMAIL_EXISTS")throw Xm(t,"email-already-in-use",a);if(c==="USER_DISABLED")throw Xm(t,"user-disabled",a);const h=r[c]||c.toLowerCase().replace(/[_\s]+/g,"-");if(d)throw lA(t,h,d);bo(t,h)}}catch(s){if(s instanceof Po)throw s;
547bo(t,"network-request-failed",{message:String(s)})}}async function zv(t,e,n,r,s={}){const i=await Bi(t,e,n,r,s);return"mfaPendingCredential"in i&&bo(t,"multi-factor-auth-required",{_serverResponse:i}),i}function dA(t,e,n,r){const s=`${e}${n}?${r}`;return t.config.emulator?Zj(t.config,s):`${t.config.apiScheme}://${s}`}function nV(t){switch(t){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}class rV{constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((n,r)=>{this.timer=setTimeout(()=>r(Ko(this.auth,"network-request-failed")),tV.get())})}clearNetworkTimeout(){clearTimeout(this.timer)}}function Xm(t,e,n){const r={appName:t.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);const s=Ko(t,e,r);return s.customData._tokenResponse=n,s}function J_(t){return t!==void 0&&t.enterprise!==void 0}class sV{constructor(e){if(this.siteKey="",this.recaptchaEnforcementState=[],e.recaptchaKey===void 0)throw new Error("recaptchaKey undefined");this.siteKey=e.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=e.recaptchaEnforcementState}getProviderEnforcementState(e){if(!this.recaptchaEnforcementState||this.recaptchaEnforcementState.length===0)return null;for(const n of this.recaptchaEnforcementState)if(n.provider&&n.provider===e)return nV(n.enforcementState);return null}isProviderEnabled(e){return this.getProviderEnforcementState(e)==="ENFORCE"||this.getProviderEnforcementState(e)==="AUDIT"}}async function oV(t,e){return Bi(t,"GET","/v2/recaptchaConfig",rl(t,e))}/** 548 * @license 549 * Copyright 2020 Google LLC 550 * 551 * Licensed under the Apache License, Version 2.0 (the "License"); 552 * you may not use this file except in compliance with the License. 553 * You may obtain a copy of the License at 554 * 555 * http://www.apache.org/licenses/LICENSE-2.0 556 * 557 * Unless required by applicable law or agreed to in writing, software 558 * distributed under the License is distributed on an "AS IS" BASIS, 559 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 560 * See the License for the specific language governing permissions and 561 * limitations under the License. 562 */async function iV(t,e){return Bi(t,"POST","/v1/accounts:delete",e)}async function hA(t,e){return Bi(t,"POST","/v1/accounts:lookup",e)}/** 563 * @license 564 * Copyright 2020 Google LLC 565 * 566 * Licensed under the Apache License, Version 2.0 (the "License"); 567 * you may not use this file except in compliance with the License. 568 * You may obtain a copy of the License at 569 * 570 * http://www.apache.org/licenses/LICENSE-2.0 571 * 572 * Unless required by applicable law or agreed to in writing, software 573 * distributed under the License is distributed on an "AS IS" BASIS, 574 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 575 * See the License for the specific language governing permissions and 576 * limitations under the License. 577 */function Ih(t){if(t)try{const e=new Date(Number(t));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function aV(t,e=!1){const n=tn(t),r=await n.getIdToken(e),s=Kj(r);rt(s&&s.exp&&s.auth_time&&s.iat,n.auth,"internal-error");const i=typeof s.firebase=="object"?s.firebase:void 0,a=i==null?void 0:i.sign_in_provider;return{claims:s,token:r,authTime:Ih(Ty(s.auth_time)),issuedAtTime:Ih(Ty(s.iat)),expirationTime:Ih(Ty(s.exp)),signInProvider:a||null,signInSecondFactor:(i==null?void 0:i.sign_in_second_factor)||null}}function Ty(t){return Number(t)*1e3}function Kj(t){const[e,n,r]=t.split(".");if(e===void 0||n===void 0||r===void 0)return Bp("JWT malformed, contained fewer than 3 sections"),null;try{const s=KT(n);return s?JSON.parse(s):(Bp("Failed to decode base64 JWT payload"),null)}catch(s){return Bp("Caught error parsing JWT payload as JSON",s==null?void 0:s.toString()),null}}function eE(t){const e=Kj(t);return rt(e,"internal-error"),rt(typeof e.exp<"u","internal-error"),rt(typeof e.iat<"u","internal-error"),Number(e.exp)-Number(e.iat)}/** 578 * @license 579 * Copyright 2020 Google LLC 580 * 581 * Licensed under the Apache License, Version 2.0 (the "License");
582 * you may not use this file except in compliance with the License. 583 * You may obtain a copy of the License at 584 * 585 * http://www.apache.org/licenses/LICENSE-2.0 586 * 587 * Unless required by applicable law or agreed to in writing, software 588 * distributed under the License is distributed on an "AS IS" BASIS, 589 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 590 * See the License for the specific language governing permissions and 591 * limitations under the License. 592 */async function lf(t,e,n=!1){if(n)return e;try{return await e}catch(r){throw r instanceof Po&&lV(r)&&t.auth.currentUser===t&&await t.auth.signOut(),r}}function lV({code:t}){return t==="auth/user-disabled"||t==="auth/user-token-expired"}/** 593 * @license 594 * Copyright 2020 Google LLC 595 * 596 * Licensed under the Apache License, Version 2.0 (the "License"); 597 * you may not use this file except in compliance with the License. 598 * You may obtain a copy of the License at 599 * 600 * http://www.apache.org/licenses/LICENSE-2.0 601 * 602 * Unless required by applicable law or agreed to in writing, software 603 * distributed under the License is distributed on an "AS IS" BASIS, 604 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 605 * See the License for the specific language governing permissions and 606 * limitations under the License. 607 */class cV{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,this.timerId!==null&&clearTimeout(this.timerId))}getInterval(e){var n;if(e){const r=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),r}else{this.errorBackoff=3e4;const s=((n=this.user.stsTokenManager.expirationTime)!==null&&n!==void 0?n:0)-Date.now()-3e5;return Math.max(0,s)}}schedule(e=!1){if(!this.isRunning)return;const n=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},n)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){(e==null?void 0:e.code)==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}/** 608 * @license 609 * Copyright 2020 Google LLC 610 * 611 * Licensed under the Apache License, Version 2.0 (the "License"); 612 * you may not use this file except in compliance with the License. 613 * You may obtain a copy of the License at 614 * 615 * http://www.apache.org/licenses/LICENSE-2.0 616 * 617 * Unless required by applicable law or agreed to in writing, software 618 * distributed under the License is distributed on an "AS IS" BASIS, 619 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 620 * See the License for the specific language governing permissions and 621 * limitations under the License. 622 */class O0{constructor(e,n){this.createdAt=e,this.lastLoginAt=n,this._initializeTime()}_initializeTime(){this.lastSignInTime=Ih(this.lastLoginAt),this.creationTime=Ih(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}/** 623 * @license 624 * Copyright 2019 Google LLC 625 * 626 * Licensed under the Apache License, Version 2.0 (the "License"); 627 * you may not use this file except in compliance with the License. 628 * You may obtain a copy of the License at 629 * 630 * http://www.apache.org/licenses/LICENSE-2.0 631 * 632 * Unless required by applicable law or agreed to in writing, software 633 * distributed under the License is distributed on an "AS IS" BASIS, 634 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 635 * See the License for the specific language governing permissions and 636 * limitations under the License. 637 */async function Ag(t){var e;const n=t.auth,r=await t.getIdToken(),s=await lf(t,hA(n,{idToken:r}));rt(s==null?void 0:s.users.length,n,"internal-error");const i=s.users[0];t._notifyReloadListener(i);const a=!((e=i.providerUserInfo)===null||e===void 0)&&e.length?fA(i.providerUserInfo):[],l=dV(t.providerData,a),c=t.isAnonymous,d=!(t.email&&i.passwordHash)&&!(l!=null&&l.length),h=c?d:!1,f={uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:l,metadata:new O0(i.createdAt,i.lastLoginAt),isAnonymous:h};Object.assign(t,f)}async function uV(t){const e=tn(t);await Ag(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function dV(t,e){return[...t.filter(r=>!e.some(s=>s.providerId===r.providerId)),...e]}function fA(t){return t.map(e=>{var{providerId:n}=e,r=nd(e,["providerId"]);
637return{providerId:n,uid:r.rawId||"",displayName:r.displayName||null,email:r.email||null,phoneNumber:r.phoneNumber||null,photoURL:r.photoUrl||null}})}/** 638 * @license 639 * Copyright 2020 Google LLC 640 * 641 * Licensed under the Apache License, Version 2.0 (the "License"); 642 * you may not use this file except in compliance with the License. 643 * You may obtain a copy of the License at 644 * 645 * http://www.apache.org/licenses/LICENSE-2.0 646 * 647 * Unless required by applicable law or agreed to in writing, software 648 * distributed under the License is distributed on an "AS IS" BASIS, 649 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 650 * See the License for the specific language governing permissions and 651 * limitations under the License. 652 */async function hV(t,e){const n=await uA(t,{},async()=>{const r=zf({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:s,apiKey:i}=t.config,a=dA(t,s,"/v1/token",`key=${i}`),l=await t._getAdditionalHeaders();return l["Content-Type"]="application/x-www-form-urlencoded",cA.fetch()(a,{method:"POST",headers:l,body:r})});return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}async function fV(t,e){return Bi(t,"POST","/v2/accounts:revokeToken",rl(t,e))}/** 653 * @license 654 * Copyright 2020 Google LLC 655 * 656 * Licensed under the Apache License, Version 2.0 (the "License"); 657 * you may not use this file except in compliance with the License. 658 * You may obtain a copy of the License at 659 * 660 * http://www.apache.org/licenses/LICENSE-2.0 661 * 662 * Unless required by applicable law or agreed to in writing, software 663 * distributed under the License is distributed on an "AS IS" BASIS, 664 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 665 * See the License for the specific language governing permissions and 666 * limitations under the License. 667 */class gu{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){rt(e.idToken,"internal-error"),rt(typeof e.idToken<"u","internal-error"),rt(typeof e.refreshToken<"u","internal-error");const n="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):eE(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,n)}updateFromIdToken(e){rt(e.length!==0,"internal-error");const n=eE(e);this.updateTokensAndExpiration(e,null,n)}async getToken(e,n=!1){return!n&&this.accessToken&&!this.isExpired?this.accessToken:(rt(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null)}clearRefreshToken(){this.refreshToken=null}async refresh(e,n){const{accessToken:r,refreshToken:s,expiresIn:i}=await hV(e,n);this.updateTokensAndExpiration(r,s,Number(i))}updateTokensAndExpiration(e,n,r){this.refreshToken=n||null,this.accessToken=e||null,this.expirationTime=Date.now()+r*1e3}static fromJSON(e,n){const{refreshToken:r,accessToken:s,expirationTime:i}=n,a=new gu;return r&&(rt(typeof r=="string","internal-error",{appName:e}),a.refreshToken=r),s&&(rt(typeof s=="string","internal-error",{appName:e}),a.accessToken=s),i&&(rt(typeof i=="number","internal-error",{appName:e}),a.expirationTime=i),a}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new gu,this.toJSON())}_performRefresh(){return bi("not implemented")}}/** 668 * @license 669 * Copyright 2020 Google LLC 670 * 671 * Licensed under the Apache License, Version 2.0 (the "License"); 672 * you may not use this file except in compliance with the License. 673 * You may obtain a copy of the License at 674 * 675 * http://www.apache.org/licenses/LICENSE-2.0 676 * 677 * Unless required by applicable law or agreed to in writing, software 678 * distributed under the License is distributed on an "AS IS" BASIS, 679 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 680 * See the License for the specific language governing permissions and 681 * limitations under the License. 682 */function Qi(t,e){rt(typeof t=="string"||typeof t>"u","internal-error",{appName:e})}class ji{constructor(e){var{uid:n,auth:r,stsTokenManager:s}=e,i=nd(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new cV(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=n,this.auth=r,this.stsTokenManager=s,this.accessToken=s.accessToken,this.displayName=i.displayName||null,this.email=i.email||null,this.emailVerified=i.emailVerified||!1,this.phoneNumber=i.phoneNumber||null,this.photoURL=i.photoURL||null,this.isAnonymous=i.isAnonymous||!1,this.tenantId=i.tenantId||null,this.providerData=i.providerData?[...i.providerData]:[],this.metadata=new O0(i.createdAt||void 0,i.lastLoginAt||void 0)}async getIdToken(e){const n=await lf(this,this.stsTokenManager.getToken(this.auth,e));return rt(n,this.auth,"internal-error"),this.accessToken!==n&&(this.accessToken=n,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),n}getIdTokenResult(e){return aV(this,e)}reload(){return uV(this)}_assign(e){this!==e&&(rt(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.ph
682otoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(n=>Object.assign({},n)),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const n=new ji(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}));return n.metadata._copy(this.metadata),n}_onReload(e){rt(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,n=!1){let r=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),r=!0),n&&await Ag(this),await this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(wi(this.auth.app))return Promise.reject(Aa(this.auth));const e=await this.getIdToken();return await lf(this,iV(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return Object.assign(Object.assign({uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>Object.assign({},e)),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,n){var r,s,i,a,l,c,d,h;const f=(r=n.displayName)!==null&&r!==void 0?r:void 0,p=(s=n.email)!==null&&s!==void 0?s:void 0,g=(i=n.phoneNumber)!==null&&i!==void 0?i:void 0,v=(a=n.photoURL)!==null&&a!==void 0?a:void 0,x=(l=n.tenantId)!==null&&l!==void 0?l:void 0,y=(c=n._redirectEventId)!==null&&c!==void 0?c:void 0,b=(d=n.createdAt)!==null&&d!==void 0?d:void 0,w=(h=n.lastLoginAt)!==null&&h!==void 0?h:void 0,{uid:j,emailVerified:E,isAnonymous:P,providerData:A,stsTokenManager:N}=n;rt(j&&N,e,"internal-error");const _=gu.fromJSON(this.name,N);rt(typeof j=="string",e,"internal-error"),Qi(f,e.name),Qi(p,e.name),rt(typeof E=="boolean",e,"internal-error"),rt(typeof P=="boolean",e,"internal-error"),Qi(g,e.name),Qi(v,e.name),Qi(x,e.name),Qi(y,e.name),Qi(b,e.name),Qi(w,e.name);const k=new ji({uid:j,auth:e,email:p,emailVerified:E,displayName:f,isAnonymous:P,photoURL:v,phoneNumber:g,tenantId:x,stsTokenManager:_,createdAt:b,lastLoginAt:w});return A&&Array.isArray(A)&&(k.providerData=A.map(L=>Object.assign({},L))),y&&(k._redirectEventId=y),k}static async _fromIdTokenResponse(e,n,r=!1){const s=new gu;s.updateFromServerResponse(n);const i=new ji({uid:n.localId,auth:e,stsTokenManager:s,isAnonymous:r});return await Ag(i),i}static async _fromGetAccountInfoResponse(e,n,r){const s=n.users[0];rt(s.localId!==void 0,"internal-error");const i=s.providerUserInfo!==void 0?fA(s.providerUserInfo):[],a=!(s.email&&s.passwordHash)&&!(i!=null&&i.length),l=new gu;l.updateFromIdToken(r);const c=new ji({uid:s.localId,auth:e,stsTokenManager:l,isAnonymous:a}),d={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:i,metadata:new O0(s.createdAt,s.lastLoginAt),isAnonymous:!(s.email&&s.passwordHash)&&!(i!=null&&i.length)};return Object.assign(c,d),c}}/** 683 * @license 684 * Copyright 2020 Google LLC 685 * 686 * Licensed under the Apache License, Version 2.0 (the "License"); 687 * you may not use this file except in compliance with the License. 688 * You may obtain a copy of the License at 689 * 690 * http://www.apache.org/licenses/LICENSE-2.0 691 * 692 * Unless required by applicable law or agreed to in writing, softw
692are 693 * distributed under the License is distributed on an "AS IS" BASIS, 694 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 695 * See the License for the specific language governing permissions and 696 * limitations under the License. 697 */const tE=new Map;function Ci(t){Di(t instanceof Function,"Expected a class definition");let e=tE.get(t);return e?(Di(e instanceof t,"Instance stored in cache mismatched with class"),e):(e=new t,tE.set(t,e),e)}/** 698 * @license 699 * Copyright 2019 Google LLC 700 * 701 * Licensed under the Apache License, Version 2.0 (the "License"); 702 * you may not use this file except in compliance with the License. 703 * You may obtain a copy of the License at 704 * 705 * http://www.apache.org/licenses/LICENSE-2.0 706 * 707 * Unless required by applicable law or agreed to in writing, software 708 * distributed under the License is distributed on an "AS IS" BASIS, 709 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 710 * See the License for the specific language governing permissions and 711 * limitations under the License. 712 */class mA{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,n){this.storage[e]=n}async _get(e){const n=this.storage[e];return n===void 0?null:n}async _remove(e){delete this.storage[e]}_addListener(e,n){}_removeListener(e,n){}}mA.type="NONE";const nE=mA;/** 713 * @license 714 * Copyright 2019 Google LLC 715 * 716 * Licensed under the Apache License, Version 2.0 (the "License"); 717 * you may not use this file except in compliance with the License. 718 * You may obtain a copy of the License at 719 * 720 * http://www.apache.org/licenses/LICENSE-2.0 721 * 722 * Unless required by applicable law or agreed to in writing, software 723 * distributed under the License is distributed on an "AS IS" BASIS, 724 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 725 * See the License for the specific language governing permissions and 726 * limitations under the License. 727 */function Wp(t,e,n){return`firebase:${t}:${e}:${n}`}class vu{constructor(e,n,r){this.persistence=e,this.auth=n,this.userKey=r;const{config:s,name:i}=this.auth;this.fullUserKey=Wp(this.userKey,s.apiKey,i),this.fullPersistenceKey=Wp("persistence",s.apiKey,i),this.boundEventHandler=n._onStorageEvent.bind(n),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){const e=await this.persistence._get(this.fullUserKey);return e?ji._fromJSON(this.auth,e):null}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;const n=await this.getCurrentUser();if(await this.removeCurrentUser(),this.persistence=e,n)return this.setCurrentUser(n)}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,n,r="authUser"){if(!n.length)return new vu(Ci(nE),e,r);const s=(await Promise.all(n.map(async d=>{if(await d._isAvailable())return d}))).filter(d=>d);let i=s[0]||Ci(nE);const a=Wp(r,e.config.apiKey,e.name);let l=null;for(const d of n)try{const h=await d._get(a);if(h){const f=ji._fromJSON(e,h);d!==i&&(l=f),i=d;break}}catch{}const c=s.filter(d=>d._shouldAllowMigration);return!i._shouldAllowMigration||!c.length?new vu(i,e,r):(i=c[0],l&&await i._set(a,l.toJSON()),await Promise.all(n.map(async d=>{if(d!==i)try{await d._remove(a)}catch{}})),new vu(i,e,r))}}/** 728 * @license 729 * Copyright 2020 Google LLC 730 * 731 * Licensed under the Apache License, Version 2.0 (the "License"); 732 * you may not use this file except in compliance with the License. 733 * You may obtain a copy of the License at 734 * 735 * http://www.apache.org/licenses/LICENSE-2.0 736 * 737 * Unless required by applicable law or agreed to in writing, software 738 * distributed under the License is distributed on an "AS IS" BASIS, 739 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 740 * See the License for the specific language governing permissions and 741 * limitations under the License. 742 */function rE(t){const e=t.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(xA(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(pA(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(wA(e))return"Blackberry";if(bA(e))return"Webos";if(gA(e))return"Safari";if((e.includes("chrome/")||vA(e))&&!e.includes("edge/"))return"Chrome";if(yA(e))return"Android";{const n=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,r=t.match(n);if((r==null?void 0:r.length)===2)return r[1]}return"Other"}function pA(t=Vr()){return/firefox\//i.test(t)}function gA(t=Vr()){const e=t.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function vA(t=Vr()){return/crios\//i.test(t)}
742function xA(t=Vr()){return/iemobile/i.test(t)}function yA(t=Vr()){return/android/i.test(t)}function wA(t=Vr()){return/blackberry/i.test(t)}function bA(t=Vr()){return/webos/i.test(t)}function Yj(t=Vr()){return/iphone|ipad|ipod/i.test(t)||/macintosh/i.test(t)&&/mobile/i.test(t)}function mV(t=Vr()){var e;return Yj(t)&&!!(!((e=window.navigator)===null||e===void 0)&&e.standalone)}function pV(){return Tz()&&document.documentMode===10}function jA(t=Vr()){return Yj(t)||yA(t)||bA(t)||wA(t)||/windows phone/i.test(t)||xA(t)}/** 743 * @license 744 * Copyright 2020 Google LLC 745 * 746 * Licensed under the Apache License, Version 2.0 (the "License"); 747 * you may not use this file except in compliance with the License. 748 * You may obtain a copy of the License at 749 * 750 * http://www.apache.org/licenses/LICENSE-2.0 751 * 752 * Unless required by applicable law or agreed to in writing, software 753 * distributed under the License is distributed on an "AS IS" BASIS, 754 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 755 * See the License for the specific language governing permissions and 756 * limitations under the License. 757 */function CA(t,e=[]){let n;switch(t){case"Browser":n=rE(Vr());break;case"Worker":n=`${rE(Vr())}-${t}`;break;default:n=t}const r=e.length?e.join(","):"FirebaseCore-web";return`${n}/JsCore/${fc}/${r}`}/** 758 * @license 759 * Copyright 2022 Google LLC 760 * 761 * Licensed under the Apache License, Version 2.0 (the "License"); 762 * you may not use this file except in compliance with the License. 763 * You may obtain a copy of the License at 764 * 765 * http://www.apache.org/licenses/LICENSE-2.0 766 * 767 * Unless required by applicable law or agreed to in writing, software 768 * distributed under the License is distributed on an "AS IS" BASIS, 769 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 770 * See the License for the specific language governing permissions and 771 * limitations under the License. 772 */class gV{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,n){const r=i=>new Promise((a,l)=>{try{const c=e(i);a(c)}catch(c){l(c)}});r.onAbort=n,this.queue.push(r);const s=this.queue.length-1;return()=>{this.queue[s]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const n=[];try{for(const r of this.queue)await r(e),r.onAbort&&n.push(r.onAbort)}catch(r){n.reverse();for(const s of n)try{s()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:r==null?void 0:r.message})}}}/** 773 * @license 774 * Copyright 2023 Google LLC 775 * 776 * Licensed under the Apache License, Version 2.0 (the "License"); 777 * you may not use this file except in compliance with the License. 778 * You may obtain a copy of the License at 779 * 780 * http://www.apache.org/licenses/LICENSE-2.0 781 * 782 * Unless required by applicable law or agreed to in writing, software 783 * distributed under the License is distributed on an "AS IS" BASIS, 784 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 785 * See the License for the specific language governing permissions and 786 * limitations under the License. 787 */async function vV(t,e={}){return Bi(t,"GET","/v2/passwordPolicy",rl(t,e))}/** 788 * @license 789 * Copyright 2023 Google LLC 790 * 791 * Licensed under the Apache License, Version 2.0 (the "License"); 792 * you may not use this file except in compliance with the License. 793 * You may obtain a copy of the License at 794 * 795 * http://www.apache.org/licenses/LICENSE-2.0 796 * 797 * Unless required by applicable law or agreed to in writing, software 798 * distributed under the License is distributed on an "AS IS" BASIS, 799 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 800 * See the License for the specific language governing permissions and 801 * limitations under the License. 802 */const xV=6;class yV{constructor(e){var n,r,s,i;const a=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=(n=a.minPasswordLength)!==null&&n!==void 0?n:xV,a.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=a.maxPasswordLength),a.containsLowercaseCharacter!==void 0&&(this.customStrengthOptions.containsLowercaseLetter=a.containsLowercaseCharacter),a.containsUppercaseCharacter!==void 0&&(this.customStrengthOptions.containsUppercaseLetter=a.containsUppercaseCharacter),a.containsNumericCharacter!==void 0&&(this.customStrengthOptions.containsNumericCharacter=a.containsNumericCharacter),a.containsNonAlphanumericCharacter!==void 0&&(this.customStrengthOptions.containsNonAlphanumericCharacter=a.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,this.enforcementState==="ENFORCEMENT_STATE_UNSPECIFIED"&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=(s=(r=e.allowedNonAlphanumericCharacters)===null||r===void 0?void 0:r.join(""))!==null&&s!==void 0?s:"",this.forceUpgradeOnSignin=(i=e.forceUpgradeOnSignin)!==null&&i!==void 0?i:!1,this.schemaVersion=e.schemaVersion}validatePassword(e){var n,r,s,i,a,l;const c={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,c),this.validatePasswordCharacterOptions(e,c),c.isValid&&
802(c.isValid=(n=c.meetsMinPasswordLength)!==null&&n!==void 0?n:!0),c.isValid&&(c.isValid=(r=c.meetsMaxPasswordLength)!==null&&r!==void 0?r:!0),c.isValid&&(c.isValid=(s=c.containsLowercaseLetter)!==null&&s!==void 0?s:!0),c.isValid&&(c.isValid=(i=c.containsUppercaseLetter)!==null&&i!==void 0?i:!0),c.isValid&&(c.isValid=(a=c.containsNumericCharacter)!==null&&a!==void 0?a:!0),c.isValid&&(c.isValid=(l=c.containsNonAlphanumericCharacter)!==null&&l!==void 0?l:!0),c}validatePasswordLengthOptions(e,n){const r=this.customStrengthOptions.minPasswordLength,s=this.customStrengthOptions.maxPasswordLength;r&&(n.meetsMinPasswordLength=e.length>=r),s&&(n.meetsMaxPasswordLength=e.length<=s)}validatePasswordCharacterOptions(e,n){this.updatePasswordCharacterOptionsStatuses(n,!1,!1,!1,!1);let r;for(let s=0;s<e.length;s++)r=e.charAt(s),this.updatePasswordCharacterOptionsStatuses(n,r>="a"&&r<="z",r>="A"&&r<="Z",r>="0"&&r<="9",this.allowedNonAlphanumericCharacters.includes(r))}updatePasswordCharacterOptionsStatuses(e,n,r,s,i){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=n)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=r)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=s)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=i))}}/** 803 * @license 804 * Copyright 2020 Google LLC 805 * 806 * Licensed under the Apache License, Version 2.0 (the "License"); 807 * you may not use this file except in compliance with the License. 808 * You may obtain a copy of the License at 809 * 810 * http://www.apache.org/licenses/LICENSE-2.0 811 * 812 * Unless required by applicable law or agreed to in writing, software 813 * distributed under the License is distributed on an "AS IS" BASIS, 814 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 815 * See the License for the specific language governing permissions and 816 * limitations under the License. 817 */class wV{constructor(e,n,r,s){this.app=e,this.heartbeatServiceProvider=n,this.appCheckServiceProvider=r,this.config=s,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new sE(this),this.idTokenSubscription=new sE(this),this.beforeStateQueue=new gV(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=aA,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=s.sdkClientVersion}_initializeWithPersistence(e,n){return n&&(this._popupRedirectResolver=Ci(n)),this._initializationPromise=this.queue(async()=>{var r,s;if(!this._deleted&&(this.persistenceManager=await vu.create(this,e),!this._deleted)){if(!((r=this._popupRedirectResolver)===null||r===void 0)&&r._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(n),this.lastNotifiedUid=((s=this.currentUser)===null||s===void 0?void 0:s.uid)||null,!this._deleted&&(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const e=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!e)){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUserFromIdToken(e){try{const n=await hA(this,{idToken:e}),r=await ji._fromGetAccountInfoResponse(this,n,e);await this.directlySetCurrentUser(r)}catch(n){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",n),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){var n;if(wi(this.app)){const a=this.app.settings.authIdToken;return a?new Promise(l=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(a).then(l,l))}):this.directlySetCurrentUser(null)}const r=await this.assertedPersistence.getCurrentUser();let s=r,i=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const a=(n=this.redirectUser)===null||n===void 0?void 0:n._redirectEventId,l=s==null?void 0:s._redirectEventId,c=await this.tryRedirectSignIn(e);(!a||a===l)&&(c!=null&&c.user)&&(s=c.user,i=!0)}if(!s)return this.directlySetCurrentUser(null);
817if(!s._redirectEventId){if(i)try{await this.beforeStateQueue.runMiddleware(s)}catch(a){s=r,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(a))}return s?this.reloadAndSetCurrentUserOrClear(s):this.directlySetCurrentUser(null)}return rt(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===s._redirectEventId?this.directlySetCurrentUser(s):this.reloadAndSetCurrentUserOrClear(s)}async tryRedirectSignIn(e){let n=null;try{n=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return n}async reloadAndSetCurrentUserOrClear(e){try{await Ag(e)}catch(n){if((n==null?void 0:n.code)!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=J$()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(wi(this.app))return Promise.reject(Aa(this));const n=e?tn(e):null;return n&&rt(n.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(n&&n._clone(this))}async _updateCurrentUser(e,n=!1){if(!this._deleted)return e&&rt(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),n||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return wi(this.app)?Promise.reject(Aa(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return wi(this.app)?Promise.reject(Aa(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(Ci(e))})}_getRecaptchaConfig(){return this.tenantId==null?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const n=this._getPasswordPolicyInternal();return n.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):n.validatePassword(e)}_getPasswordPolicyInternal(){return this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await vV(this),n=new yV(e);this.tenantId===null?this._projectPasswordPolicy=n:this._tenantPasswordPolicies[this.tenantId]=n}_getPersistence(){return this.assertedPersistence.persistence.type}_updateErrorMap(e){this._errorFactory=new Ff("auth","Firebase",e())}onAuthStateChanged(e,n,r){return this.registerStateListener(this.authStateSubscription,e,n,r)}beforeAuthStateChanged(e,n){return this.beforeStateQueue.pushCallback(e,n)}onIdTokenChanged(e,n,r){return this.registerStateListener(this.idTokenSubscription,e,n,r)}authStateReady(){return new Promise((e,n)=>{if(this.currentUser)e();else{const r=this.onAuthStateChanged(()=>{r(),e()},n)}})}async revokeAccessToken(e){if(this.currentUser){const n=await this.currentUser.getIdToken(),r={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:n};this.tenantId!=null&&(r.tenantId=this.tenantId),await fV(this,r)}}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:(e=this._currentUser)===null||e===void 0?void 0:e.toJSON()}}async _setRedirectUser(e,n){const r=await this.getOrInitRedirectPersistenceManager(n);return e===null?r.removeCurrentUser():r.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const n=e&&Ci(e)||this._popupRedirectResolver;rt(n,this,"argument-error"),this.redirectPersistenceManager=await vu.create(this,[Ci(n._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){var n,r;return this._isInitialized&&await this.queue(async()=>{}),((n=this._currentUser)===null||n===void 0?void 0:n._redirectEventId)===e?this._currentUser:((r=this.redirectUser)===null||r===void 0?void 0:r._redirectEventId)===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var e,n;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const r=(n=(e=this.currentUser)===null||e===void 0?void 0:e.uid)!==null&&n!==void 0?n:null;this.lastNotifiedUid!==r&&(this.lastNotifiedUid=r,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,n,r,s){if(this._deleted)return()=>{};const i=typeof n=="function"?n:n.next.bind(n);let a=!1;const l=this._isInitialized?Promise.resolve():this._initializationPromise;if(rt(l,this,"internal-error"),l.then(()=>{a||i(this.currentUser)}),typeof n=="function"){const c=e.addObserver(n,r,s);return()=>{a=!0,c()}}else{const c=e.addObserver(n);return()=>{a=!0,c()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return rt(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=CA(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var e;const n={"X-Client-Version":this.clientVersion};this.app.options.appId&&(n["X-Firebase-gmpid"]=this.app.options.appId);const r=await((e=this.heartbeatServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getHeartbeatsHeader());r&&(n["X-Firebase-Client"]=r);const s=await this._getAppCheckToken();return s&&(n["X-Firebase-AppCheck"]=s),n}async _getAppCheckToken(){var e;const n=await((e=this.appCheckServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getToken());return n!=null&&n.error&&Y$(`Error while retrieving App Check token: ${n.error}`),n==null?void 0:n.token}}function mc(t){return tn(t)}class sE{constructor(e){this.auth=e,this.observer=null,this.addObserver=zz(n=>this.observer=n)}get next(){return rt(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}/** 818 * @license 819 * Copyright 2020 Google LLC 820 * 821 * Licensed under the Apache License, Version 2.0 (the "License");
822 * you may not use this file except in compliance with the License. 823 * You may obtain a copy of the License at 824 * 825 * http://www.apache.org/licenses/LICENSE-2.0 826 * 827 * Unless required by applicable law or agreed to in writing, software 828 * distributed under the License is distributed on an "AS IS" BASIS, 829 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 830 * See the License for the specific language governing permissions and 831 * limitations under the License. 832 */let $v={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function bV(t){$v=t}function NA(t){return $v.loadJS(t)}function jV(){return $v.recaptchaEnterpriseScript}function CV(){return $v.gapiScript}function NV(t){return`__${t}${Math.floor(Math.random()*1e6)}`}const _V="recaptcha-enterprise",EV="NO_RECAPTCHA";class SV{constructor(e){this.type=_V,this.auth=mc(e)}async verify(e="verify",n=!1){async function r(i){if(!n){if(i.tenantId==null&&i._agentRecaptchaConfig!=null)return i._agentRecaptchaConfig.siteKey;if(i.tenantId!=null&&i._tenantRecaptchaConfigs[i.tenantId]!==void 0)return i._tenantRecaptchaConfigs[i.tenantId].siteKey}return new Promise(async(a,l)=>{oV(i,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(c=>{if(c.recaptchaKey===void 0)l(new Error("recaptcha Enterprise site key undefined"));else{const d=new sV(c);return i.tenantId==null?i._agentRecaptchaConfig=d:i._tenantRecaptchaConfigs[i.tenantId]=d,a(d.siteKey)}}).catch(c=>{l(c)})})}function s(i,a,l){const c=window.grecaptcha;J_(c)?c.enterprise.ready(()=>{c.enterprise.execute(i,{action:e}).then(d=>{a(d)}).catch(()=>{a(EV)})}):l(Error("No reCAPTCHA enterprise script loaded."))}return new Promise((i,a)=>{r(this.auth).then(l=>{if(!n&&J_(window.grecaptcha))s(l,i,a);else{if(typeof window>"u"){a(new Error("RecaptchaVerifier is only supported in browser"));return}let c=jV();c.length!==0&&(c+=l),NA(c).then(()=>{s(l,i,a)}).catch(d=>{a(d)})}}).catch(l=>{a(l)})})}}async function oE(t,e,n,r=!1){const s=new SV(t);let i;try{i=await s.verify(n)}catch{i=await s.verify(n,!0)}const a=Object.assign({},e);return r?Object.assign(a,{captchaResp:i}):Object.assign(a,{captchaResponse:i}),Object.assign(a,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(a,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),a}async function F0(t,e,n,r){var s;if(!((s=t._getRecaptchaConfig())===null||s===void 0)&&s.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")){const i=await oE(t,e,n,n==="getOobCode");return r(t,i)}else return r(t,e).catch(async i=>{if(i.code==="auth/missing-recaptcha-token"){console.log(`${n} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);const a=await oE(t,e,n,n==="getOobCode");return r(t,a)}else return Promise.reject(i)})}/** 833 * @license 834 * Copyright 2020 Google LLC 835 * 836 * Licensed under the Apache License, Version 2.0 (the "License"); 837 * you may not use this file except in compliance with the License. 838 * You may obtain a copy of the License at 839 * 840 * http://www.apache.org/licenses/LICENSE-2.0 841 * 842 * Unless required by applicable law or agreed to in writing, software 843 * distributed under the License is distributed on an "AS IS" BASIS, 844 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 845 * See the License for the specific language governing permissions and 846 * limitations under the License. 847 */function kV(t,e){const n=$f(t,"auth");if(n.isInitialized()){const s=n.getImmediate(),i=n.getOptions();if(Pg(i,e??{}))return s;bo(s,"already-initialized")}return n.initialize({options:e})}function PV(t,e){const n=(e==null?void 0:e.persistence)||[],r=(Array.isArray(n)?n:[n]).map(Ci);e!=null&&e.errorMap&&t._updateErrorMap(e.errorMap),t._initializeWithPersistence(r,e==null?void 0:e.popupRedirectResolver)}function IV(t,e,n){const r=mc(t);rt(r._canInitEmulator,r,"emulator-config-failed"),rt(/^https?:\/\//.test(e),r,"invali
847d-emulator-scheme");const s=!1,i=_A(e),{host:a,port:l}=TV(e),c=l===null?"":`:${l}`;r.config.emulator={url:`${i}//${a}${c}/`},r.settings.appVerificationDisabledForTesting=!0,r.emulatorConfig=Object.freeze({host:a,port:l,protocol:i.replace(":",""),options:Object.freeze({disableWarnings:s})}),AV()}function _A(t){const e=t.indexOf(":");return e<0?"":t.substr(0,e+1)}function TV(t){const e=_A(t),n=/(\/\/)?([^?#/]+)/.exec(t.substr(e.length));if(!n)return{host:"",port:null};const r=n[2].split("@").pop()||"",s=/^(\[[^\]]+\])(:|$)/.exec(r);if(s){const i=s[1];return{host:i,port:iE(r.substr(i.length+1))}}else{const[i,a]=r.split(":");return{host:i,port:iE(a)}}}function iE(t){if(!t)return null;const e=Number(t);return isNaN(e)?null:e}function AV(){function t(){const e=document.createElement("p"),n=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",n.position="fixed",n.width="100%",n.backgroundColor="#ffffff",n.border=".1em solid #000000",n.color="#b50000",n.bottom="0px",n.left="0px",n.margin="0px",n.zIndex="10000",n.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}typeof console<"u"&&typeof console.info=="function"&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials."),typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?window.addEventListener("DOMContentLoaded",t):t())}/** 848 * @license 849 * Copyright 2020 Google LLC 850 * 851 * Licensed under the Apache License, Version 2.0 (the "License"); 852 * you may not use this file except in compliance with the License. 853 * You may obtain a copy of the License at 854 * 855 * http://www.apache.org/licenses/LICENSE-2.0 856 * 857 * Unless required by applicable law or agreed to in writing, software 858 * distributed under the License is distributed on an "AS IS" BASIS, 859 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 860 * See the License for the specific language governing permissions and 861 * limitations under the License. 862 */class Qj{constructor(e,n){this.providerId=e,this.signInMethod=n}toJSON(){return bi("not implemented")}_getIdTokenResponse(e){return bi("not implemented")}_linkToIdToken(e,n){return bi("not implemented")}_getReauthenticationResolver(e){return bi("not implemented")}}async function RV(t,e){return Bi(t,"POST","/v1/accounts:signUp",e)}/** 863 * @license 864 * Copyright 2020 Google LLC 865 * 866 * Licensed under the Apache License, Version 2.0 (the "License"); 867 * you may not use this file except in compliance with the License. 868 * You may obtain a copy of the License at 869 * 870 * http://www.apache.org/licenses/LICENSE-2.0 871 * 872 * Unless required by applicable law or agreed to in writing, software 873 * distributed under the License is distributed on an "AS IS" BASIS, 874 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 875 * See the License for the specific language governing permissions and 876 * limitations under the License. 877 */async function DV(t,e){return zv(t,"POST","/v1/accounts:signInWithPassword",rl(t,e))}async function LV(t,e){return Bi(t,"POST","/v1/accounts:sendOobCode",rl(t,e))}async function MV(t,e){return LV(t,e)}/** 878 * @license 879 * Copyright 2020 Google LLC 880 * 881 * Licensed under the Apache License, Version 2.0 (the "License"); 882 * you may not use this file except in compliance with the License. 883 * You may obtain a copy of the License at 884 * 885 * http://www.apache.org/licenses/LICENSE-2.0 886 * 887 * Unless required by applicable law or agreed to in writing, software 888 * distributed under the License is distributed on an "AS IS" BASIS, 889 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 890 * See the License for the specific language governing permissions and 891 * limitations under the License. 892 */async function OV(t,e){return zv(t,"POST","/v1/accounts:signInWithEmailLink",rl(t,e))}async function FV(t,e){return zv(t,"POST","/v1/accounts:signInWithEmailLink",rl(t,e))}/** 893 * @license 894 * Copyright 2020 Google LLC 895 * 896 * Licensed under the Apache License, Version 2.0 (the "License");
897 * you may not use this file except in compliance with the License. 898 * You may obtain a copy of the License at 899 * 900 * http://www.apache.org/licenses/LICENSE-2.0 901 * 902 * Unless required by applicable law or agreed to in writing, software 903 * distributed under the License is distributed on an "AS IS" BASIS, 904 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 905 * See the License for the specific language governing permissions and 906 * limitations under the License. 907 */class cf extends Qj{constructor(e,n,r,s=null){super("password",r),this._email=e,this._password=n,this._tenantId=s}static _fromEmailAndPassword(e,n){return new cf(e,n,"password")}static _fromEmailAndCode(e,n,r=null){return new cf(e,n,"emailLink",r)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){const n=typeof e=="string"?JSON.parse(e):e;if(n!=null&&n.email&&(n!=null&&n.password)){if(n.signInMethod==="password")return this._fromEmailAndPassword(n.email,n.password);if(n.signInMethod==="emailLink")return this._fromEmailAndCode(n.email,n.password,n.tenantId)}return null}async _getIdTokenResponse(e){switch(this.signInMethod){case"password":const n={returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return F0(e,n,"signInWithPassword",DV);case"emailLink":return OV(e,{email:this._email,oobCode:this._password});default:bo(e,"internal-error")}}async _linkToIdToken(e,n){switch(this.signInMethod){case"password":const r={idToken:n,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return F0(e,r,"signUpPassword",RV);case"emailLink":return FV(e,{idToken:n,email:this._email,oobCode:this._password});default:bo(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}/** 908 * @license 909 * Copyright 2020 Google LLC 910 * 911 * Licensed under the Apache License, Version 2.0 (the "License"); 912 * you may not use this file except in compliance with the License. 913 * You may obtain a copy of the License at 914 * 915 * http://www.apache.org/licenses/LICENSE-2.0 916 * 917 * Unless required by applicable law or agreed to in writing, software 918 * distributed under the License is distributed on an "AS IS" BASIS, 919 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 920 * See the License for the specific language governing permissions and 921 * limitations under the License. 922 */async function xu(t,e){return zv(t,"POST","/v1/accounts:signInWithIdp",rl(t,e))}/** 923 * @license 924 * Copyright 2020 Google LLC 925 * 926 * Licensed under the Apache License, Version 2.0 (the "License"); 927 * you may not use this file except in compliance with the License. 928 * You may obtain a copy of the License at 929 * 930 * http://www.apache.org/licenses/LICENSE-2.0 931 * 932 * Unless required by applicable law or agreed to in writing, software 933 * distributed under the License is distributed on an "AS IS" BASIS, 934 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 935 * See the License for the specific language governing permissions and 936 * limitations under the License. 937 */const zV="http://localhost";class Kl extends Qj{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const n=new Kl(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(n.idToken=e.idToken),e.accessToken&&(n.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(n.nonce=e.nonce),e.pendingToken&&(n.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(n.accessToken=e.oauthToken,n.secret=e.oauthTokenSecret):bo("argument-error"),n}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,n
937once:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){const n=typeof e=="string"?JSON.parse(e):e,{providerId:r,signInMethod:s}=n,i=nd(n,["providerId","signInMethod"]);if(!r||!s)return null;const a=new Kl(r,s);return a.idToken=i.idToken||void 0,a.accessToken=i.accessToken||void 0,a.secret=i.secret,a.nonce=i.nonce,a.pendingToken=i.pendingToken||null,a}_getIdTokenResponse(e){const n=this.buildRequest();return xu(e,n)}_linkToIdToken(e,n){const r=this.buildRequest();return r.idToken=n,xu(e,r)}_getReauthenticationResolver(e){const n=this.buildRequest();return n.autoCreate=!1,xu(e,n)}buildRequest(){const e={requestUri:zV,returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{const n={};this.idToken&&(n.id_token=this.idToken),this.accessToken&&(n.access_token=this.accessToken),this.secret&&(n.oauth_token_secret=this.secret),n.providerId=this.providerId,this.nonce&&!this.pendingToken&&(n.nonce=this.nonce),e.postBody=zf(n)}return e}}/** 938 * @license 939 * Copyright 2020 Google LLC 940 * 941 * Licensed under the Apache License, Version 2.0 (the "License"); 942 * you may not use this file except in compliance with the License. 943 * You may obtain a copy of the License at 944 * 945 * http://www.apache.org/licenses/LICENSE-2.0 946 * 947 * Unless required by applicable law or agreed to in writing, software 948 * distributed under the License is distributed on an "AS IS" BASIS, 949 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 950 * See the License for the specific language governing permissions and 951 * limitations under the License. 952 */function $V(t){switch(t){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}function VV(t){const e=lh(ch(t)).link,n=e?lh(ch(e)).deep_link_id:null,r=lh(ch(t)).deep_link_id;return(r?lh(ch(r)).link:null)||r||n||e||t}class Xj{constructor(e){var n,r,s,i,a,l;const c=lh(ch(e)),d=(n=c.apiKey)!==null&&n!==void 0?n:null,h=(r=c.oobCode)!==null&&r!==void 0?r:null,f=$V((s=c.mode)!==null&&s!==void 0?s:null);rt(d&&h&&f,"argument-error"),this.apiKey=d,this.operation=f,this.code=h,this.continueUrl=(i=c.continueUrl)!==null&&i!==void 0?i:null,this.languageCode=(a=c.languageCode)!==null&&a!==void 0?a:null,this.tenantId=(l=c.tenantId)!==null&&l!==void 0?l:null}static parseLink(e){const n=VV(e);try{return new Xj(n)}catch{return null}}}/** 953 * @license 954 * Copyright 2020 Google LLC 955 * 956 * Licensed under the Apache License, Version 2.0 (the "License"); 957 * you may not use this file except in compliance with the License. 958 * You may obtain a copy of the License at 959 * 960 * http://www.apache.org/licenses/LICENSE-2.0 961 * 962 * Unless required by applicable law or agreed to in writing, software 963 * distributed under the License is distributed on an "AS IS" BASIS, 964 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 965 * See the License for the specific language governing permissions and 966 * limitations under the License. 967 */class rd{constructor(){this.providerId=rd.PROVIDER_ID}static credential(e,n){return cf._fromEmailAndPassword(e,n)}static credentialWithLink(e,n){const r=Xj.parseLink(n);return rt(r,"argument-error"),cf._fromEmailAndCode(e,r.code,r.tenantId)}}rd.PROVIDER_ID="password";rd.EMAIL_PASSWORD_SIGN_IN_METHOD="password";rd.EMAIL_LINK_SIGN_IN_METHOD="emailLink";/** 968 * @license 969 * Copyright 2020 Google LLC 970 * 971 * Licensed under the Apache License, Version 2.0 (the "License"); 972 * you may not use this file except in compliance with the License. 973 * You may obtain a copy of the License at 974 * 975 * http://www.apache.org/licenses/LICENSE-2.0 976 * 977 * Unless required by applicable law or agreed to in writing, software 978 * distributed under the License is distributed on an "AS IS" BASIS, 979 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 980 * See the License for the specific language governing permissions and 981 * limitations under the License. 982 */class EA{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}}/** 983 * @license 984 * Copyright 2019 Google LLC 985 * 986 * Licensed under the Apache License, Version 2.0 (the "License");
987 * you may not use this file except in compliance with the License. 988 * You may obtain a copy of the License at 989 * 990 * http://www.apache.org/licenses/LICENSE-2.0 991 * 992 * Unless required by applicable law or agreed to in writing, software 993 * distributed under the License is distributed on an "AS IS" BASIS, 994 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 995 * See the License for the specific language governing permissions and 996 * limitations under the License. 997 */class Uf extends EA{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}/** 998 * @license 999 * Copyright 2020 Google LLC 1000 * 1001 * Licensed under the Apache License, Version 2.0 (the "License"); 1002 * you may not use this file except in compliance with the License. 1003 * You may obtain a copy of the License at 1004 * 1005 * http://www.apache.org/licenses/LICENSE-2.0 1006 * 1007 * Unless required by applicable law or agreed to in writing, software 1008 * distributed under the License is distributed on an "AS IS" BASIS, 1009 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1010 * See the License for the specific language governing permissions and 1011 * limitations under the License. 1012 */class da extends Uf{constructor(){super("facebook.com")}static credential(e){return Kl._fromParams({providerId:da.PROVIDER_ID,signInMethod:da.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return da.credentialFromTaggedObject(e)}static credentialFromError(e){return da.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return da.credential(e.oauthAccessToken)}catch{return null}}}da.FACEBOOK_SIGN_IN_METHOD="facebook.com";da.PROVIDER_ID="facebook.com";/** 1013 * @license 1014 * Copyright 2020 Google LLC 1015 * 1016 * Licensed under the Apache License, Version 2.0 (the "License"); 1017 * you may not use this file except in compliance with the License. 1018 * You may obtain a copy of the License at 1019 * 1020 * http://www.apache.org/licenses/LICENSE-2.0 1021 * 1022 * Unless required by applicable law or agreed to in writing, software 1023 * distributed under the License is distributed on an "AS IS" BASIS, 1024 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1025 * See the License for the specific language governing permissions and 1026 * limitations under the License. 1027 */class ha extends Uf{constructor(){super("google.com"),this.addScope("profile")}static credential(e,n){return Kl._fromParams({providerId:ha.PROVIDER_ID,signInMethod:ha.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:n})}static credentialFromResult(e){return ha.credentialFromTaggedObject(e)}static credentialFromError(e){return ha.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:n,oauthAccessToken:r}=e;if(!n&&!r)return null;try{return ha.credential(n,r)}catch{return null}}}ha.GOOGLE_SIGN_IN_METHOD="google.com";ha.PROVIDER_ID="google.com";/** 1028 * @license 1029 * Copyright 2020 Google LLC 1030 * 1031 * Licensed under the Apache License, Version 2.0 (the "License"); 1032 * you may not use this file except in compliance with the License. 1033 * You may obtain a copy of the License at 1034 * 1035 * http://www.apache.org/licenses/LICENSE-2.0 1036 * 1037 * Unless required by applicable law or agreed to in writing, software 1038 * distributed under the License is distributed on an "AS IS" BASIS, 1039 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1040 * See the License for the specific language governing permissions and 1041 * limitations under the License. 1042 */class fa extends Uf{constructor(){super("github.com")}static credential(e){return Kl._fromParams({providerId:fa.PROVIDER_ID,signInMethod:fa.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return fa.credentialFromTaggedObject(e)}static credentialFromError(e){return fa.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return fa.credential(e.oauthAccessToken)}catch{return null}}}fa.GITHUB_SIGN_IN_METHOD="github.com";fa.PROVIDER_ID="github.com";/** 1043 * @license 1044 * Copyright 2020 Google LLC 1045 * 1046 * Licensed under the Apache License, Version 2.0 (the "License");
1047 * you may not use this file except in compliance with the License. 1048 * You may obtain a copy of the License at 1049 * 1050 * http://www.apache.org/licenses/LICENSE-2.0 1051 * 1052 * Unless required by applicable law or agreed to in writing, software 1053 * distributed under the License is distributed on an "AS IS" BASIS, 1054 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1055 * See the License for the specific language governing permissions and 1056 * limitations under the License. 1057 */class ma extends Uf{constructor(){super("twitter.com")}static credential(e,n){return Kl._fromParams({providerId:ma.PROVIDER_ID,signInMethod:ma.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:n})}static credentialFromResult(e){return ma.credentialFromTaggedObject(e)}static credentialFromError(e){return ma.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:n,oauthTokenSecret:r}=e;if(!n||!r)return null;try{return ma.credential(n,r)}catch{return null}}}ma.TWITTER_SIGN_IN_METHOD="twitter.com";ma.PROVIDER_ID="twitter.com";/** 1058 * @license 1059 * Copyright 2020 Google LLC 1060 * 1061 * Licensed under the Apache License, Version 2.0 (the "License"); 1062 * you may not use this file except in compliance with the License. 1063 * You may obtain a copy of the License at 1064 * 1065 * http://www.apache.org/licenses/LICENSE-2.0 1066 * 1067 * Unless required by applicable law or agreed to in writing, software 1068 * distributed under the License is distributed on an "AS IS" BASIS, 1069 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1070 * See the License for the specific language governing permissions and 1071 * limitations under the License. 1072 */class Mu{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,n,r,s=!1){const i=await ji._fromIdTokenResponse(e,r,s),a=aE(r);return new Mu({user:i,providerId:a,_tokenResponse:r,operationType:n})}static async _forOperation(e,n,r){await e._updateTokensIfNecessary(r,!0);const s=aE(r);return new Mu({user:e,providerId:s,_tokenResponse:r,operationType:n})}}function aE(t){return t.providerId?t.providerId:"phoneNumber"in t?"phone":null}/** 1073 * @license 1074 * Copyright 2020 Google LLC 1075 * 1076 * Licensed under the Apache License, Version 2.0 (the "License"); 1077 * you may not use this file except in compliance with the License. 1078 * You may obtain a copy of the License at 1079 * 1080 * http://www.apache.org/licenses/LICENSE-2.0 1081 * 1082 * Unless required by applicable law or agreed to in writing, software 1083 * distributed under the License is distributed on an "AS IS" BASIS, 1084 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1085 * See the License for the specific language governing permissions and 1086 * limitations under the License. 1087 */class Rg extends Po{constructor(e,n,r,s){var i;super(n.code,n.message),this.operationType=r,this.user=s,Object.setPrototypeOf(this,Rg.prototype),this.customData={appName:e.name,tenantId:(i=e.tenantId)!==null&&i!==void 0?i:void 0,_serverResponse:n.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(e,n,r,s){return new Rg(e,n,r,s)}}function SA(t,e,n,r){return(e==="reauthenticate"?n._getReauthenticationResolver(t):n._getIdTokenResponse(t)).catch(i=>{throw i.code==="auth/multi-factor-auth-required"?Rg._fromErrorAndOperation(t,i,e,r):i})}async function UV(t,e,n=!1){const r=await lf(t,e._linkToIdToken(t.auth,await t.getIdToken()),n);return Mu._forOperation(t,"link",r)}/** 1088 * @license 1089 * Copyright 2019 Google LLC 1090 * 1091 * Licensed under the Apache License, Version 2.0 (the "License"); 1092 * you may not use this file except in compliance with the License. 1093 * You may obtain a copy of the License at 1094 * 1095 * http://www.apache.org/licenses/LICENSE-2.0 1096 * 1097 * Unless required by applicable law or agreed to in writing, software 1098 * distributed under the License is distributed on an "AS IS" BASIS, 1099 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1100 * See the License for the specific language governing permissions and 1101 * limitations under the License. 1102 */async function BV(t,e,n=!1){const{auth:r}=t;if(wi(r.app))return Promise.reject(Aa(r));const s="reauthenticate";try{const i=await lf(t,SA(r,s,e,t),n);rt(i.idToken,r,"internal-error");const a=Kj(i.idToken);rt(a,r,"internal-error");const{sub:l}=a;return rt(t.uid===l,r,"user-mismatch"),Mu._forOperation(t,s,i)}catch(i){throw(i==null?void 0:i.code)==="auth/user-not-found"&&bo(r,"user-mismatch"),i}}/** 1103 * @license 1104 * Copyright 2020 Google LLC 1105 * 1106 * Licensed under the Apache License, Version 2.0 (the "License");
1107 * you may not use this file except in compliance with the License. 1108 * You may obtain a copy of the License at 1109 * 1110 * http://www.apache.org/licenses/LICENSE-2.0 1111 * 1112 * Unless required by applicable law or agreed to in writing, software 1113 * distributed under the License is distributed on an "AS IS" BASIS, 1114 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1115 * See the License for the specific language governing permissions and 1116 * limitations under the License. 1117 */async function kA(t,e,n=!1){if(wi(t.app))return Promise.reject(Aa(t));const r="signIn",s=await SA(t,r,e),i=await Mu._fromIdTokenResponse(t,r,s);return n||await t._updateCurrentUser(i.user),i}async function WV(t,e){return kA(mc(t),e)}/** 1118 * @license 1119 * Copyright 2020 Google LLC 1120 * 1121 * Licensed under the Apache License, Version 2.0 (the "License"); 1122 * you may not use this file except in compliance with the License. 1123 * You may obtain a copy of the License at 1124 * 1125 * http://www.apache.org/licenses/LICENSE-2.0 1126 * 1127 * Unless required by applicable law or agreed to in writing, software 1128 * distributed under the License is distributed on an "AS IS" BASIS, 1129 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1130 * See the License for the specific language governing permissions and 1131 * limitations under the License. 1132 */async function HV(t){const e=mc(t);e._getPasswordPolicyInternal()&&await e._updatePasswordPolicy()}async function qV(t,e,n){const r=mc(t);await F0(r,{requestType:"PASSWORD_RESET",email:e,clientType:"CLIENT_TYPE_WEB"},"getOobCode",MV)}function PA(t,e,n){return wi(t.app)?Promise.reject(Aa(t)):WV(tn(t),rd.credential(e,n)).catch(async r=>{throw r.code==="auth/password-does-not-meet-requirements"&&HV(t),r})}function GV(t,e,n,r){return tn(t).onIdTokenChanged(e,n,r)}function ZV(t,e,n){return tn(t).beforeAuthStateChanged(e,n)}function KV(t,e,n,r){return tn(t).onAuthStateChanged(e,n,r)}function YV(t){return tn(t).signOut()}const Dg="__sak";/** 1133 * @license 1134 * Copyright 2019 Google LLC 1135 * 1136 * Licensed under the Apache License, Version 2.0 (the "License"); 1137 * you may not use this file except in compliance with the License. 1138 * You may obtain a copy of the License at 1139 * 1140 * http://www.apache.org/licenses/LICENSE-2.0 1141 * 1142 * Unless required by applicable law or agreed to in writing, software 1143 * distributed under the License is distributed on an "AS IS" BASIS, 1144 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1145 * See the License for the specific language governing permissions and 1146 * limitations under the License. 1147 */class IA{constructor(e,n){this.storageRetriever=e,this.type=n}_isAvailable(){try{return this.storage?(this.storage.setItem(Dg,"1"),this.storage.removeItem(Dg),Promise.resolve(!0)):Promise.resolve(!1)}catch{return Promise.resolve(!1)}}_set(e,n){return this.storage.setItem(e,JSON.stringify(n)),Promise.resolve()}_get(e){const n=this.storage.getItem(e);return Promise.resolve(n?JSON.parse(n):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}/** 1148 * @license 1149 * Copyright 2020 Google LLC 1150 * 1151 * Licensed under the Apache License, Version 2.0 (the "License"); 1152 * you may not use this file except in compliance with the License. 1153 * You may obtain a copy of the License at 1154 * 1155 * http://www.apache.org/licenses/LICENSE-2.0 1156 * 1157 * Unless required by applicable law or agreed to in writing, software 1158 * distributed under the License is distributed on an "AS IS" BASIS, 1159 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1160 * See the License for the specific language governing permissions and 1161 * limitations under the License. 1162 */const QV=1e3,XV=10;class TA extends IA{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,n)=>this.onStorageEvent(e,n),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=jA(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const n of Object.keys(this.listeners)){const r=this.storage.getItem(n),s=this.localCache[n];r!==s&&e(n,s,r)}}
vendor: 1,262 bytes, line 1162
1162onStorageEvent(e,n=!1){if(!e.key){this.forAllChangedKeys((a,l,c)=>{this.notifyListeners(a,c)});return}const r=e.key;n?this.detachListener():this.stopPolling();const s=()=>{const a=this.storage.getItem(r);!n&&this.localCache[r]===a||this.notifyListeners(r,a)},i=this.storage.getItem(r);pV()&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(s,XV):s()}notifyListeners(e,n){this.localCache[e]=n;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(n&&JSON.parse(n))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,n,r)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:n,newValue:r}),!0)})},QV)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,n){Object.keys(this.listeners).length===0&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(n)}_removeListener(e,n){this.listeners[e]&&(this.listeners[e].delete(n),this.listeners[e].size===0&&delete this.listeners[e]),Ob
1162ject.keys(this.listeners).length===0&&(this.detachListener(),this.stopPolling())}async _set(e,n){await super._set(e,n),this.localCache[e]=JSON.stringify(n)}async _get(e){const n=await super._get(e);return this.localCache[e]=JSON.stringify(n),n}async _remove(e){await super._remove(e),delete this.localCache[e]}}TA.type="LOCAL";const JV=TA;/** 1163 * @license 1164 * Copyright 2020 Google LLC 1165 * 1166 * Licensed under the Apache License, Version 2.0 (the "License"); 1167 * you may not use this file except in compliance with the License. 1168 * You may obtain a copy of the License at 1169 * 1170 * http://www.apache.org/licenses/LICENSE-2.0 1171 * 1172 * Unless required by applicable law or agreed to in writing, software 1173 * distributed under the License is distributed on an "AS IS" BASIS, 1174 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1175 * See the License for the specific language governing permissions and 1176 * limitations under the License. 1177 */class AA extends IA{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,n){}_removeListener(e,n){}}AA.type="SESSION";const RA=AA;/** 1178 * @license 1179 * Copyright 2019 Google LLC 1180 * 1181 * Licensed under the Apache License, Version 2.0 (the "License"); 1182 * you may not use this file except in compliance with the License. 1183 * You may obtain a copy of the License at 1184 * 1185 * http://www.apache.org/licenses/LICENSE-2.0 1186 * 1187 * Unless required by applicable law or agreed to in writing, software 1188 * distributed under the License is distributed on an "AS IS" BASIS, 1189 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1190 * See the License for the specific language governing permissions and 1191 * limitations under the License. 1192 */function eU(t){return Promise.all(t.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(n){return{fulfilled:!1,reason:n}}}))}/** 1193 * @license 1194 * Copyright 2019 Google LLC 1195 * 1196 * Licensed under the Apache License, Version 2.0 (the "License"); 1197 * you may not use this file except in compliance with the License. 1198 * You may obtain a copy of the License at 1199 * 1200 * http://www.apache.org/licenses/LICENSE-2.0 1201 * 1202 * Unless required by applicable law or agreed to in writing, software 1203 * distributed under the License is distributed on an "AS IS" BASIS, 1204 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1205 * See the License for the specific language governing permissions and 1206 * limitations under the License. 1207 */class Vv{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const n=this.receivers.find(s=>s.isListeningto(e));if(n)return n;const r=new Vv(e);return this.receivers.push(r),r}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const n=e,{eventId:r,eventType:s,data:i}=n.data,a=this.handlersMap[s];if(!(a!=null&&a.size))return;n.ports[0].postMessage({status:"ack",eventId:r,eventType:s});const l=Array.from(a).map(async d=>d(n.origin,i)),c=await eU(l);n.ports[0].postMessage({status:"done",eventId:r,eventType:s,response:c})}_subscribe(e,n){Object.keys(this.handlersMap).length===0&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(n)}_unsubscribe(e,n){this.handlersMap[e]&&n&&this.handlersMap[e].delete(n),(!n||this.handlersMap[e].size===0)&&delete this.handlersMap[e],Object.keys(this.handlersMap).length===0&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}Vv.receivers=[];/** 1208 * @license 1209 * Copyright 2020 Google LLC 1210 * 1211 * Licensed under the Apache License, Version 2.0 (the "License"); 1212 * you may not use this file except in compliance with the License. 1213 * You may obtain a copy of the License at 1214 * 1215 * http://www.apache.org/licenses/LICENSE-2.0 1216 * 1217 * Unless required by applicable law or agreed to in writing, software 1218 * distributed under the License is distributed on an "AS IS" BASIS, 1219 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1220 * See the License for the specific language governing permissions and 1221 * limitations under the License. 1222 */function Jj(t="",e=10){let n="";for(let r=0;r<e;r++)n+=Math.floor(Math.random()*10);return t+n}/** 1223 * @license 1224 * Copyright 2019 Google LLC 1225 * 1226 * Licensed under the Apache License, Version 2.0 (the "License");
1227 * you may not use this file except in compliance with the License. 1228 * You may obtain a copy of the License at 1229 * 1230 * http://www.apache.org/licenses/LICENSE-2.0 1231 * 1232 * Unless required by applicable law or agreed to in writing, software 1233 * distributed under the License is distributed on an "AS IS" BASIS, 1234 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1235 * See the License for the specific language governing permissions and 1236 * limitations under the License. 1237 */class tU{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,n,r=50){const s=typeof MessageChannel<"u"?new MessageChannel:null;if(!s)throw new Error("connection_unavailable");let i,a;return new Promise((l,c)=>{const d=Jj("",20);s.port1.start();const h=setTimeout(()=>{c(new Error("unsupported_event"))},r);a={messageChannel:s,onMessage(f){const p=f;if(p.data.eventId===d)switch(p.data.status){case"ack":clearTimeout(h),i=setTimeout(()=>{c(new Error("timeout"))},3e3);break;case"done":clearTimeout(i),l(p.data.response);break;default:clearTimeout(h),clearTimeout(i),c(new Error("invalid_response"));break}}},this.handlers.add(a),s.port1.addEventListener("message",a.onMessage),this.target.postMessage({eventType:e,eventId:d,data:n},[s.port2])}).finally(()=>{a&&this.removeMessageHandler(a)})}}/** 1238 * @license 1239 * Copyright 2020 Google LLC 1240 * 1241 * Licensed under the Apache License, Version 2.0 (the "License"); 1242 * you may not use this file except in compliance with the License. 1243 * You may obtain a copy of the License at 1244 * 1245 * http://www.apache.org/licenses/LICENSE-2.0 1246 * 1247 * Unless required by applicable law or agreed to in writing, software 1248 * distributed under the License is distributed on an "AS IS" BASIS, 1249 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1250 * See the License for the specific language governing permissions and 1251 * limitations under the License. 1252 */function Yo(){return window}function nU(t){Yo().location.href=t}/** 1253 * @license 1254 * Copyright 2020 Google LLC. 1255 * 1256 * Licensed under the Apache License, Version 2.0 (the "License"); 1257 * you may not use this file except in compliance with the License. 1258 * You may obtain a copy of the License at 1259 * 1260 * http://www.apache.org/licenses/LICENSE-2.0 1261 * 1262 * Unless required by applicable law or agreed to in writing, software 1263 * distributed under the License is distributed on an "AS IS" BASIS, 1264 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1265 * See the License for the specific language governing permissions and 1266 * limitations under the License. 1267 */function DA(){return typeof Yo().WorkerGlobalScope<"u"&&typeof Yo().importScripts=="function"}async function rU(){if(!(navigator!=null&&navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function sU(){var t;return((t=navigator==null?void 0:navigator.serviceWorker)===null||t===void 0?void 0:t.controller)||null}function oU(){return DA()?self:null}/** 1268 * @license 1269 * Copyright 2019 Google LLC 1270 * 1271 * Licensed under the Apache License, Version 2.0 (the "License"); 1272 * you may not use this file except in compliance with the License. 1273 * You may obtain a copy of the License at 1274 * 1275 * http://www.apache.org/licenses/LICENSE-2.0 1276 * 1277 * Unless required by applicable law or agreed to in writing, software 1278 * distributed under the License is distributed on an "AS IS" BASIS, 1279 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1280 * See the License for the specific language governing permissions and 1281 * limitations under the License. 1282 */const LA="firebaseLocalStorageDb",iU=1,Lg="firebaseLocalStorage",MA="fbase_key";class Bf{constructor(e){this.request=e}toPromise(){return new Promise((e,n)=>{this.request.addEventListener("success",()=>{e(this.request.result)}),this.request.addEventListener("error",()=>{n(this.request.error)})})}}function Uv(t,e){return t.transaction([Lg],e?"readwrite":"readonly").objectStore(Lg)}function aU(){const t=indexedDB.deleteDatabase(LA);
1282return new Bf(t).toPromise()}function z0(){const t=indexedDB.open(LA,iU);return new Promise((e,n)=>{t.addEventListener("error",()=>{n(t.error)}),t.addEventListener("upgradeneeded",()=>{const r=t.result;try{r.createObjectStore(Lg,{keyPath:MA})}catch(s){n(s)}}),t.addEventListener("success",async()=>{const r=t.result;r.objectStoreNames.contains(Lg)?e(r):(r.close(),await aU(),e(await z0()))})})}async function lE(t,e,n){const r=Uv(t,!0).put({[MA]:e,value:n});return new Bf(r).toPromise()}async function lU(t,e){const n=Uv(t,!1).get(e),r=await new Bf(n).toPromise();return r===void 0?null:r.value}function cE(t,e){const n=Uv(t,!0).delete(e);return new Bf(n).toPromise()}const cU=800,uU=3;class OA{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.db?this.db:(this.db=await z0(),this.db)}async _withRetries(e){let n=0;for(;;)try{const r=await this._openDb();return await e(r)}catch(r){if(n++>uU)throw r;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return DA()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=Vv._getInstance(oU()),this.receiver._subscribe("keyChanged",async(e,n)=>({keyProcessed:(await this._poll()).includes(n.key)}
1282)),this.receiver._subscribe("ping",async(e,n)=>["keyChanged"])}async initializeSender(){var e,n;if(this.activeServiceWorker=await rU(),!this.activeServiceWorker)return;this.sender=new tU(this.activeServiceWorker);const r=await this.sender._send("ping",{},800);r&&!((e=r[0])===null||e===void 0)&&e.fulfilled&&!((n=r[0])===null||n===void 0)&&n.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(!(!this.sender||!this.activeServiceWorker||sU()!==this.activeServiceWorker))try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{if(!indexedDB)return!1;const e=await z0();return await lE(e,Dg,"1"),await cE(e,Dg),!0}catch{}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,n){return this._withPendingWrite(async()=>(await this._withRetries(r=>lE(r,e,n)),this.localCache[e]=n,this.notifyServiceWorker(e)))}async _get(e){const n=await this._withRetries(r=>lU(r,e));return this.localCache[e]=n,n}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(n=>cE(n,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(s=>{const i=Uv(s,!1).getAll();return new Bf(i).toPromise()});if(!e)return[];if(this.pendingWrites!==0)return[];const n=[],r=new Set;if(e.length!==0)for(const{fbase_key:s,value:i}of e)r.add(s),JSON.stringify(this.localCache[s])!==JSON.stringify(i)&&(this.notifyListeners(s,i),n.push(s));for(const s of Object.keys(this.localCache))this.localCache[s]&&!r.has(s)&&(this.notifyListeners(s,null),n.push(s));return n}notifyListeners(e,n){this.localCache[e]=n;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(n)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),cU)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,n){Object.keys(this.listeners).length===0&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(n)}_removeListener(e,n){this.listeners[e]&&(this.listeners[e].delete(n),this.listeners[e].size===0&&delete this.listeners[e]),Ob
vendor: 4,318 bytes, lines 1282-1331
1282ject.keys(this.listeners).length===0&&this.stopPolling()}}OA.type="LOCAL";const dU=OA;new Vf(3e4,6e4);/** 1283 * @license 1284 * Copyright 2021 Google LLC 1285 * 1286 * Licensed under the Apache License, Version 2.0 (the "License"); 1287 * you may not use this file except in compliance with the License. 1288 * You may obtain a copy of the License at 1289 * 1290 * http://www.apache.org/licenses/LICENSE-2.0 1291 * 1292 * Unless required by applicable law or agreed to in writing, software 1293 * distributed under the License is distributed on an "AS IS" BASIS, 1294 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1295 * See the License for the specific language governing permissions and 1296 * limitations under the License. 1297 */function hU(t,e){return e?Ci(e):(rt(t._popupRedirectResolver,t,"argument-error"),t._popupRedirectResolver)}/** 1298 * @license 1299 * Copyright 2019 Google LLC 1300 * 1301 * Licensed under the Apache License, Version 2.0 (the "License"); 1302 * you may not use this file except in compliance with the License. 1303 * You may obtain a copy of the License at 1304 * 1305 * http://www.apache.org/licenses/LICENSE-2.0 1306 * 1307 * Unless required by applicable law or agreed to in writing, software 1308 * distributed under the License is distributed on an "AS IS" BASIS, 1309 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1310 * See the License for the specific language governing permissions and 1311 * limitations under the License. 1312 */class eC extends Qj{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return xu(e,this._buildIdpRequest())}_linkToIdToken(e,n){return xu(e,this._buildIdpRequest(n))}_getReauthenticationResolver(e){return xu(e,this._buildIdpRequest())}_buildIdpRequest(e){const n={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(n.idToken=e),n}}function fU(t){return kA(t.auth,new eC(t),t.bypassAuthState)}function mU(t){const{auth:e,user:n}=t;return rt(n,e,"internal-error"),BV(n,new eC(t),t.bypassAuthState)}async function pU(t){const{auth:e,user:n}=t;return rt(n,e,"internal-error"),UV(n,new eC(t),t.bypassAuthState)}/** 1313 * @license 1314 * Copyright 2020 Google LLC 1315 * 1316 * Licensed under the Apache License, Version 2.0 (the "License"); 1317 * you may not use this file except in compliance with the License. 1318 * You may obtain a copy of the License at 1319 * 1320 * http://www.apache.org/licenses/LICENSE-2.0 1321 * 1322 * Unless required by applicable law or agreed to in writing, software 1323 * distributed under the License is distributed on an "AS IS" BASIS, 1324 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1325 * See the License for the specific language governing permissions and 1326 * limitations under the License. 1327 */class FA{constructor(e,n,r,s,i=!1){this.auth=e,this.resolver=r,this.user=s,this.bypassAuthState=i,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(n)?n:[n]}execute(){return new Promise(async(e,n)=>{this.pendingPromise={resolve:e,reject:n};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(r){this.reject(r)}})}async onAuthEvent(e){const{urlResponse:n,sessionId:r,postBody:s,tenantId:i,error:a,type:l}=e;if(a){this.reject(a);return}const c={auth:this.auth,requestUri:n,sessionId:r,tenantId:i||void 0,postBody:s||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(l)(c))}catch(d){this.reject(d)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return fU;case"linkViaPopup":case"linkViaRedirect":return pU;case"reauthViaPopup":case"reauthViaRedirect":return mU;default:bo(this.auth,"internal-error")}}resolve(e){Di(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){Di(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}/** 1328 * @license 1329 * Copyright 2020 Google LLC 1330 * 1331 * Licensed under the Apache License, Version 2.0 (the "License");
1332 * you may not use this file except in compliance with the License. 1333 * You may obtain a copy of the License at 1334 * 1335 * http://www.apache.org/licenses/LICENSE-2.0 1336 * 1337 * Unless required by applicable law or agreed to in writing, software 1338 * distributed under the License is distributed on an "AS IS" BASIS, 1339 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1340 * See the License for the specific language governing permissions and 1341 * limitations under the License. 1342 */const gU=new Vf(2e3,1e4);class cu extends FA{constructor(e,n,r,s,i){super(e,n,s,i),this.provider=r,this.authWindow=null,this.pollId=null,cu.currentPopupAction&&cu.currentPopupAction.cancel(),cu.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return rt(e,this.auth,"internal-error"),e}async onExecution(){Di(this.filter.length===1,"Popup operations only handle one event");const e=Jj();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(n=>{this.reject(n)}),this.resolver._isIframeWebStorageSupported(this.auth,n=>{n||this.reject(Ko(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var e;return((e=this.authWindow)===null||e===void 0?void 0:e.associatedEvent)||null}cancel(){this.reject(Ko(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,cu.currentPopupAction=null}pollUserCancellation(){const e=()=>{var n,r;if(!((r=(n=this.authWindow)===null||n===void 0?void 0:n.window)===null||r===void 0)&&r.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(Ko(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,gU.get())};e()}}cu.currentPopupAction=null;/** 1343 * @license 1344 * Copyright 2020 Google LLC 1345 * 1346 * Licensed under the Apache License, Version 2.0 (the "License"); 1347 * you may not use this file except in compliance with the License. 1348 * You may obtain a copy of the License at 1349 * 1350 * http://www.apache.org/licenses/LICENSE-2.0 1351 * 1352 * Unless required by applicable law or agreed to in writing, software 1353 * distributed under the License is distributed on an "AS IS" BASIS, 1354 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1355 * See the License for the specific language governing permissions and 1356 * limitations under the License. 1357 */const vU="pendingRedirect",Hp=new Map;class xU extends FA{constructor(e,n,r=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],n,void 0,r),this.eventId=null}async execute(){let e=Hp.get(this.auth._key());if(!e){try{const r=await yU(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(r)}catch(n){e=()=>Promise.reject(n)}Hp.set(this.auth._key(),e)}return this.bypassAuthState||Hp.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if(e.type==="signInViaRedirect")return super.onAuthEvent(e);if(e.type==="unknown"){this.resolve(null);return}if(e.eventId){const n=await this.auth._redirectUserForId(e.eventId);if(n)return this.user=n,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function yU(t,e){const n=jU(e),r=bU(t);if(!await r._isAvailable())return!1;const s=await r._get(n)==="true";return await r._remove(n),s}function wU(t,e){Hp.set(t._key(),e)}function bU(t){return Ci(t._redirectPersistence)}function jU(t){return Wp(vU,t.config.apiKey,t.name)}async function CU(t,e,n=!1){if(wi(t.app))return Promise.reject(Aa(t));const r=mc(t),s=hU(r,e),a=await new xU(r,s,n).execute();return a&&!n&&(delete a.user._redirectEventId,await r._persistUserIfCurrent(a.user),await r._setRedirectUser(null,e)),a}/** 1358 * @license 1359 * Copyright 2020 Google LLC 1360 * 1361 * Licensed under the Apache License, Version 2.0 (the "License"); 1362 * you may not use this file except in compliance with the License. 1363 * You may obtain a copy of the License at 1364 * 1365 * http://www.apache.org/licenses/LICENSE-2.0 1366 * 1367 * Unless required by applicable law or agreed to in writing, softw
1367are 1368 * distributed under the License is distributed on an "AS IS" BASIS, 1369 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1370 * See the License for the specific language governing permissions and 1371 * limitations under the License. 1372 */const NU=10*60*1e3;class _U{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let n=!1;return this.consumers.forEach(r=>{this.isEventForConsumer(e,r)&&(n=!0,this.sendToConsumer(e,r),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!EU(e)||(this.hasHandledPotentialRedirect=!0,n||(this.queuedRedirectEvent=e,n=!0)),n}sendToConsumer(e,n){var r;if(e.error&&!zA(e)){const s=((r=e.error.code)===null||r===void 0?void 0:r.split("auth/")[1])||"internal-error";n.onError(Ko(this.auth,s))}else n.onAuthEvent(e)}isEventForConsumer(e,n){const r=n.eventId===null||!!e.eventId&&e.eventId===n.eventId;return n.filter.includes(e.type)&&r}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=NU&&this.cachedEventUids.clear(),this.cachedEventUids.has(uE(e))}saveEventToCache(e){this.cachedEventUids.add(uE(e)),this.lastProcessedEventTime=Date.now()}}function uE(t){return[t.type,t.eventId,t.sessionId,t.tenantId].filter(e=>e).join("-")}function zA({type:t,error:e}){return t==="unknown"&&(e==null?void 0:e.code)==="auth/no-auth-event"}function EU(t){switch(t.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return zA(t);default:return!1}}/** 1373 * @license 1374 * Copyright 2020 Google LLC 1375 * 1376 * Licensed under the Apache License, Version 2.0 (the "License"); 1377 * you may not use this file except in compliance with the License. 1378 * You may obtain a copy of the License at 1379 * 1380 * http://www.apache.org/licenses/LICENSE-2.0 1381 * 1382 * Unless required by applicable law or agreed to in writing, software 1383 * distributed under the License is distributed on an "AS IS" BASIS, 1384 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1385 * See the License for the specific language governing permissions and 1386 * limitations under the License. 1387 */async function SU(t,e={}){return Bi(t,"GET","/v1/projects",e)}/** 1388 * @license 1389 * Copyright 2020 Google LLC 1390 * 1391 * Licensed under the Apache License, Version 2.0 (the "License"); 1392 * you may not use this file except in compliance with the License. 1393 * You may obtain a copy of the License at 1394 * 1395 * http://www.apache.org/licenses/LICENSE-2.0 1396 * 1397 * Unless required by applicable law or agreed to in writing, software 1398 * distributed under the License is distributed on an "AS IS" BASIS, 1399 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1400 * See the License for the specific language governing permissions and 1401 * limitations under the License. 1402 */const kU=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,PU=/^https?/;async function IU(t){if(t.config.emulator)return;const{authorizedDomains:e}=await SU(t);for(const n of e)try{if(TU(n))return}catch{}bo(t,"unauthorized-domain")}function TU(t){const e=M0(),{protocol:n,hostname:r}=new URL(e);if(t.startsWith("chrome-extension://")){const a=new URL(t);return a.hostname===""&&r===""?n==="chrome-extension:"&&t.replace("chrome-extension://","")===e.replace("chrome-extension://",""):n==="chrome-extension:"&&a.hostname===r}if(!PU.test(n))return!1;if(kU.test(t))return r===t;const s=t.replace(/\./g,"\\.");return new RegExp("^(.+\\."+s+"|"+s+")$","i").test(r)}/** 1403 * @license 1404 * Copyright 2020 Google LLC. 1405 * 1406 * Licensed under the Apache License, Version 2.0 (the "License"); 1407 * you may not use this file except in compliance with the License. 1408 * You may obtain a copy of the License at 1409 * 1410 * http://www.apache.org/licenses/LICENSE-2.0 1411 * 1412 * Unless required by applicable law or agreed to in writing, softw
1412are 1413 * distributed under the License is distributed on an "AS IS" BASIS, 1414 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1415 * See the License for the specific language governing permissions and 1416 * limitations under the License. 1417 */const AU=new Vf(3e4,6e4);function dE(){const t=Yo().___jsl;if(t!=null&&t.H){for(const e of Object.keys(t.H))if(t.H[e].r=t.H[e].r||[],t.H[e].L=t.H[e].L||[],t.H[e].r=[...t.H[e].L],t.CP)for(let n=0;n<t.CP.length;n++)t.CP[n]=null}}function RU(t){return new Promise((e,n)=>{var r,s,i;function a(){dE(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{dE(),n(Ko(t,"network-request-failed"))},timeout:AU.get()})}if(!((s=(r=Yo().gapi)===null||r===void 0?void 0:r.iframes)===null||s===void 0)&&s.Iframe)e(gapi.iframes.getContext());else if(!((i=Yo().gapi)===null||i===void 0)&&i.load)a();else{const l=NV("iframefcb");return Yo()[l]=()=>{gapi.load?a():n(Ko(t,"network-request-failed"))},NA(`${CV()}?onload=${l}`).catch(c=>n(c))}}).catch(e=>{throw qp=null,e})}let qp=null;function DU(t){return qp=qp||RU(t),qp}/** 1418 * @license 1419 * Copyright 2020 Google LLC. 1420 * 1421 * Licensed under the Apache License, Version 2.0 (the "License"); 1422 * you may not use this file except in compliance with the License. 1423 * You may obtain a copy of the License at 1424 * 1425 * http://www.apache.org/licenses/LICENSE-2.0 1426 * 1427 * Unless required by applicable law or agreed to in writing, software 1428 * distributed under the License is distributed on an "AS IS" BASIS, 1429 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1430 * See the License for the specific language governing permissions and 1431 * limitations under the License. 1432 */const LU=new Vf(5e3,15e3),MU="__/auth/iframe",OU="emulator/auth/iframe",FU={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},zU=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function $U(t){const e=t.config;rt(e.authDomain,t,"auth-domain-config-required");const n=e.emulator?Zj(e,OU):`https://${t.config.authDomain}/${MU}`,r={apiKey:e.apiKey,appName:t.name,v:fc},s=zU.get(t.config.apiHost);s&&(r.eid=s);const i=t._getFrameworks();return i.length&&(r.fw=i.join(",")),`${n}?${zf(r).slice(1)}`}async function VU(t){const e=await DU(t),n=Yo().gapi;return rt(n,t,"internal-error"),e.open({where:document.body,url:$U(t),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:FU,dontclear:!0},r=>new Promise(async(s,i)=>{await r.restyle({setHideOnLeave:!1});const a=Ko(t,"network-request-failed"),l=Yo().setTimeout(()=>{i(a)},LU.get());function c(){Yo().clearTimeout(l),s(r)}r.ping(c).then(c,()=>{i(a)})}))}/** 1433 * @license 1434 * Copyright 2020 Google LLC. 1435 * 1436 * Licensed under the Apache License, Version 2.0 (the "License"); 1437 * you may not use this file except in compliance with the License. 1438 * You may obtain a copy of the License at 1439 * 1440 * http://www.apache.org/licenses/LICENSE-2.0 1441 * 1442 * Unless required by applicable law or agreed to in writing, software 1443 * distributed under the License is distributed on an "AS IS" BASIS, 1444 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1445 * See the License for the specific language governing permissions and 1446 * limitations under the License. 1447 */const UU={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},BU=500,WU=600,HU="_blank",qU="http://localhost";class hE{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function GU(t,e,n,r=BU,s=WU){const i=Math.max((window.screen.availHeight-s)/2,0).toString(),a=Math.max((window.screen.availWidth-r)/2,0).toString();let l="";const c=Object.assign(Object.assign({},UU),{width:r.toString(),height:s.toString(),top:i,left:a}),d=Vr().toLowerCase();n&&(l=vA(d)?HU:n),pA(d)&&(e=e||qU,c.scrollbars="yes");const h=Object.entries(c).reduce((p,[g,v])=>`${p}${g}=${v},`,"");if(mV(d)&&l!=="_self")return ZU(e||"",l),new hE(null);const f=window.open(e||"",l,h);rt(f,t,"popup-blocked");try{f.focus()}catch{}return new hE(f)}function ZU(t,e){const n=document.createElement("a");n.href=t,n.target=e;const r=document.createEvent("MouseEvent");
1447r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),n.dispatchEvent(r)}/** 1448 * @license 1449 * Copyright 2021 Google LLC 1450 * 1451 * Licensed under the Apache License, Version 2.0 (the "License"); 1452 * you may not use this file except in compliance with the License. 1453 * You may obtain a copy of the License at 1454 * 1455 * http://www.apache.org/licenses/LICENSE-2.0 1456 * 1457 * Unless required by applicable law or agreed to in writing, software 1458 * distributed under the License is distributed on an "AS IS" BASIS, 1459 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1460 * See the License for the specific language governing permissions and 1461 * limitations under the License. 1462 */const KU="__/auth/handler",YU="emulator/auth/handler",QU=encodeURIComponent("fac");async function fE(t,e,n,r,s,i){rt(t.config.authDomain,t,"auth-domain-config-required"),rt(t.config.apiKey,t,"invalid-api-key");const a={apiKey:t.config.apiKey,appName:t.name,authType:n,redirectUrl:r,v:fc,eventId:s};if(e instanceof EA){e.setDefaultLanguage(t.languageCode),a.providerId=e.providerId||"",Fz(e.getCustomParameters())||(a.customParameters=JSON.stringify(e.getCustomParameters()));for(const[h,f]of Object.entries({}))a[h]=f}if(e instanceof Uf){const h=e.getScopes().filter(f=>f!=="");h.length>0&&(a.scopes=h.join(","))}t.tenantId&&(a.tid=t.tenantId);const l=a;for(const h of Object.keys(l))l[h]===void 0&&delete l[h];const c=await t._getAppCheckToken(),d=c?`#${QU}=${encodeURIComponent(c)}`:"";return`${XU(t)}?${zf(l).slice(1)}${d}`}function XU({config:t}){return t.emulator?Zj(t,YU):`https://${t.authDomain}/${KU}`}/** 1463 * @license 1464 * Copyright 2020 Google LLC 1465 * 1466 * Licensed under the Apache License, Version 2.0 (the "License"); 1467 * you may not use this file except in compliance with the License. 1468 * You may obtain a copy of the License at 1469 * 1470 * http://www.apache.org/licenses/LICENSE-2.0 1471 * 1472 * Unless required by applicable law or agreed to in writing, software 1473 * distributed under the License is distributed on an "AS IS" BASIS, 1474 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1475 * See the License for the specific language governing permissions and 1476 * limitations under the License. 1477 */const Ay="webStorageSupport";class JU{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=RA,this._completeRedirectFn=CU,this._overrideRedirectResult=wU}
1477async _openPopup(e,n,r,s){var i;Di((i=this.eventManagers[e._key()])===null||i===void 0?void 0:i.manager,"_initialize() not called before _openPopup()");const a=await fE(e,n,r,M0(),s);return GU(e,a,Jj())}async _openRedirect(e,n,r,s){await this._originValidation(e);const i=await fE(e,n,r,M0(),s);return nU(i),new Promise(()=>{})}_initialize(e){const n=e._key();if(this.eventManagers[n]){const{manager:s,promise:i}=this.eventManagers[n];return s?Promise.resolve(s):(Di(i,"If manager is not set, promise should be"),i)}const r=this.initAndGetManager(e);return this.eventManagers[n]={promise:r},r.catch(()=>{delete this.eventManagers[n]}),r}async initAndGetManager(e){const n=await VU(e),r=new _U(e);return n.register("authEvent",s=>(rt(s==null?void 0:s.authEvent,e,"invalid-auth-event"),{status:r.onEvent(s.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:r},this.iframes[e._key()]=n,r}_isIframeWebStorageSupported(e,n){this.iframes[e._key()].send(Ay,{type:Ay},s=>{var i;const a=(i=s==null?void 0:s[0])===null||i===void 0?void 0:i[Ay];a!==void 0&&n(!!a),bo(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const n=e._key();return this.originValidationPromises[n]||(this.originValidationPromises[n]=IU(e)),this.originValidationPromises[n]}get _shouldInitProactively(){return jA()||gA()||Yj()}}const e8=JU;var mE="@firebase/auth",pE="1.7.9";/** 1478 * @license 1479 * Copyright 2020 Google LLC 1480 * 1481 * Licensed under the Apache License, Version 2.0 (the "License"); 1482 * you may not use this file except in compliance with the License. 1483 * You may obtain a copy of the License at 1484 * 1485 * http://www.apache.org/licenses/LICENSE-2.0 1486 * 1487 * Unless required by applicable law or agreed to in writing, software 1488 * distributed under the License is distributed on an "AS IS" BASIS, 1489 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1490 * See the License for the specific language governing permissions and 1491 * limitations under the License. 1492 */class t8{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),((e=this.auth.currentUser)===null||e===void 0?void 0:e.uid)||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const n=this.auth.onIdTokenChanged(r=>{e((r==null?void 0:r.stsTokenManager.accessToken)||null)});this.internalListeners.set(e,n),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();const n=this.internalListeners.get(e);n&&(this.internalListeners.delete(e),n(),this.updateProactiveRefresh())}assertAuthConfigured(){rt(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}/** 1493 * @license 1494 * Copyright 2020 Google LLC 1495 * 1496 * Licensed under the Apache License, Version 2.0 (the "License"); 1497 * you may not use this file except in compliance with the License. 1498 * You may obtain a copy of the License at 1499 * 1500 * http://www.apache.org/licenses/LICENSE-2.0 1501 * 1502 * Unless required by applicable law or agreed to in writing, software 1503 * distributed under the License is distributed on an "AS IS" BASIS, 1504 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1505 * See the License for the specific language governing permissions and 1506 * limitations under the License. 1507 */function n8(t){switch(t){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}function r8(t){za(new Ai("auth",(e,{options:n})=>{const r=e.getProvider("app").getImmediate(),s=e.getProvider("heartbeat"),i=e.getProvider("app-check-internal"),{apiKey:a,authDomain:l}=r.options;rt(a&&!a.includes(":"),"invalid-api-key",{appName:r.name});const c={apiKey:a,authDomain:l,clientPlatform:t,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:CA(t)},d=new wV(r,s,i,c);return PV(d,n),d},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,n,r)=>{e.getProvider("auth-internal").initialize()})),za(new Ai("auth-internal",e=>{const n=mc(e.getProvider("auth").getImmediate());return(r=>new t8(r))(n)},"PRIVATE").setInstantiationMode("EXPLICIT")),Vs(mE,pE,n8(t)),Vs(mE,pE,"esm2017")}/** 1508 * @license 1509 * Copyright 2021 Google LLC 1510 * 1511 * Licensed under the Apache License, Version 2.0 (the "License");
1512 * you may not use this file except in compliance with the License. 1513 * You may obtain a copy of the License at 1514 * 1515 * http://www.apache.org/licenses/LICENSE-2.0 1516 * 1517 * Unless required by applicable law or agreed to in writing, software 1518 * distributed under the License is distributed on an "AS IS" BASIS, 1519 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1520 * See the License for the specific language governing permissions and 1521 * limitations under the License. 1522 */const s8=5*60,o8=XT("authIdTokenMaxAge")||s8;let gE=null;const i8=t=>async e=>{const n=e&&await e.getIdTokenResult(),r=n&&(new Date().getTime()-Date.parse(n.issuedAtTime))/1e3;if(r&&r>o8)return;const s=n==null?void 0:n.token;gE!==s&&(gE=s,await fetch(t,{method:s?"POST":"DELETE",headers:s?{Authorization:`Bearer ${s}`}:{}}))};function a8(t=Fv()){const e=$f(t,"auth");if(e.isInitialized())return e.getImmediate();const n=kV(t,{popupRedirectResolver:e8,persistence:[dU,JV,RA]}),r=XT("authTokenSyncURL");if(r&&typeof isSecureContext=="boolean"&&isSecureContext){const i=new URL(r,location.origin);if(location.origin===i.origin){const a=i8(i.toString());ZV(n,a,()=>a(n.currentUser)),GV(n,l=>a(l))}}const s=YT("auth");return s&&IV(n,`http://${s}`),n}function l8(){var t,e;return(e=(t=document.getElementsByTagName("head"))===null||t===void 0?void 0:t[0])!==null&&e!==void 0?e:document}bV({loadJS(t){return new Promise((e,n)=>{const r=document.createElement("script");r.setAttribute("src",t),r.onload=e,r.onerror=s=>{const i=Ko("internal-error");i.customData=s,n(i)},r.type="text/javascript",r.charset="UTF-8",l8().appendChild(r)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="});r8("Browser");var vE=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license 1523Copyright The Closure Library Authors. 1524SPDX-License-Identifier: Apache-2.0 1525*/var zl,$A;(function(){var t;/** @license 1526 1527 Copyright The Closure Library Authors. 1528 SPDX-License-Identifier: Apache-2.0 1529*/function e(N,_){function k(){}k.prototype=_.prototype,N.D=_.prototype,N.prototype=new k,N.prototype.constructor=N,N.C=function(L,I,S){for(var T=Array(arguments.length-2),V=2;V<arguments.length;V++)T[V-2]=arguments[V];return _.prototype[I].apply(L,T)}}function n(){this.blockSize=-1}function r(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.B=Array(this.blockSize),this.o=this.h=0,this.s()}e(r,n),r.prototype.s=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function s(N,_,k){k||(k=0);var L=Array(16);if(typeof _=="string")for(var I=0;16>I;++I)L[I]=_.charCodeAt(k++)|_.charCodeAt(k++)<<8|_.charCodeAt(k++)<<16|_.charCodeAt(k++)<<24;else for(I=0;16>I;++I)L[I]=_[k++]|_[k++]<<8|_[k++]<<16|_[k++]<<24;_=N.g[0],k=N.g[1],I=N.g[2];var S=N.g[3],T=_+(S^k&(I^S))+L[0]+3614090360&4294967295;_=k+(T<<7&4294967295|T>>>25),T=S+(I^_&(k^I))+L[1]+3905402710&4294967295,S=_+(T<<12&4294967295|T>>>20),T=I+(k^S&(_^k))+L[2]+606105819&4294967295,I=S+(T<<17&4294967295|T>>>15),T=k+(_^I&(S^_))+L[3]+3250441966&4294967295,k=I+(T<<22&4294967295|T>>>10),T=_+(S^k&(I^S))+L[4]+4118548399&4294967295,_=k+(T<<7&4294967295|T>>>25),T=S+(I^_&(k^I))+L[5]+1200080426&4294967295,S=_+(T<<12&4294967295|T>>>20),T=I+(k^S&(_^k))+L[6]+2821735955&4294967295,I=S+(T<<17&4294967295|T>>>15),T=k+(_^I&(S^_))+L[7]+4249261313&4294967295,k=I+(T<<22&4294967295|T>>>10),T=_+(S^k&(I^S))+L[8]+1770035416&4294967295,_=k+(T<<7&4294967295|T>>>25),T=S+(I^_&(k^I))+L[9]+2336552879&4294967295,S=_+(T<<12&4294967295|T>>>20),T=I+(k^S&(_^k))+L[10]+4294925233&4294967295,I=S+(T<<17&4294967295|T>>>15),T=k+(_^I&(S^_))+L[11]+2304563134&4294967295,k=I+(T<<22&4294967295|T>>>10),T=_+(S^k&(I^S))+L[12]+1804603682&4294967295,_=k+(T<<7&4294967295|T>>>25),T=S+(I^_&(k^I))+L[13]+4254626195&4294967295,S=_+(T<<12&4294967295|T>>>20),T=I+(k^S&(_^k))+L[14]+2792965006&4294967295,I=S+(T<<17&4294967295|T>>>15),T=k+(_^I&(S^_))+L[15]+1236535329&4294967295,k=I+(T<<22&4294967295|T>>>10),T=_+(I^S&(k^I))+L[1]+4129170786&4294967295,_=k+(T<<5&4294967295|T>>>27),T=S+(k^I&(_^k))+L[6]+3225465664&4294967295,S=_+(T<<9&4294967295|T>>>23),T=I+(_^k&(S^_))+L[11]+643717713&4294967295,I=S+(T<<14&4294967295|T>>>18),T=k+(S^_&(I^S))+L[0]+3921069994&4294967295,k=I+(T<<20&4294967295|T>>>12),T=_+(I^S&(k^I))+L[5]+3593408605&4294967295,_=k+(T<<5&4294967295|T>>>27),T=S+(k^I&(_^k))+L[10]+38016083&4294967295,S=_+(T<<9&4294967295|T>>>23),T=I+(_^k&(S^_))+L[15]+3634488961&4294967295,I=S+(T<<14&4294967295|T>>>18),T=k+(S^_&(I^S))+L[4]+3889429448&4294967295,k=I+(T<<20&4294967295|T>>>12),T=_+(I^S&(k^I))+L[9]+568446438&4294967295,_=k+(T<<5&4294967295|T>>>27),T=S+(k^I&(_^k))+L[14]+3275163606&4294967295,S=_+(T<<9&4294967295|T>>>23),T=I+(_^k&(S^_))+L[3]+4107603335&4294967295,I=S+(T<<14&4294967295|T>>>18),T=k+(S^_&(I^S))+L[8]+1163531501&4294967295,k=I+(T<<20&4294967295|T>>>12),T=_+(I^S&(k^I))+L[13]+2850285829&4294967295,_=k+(T<<5&4294967295|T>>>27),T=S+(k^I&(_^k))+L[2]+4243563512&4294967295,S=_+(T<<9&4294967295|T>>>23),T=I+(_^k&(S^_))+L[7]+1735328473&4294967295,I=S+(T<<14&4294967295|T>>>18),T=k+(S^_&(I^S))+L[12]+2368359562&4294967295,k=I+(T<<20&4294967295|T>>>12),T=_+(k^I^S)+L[5]+4294588738&4294967295,_=k+(T<<4&4294967295|T>>>28),T=S+(_^k^I)+L[8]+2272392833&4294967295,S=_+(T<<11&4294967295|T>>>21),T=I+(S^_^k)+L[11]+1839030562&4294967295,I=S+(T<<16&4294967295|T>>>16),T=k+(I^S^_)+L[14]+4259657740&4294967295,k=I+(T<<23&4294967295|T>>>9),T=_+(k^I^S)+L[1]+2763975236&4294967295,_=k+(T<<4&4294967295|T>>>28),T=S+(_^k^I)+L[4]+1272893353&4294967295,S=_+(T<<11&4294967295|T>>>21),T=I+(S^_^k)+L[7]+4139469664&4294967295,I=S+(T<<16&4294967295|T>>>16),T=k+(I^S^_)+L[10]+3200236656&4294967295,k=I+(T<<23&4294967295|T>>>9),T=_+(k^I^S)+L[13]+681279174&4294967295,_=k+(T<<4&4294967295|T>>>28),T=S+(_^k^I)+L[0]+3936430074&4294967295,S=_+(T<<11&4294967295|T>>>21),T=I+(S^_^k)+L[3]+3572445317&4294967295,I=S+(T<<16&4294967295|T>>>16),T=k+(I^S^_)+L[6]+76029189&4294967295,k=I+(T<<23&4294967295|T>>>9),T=_+(k^I^S)+L[9]+3654602809&4294967295,_=k+(T<<4&4294967295|T>>>28),T=S+(_^k^I)+L[12]+3873151461&4294967295,S=_+(T<<11&4294967295|T>>>21),T=I+(S^_^k)+L[15]+530742520&4294967295,I=S+(T<<16&4294967295|T>>>16),T=k+(I^S^_)+L[2]+3299628645&4294967295,k=I+(T<<23&4294967295|T>>>9),T=_+(I^(k|~S))+L[0]+4096336452&4294967295,_=k+(T<<6&4294967295|T>>>26),T=S+(k^(_|~I))+L[7]+1126891415&4294967295,S=_+(T<<10&4294967295|T>>>22),T=I+(_^(S|~k))+L[14]+2878612391&4294967295,I=S+(T<<15&4294967295|T>>>17),T=k+(S^(I|~_))+L[5]+4237533241&4294967295,k=I+(T<<21&4294967295|T>>>11),T=_+(I^(k|~S))+L[12]+1700485571&4294967295,_=k+(T<<6&4294967295|T>>>26),T=S+(k^(_|~I))+L[3]+2399980690&4294967295,S=_+(T<<10&4294967295|T>>>22),T=I+(_^(S|~k))+L[10]+4293915773&4294967295,I=S+(T<<15&4294967295|T>>>17),T=k+(S^(I|~_))+L[1]+2240044497&4294967295,k=I+(T<<21&4294967295|T>>>11),T=_+(I^(k|~S))+L[8]+1873313359&4294967295,_=k+(T<<6&4294967295|T>>>26),T=S+(k^(_|~I))+L[15]+4264355552&4294967295,S=_+(T<<10&4294967295|T>>>22),T=I+(_^(S|~k))+L[6]+2734768916&4294967295,I=S+(T<<15&4294967295|T>>>17),T=k+(S^(I|~_))+L[13]+1309151649&4294967295,k=I+(T<<21&4294967295|T>>>11),T=_+(I^(k|~S))+L[4]+4149444226&4294967295,_=k+(T<<6&4294967295|T>>>26),T=S+(k^(_|~I))+L[11]+3174756917&4294967295,S=_+(T<<10&4294967295|T>>>22),T=I+(_^(S|~k))+L[2]+718787259&4294967295,I=S+(T<<15&4294967295|T>>>17),T=k+(S^(I|~_))+L[9]+3951481745&4294967295,N.g[0]=N.g[0]+_&4294967295,N.g[1]=N.g[1]+(I+(T<<21&4294967295|T>>>11))&4294967295,N.g[2]=N.g[2]+I&4294967295,N.g[3]=N.g[3]+S&4294967295}r.prototype.u=function(N,_){_===void 0&&(_=N.length);for(var k=_-this.blockSize,L=this.B,I=this.h,S=0;S<_;){if(I==0)for(;S<=k;)s(this,N,S),S+=this.blockSize;if(typeof N=="string"){for(;S<_;)if(L[I++]=N.charCodeAt(S++),I==this.blockSize){s(this,L),I=0;break}}else for(;S<_;)if(L[I++]=N[S++],I==this.blockSize){s(this,L),I=0;break}}this.h=I,this.o+=_},r.prototype.v=function(){var N=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);
vendor: 46,591 bytes, lines 1529-1548
1529N[0]=128;for(var _=1;_<N.length-8;++_)N[_]=0;var k=8*this.o;for(_=N.length-8;_<N.length;++_)N[_]=k&255,k/=256;for(this.u(N),N=Array(16),_=k=0;4>_;++_)for(var L=0;32>L;L+=8)N[k++]=this.g[_]>>>L&255;return N};function i(N,_){var k=l;return Object.prototype.hasOwnProperty.call(k,N)?k[N]:k[N]=_(N)}function a(N,_){this.h=_;for(var k=[],L=!0,I=N.length-1;0<=I;I--){var S=N[I]|0;L&&S==_||(k[I]=S,L=!1)}this.g=k}var l={};function c(N){return-128<=N&&128>N?i(N,function(_){return new a([_|0],0>_?-1:0)}):new a([N|0],0>N?-1:0)}function d(N){if(isNaN(N)||!isFinite(N))return f;if(0>N)return y(d(-N));for(var _=[],k=1,L=0;N>=k;L++)_[L]=N/k|0,k*=4294967296;return new a(_,0)}function h(N,_){if(N.length==0)throw Error("number format error: empty string");if(_=_||10,2>_||36<_)throw Error("radix out of range: "+_);if(N.charAt(0)=="-")return y(h(N.substring(1),_));if(0<=N.indexOf("-"))throw Error('number format error: interior "-" character');for(var k=d(Math.pow(_,8)),L=f,I=0;I<N.length;I+=8){var S=Math.min(8,N.length-I),T=parseInt(N.substring(I,I+S),_);8>S?(S=d(Math.pow(_,S)),L=L.j(S).add(d(T))):(L=L.j(k),L=L.add(d(T)))}return L}var f=c(0),p=c(1),g=c(16777216);t=a.prototype,t.m=function(){if(x(this))return-y(this).m();for(var N=0,_=1,k=0;k<this.g.length;k++){var L=this.i(k);N+=(0<=L?L:4294967296+L)*_,_*=4294967296}return N},t.toString=function(N){if(N=N||10,2>N||36<N)throw Error("radix out of range: "+N);if(v(this))return"0";if(x(this))return"-"+y(this).toString(N);for(var _=d(Math.pow(N,6)),k=this,L="";;){var I=E(k,_).g;k=b(k,I.j(_));var S=((0<k.g.length?k.g[0]:k.h)>>>0).toString(N);if(k=I,v(k))return S+L;for(;6>S.length;)S="0"+S;L=S+L}},t.i=function(N){return 0>N?0:N<this.g.length?this.g[N]:this.h};function v(N){if(N.h!=0)return!1;for(var _=0;_<N.g.length;_++)if(N.g[_]!=0)return!1;return!0}function x(N){return N.h==-1}t.l=function(N){return N=b(this,N),x(N)?-1:v(N)?0:1};function y(N){for(var _=N.g.length,k=[],L=0;L<_;L++)k[L]=~N.g[L];return new a(k,~N.h).add(p)}t.abs=function(){return x(this)?y(this):this},t.add=function(N){for(var _=Math.max(this.g.length,N.g.length),k=[],L=0,I=0;I<=_;I++){var S=L+(this.i(I)&65535)+(N.i(I)&65535),T=(S>>>16)+(this.i(I)>>>16)+(N.i(I)>>>16);L=T>>>16,S&=65535,T&=65535,k[I]=T<<16|S}return new a(k,k[k.length-1]&-2147483648?-1:0)};function b(N,_){return N.add(y(_))}t.j=function(N){if(v(this)||v(N))return f;if(x(this))return x(N)?y(this).j(y(N)):y(y(this).j(N));if(x(N))return y(this.j(y(N)));if(0>this.l(g)&&0>N.l(g))return d(this.m()*N.m());for(var _=this.g.length+N.g.length,k=[],L=0;L<2*_;L++)k[L]=0;for(L=0;L<this.g.length;L++)for(var I=0;I<N.g.length;I++){var S=this.i(L)>>>16,T=this.i(L)&65535,V=N.i(I)>>>16,$=N.i(I)&65535;k[2*L+2*I]+=T*$,w(k,2*L+2*I),k[2*L+2*I+1]+=S*$,w(k,2*L+2*I+1),k[2*L+2*I+1]+=T*V,w(k,2*L+2*I+1),k[2*L+2*I+2]+=S*V,w(k,2*L+2*I+2)}for(L=0;L<_;L++)k[L]=k[2*L+1]<<16|k[2*L];for(L=_;L<2*_;L++)k[L]=0;return new a(k,0)};function w(N,_){for(;(N[_]&65535)!=N[_];)N[_+1]+=N[_]>>>16,N[_]&=65535,_++}function j(N,_){this.g=N,this.h=_}function E(N,_){if(v(_))throw Error("division by zero");if(v(N))return new j(f,f);if(x(N))return _=E(y(N),_),new j(y(_.g),y(_.h));if(x(_))return _=E(N,y(_)),new j(y(_.g),_.h);if(30<N.g.length){if(x(N)||x(_))throw Error("slowDivide_ only works with positive integers.");for(var k=p,L=_;0>=L.l(N);)k=P(k),L=P(L);var I=A(k,1),S=A(L,1);for(L=A(L,2),k=A(k,2);!v(L);){var T=S.add(L);0>=T.l(N)&&(I=I.add(k),S=T),L=A(L,1),k=A(k,1)}return _=b(N,I.j(_)),new j(I,_)}for(I=f;0<=N.l(_);){for(k=Math.max(1,Math.floor(N.m()/_.m())),L=Math.ceil(Math.log(k)/Math.LN2),L=48>=L?1:Math.pow(2,L-48),S=d(k),T=S.j(_);x(T)||0<T.l(N);)k-=L,S=d(k),T=S.j(_);v(S)&&(S=p),I=I.add(S),N=b(N,T)}return new j(I,N)}t.A=function(N){return E(this,N).h},t.and=function(N){for(var _=Math.max(this.g.length,N.g.length),k=[],L=0;L<_;L++)k[L]=this.i(L)&N.i(L);return new a(k,this.h&N.h)},t.or=function(N){for(var _=Math.max(this.g.length,N.g.length),k=[],L=0;L<_;L++)k[L]=this.i(L)|N.i(L);return new a(k,this.h|N.h)},t.xor=function(N){for(var _=Math.max(this.g.length,N.g.length),k=[],L=0;L<_;L++)k[L]=this.i(L)^N.i(L);return new a(k,this.h^N.h)};function P(N){for(var _=N.g.length+1,k=[],L=0;L<_;L++)k[L]=N.i(L)<<1|N.i(L-1)>>>31;return new a(k,N.h)}function A(N,_){var k=_>>5;_%=32;for(var L=N.g.length-k,I=[],S=0;S<L;S++)I[S]=0<_?N.i(S+k)>>>_|N.i(S+k+1)<<32-_:N.i(S+k);return new a(I,N.h)}r.prototype.digest=r.prototype.v,r.prototype.reset=r.prototype.s,r.prototype.update=r.prototype.u,$A=r,a.prototype.add=a.prototype.add,a.prototype.multiply=a.prototype.j,a.prototype.modulo=a.prototype.A,a.prototype.compare=a.prototype.l,a.prototype.toNumber=a.prototype.m,a.prototype.toString=a.prototype.toString,a.prototype.getBits=a.prototype.i,a.fromNumber=d,a.fromString=h,zl=a}).apply(typeof vE<"u"?vE:typeof self<"u"?self:typeof window<"u"?window:{});var Jm=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license 1530Copyright The Closure Library Authors. 1531SPDX-License-Identifier: Apache-2.0 1532*/var VA,uh,UA,Gp,$0,BA,WA,HA;(function(){var t,e=typeof Object.defineProperties=="function"?Object.defineProperty:function(m,C,R){return m==Array.prototype||m==Object.prototype||(m[C]=R.value),m};function n(m){m=[typeof globalThis=="object"&&globalThis,m,typeof window=="object"&&window,typeof self=="object"&&self,typeof Jm=="object"&&Jm];for(var C=0;C<m.length;++C){var R=m[C];if(R&&R.Math==Math)return R}throw Error("Cannot find global object")}var r=n(this);function s(m,C){if(C)e:{var R=r;m=m.split(".");for(var z=0;z<m.length-1;z++){var te=m[z];if(!(te in R))break e;R=R[te]}m=m[m.length-1],z=R[m],C=C(z),C!=z&&C!=null&&e(R,m,{configurable:!0,writable:!0,value:C})}}function i(m,C){m instanceof String&&(m+="");var R=0,z=!1,te={next:function(){if(!z&&R<m.length){var ie=R++;return{value:C(ie,m[ie]),done:!1}}return z=!0,{done:!0,value:void 0}}};return te[Symbol.iterator]=function(){return te},te}s("Array.prototype.values",function(m){return m||function(){return i(this,function(C,R){return R})}});/** @license 1533 1534 Copyright The Closure Library Authors. 1535 SPDX-License-Identifier: Apache-2.0 1536*/var a=a||{},l=this||self;function c(m){var C=typeof m;return C=C!="object"?C:m?Array.isArray(m)?"array":C:"null",C=="array"||C=="object"&&typeof m.length=="number"}function d(m){var C=typeof m;return C=="object"&&m!=null||C=="function"}function h(m,C,R){return m.call.apply(m.bind,arguments)}function f(m,C,R){if(!m)throw Error();if(2<arguments.length){var z=Array.prototype.slice.call(arguments,2);return function(){var te=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(te,z),m.apply(C,te)}}return function(){return m.apply(C,arguments)}}function p(m,C,R){return p=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?h:f,p.apply(null,arguments)}function g(m,C){var R=Array.prototype.slice.call(arguments,1);return function(){var z=R.slice();return z.push.apply(z,arguments),m.apply(this,z)}}function v(m,C){function R(){}R.prototype=C.prototype,m.aa=C.prototype,m.prototype=new R,m.prototype.constructor=m,m.Qb=function(z,te,ie){for(var Ie=Array(arguments.length-2),en=2;en<arguments.length;en++)Ie[en-2]=arguments[en];return C.prototype[te].apply(z,Ie)}}function x(m){const C=m.length;if(0<C){const R=Array(C);for(let z=0;z<C;z++)R[z]=m[z];return R}return[]}function y(m,C){for(let R=1;R<arguments.length;R++){const z=arguments[R];if(c(z)){const te=m.length||0,ie=z.length||0;m.length=te+ie;for(let Ie=0;Ie<ie;Ie++)m[te+Ie]=z[Ie]}else m.push(z)}}class b{constructor(C,R){this.i=C,this.j=R,this.h=0,this.g=null}get(){let C;return 0<this.h?(this.h--,C=this.g,this.g=C.next,C.next=null):C=this.i(),C}}function w(m){return/^[\s\xa0]*$/.test(m)}function j(){var m=l.navigator;return m&&(m=m.userAgent)?m:""}function E(m){return E[" "](m),m}E[" "]=function(){};var P=j().indexOf("Gecko")!=-1&&!(j().toLowerCase().indexOf("webkit")!=-1&&j().indexOf("Edge")==-1)&&!(j().indexOf("Trident")!=-1||j().indexOf("MSIE")!=-1)&&j().indexOf("Edge")==-1;function A(m,C,R){for(const z in m)C.call(R,m[z],z,m)}function N(m,C){for(const R in m)C.call(void 0,m[R],R,m)}function _(m){const C={};for(const R in m)C[R]=m[R];return C}const k="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function L(m,C){let R,z;for(let te=1;te<arguments.length;te++){z=arguments[te];for(R in z)m[R]=z[R];for(let ie=0;ie<k.length;ie++)R=k[ie],Object.prototype.hasOwnProperty.call(z,R)&&(m[R]=z[R])}}function I(m){var C=1;m=m.split(":");const R=[];for(;0<C&&m.length;)R.push(m.shift()),C--;return m.length&&R.push(m.join(":")),R}function S(m){l.setTimeout(()=>{throw m},0)}function T(){var m=F;let C=null;return m.g&&(C=m.g,m.g=m.g.next,m.g||(m.h=null),C.next=null),C}class V{constructor(){this.h=this.g=null}add(C,R){const z=$.get();z.set(C,R),this.h?this.h.next=z:this.g=z,this.h=z}}var $=new b(()=>new H,m=>m.reset());class H{constructor(){this.next=this.g=this.h=null}set(C,R){this.h=C,this.g=R,this.next=null}reset(){this.next=this.g=this.h=null}}let W,D=!1,F=new V,O=()=>{const m=l.Promise.resolve(void 0);W=()=>{m.then(Y)}};var Y=()=>{for(var m;m=T();){try{m.h.call(m.g)}catch(R){S(R)}var C=$;C.j(m),100>C.h&&(C.h++,m.next=C.g,C.g=m)}D=!1};function G(){this.s=this.s,this.C=this.C}G.prototype.s=!1,G.prototype.ma=function(){this.s||(this.s=!0,this.N())},G.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function q(m,C){this.type=m,this.g=this.target=C,this.defaultPrevented=!1}q.prototype.h=function(){this.defaultPrevented=!0};var re=function(){if(!l.addEventListener||!Object.defineProperty)return!1;var m=!1,C=Object.defineProperty({},"passive",{get:function(){m=!0}});try{const R=()=>{};l.addEventListener("test",R,C),l.removeEventListener("test",R,C)}catch{}return m}();function U(m,C){if(q.call(this,m?m.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,m){var R=this.type=m.type,z=m.changedTouches&&m.changedTouches.length?m.changedTouches[0]:null;if(this.target=m.target||m.srcElement,this.g=C,C=m.relatedTarget){if(P){e:{try{E(C.nodeName);var te=!0;break e}catch{}te=!1}te||(C=null)}}else R=="mouseover"?C=m.fromElement:R=="mouseout"&&(C=m.toElement);this.relatedTarget=C,z?(this.clientX=z.clientX!==void 0?z.clientX:z.pageX,this.clientY=z.clientY!==void 0?z.clientY:z.pageY,this.screenX=z.screenX||0,this.screenY=z.screenY||0):(this.clientX=m.clientX!==void 0?m.clientX:m.pageX,this.clientY=m.clientY!==void 0?m.clientY:m.pageY,this.screenX=m.screenX||0,this.screenY=m.screenY||0),this.button=m.button,this.key=m.key||"",this.ctrlKey=m.ctrlKey,this.altKey=m.altKey,this.shiftKey=m.shiftKey,this.metaKey=m.metaKey,this.pointerId=m.pointerId||0,this.pointerType=typeof m.pointerType=="string"?m.pointerType:ee[m.pointerType]||"",this.state=m.state,this.i=m,m.defaultPrevented&&U.aa.h.call(this)}}v(U,q);var ee={2:"touch",3:"pen",4:"mouse"};U.prototype.h=function(){U.aa.h.call(this);var m=this.i;m.preventDefault?m.preventDefault():m.returnValue=!1};var K="closure_listenable_"+(1e6*Math.random()|0),ue=0;function be(m,C,R,z,te){this.listener=m,this.proxy=null,this.src=C,this.type=R,this.capture=!!z,this.ha=te,this.key=++ue,this.da=this.fa=!1}function le(m){m.da=!0,m.listener=null,m.proxy=null,m.src=null,m.ha=null}function B(m){this.src=m,this.g={},this.h=0}B.prototype.add=function(m,C,R,z,te){var ie=m.toString();m=this.g[ie],m||(m=this.g[ie]=[],this.h++);var Ie=ve(m,C,z,te);return-1<Ie?(C=m[Ie],R||(C.fa=!1)):(C=new be(C,this.src,ie,!!z,te),C.fa=R,m.push(C)),C};function Q(m,C){var R=C.type;if(R in m.g){var z=m.g[R],te=Array.prototype.indexOf.call(z,C,void 0),ie;(ie=0<=te)&&Array.prototype.splice.call(z,te,1),ie&&(le(C),m.g[R].length==0&&(delete m.g[R],m.h--))}}function ve(m,C,R,z){for(var te=0;te<m.length;++te){var ie=m[te];if(!ie.da&&ie.listener==C&&ie.capture==!!R&&ie.ha==z)return te}return-1}var Ae="closure_lm_"+(1e6*Math.random()|0),he={};function J(m,C,R,z,te){if(Array.isArray(C)){for(var ie=0;ie<C.length;ie++)J(m,C[ie],R,z,te);return null}return R=ot(R),m&&m[K]?m.K(C,R,d(z)?!!z.capture:!1,te):je(m,C,R,!1,z,te)}function je(m,C,R,z,te,ie){if(!C)throw Error("Invalid event type");var Ie=d(te)?!!te.capture:!!te,en=vt(m);if(en||(m[Ae]=en=new B(m)),R=en.add(C,R,z,Ie,ie),R.proxy)return R;if(z=Ve(),R.proxy=z,z.src=m,z.listener=R,m.addEventListener)re||(te=Ie),te===void 0&&(te=!1),m.addEventListener(C.toString(),z,te);else if(m.attachEvent)m.attachEvent(Ue(C.toString()),z);else if(m.addListener&&m.removeListener)m.addListener(z);else throw Error("addEventListener and attachEvent are unavailable.");return R}function Ve(){function m(R){return C.call(m.src,m.listener,R)}const C=rn;return m}function Ye(m,C,R,z,te){if(Array.isArray(C))for(var ie=0;ie<C.length;ie++)Ye(m,C[ie],R,z,te);else z=d(z)?!!z.capture:!!z,R=ot(R),m&&m[K]?(m=m.i,C=String(C).toString(),C in m.g&&(ie=m.g[C],R=ve(ie,R,z,te),-1<R&&(le(ie[R]),Array.prototype.splice.call(ie,R,1),ie.length==0&&(delete m.g[C],m.h--)))):m&&(m=vt(m))&&(C=m.g[C.toString()],m=-1,C&&(m=ve(C,R,z,te)),(R=-1<m?C[m]:null)&&Jt(R))}function Jt(m){if(typeof m!="number"&&m&&!m.da){var C=m.src;if(C&&C[K])Q(C.i,m);else{var R=m.type,z=m.proxy;C.removeEventListener?C.removeEventListener(R,z,m.capture):C.detachEvent?C.detachEvent(Ue(R),z):C.addListener&&C.removeListener&&C.removeListener(z),(R=vt(C))?(Q(R,m),R.h==0&&(R.src=null,C[Ae]=null)):le(m)}}}function Ue(m){return m in he?he[m]:he[m]="on"+m}function rn(m,C){if(m.da)m=!0;else{C=new U(C,this);var R=m.listener,z=m.ha||m.src;m.fa&&Jt(m),m=R.call(z,C)}return m}function vt(m){return m=m[Ae],m instanceof B?m:null}var me="__closure_events_fn_"+(1e9*Math.random()>>>0);function ot(m){return typeof m=="function"?m:(m[me]||(m[me]=function(C){return m.handleEvent(C)}),m[me])}function Se(){G.call(this),this.i=new B(this),this.M=this,this.F=null}v(Se,G),Se.prototype[K]=!0,Se.prototype.removeEventListener=function(m,C,R,z){Ye(this,m,C,R,z)};function Te(m,C){var R,z=m.F;if(z)for(R=[];z;z=z.F)R.push(z);if(m=m.M,z=C.type||C,typeof C=="string")C=new q(C,m);else if(C instanceof q)C.target=C.target||m;else{var te=C;C=new q(z,m),L(C,te)}if(te=!0,R)for(var ie=R.length-1;0<=ie;ie--){var Ie=C.g=R[ie];te=He(Ie,z,!0,C)&&te}if(Ie=C.g=m,te=He(Ie,z,!0,C)&&te,te=He(Ie,z,!1,C)&&te,R)for(ie=0;ie<R.length;ie++)Ie=C.g=R[ie],te=He(Ie,z,!1,C)&&te}Se.prototype.N=function(){if(Se.aa.N.call(this),this.i){var m=this.i,C;for(C in m.g){for(var R=m.g[C],z=0;z<R.length;z++)le(R[z]);delete m.g[C],m.h--}}this.F=null},Se.prototype.K=function(m,C,R,z){return this.i.add(String(m),C,!1,R,z)},Se.prototype.L=function(m,C,R,z){return this.i.add(String(m),C,!0,R,z)};function He(m,C,R,z){if(C=m.i.g[String(C)],!C)return!0;C=C.concat();for(var te=!0,ie=0;ie<C.length;++ie){var Ie=C[ie];if(Ie&&!Ie.da&&Ie.capture==R){var en=Ie.listener,fr=Ie.ha||Ie.src;Ie.fa&&Q(m.i,Ie),te=en.call(fr,z)!==!1&&te}}return te&&!z.defaultPrevented}function Ut(m,C,R){if(typeof m=="function")R&&(m=p(m,R));else if(m&&typeof m.handleEvent=="function")m=p(m.handleEvent,m);else throw Error("Invalid listener argument");return 2147483647<Number(C)?-1:l.setTimeout(m,C||0)}function cn(m){m.g=Ut(()=>{m.g=null,m.i&&(m.i=!1,cn(m))},m.l);const C=m.h;m.h=null,m.m.apply(null,C)}class xn extends G{constructor(C,R){super(),this.m=C,this.l=R,this.h=null,this.i=!1,this.g=null}j(C){this.h=arguments,this.g?this.i=!0:cn(this)}N(){super.N(),this.g&&(l.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function un(m){G.call(this),this.h=m,this.g={}}v(un,G);var Yt=[];function st(m){A(m.g,function(C,R){this.g.hasOwnProperty(R)&&Jt(C)},m),m.g={}}un.prototype.N=function(){un.aa.N.call(this),st(this)},un.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var de=l.JSON.stringify,ze=l.JSON.parse,Qe=class{stringify(m){return l.JSON.stringify(m,void 0)}parse(m){return l.JSON.parse(m,void 0)}};function It(){}It.prototype.h=null;function se(m){return m.h||(m.h=m.i())}function Re(){}var ae={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function et(){q.call(this,"d")}v(et,q);function xt(){q.call(this,"c")}v(xt,q);var zt={},$e=null;function oe(){return $e=$e||new Se}zt.La="serverreachability";function De(m){q.call(this,zt.La,m)}v(De,q);function $t(m){const C=oe();Te(C,new De(C))}zt.STAT_EVENT="statevent";function En(m,C){q.call(this,zt.STAT_EVENT,m),this.stat=C}v(En,q);function Ct(m){const C=oe();Te(C,new En(C,m))}zt.Ma="timingevent";function qe(m,C){q.call(this,zt.Ma,m),this.size=C}v(qe,q);function Zn(m,C){if(typeof m!="function")throw Error("Fn must not be null and must be a function");return l.setTimeout(function(){m()},C)}function _r(){this.g=!0}_r.prototype.xa=function(){this.g=!1};function Bt(m,C,R,z,te,ie){m.info(function(){if(m.g)if(ie)for(var Ie="",en=ie.split("&"),fr=0;fr<en.length;fr++){var Dt=en[fr].split("=");if(1<Dt.length){var Sr=Dt[0];Dt=Dt[1];var kr=Sr.split("_");Ie=2<=kr.length&&kr[1]=="type"?Ie+(Sr+"="+Dt+"&"):Ie+(Sr+"=redacted&")}}else Ie=null;else Ie=ie;return"XMLHTTP REQ ("+z+") [attempt "+te+"]: "+C+` 1537`+R+` 1538`+Ie})}function Cc(m,C,R,z,te,ie,Ie){m.info(function(){return"XMLHTTP RESP ("+z+") [ attempt "+te+"]: "+C+` 1539`+R+` 1540`+ie+" "+Ie})}function ai(m,C,R,z){m.info(function(){return"XMLHTTP TEXT ("+C+"): "+Nc(m,R)+(z?" "+z:"")})}function qi(m,C){m.info(function(){return"TIMEOUT: "+C})}_r.prototype.info=function(){};function Nc(m,C){if(!m.g)return C;if(!C)return null;try{var R=JSON.parse(C);if(R){for(m=0;m<R.length;m++)if(Array.isArray(R[m])){var z=R[m];if(!(2>z.length)){var te=z[1];if(Array.isArray(te)&&!(1>te.length)){var ie=te[0];if(ie!="noop"&&ie!="stop"&&ie!="close")for(var Ie=1;Ie<te.length;Ie++)te[Ie]=""}}}}return de(R)}catch{return C}}var To={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},Gi={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"},Ao;function Js(){}v(Js,It),Js.prototype.g=function(){return new XMLHttpRequest},Js.prototype.i=function(){return{}},Ao=new Js;function Er(m,C,R,z){this.j=m,this.i=C,this.l=R,this.R=z||1,this.U=new un(this),this.I=45e3,this.H=null,this.o=!1,this.m=this.A=this.v=this.L=this.F=this.S=this.B=null,this.D=[],this.g=null,this.C=0,this.s=this.u=null,this.X=-1,this.J=!1,this.O=0,this.M=null,this.W=this.K=this.T=this.P=!1,this.h=new Br}function Br(){this.i=null,this.g="",this.h=!1}var xm={},bd={};function jd(m,C,R){m.L=1,m.v=Ic(to(C)),m.m=R,m.P=!0,ym(m,null)}function ym(m,C){m.F=Date.now(),Zi(m),m.A=to(m.v);var R=m.A,z=m.R;Array.isArray(z)||(z=[String(z)]),Sm(R.i,"t",z),m.C=0,R=m.j.J,m.h=new Br,m.g=wN(m.j,R?C:null,!m.m),0<m.O&&(m.M=new xn(p(m.Y,m,m.g),m.O)),C=m.U,R=m.g,z=m.ca;var te="readystatechange";Array.isArray(te)||(te&&(Yt[0]=te.toString()),te=Yt);for(var ie=0;ie<te.length;ie++){var Ie=J(R,te[ie],z||C.handleEvent,!1,C.h||C);if(!Ie)break;C.g[Ie.key]=Ie}C=m.H?_(m.H):{},m.m?(m.u||(m.u="POST"),C["Content-Type"]="application/x-www-form-urlencoded",m.g.ea(m.A,m.u,m.m,C)):(m.u="GET",m.g.ea(m.A,m.u,null,C)),$t(),Bt(m.i,m.u,m.A,m.l,m.R,m.m)}Er.prototype.ca=function(m){m=m.target;const C=this.M;C&&ui(m)==3?C.j():this.Y(m)},Er.prototype.Y=function(m){try{if(m==this.g)e:{const kr=ui(this.g);var C=this.g.Ba();const Dc=this.g.Z();if(!(3>kr)&&(kr!=3||this.g&&(this.h.h||this.g.oa()||cN(this.g)))){this.J||kr!=4||C==7||(C==8||0>=Dc?$t(3):$t(2)),Cd(this);var R=this.g.Z();this.X=R;t:if(wm(this)){var z=cN(this.g);m="";var te=z.length,ie=ui(this.g)==4;if(!this.h.i){if(typeof TextDecoder>"u"){yn(this),ul(this);var Ie="";break t}this.h.i=new l.TextDecoder}for(C=0;C<te;C++)this.h.h=!0,m+=this.h.i.decode(z[C],{stream:!(ie&&C==te-1)});z.length=0,this.h.g+=m,this.C=0,Ie=this.h.g}else Ie=this.g.oa();if(this.o=R==200,Cc(this.i,this.u,this.A,this.l,this.R,kr,R),this.o){if(this.T&&!this.K){t:{if(this.g){var en,fr=this.g;if((en=fr.g?fr.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!w(en)){var Dt=en;break t}}Dt=null}if(R=Dt)ai(this.i,this.l,R,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,Nd(this,R);else{this.o=!1,this.s=3,Ct(12),yn(this),ul(this);break e}}if(this.P){R=!0;let ro;for(;!this.J&&this.C<Ie.length;)if(ro=Ux(this,Ie),ro==bd){kr==4&&(this.s=4,Ct(14),R=!1),ai(this.i,this.l,null,"[Incomplete Response]");break}else if(ro==xm){this.s=4,Ct(15),ai(this.i,this.l,Ie,"[Invalid Chunk]"),R=!1;break}else ai(this.i,this.l,ro,null),Nd(this,ro);if(wm(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),kr!=4||Ie.length!=0||this.h.h||(this.s=1,Ct(16),R=!1),this.o=this.o&&R,!R)ai(this.i,this.l,Ie,"[Invalid Chunked Response]"),yn(this),ul(this);else if(0<Ie.length&&!this.W){this.W=!0;var Sr=this.j;Sr.g==this&&Sr.ba&&!Sr.M&&(Sr.j.info("Great, no buffering proxy detected. Bytes received: "+Ie.length),Yx(Sr),Sr.M=!0,Ct(11))}}else ai(this.i,this.l,Ie,null),Nd(this,Ie);kr==4&&yn(this),this.o&&!this.J&&(kr==4?gN(this.j,this):(this.o=!1,Zi(this)))}else D3(this.g),R==400&&0<Ie.indexOf("Unknown SID")?(this.s=3,Ct(12)):(this.s=0,Ct(13)),yn(this),ul(this)}}}catch{}finally{}};function wm(m){return m.g?m.u=="GET"&&m.L!=2&&m.j.Ca:!1}function Ux(m,C){var R=m.C,z=C.indexOf(` 1541`,R);return z==-1?bd:(R=Number(C.substring(R,z)),isNaN(R)?xm:(z+=1,z+R>C.length?bd:(C=C.slice(z,z+R),m.C=z+R,C)))}Er.prototype.cancel=function(){this.J=!0,yn(this)};function Zi(m){m.S=Date.now()+m.I,eo(m,m.I)}function eo(m,C){if(m.B!=null)throw Error("WatchDog timer not null");m.B=Zn(p(m.ba,m),C)}function Cd(m){m.B&&(l.clearTimeout(m.B),m.B=null)}Er.prototype.ba=function(){this.B=null;const m=Date.now();0<=m-this.S?(qi(this.i,this.A),this.L!=2&&($t(),Ct(17)),yn(this),this.s=2,ul(this)):eo(this,this.S-m)};function ul(m){m.j.G==0||m.J||gN(m.j,m)}function yn(m){Cd(m);var C=m.M;C&&typeof C.ma=="function"&&C.ma(),m.M=null,st(m.U),m.g&&(C=m.g,m.g=null,C.abort(),C.ma())}function Nd(m,C){try{var R=m.j;if(R.G!=0&&(R.g==m||hl(R.h,m))){if(!m.K&&hl(R.h,m)&&R.G==3){try{var z=R.Da.g.parse(C)}catch{z=null}if(Array.isArray(z)&&z.length==3){var te=z;if(te[0]==0){e:if(!R.u){if(R.g)if(R.g.F+3e3<m.F)Am(R),Im(R);else break e;Kx(R),Ct(18)}}else R.za=te[1],0<R.za-R.T&&37500>te[2]&&R.F&&R.v==0&&!R.C&&(R.C=Zn(p(R.Za,R),6e3));if(1>=Ec(R.h)&&R.ca){try{R.ca()}catch{}R.ca=void 0}}else yl(R,11)}else if((m.K||R.g==m)&&Am(R),!w(C))for(te=R.Da.g.parse(C),C=0;C<te.length;C++){let Dt=te[C];if(R.T=Dt[0],Dt=Dt[1],R.G==2)if(Dt[0]=="c"){R.K=Dt[1],R.ia=Dt[2];const Sr=Dt[3];Sr!=null&&(R.la=Sr,R.j.info("VER="+R.la));const kr=Dt[4];kr!=null&&(R.Aa=kr,R.j.info("SVER="+R.Aa));const Dc=Dt[5];Dc!=null&&typeof Dc=="number"&&0<Dc&&(z=1.5*Dc,R.L=z,R.j.info("backChannelRequestTimeoutMs_="+z)),z=R;const ro=m.g;if(ro){const Dm=ro.g?ro.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(Dm){var ie=z.h;ie.g||Dm.indexOf("spdy")==-1&&Dm.indexOf("quic")==-1&&Dm.indexOf("h2")==-1||(ie.j=ie.l,ie.g=new Set,ie.h&&(fl(ie,ie.h),ie.h=null))}if(z.D){const Qx=ro.g?ro.g.getResponseHeader("X-HTTP-Session-Id"):null;Qx&&(z.ya=Qx,Wt(z.I,z.D,Qx))}}R.G=3,R.l&&R.l.ua(),R.ba&&(R.R=Date.now()-m.F,R.j.info("Handshake RTT: "+R.R+"ms")),z=R;var Ie=m;if(z.qa=yN(z,z.J?z.ia:null,z.W),Ie.K){bm(z.h,Ie);var en=Ie,fr=z.L;fr&&(en.I=fr),en.B&&(Cd(en),Zi(en)),z.g=Ie}else mN(z);0<R.i.length&&Tm(R)}else Dt[0]!="stop"&&Dt[0]!="close"||yl(R,7);else R.G==3&&(Dt[0]=="stop"||Dt[0]=="close"?Dt[0]=="stop"?yl(R,7):Zx(R):Dt[0]!="noop"&&R.l&&R.l.ta(Dt),R.v=0)}}$t(4)}catch{}}var _d=class{constructor(m,C){this.g=m,this.map=C}};function dl(m){this.l=m||10,l.PerformanceNavigationTiming?(m=l.performance.getEntriesByType("navigation"),m=0<m.length&&(m[0].nextHopProtocol=="hq"||m[0].nextHopProtocol=="h2")):m=!!(l.chrome&&l.chrome.loadTimes&&l.chrome.loadTimes()&&l.chrome.loadTimes().wasFetchedViaSpdy),this.j=m?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function _c(m){return m.h?!0:m.g?m.g.size>=m.j:!1}function Ec(m){return m.h?1:m.g?m.g.size:0}function hl(m,C){return m.h?m.h==C:m.g?m.g.has(C):!1}function fl(m,C){m.g?m.g.add(C):m.h=C}function bm(m,C){m.h&&m.h==C?m.h=null:m.g&&m.g.has(C)&&m.g.delete(C)}dl.prototype.cancel=function(){if(this.i=Sc(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const m of this.g.values())m.cancel();this.g.clear()}};function Sc(m){if(m.h!=null)return m.i.concat(m.h.D);if(m.g!=null&&m.g.size!==0){let C=m.i;for(const R of m.g.values())C=C.concat(R.D);return C}return x(m.i)}function Bx(m){if(m.V&&typeof m.V=="function")return m.V();if(typeof Map<"u"&&m instanceof Map||typeof Set<"u"&&m instanceof Set)return Array.from(m.values());if(typeof m=="string")return m.split("");if(c(m)){for(var C=[],R=m.length,z=0;z<R;z++)C.push(m[z]);return C}C=[],R=0;for(z in m)C[R++]=m[z];return C}function Ed(m){if(m.na&&typeof m.na=="function")return m.na();if(!m.V||typeof m.V!="function"){if(typeof Map<"u"&&m instanceof Map)return Array.from(m.keys());if(!(typeof Set<"u"&&m instanceof Set)){if(c(m)||typeof m=="string"){var C=[];m=m.length;for(var R=0;R<m;R++)C.push(R);return C}C=[],R=0;for(const z in m)C[R++]=z;return C}}}function kc(m,C){if(m.forEach&&typeof m.forEach=="function")m.forEach(C,void 0);else if(c(m)||typeof m=="string")Array.prototype.forEach.call(m,C,void 0);else for(var R=Ed(m),z=Bx(m),te=z.length,ie=0;ie<te;ie++)C.call(void 0,z[ie],R&&R[ie],m)}var jm=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function Wx(m,C){if(m){m=m.split("&");for(var R=0;R<m.length;R++){var z=m[R].indexOf("="),te=null;if(0<=z){var ie=m[R].substring(0,z);te=m[R].substring(z+1)}else ie=m[R];C(ie,te?decodeURIComponent(te.replace(/\+/g," ")):"")}}}function li(m){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,m instanceof li){this.h=m.h,Ro(this,m.j),this.o=m.o,this.g=m.g,Pc(this,m.s),this.l=m.l;var C=m.i,R=new gl;R.i=C.i,C.g&&(R.g=new Map(C.g),R.h=C.h),Cm(this,R),this.m=m.m}else m&&(C=String(m).match(jm))?(this.h=!1,Ro(this,C[1]||"",!0),this.o=ml(C[2]||""),this.g=ml(C[3]||"",!0),Pc(this,C[4]),this.l=ml(C[5]||"",!0),Cm(this,C[6]||"",!0),this.m=ml(C[7]||"")):(this.h=!1,this.i=new gl(null,this.h))}li.prototype.toString=function(){var m=[],C=this.j;C&&m.push(pl(C,_m,!0),":");var R=this.g;return(R||C=="file")&&(m.push("//"),(C=this.o)&&m.push(pl(C,_m,!0),"@"),m.push(encodeURIComponent(String(R)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),R=this.s,R!=null&&m.push(":",String(R))),(R=this.l)&&(this.g&&R.charAt(0)!="/"&&m.push("/"),m.push(pl(R,R.charAt(0)=="/"?qx:Hx,!0))),(R=this.i.toString())&&m.push("?",R),(R=this.m)&&m.push("#",pl(R,kd)),m.join("")};function to(m){return new li(m)}function Ro(m,C,R){m.j=R?ml(C,!0):C,m.j&&(m.j=m.j.replace(/:$/,""))}function Pc(m,C){if(C){if(C=Number(C),isNaN(C)||0>C)throw Error("Bad port number "+C);m.s=C}else m.s=null}function Cm(m,C,R){C instanceof gl?(m.i=C,Lo(m.i,m.h)):(R||(C=pl(C,Sd)),m.i=new gl(C,m.h))}function Wt(m,C,R){m.i.set(C,R)}function Ic(m){return Wt(m,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),m}function ml(m,C){return m?C?decodeURI(m.replace(/%25/g,"%2525")):decodeURIComponent(m):""}function pl(m,C,R){return typeof m=="string"?(m=encodeURI(m).replace(C,Nm),R&&(m=m.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),m):null}function Nm(m){return m=m.charCodeAt(0),"%"+(m>>4&15).toString(16)+(m&15).toString(16)}var _m=/[#\/\?@]/g,Hx=/[#\?:]/g,qx=/[#\?]/g,Sd=/[#\?@]/g,kd=/#/g;function gl(m,C){this.h=this.g=null,this.i=m||null,this.j=!!C}function Do(m){m.g||(m.g=new Map,m.h=0,m.i&&Wx(m.i,function(C,R){m.add(decodeURIComponent(C.replace(/\+/g," ")),R)}))}t=gl.prototype,t.add=function(m,C){Do(this),this.i=null,m=ci(this,m);var R=this.g.get(m);return R||this.g.set(m,R=[]),R.push(C),this.h+=1,this};function Pd(m,C){Do(m),C=ci(m,C),m.g.has(C)&&(m.i=null,m.h-=m.g.get(C).length,m.g.delete(C))}function Em(m,C){return Do(m),C=ci(m,C),m.g.has(C)}t.forEach=function(m,C){Do(this),this.g.forEach(function(R,z){R.forEach(function(te){m.call(C,te,z,this)},this)},this)},t.na=function(){Do(this);const m=Array.from(this.g.values()),C=Array.from(this.g.keys()),R=[];for(let z=0;z<C.length;z++){const te=m[z];for(let ie=0;ie<te.length;ie++)R.push(C[z])}return R},t.V=function(m){Do(this);let C=[];if(typeof m=="string")Em(this,m)&&(C=C.concat(this.g.get(ci(this,m))));else{m=Array.from(this.g.values());for(let R=0;R<m.length;R++)C=C.concat(m[R])}return C},t.set=function(m,C){return Do(this),this.i=null,m=ci(this,m),Em(this,m)&&(this.h-=this.g.get(m).length),this.g.set(m,[C]),this.h+=1,this},t.get=function(m,C){return m?(m=this.V(m),0<m.length?String(m[0]):C):C};function Sm(m,C,R){Pd(m,C),0<R.length&&(m.i=null,m.g.set(ci(m,C),x(R)),m.h+=R.length)}t.toString=function(){if(this.i)return this.i;if(!this.g)return"";const m=[],C=Array.from(this.g.keys());for(var R=0;R<C.length;R++){var z=C[R];const ie=encodeURIComponent(String(z)),Ie=this.V(z);for(z=0;z<Ie.length;z++){var te=ie;Ie[z]!==""&&(te+="="+encodeURIComponent(String(Ie[z]))),m.push(te)}}return this.i=m.join("&")};function ci(m,C){return C=String(C),m.j&&(C=C.toLowerCase()),C}function Lo(m,C){C&&!m.j&&(Do(m),m.i=null,m.g.forEach(function(R,z){var te=z.toLowerCase();z!=te&&(Pd(this,z),Sm(this,te,R))},m)),m.j=C}function gs(m,C){const R=new _r;if(l.Image){const z=new Image;z.onload=g(no,R,"TestLoadImage: loaded",!0,C,z),z.onerror=g(no,R,"TestLoadImage: error",!1,C,z),z.onabort=g(no,R,"TestLoadImage: abort",!1,C,z),z.ontimeout=g(no,R,"TestLoadImage: timeout",!1,C,z),l.setTimeout(function(){z.ontimeout&&z.ontimeout()},1e4),z.src=m}else C(!1)}function Tc(m,C){const R=new _r,z=new AbortController,te=setTimeout(()=>{z.abort(),no(R,"TestPingServer: timeout",!1,C)},1e4);fetch(m,{signal:z.signal}).then(ie=>{clearTimeout(te),ie.ok?no(R,"TestPingServer: ok",!0,C):no(R,"TestPingServer: server error",!1,C)}).catch(()=>{clearTimeout(te),no(R,"TestPingServer: error",!1,C)})}function no(m,C,R,z,te){try{te&&(te.onload=null,te.onerror=null,te.onabort=null,te.ontimeout=null),z(R)}catch{}}function Gx(){this.g=new Qe}function vl(m,C,R){const z=R||"";try{kc(m,function(te,ie){let Ie=te;d(te)&&(Ie=de(te)),C.push(z+ie+"="+encodeURIComponent(Ie))})}catch(te){throw C.push(z+"type="+encodeURIComponent("_badmap")),te}}function Mo(m){this.l=m.Ub||null,this.j=m.eb||!1}v(Mo,It),Mo.prototype.g=function(){return new Ac(this.l,this.j)},Mo.prototype.i=function(m){return function(){return m}}({});function Ac(m,C){Se.call(this),this.D=m,this.o=C,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.u=new Headers,this.h=null,this.B="GET",this.A="",this.g=!1,this.v=this.j=this.l=null}v(Ac,Se),t=Ac.prototype,t.open=function(m,C){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.B=m,this.A=C,this.readyState=1,X(this)},t.send=function(m){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");this.g=!0;const C={headers:this.u,method:this.B,credentials:this.m,cache:void 0};m&&(C.body=m),(this.D||l).fetch(new Request(this.A,C)).then(this.Sa.bind(this),this.ga.bind(this))},t.abort=function(){this.response=this.responseText="",this.u=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),1<=this.readyState&&this.g&&this.readyState!=4&&(this.g=!1,M(this)),this.readyState=0},t.Sa=function(m){if(this.g&&(this.l=m,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=m.headers,this.readyState=2,X(this)),this.g&&(this.readyState=3,X(this),this.g)))if(this.responseType==="arraybuffer")m.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(typeof l.ReadableStream<"u"&&"body"in m){if(this.j=m.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.v=new TextDecoder;Id(this)}else m.text().then(this.Ra.bind(this),this.ga.bind(this))};function Id(m){m.j.read().then(m.Pa.bind(m)).catch(m.ga.bind(m))}t.Pa=function(m){if(this.g){if(this.o&&m.value)this.response.push(m.value);else if(!this.o){var C=m.value?m.value:new Uint8Array(0);(C=this.v.decode(C,{stream:!m.done}))&&(this.response=this.responseText+=C)}m.done?M(this):X(this),this.readyState==3&&Id(this)}},t.Ra=function(m){this.g&&(this.response=this.responseText=m,M(this))},t.Qa=function(m){this.g&&(this.response=m,M(this))},t.ga=function(){this.g&&M(this)};function M(m){m.readyState=4,m.l=null,m.j=null,m.v=null,X(m)}t.setRequestHeader=function(m,C){this.u.append(m,C)},t.getResponseHeader=function(m){return this.h&&this.h.get(m.toLowerCase())||""},t.getAllResponseHeaders=function(){if(!this.h)return"";const m=[],C=this.h.entries();for(var R=C.next();!R.done;)R=R.value,m.push(R[0]+": "+R[1]),R=C.next();return m.join(`\r 1542`)};function X(m){m.onreadystatechange&&m.onreadystatechange.call(m)}Object.defineProperty(Ac.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(m){this.m=m?"include":"same-origin"}});function we(m){let C="";return A(m,function(R,z){C+=z,C+=":",C+=R,C+=`\r 1543`}),C}function tt(m,C,R){e:{for(z in R){var z=!1;break e}z=!0}z||(R=we(R),typeof m=="string"?R!=null&&encodeURIComponent(String(R)):Wt(m,C,R))}function Ze(m){Se.call(this),this.headers=new Map,this.o=m||null,this.h=!1,this.v=this.g=null,this.D="",this.m=0,this.l="",this.j=this.B=this.u=this.A=!1,this.I=null,this.H="",this.J=!1}v(Ze,Se);var Ki=/^https?$/i,Ds=["POST","PUT"];t=Ze.prototype,t.Ha=function(m){this.J=m},t.ea=function(m,C,R,z){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+m);C=C?C.toUpperCase():"GET",this.D=m,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():Ao.g(),this.v=this.o?se(this.o):se(Ao),this.g.onreadystatechange=p(this.Ea,this);try{this.B=!0,this.g.open(C,String(m),!0),this.B=!1}catch(ie){km(this,ie);return}if(m=R||"",R=new Map(this.headers),z)if(Object.getPrototypeOf(z)===Object.prototype)for(var te in z)R.set(te,z[te]);else if(typeof z.keys=="function"&&typeof z.get=="function")for(const ie of z.keys())R.set(ie,z.get(ie));else throw Error("Unknown input type for opt_headers: "+String(z));z=Array.from(R.keys()).find(ie=>ie.toLowerCase()=="content-type"),te=l.FormData&&m instanceof l.FormData,!(0<=Array.prototype.indexOf.call(Ds,C,void 0))||z||te||R.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[ie,Ie]of R)this.g.setRequestHeader(ie,Ie);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{lN(this),this.u=!0,this.g.send(m),this.u=!1}catch(ie){km(this,ie)}};function km(m,C){m.h=!1,m.g&&(m.j=!0,m.g.abort(),m.j=!1),m.l=C,m.m=5,Td(m),Pm(m)}function Td(m){m.A||(m.A=!0,Te(m,"complete"),Te(m,"error"))}t.abort=function(m){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=m||7,Te(this,"complete"),Te(this,"abort"),Pm(this))},t.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Pm(this,!0)),Ze.aa.N.call(this)},t.Ea=function(){this.s||(this.B||this.u||this.j?xl(this):this.bb())},t.bb=function(){xl(this)};function xl(m){if(m.h&&typeof a<"u"&&(!m.v[1]||ui(m)!=4||m.Z()!=2)){if(m.u&&ui(m)==4)Ut(m.Ea,0,m);else if(Te(m,"readystatechange"),ui(m)==4){m.h=!1;try{const Ie=m.Z();e:switch(Ie){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var C=!0;break e;default:C=!1}var R;if(!(R=C)){var z;if(z=Ie===0){var te=String(m.D).match(jm)[1]||null;!te&&l.self&&l.self.location&&(te=l.self.location.protocol.slice(0,-1)),z=!Ki.test(te?te.toLowerCase():"")}R=z}if(R)Te(m,"complete"),Te(m,"success");else{m.m=6;try{var ie=2<ui(m)?m.g.statusText:""}catch{ie=""}m.l=ie+" ["+m.Z()+"]",Td(m)}}finally{Pm(m)}}}}function Pm(m,C){if(m.g){lN(m);const R=m.g,z=m.v[0]?()=>{}:null;m.g=null,m.v=null,C||Te(m,"ready");try{R.onreadystatechange=z}catch{}}}function lN(m){m.I&&(l.clearTimeout(m.I),m.I=null)}t.isActive=function(){return!!this.g};function ui(m){return m.g?m.g.readyState:0}t.Z=function(){try{return 2<ui(this)?this.g.status:-1}catch{return-1}},t.oa=function(){try{return this.g?this.g.responseText:""}catch{return""}},t.Oa=function(m){if(this.g){var C=this.g.responseText;return m&&C.indexOf(m)==0&&(C=C.substring(m.length)),ze(C)}};function cN(m){try{if(!m.g)return null;if("response"in m.g)return m.g.response;switch(m.H){case"":case"text":return m.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in m.g)return m.g.mozResponseArrayBuffer}return null}catch{return null}}function D3(m){const C={};m=(m.g&&2<=ui(m)&&m.g.getAllResponseHeaders()||"").split(`\r 1544`);for(let z=0;z<m.length;z++){if(w(m[z]))continue;var R=I(m[z]);const te=R[0];if(R=R[1],typeof R!="string")continue;R=R.trim();const ie=C[te]||[];C[te]=ie,ie.push(R)}N(C,function(z){return z.join(", ")})}t.Ba=function(){return this.m},t.Ka=function(){return typeof this.l=="string"?this.l:String(this.l)};function Ad(m,C,R){return R&&R.internalChannelParams&&R.internalChannelParams[m]||C}function uN(m){this.Aa=0,this.i=[],this.j=new _r,this.ia=this.qa=this.I=this.W=this.g=this.ya=this.D=this.H=this.m=this.S=this.o=null,this.Ya=this.U=0,this.Va=Ad("failFast",!1,m),this.F=this.C=this.u=this.s=this.l=null,this.X=!0,this.za=this.T=-1,this.Y=this.v=this.B=0,this.Ta=Ad("baseRetryDelayMs",5e3,m),this.cb=Ad("retryDelaySeedMs",1e4,m),this.Wa=Ad("forwardChannelMaxRetries",2,m),this.wa=Ad("forwardChannelRequestTimeoutMs",2e4,m),this.pa=m&&m.xmlHttpFactory||void 0,this.Xa=m&&m.Tb||void 0,this.Ca=m&&m.useFetchStreams||!1,this.L=void 0,this.J=m&&m.supportsCrossDomainXhr||!1,this.K="",this.h=new dl(m&&m.concurrentRequestLimit),this.Da=new Gx,this.P=m&&m.fastHandshake||!1,this.O=m&&m.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=m&&m.Rb||!1,m&&m.xa&&this.j.xa(),m&&m.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&m&&m.detectBufferingProxy||!1,this.ja=void 0,m&&m.longPollingTimeout&&0<m.longPollingTimeout&&(this.ja=m.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}t=uN.prototype,t.la=8,t.G=1,t.connect=function(m,C,R,z){Ct(0),this.W=m,this.H=C||{},R&&z!==void 0&&(this.H.OSID=R,this.H.OAID=z),this.F=this.X,this.I=yN(this,null,this.W),Tm(this)};function Zx(m){if(dN(m),m.G==3){var C=m.U++,R=to(m.I);if(Wt(R,"SID",m.K),Wt(R,"RID",C),Wt(R,"TYPE","terminate"),Rd(m,R),C=new Er(m,m.j,C),C.L=2,C.v=Ic(to(R)),R=!1,l.navigator&&l.navigator.sendBeacon)try{R=l.navigator.sendBeacon(C.v.toString(),"")}catch{}!R&&l.Image&&(new Image().src=C.v,R=!0),R||(C.g=wN(C.j,null),C.g.ea(C.v)),C.F=Date.now(),Zi(C)}xN(m)}function Im(m){m.g&&(Yx(m),m.g.cancel(),m.g=null)}function dN(m){Im(m),m.u&&(l.clearTimeout(m.u),m.u=null),Am(m),m.h.cancel(),m.s&&(typeof m.s=="number"&&l.clearTimeout(m.s),m.s=null)}function Tm(m){if(!_c(m.h)&&!m.s){m.s=!0;var C=m.Ga;W||O(),D||(W(),D=!0),F.add(C,m),m.B=0}}function L3(m,C){return Ec(m.h)>=m.h.j-(m.s?1:0)?!1:m.s?(m.i=C.D.concat(m.i),!0):m.G==1||m.G==2||m.B>=(m.Va?0:m.Wa)?!1:(m.s=Zn(p(m.Ga,m,C),vN(m,m.B)),m.B++,!0)}t.Ga=function(m){if(this.s)if(this.s=null,this.G==1){if(!m){this.U=Math.floor(1e5*Math.random()),m=this.U++;const te=new Er(this,this.j,m);let ie=this.o;if(this.S&&(ie?(ie=_(ie),L(ie,this.S)):ie=this.S),this.m!==null||this.O||(te.H=ie,ie=null),this.P)e:{for(var C=0,R=0;R<this.i.length;R++){t:{var z=this.i[R];if("__data__"in z.map&&(z=z.map.__data__,typeof z=="string")){z=z.length;break t}z=void 0}if(z===void 0)break;if(C+=z,4096<C){C=R;break e}if(C===4096||R===this.i.length-1){C=R+1;break e}}C=1e3}else C=1e3;C=fN(this,te,C),R=to(this.I),Wt(R,"RID",m),Wt(R,"CVER",22),this.D&&Wt(R,"X-HTTP-Session-Id",this.D),Rd(this,R),ie&&(this.O?C="headers="+encodeURIComponent(String(we(ie)))+"&"+C:this.m&&tt(R,this.m,ie)),fl(this.h,te),this.Ua&&Wt(R,"TYPE","init"),this.P?(Wt(R,"$req",C),Wt(R,"SID","null"),te.T=!0,jd(te,R,null)):jd(te,R,C),this.G=2}}else this.G==3&&(m?hN(this,m):this.i.length==0||_c(this.h)||hN(this))};function hN(m,C){var R;C?R=C.l:R=m.U++;const z=to(m.I);Wt(z,"SID",m.K),Wt(z,"RID",R),Wt(z,"AID",m.T),Rd(m,z),m.m&&m.o&&tt(z,m.m,m.o),R=new Er(m,m.j,R,m.B+1),m.m===null&&(R.H=m.o),C&&(m.i=C.D.concat(m.i)),C=fN(m,R,1e3),R.I=Math.round(.5*m.wa)+Math.round(.5*m.wa*Math.random()),fl(m.h,R),jd(R,z,C)}function Rd(m,C){m.H&&A(m.H,function(R,z){Wt(C,z,R)}),m.l&&kc({},function(R,z){Wt(C,z,R)})}function fN(m,C,R){R=Math.min(m.i.length,R);var z=m.l?p(m.l.Na,m.l,m):null;e:{var te=m.i;let ie=-1;for(;;){const Ie=["count="+R];ie==-1?0<R?(ie=te[0].g,Ie.push("ofs="+ie)):ie=0:Ie.push("ofs="+ie);let en=!0;for(let fr=0;fr<R;fr++){let Dt=te[fr].g;const Sr=te[fr].map;if(Dt-=ie,0>Dt)ie=Math.max(0,te[fr].g-100),en=!1;else try{vl(Sr,Ie,"req"+Dt+"_")}catch{z&&z(Sr)}}if(en){z=Ie.join("&");break e}}}return m=m.i.splice(0,R),C.D=m,z}function mN(m){if(!m.g&&!m.u){m.Y=1;var C=m.Fa;W||O(),D||(W(),D=!0),F.add(C,m),m.v=0}}function Kx(m){return m.g||m.u||3<=m.v?!1:(m.Y++,m.u=Zn(p(m.Fa,m),vN(m,m.v)),m.v++,!0)}t.Fa=function(){if(this.u=null,pN(this),this.ba&&!(this.M||this.g==null||0>=this.R)){var m=2*this.R;this.j.info("BP detection timer enabled: "+m),this.A=Zn(p(this.ab,this),m)}},t.ab=function(){this.A&&(this.A=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.M=!0,Ct(10),Im(this),pN(this))};function Yx(m){m.A!=null&&(l.clearTimeout(m.A),m.A=null)}function pN(m){m.g=new Er(m,m.j,"rpc",m.Y),m.m===null&&(m.g.H=m.o),m.g.O=0;var C=to(m.qa);Wt(C,"RID","rpc"),Wt(C,"SID",m.K),Wt(C,"AID",m.T),Wt(C,"CI",m.F?"0":"1"),!m.F&&m.ja&&Wt(C,"TO",m.ja),Wt(C,"TYPE","xmlhttp"),Rd(m,C),m.m&&m.o&&tt(C,m.m,m.o),m.L&&(m.g.I=m.L);var R=m.g;m=m.ia,R.L=1,R.v=Ic(to(C)),R.m=null,R.P=!0,ym(R,m)}t.Za=function(){this.C!=null&&(this.C=null,Im(this),Kx(this),Ct(19))};function Am(m){m.C!=null&&(l.clearTimeout(m.C),m.C=null)}function gN(m,C){var R=null;if(m.g==C){Am(m),Yx(m),m.g=null;var z=2}else if(hl(m.h,C))R=C.D,bm(m.h,C),z=1;else return;if(m.G!=0){if(C.o)if(z==1){R=C.m?C.m.length:0,C=Date.now()-C.F;var te=m.B;z=oe(),Te(z,new qe(z,R)),Tm(m)}else mN(m);else if(te=C.s,te==3||te==0&&0<C.X||!(z==1&&L3(m,C)||z==2&&Kx(m)))switch(R&&0<R.length&&(C=m.h,C.i=C.i.concat(R)),te){case 1:yl(m,5);break;case 4:yl(m,10);break;case 3:yl(m,6);break;default:yl(m,2)}}}function vN(m,C){let R=m.Ta+Math.floor(Math.random()*m.cb);return m.isActive()||(R*=2),R*C}function yl(m,C){if(m.j.info("Error code "+C),C==2){var R=p(m.fb,m),z=m.Xa;const te=!z;z=new li(z||"//www.google.com/images/cleardot.gif"),l.location&&l.location.protocol=="http"||Ro(z,"https"),Ic(z),te?gs(z.toString(),R):Tc(z.toString(),R)}else Ct(2);m.G=0,m.l&&m.l.sa(C),xN(m),dN(m)}t.fb=function(m){m?(this.j.info("Successfully pinged google.com"),Ct(2)):(this.j.info("Failed to ping google.com"),Ct(1))};function xN(m){if(m.G=0,m.ka=[],m.l){const C=Sc(m.h);(C.length!=0||m.i.length!=0)&&(y(m.ka,C),y(m.ka,m.i),m.h.i.length=0,x(m.i),m.i.length=0),m.l.ra()}}function yN(m,C,R){var z=R instanceof li?to(R):new li(R);if(z.g!="")C&&(z.g=C+"."+z.g),Pc(z,z.s);else{var te=l.location;z=te.protocol,C=C?C+"."+te.hostname:te.hostname,te=+te.port;var ie=new li(null);z&&Ro(ie,z),C&&(ie.g=C),te&&Pc(ie,te),R&&(ie.l=R),z=ie}return R=m.D,C=m.ya,R&&C&&Wt(z,R,C),Wt(z,"VER",m.la),Rd(m,z),z}function wN(m,C,R){if(C&&!m.J)throw Error("Can't create secondary domain capable XhrIo object.");return C=m.Ca&&!m.pa?new Ze(new Mo({eb:R})):new Ze(m.pa),C.Ha(m.J),C}t.isActive=function(){return!!this.l&&this.l.isActive(this)};function bN(){}t=bN.prototype,t.ua=function(){},t.ta=function(){},t.sa=function(){},t.ra=function(){},t.isActive=function(){return!0},t.Na=function(){};function Rm(){}Rm.prototype.g=function(m,C){return new vs(m,C)};function vs(m,C){Se.call(this),this.g=new uN(C),this.l=m,this.h=C&&C.messageUrlParams||null,m=C&&C.messageHeaders||null,C&&C.clientProtocolHeaderRequired&&(m?m["X-Client-Protocol"]="webchannel":m={"X-Client-Protocol":"webchannel"}),this.g.o=m,m=C&&C.initMessageHeaders||null,C&&C.messageContentType&&(m?m["X-WebChannel-Content-Type"]=C.messageContentType:m={"X-WebChannel-Content-Type":C.messageContentType}),C&&C.va&&(m?m["X-WebChannel-Client-Profile"]=C.va:m={"X-WebChannel-Client-Profile":C.va}),this.g.S=m,(m=C&&C.Sb)&&!w(m)&&(this.g.m=m),this.v=C&&C.supportsCrossDomainXhr||!1,this.u=C&&C.sendRawJson||!1,(C=C&&C.httpSessionIdParam)&&!w(C)&&(this.g.D=C,m=this.h,m!==null&&C in m&&(m=this.h,C in m&&delete m[C])),this.j=new Rc(this)}v(vs,Se),vs.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},vs.prototype.close=function(){Zx(this.g)},vs.prototype.o=function(m){var C=this.g;if(typeof m=="string"){var R={};R.__data__=m,m=R}else this.u&&(R={},R.__data__=de(m),m=R);C.i.push(new _d(C.Ya++,m)),C.G==3&&Tm(C)},vs.prototype.N=function(){this.g.l=null,delete this.j,Zx(this.g),delete this.g,vs.aa.N.call(this)};function jN(m){et.call(this),m.__headers__&&(this.headers=m.__headers__,this.statusCode=m.__status__,delete m.__headers__,delete m.__status__);var C=m.__sm__;if(C){e:{for(const R in C){m=R;break e}m=void 0}(this.i=m)&&(m=this.i,C=C!==null&&m in C?C[m]:void 0),this.data=C}else this.data=m}v(jN,et);function CN(){xt.call(this),this.status=1}v(CN,xt);function Rc(m){this.g=m}v(Rc,bN),Rc.prototype.ua=function(){Te(this.g,"a")},Rc.prototype.ta=function(m){Te(this.g,new jN(m))},Rc.prototype.sa=function(m){Te(this.g,new CN)},Rc.prototype.ra=function(){Te(this.g,"b")},Rm.prototype.createWebChannel=Rm.prototype.g,vs.prototype.send=vs.prototype.o,vs.prototype.open=vs.prototype.m,vs.prototype.close=vs.prototype.close,HA=function(){return new Rm},WA=function(){return oe()},BA=zt,$0={mb:0,pb:1,qb:2,Jb:3,Ob:4,Lb:5,Mb:6,Kb:7,Ib:8,Nb:9,PROXY:10,NOPROXY:11,Gb:12,Cb:13,Db:14,Bb:15,Eb:16,Fb:17,ib:18,hb:19,jb:20},To.NO_ERROR=0,To.TIMEOUT=8,To.HTTP_ERROR=6,Gp=To,Gi.COMPLETE="complete",UA=Gi,Re.EventType=ae,ae.OPEN="a",ae.CLOSE="b",ae.ERROR="c",ae.MESSAGE="d",Se.prototype.listen=Se.prototype.K,uh=Re,Ze.prototype.listenOnce=Ze.prototype.L,Ze.prototype.getLastError=Ze.prototype.Ka,Ze.prototype.getLastErrorCode=Ze.prototype.Ba,Ze.prototype.getStatus=Ze.prototype.Z,Ze.prototype.getResponseJson=Ze.prototype.Oa,Ze.prototype.getResponseText=Ze.prototype.oa,Ze.prototype.send=Ze.prototype.ea,Ze.prototype.setWithCredentials=Ze.prototype.Ha,VA=Ze}).apply(typeof Jm<"u"?Jm:typeof self<"u"?self:typeof window<"u"?window:{});const xE="@firebase/firestore";/** 1545 * @license 1546 * Copyright 2017 Google LLC 1547 * 1548 * Licensed under the Apache License, Version 2.0 (the "License");
1549 * you may not use this file except in compliance with the License. 1550 * You may obtain a copy of the License at 1551 * 1552 * http://www.apache.org/licenses/LICENSE-2.0 1553 * 1554 * Unless required by applicable law or agreed to in writing, software 1555 * distributed under the License is distributed on an "AS IS" BASIS, 1556 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1557 * See the License for the specific language governing permissions and 1558 * limitations under the License. 1559 */let Rr=class{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}};Rr.UNAUTHENTICATED=new Rr(null),Rr.GOOGLE_CREDENTIALS=new Rr("google-credentials-uid"),Rr.FIRST_PARTY=new Rr("first-party-uid"),Rr.MOCK_USER=new Rr("mock-user");/** 1560 * @license 1561 * Copyright 2017 Google LLC 1562 * 1563 * Licensed under the Apache License, Version 2.0 (the "License"); 1564 * you may not use this file except in compliance with the License. 1565 * You may obtain a copy of the License at 1566 * 1567 * http://www.apache.org/licenses/LICENSE-2.0 1568 * 1569 * Unless required by applicable law or agreed to in writing, software 1570 * distributed under the License is distributed on an "AS IS" BASIS, 1571 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1572 * See the License for the specific language governing permissions and 1573 * limitations under the License. 1574 */let sd="10.14.0";/** 1575 * @license 1576 * Copyright 2017 Google LLC 1577 * 1578 * Licensed under the Apache License, Version 2.0 (the "License"); 1579 * you may not use this file except in compliance with the License. 1580 * You may obtain a copy of the License at 1581 * 1582 * http://www.apache.org/licenses/LICENSE-2.0 1583 * 1584 * Unless required by applicable law or agreed to in writing, software 1585 * distributed under the License is distributed on an "AS IS" BASIS, 1586 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1587 * See the License for the specific language governing permissions and 1588 * limitations under the License. 1589 */const Yl=new Hj("@firebase/firestore");function Ud(){return Yl.logLevel}function Be(t,...e){if(Yl.logLevel<=Nt.DEBUG){const n=e.map(tC);Yl.debug(`Firestore (${sd}): ${t}`,...n)}}function Li(t,...e){if(Yl.logLevel<=Nt.ERROR){const n=e.map(tC);Yl.error(`Firestore (${sd}): ${t}`,...n)}}function Ou(t,...e){if(Yl.logLevel<=Nt.WARN){const n=e.map(tC);Yl.warn(`Firestore (${sd}): ${t}`,...n)}}function tC(t){if(typeof t=="string")return t;try{/** 1590* @license 1591* Copyright 2020 Google LLC 1592* 1593* Licensed under the Apache License, Version 2.0 (the "License"); 1594* you may not use this file except in compliance with the License. 1595* You may obtain a copy of the License at 1596* 1597* http://www.apache.org/licenses/LICENSE-2.0 1598* 1599* Unless required by applicable law or agreed to in writing, software 1600* distributed under the License is distributed on an "AS IS" BASIS, 1601* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1602* See the License for the specific language governing permissions and 1603* limitations under the License. 1604*/return function(n){return JSON.stringify(n)}(t)}catch{return t}}/** 1605 * @license 1606 * Copyright 2017 Google LLC 1607 * 1608 * Licensed under the Apache License, Version 2.0 (the "License"); 1609 * you may not use this file except in compliance with the License. 1610 * You may obtain a copy of the License at 1611 * 1612 * http://www.apache.org/licenses/LICENSE-2.0 1613 * 1614 * Unless required by applicable law or agreed to in writing, software 1615 * distributed under the License is distributed on an "AS IS" BASIS, 1616 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1617 * See the License for the specific language governing permissions and 1618 * limitations under the License. 1619 */function it(t="Unexpected state"){const e=`FIRESTORE (${sd}) INTERNAL ASSERTION FAILED: `+t;throw Li(e),new Error(e)}function Kt(t,e){t||it()}function lt(t,e){return t}/** 1620 * @license 1621 * Copyright 2017 Google LLC 1622 * 1623 * Licensed under the Apache License, Version 2.0 (the "License"); 1624 * you may not use this file except in compliance with the License. 1625 * You may obtain a copy of the License at 1626 * 1627 * http://www.apache.org/licenses/LICENSE-2.0 1628 * 1629 * Unless required by applicable law or agreed to in writing, softw
1629are 1630 * distributed under the License is distributed on an "AS IS" BASIS, 1631 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1632 * See the License for the specific language governing permissions and 1633 * limitations under the License. 1634 */const fe={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class Me extends Po{constructor(e,n){super(e,n),this.code=e,this.message=n,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/** 1635 * @license 1636 * Copyright 2017 Google LLC 1637 * 1638 * Licensed under the Apache License, Version 2.0 (the "License"); 1639 * you may not use this file except in compliance with the License. 1640 * You may obtain a copy of the License at 1641 * 1642 * http://www.apache.org/licenses/LICENSE-2.0 1643 * 1644 * Unless required by applicable law or agreed to in writing, software 1645 * distributed under the License is distributed on an "AS IS" BASIS, 1646 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1647 * See the License for the specific language governing permissions and 1648 * limitations under the License. 1649 */class Ei{constructor(){this.promise=new Promise((e,n)=>{this.resolve=e,this.reject=n})}}/** 1650 * @license 1651 * Copyright 2017 Google LLC 1652 * 1653 * Licensed under the Apache License, Version 2.0 (the "License"); 1654 * you may not use this file except in compliance with the License. 1655 * You may obtain a copy of the License at 1656 * 1657 * http://www.apache.org/licenses/LICENSE-2.0 1658 * 1659 * Unless required by applicable law or agreed to in writing, software 1660 * distributed under the License is distributed on an "AS IS" BASIS, 1661 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1662 * See the License for the specific language governing permissions and 1663 * limitations under the License. 1664 */class qA{constructor(e,n){this.user=n,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class c8{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,n){e.enqueueRetryable(()=>n(Rr.UNAUTHENTICATED))}shutdown(){}}class u8{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,n){this.changeListener=n,e.enqueueRetryable(()=>n(this.token.user))}shutdown(){this.changeListener=null}}class d8{constructor(e){this.t=e,this.currentUser=Rr.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,n){Kt(this.o===void 0);let r=this.i;const s=c=>this.i!==r?(r=this.i,n(c)):Promise.resolve();let i=new Ei;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new Ei,e.enqueueRetryable(()=>s(this.currentUser))};const a=()=>{const c=i;e.enqueueRetryable(async()=>{await c.promise,await s(this.currentUser)})},l=c=>{Be("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=c,this.o&&(this.auth.addAuthTokenListener(this.o),a())};this.t.onInit(c=>l(c)),setTimeout(()=>{if(!this.auth){const c=this.t.getImmediate({optional:!0});c?l(c):(Be("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new Ei)}},0),a()}getToken(){const e=this.i,n=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(n).then(r=>this.i!==e?(Be("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):r?(Kt(typeof r.accessToken=="string"),new qA(r.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){const e=this.auth&&this.auth.getUid();return Kt(e===null||typeof e=="string"),new Rr(e)}}class h8{constructor(e,n,r){this.l=e,this.h=n,this.P=r,this.type="FirstParty",this.user=Rr.FIRST_PARTY,this.I=new Map}T(){return this.P?this.P():null}get headers(){this.I.set("X-Goog-AuthUser",this.l);const e=this.T();return e&&this.I.set("Authorization",e),this.h&&this.I.set("X-Goog-Iam-Authorization-Token",this.h),this.I}}class f8{constructor(e,n,r){this.l=e,this.h=n,this.P=r}getToken(){return Promise.resolve(new h8(this.l,this.h,this.P))}start(e,n){e.enqueueRetryable(()=>n(Rr.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class m8{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class p8{constructor(e){this.A=e,this.forceRefresh=!1,this.appCheck=null,this.R=null}start(e,n){Kt(this.o===void 0);const r=i=>{i.error!=null&&Be("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${i.error.message}`);const a=i.token!==this.R;return this.R=i.token,Be("FirebaseAppCheckTokenProvider",`Received ${a?"new":"existing"} token.`),a?n(i.token):Promise.resolve()};this.o=i=>{e.enqueueRetryable(()=>r(i))};const s=i=>{Be("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=i,this.o&&this.appCheck.addTokenListener(this.o)};this.A.onInit(i=>s(i)),setTimeout(()=>{if(!this.appCheck){const i=this.A.getImmediate({optional:!0});i?s(i):Be("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(n=>n?(Kt(typeof n.token=="string"),this.R=n.token,new m8(n.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}/** 1665 * @license 1666 * Copyright 2020 Google LLC 1667 * 1668 * Licensed under the Apache License, Version 2.0 (the "License");
1669 * you may not use this file except in compliance with the License. 1670 * You may obtain a copy of the License at 1671 * 1672 * http://www.apache.org/licenses/LICENSE-2.0 1673 * 1674 * Unless required by applicable law or agreed to in writing, software 1675 * distributed under the License is distributed on an "AS IS" BASIS, 1676 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1677 * See the License for the specific language governing permissions and 1678 * limitations under the License. 1679 */function g8(t){const e=typeof self<"u"&&(self.crypto||self.msCrypto),n=new Uint8Array(t);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(n);else for(let r=0;r<t;r++)n[r]=Math.floor(256*Math.random());return n}/** 1680 * @license 1681 * Copyright 2017 Google LLC 1682 * 1683 * Licensed under the Apache License, Version 2.0 (the "License"); 1684 * you may not use this file except in compliance with the License. 1685 * You may obtain a copy of the License at 1686 * 1687 * http://www.apache.org/licenses/LICENSE-2.0 1688 * 1689 * Unless required by applicable law or agreed to in writing, software 1690 * distributed under the License is distributed on an "AS IS" BASIS, 1691 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1692 * See the License for the specific language governing permissions and 1693 * limitations under the License. 1694 */class GA{static newId(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=Math.floor(256/e.length)*e.length;let r="";for(;r.length<20;){const s=g8(40);for(let i=0;i<s.length;++i)r.length<20&&s[i]<n&&(r+=e.charAt(s[i]%e.length))}return r}}function Mt(t,e){return t<e?-1:t>e?1:0}function Fu(t,e,n){return t.length===e.length&&t.every((r,s)=>n(r,e[s]))}/** 1695 * @license 1696 * Copyright 2017 Google LLC 1697 * 1698 * Licensed under the Apache License, Version 2.0 (the "License"); 1699 * you may not use this file except in compliance with the License. 1700 * You may obtain a copy of the License at 1701 * 1702 * http://www.apache.org/licenses/LICENSE-2.0 1703 * 1704 * Unless required by applicable law or agreed to in writing, software 1705 * distributed under the License is distributed on an "AS IS" BASIS, 1706 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1707 * See the License for the specific language governing permissions and 1708 * limitations under the License. 1709 */class gn{constructor(e,n){if(this.seconds=e,this.nanoseconds=n,n<0)throw new Me(fe.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+n);if(n>=1e9)throw new Me(fe.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+n);if(e<-62135596800)throw new Me(fe.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new Me(fe.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}static now(){return gn.fromMillis(Date.now())}static fromDate(e){return gn.fromMillis(e.getTime())}static fromMillis(e){const n=Math.floor(e/1e3),r=Math.floor(1e6*(e-1e3*n));return new gn(n,r)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?Mt(this.nanoseconds,e.nanoseconds):Mt(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){const e=this.seconds- -62135596800;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}/** 1710 * @license 1711 * Copyright 2017 Google LLC 1712 * 1713 * Licensed under the Apache License, Version 2.0 (the "License"); 1714 * you may not use this file except in compliance with the License. 1715 * You may obtain a copy of the License at 1716 * 1717 * http://www.apache.org/licenses/LICENSE-2.0 1718 * 1719 * Unless required by applicable law or agreed to in writing, software 1720 * distributed under the License is distributed on an "AS IS" BASIS, 1721 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1722 * See the License for the specific language governing permissions and 1723 * limitations under the License. 1724 */class at{constructor(e){this.timestamp=e}static fromTimestamp(e){return new at(e)}static min(){return new at(new gn(0,0))}static max(){return new at(new gn(253402300799,999999999))}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}/** 1725 * @license 1726 * Copyright 2017 Google LLC 1727 * 1728 * Licensed under the Apache License, Version 2.0 (the "License");
1729 * you may not use this file except in compliance with the License. 1730 * You may obtain a copy of the License at 1731 * 1732 * http://www.apache.org/licenses/LICENSE-2.0 1733 * 1734 * Unless required by applicable law or agreed to in writing, software 1735 * distributed under the License is distributed on an "AS IS" BASIS, 1736 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1737 * See the License for the specific language governing permissions and 1738 * limitations under the License. 1739 */class uf{constructor(e,n,r){n===void 0?n=0:n>e.length&&it(),r===void 0?r=e.length-n:r>e.length-n&&it(),this.segments=e,this.offset=n,this.len=r}get length(){return this.len}isEqual(e){return uf.comparator(this,e)===0}child(e){const n=this.segments.slice(this.offset,this.limit());return e instanceof uf?e.forEach(r=>{n.push(r)}):n.push(e),this.construct(n)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length<this.length)return!1;for(let n=0;n<this.length;n++)if(this.get(n)!==e.get(n))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let n=0;n<this.length;n++)if(this.get(n)!==e.get(n))return!1;return!0}forEach(e){for(let n=this.offset,r=this.limit();n<r;n++)e(this.segments[n])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,n){const r=Math.min(e.length,n.length);for(let s=0;s<r;s++){const i=e.get(s),a=n.get(s);if(i<a)return-1;if(i>a)return 1}return e.length<n.length?-1:e.length>n.length?1:0}}class mn extends uf{construct(e,n,r){return new mn(e,n,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const n=[];for(const r of e){if(r.indexOf("//")>=0)throw new Me(fe.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);n.push(...r.split("/").filter(s=>s.length>0))}return new mn(n)}static emptyPath(){return new mn([])}}const v8=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class gr extends uf{construct(e,n,r){return new gr(e,n,r)}static isValidIdentifier(e){return v8.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),gr.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)==="__name__"}static keyField(){return new gr(["__name__"])}static fromServerFormat(e){const n=[];let r="",s=0;const i=()=>{if(r.length===0)throw new Me(fe.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);n.push(r),r=""};let a=!1;for(;s<e.length;){const l=e[s];if(l==="\\"){if(s+1===e.length)throw new Me(fe.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const c=e[s+1];if(c!=="\\"&&c!=="."&&c!=="`")throw new Me(fe.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);r+=c,s+=2}else l==="`"?(a=!a,s++):l!=="."||a?(r+=l,s++):(i(),s++)}if(i(),a)throw new Me(fe.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new gr(n)}static emptyPath(){return new gr([])}}/** 1740 * @license 1741 * Copyright 2017 Google LLC 1742 * 1743 * Licensed under the Apache License, Version 2.0 (the "License"); 1744 * you may not use this file except in compliance with the License. 1745 * You may obtain a copy of the License at 1746 * 1747 * http://www.apache.org/licenses/LICENSE-2.0 1748 * 1749 * Unless required by applicable law or agreed to in writing, software 1750 * distributed under the License is distributed on an "AS IS" BASIS, 1751 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1752 * See the License for the specific language governing permissions and 1753 * limitations under the License. 1754 */class Ge{constructor(e){this.path=e}static fromPath(e){return new Ge(mn.fromString(e))}static fromName(e){return new Ge(mn.fromString(e).popFirst(5))}static empty(){return new Ge(mn.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&mn.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,n){return mn.comparator(e.path,n.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new Ge(new mn(e.slice()))}}function x8(t,e){const n=t.toTimestamp().seconds,r=t.toTimestamp().nanoseconds+1,s=at.fromTimestamp(r===1e9?new gn(n+1,0):new gn(n,r));return new $a(s,Ge.empty(),e)}function y8(t){return new $a(t.readTime,t.key,-1)}class $a{constructor(e,n,r){this.readTime=e,this.documentKey=n,this.largestBatchId=r}static min(){return new $a(at.min(),Ge.empty(),-1)}static max(){return new $a(at.max(),Ge.empty(),-1)}}function w8(t,e){let n=t.readTime.compareTo(e.readTime);return n!==0?n:(n=Ge.comparator(t.documentKey,e.documentKey),n!==0?n:Mt(t.largestBatchId,e.largestBatchId))}/** 1755 * @license 1756 * Copyright 2020 Google LLC 1757 * 1758 * Licensed under the Apache License, Version 2.0 (the "License");
1759 * you may not use this file except in compliance with the License. 1760 * You may obtain a copy of the License at 1761 * 1762 * http://www.apache.org/licenses/LICENSE-2.0 1763 * 1764 * Unless required by applicable law or agreed to in writing, software 1765 * distributed under the License is distributed on an "AS IS" BASIS, 1766 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1767 * See the License for the specific language governing permissions and 1768 * limitations under the License. 1769 */const b8="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class j8{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}/** 1770 * @license 1771 * Copyright 2017 Google LLC 1772 * 1773 * Licensed under the Apache License, Version 2.0 (the "License"); 1774 * you may not use this file except in compliance with the License. 1775 * You may obtain a copy of the License at 1776 * 1777 * http://www.apache.org/licenses/LICENSE-2.0 1778 * 1779 * Unless required by applicable law or agreed to in writing, software 1780 * distributed under the License is distributed on an "AS IS" BASIS, 1781 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1782 * See the License for the specific language governing permissions and 1783 * limitations under the License. 1784 */async function Wf(t){if(t.code!==fe.FAILED_PRECONDITION||t.message!==b8)throw t;Be("LocalStore","Unexpectedly lost primary lease")}/** 1785 * @license 1786 * Copyright 2017 Google LLC 1787 * 1788 * Licensed under the Apache License, Version 2.0 (the "License"); 1789 * you may not use this file except in compliance with the License. 1790 * You may obtain a copy of the License at 1791 * 1792 * http://www.apache.org/licenses/LICENSE-2.0 1793 * 1794 * Unless required by applicable law or agreed to in writing, software 1795 * distributed under the License is distributed on an "AS IS" BASIS, 1796 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1797 * See the License for the specific language governing permissions and 1798 * limitations under the License. 1799 */class ye{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(n=>{this.isDone=!0,this.result=n,this.nextCallback&&this.nextCallback(n)},n=>{this.isDone=!0,this.error=n,this.catchCallback&&this.catchCallback(n)})}catch(e){return this.next(void 0,e)}next(e,n){return this.callbackAttached&&it(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(n,this.error):this.wrapSuccess(e,this.result):new ye((r,s)=>{this.nextCallback=i=>{this.wrapSuccess(e,i).next(r,s)},this.catchCallback=i=>{this.wrapFailure(n,i).next(r,s)}})}toPromise(){return new Promise((e,n)=>{this.next(e,n)})}wrapUserFunction(e){try{const n=e();return n instanceof ye?n:ye.resolve(n)}catch(n){return ye.reject(n)}}wrapSuccess(e,n){return e?this.wrapUserFunction(()=>e(n)):ye.resolve(n)}wrapFailure(e,n){return e?this.wrapUserFunction(()=>e(n)):ye.reject(n)}static resolve(e){return new ye((n,r)=>{n(e)})}static reject(e){return new ye((n,r)=>{r(e)})}static waitFor(e){return new ye((n,r)=>{let s=0,i=0,a=!1;e.forEach(l=>{++s,l.next(()=>{++i,a&&i===s&&n()},c=>r(c))}),a=!0,i===s&&n()})}static or(e){let n=ye.resolve(!1);for(const r of e)n=n.next(s=>s?ye.resolve(s):r());return n}static forEach(e,n){const r=[];return e.forEach((s,i)=>{r.push(n.call(this,s,i))}),this.waitFor(r)}static mapArray(e,n){return new ye((r,s)=>{const i=e.length,a=new Array(i);let l=0;for(let c=0;c<i;c++){const d=c;n(e[d]).next(h=>{a[d]=h,++l,l===i&&r(a)},h=>s(h))}})}static doWhile(e,n){return new ye((r,s)=>{const i=()=>{e()===!0?n().next(()=>{i()},s):r()};i()})}}function C8(t){const e=t.match(/Android ([\d.]+)/i),n=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(n)}function Hf(t){return t.name==="IndexedDbTransactionError"}/** 1800 * @license 1801 * Copyright 2018 Google LLC 1802 * 1803 * Licensed under the Apache License, Version 2.0 (the "License"); 1804 * you may not use this file except in compliance with the License. 1805 * You may obtain a copy of the License at 1806 * 1807 * http://www.apache.org/licenses/LICENSE-2.0 1808 * 1809 * Unless required by applicable law or agreed to in writing, softw
vendor: 6,848 bytes, lines 1809-1844
1809are 1810 * distributed under the License is distributed on an "AS IS" BASIS, 1811 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1812 * See the License for the specific language governing permissions and 1813 * limitations under the License. 1814 */class nC{constructor(e,n){this.previousValue=e,n&&(n.sequenceNumberHandler=r=>this.ie(r),this.se=r=>n.writeSequenceNumber(r))}ie(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.se&&this.se(e),e}}nC.oe=-1;function Bv(t){return t==null}function Mg(t){return t===0&&1/t==-1/0}function N8(t){return typeof t=="number"&&Number.isInteger(t)&&!Mg(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER}/** 1815 * @license 1816 * Copyright 2017 Google LLC 1817 * 1818 * Licensed under the Apache License, Version 2.0 (the "License"); 1819 * you may not use this file except in compliance with the License. 1820 * You may obtain a copy of the License at 1821 * 1822 * http://www.apache.org/licenses/LICENSE-2.0 1823 * 1824 * Unless required by applicable law or agreed to in writing, software 1825 * distributed under the License is distributed on an "AS IS" BASIS, 1826 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1827 * See the License for the specific language governing permissions and 1828 * limitations under the License. 1829 */function yE(t){let e=0;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function pc(t,e){for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function ZA(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}/** 1830 * @license 1831 * Copyright 2017 Google LLC 1832 * 1833 * Licensed under the Apache License, Version 2.0 (the "License"); 1834 * you may not use this file except in compliance with the License. 1835 * You may obtain a copy of the License at 1836 * 1837 * http://www.apache.org/licenses/LICENSE-2.0 1838 * 1839 * Unless required by applicable law or agreed to in writing, software 1840 * distributed under the License is distributed on an "AS IS" BASIS, 1841 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1842 * See the License for the specific language governing permissions and 1843 * limitations under the License. 1844 */class _n{constructor(e,n){this.comparator=e,this.root=n||pr.EMPTY}insert(e,n){return new _n(this.comparator,this.root.insert(e,n,this.comparator).copy(null,null,pr.BLACK,null,null))}remove(e){return new _n(this.comparator,this.root.remove(e,this.comparator).copy(null,null,pr.BLACK,null,null))}get(e){let n=this.root;for(;!n.isEmpty();){const r=this.comparator(e,n.key);if(r===0)return n.value;r<0?n=n.left:r>0&&(n=n.right)}return null}indexOf(e){let n=0,r=this.root;for(;!r.isEmpty();){const s=this.comparator(e,r.key);if(s===0)return n+r.left.size;s<0?r=r.left:(n+=r.left.size+1,r=r.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal((n,r)=>(e(n,r),!1))}toString(){const e=[];return this.inorderTraversal((n,r)=>(e.push(`${n}:${r}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new ep(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new ep(this.root,e,this.comparator,!1)}getReverseIterator(){return new ep(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new ep(this.root,e,this.comparator,!0)}}class ep{constructor(e,n,r,s){this.isReverse=s,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=n?r(e.key,n):1,n&&s&&(i*=-1),i<0)e=this.isReverse?e.left:e.right;else{if(i===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const n={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return n}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class pr{constructor(e,n,r,s,i){this.key=e,this.value=n,this.color=r??pr.RED,this.left=s??pr.EMPTY,this.right=i??pr.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,n,r,s,i){return new pr(e??this.key,n??this.value,r??this.color,s??this.left,i??this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,n,r){let s=this;const i=r(e,s.key);return s=i<0?s.copy(null,null,null,s.left.insert(e,n,r),null):i===0?s.copy(null,n,null,null,null):s.copy(null,null,null,null,s.right.insert(e,n,r)),s.fixUp()}removeMin(){if(this.left.isEmpty())return pr.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,n){let r,s=this;if(n(e,s.key)<0)s.left.isEmpty()||s.left.isRed()||s.left.left.isRed()||(s=s.moveRedLeft()),s=s.copy(null,null,null,s.left.remove(e,n),null);else{if(s.left.isRed()&&(s=s.rotateRight()),s.right.isEmpty()||s.right.isRed()||s.right.left.isRed()||(s=s.moveRedRight()),n(e,s.key)===0){if(s.right.isEmpty())return pr.EMPTY;r=s.right.min(),s=s.copy(r.key,r.value,null,null,s.right.removeMin())}s=s.copy(null,null,null,null,s.right.remove(e,n))}return s.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){const e=this.copy(null,null,pr.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,pr.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const e=this.left.copy(null,null,!this.left.color,null,null),n=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,n)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed()||this.right.isRed())throw it();const e=this.left.check();if(e!==this.right.check())throw it();return e+(this.isRed()?0:1)}}pr.EMPTY=null,pr.RED=!0,pr.BLACK=!1;
1844pr.EMPTY=new class{constructor(){this.size=0}get key(){throw it()}get value(){throw it()}get color(){throw it()}get left(){throw it()}get right(){throw it()}copy(e,n,r,s,i){return this}insert(e,n,r){return new pr(e,n)}remove(e,n){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};/** 1845 * @license 1846 * Copyright 2017 Google LLC 1847 * 1848 * Licensed under the Apache License, Version 2.0 (the "License"); 1849 * you may not use this file except in compliance with the License. 1850 * You may obtain a copy of the License at 1851 * 1852 * http://www.apache.org/licenses/LICENSE-2.0 1853 * 1854 * Unless required by applicable law or agreed to in writing, software 1855 * distributed under the License is distributed on an "AS IS" BASIS, 1856 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1857 * See the License for the specific language governing permissions and 1858 * limitations under the License. 1859 */class xr{constructor(e){this.comparator=e,this.data=new _n(this.comparator)}has(e){return this.data.get(e)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal((n,r)=>(e(n),!1))}forEachInRange(e,n){const r=this.data.getIteratorFrom(e[0]);for(;r.hasNext();){const s=r.getNext();if(this.comparator(s.key,e[1])>=0)return;n(s.key)}}forEachWhile(e,n){let r;for(r=n!==void 0?this.data.getIteratorFrom(n):this.data.getIterator();r.hasNext();)if(!e(r.getNext().key))return}firstAfterOrEqual(e){const n=this.data.getIteratorFrom(e);return n.hasNext()?n.getNext().key:null}getIterator(){return new wE(this.data.getIterator())}getIteratorFrom(e){return new wE(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let n=this;return n.size<e.size&&(n=e,e=this),e.forEach(r=>{n=n.add(r)}),n}isEqual(e){if(!(e instanceof xr)||this.size!==e.size)return!1;const n=this.data.getIterator(),r=e.data.getIterator();for(;n.hasNext();){const s=n.getNext().key,i=r.getNext().key;if(this.comparator(s,i)!==0)return!1}return!0}toArray(){const e=[];return this.forEach(n=>{e.push(n)}),e}toString(){const e=[];return this.forEach(n=>e.push(n)),"SortedSet("+e.toString()+")"}copy(e){const n=new xr(this.comparator);return n.data=e,n}}class wE{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}/** 1860 * @license 1861 * Copyright 2020 Google LLC 1862 * 1863 * Licensed under the Apache License, Version 2.0 (the "License"); 1864 * you may not use this file except in compliance with the License. 1865 * You may obtain a copy of the License at 1866 * 1867 * http://www.apache.org/licenses/LICENSE-2.0 1868 * 1869 * Unless required by applicable law or agreed to in writing, software 1870 * distributed under the License is distributed on an "AS IS" BASIS, 1871 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1872 * See the License for the specific language governing permissions and 1873 * limitations under the License. 1874 */class Cs{constructor(e){this.fields=e,e.sort(gr.comparator)}static empty(){return new Cs([])}unionWith(e){let n=new xr(gr.comparator);for(const r of this.fields)n=n.add(r);for(const r of e)n=n.add(r);return new Cs(n.toArray())}covers(e){for(const n of this.fields)if(n.isPrefixOf(e))return!0;return!1}isEqual(e){return Fu(this.fields,e.fields,(n,r)=>n.isEqual(r))}}/** 1875 * @license 1876 * Copyright 2023 Google LLC 1877 * 1878 * Licensed under the Apache License, Version 2.0 (the "License"); 1879 * you may not use this file except in compliance with the License. 1880 * You may obtain a copy of the License at 1881 * 1882 * http://www.apache.org/licenses/LICENSE-2.0 1883 * 1884 * Unless required by applicable law or agreed to in writing, software 1885 * distributed under the License is distributed on an "AS IS" BASIS, 1886 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1887 * See the License for the specific language governing permissions and 1888 * limitations under the License.
1889 */class KA extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}/** 1890 * @license 1891 * Copyright 2020 Google LLC 1892 * 1893 * Licensed under the Apache License, Version 2.0 (the "License"); 1894 * you may not use this file except in compliance with the License. 1895 * You may obtain a copy of the License at 1896 * 1897 * http://www.apache.org/licenses/LICENSE-2.0 1898 * 1899 * Unless required by applicable law or agreed to in writing, software 1900 * distributed under the License is distributed on an "AS IS" BASIS, 1901 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1902 * See the License for the specific language governing permissions and 1903 * limitations under the License. 1904 */class Cr{constructor(e){this.binaryString=e}static fromBase64String(e){const n=function(s){try{return atob(s)}catch(i){throw typeof DOMException<"u"&&i instanceof DOMException?new KA("Invalid base64 string: "+i):i}}(e);return new Cr(n)}static fromUint8Array(e){const n=function(s){let i="";for(let a=0;a<s.length;++a)i+=String.fromCharCode(s[a]);return i}(e);return new Cr(n)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return function(n){return btoa(n)}(this.binaryString)}toUint8Array(){return function(n){const r=new Uint8Array(n.length);for(let s=0;s<n.length;s++)r[s]=n.charCodeAt(s);return r}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return Mt(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}Cr.EMPTY_BYTE_STRING=new Cr("");const _8=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Va(t){if(Kt(!!t),typeof t=="string"){let e=0;const n=_8.exec(t);if(Kt(!!n),n[1]){let s=n[1];s=(s+"000000000").substr(0,9),e=Number(s)}const r=new Date(t);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}return{seconds:Tn(t.seconds),nanos:Tn(t.nanos)}}function Tn(t){return typeof t=="number"?t:typeof t=="string"?Number(t):0}function Ql(t){return typeof t=="string"?Cr.fromBase64String(t):Cr.fromUint8Array(t)}/** 1905 * @license 1906 * Copyright 2020 Google LLC 1907 * 1908 * Licensed under the Apache License, Version 2.0 (the "License"); 1909 * you may not use this file except in compliance with the License. 1910 * You may obtain a copy of the License at 1911 * 1912 * http://www.apache.org/licenses/LICENSE-2.0 1913 * 1914 * Unless required by applicable law or agreed to in writing, software 1915 * distributed under the License is distributed on an "AS IS" BASIS, 1916 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1917 * See the License for the specific language governing permissions and 1918 * limitations under the License. 1919 */function rC(t){var e,n;return((n=(((e=t==null?void 0:t.mapValue)===null||e===void 0?void 0:e.fields)||{}).__type__)===null||n===void 0?void 0:n.stringValue)==="server_timestamp"}function sC(t){const e=t.mapValue.fields.__previous_value__;return rC(e)?sC(e):e}function df(t){const e=Va(t.mapValue.fields.__local_write_time__.timestampValue);return new gn(e.seconds,e.nanos)}/** 1920 * @license 1921 * Copyright 2017 Google LLC 1922 * 1923 * Licensed under the Apache License, Version 2.0 (the "License"); 1924 * you may not use this file except in compliance with the License. 1925 * You may obtain a copy of the License at 1926 * 1927 * http://www.apache.org/licenses/LICENSE-2.0 1928 * 1929 * Unless required by applicable law or agreed to in writing, software 1930 * distributed under the License is distributed on an "AS IS" BASIS, 1931 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1932 * See the License for the specific language governing permissions and 1933 * limitations under the License. 1934 */class E8{constructor(e,n,r,s,i,a,l,c,d){this.databaseId=e,this.appId=n,this.persistenceKey=r,this.host=s,this.ssl=i,this.forceLongPolling=a,this.autoDetectLongPolling=l,this.longPollingOptions=c,this.useFetchStreams=d}}class hf{constructor(e,n){this.projectId=e,this.database=n||"(default)"}static empty(){return new hf("","")}get isDefaultDatabase(){return this.database==="(default)"}isEqual(e){return e instanceof hf&&e.projectId===this.projectId&&e.database===this.database}}/** 1935 * @license 1936 * Copyright 2020 Google LLC 1937 * 1938 * Licensed under the Apache License, Version 2.0 (the "License");
1939 * you may not use this file except in compliance with the License. 1940 * You may obtain a copy of the License at 1941 * 1942 * http://www.apache.org/licenses/LICENSE-2.0 1943 * 1944 * Unless required by applicable law or agreed to in writing, software 1945 * distributed under the License is distributed on an "AS IS" BASIS, 1946 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1947 * See the License for the specific language governing permissions and 1948 * limitations under the License. 1949 */const tp={mapValue:{}};function Xl(t){return"nullValue"in t?0:"booleanValue"in t?1:"integerValue"in t||"doubleValue"in t?2:"timestampValue"in t?3:"stringValue"in t?5:"bytesValue"in t?6:"referenceValue"in t?7:"geoPointValue"in t?8:"arrayValue"in t?9:"mapValue"in t?rC(t)?4:k8(t)?9007199254740991:S8(t)?10:11:it()}function ti(t,e){if(t===e)return!0;const n=Xl(t);if(n!==Xl(e))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return t.booleanValue===e.booleanValue;case 4:return df(t).isEqual(df(e));case 3:return function(s,i){if(typeof s.timestampValue=="string"&&typeof i.timestampValue=="string"&&s.timestampValue.length===i.timestampValue.length)return s.timestampValue===i.timestampValue;const a=Va(s.timestampValue),l=Va(i.timestampValue);return a.seconds===l.seconds&&a.nanos===l.nanos}(t,e);case 5:return t.stringValue===e.stringValue;case 6:return function(s,i){return Ql(s.bytesValue).isEqual(Ql(i.bytesValue))}(t,e);case 7:return t.referenceValue===e.referenceValue;case 8:return function(s,i){return Tn(s.geoPointValue.latitude)===Tn(i.geoPointValue.latitude)&&Tn(s.geoPointValue.longitude)===Tn(i.geoPointValue.longitude)}(t,e);case 2:return function(s,i){if("integerValue"in s&&"integerValue"in i)return Tn(s.integerValue)===Tn(i.integerValue);if("doubleValue"in s&&"doubleValue"in i){const a=Tn(s.doubleValue),l=Tn(i.doubleValue);return a===l?Mg(a)===Mg(l):isNaN(a)&&isNaN(l)}return!1}(t,e);case 9:return Fu(t.arrayValue.values||[],e.arrayValue.values||[],ti);case 10:case 11:return function(s,i){const a=s.mapValue.fields||{},l=i.mapValue.fields||{};if(yE(a)!==yE(l))return!1;for(const c in a)if(a.hasOwnProperty(c)&&(l[c]===void 0||!ti(a[c],l[c])))return!1;return!0}(t,e);default:return it()}}function ff(t,e){return(t.values||[]).find(n=>ti(n,e))!==void 0}function zu(t,e){if(t===e)return 0;const n=Xl(t),r=Xl(e);if(n!==r)return Mt(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return Mt(t.booleanValue,e.booleanValue);case 2:return function(i,a){const l=Tn(i.integerValue||i.doubleValue),c=Tn(a.integerValue||a.doubleValue);return l<c?-1:l>c?1:l===c?0:isNaN(l)?isNaN(c)?0:-1:1}(t,e);case 3:return bE(t.timestampValue,e.timestampValue);case 4:return bE(df(t),df(e));case 5:return Mt(t.stringValue,e.stringValue);case 6:return function(i,a){const l=Ql(i),c=Ql(a);return l.compareTo(c)}(t.bytesValue,e.bytesValue);case 7:return function(i,a){const l=i.split("/"),c=a.split("/");for(let d=0;d<l.length&&d<c.length;d++){const h=Mt(l[d],c[d]);if(h!==0)return h}return Mt(l.length,c.length)}(t.referenceValue,e.referenceValue);case 8:return function(i,a){const l=Mt(Tn(i.latitude),Tn(a.latitude));return l!==0?l:Mt(Tn(i.longitude),Tn(a.longitude))}(t.geoPointValue,e.geoPointValue);case 9:return jE(t.arrayValue,e.arrayValue);case 10:return function(i,a){var l,c,d,h;const f=i.fields||{},p=a.fields||{},g=(l=f.value)===null||l===void 0?void 0:l.arrayValue,v=(c=p.value)===null||c===void 0?void 0:c.arrayValue,x=Mt(((d=g==null?void 0:g.values)===null||d===void 0?void 0:d.length)||0,((h=v==null?void 0:v.values)===null||h===void 0?void 0:h.length)||0);return x!==0?x:jE(g,v)}(t.mapValue,e.mapValue);case 11:return function(i,a){if(i===tp.mapValue&&a===tp.mapValue)return 0;if(i===tp.mapValue)return 1;if(a===tp.mapValue)return-1;const l=i.fields||{},c=Object.keys(l),d=a.fields||{},h=Object.keys(d);c.sort(),h.sort();for(let f=0;f<c.length&&f<h.length;++f){const p=Mt(c[f],h[f]);if(p!==0)return p;const g=zu(l[c[f]],d[h[f]]);if(g!==0)return g}return Mt(c.length,h.length)}(t.mapValue,e.mapValue);default:throw it()}}function bE(t,e){if(typeof t=="string"&&typeof e=="string"&&t.length===e.length)return Mt(t,e);const n=Va(t),r=Va(e),s=Mt(n.seconds,r.seconds);return s!==0?s:Mt(n.nanos,r.nanos)}function jE(t,e){const n=t.values||[],r=e.values||[];for(let s=0;s<n.length&&s<r.length;++s){const i=zu(n[s],r[s]);if(i)return i}return Mt(n.length,r.length)}function $u(t){return V0(t)}function V0(t){return"nullValue"in t?"null":"booleanValue"in t?""+t.booleanValue:"integerValue"in t?""+t.integerValue:"doubleValue"in t?""+t.doubleValue:"timestampValue"in t?function(n){const r=Va(n);return`time(${r.seconds},${r.nanos})`}(t.timestampValue):"stringValue"in t?t.stringValue:"bytesValue"in t?function(n){return Ql(n).toBase64()}(t.bytesValue):"referenceValue"in t?function(n){return Ge.fromName(n).toString()}(t.referenceValue):"geoPointValue"in t?function(n){return`geo(${n.latitude},${n.longitude})`}(t.geoPointValue):"arrayValue"in t?function(n){let r="[",s=!0;for(const i of n.values||[])s?s=!1:r+=",",r+=V0(i);return r+"]"}(t.arrayValue):"mapValue"in t?function(n){const r=Object.keys(n.fields||{}).sort();let s="{",i=!0;for(const a of r)i?i=!1:s+=",",s+=`${a}:${V0(n.fields[a])}`;return s+"}"}(t.mapValue):it()}function CE(t,e){return{referenceValue:`projects/${t.projectId}/databases/${t.database}/documents/${e.path.canonicalString()}`}}function U0(t){return!!t&&"integerValue"in t}function oC(t){return!!t&&"arrayValue"in t}function NE(t){return!!t&&"nullValue"in t}function _E(t){return!!t&&"doubleValue"in t&&isNaN(Number(t.doubleValue))}function Zp(t){return!!t&&"mapValue"in t}function S8(t){var e,n;return((n=(((e=t==null?void 0:t.mapValue)===null||e===void 0?void 0:e.fields)||{}).__type__)===null||n===void 0?void 0:n.stringValue)==="__vector__"}function Th(t){if(t.geoPointValue)return{geoPointValue:Object.assign({},t.geoPointValue)};if(t.timestampValue&&typeof t.timestampValue=="object")return{timestampValue:Object.assign({},t.timestampValue)};if(t.mapValue){const e={mapValue:{fields:{}}};return pc(t.mapValue.fields,(n,r)=>e.mapValue.fields[n]=Th(r)),e}if(t.arrayValue){const e={arrayValue:{values:[]}};for(let n=0;n<(t.arrayValue.values||[]).length;++n)e.arrayValue.values[n]=Th(t.arrayValue.values[n]);return e}return Object.assign({},t)}function k8(t){return(((t.mapValue||{}).fields||{}).__type__||{}).stringValue==="__max__"}/** 1950 * @license 1951 * Copyright 2017 Google LLC 1952 * 1953 * Licensed under the Apache License, Version 2.0 (the "License");
1954 * you may not use this file except in compliance with the License. 1955 * You may obtain a copy of the License at 1956 * 1957 * http://www.apache.org/licenses/LICENSE-2.0 1958 * 1959 * Unless required by applicable law or agreed to in writing, software 1960 * distributed under the License is distributed on an "AS IS" BASIS, 1961 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1962 * See the License for the specific language governing permissions and 1963 * limitations under the License. 1964 */class os{constructor(e){this.value=e}static empty(){return new os({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let n=this.value;for(let r=0;r<e.length-1;++r)if(n=(n.mapValue.fields||{})[e.get(r)],!Zp(n))return null;return n=(n.mapValue.fields||{})[e.lastSegment()],n||null}}set(e,n){this.getFieldsMap(e.popLast())[e.lastSegment()]=Th(n)}setAll(e){let n=gr.emptyPath(),r={},s=[];e.forEach((a,l)=>{if(!n.isImmediateParentOf(l)){const c=this.getFieldsMap(n);this.applyChanges(c,r,s),r={},s=[],n=l.popLast()}a?r[l.lastSegment()]=Th(a):s.push(l.lastSegment())});const i=this.getFieldsMap(n);this.applyChanges(i,r,s)}delete(e){const n=this.field(e.popLast());Zp(n)&&n.mapValue.fields&&delete n.mapValue.fields[e.lastSegment()]}isEqual(e){return ti(this.value,e.value)}getFieldsMap(e){let n=this.value;n.mapValue.fields||(n.mapValue={fields:{}});for(let r=0;r<e.length;++r){let s=n.mapValue.fields[e.get(r)];Zp(s)&&s.mapValue.fields||(s={mapValue:{fields:{}}},n.mapValue.fields[e.get(r)]=s),n=s}return n.mapValue.fields}applyChanges(e,n,r){pc(n,(s,i)=>e[s]=i);for(const s of r)delete e[s]}clone(){return new os(Th(this.value))}}function YA(t){const e=[];return pc(t.fields,(n,r)=>{const s=new gr([n]);if(Zp(r)){const i=YA(r.mapValue).fields;
vendor: 4,180 bytes, lines 1964-2004
1964if(i.length===0)e.push(s);else for(const a of i)e.push(s.child(a))}else e.push(s)}),new Cs(e)}/** 1965 * @license 1966 * Copyright 2017 Google LLC 1967 * 1968 * Licensed under the Apache License, Version 2.0 (the "License"); 1969 * you may not use this file except in compliance with the License. 1970 * You may obtain a copy of the License at 1971 * 1972 * http://www.apache.org/licenses/LICENSE-2.0 1973 * 1974 * Unless required by applicable law or agreed to in writing, software 1975 * distributed under the License is distributed on an "AS IS" BASIS, 1976 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1977 * See the License for the specific language governing permissions and 1978 * limitations under the License. 1979 */class Lr{constructor(e,n,r,s,i,a,l){this.key=e,this.documentType=n,this.version=r,this.readTime=s,this.createTime=i,this.data=a,this.documentState=l}static newInvalidDocument(e){return new Lr(e,0,at.min(),at.min(),at.min(),os.empty(),0)}static newFoundDocument(e,n,r,s){return new Lr(e,1,n,at.min(),r,s,0)}static newNoDocument(e,n){return new Lr(e,2,n,at.min(),at.min(),os.empty(),0)}static newUnknownDocument(e,n){return new Lr(e,3,n,at.min(),at.min(),os.empty(),2)}convertToFoundDocument(e,n){return!this.createTime.isEqual(at.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=e),this.version=e,this.documentType=1,this.data=n,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=os.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=os.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=at.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(e){return e instanceof Lr&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new Lr(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}/** 1980 * @license 1981 * Copyright 2022 Google LLC 1982 * 1983 * Licensed under the Apache License, Version 2.0 (the "License"); 1984 * you may not use this file except in compliance with the License. 1985 * You may obtain a copy of the License at 1986 * 1987 * http://www.apache.org/licenses/LICENSE-2.0 1988 * 1989 * Unless required by applicable law or agreed to in writing, software 1990 * distributed under the License is distributed on an "AS IS" BASIS, 1991 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1992 * See the License for the specific language governing permissions and 1993 * limitations under the License. 1994 */class Og{constructor(e,n){this.position=e,this.inclusive=n}}function EE(t,e,n){let r=0;for(let s=0;s<t.position.length;s++){const i=e[s],a=t.position[s];if(i.field.isKeyField()?r=Ge.comparator(Ge.fromName(a.referenceValue),n.key):r=zu(a,n.data.field(i.field)),i.dir==="desc"&&(r*=-1),r!==0)break}return r}function SE(t,e){if(t===null)return e===null;if(e===null||t.inclusive!==e.inclusive||t.position.length!==e.position.length)return!1;for(let n=0;n<t.position.length;n++)if(!ti(t.position[n],e.position[n]))return!1;return!0}/** 1995 * @license 1996 * Copyright 2022 Google LLC 1997 * 1998 * Licensed under the Apache License, Version 2.0 (the "License"); 1999 * you may not use this file except in compliance with the License. 2000 * You may obtain a copy of the License at 2001 * 2002 * http://www.apache.org/licenses/LICENSE-2.0 2003 * 2004 * Unless required by applicable law or agreed to in writing, softw
2004are 2005 * distributed under the License is distributed on an "AS IS" BASIS, 2006 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2007 * See the License for the specific language governing permissions and 2008 * limitations under the License. 2009 */class mf{constructor(e,n="asc"){this.field=e,this.dir=n}}function P8(t,e){return t.dir===e.dir&&t.field.isEqual(e.field)}/** 2010 * @license 2011 * Copyright 2022 Google LLC 2012 * 2013 * Licensed under the Apache License, Version 2.0 (the "License"); 2014 * you may not use this file except in compliance with the License. 2015 * You may obtain a copy of the License at 2016 * 2017 * http://www.apache.org/licenses/LICENSE-2.0 2018 * 2019 * Unless required by applicable law or agreed to in writing, software 2020 * distributed under the License is distributed on an "AS IS" BASIS, 2021 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2022 * See the License for the specific language governing permissions and 2023 * limitations under the License. 2024 */let QA=class{};class Wn extends QA{constructor(e,n,r){super(),this.field=e,this.op=n,this.value=r}static create(e,n,r){return e.isKeyField()?n==="in"||n==="not-in"?this.createKeyFieldInFilter(e,n,r):new T8(e,n,r):n==="array-contains"?new D8(e,r):n==="in"?new L8(e,r):n==="not-in"?new M8(e,r):n==="array-contains-any"?new O8(e,r):new Wn(e,n,r)}static createKeyFieldInFilter(e,n,r){return n==="in"?new A8(e,r):new R8(e,r)}matches(e){const n=e.data.field(this.field);return this.op==="!="?n!==null&&this.matchesComparison(zu(n,this.value)):n!==null&&Xl(this.value)===Xl(n)&&this.matchesComparison(zu(n,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return it()}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class jo extends QA{constructor(e,n){super(),this.filters=e,this.op=n,this.ae=null}static create(e,n){return new jo(e,n)}matches(e){return XA(this)?this.filters.find(n=>!n.matches(e))===void 0:this.filters.find(n=>n.matches(e))!==void 0}getFlattenedFilters(){return this.ae!==null||(this.ae=this.filters.reduce((e,n)=>e.concat(n.getFlattenedFilters()),[])),this.ae}getFilters(){return Object.assign([],this.filters)}}function XA(t){return t.op==="and"}function JA(t){return I8(t)&&XA(t)}function I8(t){for(const e of t.filters)if(e instanceof jo)return!1;return!0}function B0(t){if(t instanceof Wn)return t.field.canonicalString()+t.op.toString()+$u(t.value);if(JA(t))return t.filters.map(e=>B0(e)).join(",");{const e=t.filters.map(n=>B0(n)).join(",");return`${t.op}(${e})`}}function eR(t,e){return t instanceof Wn?function(r,s){return s instanceof Wn&&r.op===s.op&&r.field.isEqual(s.field)&&ti(r.value,s.value)}(t,e):t instanceof jo?function(r,s){return s instanceof jo&&r.op===s.op&&r.filters.length===s.filters.length?r.filters.reduce((i,a,l)=>i&&eR(a,s.filters[l]),!0):!1}(t,e):void it()}function tR(t){return t instanceof Wn?function(n){return`${n.field.canonicalString()} ${n.op} ${$u(n.value)}`}(t):t instanceof jo?function(n){return n.op.toString()+" {"+n.getFilters().map(tR).join(" ,")+"}"}(t):"Filter"}class T8 extends Wn{constructor(e,n,r){super(e,n,r),this.key=Ge.fromName(r.referenceValue)}matches(e){const n=Ge.comparator(e.key,this.key);return this.matchesComparison(n)}}class A8 extends Wn{constructor(e,n){super(e,"in",n),this.keys=nR("in",n)}matches(e){return this.keys.some(n=>n.isEqual(e.key))}}class R8 extends Wn{constructor(e,n){super(e,"not-in",n),this.keys=nR("not-in",n)}matches(e){return!this.keys.some(n=>n.isEqual(e.key))}}function nR(t,e){var n;return(((n=e.arrayValue)===null||n===void 0?void 0:n.values)||[]).map(r=>Ge.fromName(r.referenceValue))}class D8 extends Wn{constructor(e,n){super(e,"array-contains",n)}matches(e){const n=e.data.field(this.field);return oC(n)&&ff(n.arrayValue,this.value)}}class L8 extends Wn{constructor(e,n){super(e,"in",n)}matches(e){const n=e.data.field(this.field);return n!==null&&ff(this.value.arrayValue,n)}}class M8 extends Wn{constructor(e,n){super(e,"not-in",n)}matches(e){if(ff(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const n=e.data.field(this.field);return n!==null&&!ff(this.value.arrayValue,n)}}class O8 extends Wn{constructor(e,n){super(e,"array-contains-any",n)}matches(e){const n=e.data.field(this.field);return!(!oC(n)||!n.arrayValue.values)&&n.arrayValue.values.some(r=>ff(this.value.arrayValue,r))}}/** 2025 * @license 2026 * Copyright 2019 Google LLC 2027 * 2028 * Licensed under the Apache License, Version 2.0 (the "License");
2029 * you may not use this file except in compliance with the License. 2030 * You may obtain a copy of the License at 2031 * 2032 * http://www.apache.org/licenses/LICENSE-2.0 2033 * 2034 * Unless required by applicable law or agreed to in writing, software 2035 * distributed under the License is distributed on an "AS IS" BASIS, 2036 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2037 * See the License for the specific language governing permissions and 2038 * limitations under the License. 2039 */class F8{constructor(e,n=null,r=[],s=[],i=null,a=null,l=null){this.path=e,this.collectionGroup=n,this.orderBy=r,this.filters=s,this.limit=i,this.startAt=a,this.endAt=l,this.ue=null}}function kE(t,e=null,n=[],r=[],s=null,i=null,a=null){return new F8(t,e,n,r,s,i,a)}function iC(t){const e=lt(t);if(e.ue===null){let n=e.path.canonicalString();e.collectionGroup!==null&&(n+="|cg:"+e.collectionGroup),n+="|f:",n+=e.filters.map(r=>B0(r)).join(","),n+="|ob:",n+=e.orderBy.map(r=>function(i){return i.field.canonicalString()+i.dir}(r)).join(","),Bv(e.limit)||(n+="|l:",n+=e.limit),e.startAt&&(n+="|lb:",n+=e.startAt.inclusive?"b:":"a:",n+=e.startAt.position.map(r=>$u(r)).join(",")),e.endAt&&(n+="|ub:",n+=e.endAt.inclusive?"a:":"b:",n+=e.endAt.position.map(r=>$u(r)).join(",")),e.ue=n}return e.ue}function aC(t,e){if(t.limit!==e.limit||t.orderBy.length!==e.orderBy.length)return!1;for(let n=0;n<t.orderBy.length;n++)if(!P8(t.orderBy[n],e.orderBy[n]))return!1;if(t.filters.length!==e.filters.length)return!1;for(let n=0;n<t.filters.length;n++)if(!eR(t.filters[n],e.filters[n]))return!1;return t.collectionGroup===e.collectionGroup&&!!t.path.isEqual(e.path)&&!!SE(t.startAt,e.startAt)&&SE(t.endAt,e.endAt)}function W0(t){return Ge.isDocumentKey(t.path)&&t.collectionGroup===null&&t.filters.length===0}/** 2040 * @license 2041 * Copyright 2017 Google LLC 2042 * 2043 * Licensed under the Apache License, Version 2.0 (the "License"); 2044 * you may not use this file except in compliance with the License. 2045 * You may obtain a copy of the License at 2046 * 2047 * http://www.apache.org/licenses/LICENSE-2.0 2048 * 2049 * Unless required by applicable law or agreed to in writing, software 2050 * distributed under the License is distributed on an "AS IS" BASIS, 2051 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2052 * See the License for the specific language governing permissions and 2053 * limitations under the License. 2054 */class od{constructor(e,n=null,r=[],s=[],i=null,a="F",l=null,c=null){this.path=e,this.collectionGroup=n,this.explicitOrderBy=r,this.filters=s,this.limit=i,this.limitType=a,this.startAt=l,this.endAt=c,this.ce=null,this.le=null,this.he=null,this.startAt,this.endAt}}function z8(t,e,n,r,s,i,a,l){return new od(t,e,n,r,s,i,a,l)}function Wv(t){return new od(t)}function PE(t){return t.filters.length===0&&t.limit===null&&t.startAt==null&&t.endAt==null&&(t.explicitOrderBy.length===0||t.explicitOrderBy.length===1&&t.explicitOrderBy[0].field.isKeyField())}function rR(t){return t.collectionGroup!==null}function Ah(t){const e=lt(t);if(e.ce===null){e.ce=[];const n=new Set;for(const i of e.explicitOrderBy)e.ce.push(i),n.add(i.field.canonicalString());const r=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(a){let l=new xr(gr.comparator);return a.filters.forEach(c=>{c.getFlattenedFilters().forEach(d=>{d.isInequality()&&(l=l.add(d.field))})}),l})(e).forEach(i=>{n.has(i.canonicalString())||i.isKeyField()||e.ce.push(new mf(i,r))}),n.has(gr.keyField().canonicalString())||e.ce.push(new mf(gr.keyField(),r))}return e.ce}function Qo(t){const e=lt(t);return e.le||(e.le=$8(e,Ah(t))),e.le}function $8(t,e){if(t.limitType==="F")return kE(t.path,t.collectionGroup,e,t.filters,t.limit,t.startAt,t.endAt);{e=e.map(s=>{const i=s.dir==="desc"?"asc":"desc";return new mf(s.field,i)});const n=t.endAt?new Og(t.endAt.position,t.endAt.inclusive):null,r=t.startAt?new Og(t.startAt.position,t.startAt.inclusive):null;return kE(t.path,t.collectionGroup,e,t.filters,t.limit,n,r)}}function H0(t,e){const n=t.filters.concat([e]);return new od(t.path,t.collectionGroup,t.explicitOrderBy.slice(),n,t.limit,t.limitType,t.startAt,t.endAt)}function Fg(t,e,n){return new od(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}function Hv(t,e){return aC(Qo(t),Qo(e))&&t.limitType===e.limitType}function sR(t){return`${iC(Qo(t))}|lt:${t.limitType}`}function Wc(t){return`Query(target=${function(n){let r=n.path.canonicalString();return n.collectionGroup!==null&&(r+=" collectionGroup="+n.collectionGroup),n.filters.length>0&&(r+=`, filters: [${n.filters.map(s=>tR(s)).join(", ")}]`),Bv(n.limit)||(r+=", limit: "+n.limit),n.orderBy.length>0&&(r+=`, orderBy: [${n.orderBy.map(s=>function(a){return`${a.field.canonicalString()} (${a.dir})`}(s)).join(", ")}]`),n.startAt&&(r+=", startAt: ",r+=n.startAt.inclusive?"b:":"a:",r+=n.startAt.position.map(s=>$u(s)).join(",")),n.endAt&&(r+=", endAt: ",r+=n.endAt.inclusive?"a:":"b:",r+=n.endAt.position.map(s=>$u(s)).join(",")),`Target(${r})`}(Qo(t))}; limitType=${t.limitType})`}function qv(t,e){return e.isFoundDocument()&&function(r,s){const i=s.key.path;return r.collectionGroup!==null?s.key.hasCollectionId(r.collectionGroup)&&r.path.isPrefixOf(i):Ge.isDocumentKey(r.path)?r.path.isEqual(i):r.path.isImmediateParentOf(i)}(t,e)&&function(r,s){for(const i of Ah(r))if(!i.field.isKeyField()&&s.data.field(i.field)===null)return!1;return!0}(t,e)&&function(r,s){for(const i of r.filters)if(!i.matches(s))return!1;return!0}(t,e)&&function(r,s){return!(r.startAt&&!function(a,l,c){const d=EE(a,l,c);return a.inclusive?d<=0:d<0}(r.startAt,Ah(r),s)||r.endAt&&!function(a,l,c){const d=EE(a,l,c);return a.inclusive?d>=0:d>0}(r.endAt,Ah(r),s))}(t,e)}function V8(t){return t.collectionGroup||(t.path.length%2==1?t.path.lastSegment():t.path.get(t.path.length-2))}function oR(t){return(e,n)=>{let r=!1;for(const s of Ah(t)){const i=U8(s,e,n);if(i!==0)return i;r=r||s.field.isKeyField()}return 0}}function U8(t,e,n){const r=t.field.isKeyField()?Ge.comparator(e.key,n.key):function(i,a,l){const c=a.data.field(i),d=l.data.field(i);return c!==null&&d!==null?zu(c,d):it()}
2054(t.field,e,n);switch(t.dir){case"asc":return r;case"desc":return-1*r;default:return it()}}/** 2055 * @license 2056 * Copyright 2017 Google LLC 2057 * 2058 * Licensed under the Apache License, Version 2.0 (the "License"); 2059 * you may not use this file except in compliance with the License. 2060 * You may obtain a copy of the License at 2061 * 2062 * http://www.apache.org/licenses/LICENSE-2.0 2063 * 2064 * Unless required by applicable law or agreed to in writing, software 2065 * distributed under the License is distributed on an "AS IS" BASIS, 2066 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2067 * See the License for the specific language governing permissions and 2068 * limitations under the License. 2069 */class id{constructor(e,n){this.mapKeyFn=e,this.equalsFn=n,this.inner={},this.innerSize=0}get(e){const n=this.mapKeyFn(e),r=this.inner[n];if(r!==void 0){for(const[s,i]of r)if(this.equalsFn(s,e))return i}}has(e){return this.get(e)!==void 0}set(e,n){const r=this.mapKeyFn(e),s=this.inner[r];if(s===void 0)return this.inner[r]=[[e,n]],void this.innerSize++;for(let i=0;i<s.length;i++)if(this.equalsFn(s[i][0],e))return void(s[i]=[e,n]);s.push([e,n]),this.innerSize++}delete(e){const n=this.mapKeyFn(e),r=this.inner[n];if(r===void 0)return!1;for(let s=0;s<r.length;s++)if(this.equalsFn(r[s][0],e))return r.length===1?delete this.inner[n]:r.splice(s,1),this.innerSize--,!0;return!1}forEach(e){pc(this.inner,(n,r)=>{for(const[s,i]of r)e(s,i)})}isEmpty(){return ZA(this.inner)}size(){return this.innerSize}}/** 2070 * @license 2071 * Copyright 2017 Google LLC 2072 * 2073 * Licensed under the Apache License, Version 2.0 (the "License"); 2074 * you may not use this file except in compliance with the License. 2075 * You may obtain a copy of the License at 2076 * 2077 * http://www.apache.org/licenses/LICENSE-2.0 2078 * 2079 * Unless required by applicable law or agreed to in writing, software 2080 * distributed under the License is distributed on an "AS IS" BASIS, 2081 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2082 * See the License for the specific language governing permissions and 2083 * limitations under the License. 2084 */const B8=new _n(Ge.comparator);function Mi(){return B8}const iR=new _n(Ge.comparator);function dh(...t){let e=iR;for(const n of t)e=e.insert(n.key,n);return e}function aR(t){let e=iR;return t.forEach((n,r)=>e=e.insert(n,r.overlayedDocument)),e}function Dl(){return Rh()}function lR(){return Rh()}function Rh(){return new id(t=>t.toString(),(t,e)=>t.isEqual(e))}
2084const W8=new _n(Ge.comparator),H8=new xr(Ge.comparator);function jt(...t){let e=H8;for(const n of t)e=e.add(n);return e}const q8=new xr(Mt);function G8(){return q8}/** 2085 * @license 2086 * Copyright 2020 Google LLC 2087 * 2088 * Licensed under the Apache License, Version 2.0 (the "License"); 2089 * you may not use this file except in compliance with the License. 2090 * You may obtain a copy of the License at 2091 * 2092 * http://www.apache.org/licenses/LICENSE-2.0 2093 * 2094 * Unless required by applicable law or agreed to in writing, software 2095 * distributed under the License is distributed on an "AS IS" BASIS, 2096 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2097 * See the License for the specific language governing permissions and 2098 * limitations under the License. 2099 */function lC(t,e){if(t.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:Mg(e)?"-0":e}}function cR(t){return{integerValue:""+t}}function Z8(t,e){return N8(e)?cR(e):lC(t,e)}/** 2100 * @license 2101 * Copyright 2018 Google LLC 2102 * 2103 * Licensed under the Apache License, Version 2.0 (the "License"); 2104 * you may not use this file except in compliance with the License. 2105 * You may obtain a copy of the License at 2106 * 2107 * http://www.apache.org/licenses/LICENSE-2.0 2108 * 2109 * Unless required by applicable law or agreed to in writing, software 2110 * distributed under the License is distributed on an "AS IS" BASIS, 2111 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2112 * See the License for the specific language governing permissions and 2113 * limitations under the License. 2114 */class Gv{constructor(){this._=void 0}}function K8(t,e,n){return t instanceof pf?function(s,i){const a={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:s.seconds,nanos:s.nanoseconds}}}};return i&&rC(i)&&(i=sC(i)),i&&(a.fields.__previous_value__=i),{mapValue:a}}(n,e):t instanceof gf?dR(t,e):t instanceof vf?hR(t,e):function(s,i){const a=uR(s,i),l=IE(a)+IE(s.Pe);return U0(a)&&U0(s.Pe)?cR(l):lC(s.serializer,l)}(t,e)}function Y8(t,e,n){return t instanceof gf?dR(t,e):t instanceof vf?hR(t,e):n}function uR(t,e){return t instanceof zg?function(r){return U0(r)||function(i){return!!i&&"doubleValue"in i}(r)}(e)?e:{integerValue:0}:null}class pf extends Gv{}class gf extends Gv{constructor(e){super(),this.elements=e}}function dR(t,e){const n=fR(e);for(const r of t.elements)n.some(s=>ti(s,r))||n.push(r);return{arrayValue:{values:n}}}class vf extends Gv{constructor(e){super(),this.elements=e}}function hR(t,e){let n=fR(e);for(const r of t.elements)n=n.filter(s=>!ti(s,r));return{arrayValue:{values:n}}}class zg extends Gv{constructor(e,n){super(),this.serializer=e,this.Pe=n}}function IE(t){return Tn(t.integerValue||t.doubleValue)}function fR(t){return oC(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}/** 2115 * @license 2116 * Copyright 2017 Google LLC 2117 * 2118 * Licensed under the Apache License, Version 2.0 (the "License"); 2119 * you may not use this file except in compliance with the License. 2120 * You may obtain a copy of the License at 2121 * 2122 * http://www.apache.org/licenses/LICENSE-2.0 2123 * 2124 * Unless required by applicable law or agreed to in writing, software 2125 * distributed under the License is distributed on an "AS IS" BASIS, 2126 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2127 * See the License for the specific language governing permissions and 2128 * limitations under the License. 2129 */class Q8{constructor(e,n){this.field=e,this.transform=n}}function X8(t,e){return t.field.isEqual(e.field)&&function(r,s){return r instanceof gf&&s instanceof gf||r instanceof vf&&s instanceof vf?Fu(r.elements,s.elements,ti):r instanceof zg&&s instanceof zg?ti(r.Pe,s.Pe):r instanceof pf&&s instanceof pf}(t.transform,e.transform)}class J8{constructor(e,n){this.version=e,this.transformResults=n}}class Us{constructor(e,n){this.updateTime=e,this.exists=n}static none(){return new Us}static exists(e){return new Us(void 0,e)}static updateTime(e){return new Us(e)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function Kp(t,e){return t.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(t.updateTime):t.exists===void 0||t.exists===e.isFoundDocument()}class Zv{}function mR(t,e){if(!t.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return t.isNoDocument()?new cC(t.key,Us.none()):new qf(t.key,t.data,Us.none());{const n=t.data,r=os.empty();let s=new xr(gr.comparator);for(let i of e.fields)if(!s.has(i)){let a=n.field(i);a===null&&i.length>1&&(i=i.popLast(),a=n.field(i)),a===null?r.delete(i):r.set(i,a),s=s.add(i)}return new sl(t.key,r,new Cs(s.toArray()),Us.none())}}function eB(t,e,n){t instanceof qf?function(s,i,a){const l=s.value.clone(),c=AE(s.fieldTransforms,i,a.transformResults);l.setAll(c),i.convertToFoundDocument(a.version,l).setHasCommittedMutations()}
2129(t,e,n):t instanceof sl?function(s,i,a){if(!Kp(s.precondition,i))return void i.convertToUnknownDocument(a.version);const l=AE(s.fieldTransforms,i,a.transformResults),c=i.data;c.setAll(pR(s)),c.setAll(l),i.convertToFoundDocument(a.version,c).setHasCommittedMutations()}(t,e,n):function(s,i,a){i.convertToNoDocument(a.version).setHasCommittedMutations()}(0,e,n)}function Dh(t,e,n,r){return t instanceof qf?function(i,a,l,c){if(!Kp(i.precondition,a))return l;const d=i.value.clone(),h=RE(i.fieldTransforms,c,a);return d.setAll(h),a.convertToFoundDocument(a.version,d).setHasLocalMutations(),null}(t,e,n,r):t instanceof sl?function(i,a,l,c){if(!Kp(i.precondition,a))return l;const d=RE(i.fieldTransforms,c,a),h=a.data;return h.setAll(pR(i)),h.setAll(d),a.convertToFoundDocument(a.version,h).setHasLocalMutations(),l===null?null:l.unionWith(i.fieldMask.fields).unionWith(i.fieldTransforms.map(f=>f.field))}(t,e,n,r):function(i,a,l){return Kp(i.precondition,a)?(a.convertToNoDocument(a.version).setHasLocalMutations(),null):l}(t,e,n)}function tB(t,e){let n=null;for(const r of t.fieldTransforms){const s=e.data.field(r.field),i=uR(r.transform,s||null);i!=null&&(n===null&&(n=os.empty()),n.set(r.field,i))}return n||null}function TE(t,e){return t.type===e.type&&!!t.key.isEqual(e.key)&&!!t.precondition.isEqual(e.precondition)&&!!function(r,s){return r===void 0&&s===void 0||!(!r||!s)&&Fu(r,s,(i,a)=>X8(i,a))}(t.fieldTransforms,e.fieldTransforms)&&(t.type===0?t.value.isEqual(e.value):t.type!==1||t.data.isEqual(e.data)&&t.fieldMask.isEqual(e.fieldMask))}class qf extends Zv{constructor(e,n,r,s=[]){super(),this.key=e,this.value=n,this.precondition=r,this.fieldTransforms=s,this.type=0}getFieldMask(){return null}}class sl extends Zv{constructor(e,n,r,s,i=[]){super(),this.key=e,this.data=n,this.fieldMask=r,this.precondition=s,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}}function pR(t){const e=new Map;return t.fieldMask.fields.forEach(n=>{if(!n.isEmpty()){const r=t.data.field(n);e.set(n,r)}}),e}function AE(t,e,n){const r=new Map;Kt(t.length===n.length);for(let s=0;s<n.length;s++){const i=t[s],a=i.transform,l=e.data.field(i.field);r.set(i.field,Y8(a,l,n[s]))}return r}function RE(t,e,n){const r=new Map;for(const s of t){const i=s.transform,a=n.data.field(s.field);r.set(s.field,K8(i,a,e))}return r}class cC extends Zv{constructor(e,n){super(),this.key=e,this.precondition=n,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class nB extends Zv{constructor(e,n){super(),this.key=e,this.precondition=n,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}/** 2130 * @license 2131 * Copyright 2017 Google LLC 2132 * 2133 * Licensed under the Apache License, Version 2.0 (the "License"); 2134 * you may not use this file except in compliance with the License. 2135 * You may obtain a copy of the License at 2136 * 2137 * http://www.apache.org/licenses/LICENSE-2.0 2138 * 2139 * Unless required by applicable law or agreed to in writing, software 2140 * distributed under the License is distributed on an "AS IS" BASIS, 2141 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2142 * See the License for the specific language governing permissions and 2143 * limitations under the License. 2144 */class rB{constructor(e,n,r,s){this.batchId=e,this.localWriteTime=n,this.baseMutations=r,this.mutations=s}applyToRemoteDocument(e,n){const r=n.mutationResults;for(let s=0;s<this.mutations.length;s++){const i=this.mutations[s];i.key.isEqual(e.key)&&eB(i,e,r[s])}}applyToLocalView(e,n){for(const r of this.baseMutations)r.key.isEqual(e.key)&&(n=Dh(r,e,n,this.localWriteTime));for(const r of this.mutations)r.key.isEqual(e.key)&&(n=Dh(r,e,n,this.localWriteTime));return n}applyToLocalDocumentSet(e,n){const r=lR();return this.mutations.forEach(s=>{const i=e.get(s.key),a=i.overlayedDocument;let l=this.applyToLocalView(a,i.mutatedFields);l=n.has(s.key)?null:l;const c=mR(a,l);c!==null&&r.set(s.key,c),a.isValidDocument()||a.convertToNoDocument(at.min())}),r}keys(){return this.mutations.reduce((e,n)=>e.add(n.key),jt())}isEqual(e){return this.batchId===e.batchId&&Fu(this.mutations,e.mutations,(n,r)=>TE(n,r))&&Fu(this.baseMutations,e.baseMutations,(n,r)=>TE(n,r))}}class uC{constructor(e,n,r,s){this.batch=e,this.commitVersion=n,this.mutationResults=r,this.docVersions=s}static from(e,n,r){Kt(e.mutations.length===r.length);let s=function(){return W8}();const i=e.mutations;for(let a=0;a<i.length;a++)s=s.insert(i[a].key,r[a].version);
2144return new uC(e,n,r,s)}}/** 2145 * @license 2146 * Copyright 2022 Google LLC 2147 * 2148 * Licensed under the Apache License, Version 2.0 (the "License"); 2149 * you may not use this file except in compliance with the License. 2150 * You may obtain a copy of the License at 2151 * 2152 * http://www.apache.org/licenses/LICENSE-2.0 2153 * 2154 * Unless required by applicable law or agreed to in writing, software 2155 * distributed under the License is distributed on an "AS IS" BASIS, 2156 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2157 * See the License for the specific language governing permissions and 2158 * limitations under the License. 2159 */let sB=class{constructor(e,n){this.largestBatchId=e,this.mutation=n}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{ 2160 largestBatchId: ${this.largestBatchId}, 2161 mutation: ${this.mutation.toString()} 2162 }`}};/** 2163 * @license 2164 * Copyright 2017 Google LLC 2165 * 2166 * Licensed under the Apache License, Version 2.0 (the "License"); 2167 * you may not use this file except in compliance with the License. 2168 * You may obtain a copy of the License at 2169 * 2170 * http://www.apache.org/licenses/LICENSE-2.0 2171 * 2172 * Unless required by applicable law or agreed to in writing, software 2173 * distributed under the License is distributed on an "AS IS" BASIS, 2174 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2175 * See the License for the specific language governing permissions and 2176 * limitations under the License. 2177 */class oB{constructor(e,n){this.count=e,this.unchangedNames=n}}/** 2178 * @license 2179 * Copyright 2017 Google LLC 2180 * 2181 * Licensed under the Apache License, Version 2.0 (the "License"); 2182 * you may not use this file except in compliance with the License. 2183 * You may obtain a copy of the License at 2184 * 2185 * http://www.apache.org/licenses/LICENSE-2.0 2186 * 2187 * Unless required by applicable law or agreed to in writing, software 2188 * distributed under the License is distributed on an "AS IS" BASIS, 2189 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2190 * See the License for the specific language governing permissions and 2191 * limitations under the License. 2192 */var Un,Pt;function iB(t){switch(t){default:return it();case fe.CANCELLED:case fe.UNKNOWN:case fe.DEADLINE_EXCEEDED:case fe.RESOURCE_EXHAUSTED:case fe.INTERNAL:case fe.UNAVAILABLE:case fe.UNAUTHENTICATED:return!1;case fe.INVALID_ARGUMENT:case fe.NOT_FOUND:case fe.ALREADY_EXISTS:case fe.PERMISSION_DENIED:case fe.FAILED_PRECONDITION:case fe.ABORTED:case fe.OUT_OF_RANGE:case fe.UNIMPLEMENTED:case fe.DATA_LOSS:return!0}}function gR(t){if(t===void 0)return Li("GRPC error has no .code"),fe.UNKNOWN;switch(t){case Un.OK:return fe.OK;case Un.CANCELLED:return fe.CANCELLED;case Un.UNKNOWN:return fe.UNKNOWN;case Un.DEADLINE_EXCEEDED:return fe.DEADLINE_EXCEEDED;case Un.RESOURCE_EXHAUSTED:return fe.RESOURCE_EXHAUSTED;case Un.INTERNAL:return fe.INTERNAL;case Un.UNAVAILABLE:return fe.UNAVAILABLE;case Un.UNAUTHENTICATED:return fe.UNAUTHENTICATED;case Un.INVALID_ARGUMENT:return fe.INVALID_ARGUMENT;case Un.NOT_FOUND:return fe.NOT_FOUND;case Un.ALREADY_EXISTS:return fe.ALREADY_EXISTS;case Un.PERMISSION_DENIED:return fe.PERMISSION_DENIED;case Un.FAILED_PRECONDITION:return fe.FAILED_PRECONDITION;case Un.ABORTED:return fe.ABORTED;case Un.OUT_OF_RANGE:return fe.OUT_OF_RANGE;case Un.UNIMPLEMENTED:return fe.UNIMPLEMENTED;case Un.DATA_LOSS:return fe.DATA_LOSS;default:return it()}}(Pt=Un||(Un={}))[Pt.OK=0]="OK",Pt[Pt.CANCELLED=1]="CANCELLED",Pt[Pt.UNKNOWN=2]="UNKNOWN",Pt[Pt.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",Pt[Pt.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",Pt[Pt.NOT_FOUND=5]="NOT_FOUND",Pt[Pt.ALREADY_EXISTS=6]="ALREADY_EXISTS",Pt[Pt.PERMISSION_DENIED=7]="PERMISSION_DENIED",Pt[Pt.UNAUTHENTICATED=16]="UNAUTHENTICATED",Pt[Pt.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",Pt[Pt.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",Pt[Pt.ABORTED=10]="ABORTED",Pt[Pt.OUT_OF_RANGE=11]="OUT_OF_RANGE",Pt[Pt.UNIMPLEMENTED=12]="UNIMPLEMENTED",Pt[Pt.INTERNAL=13]="INTERNAL",Pt[Pt.UNAVAILABLE=14]="UNAVAILABLE",Pt[Pt.DATA_LOSS=15]="DATA_LOSS";/** 2193 * @license 2194 * Copyright 2023 Google LLC 2195 * 2196 * Licensed under the Apache License, Version 2.0 (the "License");
2197 * you may not use this file except in compliance with the License. 2198 * You may obtain a copy of the License at 2199 * 2200 * http://www.apache.org/licenses/LICENSE-2.0 2201 * 2202 * Unless required by applicable law or agreed to in writing, software 2203 * distributed under the License is distributed on an "AS IS" BASIS, 2204 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2205 * See the License for the specific language governing permissions and 2206 * limitations under the License. 2207 */function aB(){return new TextEncoder}/** 2208 * @license 2209 * Copyright 2022 Google LLC 2210 * 2211 * Licensed under the Apache License, Version 2.0 (the "License"); 2212 * you may not use this file except in compliance with the License. 2213 * You may obtain a copy of the License at 2214 * 2215 * http://www.apache.org/licenses/LICENSE-2.0 2216 * 2217 * Unless required by applicable law or agreed to in writing, software 2218 * distributed under the License is distributed on an "AS IS" BASIS, 2219 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2220 * See the License for the specific language governing permissions and 2221 * limitations under the License. 2222 */const lB=new zl([4294967295,4294967295],0);function DE(t){const e=aB().encode(t),n=new $A;return n.update(e),new Uint8Array(n.digest())}function LE(t){const e=new DataView(t.buffer),n=e.getUint32(0,!0),r=e.getUint32(4,!0),s=e.getUint32(8,!0),i=e.getUint32(12,!0);return[new zl([n,r],0),new zl([s,i],0)]}class dC{constructor(e,n,r){if(this.bitmap=e,this.padding=n,this.hashCount=r,n<0||n>=8)throw new hh(`Invalid padding: ${n}`);if(r<0)throw new hh(`Invalid hash count: ${r}`);if(e.length>0&&this.hashCount===0)throw new hh(`Invalid hash count: ${r}`);if(e.length===0&&n!==0)throw new hh(`Invalid padding when bitmap length is 0: ${n}`);this.Ie=8*e.length-n,this.Te=zl.fromNumber(this.Ie)}Ee(e,n,r){let s=e.add(n.multiply(zl.fromNumber(r)));return s.compare(lB)===1&&(s=new zl([s.getBits(0),s.getBits(1)],0)),s.modulo(this.Te).toNumber()}de(e){return(this.bitmap[Math.floor(e/8)]&1<<e%8)!=0}mightContain(e){if(this.Ie===0)return!1;const n=DE(e),[r,s]=LE(n);for(let i=0;i<this.hashCount;i++){const a=this.Ee(r,s,i);if(!this.de(a))return!1}return!0}static create(e,n,r){const s=e%8==0?0:8-e%8,i=new Uint8Array(Math.ceil(e/8)),a=new dC(i,s,n);return r.forEach(l=>a.insert(l)),a}insert(e){if(this.Ie===0)return;const n=DE(e),[r,s]=LE(n);for(let i=0;i<this.hashCount;i++){const a=this.Ee(r,s,i);this.Ae(a)}}Ae(e){const n=Math.floor(e/8),r=e%8;this.bitmap[n]|=1<<r}}class hh extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}/** 2223 * @license 2224 * Copyright 2017 Google LLC 2225 * 2226 * Licensed under the Apache License, Version 2.0 (the "License"); 2227 * you may not use this file except in compliance with the License. 2228 * You may obtain a copy of the License at 2229 * 2230 * http://www.apache.org/licenses/LICENSE-2.0 2231 * 2232 * Unless required by applicable law or agreed to in writing, software 2233 * distributed under the License is distributed on an "AS IS" BASIS, 2234 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2235 * See the License for the specific language governing permissions and 2236 * limitations under the License. 2237 */class Kv{constructor(e,n,r,s,i){this.snapshotVersion=e,this.targetChanges=n,this.targetMismatches=r,this.documentUpdates=s,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(e,n,r){const s=new Map;return s.set(e,Gf.createSynthesizedTargetChangeForCurrentChange(e,n,r)),new Kv(at.min(),s,new _n(Mt),Mi(),jt())}}class Gf{constructor(e,n,r,s,i){this.resumeToken=e,this.current=n,this.addedDocuments=r,this.modifiedDocuments=s,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(e,n,r){return new Gf(r,n,jt(),jt(),jt())}}/** 2238 * @license 2239 * Copyright 2017 Google LLC 2240 * 2241 * Licensed under the Apache License, Version 2.0 (the "License"); 2242 * you may not use this file except in compliance with the License. 2243 * You may obtain a copy of the License at 2244 * 2245 * http://www.apache.org/licenses/LICENSE-2.0 2246 * 2247 * Unless required by applicable law or agreed to in writing, softw
2247are 2248 * distributed under the License is distributed on an "AS IS" BASIS, 2249 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2250 * See the License for the specific language governing permissions and 2251 * limitations under the License. 2252 */class Yp{constructor(e,n,r,s){this.Re=e,this.removedTargetIds=n,this.key=r,this.Ve=s}}class vR{constructor(e,n){this.targetId=e,this.me=n}}class xR{constructor(e,n,r=Cr.EMPTY_BYTE_STRING,s=null){this.state=e,this.targetIds=n,this.resumeToken=r,this.cause=s}}class ME{constructor(){this.fe=0,this.ge=FE(),this.pe=Cr.EMPTY_BYTE_STRING,this.ye=!1,this.we=!0}get current(){return this.ye}get resumeToken(){return this.pe}get Se(){return this.fe!==0}get be(){return this.we}De(e){e.approximateByteSize()>0&&(this.we=!0,this.pe=e)}ve(){let e=jt(),n=jt(),r=jt();return this.ge.forEach((s,i)=>{switch(i){case 0:e=e.add(s);break;case 2:n=n.add(s);break;case 1:r=r.add(s);break;default:it()}}),new Gf(this.pe,this.ye,e,n,r)}Ce(){this.we=!1,this.ge=FE()}Fe(e,n){this.we=!0,this.ge=this.ge.insert(e,n)}Me(e){this.we=!0,this.ge=this.ge.remove(e)}xe(){this.fe+=1}Oe(){this.fe-=1,Kt(this.fe>=0)}Ne(){this.we=!0,this.ye=!0}}class cB{constructor(e){this.Le=e,this.Be=new Map,this.ke=Mi(),this.qe=OE(),this.Qe=new _n(Mt)}Ke(e){for(const n of e.Re)e.Ve&&e.Ve.isFoundDocument()?this.$e(n,e.Ve):this.Ue(n,e.key,e.Ve);for(const n of e.removedTargetIds)this.Ue(n,e.key,e.Ve)}We(e){this.forEachTarget(e,n=>{const r=this.Ge(n);switch(e.state){case 0:this.ze(n)&&r.De(e.resumeToken);break;case 1:r.Oe(),r.Se||r.Ce(),r.De(e.resumeToken);break;case 2:r.Oe(),r.Se||this.removeTarget(n);break;case 3:this.ze(n)&&(r.Ne(),r.De(e.resumeToken));break;case 4:this.ze(n)&&(this.je(n),r.De(e.resumeToken));break;default:it()}})}forEachTarget(e,n){e.targetIds.length>0?e.targetIds.forEach(n):this.Be.forEach((r,s)=>{this.ze(s)&&n(s)})}He(e){const n=e.targetId,r=e.me.count,s=this.Je(n);if(s){const i=s.target;if(W0(i))if(r===0){const a=new Ge(i.path);this.Ue(n,a,Lr.newNoDocument(a,at.min()))}else Kt(r===1);else{const a=this.Ye(n);if(a!==r){const l=this.Ze(e),c=l?this.Xe(l,e,a):1;if(c!==0){this.je(n);const d=c===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Qe=this.Qe.insert(n,d)}}}}}Ze(e){const n=e.me.unchangedNames;if(!n||!n.bits)return null;const{bits:{bitmap:r="",padding:s=0},hashCount:i=0}=n;let a,l;try{a=Ql(r).toUint8Array()}catch(c){if(c instanceof KA)return Ou("Decoding the base64 bloom filter in existence filter failed ("+c.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw c}try{l=new dC(a,s,i)}catch(c){return Ou(c instanceof hh?"BloomFilter error: ":"Applying bloom filter failed: ",c),null}return l.Ie===0?null:l}Xe(e,n,r){return n.me.count===r-this.nt(e,n.targetId)?0:2}nt(e,n){const r=this.Le.getRemoteKeysForTarget(n);let s=0;return r.forEach(i=>{const a=this.Le.tt(),l=`projects/${a.projectId}/databases/${a.database}/documents/${i.path.canonicalString()}`;e.mightContain(l)||(this.Ue(n,i,null),s++)}),s}rt(e){const n=new Map;this.Be.forEach((i,a)=>{const l=this.Je(a);if(l){if(i.current&&W0(l.target)){const c=new Ge(l.target.path);this.ke.get(c)!==null||this.it(a,c)||this.Ue(a,c,Lr.newNoDocument(c,e))}i.be&&(n.set(a,i.ve()),i.Ce())}});let r=jt();this.qe.forEach((i,a)=>{let l=!0;a.forEachWhile(c=>{const d=this.Je(c);return!d||d.purpose==="TargetPurposeLimboResolution"||(l=!1,!1)}),l&&(r=r.add(i))}),this.ke.forEach((i,a)=>a.setReadTime(e));const s=new Kv(e,n,this.Qe,this.ke,r);return this.ke=Mi(),this.qe=OE(),this.Qe=new _n(Mt),s}$e(e,n){if(!this.ze(e))return;const r=this.it(e,n.key)?2:0;this.Ge(e).Fe(n.key,r),this.ke=this.ke.insert(n.key,n),this.qe=this.qe.insert(n.key,this.st(n.key).add(e))}Ue(e,n,r){if(!this.ze(e))return;const s=this.Ge(e);this.it(e,n)?s.Fe(n,1):s.Me(n),this.qe=this.qe.insert(n,this.st(n).delete(e)),r&&(this.ke=this.ke.insert(n,r))}removeTarget(e){this.Be.delete(e)}Ye(e){const n=this.Ge(e).ve();return this.Le.getRemoteKeysForTarget(e).size+n.addedDocuments.size-n.removedDocuments.size}xe(e){this.Ge(e).xe()}Ge(e){let n=this.Be.get(e);return n||(n=new ME,this.Be.set(e,n)),n}st(e){let n=this.qe.get(e);return n||(n=new xr(Mt),this.qe=this.qe.insert(e,n)),n}ze(e){const n=this.Je(e)!==null;return n||Be("WatchChangeAggregator","Detected inactive target",e),n}Je(e){const n=this.Be.get(e);return n&&n.Se?null:this.Le.ot(e)}je(e){this.Be.set(e,new ME),this.Le.getRemoteKeysForTarget(e).forEach(n=>{this.Ue(e,n,null)})}it(e,n){return this.Le.getRemoteKeysForTarget(e).has(n)}}function OE(){return new _n(Ge.comparator)}function FE(){return new _n(Ge.comparator)}const uB={asc:"ASCENDING",desc:"DESCENDING"},dB={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},hB={and:"AND",or:"OR"};class fB{constructor(e,n){this.databaseId=e,this.useProto3Json=n}}function q0(t,e){return t.useProto3Json||Bv(e)?e:{value:e}}function $g(t,e){return t.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function yR(t,e){return t.useProto3Json?e.toBase64():e.toUint8Array()}function mB(t,e){return $g(t,e.toTimestamp())}function Xo(t){return Kt(!!t),at.fromTimestamp(function(n){const r=Va(n);return new gn(r.seconds,r.nanos)}(t))}function hC(t,e){return G0(t,e).canonicalString()}function G0(t,e){const n=function(s){return new mn(["projects",s.projectId,"databases",s.database])}(t).child("documents");return e===void 0?n:n.child(e)}function wR(t){const e=mn.fromString(t);return Kt(_R(e)),e}function Z0(t,e){return hC(t.databaseId,e.path)}function Ry(t,e){const n=wR(e);if(n.get(1)!==t.databaseId.projectId)throw new Me(fe.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+t.databaseId.projectId);if(n.get(3)!==t.databaseId.database)throw new Me(fe.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+t.databaseId.database);return new Ge(jR(n))}function bR(t,e){return hC(t.databaseId,e)}function pB(t){const e=wR(t);return e.length===4?mn.emptyPath():jR(e)}function K0(t){return new mn(["projects",t.databaseId.projectId,"databases",t.databaseId.database]).canonicalString()}function jR(t){return Kt(t.length>4&&t.get(4)==="documents"),t.popFirst(5)}function zE(t,e,n){return{name:Z0(t,e),fields:n.value.mapValue.fields}}function gB(t,e){let n;if("targetChange"in e){e.targetChange;const r=function(d){return d==="NO_CHANGE"?0:d==="ADD"?1:d==="REMOVE"?2:d==="CURRENT"?3:d==="RESET"?4:it()}(e.targetChange.targetChangeType||"NO_CHANGE"),s=e.targetChange.targetIds||[],i=function(d,h){return d.useProto3Json?(Kt(h===void 0||typeof h=="string"),Cr.fromBase64String(h||"")):(Kt(h===void 0||h instanceof Buffer||h instanceof Uint8Array),Cr.fromUint8Array(h||new Uint8Array))}(t,e.targetChange.resumeToken),a=e.targetChange.cause,l=a&&function(d){const h=d.code===void 0?fe.UNKNOWN:gR(d.code);return new Me(h,d.message||"")}(a);n=new xR(r,s,i,l||null)}else if("documentChange"in e){e.documentChange;const r=e.documentChange;r.document,r.document.name,r.document.updateTime;const s=Ry(t,r.document.name),i=Xo(r.document.updateTime),a=r.document.createTime?Xo(r.document.createTime):at.min(),l=new os({mapValue:{fields:r.document.fields}}),c=Lr.newFoundDocument(s,i,a,l),d=r.targetIds||[],h=r.removedTargetIds||[];n=new Yp(d,h,c.key,c)}else if("documentDelete"in e){e.documentDelete;const r=e.documentDelete;r.document;const s=Ry(t,r.document),i=r.readTime?Xo(r.readTime):at.min(),a=Lr.newNoDocument(s,i),l=r.removedTargetIds||[];n=new Yp([],l,a.key,a)}else if("documentRemove"in e){e.documentRemove;const r=e.documentRemove;r.document;const s=Ry(t,r.document),i=r.removedTargetIds||[];n=new Yp([],i,s,null)}else{if(!("filter"in e))return it();{e.filter;const r=e.filter;r.targetId;const{count:s=0,unchangedNames:i}=r,a=new oB(s,i),l=r.targetId;n=new vR(l,a)}}return n}function vB(t,e){let n;if(e instanceof qf)n={update:zE(t,e.key,e.value)};else if(e instanceof cC)n={delete:Z0(t,e.key)};else if(e instanceof sl)n={update:zE(t,e.key,e.data),updateMask:EB(e.fieldMask)};else{if(!(e instanceof nB))return it();n={verify:Z0(t,e.key)}}return e.fieldTransforms.length>0&&(n.updateTransforms=e.fieldTransforms.map(r=>function(i,a){const l=a.transform;if(l instanceof pf)return{fieldPath:a.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(l instanceof gf)return{fieldPath:a.field.canonicalString(),appendMissingElements:{values:l.elements}};if(l instanceof vf)return{fieldPath:a.field.canonicalString(),removeAllFromArray:{values:l.elements}};if(l instanceof zg)return{fieldPath:a.field.canonicalString(),increment:l.Pe};throw it()}(0,r))),e.precondition.isNone||(n.currentDocument=function(s,i){return i.updateTime!==void 0?{updateTime:mB(s,i.updateTime)}:i.exists!==void 0?{exists:i.exists}:it()}(t,e.precondition)),n}function xB(t,e){return t&&t.length>0?(Kt(e!==void 0),t.map(n=>function(s,i){let a=s.updateTime?Xo(s.updateTime):Xo(i);return a.isEqual(at.min())&&(a=Xo(i)),new J8(a,s.transformResults||[])}(n,e))):[]}function yB(t,e){return{documents:[bR(t,e.path)]}}function wB(t,e){const n={structuredQuery:{}},r=e.path;let s;e.collectionGroup!==null?(s=r,n.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(s=r.popLast(),n.structuredQuery.from=[{collectionId:r.lastSegment()}]),n.parent=bR(t,s);const i=function(d){if(d.length!==0)return NR(jo.create(d,"and"))}(e.filters);i&&(n.structuredQuery.where=i);const a=function(d){if(d.length!==0)return d.map(h=>function(p){return{field:Hc(p.field),direction:CB(p.dir)}}(h))}(e.orderBy);a&&(n.structuredQuery.orderBy=a);const l=q0(t,e.limit);return l!==null&&(n.structuredQuery.limit=l),e.startAt&&(n.structuredQuery.startAt=function(d){return{before:d.inclusive,values:d.position}}(e.startAt)),e.endAt&&(n.structuredQuery.endAt=function(d){return{before:!d.inclusive,values:d.position}}(e.endAt)),{_t:n,parent:s}}function bB(t){let e=pB(t.parent);
2252const n=t.structuredQuery,r=n.from?n.from.length:0;let s=null;if(r>0){Kt(r===1);const h=n.from[0];h.allDescendants?s=h.collectionId:e=e.child(h.collectionId)}let i=[];n.where&&(i=function(f){const p=CR(f);return p instanceof jo&&JA(p)?p.getFilters():[p]}(n.where));let a=[];n.orderBy&&(a=function(f){return f.map(p=>function(v){return new mf(qc(v.field),function(y){switch(y){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(v.direction))}(p))}(n.orderBy));let l=null;n.limit&&(l=function(f){let p;return p=typeof f=="object"?f.value:f,Bv(p)?null:p}(n.limit));let c=null;n.startAt&&(c=function(f){const p=!!f.before,g=f.values||[];return new Og(g,p)}(n.startAt));let d=null;return n.endAt&&(d=function(f){const p=!f.before,g=f.values||[];return new Og(g,p)}(n.endAt)),z8(e,s,a,i,l,"F",c,d)}function jB(t,e){const n=function(s){switch(s){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return it()}}(e.purpose);return n==null?null:{"goog-listen-tags":n}}function CR(t){return t.unaryFilter!==void 0?function(n){switch(n.unaryFilter.op){case"IS_NAN":const r=qc(n.unaryFilter.field);return Wn.create(r,"==",{doubleValue:NaN});case"IS_NULL":const s=qc(n.unaryFilter.field);return Wn.create(s,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const i=qc(n.unaryFilter.field);return Wn.create(i,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const a=qc(n.unaryFilter.field);return Wn.create(a,"!=",{nullValue:"NULL_VALUE"});default:return it()}}(t):t.fieldFilter!==void 0?function(n){return Wn.create(qc(n.fieldFilter.field),function(s){switch(s){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return it()}}(n.fieldFilter.op),n.fieldFilter.value)}(t):t.compositeFilter!==void 0?function(n){return jo.create(n.compositeFilter.filters.map(r=>CR(r)),function(s){switch(s){case"AND":return"and";case"OR":return"or";default:return it()}}(n.compositeFilter.op))}(t):it()}function CB(t){return uB[t]}function NB(t){return dB[t]}function _B(t){return hB[t]}function Hc(t){return{fieldPath:t.canonicalString()}}function qc(t){return gr.fromServerFormat(t.fieldPath)}function NR(t){return t instanceof Wn?function(n){if(n.op==="=="){if(_E(n.value))return{unaryFilter:{field:Hc(n.field),op:"IS_NAN"}};if(NE(n.value))return{unaryFilter:{field:Hc(n.field),op:"IS_NULL"}}}else if(n.op==="!="){if(_E(n.value))return{unaryFilter:{field:Hc(n.field),op:"IS_NOT_NAN"}};if(NE(n.value))return{unaryFilter:{field:Hc(n.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Hc(n.field),op:NB(n.op),value:n.value}}}(t):t instanceof jo?function(n){const r=n.getFilters().map(s=>NR(s));return r.length===1?r[0]:{compositeFilter:{op:_B(n.op),filters:r}}}(t):it()}function EB(t){const e=[];return t.fields.forEach(n=>e.push(n.canonicalString())),{fieldPaths:e}}function _R(t){return t.length>=4&&t.get(0)==="projects"&&t.get(2)==="databases"}/** 2253 * @license 2254 * Copyright 2017 Google LLC 2255 * 2256 * Licensed under the Apache License, Version 2.0 (the "License"); 2257 * you may not use this file except in compliance with the License. 2258 * You may obtain a copy of the License at 2259 * 2260 * http://www.apache.org/licenses/LICENSE-2.0 2261 * 2262 * Unless required by applicable law or agreed to in writing, software 2263 * distributed under the License is distributed on an "AS IS" BASIS, 2264 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2265 * See the License for the specific language governing permissions and 2266 * limitations under the License. 2267 */class ya{constructor(e,n,r,s,i=at.min(),a=at.min(),l=Cr.EMPTY_BYTE_STRING,c=null){this.target=e,this.targetId=n,this.purpose=r,this.sequenceNumber=s,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=a,this.resumeToken=l,this.expectedCount=c}withSequenceNumber(e){return new ya(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,n){return new ya(this.target,this.targetId,this.purpose,this.sequenceNumber,n,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new ya(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new ya(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}/** 2268 * @license 2269 * Copyright 2017 Google LLC 2270 * 2271 * Licensed under the Apache License, Version 2.0 (the "License");
2272 * you may not use this file except in compliance with the License. 2273 * You may obtain a copy of the License at 2274 * 2275 * http://www.apache.org/licenses/LICENSE-2.0 2276 * 2277 * Unless required by applicable law or agreed to in writing, software 2278 * distributed under the License is distributed on an "AS IS" BASIS, 2279 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2280 * See the License for the specific language governing permissions and 2281 * limitations under the License. 2282 */class SB{constructor(e){this.ct=e}}function kB(t){const e=bB({parent:t.parent,structuredQuery:t.structuredQuery});return t.limitType==="LAST"?Fg(e,e.limit,"L"):e}/** 2283 * @license 2284 * Copyright 2019 Google LLC 2285 * 2286 * Licensed under the Apache License, Version 2.0 (the "License"); 2287 * you may not use this file except in compliance with the License. 2288 * You may obtain a copy of the License at 2289 * 2290 * http://www.apache.org/licenses/LICENSE-2.0 2291 * 2292 * Unless required by applicable law or agreed to in writing, software 2293 * distributed under the License is distributed on an "AS IS" BASIS, 2294 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2295 * See the License for the specific language governing permissions and 2296 * limitations under the License. 2297 */class PB{constructor(){this.un=new IB}addToCollectionParentIndex(e,n){return this.un.add(n),ye.resolve()}getCollectionParents(e,n){return ye.resolve(this.un.getEntries(n))}addFieldIndex(e,n){return ye.resolve()}deleteFieldIndex(e,n){return ye.resolve()}deleteAllFieldIndexes(e){return ye.resolve()}createTargetIndexes(e,n){return ye.resolve()}getDocumentsMatchingTarget(e,n){return ye.resolve(null)}getIndexType(e,n){return ye.resolve(0)}getFieldIndexes(e,n){return ye.resolve([])}getNextCollectionGroupToUpdate(e){return ye.resolve(null)}getMinOffset(e,n){return ye.resolve($a.min())}getMinOffsetFromCollectionGroup(e,n){return ye.resolve($a.min())}updateCollectionGroup(e,n,r){return ye.resolve()}updateIndexEntries(e,n){return ye.resolve()}}class IB{constructor(){this.index={}}add(e){const n=e.lastSegment(),r=e.popLast(),s=this.index[n]||new xr(mn.comparator),i=!s.has(r);return this.index[n]=s.add(r),i}has(e){const n=e.lastSegment(),r=e.popLast(),s=this.index[n];return s&&s.has(r)}getEntries(e){return(this.index[e]||new xr(mn.comparator)).toArray()}}/** 2298 * @license 2299 * Copyright 2017 Google LLC 2300 * 2301 * Licensed under the Apache License, Version 2.0 (the "License"); 2302 * you may not use this file except in compliance with the License. 2303 * You may obtain a copy of the License at 2304 * 2305 * http://www.apache.org/licenses/LICENSE-2.0 2306 * 2307 * Unless required by applicable law or agreed to in writing, software 2308 * distributed under the License is distributed on an "AS IS" BASIS, 2309 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2310 * See the License for the specific language governing permissions and 2311 * limitations under the License. 2312 */class Vu{constructor(e){this.Ln=e}next(){return this.Ln+=2,this.Ln}static Bn(){return new Vu(0)}static kn(){return new Vu(-1)}}/** 2313 * @license 2314 * Copyright 2017 Google LLC 2315 * 2316 * Licensed under the Apache License, Version 2.0 (the "License"); 2317 * you may not use this file except in compliance with the License. 2318 * You may obtain a copy of the License at 2319 * 2320 * http://www.apache.org/licenses/LICENSE-2.0 2321 * 2322 * Unless required by applicable law or agreed to in writing, software 2323 * distributed under the License is distributed on an "AS IS" BASIS, 2324 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2325 * See the License for the specific language governing permissions and 2326 * limitations under the License. 2327 */class TB{constructor(){this.changes=new id(e=>e.toString(),(e,n)=>e.isEqual(n)),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,n){this.assertNotApplied(),this.changes.set(e,Lr.newInvalidDocument(e).setReadTime(n))}getEntry(e,n){this.assertNotApplied();const r=this.changes.get(n);return r!==void 0?ye.resolve(r):this.getFromCache(e,n)}getEntries(e,n){return this.getAllFromCache(e,n)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}
2327assertNotApplied(){}}/** 2328 * @license 2329 * Copyright 2017 Google LLC 2330 * 2331 * Licensed under the Apache License, Version 2.0 (the "License"); 2332 * you may not use this file except in compliance with the License. 2333 * You may obtain a copy of the License at 2334 * 2335 * http://www.apache.org/licenses/LICENSE-2.0 2336 * 2337 * Unless required by applicable law or agreed to in writing, software 2338 * distributed under the License is distributed on an "AS IS" BASIS, 2339 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2340 * See the License for the specific language governing permissions and 2341 * limitations under the License. 2342 *//** 2343 * @license 2344 * Copyright 2022 Google LLC 2345 * 2346 * Licensed under the Apache License, Version 2.0 (the "License"); 2347 * you may not use this file except in compliance with the License. 2348 * You may obtain a copy of the License at 2349 * 2350 * http://www.apache.org/licenses/LICENSE-2.0 2351 * 2352 * Unless required by applicable law or agreed to in writing, software 2353 * distributed under the License is distributed on an "AS IS" BASIS, 2354 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2355 * See the License for the specific language governing permissions and 2356 * limitations under the License. 2357 */class AB{constructor(e,n){this.overlayedDocument=e,this.mutatedFields=n}}/** 2358 * @license 2359 * Copyright 2017 Google LLC 2360 * 2361 * Licensed under the Apache License, Version 2.0 (the "License"); 2362 * you may not use this file except in compliance with the License. 2363 * You may obtain a copy of the License at 2364 * 2365 * http://www.apache.org/licenses/LICENSE-2.0 2366 * 2367 * Unless required by applicable law or agreed to in writing, software 2368 * distributed under the License is distributed on an "AS IS" BASIS, 2369 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2370 * See the License for the specific language governing permissions and 2371 * limitations under the License. 2372 */class RB{constructor(e,n,r,s){this.remoteDocumentCache=e,this.mutationQueue=n,this.documentOverlayCache=r,this.indexManager=s}getDocument(e,n){let r=null;return this.documentOverlayCache.getOverlay(e,n).next(s=>(r=s,this.remoteDocumentCache.getEntry(e,n))).next(s=>(r!==null&&Dh(r.mutation,s,Cs.empty(),gn.now()),s))}getDocuments(e,n){return this.remoteDocumentCache.getEntries(e,n).next(r=>this.getLocalViewOfDocuments(e,r,jt()).next(()=>r))}getLocalViewOfDocuments(e,n,r=jt()){const s=Dl();return this.populateOverlays(e,s,n).next(()=>this.computeViews(e,n,s,r).next(i=>{let a=dh();return i.forEach((l,c)=>{a=a.insert(l,c.overlayedDocument)}),a}))}getOverlayedDocuments(e,n){const r=Dl();return this.populateOverlays(e,r,n).next(()=>this.computeViews(e,n,r,jt()))}populateOverlays(e,n,r){const s=[];return r.forEach(i=>{n.has(i)||s.push(i)}),this.documentOverlayCache.getOverlays(e,s).next(i=>{i.forEach((a,l)=>{n.set(a,l)})})}computeViews(e,n,r,s){let i=Mi();const a=Rh(),l=function(){return Rh()}();return n.forEach((c,d)=>{const h=r.get(d.key);s.has(d.key)&&(h===void 0||h.mutation instanceof sl)?i=i.insert(d.key,d):h!==void 0?(a.set(d.key,h.mutation.getFieldMask()),Dh(h.mutation,d,h.mutation.getFieldMask(),gn.now())):a.set(d.key,Cs.empty())}),this.recalculateAndSaveOverlays(e,i).next(c=>(c.forEach((d,h)=>a.set(d,h)),n.forEach((d,h)=>{var f;return l.set(d,new AB(h,(f=a.get(d))!==null&&f!==void 0?f:null))}),l))}recalculateAndSaveOverlays(e,n){const r=Rh();let s=new _n((a,l)=>a-l),i=jt();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,n).next(a=>{for(const l of a)l.keys().forEach(c=>{const d=n.get(c);if(d===null)return;let h=r.get(c)||Cs.empty();h=l.applyToLocalView(d,h),r.set(c,h);const f=(s.get(l.batchId)||jt()).add(c);s=s.insert(l.batchId,f)})}).next(()=>{const a=[],l=s.getReverseIterator();for(;l.hasNext();){const c=l.getNext(),d=c.key,h=c.value,f=lR();h.forEach(p=>{if(!i.has(p)){const g=mR(n.get(p),r.get(p));g!==null&&f.set(p,g),i=i.add(p)}}),a.push(this.documentOverlayCache.saveOverlays(e,d,f))}return ye.waitFor(a)}).next(()=>r)}recalculateAndSaveOverlaysForDocumentKeys(e,n){return this.remoteDocumentCache.getEntries(e,n).next(r=>this.recalculateAndSaveOverlays(e,r))}
vendor: 4,298 bytes, lines 2372-2402
2372getDocumentsMatchingQuery(e,n,r,s){return function(a){return Ge.isDocumentKey(a.path)&&a.collectionGroup===null&&a.filters.length===0}(n)?this.getDocumentsMatchingDocumentQuery(e,n.path):rR(n)?this.getDocumentsMatchingCollectionGroupQuery(e,n,r,s):this.getDocumentsMatchingCollectionQuery(e,n,r,s)}getNextDocuments(e,n,r,s){return this.remoteDocumentCache.getAllFromCollectionGroup(e,n,r,s).next(i=>{const a=s-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,n,r.largestBatchId,s-i.size):ye.resolve(Dl());let l=-1,c=i;return a.next(d=>ye.forEach(d,(h,f)=>(l<f.largestBatchId&&(l=f.largestBatchId),i.get(h)?ye.resolve():this.remoteDocumentCache.getEntry(e,h).next(p=>{c=c.insert(h,p)}))).next(()=>this.populateOverlays(e,d,i)).next(()=>this.computeViews(e,c,d,jt())).next(h=>({batchId:l,changes:aR(h)})))})}getDocumentsMatchingDocumentQuery(e,n){return this.getDocument(e,new Ge(n)).next(r=>{let s=dh();return r.isFoundDocument()&&(s=s.insert(r.key,r)),s})}getDocumentsMatchingCollectionGroupQuery(e,n,r,s){const i=n.collectionGroup;let a=dh();return this.indexManager.getCollectionParents(e,i).next(l=>ye.forEach(l,c=>{const d=function(f,p){return new od(p,null,f.explicitOrderBy.slice(),f.filters.slice(),f.limit,f.limitType,f.startAt,f.endAt)}(n,c.child(i));return this.getDocumentsMatchingCollectionQuery(e,d,r,s).next(h=>{h.forEach((f,p)=>{a=a.insert(f,p)})})}).next(()=>a))}getDocumentsMatchingCollectionQuery(e,n,r,s){let i;return this.documentOverlayCache.getOverlaysForCollection(e,n.path,r.largestBatchId).next(a=>(i=a,this.remoteDocumentCache.getDocumentsMatchingQuery(e,n,r,i,s))).next(a=>{i.forEach((c,d)=>{const h=d.getKey();a.get(h)===null&&(a=a.insert(h,Lr.newInvalidDocument(h)))});let l=dh();return a.forEach((c,d)=>{const h=i.get(c);h!==void 0&&Dh(h.mutation,d,Cs.empty(),gn.now()),qv(n,d)&&(l=l.insert(c,d))}),l})}}/** 2373 * @license 2374 * Copyright 2020 Google LLC 2375 * 2376 * Licensed under the Apache License, Version 2.0 (the "License"); 2377 * you may not use this file except in compliance with the License. 2378 * You may obtain a copy of the License at 2379 * 2380 * http://www.apache.org/licenses/LICENSE-2.0 2381 * 2382 * Unless required by applicable law or agreed to in writing, software 2383 * distributed under the License is distributed on an "AS IS" BASIS, 2384 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2385 * See the License for the specific language governing permissions and 2386 * limitations under the License. 2387 */class DB{constructor(e){this.serializer=e,this.hr=new Map,this.Pr=new Map}getBundleMetadata(e,n){return ye.resolve(this.hr.get(n))}saveBundleMetadata(e,n){return this.hr.set(n.id,function(s){return{id:s.id,version:s.version,createTime:Xo(s.createTime)}}(n)),ye.resolve()}getNamedQuery(e,n){return ye.resolve(this.Pr.get(n))}saveNamedQuery(e,n){return this.Pr.set(n.name,function(s){return{name:s.name,query:kB(s.bundledQuery),readTime:Xo(s.readTime)}}(n)),ye.resolve()}}/** 2388 * @license 2389 * Copyright 2022 Google LLC 2390 * 2391 * Licensed under the Apache License, Version 2.0 (the "License"); 2392 * you may not use this file except in compliance with the License. 2393 * You may obtain a copy of the License at 2394 * 2395 * http://www.apache.org/licenses/LICENSE-2.0 2396 * 2397 * Unless required by applicable law or agreed to in writing, software 2398 * distributed under the License is distributed on an "AS IS" BASIS, 2399 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2400 * See the License for the specific language governing permissions and 2401 * limitations under the License. 2402 */class LB{constructor(){this.overlays=new _n(Ge.comparator),this.Ir=new Map}getOverlay(e,n){return ye.resolve(this.overlays.get(n))}getOverlays(e,n){const r=Dl();return ye.forEach(n,s=>this.getOverlay(e,s).next(i=>{i!==null&&r.set(s,i)})).next(()=>r)}saveOverlays(e,n,r){return r.forEach((s,i)=>{this.ht(e,n,i)}),ye.resolve()}removeOverlaysForBatchId(e,n,r){const s=this.Ir.get(r);return s!==void 0&&(s.forEach(i=>this.overlays=this.overlays.remove(i)),this.Ir.delete(r)),ye.resolve()}getOverlaysForCollection(e,n,r){const s=Dl(),i=n.length+1,a=new Ge(n.child("")),l=this.overlays.getIteratorFrom(a);for(;l.hasNext();){const c=l.getNext().value,d=c.getKey();if(!n.isPrefixOf(d.path))break;d.path.length===i&&c.largestBatchId>r&&s.set(c.getKey(),c)}return ye.resolve(s)}
2402getOverlaysForCollectionGroup(e,n,r,s){let i=new _n((d,h)=>d-h);const a=this.overlays.getIterator();for(;a.hasNext();){const d=a.getNext().value;if(d.getKey().getCollectionGroup()===n&&d.largestBatchId>r){let h=i.get(d.largestBatchId);h===null&&(h=Dl(),i=i.insert(d.largestBatchId,h)),h.set(d.getKey(),d)}}const l=Dl(),c=i.getIterator();for(;c.hasNext()&&(c.getNext().value.forEach((d,h)=>l.set(d,h)),!(l.size()>=s)););return ye.resolve(l)}ht(e,n,r){const s=this.overlays.get(r.key);if(s!==null){const a=this.Ir.get(s.largestBatchId).delete(r.key);this.Ir.set(s.largestBatchId,a)}this.overlays=this.overlays.insert(r.key,new sB(n,r));let i=this.Ir.get(n);i===void 0&&(i=jt(),this.Ir.set(n,i)),this.Ir.set(n,i.add(r.key))}}/** 2403 * @license 2404 * Copyright 2024 Google LLC 2405 * 2406 * Licensed under the Apache License, Version 2.0 (the "License"); 2407 * you may not use this file except in compliance with the License. 2408 * You may obtain a copy of the License at 2409 * 2410 * http://www.apache.org/licenses/LICENSE-2.0 2411 * 2412 * Unless required by applicable law or agreed to in writing, software 2413 * distributed under the License is distributed on an "AS IS" BASIS, 2414 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2415 * See the License for the specific language governing permissions and 2416 * limitations under the License. 2417 */class MB{constructor(){this.sessionToken=Cr.EMPTY_BYTE_STRING}getSessionToken(e){return ye.resolve(this.sessionToken)}setSessionToken(e,n){return this.sessionToken=n,ye.resolve()}}/** 2418 * @license 2419 * Copyright 2017 Google LLC 2420 * 2421 * Licensed under the Apache License, Version 2.0 (the "License"); 2422 * you may not use this file except in compliance with the License. 2423 * You may obtain a copy of the License at 2424 * 2425 * http://www.apache.org/licenses/LICENSE-2.0 2426 * 2427 * Unless required by applicable law or agreed to in writing, software 2428 * distributed under the License is distributed on an "AS IS" BASIS, 2429 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2430 * See the License for the specific language governing permissions and 2431 * limitations under the License. 2432 */class fC{constructor(){this.Tr=new xr(ar.Er),this.dr=new xr(ar.Ar)}isEmpty(){return this.Tr.isEmpty()}addReference(e,n){const r=new ar(e,n);this.Tr=this.Tr.add(r),this.dr=this.dr.add(r)}Rr(e,n){e.forEach(r=>this.addReference(r,n))}removeReference(e,n){this.Vr(new ar(e,n))}mr(e,n){e.forEach(r=>this.removeReference(r,n))}gr(e){const n=new Ge(new mn([])),r=new ar(n,e),s=new ar(n,e+1),i=[];return this.dr.forEachInRange([r,s],a=>{this.Vr(a),i.push(a.key)}),i}pr(){this.Tr.forEach(e=>this.Vr(e))}Vr(e){this.Tr=this.Tr.delete(e),this.dr=this.dr.delete(e)}yr(e){const n=new Ge(new mn([])),r=new ar(n,e),s=new ar(n,e+1);let i=jt();return this.dr.forEachInRange([r,s],a=>{i=i.add(a.key)}),i}containsKey(e){const n=new ar(e,0),r=this.Tr.firstAfterOrEqual(n);return r!==null&&e.isEqual(r.key)}}class ar{constructor(e,n){this.key=e,this.wr=n}static Er(e,n){return Ge.comparator(e.key,n.key)||Mt(e.wr,n.wr)}static Ar(e,n){return Mt(e.wr,n.wr)||Ge.comparator(e.key,n.key)}}/** 2433 * @license 2434 * Copyright 2017 Google LLC 2435 * 2436 * Licensed under the Apache License, Version 2.0 (the "License"); 2437 * you may not use this file except in compliance with the License. 2438 * You may obtain a copy of the License at 2439 * 2440 * http://www.apache.org/licenses/LICENSE-2.0 2441 * 2442 * Unless required by applicable law or agreed to in writing, software 2443 * distributed under the License is distributed on an "AS IS" BASIS, 2444 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2445 * See the License for the specific language governing permissions and 2446 * limitations under the License. 2447 */class OB{constructor(e,n){this.indexManager=e,this.referenceDelegate=n,this.mutationQueue=[],this.Sr=1,this.br=new xr(ar.Er)}checkEmpty(e){return ye.resolve(this.mutationQueue.length===0)}addMutationBatch(e,n,r,s){const i=this.Sr;this.Sr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const a=new rB(i,n,r,s);this.mutationQueue.push(a);for(const l of s)this.br=this.br.add(new ar(l.key,i)),this.indexManager.addToCollectionParentIndex(e,l.key.path.popLast());return ye.resolve(a)}lookupMutationBatch(e,n){return ye.resolve(this.Dr(n))}getNextMutationBatchAfterBatchId(e,n){const r=n+1,s=this.vr(r),i=s<0?0:s;
2447return ye.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return ye.resolve(this.mutationQueue.length===0?-1:this.Sr-1)}getAllMutationBatches(e){return ye.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,n){const r=new ar(n,0),s=new ar(n,Number.POSITIVE_INFINITY),i=[];return this.br.forEachInRange([r,s],a=>{const l=this.Dr(a.wr);i.push(l)}),ye.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,n){let r=new xr(Mt);return n.forEach(s=>{const i=new ar(s,0),a=new ar(s,Number.POSITIVE_INFINITY);this.br.forEachInRange([i,a],l=>{r=r.add(l.wr)})}),ye.resolve(this.Cr(r))}getAllMutationBatchesAffectingQuery(e,n){const r=n.path,s=r.length+1;let i=r;Ge.isDocumentKey(i)||(i=i.child(""));const a=new ar(new Ge(i),0);let l=new xr(Mt);return this.br.forEachWhile(c=>{const d=c.key.path;return!!r.isPrefixOf(d)&&(d.length===s&&(l=l.add(c.wr)),!0)},a),ye.resolve(this.Cr(l))}Cr(e){const n=[];return e.forEach(r=>{const s=this.Dr(r);s!==null&&n.push(s)}),n}removeMutationBatch(e,n){Kt(this.Fr(n.batchId,"removed")===0),this.mutationQueue.shift();let r=this.br;return ye.forEach(n.mutations,s=>{const i=new ar(s.key,n.batchId);return r=r.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,s.key)}).next(()=>{this.br=r})}On(e){}containsKey(e,n){const r=new ar(n,0),s=this.br.firstAfterOrEqual(r);return ye.resolve(n.isEqual(s&&s.key))}performConsistencyCheck(e){return this.mutationQueue.length,ye.resolve()}Fr(e,n){return this.vr(e)}vr(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Dr(e){const n=this.vr(e);return n<0||n>=this.mutationQueue.length?null:this.mutationQueue[n]}}/** 2448 * @license 2449 * Copyright 2017 Google LLC 2450 * 2451 * Licensed under the Apache License, Version 2.0 (the "License"); 2452 * you may not use this file except in compliance with the License. 2453 * You may obtain a copy of the License at 2454 * 2455 * http://www.apache.org/licenses/LICENSE-2.0 2456 * 2457 * Unless required by applicable law or agreed to in writing, software 2458 * distributed under the License is distributed on an "AS IS" BASIS, 2459 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2460 * See the License for the specific language governing permissions and 2461 * limitations under the License. 2462 */class FB{constructor(e){this.Mr=e,this.docs=function(){return new _n(Ge.comparator)}(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,n){const r=n.key,s=this.docs.get(r),i=s?s.size:0,a=this.Mr(n);return this.docs=this.docs.insert(r,{document:n.mutableCopy(),size:a}),this.size+=a-i,this.indexManager.addToCollectionParentIndex(e,r.path.popLast())}removeEntry(e){const n=this.docs.get(e);n&&(this.docs=this.docs.remove(e),this.size-=n.size)}getEntry(e,n){const r=this.docs.get(n);return ye.resolve(r?r.document.mutableCopy():Lr.newInvalidDocument(n))}getEntries(e,n){let r=Mi();return n.forEach(s=>{const i=this.docs.get(s);r=r.insert(s,i?i.document.mutableCopy():Lr.newInvalidDocument(s))}),ye.resolve(r)}getDocumentsMatchingQuery(e,n,r,s){let i=Mi();const a=n.path,l=new Ge(a.child("")),c=this.docs.getIteratorFrom(l);for(;c.hasNext();){const{key:d,value:{document:h}}=c.getNext();if(!a.isPrefixOf(d.path))break;d.path.length>a.length+1||w8(y8(h),r)<=0||(s.has(h.key)||qv(n,h))&&(i=i.insert(h.key,h.mutableCopy()))}return ye.resolve(i)}getAllFromCollectionGroup(e,n,r,s){it()}Or(e,n){return ye.forEach(this.docs,r=>n(r))}newChangeBuffer(e){return new zB(this)}getSize(e){return ye.resolve(this.size)}}class zB extends TB{constructor(e){super(),this.cr=e}applyChanges(e){const n=[];
vendor: 9,492 bytes, lines 2462-2537
2462return this.changes.forEach((r,s)=>{s.isValidDocument()?n.push(this.cr.addEntry(e,s)):this.cr.removeEntry(r)}),ye.waitFor(n)}getFromCache(e,n){return this.cr.getEntry(e,n)}getAllFromCache(e,n){return this.cr.getEntries(e,n)}}/** 2463 * @license 2464 * Copyright 2017 Google LLC 2465 * 2466 * Licensed under the Apache License, Version 2.0 (the "License"); 2467 * you may not use this file except in compliance with the License. 2468 * You may obtain a copy of the License at 2469 * 2470 * http://www.apache.org/licenses/LICENSE-2.0 2471 * 2472 * Unless required by applicable law or agreed to in writing, software 2473 * distributed under the License is distributed on an "AS IS" BASIS, 2474 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2475 * See the License for the specific language governing permissions and 2476 * limitations under the License. 2477 */class $B{constructor(e){this.persistence=e,this.Nr=new id(n=>iC(n),aC),this.lastRemoteSnapshotVersion=at.min(),this.highestTargetId=0,this.Lr=0,this.Br=new fC,this.targetCount=0,this.kr=Vu.Bn()}forEachTarget(e,n){return this.Nr.forEach((r,s)=>n(s)),ye.resolve()}getLastRemoteSnapshotVersion(e){return ye.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return ye.resolve(this.Lr)}allocateTargetId(e){return this.highestTargetId=this.kr.next(),ye.resolve(this.highestTargetId)}setTargetsMetadata(e,n,r){return r&&(this.lastRemoteSnapshotVersion=r),n>this.Lr&&(this.Lr=n),ye.resolve()}Kn(e){this.Nr.set(e.target,e);const n=e.targetId;n>this.highestTargetId&&(this.kr=new Vu(n),this.highestTargetId=n),e.sequenceNumber>this.Lr&&(this.Lr=e.sequenceNumber)}addTargetData(e,n){return this.Kn(n),this.targetCount+=1,ye.resolve()}updateTargetData(e,n){return this.Kn(n),ye.resolve()}removeTargetData(e,n){return this.Nr.delete(n.target),this.Br.gr(n.targetId),this.targetCount-=1,ye.resolve()}removeTargets(e,n,r){let s=0;const i=[];return this.Nr.forEach((a,l)=>{l.sequenceNumber<=n&&r.get(l.targetId)===null&&(this.Nr.delete(a),i.push(this.removeMatchingKeysForTargetId(e,l.targetId)),s++)}),ye.waitFor(i).next(()=>s)}getTargetCount(e){return ye.resolve(this.targetCount)}getTargetData(e,n){const r=this.Nr.get(n)||null;return ye.resolve(r)}addMatchingKeys(e,n,r){return this.Br.Rr(n,r),ye.resolve()}removeMatchingKeys(e,n,r){this.Br.mr(n,r);const s=this.persistence.referenceDelegate,i=[];return s&&n.forEach(a=>{i.push(s.markPotentiallyOrphaned(e,a))}),ye.waitFor(i)}removeMatchingKeysForTargetId(e,n){return this.Br.gr(n),ye.resolve()}getMatchingKeysForTargetId(e,n){const r=this.Br.yr(n);return ye.resolve(r)}containsKey(e,n){return ye.resolve(this.Br.containsKey(n))}}/** 2478 * @license 2479 * Copyright 2017 Google LLC 2480 * 2481 * Licensed under the Apache License, Version 2.0 (the "License"); 2482 * you may not use this file except in compliance with the License. 2483 * You may obtain a copy of the License at 2484 * 2485 * http://www.apache.org/licenses/LICENSE-2.0 2486 * 2487 * Unless required by applicable law or agreed to in writing, software 2488 * distributed under the License is distributed on an "AS IS" BASIS, 2489 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2490 * See the License for the specific language governing permissions and 2491 * limitations under the License. 2492 */class VB{constructor(e,n){this.qr={},this.overlays={},this.Qr=new nC(0),this.Kr=!1,this.Kr=!0,this.$r=new MB,this.referenceDelegate=e(this),this.Ur=new $B(this),this.indexManager=new PB,this.remoteDocumentCache=function(s){return new FB(s)}(r=>this.referenceDelegate.Wr(r)),this.serializer=new SB(n),this.Gr=new DB(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.Kr=!1,Promise.resolve()}get started(){return this.Kr}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let n=this.overlays[e.toKey()];return n||(n=new LB,this.overlays[e.toKey()]=n),n}getMutationQueue(e,n){let r=this.qr[e.toKey()];return r||(r=new OB(n,this.referenceDelegate),this.qr[e.toKey()]=r),r}getGlobalsCache(){return this.$r}getTargetCache(){return this.Ur}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Gr}runTransaction(e,n,r){Be("MemoryPersistence","Starting transaction:",e);const s=new UB(this.Qr.next());return this.referenceDelegate.zr(),r(s).next(i=>this.referenceDelegate.jr(s).next(()=>i)).toPromise().then(i=>(s.raiseOnCommittedEvent(),i))}Hr(e,n){return ye.or(Object.values(this.qr).map(r=>()=>r.containsKey(e,n)))}}class UB extends j8{constructor(e){super(),this.currentSequenceNumber=e}}class mC{constructor(e){this.persistence=e,this.Jr=new fC,this.Yr=null}static Zr(e){return new mC(e)}get Xr(){if(this.Yr)return this.Yr;throw it()}addReference(e,n,r){return this.Jr.addReference(r,n),this.Xr.delete(r.toString()),ye.resolve()}removeReference(e,n,r){return this.Jr.removeReference(r,n),this.Xr.add(r.toString()),ye.resolve()}markPotentiallyOrphaned(e,n){return this.Xr.add(n.toString()),ye.resolve()}removeTarget(e,n){this.Jr.gr(n.targetId).forEach(s=>this.Xr.add(s.toString()));const r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,n.targetId).next(s=>{s.forEach(i=>this.Xr.add(i.toString()))}).next(()=>r.removeTargetData(e,n))}zr(){this.Yr=new Set}jr(e){const n=this.persistence.getRemoteDocumentCache().newChangeBuffer();return ye.forEach(this.Xr,r=>{const s=Ge.fromPath(r);return this.ei(e,s).next(i=>{i||n.removeEntry(s,at.min())})}).next(()=>(this.Yr=null,n.apply(e)))}updateLimboDocument(e,n){return this.ei(e,n).next(r=>{r?this.Xr.delete(n.toString()):this.Xr.add(n.toString())})}Wr(e){return 0}ei(e,n){return ye.or([()=>ye.resolve(this.Jr.containsKey(n)),()=>this.persistence.getTargetCache().containsKey(e,n),()=>this.persistence.Hr(e,n)])}}/** 2493 * @license 2494 * Copyright 2017 Google LLC 2495 * 2496 * Licensed under the Apache License, Version 2.0 (the "License"); 2497 * you may not use this file except in compliance with the License. 2498 * You may obtain a copy of the License at 2499 * 2500 * http://www.apache.org/licenses/LICENSE-2.0 2501 * 2502 * Unless required by applicable law or agreed to in writing, software 2503 * distributed under the License is distributed on an "AS IS" BASIS, 2504 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2505 * See the License for the specific language governing permissions and 2506 * limitations under the License. 2507 */class pC{constructor(e,n,r,s){this.targetId=e,this.fromCache=n,this.$i=r,this.Ui=s}static Wi(e,n){let r=jt(),s=jt();for(const i of n.docChanges)switch(i.type){case 0:r=r.add(i.doc.key);break;case 1:s=s.add(i.doc.key)}return new pC(e,n.fromCache,r,s)}}/** 2508 * @license 2509 * Copyright 2023 Google LLC 2510 * 2511 * Licensed under the Apache License, Version 2.0 (the "License"); 2512 * you may not use this file except in compliance with the License. 2513 * You may obtain a copy of the License at 2514 * 2515 * http://www.apache.org/licenses/LICENSE-2.0 2516 * 2517 * Unless required by applicable law or agreed to in writing, software 2518 * distributed under the License is distributed on an "AS IS" BASIS, 2519 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2520 * See the License for the specific language governing permissions and 2521 * limitations under the License. 2522 */class BB{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}/** 2523 * @license 2524 * Copyright 2019 Google LLC 2525 * 2526 * Licensed under the Apache License, Version 2.0 (the "License"); 2527 * you may not use this file except in compliance with the License. 2528 * You may obtain a copy of the License at 2529 * 2530 * http://www.apache.org/licenses/LICENSE-2.0 2531 * 2532 * Unless required by applicable law or agreed to in writing, software 2533 * distributed under the License is distributed on an "AS IS" BASIS, 2534 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2535 * See the License for the specific language governing permissions and 2536 * limitations under the License. 2537 */class WB{constructor(){this.Gi=!1,this.zi=!1,this.ji=100,this.Hi=function(){return Az()?8:C8(Vr())>0?6:4}()}initialize(e,n){this.Ji=e,this.indexManager=n,this.Gi=!0}getDocumentsMatchingQuery(e,n,r,s){const i={result:null};return this.Yi(e,n).next(a=>{i.result=a}).next(()=>{if(!i.result)return this.Zi(e,n,s,r).next(a=>{i.result=a})}).next(()=>{if(i.result)return;const a=new BB;return this.Xi(e,n,a).next(l=>{if(i.result=l,this.zi)return this.es(e,n,a,l.size)})}).next(()=>i.result)}es(e,n,r,s){return r.documentReadCount<this.ji?(Ud()<=Nt.DEBUG&&Be("QueryEngine","SDK will not create cache indexes for query:",Wc(n),"since it only creates cache indexes for collection contains","more than or equal to",this.ji,"documents"),ye.resolve()):(Ud()<=Nt.DEBUG&&Be("QueryEngine","Query:",Wc(n),"scans",r.documentReadCount,"local documents and returns",s,"documents as results."),r.documentReadCount>this.Hi*s?(Ud()<=Nt.DEBUG&&Be("QueryEngine","The SDK decides to create cache indexes for query:",Wc(n),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,Qo(n))):ye.resolve())}Yi(e,n){if(PE(n))return ye.resolve(null);let r=Qo(n);return this.indexManager.getIndexType(e,r).next(s=>s===0?null:(n.limit!==null&&s===1&&(n=Fg(n,null,"F"),r=Qo(n)),this.indexManager.getDocumentsMatchingTarget(e,r).next(i=>{const a=jt(...i);return this.Ji.getDocuments(e,a).next(l=>this.indexManager.getMinOffset(e,r).next(c=>{const d=this.ts(n,l);return this.ns(n,d,a,c.readTime)?this.Yi(e,Fg(n,null,"F")):this.rs(e,d,n,c)}))})))}
2537Zi(e,n,r,s){return PE(n)||s.isEqual(at.min())?ye.resolve(null):this.Ji.getDocuments(e,r).next(i=>{const a=this.ts(n,i);return this.ns(n,a,r,s)?ye.resolve(null):(Ud()<=Nt.DEBUG&&Be("QueryEngine","Re-using previous result from %s to execute query: %s",s.toString(),Wc(n)),this.rs(e,a,n,x8(s,-1)).next(l=>l))})}ts(e,n){let r=new xr(oR(e));return n.forEach((s,i)=>{qv(e,i)&&(r=r.add(i))}),r}ns(e,n,r,s){if(e.limit===null)return!1;if(r.size!==n.size)return!0;const i=e.limitType==="F"?n.last():n.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(s)>0)}Xi(e,n,r){return Ud()<=Nt.DEBUG&&Be("QueryEngine","Using full collection scan to execute query:",Wc(n)),this.Ji.getDocumentsMatchingQuery(e,n,$a.min(),r)}rs(e,n,r,s){return this.Ji.getDocumentsMatchingQuery(e,r,s).next(i=>(n.forEach(a=>{i=i.insert(a.key,a)}),i))}}/** 2538 * @license 2539 * Copyright 2020 Google LLC 2540 * 2541 * Licensed under the Apache License, Version 2.0 (the "License"); 2542 * you may not use this file except in compliance with the License. 2543 * You may obtain a copy of the License at 2544 * 2545 * http://www.apache.org/licenses/LICENSE-2.0 2546 * 2547 * Unless required by applicable law or agreed to in writing, software 2548 * distributed under the License is distributed on an "AS IS" BASIS, 2549 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2550 * See the License for the specific language governing permissions and 2551 * limitations under the License. 2552 */class HB{constructor(e,n,r,s){this.persistence=e,this.ss=n,this.serializer=s,this.os=new _n(Mt),this._s=new id(i=>iC(i),aC),this.us=new Map,this.cs=e.getRemoteDocumentCache(),this.Ur=e.getTargetCache(),this.Gr=e.getBundleCache(),this.ls(r)}ls(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new RB(this.cs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.cs.setIndexManager(this.indexManager),this.ss.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",n=>e.collect(n,this.os))}}function qB(t,e,n,r){return new HB(t,e,n,r)}async function ER(t,e){const n=lt(t);return await n.persistence.runTransaction("Handle user change","readonly",r=>{let s;
2552return n.mutationQueue.getAllMutationBatches(r).next(i=>(s=i,n.ls(e),n.mutationQueue.getAllMutationBatches(r))).next(i=>{const a=[],l=[];let c=jt();for(const d of s){a.push(d.batchId);for(const h of d.mutations)c=c.add(h.key)}for(const d of i){l.push(d.batchId);for(const h of d.mutations)c=c.add(h.key)}return n.localDocuments.getDocuments(r,c).next(d=>({hs:d,removedBatchIds:a,addedBatchIds:l}))})})}function GB(t,e){const n=lt(t);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",r=>{const s=e.batch.keys(),i=n.cs.newChangeBuffer({trackRemovals:!0});return function(l,c,d,h){const f=d.batch,p=f.keys();let g=ye.resolve();return p.forEach(v=>{g=g.next(()=>h.getEntry(c,v)).next(x=>{const y=d.docVersions.get(v);Kt(y!==null),x.version.compareTo(y)<0&&(f.applyToRemoteDocument(x,d),x.isValidDocument()&&(x.setReadTime(d.commitVersion),h.addEntry(x)))})}),g.next(()=>l.mutationQueue.removeMutationBatch(c,f))}(n,r,e,i).next(()=>i.apply(r)).next(()=>n.mutationQueue.performConsistencyCheck(r)).next(()=>n.documentOverlayCache.removeOverlaysForBatchId(r,s,e.batch.batchId)).next(()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(r,function(l){let c=jt();for(let d=0;d<l.mutationResults.length;++d)l.mutationResults[d].transformResults.length>0&&(c=c.add(l.batch.mutations[d].key));return c}(e))).next(()=>n.localDocuments.getDocuments(r,s))})}function SR(t){const e=lt(t);return e.persistence.runTransaction("Get last remote snapshot version","readonly",n=>e.Ur.getLastRemoteSnapshotVersion(n))}function ZB(t,e){const n=lt(t),r=e.snapshotVersion;let s=n.os;return n.persistence.runTransaction("Apply remote event","readwrite-primary",i=>{const a=n.cs.newChangeBuffer({trackRemovals:!0});s=n.os;const l=[];
vendor: 4,430 bytes, lines 2552-2556
2552e.targetChanges.forEach((h,f)=>{const p=s.get(f);if(!p)return;l.push(n.Ur.removeMatchingKeys(i,h.removedDocuments,f).next(()=>n.Ur.addMatchingKeys(i,h.addedDocuments,f)));let g=p.withSequenceNumber(i.currentSequenceNumber);e.targetMismatches.get(f)!==null?g=g.withResumeToken(Cr.EMPTY_BYTE_STRING,at.min()).withLastLimboFreeSnapshotVersion(at.min()):h.resumeToken.approximateByteSize()>0&&(g=g.withResumeToken(h.resumeToken,r)),s=s.insert(f,g),function(x,y,b){return x.resumeToken.approximateByteSize()===0||y.snapshotVersion.toMicroseconds()-x.snapshotVersion.toMicroseconds()>=3e8?!0:b.addedDocuments.size+b.modifiedDocuments.size+b.removedDocuments.size>0}(p,g,h)&&l.push(n.Ur.updateTargetData(i,g))});let c=Mi(),d=jt();if(e.documentUpdates.forEach(h=>{e.resolvedLimboDocuments.has(h)&&l.push(n.persistence.referenceDelegate.updateLimboDocument(i,h))}),l.push(KB(i,a,e.documentUpdates).next(h=>{c=h.Ps,d=h.Is})),!r.isEqual(at.min())){const h=n.Ur.getLastRemoteSnapshotVersion(i).next(f=>n.Ur.setTargetsMetadata(i,i.currentSequenceNumber,r));l.push(h)}return ye.waitFor(l).next(()=>a.apply(i)).next(()=>n.localDocuments.getLocalViewOfDocuments(i,c,d)).next(()=>c)}).then(i=>(n.os=s,i))}function KB(t,e,n){let r=jt(),s=jt();return n.forEach(i=>r=r.add(i)),e.getEntries(t,r).next(i=>{let a=Mi();return n.forEach((l,c)=>{const d=i.get(l);c.isFoundDocument()!==d.isFoundDocument()&&(s=s.add(l)),c.isNoDocument()&&c.version.isEqual(at.min())?(e.removeEntry(l,c.readTime),a=a.insert(l,c)):!d.isValidDocument()||c.version.compareTo(d.version)>0||c.version.compareTo(d.version)===0&&d.hasPendingWrites?(e.addEntry(c),a=a.insert(l,c)):Be("LocalStore","Ignoring outdated watch update for ",l,". Current version:",d.version," Watch version:",c.version)}),{Ps:a,Is:s}})}function YB(t,e){const n=lt(t);return n.persistence.runTransaction("Get next mutation batch","readonly",r=>(e===void 0&&(e=-1),n.mutationQueue.getNextMutationBatchAfterBatchId(r,e)))}function QB(t,e){const n=lt(t);return n.persistence.runTransaction("Allocate target","readwrite",r=>{let s;return n.Ur.getTargetData(r,e).next(i=>i?(s=i,ye.resolve(s)):n.Ur.allocateTargetId(r).next(a=>(s=new ya(e,a,"TargetPurposeListen",r.currentSequenceNumber),n.Ur.addTargetData(r,s).next(()=>s))))}).then(r=>{const s=n.os.get(r.targetId);return(s===null||r.snapshotVersion.compareTo(s.snapshotVersion)>0)&&(n.os=n.os.insert(r.targetId,r),n._s.set(e,r.targetId)),r})}async function Y0(t,e,n){const r=lt(t),s=r.os.get(e),i=n?"readwrite":"readwrite-primary";try{n||await r.persistence.runTransaction("Release target",i,a=>r.persistence.referenceDelegate.removeTarget(a,s))}catch(a){if(!Hf(a))throw a;Be("LocalStore",`Failed to update sequence numbers for target ${e}: ${a}`)}r.os=r.os.remove(e),r._s.delete(s.target)}function $E(t,e,n){const r=lt(t);let s=at.min(),i=jt();return r.persistence.runTransaction("Execute query","readwrite",a=>function(c,d,h){const f=lt(c),p=f._s.get(h);return p!==void 0?ye.resolve(f.os.get(p)):f.Ur.getTargetData(d,h)}(r,a,Qo(e)).next(l=>{if(l)return s=l.lastLimboFreeSnapshotVersion,r.Ur.getMatchingKeysForTargetId(a,l.targetId).next(c=>{i=c})}).next(()=>r.ss.getDocumentsMatchingQuery(a,e,n?s:at.min(),n?i:jt())).next(l=>(XB(r,V8(e),l),{documents:l,Ts:i})))}function XB(t,e,n){let r=t.us.get(e)||at.min();n.forEach((s,i)=>{i.readTime.compareTo(r)>0&&(r=i.readTime)}),t.us.set(e,r)}class VE{constructor(){this.activeTargetIds=G8()}fs(e){this.activeTargetIds=this.activeTargetIds.add(e)}gs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Vs(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class JB{constructor(){this.so=new VE,this.oo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,n,r){}addLocalQueryTarget(e,n=!0){return n&&this.so.fs(e),this.oo[e]||"not-current"}updateQueryState(e,n,r){this.oo[e]=n}removeLocalQueryTarget(e){this.so.gs(e)}isLocalQueryTarget(e){return this.so.activeTargetIds.has(e)}clearQueryState(e){delete this.oo[e]}getAllActiveQueryTargets(){return this.so.activeTargetIds}isActiveQueryTarget(e){return this.so.activeTargetIds.has(e)}start(){return this.so=new VE,Promise.resolve()}handleUserChange(e,n,r){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}/** 2553 * @license 2554 * Copyright 2019 Google LLC 2555 * 2556 * Licensed under the Apache License, Version 2.0 (the "License");
2557 * you may not use this file except in compliance with the License. 2558 * You may obtain a copy of the License at 2559 * 2560 * http://www.apache.org/licenses/LICENSE-2.0 2561 * 2562 * Unless required by applicable law or agreed to in writing, software 2563 * distributed under the License is distributed on an "AS IS" BASIS, 2564 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2565 * See the License for the specific language governing permissions and 2566 * limitations under the License. 2567 */class e9{_o(e){}shutdown(){}}/** 2568 * @license 2569 * Copyright 2019 Google LLC 2570 * 2571 * Licensed under the Apache License, Version 2.0 (the "License"); 2572 * you may not use this file except in compliance with the License. 2573 * You may obtain a copy of the License at 2574 * 2575 * http://www.apache.org/licenses/LICENSE-2.0 2576 * 2577 * Unless required by applicable law or agreed to in writing, software 2578 * distributed under the License is distributed on an "AS IS" BASIS, 2579 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2580 * See the License for the specific language governing permissions and 2581 * limitations under the License. 2582 */class UE{constructor(){this.ao=()=>this.uo(),this.co=()=>this.lo(),this.ho=[],this.Po()}_o(e){this.ho.push(e)}shutdown(){window.removeEventListener("online",this.ao),window.removeEventListener("offline",this.co)}Po(){window.addEventListener("online",this.ao),window.addEventListener("offline",this.co)}uo(){Be("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(const e of this.ho)e(0)}lo(){Be("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(const e of this.ho)e(1)}static D(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}/** 2583 * @license 2584 * Copyright 2023 Google LLC 2585 * 2586 * Licensed under the Apache License, Version 2.0 (the "License"); 2587 * you may not use this file except in compliance with the License. 2588 * You may obtain a copy of the License at 2589 * 2590 * http://www.apache.org/licenses/LICENSE-2.0 2591 * 2592 * Unless required by applicable law or agreed to in writing, software 2593 * distributed under the License is distributed on an "AS IS" BASIS, 2594 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2595 * See the License for the specific language governing permissions and 2596 * limitations under the License. 2597 */let np=null;function Dy(){return np===null?np=function(){return 268435456+Math.round(2147483648*Math.random())}():np++,"0x"+np.toString(16)}/** 2598 * @license 2599 * Copyright 2020 Google LLC 2600 * 2601 * Licensed under the Apache License, Version 2.0 (the "License"); 2602 * you may not use this file except in compliance with the License. 2603 * You may obtain a copy of the License at 2604 * 2605 * http://www.apache.org/licenses/LICENSE-2.0 2606 * 2607 * Unless required by applicable law or agreed to in writing, software 2608 * distributed under the License is distributed on an "AS IS" BASIS, 2609 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2610 * See the License for the specific language governing permissions and 2611 * limitations under the License. 2612 */const t9={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};/** 2613 * @license 2614 * Copyright 2017 Google LLC 2615 * 2616 * Licensed under the Apache License, Version 2.0 (the "License"); 2617 * you may not use this file except in compliance with the License. 2618 * You may obtain a copy of the License at 2619 * 2620 * http://www.apache.org/licenses/LICENSE-2.0 2621 * 2622 * Unless required by applicable law or agreed to in writing, software 2623 * distributed under the License is distributed on an "AS IS" BASIS, 2624 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2625 * See the License for the specific language governing permissions and 2626 * limitations under the License. 2627 */class n9{constructor(e){this.Io=e.Io,this.To=e.To}Eo(e){this.Ao=e}Ro(e){this.Vo=e}mo(e){this.fo=e}onMessage(e){this.po=e}close(){this.To()}send(e){this.Io(e)}yo(){this.Ao()}wo(){this.Vo()}So(e){this.fo(e)}bo(e){this.po(e)}}/** 2628 * @license 2629 * Copyright 2017 Google LLC 2630 * 2631 * Licensed under the Apache License, Version 2.0 (the "License");
2632 * you may not use this file except in compliance with the License. 2633 * You may obtain a copy of the License at 2634 * 2635 * http://www.apache.org/licenses/LICENSE-2.0 2636 * 2637 * Unless required by applicable law or agreed to in writing, software 2638 * distributed under the License is distributed on an "AS IS" BASIS, 2639 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2640 * See the License for the specific language governing permissions and 2641 * limitations under the License. 2642 */const Tr="WebChannelConnection";class r9 extends class{constructor(n){this.databaseInfo=n,this.databaseId=n.databaseId;const r=n.ssl?"https":"http",s=encodeURIComponent(this.databaseId.projectId),i=encodeURIComponent(this.databaseId.database);this.Do=r+"://"+n.host,this.vo=`projects/${s}/databases/${i}`,this.Co=this.databaseId.database==="(default)"?`project_id=${s}`:`project_id=${s}&database_id=${i}`}get Fo(){return!1}Mo(n,r,s,i,a){const l=Dy(),c=this.xo(n,r.toUriEncodedString());Be("RestConnection",`Sending RPC '${n}' ${l}:`,c,s);const d={"google-cloud-resource-prefix":this.vo,"x-goog-request-params":this.Co};return this.Oo(d,i,a),this.No(n,c,d,s).then(h=>(Be("RestConnection",`Received RPC '${n}' ${l}: `,h),h),h=>{throw Ou("RestConnection",`RPC '${n}' ${l} failed with error: `,h,"url: ",c,"request:",s),h})}Lo(n,r,s,i,a,l){return this.Mo(n,r,s,i,a)}Oo(n,r,s){n["X-Goog-Api-Client"]=function(){return"gl-js/ fire/"+sd}(),n["Content-Type"]="text/plain",this.databaseInfo.appId&&(n["X-Firebase-GMPID"]=this.databaseInfo.appId),r&&r.headers.forEach((i,a)=>n[a]=i),s&&s.headers.forEach((i,a)=>n[a]=i)}xo(n,r){const s=t9[n];return`${this.Do}/v1/${r}:${s}`}terminate(){}}{constructor(e){super(e),this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}No(e,n,r,s){const i=Dy();return new Promise((a,l)=>{const c=new VA;c.setWithCredentials(!0),c.listenOnce(UA.COMPLETE,()=>{try{switch(c.getLastErrorCode()){case Gp.NO_ERROR:const h=c.getResponseJson();Be(Tr,`XHR for RPC '${e}' ${i} received:`,JSON.stringify(h)),a(h);break;case Gp.TIMEOUT:Be(Tr,`RPC '${e}' ${i} timed out`),l(new Me(fe.DEADLINE_EXCEEDED,"Request time out"));break;case Gp.HTTP_ERROR:const f=c.getStatus();if(Be(Tr,`RPC '${e}' ${i} failed with status:`,f,"response text:",c.getResponseText()),f>0){let p=c.getResponseJson();Array.isArray(p)&&(p=p[0]);const g=p==null?void 0:p.error;if(g&&g.status&&g.message){const v=function(y){const b=y.toLowerCase().replace(/_/g,"-");return Object.values(fe).indexOf(b)>=0?b:fe.UNKNOWN}(g.status);l(new Me(v,g.message))}else l(new Me(fe.UNKNOWN,"Server responded with status "+c.getStatus()))}else l(new Me(fe.UNAVAILABLE,"Connection failed."));break;default:it()}}finally{Be(Tr,`RPC '${e}' ${i} completed.`)}});const d=JSON.stringify(s);Be(Tr,`RPC '${e}' ${i} sending request:`,s),c.send(n,"POST",d,r,15)})}Bo(e,n,r){const s=Dy(),i=[this.Do,"/","google.firestore.v1.Firestore","/",e,"/channel"],a=HA(),l=WA(),c={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},d=this.longPollingOptions.timeoutSeconds;d!==void 0&&(c.longPollingTimeout=Math.round(1e3*d)),this.useFetchStreams&&(c.useFetchStreams=!0),this.Oo(c.initMessageHeaders,n,r),c.encodeInitMessageHeaders=!0;const h=i.join("");Be(Tr,`Creating RPC '${e}' stream ${s}: ${h}`,c);const f=a.createWebChannel(h,c);let p=!1,g=!1;const v=new n9({Io:y=>{g?Be(Tr,`Not sending because RPC '${e}' stream ${s} is closed:`,y):(p||(Be(Tr,`Opening RPC '${e}' stream ${s} transport.`),f.open(),p=!0),Be(Tr,`RPC '${e}' stream ${s} sending:`,y),f.send(y))},To:()=>f.close()}),x=(y,b,w)=>{y.listen(b,j=>{try{w(j)}catch(E){setTimeout(()=>{throw E},0)}})};return x(f,uh.EventType.OPEN,()=>{g||(Be(Tr,`RPC '${e}' stream ${s} transport opened.`),v.yo())}),x(f,uh.EventType.CLOSE,()=>{g||(g=!0,Be(Tr,`RPC '${e}' stream ${s} transport closed`),v.So())}
2642),x(f,uh.EventType.ERROR,y=>{g||(g=!0,Ou(Tr,`RPC '${e}' stream ${s} transport errored:`,y),v.So(new Me(fe.UNAVAILABLE,"The operation could not be completed")))}),x(f,uh.EventType.MESSAGE,y=>{var b;if(!g){const w=y.data[0];Kt(!!w);const j=w,E=j.error||((b=j[0])===null||b===void 0?void 0:b.error);if(E){Be(Tr,`RPC '${e}' stream ${s} received error:`,E);const P=E.status;let A=function(k){const L=Un[k];if(L!==void 0)return gR(L)}(P),N=E.message;A===void 0&&(A=fe.INTERNAL,N="Unknown error status: "+P+" with message "+E.message),g=!0,v.So(new Me(A,N)),f.close()}else Be(Tr,`RPC '${e}' stream ${s} received:`,w),v.bo(w)}}),x(l,BA.STAT_EVENT,y=>{y.stat===$0.PROXY?Be(Tr,`RPC '${e}' stream ${s} detected buffering proxy`):y.stat===$0.NOPROXY&&Be(Tr,`RPC '${e}' stream ${s} detected no buffering proxy`)}),setTimeout(()=>{v.wo()},0),v}}function Ly(){return typeof document<"u"?document:null}/** 2643 * @license 2644 * Copyright 2020 Google LLC 2645 * 2646 * Licensed under the Apache License, Version 2.0 (the "License"); 2647 * you may not use this file except in compliance with the License. 2648 * You may obtain a copy of the License at 2649 * 2650 * http://www.apache.org/licenses/LICENSE-2.0 2651 * 2652 * Unless required by applicable law or agreed to in writing, software 2653 * distributed under the License is distributed on an "AS IS" BASIS, 2654 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2655 * See the License for the specific language governing permissions and 2656 * limitations under the License. 2657 */function Yv(t){return new fB(t,!0)}/** 2658 * @license 2659 * Copyright 2017 Google LLC 2660 * 2661 * Licensed under the Apache License, Version 2.0 (the "License"); 2662 * you may not use this file except in compliance with the License. 2663 * You may obtain a copy of the License at 2664 * 2665 * http://www.apache.org/licenses/LICENSE-2.0 2666 * 2667 * Unless required by applicable law or agreed to in writing, software 2668 * distributed under the License is distributed on an "AS IS" BASIS, 2669 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2670 * See the License for the specific language governing permissions and 2671 * limitations under the License. 2672 */class kR{constructor(e,n,r=1e3,s=1.5,i=6e4){this.ui=e,this.timerId=n,this.ko=r,this.qo=s,this.Qo=i,this.Ko=0,this.$o=null,this.Uo=Date.now(),this.reset()}reset(){this.Ko=0}Wo(){this.Ko=this.Qo}Go(e){this.cancel();const n=Math.floor(this.Ko+this.zo()),r=Math.max(0,Date.now()-this.Uo),s=Math.max(0,n-r);s>0&&Be("ExponentialBackoff",`Backing off for ${s} ms (base delay: ${this.Ko} ms, delay with jitter: ${n} ms, last attempt: ${r} ms ago)`),this.$o=this.ui.enqueueAfterDelay(this.timerId,s,()=>(this.Uo=Date.now(),e())),this.Ko*=this.qo,this.Ko<this.ko&&(this.Ko=this.ko),this.Ko>this.Qo&&(this.Ko=this.Qo)}jo(){this.$o!==null&&(this.$o.skipDelay(),this.$o=null)}cancel(){this.$o!==null&&(this.$o.cancel(),this.$o=null)}zo(){return(Math.random()-.5)*this.Ko}}/** 2673 * @license 2674 * Copyright 2017 Google LLC 2675 * 2676 * Licensed under the Apache License, Version 2.0 (the "License"); 2677 * you may not use this file except in compliance with the License. 2678 * You may obtain a copy of the License at 2679 * 2680 * http://www.apache.org/licenses/LICENSE-2.0 2681 * 2682 * Unless required by applicable law or agreed to in writing, software 2683 * distributed under the License is distributed on an "AS IS" BASIS, 2684 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2685 * See the License for the specific language governing permissions and 2686 * limitations under the License. 2687 */class PR{constructor(e,n,r,s,i,a,l,c){this.ui=e,this.Ho=r,this.Jo=s,this.connection=i,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=l,this.listener=c,this.state=0,this.Yo=0,this.Zo=null,this.Xo=null,this.stream=null,this.e_=0,this.t_=new kR(e,n)}n_(){return this.state===1||this.state===5||this.r_()}r_(){return this.state===2||this.state===3}start(){this.e_=0,this.state!==4?this.auth():this.i_()}async stop(){this.n_()&&await this.close(0)}s_(){this.state=0,this.t_.reset()}o_(){this.r_()&&this.Zo===null&&(this.Zo=this.ui.enqueueAfterDelay(this.Ho,6e4,()=>this.__()))}a_(e){this.u_(),this.stream.send(e)}async __(){if(this.r_())return this.close(0)}u_(){this.Zo&&(this.Zo.cancel(),this.Zo=null)}
2687c_(){this.Xo&&(this.Xo.cancel(),this.Xo=null)}async close(e,n){this.u_(),this.c_(),this.t_.cancel(),this.Yo++,e!==4?this.t_.reset():n&&n.code===fe.RESOURCE_EXHAUSTED?(Li(n.toString()),Li("Using maximum backoff delay to prevent overloading the backend."),this.t_.Wo()):n&&n.code===fe.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.l_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.mo(n)}l_(){}auth(){this.state=1;const e=this.h_(this.Yo),n=this.Yo;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([r,s])=>{this.Yo===n&&this.P_(r,s)},r=>{e(()=>{const s=new Me(fe.UNKNOWN,"Fetching auth token failed: "+r.message);return this.I_(s)})})}P_(e,n){const r=this.h_(this.Yo);this.stream=this.T_(e,n),this.stream.Eo(()=>{r(()=>this.listener.Eo())}),this.stream.Ro(()=>{r(()=>(this.state=2,this.Xo=this.ui.enqueueAfterDelay(this.Jo,1e4,()=>(this.r_()&&(this.state=3),Promise.resolve())),this.listener.Ro()))}),this.stream.mo(s=>{r(()=>this.I_(s))}),this.stream.onMessage(s=>{r(()=>++this.e_==1?this.E_(s):this.onNext(s))})}i_(){this.state=5,this.t_.Go(async()=>{this.state=0,this.start()})}I_(e){return Be("PersistentStream",`close with error: ${e}`),this.stream=null,this.close(4,e)}h_(e){return n=>{this.ui.enqueueAndForget(()=>this.Yo===e?n():(Be("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class s9 extends PR{constructor(e,n,r,s,i,a){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",n,r,s,a),this.serializer=i}T_(e,n){return this.connection.Bo("Listen",e,n)}E_(e){return this.onNext(e)}onNext(e){this.t_.reset();const n=gB(this.serializer,e),r=function(i){if(!("targetChange"in i))return at.min();const a=i.targetChange;return a.targetIds&&a.targetIds.length?at.min():a.readTime?Xo(a.readTime):at.min()}(e);return this.listener.d_(n,r)}A_(e){const n={};n.database=K0(this.serializer),n.addTarget=function(i,a){let l;const c=a.target;if(l=W0(c)?{documents:yB(i,c)}:{query:wB(i,c)._t},l.targetId=a.targetId,a.resumeToken.approximateByteSize()>0){l.resumeToken=yR(i,a.resumeToken);const d=q0(i,a.expectedCount);d!==null&&(l.expectedCount=d)}else if(a.snapshotVersion.compareTo(at.min())>0){l.readTime=$g(i,a.snapshotVersion.toTimestamp());const d=q0(i,a.expectedCount);d!==null&&(l.expectedCount=d)}return l}(this.serializer,e);const r=jB(this.serializer,e);r&&(n.labels=r),this.a_(n)}R_(e){const n={};n.database=K0(this.serializer),n.removeTarget=e,this.a_(n)}}class o9 extends PR{constructor(e,n,r,s,i,a){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",n,r,s,a),this.serializer=i}get V_(){return this.e_>0}start(){this.lastStreamToken=void 0,super.start()}l_(){this.V_&&this.m_([])}T_(e,n){return this.connection.Bo("Write",e,n)}E_(e){return Kt(!!e.streamToken),this.lastStreamToken=e.streamToken,Kt(!e.writeResults||e.writeResults.length===0),this.listener.f_()}onNext(e){Kt(!!e.streamToken),this.lastStreamToken=e.streamToken,this.t_.reset();const n=xB(e.writeResults,e.commitTime),r=Xo(e.commitTime);return this.listener.g_(r,n)}p_(){const e={};e.database=K0(this.serializer),this.a_(e)}m_(e){const n={streamToken:this.lastStreamToken,writes:e.map(r=>vB(this.serializer,r))};this.a_(n)}}/** 2688 * @license 2689 * Copyright 2017 Google LLC 2690 * 2691 * Licensed under the Apache License, Version 2.0 (the "License"); 2692 * you may not use this file except in compliance with the License. 2693 * You may obtain a copy of the License at 2694 * 2695 * http://www.apache.org/licenses/LICENSE-2.0 2696 * 2697 * Unless required by applicable law or agreed to in writing, software 2698 * distributed under the License is distributed on an "AS IS" BASIS, 2699 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2700 * See the License for the specific language governing permissions and 2701 * limitations under the License. 2702 */class i9 extends class{}{constructor(e,n,r,s){super(),this.authCredentials=e,this.appCheckCredentials=n,this.connection=r,this.serializer
2702=s,this.y_=!1}w_(){if(this.y_)throw new Me(fe.FAILED_PRECONDITION,"The client has already been terminated.")}Mo(e,n,r,s){return this.w_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([i,a])=>this.connection.Mo(e,G0(n,r),s,i,a)).catch(i=>{throw i.name==="FirebaseError"?(i.code===fe.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),i):new Me(fe.UNKNOWN,i.toString())})}Lo(e,n,r,s,i){return this.w_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([a,l])=>this.connection.Lo(e,G0(n,r),s,a,l,i)).catch(a=>{throw a.name==="FirebaseError"?(a.code===fe.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),a):new Me(fe.UNKNOWN,a.toString())})}terminate(){this.y_=!0,this.connection.terminate()}}class a9{constructor(e,n){this.asyncQueue=e,this.onlineStateHandler=n,this.state="Unknown",this.S_=0,this.b_=null,this.D_=!0}v_(){this.S_===0&&(this.C_("Unknown"),this.b_=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.b_=null,this.F_("Backend didn't respond within 10 seconds."),this.C_("Offline"),Promise.resolve())))}M_(e){this.state==="Online"?this.C_("Unknown"):(this.S_++,this.S_>=1&&(this.x_(),this.F_(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.C_("Offline")))}set(e){this.x_(),this.S_=0,e==="Online"&&(this.D_=!1),this.C_(e)}C_(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}F_(e){const n=`Could not reach Cloud Firestore backend. ${e} 2703This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.D_?(Li(n),this.D_=!1):Be("OnlineStateTracker",n)}x_(){this.b_!==null&&(this.b_.cancel(),this.b_=null)}}/** 2704 * @license 2705 * Copyright 2017 Google LLC 2706 * 2707 * Licensed under the Apache License, Version 2.0 (the "License"); 2708 * you may not use this file except in compliance with the License. 2709 * You may obtain a copy of the License at 2710 * 2711 * http://www.apache.org/licenses/LICENSE-2.0 2712 * 2713 * Unless required by applicable law or agreed to in writing, software 2714 * distributed under the License is distributed on an "AS IS" BASIS, 2715 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2716 * See the License for the specific language governing permissions and 2717 * limitations under the License. 2718 */class l9{constructor(e,n,r,s,i){this.localStore=e,this.datastore=n,this.asyncQueue=r,this.remoteSyncer={},this.O_=[],this.N_=new Map,this.L_=new Set,this.B_=[],this.k_=i,this.k_._o(a=>{r.enqueueAndForget(async()=>{gc(this)&&(Be("RemoteStore","Restarting streams for network reachability change."),await async function(c){const d=lt(c);d.L_.add(4),await Zf(d),d.q_.set("Unknown"),d.L_.delete(4),await Qv(d)}(this))})}),this.q_=new a9(r,s)}}async function Qv(t){if(gc(t))for(const e of t.B_)await e(!0)}async function Zf(t){for(const e of t.B_)await e(!1)}function IR(t,e){const n=lt(t);n.N_.has(e.targetId)||(n.N_.set(e.targetId,e),yC(n)?xC(n):ad(n).r_()&&vC(n,e))}function gC(t,e){const n=lt(t),r=ad(n);n.N_.delete(e),r.r_()&&TR(n,e),n.N_.size===0&&(r.r_()?r.o_():gc(n)&&n.q_.set("Unknown"))}function vC(t,e){if(t.Q_.xe(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo(at.min())>0){const n=t.remoteSyncer.getRemoteKeysForTarget(e.targetId).size;e=e.withExpectedCount(n)}ad(t).A_(e)}function TR(t,e){t.Q_.xe(e),ad(t).R_(e)}function xC(t){t.Q_=new cB({getRemoteKeysForTarget:e=>t.remoteSyncer.getRemoteKeysForTarget(e),ot:e=>t.N_.get(e)||null,tt:()=>t.datastore.serializer.databaseId}),ad(t).start(),t.q_.v_()}function yC(t){return gc(t)&&!ad(t).n_()&&t.N_.size>0}function gc(t){return lt(t).L_.size===0}function AR(t){t.Q_=void 0}async function c9(t){t.q_.set("Online")}async function u9(t){t.N_.forEach((e,n)=>{vC(t,e)})}async function d9(t,e){AR(t),yC(t)?(t.q_.M_(e),xC(t)):t.q_.set("Unknown")}async function h9(t,e,n){if(t.q_.set("Online"),e instanceof xR&&e.state===2&&e.cause)try{await async function(s,i){const a=i.cause;for(const l of i.targetIds)s.N_.has(l)&&(await s.remoteSyncer.rejectListen(l,a),s.N_.delete(l),s.Q_.removeTarget(l))}(t,e)}catch(r){Be("RemoteStore","Failed to remove targets %s: %s ",e.targetIds.join(","),r),await Vg(t,r)}else if(e instanceof Yp?t.Q_.Ke(e):e instanceof vR?t.Q_.He(e):t.Q_.We(e),!n.isEqual(at.min()))try{const r=await SR(t.localStore);n.compareTo(r)>=0&&await function(i,a){const l=i.Q_.rt(a);
2718return l.targetChanges.forEach((c,d)=>{if(c.resumeToken.approximateByteSize()>0){const h=i.N_.get(d);h&&i.N_.set(d,h.withResumeToken(c.resumeToken,a))}}),l.targetMismatches.forEach((c,d)=>{const h=i.N_.get(c);if(!h)return;i.N_.set(c,h.withResumeToken(Cr.EMPTY_BYTE_STRING,h.snapshotVersion)),TR(i,c);const f=new ya(h.target,c,d,h.sequenceNumber);vC(i,f)}),i.remoteSyncer.applyRemoteEvent(l)}(t,n)}catch(r){Be("RemoteStore","Failed to raise snapshot:",r),await Vg(t,r)}}async function Vg(t,e,n){if(!Hf(e))throw e;t.L_.add(1),await Zf(t),t.q_.set("Offline"),n||(n=()=>SR(t.localStore)),t.asyncQueue.enqueueRetryable(async()=>{Be("RemoteStore","Retrying IndexedDB access"),await n(),t.L_.delete(1),await Qv(t)})}function RR(t,e){return e().catch(n=>Vg(t,n,e))}async function Xv(t){const e=lt(t),n=Ua(e);let r=e.O_.length>0?e.O_[e.O_.length-1].batchId:-1;for(;f9(e);)try{const s=await YB(e.localStore,r);if(s===null){e.O_.length===0&&n.o_();break}r=s.batchId,m9(e,s)}catch(s){await Vg(e,s)}DR(e)&&LR(e)}function f9(t){return gc(t)&&t.O_.length<10}function m9(t,e){t.O_.push(e);const n=Ua(t);n.r_()&&n.V_&&n.m_(e.mutations)}function DR(t){return gc(t)&&!Ua(t).n_()&&t.O_.length>0}function LR(t){Ua(t).start()}async function p9(t){Ua(t).p_()}async function g9(t){const e=Ua(t);for(const n of t.O_)e.m_(n.mutations)}async function v9(t,e,n){const r=t.O_.shift(),s=uC.from(r,e,n);await RR(t,()=>t.remoteSyncer.applySuccessfulWrite(s)),await Xv(t)}async function x9(t,e){e&&Ua(t).V_&&await async function(r,s){if(function(a){return iB(a)&&a!==fe.ABORTED}(s.code)){const i=r.O_.shift();Ua(r).s_(),await RR(r,()=>r.remoteSyncer.rejectFailedWrite(i.batchId,s)),await Xv(r)}}(t,e),DR(t)&&LR(t)}async function BE(t,e){const n=lt(t);n.asyncQueue.verifyOperationInProgress(),Be("RemoteStore","RemoteStore received new credentials");const r=gc(n);n.L_.add(3),await Zf(n),r&&n.q_.set("Unknown"),await n.remoteSyncer.handleCredentialChange(e),n.L_.delete(3),await Qv(n)}async function y9(t,e){const n=lt(t);e?(n.L_.delete(2),await Qv(n)):e||(n.L_.add(2),await Zf(n),n.q_.set("Unknown"))}function ad(t){return t.K_||(t.K_=function(n,r,s){const i=lt(n);return i.w_(),new s9(r,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,s)}(t.datastore,t.asyncQueue,{Eo:c9.bind(null,t),Ro:u9.bind(null,t),mo:d9.bind(null,t),d_:h9.bind(null,t)}),t.B_.push(async e=>{e?(t.K_.s_(),yC(t)?xC(t):t.q_.set("Unknown")):(await t.K_.stop(),AR(t))})),t.K_}function Ua(t){return t.U_||(t.U_=function(n,r,s){const i=lt(n);return i.w_(),new o9(r,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,s)}(t.datastore,t.asyncQueue,{Eo:()=>Promise.resolve(),Ro:p9.bind(null,t),mo:x9.bind(null,t),f_:g9.bind(null,t),g_:v9.bind(null,t)}),t.B_.push(async e=>{e?(t.U_.s_(),await Xv(t)):(await t.U_.stop(),t.O_.length>0&&(Be("RemoteStore",`Stopping write stream with ${t.O_.length} pending writes`),t.O_=[]))})),t.U_}/** 2719 * @license 2720 * Copyright 2017 Google LLC 2721 * 2722 * Licensed under the Apache License, Version 2.0 (the "License"); 2723 * you may not use this file except in compliance with the License. 2724 * You may obtain a copy of the License at 2725 * 2726 * http://www.apache.org/licenses/LICENSE-2.0 2727 * 2728 * Unless required by applicable law or agreed to in writing, software 2729 * distributed under the License is distributed on an "AS IS" BASIS, 2730 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2731 * See the License for the specific language governing permissions and 2732 * limitations under the License. 2733 */class wC{constructor(e,n,r,s,i){this.asyncQueue=e,this.timerId=n,this.targetTimeMs=r,this.op=s,this.removalCallback=i,this.deferred=new Ei,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(a=>{})}get promise(){return this.deferred.promise}static createAndSchedule(e,n,r,s,i){const a=Date.now()+r,l=new wC(e,n,a,s,i);return l.start(r),l}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new Me(fe.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then(e=>this.deferred.resolve(e))):Promise.resolve())}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function bC(t,e){if(Li("AsyncQueue",`${e}: ${t}`),Hf(t))return new Me(fe.UNAVAILABLE,`${e}: ${t}`);throw t}/** 2734 * @license 2735 * Copyright 2017 Google LLC 2736 * 2737 * Licensed under the Apache License, Version 2.0 (the "License");
2738 * you may not use this file except in compliance with the License. 2739 * You may obtain a copy of the License at 2740 * 2741 * http://www.apache.org/licenses/LICENSE-2.0 2742 * 2743 * Unless required by applicable law or agreed to in writing, software 2744 * distributed under the License is distributed on an "AS IS" BASIS, 2745 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2746 * See the License for the specific language governing permissions and 2747 * limitations under the License. 2748 */class yu{constructor(e){this.comparator=e?(n,r)=>e(n,r)||Ge.comparator(n.key,r.key):(n,r)=>Ge.comparator(n.key,r.key),this.keyedMap=dh(),this.sortedSet=new _n(this.comparator)}static emptySet(e){return new yu(e.comparator)}has(e){return this.keyedMap.get(e)!=null}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){const n=this.keyedMap.get(e);return n?this.sortedSet.indexOf(n):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal((n,r)=>(e(n),!1))}add(e){const n=this.delete(e.key);return n.copy(n.keyedMap.insert(e.key,e),n.sortedSet.insert(e,null))}delete(e){const n=this.get(e);return n?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(n)):this}isEqual(e){if(!(e instanceof yu)||this.size!==e.size)return!1;const n=this.sortedSet.getIterator(),r=e.sortedSet.getIterator();for(;n.hasNext();){const s=n.getNext().key,i=r.getNext().key;if(!s.isEqual(i))return!1}return!0}toString(){const e=[];return this.forEach(n=>{e.push(n.toString())}),e.length===0?"DocumentSet ()":`DocumentSet ( 2749 `+e.join(` 2750`)+` 2751)`}copy(e,n){const r=new yu;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=n,r}}/** 2752 * @license 2753 * Copyright 2017 Google LLC 2754 * 2755 * Licensed under the Apache License, Version 2.0 (the "License"); 2756 * you may not use this file except in compliance with the License. 2757 * You may obtain a copy of the License at 2758 * 2759 * http://www.apache.org/licenses/LICENSE-2.0 2760 * 2761 * Unless required by applicable law or agreed to in writing, software 2762 * distributed under the License is distributed on an "AS IS" BASIS, 2763 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2764 * See the License for the specific language governing permissions and 2765 * limitations under the License. 2766 */class WE{constructor(){this.W_=new _n(Ge.comparator)}track(e){const n=e.doc.key,r=this.W_.get(n);r?e.type!==0&&r.type===3?this.W_=this.W_.insert(n,e):e.type===3&&r.type!==1?this.W_=this.W_.insert(n,{type:r.type,doc:e.doc}):e.type===2&&r.type===2?this.W_=this.W_.insert(n,{type:2,doc:e.doc}):e.type===2&&r.type===0?this.W_=this.W_.insert(n,{type:0,doc:e.doc}):e.type===1&&r.type===0?this.W_=this.W_.remove(n):e.type===1&&r.type===2?this.W_=this.W_.insert(n,{type:1,doc:r.doc}):e.type===0&&r.type===1?this.W_=this.W_.insert(n,{type:2,doc:e.doc}):it():this.W_=this.W_.insert(n,e)}G_(){const e=[];return this.W_.inorderTraversal((n,r)=>{e.push(r)}),e}}class Uu{constructor(e,n,r,s,i,a,l,c,d){this.query=e,this.docs=n,this.oldDocs=r,this.docChanges=s,this.mutatedKeys=i,this.fromCache=a,this.syncStateChanged=l,this.excludesMetadataChanges=c,this.hasCachedResults=d}static fromInitialDocuments(e,n,r,s,i){const a=[];return n.forEach(l=>{a.push({type:0,doc:l})}),new Uu(e,n,yu.emptySet(n),a,r,s,!0,!1,i)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&Hv(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const n=this.docChanges,r=e.docChanges;if(n.length!==r.length)return!1;for(let s=0;s<n.length;s++)if(n[s].type!==r[s].type||!n[s].doc.isEqual(r[s].doc))return!1;return!0}}/** 2767 * @license 2768 * Copyright 2017 Google LLC 2769 * 2770 * Licensed under the Apache License, Version 2.0 (the "License"); 2771 * you may not use this file except in compliance with the License. 2772 * You may obtain a copy of the License at 2773 * 2774 * http://www.apache.org/licenses/LICENSE-2.0 2775 * 2776 * Unless required by applicable law or agreed to in writing, softw
2776are 2777 * distributed under the License is distributed on an "AS IS" BASIS, 2778 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2779 * See the License for the specific language governing permissions and 2780 * limitations under the License. 2781 */class w9{constructor(){this.z_=void 0,this.j_=[]}H_(){return this.j_.some(e=>e.J_())}}class b9{constructor(){this.queries=HE(),this.onlineState="Unknown",this.Y_=new Set}terminate(){(function(n,r){const s=lt(n),i=s.queries;s.queries=HE(),i.forEach((a,l)=>{for(const c of l.j_)c.onError(r)})})(this,new Me(fe.ABORTED,"Firestore shutting down"))}}function HE(){return new id(t=>sR(t),Hv)}async function jC(t,e){const n=lt(t);let r=3;const s=e.query;let i=n.queries.get(s);i?!i.H_()&&e.J_()&&(r=2):(i=new w9,r=e.J_()?0:1);try{switch(r){case 0:i.z_=await n.onListen(s,!0);break;case 1:i.z_=await n.onListen(s,!1);break;case 2:await n.onFirstRemoteStoreListen(s)}}catch(a){const l=bC(a,`Initialization of query '${Wc(e.query)}' failed`);return void e.onError(l)}n.queries.set(s,i),i.j_.push(e),e.Z_(n.onlineState),i.z_&&e.X_(i.z_)&&NC(n)}async function CC(t,e){const n=lt(t),r=e.query;let s=3;const i=n.queries.get(r);if(i){const a=i.j_.indexOf(e);a>=0&&(i.j_.splice(a,1),i.j_.length===0?s=e.J_()?0:1:!i.H_()&&e.J_()&&(s=2))}switch(s){case 0:return n.queries.delete(r),n.onUnlisten(r,!0);case 1:return n.queries.delete(r),n.onUnlisten(r,!1);case 2:return n.onLastRemoteStoreUnlisten(r);default:return}}function j9(t,e){const n=lt(t);let r=!1;for(const s of e){const i=s.query,a=n.queries.get(i);if(a){for(const l of a.j_)l.X_(s)&&(r=!0);a.z_=s}}r&&NC(n)}function C9(t,e,n){const r=lt(t),s=r.queries.get(e);if(s)for(const i of s.j_)i.onError(n);r.queries.delete(e)}function NC(t){t.Y_.forEach(e=>{e.next()})}var Q0,qE;(qE=Q0||(Q0={})).ea="default",qE.Cache="cache";class _C{constructor(e,n,r){this.query=e,this.ta=n,this.na=!1,this.ra=null,this.onlineState="Unknown",this.options=r||{}}X_(e){if(!this.options.includeMetadataChanges){const r=[];for(const s of e.docChanges)s.type!==3&&r.push(s);e=new Uu(e.query,e.docs,e.oldDocs,r,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let n=!1;return this.na?this.ia(e)&&(this.ta.next(e),n=!0):this.sa(e,this.onlineState)&&(this.oa(e),n=!0),this.ra=e,n}onError(e){this.ta.error(e)}Z_(e){this.onlineState=e;let n=!1;return this.ra&&!this.na&&this.sa(this.ra,e)&&(this.oa(this.ra),n=!0),n}sa(e,n){if(!e.fromCache||!this.J_())return!0;const r=n!=="Offline";return(!this.options._a||!r)&&(!e.docs.isEmpty()||e.hasCachedResults||n==="Offline")}ia(e){if(e.docChanges.length>0)return!0;const n=this.ra&&this.ra.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!n)&&this.options.includeMetadataChanges===!0}oa(e){e=Uu.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.na=!0,this.ta.next(e)}J_(){return this.options.source!==Q0.Cache}}/** 2782 * @license 2783 * Copyright 2017 Google LLC 2784 * 2785 * Licensed under the Apache License, Version 2.0 (the "License"); 2786 * you may not use this file except in compliance with the License. 2787 * You may obtain a copy of the License at 2788 * 2789 * http://www.apache.org/licenses/LICENSE-2.0 2790 * 2791 * Unless required by applicable law or agreed to in writing, software 2792 * distributed under the License is distributed on an "AS IS" BASIS, 2793 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2794 * See the License for the specific language governing permissions and 2795 * limitations under the License. 2796 */class MR{constructor(e){this.key=e}}class OR{constructor(e){this.key=e}}class N9{constructor(e,n){this.query=e,this.Ta=n,this.Ea=null,this.hasCachedResults=!1,this.current=!1,this.da=jt(),this.mutatedKeys=jt(),this.Aa=oR(e),this.Ra=new yu(this.Aa)}get Va(){return this.Ta}ma(e,n){const r=n?n.fa:new WE,s=n?n.Ra:this.Ra;let i=n?n.mutatedKeys:this.mutatedKeys,a=s,l=!1;const c=this.query.limitType==="F"&&s.size===this.query.limit?s.last():null,d=this.query.limitType==="L"&&s.size===this.query.limit?s.first():null;if(e.inorderTraversal((h,f)=>{const p=s.get(h),g=qv(this.query,f)?f:null,v=!!p&&this.mutatedKeys.has(p.key),x=!!g&&(g.hasLocalMutations||this.mutatedKeys.has(g.key)&&g.hasCommittedMutations);let y=!1;p&&g?p.data.isEqual(g.data)?v!==x&&(r.track({type:3,doc:g}),y=!0):this.ga(p,g)||(r.track({type:2,doc:g}),y=!0,(c&&this.Aa(g,c)>0||d&&this.Aa(g,d)<0)&&(l=!0)):!p&&g?(r.track({type:0,doc:g}),y=!0):p&&!g&&(r.track({type:1,doc:p}),y=!0,(c||d)&&(l=!0)),y&&(g?(a=a.add(g),i=x?i.add(h):i.delete(h)):(a=a.delete(h),i=i.delete(h)))}),this.query.limit!==null)for(;a.size>this.query.limit;){const h=this.query.limitType==="F"?a.last():a.first();a=a.delete(h.key),i=i.delete(h.key),r.track({type:1,doc:h})}return{Ra:a,fa:r,ns:l,mutatedKeys:i}}ga(e,n){return e.hasLocalMutations&&n.hasCommittedMutations&&!n.hasLocalMutations}
2796applyChanges(e,n,r,s){const i=this.Ra;this.Ra=e.Ra,this.mutatedKeys=e.mutatedKeys;const a=e.fa.G_();a.sort((h,f)=>function(g,v){const x=y=>{switch(y){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return it()}};return x(g)-x(v)}(h.type,f.type)||this.Aa(h.doc,f.doc)),this.pa(r),s=s!=null&&s;const l=n&&!s?this.ya():[],c=this.da.size===0&&this.current&&!s?1:0,d=c!==this.Ea;return this.Ea=c,a.length!==0||d?{snapshot:new Uu(this.query,e.Ra,i,a,e.mutatedKeys,c===0,d,!1,!!r&&r.resumeToken.approximateByteSize()>0),wa:l}:{wa:l}}Z_(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({Ra:this.Ra,fa:new WE,mutatedKeys:this.mutatedKeys,ns:!1},!1)):{wa:[]}}Sa(e){return!this.Ta.has(e)&&!!this.Ra.has(e)&&!this.Ra.get(e).hasLocalMutations}pa(e){e&&(e.addedDocuments.forEach(n=>this.Ta=this.Ta.add(n)),e.modifiedDocuments.forEach(n=>{}),e.removedDocuments.forEach(n=>this.Ta=this.Ta.delete(n)),this.current=e.current)}ya(){if(!this.current)return[];const e=this.da;this.da=jt(),this.Ra.forEach(r=>{this.Sa(r.key)&&(this.da=this.da.add(r.key))});const n=[];return e.forEach(r=>{this.da.has(r)||n.push(new OR(r))}),this.da.forEach(r=>{e.has(r)||n.push(new MR(r))}),n}ba(e){this.Ta=e.Ts,this.da=jt();const n=this.ma(e.documents);return this.applyChanges(n,!0)}Da(){return Uu.fromInitialDocuments(this.query,this.Ra,this.mutatedKeys,this.Ea===0,this.hasCachedResults)}}class _9{constructor(e,n,r){this.query=e,this.targetId=n,this.view=r}}class E9{constructor(e){this.key=e,this.va=!1}}class S9{constructor(e,n,r,s,i,a){this.localStore=e,this.remoteStore=n,this.eventManager=r,this.sharedClientState=s,this.currentUser=i,this.maxConcurrentLimboResolutions=a,this.Ca={},this.Fa=new id(l=>sR(l),Hv),this.Ma=new Map,this.xa=new Set,this.Oa=new _n(Ge.comparator),this.Na=new Map,this.La=new fC,this.Ba={},this.ka=new Map,this.qa=Vu.kn(),this.onlineState="Unknown",this.Qa=void 0}get isPrimaryClient(){return this.Qa===!0}}async function k9(t,e,n=!0){const r=BR(t);let s;const i=r.Fa.get(e);return i?(r.sharedClientState.addLocalQueryTarget(i.targetId),s=i.view.Da()):s=await FR(r,e,n,!0),s}async function P9(t,e){const n=BR(t);await FR(n,e,!0,!1)}async function FR(t,e,n,r){const s=await QB(t.localStore,Qo(e)),i=s.targetId,a=t.sharedClientState.addLocalQueryTarget(i,n);let l;return r&&(l=await I9(t,e,i,a==="current",s.resumeToken)),t.isPrimaryClient&&n&&IR(t.remoteStore,s),l}async function I9(t,e,n,r,s){t.Ka=(f,p,g)=>async function(x,y,b,w){let j=y.view.ma(b);j.ns&&(j=await $E(x.localStore,y.query,!1).then(({documents:N})=>y.view.ma(N,j)));const E=w&&w.targetChanges.get(y.targetId),P=w&&w.targetMismatches.get(y.targetId)!=null,A=y.view.applyChanges(j,x.isPrimaryClient,E,P);return ZE(x,y.targetId,A.wa),A.snapshot}(t,f,p,g);const i=await $E(t.localStore,e,!0),a=new N9(e,i.Ts),l=a.ma(i.documents),c=Gf.createSynthesizedTargetChangeForCurrentChange(n,r&&t.onlineState!=="Offline",s),d=a.applyChanges(l,t.isPrimaryClient,c);ZE(t,n,d.wa);const h=new _9(e,n,a);return t.Fa.set(e,h),t.Ma.has(n)?t.Ma.get(n).push(e):t.Ma.set(n,[e]),d.snapshot}async function T9(t,e,n){const r=lt(t),s=r.Fa.get(e),i=r.Ma.get(s.targetId);if(i.length>1)return r.Ma.set(s.targetId,i.filter(a=>!Hv(a,e))),void r.Fa.delete(e);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(s.targetId),r.sharedCl
2796ientState.isActiveQueryTarget(s.targetId)||await Y0(r.localStore,s.targetId,!1).then(()=>{r.sharedClientState.clearQueryState(s.targetId),n&&gC(r.remoteStore,s.targetId),X0(r,s.targetId)}).catch(Wf)):(X0(r,s.targetId),await Y0(r.localStore,s.targetId,!0))}async function A9(t,e){const n=lt(t),r=n.Fa.get(e),s=n.Ma.get(r.targetId);n.isPrimaryClient&&s.length===1&&(n.sharedClientState.removeLocalQueryTarget(r.targetId),gC(n.remoteStore,r.targetId))}async function R9(t,e,n){const r=$9(t);try{const s=await function(a,l){const c=lt(a),d=gn.now(),h=l.reduce((g,v)=>g.add(v.key),jt());let f,p;return c.persistence.runTransaction("Locally write mutations","readwrite",g=>{let v=Mi(),x=jt();return c.cs.getEntries(g,h).next(y=>{v=y,v.forEach((b,w)=>{w.isValidDocument()||(x=x.add(b))})}).next(()=>c.localDocuments.getOverlayedDocuments(g,v)).next(y=>{f=y;const b=[];for(const w of l){const j=tB(w,f.get(w.key).overlayedDocument);j!=null&&b.push(new sl(w.key,j,YA(j.value.mapValue),Us.exists(!0)))}return c.mutationQueue.addMutationBatch(g,d,b,l)}).next(y=>{p=y;const b=y.applyToLocalDocumentSet(f,x);return c.documentOverlayCache.saveOverlays(g,y.batchId,b)})}).then(()=>({batchId:p.batchId,changes:aR(f)}))}(r.localStore,e);r.sharedClientState.addPendingMutation(s.batchId),function(a,l,c){let d=a.Ba[a.currentUser.toKey()];d||(d=new _n(Mt)),d=d.insert(l,c),a.Ba[a.currentUser.toKey()]=d}(r,s.batchId,n),await Kf(r,s.changes),await Xv(r.remoteStore)}catch(s){const i=bC(s,"Failed to persist write");n.reject(i)}}async function zR(t,e){const n=lt(t);try{const r=await ZB(n.localStore,e);
2796e.targetChanges.forEach((s,i)=>{const a=n.Na.get(i);a&&(Kt(s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size<=1),s.addedDocuments.size>0?a.va=!0:s.modifiedDocuments.size>0?Kt(a.va):s.removedDocuments.size>0&&(Kt(a.va),a.va=!1))}),await Kf(n,r,e)}catch(r){await Wf(r)}}function GE(t,e,n){const r=lt(t);if(r.isPrimaryClient&&n===0||!r.isPrimaryClient&&n===1){const s=[];r.Fa.forEach((i,a)=>{const l=a.view.Z_(e);l.snapshot&&s.push(l.snapshot)}),function(a,l){const c=lt(a);c.onlineState=l;let d=!1;c.queries.forEach((h,f)=>{for(const p of f.j_)p.Z_(l)&&(d=!0)}),d&&NC(c)}(r.eventManager,e),s.length&&r.Ca.d_(s),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}async function D9(t,e,n){const r=lt(t);r.sharedClientState.updateQueryState(e,"rejected",n);const s=r.Na.get(e),i=s&&s.key;if(i){let a=new _n(Ge.comparator);a=a.insert(i,Lr.newNoDocument(i,at.min()));const l=jt().add(i),c=new Kv(at.min(),new Map,new _n(Mt),a,l);await zR(r,c),r.Oa=r.Oa.remove(i),r.Na.delete(e),EC(r)}else await Y0(r.localStore,e,!1).then(()=>X0(r,e,n)).catch(Wf)}async function L9(t,e){const n=lt(t),r=e.batch.batchId;try{const s=await GB(n.localStore,e);VR(n,r,null),$R(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),await Kf(n,s)}catch(s){await Wf(s)}}async function M9(t,e,n){const r=lt(t);try{const s=await function(a,l){const c=lt(a);return c.persistence.runTransaction("Reject batch","readwrite-primary",d=>{let h;return c.mutationQueue.lookupMutationBatch(d,l).next(f=>
2796(Kt(f!==null),h=f.keys(),c.mutationQueue.removeMutationBatch(d,f))).next(()=>c.mutationQueue.performConsistencyCheck(d)).next(()=>c.documentOverlayCache.removeOverlaysForBatchId(d,h,l)).next(()=>c.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(d,h)).next(()=>c.localDocuments.getDocuments(d,h))})}(r.localStore,e);VR(r,e,n),$R(r,e),r.sharedClientState.updateMutationState(e,"rejected",n),await Kf(r,s)}catch(s){await Wf(s)}}function $R(t,e){(t.ka.get(e)||[]).forEach(n=>{n.resolve()}),t.ka.delete(e)}function VR(t,e,n){const r=lt(t);let s=r.Ba[r.currentUser.toKey()];if(s){const i=s.get(e);i&&(n?i.reject(n):i.resolve(),s=s.remove(e)),r.Ba[r.currentUser.toKey()]=s}}function X0(t,e,n=null){t.sharedClientState.removeLocalQueryTarget(e);for(const r of t.Ma.get(e))t.Fa.delete(r),n&&t.Ca.$a(r,n);t.Ma.delete(e),t.isPrimaryClient&&t.La.gr(e).forEach(r=>{t.La.containsKey(r)||UR(t,r)})}function UR(t,e){t.xa.delete(e.path.canonicalString());const n=t.Oa.get(e);n!==null&&(gC(t.remoteStore,n),t.Oa=t.Oa.remove(e),t.Na.delete(n),EC(t))}function ZE(t,e,n){for(const r of n)r instanceof MR?(t.La.addReference(r.key,e),O9(t,r)):r instanceof OR?(Be("SyncEngine","Document no longer in limbo: "+r.key),t.La.removeReference(r.key,e),t.La.containsKey(r.key)||UR(t,r.key)):it()}function O9(t,e){const n=e.key,r=n.path.canonicalString();t.Oa.get(n)||t.xa.has(r)||(Be("SyncEngine","New document in limbo: "+n),t.xa.add(r),EC(t))}function EC(t){for(;t.xa.size>0&&t.Oa.size<t.maxConcurrentLimboResolutions;){const e=t.xa.values().next().value;t.xa.delete(e);const n=new Ge(mn.fromString(e)),r=t.qa.next();t.Na.set(r,new E9(n)),t.Oa=t.Oa.insert(n,r),IR(t.remoteStore,new ya(Qo(Wv(n.path)),r,"TargetPurposeLimboResolution",nC.oe))}}async function Kf(t,e,n){const r=lt(t),s=[],i=[],a=[];r.Fa.isEmpty()||(r.Fa.forEach((l,c)=>{a.push(r.Ka(c,e,n).then(d=>{var h;if((d||n)&&r.isPrimaryClient){const f=d?!d.fromCache:(h=n==null?void 0:n.targetChanges.get(c.targetId))===null||h===void 0?void 0:h.current;
2796r.sharedClientState.updateQueryState(c.targetId,f?"current":"not-current")}if(d){s.push(d);const f=pC.Wi(c.targetId,d);i.push(f)}}))}),await Promise.all(a),r.Ca.d_(s),await async function(c,d){const h=lt(c);try{await h.persistence.runTransaction("notifyLocalViewChanges","readwrite",f=>ye.forEach(d,p=>ye.forEach(p.$i,g=>h.persistence.referenceDelegate.addReference(f,p.targetId,g)).next(()=>ye.forEach(p.Ui,g=>h.persistence.referenceDelegate.removeReference(f,p.targetId,g)))))}catch(f){if(!Hf(f))throw f;Be("LocalStore","Failed to update sequence numbers: "+f)}for(const f of d){const p=f.targetId;if(!f.fromCache){const g=h.os.get(p),v=g.snapshotVersion,x=g.withLastLimboFreeSnapshotVersion(v);h.os=h.os.insert(p,x)}}}(r.localStore,i))}async function F9(t,e){const n=lt(t);if(!n.currentUser.isEqual(e)){Be("SyncEngine","User change. New user:",e.toKey());const r=await ER(n.localStore,e);n.currentUser=e,function(i,a){i.ka.forEach(l=>{l.forEach(c=>{c.reject(new Me(fe.CANCELLED,a))})}),i.ka.clear()}(n,"'waitForPendingWrites' promise is rejected due to a user change."),n.sharedClientState.handleUserChange(e,r.removedBatchIds,r.addedBatchIds),await Kf(n,r.hs)}}function z9(t,e){const n=lt(t),r=n.Na.get(e);if(r&&r.va)return jt().add(r.key);{let s=jt();const i=n.Ma.get(e);if(!i)return s;for(const a of i){const l=n.Fa.get(a);s=s.unionWith(l.view.Va)}return s}}function BR(t){const e=lt(t);return e.remoteStore.remoteSyncer.applyRemoteEvent=zR.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=z9.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=D9.bind(null,e),e.Ca.d_=j9.bind(null,e.eventManager),e.Ca.$a=C9.bind(null,e.eventManager),e}function $9(t){const e=lt(t);return e.remoteStore.remoteSyncer.applySuccessfulWrite=L9.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=M9.bind(null,e),e}class Ug{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=Yv(e.databaseInfo.databaseId),this.sharedClientState=this.Wa(e),this.persistence=this.Ga(e),await this.persistence.start(),this.localStore=this.za(e),this.gcScheduler=this.ja(e,this.localStore),this.indexBackfillerScheduler=this.Ha(e,this.localStore)}ja(e,n){return null}Ha(e,n){return null}za(e){return qB(this.persistence,new WB,e.initialUser,this.serializer)}Ga(e){return new VB(mC.Zr,this.serializer)}Wa(e){return new JB}async terminate(){var e,n;(e=this.gcScheduler)===null||e===void 0||e.stop(),(n=this.indexBackfillerScheduler)===null||n===void 0||n.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}Ug.provider={build:()=>new Ug};class J0{async initialize(e,n){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(n),this.remoteStore=this.createRemoteStore(n),this.eventManager=this.createEventManager(n),this.syncEngine=this.createSyncEngine(n,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=r=>GE(this.syncEngine,r,1),this.remoteStore.remoteSyncer.handleCredentialChange=F9.bind(null,this.syncEngine),await y9(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return function(){return new b9}()}createDatastore(e){const n=Yv(e.databaseInfo.databaseId),r=function(i){return new r9(i)}(e.databaseInfo);return function(i,a,l,c){return new i9(i,a,l,c)}(e.authCredentials,e.appCheckCredentials,r,n)}createRemoteStore(e){return function(r,s,i,a,l){return new l9(r,s,i,a,l)}(this.localStore,this.datastore,e.asyncQueue,n=>GE(this.syncEngine,n,0),function(){return UE.D()?new UE:new e9}())}createSyncEngine(e,n){return function(s,i,a,l,c,d,h){const f=new S9(s,i,a,l,c,d);return h&&(f.Qa=!0),f}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,n)}async terminate(){var e,n;await async function(s){const i=lt(s);Be("RemoteStore","RemoteStore shutting down."),i.L_.add(5),await Zf(i),i.k_.shutdown(),i.q_.set("Unknown")}(this.remoteStore),(e=this.datastore)===null||e===void 0||e.terminate(),(n=this.eventManager)===null||n===void 0||n.terminate()}}J0.provider={build:()=>new J0};/** 2797 * @license 2798 * Copyright 2020 Google LLC 2799 * 2800 * Licensed under the Apache License, Version 2.0 (the "License");
2801 * you may not use this file except in compliance with the License. 2802 * You may obtain a copy of the License at 2803 * 2804 * http://www.apache.org/licenses/LICENSE-2.0 2805 * 2806 * Unless required by applicable law or agreed to in writing, software 2807 * distributed under the License is distributed on an "AS IS" BASIS, 2808 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2809 * See the License for the specific language governing permissions and 2810 * limitations under the License. 2811 *//** 2812 * @license 2813 * Copyright 2017 Google LLC 2814 * 2815 * Licensed under the Apache License, Version 2.0 (the "License"); 2816 * you may not use this file except in compliance with the License. 2817 * You may obtain a copy of the License at 2818 * 2819 * http://www.apache.org/licenses/LICENSE-2.0 2820 * 2821 * Unless required by applicable law or agreed to in writing, software 2822 * distributed under the License is distributed on an "AS IS" BASIS, 2823 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2824 * See the License for the specific language governing permissions and 2825 * limitations under the License. 2826 */class SC{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Ya(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Ya(this.observer.error,e):Li("Uncaught Error in snapshot listener:",e.toString()))}Za(){this.muted=!0}Ya(e,n){setTimeout(()=>{this.muted||e(n)},0)}}/** 2827 * @license 2828 * Copyright 2017 Google LLC 2829 * 2830 * Licensed under the Apache License, Version 2.0 (the "License"); 2831 * you may not use this file except in compliance with the License. 2832 * You may obtain a copy of the License at 2833 * 2834 * http://www.apache.org/licenses/LICENSE-2.0 2835 * 2836 * Unless required by applicable law or agreed to in writing, software 2837 * distributed under the License is distributed on an "AS IS" BASIS, 2838 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2839 * See the License for the specific language governing permissions and 2840 * limitations under the License. 2841 */class V9{constructor(e,n,r,s,i){this.authCredentials=e,this.appCheckCredentials=n,this.asyncQueue=r,this.databaseInfo=s,this.user=Rr.UNAUTHENTICATED,this.clientId=GA.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(r,async a=>{Be("FirestoreClient","Received user=",a.uid),await this.authCredentialListener(a),this.user=a}),this.appCheckCredentials.start(r,a=>(Be("FirestoreClient","Received new app check token=",a),this.appCheckCredentialListener(a,this.user)))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();const e=new Ei;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(n){const r=bC(n,"Failed to shutdown persistence");e.reject(r)}}),e.promise}}async function My(t,e){t.asyncQueue.verifyOperationInProgress(),Be("FirestoreClient","Initializing OfflineComponentProvider");const n=t.configuration;await e.initialize(n);let r=n.initialUser;t.setCredentialChangeListener(async s=>{r.isEqual(s)||(await ER(e.localStore,s),r=s)}),e.persistence.setDatabaseDeletedListener(()=>t.terminate()),t._offlineComponents=e}async function KE(t,e){t.asyncQueue.verifyOperationInProgress();const n=await U9(t);Be("FirestoreClient","Initializing OnlineComponentProvider"),await e.initialize(n,t.configuration),t.setCredentialChangeListener(r=>BE(e.remoteStore,r)),t.setAppCheckTokenChangeListener((r,s)=>BE(e.remoteStore,s)),t._onlineComponents=e}async function U9(t){if(!t._offlineComponents)if(t._uninitializedComponentsProvider){Be("FirestoreClient","Using user provided OfflineComponentProvider");try{await My(t,t._uninitializedComponentsProvider._offline)}catch(e){const n=e;if(!function(s){return s.name==="FirebaseError"?s.code===fe.FAILED_PRECONDITION||s.code===fe.UNIMPLEMENT
2841ED:!(typeof DOMException<"u"&&s instanceof DOMException)||s.code===22||s.code===20||s.code===11}(n))throw n;Ou("Error using user provided cache. Falling back to memory cache: "+n),await My(t,new Ug)}}else Be("FirestoreClient","Using default OfflineComponentProvider"),await My(t,new Ug);return t._offlineComponents}async function WR(t){return t._onlineComponents||(t._uninitializedComponentsProvider?(Be("FirestoreClient","Using user provided OnlineComponentProvider"),await KE(t,t._uninitializedComponentsProvider._online)):(Be("FirestoreClient","Using default OnlineComponentProvider"),await KE(t,new J0))),t._onlineComponents}function B9(t){return WR(t).then(e=>e.syncEngine)}async function Bg(t){const e=await WR(t),n=e.eventManager;return n.onListen=k9.bind(null,e.syncEngine),n.onUnlisten=T9.bind(null,e.syncEngine),n.onFirstRemoteStoreListen=P9.bind(null,e.syncEngine),n.onLastRemoteStoreUnlisten=A9.bind(null,e.syncEngine),n}function W9(t,e,n={}){const r=new Ei;return t.asyncQueue.enqueueAndForget(async()=>function(i,a,l,c,d){const h=new SC({next:p=>{h.Za(),a.enqueueAndForget(()=>CC(i,f));const g=p.docs.has(l);!g&&p.fromCache?d.reject(new Me(fe.UNAVAILABLE,"Failed to get document because the client is offline.")):g&&p.fromCache&&c&&c.source==="server"?d.reject(new Me(fe.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):d.resolve(p)},error:p=>d.reject(p)}),f=new _C(Wv(l.path),h,{includeMetadataChanges:!0,_a:!0});return jC(i,f)}(await Bg(t),t.asyncQueue,e,n,r)),r.promise}function H9(t,e,n={}){const r=new Ei;return t.asyncQueue.enqueueAndForget(async()=>function(i,a,l,c,d){const h=new SC({next:p=>{h.Za(),a.enqueueAndForget(()=>CC(i,f)),p.fromCache&&c.source==="server"?d.reject(new Me(fe.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):d.resolve(p)},error:p=>d.reject(p)}),f=new _C(l,h,{includeMetadataChanges:!0,_a:!0});return jC(i,f)}(await Bg(t),t.asyncQueue,e,n,r)),r.promise}/** 2842 * @license 2843 * Copyright 2023 Google LLC 2844 * 2845 * Licensed under the Apache License, Version 2.0 (the "License"); 2846 * you may not use this file except in compliance with the License. 2847 * You may obtain a copy of the License at 2848 * 2849 * http://www.apache.org/licenses/LICENSE-2.0 2850 * 2851 * Unless required by applicable law or agreed to in writing, software 2852 * distributed under the License is distributed on an "AS IS" BASIS, 2853 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2854 * See the License for the specific language governing permissions and 2855 * limitations under the License. 2856 */function HR(t){const e={};return t.timeoutSeconds!==void 0&&(e.timeoutSeconds=t.timeoutSeconds),e}/** 2857 * @license 2858 * Copyright 2020 Google LLC 2859 * 2860 * Licensed under the Apache License, Version 2.0 (the "License"); 2861 * you may not use this file except in compliance with the License. 2862 * You may obtain a copy of the License at 2863 * 2864 * http://www.apache.org/licenses/LICENSE-2.0 2865 * 2866 * Unless required by applicable law or agreed to in writing, software 2867 * distributed under the License is distributed on an "AS IS" BASIS, 2868 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2869 * See the License for the specific language governing permissions and 2870 * limitations under the License. 2871 */const YE=new Map;/** 2872 * @license 2873 * Copyright 2017 Google LLC 2874 * 2875 * Licensed under the Apache License, Version 2.0 (the "License"); 2876 * you may not use this file except in compliance with the License. 2877 * You may obtain a copy of the License at 2878 * 2879 * http://www.apache.org/licenses/LICENSE-2.0 2880 * 2881 * Unless required by applicable law or agreed to in writing, software 2882 * distributed under the License is distributed on an "AS IS" BASIS, 2883 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2884 * See the License for the specific language governing permissions and 2885 * limitations under the License. 2886 */function qR(t,e,n){if(!n)throw new Me(fe.INVALID_ARGUMENT,`Function ${t}() cannot be called with an empty ${e}.`)}function q9(t,e,n,r){if(e===!0&&r===!0)throw new Me(fe.INVALID_ARGUMENT,`${t} and ${n} cannot be used together.`)}
2886function QE(t){if(!Ge.isDocumentKey(t))throw new Me(fe.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`)}function XE(t){if(Ge.isDocumentKey(t))throw new Me(fe.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`)}function Jv(t){if(t===void 0)return"undefined";if(t===null)return"null";if(typeof t=="string")return t.length>20&&(t=`${t.substring(0,20)}...`),JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean")return""+t;if(typeof t=="object"){if(t instanceof Array)return"an array";{const e=function(r){return r.constructor?r.constructor.name:null}(t);return e?`a custom ${e} object`:"an object"}}return typeof t=="function"?"a function":it()}function ds(t,e){if("_delegate"in t&&(t=t._delegate),!(t instanceof e)){if(e.name===t.constructor.name)throw new Me(fe.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const n=Jv(t);throw new Me(fe.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${n}`)}}return t}/** 2887 * @license 2888 * Copyright 2020 Google LLC 2889 * 2890 * Licensed under the Apache License, Version 2.0 (the "License"); 2891 * you may not use this file except in compliance with the License. 2892 * You may obtain a copy of the License at 2893 * 2894 * http://www.apache.org/licenses/LICENSE-2.0 2895 * 2896 * Unless required by applicable law or agreed to in writing, software 2897 * distributed under the License is distributed on an "AS IS" BASIS, 2898 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2899 * See the License for the specific language governing permissions and 2900 * limitations under the License. 2901 */class JE{constructor(e){var n,r;if(e.host===void 0){if(e.ssl!==void 0)throw new Me(fe.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=e.host,this.ssl=(n=e.ssl)===null||n===void 0||n;if(this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=41943040;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<1048576)throw new Me(fe.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}q9("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=HR((r=e.experimentalLongPollingOptions)!==null&&r!==void 0?r:{}),function(i){if(i.timeoutSeconds!==void 0){if(isNaN(i.timeoutSeconds))throw new Me(fe.INVALID_ARGUMENT,`invalid long polling timeout: ${i.timeoutSeconds} (must not be NaN)`);if(i.timeoutSeconds<5)throw new Me(fe.INVALID_ARGUMENT,`invalid long polling timeout: ${i.timeoutSeconds} (minimum allowed value is 5)`);if(i.timeoutSeconds>30)throw new Me(fe.INVALID_ARGUMENT,`invalid long polling timeout: ${i.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&function(r,s){return r.timeoutSeconds===s.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class ex{constructor(e,n,r,s){this._authCredentials=e,this._appCheckCredentials=n,this._databaseId=r,this._app=s,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new JE({}),this._settingsFrozen=!1,this._terminateTask="notTerminated"}get app(){if(!this._app)throw new Me(fe.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!=="notTerminated"}_setSettings(e){if(this._settingsFrozen)throw new Me(fe.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new JE(e),e.credentials!==void 0&&(this._authCredentials=function(r){if(!r)return new c8;switch(r.type){case"firstParty":return new f8(r.sessionIndex||"0",r.iamToken||null,r.authTokenFactory||null);case"provider":return r.client;default:throw new Me(fe.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invali
2901d credential type")}}(e.credentials))}_getSettings(){return this._settings}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(n){const r=YE.get(n);r&&(Be("ComponentProvider","Removing Datastore"),YE.delete(n),r.terminate())}(this),Promise.resolve()}}function G9(t,e,n,r={}){var s;const i=(t=ds(t,ex))._getSettings(),a=`${e}:${n}`;if(i.host!=="firestore.googleapis.com"&&i.host!==a&&Ou("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used."),t._setSettings(Object.assign(Object.assign({},i),{host:a,ssl:!1})),r.mockUserToken){let l,c;if(typeof r.mockUserToken=="string")l=r.mockUserToken,c=Rr.MOCK_USER;else{l=JT(r.mockUserToken,(s=t._app)===null||s===void 0?void 0:s.options.projectId);const d=r.mockUserToken.sub||r.mockUserToken.user_id;if(!d)throw new Me(fe.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");c=new Rr(d)}t._authCredentials=new u8(new qA(l,c))}}/** 2902 * @license 2903 * Copyright 2020 Google LLC 2904 * 2905 * Licensed under the Apache License, Version 2.0 (the "License"); 2906 * you may not use this file except in compliance with the License. 2907 * You may obtain a copy of the License at 2908 * 2909 * http://www.apache.org/licenses/LICENSE-2.0 2910 * 2911 * Unless required by applicable law or agreed to in writing, software 2912 * distributed under the License is distributed on an "AS IS" BASIS, 2913 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2914 * See the License for the specific language governing permissions and 2915 * limitations under the License. 2916 */class Wi{constructor(e,n,r){this.converter=n,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new Wi(this.firestore,e,this._query)}}class zr{constructor(e,n,r){this.converter=n,this._key=r,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new Ra(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new zr(this.firestore,e,this._key)}}class Ra extends Wi{constructor(e,n,r){super(e,n,Wv(r)),this._path=r,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new zr(this.firestore,null,new Ge(e))}withConverter(e){return new Ra(this.firestore,e,this._path)}}function jn(t,e,...n){if(t=tn(t),qR("collection","path",e),t instanceof ex){const r=mn.fromString(e,...n);return XE(r),new Ra(t,null,r)}{if(!(t instanceof zr||t instanceof Ra))throw new Me(fe.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=t._path.child(mn.fromString(e,...n));return XE(r),new Ra(t.firestore,null,r)}}function Ht(t,e,...n){if(t=tn(t),arguments.length===1&&(e=GA.newId()),qR("doc","path",e),t instanceof ex){const r=mn.fromString(e,...n);return QE(r),new zr(t,null,new Ge(r))}{if(!(t instanceof zr||t instanceof Ra))throw new Me(fe.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=t._path.child(mn.fromString(e,...n));return QE(r),new zr(t.firestore,t instanceof Ra?t.converter:null,new Ge(r))}}/** 2917 * @license 2918 * Copyright 2020 Google LLC 2919 * 2920 * Licensed under the Apache License, Version 2.0 (the "License"); 2921 * you may not use this file except in compliance with the License. 2922 * You may obtain a copy of the License at 2923 * 2924 * http://www.apache.org/licenses/LICENSE-2.0 2925 * 2926 * Unless required by applicable law or agreed to in writing, software 2927 * distributed under the License is distributed on an "AS IS" BASIS, 2928 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2929 * See the License for the specific language governing permissions and 2930 * limitations under the License. 2931 */class eS{constructor(e=Promise.resolve()){this.Pu=[],this.Iu=!1,this.Tu=[],this.Eu=null,this.du=!1,this.Au=!1,this.Ru=[],this.t_=new kR(this,"async_queue_retry"),this.Vu=()=>{const r=Ly();r&&Be("AsyncQueue","Visibility state changed to "+r.visibilityState),this.t_.jo()},this.mu=e;const n=Ly();n&&typeof n.addEventListener=="function"&&n.addEventListener("visibilitychange",this.Vu)}get isShuttingDown(){return this.Iu}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.fu(),this.gu(e)}enterRestrictedMode(e){if(!this.Iu){this.Iu=!0,this.Au=e||!1;const n=Ly();n&&typeof n.removeEventListener=="function"&&n.removeEventListener("visibilitychange",this.Vu)}}enqueue(e){if(this.fu(),this.Iu)return new Promise(()=>{});const n=new Ei;return this.gu(()=>this.Iu&&this.Au?Promise.resolve():(e().then(n.resolve,n.reject),n.promise)).then(()=>n.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.Pu.push(e),this.pu()))}async pu(){if(this.Pu.length!==0){try{await this.Pu[0](),this.Pu.shift(),this.t_.reset()}catch(e){if(!Hf(e))throw e;Be("AsyncQueue","Operation failed with retryable error: "+e)}this.Pu.length>0&&this.t_.Go(()=>this.pu())}}gu(e){const n=this.mu.then(()=>(this.du=!0,e().catch(r=>{this.Eu=r,this.du=!1;const s=function(a){let l=a.message||"";return a.stack&&(l=a.stack.includes(a.message)?a.stack:a.message+` 2932`+a.stack),l}(r);throw Li("INTERNAL UNHANDLED ERROR: ",s),r}).then(r=>(this.du=!1,r))));return this.mu=n,n}enqueueAfterDelay(e,n,r){this.fu(),this.Ru.indexOf(e)>-1&&(n=0);const s=wC.createAndSchedule(this,e,n,r,i=>this.yu(i));return this.Tu.push(s),s}fu(){this.Eu&&it()}verifyOperationInProgress(){}async wu(){let e;do e=this.mu,await e;while(e!==this.mu)}Su(e){for(const n of this.Tu)if(n.timerId===e)return!0;return!1}bu(e){return this.wu().then(()=>{this.Tu.sort((n,r)=>n.targetTimeMs-r.targetTimeMs);for(const n of this.Tu)if(n.skipDelay(),e!=="all"&&n.timerId===e)break;return this.wu()})}Du(e){this.Ru.push(e)}yu(e){const n=this.Tu.indexOf(e);this.Tu.splice(n,1)}}function tS(t){return function(n,r){if(typeof n!="object"||n===null)return!1;const s=n;for(const i of r)if(i in s&&typeof s[i]=="function")return!0;return!1}(t,["next","error","complete"])}class Oi extends ex{constructor(e,n,r,s){super(e,n,r,s),this.type="firestore",this._queue=new eS,this._persistenceKey=(s==null?void 0:s.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const e=this._firestoreClient.terminate();this._queue=new eS(e),this._firestoreClient=void 0,await e}}}function Z9(t,e){const n=typeof t=="object"?t:Fv(),r=typeof t=="string"?t:"(default)",s=$f(n,"firestore").getImmediate({identifier:r});if(!s._initialized){const i=Wj("firestore");i&&G9(s,...i)}return s}function tx(t){if(t._terminated)throw new Me(fe.FAILED_PRECONDITION,"The client has already been terminated.");return t._firestoreClient||K9(t),t._firestoreClient}function K9(t){var e,n,r;const s=t._freezeSettings(),i=function(l,c,d,h){return new E8(l,c,d,h.host,h.ssl,h.experimentalForceLongPolling,h.experimentalAutoDetectLongPolling,HR(h.experimentalLongPollingOptions),h.useFetchStreams)}(t._databaseId,((e=t._app)===null||e===void 0?void 0:e.options.appId)||"",t._persistenceKey,s);t._componentsProvider||!((n=s.localCache)===null||n===void 0)&&n._offlineComponentProvider&&(!((r=s.localCache)===null||r===void 0)&&r._onlineComponentProvider)&&(t._componentsProvider={_offline:s.localCache._offlineComponentProvider,_online:s.localCache._onlineComponentProvider}),t._firestoreClient=new V9(t._authCredentials,t._appCheckCredentials,t._queue,i,t._componentsProvider&&function(l){const c=l==null?void 0:l._online.build();return{_offline:l==null?void 0:l._offline.build(c),_online:c}}(t._componentsProvider))}/** 2933 * @license 2934 * Copyright 2020 Google LLC 2935 * 2936 * Licensed under the Apache License, Version 2.0 (the "License");
2937 * you may not use this file except in compliance with the License. 2938 * You may obtain a copy of the License at 2939 * 2940 * http://www.apache.org/licenses/LICENSE-2.0 2941 * 2942 * Unless required by applicable law or agreed to in writing, software 2943 * distributed under the License is distributed on an "AS IS" BASIS, 2944 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2945 * See the License for the specific language governing permissions and 2946 * limitations under the License. 2947 */class Bu{constructor(e){this._byteString=e}static fromBase64String(e){try{return new Bu(Cr.fromBase64String(e))}catch(n){throw new Me(fe.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+n)}}static fromUint8Array(e){return new Bu(Cr.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}}/** 2948 * @license 2949 * Copyright 2020 Google LLC 2950 * 2951 * Licensed under the Apache License, Version 2.0 (the "License"); 2952 * you may not use this file except in compliance with the License. 2953 * You may obtain a copy of the License at 2954 * 2955 * http://www.apache.org/licenses/LICENSE-2.0 2956 * 2957 * Unless required by applicable law or agreed to in writing, software 2958 * distributed under the License is distributed on an "AS IS" BASIS, 2959 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2960 * See the License for the specific language governing permissions and 2961 * limitations under the License. 2962 */class nx{constructor(...e){for(let n=0;n<e.length;++n)if(e[n].length===0)throw new Me(fe.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new gr(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}/** 2963 * @license 2964 * Copyright 2020 Google LLC 2965 * 2966 * Licensed under the Apache License, Version 2.0 (the "License"); 2967 * you may not use this file except in compliance with the License. 2968 * You may obtain a copy of the License at 2969 * 2970 * http://www.apache.org/licenses/LICENSE-2.0 2971 * 2972 * Unless required by applicable law or agreed to in writing, software 2973 * distributed under the License is distributed on an "AS IS" BASIS, 2974 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2975 * See the License for the specific language governing permissions and 2976 * limitations under the License. 2977 */class rx{constructor(e){this._methodName=e}}/** 2978 * @license 2979 * Copyright 2017 Google LLC 2980 * 2981 * Licensed under the Apache License, Version 2.0 (the "License"); 2982 * you may not use this file except in compliance with the License. 2983 * You may obtain a copy of the License at 2984 * 2985 * http://www.apache.org/licenses/LICENSE-2.0 2986 * 2987 * Unless required by applicable law or agreed to in writing, software 2988 * distributed under the License is distributed on an "AS IS" BASIS, 2989 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2990 * See the License for the specific language governing permissions and 2991 * limitations under the License. 2992 */class Fi{constructor(e,n){if(!isFinite(e)||e<-90||e>90)throw new Me(fe.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(n)||n<-180||n>180)throw new Me(fe.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+n);this._lat=e,this._long=n}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(e){return Mt(this._lat,e._lat)||Mt(this._long,e._long)}}/** 2993 * @license 2994 * Copyright 2024 Google LLC 2995 * 2996 * Licensed under the Apache License, Version 2.0 (the "License"); 2997 * you may not use this file except in compliance with the License. 2998 * You may obtain a copy of the License at 2999 * 3000 * http://www.apache.org/licenses/LICENSE-2.0 3001 * 3002 * Unless required by applicable law or agreed to in writing, software 3003 * distributed under the License is distributed on an "AS IS" BASIS, 3004 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3005 * See the License for the specific language governing permissions and 3006 * limitations under the License. 3007 */class kC{constructor(e){this._values=(e||[]).map(n=>n)}toArray(){return this._values.map(e=>e)}isEqual(e){return function(r,s){if(r.length!==s.length)return!1;for(let i=0;i<r.length;++i)if(r[i]!==s[i])return!1;return!0}(this._values,e._values)}}/** 3008 * @license 3009 * Copyright 2017 Google LLC 3010 * 3011 * Licensed under the Apache License, Version 2.0 (the "License");
3012 * you may not use this file except in compliance with the License. 3013 * You may obtain a copy of the License at 3014 * 3015 * http://www.apache.org/licenses/LICENSE-2.0 3016 * 3017 * Unless required by applicable law or agreed to in writing, software 3018 * distributed under the License is distributed on an "AS IS" BASIS, 3019 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3020 * See the License for the specific language governing permissions and 3021 * limitations under the License. 3022 */const Y9=/^__.*__$/;class Q9{constructor(e,n,r){this.data=e,this.fieldMask=n,this.fieldTransforms=r}toMutation(e,n){return this.fieldMask!==null?new sl(e,this.data,this.fieldMask,n,this.fieldTransforms):new qf(e,this.data,n,this.fieldTransforms)}}class GR{constructor(e,n,r){this.data=e,this.fieldMask=n,this.fieldTransforms=r}toMutation(e,n){return new sl(e,this.data,this.fieldMask,n,this.fieldTransforms)}}function ZR(t){switch(t){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw it()}}class PC{constructor(e,n,r,s,i,a){this.settings=e,this.databaseId=n,this.serializer=r,this.ignoreUndefinedProperties=s,i===void 0&&this.vu(),this.fieldTransforms=i||[],this.fieldMask=a||[]}get path(){return this.settings.path}get Cu(){return this.settings.Cu}Fu(e){return new PC(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}Mu(e){var n;const r=(n=this.path)===null||n===void 0?void 0:n.child(e),s=this.Fu({path:r,xu:!1});return s.Ou(e),s}Nu(e){var n;const r=(n=this.path)===null||n===void 0?void 0:n.child(e),s=this.Fu({path:r,xu:!1});return s.vu(),s}Lu(e){return this.Fu({path:void 0,xu:!0})}Bu(e){return Wg(e,this.settings.methodName,this.settings.ku||!1,this.path,this.settings.qu)}contains(e){return this.fieldMask.find(n=>e.isPrefixOf(n))!==void 0||this.fieldTransforms.find(n=>e.isPrefixOf(n.field))!==void 0}vu(){if(this.path)for(let e=0;e<this.path.length;e++)this.Ou(this.path.get(e))}Ou(e){if(e.length===0)throw this.Bu("Document fields must not be empty");if(ZR(this.Cu)&&Y9.test(e))throw this.Bu('Document fields cannot begin and end with "__"')}}class X9{constructor(e,n,r){this.databaseId=e,this.ignoreUndefinedProperties=n,this.serializer=r||Yv(e)}Qu(e,n,r,s=!1){return new PC({Cu:e,methodName:n,qu:r,path:gr.emptyPath(),xu:!1,ku:s},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function sx(t){const e=t._freezeSettings(),n=Yv(t._databaseId);return new X9(t._databaseId,!!e.ignoreUndefinedProperties,n)}function KR(t,e,n,r,s,i={}){const a=t.Qu(i.merge||i.mergeFields?2:0,e,n,s);TC("Data must be an object, but it was:",a,r);const l=YR(r,a);let c,d;if(i.merge)c=new Cs(a.fieldMask),d=a.fieldTransforms;else if(i.mergeFields){const h=[];for(const f of i.mergeFields){const p=eb(e,f,n);if(!a.contains(p))throw new Me(fe.INVALID_ARGUMENT,`Field '${p}' is specified in your field mask but missing from your input data.`);XR(h,p)||h.push(p)}c=new Cs(h),d=a.fieldTransforms.filter(f=>c.covers(f.field))}else c=null,d=a.fieldTransforms;return new Q9(new os(l),c,d)}class ox extends rx{_toFieldTransform(e){if(e.Cu!==2)throw e.Cu===1?e.Bu(`${this._methodName}() can only appear at the top level of your update data`):e.Bu(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof ox}}class IC extends rx{_toFieldTransform(e){return new Q8(e.path,new pf)}isEqual(e){return e instanceof IC}}function J9(t,e,n,r){const s=t.Qu(1,e,n);TC("Data must be an object, but it was:",s,r);const i=[],a=os.empty();pc(r,(c,d)=>{const h=AC(e,c,n);d=tn(d);const f=s.Nu(h);if(d instanceof ox)i.push(h);else{const p=Yf(d,f);p!=null&&(i.push(h),a.set(h,p))}});const l=new Cs(i);return new GR(a,l,s.fieldTransforms)}function e7(t,e,n,r,s,i){const a=t.Qu(1,e,n),l=[eb(e,r,n)],c=[s];if(i.length%2!=0)throw new Me(fe.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let p=0;p<i.length;p+=2)l.push(eb(e,i[p])),c.push(i[p+1]);const d=[],h=os.empty();for(let p=l.length-1;p>=0;--p)if(!XR(d,l[p])){const g=l[p];let v=c[p];v=tn(v);const x=a.Nu(g);if(v instanceof ox)d.push(g);else{const y=Yf(v,x);y!=null&&(d.push(g),h.set(g,y))}}const f=new Cs(d);return new GR(h,f,a.fieldTransforms)}function t7(t,e,n,r=!1){return Yf(n,t.Qu(r?4:3,e))}function Yf(t,e){if(QR(t=tn(t)))return TC("Unsupported field value:",e,t),YR(t,e);
3022if(t instanceof rx)return function(r,s){if(!ZR(s.Cu))throw s.Bu(`${r._methodName}() can only be used with update() and set()`);if(!s.path)throw s.Bu(`${r._methodName}() is not currently supported inside arrays`);const i=r._toFieldTransform(s);i&&s.fieldTransforms.push(i)}(t,e),null;if(t===void 0&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),t instanceof Array){if(e.settings.xu&&e.Cu!==4)throw e.Bu("Nested arrays are not supported");return function(r,s){const i=[];let a=0;for(const l of r){let c=Yf(l,s.Lu(a));c==null&&(c={nullValue:"NULL_VALUE"}),i.push(c),a++}return{arrayValue:{values:i}}}(t,e)}return function(r,s){if((r=tn(r))===null)return{nullValue:"NULL_VALUE"};if(typeof r=="number")return Z8(s.serializer,r);if(typeof r=="boolean")return{booleanValue:r};if(typeof r=="string")return{stringValue:r};if(r instanceof Date){const i=gn.fromDate(r);return{timestampValue:$g(s.serializer,i)}}if(r instanceof gn){const i=new gn(r.seconds,1e3*Math.floor(r.nanoseconds/1e3));return{timestampValue:$g(s.serializer,i)}}if(r instanceof Fi)return{geoPointValue:{latitude:r.latitude,longitude:r.longitude}};if(r instanceof Bu)return{bytesValue:yR(s.serializer,r._byteString)};if(r instanceof zr){const i=s.databaseId,a=r.firestore._databaseId;if(!a.isEqual(i))throw s.Bu(`Document reference is for database ${a.projectId}/${a.database} but should be for database ${i.projectId}/${i.database}`);return{referenceValue:hC(r.firestore._databaseId||s.databaseId,r._key.path)}}if(r instanceof kC)return function(a,l){return{mapValue:{fields:{__type__:{stringValue:"__vector__"},value:{arrayValue:{values:a.toArray().map(c=>{if(typeof c!="number")throw l.Bu("VectorValues must only contain numeric values.");return lC(l.serializer,c)})}}}}}}(r,s);throw s.Bu(`Unsupported field value: ${Jv(r)}`)}(t,e)}function YR(t,e){const n={};return ZA(t)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):pc(t,(r,s)=>{const i=Yf(s,e.Mu(r));i!=null&&(n[r]=i)}),{mapValue:{fields:n}}}function QR(t){return!(typeof t!="object"||t===null||t instanceof Array||t instanceof Date||t instanceof gn||t instanceof Fi||t instanceof Bu||t instanceof zr||t instanceof rx||t instanceof kC)}function TC(t,e,n){if(!QR(n)||!function(s){return typeof s=="object"&&s!==null&&(Object.getPrototypeOf(s)===Object.prototype||Object.getPrototypeOf(s)===null)}(n)){const r=Jv(n);throw r==="an object"?e.Bu(t+" a custom object"):e.Bu(t+" "+r)}}function eb(t,e,n){if((e=tn(e))instanceof nx)return e._internalPath;if(typeof e=="string")return AC(t,e);throw Wg("Field path arguments must be of type string or ",t,!1,void 0,n)}const n7=new RegExp("[~\\*/\\[\\]]");function AC(t,e,n){if(e.search(n7)>=0)throw Wg(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,t,!1,void 0,n);try{return new nx(...e.split("."))._internalPath}catch{throw Wg(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,t,!1,void 0,n)}}function Wg(t,e,n,r,s){const i=r&&!r.isEmpty(),a=s!==void 0;let l=`Function ${e}() called with invalid data`;n&&(l+=" (via `toFirestore()`)"),l+=". ";let c="";return(i||a)&&(c+=" (found",i&&(c+=` in field ${r}`),a&&(c+=` in document ${s}`),c+=")"),new Me(fe.INVALID_ARGUMENT,l+t+c)}function XR(t,e){return t.some(n=>n.isEqual(e))}/** 3023 * @license 3024 * Copyright 2020 Google LLC 3025 * 3026 * Licensed under the Apache License, Version 2.0 (the "License"); 3027 * you may not use this file except in compliance with the License. 3028 * You may obtain a copy of the License at 3029 * 3030 * http://www.apache.org/licenses/LICENSE-2.0 3031 * 3032 * Unless required by applicable law or agreed to in writing, software 3033 * distributed under the License is distributed on an "AS IS" BASIS, 3034 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3035 * See the License for the specific language governing permissions and 3036 * limitations under the License. 3037 */class JR{constructor(e,n,r,s,i){this._firestore=e,this._userDataWriter=n,this._key=r,this._document=s,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new zr(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const e=new r7(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}get(e){if(this._document){const n=this._document.data.field(ix("DocumentSnapshot.get",e));if(n!==null)return this._userDataWriter.convertValue(n)}}}class r7 extends JR{data(){return super.data()}}function ix(t,e){return typeof e=="string"?AC(t,e):e instanceof nx?e._internalPath:e._delegate._internalPath}/** 3038 * @license 3039 * Copyright 2020 Google LLC 3040 * 3041 * Licensed under the Apache License, Version 2.0 (the "License");
3042 * you may not use this file except in compliance with the License. 3043 * You may obtain a copy of the License at 3044 * 3045 * http://www.apache.org/licenses/LICENSE-2.0 3046 * 3047 * Unless required by applicable law or agreed to in writing, software 3048 * distributed under the License is distributed on an "AS IS" BASIS, 3049 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3050 * See the License for the specific language governing permissions and 3051 * limitations under the License. 3052 */function eD(t){if(t.limitType==="L"&&t.explicitOrderBy.length===0)throw new Me(fe.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class RC{}class DC extends RC{}function Gr(t,e,...n){let r=[];e instanceof RC&&r.push(e),r=r.concat(n),function(i){const a=i.filter(c=>c instanceof LC).length,l=i.filter(c=>c instanceof ax).length;if(a>1||a>0&&l>0)throw new Me(fe.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}(r);for(const s of r)t=s._apply(t);return t}class ax extends DC{constructor(e,n,r){super(),this._field=e,this._op=n,this._value=r,this.type="where"}static _create(e,n,r){return new ax(e,n,r)}_apply(e){const n=this._parse(e);return tD(e._query,n),new Wi(e.firestore,e.converter,H0(e._query,n))}_parse(e){const n=sx(e.firestore);return function(i,a,l,c,d,h,f){let p;if(d.isKeyField()){if(h==="array-contains"||h==="array-contains-any")throw new Me(fe.INVALID_ARGUMENT,`Invalid Query. You can't perform '${h}' queries on documentId().`);if(h==="in"||h==="not-in"){rS(f,h);const g=[];for(const v of f)g.push(nS(c,i,v));p={arrayValue:{values:g}}}else p=nS(c,i,f)}else h!=="in"&&h!=="not-in"&&h!=="array-contains-any"||rS(f,h),p=t7(l,a,f,h==="in"||h==="not-in");return Wn.create(d,h,p)}(e._query,"where",n,e.firestore._databaseId,this._field,this._op,this._value)}}function is(t,e,n){const r=e,s=ix("where",t);return ax._create(s,r,n)}class LC extends RC{constructor(e,n){super(),this.type=e,this._queryConstraints=n}static _create(e,n){return new LC(e,n)}_parse(e){const n=this._queryConstraints.map(r=>r._parse(e)).filter(r=>r.getFilters().length>0);return n.length===1?n[0]:jo.create(n,this._getOperator())}_apply(e){const n=this._parse(e);return n.getFilters().length===0?e:(function(s,i){let a=s;const l=i.getFlattenedFilters();for(const c of l)tD(a,c),a=H0(a,c)}(e._query,n),new Wi(e.firestore,e.converter,H0(e._query,n)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}class MC extends DC{constructor(e,n){super(),this._field=e,this._direction=n,this.type="orderBy"}static _create(e,n){return new MC(e,n)}_apply(e){const n=function(s,i,a){if(s.startAt!==null)throw new Me(fe.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(s.endAt!==null)throw new Me(fe.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new mf(i,a)}(e._query,this._field,this._direction);return new Wi(e.firestore,e.converter,function(s,i){const a=s.explicitOrderBy.concat([i]);return new od(s.path,s.collectionGroup,a,s.filters.slice(),s.limit,s.limitType,s.startAt,s.endAt)}(e._query,n))}}function OC(t,e="asc"){const n=e,r=ix("orderBy",t);return MC._create(r,n)}class FC extends DC{constructor(e,n,r){super(),this.type=e,this._limit=n,this._limitType=r}static _create(e,n,r){return new FC(e,n,r)}_apply(e){return new Wi(e.firestore,e.converter,Fg(e._query,this._limit,this._limitType))}}function s7(t){return FC._create("limitToLast",t,"L")}function nS(t,e,n){if(typeof(n=tn(n))=="string"){if(n==="")throw new Me(fe.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!rR(e)&&n.indexOf("/")!==-1)throw new Me(fe.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);const r=e.path.child(mn.fromString(n));
3052if(!Ge.isDocumentKey(r))throw new Me(fe.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return CE(t,new Ge(r))}if(n instanceof zr)return CE(t,n._key);throw new Me(fe.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${Jv(n)}.`)}function rS(t,e){if(!Array.isArray(t)||t.length===0)throw new Me(fe.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`)}function tD(t,e){const n=function(s,i){for(const a of s)for(const l of a.getFlattenedFilters())if(i.indexOf(l.op)>=0)return l.op;return null}(t.filters,function(s){switch(s){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}}(e.op));if(n!==null)throw n===e.op?new Me(fe.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new Me(fe.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`)}class o7{convertValue(e,n="none"){switch(Xl(e)){case 0:return null;case 1:return e.booleanValue;case 2:return Tn(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,n);case 5:return e.stringValue;case 6:return this.convertBytes(Ql(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,n);case 11:return this.convertObject(e.mapValue,n);case 10:return this.convertVectorValue(e.mapValue);default:throw it()}}convertObject(e,n){return this.convertObjectMap(e.fields,n)}convertObjectMap(e,n="none"){const r={};return pc(e,(s,i)=>{r[s]=this.convertValue(i,n)}),r}convertVectorValue(e){var n,r,s;const i=(s=(r=(n=e.fields)===null||n===void 0?void 0:n.value.arrayValue)===null||r===void 0?void 0:r.values)===null||s===void 0?void 0:s.map(a=>Tn(a.doubleValue));return new kC(i)}convertGeoPoint(e){return new Fi(Tn(e.latitude),Tn(e.longitude))}convertArray(e,n){return(e.values||[]).map(r=>this.convertValue(r,n))}convertServerTimestamp(e,n){switch(n){case"previous":const r=sC(e);return r==null?null:this.convertValue(r,n);case"estimate":return this.convertTimestamp(df(e));default:return null}}convertTimestamp(e){const n=Va(e);return new gn(n.seconds,n.nanos)}convertDocumentKey(e,n){const r=mn.fromString(e);Kt(_R(r));const s=new hf(r.get(1),r.get(3)),i=new Ge(r.popFirst(5));return s.isEqual(n)||Li(`Document ${i} contains a document reference within a different database (${s.projectId}/${s.database}) which is not supported. It will be treated as a reference in the current database (${n.projectId}/${n.database}) instead.`),i}}/** 3053 * @license 3054 * Copyright 2020 Google LLC 3055 * 3056 * Licensed under the Apache License, Version 2.0 (the "License"); 3057 * you may not use this file except in compliance with the License. 3058 * You may obtain a copy of the License at 3059 * 3060 * http://www.apache.org/licenses/LICENSE-2.0 3061 * 3062 * Unless required by applicable law or agreed to in writing, software 3063 * distributed under the License is distributed on an "AS IS" BASIS, 3064 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3065 * See the License for the specific language governing permissions and 3066 * limitations under the License. 3067 */function nD(t,e,n){let r;return r=t?n&&(n.merge||n.mergeFields)?t.toFirestore(e,n):t.toFirestore(e):e,r}/** 3068 * @license 3069 * Copyright 2020 Google LLC 3070 * 3071 * Licensed under the Apache License, Version 2.0 (the "License"); 3072 * you may not use this file except in compliance with the License. 3073 * You may obtain a copy of the License at 3074 * 3075 * http://www.apache.org/licenses/LICENSE-2.0 3076 * 3077 * Unless required by applicable law or agreed to in writing, software 3078 * distributed under the License is distributed on an "AS IS" BASIS, 3079 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3080 * See the License for the specific language governing permissions and 3081 * limitations under the License. 3082 */class fh{constructor(e,n){this.hasPendingWrites=e,this.fromCache=n}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class rD extends JR{constructor(e,n,r,s,i,a){super(e,n,r,s,a),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const n=new Qp(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(n,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,n={}){if(this._document){const r=this._document.data.field(ix("DocumentSnapshot.get",e));if(r!==null)return this._userDataWriter.convertValue(r,n.serverTimestamps)}}}class Qp extends rD{data(e={}){return super.data(e)}}class sD{constructor(e,n,r,s){this._firestore=e,this._userDataWriter=n,this._snapshot=s,this.metadata=new fh(s.hasPendingWrites,s.fromCache),this.query=r}get docs(){const e=[];return this.forEach(n=>e.push(n)),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,n){this._snapshot.docs.forEach(r=>{e.call(n,new Qp(this._firestore,this._userDataWriter,r.key,r,new fh(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))})}
3082docChanges(e={}){const n=!!e.includeMetadataChanges;if(n&&this._snapshot.excludesMetadataChanges)throw new Me(fe.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===n||(this._cachedChanges=function(s,i){if(s._snapshot.oldDocs.isEmpty()){let a=0;return s._snapshot.docChanges.map(l=>{const c=new Qp(s._firestore,s._userDataWriter,l.doc.key,l.doc,new fh(s._snapshot.mutatedKeys.has(l.doc.key),s._snapshot.fromCache),s.query.converter);return l.doc,{type:"added",doc:c,oldIndex:-1,newIndex:a++}})}{let a=s._snapshot.oldDocs;return s._snapshot.docChanges.filter(l=>i||l.type!==3).map(l=>{const c=new Qp(s._firestore,s._userDataWriter,l.doc.key,l.doc,new fh(s._snapshot.mutatedKeys.has(l.doc.key),s._snapshot.fromCache),s.query.converter);let d=-1,h=-1;return l.type!==0&&(d=a.indexOf(l.doc.key),a=a.delete(l.doc.key)),l.type!==1&&(a=a.add(l.doc),h=a.indexOf(l.doc.key)),{type:i7(l.type),doc:c,oldIndex:d,newIndex:h}})}}(this,n),this._cachedChangesIncludeMetadataChanges=n),this._cachedChanges}}function i7(t){switch(t){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return it()}}/** 3083 * @license 3084 * Copyright 2020 Google LLC 3085 * 3086 * Licensed under the Apache License, Version 2.0 (the "License"); 3087 * you may not use this file except in compliance with the License. 3088 * You may obtain a copy of the License at 3089 * 3090 * http://www.apache.org/licenses/LICENSE-2.0 3091 * 3092 * Unless required by applicable law or agreed to in writing, software 3093 * distributed under the License is distributed on an "AS IS" BASIS, 3094 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3095 * See the License for the specific language governing permissions and 3096 * limitations under the License. 3097 */function ms(t){t=ds(t,zr);const e=ds(t.firestore,Oi);return W9(tx(e),t._key).then(n=>oD(e,t,n))}class zC extends o7{constructor(e){super(),this.firestore=e}convertBytes(e){return new Bu(e)}convertReference(e){const n=this.convertDocumentKey(e,this.firestore._databaseId);return new zr(this.firestore,null,n)}}function Yr(t){t=ds(t,Wi);const e=ds(t.firestore,Oi),n=tx(e),r=new zC(e);return eD(t._query),H9(n,t._query).then(s=>new sD(e,r,t,s))}function tb(t,e,n){t=ds(t,zr);const r=ds(t.firestore,Oi),s=nD(t.converter,e,n);return lx(r,[KR(sx(r),"setDoc",t._key,s,t.converter!==null,n).toMutation(t._key,Us.none())])}function Ba(t,e,n,...r){t=ds(t,zr);const s=ds(t.firestore,Oi),i=sx(s);let a;return a=typeof(e=tn(e))=="string"||e instanceof nx?e7(i,"updateDoc",t._key,e,n,r):J9(i,"updateDoc",t._key,e),lx(s,[a.toMutation(t._key,Us.exists(!0))])}function Qf(t){return lx(ds(t.firestore,Oi),[new cC(t._key,Us.none())])}function ld(t,e){const n=ds(t.firestore,Oi),r=Ht(t),s=nD(t.converter,e);return lx(n,[KR(sx(t.firestore),"addDoc",r._key,s,t.converter!==null,{}).toMutation(r._key,Us.exists(!1))]).then(()=>r)}function nb(t,...e){var n,r,s;t=tn(t);let i={includeMetadataChanges:!1,source:"default"},a=0;typeof e[a]!="object"||tS(e[a])||(i=e[a],a++);const l={includeMetadataChanges:i.includeMetadataChanges,source:i.source};if(tS(e[a])){const f=e[a];e[a]=(n=f.next)===null||n===void 0?void 0:n.bind(f),e[a+1]=(r=f.error)===null||r===void 0?void 0:r.bind(f),e[a+2]=(s=f.complete)===null||s===void 0?void 0:s.bind(f)}let c,d,h;if(t instanceof zr)d=ds(t.firestore,Oi),h=Wv(t._key.path),c={next:f=>{e[a]&&e[a](oD(d,t,f))},error:e[a+1],complete:e[a+2]};else{const f=ds(t,Wi);d=ds(f.firestore,Oi),h=f._query;const p=new zC(d);c={next:g=>{e[a]&&e[a](new sD(d,p,f,g))},error:e[a+1],complete:e[a+2]},eD(t._query)}return function(p,g,v,x){const y=new SC(x),b=new _C(g,y,v);return p.asyncQueue.enqueueAndForget(async()=>jC(await Bg(p),b)),()=>{y.Za(),p.asyncQueue.enqueueAndForget(async()=>CC(await Bg(p),b))}}(tx(d),h,l,c)}function lx(t,e){return function(r,s){const i=new Ei;return r.asyncQueue.enqueueAndForget(async()=>R9(await B9(r),s,i)),i.promise}(tx(t),e)}function oD(t,e,n){const r=n.docs.get(e._key),s=new zC(t);return new rD(t,s,e._key,r,new fh(n.hasPendingWrites,n.fromCache),e.converter)}function Or(){return new IC("serverTimestamp")}(function(e,n=!0){(function(s){sd=s})(fc),za(new Ai("firestore",(r,{instanceIdentifier:s,options:i})=>{const a=r.getProvider("app").getImmediate(),l=new Oi(new d8(r.getProvider("auth-internal")),new p8(r.getProvider("app-check-internal")),function(d,h){if(!Object.prototype.hasOwnProperty.apply(d.options,["projectId"]))throw new Me(fe.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new hf(d.options.projectId,h)}(a,s),a);return i=Object.assign({useFetchStreams:n},i),l._setSettings(i),l},"PUBLIC").setMultipleInstances(!0)),Vs(xE,"4.7.3",e),Vs(xE,"4.7.3","esm2017")})();var a7="firebase",l7="10.14.1";/** 3098 * @license 3099 * Copyright 2020 Google LLC 3100 * 3101 * Licensed under the Apache License, Version 2.0 (the "License");
3102 * you may not use this file except in compliance with the License. 3103 * You may obtain a copy of the License at 3104 * 3105 * http://www.apache.org/licenses/LICENSE-2.0 3106 * 3107 * Unless required by applicable law or agreed to in writing, software 3108 * distributed under the License is distributed on an "AS IS" BASIS, 3109 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3110 * See the License for the specific language governing permissions and 3111 * limitations under the License. 3112 */Vs(a7,l7,"app");/** 3113 * @license 3114 * Copyright 2017 Google LLC 3115 * 3116 * Licensed under the Apache License, Version 2.0 (the "License"); 3117 * you may not use this file except in compliance with the License. 3118 * You may obtain a copy of the License at 3119 * 3120 * http://www.apache.org/licenses/LICENSE-2.0 3121 * 3122 * Unless required by applicable law or agreed to in writing, software 3123 * distributed under the License is distributed on an "AS IS" BASIS, 3124 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3125 * See the License for the specific language governing permissions and 3126 * limitations under the License. 3127 */const iD="firebasestorage.googleapis.com",aD="storageBucket",c7=2*60*1e3,u7=10*60*1e3;/** 3128 * @license 3129 * Copyright 2017 Google LLC 3130 * 3131 * Licensed under the Apache License, Version 2.0 (the "License"); 3132 * you may not use this file except in compliance with the License. 3133 * You may obtain a copy of the License at 3134 * 3135 * http://www.apache.org/licenses/LICENSE-2.0 3136 * 3137 * Unless required by applicable law or agreed to in writing, software 3138 * distributed under the License is distributed on an "AS IS" BASIS, 3139 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3140 * See the License for the specific language governing permissions and 3141 * limitations under the License. 3142 */class In extends Po{constructor(e,n,r=0){super(Oy(e),`Firebase Storage: ${n} (${Oy(e)})`),this.status_=r,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,In.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return Oy(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage} 3143${this.customData.serverResponse}`:this.message=this._baseMessage}}var Pn;(function(t){t.UNKNOWN="unknown",t.OBJECT_NOT_FOUND="object-not-found",t.BUCKET_NOT_FOUND="bucket-not-found",t.PROJECT_NOT_FOUND="project-not-found",t.QUOTA_EXCEEDED="quota-exceeded",t.UNAUTHENTICATED="unauthenticated",t.UNAUTHORIZED="unauthorized",t.UNAUTHORIZED_APP="unauthorized-app",t.RETRY_LIMIT_EXCEEDED="retry-limit-exceeded",t.INVALID_CHECKSUM="invalid-checksum",t.CANCELED="canceled",t.INVALID_EVENT_NAME="invalid-event-name",t.INVALID_URL="invalid-url",t.INVALID_DEFAULT_BUCKET="invalid-default-bucket",t.NO_DEFAULT_BUCKET="no-default-bucket",t.CANNOT_SLICE_BLOB="cannot-slice-blob",t.SERVER_FILE_WRONG_SIZE="server-file-wrong-size",t.NO_DOWNLOAD_URL="no-download-url",t.INVALID_ARGUMENT="invalid-argument",t.INVALID_ARGUMENT_COUNT="invalid-argument-count",t.APP_DELETED="app-deleted",t.INVALID_ROOT_OPERATION="invalid-root-operation",t.INVALID_FORMAT="invalid-format",t.INTERNAL_ERROR="internal-error",t.UNSUPPORTED_ENVIRONMENT="unsupported-environment"})(Pn||(Pn={}));function Oy(t){return"storage/"+t}function $C(){const t="An unknown error occurred, please check the error payload for server response.";return new In(Pn.UNKNOWN,t)}function d7(t){return new In(Pn.OBJECT_NOT_FOUND,"Object '"+t+"' does not exist.")}function h7(t){return new In(Pn.QUOTA_EXCEEDED,"Quota for bucket '"+t+"' exceeded, please view quota on https://firebase.google.com/pricing/.")}function f7(){const t="User is not authenticated, please authenticate using Firebase Authentication and try again.";return new In(Pn.UNAUTHENTICATED,t)}function m7(){return new In(Pn.UNAUTHORIZED_APP,"This app does not have permission to access Firebase Storage on this project.")}function p7(t){return new In(Pn.UNAUTHORIZED,"User does not have permission to access '"+t+"'.")}function g7(){return new In(Pn.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function v7(){return new In(Pn.CANCELED,"User canceled the upload/download.")}function x7(t){return new In(Pn.INVALID_URL,"Invalid URL '"+t+"'.")}function y7(t){return new In(Pn.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+t+"'.")}function w7(){return new In(Pn.NO_DEFAULT_BUCKET,"No default bucket found. Did you set the '"+aD+"' property when initializing the app?")}function b7(){return new In(Pn.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function j7(){return new In(Pn.NO_DOWNLOAD_URL,"The given file does not have any download URLs.")}function C7(t){return new In(Pn.UNSUPPORTED_ENVIRONMENT,`${t} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`)}function rb(t){return new In(Pn.INVALID_ARGUMENT,t)}function lD(){return new In(Pn.APP_DELETED,"The Firebase app was deleted.")}function N7(t){return new In(Pn.INVALID_ROOT_OPERATION,"The operation '"+t+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}function Lh(t,e){return new In(Pn.INVALID_FORMAT,"String does not match format '"+t+"': "+e)}function Bd(t){throw new In(Pn.INTERNAL_ERROR,"Internal error: "+t)}/** 3144 * @license 3145 * Copyright 2017 Google LLC 3146 * 3147 * Licensed under the Apache License, Version 2.0 (the "License");
3148 * you may not use this file except in compliance with the License. 3149 * You may obtain a copy of the License at 3150 * 3151 * http://www.apache.org/licenses/LICENSE-2.0 3152 * 3153 * Unless required by applicable law or agreed to in writing, software 3154 * distributed under the License is distributed on an "AS IS" BASIS, 3155 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3156 * See the License for the specific language governing permissions and 3157 * limitations under the License. 3158 */class Ns{constructor(e,n){this.bucket=e,this.path_=n}get path(){return this.path_}get isRoot(){return this.path.length===0}fullServerUrl(){const e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o/"+e(this.path)}bucketOnlyServerUrl(){return"/b/"+encodeURIComponent(this.bucket)+"/o"}static makeFromBucketSpec(e,n){let r;try{r=Ns.makeFromUrl(e,n)}catch{return new Ns(e,"")}if(r.path==="")return r;throw y7(e)}static makeFromUrl(e,n){let r=null;const s="([A-Za-z0-9.\\-_]+)";function i(E){E.path.charAt(E.path.length-1)==="/"&&(E.path_=E.path_.slice(0,-1))}const a="(/(.*))?$",l=new RegExp("^gs://"+s+a,"i"),c={bucket:1,path:3};function d(E){E.path_=decodeURIComponent(E.path)}const h="v[A-Za-z0-9_]+",f=n.replace(/[.]/g,"\\."),p="(/([^?#]*).*)?$",g=new RegExp(`^https?://${f}/${h}/b/${s}/o${p}`,"i"),v={bucket:1,path:3},x=n===iD?"(?:storage.googleapis.com|storage.cloud.google.com)":n,y="([^?#]*)",b=new RegExp(`^https?://${x}/${s}/${y}`,"i"),j=[{regex:l,indices:c,postModify:i},{regex:g,indices:v,postModify:d},{regex:b,indices:{bucket:1,path:2},postModify:d}];for(let E=0;E<j.length;E++){const P=j[E],A=P.regex.exec(e);if(A){const N=A[P.indices.bucket];let _=A[P.indices.path];_||(_=""),r=new Ns(N,_),P.postModify(r);break}}if(r==null)throw x7(e);return r}}class _7{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}}/** 3159 * @license 3160 * Copyright 2017 Google LLC 3161 * 3162 * Licensed under the Apache License, Version 2.0 (the "License"); 3163 * you may not use this file except in compliance with the License. 3164 * You may obtain a copy of the License at 3165 * 3166 * http://www.apache.org/licenses/LICENSE-2.0 3167 * 3168 * Unless required by applicable law or agreed to in writing, software 3169 * distributed under the License is distributed on an "AS IS" BASIS, 3170 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3171 * See the License for the specific language governing permissions and 3172 * limitations under the License. 3173 */function E7(t,e,n){let r=1,s=null,i=null,a=!1,l=0;function c(){return l===2}let d=!1;function h(...y){d||(d=!0,e.apply(null,y))}function f(y){s=setTimeout(()=>{s=null,t(g,c())},y)}function p(){i&&clearTimeout(i)}function g(y,...b){if(d){p();return}if(y){p(),h.call(null,y,...b);return}if(c()||a){p(),h.call(null,y,...b);return}r<64&&(r*=2);let j;l===1?(l=2,j=0):j=(r+Math.random())*1e3,f(j)}let v=!1;function x(y){v||(v=!0,p(),!d&&(s!==null?(y||(l=2),clearTimeout(s),f(0)):y||(l=1)))}return f(0),i=setTimeout(()=>{a=!0,x(!0)},n),x}function S7(t){t(!1)}/** 3174 * @license 3175 * Copyright 2017 Google LLC 3176 * 3177 * Licensed under the Apache License, Version 2.0 (the "License"); 3178 * you may not use this file except in compliance with the License. 3179 * You may obtain a copy of the License at 3180 * 3181 * http://www.apache.org/licenses/LICENSE-2.0 3182 * 3183 * Unless required by applicable law or agreed to in writing, software 3184 * distributed under the License is distributed on an "AS IS" BASIS, 3185 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3186 * See the License for the specific language governing permissions and 3187 * limitations under the License. 3188 */function k7(t){return t!==void 0}function P7(t){return typeof t=="object"&&!Array.isArray(t)}function VC(t){return typeof t=="string"||t instanceof String}function sS(t){return UC()&&t instanceof Blob}function UC(){return typeof Blob<"u"}function oS(t,e,n,r){if(r<e)throw rb(`Invalid value for '${t}'. Expected ${e} or greater.`);if(r>n)throw rb(`Invalid value for '${t}'. Expected ${n} or less.`)}/** 3189 * @license 3190 * Copyright 2017 Google LLC 3191 * 3192 * Licensed under the Apache License, Version 2.0 (the "License");
3193 * you may not use this file except in compliance with the License. 3194 * You may obtain a copy of the License at 3195 * 3196 * http://www.apache.org/licenses/LICENSE-2.0 3197 * 3198 * Unless required by applicable law or agreed to in writing, software 3199 * distributed under the License is distributed on an "AS IS" BASIS, 3200 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3201 * See the License for the specific language governing permissions and 3202 * limitations under the License. 3203 */function cx(t,e,n){let r=e;return n==null&&(r=`https://${e}`),`${n}://${r}/v0${t}`}function cD(t){const e=encodeURIComponent;let n="?";for(const r in t)if(t.hasOwnProperty(r)){const s=e(r)+"="+e(t[r]);n=n+s+"&"}return n=n.slice(0,-1),n}var $l;(function(t){t[t.NO_ERROR=0]="NO_ERROR",t[t.NETWORK_ERROR=1]="NETWORK_ERROR",t[t.ABORT=2]="ABORT"})($l||($l={}));/** 3204 * @license 3205 * Copyright 2022 Google LLC 3206 * 3207 * Licensed under the Apache License, Version 2.0 (the "License"); 3208 * you may not use this file except in compliance with the License. 3209 * You may obtain a copy of the License at 3210 * 3211 * http://www.apache.org/licenses/LICENSE-2.0 3212 * 3213 * Unless required by applicable law or agreed to in writing, software 3214 * distributed under the License is distributed on an "AS IS" BASIS, 3215 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3216 * See the License for the specific language governing permissions and 3217 * limitations under the License. 3218 */function I7(t,e){const n=t>=500&&t<600,s=[408,429].indexOf(t)!==-1,i=e.indexOf(t)!==-1;return n||s||i}/** 3219 * @license 3220 * Copyright 2017 Google LLC 3221 * 3222 * Licensed under the Apache License, Version 2.0 (the "License"); 3223 * you may not use this file except in compliance with the License. 3224 * You may obtain a copy of the License at 3225 * 3226 * http://www.apache.org/licenses/LICENSE-2.0 3227 * 3228 * Unless required by applicable law or agreed to in writing, software 3229 * distributed under the License is distributed on an "AS IS" BASIS, 3230 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3231 * See the License for the specific language governing permissions and 3232 * limitations under the License. 3233 */class T7{constructor(e,n,r,s,i,a,l,c,d,h,f,p=!0){this.url_=e,this.method_=n,this.headers_=r,this.body_=s,this.successCodes_=i,this.additionalRetryCodes_=a,this.callback_=l,this.errorCallback_=c,this.timeout_=d,this.progressCallback_=h,this.connectionFactory_=f,this.retry=p,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((g,v)=>{this.resolve_=g,this.reject_=v,this.start_()})}start_(){const e=(r,s)=>{if(s){r(!1,new rp(!1,null,!0));return}const i=this.connectionFactory_();this.pendingConnection_=i;const a=l=>{const c=l.loaded,d=l.lengthComputable?l.total:-1;this.progressCallback_!==null&&this.progressCallback_(c,d)};this.progressCallback_!==null&&i.addUploadProgressListener(a),i.send(this.url_,this.method_,this.body_,this.headers_).then(()=>{this.progressCallback_!==null&&i.removeUploadProgressListener(a),this.pendingConnection_=null;const l=i.getErrorCode()===$l.NO_ERROR,c=i.getStatus();if(!l||I7(c,this.additionalRetryCodes_)&&this.retry){const h=i.getErrorCode()===$l.ABORT;r(!1,new rp(!1,null,h));return}const d=this.successCodes_.indexOf(c)!==-1;r(!0,new rp(d,i))})},n=(r,s)=>{const i=this.resolve_,a=this.reject_,l=s.connection;if(s.wasSuccessCode)try{const c=this.callback_(l,l.getResponse());k7(c)?i(c):i()}catch(c){a(c)}else if(l!==null){const c=$C();c.serverResponse=l.getErrorText(),this.errorCallback_?a(this.errorCallback_(l,c)):a(c)}else if(s.canceled){const c=this.appDelete_?lD():v7();a(c)}else{const c=g7();a(c)}};this.canceled_?n(!1,new rp(!1,null,!0)):this.backoffId_=E7(e,n,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,this.backoffId_!==null&&S7(this.backoffId_),this.pendingConnection_!==null&&this.pendingConnection_.abort()}}class rp{constructor(e,n,r){this.wasSuccessCode=e,this.connection=n,this.canceled=!!r}}function A7(t,e){e!==null&&e.length>0&&(t.Authorization="Firebase "+e)}function R7(t,e){t["X-Firebase-Storage-Version"]="webjs/"+(e??"AppManager")}function D7(t,e){e&&(t["X-Firebase-GMPID"]=e)}function L7(t,e){e!==null&&(t["X-Firebase-AppCheck"]=e)}
3233function M7(t,e,n,r,s,i,a=!0){const l=cD(t.urlParams),c=t.url+l,d=Object.assign({},t.headers);return D7(d,e),A7(d,n),R7(d,i),L7(d,r),new T7(c,t.method,d,t.body,t.successCodes,t.additionalRetryCodes,t.handler,t.errorHandler,t.timeout,t.progressCallback,s,a)}/** 3234 * @license 3235 * Copyright 2017 Google LLC 3236 * 3237 * Licensed under the Apache License, Version 2.0 (the "License"); 3238 * you may not use this file except in compliance with the License. 3239 * You may obtain a copy of the License at 3240 * 3241 * http://www.apache.org/licenses/LICENSE-2.0 3242 * 3243 * Unless required by applicable law or agreed to in writing, software 3244 * distributed under the License is distributed on an "AS IS" BASIS, 3245 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3246 * See the License for the specific language governing permissions and 3247 * limitations under the License. 3248 */function O7(){return typeof BlobBuilder<"u"?BlobBuilder:typeof WebKitBlobBuilder<"u"?WebKitBlobBuilder:void 0}function F7(...t){const e=O7();if(e!==void 0){const n=new e;for(let r=0;r<t.length;r++)n.append(t[r]);return n.getBlob()}else{if(UC())return new Blob(t);throw new In(Pn.UNSUPPORTED_ENVIRONMENT,"This browser doesn't seem to support creating Blobs")}}function z7(t,e,n){return t.webkitSlice?t.webkitSlice(e,n):t.mozSlice?t.mozSlice(e,n):t.slice?t.slice(e,n):null}/** 3249 * @license 3250 * Copyright 2021 Google LLC 3251 * 3252 * Licensed under the Apache License, Version 2.0 (the "License"); 3253 * you may not use this file except in compliance with the License. 3254 * You may obtain a copy of the License at 3255 * 3256 * http://www.apache.org/licenses/LICENSE-2.0 3257 * 3258 * Unless required by applicable law or agreed to in writing, software 3259 * distributed under the License is distributed on an "AS IS" BASIS, 3260 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3261 * See the License for the specific language governing permissions and 3262 * limitations under the License. 3263 */function $7(t){if(typeof atob>"u")throw C7("base-64");return atob(t)}/** 3264 * @license 3265 * Copyright 2017 Google LLC 3266 * 3267 * Licensed under the Apache License, Version 2.0 (the "License"); 3268 * you may not use this file except in compliance with the License. 3269 * You may obtain a copy of the License at 3270 * 3271 * http://www.apache.org/licenses/LICENSE-2.0 3272 * 3273 * Unless required by applicable law or agreed to in writing, software 3274 * distributed under the License is distributed on an "AS IS" BASIS, 3275 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3276 * See the License for the specific language governing permissions and 3277 * limitations under the License. 3278 */const Wo={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};class Fy{constructor(e,n){this.data=e,this.contentType=n||null}}function V7(t,e){switch(t){case Wo.RAW:return new Fy(uD(e));case Wo.BASE64:case Wo.BASE64URL:return new Fy(dD(t,e));case Wo.DATA_URL:return new Fy(B7(e),W7(e))}throw $C()}function uD(t){const e=[];for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);if(r<=127)e.push(r);else if(r<=2047)e.push(192|r>>6,128|r&63);else if((r&64512)===55296)if(!(n<t.length-1&&(t.charCodeAt(n+1)&64512)===56320))e.push(239,191,189);else{const i=r,a=t.charCodeAt(++n);r=65536|(i&1023)<<10|a&1023,e.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63)}else(r&64512)===56320?e.push(239,191,189):e.push(224|r>>12,128|r>>6&63,128|r&63)}return new Uint8Array(e)}function U7(t){let e;try{e=decodeURIComponent(t)}catch{throw Lh(Wo.DATA_URL,"Malformed data URL.")}return uD(e)}function dD(t,e){switch(t){case Wo.BASE64:{const s=e.indexOf("-")!==-1,i=e.indexOf("_")!==-1;if(s||i)throw Lh(t,"Invalid character '"+(s?"-":"_")+"' found: is it base64url encoded?");break}case Wo.BASE64URL:{const s=e.indexOf("+")!==-1,i=e.indexOf("/")!==-1;if(s||i)throw Lh(t,"Invalid character '"+(s?"+":"/")+"' found: is it base64 encoded?");e=e.replace(/-/g,"+").replace(/_/g,"/");break}}let n;try{n=$7(e)}catch(s){throw s.message.includes("polyfill")?s:Lh(t,"Invalid character found")}const r=new Uint8Array(n.length);for(let s=0;s<n.length;s++)r[s]=n.charCodeAt(s);return r}class hD{constructor(e){this.base64=!1,this.contentType=null;const n=e.match(/^data:([^,]+)?,/);if(n===null)throw Lh(Wo.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");const r=n[1]||null;r!=null&&(this.base64=H7(r,";base64"),this.contentType=this.base64?r.substring(0,r.length-7):r),this.rest=e.substring(e.indexOf(",")+1)}}function B7(t){const e=new hD(t);return e.base64?dD(Wo.BASE64,e.rest):U7(e.rest)}function W7(t){return new hD(t).contentType}function H7(t,e){return t.length>=e.length?t.substring(t.length-e.length)===e:!1}/** 3279 * @license 3280 * Copyright 2017 Google LLC 3281 * 3282 * Licensed under the Apache License, Version 2.0 (the "License");
3283 * you may not use this file except in compliance with the License. 3284 * You may obtain a copy of the License at 3285 * 3286 * http://www.apache.org/licenses/LICENSE-2.0 3287 * 3288 * Unless required by applicable law or agreed to in writing, software 3289 * distributed under the License is distributed on an "AS IS" BASIS, 3290 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3291 * See the License for the specific language governing permissions and 3292 * limitations under the License. 3293 */class pa{constructor(e,n){let r=0,s="";sS(e)?(this.data_=e,r=e.size,s=e.type):e instanceof ArrayBuffer?(n?this.data_=new Uint8Array(e):(this.data_=new Uint8Array(e.byteLength),this.data_.set(new Uint8Array(e))),r=this.data_.length):e instanceof Uint8Array&&(n?this.data_=e:(this.data_=new Uint8Array(e.length),this.data_.set(e)),r=e.length),this.size_=r,this.type_=s}size(){return this.size_}type(){return this.type_}slice(e,n){if(sS(this.data_)){const r=this.data_,s=z7(r,e,n);return s===null?null:new pa(s)}else{const r=new Uint8Array(this.data_.buffer,e,n-e);return new pa(r,!0)}}static getBlob(...e){if(UC()){const n=e.map(r=>r instanceof pa?r.data_:r);return new pa(F7.apply(null,n))}else{const n=e.map(a=>VC(a)?V7(Wo.RAW,a).data:a.data_);let r=0;n.forEach(a=>{r+=a.byteLength});const s=new Uint8Array(r);let i=0;return n.forEach(a=>{for(let l=0;l<a.length;l++)s[i++]=a[l]}),new pa(s,!0)}}uploadData(){return this.data_}}/** 3294 * @license 3295 * Copyright 2017 Google LLC 3296 * 3297 * Licensed under the Apache License, Version 2.0 (the "License"); 3298 * you may not use this file except in compliance with the License. 3299 * You may obtain a copy of the License at 3300 * 3301 * http://www.apache.org/licenses/LICENSE-2.0 3302 * 3303 * Unless required by applicable law or agreed to in writing, software 3304 * distributed under the License is distributed on an "AS IS" BASIS, 3305 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3306 * See the License for the specific language governing permissions and 3307 * limitations under the License. 3308 */function fD(t){let e;try{e=JSON.parse(t)}catch{return null}return P7(e)?e:null}/** 3309 * @license 3310 * Copyright 2017 Google LLC 3311 * 3312 * Licensed under the Apache License, Version 2.0 (the "License"); 3313 * you may not use this file except in compliance with the License. 3314 * You may obtain a copy of the License at 3315 * 3316 * http://www.apache.org/licenses/LICENSE-2.0 3317 * 3318 * Unless required by applicable law or agreed to in writing, software 3319 * distributed under the License is distributed on an "AS IS" BASIS, 3320 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3321 * See the License for the specific language governing permissions and 3322 * limitations under the License. 3323 */function q7(t){if(t.length===0)return null;const e=t.lastIndexOf("/");return e===-1?"":t.slice(0,e)}function G7(t,e){const n=e.split("/").filter(r=>r.length>0).join("/");return t.length===0?n:t+"/"+n}function mD(t){const e=t.lastIndexOf("/",t.length-2);return e===-1?t:t.slice(e+1)}/** 3324 * @license 3325 * Copyright 2017 Google LLC 3326 * 3327 * Licensed under the Apache License, Version 2.0 (the "License"); 3328 * you may not use this file except in compliance with the License. 3329 * You may obtain a copy of the License at 3330 * 3331 * http://www.apache.org/licenses/LICENSE-2.0 3332 * 3333 * Unless required by applicable law or agreed to in writing, software 3334 * distributed under the License is distributed on an "AS IS" BASIS, 3335 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3336 * See the License for the specific language governing permissions and 3337 * limitations under the License. 3338 */function Z7(t,e){return e}class Wr{constructor(e,n,r,s){this.server=e,this.local=n||e,this.writable=!!r,this.xform=s||Z7}}let sp=null;function K7(t){return!VC(t)||t.length<2?t:mD(t)}function pD(){if(sp)return sp;const t=[];t.push(new Wr("bucket")),t.push(new Wr("generation")),t.push(new Wr("metageneration")),t.push(new Wr("name","fullPath",!0));function e(i,a){return K7(a)}const n=new Wr("name");n.xform=e,t.push(n);function r(i,a){return a!==void 0?Number(a):a}const s=new Wr("size");return s.xform=r,t.push(s),t.push(new Wr("timeCreated")),t.push(new Wr("updated")),t.push(new Wr("md5Hash",null,!0)),t.push(new Wr("cacheControl",null,!0)),t.push(new Wr("contentDisposition",null,!0)),t.push(new Wr("contentEncoding",null,!0)),t.push(new Wr("contentLanguage",null,!0)),t.push(new Wr("contentType",null,!0)),t.push(new Wr("metadata","customMetadata",!0)),sp=t,sp}function Y7(t,e){function n(){const r=t.bucket,s=t.fullPath,i=new Ns(r,s);return e._makeStorageReference(i)}Object.defineProperty(t,"ref",{get:n})}function Q7(t,e,n){const r={};r.type="file";const s=n.length;for(let i=0;i<s;i++){const a=n[i];r[a.local]=a.xform(r,e[a.server])}return Y7(r,t),r}function gD(t,e,n){const r=fD(e);return r===null?null:Q7(t,r,n)}function X7(t,e,n,r){const s=fD(e);if(s===null||!VC(s.downloadTokens))return null;const i=s.downloadTokens;if(i.length===0)return null;const a=encodeURIComponent;return i.split(",").map(d=>{const h=t.bucket,f=t.fullPath,p="/b/"+a(h)+"/o/"+a(f),g=cx(p,n,r),v=cD({alt:"media",token:d});return g+v})[0]}function J7(t,e){const n={},r=e.length;for(let s=0;s<r;s++){const i=e[s];i.writable&&(n[i.server]=t[i.local])}return JSON.stringify(n)}class BC{constructor(e,n,r,s){this.url=e,this.method=n,this.handler=r,this.timeout=s,this.urlParam
vendor: 1,504 bytes, lines 3338-3353
3338s={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}}/** 3339 * @license 3340 * Copyright 2017 Google LLC 3341 * 3342 * Licensed under the Apache License, Version 2.0 (the "License"); 3343 * you may not use this file except in compliance with the License. 3344 * You may obtain a copy of the License at 3345 * 3346 * http://www.apache.org/licenses/LICENSE-2.0 3347 * 3348 * Unless required by applicable law or agreed to in writing, software 3349 * distributed under the License is distributed on an "AS IS" BASIS, 3350 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3351 * See the License for the specific language governing permissions and 3352 * limitations under the License. 3353 */function vD(t){if(!t)throw $C()}function eW(t,e){function n(r,s){const i=gD(t,s,e);return vD(i!==null),i}return n}function tW(t,e){function n(r,s){const i=gD(t,s,e);return vD(i!==null),X7(i,s,t.host,t._protocol)}return n}function xD(t){function e(n,r){let s;return n.getStatus()===401?n.getErrorText().includes("Firebase App Check token is invalid")?s=m7():s=f7():n.getStatus()===402?s=h7(t.bucket):n.getStatus()===403?s=p7(t.path):s=r,s.status=n.getStatus(),s.serverResponse=r.serverResponse,s}return e}function yD(t){const e=xD(t);function n(r,s){let i=e(r,s);return r.getStatus()===404&&(i=d7(t.path)),i.serverResponse=s.serverResponse,i}return n}function nW(t,e,n){const r=e.fullServerUrl(),s=cx(r,t.host,t._protocol),i="GET",a=t.maxOperationRetryTime,l=ne
3353w BC(s,i,tW(t,n),a);return l.errorHandler=yD(e),l}function rW(t,e){const n=e.fullServerUrl(),r=cx(n,t.host,t._protocol),s="DELETE",i=t.maxOperationRetryTime;function a(c,d){}const l=new BC(r,s,a,i);return l.successCodes=[200,204],l.errorHandler=yD(e),l}function sW(t,e){return t&&t.contentType||e&&e.type()||"application/octet-stream"}function oW(t,e,n){const r=Object.assign({},n);return r.fullPath=t.path,r.size=e.size(),r.contentType||(r.contentType=sW(null,e)),r}function iW(t,e,n,r,s){const i=e.bucketOnlyServerUrl(),a={"X-Goog-Upload-Protocol":"multipart"};function l(){let j="";for(let E=0;E<2;E++)j=j+Math.random().toString().slice(2);return j}const c=l();a["Content-Type"]="multipart/related; boundary="+c;const d=oW(e,r,s),h=J7(d,n),f="--"+c+`\r 3354Content-Type: application/json; charset=utf-8\r 3355\r 3356`+h+`\r 3357--`+c+`\r 3358Content-Type: `+d.contentType+`\r 3359\r 3360`,p=`\r 3361--`+c+"--",g=pa.getBlob(f,r,p);if(g===null)throw b7();const v={name:d.fullPath},x=cx(i,t.host,t._protocol),y="POST",b=t.maxUploadRetryTime,w=new BC(x,y,eW(t,n),b);return w.urlParams=v,w.headers=a,w.body=g.uploadData(),w.errorHandler=xD(e),w}class aW{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=$l.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener("abort",()=>{this.errorCode_=$l.ABORT,e()}),this.xhr_.addEventListener("error",()=>{this.errorCode_=$l.NETWORK_ERROR,e()}),this.xhr_.addEventListener("load",()=>{e()})})}send(e,n,r,s){if(this.sent_)throw Bd("cannot .send() more than once");if(this.sent_=!0,this.xhr_.open(n,e,!0),s!==void 0)for(const i in s)s.hasOwnProperty(i)&&this.xhr_.setRequestHeader(i,s[i].toString());return r!==void 0?this.xhr_.send(r):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(!this.sent_)throw Bd("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw Bd("cannot .getStatus() before sending");try{return this.xhr_.status}catch{return-1}}getResponse(){if(!this.sent_)throw Bd("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw Bd("cannot .getErrorText() before sending");return this.xhr_.statusText}abort(){this.xhr_.abort()}getResponseHeader(e){return this.xhr_.getResponseHeader(e)}addUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.addEventListener("progress",e)}removeUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.removeEventListener("progress",e)}}class lW extends aW{initXhr(){this.xhr_.responseType="text"}}function WC(){return new lW}/** 3362 * @license 3363 * Copyright 2019 Google LLC 3364 * 3365 * Licensed under the Apache License, Version 2.0 (the "License"); 3366 * you may not use this file except in compliance with the License. 3367 * You may obtain a copy of the License at 3368 * 3369 * http://www.apache.org/licenses/LICENSE-2.0 3370 * 3371 * Unless required by applicable law or agreed to in writing, software 3372 * distributed under the License is distributed on an "AS IS" BASIS, 3373 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3374 * See the License for the specific language governing permissions and 3375 * limitations under the License. 3376 */class Jl{constructor(e,n){this._service=e,n instanceof Ns?this._location=n:this._location=Ns.makeFromUrl(n,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,n){return new Jl(e,n)}get root(){const e=new Ns(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return mD(this._location.path)}get storage(){return this._service}get parent(){const e=q7(this._location.path);if(e===null)return null;const n=new Ns(this._location.bucket,e);return new Jl(this._service,n)}_throwIfRoot(e){if(this._location.path==="")throw N7(e)}}function cW(t,e,n){t._throwIfRoot("uploadBytes");const r=iW(t.storage,t._location,pD(),new pa(e,!0),n);return t.storage.makeRequestWithTokens(r,WC).then(s=>({metadata:s,ref:t}))}function uW(t){t._throwIfRoot("getDownloadURL");const e=nW(t.storage,t._location,pD());return t.storage.makeRequestWithTokens(e,WC).then(n=>{if(n===null)throw j7();return n})}function dW(t){t._throwIfRoot("deleteObject");const e=rW(t.storage,t._location);return t.storage.makeRequestWithTokens(e,WC)}function hW(t,e){const n=G7(t._location.path,e),r=new Ns(t._location.bucket,n);return new Jl(t.storage,r)}/** 3377 * @license 3378 * Copyright 2017 Google LLC 3379 * 3380 * Licensed under the Apache License, Version 2.0 (the "License");
3381 * you may not use this file except in compliance with the License. 3382 * You may obtain a copy of the License at 3383 * 3384 * http://www.apache.org/licenses/LICENSE-2.0 3385 * 3386 * Unless required by applicable law or agreed to in writing, software 3387 * distributed under the License is distributed on an "AS IS" BASIS, 3388 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3389 * See the License for the specific language governing permissions and 3390 * limitations under the License. 3391 */function fW(t){return/^[A-Za-z]+:\/\//.test(t)}function mW(t,e){return new Jl(t,e)}function wD(t,e){if(t instanceof HC){const n=t;if(n._bucket==null)throw w7();const r=new Jl(n,n._bucket);return e!=null?wD(r,e):r}else return e!==void 0?hW(t,e):t}function pW(t,e){if(e&&fW(e)){if(t instanceof HC)return mW(t,e);throw rb("To use ref(service, url), the first argument must be a Storage instance.")}else return wD(t,e)}function iS(t,e){const n=e==null?void 0:e[aD];return n==null?null:Ns.makeFromBucketSpec(n,t)}function gW(t,e,n,r={}){t.host=`${e}:${n}`,t._protocol="http";const{mockUserToken:s}=r;s&&(t._overrideAuthToken=typeof s=="string"?s:JT(s,t.app.options.projectId))}class HC{constructor(e,n,r,s,i){this.app=e,this._authProvider=n,this._appCheckProvider=r,this._url=s,this._firebaseVersion=i,this._bucket=null,this._host=iD,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=c7,this._maxUploadRetryTime=u7,this._requests=new Set,s!=null?this._bucket=Ns.makeFromBucketSpec(s,this._host):this._bucket=iS(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,this._url!=null?this._bucket=Ns.makeFromBucketSpec(this._url,e):this._bucket=iS(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){oS("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){oS("time",0,Number.POSITIVE_INFINITY,e),this._maxOperationRetryTime=e}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;const e=this._authProvider.getImmediate({optional:!0});if(e){const n=await e.getToken();if(n!==null)return n.accessToken}return null}async _getAppCheckToken(){const e=this._appCheckProvider.getImmediate({optional:!0});return e?(await e.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach(e=>e.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new Jl(this,e)}_makeRequest(e,n,r,s,i=!0){if(this._deleted)return new _7(lD());{const a=M7(e,this._appId,r,s,n,this._firebaseVersion,i);return this._requests.add(a),a.getPromise().then(()=>this._requests.delete(a),()=>this._requests.delete(a)),a}}async makeRequestWithTokens(e,n){const[r,s]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,n,r,s).getPromise()}}const aS="@firebase/storage",lS="0.13.2";/** 3392 * @license 3393 * Copyright 2020 Google LLC 3394 * 3395 * Licensed under the Apache License, Version 2.0 (the "License"); 3396 * you may not use this file except in compliance with the License. 3397 * You may obtain a copy of the License at 3398 * 3399 * http://www.apache.org/licenses/LICENSE-2.0 3400 * 3401 * Unless required by applicable law or agreed to in writing, software 3402 * distributed under the License is distributed on an "AS IS" BASIS, 3403 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3404 * See the License for the specific language governing permissions and 3405 * limitations under the License. 3406 */const bD="storage";function sb(t,e,n){return t=tn(t),cW(t,e,n)}function xf(t){return t=tn(t),uW(t)}function vW(t){return t=tn(t),dW(t)}function Wa(t,e){return t=tn(t),pW(t,e)}function xW(t=Fv(),e){t=tn(t);const r=$f(t,bD).getImmediate({identifier:e}),s=Wj("storage");return s&&yW(r,...s),r}function yW(t,e,n,r={}){gW(t,e,n,r)}function wW(t,{instanceIdentifier:e}){const n=t.getProvider("app").getImmediate(),r=t.getProvider("auth-internal"),s=t.getProvider("app-check-internal");return new HC(n,r,s,e,fc)}function bW(){za(new Ai(bD,wW,"PUBLIC").setMultipleInstances(!0)),Vs(aS,lS,""),Vs(aS,lS,"esm2017")}bW();/** 3407 * @license 3408 * Copyright 2017 Google LLC 3409 * 3410 * Licensed under the Apache License, Version 2.0 (the "License");
3411 * you may not use this file except in compliance with the License. 3412 * You may obtain a copy of the License at 3413 * 3414 * http://www.apache.org/licenses/LICENSE-2.0 3415 * 3416 * Unless required by applicable law or agreed to in writing, software 3417 * distributed under the License is distributed on an "AS IS" BASIS, 3418 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3419 * See the License for the specific language governing permissions and 3420 * limitations under the License. 3421 */const jW="type.googleapis.com/google.protobuf.Int64Value",CW="type.googleapis.com/google.protobuf.UInt64Value";function jD(t,e){const n={};for(const r in t)t.hasOwnProperty(r)&&(n[r]=e(t[r]));return n}function ob(t){if(t==null)return null;if(t instanceof Number&&(t=t.valueOf()),typeof t=="number"&&isFinite(t)||t===!0||t===!1||Object.prototype.toString.call(t)==="[object String]")return t;if(t instanceof Date)return t.toISOString();if(Array.isArray(t))return t.map(e=>ob(e));if(typeof t=="function"||typeof t=="object")return jD(t,e=>ob(e));throw new Error("Data cannot be encoded in JSON: "+t)}function Hg(t){if(t==null)return t;if(t["@type"])switch(t["@type"]){case jW:case CW:{const e=Number(t.value);if(isNaN(e))throw new Error("Data cannot be decoded from JSON: "+t);return e}default:throw new Error("Data cannot be decoded from JSON: "+t)}return Array.isArray(t)?t.map(e=>Hg(e)):typeof t=="function"||typeof t=="object"?jD(t,e=>Hg(e)):t}/** 3422 * @license 3423 * Copyright 2020 Google LLC 3424 * 3425 * Licensed under the Apache License, Version 2.0 (the "License"); 3426 * you may not use this file except in compliance with the License. 3427 * You may obtain a copy of the License at 3428 * 3429 * http://www.apache.org/licenses/LICENSE-2.0 3430 * 3431 * Unless required by applicable law or agreed to in writing, software 3432 * distributed under the License is distributed on an "AS IS" BASIS, 3433 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3434 * See the License for the specific language governing permissions and 3435 * limitations under the License. 3436 */const qC="functions";/** 3437 * @license 3438 * Copyright 2017 Google LLC 3439 * 3440 * Licensed under the Apache License, Version 2.0 (the "License"); 3441 * you may not use this file except in compliance with the License. 3442 * You may obtain a copy of the License at 3443 * 3444 * http://www.apache.org/licenses/LICENSE-2.0 3445 * 3446 * Unless required by applicable law or agreed to in writing, software 3447 * distributed under the License is distributed on an "AS IS" BASIS, 3448 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3449 * See the License for the specific language governing permissions and 3450 * limitations under the License. 3451 */const cS={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class wu extends Po{constructor(e,n,r){super(`${qC}/${e}`,n||""),this.details=r}}function NW(t){if(t>=200&&t<300)return"ok";switch(t){case 0:return"internal";case 400:return"invalid-argument";case 401:return"unauthenticated";case 403:return"permission-denied";case 404:return"not-found";case 409:return"aborted";case 429:return"resource-exhausted";case 499:return"cancelled";case 500:return"internal";case 501:return"unimplemented";case 503:return"unavailable";case 504:return"deadline-exceeded"}return"unknown"}function _W(t,e){let n=NW(t),r=n,s;try{const i=e&&e.error;if(i){const a=i.status;if(typeof a=="string"){if(!cS[a])return new wu("internal","internal");n=cS[a],r=a}const l=i.message;typeof l=="string"&&(r=l),s=i.details,s!==void 0&&(s=Hg(s))}}catch{}return n==="ok"?null:new wu(n,r,s)}/** 3452 * @license 3453 * Copyright 2017 Google LLC 3454 * 3455 * Licensed under the Apache License, Version 2.0 (the "License"); 3456 * you may not use this file except in compliance with the License. 3457 * You may obtain a copy of the License at 3458 * 3459 * http://www.apache.org/licenses/LICENSE-2.0 3460 * 3461 * Unless required by applicable law or agreed to in writing, softw
3461are 3462 * distributed under the License is distributed on an "AS IS" BASIS, 3463 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3464 * See the License for the specific language governing permissions and 3465 * limitations under the License. 3466 */class EW{constructor(e,n,r){this.auth=null,this.messaging=null,this.appCheck=null,this.auth=e.getImmediate({optional:!0}),this.messaging=n.getImmediate({optional:!0}),this.auth||e.get().then(s=>this.auth=s,()=>{}),this.messaging||n.get().then(s=>this.messaging=s,()=>{}),this.appCheck||r.get().then(s=>this.appCheck=s,()=>{})}async getAuthToken(){if(this.auth)try{const e=await this.auth.getToken();return e==null?void 0:e.accessToken}catch{return}}async getMessagingToken(){if(!(!this.messaging||!("Notification"in self)||Notification.permission!=="granted"))try{return await this.messaging.getToken()}catch{return}}async getAppCheckToken(e){if(this.appCheck){const n=e?await this.appCheck.getLimitedUseToken():await this.appCheck.getToken();return n.error?null:n.token}return null}async getContext(e){const n=await this.getAuthToken(),r=await this.getMessagingToken(),s=await this.getAppCheckToken(e);return{authToken:n,messagingToken:r,appCheckToken:s}}}/** 3467 * @license 3468 * Copyright 2017 Google LLC 3469 * 3470 * Licensed under the Apache License, Version 2.0 (the "License"); 3471 * you may not use this file except in compliance with the License. 3472 * You may obtain a copy of the License at 3473 * 3474 * http://www.apache.org/licenses/LICENSE-2.0 3475 * 3476 * Unless required by applicable law or agreed to in writing, software 3477 * distributed under the License is distributed on an "AS IS" BASIS, 3478 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3479 * See the License for the specific language governing permissions and 3480 * limitations under the License. 3481 */const ib="us-central1";function SW(t){let e=null;return{promise:new Promise((n,r)=>{e=setTimeout(()=>{r(new wu("deadline-exceeded","deadline-exceeded"))},t)}),cancel:()=>{e&&clearTimeout(e)}}}class kW{constructor(e,n,r,s,i=ib,a){this.app=e,this.fetchImpl=a,this.emulatorOrigin=null,this.contextProvider=new EW(n,r,s),this.cancelAllRequests=new Promise(l=>{this.deleteService=()=>Promise.resolve(l())});try{const l=new URL(i);this.customDomain=l.origin+(l.pathname==="/"?"":l.pathname),this.region=ib}catch{this.customDomain=null,this.region=i}}_delete(){return this.deleteService()}_url(e){const n=this.app.options.projectId;return this.emulatorOrigin!==null?`${this.emulatorOrigin}/${n}/${this.region}/${e}`:this.customDomain!==null?`${this.customDomain}/${e}`:`https://${this.region}-${n}.cloudfunctions.net/${e}`}}function PW(t,e,n){t.emulatorOrigin=`http://${e}:${n}`}function IW(t,e,n){return r=>AW(t,e,r,{})}async function TW(t,e,n,r){n["Content-Type"]="application/json";let s;try{s=await r(t,{method:"POST",body:JSON.stringify(e),headers:n})}catch{return{status:0,json:null}}let i=null;try{i=await s.json()}catch{}return{status:s.status,json:i}}function AW(t,e,n,r){const s=t._url(e);return RW(t,s,n,r)}async function RW(t,e,n,r){n=ob(n);const s={data:n},i={},a=await t.contextProvider.getContext(r.limitedUseAppCheckTokens);a.authToken&&(i.Authorization="Bearer "+a.authToken),a.messagingToken&&(i["Firebase-Instance-ID-Token"]=a.messagingToken),a.appCheckToken!==null&&(i["X-Firebase-AppCheck"]=a.appCheckToken);const l=r.timeout||7e4,c=SW(l),d=await Promise.race([TW(e,s,i,t.fetchImpl),c.promise,t.cancelAllRequests]);if(c.cancel(),!d)throw new wu("cancelled","Firebase Functions instance was deleted.");const h=_W(d.status,d.json);if(h)throw h;if(!d.json)throw new wu("internal","Response is not valid JSON object.");let f=d.json.data;if(typeof f>"u"&&(f=d.json.result),typeof f>"u")throw new wu("internal","Response is missing data field.");return{data:Hg(f)}}const uS="@firebase/functions",dS="0.11.8";/** 3482 * @license 3483 * Copyright 2019 Google LLC 3484 * 3485 * Licensed under the Apache License, Version 2.0 (the "License"); 3486 * you may not use this file except in compliance with the License. 3487 * You may obtain a copy of the License at 3488 * 3489 * http://www.apache.org/licenses/LICENSE-2.0 3490 * 3491 * Unless required by applicable law or agreed to in writing, softw
3491are 3492 * distributed under the License is distributed on an "AS IS" BASIS, 3493 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3494 * See the License for the specific language governing permissions and 3495 * limitations under the License. 3496 */const DW="auth-internal",LW="app-check-internal",MW="messaging-internal";function OW(t,e){const n=(r,{instanceIdentifier:s})=>{const i=r.getProvider("app").getImmediate(),a=r.getProvider(DW),l=r.getProvider(MW),c=r.getProvider(LW);return new kW(i,a,l,c,s,t)};za(new Ai(qC,n,"PUBLIC").setMultipleInstances(!0)),Vs(uS,dS,e),Vs(uS,dS,"esm2017")}/** 3497 * @license 3498 * Copyright 2020 Google LLC 3499 * 3500 * Licensed under the Apache License, Version 2.0 (the "License"); 3501 * you may not use this file except in compliance with the License. 3502 * You may obtain a copy of the License at 3503 * 3504 * http://www.apache.org/licenses/LICENSE-2.0 3505 * 3506 * Unless required by applicable law or agreed to in writing, software 3507 * distributed under the License is distributed on an "AS IS" BASIS, 3508 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3509 * See the License for the specific language governing permissions and 3510 * limitations under the License. 3511 */function FW(t=Fv(),e=ib){const r=$f(tn(t),qC).getImmediate({identifier:e}),s=Wj("functions");return s&&zW(r,...s),r}function zW(t,e,n){PW(tn(t),e,n)}function pe(t,e,n){return IW(tn(t),e)}OW(fetch.bind(self));const $W={apiKey:"AIzaSyCngn4iLKQke25shPCJsZpA5p4pyzapYTU",authDomain:"foretpourtous-ad778.firebaseapp.com",projectId:"foretpourtous-ad778",storageBucket:"foretpourtous-ad778.appspot.com",messagingSenderId:"561016943670",appId:"1:561016943670:web:6c4ab344299a7222ed1497"},ux=nA($W),Sl=a8(ux),Xe=Z9(ux),Ha=xW(ux),ge=FW(ux,"europe-west3"),CD={user:["view_map"],hunter:["view_map","view_company_zones"],farmer:["view_map","manage_own_plots","create_damage_reports","create_burrow_reports","view_own_data"],louvetier:["view_map","view_assigned_zones","view_zone_plots","view_zone_damages","view_zone_burrows","edit_shuttle_form_louvetier"],trapper:["view_map","view_trapper_assigned_zones"],federation:["view_map","manage_department_zones","assign_companies_to_zones","assign_trappers_to_zones","view_department_plots","view_department_damages","view_department_burrows","view_department_companies","download_shuttle_form","edit_shuttle_form_federation"],ddt:["view_map","manage_department_zones","assign_louvetiers_to_zones","view_department_plots","view_department_damages","view_department_burrows","download_shuttle_form"],chambre_agriculture:["view_map","view_department_farmers","manage_department_farmers","view_department_plots","view_department_damages","view_department_burrows"],asso_piegeurs:["view_map","manage_department_zones","assign_trappers_to_zones","manage_department_trappers"]},bu={user:"Utilisateur",hunter:"Chasseur",farmer:"Agriculteur",louvetier:"Louvetier",trapper:"Piégeur",federation:"Fédération de chasse",ddt:"DDT",chambre_agriculture:"Chambre d'agriculture",asso_piegeurs:"Association de piégeurs"},zy={user:"Accès de base à la carte",hunter:"Membre d'une société de chasse",farmer:"Peut gérer ses zones de culture et signaler des dégâts/terriers",louvetier:"Intervient sur les dégâts de son département",trapper:"Intervient sur les nuisibles de ses zones assignées",federation:"Gère les zones et assigne les sociétés de chasse et piégeurs",ddt:"Gère les zones et assigne les louvetiers",chambre_agriculture:"Gère les agriculteurs du département",asso_piegeurs:"Gère les piégeurs et les assigne aux zones du département"},ab={manage_users:"Gérer les utilisateurs",manage_all_zones:"Gérer toutes les zones",manage_departments:"Gérer les départements",manage_sponsors:"Gérer les sponsors",manage_companies:"Gérer les sociétés de chasse",manage_department_zones:"Gérer les zones du département",assign_companies_to_zones:"Assigner des sociétés aux zones",assign_louvetiers_to_zones:"Assigner des louvetiers aux zones",assign_trappers_to_zones:"Assigner des piégeurs aux zones",view_department_plots:"Voir les zones de culture du département",view_department_damages:"Voir les dégâts du département",view_department_burrows:"Voir les terriers du département",view_department_companies:"Voir les sociétés du département",download_shuttle_form:"Télécharger les fiches navettes",edit_shuttle_form_federation:"Remplir section fédération (fiche navette)",manage_department_farmers:"Gérer les agriculteurs du département",view_department_farmers:"Voir les agriculteurs du département",manage_department_trappers:"Gérer les piégeurs du département",view_assigned_zones:"Voir ses zones assignées",view_zone_plots:"Voir les zones de culture de sa zone",view_zone_damages:"Voir les dégâts de sa zone",view_zone_burrows:"Voir les terriers de sa zone",edit_shuttle_form_louvetier:"Remplir section louvetier (fiche navette)",view_trapper_assigned_zones:"Voir ses zones assignées (piégeur)",manage_own_plots:"Gérer ses zones de culture",create_damage_reports:"Signaler des dégâts",create_burrow_reports:"Signaler des terriers",view_own_data:"Voir ses propres données",view_company_zones:"Voir les zones de sa société",edit_shuttle_form_company:"Remplir section société (fiche navette)",view_map:"Voir la carte"},VW=["chambre_agriculture","asso_piegeurs","federation","ddt"],UW=["farmer","louvetier","trapper"],qa={huntingReserve:"Réserve de chasse",noShootingZone:"Zone de non tir",wetlands:"Zone humide",federationZone:"Info Fédération de chasse",huntingTerritory:"Territoire de chasse",protectedArea:"Zone protégée",publicForest:"Forêts publiques",other:"Autre"},Wu={huntingReserve:"#FFFF8D",noShootingZone:"#FFD600",wetlands:"#B2EBF2",federationZone:"#CE93D8",huntingTerritory:"#BCAAA4",protectedArea:"#C5E1A5",publicForest:"#097138",other:"#795548"},BW={draft:"Brouillon",scheduled:"Programmée",inProgress:"En cours",done:"Terminée",cancelled:"Annulée"},WW={corn:"Maïs",wheat:"Blé",barley:"Orge",sunflower:"Tournesol",rapeseed:"Colza",soybean:"Soja",beet:"Betterave",potato:"Pomme de terre",other:"Autre"},yf={pending:"En attente",inProgress:"En cours",resolved:"Résolu",closedWithoutAction:"Classé sans suite"}
3511,Nl={pending:"orange",inProgress:"blue",resolved:"green",closedWithoutAction:"gray"},Hu={boar:"Sanglier",deer:"Cerf",roeDeer:"Chevreuil",other:"Autre"},dx={activeSpotted:"Repéré actif",monitoring:"Sous surveillance",inactive:"Inactif"},mh={activeSpotted:"red",monitoring:"orange",inactive:"gray"},qu={boar:"Sanglier",cervid:"Cervidé",roeDeer:"Chevreuil",redFox:"Renard Roux",badger:"Blaireau",raccoon:"Raton Laveur",raccoonDog:"Chien viverrin",americanMink:"Vison d'Amérique",coypu:"Ragondin",muskrat:"Rat Musqué",stoneMartin:"Fouine",pineMarten:"Martre des Pins",weasel:"Belette",wildRabbit:"Lapin de Garenne",rook:"Corbeau Freux",carrionCrow:"Corneille Noire",starling:"Ãtourneau",eurasianJay:"Geai des Chênes",magpie:"Pie Bavarde",woodPigeon:"Pigeon Ramier",other:"Autre",fox:"Renard"},GC={1:"hunter",2:"walker",3:"cyclist",4:"horseman",5:"rider"},ZC={hunter:"Chasseur",walker:"Piéton",cyclist:"Cycliste",horseman:"Cavalier",rider:"Motard",none:"Aucune"},ND=["Parking","Mirador","Agrainoir","Poste au sol","Goudron","Point de vigilance","Point d'eau","Aménagement","Maison","Piège","Chaise","Autre"],uo={Parking:"/pins/poi/parking.png",Mirador:"/pins/poi/mirador.png",Agrainoir:"/pins/poi/agrainoir.png","Poste au sol":"/pins/poi/postesol.png",Goudron:"/pins/poi/goudron.png","Point de vigilance":"/pins/poi/vigilance.png","Point d'eau":"/pins/poi/pointdeau.png",Aménagement:"/pins/poi/amenagement.png",Maison:"/pins/poi/home.png",Piège:"/pins/poi/trap.png",Chaise:"/pins/poi/chaise.png",Autre:"/pins/poi/autre.png"},Vl={walker:"Marcheur",cyclist:"Cycliste",horseman:"Cavalier",rider:"Moto",hunter:"Chasseur",farmer:"Agriculteur",public:"Chemins publics",federation:"Fédération de chasse",none:"Autre"},fo={walker:"#01579B",cyclist:"#880E4F",horseman:"#673AB7",rider:"#4E342E",hunter:"#097138",farmer:"#33691E",public:"#097138",federation:"#CE93D8",none:"#5086D3"};let $y=null;async function As(){if($y)return $y;try{const e=await(await fetch("/departements.json")).json();return $y=e,e}catch(t){return console.error("Error loading departments:",t),[]}}function ec(t){const e=String(t).padStart(5,"0");return e.startsWith("20")?"20":e.startsWith("97")||e.startsWith("98")?e.substring(0,3):e.substring(0,2)}function qg(t,e){if(t==null)return"";const n=String(t).padStart(2,"0"),r=e.find(s=>s.code===n);return r?`${r.code} - ${r.nom}`:`Département ${t}`}function _D(t){var r,s;const e=new Set;if(t.isSuperAdmin)return new Set(Object.keys(ab));(r=t.roles)==null||r.forEach(i=>{const a=CD[i];a==null||a.forEach(l=>e.add(l))});const n=t.company&&((s=t.companyRoles)==null?void 0:s[t.company]);return n&&HW(e,n),e}function HW(t,e){t.add("view_company_zones"),(e==="writer"||e==="admin")&&t.add("edit_shuttle_form_company")}function Yn(t,e){return t.isSuperAdmin?!0:_D(t).has(e)}function qW(t,e){if(t.isSuperAdmin)return!0;const n=_D(t);return e.some(r=>n.has(r))}function Bs(t,e){var n;return t.isSuperAdmin?!0:((n=t.roles)==null?void 0:n.includes(e))??!1}function GW(t,e){return t.isSuperAdmin?!0:e.some(n=>{var r;return(r=t.roles)==null?void 0:r.includes(n)})}function ZW(t){return t.isSuperAdmin||GW(t,["federation","ddt","asso_piegeurs"])}function KW(t){return t.isSuperAdmin}function YW(t){return t.isSuperAdmin||Bs(t,"chambre_agriculture")}function QW(t){return t.isSuperAdmin||Bs(t,"federation")}function ED(t){return Object.values(t.companyRoles??{}).some(e=>e==="writer"||e==="admin")}function XW(t){return t.isSuperAdmin||Bs(t,"federation")||ED(t)}function JW(t){return t.isSuperAdmin||Bs(t,"federation")}function KC(t){var n;return t.company&&((n=t.companyRoles)!=null&&n[t.company])?t.company:(t.companyRoles?Object.keys(t.companyRoles):[])[0]}function eH(t){var r;const e=KC(t);if(!e)return!1;const n=(r=t.companyRoles)==null?void 0:r[e];return n==="writer"||n==="admin"}function tH(t){var n;const e=KC(t);return e?((n=t.companyRoles)==null?void 0:n[e])==="admin":!1}function nH(t){return t.isSuperAdmin?!0:qW(t,["view_map","view_department_plots","view_zone_plots","view_department_damages","view_zone_damages","view_department_burrows","view_zone_burrows","view_own_data"])}function rH(t,e){if(!e||!Bs(t,"federation"))return!1;const n=e.departmentCode??(e.zipCode?Number(ec(e.zipCode)):null);return!!n&&n===Number(t.departmentCode)}
3511async function hS(t){try{const e=await ms(Ht(Xe,"users",t.uid));if(!e.exists())return{id:t.uid,email:t.email||"",pseudo:t.displayName||t.email||"",roles:["user"],isSuperAdmin:!1,departmentCode:0,departmentLabel:"",createdAt:new Date};const n=e.data();return{id:t.uid,email:t.email||"",pseudo:n.pseudo||t.displayName||t.email||"",firstName:n.firstName,lastName:n.lastName,phoneNumber:n.phoneNumber,roles:n.roles||["user"],isSuperAdmin:n.isSuperAdmin||!1,departmentCode:n.departmentCode||0,departmentLabel:n.departmentLabel||"",company:n.company,companyRoles:n.companyRoles,assignedZoneIds:n.assignedZoneIds||[],createdAt:n.createdAt||new Date,updatedAt:n.updatedAt}}catch(e){return console.error("Error fetching user data:",e),null}}const SD=u.createContext(void 0);function sH({children:t}){const[e,n]=u.useState(null),[r,s]=u.useState(null),[i,a]=u.useState(!0);u.useEffect(()=>KV(Sl,async p=>{s(p),n(p?await hS(p):null),a(!1)}),[]);const l=async(f,p)=>{await PA(Sl,f,p)},c=async()=>{await YV(Sl)},d=async()=>{Sl.currentUser&&n(await hS(Sl.currentUser))},h={user:e,firebaseUser:r,loading:i,isSuperAdmin:(e==null?void 0:e.isSuperAdmin)??!1,canManageUsers:e?KW(e):!1,canManageFarmers:e?YW(e):!1,canManageZones:e?ZW(e):!1,canCreateZones:e?XW(e):!1,canViewCompanies:e?QW(e):!1,isCompanyEditor:e?eH(e):!1,isCompanyAdmin:e?tH(e):!1,login:l,logout:c,refreshUser:d};return o.jsx(SD.Provider,{value:h,children:t})}function nn(){const t=u.useContext(SD);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}var oH=t=>{switch(t){case"success":return lH;case"info":return uH;case"warning":return cH;case"error":return dH;default:return null}},iH=Array(12).fill(0),aH=({visible:t,className:e})=>Ce.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},Ce.createElement("div",{className:"sonner-spinner"},iH.map((n,r)=>Ce.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),lH=Ce.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Ce.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"})),cH=Ce.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},Ce.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"})),uH=Ce.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Ce.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"})),dH=Ce.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Ce.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"})),hH=Ce.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"},Ce.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Ce.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),fH=()=>{let[t,e]=Ce.useState(document.hidden);return Ce.useEffect(()=>{let n=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),t},lb=1,mH=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let e=this.subscribers.indexOf(t);this.subscribers.splice(e,1)}),this.publish=t=>
3511{this.subscribers.forEach(e=>e(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var e;let{message:n,...r}=t,s=typeof(t==null?void 0:t.id)=="number"||((e=t.id)==null?void 0:e.length)>0?t.id:lb++,i=this.toasts.find(l=>l.id===s),a=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(s)&&this.dismissedToasts.delete(s),i?this.toasts=this.toasts.map(l=>l.id===s?(this.publish({...l,...t,id:s,title:n}),{...l,...t,id:s,dismissible:a,title:n}):l):this.addToast({title:n,...r,dismissible:a,id:s}),s},this.dismiss=t=>(this.dismissedToasts.add(t),t||this.toasts.forEach(e=>{this.subscribers.forEach(n=>n({id:e.id,dismiss:!0}))}),this.subscribers.forEach(e=>e({id:t,dismiss:!0})),t),this.message=(t,e)=>this.create({...e,message:t}),this.error=(t,e)=>this.create({...e,message:t,type:"error"}),this.success=(t,e)=>this.create({...e,type:"success",message:t}),this.info=(t,e)=>this.create({...e,type:"info",message:t}),this.warning=(t,e)=>this.create({...e,type:"warning",message:t}),this.loading=(t,e)=>this.create({...e,type:"loading",message:t}),this.promise=(t,e)=>{if(!e)return;let n;e.loading!==void 0&&(n=this.create({...e,promise:t,type:"loading",message:e.loading,description:typeof e.description!="function"?e.description:void 0}));let r=t instanceof Promise?t:t(),s=n!==void 0,i,a=r.then(async c=>{if(i=["resolve",c],Ce.isValidElement(c))s=!1,this.create({id:n,type:"default",message:c});else if(gH(c)&&!c.ok){s=!1;let d=typeof e.error=="function"?await e.error(`HTTP error! status: ${c.status}`):e.error,h=typeof e.description=="function"?await e.description(`HTTP error! status: ${c.status}`):e.description;this.create({id:n,type:"error",message:d,description:h})}else if(e.success!==void 0){s=!1;let d=typeof e.success=="function"?await e.success(c):e.success,h=typeof e.description=="function"?await e.description(c):e.description;this.create({id:n,type:"success",message:d,description:h})}}).catch(async c=>{if(i=["reject",c],e.error!==void 0){s=!1;let d=typeof e.error=="function"?await e.error(c):e.error,h=typeof e.description=="function"?await e.description(c):e.description;this.create({id:n,type:"error",message:d,description:h})}}).finally(()=>{var c;s&&(this.dismiss(n),n=void 0),(c=e.finally)==null||c.call(e)}),l=()=>new Promise((c,d)=>a.then(()=>i[0]==="reject"?d(i[1]):c(i[1])).catch(d));return typeof n!="string"&&typeof n!="number"?{unwrap:l}:Object.assign(n,{unwrap:l})},this.custom=(t,e)=>{let n=(e==null?void 0:e.id)||lb++;return this.create({jsx:t(n),id:n,...e}),n},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},ts=new mH,pH=(t,e)=>{let n=(e==null?void 0:e.id)||lb++;return ts.addToast({title:t,...e,id:n}),n},gH=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",vH=pH,xH=()=>ts.toasts,yH=()=>ts.getActiveToasts(),op=Object.assign(vH,{success:ts.success,info:ts.info,warning:ts.warning,error:ts.error,custom:ts.custom,message:ts.message,promise:ts.promise,dismiss:ts.dismiss,loading:ts.loading},{getHistory:xH,getToasts:yH});function wH(t,{insertAt:e}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",e==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=t:r.appendChild(document.createTextNode(t))}wH(`: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;
3511left: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}
3511: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%);
3511--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%)} 3512`);function ip(t){return t.label!==void 0}var bH=3,jH="32px",CH="16px",fS=4e3,NH=356,_H=14,EH=20,SH=200;function oo(...t){return t.filter(Boolean).join(" ")}function kH(t){let[e,n]=t.split("-"),r=[];return e&&r.push(e),n&&r.push(n),r}var PH=t=>{var e,n,r,s,i,a,l,c,d,h,f;let{invert:p,toast:g,unstyled:v,interacting:x,setHeights:y,visibleToasts:b,heights:w,index:j,toasts:E,expanded:P,removeToast:A,defaultRichColors:N,closeButton:_,style:k,cancelButtonStyle:L,actionButtonStyle:I,className:S="",descriptionClassName:T="",duration:V,position:$,gap:H,loadingIcon:W,expandByDefault:D,classNames:F,icons:O,closeButtonAriaLabel:Y="Close toast",pauseWhenPageIsHidden:G}=t,[q,re]=Ce.useState(null),[U,ee]=Ce.useState(null),[K,ue]=Ce.useState(!1),[be,le]=Ce.useState(!1),[B,Q]=Ce.useState(!1),[ve,Ae]=Ce.useState(!1),[he,J]=Ce.useState(!1),[je,Ve]=Ce.useState(0),[Ye,Jt]=Ce.useState(0),Ue=Ce.useRef(g.duration||V||fS),r
3512n=Ce.useRef(null),vt=Ce.useRef(null),me=j===0,ot=j+1<=b,Se=g.type,Te=g.dismissible!==!1,He=g.className||"",Ut=g.descriptionClassName||"",cn=Ce.useMemo(()=>w.findIndex($e=>$e.toastId===g.id)||0,[w,g.id]),xn=Ce.useMemo(()=>{var $e;return($e=g.closeButton)!=null?$e:_},[g.closeButton,_]),un=Ce.useMemo(()=>g.duration||V||fS,[g.duration,V]),Yt=Ce.useRef(0),st=Ce.useRef(0),de=Ce.useRef(0),ze=Ce.useRef(null),[Qe,It]=$.split("-"),se=Ce.useMemo(()=>w.reduce(($e,oe,De)=>De>=cn?$e:$e+oe.height,0),[w,cn]),Re=fH(),ae=g.invert||p,et=Se==="loading";st.current=Ce.useMemo(()=>cn*H+se,[cn,se]),Ce.useEffect(()=>{Ue.current=un},[un]),Ce.useEffect(()=>{ue(!0)},[]),Ce.useEffect(()=>{let $e=vt.current;if($e){let oe=$e.getBoundingClientRect().height;return Jt(oe),y(De=>[{toastId:g.id,height:oe,position:g.position},...De]),()=>y(De=>De.filter($t=>$t.toastId!==g.id))}},[y,g.id]),Ce.useLayoutEffect(()=>{if(!K)return;let $e=vt.current,oe=$e.style.height;$e.style.height="auto";let De=$e.getBoundingClientRect().height;$e.style.height=oe,Jt(De),y($t=>$t.find(En=>En.toastId===g.id)?$t.map(En=>En.toastId===g.id?{...En,height:De}:En):[{toastId:g.id,height:De,position:g.position},...$t])},[K,g.title,g.description,y,g.id]);let xt=Ce.useCallback(()=>{le(!0),Ve(st.current),y($e=>$e.filter(oe=>oe.toastId!==g.id)),setTimeout(()=>{A(g)},SH)},[g,A,y,st]);Ce.useEffect(()=>{if(g.promise&&Se==="loading"||g.duration===1/0||g.type==="loading")return;let $e;return P||x||G&&Re?(()=>{if(de.current<Yt.current){let oe=new Date().getTime()-Yt.current;Ue.current=Ue.current-oe}de.current=new Date().getTime()})():Ue.current!==1/0&&(Yt.current=new Date().getTime(),$e=setTimeout(()=>{var oe;(oe=g.onAutoClose)==null||oe.call(g,g),xt()},Ue.current)),()=>clearTimeout($e)},[P,x,g,Se,G,Re,xt]),Ce.useEffect(()=>{g.delete&&xt()},[xt,g.delete]);function zt(){var $e,oe,De;return O!=null&&O.loading?Ce.createElement("div",{className:oo(F==null?void 0:F.loader,($e=g==null?void 0:g.classNames)==null?void 0:$e.loader,"sonner-loader"),"data-visible":Se==="loading"},O.loading):W?Ce.createElement("div",{className:oo(F==null?void 0:F.loader,(oe=g==null?void 0:g.classNames)==null?void 0:oe.loader,"sonner-loader"),"data-visible":Se==="loading"},W):Ce.createElement(aH,{className:oo(F==null?void 0:F.loader,(De=g==null?void 0:g.classNames)==null?void 0:De.loader),visible:Se==="loading"})}return Ce.createElement("li",{tabIndex:0,ref:vt,className:oo(S,He,F==null?void 0:F.toast,(e=g==null?void 0:g.classNames)==null?void 0:e.toast,F==null?void 0:F.default,F==null?void 0:F[Se],(n=g==null?void 0:g.classNames)==null?void 0:n[Se]),"data-sonner-toast":"","data-rich-colors":(r=g.richColors)!=null?r:N,"data-styled":!(g.jsx||g.unstyled||v),"data-mounted":K,"data-promise":!!g.promise,"data-swiped":he,"data-removed":be,"data-visible":ot,"data-y-position":Qe,"data-x-position":It,"data-index":j,"data-front":me,"data-swiping":B,"data-dismissible":Te,"data-type":Se,"data-invert":ae,"data-swipe-out":ve,"data-swipe-direction":U,"data-expanded":!!(P||D&&K),style:{"--index":j,"--toasts-before":j,"--z-index":E.length-j,"--offset":`${be?je:st.current}px`,"--initial-height":D?"auto":`${Ye}px`,...k,...g.style},onDragEnd:()=>{Q(!1),re(null),ze.current=null},onPointerDown:$e=>{et||!Te||(rn.current=new Date,Ve(st.current),$e.target.setPointerCapture($e.pointerId),$e.target.tagName!=="BUTTON"&&(Q(!0),ze.current={x:$e.clientX,y:$e.clientY}))},onPointerUp:()=>{var $e,oe,De,$t;if(ve||!Te)return;ze.current=null;let En=Number((($e=vt.current)==null?void 0:$e.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Ct=Number(((oe=vt.current)==null?void 0:oe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),qe=new Date().getTime()-((De=rn.current)==null?void 0:De.getTime()),Zn=q==="x"?En:Ct,_r=Math.abs(Zn)/qe;if(Math.abs(Zn)>=EH||_r>.11){Ve(st.current),($t=g.onDismiss)==null||$t.call(g,g),ee(q==="x"?En>0?"right":"left":Ct>0?"down":"up"),xt(),Ae(!0),J(!1);return}Q(!1),re(null)},onPointerMove:$e=>{var oe,De,$t,En;if(!ze.current||!Te||((oe=window.getSelection())==null?void 0:oe.toString().length)>0)return;let Ct=$e.clientY-ze.current.y,qe=$e.clientX-ze.current.x,Zn=(De=t.swipeDirections)!=null?De:kH($);!q&&(Math.abs(qe)>1||Math.abs(Ct)>1)&&re(Math.abs(qe)>Math.abs(Ct)?"x":"y");let _r={x:0,y:0};q==="y"?(Zn.includes("top")||Zn.includes("bottom"))&&(Zn.includes("top")&&Ct<0||Zn.includes("bottom")&&Ct>0)&&(_r.y=Ct):q==="x"&&(Zn.includes("left")||Zn.includes("right"))&&(Zn.includes("left")&&qe<0||Zn.includes("right")&&qe>0)&&(_r.x=qe),(Math.abs(_r.x)>0||Math.abs(_r.y)>0)&&J(!0),($t=vt.current)==null||$t.style.setProperty("--swipe-amount-x",`${_r.x}px`),(En=vt.current)==null||En.style.setProperty("--swipe-amount-y",`${_r.y}px`)}},xn&&!g.jsx?Ce.createElement("button",{"aria-label":Y,"data-disabled":et,"data-close-button":!0,onClick:et||!Te?()=>{}:()=>{var $e;xt(),($e=g.onDismiss)==null||$e.call(g,g)}
3512,className:oo(F==null?void 0:F.closeButton,(s=g==null?void 0:g.classNames)==null?void 0:s.closeButton)},(i=O==null?void 0:O.close)!=null?i:hH):null,g.jsx||u.isValidElement(g.title)?g.jsx?g.jsx:typeof g.title=="function"?g.title():g.title:Ce.createElement(Ce.Fragment,null,Se||g.icon||g.promise?Ce.createElement("div",{"data-icon":"",className:oo(F==null?void 0:F.icon,(a=g==null?void 0:g.classNames)==null?void 0:a.icon)},g.promise||g.type==="loading"&&!g.icon?g.icon||zt():null,g.type!=="loading"?g.icon||(O==null?void 0:O[Se])||oH(Se):null):null,Ce.createElement("div",{"data-content":"",className:oo(F==null?void 0:F.content,(l=g==null?void 0:g.classNames)==null?void 0:l.content)},Ce.createElement("div",{"data-title":"",className:oo(F==null?void 0:F.title,(c=g==null?void 0:g.classNames)==null?void 0:c.title)},typeof g.title=="function"?g.title():g.title),g.description?Ce.createElement("div",{"data-description":"",className:oo(T,Ut,F==null?void 0:F.description,(d=g==null?void 0:g.classNames)==null?void 0:d.description)},typeof g.description=="function"?g.description():g.description):null),u.isValidElement(g.cancel)?g.cancel:g.cancel&&ip(g.cancel)?Ce.createElement("button",{"data-button":!0,"data-cancel":!0,style:g.cancelButtonStyle||L,onClick:$e=>{var oe,De;ip(g.cancel)&&Te&&((De=(oe=g.cancel).onClick)==null||De.call(oe,$e),xt())},className:oo(F==null?void 0:F.cancelButton,(h=g==null?void 0:g.classNames)==null?void 0:h.cancelButton)},g.cancel.label):null,u.isValidElement(g.action)?g.action:g.action&&ip(g.action)?Ce.createElement("button",{"data-button":!0,"data-action":!0,style:g.actionButtonStyle||I,onClick:$e=>{var oe,De;ip(g.action)&&((De=(oe=g.action).onClick)==null||De.call(oe,$e),!$e.defaultPrevented&&xt())},className:oo(F==null?void 0:F.actionButton,(f=g==null?void 0:g.classNames)==null?void 0:f.actionButton)},g.action.label):null))};function mS(){if(typeof window>"u"||typeof document>"u")return"ltr";let t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function IH(t,e){let n={};return[t,e].forEach((r,s)=>{let i=s===1,a=i?"--mobile-offset":"--offset",l=i?CH:jH;function c(d){["top","right","bottom","left"].forEach(h=>{n[`${a}-${h}`]=typeof d=="number"?`${d}px`:d})}typeof r=="number"||typeof r=="string"?c(r):typeof r=="object"?["top","right","bottom","left"].forEach(d=>{r[d]===void 0?n[`${a}-${d}`]=l:n[`${a}-${d}`]=typeof r[d]=="number"?`${r[d]}px`:r[d]}):c(l)}),n}var TH=u.forwardRef(function(t,e){let{invert:n,position:r="bottom-right",hotkey:s=["altKey","KeyT"],expand:i,closeButton:a,className:l,offset:c,mobileOffset:d,theme:h="light",richColors:f,duration:p,style:g,visibleToasts:v=bH,toastOptions:x,dir:y=mS(),gap:b=_H,loadingIcon:w,icons:j,containerAriaLabel:E="Notifications",pauseWhenPageIsHidden:P}=t,[A,N]=Ce.useState([]),_=Ce.useMemo(()=>Array.from(new Set([r].concat(A.filter(G=>G.position).map(G=>G.position)))),[A,r]),[k,L]=Ce.useState([]),[I,S]=Ce.useState(!1),[T,V]=Ce.useState(!1),[$,H]=Ce.useState(h!=="system"?h:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),W=Ce.useRef(null),D=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),F=Ce.useRef(null),O=Ce.useRef(!1),Y=Ce.useCallback(G=>{N(q=>{var re;return(re=q.find(U=>U.id===G.id))!=null&&re.delete||ts.dismiss(G.id),q.filter(({id:U})=>U!==G.id)})},[]);return Ce.useEffect(()=>ts.subscribe(G=>{if(G.dismiss){N(q=>q.map(re=>re.id===G.id?{...re,delete:!0}:re));return}setTimeout(()=>{Fj.flushSync(()=>{N(q=>{let re=q.findIndex(U=>U.id===G.id);return re!==-1?[...q.slice(0,re),{...q[re],...G},...q.slice(re+1)]:[G,...q]})})})}),[]),Ce.useEffect(()=>{if(h!=="system"){H(h);return}if(h==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?H("dark"):H("light")),typeof window>"u")return;let G=window.matchMedia("(prefers-color-scheme: dark)");try{G.addEventListener("change",({matches:q})=>{H(q?"dark":"light")})}catch{G.addListener(({matches:re})=>{try{H(re?"dark":"light")}catch(U){console.error(U)}})}},[h]),Ce.useEffect(()=>{A.length<=1&&S(!1)},[A]),Ce.useEffect(()=>{let G=q=>{var re,U;s.every(ee=>q[ee]||q.code===ee)&&(S(!0),(re=W.current)==null||re.focus()),q.code==="Escape"&&(document.activeElement===W.current||(U=W.current)!=null&&U.contains(document.activeElement))&&S(!1)};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[s]),Ce.useEffect(()=>{if(W.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,O.current=!1)}},[W.current]),Ce.createElement("section",{ref:e,"aria-label":`${E} ${D}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},_.map((G,q)=>{var re;let[U,ee]=G.split("-");return A.length?Ce.createElement("ol",{key:G,dir:y==="auto"?mS():y,tabIndex:-1,ref:W,className:l,"data-sonner-toaster":!0,"data-theme":$,"data-y-position":U,"data-lifted":I&&A.length>1&&!i,"data-x-position":ee,style:{"--front-toast-height":`${((re=k[0])==null?void 0:re.height)||0}px`,"--width":`${NH}px`,"--gap":`${b}px`,...g,...IH(c,d)},onBlur:K=>{O.current&&!K.currentTarget.contains(K.relatedTarget)&&(O.current=!1,F.current&&(F.current.focus({preventScroll:!0}),F.current=null))},onFocus:K=>{K.target instanceof HTMLElement&&K.target.dataset.dismissible==="false"||O.current||(O.current=!0,F.current=K.relatedTarget)},onMouseEnter:()=>S(!0),onMouseMove:()=>S(!0),onMouseLeave:()=>{T||S(!1)},onDragEnd:()=>S(!1),onPointerDown:K=>{K.target instanceof HTMLElement&&K.target.dataset.dismissible==="false"||V(!0)},onPointerUp:()=>V(!1)},A.filter(K=>!K.position&&q===0||K.position===G).map((K,ue)=>{var be,le;return Ce.createElement(PH,{key:K.id,icons:j,index:ue,toast:K,defaultRichColors:f,duration:(be=x==null?void 0:x.duration)!=null?be:p,className:x==null?void 0:x.className,descriptionClassName:x==null?void 0:x.descriptionClassName,invert:n,visibleToasts:v,closeButton:(le=x==null?void 0:x.closeButton)!=null?le:a,interacting:T,position:G,style:x==null?void 0:x.style,unstyled:x==null?void 0:x.unstyled,classNames:x==null?void 0:x.classNames,cancelButtonStyle:x==null?void 0:x.cancelButtonStyle,actionButtonStyle:x==null?void 0:x.actionButtonStyle,removeToast:Y,toasts:A.filter(B=>
3512B.position==K.position),heights:k.filter(B=>B.position==K.position),setHeights:L,expandByDefault:i,gap:b,loadingIcon:w,expanded:I,pauseWhenPageIsHidden:P,swipeDirections:t.swipeDirections})})):null}))});const kD=u.createContext(void 0);function AH({children:t}){const e={success:(n,r)=>{op.success(n,{description:r})},error:(n,r)=>{op.error(n,{description:r})},info:(n,r)=>{op.info(n,{description:r})},warning:(n,r)=>{op.warning(n,{description:r})}};return o.jsx(kD.Provider,{value:{toast:e},children:t})}function Ft(){const t=u.useContext(kD);if(t===void 0)throw new Error("useToast must be used within a ToastProvider");return t.toast}const ap="path",RH="0123456789bcdefghjkmnpqrstuvwxyz";function PD(t,e,n=9){let r="",s=0,i=0,a=!0;const l={min:-90,max:90},c={min:-180,max:180};for(;r.length<n;){if(a){const d=(c.min+c.max)/2;e>d?(s=(s<<1)+1,c.min=d):(s=s<<1,c.max=d)}else{const d=(l.min+l.max)/2;t>d?(s=(s<<1)+1,l.min=d):(s=s<<1,l.max=d)}a=!a,i<4?i++:(r+=RH[s],i=0,s=0)}return r}function DH(t,e){const n=[];for(let r=0;r<t.length;r+=e)n.push(t.slice(r,r+e));return n}function pS(t,e){const r=(e.gpsPoint??[]).map(s=>({latitude:s.latitude??s._latitude,longitude:s.longitude??s._longitude}));return{id:t,name:e.name??"",description:e.description??"",activity:e.activity??"none",companyId:e.companyId??"",creatorId:e.creatorId??"",pseudoCreator:e.pseudoCreator??"",gpsPoints:r,fillColor:e.fillColor,isActive:e.isActive??!1,creationDate:e.creationDate}}const Ll={async getPathsByCompanies(t){if(t.length===0)return[];try{return(await Promise.all(DH(t,30).map(async n=>{const r=Gr(jn(Xe,ap),is("companyId","in",n));return(await Yr(r)).docs.map(i=>pS(i.id,i.data()))}))).flat()}catch(e){return console.error("Error fetching paths by companies:",e),[]}},async getAllPaths(t=1e3){try{return(await Yr(jn(Xe,ap))).docs.slice(0,t).map(n=>pS(n.id,n.data()))}catch(e){return console.error("Error fetching all paths:",e),[]}},async createPath(t){var a;if(t.gpsPoints.length<2)throw new Error("Un chemin nécessite au moins 2 points.");const e=t.gpsPoints.map(l=>new Fi(l.latitude,l.longitude)),n=t.gpsPoints[0],s=`#FF${(fo[t.activity]??fo.none).replace("#","")}`;return(await ld(jn(Xe,ap),{name:t.name.trim(),description:((a=t.description)==null?void 0:a.trim())??"",activity:t.activity,companyId:t.companyId,creatorId:t.creatorId,pseudoCreator:t.pseudoCreator,gpsPoint:e,fillColor:s,isActive:!1,creationDate:Or(),startPoint:{geopoint:new Fi(n.latitude,n.longitude),geohash:PD(n.latitude,n.longitude)}})).id},async deletePath(t){await Qf(Ht(Xe,ap,t))}},gS=t=>t.map(e=>new Fi(e.latitude,e.longitude)),vS=t=>({geopoint:new Fi(t[0].latitude,t[0].longitude),geohash:PD(t[0].latitude,t[0].longitude)}),LH=t=>(t||[]).map(e=>({latitude:e.latitude,longitude:e.longitude})),er={async getZonesPaginated(t=20,e=0,n,r,s,i){try{const l=await pe(ge,"getHuntingZones")({limit:t,offset:e,searchTerm:n,filter:r,departmentCode:s,zoneTypes:i});return{zones:l.data.zones||[],totalCount:l.data.total||0,offset:l.data.offset||0,hasMore:l.data.hasMore||!1}}catch(a){return console.error("Error fetching zones:",a),{zones:[],totalCount:0,offset:0,hasMore:!1}}},async getZoneById(t){try{const e=await ms(Ht(Xe,"zone",t));return e.exists()?{id:e.id,...e.data()}:null}catch(e){return console.error("Error fetching zone:",e),null}},async listCompanyTerritories(t){const e=Gr(jn(Xe,"zone"),is("companyId","==",t));return(await Yr(e)).docs.map(r=>{const s=r.data();return{id:r.id,...s,gpsPoint:LH(s.gpsPoint)}})},async createTerritory(t){return(await ld(jn(Xe,"zone"),{name:t.name.trim(),description:"",zoneType:"huntingTerritory",gpsPoint:gS(t.gpsPoint),startPoint:vS(t.gpsPoint),companyId:t.companyId,louvetierEmails:[],trapperEmails:[],departmentCode:t.departmentCode??null,createdAt:Or(),updatedAt:Or()})).id},async updateTerritory(t,e){const n={updatedAt:Or()};e.name!==void 0&&(n.name=e.name.trim()),e.gpsPoint!==void 0&&(n.gpsPoint=gS(e.gpsPoint),n.startPoint=vS(e.gpsPoint)),await Ba(Ht(Xe,"zone",t),n)},async deleteTerritory(t){await Qf(Ht(Xe,"zone",t))},async createZone(t){const n=await pe(ge,"createHuntingZone")({...t,zoneType:t.zoneType??"huntingTerritory"}),{zoneId:r}=n.data,s=await this.getZoneById(r);if(!s)throw new Error("Failed to create zone");return s},async updateZone(t,e){const n=pe(ge,"updateZone"),r={zoneId:t,...e};e.gpsPoint!==void 0&&(r.gpsPoint=e.gpsPoint.map(s=>({latitude:s.latitude,longitude:s.longitude}))),await n(r)},async deleteZone(t){await pe(ge,"deleteZone")({zoneId:t})},async assignCompanyToZone(t,e){await pe(ge,"updateZone")({zoneId:t,companyId:e})},async removeCompanyFromZone(t){await pe(ge,"updateZone")({zoneId:t,companyId:null})},async addLouvetierToZone(t,e){await pe(ge,"addLouvetierToZone")({zoneId:t,email:e})},async removeLouvetierFromZone(t,e){await pe(ge,"removeLouvetierFromZone")({zoneId:t,email:e})},async addTrapperToZone(t,e){await pe(ge,"addTrapperToZone")({zoneId:t,email:e})},async removeTrapperFromZone(t,e){await pe(ge,"removeTrapperFromZone")({zoneId:t,email:e})},async createZonesBulk(t){const n=await pe(ge,"createZonesBulk")(t);return{created:n.data.created||0,updated:n.data.updated||0,skipped:n.data.skipped||[]}},async deleteZonesBulk(t){return{deleted:(await pe(ge,"deleteZonesBulk")(t)).data.deleted||0}},async finalizeZoneImport(t){await pe(ge,"finalizeZoneImport")(t)},async getZonesByViewport(t,e=[],n=100){try{return(await pe(ge,"getZonesByViewport")({bounds:t,excludeIds:e,limit:n})).data.zones||[]}catch(r){return console.error("Error fetching zones by viewport:",r),[]}}},Ar={async getCropZones(){try{return(await pe(ge,"getCropZones")()).data.cropZones||[]}catch(t){return console.error("Error fetching cropZones:",t),[]}},async getCropZonesByDepartment(t){try{return(await pe(ge,"getCropZonesByDepartment")(t?{departmentCode:t}:{})).data.cropZones||[]}catch(e){return console.error("Error fetching cropZones by department:",e),[]}},async getCropZonesByZone(t){try{return(await pe(ge,"getCropZonesByZone")({zoneId:t})).data.cropZones||[]}catch(e){return console.error("Error fetching cropZones by zone:",e),[]}},async getCropZonesByZones(t){try{return(await pe(ge,"getCropZonesByZones")({zoneIds:t})).data.cropZones||[]}catch(e){return console.error("Error fetching cropZones by zones:",e),[]}},async getCropZoneById(t){try{const e=await ms(Ht(Xe,"cropZones",t));return e.exists()?{id:e.id,...e.data()}:null}catch(e){return console.error("[cropZoneService] Error fetching cropZone:",{cropZoneId:t,error:e.message}),null}},async getSeedingsByCropZone(t){try{const e=Gr(jn(Xe,"seedings"),is("cropZoneId","==",t));return(await Yr(e)).docs.map(r=>({id:r.id,...r.data()}))}catch(e){return console.error("Error fetching seedings:",e),[]}},async getDamagesByCropZone(t){try{const e=Gr(jn(Xe,"damages"),is("cropZoneId","==",t));return(await Yr(e)).docs.map(r=>({id:r.id,...r.data()}))}catch(e){return console.error("Error fetching damages:",e),[]}},async getBurrowsByCropZone(t){try{const e=Gr(jn(Xe,"burrows"),is("cropZoneId","==",t));return(await Yr(e)).docs.map(r=>({id:r.id,...r.data()}))}catch(e){return console.error("Error fetching burrows:",e),[]}},async getCropZoneFarmer(t){try{const e=await ms(Ht(Xe,"users",t));if(!e.exists())return null;const n=e.data();return{pseudo:(n==null?void 0:n.pseudo)||"",email:(n==null?void 0:n.email)||"",firstName:(n==null?void 0:n.firstName)||void 0,lastName:(n==null?void 0:n.lastName)||void 0}}catch(e){return console.error("Error fetching farmer:",e),null}}};Ar.getCropZones.bind(Ar),Ar.getCropZonesByDepartment.bind(Ar),Ar.getCropZonesByZone.bind(Ar),Ar.getCropZonesByZones.bind(Ar),Ar.getCropZoneFarmer.bind(Ar);const ph={async getDamages(t){try{return(await pe(ge,"getDamages")({filter:t})).data.damages||[]}catch(e){return console.error("Error fetching damages:",e),[]}},async getDamagesByDepartment(t,e){try{return(await pe(ge,"getDamagesByDepartment")({departmentCode:t,filter:e})).data.damages||[]}catch(n){return console.error("Error fetching damages by department:",n),[]}},async getDamagesByZone(t,e){try{return(await pe(ge,"getDamagesByZone")({zoneId:t,filter:e})).data.damages||[]}catch(n){return console.error("Error fetching damages by zone:",n),[]}},async getDamagesByZones(t,e){try{return(await pe(ge,"getDamagesByZones")({zoneIds:t,filter:e})).data.damages||[]}catch(n){return console.error("Error fetching damages by zones:",n),[]}},async getDamageById(t){try{const e=await ms(Ht(Xe,"damages",t));return e.exists()?{id:e.id,...e.data()}:null}catch(e){return console.error("Error fetching damage:",e),null}},async updateDamageStatus(t,e,n){await pe(ge,"updateDamageStatus")({damageId:t,status:e,note:n})},async downloadShuttleForm(t){const r=(await pe(ge,"generateShuttleFormPdf")({damageId:t})).data.pdf,s=atob(r),i=new Uint8Array(s.length);for(let a=0;a<s.length;a++)i[a]=s.charCodeAt(a);return new Blob([i],{type:"application/pdf"})},async getShuttleForm(t){try{return(await pe(ge,"getShuttleFormByDamage")({damageId:t})).data.shuttleForm||null}catch(e){return console.error("Error fetching shuttle form:",e),null}},async deleteDamage(t){await pe(ge,"deleteDamage")({damageId:t})}},cb={async getBurrows(t){try{return(await pe(ge,"getBurrows")({filter:t})).data.burrows||[]}catch(e){return console.error("Error fetching burrows:",e),[]}},async getBurrowsByDepartment(t,e){try{return(await pe(ge,"getBurrowsByDepartment")({departmentCode:t,filter:e})).data.burrows||[]}catch(n){return console.error("Error fetching burrows by department:",n),[]}},async getBurrowsByZone(t,e){try{return(await pe(ge,"getBurrowsByZone")({zoneId:t,filter:e})).data.burrows||[]}catch(n){return console.error("Error fetching burrows by zone:",n),[]}},async getBurrowsByZones(t,e){try{return(await pe(ge,"getBurrowsByZones")({zoneIds:t,filter:e})).data.burrows||[]}catch(n){return console.error("Error fetching burrows by zones:",n),[]}},async getBurrowById(t){try{const e=await ms(Ht(Xe,"burrows",t));return e.exists()?{id:e.id,...e.data()}:null}catch(e){return console.error("Error fetching burrow:",e),null}},async updateBurrowStatus(t,e){await pe(ge,"updateBurrowStatus")({burrowId:t,status:e})},async deleteBurrow(t){await pe(ge,"deleteBurrow")({burrowId:t})}},ID=u.createContext(void 0),MH=5*60*1e3;function OH({children:t}){const{user:e,isSuperAdmin:n}=nn(),[r,s]=u.useState([]),[i,a]=u.useState([]),[l,c]=u.useState([]),[d,h]=u.useState([]),[f,p]=u.useState(!1),[g,v]=u.useState(null),x=u.useMemo(()=>Object.keys((e==null?void 0:e.companyRoles)??{}).length>0,[e]),y=u.useMemo(()=>e?n||x||Yn(e,"manage_department_zones")||Yn(e,"view_assigned_zones")||Yn(e,"view_company_zones"):!1,[e,n,x]),b=u.useMemo(()=>e?n||x||Yn(e,"view_department_plots")||Yn(e,"view_zone_plots"):!1,[e,n,x]),w=u.useMemo(()=>e?n||x||Yn(e,"view_department_damages")||Yn(e,"view_zone_damages"):!1,[e,n,x]),j=u.useMemo(()=>e?n||x||Yn(e,"view_department_burrows")||Yn(e,"view_zone_burrows"):!1,[e,n,x]),E=u.useCallback(async()=>
3512{if(y)try{const I=await er.getZonesPaginated(100,0);s(I.zones)}catch(I){console.error("Error fetching zones:",I)}},[y]),P=u.useCallback(async()=>{if(!(!b||!e))try{const I=await Ar.getCropZones();a(I)}catch(I){console.error("Error fetching plots:",I)}},[b,e]),A=u.useCallback(async()=>{if(!(!w||!e))try{const I=await ph.getDamages();c(I)}catch(I){console.error("Error fetching damages:",I)}},[w,e]),N=u.useCallback(async()=>{if(!(!j||!e))try{const I=await cb.getBurrows();h(I)}catch(I){console.error("Error fetching burrows:",I)}},[j,e]),_=u.useCallback(async()=>{if(e){p(!0);try{await Promise.all([E(),P(),A(),N()]),v(new Date)}finally{p(!1)}}},[e,E,P,A,N]),k=u.useMemo(()=>g?Date.now()-g.getTime()>MH:!0,[g]),L=u.useMemo(()=>({zones:r,plots:i,damages:l,burrows:d,loading:f,lastFetched:g,refreshAll:_,refreshZones:E,refreshPlots:P,refreshDamages:A,refreshBurrows:N,isStale:k}),[r,i,l,d,f,g,_,E,P,A,N,k]);return o.jsx(ID.Provider,{value:L,children:t})}function FH(){const t=u.useContext(ID);if(t===void 0)throw new Error("useDataCache must be used within a DataCacheProvider");return t}const TD=u.createContext(void 0);function zH({children:t}){const[e,n]=u.useState(()=>{const s=localStorage.getItem("theme");return s==="light"||s==="dark"?s:"light"});u.useEffect(()=>{const s=document.documentElement;e==="dark"?s.classList.add("dark"):s.classList.remove("dark"),localStorage.setItem("theme",e)},[e]);const r=()=>n(s=>s==="dark"?"light":"dark");return o.jsx(TD.Provider,{value:{theme:e,toggleTheme:r},children:t})}function $H(){const t=u.useContext(TD);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}const AD=u.createContext(void 0);function VH({children:t}){const[e,n]=u.useState(()=>localStorage.getItem("sidebar-collapsed")==="true"),[r,s]=u.useState(!1),i=()=>n(c=>{const d=!c;return localStorage.setItem("sidebar-collapsed",String(d)),d}),a=()=>s(!0),l=()=>s(!1);return o.jsx(AD.Provider,{value:{collapsed:e,toggleCollapsed:i,drawerOpen:r,openDrawer:a,closeDrawer:l},children:t})}function UH(){const t=u.useContext(AD);if(!t)throw new Error("useSidebar must be used within SidebarProvider");return t}const Ot={async getCompaniesPaginated(t=20,e,n,r,s){try{const a=await pe(ge,"getCompanies")({limit:Math.min(t,100),searchTerm:e,departmentCode:n,lastDocId:r,territoryFilter:s});return{companies:a.data.companies||[],totalCount:a.data.totalCount||0,hasMore:a.data.hasMore||!1,lastDocId:a.data.lastDocId||null,isSearchResult:a.data.isSearchResult||!1}}catch(i){return console.error("Error fetching companies:",i),{companies:[],totalCount:0,hasMore:!1,lastDocId:null,isSearchResult:!1}}},async getAllCompanies(){return(await pe(ge,"getAllCompanies")()).data.companies||[]},async getCompanyById(t){try{const e=await ms(Ht(Xe,"company",t));return e.exists()?{id:e.id,...e.data()}:null}catch(e){return console.error("Error getting company:",e),null}},async createCompany(t){const n=await pe(ge,"createCompany")(t),{companyId:r}=n.data,s=await this.getCompanyById(r);if(!s)throw new Error("Failed to create company");return s},async updateCompany(t,e){await pe(ge,"updateCompany")({companyId:t,...e})},async updateCompanyFields(t,e){const n={updatedAt:Or()};Object.entries(e).forEach(([r,s])=>{s!==void 0&&(n[r]=s)}),await Ba(Ht(Xe,"company",t),n)},async deleteCompany(t){await pe(ge,"deleteCompany")({companyId:t})},async addMember(t,e,n){await pe(ge,"addMemberToCompany")({companyId:t,userId:e,companyRole:n})},async addMemberByEmail(t,e,n="reader"){return(await pe(ge,"addMemberByEmail")({companyId:t,email:e,role:n})).data.member},async removeMember(t,e){await pe(ge,"removeMemberFromCompany")({companyId:t,userId:e})},subscribeToAllCompanies(t){const e=jn(Xe,"company"),n=Gr(e,OC("name","asc"));return nb(n,r=>{const s=r.docs.map(i=>({id:i.id,...i.data()}));t(s)})},subscribeToCompanyById(t,e){const n=Ht(Xe,"company",t);return nb(n,r=>{r.exists()?e({id:r.id,...r.data()}):e(null)})},async searchCompanies(t,e=50){try{return(await pe(ge,"searchCompanies")({searchTerm:t,limit:e})).data.companies||[]}catch(n){return console.error("Error searching companies:",n),[]}},async getCompanyZones(t){try{const e=Gr(jn(Xe,"zone"),is("companyId","==",t));return{zones:(await Yr(e)).docs.map(s=>({id:s.id,name:s.data().name||"",zoneType:s.data().zoneType||null}))}}catch(e){return console.error("Error fetching company zones:",e),{zones:[]}}},async getCompanyMembers(t){var e;try{return{members:(((e=(await pe(ge,"getCompanyMembers")({companyId:t})).data)==null?void 0:e.members)||[]).map(i=>({id:String(i.id),pseudo:i.pseudo||"",firstName:i.firstName||void 0,lastName:i.lastName||void 0,email:i.email||"",role:i.role||"reader",isPremium:!!i.isPremium}))}}catch(n){return console.error("Error fetching company members:",n),{members:[]}}},async updateMemberCompanyRole(t,e,n){await pe(ge,"updateMemberCompanyRole")({companyId:t,userId:e,role:n})},async requestCompanyJoin(t){const n=await pe(ge,"requestCompanyJoin")({identificationCode:t});return{requestId:n.data.requestId,message:n.data.message}},async inviteMemberByEmail(t,e,n){var i;return{added:!!((i=(await pe(ge,"inviteMemberByEmail")({companyId:t,email:e.trim().toLowerCase(),role:n})).data)!=null&&i.added)}},async listPendingInvitations(t){const e=Gr(jn(Xe,"companyInvitations"),is("companyId","==",t),is("status","==","pending"));return(await Yr(e)).docs.map(r=>({id:r.id,email:r.data().email||"",role:r.data().role||"reader"}))},async revokeInvitation(t){await pe(ge,"revokeCompanyInvitation")({invitationId:t})},async listPendingJoinRequests(t){const e=Gr(jn(Xe,"companyJoinRequests"),is("companyId","==",t),is("status","==","pending"));return(await Yr(e)).docs.map(r=>({id:r.id,userId:r.data().userId||"",userEmail:r.data().userEmail||"",userPseudo:r.data().userPseudo||""}))},async approveJoinRequest(t){await pe(ge,"approveCompanyJoin")({requestId:t})},async rejectJoinRequest(t){await pe(ge,"rejectCompanyJoin")({requestId:t})}},xS="active-company-id",RD=u.createContext(void 0);function BH({children:t}){const{user:e}=nn(),n=u.useMemo(()=>Object.keys((e==null?void 0:e.companyRoles)??{}),[e]),[r,s]=u.useState(void 0),[i,a]=u.useState([]),[l,c]=u.useState(!0);u.useEffect(()=>{var p;if(r&&n.includes(r))return;const h=localStorage.getItem(xS)??void 0,f=h&&n.includes(h)&&h||(e!=null&&e.company&&((p=e.companyRoles)!=null&&p[e.company])?e.company:void 0)||n[0];s(f)},[e,n,r]);const d=h=>{localStorage.setItem(xS,h),s(h)};return u.useEffect(()=>{let h=!1;return(async()=>{c(!0);const f=Object.entries((e==null?void 0:e.companyRoles)??{}),p=await Promise.all(f.map(async([g,v])=>{const x=await Ot.getCompanyById(g).catch(()=>null);return x?{id:g,name:x.name,role:v}:null}));h||(a(p.filter(g=>g!==null)),c(!1))})(),()=>{h=!0}},[e==null?void 0:e.companyRoles]),o.jsx(RD.Provider,{value:{activeCompanyId:r,setActiveCompanyId:d,companies:i,loading:l},children:t})}function cd(){const t=u.useContext(RD);if(!t)throw new Error("useActiveCompany must be used within ActiveCompanyProvider");return t}function wf(t){"@babel/helpers - typeof";return wf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},wf(t)}function WH(t,e){if(wf(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(wf(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function HH(t){var e=WH(t,"string");return wf(e)=="symbol"?e:e+""}function ce(t,e,n){return(e=HH(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function DD(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Vy,yS;function qH(){if(yS)return Vy;yS=1;var t=function(n,r,s,i,a,l,c,d){if(!n){var h;if(r===void 0)h=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var f=[s,i,a,l,c,d],p=0;h=new Error(r.replace(/%s/g,function(){return f[p++]})),h.name="Invariant Violation"}throw h.framesToPop=1,h}};return Vy=t,Vy}var GH=qH(),tr=DD(GH),ut=u.createContext(null);function ZH(){tr(!!u.useContext,"useGoogleMap is React hook and requires React version 16.8+");var t=u.useContext(ut);return tr(!!t,"useGoogleMap needs a GoogleMap available up in the tree"),t}function KH(t,e,n){return Object.keys(t).reduce(function(s,i){return e(s,t[i],i)},n)}function YH(t,e){Object.keys(t).forEach(n=>e(t[n],n))}function QH(t,e,n,r){var s={},i=(a,l)=>{var c=n[l];c!==e[l]&&(s[l]=c,a(r,c))};return YH(t,i),s}function XH(t,e,n){var r=KH(n,function(i,a,l){return typeof t[l]=="function"&&i.push(google.maps.event.addListener(e,a,t[l])),i},[]);return r}function JH(t){google.maps.event.removeListener(t)}function yt(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];t.forEach(JH)}function gt(t){var{updaterMap:e,eventMap:n,prevProps:r,nextProps:s,instance:i}=t,a=XH(s,i,n);return QH(e,r,s,i),a}var wS={onDblClick:"dblclick",onDragEnd:"dragend",onDragStart:"dragstart",onMapTypeIdChanged:"maptypeid_changed",onMouseMove:"mousemove",onMouseOut:"mouseout",onMouseOver:"mouseover",onMouseDown:"mousedown",onMouseUp:"mouseup",onRightClick:"rightclick",onTilesLoaded:"tilesloaded",onBoundsChanged:"bounds_changed",onCenterChanged:"center_changed",onClick:"click",onDrag:"drag",onHeadingChanged:"heading_changed",onIdle:"idle",onProjectionChanged:"projection_changed",onResize:"resize",onTiltChanged:"tilt_changed",onZoomChanged:"zoom_changed"},bS={extraMapTypes(t,e){e.forEach(function(r,s){t.mapTypes.set(String(s),r)})},center(t,e){t.setCenter(e)},clickableIcons(t,e){t.setClickableIcons(e)},heading(t,e){t.setHeading(e)},mapTypeId(t,e){t.setMapTypeId(e)},options(t,e){t.setOptions(e)},streetView(t,e){t.setStreetView(e)},tilt(t,e){t.setTilt(e)},zoom(t,e){t.setZoom(e)}};function eq(t){var{children:e,options:n,id:r,mapContainerStyle:s,mapContainerClassName:i,center:a,onClick:l,onDblClick:c,onDrag:d,onDragEnd:h,onDragStart:f,onMouseMove:p,onMouseOut:g,onMouseOver:v,onMouseDown:x,onMouseUp:y,onRightClick:b,onCenterChanged:w,onLoad:j,onUnmount:E}=t,[P,A]=u.useState(null),N=u.useRef(null),[_,k]=u.useState(null),[L,I]=u.useState(null),[S,T]=u.useState(null),[V,$]=u.useState(null),[H,W]=u.useState(null),[D,F]=u.useState(null),[O,Y]=u.useState(null),[G,q]=u.useState(null),[re,U]=u.useState(null),[ee,K]=u.useState(null),[ue,be]=u.useState(null),[le,B]=u.useState(null);return u.useEffect(()=>{n&&P!==null&&P.setOptions(n)},[P,n]),u.useEffect(()=>{P!==null&&typeof a<"u"&&P.setCenter(a)},[P,a]),u.useEffect(()=>{P&&c&&(L!==null&&google.maps.event.removeListener(L),I(google.maps.event.addListener(P,"dblclick",c)))},[c]),u.useEffect(()=>{P&&h&&(S!==null&&google.maps.event.removeListener(S),T(google.maps.event.addListener(P,"dragend",h)))},[h]),u.useEffect(()=>{P&&f&&(V!==null&&google.maps.event.removeListener(V),$(google.maps.event.addListener(P,"dragstart",f)))},[f]),u.useEffect(()=>{P&&x&&(H!==null&&google.maps.event.removeListener(H),W(google.maps.event.addListener(P,"mousedown",x)))},[x]),u.useEffect(()=>
3512{P&&p&&(D!==null&&google.maps.event.removeListener(D),F(google.maps.event.addListener(P,"mousemove",p)))},[p]),u.useEffect(()=>{P&&g&&(O!==null&&google.maps.event.removeListener(O),Y(google.maps.event.addListener(P,"mouseout",g)))},[g]),u.useEffect(()=>{P&&v&&(G!==null&&google.maps.event.removeListener(G),q(google.maps.event.addListener(P,"mouseover",v)))},[v]),u.useEffect(()=>{P&&y&&(re!==null&&google.maps.event.removeListener(re),U(google.maps.event.addListener(P,"mouseup",y)))},[y]),u.useEffect(()=>{P&&b&&(ee!==null&&google.maps.event.removeListener(ee),K(google.maps.event.addListener(P,"rightclick",b)))},[b]),u.useEffect(()=>{P&&l&&(ue!==null&&google.maps.event.removeListener(ue),be(google.maps.event.addListener(P,"click",l)))},[l]),u.useEffect(()=>{P&&d&&(le!==null&&google.maps.event.removeListener(le),B(google.maps.event.addListener(P,"drag",d)))},[d]),u.useEffect(()=>{P&&w&&(_!==null&&google.maps.event.removeListener(_),k(google.maps.event.addListener(P,"center_changed",w)))},[l]),u.useEffect(()=>{var Q=N.current===null?null:new google.maps.Map(N.current,n);return A(Q),Q!==null&&j&&j(Q),()=>{Q!==null&&E&&E(Q)}},[]),o.jsx("div",{id:r,ref:N,style:s,className:i,children:o.jsx(ut.Provider,{value:P,children:P!==null?e:null})})}u.memo(eq);class Qs extends u.PureComponent{constructor(){super(...arguments),ce(this,"state",{map:null}),ce(this,"registeredEvents",[]),ce(this,"mapRef",null),ce(this,"getInstance",()=>this.mapRef===null?null:new google.maps.Map(this.mapRef,this.props.options)),ce(this,"panTo",e=>{var n=this.getInstance();n&&n.panTo(e)}),ce(this,"setMapCallback",()=>{this.state.map!==null&&this.props.onLoad&&this.props.onLoad(this.state.map)}),ce(this,"getRef",e=>{this.mapRef=e})}componentDidMount(){var e=this.getInstance();this.registeredEvents=gt({updaterMap:bS,eventMap:wS,prevProps:{},nextProps:this.props,instance:e}),this.setState(function(){return{map:e}},this.setMapCallback)}componentDidUpdate(e){this.state.map!==null&&(yt(this.registeredEvents),this.registeredEvents=gt({updaterMap:bS,eventMap:wS,prevProps:e,nextProps:this.props,instance:this.state.map}))}componentWillUnmount(){this.state.map!==null&&(this.props.onUnmount&&this.props.onUnmount(this.state.map),yt(this.registeredEvents))}render(){return o.jsx("div",{id:this.props.id,ref:this.getRef,style:this.props.mapContainerStyle,className:this.props.mapContainerClassName,children:o.jsx(ut.Provider,{value:this.state.map,children:this.state.map!==null?this.props.children:null})})}}function jS(t,e,n,r,s,i,a){try{var l=t[i](a),c=l.value}catch(d){return void n(d)}l.done?e(c):Promise.resolve(c).then(r,s)}function LD(t){return function(){var e=this,n=arguments;return new Promise(function(r,s){var i=t.apply(e,n);function a(c){jS(i,r,s,a,l,"next",c)}function l(c){jS(i,r,s,a,l,"throw",c)}a(void 0)})}}function MD(t){var{googleMapsApiKey:e,googleMapsClientId:n,version:r="weekly",language:s,region:i,libraries:a,channel:l,mapIds:c,authReferrerPolicy:d,apiUrl:h="https://maps.googleapis.com"}=t,f=[];return tr(e&&n||!(e&&n),"You need to specify either googleMapsApiKey or googleMapsClientId for @react-google-maps/api load script to work. You cannot use both at the same time."),e?f.push("key=".concat(e)):n&&f.push("client=".concat(n)),r&&f.push("v=".concat(r)),s&&f.push("language=".concat(s)),i&&f.push("region=".concat(i)),a&&a.length&&f.push("libraries=".concat(a.sort().join(","))),l&&f.push("channel=".concat(l)),c&&c.length&&f.push("map_ids=".concat(c.join(","))),d&&f.push("auth_referrer_policy=".concat(d)),f.push("loading=async"),f.push("callback=initMap"),"".concat(h,"/maps/api/js?").concat(f.join("&"))}var Ml=typeof document<"u";function OD(t){var{url:e,id:n,nonce:r}=t;return Ml?new Promise(function(i,a){var l=document.getElementById(n),c=window;if(l){var d=l.getAttribute("data-state");if(l.src===e&&d!=="error"){if(d==="ready")return i(n);var h=c.initMap,f=l.onerror;c.initMap=function(){h&&h(),i(n)},l.onerror=function(g){f&&f(g),a(g)};return}else l.remove()}var p=document.createElement("script");p.type="text/javascript",p.src=e,p.id=n,p.async=!0,p.nonce=r||"",p.onerror=function(v){p.setAttribute("data-state","error"),a(v)},c.initMap=function(){p.setAttribute("data-state","ready"),i(n)},document.head.appendChild(p)}).catch(s=>{throw console.error("injectScript error: ",s),s}):Promise.reject(new Error("document is undefined"))}function CS(t){var e=t.href;return e&&(e.indexOf("https://fonts.googleapis.com/css?family=Roboto")===0||e.indexOf("https://fonts.googleapis.com/css?family=Google+Sans+Text")===0)?!0:t.tagName.toLowerCase()==="style"&&t.styleSheet&&t.styleSheet.cssText&&t.styleSheet.cssText.replace(`\r 3513`,"").indexOf(".gm-style")===0?(t.styleSheet.cssText="",!0):t.tagName.toLowerCase()==="style"&&t.innerHTML&&t.innerHTML.replace(`\r 3514`,"").indexOf(".gm-style")===0?(t.innerHTML="",!0):t.tagName.toLowerCase()==="style"&&!t.styleSheet&&!t.innerHTML}function FD(){var t=document.getElementsByTagName("head")[0];if(t){var e=t.insertBefore.bind(t);t.insertBefore=function(s,i){return CS(s)||Reflect.apply(e,t,[s,i]),s};var n=t.appendChild.bind(t);t.appendChild=function(s){return CS(s)||Reflect.apply(n,t,[s]),s}}}var Wd=!1;function zD(){return o.jsx("div",{children:"Loading..."})}var ub={id:"script-loader",version:"weekly"};class $D extends u.PureComponent{constructor(){super(...arguments),ce(this,"check",null),ce(this,"state",{loaded:!1}),ce(this,"cleanupCallback",()=>{delete window.google.maps,this.injectScript()}),ce(this,"isCleaningUp",LD(function*(){function e(n){if(!Wd)n();else if(Ml)var r=window.setInterval(function(){Wd||(window.clearInterval(r),n())},1)}return new Promise(e)})),ce(this,"cleanup",()=>{Wd=!0;var e=document.getElementById(this.props.id);e&&e.parentNode&&e.parentNode.removeChild(e),Array.prototype.slice.call(document.getElementsByTagName("script")).filter(function(r){return typeof r.src=="string"&&r.src.includes("maps.googleapis")}
3514).forEach(function(r){r.parentNode&&r.parentNode.removeChild(r)}),Array.prototype.slice.call(document.getElementsByTagName("link")).filter(function(r){return r.href==="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Google+Sans"}).forEach(function(r){r.parentNode&&r.parentNode.removeChild(r)}),Array.prototype.slice.call(document.getElementsByTagName("style")).filter(function(r){return r.innerText!==void 0&&r.innerText.length>0&&r.innerText.includes(".gm-")}).forEach(function(r){r.parentNode&&r.parentNode.removeChild(r)})}),ce(this,"injectScript",()=>{this.props.preventGoogleFontsLoading&&FD(),tr(!!this.props.id,'LoadScript requires "id" prop to be a string: %s',this.props.id);var e={id:this.props.id,nonce:this.props.nonce,url:MD(this.props)};OD(e).then(()=>{this.props.onLoad&&this.props.onLoad(),this.setState(function(){return{loaded:!0}})}).catch(n=>{this.props.onError&&this.props.onError(n),console.error(` 3515 There has been an Error with loading Google Maps API script, please check that you provided correct google API key (`.concat(this.props.googleMapsApiKey||"-",") or Client ID (").concat(this.props.googleMapsClientId||"-",`) to <LoadScript /> 3516 Otherwise it is a Network issue. 3517 `))})}),ce(this,"getRef",e=>{this.check=e})}componentDidMount(){if(Ml){if(window.google&&window.google.maps&&!Wd){console.error("google api is already presented");return}this.isCleaningUp().then(this.injectScript).catch(function(n){console.error("Error at injecting script after cleaning up: ",n)})}}componentDidUpdate(e){this.props.libraries!==e.libraries&&console.warn("Performance warning! LoadScript has been reloaded unintentionally! You should not pass `libraries` prop as new array. Please keep an array of libraries as static class property for Components and PureComponents, or just a const variable outside of component, or somewhere in config files or ENV variables"),Ml&&e.language!==this.props.language&&(this.cleanup(),this.setState(function(){return{loaded:!1}},this.cleanupCallback))}componentWillUnmount(){if(Ml){this.cleanup();var e=()=>{this.check||(delete window.google,Wd=!1)};window.setTimeout(e,1),this.props.onUnmount&&this.props.onUnmount()}}render(){return o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:this.getRef}),this.state.loaded?this.props.children:this.props.loadingElement||o.jsx(zD,{})]})}}ce($D,"defaultProps",ub);function tq(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.includes(r))continue;n[r]=t[r]}return n}function YC(t,e){if(t==null)return{};var n,r,s=tq(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)n=i[r],e.includes(n)||{}.propertyIsEnumerable.call(t,n)&&(s[n]=t[n])}return s}var NS;function nq(t){var{id:e=ub.id,version:n=ub.version,nonce:r,googleMapsApiKey:s,googleMapsClientId:i,language:a,region:l,libraries:c,preventGoogleFontsLoading:d,channel:h,mapIds:f,authReferrerPolicy:p,apiUrl:g="https://maps.googleapis.com"}=t,v=u.useRef(!1),[x,y]=u.useState(!1),[b,w]=u.useState(void 0);u.useEffect(function(){return v.current=!0,()=>{v.current=!1}},[]),u.useEffect(function(){Ml&&d&&FD()},[d]),u.useEffect(function(){x&&tr(!!window.google,"useLoadScript was marked as loaded, but window.google is not present. Something went wrong.")},[x]);var j=MD({version:n,googleMapsApiKey:s,googleMapsClientId:i,language:a,region:l,libraries:c,channel:h,mapIds:f,authReferrerPolicy:p,apiUrl:g});u.useEffect(function(){if(!Ml)return;function A(){v.current&&(y(!0),NS=j)}if(window.google&&window.google.maps&&NS===j){A();return}OD({id:e,url:j,nonce:r}).then(A).catch(function(_){v.current&&w(_),console.warn(` 3518 There has been an Error with loading Google Maps API script, please check that you provided correct google API key (`.concat(s||"-",") or Client ID (").concat(i||"-",`) 3519 Otherwise it is a Network issue. 3520 `)),console.error(_)})},[e,j,r]);var E=u.useRef(void 0);return u.useEffect(function(){E.current&&c!==E.current&&console.warn("Performance warning! LoadScript has been reloaded unintentionally! You should not pass `libraries` prop as new array. Please keep an array of libraries as
3520static class property for Components and PureComponents, or just a const variable outside of component, or somewhere in config files or ENV variables"),E.current=c},[c]),{isLoaded:x,loadError:b,url:j}}var rq=["loadingElement","onLoad","onError","onUnmount","children"],sq=o.jsx(zD,{});function oq(t){var{loadingElement:e,onLoad:n,onError:r,onUnmount:s,children:i}=t,a=YC(t,rq),{isLoaded:l,loadError:c}=nq(a);return u.useEffect(function(){l&&typeof n=="function"&&n()},[l,n]),u.useEffect(function(){c&&typeof r=="function"&&r(c)},[c,r]),u.useEffect(function(){return()=>{s&&s()}},[s]),l?i:e||sq}u.memo(oq);var _S;(function(t){t[t.INITIALIZED=0]="INITIALIZED",t[t.LOADING=1]="LOADING",t[t.SUCCESS=2]="SUCCESS",t[t.FAILURE=3]="FAILURE"})(_S||(_S={}));function ES(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function Gg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ES(Object(n),!0).forEach(function(r){ce(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ES(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var SS={},kS={options(t,e){t.setOptions(e)}};function iq(t){var{options:e,onLoad:n,onUnmount:r}=t,s=u.useContext(ut),[i,a]=u.useState(null);return u.useEffect(()=>{i!==null&&i.setMap(s)},[s]),u.useEffect(()=>{e&&i!==null&&i.setOptions(e)},[i,e]),u.useEffect(()=>{var l=new google.maps.TrafficLayer(Gg(Gg({},e),{},{map:s}));return a(l),n&&n(l),()=>{i!==null&&(r&&r(i),i.setMap(null))}},[]),null}u.memo(iq);class aq extends u.PureComponent{constructor(){super(...arguments),ce(this,"state",{trafficLayer:null}),ce(this,"setTrafficLayerCallback",()=>{this.state.trafficLayer!==null&&this.props.onLoad&&this.props.onLoad(this.state.trafficLayer)}),ce(this,"registeredEvents",[])}componentDidMount(){var e=new google.maps.TrafficLayer(Gg(Gg({},this.props.options),{},{map:this.context}));this.registeredEvents=gt({updaterMap:kS,eventMap:SS,prevProps:{},nextProps:this.props,instance:e}),this.setState(function(){return{trafficLayer:e}},this.setTrafficLayerCallback)}componentDidUpdate(e){this.state.trafficLayer!==null&&(yt(this.registeredEvents),this.registeredEvents=gt({updaterMap:kS,eventMap:SS,prevProps:e,nextProps:this.props,instance:this.state.trafficLayer}))}componentWillUnmount(){this.state.trafficLayer!==null&&(this.props.onUnmount&&this.props.onUnmount(this.state.trafficLayer),yt(this.registeredEvents),this.state.trafficLayer.setMap(null))}render(){return null}}ce(aq,"contextType",ut);function lq(t){var{onLoad:e,onUnmount:n}=t,r=u.useContext(ut),[s,i]=u.useState(null);return u.useEffect(()=>{s!==null&&s.setMap(r)},[r]),u.useEffect(()=>{var a=new google.maps.BicyclingLayer;return i(a),a.setMap(r),e&&e(a),()=>{a!==null&&(n&&n(a),a.setMap(null))}},[]),null}u.memo(lq);class cq extends u.PureComponent{constructor(){super(...arguments),ce(this,"state",{bicyclingLayer:null}),ce(this,"setBicyclingLayerCallback",()=>{this.state.bicyclingLayer!==null&&(this.state.bicyclingLayer.setMap(this.context),this.props.onLoad&&this.props.onLoad(this.state.bicyclingLayer))})}componentDidMount(){var e=new google.maps.BicyclingLayer;this.setState(()=>({bicyclingLayer:e}),this.setBicyclingLayerCallback)}componentWillUnmount(){this.state.bicyclingLayer!==null&&(this.props.onUnmount&&this.props.onUnmount(this.state.bicyclingLayer),this.state.bicyclingLayer.setMap(null))}render(){return null}}ce(cq,"contextType",ut);function uq(t){var{onLoad:e,onUnmount:n}=t,r=u.useContext(ut),[s,i]=u.useState(null);return u.useEffect(()=>{s!==null&&s.setMap(r)},[r]),u.useEffect(()=>{var a=new google.maps.TransitLayer;return i(a),a.setMap(r),e&&e(a),()=>{s!==null&&(n&&n(s),s.setMap(null))}},[]),null}u.memo(uq);class dq extends u.PureComponent{constructor(){super(...arguments),ce(this,"state",{transitLayer:null}),ce(this,"setTransitLayerCallback",()=>{this.state.transitLayer!==null&&(this.state.transitLayer.setMap(this.context),this.props.onLoad&&this.props.onLoad(this.state.transitLayer))})}componentDidMount(){var e=new google.maps.TransitLayer;this.setState(function(){return{transitLayer:e}},this.setTransitLayerCallback)}componentWillUnmount(){this.state.transitLayer!==null&&(this.props.onUnmount&&this.props.onUnmount(this.state.transitLayer),this.state.transitLayer.setMap(null))}render(){return null}}ce(dq,"contextType",ut);function PS(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function Zg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};
3520e%2?PS(Object(n),!0).forEach(function(r){ce(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):PS(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var IS={onCircleComplete:"circlecomplete",onMarkerComplete:"markercomplete",onOverlayComplete:"overlaycomplete",onPolygonComplete:"polygoncomplete",onPolylineComplete:"polylinecomplete",onRectangleComplete:"rectanglecomplete"},TS={drawingMode(t,e){t.setDrawingMode(e)},options(t,e){t.setOptions(e)}};function hq(t){var{options:e,drawingMode:n,onCircleComplete:r,onMarkerComplete:s,onOverlayComplete:i,onPolygonComplete:a,onPolylineComplete:l,onRectangleComplete:c,onLoad:d,onUnmount:h}=t,f=u.useContext(ut),[p,g]=u.useState(null),[v,x]=u.useState(null),[y,b]=u.useState(null),[w,j]=u.useState(null),[E,P]=u.useState(null),[A,N]=u.useState(null),[_,k]=u.useState(null);return u.useEffect(()=>{p!==null&&p.setMap(f)},[f]),u.useEffect(()=>{e&&p!==null&&p.setOptions(e)},[p,e]),u.useEffect(()=>{p!==null&&p.setDrawingMode(n??null)},[p,n]),u.useEffect(()=>{p&&r&&(v!==null&&google.maps.event.removeListener(v),x(google.maps.event.addListener(p,"circlecomplete",r)))},[p,r]),u.useEffect(()=>{p&&s&&(y!==null&&google.maps.event.removeListener(y),b(google.maps.event.addListener(p,"markercomplete",s)))},[p,s]),u.useEffect(()=>{p&&i&&(w!==null&&google.maps.event.removeListener(w),j(google.maps.event.addListener(p,"overlaycomplete",i)))},[p,i]),u.useEffect(()=>{p&&a&&(E!==null&&google.maps.event.removeListener(E),P(google.maps.event.addListener(p,"polygoncomplete",a)))},[p,a]),u.useEffect(()=>{p&&l&&(A!==null&&google.maps.event.removeListener(A),N(google.maps.event.addListener(p,"polylinecomplete",l)))},[p,l]),u.useEffect(()=>{p&&c&&(_!==null&&google.maps.event.removeListener(_),k(google.maps.event.addListener(p,"rectanglecomplete",c)))},[p,c]),u.useEffect(()=>{tr(!!google.maps.drawing,"Did you include prop libraries={['drawing']} in the URL? %s",google.maps.drawing);var L=new google.maps.drawing.DrawingManager(Zg(Zg({},e),{},{map:f}));return n&&L.setDrawingMode(n),r&&x(google.maps.event.addListener(L,"circlecomplete",r)),s&&b(google.maps.event.addListener(L,"markercomplete",s)),i&&j(google.maps.event.addListener(L,"overlaycomplete",i)),a&&P(google.maps.event.addListener(L,"polygoncomplete",a)),l&&N(google.maps.event.addListener(L,"polylinecomplete",l)),c&&k(google.maps.event.addListener(L,"rectanglecomplete",c)),g(L),d&&d(L),()=>{p!==null&&(v&&google.maps.event.removeListener(v),y&&google.maps.event.removeListener(y),w&&google.maps.event.removeListener(w),E&&google.maps.event.removeListener(E),A&&google.maps.event.removeListener(A),_&&google.maps.event.removeListener(_),h&&h(p),p.setMap(null))}},[]),null}u.memo(hq);class fq extends u.PureComponent{constructor(e){super(e),ce(this,"registeredEvents",[]),ce(this,"state",{drawingManager:null}),ce(this,"setDrawingManagerCallback",()=>{this.state.drawingManager!==null&&this.props.onLoad&&this.props.onLoad(this.state.drawingManager)}),tr(!!google.maps.drawing,"Did you include prop libraries={['drawing']} in the URL? %s",google.maps.drawing)}componentDidMount(){var e=new google.maps.drawing.DrawingManager(Zg(Zg({},this.props.options),{},{map:this.context}));this.registeredEvents=gt({updaterMap:TS,eventMap:IS,prevProps:{},nextProps:this.props,instance:e}),this.setState(function(){return{drawingManager:e}},this.setDrawingManagerCallback)}componentDidUpdate(e){this.state.drawingManager!==null&&(yt(this.registeredEvents),this.registeredEvents=gt({updaterMap:TS,eventMap:IS,prevProps:e,nextProps:this.props,instance:this.state.drawingManager}))}componentWillUnmount(){this.state.drawingManager!==null&&(this.props.onUnmount&&this.props.onUnmount(this.state.drawingManager),yt(this.registeredEvents),this.state.drawingManager.setMap(null))}render(){return null}}ce(fq,"contextType",ut);function AS(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function ju(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};
3520e%2?AS(Object(n),!0).forEach(function(r){ce(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):AS(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var RS={onAnimationChanged:"animation_changed",onClick:"click",onClickableChanged:"clickable_changed",onCursorChanged:"cursor_changed",onDblClick:"dblclick",onDrag:"drag",onDragEnd:"dragend",onDraggableChanged:"draggable_changed",onDragStart:"dragstart",onFlatChanged:"flat_changed",onIconChanged:"icon_changed",onMouseDown:"mousedown",onMouseOut:"mouseout",onMouseOver:"mouseover",onMouseUp:"mouseup",onPositionChanged:"position_changed",onRightClick:"rightclick",onShapeChanged:"shape_changed",onTitleChanged:"title_changed",onVisibleChanged:"visible_changed",onZindexChanged:"zindex_changed"},DS={animation(t,e){t.setAnimation(e)},clickable(t,e){t.setClickable(e)},cursor(t,e){t.setCursor(e)},draggable(t,e){t.setDraggable(e)},icon(t,e){t.setIcon(e)},label(t,e){t.setLabel(e)},map(t,e){t.setMap(e)},opacity(t,e){t.setOpacity(e)},options(t,e){t.setOptions(e)},position(t,e){t.setPosition(e)},shape(t,e){t.setShape(e)},title(t,e){t.setTitle(e)},visible(t,e){t.setVisible(e)},zIndex(t,e){t.setZIndex(e)}},Kg={};function mq(t){var{position:e,options:n,clusterer:r,noClustererRedraw:s,children:i,draggable:a,visible:l,animation:c,clickable:d,cursor:h,icon:f,label:p,opacity:g,shape:v,title:x,zIndex:y,onClick:b,onDblClick:w,onDrag:j,onDragEnd:E,onDragStart:P,onMouseOut:A,onMouseOver:N,onMouseUp:_,onMouseDown:k,onRightClick:L,onClickableChanged:I,onCursorChanged:S,onAnimationChanged:T,onDraggableChanged:V,onFlatChanged:$,onIconChanged:H,onPositionChanged:W,onShapeChanged:D,onTitleChanged:F,onVisibleChanged:O,onZindexChanged:Y,onLoad:G,onUnmount:q}=t,re=u.useContext(ut),[U,ee]=u.useState(null),[K,ue]=u.useState(null),[be,le]=u.useState(null),[B,Q]=u.useState(null),[ve,Ae]=u.useState(null),[he,J]=u.useState(null),[je,Ve]=u.useState(null),[Ye,Jt]=u.useState(null),[Ue,rn]=u.useState(null),[vt,me]=u.useState(null),[ot,Se]=u.useState(null),[Te,He]=u.useState(null),[Ut,cn]=u.useState(null),[xn,un]=u.useState(null),[Yt,st]=u.useState(null),[de,ze]=u.useState(null),[Qe,It]=u.useState(null),[se,Re]=u.useState(null),[ae,et]=u.useState(null),[xt,zt]=u.useState(null),[$e,oe]=u.useState(null),[De,$t]=u.useState(null);u.useEffect(()=>{U!==null&&U.setMap(re)},[re]),u.useEffect(()=>{typeof n<"u"&&U!==null&&U.setOptions(n)},[U,n]),u.useEffect(()=>{typeof a<"u"&&U!==null&&U.setDraggable(a)},[U,a]),u.useEffect(()=>{e&&U!==null&&U.setPosition(e)},[U,e]),u.useEffect(()=>{typeof l<"u"&&U!==null&&U.setVisible(l)},[U,l]),u.useEffect(()=>{U==null||U.setAnimation(c)},[U,c]),u.useEffect(()=>{U&&d!==void 0&&U.setClickable(d)},[U,d]),u.useEffect(()=>{U&&h!==void 0&&U.setCursor(h)},[U,h]),u.useEffect(()=>{U&&f!==void 0&&U.setIcon(f)},[U,f]),u.useEffect(()=>{U&&p!==void 0&&U.setLabel(p)},[U,p]),u.useEffect(()=>{U&&g!==void 0&&U.setOpacity(g)},[U,g]),u.useEffect(()=>{U&&v!==void 0&&U.setShape(v)},[U,v]),u.useEffect(()=>{U&&x!==void 0&&U.setTitle(x)},[U,x]),u.useEffect(()=>{U&&y!==void 0&&U.setZIndex(y)},[U,y]),u.useEffect(()=>{U&&w&&(K!==null&&google.maps.event.removeListener(K),ue(google.maps.event.addListener(U,"dblclick",w)))},[w]),u.useEffect(()=>{U&&E&&(be!==null&&google.maps.event.removeListener(be),le(google.maps.event.addListener(U,"dragend",E)))},[E]),u.useEffect(()=>{U&&P&&(B!==null&&google.maps.event.removeListener(B),Q(google.maps.event.addListener(U,"dragstart",P)))},[P]),u.useEffect(()=>{U&&k&&(ve!==null&&google.maps.event.removeListener(ve),Ae(google.maps.event.addListener(U,"mousedown",k)))},[k]),u.useEffect(()=>{U&&A&&(he!==null&&google.maps.event.removeListener(he),J(google.maps.event.addListener(U,"mouseout",A)))},[A]),u.useEffect(()=>{U&&N&&(je!==null&&google.maps.event.removeListener(je),Ve(google.maps.event.addListener(U,"mouseover",N)))},[N]),u.useEffect(()=>{U&&_&&(Ye!==null&&google.maps.event.removeListener(Ye),Jt(google.maps.event.addListener(U,"mouseup",_)))},[_]),u.useEffect(()=>{U&&L&&(Ue!==null&&google.maps.event.removeListener(Ue),rn(google.maps.event.addListener(U,"rightclick",L)))},[L]),u.useEffect(()=>{U&&b&&(vt!==null&&google.maps.event.removeListener(vt),me(google.maps.event.addListener(U,"click",b)))},[b]),u.useEffect(()=>{U&&j&&(ot!==null&&google.maps.event.removeListener(ot),Se(google.maps.event.addListener(U,"drag",j)))},[j]),u.useEffect(()=>{U&&I&&(Te!==null&&google.maps.event.removeListener(Te),He(google.maps.event.addListener(U,"clickable_changed",I)))},[I]),u.useEffect(()=>{U&&S&&(Ut!==null&&google.maps.event.removeListener(Ut),cn(google.maps.event.addListener(U,"cursor_changed",S)))},[S]),u.useEffect(()=>{U&&T&&(xn!==null&&google.maps.event.removeListener(xn),un(google.maps.event.addListener(U,"animation_changed",T)))},[T]),u.useEffect(()=>{U&&V&&(Yt!==null&&google.maps.event.removeListener(Yt),st(google.maps.event.addListener(U,"draggable_changed",V)))},[V]),u.useEffect(()=>{U&&$&&(de!==null&&google.maps.event.removeListener(de),ze(google.maps.event.addListener(U,"flat_changed",$)))},[$]),u.useEffect(()=>{U&&H&&(Qe!==null&&google.maps.event.removeListener(Qe),It(google.maps.event.addListener(U,"icon_changed",H)))},[H]),u.useEffect(()=>{U&&W&&(se!==null&&google.maps.event.removeListener(se),Re(google.maps.event.addListener(U,"position_changed",W)))},[W]),u.useEffect(()=>{U&&D&&(ae!==null&&google.maps.event.removeListener(ae),et(google.maps.event.addListener(U,"shape_changed",D)))},[D]),u.useEffect(()=>{U&&F&&(xt!==null&&google.maps.event.removeListener(xt),zt(google.maps.event.addListener(U,"title_changed",F)))},[F]),u.useEffect(()=>{U&&O&&($e!==null&&google.maps.event.removeListener($e),oe(google.maps.event.addListener(U,"visible_changed",O)))},[O]),u.useEffect(()=>
3520{U&&Y&&(De!==null&&google.maps.event.removeListener(De),$t(google.maps.event.addListener(U,"zindex_changed",Y)))},[Y]),u.useEffect(()=>{var Ct=ju(ju(ju({},n||Kg),r?Kg:{map:re}),{},{position:e}),qe=new google.maps.Marker(Ct);return r?r.addMarker(qe,!!s):qe.setMap(re),e&&qe.setPosition(e),typeof l<"u"&&qe.setVisible(l),typeof a<"u"&&qe.setDraggable(a),typeof d<"u"&&qe.setClickable(d),typeof h=="string"&&qe.setCursor(h),f&&qe.setIcon(f),typeof p<"u"&&qe.setLabel(p),typeof g<"u"&&qe.setOpacity(g),v&&qe.setShape(v),typeof x=="string"&&qe.setTitle(x),typeof y=="number"&&qe.setZIndex(y),w&&ue(google.maps.event.addListener(qe,"dblclick",w)),E&&le(google.maps.event.addListener(qe,"dragend",E)),P&&Q(google.maps.event.addListener(qe,"dragstart",P)),k&&Ae(google.maps.event.addListener(qe,"mousedown",k)),A&&J(google.maps.event.addListener(qe,"mouseout",A)),N&&Ve(google.maps.event.addListener(qe,"mouseover",N)),_&&Jt(google.maps.event.addListener(qe,"mouseup",_)),L&&rn(google.maps.event.addListener(qe,"rightclick",L)),b&&me(google.maps.event.addListener(qe,"click",b)),j&&Se(google.maps.event.addListener(qe,"drag",j)),I&&He(google.maps.event.addListener(qe,"clickable_changed",I)),S&&cn(google.maps.event.addListener(qe,"cursor_changed",S)),T&&un(google.maps.event.addListener(qe,"animation_changed",T)),V&&st(google.maps.event.addListener(qe,"draggable_changed",V)),$&&ze(google.maps.event.addListener(qe,"flat_changed",$)),H&&It(google.maps.event.addListener(qe,"icon_changed",H)),W&&Re(google.maps.event.addListener(qe,"position_changed",W)),D&&et(google.maps.event.addListener(qe,"shape_changed",D)),F&&zt(google.maps.event.addListener(qe,"title_changed",F)),O&&oe(google.maps.event.addListener(qe,"visible_changed",O)),Y&&$t(google.maps.event.addListener(qe,"zindex_changed",Y)),ee(qe),G&&G(qe),()=>{K!==null&&google.maps.event.removeListener(K),be!==null&&google.maps.event.removeListener(be),B!==null&&google.maps.event.removeListener(B),ve!==null&&google.maps.event.removeListener(ve),he!==null&&google.maps.event.removeListener(he),je!==null&&google.maps.event.removeListener(je),Ye!==null&&google.maps.event.removeListener(Ye),Ue!==null&&google.maps.event.removeListener(Ue),vt!==null&&google.maps.event.removeListener(vt),Te!==null&&google.maps.event.removeListener(Te),Ut!==null&&google.maps.event.removeListener(Ut),xn!==null&&google.maps.event.removeListener(xn),Yt!==null&&google.maps.event.removeListener(Yt),de!==null&&google.maps.event.removeListener(de),Qe!==null&&google.maps.event.removeListener(Qe),se!==null&&google.maps.event.removeListener(se),xt!==null&&google.maps.event.removeListener(xt),$e!==null&&google.maps.event.removeListener($e),De!==null&&google.maps.event.removeListener(De),q&&q(qe),r?r.removeMarker(qe,!!s):qe&&qe.setMap(null)}},[]);var En=u.useMemo(()=>i?u.Children.map(i,Ct=>{if(!u.isValidElement(Ct))return Ct;var qe=Ct;return u.cloneElement(qe,{anchor:U})}):null,[i,U]);return o.jsx(o.Fragment,{children:En})||null}u.memo(mq);class ho extends u.PureComponent{constructor(){super(...arguments),ce(this,"registeredEvents",[])}componentDidMount(){var e=this;return LD(function*(){var n=ju(ju(ju({},e.props.options||Kg),e.props.clusterer?Kg:{map:e.context}),{},{position:e.props.position});e.marker=new google.maps.Marker(n),e.props.clusterer?e.props.clusterer.addMarker(e.marker,!!e.props.noClustererRedraw):e.marker.setMap(e.context),e.registeredEvents=gt({updaterMap:DS,eventMap:RS,prevProps:{},nextProps:e.props,instance:e.marker}),e.props.onLoad&&e.props.onLoad(e.marker)})()}componentDidUpdate(e){this.marker&&(yt(this.registeredEvents),this.registeredEvents=gt({updaterMap:DS,eventMap:RS,prevProps:e,nextProps:this.props,instance:this.marker}))}componentWillUnmount(){this.marker&&(this.props.onUnmount&&this.props.onUnmount(this.marker),yt(this.registeredEvents),this.props.clusterer?this.props.clusterer.removeMarker(this.marker,!!this.props.noClustererRedraw):this.marker&&this.marker.setMap(null))}render(){var e=this.props.children?u.Children.map(this.props.children,n=>{if(!u.isValidElement(n))return n;var r=n;return u.cloneElement(r,{anchor:this.marker})}):null;return e||null}}ce(ho,"contextType",ut);var pq=function(){function t(e,n){e.getClusterer().extend(t,google.maps.OverlayView),this.cluster=e,this.clusterClassName=this.cluster.getClusterer().getClusterClass(),this.className=this.clusterClassName,this.styles=n,this.center=void 0,this.div=null,this.sums=null,this.visible=!1,this.boundsChangedListener=null,this.url="",this.height=0,this.width=0,this.anchorText=[0,0],this.anchorIcon=[0,0],this.textColor="black",this.textSize=11,this.textDecoration="none",this.fontWeight="bold",this.fontStyle="normal",this.fontFamily="Arial,sans-serif",this.backgroundPosition="0 0",this.cMouseDownInCluster=null,this.cDraggingMapByCluster=null,this.timeOut=null,this.setMap(e.getMap()),this.onBoundsChanged=this.onBoundsChanged.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onClick=this.onClick.bind(this),this.onMouseOver=this.onMouseOver.bind(this),this.onMouseOut=this.onMouseOut.bind(this),this.onAdd=this.onAdd.bind(this),this.onRemove=this.onRemove.bind(this),this.draw=this.draw.bind(this),this.hide=this.hide.bind(this),this.show=this.show.bind(this),this.useStyle=this.useStyle.bind(this),this.setCenter=this.setCenter.bind(this),this.getPosFromLatLng=this.getPosFromLatLng.bind(this)}return t.prototype.onBoundsChanged=function(){this.cDraggingMapByCluster=this.cMouseDownInCluster},t.prototype.onMouseDown=function(){this.cMouseDownInCluster=!0,this.cDraggingMapByCluster=!1},t.prototype.onClick=function(e){if(this.cMouseDownInCluster=!1,!this.cDraggingMapByCluster){var n=this.cluster.getClusterer();if(google.maps.event.trigger(n,"click",this.cluster),google.maps.event.trigger(n,"clusterclick",this.cluster),n.getZoomOnClick()){var r=n.getMaxZoom(),s=this.cluster.getBounds(),i=n.getMap();i!==null&&"fitBounds"in i&&i.fitBounds(s),this.timeOut=window.setTimeout(function(){var a=n.getMap();if(a!==null){"fitBounds"in a&&a.fitBounds(s);var l=a.getZoom()||0;r!==null&&l>
3520r&&a.setZoom(r+1)}},100)}e.cancelBubble=!0,e.stopPropagation&&e.stopPropagation()}},t.prototype.onMouseOver=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseover",this.cluster)},t.prototype.onMouseOut=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseout",this.cluster)},t.prototype.onAdd=function(){var e;this.div=document.createElement("div"),this.div.className=this.className,this.visible&&this.show(),(e=this.getPanes())===null||e===void 0||e.overlayMouseTarget.appendChild(this.div);var n=this.getMap();n!==null&&(this.boundsChangedListener=google.maps.event.addListener(n,"bounds_changed",this.onBoundsChanged),this.div.addEventListener("mousedown",this.onMouseDown),this.div.addEventListener("click",this.onClick),this.div.addEventListener("mouseover",this.onMouseOver),this.div.addEventListener("mouseout",this.onMouseOut))},t.prototype.onRemove=function(){this.div&&this.div.parentNode&&(this.hide(),this.boundsChangedListener!==null&&google.maps.event.removeListener(this.boundsChangedListener),this.div.removeEventListener("mousedown",this.onMouseDown),this.div.removeEventListener("click",this.onClick),this.div.removeEventListener("mouseover",this.onMouseOver),this.div.removeEventListener("mouseout",this.onMouseOut),this.div.parentNode.removeChild(this.div),this.timeOut!==null&&(window.clearTimeout(this.timeOut),this.timeOut=null),this.div=null)},t.prototype.draw=function(){if(this.visible&&this.div!==null&&this.center){var e=this.getPosFromLatLng(this.center);this.div.style.top=e!==null?"".concat(e.y,"px"):"0",this.div.style.left=e!==null?"".concat(e.x,"px"):"0"}},t.prototype.hide=function(){this.div&&(this.div.style.display="none"),this.visible=!1},t.prototype.show=function(){var e,n,r,s,i,a;if(this.div&&this.center){var l=this.sums===null||typeof this.sums.title>"u"||this.sums.title===""?this.cluster.getClusterer().getTitle():this.sums.title,c=this.backgroundPosition.split(" "),d=parseInt(((e=c[0])===null||e===void 0?void 0:e.replace(/^\s+|\s+$/g,""))||"0",10),h=parseInt(((n=c[1])===null||n===void 0?void 0:n.replace(/^\s+|\s+$/g,""))||"0",10),f=this.getPosFromLatLng(this.center);this.div.className=this.className,this.div.setAttribute("style","cursor: pointer; position: absolute; top: ".concat(f!==null?"".concat(f.y,"px"):"0","; left: ").concat(f!==null?"".concat(f.x,"px"):"0","; width: ").concat(this.width,"px; height: ").concat(this.height,"px; "));var p=document.createElement("img");p.alt=l,p.src=this.url,p.width=this.width,p.height=this.height,p.setAttribute("style","position: absolute; top: ".concat(h,"px; left: ").concat(d,"px")),this.cluster.getClusterer().enableRetinaIcons||(p.style.clip="rect(-".concat(h,"px, -").concat(d+this.width,"px, -").concat(h+this.height,", -").concat(d,")"));var g=document.createElement("div");g.setAttribute("style","position: absolute; top: ".concat(this.anchorText[0],"px; left: ").concat(this.anchorText[1],"px; color: ").concat(this.textColor,"; font-size: ").concat(this.textSize,"px; font-family: ").concat(this.fontFamily,"; font-weight: ").concat(this.fontWeight,"; fontStyle: ").concat(this.fontStyle,"; text-decoration: ").concat(this.textDecoration,"; text-align: center; width: ").concat(this.width,"px; line-height: ").concat(this.height,"px")),!((r=this.sums)===null||r===void 0)&&r.text&&(g.innerText="".concat((s=this.sums)===null||s===void 0?void 0:s.text)),!((i=this.sums)===null||i===void 0)&&i.html&&(g.innerHTML="".concat((a=this.sums)===null||a===void 0?void 0:a.html)),this.div.innerHTML="",this.div.appendChild(p),this.div.appendChild(g),this.div.title=l,this.div.style.display=""}this.visible=!0},t.prototype.useStyle=function(e){this.sums=e;var n=this.cluster.getClusterer().getStyles(),r=n[Math.min(n.length-1,Math.max(0,e.index-1))];r&&(this.url=r.url,this.height=r.height,this.width=r.width,r.className&&(this.className="".concat(this.clusterClassName," ").concat(r.className)),this.anchorText=r.anchorText||[0,0],this.anchorIcon=r.anchorIcon||[this.height/2,this.width/2],this.textColor=r.textColor||"black",this.textSize=r.textSize||11,this.textDecoration=r.textDecoration||"none",this.fontWeight=r.fontWeight||"bold",this.fontStyle=r.fontStyle||"normal",this.fontFamily=r.fontFamily||"Arial,sans-serif",this.backgroundPosition=r.backgroundPosition||"0 0")},t.prototype.setCenter=function(e){this.center=e},t.prototype.getPosFromLatLng=function(e){var n=this.getProjection().fromLatLngToDivPixel(e);return n!==null&&(n.x-=this.anchorIcon[1],n.y-=this.anchorIcon[0]),n},t}(),gq=function(){function t(e){this.markerClusterer=e,this.map=this.markerClusterer.getMap(),this.gridSize=this.markerClusterer.getGridSize(),this.minClusterSize=this.markerClusterer.getMinimumClusterSize(),this.averageCenter=this.markerClusterer.getAverageCenter(),this.markers=[],this.center=void 0,this.bounds=null,this.clusterIcon=new pq(this,this.markerClusterer.getStyles()),this.get
3520Size=this.getSize.bind(this),this.getMarkers=this.getMarkers.bind(this),this.getCenter=this.getCenter.bind(this),this.getMap=this.getMap.bind(this),this.getClusterer=this.getClusterer.bind(this),this.getBounds=this.getBounds.bind(this),this.remove=this.remove.bind(this),this.addMarker=this.addMarker.bind(this),this.isMarkerInClusterBounds=this.isMarkerInClusterBounds.bind(this),this.calculateBounds=this.calculateBounds.bind(this),this.updateIcon=this.updateIcon.bind(this),this.isMarkerAlreadyAdded=this.isMarkerAlreadyAdded.bind(this)}return t.prototype.getSize=function(){return this.markers.length},t.prototype.getMarkers=function(){return this.markers},t.prototype.getCenter=function(){return this.center},t.prototype.getMap=function(){return this.map},t.prototype.getClusterer=function(){return this.markerClusterer},t.prototype.getBounds=function(){for(var e=new google.maps.LatLngBounds(this.center,this.center),n=this.getMarkers(),r=0,s=n;r<s.length;r++){var i=s[r],a=i.getPosition();a&&e.extend(a)}return e},t.prototype.remove=function(){this.clusterIcon.setMap(null),this.markers=[],delete this.markers},t.prototype.addMarker=function(e){var n;if(this.isMarkerAlreadyAdded(e))return!1;if(this.center){if(this.averageCenter){var r=e.getPosition();if(r){var s=this.markers.length+1;this.center=new google.maps.LatLng((this.center.lat()*(s-1)+r.lat())/s,(this.center.lng()*(s-1)+r.lng())/s),this.calculateBounds()}}}else{var r=e.getPosition();r&&(this.center=r,this.calculateBounds())}e.isAdded=!0,this.markers.push(e);var i=this.markers.length,a=this.markerClusterer.getMaxZoom(),l=(n=this.map)===null||n===void 0?void 0:n.getZoom();if(a!==null&&typeof l<"u"&&l>a)e.getMap()!==this.map&&e.setMap(this.map);else if(i<this.minClusterSize)e.getMap()!==this.map&&e.setMap(this.map);else if(i===this.minClusterSize)for(var c=0,d=this.markers;c<d.length;c++){var h=d[c];h.setMap(null)}else e.setMap(null);return!0},t.prototype.isMarkerInClusterBounds=function(e){if(this.bounds!==null){var n=e.getPosition();if(n)return this.bounds.contains(n)}return!1},t.prototype.calculateBounds=function(){this.bounds=this.markerClusterer.getExtendedBounds(new google.maps.LatLngBounds(this.center,this.center))},t.prototype.updateIcon=function(){var e,n=this.markers.length,r=this.markerClusterer.getMaxZoom(),s=(e=this.map)===null||e===void 0?void 0:e.getZoom();if(r!==null&&typeof s<"u"&&s>r){this.clusterIcon.hide();return}if(n<this.minClusterSize){this.clusterIcon.hide();return}this.center&&this.clusterIcon.setCenter(this.center),this.clusterIcon.useStyle(this.markerClusterer.getCalculator()(this.markers,this.markerClusterer.getStyles().length)),this.clusterIcon.show()},t.prototype.isMarkerAlreadyAdded=function(e){if(this.markers.includes)return this.markers.includes(e);for(var n=0;n<this.markers.length;n++)if(e===this.markers[n])return!0;return!1},t}();function vq(t,e){var n=t.length,r=n.toString().length,s=Math.min(r,e);return{text:n.toString(),index:s,title:""}}var xq=2e3,yq=500,wq="https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m",bq="png",jq=[53,56,66,78,90],Cq="cluster",VD=function(){function t(e,n,r){n===void 0&&(n=[]),r===void 0&&(r={}),this.getMinimumClusterSize=this.getMinimumClusterSize.bind(this),this.setMinimumClusterSize=this.setMinimumClusterSize.bind(this),this.getEnableRetinaIcons=this.getEnableRetinaIcons.bind(this),this.setEnableRetinaIcons=this.setEnableRetinaIcons.bind(this),this.addToClosestCluster=this.addToClosestCluster.bind(this),this.getImageExtension=this.getImageExtension.bind(this),this.setImageExtension=this.setImageExtension.bind(this),this.getExtendedBounds=this.getExtendedBounds.bind(this),this.getAverageCenter=this.getAverageCenter.bind(this),this.setAverageCenter=this.setAverageCenter.bind(this),this.getTotalClusters=this.getTotalClusters.bind(this),this.fitMapToMarkers=this.fitMapToMarkers.bind(this),this.getIgnoreHidden=this.getIgnoreHidden.bind(this),this.setIgnoreHidden=this.setIgnoreHidden.bind(this),this.getClusterClass=this.getClusterClass.bind(this),this.setClusterClass=this.setClusterClass.bind(this),this.getTotalMarkers=this.getTotalMarkers.bind(this),this.getZoomOnClick=this.getZoomOnClick.bind(this),this.setZoomOnClick=this.setZoomOnClick.bind(this),this.getBatchSizeIE=this.getBatchSizeIE.bind(this),this.setBatchSizeIE=this.setBatchSizeIE.bind(this),this.createCluster
3520s=this.createClusters.bind(this),this.onZoomChanged=this.onZoomChanged.bind(this),this.getImageSizes=this.getImageSizes.bind(this),this.setImageSizes=this.setImageSizes.bind(this),this.getCalculator=this.getCalculator.bind(this),this.setCalculator=this.setCalculator.bind(this),this.removeMarkers=this.removeMarkers.bind(this),this.resetViewport=this.resetViewport.bind(this),this.getImagePath=this.getImagePath.bind(this),this.setImagePath=this.setImagePath.bind(this),this.pushMarkerTo=this.pushMarkerTo.bind(this),this.removeMarker=this.removeMarker.bind(this),this.clearMarkers=this.clearMarkers.bind(this),this.setupStyles=this.setupStyles.bind(this),this.getGridSize=this.getGridSize.bind(this),this.setGridSize=this.setGridSize.bind(this),this.getClusters=this.getClusters.bind(this),this.getMaxZoom=this.getMaxZoom.bind(this),this.setMaxZoom=this.setMaxZoom.bind(this),this.getMarkers=this.getMarkers.bind(this),this.addMarkers=this.addMarkers.bind(this),this.getStyles=this.getStyles.bind(this),this.setStyles=this.setStyles.bind(this),this.addMarker=this.addMarker.bind(this),this.onRemove=this.onRemove.bind(this),this.getTitle=this.getTitle.bind(this),this.setTitle=this.setTitle.bind(this),this.repaint=this.repaint.bind(this),this.onIdle=this.onIdle.bind(this),this.redraw=this.redraw.bind(this),this.onAdd=this.onAdd.bind(this),this.draw=this.draw.bind(this),this.extend=this.extend.bind(this),this.extend(t,google.maps.OverlayView),this.markers=[],this.clusters=[],this.listeners=[],this.activeMap=null,this.ready=!1,this.gridSize=r.gridSize||60,this.minClusterSize=r.minimumClusterSize||2,this.maxZoom=r.maxZoom||null,this.styles=r.styles||[],this.title=r.title||"",this.zoomOnClick=!0,r.zoomOnClick!==void 0&&(this.zoomOnClick=r.zoomOnClick),this.averageCenter=!1,r.averageCenter!==void 0&&(this.averageCenter=r.averageCenter),this.ignoreHidden=!1,r.ignoreHidden!==void 0&&(this.ignoreHidden=r.ignoreHidden),this.enableRetinaIcons=!1,r.enableRetinaIcons!==void 0&&(this.enableRetinaIcons=r.enableRetinaIcons),this.imagePath=r.imagePath||wq,this.imageExtension=r.imageExtension||bq,this.imageSizes=r.imageSizes||jq,this.calculator=r.calculator||vq,this.batchSize=r.batchSize||xq,this.batchSizeIE=r.batchSizeIE||yq,this.clusterClass=r.clusterClass||Cq,navigator.userAgent.toLowerCase().indexOf("msie")!==-1&&(this.batchSize=this.batchSizeIE),this.timerRefStatic=null,this.setupStyles(),this.addMarkers(n,!0),this.setMap(e)}return t.prototype.onZoomChanged=function(){var e,n;this.resetViewport(!1),(((e=this.getMap())===null||e===void 0?void 0:e.getZoom())===(this.get("minZoom")||0)||((n=this.getMap())===null||n===void 0?void 0:n.getZoom())===this.get("maxZoom"))&&google.maps.event.trigger(this,"idle")},t.prototype.onIdle=function(){this.redraw()},t.prototype.onAdd=function(){var e=this.getMap();this.activeMap=e,this.ready=!0,this.repaint(),e!==null&&(this.listeners=[google.maps.event.addListener(e,"zoom_changed",this.onZoomChanged),google.maps.event.addListener(e,"idle",this.onIdle)])},t.prototype.onRemove=function(){for(var e=0,n=this.markers;e<n.length;e++){var r=n[e];r.getMap()!==this.activeMap&&r.setMap(this.activeMap)}
3520for(var s=0,i=this.clusters;s<i.length;s++){var a=i[s];a.remove()}this.clusters=[];for(var l=0,c=this.listeners;l<c.length;l++){var d=c[l];google.maps.event.removeListener(d)}this.listeners=[],this.activeMap=null,this.ready=!1},t.prototype.draw=function(){},t.prototype.getMap=function(){return null},t.prototype.getPanes=function(){return null},t.prototype.getProjection=function(){return{fromContainerPixelToLatLng:function(){return null},fromDivPixelToLatLng:function(){return null},fromLatLngToContainerPixel:function(){return null},fromLatLngToDivPixel:function(){return null},getVisibleRegion:function(){return null},getWorldWidth:function(){return 0}}},t.prototype.setMap=function(){},t.prototype.addListener=function(){return{remove:function(){}}},t.prototype.bindTo=function(){},t.prototype.get=function(){},t.prototype.notify=function(){},t.prototype.set=function(){},t.prototype.setValues=function(){},t.prototype.unbind=function(){},t.prototype.unbindAll=function(){},t.prototype.setupStyles=function(){if(!(this.styles.length>0))for(var e=0;e<this.imageSizes.length;e++)this.styles.push({url:"".concat(this.imagePath+(e+1),".").concat(this.imageExtension),height:this.imageSizes[e]||0,width:this.imageSizes[e]||0})},t.prototype.fitMapToMarkers=function(){for(var e=this.getMarkers(),n=new google.maps.LatLngBounds,r=0,s=e;r<s.length;r++){var i=s[r],a=i.getPosition();a&&n.extend(a)}var l=this.getMap();l!==null&&"fitBounds"in l&&l.fitBounds(n)},t.prototype.getGridSize=function(){return this.gridSize},t.prototype.setGridSize=function(e){this.gridSize=e},t.prototype.getMinimumClusterSize=function(){return this.minClusterSize},t.prototype.setMinimumClusterSize=function(e){this.minClusterSize=e},t.prototype.getMaxZoom=function(){return this.maxZoom},t.prototype.setMaxZoom=function(e){this.maxZoom=e},t.prototype.getStyles=function(){return this.styles},t.prototype.setStyles=function(e){this.styles=e},t.prototype.getTitle=function(){return this.title},t.prototype.setTitle=function(e){this.title=e},t.prototype.getZoomOnClick=function(){return this.zoomOnClick},t.prototype.setZoomOnClick=function(e){this.zoomOnClick=e},t.prototype.getAverageCenter=function(){return this.averageCenter},t.prototype.setAverageCenter=function(e){this.averageCenter=e},t.prototype.getIgnoreHidden=function(){return this.ignoreHidden},t.prototype.setIgnoreHidden=function(e){this.ignoreHidden=e},t.prototype.getEnableRetinaIcons=function(){return this.enableRetinaIcons},t.prototype.setEnableRetinaIcons=function(e){this.enableRetinaIcons=e},t.prototype.getImageExtension=function(){return this.imageExtension},t.prototype.setImageExtension=function(e){this.imageExtension=e},t.prototype.getImagePath=function(){return this.imagePath},t.prototype.setImagePath=function(e){this.imagePath=e},t.prototype.getImageSizes=function(){return this.imageSizes},t.prototype.setImageSizes=function(e){this.imageSizes=e},t.prototype.getCalculator=function(){return this.calculator},t.prototype.setCalculator=function(e){this.calculator=e},t.prototype.getBatchSizeIE=function(){return this.batchSizeIE},t.prototype.setBatchSizeIE=function(e){this.batchSizeIE=e},t.prototype.getClusterClass=function(){return this.clusterClass},t.prototype.setClusterClass=function(e){this.clusterClass=e},t.prototype.getMarkers=function(){return this.markers},t.prototype.getTotalMarkers=function(){return this.markers.length},t.prototype.getClusters=function(){return this.clusters},t.prototype.getTotalClusters=function(){return this.clusters.length},t.prototype.addMarker=function(e,n){this.pushMarkerTo(e),n||this.redraw()},t.prototype.addMarkers=function(e,n){for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var s=e[r];s&&this.pushMarkerTo(s)}n||this.redraw()},t.prototype.pushMarkerTo=function(e){var n=this;e.getDraggable()&&google.maps.event.addListener(e,"dragend",function(){n.ready&&(e.isAdded=!1,n.repaint())}),e.isAdded=!1,this.markers.push(e)},t.prototype.removeMarker_=function(e){var n=-1;if(this.markers.indexOf)n=this.markers.indexOf(e);else for(var r=0;r<this.markers.length;r++)if(e===this.markers[r]){n=r;break}return n===-1?!1:(e.setMap(null),this.markers.splice(n,1),!0)},t.prototype.removeMarker=function(e,n){var r=this.removeMarker_(e);return!n&&r&&this.repaint(),r},t.prototype.removeMarkers=function(e,n){for(var r=!1,s=0,i=e;s<i.length;s++){var a=i[s];r=r||this.removeMarker_(a)}return!n&&r&&this.repaint(),r},t.prototype.clearMarkers=function(){this.resetViewport(!0),this.markers=[]}
3520,t.prototype.repaint=function(){var e=this.clusters.slice();this.clusters=[],this.resetViewport(!1),this.redraw(),setTimeout(function(){for(var r=0,s=e;r<s.length;r++){var i=s[r];i.remove()}},0)},t.prototype.getExtendedBounds=function(e){var n=this.getProjection(),r=n.fromLatLngToDivPixel(new google.maps.LatLng(e.getNorthEast().lat(),e.getNorthEast().lng()));r!==null&&(r.x+=this.gridSize,r.y-=this.gridSize);var s=n.fromLatLngToDivPixel(new google.maps.LatLng(e.getSouthWest().lat(),e.getSouthWest().lng()));if(s!==null&&(s.x-=this.gridSize,s.y+=this.gridSize),r!==null){var i=n.fromDivPixelToLatLng(r);i!==null&&e.extend(i)}if(s!==null){var a=n.fromDivPixelToLatLng(s);a!==null&&e.extend(a)}return e},t.prototype.redraw=function(){this.createClusters(0)},t.prototype.resetViewport=function(e){for(var n=0,r=this.clusters;n<r.length;n++){var s=r[n];s.remove()}this.clusters=[];for(var i=0,a=this.markers;i<a.length;i++){var l=a[i];l.isAdded=!1,e&&l.setMap(null)}},t.prototype.distanceBetweenPoints=function(e,n){var r=6371,s=(n.lat()-e.lat())*Math.PI/180,i=(n.lng()-e.lng())*Math.PI/180,a=Math.sin(s/2)*Math.sin(s/2)+Math.cos(e.lat()*Math.PI/180)*Math.cos(n.lat()*Math.PI/180)*Math.sin(i/2)*Math.sin(i/2);return r*(2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a)))},t.prototype.isMarkerInBounds=function(e,n){var r=e.getPosition();return r?n.contains(r):!1},t.prototype.addToClosestCluster=function(e){for(var n,r=4e4,s=null,i=0,a=this.cluster
3520s;i<a.length;i++){var l=a[i];n=l;var c=n.getCenter(),d=e.getPosition();if(c&&d){var h=this.distanceBetweenPoints(c,d);h<r&&(r=h,s=n)}}s&&s.isMarkerInClusterBounds(e)?s.addMarker(e):(n=new gq(this),n.addMarker(e),this.clusters.push(n))},t.prototype.createClusters=function(e){var n=this;if(this.ready){e===0&&(google.maps.event.trigger(this,"clusteringbegin",this),this.timerRefStatic!==null&&(window.clearTimeout(this.timerRefStatic),delete this.timerRefStatic));for(var r=this.getMap(),s=r!==null&&("getBounds"in r)?r.getBounds():null,i=(r==null?void 0:r.getZoom())||0,a=i>3?new google.maps.LatLngBounds(s==null?void 0:s.getSouthWest(),s==null?void 0:s.getNorthEast()):new google.maps.LatLngBounds(new google.maps.LatLng(85.02070771743472,-178.48388434375),new google.maps.LatLng(-85.08136444384544,178.00048865625)),l=this.getExtendedBounds(a),c=Math.min(e+this.batchSize,this.markers.length),d=e;d<c;d++){var h=this.markers[d];h&&!h.isAdded&&this.isMarkerInBounds(h,l)&&(!this.ignoreHidden||this.ignoreHidden&&h.getVisible())&&this.addToClosestCluster(h)}if(c<this.markers.length)this.timerRefStatic=window.setTimeout(function(){n.createClusters(c)},0);else{this.timerRefStatic=null,google.maps.event.trigger(this,"clusteringend",this);
3520for(var f=0,p=this.clusters;f<p.length;f++){var g=p[f];g.updateIcon()}}}},t.prototype.extend=function(e,n){return(function(s){for(var i in s.prototype){var a=i;this.prototype[a]=s.prototype[a]}return this}).apply(e,[n])},t}();function LS(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function Nq(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?LS(Object(n),!0).forEach(function(r){ce(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):LS(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var Ls={onClick:"click",onClusteringBegin:"clusteringbegin",onClusteringEnd:"clusteringend",onMouseOut:"mouseout",onMouseOver:"mouseover"},Lt={averageCenter(t,e){t.setAverageCenter(e)},batchSizeIE(t,e){t.setBatchSizeIE(e)},calculator(t,e){t.setCalculator(e)},clusterClass(t,e){t.setClusterClass(e)},enableRetinaIcons(t,e){t.setEnableRetinaIcons(e)},gridSize(t,e){t.setGridSize(e)},ignoreHidden(t,e){t.setIgnoreHidden(e)},imageExtension(t,e){t.setImageExtension(e)},imagePath(t,e){t.setImagePath(e)},imageSizes(t,e){t.setImageSizes(e)},maxZoom(t,e){t.setMaxZoom(e)},minimumClusterSize(t,e){t.setMinimumClusterSize(e)},styles(t,e){t.setStyles(e)},title(t,e){t.setTitle(e)},zoomOnClick(t,e){t.setZoomOnClick(e)}},_q={};function Eq(t){var{children:e,options:n,averageCenter:r,batchSizeIE:s,calculator:i,clusterClass:a,enableRetinaIcons:l,gridSize:c,ignoreHidden:d,imageExtension:h,imagePath:f,imageSizes:p,maxZoom:g,minimumClusterSize:v,styles:x,title:y,zoomOnClick:b,onClick:w,onClusteringBegin:j,onClusteringEnd:E,onMouseOver:P,onMouseOut:A,onLoad:N,onUnmount:_}=t,[k,L]=u.useState(null),I=u.useContext(ut),[S,T]=u.useState(null),[V,$]=u.useState(null),[H,W]=u.useState(null),[D,F]=u.useState(null),[O,Y]=u.useState(null);return u.useEffect(()=>{k&&A&&(D!==null&&google.maps.event.removeListener(D),F(google.maps.event.addListener(k,Ls.onMouseOut,A)))},[A]),u.useEffect(()=>{k&&P&&(O!==null&&google.maps.event.removeListener(O),Y(google.maps.event.addListener(k,Ls.onMouseOver,P)))},[P]),u.useEffect(()=>{k&&w&&(S!==null&&google.maps.event.removeListener(S),T(google.maps.event.addListener(k,Ls.onClick,w)))},[w]),u.useEffect(()=>{k&&j&&(V!==null&&google.maps.event.removeListener(V),$(google.maps.event.addListener(k,Ls.onClusteringBegin,j)))},[j]),u.useEffect(()=>{k&&E&&(H!==null&&google.maps.event.removeListener(H),$(google.maps.event.addListener(k,Ls.onClusteringEnd,E)))},[E]),u.useEffect(()=>{typeof r<"u"&&k!==null&&Lt.averageCenter(k,r)},[k,r]),u.useEffect(()=>{typeof s<"u"&&k!==null&&Lt.batchSizeIE(k,s)},[k,s]),u.useEffect(()=>{typeof i<"u"&&k!==null&&Lt.calculator(k,i)},[k,i]),u.useEffect(()=>{typeof a<"u"&&k!==null&&Lt.clusterClass(k,a)},[k,a]),u.useEffect(()=>{typeof l<"u"&&k!==null&&Lt.enableRetinaIcons(k,l)},[k,l]),u.useEffect(()=>{typeof c<"u"&&k!==null&&Lt.gridSize(k,c)},[k,c]),u.useEffect(()=>{typeof d<"u"&&k!==null&&Lt.ignoreHidden(k,d)},[k,d]),u.useEffect(()=>{typeof h<"u"&&k!==null&&Lt.imageExtension(k,h)},[k,h]),u.useEffect(()=>{typeof f<"u"&&k!==null&&Lt.imagePath(k,f)},[k,f]),u.useEffect(()=>{typeof p<"u"&&k!==null&&Lt.imageSizes(k,p)},[k,p]),u.useEffect(()=>{typeof g<"u"&&k!==null&&Lt.maxZoom(k,g)},[k,g]),u.useEffect(()=>{typeof v<"u"&&k!==null&&Lt.minimumClusterSize(k,v)},[k,v]),u.useEffect(()=>{typeof x<"u"&&k!==null&&Lt.styles(k,x)},[k,x]),u.useEffect(()=>{typeof y<"u"&&k!==null&&Lt.title(k,y)},[k,y]),u.useEffect(()=>{typeof b<"u"&&k!==null&&Lt.zoomOnClick(k,b)},[k,b]),u.useEffect(()=>{if(I){var G=Nq({},n||_q),q=new VD(I,[],G);return r&&Lt.averageCenter(q,r),s&&Lt.batchSizeIE(q,s),i&&Lt.calculator(q,i),a&&Lt.clusterClass(q,a),l&&Lt.enableRetinaIcons(q,l),c&&Lt.gridSize(q,c),d&&Lt.ignoreHidden(q,d),h&&Lt.imageExtension(q,h),f&&Lt.imagePath(q,f),p&&Lt.imageSizes(q,p),g&&Lt.maxZoom(q,g),v&&Lt.minimumClusterSize(q,v),x&&Lt.styles(q,x),y&&Lt.title(q,y),b&&Lt.zoomOnClick(q,b),A&&F(google.maps.event.addListener(q,Ls.onMouseOut,A)),P&&Y(google.maps.event.addListener(q,Ls.onMouseOver,P)),w&&T(google.maps.event.addListener(q,Ls.onClick,w)),j&&$(google.maps.event.addListener(q,Ls.onClusteringBegin,j)),E&&W(google.maps.event.addListener(q,Ls.onClusteringEnd,E)),L(q),N&&N(q),()=>
3520{D!==null&&google.maps.event.removeListener(D),O!==null&&google.maps.event.removeListener(O),S!==null&&google.maps.event.removeListener(S),V!==null&&google.maps.event.removeListener(V),H!==null&&google.maps.event.removeListener(H),_&&_(q)}}},[]),k!==null&&e(k)||null}u.memo(Eq);class Sq extends u.PureComponent{constructor(){super(...arguments),ce(this,"registeredEvents",[]),ce(this,"state",{markerClusterer:null}),ce(this,"setClustererCallback",()=>{this.state.markerClusterer!==null&&this.props.onLoad&&this.props.onLoad(this.state.markerClusterer)})}componentDidMount(){if(this.context){var e=new VD(this.context,[],this.props.options);this.registeredEvents=gt({updaterMap:Lt,eventMap:Ls,prevProps:{},nextProps:this.props,instance:e}),this.setState(()=>({markerClusterer:e}),this.setClustererCallback)}}componentDidUpdate(e){this.state.markerClusterer&&(yt(this.registeredEvents),this.registeredEvents=gt({updaterMap:Lt,eventMap:Ls,prevProps:e,nextProps:this.props,instance:this.state.markerClusterer}))}componentWillUnmount(){this.state.markerClusterer!==null&&(this.props.onUnmount&&this.props.onUnmount(this.state.markerClusterer),yt(this.registeredEvents),this.state.markerClusterer.setMap(null))}render(){return this.state.markerClusterer!==null?this.props.children(this.state.markerClusterer):null}}ce(Sq,"contextType",ut);function MS(t){t.cancelBubble=!0,t.stopPropagation&&t.stopPropagation()}var UD=function(){function t(e){e===void 0&&(e={}),this.getCloseClickHandler=this.getCloseClickHandler.bind(this),this.closeClickHandler=this.closeClickHandler.bind(this),this.createInfoBoxDiv=this.createInfoBoxDiv.bind(this),this.addClickHandler=this.addClickHandler.bind(this),this.getCloseBoxImg=this.getCloseBoxImg.bind(this),this.getBoxWidths=this.getBoxWidths.bind(this),this.setBoxStyle=this.setBoxStyle.bind(this),this.setPosition=this.setPosition.bind(this),this.getPosition=this.getPosition.bind(this),this.setOptions=this.setOptions.bind(this),this.setContent=this.setContent.bind(this),this.setVisible=this.setVisible.bind(this),this.getContent=this.getContent.bind(this),this.getVisible=this.getVisible.bind(this),this.setZIndex=this.setZIndex.bind(this),this.getZIndex=this.getZIndex.bind(this),this.onRemove=this.onRemove.bind(this),this.panBox=this.panBox.bind(this),this.extend=this.extend.bind(this),this.close=this.close.bind(this),this.draw=this.draw.bind(this),this.show=this.show.bind(this),this.hide=this.hide.bind(this),this.open=this.open.bind(this),this.extend(t,google.maps.OverlayView),this.content=e.content||"",this.disableAutoPan=e.disableAutoPan||!1,this.maxWidth=e.maxWidth||0,this.pixelOffset=e.pixelOffset||new google.maps.Size(0,0),this.position=e.position||new google.maps.LatLng(0,0),this.zIndex=e.zIndex||null,this.boxClass=e.boxClass||"infoBox",this.boxStyle=e.boxStyle||{},this.closeBoxMargin=e.closeBoxMargin||"2px",this.closeBoxURL=e.closeBoxURL||"http://www.google.com/intl/en_us/mapfiles/close.gif",e.closeBoxURL===""&&(this.closeBoxURL=""),this.infoBoxClearance=e.infoBoxClearance||new google.maps.Size(1,1),typeof e.visible>"u"&&(typeof e.isHidden>"u"?e.visible=!0:e.visible=!e.isHidden),this.isHidden=!e.visible,this.alignBottom=e.alignBottom||!1,this.pane=e.pane||"floatPane",this.enableEventPropagation=e.enableEventPropagation||!1,this.div=null,this.closeListener=null,this.moveListener=null,this.mapListener=null,this.contextListener=null,this.eventListeners=null,this.fixedWidthSet=null}return t.prototype.createInfoBoxDiv=function(){var e=this,n=function(h){h.returnValue=!1,h.preventDefault&&h.preventDefault(),e.enableEventPropagation||MS(h)};if(!this.div){this.div=document.createElement("div"),this.setBoxStyle(),typeof this.content=="string"?this.div.innerHTML=this.getCloseBoxImg()+this.content:(this.div.innerHTML=this.getCloseBoxImg(),this.div.appendChild(this.content));var r=this.getPanes();if(r!==null&&r[this.pane].appendChild(this.div),this.addClickHandler(),this.div.style.width)this.fixedWidthSet=!0;else if(this.maxWidth!==0&&this.div.offsetWidth>this.maxWidth)this.div.style.width=this.maxWidth+"px",this.fixedWidthSet=!0;else{var s=this.getBoxWidths();this.div.style.width=this.div.offsetWidth-s.left-s.right+"px",this.fixedWidthSet=!1}if(this.panBox(this.disableAutoPan),!this.enableEventPropagation){this.eventListeners=[];for(var i=["mousedown","mouseover","mouseout","mouseup","click","dblclick","touchstart","touchend","touchmove"],a=0,l=i;a<l.length;a++){var c=l[a];this.eventListeners.push(google.maps.event.addListener(this.div,c,MS))}this.eventListeners.push(google.maps.event.addListener(this.div,"mouseover",function(){e.div&&(e.div.style.cursor="default")}))}this.contextListener=google.maps.event.addListener(this.div,"contextmenu",n),google.maps.event.trigger(this,"domready")}},t.prototype.getCloseBoxImg=function(){var e="";return this.closeBoxURL!==""&&(e='<img alt=""',e+=' aria-hidden="true"',e+=" src='"+this.closeBoxURL+"'",e+=" align=right",e+=" style='",e+=" position: relative;",e+=" cursor: pointer;",e+=" margin: "+this.closeBoxMargin+";",e+="'>"),e},t.prototype.addClickHandler=function(){this.closeListener=this.div&&this.div.firstChild&&this.closeBoxURL!==""?google.maps.event.addListener(this.div.firstChild,"click",this.getCloseClickHandler()):null},t.prototype.closeClickHandler=function(e){e.cancelBubble=!0,e.stopPropagation&&e.stopPropagation(),google.maps.event.trigger(this,"closeclick"),this.close()},t.prototype.getCloseClickHandler=function(){return this.closeClickHandler},t.prototype.panBox=function(e){if(this.div&&!e){var n=this.getMap();if(n instanceof google.maps.Map){var r=0,s=0,i=n.getBounds();i&&!i.contains(this.position)&&n.setCenter(this.position);var a=n.getDiv(),l=a.offsetWidth,c=a.offsetHeight,d=this.pixelOffset.width,h=this.pixelOffset.height,f=this.div.offsetWidth,p=this.div.offsetHeight,g=this.infoBoxClearance.width,v=this.infoBoxClearance.height,x=this.getProjection(),y=x.fromLatLngToContainerPixel(this.position);y!==null&&(y.x<-d+g?r=y.x+d-g:y.x+f+d+g>l&&(r=y.x+f+d+g-l),this.alignBottom?y.y<-h+v+p?s=y.y+h-v-p:y.y+h+v>c&&(s=y.y+h+v-c):y.y<-h+v?s=y.y+h-v:y.y+p+h+v>c&&(s=y.y+p+h+v-c)),r===0&&s===0||n.panBy(r,s)}}},t.prototype.setBoxStyle=function(){if(this.div){this.div.className=this.boxClass,this.div.style.cssText="";var e=this.boxStyle;for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(this.div.style[n]=e[n]);if(this.div.style.webkitTransform="translateZ(0)",typeof this.div.style.opacity<"u"&&this.div.style.opacity!==""){var r=parseFloat(this.div.style.opacity||"");this.div.style.msFilter='"progid:DXImageTransform.Microsoft.Alpha(Opacity='+r*100+')"',this.div.style.filter="alpha(opacity="+r*100+")"}this.div.style.position="absolute",this.div.style.visibility="hidden",this.zIndex!==null&&(this.div.style.zIndex=this.zIndex+""),this.div.style.overflow||(this.div.style.overflow="auto")}},t.prototype.getBoxWidths=function(){var e={top:0,bottom:0,left:0,right:0};if(!this.div)return e;if(document.defaultView){var n=this.div.ownerDocument,r=n&&n.defaultView?n.defaultView.getComputedStyle(this.div,""):null;r&&(e.top=parseInt(r.borderTopWidth||"",10)||0,e.bottom=parseInt(r.borderBottomWidth||"",10)||0,e.left=parseInt(r.borderLeftWidth||"",10)||0,e.right=parseInt(r.borderRightWidth||"",10)||0)}else if(document.documentElement.currentStyle){var s=this.div.currentStyle;s&&(e.top=parseInt(s.borderTopWidth||"",10)||0,e.bottom=parseInt(s.borderBottomWidth||"",10)||0,e.left=parseInt(s.borderLeftWidth||"",10)||0,e.right=parseInt(s.borderRightWidth||"",10)||0)}return e},t.prototype.onRemove=function(){this.div&&this.div.parentNode&&(this.div.parentNode.removeChild(this.div),this.div=null)},t.prototype.draw=function(){if(this.createInfoBoxDiv(),this.div){var e=this.getProjection(),n=e.fromLatLngToDivPixel(this.position);n!==null&&(this.div.style.left=n.x+this.pixelOffset.width+"px",this.alignBottom?this.div.style.bottom=-(n.y+this.pixelOffset.height)+"px":this.div.style.top=n.y+this.pixelOffset.height+"px"),this.isHidden?this.div.style.visibility="hidden":this.div.style.visibility="visible"}},t.prototype.setOptions=function(e){e===void 0&&(e={}),typeof e.boxClass<"u"&&(this.boxClass=e.boxClass,this.setBoxStyle()),typeof e.boxStyle<"u"&&(this.boxStyle=e.boxStyle,this.setBoxStyle()),typeof e.content<"u"&&this.setContent(e.content),typeof e.disableAutoPan<"u"&&(this.disableAutoPan=e.disableAutoPan),typeof e.maxWidth<"u"&&(this.maxWidth=e.maxWidth),typeof e.pixelOffset<"u"&&(this.pixelOffset=e.pixelOffset),typeof e.alignBottom<"u"&&(this.alignBottom=e.alignBottom),typeof e.position<"u"&&this.setPosition(e.position),typeof e.zIndex<"u"&&this.setZIndex(e.zIndex),typeof e.closeBoxMargin<"u"&&(this.closeBoxMargin=e.closeBoxMargin),typeof e.closeBoxURL<"u"&&(this.closeBoxURL=e.closeBoxURL),typeof e.infoBoxClearance<"u"&&(this.infoBoxClearance=e.infoBoxClearance),typeof e.isHidden<"u"&&(this.isHidden=e.isHidden),typeof e.visible<"u"&&(this.isHidden=!e.visible),typeof e.enableEventPropagation<"u"&&(this.enableEventPropagation=e.enableEventPropagation),this.div&&this.draw()},t.prototype.setContent=function(e){this.content=e,this.div&&(this.closeListener&&(google.maps.event.removeListener(this.closeListener),this.closeListener=null),this.fixedWidthSet||(this.div.style.width=""),typeof e=="string"?this.div.innerHTML=this.getCloseBoxImg()+e:(this.div.innerHTML=this.getCloseBoxImg(),this.div.appendChild(e)),this.fixedWidthSet||(this.div.style.width=this.div.offsetWidth+"px",typeof e=="string"?this.div.innerHTML=this.getCloseBoxImg()+e:(this.div.innerHTML=this.getCloseBoxImg(),this.div.appendChild(e))),this.addClickHandler()),google.maps.event.trigger(this,"content_changed")},t.prototype.setPosition=function(e){this.position=e,this.div&&this.draw(),google.maps.event.trigger(this,"position_changed")},t.prototype.setVisible=function(e){this.isHidden=!e,this.div&&(this.div.style.visibility=this.isHidden?"hidden":"visible")},t.prototype.setZIndex=function(e){this.zIndex=e,this.div&&(this.div.style.zIndex=e+""),google.maps.event.trigger(this,"zindex_changed")},t.prototype.getContent=function(){return this.content},t.prototype.getPosition=function(){return this.position},t.prototype.getZIndex=function(){return this.zIndex},t.prototype.getVisible=function(){var e=this.getMap();return typeof e>"u"||e===null?!1:!this.isHidden},t.prototype.show=function(){this.isHidden=!1,this.div&&(this.div.style.visibility="visible")},t.prototype.hide=function(){this.isHidden=!0,this.div&&(this.div.style.visibility="hidden")},t.prototype.open=function(e,n){var r=this;n&&(this.position=n.getPosition(),this.moveListener=google.maps.event.addListener(n,"position_changed",function(){var s=n.getPosition();r.setPosition(s)}),this.mapListener=google.maps.event.addListener(n,"map_changed",function(){r.setMap(n.map)})),this.setMap(e),this.div&&this.panBox()},t.prototype.close=function(){if(this.closeListener&&(google.maps.event.removeListener(this.closeListener),this.closeListener=null),this.eventListeners){for(var e=0,n=this.eventListeners;e<n.length;e++){var r=n[e];google.maps.event.removeListener(r)}this.eventListeners=null}this.moveListener&&(google.maps.event.removeListener(this.moveListener),this.moveListener=null),this.mapListener&&(google.maps.event.removeListener(this.mapListener),this.mapListener=null),this.contextListener&&(google.maps.event.removeListener(this.contextListener),this.contextListener=null),this.setMap(null)},t.prototype.extend=function(e,n){return(function(s){for(var i in s.prototype)Object.prototype.hasOwnProperty.call(this,i)||
3520(this.prototype[i]=s.prototype[i]);return this}).apply(e,[n])},t}(),kq=["position"],Pq=["position"];function OS(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function Yg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?OS(Object(n),!0).forEach(function(r){ce(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):OS(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var FS={onCloseClick:"closeclick",onContentChanged:"content_changed",onDomReady:"domready",onPositionChanged:"position_changed",onZindexChanged:"zindex_changed"},zS={options(t,e){t.setOptions(e)},position(t,e){e instanceof google.maps.LatLng?t.setPosition(e):t.setPosition(new google.maps.LatLng(e.lat,e.lng))},visible(t,e){t.setVisible(e)},zIndex(t,e){t.setZIndex(e)}},Iq={};function Tq(t){var{children:e,anchor:n,options:r,position:s,zIndex:i,onCloseClick:a,onDomReady:l,onContentChanged:c,onPositionChanged:d,onZindexChanged:h,onLoad:f,onUnmount:p}=t,g=u.useContext(ut),[v,x]=u.useState(null),[y,b]=u.useState(null),[w,j]=u.useState(null),[E,P]=u.useState(null),[A,N]=u.useState(null),[_,k]=u.useState(null),L=u.useRef(null);return u.useEffect(()=>{g&&v!==null&&(v.close(),n?v.open(g,n):v.getPosition()&&v.open(g))},[g,v,n]),u.useEffect(()=>{r&&v!==null&&v.setOptions(r)},[v,r]),u.useEffect(()=>{if(s&&v!==null){var I=s instanceof google.maps.LatLng?s:new google.maps.LatLng(s.lat,s.lng);v.setPosition(I)}},[s]),u.useEffect(()=>{typeof i=="number"&&v!==null&&v.setZIndex(i)},[i]),u.useEffect(()=>{v&&a&&(y!==null&&google.maps.event.removeListener(y),b(google.maps.event.addListener(v,"closeclick",a)))},[a]),u.useEffect(()=>{v&&l&&(w!==null&&google.maps.event.removeListener(w),j(google.maps.event.addListener(v,"domready",l)))},[l]),u.useEffect(()=>{v&&c&&(E!==null&&google.maps.event.removeListener(E),P(google.maps.event.addListener(v,"content_changed",c)))},[c]),u.useEffect(()=>{v&&d&&(A!==null&&google.maps.event.removeListener(A),N(google.maps.event.addListener(v,"position_changed",d)))},[d]),u.useEffect(()=>{v&&h&&(_!==null&&google.maps.event.removeListener(_),k(google.maps.event.addListener(v,"zindex_changed",h)))},[h]),u.useEffect(()=>{if(g){var I=r||Iq,{position:S}=I,T=YC(I,kq),V;S&&!(S instanceof google.maps.LatLng)&&(V=new google.maps.LatLng(S.lat,S.lng));var $=new UD(Yg(Yg({},T),V?{position:V}:{}));L.current=document.createElement("div"),x($),a&&b(google.maps.event.addListener($,"closeclick",a)),l&&j(google.maps.event.addListener($,"domready",l)),c&&P(google.maps.event.addListener($,"content_changed",c)),d&&N(google.maps.event.addListener($,"position_changed",d)),h&&k(google.maps.event.addListener($,"zindex_changed",h)),$.setContent(L.current),n?$.open(g,n):$.getPosition()?$.open(g):tr(!1,"You must provide either an anchor or a position prop for <InfoBox>."),f&&f($)}return()=>{v!==null&&(y&&google.maps.event.removeListener(y),E&&google.maps.event.removeListener(E),w&&google.maps.event.removeListener(w),A&&google.maps.event.removeListener(A),_&&google.maps.event.removeListener(_),p&&p(v),v.close())}},[]),L.current?ps.createPortal(u.Children.only(e),L.current):null}u.memo(Tq);class Aq extends u.PureComponent{constructor(){super(...arguments),ce(this,"registeredEvents",[]),ce(this,"containerElement",null),ce(this,"state",{infoBox:null}),ce(this,"open",(e,n)=>{n?this.context!==null&&e.open(this.context,n):e.getPosition()?this.context!==null&&e.open(this.context):tr(!1,"You must provide either an anchor or a position prop for <InfoBox>.")}),ce(this,"setInfoBoxCallback",()=>{this.state.infoBox!==null&&this.containerElement!==null&&(this.state.infoBox.setContent(this.containerElement),this.open(this.state.infoBox,this.props.anchor),this.props.onLoad&&this.props.onLoad(this.state.infoBox))})}componentDidMount(){var e=this.props.options||{},{position:n}=e,r=YC(e,Pq),s;n&&!(n instanceof google.maps.LatLng)&&(s=new google.maps.LatLng(n.lat,n.lng));var i=new UD(Yg(Yg({},r),s?{position:s}:{}));this.containerElement=document.createElement("div"),this.registeredEvents=gt({updaterMap:zS,eventMap:FS,prevProps:{},nextProps:this.props,instance:i}),this.setState({infoBox:i},this.setInfoBoxCallback)}componentDidUpdate(e){var{infoBox:n}=this.state;n!==null&&(yt(this.registeredEvents),this.registeredEvents=gt({updaterMap:zS,eventMap:FS,prevProps:e,nextProps:this.props,instance:n}))}componentWillUnmount(){var{onUnmount:e}=this.props,{infoBox:n}=this.state;n!==null&&(e&&e(n),yt(this.registeredEvents),n.close())}render(){return this.containerElement?ps.createPortal(u.Children.only(this.props.children),this.containerElement):null}}ce(Aq,"contextType",ut);var Uy,$S;function Rq(){return $S||($S=1,Uy=function t(e,n){if(e===n)return!0;
3520if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,s,i;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(s=r;s--!==0;)if(!t(e[s],n[s]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(i=Object.keys(e),r=i.length,r!==Object.keys(n).length)return!1;for(s=r;s--!==0;)if(!Object.prototype.hasOwnProperty.call(n,i[s]))return!1;for(s=r;s--!==0;){var a=i[s];if(!t(e[a],n[a]))return!1}return!0}return e!==e&&n!==n}),Uy}var Dq=Rq(),VS=DD(Dq),US=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],By=1,Hd=8;class QC{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");var[n,r]=new Uint8Array(e,0,2);if(n!==219)throw new Error("Data does not appear to be in a KDBush format.");var s=r>>4;if(s!==By)throw new Error("Got v".concat(s," data when expected v").concat(By,"."));var i=US[r&15];if(!i)throw new Error("Unrecognized array type.");var[a]=new Uint16Array(e,2,1),[l]=new Uint32Array(e,4,1);return new QC(l,a,i,e)}constructor(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:64,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Float64Array,s=arguments.length>3?arguments[3]:void 0;if(isNaN(e)||e<0)throw new Error("Unpexpected numItems value: ".concat(e,"."));this.numItems=+e,this.nodeSize=Math.min(Math.max(+n,2),65535),this.ArrayType=r,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;var i=US.indexOf(this.ArrayType),a=e*2*this.ArrayType.BYTES_PER_ELEMENT,l=e*this.IndexArrayType.BYTES_PER_ELEMENT,c=(8-l%8)%8;if(i<0)throw new Error("Unexpected typed array class: ".concat(r,"."));s&&s instanceof ArrayBuffer?(this.data=s,this.ids=new this.IndexArrayType(this.data,Hd,e),this.coords=new this.ArrayType(this.data,Hd+l+c,e*2),this._pos=e*2,this._finished=!0):(this.data=new ArrayBuffer(Hd+a+l+c),this.ids=new this.IndexArrayType(this.data,Hd,e),this.coords=new this.ArrayType(this.data,Hd+l+c,e*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(By<<4)+i]),new Uint16Array(this.data,2,1)[0]=n,new Uint32Array(this.data,4,1)[0]=e)}add(e,n){var r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=e,this.coords[this._pos++]=n,r}finish(){var e=this._pos>>1;if(e!==this.numItems)throw new Error("Added ".concat(e," items when expected ").concat(this.numItems,"."));return db(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,n,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");for(var{ids:i,coords:a,nodeSize:l}=this,c=[0,i.length-1,0],d=[];c.length;){var h=c.pop()||0,f=c.pop()||0,p=c.pop()||0;if(f-p<=l){for(var g=p;g<=f;g++){var v=a[2*g],x=a[2*g+1];v>=e&&v<=r&&x>=n&&x<=s&&d.push(i[g])}continue}var y=p+f>>1,b=a[2*y],w=a[2*y+1];b>=e&&b<=r&&w>=n&&w<=s&&d.push(i[y]),(h===0?e<=b:n<=w)&&(c.push(p),c.push(y-1),c.push(1-h)),(h===0?r>=b:s>=w)&&(c.push(y+1),c.push(f),c.push(1-h))}return d}within(e,n,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");for(var{ids:s,coords:i,nodeSize:a}=this,l=[0,s.length-1,0],c=[],d=r*r;l.length;){var h=l.pop()||0,f=l.pop()||0,p=l.pop()||0;if(f-p<=a){for(var g=p;g<=f;g++)BS(i[2*g],i[2*g+1],e,n)<=d&&c.push(s[g]);continue}var v=p+f>>1,x=i[2*v],y=i[2*v+1];BS(x,y,e,n)<=d&&c.push(s[v]),(h===0?e-r<=x:n-r<=y)&&(l.push(p),l.push(v-1),l.push(1-h)),(h===0?e+r>=x:n+r>=y)&&(l.push(v+1),l.push(f),l.push(1-h))}return c}}function db(t,e,n,r,s,i){if(!(s-r<=n)){var a=r+s>>1;BD(t,e,a,r,s,i),db(t,e,n,r,a-1,1-i),db(t,e,n,a+1,s,1-i)}}function BD(t,e,n,r,s,i){for(;s>r;){if(s-r>600){var a=s-r+1,l=n-r+1,c=Math.log(a),d=.5*Math.exp(2*c/3),h=.5*Math.sqrt(c*d*(a-d)/a)*(l-a/2<0?-1:1),f=Math.max(r,Math.floor(n-l*d/a+h)),p=Math.min(s,Math.floor(n+(a-l)*d/a+h));BD(t,e,n,f,p,i)}var g=e[2*n+i],v=r,x=s;for(qd(t,e,r,n),e[2*s+i]>g&&qd(t,e,r,s);v<x;){for(qd(t,e,v,x),v++,x--;e[2*v+i]<g;)v++;for(;e[2*x+i]>g;)x--}e[2*r+i]===g?qd(t,e,r,x):(x++,qd(t,e,x,s)),x<=n&&(r=x+1),n<=x&&(s=x-1)}}function qd(t,e,n,r){Wy(t,n,r),Wy(e,2*n,2*r),Wy(e,2*n+1,2*r+1)}function Wy(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function BS(t,e,n,r){var s=t-n,i=e-r;return s*s+i*i}var Lq={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},WS=Math.fround||(t=>e=>(t[0]=+e,t[0]))(new Float32Array(1)),wl=2,aa=3,Hy=4,na=5,WD=6;class Mq{constructor(e){this.options=Object.assign(Object.create(Lq),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){var{log:n,minZoom:r,maxZoom:s}=this.options;n&&console.time("total time");var i="prepare ".concat(e.length," points");n&&console.time(i),this.points=e;for(var a=[],l=0;l<e.length;l++){var c=e[l];
3520if(c.geometry){var[d,h]=c.geometry.coordinates,f=WS(lp(d)),p=WS(cp(h));a.push(f,p,1/0,l,-1,1),this.options.reduce&&a.push(0)}}var g=this.trees[s+1]=this._createTree(a);n&&console.timeEnd(i);for(var v=s;v>=r;v--){var x=+Date.now();g=this.trees[v]=this._createTree(this._cluster(g,v)),n&&console.log("z%d: %d clusters in %dms",v,g.numItems,+Date.now()-x)}return n&&console.timeEnd("total time"),this}getClusters(e,n){var r=((e[0]+180)%360+360)%360-180,s=Math.max(-90,Math.min(90,e[1])),i=e[2]===180?180:((e[2]+180)%360+360)%360-180,a=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)r=-180,i=180;else if(r>i){var l=this.getClusters([r,s,180,a],n),c=this.getClusters([-180,s,i,a],n);return l.concat(c)}var d=this.trees[this._limitZoom(n)],h=d.range(lp(r),cp(a),lp(i),cp(s)),f=d.data,p=[];for(var g of h){var v=this.stride*g;p.push(f[v+na]>1?HS(f,v,this.clusterProps):this.points[f[v+aa]])}return p}getChildren(e){var n=this._getOriginId(e),r=this._getOriginZoom(e),s="No cluster with the specified id.",i=this.trees[r];if(!i)throw new Error(s);var a=i.data;if(n*this.stride>=a.length)throw new Error(s);var l=this.options.radius/(this.options.extent*Math.pow(2,r-1)),c=a[n*this.stride],d=a[n*this.stride+1],h=i.within(c,d,l),f=[];for(var p of h){var g=p*this.stride;a[g+Hy]===e&&f.push(a[g+na]>1?HS(a,g,this.clusterProps):this.points[a[g+aa]])}if(f.length===0)throw new Error(s);return f}getLeaves(e,n,r){n=n||10,r=r||0;var s=[];return this._appendLeaves(s,e,n,r,0),s}getTile(e,n,r){var s=this.trees[this._limitZoom(e)],i=Math.pow(2,e),{extent:a,radius:l}=this.options,c=l/a,d=(r-c)/i,h=(r+1+c)/i,f={features:[]};return this._addTileFeatures(s.range((n-c)/i,d,(n+1+c)/i,h),s.data,n,r,i,f),n===0&&this._addTileFeatures(s.range(1-c/i,d,1,h),s.data,i,r,i,f),n===i-1&&this._addTileFeatures(s.range(0,d,c/i,h),s.data,-1,r,i,f),f.features.length?f:null}getClusterExpansionZoom(e){for(var n=this._getOriginZoom(e)-1;n<=this.options.maxZoom;){var r=this.getChildren(e);if(n++,r.length!==1)break;e=r[0].properties.cluster_id}return n}_appendLeaves(e,n,r,s,i){var a=this.getChildren(n);for(var l of a){var c=l.properties;if(c&&c.cluster?i+c.point_count<=s?i+=c.point_count:i=this._appendLeaves(e,c.cluster_id,r,s,i):i<s?i++:e.push(l),e.length===r)break}return i}_createTree(e){for(var n=new QC(e.length/this.stride|0,this.options.nodeSize,Float32Array),r=0;r<e.length;r+=this.stride)n.add(e[r],e[r+1]);return n.finish(),n.data=e,n}_addTileFeatures(e,n,r,s,i,a){for(var l of e){var c=l*this.stride,d=n[c+na]>1,h=void 0,f=void 0,p=void 0;if(d)h=HD(n,c,this.clusterProps),f=n[c],p=n[c+1];else{var g=this.points[n[c+aa]];h=g.properties;var[v,x]=g.geometry.coordinates;f=lp(v),p=cp(x)}var y={type:1,geometry:[[Math.round(this.options.extent*(f*i-r)),Math.round(this.options.extent*(p*i-s))]],tags:h},b=void 0;d||this.options.generateId?b=n[c+aa]:b=this.points[n[c+aa]].id,b!==void 0&&(y.id=b),a.features.push(y)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,n){for(var{radius:r,extent:s,reduce:i,minPoints:a}=this.options,l=r/(s*Math.pow(2,n)),c=e.data,d=[],h=this.stride,f=0;f<c.length;f+=h)if(!(c[f+wl]<=n)){c[f+wl]=n;var p=c[f],g=c[f+1],v=e.within(c[f],c[f+1],l),x=c[f+na],y=x;for(var b of v){var w=b*h;c[w+wl]>n&&(y+=c[w+na])}if(y>x&&y>=a){var j=p*x,E=g*x,P=void 0,A=-1,N=((f/h|0)<<5)+(n+1)+this.points.length;for(var _ of v){var k=_*h;if(!(c[k+wl]<=n)){c[k+wl]=n;var L=c[k+na];j+=c[k]*L,E+=c[k+1]*L,c[k+Hy]=N,i&&(P||(P=this._map(c,f,!0),A=this.clusterProps.length,this.clusterProps.push(P)),i(P,this._map(c,k)))}}c[f+Hy]=N,d.push(j/y,E/y,1/0,N,-1,y),i&&d.push(A)}else{for(var I=0;I<h;I++)d.push(c[f+I]);if(y>1)for(var S of v){var T=S*h;if(!(c[T+wl]<=n)){c[T+wl]=n;for(var V=0;V<h;V++)d.push(c[T+V])}}}}return d}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,n,r){if(e[n+na]>1){var s=this.clusterProps[e[n+WD]];return r?Object.assign({},s):s}var i=this.points[e[n+aa]].properties,a=this.options.map(i);return r&&a===i?Object.assign({},a):a}}function HS(t,e,n){return{type:"Feature",id:t[e+aa],properties:HD(t,e,n),geometry:{type:"Point",coordinates:[Oq(t[e]),Fq(t[e+1])]}}}function HD(t,e,n){var r=t[e+na],s=r>=1e4?"".concat(Math.round(r/1e3),"k"):r>=1e3?"".concat(Math.round(r/100)/10,"k"):r,i=t[e+WD],a=i===-1?{}:Object.assign({},n[i]);return Object.assign(a,{cluster:!0,cluster_id:t[e+aa],point_count:r,point_count_abbreviated:s})}function lp(t){return t/360+.5}function cp(t){var e=Math.sin(t*Math.PI/180),n=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return n<0?0:n>1?1:n}function Oq(t){return(t-.5)*360}function Fq(t){var e=(180-t*360)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}/*! ***************************************************************************** 3521Copyright (c) Microsoft Corporation. 3522 3523Permission to use, copy, modify, and/or distribute this software for any 3524purpose with or without fee is hereby granted. 3525 3526THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 3527REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 3528AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 3529INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 3530LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 3531OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 3532PERFORMANCE OF THIS SOFTWARE. 3533***************************************************************************** */function zq(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n}class ws{static isAdvancedMarkerAvailable(e){return google.maps.marker&&e.getMapCapabilities().isAdvancedMarkersAvailable===!0}static isAdvancedMarker(e){return google.maps.marker&&e instanceof google.maps.marker.AdvancedMarkerElement}static setMap(e,n){this.isAdvancedMarker(e)?e.map=n:e.setMap(n)}static getPosition(e){if(this.isAdvancedMarker(e)){if(e.position){if(e.position instanceof google.maps.LatLng)return e.position;if(e.position.lat&&e.position.lng)return new google.maps.LatLng(e.position.lat,e.position.lng)}return new google.maps.LatLng(null)}return e.getPosition()}static getVisible(e){return this.isAdvancedMarker(e)?!0:e.getVisible()}}class hb{constructor(e){var{markers:n,position:r}=e;this.markers=n,r&&(r instanceof google.maps.LatLng?this._position=r:this._position=new google.maps.LatLng(r))}get bounds(){if(!(this.markers.length===0&&!this._position)){var e=new google.maps.LatLngBounds(this._position,this._position);for(var n of this.markers)e.extend(ws.getPosition(n));return e}}get position(){return this._position||this.bounds.getCenter()}get count(){return this.markers.filter(e=>ws.getVisible(e)).length}push(e){this.markers.push(e)}delete(){this.marker&&(ws.setMap(this.marker,null),this.marker=void 0),this.markers.length=0}}class $q{constructor(e){var{maxZoom:n=16}=e;this.maxZoom=n}noop(e){var{markers:n}=e;return Vq(n)}}var Vq=t=>{var e=t.map(n=>new hb({position:ws.getPosition(n),markers:[n]}));return e};class Uq extends $q{constructor(e){var{maxZoom:n,radius:r=60}=e,s=zq(e,["maxZoom","radius"]);super({maxZoom:n}),this.state={zoom:-1}
3533,this.superCluster=new Mq(Object.assign({maxZoom:this.maxZoom,radius:r},s))}calculate(e){var n=!1,r={zoom:e.map.getZoom()};if(!VS(e.markers,this.markers)){n=!0,this.markers=[...e.markers];var s=this.markers.map(i=>{var a=ws.getPosition(i),l=[a.lng(),a.lat()];return{type:"Feature",geometry:{type:"Point",coordinates:l},properties:{marker:i}}});this.superCluster.load(s)}return n||(this.state.zoom<=this.maxZoom||r.zoom<=this.maxZoom)&&(n=!VS(this.state,r)),this.state=r,n&&(this.clusters=this.cluster(e)),{clusters:this.clusters,changed:n}}cluster(e){var{map:n}=e;return this.superCluster.getClusters([-180,-90,180,90],Math.round(n.getZoom())).map(r=>this.transformCluster(r))}transformCluster(e){var{geometry:{coordinates:[n,r]},properties:s}=e;if(s.cluster)return new hb({markers:this.superCluster.getLeaves(s.cluster_id,1/0).map(a=>a.properties.marker),position:{lat:r,lng:n}});var i=s.marker;return new hb({markers:[i],position:ws.getPosition(i)})}}class Bq{constructor(e,n){this.markers={sum:e.length};var r=n.map(i=>i.count),s=r.reduce((i,a)=>i+a,0);this.clusters={count:n.length,markers:{mean:s/n.length,sum:s,min:Math.min(...r),max:Math.max(...r)}}}}class Wq{render(e,n,r){var{count:s,position:i}=e,a=s>Math.max(10,n.clusters.markers.mean)?"#ff0000":"#0000ff",l='<svg fill="'.concat(a,`" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 240" width="50" height="50"> 3534<circle cx="120" cy="120" opacity=".6" r="70" /> 3535<circle cx="120" cy="120" opacity=".3" r="90" /> 3536<circle cx="120" cy="120" opacity=".2" r="110" /> 3537<text x="50%" y="50%" style="fill:#fff" text-anchor="middle" font-size="50" dominant-baseline="middle" font-family="roboto,arial,sans-serif">`).concat(s,`</text> 3538</svg>`),c="Cluster of ".concat(s," markers"),d=Number(google.maps.Marker.MAX_ZINDEX)+s;if(ws.isAdvancedMarkerAvailable(r)){var h=new DOMParser,f=h.parseFromString(l,"image/svg+xml").documentElement;f.setAttribute("transform","translate(0 25)");var p={map:r,position:i,zIndex:d,title:c,content:f};return new google.maps.marker.AdvancedMarkerElement(p)}var g={position:i,zIndex:d,title:c,icon:{url:"data:image/svg+xml;base64,".concat(btoa(l)),anchor:new google.maps.Point(25,25)}};return new google.maps.Marker(g)}}function Hq(t,e){for(var n in e.prototype)t.prototype[n]=e.prototype[n]}class XC{constructor(){Hq(XC,google.maps.OverlayView)}}var Mh;(function(t){t.CLUSTERING_BEGIN="clusteringbegin",t.CLUSTERING_END="clusteringend",t.CLUSTER_CLICK="click"})(Mh||(Mh={}));var qq=(t,e,n)=>{n.fitBounds(e.bounds)};class Gq extends XC{constructor(e){var{map:n,markers:r=[],algorithmOptions:s={},algorithm:i=new Uq(s),renderer:a=new Wq,onClusterClick:l=qq}=e;super(),this.markers=[...r],this.clusters=[],this.algorithm=i,this.renderer=a,this.onClusterClick=l,n&&this.setMap(n)}addMarker(e,n){this.markers.includes(e)||(this.markers.push(e),n||this.render())}addMarkers(e,n){e.forEach(r=>{this.addMarker(r,!0)}),n||this.render()}removeMarker(e,n){var r=this.markers.indexOf(e);return r===-1?!1:(ws.setMap(e,null),this.markers.splice(r,1),n||this.render(),!0)}removeMarkers(e,n){var r=!1;return e.forEach(s=>{r=this.removeMarker(s,!0)||r}),r&&!n&&this.render(),r}clearMarkers(e){this.markers.length=0,e||this.render()}render(){var e=this.getMap();if(e instanceof google.maps.Map&&e.getProjection()){google.maps.event.trigger(this,Mh.CLUSTERING_BEGIN,this);var{clusters:n,changed:r}=this.algorithm.calculate({markers:this.markers,map:e,mapCanvasProjection:this.getProjection()});if(r||r==null){var s=new Set;for(var i of n)i.markers.length==1&&s.add(i.markers[0]);var a=[];for(var l of this.clusters)l.marker!=null&&(l.markers.length==1?s.has(l.marker)||ws.setMap(l.marker,null):a.push(l.marker));this.clusters=n,this.renderClusters(),requestAnimationFrame(()=>a.forEach(c=>ws.setMap(c,null)))}google.maps.event.trigger(this,Mh.CLUSTERING_END,this)}}onAdd(){this.idleListener=this.getMap().addListener("idle",this.render.bind(this)),this.render()}onRemove(){google.maps.event.removeListener(this.idleListener),this.reset()}reset(){this.markers.forEach(e=>ws.setMap(e,null)),this.clusters.forEach(e=>
3538e.delete()),this.clusters=[]}renderClusters(){var e=new Bq(this.markers,this.clusters),n=this.getMap();this.clusters.forEach(r=>{r.markers.length===1?r.marker=r.markers[0]:(r.marker=this.renderer.render(r,e,n),r.markers.forEach(s=>ws.setMap(s,null)),this.onClusterClick&&r.marker.addListener("click",s=>{google.maps.event.trigger(this,Mh.CLUSTER_CLICK,r),this.onClusterClick(s,r,n)})),ws.setMap(r.marker,n)})}}function qS(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function GS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qS(Object(n),!0).forEach(function(r){ce(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qS(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Zq(t){var e=ZH(),[n,r]=u.useState(null);return u.useEffect(()=>{if(e&&n===null){var s=new Gq(GS(GS({},t),{},{map:e}));r(s)}},[e]),n}function Kq(t){var{children:e,options:n}=t,r=Zq(n);return r!==null?e(r):null}u.memo(Kq);var ZS={onCloseClick:"closeclick",onContentChanged:"content_changed",onDomReady:"domready",onPositionChanged:"position_changed",onZindexChanged:"zindex_changed"},KS={options(t,e){t.setOptions(e)},position(t,e){t.setPosition(e)},zIndex(t,e){t.setZIndex(e)}};function Yq(t){var{children:e,anchor:n,options:r,position:s,zIndex:i,onCloseClick:a,onDomReady:l,onContentChanged:c,onPositionChanged:d,onZindexChanged:h,onLoad:f,onUnmount:p}=t,g=u.useContext(ut),[v,x]=u.useState(null),[y,b]=u.useState(null),[w,j]=u.useState(null),[E,P]=u.useState(null),[A,N]=u.useState(null),[_,k]=u.useState(null),L=u.useRef(null);return u.useEffect(()=>{v!==null&&(v.close(),n?v.open(g,n):v.getPosition()&&v.open(g))},[g,v,n]),u.useEffect(()=>{r&&v!==null&&v.setOptions(r)},[v,r]),u.useEffect(()=>{s&&v!==null&&v.setPosition(s)},[s]),u.useEffect(()=>{typeof i=="number"&&v!==null&&v.setZIndex(i)},[i]),u.useEffect(()=>{v&&a&&(y!==null&&google.maps.event.removeListener(y),b(google.maps.event.addListener(v,"closeclick",a)))},[a]),u.useEffect(()=>{v&&l&&(w!==null&&google.maps.event.removeListener(w),j(google.maps.event.addListener(v,"domready",l)))},[l]),u.useEffect(()=>{v&&c&&(E!==null&&google.maps.event.removeListener(E),P(google.maps.event.addListener(v,"content_changed",c)))},[c]),u.useEffect(()=>{v&&d&&(A!==null&&google.maps.event.removeListener(A),N(google.maps.event.addListener(v,"position_changed",d)))},[d]),u.useEffect(()=>{v&&h&&(_!==null&&google.maps.event.removeListener(_),k(google.maps.event.addListener(v,"zindex_changed",h)))},[h]),u.useEffect(()=>{var I=new google.maps.InfoWindow(r);return x(I),L.current=document.createElement("div"),a&&b(google.maps.event.addListener(I,"closeclick",a)),l&&j(google.maps.event.addListener(I,"domready",l)),c&&P(google.maps.event.addListener(I,"content_changed",c)),d&&N(google.maps.event.addListener(I,"position_changed",d)),h&&k(google.maps.event.addListener(I,"zindex_changed",h)),I.setContent(L.current),s&&I.setPosition(s),i&&I.setZIndex(i),n?I.open(g,n):I.getPosition()?I.open(g):tr(!1,"You must provide either an anchor (typically render it inside a <Marker>) or a position props for <InfoWindow>."),f&&f(I),()=>{y&&google.maps.event.removeListener(y),E&&google.maps.event.removeListener(E),w&&google.maps.event.removeListener(w),A&&google.maps.event.removeListener(A),_&&google.maps.event.removeListener(_),p&&p(I),I.close()}},[]),L.current?ps.createPortal(u.Children.only(e),L.current):null}u.memo(Yq);class Qq extends u.PureComponent{constructor(){super(...arguments),ce(this,"registeredEvents",[]),ce(this,"containerElement",null),ce(this,"state",{infoWindow:null}),ce(this,"open",(e,n)=>{n?e.open(this.context,n):e.getPosition()?e.open(this.context):tr(!1,"You must provide either an anchor (typically render it inside a <Marker>) or a position props for <InfoWindow>.")}),ce(this,"setInfoWindowCallback",()=>{this.state.infoWindow!==null&&this.containerElement!==null&&(this.state.infoWindow.setContent(this.containerElement),this.open(this.state.infoWindow,this.props.anchor),this.props.onLoad&&this.props.onLoad(this.state.infoWindow))})}componentDidMount(){var e=new google.maps.InfoWindow(this.props.options);this.containerElement=document.createElement("div"),this.registeredEvents=gt({updaterMap:KS,eventMap:ZS,prevProps:{},nextProps:this.props,instance:e}),this.setState(()=>({infoWindow:e}),this.setInfoWindowCallback)}componentDidUpdate(e){this.state.infoWindow!==null&&(yt(this.registeredEvents),this.registeredEvents=gt({updaterMap:KS,eventMap:ZS,prevProps:e,nextProps:this.props,instance:this.state.infoWindow}))}componentWillUnmount(){this.state.infoWindow!==null&&(yt(this.registeredEvents),this.props.onUnmount&&this.props.onUnmount(this.state.infoWindow),this.state.infoWindow.close())}render(){return this.containerElement?ps.createPortal(u.Children.only(this.props.children),this.containerElement):null}}ce(Qq,"contextType",ut);function YS(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function Qg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};
3538e%2?YS(Object(n),!0).forEach(function(r){ce(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):YS(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var QS={onClick:"click",onDblClick:"dblclick",onDrag:"drag",onDragEnd:"dragend",onDragStart:"dragstart",onMouseDown:"mousedown",onMouseMove:"mousemove",onMouseOut:"mouseout",onMouseOver:"mouseover",onMouseUp:"mouseup",onRightClick:"rightclick"},XS={draggable(t,e){t.setDraggable(e)},editable(t,e){t.setEditable(e)},map(t,e){t.setMap(e)},options(t,e){t.setOptions(e)},path(t,e){t.setPath(e)},visible(t,e){t.setVisible(e)}},Xq={};function Jq(t){var{options:e,draggable:n,editable:r,visible:s,path:i,onDblClick:a,onDragEnd:l,onDragStart:c,onMouseDown:d,onMouseMove:h,onMouseOut:f,onMouseOver:p,onMouseUp:g,onRightClick:v,onClick:x,onDrag:y,onLoad:b,onUnmount:w}=t,j=u.useContext(ut),[E,P]=u.useState(null),[A,N]=u.useState(null),[_,k]=u.useState(null),[L,I]=u.useState(null),[S,T]=u.useState(null),[V,$]=u.useState(null),[H,W]=u.useState(null),[D,F]=u.useState(null),[O,Y]=u.useState(null),[G,q]=u.useState(null),[re,U]=u.useState(null),[ee,K]=u.useState(null);return u.useEffect(()=>{E!==null&&E.setMap(j)},[j]),u.useEffect(()=>{typeof e<"u"&&E!==null&&E.setOptions(e)},[E,e]),u.useEffect(()=>{typeof n<"u"&&E!==null&&E.setDraggable(n)},[E,n]),u.useEffect(()=>{typeof r<"u"&&E!==null&&E.setEditable(r)},[E,r]),u.useEffect(()=>{typeof s<"u"&&E!==null&&E.setVisible(s)},[E,s]),u.useEffect(()=>{typeof i<"u"&&E!==null&&E.setPath(i)},[E,i]),u.useEffect(()=>{E&&a&&(A!==null&&google.maps.event.removeListener(A),N(google.maps.event.addListener(E,"dblclick",a)))},[a]),u.useEffect(()=>{E&&l&&(_!==null&&google.maps.event.removeListener(_),k(google.maps.event.addListener(E,"dragend",l)))},[l]),u.useEffect(()=>{E&&c&&(L!==null&&google.maps.event.removeListener(L),I(google.maps.event.addListener(E,"dragstart",c)))},[c]),u.useEffect(()=>{E&&d&&(S!==null&&google.maps.event.removeListener(S),T(google.maps.event.addListener(E,"mousedown",d)))},[d]),u.useEffect(()=>{E&&h&&(V!==null&&google.maps.event.removeListener(V),$(google.maps.event.addListener(E,"mousemove",h)))},[h]),u.useEffect(()=>{E&&f&&(H!==null&&google.maps.event.removeListener(H),W(google.maps.event.addListener(E,"mouseout",f)))},[f]),u.useEffect(()=>{E&&p&&(D!==null&&google.maps.event.removeListener(D),F(google.maps.event.addListener(E,"mouseover",p)))},[p]),u.useEffect(()=>{E&&g&&(O!==null&&google.maps.event.removeListener(O),Y(google.maps.event.addListener(E,"mouseup",g)))},[g]),u.useEffect(()=>{E&&v&&(G!==null&&google.maps.event.removeListener(G),q(google.maps.event.addListener(E,"rightclick",v)))},[v]),u.useEffect(()=>{E&&x&&(re!==null&&google.maps.event.removeListener(re),U(google.maps.event.addListener(E,"click",x)))},[x]),u.useEffect(()=>{E&&y&&(ee!==null&&google.maps.event.removeListener(ee),K(google.maps.event.addListener(E,"drag",y)))},[y]),u.useEffect(()=>{var ue=new google.maps.Polyline(Qg(Qg({},e||Xq),{},{map:j}));return i&&ue.setPath(i),typeof s<"u"&&ue.setVisible(s),typeof r<"u"&&ue.setEditable(r),typeof n<"u"&&ue.setDraggable(n),a&&N(google.maps.event.addListener(ue,"dblclick",a)),l&&k(google.maps.event.addListener(ue,"dragend",l)),c&&I(google.maps.event.addListener(ue,"dragstart",c)),d&&T(google.maps.event.addListener(ue,"mousedown",d)),h&&$(google.maps.event.addListener(ue,"mousemove",h)),f&&W(google.maps.event.addListener(ue,"mouseout",f)),p&&F(google.maps.event.addListener(ue,"mouseover",p)),g&&Y(google.maps.event.addListener(ue,"mouseup",g)),v&&q(google.maps.event.addListener(ue,"rightclick",v)),x&&U(google.maps.event.addListener(ue,"click",x)),y&&K(google.maps.event.addListener(ue,"drag",y)),P(ue),b&&b(ue),()=>{A!==null&&google.maps.event.removeListener(A),_!==null&&google.maps.event.removeListener(_),L!==null&&google.maps.event.removeListener(L),S!==null&&google.maps.event.removeListener(S),V!==null&&google.maps.event.removeListener(V),H!==null&&google.maps.event.removeListener(H),D!==null&&google.maps.event.removeListener(
3538D),O!==null&&google.maps.event.removeListener(O),G!==null&&google.maps.event.removeListener(G),re!==null&&google.maps.event.removeListener(re),w&&w(ue),ue.setMap(null)}},[]),null}u.memo(Jq);class qD extends u.PureComponent{constructor(){super(...arguments),ce(this,"registeredEvents",[]),ce(this,"state",{polyline:null}),ce(this,"setPolylineCallback",()=>{this.state.polyline!==null&&this.props.onLoad&&this.props.onLoad(this.state.polyline)})}componentDidMount(){var e=new google.maps.Polyline(Qg(Qg({},this.props.options),{},{map:this.context}));this.registeredEvents=gt({updaterMap:XS,eventMap:QS,prevProps:{},nextProps:this.props,instance:e}),this.setState(function(){return{polyline:e}},this.setPolylineCallback)}componentDidUpdate(e){this.state.polyline!==null&&(yt(this.registeredEvents),this.registeredEvents=gt({updaterMap:XS,eventMap:QS,prevProps:e,nextProps:this.props,instance:this.state.polyline}))}componentWillUnmount(){this.state.polyline!==null&&(this.props.onUnmount&&this.props.onUnmount(this.state.polyline),yt(this.registeredEvents),this.state.polyline.setMap(null))}render(){return null}}ce(qD,"contextType",ut);function JS(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function ek(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?JS(Object(n),!0).forEach(function(r){ce(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):JS(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var tk={onClick:"click",onDblClick:"dblclick",onDrag:"drag",onDragEnd:"dragend",onDragStart:"dragstart",onMouseDown:"mousedown",onMouseMove:"mousemove",onMouseOut:"mouseout",onMouseOver:"mouseover",onMouseUp:"mouseup",onRightClick:"rightclick"},nk={draggable(t,e){t.setDraggable(e)},editable(t,e){t.setEditable(e)},map(t,e){t.setMap(e)},options(t,e){t.setOptions(e)},path(t,e){t.setPath(e)},paths(t,e){t.setPaths(e)},visible(t,e){t.setVisible(e)}};function eG(t){var{options:e,draggable:n,editable:r,visible:s,path:i,paths:a,onDblClick:l,onDragEnd:c,onDragStart:d,onMouseDown:h,onMouseMove:f,onMouseOut:p,onMouseOver:g,onMouseUp:v,onRightClick:x,onClick:y,onDrag:b,onLoad:w,onUnmount:j,onEdit:E}=t,P=u.useContext(ut),[A,N]=u.useState(null),[_,k]=u.useState(null),[L,I]=u.useState(null),[S,T]=u.useState(null),[V,$]=u.useState(null),[H,W]=u.useState(null),[D,F]=u.useState(null),[O,Y]=u.useState(null),[G,q]=u.useState(null),[re,U]=u.useState(null),[ee,K]=u.useState(null),[ue,be]=u.useState(null);return u.useEffect(()=>{A!==null&&A.setMap(P)},[P]),u.useEffect(()=>{typeof e<"u"&&A!==null&&A.setOptions(e)},[A,e]),u.useEffect(()=>{typeof n<"u"&&A!==null&&A.setDraggable(n)},[A,n]),u.useEffect(()=>{typeof r<"u"&&A!==null&&A.setEditable(r)},[A,r]),u.useEffect(()=>{typeof s<"u"&&A!==null&&A.setVisible(s)},[A,s]),u.useEffect(()=>{typeof i<"u"&&A!==null&&A.setPath(i)},[A,i]),u.useEffect(()=>{typeof a<"u"&&A!==null&&A.setPaths(a)},[A,a]),u.useEffect(()=>{A&&typeof l=="function"&&(_!==null&&google.maps.event.removeListener(_),k(google.maps.event.addListener(A,"dblclick",l)))},[l]),u.useEffect(()=>{A&&(google.maps.event.addListener(A.getPath(),"insert_at",()=>{E==null||E(A)}),google.maps.event.addListener(A.getPath(),"set_at",()=>{E==null||E(A)}),google.maps.event.addListener(A.getPath(),"remove_at",()=>{E==null||E(A)}))},[A,E]),u.useEffect(()=>{A&&typeof c=="function"&&(L!==null&&google.maps.event.removeListener(L),I(google.maps.event.addListener(A,"dragend",c)))},[c]),u.useEffect(()=>{A&&typeof d=="function"&&(S!==null&&google.maps.event.removeListener(S),T(google.maps.event.addListener(A,"dragstart",d)))},[d]),u.useEffect(()=>{A&&typeof h=="function"&&(V!==null&&google.maps.event.removeListener(V),$(google.maps.event.addListener(A,"mousedown",h)))},[h]),u.useEffect(()=>{A&&typeof f=="function"&&(H!==null&&google.maps.event.removeListener(H),W(google.maps.event.addListener(A,"mousemove",f)))},[f]),u.useEffect(()=>{A&&typeof p=="function"&&(D!==null&&google.maps.event.removeListener(
3538D),F(google.maps.event.addListener(A,"mouseout",p)))},[p]),u.useEffect(()=>{A&&typeof g=="function"&&(O!==null&&google.maps.event.removeListener(O),Y(google.maps.event.addListener(A,"mouseover",g)))},[g]),u.useEffect(()=>{A&&typeof v=="function"&&(G!==null&&google.maps.event.removeListener(G),q(google.maps.event.addListener(A,"mouseup",v)))},[v]),u.useEffect(()=>{A&&typeof x=="function"&&(re!==null&&google.maps.event.removeListener(re),U(google.maps.event.addListener(A,"rightclick",x)))},[x]),u.useEffect(()=>{A&&typeof y=="function"&&(ee!==null&&google.maps.event.removeListener(ee),K(google.maps.event.addListener(A,"click",y)))},[y]),u.useEffect(()=>{A&&typeof b=="function"&&(ue!==null&&google.maps.event.removeListener(ue),be(google.maps.event.addListener(A,"drag",b)))},[b]),u.useEffect(()=>{var le=new google.maps.Polygon(ek(ek({},e),{},{map:P}));return i&&le.setPath(i),a&&le.setPaths(a),typeof s<"u"&&le.setVisible(s),typeof r<"u"&&le.setEditable(r),typeof n<"u"&&le.setDraggable(n),l&&k(google.maps.event.addListener(le,"dblclick",l)),c&&I(google.maps.event.addListener(le,"dragend",c)),d&&T(google.maps.event.addListener(le,"dragstart",d)),h&&$(google.maps.event.addListener(le,"mousedown",h)),f&&W(google.maps.event.addListener(le,"mousemove",f)),p&&F(google.maps.event.addListener(le,"mouseout",p)),g&&Y(google.maps.event.addListener(le,"mouseover",g)),v&&q(google.maps.event.addListener(le,"mouseup",v)),x&&U(google.maps.event.addListener(le,"rightclick",x)),y&&K(google.maps.event.addListener(le,"click",y)),b&&be(google.maps.event.addListener(le,"drag",b)),N(le),w&&w(le),()=>{_!==null&&google.maps.event.removeListener(_),L!==null&&google.maps.event.removeListener(L),S!==null&&google.maps.event.removeListener(S),V!==null&&google.maps.event.removeListener(V),H!==null&&google.maps.event.removeListener(H),D!==null&&google.maps.event.removeListener(D),O!==null&&google.maps.event.removeListener(O),G!==null&&google.maps.event.removeListener(G),re!==null&&google.maps.event.removeListener(re),ee!==null&&google.maps.event.removeListener(ee),j&&j(le),le.setMap(null)}},[]),null}u.memo(eG);class Oh extends u.PureComponent{constructor(){super(...arguments),ce(this,"registeredEvents",[])}componentDidMount(){var e=this.props.options||{};this.polygon=new google.maps.Polygon(e),this.polygon.setMap(this.context),this.registeredEvents=gt({updaterMap:nk,eventMap:tk,prevProps:{},nextProps:this.props,instance:this.polygon}),this.props.onLoad&&this.props.onLoad(this.polygon)}componentDidUpdate(e){this.polygon&&(yt(this.registeredEvents),this.registeredEvents=gt({updaterMap:nk,eventMap:tk,prevProps:e,nextProps:this.props,instance:this.polygon}))}componentWillUnmount(){this.polygon&&(this.props.onUnmount&&this.props.onUnmount(this.polygon),yt(this.registeredEvents),this.polygon&&this.polygon.setMap(null))}render(){return null}}ce(Oh,"contextType",ut);function rk(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function Xg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?rk(Object(n),!0).forEach(function(r){ce(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):rk(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var sk={onBoundsChanged:"bounds_changed",onClick:"click",onDblClick:"dblclick",onDrag:"drag",onDragEnd:"dragend",onDragStart:"dragstart",onMouseDown:"mousedown",onMouseMove:"mousemove",onMouseOut:"mouseout",onMouseOver:"mouseover",onMouseUp:"mouseup",onRightClick:"rightclick"},ok={bounds(t,e){t.setBounds(e)},draggable(t,e){t.setDraggable(e)},editable(t,e){t.setEditable(e)},map(t,e){t.setMap(e)},options(t,e){t.setOptions(e)},visible(t,e){t.setVisible(e)}};function tG(t){var{options:e,bounds:n,draggable:r,editable:s,visible:i,onDblClick:a,onDragEnd:l,onDragStart:c,onMouseDown:d,onMouseMove:h,onMouseOut:f,onMouseOver:p,onMouseUp:g,onRightClick:v,onClick:x,onDrag:y,onBoundsChanged:b,onLoad:w,onUnmount:j}=t,E=u.useContext(ut),[P,A]=u.useState(null),[N,_]=u.useState(null),[k,L]=u.useState(null),[I,S]=u.useState(null),[T,V]=u.useState(null),[$,H]=u.useState(null),[W,D]=u.useState(null),[F,O]=u.useState(null),[Y,G]=u.useState(null),[q,re]=u.useState(null),[U,ee]=u.useState(null),[K,ue]=u.useState(null),[be,le]=u.useState(null);return u.useEffect(()=>{P!==null&&P.setMap(E)},[E]),u.useEffect(()=>{typeof e<"u"&&P!==null&&P.setOptions(e)},[P,e]),u.useEffect(()=>{typeof r<"u"&&P!==null&&P.setDraggable(r)},[P,r]),u.useEffect(()=>{typeof s<"u"&&P!==null&&P.setEditable(s)},[P,s]),u.useEffect(()=>{typeof i<"u"&&P!==null&&P.setVisible(i)},[P,i]),u.useEffect(()=>{typeof n<"u"&&P!==null&&P.setBounds(n)},[P,n]),u.useEffect(()=>{P&&a&&(N!==null&&google.maps.event.removeListener(N),_(google.maps.event.addListener(P,"dblclick",a)))},[a]),u.useEffect(()=>{P&&l&&(k!==null&&google.maps.event.removeListener(k),L(google.maps.event.addListener(P,"dragend",l)))},[l]),u.useEffect(()=>{P&&c&&(I!==null&&google.maps.event.removeListener(I),S(google.maps.event.addListener(P,"dragstart",c)))},[c]),u.useEffect(()=>{P&&d&&(T!==null&&google.maps.event.removeListener(T),V(google.maps.event.addListener(P,"mousedown",d)))},[d]),u.useEffect(()=>{P&&h&&($!==null&&google.maps.event.removeListener($),H(google.maps.event.addListener(P,"mousemove",h)))},[h]),u.useEffect(()=>{P&&f&&(W!==null&&google.maps.event.removeListener(W),D(google.maps.event.addListener(P,"mouseout",f)))},[f]),u.useEffect(()=>{P&&p&&(F!==null&&google.maps.event.removeListener(F),O(google.maps.event.addListener(P,"mouseover",p)))}
3538,[p]),u.useEffect(()=>{P&&g&&(Y!==null&&google.maps.event.removeListener(Y),G(google.maps.event.addListener(P,"mouseup",g)))},[g]),u.useEffect(()=>{P&&v&&(q!==null&&google.maps.event.removeListener(q),re(google.maps.event.addListener(P,"rightclick",v)))},[v]),u.useEffect(()=>{P&&x&&(U!==null&&google.maps.event.removeListener(U),ee(google.maps.event.addListener(P,"click",x)))},[x]),u.useEffect(()=>{P&&y&&(K!==null&&google.maps.event.removeListener(K),ue(google.maps.event.addListener(P,"drag",y)))},[y]),u.useEffect(()=>{P&&b&&(be!==null&&google.maps.event.removeListener(be),le(google.maps.event.addListener(P,"bounds_changed",b)))},[b]),u.useEffect(()=>{var B=new google.maps.Rectangle(Xg(Xg({},e),{},{map:E}));return typeof i<"u"&&B.setVisible(i),typeof s<"u"&&B.setEditable(s),typeof r<"u"&&B.setDraggable(r),typeof n<"u"&&B.setBounds(n),a&&_(google.maps.event.addListener(B,"dblclick",a)),l&&L(google.maps.event.addListener(B,"dragend",l)),c&&S(google.maps.event.addListener(B,"dragstart",c)),d&&V(google.maps.event.addListener(B,"mousedown",d)),h&&H(google.maps.event.addListener(B,"mousemove",h)),f&&D(google.maps.event.addListener(B,"mouseout",f)),p&&O(google.maps.event.addListener(B,"mouseover",p)),g&&G(google.maps.event.addListener(B,"mouseup",g)),v&&re(google.maps.event.addListener(B,"rightclick",v)),x&&ee(google.maps.event.addListener(B,"click",x)),y&&ue(google.maps.event.addListener(B,"drag",y)),b&&le(google.maps.event.addListener(B,"bounds_changed",b)),A(B),w&&w(B),()=>{N!==null&&google.maps.event.removeListener(N),k!==null&&google.maps.event.removeListener(k),I!==null&&google.maps.event.removeListener(I),T!==null&&google.maps.event.removeListener(T),$!==null&&google.maps.event.removeListener($),W!==null&&google.maps.event.removeListener(W),F!==null&&google.maps.event.removeListener(F),Y!==null&&google.maps.event.removeListener(Y),q!==null&&google.maps.event.removeListener(q),U!==null&&google.maps.event.removeListener(U),K!==null&&google.maps.event.removeListener(K),be!==null&&google.maps.event.removeListener(be),j&&j(B),B.setMap(null)}},[]),null}u.memo(tG);class nG extends u.PureComponent{constructor(){super(...arguments),ce(this,"registeredEvents",[]),ce(this,"state",{rectangle:null}),ce(this,"setRectangleCallback",()=>{this.state.rectangle!==null&&this.props.onLoad&&this.props.onLoad(this.state.rectangle)})}componentDidMount(){var e=new google.maps.Rectangle(Xg(Xg({},this.props.options),{},{map:this.context}));this.registeredEvents=gt({updaterMap:ok,eventMap:sk,prevProps:{},nextProps:this.props,instance:e}),this.setState(function(){return{rectangle:e}},this.setRectangleCallback)}componentDidUpdate(e){this.state.rectangle!==null&&(yt(this.registeredEvents),this.registeredEvents=gt({updaterMap:ok,eventMap:sk,prevProps:e,nextProps:this.props,instance:this.state.rectangle}))}componentWillUnmount(){this.state.rectangle!==null&&(this.props.onUnmount&&this.props.onUnmount(this.state.rectangle),yt(this.registeredEvents),this.state.rectangle.setMap(null))}render(){return null}}ce(nG,"contextType",ut);function ik(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function Jg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ik(Object(n),!0).forEach(function(r){ce(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ik(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var ak={onCenterChanged:"center_changed",onRadiusChanged:"radius_changed",onClick:"click",onDblClick:"dblclick",onDrag:"drag",onDragEnd:"dragend",onDragStart:"dragstart",onMouseDown:"mousedown",onMouseMove:"mousemove",onMouseOut:"mouseout",onMouseOver:"mouseover",onMouseUp:"mouseup",onRightClick:"rightclick"},lk={center(t,e){t.setCenter(e)},draggable(t,e){t.setDraggable(e)},editable(t,e){t.setEditable(e)},map(t,e){t.setMap(e)},options(t,e){t.setOptions(e)},radius(t,e){t.setRadius(e)},visible(t,e){t.setVisible(e)}},rG={};function sG(t){var{options:e,center:n,radius:r,draggable:s,editable:i,visible:a,onDblClick:l,onDragEnd:c,onDragStart:d,onMouseDown:h,onMouseMove:f,onMouseOut:p,onMouseOver:g,onMouseUp:v,onRightClick:x,onClick:y,onDrag:b,onCenterChanged:w,onRadiusChanged:j,onLoad:E,onUnmount:P}=t,A=u.useContext(ut),[N,_]=u.useState(null),[k,L]=u.useState(null),[I,S]=u.useState(null),[T,V]=u.useState(null),[$,H]=u.useState(null),[W,D]=u.useState(null),[F,O]=u.useState(null),[Y,G]=u.useState(null),[q,re]=u.useState(null),[U,ee]=u.useState(null),[K,ue]=u.useState(null),[be,le]=u.useState(null),[B,Q]=u.useState(null),[ve,Ae]=u.useState(null);return u.useEffect(()=>{N!==null&&N.setMap(A)},[A]),u.useEffect(()=>{typeof e<"u"&&N!==null&&N.setOptions(e)},[N,e]),u.useEffect(()=>{typeof s<"u"&&N!==null&&N.setDraggable(s)},[N,s]),u.useEffect(()=>{typeof i<"u"&&N!==null&&N.setEditable(i)},[N,i]),u.useEffect(()=>{typeof a<"u"&&N!==null&&N.setVisible(a)},[N,a]),u.useEffect(()=>{typeof r=="number"&&N!==null&&N.setRadius(r)},[N,r]),u.useEffect(()=>{typeof n<"u"&&N!==null&&N.setCenter(n)},[N,n]),u.useEffect(()=>{N&&l&&(k!==null&&google.maps.event.removeListener(k),L(google.maps.event.addListener(N,"dblclick",l)))},[l]),u.useEffect(()=>{N&&c&&(I!==null&&google.maps.event.removeListener(I),S(google.maps.event.addListener(N,"dragend",c)))},[c]),u.useEffect(()=>{N&&d&&(T!==null&&google.maps.event.removeListener(T),V(google.maps.event.addListener(N,"dragstart",d)))},[d]),u.useEffect(()=>{N&&h&&($!==null&&google.maps.event.removeListener($),H(google.maps.event.addListener(N,"mousedown",h)))},[h]),u.useEffect(()=>{N&&f&&(W!==null&&google.maps.event.removeListener(W),D(google.maps.event.addListener(N,"mousemove",f)))},[f]),u.useEffect(()=>{N&&p&&(F!==null&&google.maps.event.removeListener(F),O(google.maps.event.addListener(N,"mouseout",p)))}
3538,[p]),u.useEffect(()=>{N&&g&&(Y!==null&&google.maps.event.removeListener(Y),G(google.maps.event.addListener(N,"mouseover",g)))},[g]),u.useEffect(()=>{N&&v&&(q!==null&&google.maps.event.removeListener(q),re(google.maps.event.addListener(N,"mouseup",v)))},[v]),u.useEffect(()=>{N&&x&&(U!==null&&google.maps.event.removeListener(U),ee(google.maps.event.addListener(N,"rightclick",x)))},[x]),u.useEffect(()=>{N&&y&&(K!==null&&google.maps.event.removeListener(K),ue(google.maps.event.addListener(N,"click",y)))},[y]),u.useEffect(()=>{N&&b&&(be!==null&&google.maps.event.removeListener(be),le(google.maps.event.addListener(N,"drag",b)))},[b]),u.useEffect(()=>{N&&w&&(B!==null&&google.maps.event.removeListener(B),Q(google.maps.event.addListener(N,"center_changed",w)))},[y]),u.useEffect(()=>{N&&j&&(ve!==null&&google.maps.event.removeListener(ve),Ae(google.maps.event.addListener(N,"radius_changed",j)))},[j]),u.useEffect(()=>{var he=new google.maps.Circle(Jg(Jg({},e||rG),{},{map:A}));return typeof r=="number"&&he.setRadius(r),typeof n<"u"&&he.setCenter(n),typeof r=="number"&&he.setRadius(r),typeof a<"u"&&he.setVisible(a),typeof i<"u"&&he.setEditable(i),typeof s<"u"&&he.setDraggable(s),l&&L(google.maps.event.addListener(he,"dblclick",l)),c&&S(google.maps.event.addListener(he,"dragend",c)),d&&V(google.maps.event.addListener(he,"dragstart",d)),h&&H(google.maps.event.addListener(he,"mousedown",h)),f&&D(google.maps.event.addListener(he,"mousemove",f)),p&&O(google.maps.event.addListener(he,"mouseout",p)),g&&G(google.maps.event.addListener(he,"mouseover",g)),v&&re(google.maps.event.addListener(he,"mouseup",v)),x&&ee(google.maps.event.addListener(he,"rightclick",x)),y&&ue(google.maps.event.addListener(he,"click",y)),b&&le(google.maps.event.addListener(he,"drag",b)),w&&Q(google.maps.event.addListener(he,"center_changed",w)),j&&Ae(google.maps.event.addListener(he,"radius_changed",j)),_(he),E&&E(he),()=>{k!==null&&google.maps.event.removeListener(k),I!==null&&google.maps.event.removeListener(I),T!==null&&google.maps.event.removeListener(T),$!==null&&google.maps.event.removeListener($),W!==null&&google.maps.event.removeListener(W),F!==null&&google.maps.event.removeListener(F),Y!==null&&google.maps.event.removeListener(Y),q!==null&&google.maps.event.removeListener(q),U!==null&&google.maps.event.removeListener(U),K!==null&&google.maps.event.removeListener(K),B!==null&&google.maps.event.removeListener(B),ve!==null&&google.maps.event.removeListener(ve),P&&P(he),he.setMap(null)}},[]),null}u.memo(sG);class oG extends u.PureComponent{constructor(){super(...arguments),ce(this,"registeredEvents",[]),ce(this,"state",{circle:null}),ce(this,"setCircleCallback",()=>{this.state.circle!==null&&this.props.onLoad&&this.props.onLoad(this.state.circle)})}componentDidMount(){var e=new google.maps.Circle(Jg(Jg({},this.props.options),{},{map:this.context}));this.registeredEvents=gt({updaterMap:lk,eventMap:ak,prevProps:{},nextProps:this.props,instance:e}),this.setState(function(){return{circle:e}},this.setCircleCallback)}componentDidUpdate(e){this.state.circle!==null&&(yt(this.registeredEvents),this.registeredEvents=gt({updaterMap:lk,eventMap:ak,prevProps:e,nextProps:this.props,instance:this.state.circle}))}componentWillUnmount(){if(this.state.circle!==null){var e;this.props.onUnmount&&this.props.onUnmount(this.state.circle),yt(this.registeredEvents),(e=this.state.circle)===null||e===void 0||e.setMap(null)}}render(){return null}}ce(oG,"contextType",ut);function ck(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function ev(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ck(Object(n),!0).forEach(function(r){ce(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ck(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var uk={onClick:"click",onDblClick:"dblclick",onMouseDown:"mousedown",onMouseOut:"mouseout",onMouseOver:"mouseover",onMouseUp:"mouseup",onRightClick:"rightclick",onAddFeature:"addfeature",onRemoveFeature:"removefeature",onRemoveProperty:"removeproperty",onSetGeometry:"setgeometry",onSetProperty:"setproperty"},dk={add(t,e){t.add(e)},addgeojson(t,e,n){t.addGeoJson(e,n)},contains(t,e){t.contains(e)},foreach(t,e){t.forEach(e)},loadgeojson(t,e,n,r){t.loadGeoJson(e,n,r)},overridestyle(t,e,n){t.overrideStyle(e,n)},remove(t,e){t.remove(e)},revertstyle(t,e){t.revertStyle(e)},controlposition(t,e){t.setControlPosition(e)},controls(t,e){t.setControls(e)},drawingmode(t,e){t.setDrawingMode(e)},map(t,e){t.setMap(e)},style(t,e){t.setStyle(e)},togeojson(t,e){t.toGeoJson(e)}};function iG(t){var{options:e,onClick:n,onDblClick:r,onMouseDown:s,onMouseMove:i,onMouseOut:a,onMouseOver:l,onMouseUp:c,onRightClick:d,onAddFeature:h,onRemoveFeature:f,onRemoveProperty:p,onSetGeometry:g,onSetProperty:v,onLoad:x,onUnmount:y}=t,b=u.useContext(ut),[w,j]=u.useState(null),[E,P]=u.useState(null),[A,N]=u.useState(null),[_,k]=u.useState(null),[L,I]=u.useState(null),[S,T]=u.useState(null),[V,$]=u.useState(null),[H,W]=u.useState(null),[D,F]=u.useState(null),[O,Y]=u.useState(null),[G,q]=u.useState(null),[re,U]=u.useState(null),[ee,K]=u.useState(null),[ue,be]=u.useState(null);return u.useEffect(()=>{w!==null&&w.setMap(b)},[b]),u.useEffect(()=>{w&&r&&(E!==null&&google.maps.event.removeListener(E),P(google.maps.event.addListener(w,"dblclick",r)))},[r]),u.useEffect(()=>{w&&s&&(A!==null&&google.maps.event.removeListener(A),N(google.maps.event.addListener(w,"mousedown",s)))},[s]),u.useEffect(()=>{w&&i&&(_!==null&&google.maps.event.removeListener(_),k(google.maps.event.addListener(w,"mousemove",i)))},[i]),u.useEffect(()=>{w&&a&&(L!==null&&google.maps.event.removeListener(L),I(google.maps.event.addListener(w,"mouseout",a))
3538)},[a]),u.useEffect(()=>{w&&l&&(S!==null&&google.maps.event.removeListener(S),T(google.maps.event.addListener(w,"mouseover",l)))},[l]),u.useEffect(()=>{w&&c&&(V!==null&&google.maps.event.removeListener(V),$(google.maps.event.addListener(w,"mouseup",c)))},[c]),u.useEffect(()=>{w&&d&&(H!==null&&google.maps.event.removeListener(H),W(google.maps.event.addListener(w,"rightclick",d)))},[d]),u.useEffect(()=>{w&&n&&(D!==null&&google.maps.event.removeListener(D),F(google.maps.event.addListener(w,"click",n)))},[n]),u.useEffect(()=>{w&&h&&(O!==null&&google.maps.event.removeListener(O),Y(google.maps.event.addListener(w,"addfeature",h)))},[h]),u.useEffect(()=>{w&&f&&(G!==null&&google.maps.event.removeListener(G),q(google.maps.event.addListener(w,"removefeature",f)))},[f]),u.useEffect(()=>{w&&p&&(re!==null&&google.maps.event.removeListener(re),U(google.maps.event.addListener(w,"removeproperty",p)))},[p]),u.useEffect(()=>{w&&g&&(ee!==null&&google.maps.event.removeListener(ee),K(google.maps.event.addListener(w,"setgeometry",g)))},[g]),u.useEffect(()=>{w&&v&&(ue!==null&&google.maps.event.removeListener(ue),be(google.maps.event.addListener(w,"setproperty",v)))},[v]),u.useEffect(()=>{if(b!==null){var le=new google.maps.Data(ev(ev({},e),{},{map:b}));r&&P(google.maps.event.addListener(le,"dblclick",r)),s&&N(google.maps.event.addListener(le,"mousedown",s)),i&&k(google.maps.event.addListener(le,"mousemove",i)),a&&I(google.maps.event.addListener(le,"mouseout",a)),l&&T(google.maps.event.addListener(le,"mouseover",l)),c&&$(google.maps.event.addListener(le,"mouseup",c)),d&&W(google.maps.event.addListener(le,"rightclick",d)),n&&F(google.maps.event.addListener(le,"click",n)),h&&Y(google.maps.event.addListener(le,"addfeature",h)),f&&q(google.maps.event.addListener(le,"removefeature",f)),p&&U(google.maps.event.addListener(le,"removeproperty",p)),g&&K(google.maps.event.addListener(le,"setgeometry",g)),v&&be(google.maps.event.addListener(le,"setproperty",v)),j(le),x&&x(le)}return()=>{w&&(E!==null&&google.maps.event.removeListener(E),A!==null&&google.maps.event.removeListener(A),_!==null&&google.maps.event.removeListener(_),L!==null&&google.maps.event.removeListener(L),S!==null&&google.maps.event.removeListener(S),V!==null&&google.maps.event.removeListener(V),H!==null&&google.maps.event.removeListener(H),D!==null&&google.maps.event.removeListener(D),O!==null&&google.maps.event.removeListener(O),G!==null&&google.maps.event.removeListener(G),re!==null&&google.maps.event.removeListener(re),ee!==null&&google.maps.event.removeListener(ee),ue!==null&&google.maps.event.removeListener(ue),y&&y(w),w.setMap(null))}},[]),null}u.memo(iG);class aG extends u.PureComponent{constructor(){super(...arguments),ce(this,"registeredEvents",[]),ce(this,"state",{data:null}),ce(this,"setDataCallback",()=>{this.state.data!==null&&this.props.onLoad&&this.props.onLoad(this.state.data)})}componentDidMount(){if(this.context!==null){var e=new google.maps.Data(ev(ev({},this.props.options),{},{map:this.context}));this.registeredEvents=gt({updaterMap:dk,eventMap:uk,prevProps:{},nextProps:this.props,instance:e}),this.setState(()=>({data:e}),this.setDataCallback)}}componentDidUpdate(e){this.state.data!==null&&(yt(this.registeredEvents),this.registeredEvents=gt({updaterMap:dk,eventMap:uk,prevProps:e,nextProps:this.props,instance:this.state.data}))}componentWillUnmount(){this.state.data!==null&&(this.props.onUnmount&&this.props.onUnmount(this.state.data),yt(this.registeredEvents),this.state.data&&this.state.data.setMap(null))}render(){return null}}ce(aG,"contextType",ut);function hk(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function fk(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?hk(Object(n),!0).forEach(function(r){ce(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):hk(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var mk={onClick:"click",onDefaultViewportChanged:"defaultviewport_changed",onStatusChanged:"status_changed"},pk={options(t,e){t.setOptions(e)},url(t,e){t.setUrl(e)},zIndex(t,e){t.setZIndex(e)}};class lG extends u.PureComponent{constructor(){super(...arguments),ce(this,"registeredEvents",[]),ce(this,"state",{kmlLayer:null}),ce(this,"setKmlLayerCallback",()=>{this.state.kmlLayer!==null&&this.props.onLoad&&this.props.onLoad(this.state.kmlLayer)})}componentDidMount(){var e=new google.maps.KmlLayer(fk(fk({},this.props.options),{},{map:this.context}));this.registeredEvents=gt({updaterMap:pk,eventMap:mk,prevProps:{},nextProps:this.props,instance:e}),this.setState(function(){return{kmlLayer:e}},this.setKmlLayerCallback)}componentDidUpdate(e){this.state.kmlLayer!==null&&(yt(this.registeredEvents),this.registeredEvents=gt({updaterMap:pk,eventMap:mk,prevProps:e,nextProps:this.props,instance:this.state.kmlLayer}))}componentWillUnmount(){this.state.kmlLayer!==null&&(this.props.onUnmount&&this.props.onUnmount(this.state.kmlLayer),yt(this.registeredEvents),this.state.kmlLayer.setMap(null))}render(){return null}}ce(lG,"contextType",ut);function GD(t,e){return typeof e=="function"?e(t.offsetWidth,t.offsetHeight):{x:0,y:0}}function cG(t,e){return new e(t.lat,t.lng)}function uG(t,e){return new e(new google.maps.LatLng(t.ne.lat,t.ne.lng),new google.maps.LatLng(t.sw.lat,t.sw.lng))}function dG(t,e,n){return t instanceof e?t:n(t,e)}function hG(t,e,n){return t instanceof e?t:n(t,e)}function fG(t,e,n){var r=t&&t.fromLatLngToDivPixel(n.getNorthEast()),s=t&&t.fromLatLngToDivPixel(n.getSouthWest
3538());return r&&s?{left:"".concat(s.x+e.x,"px"),top:"".concat(r.y+e.y,"px"),width:"".concat(r.x-s.x-e.x,"px"),height:"".concat(s.y-r.y-e.y,"px")}:{left:"-9999px",top:"-9999px"}}function mG(t,e,n){var r=t&&t.fromLatLngToDivPixel(n);if(r){var{x:s,y:i}=r;return{left:"".concat(s+e.x,"px"),top:"".concat(i+e.y,"px")}}return{left:"-9999px",top:"-9999px"}}function ZD(t,e,n,r){return n!==void 0?fG(t,e,hG(n,google.maps.LatLngBounds,uG)):mG(t,e,dG(r,google.maps.LatLng,cG))}function pG(t,e){return t.left===e.left&&t.top===e.top&&t.width===e.height&&t.height===e.height}function gk(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function gG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?gk(Object(n),!0).forEach(function(r){ce(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):gk(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function vG(t,e,n,r,s){class i extends google.maps.OverlayView{constructor(l,c,d,h){super(),this.container=l,this.pane=c,this.position=d,this.bounds=h}onAdd(){var l,c=(l=this.getPanes())===null||l===void 0?void 0:l[this.pane];c==null||c.appendChild(this.container)}draw(){var l=this.getProjection(),c=gG({},this.container?GD(this.container,s):{x:0,y:0}),d=ZD(l,c,this.bounds,this.position);for(var[h,f]of Object.entries(d))this.container.style[h]=f}onRemove(){this.container.parentNode!==null&&this.container.parentNode.removeChild(this.container)}}return new i(t,e,n,r)}function vk(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function xG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?vk(Object(n),!0).forEach(function(r){ce(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):vk(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function xk(t){if(!t)return"";var e=t instanceof google.maps.LatLng?t:new google.maps.LatLng(t.lat,t.lng);return e+""}function yk(t){if(!t)return"";var e=t instanceof google.maps.LatLngBounds?t:new google.maps.LatLngBounds(new google.maps.LatLng(t.south,t.east),new google.maps.LatLng(t.north,t.west));return e+""}function yG(t){var{position:e,bounds:n,mapPaneName:r,zIndex:s,onLoad:i,onUnmount:a,getPixelPositionOffset:l,children:c}=t,d=u.useContext(ut),h=u.useMemo(()=>{var p=document.createElement("div");return p.style.position="absolute",p},[]),f=u.useMemo(()=>vG(h,r,e,n,l),[h,r,e,n]);return u.useEffect(()=>(i==null||i(f),f==null||f.setMap(d),()=>{a==null||a(f),f==null||f.setMap(null)}),[d,f]),u.useEffect(()=>{h.style.zIndex="".concat(s)},[s,h]),ps.createPortal(c,h)}u.memo(yG);class ud extends u.PureComponent{constructor(e){super(e),ce(this,"state",{paneEl:null,containerStyle:{position:"absolute"}}),ce(this,"updatePane",()=>{var r=this.props.mapPaneName,s=this.overlayView.getPanes();tr(!!r,"OverlayView requires props.mapPaneName but got %s",r),s?this.setState({paneEl:s[r]}):this.setState({paneEl:null})}),ce(this,"onAdd",()=>{var r,s;this.updatePane(),(r=(s=this.props).onLoad)===null||r===void 0||r.call(s,this.overlayView)}),ce(this,"onPositionElement",()=>{var r=this.overlayView.getProjection(),s=xG({x:0,y:0},this.containerRef.current?GD(this.containerRef.current,this.props.getPixelPositionOffset):{}),i=ZD(r,s,this.props.bounds,this.props.position);if(!pG(i,{left:this.state.containerStyle.left,top:this.state.containerStyle.top,width:this.state.containerStyle.width,height:this.state.containerStyle.height})){var a,l,c,d;this.setState({containerStyle:{top:(a=i.top)!==null&&a!==void 0?a:0,left:(l=i.left)!==null&&l!==void 0?l:0,width:(c=i.width)!==null&&c!==void 0?c:0,height:(d=i.height)!==null&&d!==void 0?d:0,position:"absolute"}})}}),ce(this,"draw",()=>{this.onPositionElement()}),ce(this,"onRemove",()=>{var r,s;this.setState(()=>({paneEl:null})),(r=(s=this.props).onUnmount)===null||r===void 0||r.call(s,this.overlayView)}
3538),this.containerRef=u.createRef();var n=new google.maps.OverlayView;n.onAdd=this.onAdd,n.draw=this.draw,n.onRemove=this.onRemove,this.overlayView=n}componentDidMount(){this.overlayView.setMap(this.context)}componentDidUpdate(e){var n=xk(e.position),r=xk(this.props.position),s=yk(e.bounds),i=yk(this.props.bounds);(n!==r||s!==i)&&this.overlayView.draw(),e.mapPaneName!==this.props.mapPaneName&&this.updatePane()}componentWillUnmount(){this.overlayView.setMap(null)}render(){var e=this.state.paneEl;return e?ps.createPortal(o.jsx("div",{ref:this.containerRef,style:this.state.containerStyle,children:u.Children.only(this.props.children)}),e):null}}ce(ud,"FLOAT_PANE","floatPane");ce(ud,"MAP_PANE","mapPane");ce(ud,"MARKER_LAYER","markerLayer");ce(ud,"OVERLAY_LAYER","overlayLayer");ce(ud,"OVERLAY_MOUSE_TARGET","overlayMouseTarget");ce(ud,"contextType",ut);function wG(){}function wk(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function bk(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?wk(Object(n),!0).forEach(function(r){ce(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):wk(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var jk={onDblClick:"dblclick",onClick:"click"},Ck={opacity(t,e){t.setOpacity(e)}};function bG(t){var{url:e,bounds:n,options:r,visible:s}=t,i=u.useContext(ut),a=new google.maps.LatLngBounds(new google.maps.LatLng(n.south,n.west),new google.maps.LatLng(n.north,n.east)),l=u.useMemo(()=>new google.maps.GroundOverlay(e,a,r),[]);return u.useEffect(()=>{l!==null&&l.setMap(i)},[i]),u.useEffect(()=>{typeof e<"u"&&l!==null&&(l.set("url",e),l.setMap(i))},[l,e]),u.useEffect(()=>{typeof s<"u"&&l!==null&&l.setOpacity(s?1:0)},[l,s]),u.useEffect(()=>{var c=new google.maps.LatLngBounds(new google.maps.LatLng(n.south,n.west),new google.maps.LatLng(n.north,n.east));typeof n<"u"&&l!==null&&(l.set("bounds",c),l.setMap(i))},[l,n]),null}u.memo(bG);class KD extends u.PureComponent{constructor(){super(...arguments),ce(this,"registeredEvents",[]),ce(this,"state",{groundOverlay:null}),ce(this,"setGroundOverlayCallback",()=>{this.state.groundOverlay!==null&&this.props.onLoad&&this.props.onLoad(this.state.groundOverlay)})}componentDidMount(){tr(!!this.props.url||!!this.props.bounds,"For GroundOverlay, url and bounds are passed in to constructor and are immutable after instantiated. This is the behavior of Google Maps JavaScript API v3 ( See https://developers.google.com/maps/documentation/javascript/reference#GroundOverlay) Hence, use the corresponding two props provided by `react-google-maps-api`, url and bounds. In some cases, you'll need the GroundOverlay component to reflect the changes of url and bounds. You can leverage the React's key property to remount the component. Typically, just `key={url}` would serve your need. See https://github.com/tomchentw/react-google-maps/issues/655");var e=new google.maps.GroundOverlay(this.props.url,this.props.bounds,bk(bk({},this.props.options),{},{map:this.context}));this.registeredEvents=gt({updaterMap:Ck,eventMap:jk,prevProps:{},nextProps:this.props,instance:e}),this.setState(function(){return{groundOverlay:e}},this.setGroundOverlayCallback)}componentDidUpdate(e){this.state.groundOverlay!==null&&(yt(this.registeredEvents),this.registeredEvents=gt({updaterMap:Ck,eventMap:jk,prevProps:e,nextProps:this.props,instance:this.state.groundOverlay}))}componentWillUnmount(){this.state.groundOverlay&&(this.props.onUnmount&&this.props.onUnmount(this.state.groundOverlay),this.state.groundOverlay.setMap(null))}render(){return null}}ce(KD,"defaultProps",{onLoad:wG});ce(KD,"contextType",ut);function Nk(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function tv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};
3538e%2?Nk(Object(n),!0).forEach(function(r){ce(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Nk(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var _k={},Ek={data(t,e){t.setData(e)},map(t,e){t.setMap(e)},options(t,e){t.setOptions(e)}};function jG(t){var{data:e,onLoad:n,onUnmount:r,options:s}=t,i=u.useContext(ut),[a,l]=u.useState(null);return u.useEffect(()=>{google.maps.visualization||tr(!!google.maps.visualization,'Did you include prop libraries={["visualization"]} in useJsApiScript? %s',google.maps.visualization)},[]),u.useEffect(()=>{tr(!!e,"data property is required in HeatmapLayer %s",e)},[e]),u.useEffect(()=>{a!==null&&a.setMap(i)},[i]),u.useEffect(()=>{s&&a!==null&&a.setOptions(s)},[a,s]),u.useEffect(()=>{var c=new google.maps.visualization.HeatmapLayer(tv(tv({},s),{},{data:e,map:i}));return l(c),n&&n(c),()=>{a!==null&&(r&&r(a),a.setMap(null))}},[]),null}u.memo(jG);class CG extends u.PureComponent{constructor(){super(...arguments),ce(this,"registeredEvents",[]),ce(this,"state",{heatmapLayer:null}),ce(this,"setHeatmapLayerCallback",()=>{this.state.heatmapLayer!==null&&this.props.onLoad&&this.props.onLoad(this.state.heatmapLayer)})}componentDidMount(){tr(!!google.maps.visualization,'Did you include prop libraries={["visualization"]} to <LoadScript />? %s',google.maps.visualization),tr(!!this.props.data,"data property is required in HeatmapLayer %s",this.props.data);var e=new google.maps.visualization.HeatmapLayer(tv(tv({},this.props.options),{},{data:this.props.data,map:this.context}));this.registeredEvents=gt({updaterMap:Ek,eventMap:_k,prevProps:{},nextProps:this.props,instance:e}),this.setState(function(){return{heatmapLayer:e}},this.setHeatmapLayerCallback)}componentDidUpdate(e){yt(this.registeredEvents),this.registeredEvents=gt({updaterMap:Ek,eventMap:_k,prevProps:e,nextProps:this.props,instance:this.state.heatmapLayer})}componentWillUnmount(){this.state.heatmapLayer!==null&&(this.props.onUnmount&&this.props.onUnmount(this.state.heatmapLayer),yt(this.registeredEvents),this.state.heatmapLayer.setMap(null))}render(){return null}}ce(CG,"contextType",ut);var Sk={onCloseClick:"closeclick",onPanoChanged:"pano_changed",onPositionChanged:"position_changed",onPovChanged:"pov_changed",onResize:"resize",onStatusChanged:"status_changed",onVisibleChanged:"visible_changed",onZoomChanged:"zoom_changed"},kk={register(t,e,n){t.registerPanoProvider(e,n)},links(t,e){t.setLinks(e)},motionTracking(t,e){t.setMotionTracking(e)},options(t,e){t.setOptions(e)},pano(t,e){t.setPano(e)},position(t,e){t.setPosition(e)},pov(t,e){t.setPov(e)},visible(t,e){t.setVisible(e)},zoom(t,e){t.setZoom(e)}};class NG extends u.PureComponent{constructor(){super(...arguments),ce(this,"registeredEvents",[]),ce(this,"state",{streetViewPanorama:null}),ce(this,"setStreetViewPanoramaCallback",()=>{this.state.streetViewPanorama!==null&&this.props.onLoad&&this.props.onLoad(this.state.streetViewPanorama)})}componentDidMount(){var e,n,r=(e=(n=this.context)===null||n===void 0?void 0:n.getStreetView())!==null&&e!==void 0?e:null;this.registeredEvents=gt({updaterMap:kk,eventMap:Sk,prevProps:{},nextProps:this.props,instance:r}),this.setState(()=>({streetViewPanorama:r}),this.setStreetViewPanoramaCallback)}componentDidUpdate(e){this.state.streetViewPanorama!==null&&(yt(this.registeredEvents),this.registeredEvents=gt({updaterMap:kk,eventMap:Sk,prevProps:e,nextProps:this.props,instance:this.state.streetViewPanorama}))}componentWillUnmount(){this.state.streetViewPanorama!==null&&(this.props.onUnmount&&this.props.onUnmount(this.state.streetViewPanorama),yt(this.registeredEvents),this.state.streetViewPanorama.setVisible(!1))}render(){return null}}ce(NG,"contextType",ut);class _G extends u.PureComponent{constructor(){super(...arguments),ce(this,"state",{streetViewService:null}),ce(this,"setStreetViewServiceCallback",()=>{this.state.streetViewService!==null&&this.props.onLoad&&this.props.onLoad(this.state.streetViewService)})}componentDidMount(){var e=new google.maps.StreetViewService;this.setState(function(){return{streetViewService:e}},this.setStreetViewServiceCallback)}componentWillUnmount(){this.state.streetViewService!==null&&this.props.onUnmount&&this.props.onUnmount(this.state.streetViewService)}render(){return null}}ce(_G,"contextType",ut);var Pk={onDirectionsChanged:"directions_changed"},Ik={directions(t,e){t.setDirections(e)},map(t,e){t.setMap(e)},options(t,e){t.setOptions(e)},panel(t,e){t.setPanel(e)},routeIndex(t,e){t.setRouteIndex(e)}};class EG extends u.PureComponent{constructor(){super(...arguments),ce(this,"registeredEvents",[]),ce(this,"state",{directionsRenderer:null}),ce(this,"setDirectionsRendererCallback",()=>{this.state.directionsRenderer!==null&&(this.state.directionsRenderer.setMap(this.context),this.props.onLoad&&this.props.onLoad(this.state.directionsRenderer))})}componentDidMount(){var e=new google.maps.DirectionsRenderer(this.props.options);this.registeredEvents=gt({updaterMap:Ik,eventMap:Pk,prevProps:{},nextProps:this.props,instance:e}),this.setState(function(){return{directionsRenderer:e}},this.setDirectionsRendererCallback)}componentDidUpdate(e){this.state.directionsRenderer!==null&&(yt(this.registeredEvents),this.registeredEvents=gt({updaterMap:Ik,eventMap:Pk,prevProps:e,nextProps:this.props,instance:this.state.directionsRenderer}))}componentWillUnmount(){this.state.directionsRenderer!==null&&(this.props.onUnmount&&this.props.onUnmount(this.state.directionsRenderer),yt(this.registeredEvents),this.state.directionsRenderer&&this.state.directionsRenderer.setMap(null))}render(){return null}}ce(EG,"contextType",ut);var Tk={onPlacesChanged:"places_changed"},Ak={bounds(t,e){t.setBounds(e)}};class SG extends u.PureComponent{constructor(){super(...arguments),ce(this,"registeredEvents",[]),ce(this,"containerElement",u.createRef()),ce(this,"state",{searchBox:null}),ce(this,"setSearchBoxCallback",()=>{this.state.searchBox!==null&&this.props.onLoad&&this.props.onLoad(this.state.searchBox
3538)})}componentDidMount(){if(tr(!!google.maps.places,'You need to provide libraries={["places"]} prop to <LoadScript /> component %s',google.maps.places),this.containerElement!==null&&this.containerElement.current!==null){var e=this.containerElement.current.querySelector("input");if(e!==null){var n=new google.maps.places.SearchBox(e,this.props.options);this.registeredEvents=gt({updaterMap:Ak,eventMap:Tk,prevProps:{},nextProps:this.props,instance:n}),this.setState(function(){return{searchBox:n}},this.setSearchBoxCallback)}}}componentDidUpdate(e){this.state.searchBox!==null&&(yt(this.registeredEvents),this.registeredEvents=gt({updaterMap:Ak,eventMap:Tk,prevProps:e,nextProps:this.props,instance:this.state.searchBox}))}componentWillUnmount(){this.state.searchBox!==null&&(this.props.onUnmount&&this.props.onUnmount(this.state.searchBox),yt(this.registeredEvents))}render(){return o.jsx("div",{ref:this.containerElement,children:u.Children.only(this.props.children)})}}ce(SG,"contextType",ut);var Rk={onPlaceChanged:"place_changed"},Dk={bounds(t,e){t.setBounds(e)},restrictions(t,e){t.setComponentRestrictions(e)},fields(t,e){t.setFields(e)},options(t,e){t.setOptions(e)},types(t,e){t.setTypes(e)}};class YD extends u.PureComponent{constructor(){super(...arguments),ce(this,"registeredEvents",[]),ce(this,"containerElement",u.createRef()),ce(this,"state",{autocomplete:null}),ce(this,"setAutocompleteCallback",()=>{this.state.autocomplete!==null&&this.props.onLoad&&this.props.onLoad(this.state.autocomplete)})}componentDidMount(){var e;tr(!!google.maps.places,'You need to provide libraries={["places"]} prop to <LoadScript /> component %s',google.maps.places);var n=(e=this.containerElement.current)===null||e===void 0?void 0:e.querySelector("input");if(n){var r=new google.maps.places.Autocomplete(n,this.props.options);this.registeredEvents=gt({updaterMap:Dk,eventMap:Rk,prevProps:{},nextProps:this.props,instance:r}),this.setState(()=>({autocomplete:r}),this.setAutocompleteCallback)}}componentDidUpdate(e){yt(this.registeredEvents),this.registeredEvents=gt({updaterMap:Dk,eventMap:Rk,prevProps:e,nextProps:this.props,instance:this.state.autocomplete})}componentWillUnmount(){this.state.autocomplete!==null&&yt(this.registeredEvents)}render(){return o.jsx("div",{ref:this.containerElement,className:this.props.className,children:u.Children.only(this.props.children)})}}ce(YD,"defaultProps",{className:""});ce(YD,"contextType",ut);function kG({children:t}){return o.jsx($D,{googleMapsApiKey:"AIzaSyByRW74GF7cyOjwhL6ZteycAyo5oKeLsqw",children:t})}function Lk(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function hx(...t){return e=>{let n=!1;const r=t.map(s=>{const i=Lk(s,e);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():Lk(t[s],null)}}}}function At(...t){return u.useCallback(hx(...t),t)}function Ga(t){const e=PG(t),n=u.forwardRef((r,s)=>{const{children:i,...a}=r,l=u.Children.toArray(i),c=l.find(TG);if(c){const d=c.props.children,h=l.map(f=>f===c?u.Children.count(d)>1?u.Children.only(null):u.isValidElement(d)?d.props.children:null:f);return o.jsx(e,{...a,ref:s,children:u.isValidElement(d)?u.cloneElement(d,void 0,h):null})}return o.jsx(e,{...a,ref:s,children:i})});return n.displayName=`${t}.Slot`,n}var QD=Ga("Slot");function PG(t){const e=u.forwardRef((n,r)=>{const{children:s,...i}=n;if(u.isValidElement(s)){const a=RG(s),l=AG(i,s.props);return s.type!==u.Fragment&&(l.ref=r?hx(r,a):a),u.cloneElement(s,l)}return u.Children.count(s)>1?u.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var XD=Symbol("radix.slottable");function IG(t){const e=({children:n})=>o.jsx(o.Fragment,{children:n});return e.displayName=`${t}.Slottable`,e.__radixId=XD,e}function TG(t){return u.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===XD}function AG(t,e){const n={...e};for(const r in e){const s=t[r],i=e[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}
vendor: 13,702 bytes, line 3538
3538:r==="className"&&(n[r]=[s,i].filter(Boolean).join(" "))}return{...t,...n}}function RG(t){var r,s;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(s=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function JD(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var s=t.length;for(e=0;e<s;e++)t[e]&&(n=JD(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function JC(){for(var t,e,n=0,r="",s=arguments.length;n<s;n++)(t=arguments[n])&&(e=JD(t))&&(r&&(r+=" "),r+=e);return r}const Mk=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,Ok=JC,fx=(t,e)=>n=>{var r;if((e==null?void 0:e.variants)==null)return Ok(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:s,defaultVariants:i}=e,a=Object.keys(s).map(d=>{const h=n==null?void 0:n[d],f=i==null?void 0:i[d];if(h===null)return null;const p=Mk(h)||Mk(f);return s[d][p]}),l=n&&Object.entries(n).reduce((d,h)=>{let[f,p]=h;return p===void 0||(d[f]=p),d},{}),c=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((d,h)=>{let{class:f,className:p,...g}=h;return Object.entries(g).every(v=>{let[x,y]=v;return Array.isArray(y)?y.includes({...i,...l}[x]):{...i,...l}[x]===y})?[...d,f,p]:d},[]);return Ok(t,a,c,n==null?void 0:n.class,n==null?void 0:n.className)},e1="-",DG=t=>{const e=MG(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:a=>{const l=a.split(e1);return l[0]===""&&l.length!==1&&l.shift(),eL(l,e)||LG(a)},getConflictingClassGroupIds:(a,l)=>{const c=n[a]||[];return l&&r[a]?[...c,...r[a]]:c}}},eL=(t,e)=>{var a;if(t.length===0)return e.classGroupId;const n=t[0],r=e.nextPart.get(n),s=r?eL(t.slice(1),r):void 0;if(s)return s;if(e.validators.length===0)return;const i=t.join(e1);return(a=e.validators.find(({validator:l})=>l(i)))==null?void 0:a.classGroupId},Fk=/^\[(.+)\]$/,LG=t=>{if(Fk.test(t)){const e=Fk.exec(t)[1],n=e==null?void 0:e.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},MG=t=>{const{theme:e,prefix:n}=t,r={nextPart:new Map,validators:[]};return FG(Object.entries(t.classGroups),n).forEach(([i,a])=>{fb(a,r,i,e)}),r},fb=(t,e,n,r)=>{t.forEach(s=>{if(typeof s=="string"){const i=s===""?e:zk(e,s);i.classGroupId=n;return}if(typeof s=="function"){if(OG(s)){fb(s(r),e,n,r);return}e.validators.push({validator:s,classGroupId:n});return}Object.entries(s).forEach(([i,a])=>{fb(a,zk(e,i),n,r)})})},zk=(t,e)=>{let n=t;return e.split(e1).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},OG=t=>t.isThemeGetter,FG=(t,e)=>e?t.map(([n,r])=>{const s=r.map(i=>typeof i=="string"?e+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([a,l])=>[e+a,l])):i);return[n,s]}):t,zG=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,r=new Map;const s=(i,a)=>{n.set(i,a),e++,e>t&&(e=0,r=n,n=new Map)};return{get(i){let a=n.get(i);if(a!==void 0)return a;if((a=r.get(i))!==void 0)return s(i,a),a},set(i,a){n.has(i)?n.set(i,a):s(i,a)}}},tL="!",$G=t=>{const{separator:e,experimentalParseClassName:n}=t,r=e.length===1,s=e[0],i=e.length,a=l=>{const c=[];let d=0,h=0,f;for(let y=0;y<l.length;y++){let b=l[y];if(d===0){if(b===s&&(r||l.slice(y,y+i)===e)){c.push(l.slice(h,y)),h=y+i;continue}if(b==="/"){f=y;continue}}b==="["?d++:b==="]"&&d--}const p=c.length===0?l:l.substring(h),g=p.startsWith(tL),v=g?p.substring(1):p,x=f&&f>h?f-h:void 0;return{modifiers:c,hasImportantModifier:g,baseClassName:v,maybePostfixModifierPosition:x}};return n?l=>n({className:l,parseClassName:a}):a},VG=t=>{if(t.length<=1)return t;const e=[];let n=[];return t.forEach(r=>{r[0]==="["?(e.push(...n.sort(),r),n=[]):n.push(r)}),e.push(...n.sort()),e},UG=t=>({cache:zG(t.cacheSize),parseClassName:$G(t),...DG(t)}),BG=/\s+/,WG=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:s}=e,i=[],a=t.trim().split(BG);let l="";for(let c=a.length-1;c>=0;c-=1){const d=a[c],{modifiers:h,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:g}=n(d);let v=!!g,x=r(v?p.substring(0,g):p);if(!x){if(!v){l=d+(l.length>0?" "+l:l);continue}if(x=r(p),!x){l=d+(l.length>0?" "+l:l);continue}v=!1}const y=VG(h).join(":"),b=f?y+tL:y,w=b+x;if(i.includes(w))continue;i.push(w);const j=s(x,v);for(let E=0;E<j.length;++E){const P=j[E];i.push(b+P)}l=d+(l.length>0?" "+l:l)}return l};function HG(){let t=0,e,n,r="";for(;t<arguments.length;)(e=arguments[t++])&&(n=nL(e))&&(r&&(r+=" "),r+=n);return r}const nL=t=>{if(typeof t=="string")return t;let e,n="";for(let r=0;r<t.length;r++)t[r]&&(e=nL(t[r]))&&(n&&(n+=" "),n+=e);return n};function qG(t,...e){let n,r,s,i=a;function a(c){const d=e.reduce((h,f)=>f(h),t());return n=UG(d),r=n.cache.get,s=n.cache.set,i=l,l(c)}function l(c){const d=r(c);if(d)return d;const h=WG(c,n);return s(c,h),h}return function(){return i(HG.apply(null,arguments))}}const dn=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},rL=/^\[(?:([a-z-]+):)?(.+)\]$/i,GG=/^\d+\/\d+$/,ZG=new Set(["px","full","screen"]),KG=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,YG=/\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$/,QG=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,XG=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,JG=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,di=t=>Cu(t)||ZG.has(t)||GG.test(t),Xi=t=>dd(t,"length",aZ),Cu=t=>!!t&&!Number.isNaN(Number(t)),qy=t=>dd(t,"number",Cu),Gd=t=>!!t&&Number.isInteger(Number(t)),eZ=t=>t.endsWith("%")&&Cu(t.slice(0,-1)),ct=t=>rL.test(t),Ji=t=>KG.test(t),tZ=new Set(["length","size","percentage"]),nZ=t=>dd(t,tZ,sL),rZ=t=>dd(t,"position",sL),sZ=new Set(["image","url"]),oZ=t=>dd(t,sZ,cZ),iZ=t=>dd(t,"",lZ),Zd=()=>!0,dd=(t,e,n)=>{const r=rL.exec(t);return r?r[1]?typeof e=="string"?r[1]===e:e.has(r[1]):n(r[2]):!1},aZ=t=>YG.test(t)&&!QG.test(t),sL=()=>!1,lZ=t=>XG.test(t),cZ=t=>JG.test(t),uZ=()=>{const t=dn("colors"),e=dn("spacing"),n=dn("blur"),r=dn("brightness"),s=dn("borderColor"),i=dn("borderRadius"),a=dn("borderSpacing"),l=dn("borderWidth"),c=dn("contrast"),d=dn("grayscale"),h=dn("hueRotate"),f=dn("invert"),p=dn("gap"),g=dn("gradientColorStops"),v=dn("gradientColorStopPositions"),x=dn("inset"),y=dn("margin"),b=dn("opacity"),w=dn("padding"),j=dn("saturate"),E=dn("scale"),P=dn("sepia"),A=dn("skew"),N=dn("space"),_=dn("translate"),k=()=>["auto","contain","none"],L=()=>["auto","hidden","clip","visible","scroll"],I=()=>["auto",ct,e],S=()=>[ct,e],T=()=>["",di,Xi],V=()=>["auto",Cu,ct],$=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],H=()=>["solid","dashed","dotted","double","none"],W=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],D=()=>["start","end","center","between","around","evenly","stretch"],F=()=>["","0",ct],O=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Y=()=>[Cu,ct];return{cacheSize:500,separator:":",theme:{colors:[Zd],spacing:[di,Xi],blur:["none","",Ji,ct],brightness:Y(),borderColor:[t],borderRadius:["none","","full",Ji,ct],borderSpacing:S(),borderWidth:T(),contrast:Y(),grayscale:F(),hueRotate:Y(),invert:F(),gap:S(),gradientColorStops:[t],gradientColorStopPositions:[eZ,Xi],inset:I(),margin:I(),opacity:Y(),padding:S(),saturate:Y(),scale:Y(),sepia:F(),skew:Y(),space:S(),translate:S()},classGroups:{aspect:[{aspect:["auto","square","video",ct]}],container:["container"],columns:[{columns:[Ji]}],"break-after":[{"break-after":O()}],"break-before":[{"break-before":O()}],"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:[...$(),ct]}],overflow:[{overflow:L()}],"overflow-x":[{"overflow-x":L()}],"overflow-y":[{"overflow-y":L()}],overscroll:[{overscroll:k()}],"overscroll-x":[{"overscroll-x":k()}],"overscroll-y":[{"overscroll-y":k()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[x]}],"inset-x":[{"inset-x":[x]}],"inset-y":[{"inset-y":[x]}],start:[{start:[x]}],end:[{end:[x]}],top:[{top:[x]}],right:[{right:[x]}],bottom:[{bottom:[x]}],left:[{left:[x]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Gd,ct]}],basis:[{basis:I()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ct]}],grow:[{grow:F()}],shrink:[{shrink:F()}],order:[{order:["first","last","none",Gd,ct]}],"grid-cols":[{"grid-cols":[Zd]}],"col-start-end":[{col:["auto",{span:["full",Gd,ct]},ct]}],"col-start":[{"col-start":V()}],"col-end":[{"col-end":V()}],"grid-rows":[{"grid-rows":[Zd]}],"row-start-end":[{row:["auto",{span:[Gd,ct]},ct]}],"row-start":[{"row-start":V()}],"row-end":[{"row-end":V()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ct]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ct]}],gap:[{gap:[p]}],"gap-x":[{"gap-x":[p]}],"gap-y":[{"gap-y":[p]}],"justify-content":[{justify:["normal",...D()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...D(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...D(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[w]}],px:[{px:[w]}],py:[{py:[w]}],ps:[{ps:[w]}],pe:[{pe:[w]}],pt:[{pt:[w]}],pr:[{pr:[w]}],pb:[{pb:[w]}],pl:[{pl:[w]}],m:[{m:[y]}],mx:[{mx:[y]}],my:[{my:[y]}],ms:[{ms:[y]}],me:[{me:[y]}],mt:[{mt:[y]}],mr:[{mr:[y]}],mb:[{mb:[y]}],ml:[{ml:[y]}],"space-x":[{"space-x":[N]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[N]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ct,e]}],"min-w":[{"min-w":[ct,e,"min","max","fit"]}],"max-w":[{"max-w":[ct,e,"none","full","min","max","fit","prose",{screen:[Ji]},Ji]}],h:[{h:[ct,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ct,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ct,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ct,e,"auto","min","max","fit"]}],"font-size":[{text:["base",Ji,Xi]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",qy]}],"font-family":[{font:[Zd]}],"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",ct]}],"line-clamp":[{"line-clamp":["none",Cu,qy]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",di,ct]}],"list-image":[{"list-image":["none",ct]}],"list-style-type":[{list:["none","disc","decimal",ct]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[b]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[b]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...H(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",di,Xi]}],"underline-offset":[{"underline-offset":["auto",di,ct]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:S()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ct]}],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",ct]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[b]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...$(),rZ]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",nZ]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},oZ]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[v]}
vendor: 5,180 bytes, line 3538
3538],"gradient-via-pos":[{via:[v]}],"gradient-to-pos":[{to:[v]}],"gradient-from":[{from:[g]}],"gradient-via":[{via:[g]}],"gradient-to":[{to:[g]}],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":[b]}],"border-style":[{border:[...H(),"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":[b]}],"divide-style":[{divide:H()}],"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:["",...H()]}],"outline-offset":[{"outline-offset":[di,ct]}],"outline-w":[{outline:[di,Xi]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:T()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[b]}],"ring-offset-w":[{"ring-offset":[di,Xi]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Ji,iZ]}],"shadow-color":[{shadow:[Zd]}],opacity:[{opacity:[b]}],"mix-blend":[{"mix-blend":[...W(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":W()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",Ji,ct]}],grayscale:[{grayscale:[d]}],"hue-rotate":[{"hue-rotate":[h]}],invert:[{invert:[f]}],saturate:[{saturate:[j]}],sepia:[{sepia:[P]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[d]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[h]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[b]}],"backdrop-saturate":[{"backdrop-saturate":[j]}],"backdrop-sepia":[{"backdrop-sepia":[P]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[a]}],"border-spacing-x":[{"border-spacing-x":[a]}],"border-spacing-y":[{"border-spacing-y":[a]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",ct]}],duration:[{duration:Y()}],ease:[{ease:["linear","in","out","in-out",ct]}],delay:[{delay:Y()}],animate:[{animate:["none","spin","ping","pulse","bounce",ct]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[E]}],"scale-x":[{"scale-x":[E]}],"scale-y":[{"scale-y":[E]}],rotate:[{rotate:[Gd,ct]}],"translate-x":[{"translate-x":[_]}],"translate-y":[{"translate-y":[_]}],"skew-x":[{"skew-x":[A]}],"skew-y":[{"skew-y":[A]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ct]}],accent:[{accent:["auto",t]}],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",ct]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":S()}],"scroll-mx":[{"scroll-mx":S()}],"scroll-my":[{"scroll-my":S()}],"scroll-ms":[{"scroll-ms":S()}],"scroll-me":[{"scroll-me":S()}],"scroll-mt":[{"scroll-mt":S()}],"scroll-mr":[{"scroll-mr":S()}],"scroll-mb":[{"scroll-mb":S()}],"scroll-ml":[{"scroll-ml":S()}],"scroll-p":[{"scroll-p":S()}],"scroll-px":[{"scroll-px":S()}],"scroll-py":[{"scroll-py":S()}],"scroll-ps":[{"scroll-ps":S()}],"scroll-pe":[{"scroll-pe":S()}],"scroll-pt":[{"scroll-pt":S()}],"scroll-pr":[{"scroll-pr":S()}],"scroll-pb":[{"scroll-pb":S()}],"scroll-pl":[{"scroll-pl":S()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}
vendor: 4,225 bytes, line 3538
3538],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",ct]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[di,Xi,qy]}],stroke:[{stroke:[t,"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"]}}},oL=qG(uZ);function Oe(...t){return oL(JC(t))}const bf=fx("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20",outline:"border border-border bg-card text-foreground hover:bg-muted hover:text-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-muted hover:text-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9 rounded-md"}},defaultVariants:{variant:"default",size:"default"}}),Z=u.forwardRef(({className:t,variant:e,size:n,asChild:r=!1,...s},i)=>{const a=r?QD:"button";return o.jsx(a,{ref:i,"data-slot":"button",className:Oe(bf({variant:e,size:n,className:t})),...s})});Z.displayName="Button";function Ne({className:t,type:e,...n}){return o.jsx("input",{type:e,"data-slot":"input",className:Oe("h-12 w-full rounded-xl border border-border bg-card px-3 py-2 text-base text-foreground transition-colors","placeholder:text-muted-foreground
3538/50","focus:border-ring/50 focus:outline-none focus:ring-2 focus:ring-ring/20","disabled:cursor-not-allowed disabled:opacity-50","aria-invalid:border-destructive aria-invalid:focus:border-destructive aria-invalid:focus:ring-destructive/20",t),...n})}var dZ=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Je=dZ.reduce((t,e)=>{const n=Ga(`Primitive.${e}`),r=u.forwardRef((s,i)=>{const{asChild:a,...l}=s,c=a?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(c,{...l,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function iL(t,e){t&&ps.flushSync(()=>t.dispatchEvent(e))}var hZ="Label",aL=u.forwardRef((t,e)=>o.jsx(Je.label,{...t,ref:e,onMouseDown:n=>{var s;n.target.closest("button, input, select, textarea")||((s=t.onMouseDown)==null||s.call(t,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));aL.displayName=hZ;var fZ=aL;function ne({className:t,...e}){return o.jsx(fZ,{"data-slot":"label",className:Oe("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...e})}const mZ=fx("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function yr({className:t,variant:e,...n}){return o.jsx("div",{"data-slot":"alert",role:"alert",className:Oe(mZ({variant:e}),t),...n})}function pZ({className:t,...e}){return o.jsx("div",{"data-slot":"alert-title",className:Oe("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",t),...e})}function wr({className:t,...e}){return o.jsx("div",{"data-slot":"alert-description",className:Oe("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",t),...e})}function Le(t,e,{checkForDefaultPrevented:n=!0}={}){return function(s){if(t==null||t(s),n===!1||!s.defaultPrevented)return e==null?void 0:e(s)}}function gZ(t,e){const n=u.createContext(e),r=i=>{const{children:a,...l}=i,c=u.useMemo(()=>l,Object.values(l));return o.jsx(n.Provider,{value:c,children:a})};r.displayName=t+"Provider";function s(i){const a=u.useContext(n);if(a)return a;if(e!==void 0)return e;throw new Error(`\`${i}\` must be used within \`${t}\``)}return[r,s]}function Rs(t,e=[]){let n=[];function r(i,a){const l=u.createContext(a),c=n.length;n=[...n,a];const d=f=>{var b;const{scope:p,children:g,...v}=f,x=((b=p==null?void 0:p[t])==null?void 0:b[c])||l,y=u.useMemo(()=>v,Object.values(v));return o.jsx(x.Provider,{value:y,children:g})};d.displayName=i+"Provider";function h(f,p){var x;const g=((x=p==null?void 0:p[t])==null?void 0:x[c])||l,v=u.useContext(g);if(v)return v;if(a!==void 0)return a;throw new Error(`\`${f}\` must be used within \`${i}\``)}return[d,h]}const s=()=>{const i=n.map(a=>u.createContext(a));return function(l){const c=(l==null?void 0:l[t])||i;return u.useMemo(()=>({[`__scope${t}`]:{...l,[t]:c}}),[l,c])}};return s.scopeName=t,[r,vZ(s,...e)]}function vZ(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(i){const a=r.reduce((l,{useScope:c,scopeName:d})=>{const f=c(i)[`__scope${d}`];return{...l,...f}},{});return u.useMemo(()=>({[`__scope${e.scopeName}`]:a}),[a])}};return n.scopeName=e.scopeName,n}var Ur=globalThis!=null&&globalThis.document?u.useLayoutEffect:()=>{},xZ=wv[" useId ".trim().toString()]||(()=>{}),yZ=0;function yo(t){const[e,n]=u.useState(xZ());return Ur(()=>{n(r=>r??String(yZ++))},[t]),t||(e?`radix-${e}`:"")}var wZ=wv[" useInsertionEffect ".trim().toString()]||Ur;function Co({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[s,i,a]=bZ({defaultProp:e,onChange:n}),l=t!==void 0,c=l?t:s;{const h=u.useRef(t!==void 0);u.useEffect(()=>{const f=h.current;f!==l&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),h.current=l},[l,r])}const d=u.useCallback(h=>{var f;if(l){const p=jZ(h)?h(t):h;p!==t&&((f=a.current)==null||f.call(a,p))}else i(h)},[l,t,i,a]);return[c,d]}function bZ({defaultProp:t,onChange:e}){const[n,r]=u.useState(t),s=u.useRef(n),i=u.useRef(e);return wZ(()=>{i.current=e},[e]),u.useEffect(()=>{var a;s.current!==n&&((a=i.current)==null||a.call(i,n),s.current=n)},[n,s]),[n,r,i]}function jZ(t){return typeof t=="function"}function ni(t){const e=u.useRef(t);return u.useEffect(()=>{e.current=t}),u.useMemo(()=>(...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)},[])}function CZ(t,e=globalThis==null?void 0:globalThis.document){const n=ni(t);u.useEffect(()=>{const r=s=>{s.key==="Escape"&&n(s)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}
3538var NZ="DismissableLayer",mb="dismissableLayer.update",_Z="dismissableLayer.pointerDownOutside",EZ="dismissableLayer.focusOutside",$k,lL=u.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Xf=u.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:i,onInteractOutside:a,onDismiss:l,...c}=t,d=u.useContext(lL),[h,f]=u.useState(null),p=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,g]=u.useState({}),v=At(e,N=>f(N)),x=Array.from(d.layers),[y]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),b=x.indexOf(y),w=h?x.indexOf(h):-1,j=d.layersWithOutsidePointerEventsDisabled.size>0,E=w>=b,P=PZ(N=>{const _=N.target,k=[...d.branches].some(L=>L.contains(_));!E||k||(s==null||s(N),a==null||a(N),N.defaultPrevented||l==null||l())},p),A=IZ(N=>{const _=N.target;[...d.branches].some(L=>L.contains(_))||(i==null||i(N),a==null||a(N),N.defaultPrevented||l==null||l())},p);return CZ(N=>{w===d.layers.size-1&&(r==null||r(N),!N.defaultPrevented&&l&&(N.preventDefault(),l()))},p),u.useEffect(()=>{if(h)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&($k=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(h)),d.layers.add(h),Vk(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=$k)}},[h,p,n,d]),u.useEffect(()=>()=>{h&&(d.layers.delete(h),d.layersWithOutsidePointerEventsDisabled.delete(h),Vk())},[h,d]),u.useEffect(()=>{const N=()=>g({});return document.addEventListener(mb,N),()=>document.removeEventListener(mb,N)},[]),o.jsx(Je.div,{...c,ref:v,style:{pointerEvents:j?E?"auto":"none":void 0,...t.style},onFocusCapture:Le(t.onFocusCapture,A.onFocusCapture),onBlurCapture:Le(t.onBlurCapture,A.onBlurCapture),onPointerDownCapture:Le(t.onPointerDownCapture,P.onPointerDownCapture)})});Xf.displayName=NZ;var SZ="DismissableLayerBranch",kZ=u.forwardRef((t,e)=>{const n=u.useContext(lL),r=u.useRef(null),s=At(e,r);return u.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),o.jsx(Je.div,{...t,ref:s})});kZ.displayName=SZ;function PZ(t,e=globalThis==null?void 0:globalThis.document){const n=ni(t),r=u.useRef(!1),s=u.useRef(()=>{});return u.useEffect(()=>{const i=l=>{if(l.target&&!r.current){let c=function(){cL(_Z,n,d,{discrete:!0})};const d={originalEvent:l};l.pointerType==="touch"?(e.removeEventListener("click",s.current),s.current=c,e.addEventListener("click",s.current,{once:!0})):c()}else e.removeEventListener("click",s.current);r.current=!1},a=window.setTimeout(()=>{e.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(a),e.removeEventListener("pointerdown",i),e.removeEventListener("click",s.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function IZ(t,e=globalThis==null?void 0:globalThis.document){const n=ni(t),r=u.useRef(!1);return u.useEffect(()=>{const s=i=>{i.target&&!r.current&&cL(EZ,n,{originalEvent:i},{discrete:!1})};return e.addEventListener("focusin",s),()=>e.removeEventListener("focusin",s)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Vk(){const t=new CustomEvent(mb);document.dispatchEvent(t)}function cL(t,e,n,{discrete:r}){const s=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&s.addEventListener(t,e,{once:!0}),r?iL(s,i):s.dispatchEvent(i)}var Gy="focusScope.autoFocusOnMount",Zy="focusScope.autoFocusOnUnmount",Uk={bubbles:!1,cancelable:!0},TZ="FocusScope",Jf=u.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:s,onUnmountAutoFocus:i,...a}=t,[l,c]=u.useState(null),d=ni(s),h=ni(i),f=u.useRef(null),p=At(e,x=>c(x)),g=u.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;u.useEffect(()=>{if(r){let x=function(j){if(g.paused||!l)return;const E=j.target;l.contains(E)?f.current=E:ra(f.current,{select:!0})},y=function(j){if(g.paused||!l)return;const E=j.relatedTarget;E!==null&&(l.contains(E)||ra(f.current,{select:!0}))},b=function(j){if(document.activeElement===document.body)for(const P of j)P.removedNodes.length>0&&ra(l)};document.addEventListener("focusin",x),document.addEventListener("focusout",y);const w=new MutationObserver(b);return l&&w.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",y),w.disconnect()}}},[r,l,g.paused]),u.useEffect(()=>{if(l){Wk.add(g);const x=document.activeElement;if(!l.contains(x)){const b=new CustomEvent(Gy,Uk);l.addEventListener(Gy,d),l.dispatchEvent(b),b.defaultPrevented||(AZ(OZ(uL(l)),{select:!0}),document.activeElement===x&&ra(l))}return()=>{l.removeEventListener(Gy,d),setTimeout(()=>{const b=new CustomEvent(Zy,Uk);l.addEventListener(Zy,h),l.dispatchEvent(b),b.defaultPrevented||ra(x??document.body,{select:!0}),l.removeEventListener(Zy,h),Wk.remove(g)},0)}}},[l,d,h,g]);const v=u.useCallback(x=>{if(!n&&!r||g.paused)return;const y=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,b=document.activeElement;if(y&&b){const w=x.currentTarget,[j,E]=RZ(w);
3538j&&E?!x.shiftKey&&b===E?(x.preventDefault(),n&&ra(j,{select:!0})):x.shiftKey&&b===j&&(x.preventDefault(),n&&ra(E,{select:!0})):b===w&&x.preventDefault()}},[n,r,g.paused]);return o.jsx(Je.div,{tabIndex:-1,...a,ref:p,onKeyDown:v})});Jf.displayName=TZ;function AZ(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(ra(r,{select:e}),document.activeElement!==n)return}function RZ(t){const e=uL(t),n=Bk(e,t),r=Bk(e.reverse(),t);return[n,r]}function uL(t){const e=[],n=document.createTreeWalker(t,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();)e.push(n.currentNode);return e}function Bk(t,e){for(const n of t)if(!DZ(n,{upTo:e}))return n}function DZ(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function LZ(t){return t instanceof HTMLInputElement&&"select"in t}function ra(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&LZ(t)&&e&&t.select()}}var Wk=MZ();function MZ(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=Hk(t,e),t.unshift(e)},remove(e){var n;t=Hk(t,e),(n=t[0])==null||n.resume()}}}function Hk(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function OZ(t){return t.filter(e=>e.tagName!=="A")}var FZ="Portal",em=u.forwardRef((t,e)=>{var l;const{container:n,...r}=t,[s,i]=u.useState(!1);Ur(()=>i(!0),[]);const a=n||s&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return a?Fj.createPortal(o.jsx(Je.div,{...r,ref:e}),a):null});em.displayName=FZ;function zZ(t,e){return u.useReducer((n,r)=>e[n][r]??n,t)}var Xs=t=>{const{present:e,children:n}=t,r=$Z(e),s=typeof n=="function"?n({present:r.isPresent}):u.Children.only(n),i=At(r.ref,VZ(s));return typeof n=="function"||r.isPresent?u.cloneElement(s,{ref:i}):null};Xs.displayName="Presence";function $Z(t){const[e,n]=u.useState(),r=u.useRef(null),s=u.useRef(t),i=u.useRef("none"),a=t?"mounted":"unmounted",[l,c]=zZ(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return u.useEffect(()=>{const d=up(r.current);i.current=l==="mounted"?d:"none"},[l]),Ur(()=>{const d=r.current,h=s.current;if(h!==t){const p=i.current,g=up(d);t?c("MOUNT"):g==="none"||(d==null?void 0:d.display)==="none"?c("UNMOUNT"):c(h&&p!==g?"ANIMATION_OUT":"UNMOUNT"),s.current=t}},[t,c]),Ur(()=>{if(e){let d;const h=e.ownerDocument.defaultView??window,f=g=>{const x=up(r.current).includes(CSS.escape(g.animationName));if(g.target===e&&x&&(c("ANIMATION_END"),!s.current)){const y=e.style.animationFillMode;e.style.animationFillMode="forwards",d=h.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=y)})}},p=g=>{g.target===e&&(i.current=up(r.current))};return e.addEventListener("animationstart",p),e.addEventListener("animationcancel",f),e.addEventListener("animationend",f),()=>{h.clearTimeout(d),e.removeEventListener("animationstart",p),e.removeEventListener("animationcancel",f),e.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[e,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:u.useCallback(d=>{r.current=d?getComputedStyle(d):null,n(d)},[])}}function up(t){return(t==null?void 0:t.animationName)||"none"}function VZ(t){var r,s;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(s=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var Ky=0;function mx(){u.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??qk()),document.body.insertAdjacentElement("beforeend",t[1]??qk()),Ky++,()=>{Ky===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e
vendor: 14,063 bytes, lines 3538-3578
3538=>e.remove()),Ky--}},[])}function qk(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var Fh="right-scroll-bar-position",zh="width-before-scroll-bar",UZ="with-scroll-bars-hidden",BZ="--removed-body-scroll-bar-size";function Yy(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function WZ(t,e){var n=u.useState(function(){return{value:t,callback:e,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=e,n.facade}var HZ=typeof window<"u"?u.useLayoutEffect:u.useEffect,Gk=new WeakMap;function dL(t,e){var n=WZ(null,function(r){return t.forEach(function(s){return Yy(s,r)})});return HZ(function(){var r=Gk.get(n);if(r){var s=new Set(r),i=new Set(t),a=n.current;s.forEach(function(l){i.has(l)||Yy(l,null)}),i.forEach(function(l){s.has(l)||Yy(l,a)})}Gk.set(n,t)},[t]),n}function qZ(t){return t}function GZ(t,e){e===void 0&&(e=qZ);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]:t},useMedium:function(i){var a=e(i,r);return n.push(a),function(){n=n.filter(function(l){return l!==a})}},assignSyncMedium:function(i){for(r=!0;n.length;){var a=n;n=[],a.forEach(i)}n={push:function(l){return i(l)},filter:function(){return n}}},assignMedium:function(i){r=!0;var a=[];if(n.length){var l=n;n=[],l.forEach(i),a=n}var c=function(){var h=a;a=[],h.forEach(i)},d=function(){return Promise.resolve().then(c)};d(),n={push:function(h){a.push(h),d()},filter:function(h){return a=a.filter(h),n}}}};return s}function hL(t){t===void 0&&(t={});var e=GZ(null);return e.options=Mr({async:!0,ssr:!1},t),e}var fL=function(t){var e=t.sideCar,n=nd(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return u.createElement(r,Mr({},n))};fL.isSideCarExport=!0;function mL(t,e){return t.useMedium(e),fL}var pL=hL(),Qy=function(){},px=u.forwardRef(function(t,e){var n=u.useRef(null),r=u.useState({onScrollCapture:Qy,onWheelCapture:Qy,onTouchMoveCapture:Qy}),s=r[0],i=r[1],a=t.forwardProps,l=t.children,c=t.className,d=t.removeScrollBar,h=t.enabled,f=t.shards,p=t.sideCar,g=t.noRelative,v=t.noIsolation,x=t.inert,y=t.allowPinchZoom,b=t.as,w=b===void 0?"div":b,j=t.gapMode,E=nd(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),P=p,A=dL([n,e]),N=Mr(Mr({},E),s);return u.createElement(u.Fragment,null,h&&u.createElement(P,{sideCar:pL,removeScrollBar:d,shards:f,noRelative:g,noIsolation:v,inert:x,setCallbacks:i,allowPinchZoom:!!y,lockRef:n,gapMode:j}),a?u.cloneElement(u.Children.only(l),Mr(Mr({},N),{ref:A})):u.createElement(w,Mr({},N,{className:c,ref:A}),l))});px.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};px.classNames={fullWidth:zh,zeroRight:Fh};var ZZ=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function KZ(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=ZZ();return e&&t.setAttribute("nonce",e),t}function YZ(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function QZ(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var XZ=function(){var t=0,e=null;return{add:function(n){t==0&&(e=KZ())&&(YZ(e,n),QZ(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},JZ=function(){var t=XZ();return function(e,n){u.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},t1=function(){var t=JZ(),e=function(n){var r=n.styles,s=n.dynamic;return t(r,s),null};return e},eK={left:0,top:0,right:0,gap:0},Xy=function(t){return parseInt(t||"",10)||0},tK=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],s=e[t==="padding"?"paddingRight":"marginRight"];return[Xy(n),Xy(r),Xy(s)]},nK=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return eK;var e=tK(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},rK=t1(),Nu="data-scroll-locked",sK=function(t,e,n,r){var s=t.left,i=t.top,a=t.right,l=t.gap;return n===void 0&&(n="margin"),` 3539 .`.concat(UZ,` { 3540 overflow: hidden `).concat(r,`; 3541 padding-right: `).concat(l,"px ").concat(r,`; 3542 } 3543 body[`).concat(Nu,`] { 3544 overflow: hidden `).concat(r,`; 3545 overscroll-behavior: contain; 3546 `).concat([e&&"position: relative ".concat(r,";"),n==="margin"&&` 3547 padding-left: `.concat(s,`px; 3548 padding-top: `).concat(i,`px; 3549 padding-right: `).concat(a,`px; 3550 margin-left:0; 3551 margin-top:0; 3552 margin-right: `).concat(l,"px ").concat(r,`; 3553 `),n==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),` 3554 } 3555 3556 .`).concat(Fh,` { 3557 right: `).concat(l,"px ").concat(r,`; 3558 } 3559 3560 .`).concat(zh,` { 3561 margin-right: `).concat(l,"px ").concat(r,`; 3562 } 3563 3564 .`).concat(Fh," .").concat(Fh,` { 3565 right: 0 `).concat(r,`; 3566 } 3567 3568 .`).concat(zh," .").concat(zh,` { 3569 margin-right: 0 `).concat(r,`; 3570 } 3571 3572 body[`).concat(Nu,`] { 3573 `).concat(BZ,": ").concat(l,`px; 3574 } 3575`)},Zk=function(){var t=parseInt(document.body.getAttribute(Nu)||"0",10);return isFinite(t)?t:0},oK=function(){u.useEffect(function(){return document.body.setAttribute(Nu,(Zk()+1).toString()),function(){var t=Zk()-1;t<=0?document.body.removeAttribute(Nu):document.body.setAttribute(Nu,t.toString())}},[])},gL=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,s=r===void 0?"margin":r;oK();var i=u.useMemo(function(){return nK(s)},[s]);return u.createElement(rK,{styles:sK(i,!e,s,n?"":"!important")})},pb=!1;if(typeof window<"u")try{var dp=Object.defineProperty({},"passive",{get:function(){return pb=!0,!0}});window.addEventListener("test",dp,dp),window.removeEventListener("test",dp,dp)}catch{pb=!1}var Mc=pb?{passive:!1}:!1,iK=function(t){return t.tagName==="TEXTAREA"},vL=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!iK(t)&&n[e]==="visible")},aK=function(t){return vL(t,"overflowY")},lK=function(t){return vL(t,"overflowX")},Kk=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var s=xL(t,r);if(s){var i=yL(t,r),a=i[1],l=i[2];if(a>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},cK=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},uK=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},xL=function(t,e){return t==="v"?aK(e):lK(e)},yL=function(t,e){return t==="v"?cK(e):uK(e)},dK=function(t,e){return t==="h"&&e==="rtl"?-1:1},hK=function(t,e,n,r,s){var i=dK(t,window.getComputedStyle(e).direction),a=i*r,l=n.target,c=e.contains(l),d=!1,h=a>0,f=0,p=0;do{if(!l)break;var g=yL(t,l),v=g[0],x=g[1],y=g[2],b=x-y-i*v;(v||b)&&xL(t,l)&&(f+=b,p+=v);var w=l.parentNode;l=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!c&&l!==document.body||c&&(e.contains(l)||e===l));return(h&&Math.abs(f)<1||!h&&Math.abs(p)<1)&&(d=!0),d},hp=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},Yk=function(t){return[t.deltaX,t.deltaY]},Qk=function(t){return t&&"current"in t?t.current:t},fK=function(t,e){return t[0]===e[0]&&t[1]===e[1]},mK=function(t){return` 3576 .block-interactivity-`.concat(t,` {pointer-events: none;} 3577 .allow-interactivity-`).concat(t,` {pointer-events: all;} 3578`)},pK=0,Oc=[];function gK(t){var e=u.useRef([]),n=u.useRef([0,0]),r=u.useRef(),s=u.useState(pK++)[0],i=u.useState(t1)[0],a=u.useRef(t);u.useEffect(function(){a.current=t},[t]),u.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(s));var x=oA([t.lockRef.current],(t.shards||[]).map(Qk),!0).filter(Boolean);return x.forEach(function(y){return y.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),x.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(s))})}}},[t.inert,t.lockRef.current,t.shards]);var l=u.useCallback(function(x,y){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!a.current.allowPinchZoom;var b=hp(x),w=n.current,j="deltaX"in x?x.deltaX:w[0]-b[0],E="deltaY"in x?x.deltaY:w[1]-b[1],P,A=x.target,N=Math.abs(j)>Math.abs(E)?"h":"v";if("touches"in x&&N==="h"&&A.type==="range")return!1;var _=Kk(N,A);if(!_)return!0;if(_?P=N:(P=N==="v"?"h":"v",_=Kk(N,A)),!_)return!1;if(!r.current&&"changedTouches"in x&&(j||E)&&(r.current=P),!P)return!0;var k=r.current||P;return hK(k,y,x,k==="h"?j:E)},[]),c=u.useCallback(function(x){var y=x;if(!(!Oc.length||Oc[Oc.length-1]!==i)){var b="deltaY"in y?Yk(y):hp(y),w=e.current.filter(function(P){return P.name===y.type&&(P.target===y.target||y.target===P.shadowParent)&&fK(P.delta,b)})[0];if(w&&w.should){y.cancelable&&y.preventDefault();return}if(!w){var j=(a.current.shards||[]).map(Qk).filter(Boolean).filter(function(P){return P.contains(y.target)}),E=j.length>0?l(y,j[0]):!a.current.noIsolation;E&&y.cancelable&&y.preventDefault()}}},[]),d=u.useCallback(function(x,y,b,w){var j={name:x,delta:y,target:b,should:w,shadowParent:vK(b)};e.current.push(j),setTimeout(function(){e.current=e.current.filter(function(E){return E!==j})},1)},[]),h=u.useCallback(function(x){n.current=hp(x),r.current=void 0},[]),f=u.useCallback(function(x){d(x.type,Yk(x),x.target,l(x,t.lockRef.current))},[]),p=u.useCallback(function(x){d(x.type,hp(x),x.target,l(x,t.lockRef.current))},[]);u.useEffect(function(){return Oc.push(i),t.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",c,Mc),document.addEventListener("touchmove",c,Mc),document.addEventListener("touchstart",h,Mc),function(){Oc=Oc.filter(function(x){return x!==i}),document.removeEventListener("wheel",c,Mc),document.removeEventListener("touchmove",c,Mc),document.removeEventListener("touchstart",h,Mc)}},[]);var g=t.removeScrollBar,v=t.inert;return u.createElement(u.Fragment,null,v?u.createElement(i,{styles:mK(s)}):null,g?u.createElement(gL,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function vK(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const xK=mL(pL,gK);var tm=u.forwardRef(function(t,e){return u.createElement(px,Mr({},t,{ref:e,sideCar:xK}))});tm.classNames=px.classNames;var yK=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Fc=new WeakMap,fp=new WeakMap,mp={},Jy=0,wL=function(t){return t&&(t.host||wL(t.parentNode))},wK=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=wL(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},bK=function(t,e,n,r){var s=wK(e,Array.isArray(t)?t:[t]);mp[n]||(mp[n]=new WeakMap);var i=mp[n],a=[],l=new Set,c=new Set(s),d=function(f){!f||l.has(f)||(l.add(f),d(f.parentNode))};s.forEach(d);var h=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(p){if(l.has(p))h(p);else try{var g=p.getAttribute(r),v=g!==null&&g!=="false",x=(Fc.get(p)||0)+1,y=(i.get(p)||0)+1;Fc.set(p,x),i.set(p,y),a.push(p),x===1&&v&&fp.set(p,!0),y===1&&p.setAttribute(n,"true"),v||p.setAttribute(r,"true")}catch(b){console.error("aria-hidden: cannot operate on ",p,b)}})};return h(e),l.clear(),Jy++,function(){a.forEach(function(f){var p=Fc.get(f)-1,g=i.get(f)-1;Fc.set(f,p),i.set(f,g),p||(fp.has(f)||f.removeAttribute(r),fp.delete(f)),g||f.removeAttribute(n)}),Jy--,Jy||(Fc=new WeakMap,Fc=new WeakMap,fp=new WeakMap,mp={})}},nm=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),s=yK(t);return s?(r.push.apply(r,Array.from(s.querySelectorAll("[aria-live], script"))),bK(r,s,n,"aria-hidden")):function(){return null}},gx="Dialog",[bL,jL]=Rs(gx),[jK,Io]=bL(gx),CL=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:s,onOpenChange:i,modal:a=!0}=t,l=u.useRef(null),c=u.useRef(null),[d,h]=Co({prop:r,defaultProp:s??!1,onChange:i,caller:gx});return o.jsx(jK,{scope:e,triggerRef:l,contentRef:c,contentId:yo(),titleId:yo(),descriptionId:yo(),open:d,onOpenChange:h,onOpenToggle:u.useCallback(()=>h(f=>!f),[h]),modal:a,children:n})};CL.displayName=gx;var NL="DialogTrigger",_L=u.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,s=Io(NL,n),i=At(e,s.triggerRef);return o.jsx(Je.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":s1(s.open),...r,ref:i,onClick:Le(t.onClick,s.onOpenToggle)})});_L.displayName=NL;var n1="DialogPortal",[CK,EL]=bL(n1,{forceMount:void 0}),SL=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:s}=t,i=Io(n1,e);return o.jsx(CK,{scope:e,forceMount:n,children:u.Children.map(r,a=>o.jsx(Xs,{present:n||i.open,children:o.jsx(em,{asChild:!0,container:s,children:a})}))})};SL.displayName=n1;var nv="DialogOverlay",kL=u.forwardRef((t,e)=>{const n=EL(nv,t.__scopeDialog),{forceMount:r=n.forceMount,...s}=t,i=Io(nv,t.__scopeDialog);return i.modal?o.jsx(Xs,{present:r||i.open,children:o.jsx(_K,{...s,ref:e})}):null});kL.displayName=nv;var NK=Ga("DialogOverlay.RemoveScroll"),_K=u.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,s=Io(nv,n);return o.jsx(tm,{as:NK,allowPinchZoom:!0,shards:[s.contentRef],children:o.jsx(Je.div,{"data-state":s1(s.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),tc="DialogContent",PL=u.forwardRef((t,e)=>{const n=EL(tc,t.__scopeDialog),{forceMount:r=n.forceMount,...s}=t,i=Io(tc,t.__scopeDialog);return o.jsx(Xs,{present:r||i.open,children:i.modal?o.jsx(EK,{...s,ref:e}):o.jsx(SK,{...s,ref:e})})});
3578PL.displayName=tc;var EK=u.forwardRef((t,e)=>{const n=Io(tc,t.__scopeDialog),r=u.useRef(null),s=At(e,n.contentRef,r);return u.useEffect(()=>{const i=r.current;if(i)return nm(i)},[]),o.jsx(IL,{...t,ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Le(t.onCloseAutoFocus,i=>{var a;i.preventDefault(),(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:Le(t.onPointerDownOutside,i=>{const a=i.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0;(a.button===2||l)&&i.preventDefault()}),onFocusOutside:Le(t.onFocusOutside,i=>i.preventDefault())})}),SK=u.forwardRef((t,e)=>{const n=Io(tc,t.__scopeDialog),r=u.useRef(!1),s=u.useRef(!1);return o.jsx(IL,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var a,l;(a=t.onCloseAutoFocus)==null||a.call(t,i),i.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),i.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:i=>{var c,d;(c=t.onInteractOutside)==null||c.call(t,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const a=i.target;((d=n.triggerRef.current)==null?void 0:d.contains(a))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&s.current&&i.preventDefault()}})}),IL=u.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:i,...a}=t,l=Io(tc,n),c=u.useRef(null),d=At(e,c);return mx(),o.jsxs(o.Fragment,{children:[o.jsx(Jf,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:i,children:o.jsx(Xf,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":s1(l.open),...a,ref:d,onDismiss:()=>l.onOpenChange(!1)})}),o.jsxs(o.Fragment,{children:[o.jsx(PK,{titleId:l.titleId}),o.jsx(TK,{contentRef:c,descriptionId:l.descriptionId})]})]})}),r1="DialogTitle",TL=u.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,s=Io(r1,n);return o.jsx(Je.h2,{id:s.titleId,...r,ref:e})});TL.displayName=r1;var AL="DialogDescription",RL=u.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,s=Io(AL,n);return o.jsx(Je.p,{id:s.descriptionId,...r,ref:e})});RL.displayName=AL;var DL="DialogClose",LL=u.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,s=Io(DL,n);return o.jsx(Je.button,{type:"button",...r,ref:e,onClick:Le(t.onClick,()=>s.onOpenChange(!1))})});LL.displayName=DL;function s1(t){return t?"open":"closed"}var ML="DialogTitleWarning",[kK,OL]=gZ(ML,{contentName:tc,titleName:r1,docsSlug:"dialog"}),PK=({titleId:t})=>{const e=OL(ML),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users. 3579 3580If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component. 3581 3582For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return u.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},IK="DialogDescriptionWarning",TK=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${OL(IK).contentName}}.`;return u.useEffect(()=>{var i;const s=(i=t.current)==null?void 0:i.getAttribute("aria-describedby");e&&s&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},o1=CL,AK=_L,i1=SL,a1=kL,l1=PL,c1=TL,FL=RL,vx=LL;/** 3583 * @license lucide-react v0.323.0 - ISC 3584 * 3585 * This source code is licensed under the ISC license. 3586 * See the LICENSE file in the root directory of this source tree. 3587 */var RK={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"};/** 3588 * @license lucide-react v0.323.0 - ISC 3589 * 3590 * This source code is licensed under the ISC license. 3591 * See the LICENSE file in the root directory of this source tree. 3592 */const DK=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),Ee=(t,e)=>{const n=u.forwardRef(({color:r="currentColor",size:s=24,strokeWidth:i=2,absoluteStrokeWidth:a,className:l="",children:c,...d},h)=>u.createElement("svg",{ref:h,...RK,width:s,height:s,stroke:r,strokeWidth:a?Number(i)*24/Number(s):i,className:["lucide",`lucide-${DK(t)}`,l].join(" "),...d},[...e.map(([f,p])=>
3592u.createElement(f,p)),...Array.isArray(c)?c:[c]]));return n.displayName=`${t}`,n};/** 3593 * @license lucide-react v0.323.0 - ISC 3594 * 3595 * This source code is licensed under the ISC license. 3596 * See the LICENSE file in the root directory of this source tree. 3597 */const rv=Ee("AlertCircle",[["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"}]]);/** 3598 * @license lucide-react v0.323.0 - ISC 3599 * 3600 * This source code is licensed under the ISC license. 3601 * See the LICENSE file in the root directory of this source tree. 3602 */const an=Ee("AlertTriangle",[["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-3Z",key:"c3ski4"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** 3603 * @license lucide-react v0.323.0 - ISC 3604 * 3605 * This source code is licensed under the ISC license. 3606 * See the LICENSE file in the root directory of this source tree. 3607 */const LK=Ee("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/** 3608 * @license lucide-react v0.323.0 - ISC 3609 * 3610 * This source code is licensed under the ISC license. 3611 * See the LICENSE file in the root directory of this source tree. 3612 */const Nr=Ee("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/** 3613 * @license lucide-react v0.323.0 - ISC 3614 * 3615 * This source code is licensed under the ISC license. 3616 * See the LICENSE file in the root directory of this source tree. 3617 */const MK=Ee("BarChart3",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** 3618 * @license lucide-react v0.323.0 - ISC 3619 * 3620 * This source code is licensed under the ISC license. 3621 * See the LICENSE file in the root directory of this source tree. 3622 */const gb=Ee("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/** 3623 * @license lucide-react v0.323.0 - ISC 3624 * 3625 * This source code is licensed under the ISC license. 3626 * See the LICENSE file in the root directory of this source tree. 3627 */const qn=Ee("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** 3628 * @license lucide-react v0.323.0 - ISC 3629 * 3630 * This source code is licensed under the ISC license. 3631 * See the LICENSE file in the root directory of this source tree. 3632 */const vb=Ee("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"}]]);/** 3633 * @license lucide-react v0.323.0 - ISC 3634 * 3635 * This source code is licensed under the ISC license. 3636 * See the LICENSE file in the root directory of this source tree. 3637 */const Da=Ee("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"}]]);/** 3638 * @license lucide-react v0.323.0 - ISC 3639 * 3640 * This source code is licensed under the ISC license. 3641 * See the LICENSE file in the root directory of this source tree. 3642 */const ew=Ee("CheckCircle2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** 3643 * @license lucide-react v0.323.0 - ISC 3644 * 3645 * This source code is licensed under the ISC license. 3646 * See the LICENSE file in the root directory of this source tree. 3647 */const ns=Ee("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** 3648 * @license lucide-react v0.323.0 - ISC 3649 * 3650 * This source code is licensed under the ISC license. 3651 * See the LICENSE file in the root directory of this source tree. 3652 */const Xn=Ee("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** 3653 * @license lucide-react v0.323.0 - ISC 3654 * 3655 * This source code is licensed under the ISC license. 3656 * See the LICENSE file in the root directory of this source tree. 3657 */const jf=Ee("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** 3658 * @license lucide-react v0.323.0 - ISC 3659 * 3660 * This source code is licensed under the ISC license. 3661 * See the LICENSE file in the root directory of this source tree. 3662 */const vc=Ee("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/** 3663 * @license lucide-react v0.323.0 - ISC 3664 * 3665 * This source code is licensed under the ISC license. 3666 * See the LICENSE file in the root directory of this source tree. 3667 */const nr=Ee("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** 3668 * @license lucide-react v0.323.0 - ISC 3669 * 3670 * This source code is licensed under the ISC license. 3671 * See the LICENSE file in the root directory of this source tree. 3672 */const OK=Ee("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** 3673 * @license lucide-react v0.323.0 - ISC 3674 * 3675 * This source code is licensed under the ISC license. 3676 * See the LICENSE file in the root directory of this source tree. 3677 */const zL=Ee("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/** 3678 * @license lucide-react v0.323.0 - ISC 3679 * 3680 * This source code is licensed under the ISC license. 3681 * See the LICENSE file in the root directory of this source tree. 3682 */const $L=Ee("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** 3683 * @license lucide-react v0.323.0 - ISC 3684 * 3685 * This source code is licensed under the ISC license. 3686 * See the LICENSE file in the root directory of this source tree. 3687 */const u1=Ee("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);/** 3688 * @license lucide-react v0.323.0 - ISC 3689 * 3690 * This source code is licensed under the ISC license. 3691 * See the LICENSE file in the root directory of this source tree. 3692 */const wa=Ee("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** 3693 * @license lucide-react v0.323.0 - ISC 3694 * 3695 * This source code is licensed under the ISC license. 3696 * See the LICENSE file in the root directory of this source tree. 3697 */const hd=Ee("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** 3698 * @license lucide-react v0.323.0 - ISC 3699 * 3700 * This source code is licensed under the ISC license. 3701 * See the LICENSE file in the root directory of this source tree.
3702 */const Xp=Ee("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"}]]);/** 3703 * @license lucide-react v0.323.0 - ISC 3704 * 3705 * This source code is licensed under the ISC license. 3706 * See the LICENSE file in the root directory of this source tree. 3707 */const Cf=Ee("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"}]]);/** 3708 * @license lucide-react v0.323.0 - ISC 3709 * 3710 * This source code is licensed under the ISC license. 3711 * See the LICENSE file in the root directory of this source tree. 3712 */const VL=Ee("Crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]);/** 3713 * @license lucide-react v0.323.0 - ISC 3714 * 3715 * This source code is licensed under the ISC license. 3716 * See the LICENSE file in the root directory of this source tree. 3717 */const mo=Ee("Crown",[["path",{d:"m2 4 3 12h14l3-12-6 7-4-7-4 7-6-7zm3 16h14",key:"zkxr6b"}]]);/** 3718 * @license lucide-react v0.323.0 - ISC 3719 * 3720 * This source code is licensed under the ISC license. 3721 * See the LICENSE file in the root directory of this source tree. 3722 */const Xk=Ee("Dices",[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]]);/** 3723 * @license lucide-react v0.323.0 - ISC 3724 * 3725 * This source code is licensed under the ISC license. 3726 * See the LICENSE file in the root directory of this source tree. 3727 */const Nf=Ee("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"}]]);/** 3728 * @license lucide-react v0.323.0 - ISC 3729 * 3730 * This source code is licensed under the ISC license. 3731 * See the LICENSE file in the root directory of this source tree. 3732 */const xx=Ee("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"}]]);/** 3733 * @license lucide-react v0.323.0 - ISC 3734 * 3735 * This source code is licensed under the ISC license. 3736 * See the LICENSE file in the root directory of this source tree. 3737 */const gh=Ee("Eye",[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",key:"rwhkz3"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** 3738 * @license lucide-react v0.323.0 - ISC 3739 * 3740 * This source code is licensed under the ISC license. 3741 * See the LICENSE file in the root directory of this source tree. 3742 */const UL=Ee("FilePenLine",[["path",{d:"m18 5-3-3H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2",key:"h0fsxq"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M18.4 9.6a2 2 0 1 1 3 3L17 17l-4 1 1-4Z",key:"dyo8mm"}]]);/** 3743 * @license lucide-react v0.323.0 - ISC 3744 * 3745 * This source code is licensed under the ISC license. 3746 * See the LICENSE file in the root directory of this source tree. 3747 */const sv=Ee("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"}]]);/** 3748 * @license lucide-react v0.323.0 - ISC 3749 * 3750 * This source code is licensed under the ISC license. 3751 * See the LICENSE file in the root directory of this source tree. 3752 */const FK=Ee("FileX",[["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:"m14.5 12.5-5 5",key:"b62r18"}],["path",{d:"m9.5 12.5 5 5",key:"1rk7el"}]]);/** 3753 * @license lucide-react v0.323.0 - ISC 3754 * 3755 * This source code is licensed under the ISC license. 3756 * See the LICENSE file in the root directory of this source tree. 3757 */const d1=Ee("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/** 3758 * @license lucide-react v0.323.0 - ISC 3759 * 3760 * This source code is licensed under the ISC license. 3761 * See the LICENSE file in the root directory of this source tree. 3762 */const BL=Ee("Footprints",[["path",{d:"M4 16v-2.38C4 11.5 2.97 10.5 3 8c.03-2.72 1.49-6 4.5-6C9.37 2 10 3.8 10 5.5c0 3.11-2 5.66-2 8.68V16a2 2 0 1 1-4 0Z",key:"1dudjm"}],["path",{d:"M20 20v-2.38c0-2.12 1.03-3.12 1-5.62-.03-2.72-1.49-6-4.5-6C14.63 6 14 7.8 14 9.5c0 3.11 2 5.66 2 8.68V20a2 2 0 1 0 4 0Z",key:"l2t8xc"}],["path",{d:"M16 17h4",key:"1dejxt"}],["path",{d:"M4 13h4",key:"1bwh8b"}]]);/** 3763 * @license lucide-react v0.323.0 - ISC 3764 * 3765 * This source code is licensed under the ISC license. 3766 * See the LICENSE file in the root directory of this source tree. 3767 */const zK=Ee("Gift",[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]]);/** 3768 * @license lucide-react v0.323.0 - ISC 3769 * 3770 * This source code is licensed under the ISC license. 3771 * See the LICENSE file in the root directory of this source tree. 3772 */const $K=Ee("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"}]]);/** 3773 * @license lucide-react v0.323.0 - ISC 3774 * 3775 * This source code is licensed under the ISC license. 3776 * See the LICENSE file in the root directory of this source tree. 3777 */const VK=Ee("Hexagon",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]]);/** 3778 * @license lucide-react v0.323.0 - ISC 3779 * 3780 * This source code is licensed under the ISC license. 3781 * See the LICENSE file in the root directory of this source tree. 3782 */const UK=Ee("Home",[["path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"y5dka4"}],["polyline",{points:"9 22 9 12 15 12 15 22",key:"e2us08"}]]);/** 3783 * @license lucide-react v0.323.0 - ISC 3784 * 3785 * This source code is licensed under the ISC license. 3786 * See the LICENSE file in the root directory of this source tree. 3787 */const WL=Ee("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/** 3788 * @license lucide-react v0.323.0 - ISC 3789 * 3790 * This source code is licensed under the ISC license. 3791 * See the LICENSE file in the root directory of this source tree. 3792 */const HL=Ee("KeyRound",[["path",{d:"M2 18v3c0 .6.4 1 1 1h4v-3h3v-3h2l1.4-1.4a6.5 6.5 0 1 0-4-4Z",key:"167ctg"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/** 3793 * @license lucide-react v0.323.0 - ISC 3794 * 3795 * This source code is licensed under the ISC license. 3796 * See the LICENSE file in the root directory of this source tree. 3797 */const BK=Ee("Key",[["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["path",{d:"m15.5 7.5 3 3L22 7l-3-3",key:"1rn1fs"}]]);/** 3798 * @license lucide-react v0.323.0 - ISC 3799 * 3800 * This source code is licensed under the ISC license. 3801 * See the LICENSE file in the root directory of this source tree. 3802 */const Si=Ee("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/** 3803 * @license lucide-react v0.323.0 - ISC 3804 * 3805 * This source code is licensed under the ISC license. 3806 * See the LICENSE file in the root directory of this source tree. 3807 */const kl=Ee("Leaf",[["path",{d:"M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19 2c1 2 2 4.18 2 8 0 5.5-4.78 10-10 10Z",key:"nnexq3"}],["path",{d:"M2 21c0-3 1.85-5.36 5.08-6C9.5 14.52 12 13 13 12",key:"mt58a7"}]]);/** 3808 * @license lucide-react v0.323.0 - ISC 3809 * 3810 * This source code is licensed under the ISC license. 3811 * See the LICENSE file in the root directory of this source tree. 3812 */const WK=Ee("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/** 3813 * @license lucide-react v0.323.0 - ISC 3814 * 3815 * This source code is licensed under the ISC license. 3816 * See the LICENSE file in the root directory of this source tree. 3817 */const qL=Ee("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);/** 3818 * @license lucide-react v0.323.0 - ISC 3819 * 3820 * This source code is licensed under the ISC license. 3821 * See the LICENSE file in the root directory of this source tree. 3822 */const hs=Ee("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** 3823 * @license lucide-react v0.323.0 - ISC 3824 * 3825 * This source code is licensed under the ISC license. 3826 * See the LICENSE file in the root directory of this source tree.
3827 */const HK=Ee("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"}]]);/** 3828 * @license lucide-react v0.323.0 - ISC 3829 * 3830 * This source code is licensed under the ISC license. 3831 * See the LICENSE file in the root directory of this source tree. 3832 */const qK=Ee("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/** 3833 * @license lucide-react v0.323.0 - ISC 3834 * 3835 * This source code is licensed under the ISC license. 3836 * See the LICENSE file in the root directory of this source tree. 3837 */const GK=Ee("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"}]]);/** 3838 * @license lucide-react v0.323.0 - ISC 3839 * 3840 * This source code is licensed under the ISC license. 3841 * See the LICENSE file in the root directory of this source tree. 3842 */const rs=Ee("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"}]]);/** 3843 * @license lucide-react v0.323.0 - ISC 3844 * 3845 * This source code is licensed under the ISC license. 3846 * See the LICENSE file in the root directory of this source tree. 3847 */const Rn=Ee("MapPin",[["path",{d:"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z",key:"2oe9fu"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/** 3848 * @license lucide-react v0.323.0 - ISC 3849 * 3850 * This source code is licensed under the ISC license. 3851 * See the LICENSE file in the root directory of this source tree. 3852 */const ur=Ee("MapPinned",[["path",{d:"M18 8c0 4.5-6 9-6 9s-6-4.5-6-9a6 6 0 0 1 12 0",key:"yrbn30"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["path",{d:"M8.835 14H5a1 1 0 0 0-.9.7l-2 6c-.1.1-.1.2-.1.3 0 .6.4 1 1 1h18c.6 0 1-.4 1-1 0-.1 0-.2-.1-.3l-2-6a1 1 0 0 0-.9-.7h-3.835",key:"112zkj"}]]);/** 3853 * @license lucide-react v0.323.0 - ISC 3854 * 3855 * This source code is licensed under the ISC license. 3856 * See the LICENSE file in the root directory of this source tree. 3857 */const h1=Ee("Map",[["polygon",{points:"3 6 9 3 15 6 21 3 21 18 15 21 9 18 3 21",key:"ok2ie8"}],["line",{x1:"9",x2:"9",y1:"3",y2:"18",key:"w34qz5"}],["line",{x1:"15",x2:"15",y1:"6",y2:"21",key:"volv9a"}]]);/** 3858 * @license lucide-react v0.323.0 - ISC 3859 * 3860 * This source code is licensed under the ISC license. 3861 * See the LICENSE file in the root directory of this source tree. 3862 */const yx=Ee("Megaphone",[["path",{d:"m3 11 18-5v12L3 14v-3z",key:"n962bs"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}]]);/** 3863 * @license lucide-react v0.323.0 - ISC 3864 * 3865 * This source code is licensed under the ISC license. 3866 * See the LICENSE file in the root directory of this source tree. 3867 */const ZK=Ee("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/** 3868 * @license lucide-react v0.323.0 - ISC 3869 * 3870 * This source code is licensed under the ISC license. 3871 * See the LICENSE file in the root directory of this source tree. 3872 */const GL=Ee("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"}]]);/** 3873 * @license lucide-react v0.323.0 - ISC 3874 * 3875 * This source code is licensed under the ISC license. 3876 * See the LICENSE file in the root directory of this source tree. 3877 */const KK=Ee("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/** 3878 * @license lucide-react v0.323.0 - ISC 3879 * 3880 * This source code is licensed under the ISC license. 3881 * See the LICENSE file in the root directory of this source tree. 3882 */const YK=Ee("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** 3883 * @license lucide-react v0.323.0 - ISC 3884 * 3885 * This source code is licensed under the ISC license. 3886 * See the LICENSE file in the root directory of this source tree. 3887 */const vh=Ee("MousePointer",[["path",{d:"m3 3 7.07 16.97 2.51-7.39 7.39-2.51L3 3z",key:"y2ucgo"}],["path",{d:"m13 13 6 6",key:"1nhxnf"}]]);/** 3888 * @license lucide-react v0.323.0 - ISC 3889 * 3890 * This source code is licensed under the ISC license. 3891 * See the LICENSE file in the root directory of this source tree. 3892 */const QK=Ee("PanelLeftOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);/** 3893 * @license lucide-react v0.323.0 - ISC 3894 * 3895 * This source code is licensed under the ISC license. 3896 * See the LICENSE file in the root directory of this source tree. 3897 */const XK=Ee("PawPrint",[["circle",{cx:"11",cy:"4",r:"2",key:"vol9p0"}],["circle",{cx:"18",cy:"8",r:"2",key:"17gozi"}],["circle",{cx:"20",cy:"16",r:"2",key:"1v9bxh"}],["path",{d:"M9 10a5 5 0 0 1 5 5v3.5a3.5 3.5 0 0 1-6.84 1.045Q6.52 17.48 4.46 16.84A3.5 3.5 0 0 1 5.5 10Z",key:"1ydw1z"}]]);/** 3898 * @license lucide-react v0.323.0 - ISC 3899 * 3900 * This source code is licensed under the ISC license. 3901 * See the LICENSE file in the root directory of this source tree. 3902 */const _f=Ee("PenTool",[["path",{d:"m12 19 7-7 3 3-7 7-3-3z",key:"rklqx2"}],["path",{d:"m18 13-1.5-7.5L2 2l3.5 14.5L13 18l5-5z",key:"1et58u"}],["path",{d:"m2 2 7.586 7.586",key:"etlp93"}],["circle",{cx:"11",cy:"11",r:"2",key:"xmgehs"}]]);/** 3903 * @license lucide-react v0.323.0 - ISC 3904 * 3905 * This source code is licensed under the ISC license. 3906 * See the LICENSE file in the root directory of this source tree. 3907 */const JK=Ee("PencilRuler",[["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"M13 7 8.7 2.7a2.41 2.41 0 0 0-3.4 0L2.7 5.3a2.41 2.41 0 0 0 0 3.4L7 13",key:"orapub"}
3907],["path",{d:"m8 6 2-2",key:"115y1s"}],["path",{d:"m2 22 5.5-1.5L21.17 6.83a2.82 2.82 0 0 0-4-4L3.5 16.5Z",key:"hes763"}],["path",{d:"m18 16 2-2",key:"ee94s4"}],["path",{d:"m17 11 4.3 4.3c.94.94.94 2.46 0 3.4l-2.6 2.6c-.94.94-2.46.94-3.4 0L11 17",key:"cfq27r"}]]);/** 3908 * @license lucide-react v0.323.0 - ISC 3909 * 3910 * This source code is licensed under the ISC license. 3911 * See the LICENSE file in the root directory of this source tree. 3912 */const fd=Ee("Pencil",[["path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z",key:"5qss01"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** 3913 * @license lucide-react v0.323.0 - ISC 3914 * 3915 * This source code is licensed under the ISC license. 3916 * See the LICENSE file in the root directory of this source tree. 3917 */const rm=Ee("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"}]]);/** 3918 * @license lucide-react v0.323.0 - ISC 3919 * 3920 * This source code is licensed under the ISC license. 3921 * See the LICENSE file in the root directory of this source tree. 3922 */const hr=Ee("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** 3923 * @license lucide-react v0.323.0 - ISC 3924 * 3925 * This source code is licensed under the ISC license. 3926 * See the LICENSE file in the root directory of this source tree. 3927 */const eY=Ee("Radio",[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]]);/** 3928 * @license lucide-react v0.323.0 - ISC 3929 * 3930 * This source code is licensed under the ISC license. 3931 * See the LICENSE file in the root directory of this source tree. 3932 */const ft=Ee("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"}]]);/** 3933 * @license lucide-react v0.323.0 - ISC 3934 * 3935 * This source code is licensed under the ISC license. 3936 * See the LICENSE file in the root directory of this source tree. 3937 */const nc=Ee("Route",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]]);/** 3938 * @license lucide-react v0.323.0 - ISC 3939 * 3940 * This source code is licensed under the ISC license. 3941 * See the LICENSE file in the root directory of this source tree. 3942 */const tY=Ee("Ruler",[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]]);/** 3943 * @license lucide-react v0.323.0 - ISC 3944 * 3945 * This source code is licensed under the ISC license. 3946 * See the LICENSE file in the root directory of this source tree. 3947 */const xc=Ee("Save",[["path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z",key:"1owoqh"}],["polyline",{points:"17 21 17 13 7 13 7 21",key:"1md35c"}],["polyline",{points:"7 3 7 8 15 8",key:"8nz8an"}]]);/** 3948 * @license lucide-react v0.323.0 - ISC 3949 * 3950 * This source code is licensed under the ISC license. 3951 * See the LICENSE file in the root directory of this source tree. 3952 */const nY=Ee("Scale",[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]]);/** 3953 * @license lucide-react v0.323.0 - ISC 3954 * 3955 * This source code is licensed under the ISC license. 3956 * See the LICENSE file in the root directory of this source tree. 3957 */const Ws=Ee("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** 3958 * @license lucide-react v0.323.0 - ISC 3959 * 3960 * This source code is licensed under the ISC license. 3961 * See the LICENSE file in the root directory of this source tree. 3962 */const rY=Ee("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]);/** 3963 * @license lucide-react v0.323.0 - ISC 3964 * 3965 * This source code is licensed under the ISC license. 3966 * See the LICENSE file in the root directory of this source tree. 3967 */const sY=Ee("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"}]]);/** 3968 * @license lucide-react v0.323.0 - ISC 3969 * 3970 * This source code is licensed under the ISC license. 3971 * See the LICENSE file in the root directory of this source tree. 3972 */const oY=Ee("ShieldCheck",[["path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10",key:"1irkt0"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** 3973 * @license lucide-react v0.323.0 - ISC 3974 * 3975 * This source code is licensed under the ISC license. 3976 * See the LICENSE file in the root directory of this source tree. 3977 */const rc=Ee("Shield",[["path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10",key:"1irkt0"}]]);/** 3978 * @license lucide-react v0.323.0 - ISC 3979 * 3980 * This source code is licensed under the ISC license. 3981 * See the LICENSE file in the root directory of this source tree. 3982 */const xb=Ee("Siren",[["path",{d:"M7 12a5 5 0 0 1 5-5v0a5 5 0 0 1 5 5v6H7v-6Z",key:"rmc51c"}],["path",{d:"M5 20a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v2H5v-2Z",key:"yyvmjy"}],["path",{d:"M21 12h1",key:"jtio3y"}],["path",{d:"M18.5 4.5 18 5",key:"g5sp9y"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"m4.929 4.929.707.707",key:"1i51kw"}],["path",{d:"M12 12v6",key:"3ahymv"}]]);/** 3983 * @license lucide-react v0.323.0 - ISC 3984 * 3985 * This source code is licensed under the ISC license. 3986 * See the LICENSE file in the root directory of this source tree. 3987 */const iY=Ee("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);/** 3988 * @license lucide-react v0.323.0 - ISC 3989 * 3990 * This source code is licensed under the ISC license. 3991 * See the LICENSE file in the root directory of this source tree. 3992 */const Gc=Ee("Sparkles",[["path",{d:"m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z",key:"17u4zn"}],["path",{d:"M5 3v4",key:"bklmnn"}],["path",{d:"M19 17v4",key:"iiml17"}],["path",{d:"M3 5h4",key:"nem4j1"}],["path",{d:"M17 19h4",key:"lbex7p"}]]);/** 3993 * @license lucide-react v0.323.0 - ISC 3994 * 3995 * This source code is licensed under the ISC license. 3996 * See the LICENSE file in the root directory of this source tree. 3997 */const pp=Ee("Sprout",[["path",{d:"M7 20h10",key:"e6iznv"}],["path",{d:"M10 20c5.5-2.5.8-6.4 3-10",key:"161w41"}],["path",{d:"M9.5 9.4c1.1.8 1.8 2.2 2.3 3.7-2 .4-3.5.4-4.8-.3-1.2-.6-2.3-1.9-3-4.2 2.8-.5 4.4 0 5.5.8z",key:"9gtqwd"}],["path",{d:"M14.1 6a7 7 0 0 0-1.1 4c1.9-.1 3.3-.6 4.3-1.4 1-1 1.6-2.3 1.7-4.6-2.7.1-4 1-4.9 2z",key:"bkxnd2"}]]);/** 3998 * @license lucide-react v0.323.0 - ISC 3999 * 4000 * This source code is licensed under the ISC license. 4001 * See the LICENSE file in the root directory of this source tree. 4002 */const aY=Ee("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** 4003 * @license lucide-react v0.323.0 - ISC 4004 * 4005 * This source code is licensed under the ISC license. 4006 * See the LICENSE file in the root directory of this source tree. 4007 */const ZL=Ee("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"}]]);/** 4008 * @license lucide-react v0.323.0 - ISC 4009 * 4010 * This source code is licensed under the ISC license. 4011 * See the LICENSE file in the root directory of this source tree. 4012 */const Ef=Ee("Tractor",[["path",{d:"M3 4h9l1 7",key:"1ftpo8"}],["path",{d:"M4 11V4",key:"9ft8pt"}],["path",{d:"M8 10V4",key:"1y5f7n"}],["path",{d:"M18 5c-.6 0-1 .4-1 1v5.6",key:"10zbvr"}],["path",{d:"m10 11 11 .9c.6 0 .9.5.8 1.1l-.8 5h-1",key:"2w242w"}],["circle",{cx:"7",cy:"15",r:".5",key:"fbsjqy"}],["circle",{cx:"7",cy:"15",r:"5",key:"ddtuc"}],["path",{d:"M16 18h-5",key:"bq60fd"}],["circle",{cx:"18",cy:"18",r:"2",key:"1emm8v"}]]);/** 4013 * @license lucide-react v0.323.0 - ISC 4014 * 4015 * This source code is licensed under the ISC license. 4016 * See the LICENSE file in the root directory of this source tree. 4017 */const Vt=Ee("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}
4017],["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"}]]);/** 4018 * @license lucide-react v0.323.0 - ISC 4019 * 4020 * This source code is licensed under the ISC license. 4021 * See the LICENSE file in the root directory of this source tree. 4022 */const No=Ee("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"}]]);/** 4023 * @license lucide-react v0.323.0 - ISC 4024 * 4025 * This source code is licensed under the ISC license. 4026 * See the LICENSE file in the root directory of this source tree. 4027 */const sc=Ee("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"}]]);/** 4028 * @license lucide-react v0.323.0 - ISC 4029 * 4030 * This source code is licensed under the ISC license. 4031 * See the LICENSE file in the root directory of this source tree. 4032 */const po=Ee("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"}]]);/** 4033 * @license lucide-react v0.323.0 - ISC 4034 * 4035 * This source code is licensed under the ISC license. 4036 * See the LICENSE file in the root directory of this source tree. 4037 */const Jk=Ee("UsersRound",[["path",{d:"M18 21a8 8 0 0 0-16 0",key:"3ypg7q"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3",key:"10s06x"}]]);/** 4038 * @license lucide-react v0.323.0 - ISC 4039 * 4040 * This source code is licensed under the ISC license. 4041 * See the LICENSE file in the root directory of this source tree. 4042 */const cr=Ee("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"}]]);/** 4043 * @license lucide-react v0.323.0 - ISC 4044 * 4045 * This source code is licensed under the ISC license. 4046 * See the LICENSE file in the root directory of this source tree. 4047 */const lY=Ee("Wheat",[["path",{d:"M2 22 16 8",key:"60hf96"}],["path",{d:"M3.47 12.53 5 11l1.53 1.53a3.5 3.5 0 0 1 0 4.94L5 19l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1rdhi6"}],["path",{d:"M7.47 8.53 9 7l1.53 1.53a3.5 3.5 0 0 1 0 4.94L9 15l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1sdzmb"}],["path",{d:"M11.47 4.53 13 3l1.53 1.53a3.5 3.5 0 0 1 0 4.94L13 11l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"eoatbi"}],["path",{d:"M20 2h2v2a4 4 0 0 1-4 4h-2V6a4 4 0 0 1 4-4Z",key:"19rau1"}],["path",{d:"M11.47 17.47 13 19l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L5 19l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"tc8ph9"}],["path",{d:"M15.47 13.47 17 15l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L9 15l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"2m8kc5"}],["path",{d:"M19.47 9.47 21 11l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L13 11l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"vex3ng"}]]);/** 4048 * @license lucide-react v0.323.0 - ISC 4049 * 4050 * This source code is licensed under the ISC license. 4051 * See the LICENSE file in the root directory of this source tree. 4052 */const KL=Ee("XCircle",[["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"}]]);/** 4053 * @license lucide-react v0.323.0 - ISC 4054 * 4055 * This source code is licensed under the ISC license. 4056 * See the LICENSE file in the root directory of this source tree. 4057 */const br=Ee("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function rr({...t}){return o.jsx(o1,{"data-slot":"dialog",...t})}function cY({...t}){return o.jsx(i1,{"data-slot":"dialog-portal",...t})}function uY({className:t,...e}){return o.jsx(a1,{"data-slot":"dialog-overlay",className:Oe("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...e})}function sr({className:t,children:e,...n}){return o.jsxs(cY,{"data-slot":"dialog-portal",children:[o.jsx(uY,{}),o.jsxs(l1,{"data-slot":"dialog-content",className:Oe("bg-background 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 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 roun
4057ded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",t),...n,children:[e,o.jsxs(vx,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[o.jsx(br,{}),o.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function or({className:t,...e}){return o.jsx("div",{"data-slot":"dialog-header",className:Oe("flex flex-col gap-2 text-center sm:text-left",t),...e})}function ks({className:t,...e}){return o.jsx("div",{"data-slot":"dialog-footer",className:Oe("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function Gn({className:t,...e}){return o.jsx(c1,{"data-slot":"dialog-title",className:Oe("text-lg leading-none font-semibold",t),...e})}function ir({className:t,...e}){return o.jsx(FL,{"data-slot":"dialog-description",className:Oe("text-muted-foreground text-sm",t),...e})}const f1={async signup(t){try{const n=await pe(ge,"signup")(t);if(!n.data.success)throw new Error(n.data.message||"Erreur lors de l'inscription");return await PA(Sl,t.email,t.password),{uid:n.data.uid}}catch(e){throw console.error("Error during signup:",e),e.code==="functions/already-exists"?new Error("Un compte existe déjà avec cet email"):e.code==="functions/invalid-argument"?new Error(e.message||"Données invalides"):e}},async resetPassword(t){await qV(Sl,t.toLowerCase().trim())}};function dY(){const[t,e]=u.useState(""),[n,r]=u.useState(""),[s,i]=u.useState(""),[a,l]=u.useState(!1),{login:c}=nn(),[d,h]=u.useState(!1),[f,p]=u.useState(""),[g,v]=u.useState(!1),[x,y]=u.useState(!1),[b,w]=u.useState(""),j=async A=>{A.preventDefault(),i(""),l(!0);try{await c(t,n)}catch(N){console.error("Login error COMPLET:",N),console.error("Error code:",N.code),console.error("Error message:",N.message),N.code==="auth/invalid-credential"?i("Email ou mot de passe incorrect"):N.code==="auth/user-not-found"?i("Aucun utilisateur trouvé avec cet email"):N.code==="auth/wrong-password"?i("Mot de passe incorrect"):N.code==="auth/too-many-requests"?i("Trop de tentatives de connexion. Veuillez réessayer plus tard."):i(`Erreur de connexion: ${N.code||N.message}`)}finally{l(!1)}},E=async A=>{A.preventDefault(),w(""),v(!0);try{await f1.resetPassword(f),y(!0)}catch(N){console.error("Reset password error:",N),N.code==="auth/user-not-found"?y(!0):N.code==="auth/invalid-email"?w("Adresse email invalide"):w("Erreur lors de l'envoi. Veuillez réessayer.")}finally{v(!1)}},P=()=>{p(t),y(!1),w(""),h(!0)};return o.jsxs("div",{className:"min-h-screen flex flex-col login-gradient relative overflow-hidden",children:[o.jsx("div",{className:"absolute inset-0 opacity-[0.03]",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E")`}}),o.jsx("div",{className:"flex-1 flex items-center justify-center p-4 relative z-10",children:o.jsxs("div",{className:"w-full max-w-md animate-fade-in",children:[o.jsxs("div",{className:"text-center mb-8",children:[o.jsx("div",{className:"inline-flex items-center justify-center mb-5",children:o.jsx("img",{src:"/logo.png",alt:"Chassé & Croisé",className:"h-16 w-16 rounded-2xl shadow-lg ring-1 ring-white/20"})}),o.jsx("h1",{className:"text-3xl font-bold text-white font-heading tracking-tight",children:"Chassé & Croisé"}),o.jsx("p",{className:"text-white/50 mt-2 text-sm",children:"Connectez-vous à votre espace"})]}),o.jsxs("div",{className:"bg-white/[0.07] backdrop-blur-xl rounded-2xl border border-white/10 shadow-2xl p-8",children:[o.jsxs("form",{onSubmit:j,className:"space-y-5",autoComplete:"on",children:[s&&o.jsx("div",{className:"bg-red-500/15 border border-red-400/20 rounded-lg px-4 py-3 text-sm text-red-200",children:s}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"email",className:"text-white/70 text-sm font-medium",children:"Email"}),o.jsx(Ne,{id:"email",name:"email",type:"email",autoComplete:"email",value:t,onChange:A=>e(A.target.value),required:!0,disabled:a,placeholder:"[email protected]",className:"bg-white/[0.06] border-white/10 text-white placeholder:text-white/25 focus:border-app-green-light/50 focus:ring-app-green-light/20 h-11"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"password",className:"text-white/70 text-sm font-medium",children:"Mot de passe"}),o.jsx(Ne,{id:"password",name:"password",type:"password",autoComplete:"current-password",value:n,onChange:A=>r(A.target.value),required:!0,disabled:a,placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",className:"bg-white/[0.06] border-white/10 text-white placeholder:text-white/25 focus:border-app-green-light/50 focus:ring-app-green-light/20 h-11"})]}),o.jsx(Z,{type:"submit",className:"w-full h-11 bg-white text-app-bg font-semibold hover:bg-white/90 transition-all",disabled:a,children:a?o.jsxs(o.Fragment,{children:[o.jsx(hs,{className:"mr-2 h-4 w-4 animate-spin"}),"Connexion..."]}):"Se connecter"}),o.jsx("div",{className:"text-center",children:o.jsxs("button",{type:"button",className:"text-sm text-white/40 hover:text-white/70 transition-colors inline-flex items-center gap-1.5",onClick:P,children:[o.jsx(HL,{className:"h-3.5 w-3.5"}),"Mot de passe oublié ?"]})})]}),o.jsx("div",{className:"relative my-6",children:o.jsx("div",{className:"absolute inset-0 flex items-center",children:o.jsx("div",{className:"w-full border-t border-white/10"})})}),o.jsxs("div",{className:"bg-white/[0.04] rounded-xl p-5 border border-white/[0.06]",children:[o.jsx("div",{className:"text-white/80 font-medium text-sm",children:"Première connexion ?"}),o.jsx("p",{className:"text-[13px] text-white/40 mt-1.5 leading-relaxed",children:"Si votre email a été ajouté au système, créez votre compte pour accéder à vos fonctionnalités."}),o.jsx("div",{className:"mt-3",children:o.jsx(Fa,{to:xe.signup,children:o.jsx(Z,{variant:"outline",className:"w-full border-white/15 text-white/80 bg-transparent hover:bg-white/8 hover:text-white hover:border-white/25",children:"Créer mon compte"})})})]})]})]})}),o.jsxs("div",{className:"relative z-10",children:[o.jsx("div",{className:"flex justify-center",children:o.jsx("img",{src:"/arbres.svg",alt:"Arbres",className:"h-28 w-auto object-contain opacity-20"})}),o.jsx("div",{className:"h-1 bg-app-green-medium/40"})]}),o.jsx(rr,{open:d,onOpenChange:h,children:o.jsxs(sr,{className:"sm:max-w-md",children:[o.jsxs(or,{children:[o.jsx(Gn,{children:"Réinitialiser le mot de passe"}),o.jsx(ir,{children:"Entrez votre adresse email pour recevoir un lien de réinitialisation."})]}),x?o.jsxs("div",{className:"py-6 text-center space-y-4",children:[o.jsx(ns,{className:"h-12 w-12 text-app-green-medium mx-auto"}),o.jsxs("div",{children:[o.jsx("p",{className:"font-medium text-foreground",children:"Email envoyé !"}),o.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Si un compte existe avec cette adresse, vous recevrez un email avec un lien pour réinitialiser votre mot de passe."})]}),o.jsx(Z,{onClick:()=>h(!1),className:"w-full",children:"Fermer"})]}):o.jsxs("form",{onSubmit:E,className:"space-y-4",children:[b&&o.jsx(yr,{variant:"destructive",children:o.jsx(wr,{children:b})}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"reset-email",children:"Email"}),o.jsx(Ne,{id:"reset-email",type:"email",value:f,onChange:A=>p(A.target.value),required:!0,disabled:g,placeholder:"[email protected]"})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(Z,{type:"button",variant:"outline",className:"flex-1",onClick:()=>h(!1),disabled:g,children:"Annuler"}),o.jsx(Z,{type:"submit",className:"flex-1",disabled:g,children:g?o.jsxs(o.Fragment,{children:[o.jsx(hs,{className:"mr-2 h-4 w-4 animate-spin"}),"Envoi..."]}):"Envoyer"})]})]})]})})]})}function eP(t,[e,n]){return Math.min(n,Math.max(e,t))}function m1(t){const e=t+"CollectionProvider",[n,r]=Rs(e),[s,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),a=x=>{const{scope:y,children:b}=x,w=Ce.useRef(null),j=Ce.useRef(new Map).current;return o.jsx(s,{scope:y,itemMap:j,collectionRef:w,children:b})};a.displayName=e;const l=t+"CollectionSlot",c=Ga(l),d=Ce.forwardRef((x,y)=>{const{scope:b,children:w}=x,j=i(l,b),E=At(y,j.collectionRef);return o.jsx(c,{ref:E,children:w})});d.displayName=l;const h=t+"CollectionItemSlot",f="data-radix-collection-item",p=Ga(h),g=Ce.forwardRef((x,y)=>{const{scope:b,children:w,...j}=x,E=Ce.useRef(null),P=At(y,E),A=i(h,b);return Ce.useEffect(()=>(A.itemMap.set(E,{ref:E,...j}),()=>void A.itemMap.delete(E))),o.jsx(p,{[f]:"",ref:P,children:w})});g.displayName=h;function v(x){const y=i(t+"CollectionConsumer",x);return Ce.useCallback(()=>{const w=y.collectionRef.current;if(!w)return[];const j=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(y.itemMap.values()).sort((A,N)=>j.indexOf(A.ref.current)-j.indexOf(N.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:a,Slot:d,ItemSlot:g},v,r]}var hY=u.createContext(void 0);function sm(t){const e=u.useContext(hY);return t||e||"ltr"}const fY=["top","right","bottom","left"],Za=Math.min,bs=Math.max,ov=Math.round,gp=Math.floor,Jo=t=>({x:t,y:t}
vendor: 4,117 bytes, line 4057
4057),mY={left:"right",right:"left",bottom:"top",top:"bottom"},pY={start:"end",end:"start"};function yb(t,e,n){return bs(t,Za(e,n))}function zi(t,e){return typeof t=="function"?t(e):t}function $i(t){return t.split("-")[0]}function md(t){return t.split("-")[1]}function p1(t){return t==="x"?"y":"x"}function g1(t){return t==="y"?"height":"width"}const gY=new Set(["top","bottom"]);function Ho(t){return gY.has($i(t))?"y":"x"}function v1(t){return p1(Ho(t))}function vY(t,e,n){n===void 0&&(n=!1);const r=md(t),s=v1(t),i=g1(s);let a=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(a=iv(a)),[a,iv(a)]}function xY(t){const e=iv(t);return[wb(t),e,wb(e)]}function wb(t){return t.replace(/start|end/g,e=>pY[e])}const tP=["left","right"],nP=["right","left"],yY=["top","bottom"],wY=["bottom","top"];function bY(t,e,n){switch(t){case"top":case"bottom":return n?e?nP:tP:e?tP:nP;case"left":case"right":return e?yY:wY;default:return[]}}function jY(t,e,n,r){const s=md(t);let i=bY($i(t),n==="start",r);return s&&(i=i.map(a=>a+"-"+s),e&&(i=i.concat(i.map(wb)))),i}function iv(t){return t.replace(/left|right|bottom|top/g,e=>mY[e])}function CY(t){return{top:0,right:0,bottom:0,left:0,...t}}function YL(t){return typeof t!="number"?CY(t):{top:t,right:t,bottom:t,left:t}}function av(t){const{x:e,y:n,width:r,height:s}=t;return{width:r,height:s,top:n,left:e,right:e+r,bottom:n+s,x:e,y:n}}function rP(t,e,n){let{reference:r,floating:s}=t;const i=Ho(e),a=v1(e),l=g1(a),c=$i(e),d=i==="y",h=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,p=r[l]/2-s[l]/2;let g;switch(c){case"top":g={x:h,y:r.y-s.height};break;case"bottom":g={x:h,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:f};break;case"left":g={x:r.x-s.width,y:f};break;default:g={x:r.x,y:r.y}}switch(md(e)){case"start":g[a]-=p*(n&&d?-1:1);break;case"end":g[a]+=p*(n&&d?-1:1);break}return g}const NY=async(t,e,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:a}=n,l=i.filter(Boolean),c=await(a.isRTL==null?void 0:a.isRTL(e));let d=await a.getElementRects({reference:t,floating:e,strategy:s}),{x:h,y:f}=rP(d,r,c),p=r,g={},v=0;for(let x=0;x<l.length;x++){const{name:y,fn:b}=l[x],{x:w,y:j,data:E,reset:P}=await b({x:h,y:f,initialPlacement:r,placement:p,strategy:s,middlewareData:g,rects:d,platform:a,elements:{reference:t,floating:e}});h=w??h,f=j??f,g={...g,[y]:{...g[y],...E}},P&&v<=50&&(v++,typeof P=="object"&&(P.placement&&(p=P.placement),P.rects&&(d=P.rects===!0?await a.getElementRects({reference:t,floating:e,strategy:s}):P.rects),{x:h,y:f}=rP(d,p,c)),x=-1)}return{x:h,y:f,placement:p,strategy:s,middlewareData:g}};async function Sf(t,e){var n;e===void 0&&(e={});const{x:r,y:s,platform:i,rects:a,elements:l,strategy:c}=t,{boundary:d="clippingAncestors",rootBoundary:h="viewport",elementContext:f="floating",altBoundary:p=!1,padding:g=0}=zi(e,t),v=YL(g),y=l[p?f==="floating"?"reference":"floating":f],b=av(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(y)))==null||n?y:y.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:d,rootBoundary:h,strategy:c})),w=f==="floating"?{x:r,y:s,width:a.floating.width,height:a.floating.height}:a.reference,j=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),E=await(i.isElement==null?void 0:i.isElement(j))?await(i.getScale==null?void 0:i.getScale(j))||{x:1,y:1}:{x:1,y:1},P=av(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:j,strategy:c}):w);return{top:(b.top-P.top+v.top)/E.y,bottom:(P.bottom-b.bottom+v.bottom)/E.y,left:(b.left-P.left+v.left)/E.x,right:(P.right-b.right+v.right)/E.x}}const _Y=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:s,rects:i,platform:a,elements:l,middlewareData:c}=e,{element:d,padding:h=0}=zi(t,e)||{};if(d==null)return{};const f=YL(h),p={x:n,y:r},g=v1(s),v=g1(g),x=await a.getDimensions(d),y=g==="y",b=y?"top":"left",w=y?"bottom":"right",j=y?"clientHeight":"clientWidth",E=i.reference[v]+i.reference[g]-
4057p[g]-i.floating[v],P=p[g]-i.reference[g],A=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let N=A?A[j]:0;(!N||!await(a.isElement==null?void 0:a.isElement(A)))&&(N=l.floating[j]||i.floating[v]);const _=E/2-P/2,k=N/2-x[v]/2-1,L=Za(f[b],k),I=Za(f[w],k),S=L,T=N-x[v]-I,V=N/2-x[v]/2+_,$=yb(S,V,T),H=!c.arrow&&md(s)!=null&&V!==$&&i.reference[v]/2-(V<S?L:I)-x[v]/2<0,W=H?V<S?V-S:V-T:0;return{[g]:p[g]+W,data:{[g]:$,centerOffset:V-$-W,...H&&{alignmentOffset:W}},reset:H}}}),EY=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:s,middlewareData:i,rects:a,initialPlacement:l,platform:c,elements:d}=e,{mainAxis:h=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:x=!0,...y}=zi(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const b=$i(s),w=Ho(l),j=$i(l)===l,E=await(c.isRTL==null?void 0:c.isRTL(d.floating)),P=p||(j||!x?[iv(l)]:xY(l)),A=v!=="none";!p&&A&&P.push(...jY(l,x,v,E));const N=[l,...P],_=await Sf(e,y),k=[];let L=((r=i.flip)==null?void 0:r.overflows)||[];if(h&&k.push(_[b]),f){const V=vY(s,a,E);k.push(_[V[0]],_[V[1]])}if(L=[...L,{placement:s,overflows:k}],!k.every(V=>V<=0)){var I,S;const V=(((I=i.flip)==null?void 0:I.index)||0)+1,$=N[V];if($&&(!(f==="alignment"?w!==Ho($):!1)||L.every(D=>Ho(D.placement)===w?D.overflows[0]>0:!0)))return{data:{index:V,overflows:L},reset:{placement:$}};let H=(S=L.filter(W=>W.overflows[0]<=0).sort((W,D)=>W.overflows[1]-D.overflows[1])[0])==null?void 0:S.placement;if(!H)switch(g){case"bestFit":{var T;const W=(T=L.filter(D=>{if(A){const F=Ho(D.placement);return F===w||F==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(F=>F>0).reduce((F,O)=>F+O,0)]).sort((D,F)=>D[1]-F[1])[0])==null?void 0:T[0];W&&(H=W);break}case"initialPlacement":H=l;break}if(s!==H)return{reset:{placement:H}}}return{}}}};function sP(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function oP(t){return fY.some(e=>t[e]>=0)}const SY=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...s}=zi(t,e);switch(r){case"referenceHidden":{const i=await Sf(e,{...s,elementContext:"reference"}),a=sP(i,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:oP(a)}}}case"escaped":{const i=await Sf(e,{...s,altBoundary:!0}),a=sP(i,n.floating);return{data:{escapedOffsets:a,escaped:oP(a)}}}default:return{}}}}},QL=new Set(["left","top"]);async function kY(t,e){const{placement:n,platform:r,elements:s}=t,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),a=$i(n),l=md(n),c=Ho(n)==="y",d=QL.has(a)?-1:1,h=i&&c?-1:1,f=zi(e,t);let{mainAxis:p,crossAxis:g,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof v=="number"&&(g=l==="end"?v*-1:v),c?{x:g*h,y:p*d}:{x:p*d,y:g*h}}const PY=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:s,y:i,placement:a,middlewareData:l}=e,c=await kY(e,t);return a===((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:a}}}}},IY=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:s}=e,{mainAxis:i=!0,crossAxis:a=!1,limiter:l={fn:y=>{let{x:b,y:w}=y;return{x:b,y:w}}},...c}=zi(t,e),d={x:n,y:r},h=await Sf(e,c),f=Ho($i(s)),p=p1(f);let g=d[p],v=d[f];if(i){const y=p==="y"?"top":"left",b=p==="y"?"bottom":"right",w=g+h[y],j=g-h[b];g=yb(w,g,j)}if(a){const y=f==="y"?"top":"left",b=f==="y"?"bottom":"right",w=v+h[y],j=v-h[b];v=yb(w,v,j)}const x=l.fn({...e,[p]:g,[f]:v});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[p]:i,[f]:a}}}}}},TY=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:s,rects:i,middlewareData:a}=e,{offset:l=0,mainAxis:c=!0,crossAxis:d=!0}=zi(t,e),h={x:n,y:r},f=Ho(s),p=p1(f);let g=h[p],v=h[f];const x=zi(l,e),y=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(c){const j=p==="y"?"height":"width",E=i.reference[p]-i.floating[j]+y.mainAxis,P=i.reference[p]+i.reference[j]-y.mainAxis;g<E?g=E:g>P&&(g=P)}if(d){var b,w;const j=p==="y"?"width":"height",E=QL.has($i(s)),P=i.reference[f]-i.floating[j]+(E&&((b=a.offset)==null?void 0:b[f])||0)+(E?0:y.crossAxis),A=i.reference[f]+i.reference[j]+(E?0:((w=a.offset)==null?void 0:w[f])||0)-(E?y.crossAxis:0);v<P?v=P:v>A&&(v=A)}return{[p]:g,[f]:v}}}},AY=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:s,rects:i,platform:a,elements:l}=e,{apply:c=()=>{},...d}=zi(t,e),h=await Sf(e,d),f=$i(s),p=md(s),g=Ho(s)==="y",{width:v,height:x}=i.floating;let y,b;f==="top"||f==="bottom"?(y=f,b=p===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(b=f,y=p==="end"?"top":"bottom");const w=x-h.top-h.bottom,j=v-h.left-h.right,E=Za(x-h[y],w),P=Za(v-h[b],j),A=!e.middlewareData.shift;let N=E,_=P;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(_=j),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(N=w),A&&!p){const L=bs(h.left,0),I=bs(h.right,0),S=bs(h.top,0),T=bs(h.bottom,0);g?_=v-2*(L!==0||I!==0?L+I:bs(h.left,h.right)):N=x-2*(S!==0||T!==0?S+T:bs(h.top,h.bottom))}await c({...e,availableWidth:_,availableHeight:N});const k=await a.getDimensions(l.floating);return v!==k.width||x!==k.height?{reset:{rects:!0}}:{}}}};function wx(){return typeof window<"u"}function pd(t){return XL(t)?(t.nodeName||"").toLowerCase():"#document"}function Es(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function ii(t){var e;return(e=(XL(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function XL(t){return wx()?t instanceof Node||t instanceof Es(t).Node:!1}function _o(t){return wx()?t instanceof Element||t instanceof Es(t).Element:!1}function ri(t){return wx()?t instanceof HTMLElement||t instanceof Es(t).HTMLElement:!1}function iP(t){return!wx()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Es(t).ShadowRoot}const RY=new Set(["inline","contents"]);function om(t){const{overflow:e,overflowX:n,overflowY:r,display:s}=Eo(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!RY.has(s)}const DY=new Set(["table","td","th"]);function LY(t){return DY.has(pd(t))}const MY=[":popover-open",":modal"];function bx(t){return MY.some(e=>{try{return t.matches(e)}catch{return!1}})}const OY=["transform","translate","scale","rotate","perspective"],FY=["transform","translate","scale","rotate","perspective","filter"],zY=["paint","layout","strict","content"];function x1(t){const e=y1(),n=_o(t)?Eo(t):t;return OY.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||FY.some(r=>(n.willChange||"").includes(r))||zY.some(r=>(n.contain||"").includes(r))}function $Y(t){let e=Ka(t);for(;ri(e)&&!Gu(e);){if(x1(e))return e;if(bx(e))return null;e=Ka(e)}return null}function y1(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const VY=new Set(["html","body","#document"]);function Gu(t){return VY.has(pd(t))}function Eo(t){return Es(t).getComputedStyle(t)}function jx(t){return _o(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Ka(t){if(pd(t)==="html")return t;const e=t.assignedSlot||t.parentNode||iP(t)&&t.host||ii(t);return iP(e)?e.host:e}function JL(t){const e=Ka(t);return Gu(e)?t.ownerDocument?t.ownerDocument.body:t.body:ri(e)&&om(e)?e:JL(e)}function kf(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const s=JL(t),i=s===((r=t.ownerDocument)==null?void 0:r.body),a=Es(s);if(i){const l=bb(a);
4057return e.concat(a,a.visualViewport||[],om(s)?s:[],l&&n?kf(l):[])}return e.concat(s,kf(s,[],n))}function bb(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function eM(t){const e=Eo(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=ri(t),i=s?t.offsetWidth:n,a=s?t.offsetHeight:r,l=ov(n)!==i||ov(r)!==a;return l&&(n=i,r=a),{width:n,height:r,$:l}}function w1(t){return _o(t)?t:t.contextElement}function _u(t){const e=w1(t);if(!ri(e))return Jo(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:i}=eM(e);let a=(i?ov(n.width):n.width)/r,l=(i?ov(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const UY=Jo(0);function tM(t){const e=Es(t);return!y1()||!e.visualViewport?UY:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function BY(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Es(t)?!1:e}function oc(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),i=w1(t);let a=Jo(1);e&&(r?_o(r)&&(a=_u(r)):a=_u(t));const l=BY(i,n,r)?tM(i):Jo(0);let c=(s.left+l.x)/a.x,d=(s.top+l.y)/a.y,h=s.width/a.x,f=s.height/a.y;if(i){const p=Es(i),g=r&&_o(r)?Es(r):r;let v=p,x=bb(v);for(;x&&r&&g!==v;){const y=_u(x),b=x.getBoundingClientRect(),w=Eo(x),j=b.left+(x.clientLeft+parseFloat(w.paddingLeft))*y.x,E=b.top+(x.clientTop+parseFloat(w.paddingTop))*y.y;c*=y.x,d*=y.y,h*=y.x,f*=y.y,c+=j,d+=E,v=Es(x),x=bb(v)}}return av({width:h,height:f,x:c,y:d})}function Cx(t,e){const n=jx(t).scrollLeft;return e?e.left+n:oc(ii(t)).left+n}function nM(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-Cx(t,n),s=n.top+e.scrollTop;return{x:r,y:s}}function WY(t){let{elements:e,rect:n,offsetParent:r,strategy:s}=t;const i=s==="fixed",a=ii(r),l=e?bx(e.floating):!1;if(r===a||l&&i)return n;let c={scrollLeft:0,scrollTop:0},d=Jo(1);const h=Jo(0),f=ri(r);if((f||!f&&!i)&&((pd(r)!=="body"||om(a))&&(c=jx(r)),ri(r))){const g=oc(r);d=_u(r),h.x=g.x+r.clientLeft,h.y=g.y+r.clientTop}const p=a&&!f&&!i?nM(a,c):Jo(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+h.x+p.x,y:n.y*d.y-c.scrollTop*d.y+h.y+p.y}}function HY(t){return Array.from(t.getClientRects())}function qY(t){const e=ii(t),n=jx(t),r=t.ownerDocument.body,s=bs(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=bs(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Cx(t);const l=-n.scrollTop;return Eo(r).direction==="rtl"&&(a+=bs(e.clientWidth,r.clientWidth)-s),{width:s,height:i,x:a,y:l}}const aP=25;function GY(t,e){const n=Es(t),r=ii(t),s=n.visualViewport;let i=r.clientWidth,a=r.clientHeight,l=0,c=0;if(s){i=s.width,a=s.height;const h=y1();(!h||h&&e==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}const d=Cx(r);if(d<=0){const h=r.ownerDocument,f=h.body,p=getComputedStyle(f),g=h.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-g);v<=aP&&(i-=v)}else d<=aP&&(i+=d);return{width:i,height:a,x:l,y:c}}const ZY=new Set(["absolute","fixed"]);function KY(t,e){const n=oc(t,!0,e==="fixed"),r=n.top+t.clientTop,s=n.left+t.clientLeft,i=ri(t)?_u(t):Jo(1),a=t.clientWidth*i.x,l=t.clientHeight*i.y,c=s*i.x,d=r*i.y;return{width:a,height:l,x:c,y:d}}function lP(t,e,n){let r;if(e==="viewport")r=GY(t,n);else if(e==="document")r=qY(ii(t));else if(_o(e))r=KY(e,n);else{const s=tM(t);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return av(r)}function rM(t,e){const n=Ka(t);return n===e||!_o(n)||Gu(n)?!1:Eo(n).position==="fixed"||rM(n,e)}function YY(t,e){const n=e.get(t);if(n)return n;let r=kf(t,[],!1).filter(l=>_o(l)&&pd(l)!=="body"),s=null;const i=Eo(t).position==="fixed";let a=i?Ka(t):t;for(;_o(a)&&!Gu(a);){const l=Eo(a),c=x1(a);!c&&l.position==="fixed"&&(s=null),(i?!c&&!s:!c&&l.position==="static"&&!!s&&ZY.has(s.position)||om(a)&&!c&&rM(t,a))?r=r.filter(h=>h!==a):s=l,a=Ka(a)}return e.set(t,r),r}function QY(t){let{element:e,boundary:n,rootBoundary:r,strategy:s}=t;const a=[...n==="clippingAncestors"?bx(e)?[]:YY(e,this._c):[].concat(n),r],l=a[0],c=a.reduce((d,h)=>{const f=lP(e,h,s);return d.top=bs(f.top,d.top),d.right=Za(f.right,d.right),d.bottom=Za(f.bottom,d.bottom),d.left
4057=bs(f.left,d.left),d},lP(e,l,s));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function XY(t){const{width:e,height:n}=eM(t);return{width:e,height:n}}function JY(t,e,n){const r=ri(e),s=ii(e),i=n==="fixed",a=oc(t,!0,i,e);let l={scrollLeft:0,scrollTop:0};const c=Jo(0);function d(){c.x=Cx(s)}if(r||!r&&!i)if((pd(e)!=="body"||om(s))&&(l=jx(e)),r){const g=oc(e,!0,i,e);c.x=g.x+e.clientLeft,c.y=g.y+e.clientTop}else s&&d();i&&!r&&s&&d();const h=s&&!r&&!i?nM(s,l):Jo(0),f=a.left+l.scrollLeft-c.x-h.x,p=a.top+l.scrollTop-c.y-h.y;return{x:f,y:p,width:a.width,height:a.height}}function tw(t){return Eo(t).position==="static"}function cP(t,e){if(!ri(t)||Eo(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return ii(t)===n&&(n=n.ownerDocument.body),n}function sM(t,e){const n=Es(t);if(bx(t))return n;if(!ri(t)){let s=Ka(t);for(;s&&!Gu(s);){if(_o(s)&&!tw(s))return s;s=Ka(s)}return n}let r=cP(t,e);for(;r&&LY(r)&&tw(r);)r=cP(r,e);return r&&Gu(r)&&tw(r)&&!x1(r)?n:r||$Y(t)||n}const eQ=async function(t){const e=this.getOffsetParent||sM,n=this.getDimensions,r=await n(t.floating);return{reference:JY(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function tQ(t){return Eo(t).direction==="rtl"}const nQ={convertOffsetParentRelativeRectToViewportRelativeRect:WY,getDocumentElement:ii,getClippingRect:QY,getOffsetParent:sM,getElementRects:eQ,getClientRects:HY,getDimensions:XY,getScale:_u,isElement:_o,isRTL:tQ};function oM(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function rQ(t,e){let n=null,r;const s=ii(t);function i(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),i();const d=t.getBoundingClientRect(),{left:h,top:f,width:p,height:g}=d;if(l||e(),!p||!g)return;const v=gp(f),x=gp(s.clientWidth-(h+p)),y=gp(s.clientHeight-(f+g)),b=gp(h),j={rootMargin:-v+"px "+-x+"px "+-y+"px "+-b+"px",threshold:bs(0,Za(1,c))||1};let E=!0;function P(A){const N=A[0].intersectionRatio;if(N!==c){if(!E)return a();N?a(!1,N):r=setTimeout(()=>{a(!1,1e-7)},1e3)}N===1&&!oM(d,t.getBoundingClientRect())&&a(),E=!1}try{n=new IntersectionObserver(P,{...j,root:s.ownerDocument})}catch{n=new IntersectionObserver(P,j)}n.observe(t)}return a(!0),i}function sQ(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,d=w1(t),h=s||i?[...d?kf(d):[],...kf(e)]:[];h.forEach(b=>{s&&b.addEventListener("scroll",n,{passive:!0}),i&&b.addEventListener("resize",n)});const f=d&&l?rQ(d,n):null;let p=-1,g=null;a&&(g=new ResizeObserver(b=>{let[w]=b;w&&w.target===d&&g&&(g.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var j;(j=g)==null||j.observe(e)})),n()}),d&&!c&&g.observe(d),g.observe(e));let v,x=c?oc(t):null;c&&y();function y(){const b=oc(t);x&&!oM(x,b)&&n(),x=b,v=requestAnimationFrame(y)}return n(),()=>{var b;h.forEach(w=>{s&&w.removeEventListener("scroll",n),i&&w.removeEventListener("resize",n)}),f==null||f(),(b=g)==null||b.disconnect(),g=null,c&&cancelAnimationFrame(v)}}const oQ=PY,iQ=IY,aQ=EY,lQ=AY,cQ=SY,uP=_Y,uQ=TY,dQ=(t,e,n)=>{const r=new Map,s={platform:nQ,...n},i={...s.platform,_c:r};return NY(t,e,{...s,platform:i})};var hQ=typeof document<"u",fQ=function(){},Jp=hQ?u.useLayoutEffect:fQ;function lv(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,s;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!lv(t[r],e[r]))return!1;return!0}if(s=Object.keys(t),n=s.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,s[r]))return!1;for(r=n;r--!==0;){const i=s[r];if(!(i==="_owner"&&t.$$typeof)&&!lv(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function iM(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function dP(t,e){const n=iM(t);return Math.round(e*n)/n}function nw(t){const e=u.useRef(t);return Jp(()=>{e.current=t}),e}function mQ(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:i,floating:a}={},transform:l=!0,whileElementsMounted:c,open:d}=t,[h,f]=u.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[p,g]=u.useState(r);lv(p,r)||g(r);const[v,x]=u.useState(null),[y,b]=u.useState(null),w=u.useCallback(D=>{D!==A.current&&(A.current=D,x(D))},[]),j=u.useCallback(D=>{D!==N.current&&(N.current=D,b(D))},[]),E=i||v,P=a||y,A=u.useRef(null),N=u.useRef(null),_=u.useRef(h),k=c!=null,
4057L=nw(c),I=nw(s),S=nw(d),T=u.useCallback(()=>{if(!A.current||!N.current)return;const D={placement:e,strategy:n,middleware:p};I.current&&(D.platform=I.current),dQ(A.current,N.current,D).then(F=>{const O={...F,isPositioned:S.current!==!1};V.current&&!lv(_.current,O)&&(_.current=O,ps.flushSync(()=>{f(O)}))})},[p,e,n,I,S]);Jp(()=>{d===!1&&_.current.isPositioned&&(_.current.isPositioned=!1,f(D=>({...D,isPositioned:!1})))},[d]);const V=u.useRef(!1);Jp(()=>(V.current=!0,()=>{V.current=!1}),[]),Jp(()=>{if(E&&(A.current=E),P&&(N.current=P),E&&P){if(L.current)return L.current(E,P,T);T()}},[E,P,T,L,k]);const $=u.useMemo(()=>({reference:A,floating:N,setReference:w,setFloating:j}),[w,j]),H=u.useMemo(()=>({reference:E,floating:P}),[E,P]),W=u.useMemo(()=>{const D={position:n,left:0,top:0};if(!H.floating)return D;const F=dP(H.floating,h.x),O=dP(H.floating,h.y);return l?{...D,transform:"translate("+F+"px, "+O+"px)",...iM(H.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:F,top:O}},[n,l,H.floating,h.x,h.y]);return u.useMemo(()=>({...h,update:T,refs:$,elements:H,floatingStyles:W}),[h,T,$,H,W])}const pQ=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:s}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?uP({element:r.current,padding:s}).fn(n):{}:r?uP({element:r,padding:s}).fn(n):{}}}},gQ=(t,e)=>({...oQ(t),options:[t,e]}),vQ=(t,e)=>({...iQ(t),options:[t,e]}),xQ=(t,e)=>({...uQ(t),options:[t,e]}),yQ=(t,e)=>({...aQ(t),options:[t,e]}),wQ=(t,e)=>({...lQ(t),options:[t,e]}),bQ=(t,e)=>({...cQ(t),options:[t,e]}),jQ=(t,e)=>({...pQ(t),options:[t,e]});var CQ="Arrow",aM=u.forwardRef((t,e)=>{const{children:n,width:r=10,height:s=5,...i}=t;return o.jsx(Je.svg,{...i,ref:e,width:r,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:o.jsx("polygon",{points:"0,0 30,0 15,10"})})});aM.displayName=CQ;var NQ=aM;function lM(t){const[e,n]=u.useState(void 0);return Ur(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const i=s[0];let a,l;if("borderBoxSize"in i){const c=i.borderBoxSize,d=Array.isArray(c)?c[0]:c;a=d.inlineSize,l=d.blockSize}else a=t.offsetWidth,l=t.offsetHeight;n({width:a,height:l})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var b1="Popper",[cM,gd]=Rs(b1),[_Q,uM]=cM(b1),dM=t=>{const{__scopePopper:e,children:n}=t,[r,s]=u.useState(null);return o.jsx(_Q,{scope:e,anchor:r,onAnchorChange:s,children:n})};dM.displayName=b1;var hM="PopperAnchor",fM=u.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...s}=t,i=uM(hM,n),a=u.useRef(null),l=At(e,a),c=u.useRef(null);return u.useEffect(()=>{const d=c.current;c.current=(r==null?void 0:r.current)||a.current,d!==c.current&&i.onAnchorChange(c.current)}),r?null:o.jsx(Je.div,{...s,ref:l})});fM.displayName=hM;var j1="PopperContent",[EQ,SQ]=cM(j1),mM=u.forwardRef((t,e)=>{var K,ue,be,le,B,Q;const{__scopePopper:n,side:r="bottom",sideOffset:s=0,align:i="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:h=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:g="optimized",onPlaced:v,...x}=t,y=uM(j1,n),[b,w]=u.useState(null),j=At(e,ve=>w(ve)),[E,P]=u.useState(null),A=lM(E),N=(A==null?void 0:A.width)??0,_=(A==null?void 0:A.height)??0,k=r+(i!=="center"?"-"+i:""),L=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},I=Array.isArray(d)?d:[d],S=I.length>0,T={padding:L,boundary:I.filter(PQ),altBoundary:S},{refs:V,floatingStyles:$,placement:H,isPositioned:W,middlewareData:D}=mQ({strategy:"fixed",placement:k,whileElementsMounted:(...ve)=>sQ(...ve,{animationFrame:g==="always"}),elements:{reference:y.anchor},middleware:[gQ({mainAxis:s+_,alignmentAxis:a}),c&&vQ({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?xQ():void 0,...T}),c&&yQ({...T}),wQ({...T,apply:({elements:ve,rects:Ae,availableWidth:he,availableHeight:J})=>{const{width:je,height:Ve}=Ae.reference,Ye=ve.floating.style;Ye.setProperty("--radix-popper-available-width",`${he}px`),Ye.setProperty("--radix-popper-available-height",`${J}px`),Ye.setProperty("--radix-popper-anchor-width",`${je}px`),Ye.setProperty("--radix-popper-anchor-height",`${Ve}px`)}}),E&&jQ({element:E,padding:l}),IQ({arrowWidth:N,arrowHeight:_}),p&&bQ({strategy:"referenceHidden",...T})]}),[F,O]=vM(H),Y=ni(v);Ur(()=>{W&&(Y==null||Y())},[W,Y]);const G=(K=D.arrow)==null?void 0:K.x,q=(ue=D.arrow)==null?void 0:ue.y,re=((be=D.arrow)==null?void 0:be.centerOffset)!==0,[U,ee]=u.useState();return Ur(()=>{b&&ee(window.getComputedStyle(b).zIndex)},[b]),o.jsx("div",{ref:V.setFloating,"data-radix-popper-content-wrapper":"",style:{...$,transform:W?$.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:U,"--radix-popper-transform-origin":[(le=D.transformOrigin)==null?void 0:le.x,(B=D.transformOrigin)==null?void 0:B.y].join(" "),...((Q=D.hide)==null?void 0:Q.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:o.jsx(EQ,{scope:n,placedSide:F,onArrowChange:P,arrowX:G,arrowY:q,shouldHideArrow:re,children:o.jsx(Je.div,{"data-side":F,"data-align":O,...x,ref:j,style:{...x.style,animation:W?void 0:"none"}})})})});mM.displayName=j1;var pM="PopperArrow",kQ={top:"bottom",right:"left",bottom:"top",left:"r
4057ight"},gM=u.forwardRef(function(e,n){const{__scopePopper:r,...s}=e,i=SQ(pM,r),a=kQ[i.placedSide];return o.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[a]: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:o.jsx(NQ,{...s,ref:n,style:{...s.style,display:"block"}})})});gM.displayName=pM;function PQ(t){return t!==null}var IQ=t=>({name:"transformOrigin",options:t,fn(e){var y,b,w;const{placement:n,rects:r,middlewareData:s}=e,a=((y=s.arrow)==null?void 0:y.centerOffset)!==0,l=a?0:t.arrowWidth,c=a?0:t.arrowHeight,[d,h]=vM(n),f={start:"0%",center:"50%",end:"100%"}[h],p=(((b=s.arrow)==null?void 0:b.x)??0)+l/2,g=(((w=s.arrow)==null?void 0:w.y)??0)+c/2;let v="",x="";return d==="bottom"?(v=a?f:`${p}px`,x=`${-c}px`):d==="top"?(v=a?f:`${p}px`,x=`${r.floating.height+c}px`):d==="right"?(v=`${-c}px`,x=a?f:`${g}px`):d==="left"&&(v=`${r.floating.width+c}px`,x=a?f:`${g}px`),{data:{x:v,y:x}}}});function vM(t){const[e,n="center"]=t.split("-");return[e,n]}var C1=dM,Nx=fM,N1=mM,_1=gM;function xM(t){const e=u.useRef({value:t,previous:t});return u.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var yM=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"}),TQ="VisuallyHidden",AQ=u.forwardRef((t,e)=>o.jsx(Je.span,{...t,ref:e,style:{...yM,...t.style}}));AQ.displayName=TQ;var RQ=[" ","Enter","ArrowUp","ArrowDown"],DQ=[" ","Enter"],ic="Select",[_x,Ex,LQ]=m1(ic),[vd]=Rs(ic,[LQ,gd]),Sx=gd(),[MQ,ol]=vd(ic),[OQ,FQ]=vd(ic),wM=t=>{const{__scopeSelect:e,children:n,open:r,defaultOpen:s,onOpenChange:i,value:a,defaultValue:l,onValueChange:c,dir:d,name:h,autoComplete:f,disabled:p,required:g,form:v}=t,x=Sx(e),[y,b]=u.useState(null),[w,j]=u.useState(null),[E,P]=u.useState(!1),A=sm(d),[N,_]=Co({prop:r,defaultProp:s??!1,onChange:i,caller:ic}),[k,L]=Co({prop:a,defaultProp:l,onChange:c,caller:ic}),I=u.useRef(null),S=y?v||!!y.closest("form"):!0,[T,V]=u.useState(new Set),$=Array.from(T).map(H=>H.props.value).join(";");return o.jsx(C1,{...x,children:o.jsxs(MQ,{required:g,scope:e,trigger:y,onTriggerChange:b,valueNode:w,onValueNodeChange:j,valueNodeHasChildren:E,onValueNodeHasChildrenChange:P,contentId:yo(),value:k,onValueChange:L,open:N,onOpenChange:_,dir:A,triggerPointerDownPosRef:I,disabled:p,children:[o.jsx(_x.Provider,{scope:e,children:o.jsx(OQ,{scope:t.__scopeSelect,onNativeOptionAdd:u.useCallback(H=>{V(W=>new Set(W).add(H))},[]),onNativeOptionRemove:u.useCallback(H=>{V(W=>{const D=new Set(W);return D.delete(H),D})},[]),children:n})}),S?o.jsxs(UM,{"aria-hidden":!0,required:g,tabIndex:-1,name:h,autoComplete:f,value:k,onChange:H=>L(H.target.value),disabled:p,form:v,children:[k===void 0?o.jsx("option",{value:""}):null,Array.from(T)]},$):null]})})};wM.displayName=ic;var bM="SelectTrigger",jM=u.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:r=!1,...s}=t,i=Sx(n),a=ol(bM,n),l=a.disabled||r,c=At(e,a.onTriggerChange),d=Ex(n),h=u.useRef("touch"),[f,p,g]=WM(x=>{const y=d().filter(j=>!j.disabled),b=y.find(j=>j.value===a.value),w=HM(y,x,b);w!==void 0&&a.onValueChange(w.value)}),v=x=>{l||(a.onOpenChange(!0),g()),x&&(a.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return o.jsx(Nx,{asChild:!0,...i,children:o.jsx(Je.button,{type:"button",role:"combobox","aria-controls":a.contentId,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":BM(a.value)?"":void 0,...s,ref:c,onClick:Le(s.onClick,x=>{x.currentTarget.focus(),h.current!=="mouse"&&v(x)}),onPointerDown:Le(s.onPointerDown,x=>{h.current=x.pointerType;const y=x.target;y.hasPointerCapture(x.pointerId)&&y.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(v(x),x.preventDefault())}),onKeyDown:Le(s.onKeyDown,x=>{const y=f.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&p(x.key),!(y&&x.key===" ")&&RQ.includes(x.key)&&(v(),x.preventDefault())})})})});jM.displayName=bM;var CM="SelectValue",NM=u.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:s,children:i,placeholder:a="",...l}=t,c=ol(CM,n),{onValueNodeHasChildrenChange:d}=c,h=i!==void 0,f=At(e,c.onValueNodeChange);return Ur(()=>{d(h)},[d,h]),o.jsx(Je.span,{...l,ref:f,style:{pointerEvents:"none"},children:BM(c.value)?o.jsx(o.Fragment,{children:a}):i})});NM.displayName=CM;var zQ="SelectIcon",_M=u.forwardRef((t,e)=>{const{__scopeSelect:n,children:r,...s}=t;return o.jsx(Je.span,{"aria-hidden":!0,...s,ref:e,children:r||"â¼"})});_M.displayName=zQ;var $Q="SelectPortal",EM=t=>o.jsx(em,{asChild:!0,...t});EM.displayName=$Q;var ac="SelectContent",SM=u.forwardRef((t,e)=>{const n=ol(ac,t.__scopeSelect),[r,s]=u.useState();if(Ur(()=>{s(new DocumentFragment)},[]),!n.open){const i=r;return i?ps.createPortal(o.jsx(kM,{scope:t.__scopeSelect,children:o.jsx(_x.Slot,{scope:t.__scopeSelect,children:o.jsx("div",{children:t.children})})}),i):null}return o.jsx(PM,{...t,ref:e})});SM.displayName=ac;var io=10,[kM,il]=vd(ac),VQ="SelectContentImpl",UQ=Ga("SelectContent.RemoveScroll"),PM=u.forwardRef((t,e)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:i,onPointerDownOutside:a,side:l,sideOffset:c,align:d,alignOffset:h,arrowPadding:f,collisionBoundary:p,collisionPadding:g,sticky:v,hideWhenDetached:x,avoidCollisions:y,...b}=t,w=ol(ac,n),[j,E]=u.useState(null),[P,A]=u.useState(null),N=At(e,K=>E(K)),[_,k]=u.useState(null),[L,I]=u.useState(null),S=Ex(n),[T,V]=u.useState(!1),$=u.useRef(!1);u.useEffect(()=>{if(j)return nm(j)},[j]),mx();const H=u.useCallback(K=>{const[ue,...be]=S().map(Q=>Q.ref.current),[le]=be.slice(-1),B=document.activeElement;for(const Q of K)if(Q===B||(Q==null||Q.scrollIntoView({block:"nearest"}),Q===ue&&P&&(P.scrollTop=0),Q===le&&P&&(P.scrollTop=P.scrollHeight),Q==null||Q.focus(),document.activeElement!==B))return},[S,P]),W=u.useCallback(()=>H([_,j]),[H,_,j]);u.useEffect(()=>{T&&W()},[T,W]);const{onOpenChange:D,triggerPointerDownPosRef:F}=w;u.useEffect(()=>{if(j){let K={x:0,y:0};const ue=le=>{var B,Q;K={x:Math.abs(Math.round(le.pageX)-(((B=F.current)==null?void 0:B.x)??0)),y:Math.abs(Math.round(le.pageY)-(((Q=F.current)==null?void 0:Q.y)??0))}},be=le=>{K.x<=10&&K.y<=10?le.preventDefault():j.contains(le.target)||D(!1),document.removeEventListener("pointermove",ue),F.current=null};return F.current!==null&&(document.addEventListener("pointermove",ue),document.addEventListener("pointerup",be,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ue),document.removeEventListener("pointerup",be,{capture:!0})}}},[j,D,F]),u.useEffect(()=>{const K=()=>D(!1);return window.addEventListener("blur",K),window.addEventListener("resize",K),()=>{window.removeEventListener("blur",K),window.removeEventListener("resize",K)}},[D]);const[O,Y]=WM(K=>
4057{const ue=S().filter(B=>!B.disabled),be=ue.find(B=>B.ref.current===document.activeElement),le=HM(ue,K,be);le&&setTimeout(()=>le.ref.current.focus())}),G=u.useCallback((K,ue,be)=>{const le=!$.current&&!be;(w.value!==void 0&&w.value===ue||le)&&(k(K),le&&($.current=!0))},[w.value]),q=u.useCallback(()=>j==null?void 0:j.focus(),[j]),re=u.useCallback((K,ue,be)=>{const le=!$.current&&!be;(w.value!==void 0&&w.value===ue||le)&&I(K)},[w.value]),U=r==="popper"?jb:IM,ee=U===jb?{side:l,sideOffset:c,align:d,alignOffset:h,arrowPadding:f,collisionBoundary:p,collisionPadding:g,sticky:v,hideWhenDetached:x,avoidCollisions:y}:{};return o.jsx(kM,{scope:n,content:j,viewport:P,onViewportChange:A,itemRefCallback:G,selectedItem:_,onItemLeave:q,itemTextRefCallback:re,focusSelectedItem:W,selectedItemText:L,position:r,isPositioned:T,searchRef:O,children:o.jsx(tm,{as:UQ,allowPinchZoom:!0,children:o.jsx(Jf,{asChild:!0,trapped:w.open,onMountAutoFocus:K=>{K.preventDefault()},onUnmountAutoFocus:Le(s,K=>{var ue;(ue=w.trigger)==null||ue.focus({preventScroll:!0}),K.preventDefault()}),children:o.jsx(Xf,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:K=>K.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:o.jsx(U,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:K=>K.preventDefault(),...b,...ee,onPlaced:()=>V(!0),ref:N,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:Le(b.onKeyDown,K=>{const ue=K.ctrlKey||K.altKey||K.metaKey;if(K.key==="Tab"&&K.preventDefault(),!ue&&K.key.length===1&&Y(K.key),["ArrowUp","ArrowDown","Home","End"].includes(K.key)){let le=S().filter(B=>!B.disabled).map(B=>B.ref.current);if(["ArrowUp","End"].includes(K.key)&&(le=le.slice().reverse()),["ArrowUp","ArrowDown"].includes(K.key)){const B=K.target,Q=le.indexOf(B);le=le.slice(Q+1)}setTimeout(()=>H(le)),K.preventDefault()}})})})})})})});PM.displayName=VQ;var BQ="SelectItemAlignedPosition",IM=u.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:r,...s}=t,i=ol(ac,n),a=il(ac,n),[l,c]=u.useState(null),[d,h]=u.useState(null),f=At(e,N=>h(N)),p=Ex(n),g=u.useRef(!1),v=u.useRef(!0),{viewport:x,selectedItem:y,selectedItemText:b,focusSelectedItem:w}=a,j=u.useCallback(()=>{if(i.trigger&&i.valueNode&&l&&d&&x&&y&&b){const N=i.trigger.getBoundingClientRect(),_=d.getBoundingClientRect(),k=i.valueNode.getBoundingClientRect(),L=b.getBoundingClientRect();if(i.dir!=="rtl"){const B=L.left-_.left,Q=k.left-B,ve=N.left-Q,Ae=N.width+ve,he=Math.max(Ae,_.width),J=window.innerWidth-io,je=eP(Q,[io,Math.max(io,J-he)]);l.style.minWidth=Ae+"px",l.style.left=je+"px"}else{const B=_.right-L.right,Q=window.innerWidth-k.right-B,ve=window.innerWidth-N.right-Q,Ae=N.width+ve,he=Math.max(Ae,_.width),J=window.innerWidth-io,je=eP(Q,[io,Math.max(io,J-he)]);l.style.minWidth=Ae+"px",l.style.right=je+"px"}const I=p(),S=window.innerHeight-io*2,T=x.scrollHeight,V=window.getComputedStyle(d),$=parseInt(V.borderTopWidth,10),H=parseInt(V.paddingTop,10),W=parseInt(V.borderBottomWidth,10),D=parseInt(V.paddingBottom,10),F=$+H+T+D+W,O=Math.min(y.offsetHeight*5,F),Y=window.getComputedStyle(x),G=parseInt(Y.paddingTop,10),q=parseInt(Y.paddingBottom,10),re=N.top+N.height/2-io,U=S-re,ee=y.offsetHeight/2,K=y.offsetTop+ee,ue=$+H+K,be=F-ue;if(ue<=re){const B=I.length>0&&y===I[I.length-1].ref.current;l.style.bottom="0px";const Q=d.clientHeight-x.offsetTop-x.offsetHeight,ve=Math.max(U,ee+(B?q:0)+Q+W),Ae=ue+ve;l.style.height=Ae+"px"}else{const B=I.length>0&&y===I[0].ref.current;l.style.top="0px";const ve=Math.max(re,$+x.offsetTop+(B?G:0)+ee)+be;l.style.height=ve+"px",x.scrollTop=ue-re+x.offsetTop}l.style.margin=`${io}px 0`,l.style.minHeight=O+"px",l.style.maxHeight=S+"px",r==null||r(),requestAnimationFrame(()=>g.current=!0)}},[p,i.trigger,i.valueNode,l,d,x,y,b,i.dir,r]);Ur(()=>j(),[j]);const[E,P]=u.useState();Ur(()=>{d&&P(window.getComputedStyle(d).zIndex)},[d]);const A=u.useCallback(N=>{N&&v.current===!0&&(j(),w==null||w(),v.current=!1)},[j,w]);return o.jsx(HQ,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:g,onScrollButtonChange:A,children:o.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:o.jsx(Je.div,{...s,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})});IM.displayName=BQ;var WQ="SelectPopperPosition",jb=u.forwardRef((t,e)=>{const{__scopeSelect:n,align:r="start",collisionPadding:s=io,...i}=t,a=Sx(n);return o.jsx(N1,{...a,...i,ref:e,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)"}})});jb.displayName=WQ;var[HQ,E1]=vd(ac,{}),Cb="SelectViewport",TM=u.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:r,...s}=t,i=il(Cb,n),a=E1(Cb,n),l=At(e,i.onViewportChange),c=u.useRef(0);return o.jsxs(o.Fragment,{children:[o.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}),o.jsx(_x.Slot,{scope:n,children:o.jsx(Je.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:Le(s.onScroll,d=>{const h=d.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:p}=a;if(p!=null&&p.current&&f){const g=Math.abs(c.current-h.scrollTop);if(g>0){const v=window.innerHeight-io*2,x=parseFloat(f.style.minHeight),y=parseFloat(f.style.height),b=Math.max(x,y);if(b<v){const w=b+g,j=Math.min(v,w),E=w-j;f.style.height=j+"px",f.style.bottom==="0px"&&(h.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}c.current=h.scrollTop})})})]})});TM.displayName=Cb;var AM="SelectGroup",[qQ,GQ]=vd(AM),ZQ=u.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,s=yo();return o.jsx(qQ,{scope:n,id:s,children:o.jsx(Je.div,{role:"group","aria-labelledby":s,...r,ref:e})})});ZQ.displayName=AM;var RM="SelectLabel",KQ=u.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,s=GQ(RM,n);return o.jsx(Je.div,{id:s.id,...r,ref:e})});KQ.displayName=RM;var cv="SelectItem",[YQ,DM]=vd(cv),LM=u.forwardRef((t,e)=>{const{__scopeSelect:n,value:r,disabled:s=!1,textValue:i,...a}=t,l=ol(cv,n),c=il(cv,n),d=l.value===r,[h,f]=u.useState(i??""),[p,g]=u.useState(!1),v=At(e,w=>{var j;return(j=c.itemRefCallback)==null?void 0:j.call(c,w,r,s)}),x=yo(),y=u.useRef("touch"),b=()=>{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 o.jsx(YQ,{scope:n,value:r,disabled:s,textId:x,isSelected:d,onItemTextChange:u.useCallback(w=>{f(j=>j||((w==null?void 0:w.textContent)??"").trim())},[]),children:o.jsx(_x.ItemSlot,{scope:n,value:r,disabled:s,textValue:h,children:o.jsx(Je.div,{role:"option","aria-labelledby":x,"data-highlighted":p?"":void 0,"aria-selected":d&&p,"data-state":d?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...a,ref:v,onFocus:Le(a.onFocus,()=>g(!0)),onBlur:Le(a.onBlur,()=>g(!1)),onClick:Le(a.onClick,()=>{y.current!=="mouse"&&b()}),onPointerUp:Le(a.onPointerUp,()=>{y.current==="mouse"&&b()}),onPointerDown:Le(a.onPointerDown,w=>{y.current=w.pointerType}),onPointerMove:Le(a.onPointerMove,w=>{var j;y.current=w.pointerType,s?(j=c.onItemLeave)==null||j.call(c):y.current==="mouse"&&w.currentTarget.focu
4057s({preventScroll:!0})}),onPointerLeave:Le(a.onPointerLeave,w=>{var j;w.currentTarget===document.activeElement&&((j=c.onItemLeave)==null||j.call(c))}),onKeyDown:Le(a.onKeyDown,w=>{var E;((E=c.searchRef)==null?void 0:E.current)!==""&&w.key===" "||(DQ.includes(w.key)&&b(),w.key===" "&&w.preventDefault())})})})})});LM.displayName=cv;var xh="SelectItemText",MM=u.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:s,...i}=t,a=ol(xh,n),l=il(xh,n),c=DM(xh,n),d=FQ(xh,n),[h,f]=u.useState(null),p=At(e,b=>f(b),c.onItemTextChange,b=>{var w;return(w=l.itemTextRefCallback)==null?void 0:w.call(l,b,c.value,c.disabled)}),g=h==null?void 0:h.textContent,v=u.useMemo(()=>o.jsx("option",{value:c.value,disabled:c.disabled,children:g},c.value),[c.disabled,c.value,g]),{onNativeOptionAdd:x,onNativeOptionRemove:y}=d;return Ur(()=>(x(v),()=>y(v)),[x,y,v]),o.jsxs(o.Fragment,{children:[o.jsx(Je.span,{id:c.textId,...i,ref:p}),c.isSelected&&a.valueNode&&!a.valueNodeHasChildren?ps.createPortal(i.children,a.valueNode):null]})});MM.displayName=xh;var OM="SelectItemIndicator",FM=u.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return DM(OM,n).isSelected?o.jsx(Je.span,{"aria-hidden":!0,...r,ref:e}):null});FM.displayName=OM;var Nb="SelectScrollUpButton",zM=u.forwardRef((t,e)=>{const n=il(Nb,t.__scopeSelect),r=E1(Nb,t.__scopeSelect),[s,i]=u.useState(!1),a=At(e,r.onScrollButtonChange);return Ur(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=c.scrollTop>0;i(d)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),s?o.jsx(VM,{...t,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});zM.displayName=Nb;var _b="SelectScrollDownButton",$M=u.forwardRef((t,e)=>{const n=il(_b,t.__scopeSelect),r=E1(_b,t.__scopeSelect),[s,i]=u.useState(!1),a=At(e,r.onScrollButtonChange);return Ur(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=c.scrollHeight-c.clientHeight,h=Math.ceil(c.scrollTop)<d;i(h)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),s?o.jsx(VM,{...t,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});$M.displayName=_b;var VM=u.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:r,...s}=t,i=il("SelectScrollButton",n),a=u.useRef(null),l=Ex(n),c=u.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return u.useEffect(()=>()=>c(),[c]),Ur(()=>{var h;const d=l().find(f=>f.ref.current===document.activeElement);(h=d==null?void 0:d.ref.current)==null||h.scrollIntoView({block:"nearest"})},[l]),o.jsx(Je.div,{"aria-hidden":!0,...s,ref:e,style:{flexShrink:0,...s.style},onPointerDown:Le(s.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(r,50))}),onPointerMove:Le(s.onPointerMove,()=>{var d;(d=i.onItemLeave)==null||d.call(i),a.current===null&&(a.current=window.setInterval(r,50))}),onPointerLeave:Le(s.onPointerLeave,()=>{c()})})}),QQ="SelectSeparator",XQ=u.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return o.jsx(Je.div,{"aria-hidden":!0,...r,ref:e})});XQ.displayName=QQ;var Eb="SelectArrow",JQ=u.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,s=Sx(n),i=ol(Eb,n),a=il(Eb,n);return i.open&&a.position==="popper"?o.jsx(_1,{...s,...r,ref:e}):null});JQ.displayName=Eb;var eX="SelectBubbleInput",UM=u.forwardRef(({__scopeSelect:t,value:e,...n},r)=>{const s=u.useRef(null),i=At(r,s),a=xM(e);return u.useEffect(()=>{const l=s.current;if(!l)return;const c=window.HTMLSelectElement.prototype,h=Object.getOwnPropertyDescriptor(c,"value").set;if(a!==e&&h){const f=new Event("change",{bubbles:!0});h.call(l,e),l.dispatchEvent(f)}},[a,e]),o.jsx(Je.select,{...n,style:{...yM,...n.style},ref:i,defaultValue:e})});UM.displayName=eX;function BM(t){return t===""||t===void 0}function WM(t){const e=ni(t),n=u.useRef(""),r=u.useRef(0),s=u.useCallback(a=>{const l=n.current+a;e(l),function c(d){n.current=d,window.clearTimeout(r.current),d!==""&&(r.current=window.setTimeout(()=>c(""),1e3))}(l)},[e]),i=u.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return u.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,s,i]}function HM(t,e,n){const s=e.length>1&&Array.from(e).every(d=>d===e[0])?e[0]:e,i=n?t.indexOf(n):-1;let a=tX(t,Math.max(i,0));s.length===1&&(a=a.filter(d=>d!==n));const c=a.find(d=>d.textValue.toLowerCase().startsWith(s.toLowerCase()));return c!==n?c:void 0}function tX(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var nX=wM,rX=jM,sX=NM,oX=_M,iX=EM,aX=SM,lX=TM,cX=LM,uX=MM,dX=FM,hX=zM,fX=$M;function _t({...t}){return o.jsx(nX,{"data-slot":"select",...t})}function Et({...t}){return o.jsx(sX,{"data-slot":"select-value",...t})}function St({className:t,size:e="default",children:n,...r}){return o.jsxs(rX,{"data-slot":"select-trigger","data-size":e,className:Oe("border-border bg-card text-foreground data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 aria-invalid:border-destructive flex w-full items-center justify-between gap-2 rounded-md border px-3 py-2 text-sm whitespace-nowrap transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 hover:bg-muted data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...r,children:[n,o.jsx(oX,{asChild:!0,children:o.jsx(jf,{className:"size-4 opacity-50"})})]})}function kt({className:t,children:e,position:n="popper",...r}){return o.jsx(iX,{children:o.jsxs(aX,{"data-slot":"select-content",className:Oe("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:sli
4057de-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-[var(--radix-select-content-available-height)] min-w-[8rem] origin-[var(--radix-select-content-transform-origin)] overflow-x-hidden overflow-y-auto rounded-md border shadow-md",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",t),position:n,...r,children:[o.jsx(mX,{}),o.jsx(lX,{className:Oe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:e}),o.jsx(pX,{})]})})}function Ke({className:t,children:e,...n}){return o.jsxs(cX,{"data-slot":"select-item",className:Oe("focus:bg-muted focus:text-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...n,children:[o.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:o.jsx(dX,{children:o.jsx(Xn,{className:"size-4"})})}),o.jsx(uX,{children:e})]})}function mX({className:t,...e}){return o.jsx(hX,{"data-slot":"select-scroll-up-button",className:Oe("flex cursor-default items-center justify-center py-1",t),...e,children:o.jsx(OK,{className:"size-4"})})}function pX({className:t,...e}){return o.jsx(fX,{"data-slot":"select-scroll-down-button",className:Oe("flex cursor-default items-center justify-center py-1",t),...e,children:o.jsx(jf,{className:"size-4"})})}function gX(){const[t,e]=u.useState(""),[n,r]=u.useState(""),[s,i]=u.useState(""),[a,l]=u.useState(""),[c,d]=u.useState(""),[h,f]=u.useState(""),[p,g]=u.useState(!1),[v,x]=u.useState([]);u.useEffect(()=>{As().then(x)},[]);const y=async w=>{if(w.preventDefault(),f(""),!t||!n||!a||!c){f("Veuillez remplir tous les champs obligatoires");return}if(n!==s){f("Les mots de passe ne correspondent pas");return}if(n.length<6){f("Le mot de passe doit contenir au moins 6 caractères");return}const j=v.find(E=>E.code===c);if(!j){f("Département invalide");return}g(!0);try{await f1.signup({email:t.toLowerCase().trim(),password:n,pseudo:a.trim(),departmentCode:parseInt(c),departmentLabel:j.nom})}catch(E){console.error("Signup error:",E),f(E.message||"Erreur lors de l'inscription")}finally{g(!1)}},b="bg-white/[0.06] border-white/10 text-white placeholder:text-white/25 focus:border-app-green-light/50 focus:ring-app-green-light/20 h-11";return o.jsxs("div",{className:"min-h-screen flex flex-col login-gradient relative overflow-hidden",children:[o.jsx("div",{className:"absolute inset-0 opacity-[0.03]",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E")`}}),o.jsx("div",{className:"flex-1 flex items-center justify-center p-4 relative z-10",children:o.jsxs("div",{className:"w-full max-w-md animate-fade-in",children:[o.jsxs("div",{className:"text-center mb-8",children:[o.jsx("div",{className:"inline-flex items-center justify-center mb-5",children:o.jsx("img",{src:"/logo.png",alt:"Chassé & Croisé",className:"h-14 w-14 rounded-2xl shadow-lg ring-1 ring-white/20"})}),o.jsx("h1",{className:"text-3xl font-bold text-white font-heading tracking-tight",children:"Créer un compte"}),o.jsx("p",{className:"text-white/50 mt-2 text-sm",children:"Inscrivez-vous pour accéder à Chassé & Croisé"})]}),o.jsx("div",{className:"bg-white/[0.07] backdrop-blur-xl rounded-2xl border border-white/10 shadow-2xl p-8",children:o.jsxs("form",{onSubmit:y,className:"space-y-4",children:[h&&o.jsx("div",{className:"bg-red-500/15 border border-red-400/20 rounded-lg px-4 py-3 text-sm text-red-200",children:h}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"pseudo",className:"text-white/70 text-sm font-medium",children:"Nom *"}),o.jsx(Ne,{id:"pseudo",type:"text",value:a,onChange:w=>l(w.target.value),required:!0,disabled:p,placeholder:"Votre nom",className:b})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"email",className:"text-white/70 text-sm font-medium",children:"Email *"}),o.jsx(Ne,{id:"email",type:"email",value:t,onChange:w=>e(w.target.value),required:!0,disabled:p,placeholder:"[email protected]",className:b})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"department",className:"text-white/70 text-sm font-medium",children:"Département *"}),o.jsxs(_t,{value:c,onValueChange:d,disabled:p,children:[o.jsx(St,{className:"bg-white/[0.06] border-white/10 text-white h-11 [&>span]:text-white/60",children:o.jsx(Et,{placeholder:"Sélectionnez un département"})}),o.jsx(kt,{className:"max-h-[300px]",children:v.map(w=>o.jsxs(Ke,{value:w.code,children:[w.code," - ",w.nom]},w.code))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"password",className:"text-white/70 text-sm font-medium",children:"Mot de passe *"}),o.jsx(Ne,{id:"password",type:"password",value:n,onChange:w=>r(w.target.value),required:!0,disabled:p,placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",className:b})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"confirmPassword",className:"text-white/70 text-sm font-medium",children:"Confirmer le mot de passe *"}),o.jsx(Ne,{id:"confirmPassword",type:"password",value:s,onChange:w=>i(w.target.value),required:!0,disabled:p,placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",className:b})]}),o.jsx(Z,{type:"submit",className:"w-full h-11 bg-white text-app-bg font-semibold hover:bg-white/90 transition-all",disabled:p,children:p?o.jsxs(o.Fragment,{children:[o.jsx(hs,{className:"mr-2 h-4 w-4 animate-spin"}),"Inscription..."]}):"Créer mon compte"}),o.jsxs("div",{className:"text-center text-sm pt-2",children:[o.jsx("span",{className:"text-white/40",children:"Déjà inscrit ? "}
4057),o.jsx(Fa,{to:xe.login,className:"text-app-green-light/80 hover:text-app-green-light font-medium transition-colors",children:"Se connecter"})]})]})})]})}),o.jsxs("div",{className:"relative z-10",children:[o.jsx("div",{className:"flex justify-center",children:o.jsx("img",{src:"/arbres.svg",alt:"Arbres",className:"h-28 w-auto object-contain opacity-20"})}),o.jsx("div",{className:"h-1 bg-app-green-medium/40"})]})]})}function vX({...t}){return o.jsx(o1,{"data-slot":"sheet",...t})}function xX({...t}){return o.jsx(i1,{"data-slot":"sheet-portal",...t})}function yX({className:t,...e}){return o.jsx(a1,{"data-slot":"sheet-overlay",className:Oe("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...e})}function wX({className:t,children:e,side:n="right",...r}){return o.jsxs(xX,{children:[o.jsx(yX,{}),o.jsxs(l1,{"data-slot":"sheet-content",className:Oe("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500",n==="right"&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",n==="left"&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",n==="top"&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",n==="bottom"&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",t),...r,children:[e,o.jsxs(vx,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none",children:[o.jsx(br,{className:"size-4"}),o.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function bX({className:t,...e}){return o.jsx(c1,{"data-slot":"sheet-title",className:Oe("text-foreground font-semibold",t),...e})}function Kn(...t){return oL(JC(t))}function bn(t){var n;return[t.firstName,t.lastName].map(r=>r==null?void 0:r.trim()).filter(Boolean).join(" ")||((n=t.pseudo)==null?void 0:n.trim())||t.email||""}function kx(t){var r;const e=(r=t.pseudo)==null?void 0:r.trim();return[!!e&&e!==bn(t)?e:null,t.email].filter(Boolean).join(" · ")}const jX=fx("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function We({className:t,variant:e,asChild:n=!1,...r}){const s=n?QD:"span";return o.jsx(s,{"data-slot":"badge",className:Oe(jX({variant:e}),t),...r})}var CX="Separator",hP="horizontal",NX=["horizontal","vertical"],qM=u.forwardRef((t,e)=>{const{decorative:n,orientation:r=hP,...s}=t,i=_X(r)?r:hP,l=n?{role:"none"}:{"aria-orientation":i==="vertical"?i:void 0,role:"separator"};return o.jsx(Je.div,{"data-orientation":i,...l,...s,ref:e})});qM.displayName=CX;function _X(t){return NX.includes(t)}var EX=qM;function Hn({className:t,orientation:e="horizontal",decorative:n=!0,...r}){return o.jsx(EX,{"data-slot":"separator-root",decorative:n,orientation:e,className:Oe("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",t),...r})}var rw="rovingFocusGroup.onEntryFocus",SX={bubbles:!1,cancelable:!0},im="RovingFocusGroup",[Sb,GM,kX]=m1(im),[PX,xd]=Rs(im,[kX]),[IX,TX]=PX(im),ZM=u.forwardRef((t,e)=>o.jsx(Sb.Provider,{scope:t.__scopeRovingFocusGroup,children:o.jsx(Sb.Slot,{scope:t.__scopeRovingFocusGroup,children:o.jsx(AX,{...t,ref:e})})}));ZM.displayName=im;var AX=u.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:s=!1,dir:i,currentTabStopId:a,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:h=!1,...f}=t,p=u.useRef(null),g=At(e,p),v=sm(i),[x,y]=Co({prop:a,defaultProp:l??null,onChange:c,caller:im}),[b,w]=u.useState(!1),j=ni(d),E=GM(n),P=u.useRef(!1),[A,N]=u.useState(0);return u.useEffect(()=>{const _=p.current;if(_)return _.addEventListener(rw,j),()=>_.removeEventListener(rw,j)},[j]),o.jsx(IX,{scope:n,orientation:r,dir:v,loop:s,currentTabStopId:x,onItemFocus:u.useCallback(_=>y(_),[y]),onItemShiftTab:u.useCallback(()=>w(!0),[]),onFocusableItemAdd:u.useCallback(()=>N(_=>_+1),[]),onFocusableItemRemove:u.useCallback(()=>N(_=>_-1),[]),children:o.jsx(Je.div,{tabIndex:b||A===0?-1:0,"data-orientation":r,...f,ref:g,style:{outline:"none",...t.style},onMouseDown:Le(t.onMouseDown,()=>{P.current=!0}),onFocus:Le(t.onFocus,_=>{const k=!P.current;if(_.target===_.currentTarget&&k&&!b){const L=new CustomEvent(rw,SX);if(_.currentTarget.dispatchEvent(L),!L.defaultPrevented){const I=E().filter(H=>H.focusable),S=I.find(H=>H.active),T=I.find(H=>
4057H.id===x),$=[S,T,...I].filter(Boolean).map(H=>H.ref.current);QM($,h)}}P.current=!1}),onBlur:Le(t.onBlur,()=>w(!1))})})}),KM="RovingFocusGroupItem",YM=u.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:s=!1,tabStopId:i,children:a,...l}=t,c=yo(),d=i||c,h=TX(KM,n),f=h.currentTabStopId===d,p=GM(n),{onFocusableItemAdd:g,onFocusableItemRemove:v,currentTabStopId:x}=h;return u.useEffect(()=>{if(r)return g(),()=>v()},[r,g,v]),o.jsx(Sb.ItemSlot,{scope:n,id:d,focusable:r,active:s,children:o.jsx(Je.span,{tabIndex:f?0:-1,"data-orientation":h.orientation,...l,ref:e,onMouseDown:Le(t.onMouseDown,y=>{r?h.onItemFocus(d):y.preventDefault()}),onFocus:Le(t.onFocus,()=>h.onItemFocus(d)),onKeyDown:Le(t.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){h.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const b=LX(y,h.orientation,h.dir);if(b!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let j=p().filter(E=>E.focusable).map(E=>E.ref.current);if(b==="last")j.reverse();else if(b==="prev"||b==="next"){b==="prev"&&j.reverse();const E=j.indexOf(y.currentTarget);j=h.loop?MX(j,E+1):j.slice(E+1)}setTimeout(()=>QM(j))}}),children:typeof a=="function"?a({isCurrentTabStop:f,hasTabStop:x!=null}):a})})});YM.displayName=KM;var RX={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function DX(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function LX(t,e,n){const r=DX(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return RX[r]}function QM(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function MX(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var S1=ZM,k1=YM,kb=["Enter"," "],OX=["ArrowDown","PageUp","Home"],XM=["ArrowUp","PageDown","End"],FX=[...OX,...XM],zX={ltr:[...kb,"ArrowRight"],rtl:[...kb,"ArrowLeft"]},$X={ltr:["ArrowLeft"],rtl:["ArrowRight"]},am="Menu",[Pf,VX,UX]=m1(am),[yc,JM]=Rs(am,[UX,gd,xd]),Px=gd(),e4=xd(),[BX,wc]=yc(am),[WX,lm]=yc(am),t4=t=>{const{__scopeMenu:e,open:n=!1,children:r,dir:s,onOpenChange:i,modal:a=!0}=t,l=Px(e),[c,d]=u.useState(null),h=u.useRef(!1),f=ni(i),p=sm(s);return u.useEffect(()=>{const g=()=>{h.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>h.current=!1;return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),o.jsx(C1,{...l,children:o.jsx(BX,{scope:e,open:n,onOpenChange:f,content:c,onContentChange:d,children:o.jsx(WX,{scope:e,onClose:u.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:h,dir:p,modal:a,children:r})})})};t4.displayName=am;var HX="MenuAnchor",P1=u.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,s=Px(n);return o.jsx(Nx,{...s,...r,ref:e})});P1.displayName=HX;var I1="MenuPortal",[qX,n4]=yc(I1,{forceMount:void 0}),r4=t=>{const{__scopeMenu:e,forceMount:n,children:r,container:s}=t,i=wc(I1,e);return o.jsx(qX,{scope:e,forceMount:n,children:o.jsx(Xs,{present:n||i.open,children:o.jsx(em,{asChild:!0,container:s,children:r})})})};r4.displayName=I1;var Hs="MenuContent",[GX,T1]=yc(Hs),s4=u.forwardRef((t,e)=>{const n=n4(Hs,t.__scopeMenu),{forceMount:r=n.forceMount,...s}=t,i=wc(Hs,t.__scopeMenu),a=lm(Hs,t.__scopeMenu);return o.jsx(Pf.Provider,{scope:t.__scopeMenu,children:o.jsx(Xs,{present:r||i.open,children:o.jsx(Pf.Slot,{scope:t.__scopeMenu,children:a.modal?o.jsx(ZX,{...s,ref:e}):o.jsx(KX,{...s,ref:e})})})})}),ZX=u.forwardRef((t,e)=>{const n=wc(Hs,t.__scopeMenu),r=u.useRef(null),s=At(e,r);return u.useEffect(()=>{const i=r.current;if(i)return nm(i)},[]),o.jsx(A1,{...t,ref:s,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Le(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),KX=u.forwardRef((t,e)=>{const n=wc(Hs,t.__scopeMenu);return o.jsx(A1,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),YX=Ga("MenuContent.ScrollLock"),A1=u.forwardRef((t,e)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:s,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:p,onDismiss:g,disableOutsideScroll:v,...x}=t,y=wc(Hs,n),b=lm(Hs,n),w=Px(n),j=e4(n),E=VX(n),[P,A]=u.useState(null),N=u.useRef(null),_=At(e,N,y.onContentChange),k=u.useRef(0),L=u.useRef(""),I=u.useRef(0),S=u.useRef(null),T=u.useRef("right"),V=u.useRef(0),$=v?tm:u.Fragment,H=v?{as:YX,allowPinchZoom:!0}:void 0,W=F=>{var K,ue;const O=L.current+F,Y=E().filter(be=>!be.disabled),G=document.activeElement,q=(K=Y.find(be=>be.ref.current===G))==null?void 0:K.textValue,re=Y.map(be=>be.textValue),U=lJ(re,O,q),ee=(ue=Y.find(be=>be.textValue===U))==null?void 0:ue.ref.current;(function be(le){L.current=le,window.clearTimeout(k.current),le!==""&&(k.current=window.setTimeout(()=>be(""),1e3))})(O),ee&&setTimeout(()=>ee.focus())};u.useEffect(()=>()=>window.clearTimeout(k.current),[]),mx();const D=u.useCallback(F=>{var Y,G;return T.current===((Y=S.current)==null?void 0:Y.side)&&uJ(F,(G=S.current)==null?void 0:G.area)},[]);return o.jsx(GX,{scope:n,searchRef:L,onItemEnter:u.useCallback(F=>{D(F)&&F.preventDefault()},[D]),onItemLeave:u.useCallback(F=>{var O;D(F)||((O=N.current)==null||O.focus(),A(null))},[D]),onTriggerLeave:u.useCallback(F=>{D(F)&&F.preventDefault()},[D]),pointerGraceTimerRef:I,onPointerGraceIntentChange:u.useCallback(F=>{S.current=F}
4057,[]),children:o.jsx($,{...H,children:o.jsx(Jf,{asChild:!0,trapped:s,onMountAutoFocus:Le(i,F=>{var O;F.preventDefault(),(O=N.current)==null||O.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:o.jsx(Xf,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:p,onDismiss:g,children:o.jsx(S1,{asChild:!0,...j,dir:b.dir,orientation:"vertical",loop:r,currentTabStopId:P,onCurrentTabStopIdChange:A,onEntryFocus:Le(c,F=>{b.isUsingKeyboardRef.current||F.preventDefault()}),preventScrollOnEntryFocus:!0,children:o.jsx(N1,{role:"menu","aria-orientation":"vertical","data-state":w4(y.open),"data-radix-menu-content":"",dir:b.dir,...w,...x,ref:_,style:{outline:"none",...x.style},onKeyDown:Le(x.onKeyDown,F=>{const Y=F.target.closest("[data-radix-menu-content]")===F.currentTarget,G=F.ctrlKey||F.altKey||F.metaKey,q=F.key.length===1;Y&&(F.key==="Tab"&&F.preventDefault(),!G&&q&&W(F.key));const re=N.current;if(F.target!==re||!FX.includes(F.key))return;F.preventDefault();const ee=E().filter(K=>!K.disabled).map(K=>K.ref.current);XM.includes(F.key)&&ee.reverse(),iJ(ee)}),onBlur:Le(t.onBlur,F=>{F.currentTarget.contains(F.target)||(window.clearTimeout(k.current),L.current="")}),onPointerMove:Le(t.onPointerMove,If(F=>{const O=F.target,Y=V.current!==F.clientX;if(F.currentTarget.contains(O)&&Y){const G=F.clientX>V.current?"right":"left";T.current=G,V.current=F.clientX}}))})})})})})})});s4.displayName=Hs;var QX="MenuGroup",R1=u.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return o.jsx(Je.div,{role:"group",...r,ref:e})});R1.displayName=QX;var XX="MenuLabel",o4=u.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return o.jsx(Je.div,{...r,ref:e})});o4.displayName=XX;var uv="MenuItem",fP="menu.itemSelect",Ix=u.forwardRef((t,e)=>{const{disabled:n=!1,onSelect:r,...s}=t,i=u.useRef(null),a=lm(uv,t.__scopeMenu),l=T1(uv,t.__scopeMenu),c=At(e,i),d=u.useRef(!1),h=()=>{const f=i.current;if(!n&&f){const p=new CustomEvent(fP,{bubbles:!0,cancelable:!0});f.addEventListener(fP,g=>r==null?void 0:r(g),{once:!0}),iL(f,p),p.defaultPrevented?d.current=!1:a.onClose()}};return o.jsx(i4,{...s,ref:c,disabled:n,onClick:Le(t.onClick,h),onPointerDown:f=>{var p;(p=t.onPointerDown)==null||p.call(t,f),d.current=!0},onPointerUp:Le(t.onPointerUp,f=>{var p;d.current||(p=f.currentTarget)==null||p.click()}),onKeyDown:Le(t.onKeyDown,f=>{const p=l.searchRef.current!=="";n||p&&f.key===" "||kb.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Ix.displayName=uv;var i4=u.forwardRef((t,e)=>{const{__scopeMenu:n,disabled:r=!1,textValue:s,...i}=t,a=T1(uv,n),l=e4(n),c=u.useRef(null),d=At(e,c),[h,f]=u.useState(!1),[p,g]=u.useState("");return u.useEffect(()=>{const v=c.current;v&&g((v.textContent??"").trim())},[i.children]),o.jsx(Pf.ItemSlot,{scope:n,disabled:r,textValue:s??p,children:o.jsx(k1,{asChild:!0,...l,focusable:!r,children:o.jsx(Je.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...i,ref:d,onPointerMove:Le(t.onPointerMove,If(v=>{r?a.onItemLeave(v):(a.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Le(t.onPointerLeave,If(v=>a.onItemLeave(v))),onFocus:Le(t.onFocus,()=>f(!0)),onBlur:Le(t.onBlur,()=>f(!1))})})})}),JX="MenuCheckboxItem",a4=u.forwardRef((t,e)=>{const{checked:n=!1,onCheckedChange:r,...s}=t;return o.jsx(h4,{scope:t.__scopeMenu,checked:n,children:o.jsx(Ix,{role:"menuitemcheckbox","aria-checked":dv(n)?"mixed":n,...s,ref:e,"data-state":L1(n),onSelect:Le(s.onSelect,()=>r==null?void 0:r(dv(n)?!0:!n),{checkForDefaultPrevented:!1})})})});a4.displayName=JX;var l4="MenuRadioGroup",[eJ,tJ]=yc(l4,{value:void 0,onValueChange:()=>{}}),c4=u.forwardRef((t,e)=>{const{value:n,onValueChange:r,...s}=t,i=ni(r);return o.jsx(eJ,{scope:t.__scopeMenu,value:n,onValueChange:i,children:o.jsx(R1,{...s,ref:e})})});c4.displayName=l4;var u4="MenuRadioItem",d4=u.forwardRef((t,e)=>{const{value:n,...r}=t,s=tJ(u4,t.__scopeMenu),i=n===s.value;return o.jsx(h4,{scope:t.__scopeMenu,checked:i,children:o.jsx(Ix,{role:"menuitemradio","aria-checked":i,...r,ref:e,"data-state":L1(i),onSelect:Le(r.onSelect,()=>{var a;return(a=s.onValueChange)==null?void 0:a.call(s,n)},{checkForDefaultPrevented:!1})})})});d4.displayName=u4;var D1="MenuItemIndicator",[h4,nJ]=yc(D1,{checked:!1}
4057),f4=u.forwardRef((t,e)=>{const{__scopeMenu:n,forceMount:r,...s}=t,i=nJ(D1,n);return o.jsx(Xs,{present:r||dv(i.checked)||i.checked===!0,children:o.jsx(Je.span,{...s,ref:e,"data-state":L1(i.checked)})})});f4.displayName=D1;var rJ="MenuSeparator",m4=u.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return o.jsx(Je.div,{role:"separator","aria-orientation":"horizontal",...r,ref:e})});m4.displayName=rJ;var sJ="MenuArrow",p4=u.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,s=Px(n);return o.jsx(_1,{...s,...r,ref:e})});p4.displayName=sJ;var oJ="MenuSub",[Ple,g4]=yc(oJ),yh="MenuSubTrigger",v4=u.forwardRef((t,e)=>{const n=wc(yh,t.__scopeMenu),r=lm(yh,t.__scopeMenu),s=g4(yh,t.__scopeMenu),i=T1(yh,t.__scopeMenu),a=u.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=i,d={__scopeMenu:t.__scopeMenu},h=u.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return u.useEffect(()=>h,[h]),u.useEffect(()=>{const f=l.current;return()=>{window.clearTimeout(f),c(null)}},[l,c]),o.jsx(P1,{asChild:!0,...d,children:o.jsx(i4,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":s.contentId,"data-state":w4(n.open),...t,ref:hx(e,s.onTriggerChange),onClick:f=>{var p;(p=t.onClick)==null||p.call(t,f),!(t.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Le(t.onPointerMove,If(f=>{i.onItemEnter(f),!f.defaultPrevented&&!t.disabled&&!n.open&&!a.current&&(i.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{n.onOpenChange(!0),h()},100))})),onPointerLeave:Le(t.onPointerLeave,If(f=>{var g,v;h();const p=(g=n.content)==null?void 0:g.getBoundingClientRect();if(p){const x=(v=n.content)==null?void 0:v.dataset.side,y=x==="right",b=y?-5:5,w=p[y?"left":"right"],j=p[y?"right":"left"];i.onPointerGraceIntentChange({area:[{x:f.clientX+b,y:f.clientY},{x:w,y:p.top},{x:j,y:p.top},{x:j,y:p.bottom},{x:w,y:p.bottom}],side:x}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(f),f.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:Le(t.onKeyDown,f=>{var g;const p=i.searchRef.current!=="";t.disabled||p&&f.key===" "||zX[r.dir].includes(f.key)&&(n.onOpenChange(!0),(g=n.content)==null||g.focus(),f.preventDefault())})})})});v4.displayName=yh;var x4="MenuSubContent",y4=u.forwardRef((t,e)=>{const n=n4(Hs,t.__scopeMenu),{forceMount:r=n.forceMount,...s}=t,i=wc(Hs,t.__scopeMenu),a=lm(Hs,t.__scopeMenu),l=g4(x4,t.__scopeMenu),c=u.useRef(null),d=At(e,c);return o.jsx(Pf.Provider,{scope:t.__scopeMenu,children:o.jsx(Xs,{present:r||i.open,children:o.jsx(Pf.Slot,{scope:t.__scopeMenu,children:o.jsx(A1,{id:l.contentId,"aria-labelledby":l.triggerId,...s,ref:d,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:h=>{var f;a.isUsingKeyboardRef.current&&((f=c.current)==null||f.focus()),h.preventDefault()},onCloseAutoFocus:h=>h.preventDefault(),onFocusOutside:Le(t.onFocusOutside,h=>{h.target!==l.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Le(t.onEscapeKeyDown,h=>{a.onClose(),h.preventDefault()}),onKeyDown:Le(t.onKeyDown,h=>{var g;const f=h.currentTarget.contains(h.target),p=$X[a.dir].includes(h.key);f&&p&&(i.onOpenChange(!1),(g=l.trigger)==null||g.focus(),h.preventDefault())})})})})})});y4.displayName=x4;function w4(t){return t?"open":"closed"}function dv(t){return t==="indeterminate"}function L1(t){return dv(t)?"indeterminate":t?"checked":"unchecked"}function iJ(t){const e=document.activeElement;for(const n of t)if(n===e||(n.focus(),document.activeElement!==e))return}function aJ(t,e){return t.map((n,r)=>t[(e+r)%t.length])}function lJ(t,e,n){const s=e.length>1&&Array.from(e).every(d=>d===e[0])?e[0]:e,i=n?t.indexOf(n):-1;let a=aJ(t,Math.max(i,0));s.length===1&&(a=a.filter(d=>d!==n));const c=a.find(d=>d.toLowerCase().startsWith(s.toLowerCase()));return c!==n?c:void 0}function cJ(t,e){const{x:n,y:r}=t;let s=!1;for(let i=0,a=e.length-1;i<e.length;a=i++){const l=e[i],c=e[a],d=l.x,h=l.y,f=c.x,p=c.y;h>r!=p>
4057r&&n<(f-d)*(r-h)/(p-h)+d&&(s=!s)}return s}function uJ(t,e){if(!e)return!1;const n={x:t.clientX,y:t.clientY};return cJ(n,e)}function If(t){return e=>e.pointerType==="mouse"?t(e):void 0}var dJ=t4,hJ=P1,fJ=r4,mJ=s4,pJ=R1,gJ=o4,vJ=Ix,xJ=a4,yJ=c4,wJ=d4,bJ=f4,jJ=m4,CJ=p4,NJ=v4,_J=y4,Tx="DropdownMenu",[EJ]=Rs(Tx,[JM]),es=JM(),[SJ,b4]=EJ(Tx),j4=t=>{const{__scopeDropdownMenu:e,children:n,dir:r,open:s,defaultOpen:i,onOpenChange:a,modal:l=!0}=t,c=es(e),d=u.useRef(null),[h,f]=Co({prop:s,defaultProp:i??!1,onChange:a,caller:Tx});return o.jsx(SJ,{scope:e,triggerId:yo(),triggerRef:d,contentId:yo(),open:h,onOpenChange:f,onOpenToggle:u.useCallback(()=>f(p=>!p),[f]),modal:l,children:o.jsx(dJ,{...c,open:h,onOpenChange:f,dir:r,modal:l,children:n})})};j4.displayName=Tx;var C4="DropdownMenuTrigger",N4=u.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...s}=t,i=b4(C4,n),a=es(n);return o.jsx(hJ,{asChild:!0,...a,children:o.jsx(Je.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:hx(e,i.triggerRef),onPointerDown:Le(t.onPointerDown,l=>{!r&&l.button===0&&l.ctrlKey===!1&&(i.onOpenToggle(),i.open||l.preventDefault())}),onKeyDown:Le(t.onKeyDown,l=>{r||(["Enter"," "].includes(l.key)&&i.onOpenToggle(),l.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});N4.displayName=C4;var kJ="DropdownMenuPortal",_4=t=>{const{__scopeDropdownMenu:e,...n}=t,r=es(e);return o.jsx(fJ,{...r,...n})};_4.displayName=kJ;var E4="DropdownMenuContent",S4=u.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=b4(E4,n),i=es(n),a=u.useRef(!1);return o.jsx(mJ,{id:s.contentId,"aria-labelledby":s.triggerId,...i,...r,ref:e,onCloseAutoFocus:Le(t.onCloseAutoFocus,l=>{var c;a.current||(c=s.triggerRef.current)==null||c.focus(),a.current=!1,l.preventDefault()}),onInteractOutside:Le(t.onInteractOutside,l=>{const c=l.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0,h=c.button===2||d;(!s.modal||h)&&(a.current=!0)}),style:{...t.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)"}})});S4.displayName=E4;var PJ="DropdownMenuGroup",IJ=u.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=es(n);return o.jsx(pJ,{...s,...r,ref:e})});IJ.displayName=PJ;var TJ="DropdownMenuLabel",k4=u.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=es(n);return o.jsx(gJ,{...s,...r,ref:e})});k4.displayName=TJ;var AJ="DropdownMenuItem",P4=u.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=es(n);return o.jsx(vJ,{...s,...r,ref:e})});P4.displayName=AJ;var RJ="DropdownMenuCheckboxItem",DJ=u.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=es(n);return o.jsx(xJ,{...s,...r,ref:e})});DJ.displayName=RJ;var LJ="DropdownMenuRadioGroup",MJ=u.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=es(n);return o.jsx(yJ,{...s,...r,ref:e})});MJ.displayName=LJ;var OJ="DropdownMenuRadioItem",FJ=u.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=es(n);return o.jsx(wJ,{...s,...r,ref:e})});FJ.displayName=OJ;var zJ="DropdownMenuItemIndicator",$J=u.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=es(n);return o.jsx(bJ,{...s,...r,ref:e})});$J.displayName=zJ;var VJ="DropdownMenuSeparator",I4=u.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=es(n);return o.jsx(jJ,{...s,...r,ref:e})});I4.displayName=VJ;var UJ="DropdownMenuArrow",BJ=u.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=es(n);return o.jsx(CJ,{...s,...r,ref:e})});BJ.displayName=UJ;var WJ="DropdownMenuSubTrigger",HJ=u.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=es(n);return o.jsx(NJ,{...s,...r,ref:e})});HJ.displayName=WJ;var qJ="DropdownMenuSubContent",GJ=u.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=es(n);return o.jsx(_J,{...s,...r,ref:e,style:{...t.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)"}})});GJ.displayName=qJ;var ZJ=j4,KJ=N4,YJ=_4,QJ=S4,XJ=k4,JJ=P4,eee=I4;function M1({...t}){return o.jsx(ZJ,{"data-slot":"dropdown-menu",...t})}function O1({...t}){return o.jsx(KJ,{"data-slot":"dropdown-menu-trigger",...t})}function F1({className:t,sideOffset:e=4,...n}){return o.jsx(YJ,{children:o.jsx(QJ,{"data-slot":"dropdown-menu-content",sideOffset:e,className:Oe("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:sli
4057de-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",t),...n})})}function Ul({className:t,inset:e,variant:n="default",...r}){return o.jsx(JJ,{"data-slot":"dropdown-menu-item","data-inset":e,"data-variant":n,className:Oe("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...r})}function T4({className:t,inset:e,...n}){return o.jsx(XJ,{"data-slot":"dropdown-menu-label","data-inset":e,className:Oe("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",t),...n})}function tee({className:t,...e}){return o.jsx(eee,{"data-slot":"dropdown-menu-separator",className:Oe("bg-border -mx-1 my-1 h-px",t),...e})}const nee={reader:"Classique",writer:"Référent",admin:"Admin"};function mP({onNavigate:t,iconOnly:e=!1,showCollapseToggle:n=!1,onToggleCollapse:r}={}){var I;const s=Ui(),{user:i,logout:a,isSuperAdmin:l,canManageZones:c,canManageFarmers:d,canViewCompanies:h}=nn(),{theme:f,toggleTheme:p}=$H(),{activeCompanyId:g,setActiveCompanyId:v,companies:x}=cd(),y=x.find(S=>S.id===g),b=[];i&&nH(i)&&b.push({name:"Carte",href:xe.home,icon:h1}),i&&b.push({name:"Ma société",href:xe.myCompany,icon:qn});const w=[];c&&w.push({name:"Zones",href:xe.zones,icon:ur}),h&&(w.push({name:"Sociétés",href:xe.companies,icon:qn}),w.push({name:"Accès premium",href:xe.premiumAccess,icon:mo}));const j=[];d&&j.push({name:"Agriculteurs",href:xe.farmers,icon:Ef});const E=[];l&&(E.push({name:"Départements",href:xe.departments,icon:$K}),E.push({name:"Utilisateurs",href:xe.users,icon:cr}),E.push({name:"Sponsors",href:xe.sponsors,icon:yx}),E.push({name:"Contrats",href:xe.contracts,icon:UL}));const P=S=>S.split(" ").map(T=>T[0]).join("").toUpperCase().slice(0,2),A=()=>{var V;if(!i)return null;const S=[];i.isSuperAdmin&&S.push(o.jsx(We,{className:"text-[10px] bg-app-yellow/20 text-app-yellow border-app-yellow/30 hover:bg-app-yellow/30",children:"Admin"},"admin"));const T=["farmer","louvetier","trapper","federation","ddt","chambre_agriculture","asso_piegeurs"];return(V=i.roles)==null||V.filter($=>T.includes($)).forEach($=>{S.push(o.jsx(We,{className:"text-[10px] bg-white/10 text-white/70 border-white/15 hover:bg-white/15",children:bu[$]},$))}),S},N=S=>S==="/"?s.pathname==="/":s.pathname.startsWith(S),_=s.pathname===xe.profile,k=(S,T)=>T.length>0?o.jsxs("div",{children:[!e&&o.jsx("div",{className:"pt-4 pb-1 px-3",children:o.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider text-white/30",children:S})}),e&&o.jsx(Hn,{className:"my-2 bg-white/10"}),T.map(L)]},S):null,L=(S,T)=>{const V=N(S.href);return o.jsxs(Fa,{to:S.href,onClick:t,title:S.name,className:Kn("group flex items-center rounded-lg text-sm font-medium transition-all duration-150",e?"justify-center px-0 py-2.5":"px-3 py-2",V?"bg-white/15 text-white shadow-sm backdrop-blur-sm":"text-white/65 hover:bg-white/8 hover:text-white/90"),children:[o.jsx(S.icon,{className:Kn("h-[18px] w-[18px] flex-shrink-0 transition-colors",!e&&"mr-3",V?"text-app-yellow":"text-white/40 group-hover:text-white/60"),"aria-hidden":"true"}),!e&&S.name]},S.href)};return o.jsxs("div",{className:Kn("flex h-full flex-col sidebar-bg",e?"w-[76px]":"w-64"),children:[o.jsxs("div",{className:Kn("flex h-16 items-center border-b border-white/10",e?"justify-center px-2":"px-5"),children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsxs("div",{className:"relative flex-shrink-0",children:[o.jsx("img",{src:"/logo.png",alt:"Chassé & Croisé",className:"h-9 w-9 rounded-lg ring-1 ring-white/20"}),!1]}),!e&&o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"text-[15px] font-semibold text-white/95 font-heading leading-tight truncate",children:"Chassé & Croisé"}),o.jsx("div",{className:"text-[11px] text-white/40 leading-tight truncate",children:"Espace société"})]})]}),n&&!e&&o.jsx("button",{onClick:r,title:"Replier le menu",className:"ml-auto h-8 w-8 flex items-center justify-center rounded-lg text-white/40 hover:text-white/80 hover:bg-white/8 transition-colors flex-shrink-0",children:o.jsx(vc,{className:"h-[18px] w-[18px]"})})]}),n&&e&&o.jsx("div",{className:"flex justify-center px-2 pt-2",children:o.jsx("button",{onClick:r,title:"Agrandir le menu",className:"h-9 w-full flex items-center justify-center rounded-lg text-white/50 hover:text-white/90 hover:bg-white/8 border border-white/10 transition-colors",children:o.jsx(QK,{className:"h-[18px] w-[18px]"})})}),y&&o.jsx("div",{className:Kn("pt-2",e?"px-2":"px-3"),children:o.jsxs(M1,{children:[o.jsx(O1,{asChild:!0,children:o.jsxs("button",{title:`Société : ${y.name}`,className:Kn("w-full flex items-center rounded-xl bg-white/5 hover:bg-white/10 border border-white/10 transition-colors",e?"justify-center p-1.5":"gap-2.5 px-2 py-2"),children:[o.jsx("span",{className:"h-8 w-8 rounded-lg bg-app-green-light/20 text-app-green-light flex items-center justify-center font-bold text-xs flex-shrink-0",children:(y.name||"?").trim().slice(0,1).toUpperCase()}),!e&&o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"flex-1 min-w-0 text-left",children:[o.jsx("span",{className:"block text-[13px] font-semibold text-white/90 truncate",children:y.name}),o.jsx("span",{className:"block text-[11px] text-white/40",children:"Société active"})]}),o.jsx(u1,{className:"h-4 w-4 text-white/40 flex-shrink-0"})]})]})}),o.jsxs(F1,{align:"start",className:"w-60",children:[o.jsx(T4,{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:"Société active"}),x.map(S=>o.jsxs(Ul,{className:"gap-2.5 cursor-pointer",onSelect:()=>v(S.id),children:[o.jsx("span",{className:"h-7 w-7 rounded-md bg-primary/10 text-primary flex items-center justify-center font-bold text-[11px] flex-shrink-0",children:(S.name||"?").trim().slice(0,1).toUpperCase()}),o.jsxs("span",{className:"flex-1 min-w-0",children:[o.jsx("span",{className:"block text-sm font-medium truncate",children:S.name}),o.jsx("span",{className:"block text-[11px] text-muted-foreground",children:nee[S.role]}
4057)]}),S.id===g&&o.jsx(Xn,{className:"h-4 w-4 text-primary flex-shrink-0"})]},S.id))]})]})}),o.jsxs("nav",{className:Kn("flex-1 py-4 space-y-0.5 overflow-y-auto overflow-x-hidden",e?"px-2":"px-3"),children:[b.map(L),k("Fédération",w),k("Agriculture",j),k("Administration",E)]}),o.jsxs("div",{className:Kn("border-t border-white/10 py-3 space-y-1",e?"px-2":"px-3"),children:[o.jsxs("button",{onClick:p,title:f==="dark"?"Mode clair":"Mode sombre",className:Kn("flex items-center gap-3 w-full rounded-lg text-sm text-white/55 hover:bg-white/8 hover:text-white/90 transition-all duration-150",e?"justify-center px-0 py-2.5":"px-3 py-2"),children:[f==="dark"?o.jsx(aY,{className:"h-[18px] w-[18px] text-white/40 flex-shrink-0"}):o.jsx(YK,{className:"h-[18px] w-[18px] text-white/40 flex-shrink-0"}),!e&&(f==="dark"?"Mode clair":"Mode sombre")]}),o.jsx(Hn,{className:"!my-2 bg-white/10"}),o.jsxs(Fa,{to:xe.profile,onClick:t,title:(i==null?void 0:i.pseudo)||(i==null?void 0:i.email)||"Mon profil",className:Kn("block rounded-lg transition-all duration-150 group",e?"p-2":"p-3",_?"bg-white/15":"hover:bg-white/8"),children:[o.jsxs("div",{className:Kn("flex items-center gap-3",e&&"justify-center"),children:[o.jsx("div",{className:"h-9 w-9 rounded-full bg-app-green-light/20 flex items-center justify-center flex-shrink-0 ring-1 ring-white/10",children:o.jsx("span",{className:"text-xs font-semibold text-app-green-light",children:i!=null&&i.pseudo?P(i.pseudo):"U"})}),!e&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm font-medium text-white/90 truncate",children:(i==null?void 0:i.pseudo)||
4057(i==null?void 0:i.email)}),o.jsx("p",{className:"text-xs text-white/40 mt-0.5",children:"Voir mon profil"})]}),o.jsx(nr,{className:Kn("h-4 w-4 flex-shrink-0 transition-all",_?"text-white/60":"text-white/20 group-hover:text-white/50")})]})]}),!e&&(((I=A())==null?void 0:I.length)??0)>0&&o.jsx("div",{className:"flex flex-wrap items-center gap-1 mt-2 pl-12",children:A()})]}),o.jsx(Hn,{className:"my-2 bg-white/10"}),o.jsxs(Z,{variant:"ghost",size:"sm",onClick:a,title:"Déconnexion",className:Kn("w-full text-white/50 hover:text-white/90 hover:bg-white/8 text-xs h-8",e?"justify-center px-0":"justify-start"),children:[o.jsx(GK,{className:Kn("h-3.5 w-3.5",!e&&"mr-2")}),!e&&"Déconnexion"]})]})]})}const pP={drawer:1024,desktop:1280};function gP(t){return t<pP.drawer?"drawer":t<pP.desktop?"railIcon":"desktop"}function ree(){const[t,e]=u.useState(()=>typeof window>"u"?"desktop":gP(window.innerWidth));return u.useEffect(()=>{const n=()=>e(gP(window.innerWidth));return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),t}const vP=!1;function see(){const t=ree(),{collapsed:e,toggleCollapsed:n,drawerOpen:r,openDrawer:s,closeDrawer:i}=UH(),a=t==="drawer",l=t==="railIcon"||t==="desktop"&&e;return u.useEffect(()=>{!a&&r&&i()},[a,r,i]),o.jsxs("div",{className:"h-dvh flex bg-background overflow-hidden",children:[!a&&o.jsx("div",{className:"flex-shrink-0",children:o.jsx(mP,{iconOnly:l,showCollapseToggle:t==="desktop",onToggleCollapse:n})}),o.jsx(vX,{open:a&&r,onOpenChange:c=>c?s():i(),children:o.jsxs(wX,{side:"left",className:"p-0 w-64",children:[o.jsx(bX,{className:"sr-only",children:"Menu de navigation"}),o.jsx(mP,{onNavigate:i})]})}),o.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[a&&o.jsxs("div",{className:"flex items-center h-14 border-b border-border bg-card px-4 gap-3 shrink-0",children:[o.jsx(Z,{variant:"ghost",size:"icon",onClick:s,"aria-label":"Ouvrir le menu",children:o.jsx(ZK,{className:"h-5 w-5"})}),o.jsxs("div",{className:"relative",children:[o.jsx("img",{src:"/logo.png",alt:"Chassé & Croisé",className:"h-8 w-8 rounded-lg"}),vP]}),o.jsx("span",{className:"text-sm font-bold text-foreground font-heading",children:"Chassé & Croisé"})]}),o.jsx("main",{className:"flex-1 overflow-auto",children:o.jsx(nz,{})}),vP]})]})}const oee={"01":{lat:46.0667,lng:5.3333,zoom:10},"02":{lat:49.5667,lng:3.6167,zoom:10},"03":{lat:46.35,lng:3.3333,zoom:10},"04":{lat:44.0833,lng:6.2333,zoom:9},"05":{lat:44.6667,lng:6.25,zoom:9},"06":{lat:43.95,lng:7.15,zoom:10},"07":{lat:44.75,lng:4.4167,zoom:10},"08":{lat:49.6167,lng:4.6333,zoom:10},"09":{lat:42.9333,lng:1.5,zoom:10},10:{lat:48.3,lng:4.0833,zoom:10},11:{lat:43.1167,lng:2.4167,zoom:10},12:{lat:44.2667,lng:2.5833,zoom:10},13:{lat:43.5333,lng:5.0833,zoom:10},14:{lat:49.1,lng:-.3667,zoom:10},15:{lat:45.05,lng:2.6667,zoom:10},16:{lat:45.7167,lng:.15,zoom:10},17:{lat:45.8333,lng:-.8333,zoom:10},18:{lat:47.0667,lng:2.4167,zoom:10},19:{lat:45.35,lng:1.8333,zoom:10},21:{lat:47.4333,lng:4.8333,zoom:10},22:{lat:48.45,lng:-2.9,zoom:10},23:{lat:46.1,lng:2.0333,zoom:10},24:{lat:45.15,lng:.75,zoom:10},25:{lat:47.1667,lng:6.3667,zoom:10},26:{lat:44.7333,lng:5.1667,zoom:10},27:{lat:49.1,lng:1.1,zoom:10},28:{lat:48.3333,lng:1.4833,zoom:10},29:{lat:48.4,lng:-4.5,zoom:10},"2A":{lat:41.8667,lng:8.9,zoom:10},"2B":{lat:42.45,lng:9.15,zoom:10},30:{lat:44.0333,lng:4.2,zoom:10},31:{lat:43.45,lng:1.4333,zoom:10},32:{lat:43.65,lng:.5833,zoom:10},33:{lat:44.9,lng:-.6,zoom:10},34:{lat:43.6167,lng:3.45,zoom:10},35:{lat:48.1667,lng:-1.7333,zoom:10},36:{lat:46.8333,lng:1.5667,zoom:10},37:{lat:47.2667,lng:.7,zoom:10},38:{lat:45.2833,lng:5.5667,zoom:10},39:{lat:46.75,lng:5.6667,zoom:10},40:{lat:43.9333,lng:-.8,zoom:10},41:{lat:47.6167,lng:1.3333,zoom:10},42:{lat:45.7333,lng:4.1667,zoom:10},43:{lat:45.1333,lng:3.8833,zoom:10},44:{lat:47.3667,lng:-1.75,zoom:10},45:{lat:47.9167,lng:2.15,zoom:10},46:{lat:44.6333,lng:1.6167,zoom:10},47:{lat:44.35,lng:.6,zoom:10},48:{lat:44.5167,lng:3.5,zoom:10},49:{lat:47.45,lng:-.55,zoom:10},50:{lat:49.0833,lng:-1.3333,zoom:10},51:{lat:49,lng:4.2167,zoom:10},52:{lat:48.1,lng:5.1333,zoom:10},53:{lat:48.0667,lng:-.7667,zoom:10},54:{lat:48.8333,lng:6.1667,zoom:10},55:{lat:49.1,lng:5.3833,zoom:10},56:{lat:47.8333,lng:-2.8333,zoom:10},57:{lat:49.0333,lng:6.6667,zoom:10},58:{lat:47.1167,lng:3.6,zoom:10},59:{lat:50.2,lng:3.2667,zoom:10},60:{lat:49.4167,lng:2.5,zoom:10},61:{lat:48.6333,lng:.0833,zoom:10},62:{lat:50.4833,lng:2.3667,zoom:10},63:{lat:45.7667,lng:3.0833,zoom:10},64:{lat:43.3,lng:-.7667,zoom:10},65:{lat:43.1,lng:.15,zoom:10},66:{lat:42.5667,lng:2.5,zoom:10},67:{lat:48.6667,lng:7.55,zoom:10},68:{lat:47.85,lng:7.25,zoom:10},69:{lat:45.8833,lng:4.6333,zoom:10},70:{lat:47.6333,lng:6.15,zoom:10},71:{lat:46.75,lng:4.6667,zoom:10},72:{lat:47.9833,lng:.2167,zoom:10},73:{lat:45.5833,lng:6.4167,zoom:10},74:{lat:46.0667,lng:6.4167,zoom:10},75:{lat:48.8566,lng:2.3522,zoom:12},76:{lat:49.65,lng:1.0833,zoom:10},77:{lat:48.6167,lng:2.9167,zoom:10},78:{lat:48.8333,lng:1.8333,zoom:10},79:{lat:46.5,lng:-.3333,zoom:10},80:{lat:49.9333,lng:2.4667,zoom:10},81:{lat:43.8833,lng:2.15,zoom:10},82:{lat:44.0167,lng:1.35,zoom:10},83:{lat:43.4667,lng:6.2167,zoom:10},84:{lat:44,lng:5.1833,zoom:10},85:{lat:46.6667,lng:-1.4333,zoom:10},86:{lat:46.5833,lng:.4167,zoom:10},87:{lat:45.85,lng:1.25,zoom:10},88:{lat:48.1667,lng:6.45,zoom:10},89:{lat:47.85,lng:3.5667,zoom:10},90:{lat:47.6333,lng:6.8667,zoom:11},91:{lat:48.5,lng:2.2167,zoom:11},92:{lat:48.8667,lng:2.2167,zoom:12},93:{lat:48.9167,lng:2.4833,zoom:12}
4057,94:{lat:48.7833,lng:2.4667,zoom:12},95:{lat:49.0833,lng:2.1333,zoom:11},971:{lat:16.25,lng:-61.5833,zoom:10},972:{lat:14.6667,lng:-61,zoom:10},973:{lat:4,lng:-53,zoom:7},974:{lat:-21.1333,lng:55.5167,zoom:10},976:{lat:-12.8333,lng:45.1667,zoom:10}};function xP(t){const e=String(t).padStart(2,"0");return oee[e]||null}const ys={async getDepartmentsPaginated(t=20,e=0,n,r){try{const i=await pe(ge,"getDepartmentConfigs")({limit:t,offset:e,searchTerm:n,missingFederation:r==null?void 0:r.missingFederation,missingDdt:r==null?void 0:r.missingDdt});return{departments:i.data.departments||[],totalCount:i.data.total||0,offset:i.data.offset||0,hasMore:i.data.hasMore||!1}}catch(s){return console.error("Error fetching department configs:",s),{departments:[],totalCount:0,offset:0,hasMore:!1}}},async getAllDepartments(){try{return(await pe(ge,"getAllDepartmentConfigs")()).data.departments||[]}catch(t){return console.error("Error fetching all department configs:",t),[]}},async getConfiguredDepartmentCodes(){try{return(await pe(ge,"getConfiguredDepartmentCodes")()).data.codes||[]}catch(t){return console.error("Error fetching configured department codes:",t),[]}},async getDepartmentById(t){try{const e=await ms(Ht(Xe,"departments",t));return e.exists()?{id:e.id,...e.data()}:null}catch(e){return console.error("Error getting department config:",e),null}},async createDepartment(t){const n=await pe(ge,"createDepartmentConfig")(t),{departmentId:r}=n.data,s=await this.getDepartmentById(r);if(!s)throw new Error("Failed to create department config");return s},async updateDepartment(t,e){await pe(ge,"updateDepartmentConfig")({departmentId:t,...e})},async deleteDepartment(t){await pe(ge,"deleteDepartmentConfig")({departmentId:t})},async uploadFederationLogo(t,e){const n=pe(ge,"uploadFederationLogo"),r=await new Promise((i,a)=>{const l=new FileReader;l.onload=()=>{const d=l.result.split(",")[1];i(d)},l.onerror=a,l.readAsDataURL(e)});return(await n({departmentId:t,logoBase64:r,contentType:e.type||"image/jpeg"})).data.logoPath},async deleteFederationLogo(t){await pe(ge,"deleteFederationLogo")({departmentId:t})},async getDepartmentBoundsByCode(t){try{return(await pe(ge,"getDepartmentBoundsByCode")({departmentCode:t})).data.bounds||null}catch(e){return console.error("Error fetching department bounds:",e),null}}},iee=2*60*60*1e3;function aee(t){return t?t.toDate?t.toDate():t.seconds?new Date(t.seconds*1e3):t._seconds?new Date(t._seconds*1e3):new Date(t):null}const lee={async getEmergencies(){try{const t=jn(Xe,"emergency"),e=Gr(t,OC("creationDate","desc")),n=await Yr(e),r=Date.now(),s=n.docs.map(a=>{var c,d,h,f;const l=a.data();return{id:a.id,creationDate:l.creationDate,location:{latitude:((c=l.location)==null?void 0:c.latitude)??((d=l.location)==null?void 0:d._latitude)??0,longitude:((h=l.location)==null?void 0:h.longitude)??((f=l.location)==null?void 0:f._longitude)??0},userId:l.userId,userPseudo:l.userPseudo,userEmail:l.userEmail,userPhone:l.userPhone}}).filter(a=>{const l=aee(a.creationDate);return l?r-l.getTime()<iee:!1});return await Promise.all(s.map(async a=>{if(a.userEmail&&a.userPhone)return a;try{const l=await ms(Ht(Xe,"users",a.userId));if(l.exists()){const c=l.data();return{...a,userEmail:a.userEmail||c.email,userPhone:a.userPhone||c.phone}}}catch(l){console.error("Error fetching user data for emergency:",l)}return a}))}catch(t){return console.error("Error fetching emergencies:",t),[]}}},Kd="poi";function cee(t,e){const n=[];for(let r=0;r<t.length;r+=e)n.push(t.slice(r,r+e));return n}function yP(t,e){const n=e.gpsPoint,r=n?{latitude:n.latitude??n._latitude,longitude:n.longitude??n._longitude}:{latitude:0,longitude:0};return{id:t,companyId:e.companyId??"",name:e.name??"",description:e.description??"",type:e.type??"Autre",position:r,zones:e.zones??{},logo:e.logo,clicks:e.clicks??[],creationDate:e.creationDate}}const vi={async getPoisByCompanies(t){if(t.length===0)return[];try{return(await Promise.all(cee(t,30).map(async n=>{const r=Gr(jn(Xe,Kd),is("companyId","in",n));return(await Yr(r)).docs.map(i=>yP(i.id,i.data()))}))).flat()}catch(e){return console.error("Error fetching POIs by companies:",e),[]}},async getAllPois(t=1e3){try{return(await Yr(jn(Xe,Kd))).docs.slice(0,t).map(n=>yP(n.id,n.data()))}catch(e){return console.error("Error fetching all POIs:",e),[]}},async createPoi(t){var n;return(await ld(jn(Xe,Kd),{companyId:t.companyId,name:t.name.trim(),description:((n=t.description)==null?void 0:n.trim())??"",type:t.type,gpsPoint:new Fi(t.position.latitude,t.position.longitude),zones:{},clicks:[],creationDate:Or()})).id},async updatePoi(t,e){const n={};e.name!==void 0&&(n.name=e.name.trim()),e.description!==void 0&&(n.description=e.description.trim()),e.type!==void 0&&(n.type=e.type),e.position!==void 0&&(n.gpsPoint=new Fi(e.position.latitude,e.position.longitude)),await Ba(Ht(Xe,Kd,t),n)},async deletePoi(t){await Qf(Ht(Xe,Kd,t))}};function uee(){const{user:t}=nn(),[e,n]=u.useState([]),[r,s]=u.useState(!0);return u.useEffect(()=>{let i=!1;async function a(){if(!t){n([]),s(!1);return}s(!0);try{const l=Object.entries(t.companyRoles??{}).filter(([,d])=>d==="writer"||d==="admin").map(([d])=>d),c=await Promise.all(l.map(async d=>{const h=await Ot.getCompanyById(d);return h?{id:h.id,name:h.name}:null}));i||n(c.filter(d=>d!==null).sort((d,h)=>d.name.localeCompare(h.name)))}catch(l){console.error("Error loading editable companies:",l),i||n([])}finally{i||s(!1)}}return a(),()=>{i=!0}},[t]),{companies:e,loading:r}}const Pl={async getUserPremium(t,e){try{const r=await pe(ge,"getPremium")({userId:t,companyId:e||void 0});return{isPremium:r.data.isPremium||!1,source:r.data.source||null,premiumEndDate:r.data.premiumEndDate||null,sources:r.data.sources||[]}}catch(n){throw console.error("Error getting user premium status:",n),new Error(n.message||"Erreur lors de la récupération du statut premium")}},async grantUserPremium(t,e){try{await pe(ge,"grantUserSubscription")({userId:t,endDate:e})}catch(n){throw console.error("Error granting user premium:",n),new Error(n.message||"Erreur lors de la mise à jour du statut premium")}},async getProtectionCultures(t){try{const n=await pe(ge,"hasProtectionCultures")({userId:t});return{hasEntitlement:n.data.hasEntitlement||!1,source:n.data.source||null,expiresDate:n.data.expiresDate||null}}catch(e){throw console.error("Error getting protectionCultures status:",e),new Error(e.message||"Erreur lors de la récupération du statut protectionCultures")}},async updateProtectionCultures(t,e){try{await pe(ge,"updateProtectionCultures")({userId:t,endDate:e})}catch(n){throw console.error("Error updating protectionCultures:",n),new Error(n.message||"Erreur lors de la mise à jour de protectionCultures")}}},dee=Object.freeze(Object.defineProperty({__proto__:null,premiumService:Pl},Symbol.toStringTag,{value:"Module"}));function A4(){const{user:t,isSuperAdmin:e}=nn(),{activeCompanyId:n}=cd(),[r,s]=u.useState(!1),[i,a]=u.useState(!0);return u.useEffect(()=>{let l=!1;if(!t){s(!1),a(!1);return}if(e){s(!0),a(!1);return}return a(!0),Pl.getUserPremium(t.id,n).then(c=>{l||s(!!c.isPremium)}).catch(()=>{l||s(!1)}).finally(()=>{l||a(!1)}),()=>{l=!0}},[t,e,n]),{isPremium:r,loading:i}}function bc({className:t,...e}){return o.jsx("textarea",{"data-slot":"textarea",className:Oe("resize-none border-border bg-card text-foreground placeholder:text-muted-foreground
4057/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 aria-invalid:border-destructive flex field-sizing-content min-h-16 w-full rounded-md border px-3 py-2 text-base transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),...e})}const $h="__none__",hee=["walker","cyclist","horseman","rider","hunter","public","federation","none"];function fee({draft:t,companies:e,companiesLoading:n,allowNoCompany:r,canChooseActivity:s,saving:i,onChange:a,onClearPoints:l,onCancel:c,onSave:d,onDelete:h}){const f=t.kind==="poi",p=t.kind==="poi"&&t.mode==="edit",g=u.useMemo(()=>{var b;const y=e.map(w=>({value:w.id,label:w.name}));if(r&&y.unshift({value:$h,label:"Aucune société"}),t.kind==="poi"&&t.mode==="edit"){const w=t.companyId===""?$h:t.companyId;w&&!y.some(j=>j.value===w)&&y.push({value:w,label:((b=e.find(j=>j.id===t.companyId))==null?void 0:b.name)??"Société rattachée"})}return y},[e,r,t]);u.useEffect(()=>{n||p||t.companyId===""&&g.length===1&&a({companyId:g[0].value})},[n,p,t.companyId,g,a]);const v=f?t.name.trim().length>=2&&!!t.companyId&&!!t.position:t.name.trim().length>=2&&!!t.companyId&&t.points.length>=2,x=f?t.position?"Point placé : glissez le marqueur pour ajuster":"Cliquez sur la carte pour placer le point":t.points.length===0?"Cliquez sur la carte pour démarrer le tracé":t.points.length<2?"Ajoutez au moins un second point":`${t.points.length} points : glissez pour ajuster, cliquez un point pour le retirer`;return o.jsx("div",{className:"absolute inset-x-0 bottom-0 z-40 lg:inset-x-auto lg:left-1/2 lg:-translate-x-1/2 lg:bottom-4 lg:w-[95%] lg:max-w-3xl",children:o.jsxs("div",{className:"flex flex-col max-h-[82vh] lg:max-h-[72vh] rounded-t-2xl lg:rounded-2xl bg-card border border-border shadow-2xl overflow-hidden",children:[o.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 border-b border-border bg-muted/40 flex-shrink-0",children:[o.jsx("div",{className:"h-8 w-8 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:f?o.jsx(Rn,{className:"h-4 w-4 text-primary"}):o.jsx(nc,{className:"h-4 w-4 text-primary"})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("p",{className:"text-sm font-bold font-heading leading-tight",children:f?p?"Modifier le POI":"Nouveau point dâintérêt":"Nouveau chemin"}),o.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight truncate",children:x})]}),o.jsx("button",{onClick:c,className:"h-7 w-7 rounded-full hover:bg-muted flex items-center justify-center flex-shrink-0",children:o.jsx(br,{className:"h-4 w-4 text-muted-foreground"})})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-3",children:[o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ne,{htmlFor:"ed-name",children:"Nom *"}),o.jsx(Ne,{id:"ed-name",value:t.name,onChange:y=>a({name:y.target.value}),placeholder:f?"Ex : Mirador nord":"Ex : Sentier des Crêtes"})]}),f?o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ne,{children:"Type *"}),o.jsxs(_t,{value:t.type,onValueChange:y=>a({type:y}),children:[o.jsx(St,{children:o.jsx(Et,{})}),o.jsx(kt,{children:ND.map(y=>o.jsx(Ke,{value:y,children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("img",{src:uo[y],alt:"",className:"h-4 w-4 object-contain"}),y]})},y))})]})]}):s?o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ne,{children:"Activité *"}),o.jsxs(_t,{value:t.activity,onValueChange:y=>a({activity:y}),children:[o.jsx(St,{children:o.jsx(Et,{})}),o.jsx(kt,{children:hee.map(y=>o.jsx(Ke,{value:y,children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"h-3 w-3 rounded-full",style:{backgroundColor:fo[y]}}),Vl[y]]})},y))})]})]}):o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ne,{children:"Activité"}),o.jsxs("div",{className:"h-9 px-3 rounded-md border border-input bg-muted/50 flex items-center gap-2 text-sm text-muted-foreground",children:[o.jsx("span",{className:"h-3 w-3 rounded-full",style:{backgroundColor:fo[t.activity]}}),Vl[t.activity]]})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ne,{children:"Société *"}),o.jsxs(_t,{value:t.companyId,onValueChange:y=>a({companyId:y}),disabled:p||g.length<=1,children:[o.jsx(St,{children:o.jsx(Et,{placeholder:"Choisir une société"})}),o.jsx(kt,{children:g.map(y=>o.jsx(Ke,{value:y.value,children:y.label},y.value))})]})]})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ne,{htmlFor:"ed-desc",children:"Description"}),o.jsx(bc,{id:"ed-desc",value:t.description,onChange:y=>a({description:y.target.value}),rows:2,placeholder:"Information complémentaire (facultatif)"})]})]}),o.jsxs("div",{className:"border-t border-border px-4 py-3 flex items-center gap-2 flex-shrink-0",children:[p&&h&&o.jsxs(Z,{variant:"outline",size:"sm",onClick:h,disabled:i,className:"text-destructive hover:text-destructive hover:bg-destructive/10",children:[o.jsx(Vt,{className:"h-4 w-4 mr-1.5"})," Supprimer"]}),!f&&t.points.length>0&&o.jsxs(Z,{variant:"outline",size:"sm",onClick:l,disabled:i,className:"text-destructive hover:text-destructive hover:bg-destructive/10",children:[o.jsx(Vt,{className:"h-4 w-4 mr-1.5"})," Effacer le tracé"]}),o.jsx("div",{className:"flex-1"}),o.jsx(Z,{variant:"outline",onClick:c,disabled:i,children:"Annuler"}),o.jsx(Z,{onClick:d,disabled:!v||i,children:i?"Enregistrementâ¦":p?"Enregistrer":f?"Créer le POI":"Créer le chemin"})]})]})})}const go={async listByCompany(t){var r;return((r=(await pe(ge,"listCompanyHuntingZones")({companyId:t})).data)==null?void 0:r.zones)||[]},async create(t){var r;return(r=(await pe(ge,"createCompanyHuntingZone")(t)).data)==null?void 0:r.zoneId},async update(t){await pe(ge,"updateCompanyHuntingZone")(t)},async remove(t){await pe(ge,"deleteCompanyHuntingZone")({zoneId:t})},async removeAllByCompany(t){var r;return((r=(await pe(ge,"deleteAllCompanyHuntingZones")({companyId:t})).data)==null?void 0:r.deletedCount)??0}},mee="https://data.geopf.fr/wmts",R4="map-base-layer";function D4(){const t=typeof localStorage<"u"?localStorage.getItem(R4):null;return t==="plan"||t==="ign"?t:"satellite"}function pee(t){localStorage.setItem(R4,t)}function wP(t,e,n){return new google.maps.ImageMapType({name:t,tileSize:new google.maps.Size(256,256),minZoom:0,maxZoom:21,getTileUrl:(r,s)=>s>n?null:`${mee}?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=${t}&STYLE=normal&TILEMATRIXSET=${e}&TILEMATRIX=${s}&TILEROW=${r.y}&TILECOL=${r.x}&FORMAT=image/png`})}function Pb(t,e){t.overlayMapTypes.clear(),t.setMapTypeId(e==="satellite"?"hybrid":"roadmap"),e==="ign"&&(t.overlayMapTypes.push(wP("GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2","PM",19)),t.overlayMapTypes.push(wP("ELEVATION.CONTOUR.LINE","PM_6_18",18)))}const wh="#8EC9A4",Zc="#F66D51",gee=5*60*1e3;
4057let bP=null;const vp="#2f7d52",eg="#5E9A74",Kc="#4E8DD0",Ib="#F97316",Tb="#DC4A5D",Ab="#DC4A5D",vee={lat:46.603354,lng:1.888334},xee=6,jP=12,yee=5,wee=8,CP=1024;let zc=null,Yd=null;const Fo={damagePending:"/pins/damage_pending.png",damageInProgress:"/pins/damage_in_progress.png",damageResolved:"/pins/damage_resolved.png",damageClosed:"/pins/damage_closed.png",burrowSpotted:"/pins/burrow_spotted.png",burrowMonitoring:"/pins/burrow_monitoring.png",burrowInactive:"/pins/burrow_inactive.png",emergencySOS:"/pins/emergency_sos.png"};function bee(){const[t,e]=u.useState(()=>window.innerWidth>=CP);return u.useEffect(()=>{const n=()=>e(window.innerWidth>=CP);return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),t}function jee(){const t=qt(),e=Ui(),{user:n,isSuperAdmin:r,canCreateZones:s}=nn(),{activeCompanyId:i}=cd(),{plots:a,damages:l,burrows:c,loading:d,isStale:h,refreshPlots:f,refreshDamages:p,refreshBurrows:g}=FH(),v=bee(),x=u.useRef(!1),y=u.useRef(null),[b,w]=u.useState([]),[j,E]=u.useState(!1),[P,A]=u.useState([]),[N,_]=u.useState([]),[k,L]=u.useState(null),{companies:I,loading:S}=uee(),[T,V]=u.useState([]),[$,H]=u.useState([]),[W,D]=u.useState(!1),[F,O]=u.useState(null),[Y,G]=u.useState(!1),q=!!F,re=Ft(),[U,ee]=u.useState(null),[K,ue]=u.useState(null),[be,le]=u.useState(null),[B,Q]=u.useState(zc??vee),[ve,Ae]=u.useState(Yd??xee),[he,J]=u.useState(""),[je,Ve]=u.useState(!1),[Ye,Jt]=u.useState({pois:!0,paths:!0,zones:!1,huntingZones:!1,damages:!0,burrows:!0,plots:!1,emergencies:!0}),[Ue,rn]=u.useState(()=>{const M={pois:!0,paths:!0,zones:!0,huntingZones:!0,damages:!0,burrows:!0,plots:!0,emergencies:!0};try{return{...M,...JSON.parse(localStorage.getItem("map-visibility")||"{}")}}catch{return M}});u.useEffect(()=>{localStorage.setItem("map-visibility",JSON.stringify(Ue))},[Ue]);const vt=u.useCallback(M=>rn(X=>({...X,[M]:!X[M]})),[]),me=u.useCallback(M=>Jt(X=>({...X,[M]:!X[M]})),[]),[ot,Se]=u.useState(!0),[Te,He]=u.useState(()=>{try{const M=JSON.parse(localStorage.getItem("map-subfilters")||"{}");return{pois:new Set(M.pois||[]),paths:new Set(M.paths||[]),zones:new Set(M.zones||[])}}catch{return{pois:new Set,paths:new Set,zones:new Set}}});u.useEffect(()=>{localStorage.setItem("map-subfilters",JSON.stringify({pois:[...Te.pois],paths:[...Te.paths],zones:[...Te.zones]}))},[Te]);const Ut=u.useCallback((M,X)=>He(we=>{const tt=new Set(we[M]);return tt.has(X)?tt.delete(X):tt.add(X),{...we,[M]:tt}}),[]),cn=u.useCallback(()=>He({pois:new Set,paths:new Set,zones:new Set}),[]),xn=u.useCallback(M=>Te.pois.size===0||Te.pois.has(M.type),[Te]),un=u.useCallback(M=>Te.paths.size===0||Te.paths.has(M.activity),[Te]),Yt=u.useCallback(M=>{const X=Te.zones,we=[...X].filter(Ki=>Ki!=="assigned"&&Ki!=="unassigned"),tt=we.length===0?M.zoneType==="huntingTerritory":we.includes(M.zoneType),Ze=!X.has("assigned")&&!X.has("unassigned")||X.has("assigned")&&!!M.companyId||X.has("unassigned")&&!M.companyId;return tt&&Ze},[Te]),st=u.useMemo(()=>Object.keys((n==null?void 0:n.companyRoles)??{}),[n]),de=st.length>0,ze=u.useMemo(()=>n?r||de||Yn(n,"view_department_plots")||Yn(n,"view_zone_plots"):!1,[n,r,de]),Qe=u.useMemo(()=>n?r||de||Yn(n,"view_department_damages")||Yn(n,"view_zone_damages"):!1,[n,r,de]),It=u.useMemo(()=>n?r||de||Yn(n,"view_department_burrows")||Yn(n,"view_zone_burrows"):!1,[n,r,de]),se=u.useMemo(()=>n?r||de||Yn(n,"manage_department_zones")||Yn(n,"view_assigned_zones"):!1,[n,r,de]),Re=r||de,{isPremium:ae}=A4(),et=(n==null?void 0:n.roles)??[],xt=et.includes("ddt"),zt=et.includes("federation"),$e=u.useMemo(()=>Object.values((n==null?void 0:n.companyRoles)??{}).some(M=>M==="writer"||M==="admin"),[n]),oe=r||zt||$e,De=r||!xt&&(zt||$e),En=oe&&(r||ae),Ct=oe||De,qe=r||zt,Zn=u.useCallback(M=>{var we;if(r)return!0;const X=(we=n==null?void 0:n.companyRoles)==null?void 0:we[M.companyId];return X==="writer"||X==="admin"},[n,r]),_r=u.useCallback(M=>{var we;if(r)return!0;const X=(we=n==null?void 0:n.companyRoles)==null?void 0:we[M.companyId];return X==="writer"||X==="admin"},[n,r]),Bt={pois:Re,paths:Re,zones:se,huntingZones:r||de,damages:Qe,burrows:It,plots:ze,emergencie
4057s:r||de},Cc=M=>M instanceof Date?M:M!=null&&M.toDate?M.toDate():M!=null&&M.seconds?new Date(M.seconds*1e3):new Date(M),ai=M=>M.status||"pending",qi=M=>({lat:M.latitude,lng:M.longitude}),Nc=M=>{if(!M.length)return null;const X=M.reduce((tt,Ze)=>tt+(Ze.latitude??Ze._latitude??0),0)/M.length,we=M.reduce((tt,Ze)=>tt+(Ze.longitude??Ze._longitude??0),0)/M.length;return{lat:X,lng:we}},To=u.useMemo(()=>l.filter(M=>{var X,we;return((X=M.position)==null?void 0:X.latitude)!=null&&((we=M.position)==null?void 0:we.longitude)!=null}).filter(M=>{const X=M.status||"pending";return X==="pending"||X==="inProgress"}).sort((M,X)=>Cc(X.createdAt).getTime()-Cc(M.createdAt).getTime()),[l]),Gi=u.useMemo(()=>c.filter(M=>{var X,we;return((X=M.position)==null?void 0:X.latitude)!=null&&((we=M.position)==null?void 0:we.longitude)!=null}).filter(M=>M.status!=="inactive").sort((M,X)=>Cc(X.createdAt).getTime()-Cc(M.createdAt).getTime()),[c]),Ao=u.useMemo(()=>T.filter(M=>{var X,we;return((X=M.position)==null?void 0:X.latitude)!=null&&((we=M.position)==null?void 0:we.longitude)!=null}),[T]),Js=u.useMemo(()=>$.filter(M=>{var X;return(((X=M.gpsPoints)==null?void 0:X.length)??0)>=2}),[$]),Er=u.useMemo(()=>b.filter(M=>{var X;return(((X=M.gpsPoint)==null?void 0:X.length)??0)>=3}),[b]),Br=u.useCallback((M,X)=>be?be.contains({lat:M,lng:X}):!0,[be]),xm=u.useMemo(()=>To.filter(M=>Br(M.position.latitude,M.position.longitude)),[To,Br]),bd=u.useMemo(()=>Gi.filter(M=>Br(M.position.latitude,M.position.longitude)),[Gi,Br]),jd=u.useMemo(()=>Ao.filter(M=>Br(M.position.latitude,M.position.longitude)),[Ao,Br]),ym=u.useMemo(()=>Js.filter(M=>M.gpsPoints.some(X=>Br(X.latitude,X.longitude))),[Js,Br]),wm=u.useMemo(()=>Er.filter(M=>M.gpsPoint.some(X=>Br(X.latitude,X.longitude))),[Er,Br]),Ux=u.useMemo(()=>a.filter(M=>{var tt;const X=M.gpsPoints||M.gpsPoint||((tt=M.polygons)==null?void 0:tt[0]),we=Array.isArray(X)?X:(X==null?void 0:X.points)??[];return!Array.isArray(we)||we.length===0?!1:we.some(Ze=>Br(Ze.latitude??Ze._latitude,Ze.longitude??Ze._longitude))}),[a,Br]);u.useEffect(()=>{if(!x.current&&(x.current=!0,!zc)){if(navigator.geolocation)navigator.geolocation.getCurrentPosition(M=>{const X={lat:M.coords.latitude,lng:M.coords.longitude};Q(X),Ae(jP),zc=X,Yd=jP},()=>{if(!r&&(n!=null&&n.departmentCode)){const M=xP(n.departmentCode);M&&(Q({lat:M.lat,lng:M.lng}),Ae(M.zoom),zc={lat:M.lat,lng:M.lng},Yd=M.zoom)}},{timeout:5e3,maximumAge:3e5});else if(!r&&(n!=null&&n.departmentCode)){const M=xP(n.departmentCode);M&&(Q({lat:M.lat,lng:M.lng}),Ae(M.zoom),zc={lat:M.lat,lng:M.lng},Yd=M.zoom)}}},[r,n==null?void 0:n.departmentCode]),u.useEffect(()=>{r||!(n!=null&&n.departmentCode)||ys.getDepartmentBoundsByCode(n.departmentCode).then(M=>{M&&L(M)})},[r,n==null?void 0:n.departmentCode]),u.useEffect(()=>{h&&(f(),p(),g())},[h,f,p,g]),u.useEffect(()=>{if(!se||!n){w([]);return}let M=!1;const X=r||Yn(n,"manage_department_zones")||Yn(n,"view_assigned_zones"),we=r?"all":X&&n.departmentCode?`dept:${n.departmentCode}`:`company:${i??""}`,tt=bP;if(tt&&tt.key===we&&Date.now()-tt.at<gee){w(tt.zones);return}return(async()=>{E(!0);try{let Ze=[];r?Ze=(await er.getZonesPaginated(1e4,0)).zones:X&&n.departmentCode?Ze=(await er.getZonesPaginated(1e4,0,void 0,void 0,n.departmentCode)).zones:i&&(Ze=await er.listCompanyTerritories(i)),M||(bP={key:we,at:Date.now(),zones:Ze},w(Ze))}catch(Ze){console.error("Error loading zones:",Ze)}finally{M||E(!1)}})(),()=>{M=!0}},[se,r,n,i]),u.useEffect(()=>{if(!i){A([]);return}let M=!1;return go.listByCompany(i).then(X=>{M||A(X)}).catch(X=>console.error("Error loading hunting zones:",X)),()=>{M=!0}},[i]),u.useEffect(()=>{(r||de)&&lee.getEmergencies().then(_).catch(console.error)},[r,de]);const Zi=i?[i]:st,eo=u.useCallback(async()=>{if(Re){D(!0);try{const[M,X]=await Promise.all([r?vi.getAllPois():vi.getPoisByCompanies(Zi),r?Ll.getAllPaths():Ll.getPathsByCompanies(Zi)]);V(M),H(X)}catch(M){console.error("Error loading POIs/paths:",M)}finally{D(!1)}}},[Re,r,Zi.join(",")]);u.useEffect(()=>{eo()},[eo]);const Cd=M=>{switch(M.status||"pending"){case"pending":return Fo.damagePending;case"inProgress":return Fo.damageInProgress;case"resolved":return Fo.damageResolved;case"closedWithoutAction":return Fo.damageClosed;default:return Fo.damagePending}},ul=M=>{switch(M.status){case"activeSpotted":return Fo.burrowSpotted;case"monitoring":return Fo.burrowMonitoring;case"inactive":return Fo.burrowInactive;default:return Fo.burrowSpotted}},yn=u.useCallback((M,X,we=15)=>{var tt,Ze;(tt=y.current)==null||tt.panTo({lat:M,lng:X}),(Ze=y.current)==null||Ze.setZoom(Math.max(y.current.getZoom()??we,we))},[]),Nd=u.useCallback(M=>{if(F){if(!M.latLng)return;const X={lat:M.latLng.lat(),lng:M.latLng.lng()};O(we=>we&&(we.kind==="poi"?{...we,position:X}:{...we,points:[...we.points,X]}));return}ee(null)},[F]),_d=u.useCallback(M=>{ee({type:"zone",data:M});const X=Nc(M.gpsPoint);X&&yn(X.lat,X.lng,12)},[yn]),dl=u.useCallback(M=>{var tt;ee({type:"plot",data:M});const X=M.gpsPoints||M.gpsPoint||((tt=M.polygons)==null?void 0:tt[0])||[],we=Nc(X);we&&yn(we.lat,we.lng,14)},[yn]),_c=u.useCallback(M=>{ee({type:"damage",data:M}),yn(M.position.latitude,M.position.longitude)},[yn]),Ec=u.useCallback(M=>{ee({type:"burrow",data:M}),yn(M.position.latitude,M.position.longitude)},[yn]),hl=u.useCallback(M=>{ee({type:"emergency",data:M}),yn(M.location.latitude,M.location.longitude,13)},[yn]),fl=u.useCallback(M=>{yn(M.position.latitude,M.position.longitude),ee({type:"poi",data:M})},[yn]),bm=u.useCallback(M=>{ee(null),O({kind:"poi",mode:"edit",poiId:M.id,position:{lat:M.position.latitude,lng:M.position.longitude},name:M.name,description:M.description,type:M.type,companyId:M.companyId===""?$h:M.c
4057ompanyId})},[]),Sc=u.useCallback(M=>{ee({type:"path",data:M});const X=Nc(M.gpsPoints);X&&yn(X.lat,X.lng,13)},[yn]),Bx=u.useCallback(M=>{O(X=>X&&{...X,...M})},[]),Ed=u.useCallback((M="")=>{ee(null),O({kind:"poi",mode:"create",position:null,name:"",description:"",type:"Mirador",companyId:M})},[]),kc=u.useCallback((M="")=>{ee(null),O({kind:"path",points:[],name:"",description:"",activity:"public",companyId:M})},[]);u.useEffect(()=>{const M=e.state;M!=null&&M.createKind&&(M.createKind==="poi"?Ed(M.companyId??""):M.createKind==="path"&&kc(M.companyId??""),t(e.pathname,{replace:!0,state:null}))},[e,t,Ed,kc]);const jm=u.useCallback(async()=>{if(!(!F||!n)&&!(F.kind==="poi"&&!F.position)){G(!0);try{if(F.kind==="poi"){const M={name:F.name,description:F.description,type:F.type,position:{latitude:F.position.lat,longitude:F.position.lng}};F.mode==="edit"&&F.poiId?(await vi.updatePoi(F.poiId,M),re.success("POI mis à jour")):(await vi.createPoi({companyId:F.companyId===$h?"":F.companyId,...M}),re.success("POI créé"))}else await Ll.createPath({name:F.name,description:F.description,activity:F.activity,companyId:F.companyId===$h?"":F.companyId,creatorId:n.id,pseudoCreator:n.pseudo||"admin",gpsPoints:F.points.map(M=>({latitude:M.lat,longitude:M.lng}))}),re.success("Chemin créé");O(null),eo()}catch(M){console.error("Error saving draft:",M),re.error("Erreur","L'enregistrement a échoué.")}finally{G(!1)}}},[F,n,re,eo]),Wx=u.useCallback(async()=>{if(!(!F||F.kind!=="poi"||!F.poiId)&&window.confirm("Supprimer définitivement ce POI ?")){G(!0);try{await vi.deletePoi(F.poiId),re.success("POI supprimé"),O(null),eo()}catch(M){console.error("Error deleting POI:",M),re.error("Erreur","La suppression a échoué.")}finally{G(!1)}}},[F,re,eo]),li=u.useCallback(async M=>{if(window.confirm(`Supprimer définitivement le chemin « ${M.name||"Chemin"} » ?`))try{await Ll.deletePath(M.id),re.success("Chemin supprimé"),ee(null),eo()}catch(X){console.error("Error deleting path:",X),re.error("Erreur","La suppression a échoué.")}},[re,eo]),to=()=>{if(U)switch(U.type){case"plot":t(mt.plot(U.data.id));break;case"damage":t(mt.damage(U.data.id));break;case"burrow":t(mt.burrow(U.data.id));break;case"zone":t(mt.zone(U.data.id));break}},[Ro,Pc]=u.useState(()=>D4()),Cm=u.useCallback(M=>{pee(M),Pc(M)},[]);u.useEffect(()=>{y.current&&Pb(y.current,Ro)},[Ro]);const[Wt,Ic]=u.useState(!1),ml=u.useCallback(M=>{y.current=M,Ic(!0),Pb(M,Ro)},[Ro]),pl=u.useCallback(()=>{if(!y.current)return;const M=y.current.getCenter(),X=y.current.getZoom();M&&X!==void 0&&(zc={lat:M.lat(),lng:M.lng()},Yd=X);const we=y.current.getBounds();we&&le(we)},[]);u.useEffect(()=>{y.current&&(y.current.panTo(B),y.current.setZoom(ve))},[B,ve]);const Nm=r?yee:wee,_m=u.useMemo(()=>{const M={streetViewControl:!1,mapTypeControl:!1,fullscreenControl:!1,mapTypeId:"hybrid",minZoom:Nm,zoomControl:!0,zoomControlOptions:{position:google.maps.ControlPosition.RIGHT_BOTTOM},gestureHandling:"greedy",draggableCursor:q?"crosshair":void 0};return!r&&k&&(M.restriction={latLngBounds:{north:k.north,south:k.south,east:k.east,west:k.west},strictBounds:!1}),M},[Nm,r,k,q]),Hx=u.useMemo(()=>!Bt.zones||!Ue.zones?null:Er.filter(Yt).map(M=>{const X=M.zoneType==="huntingTerritory"?Zc:Wu[M.zoneType]??Zc;return o.jsx(Oh,{paths:M.gpsPoint.map(qi),options:{fillColor:X,fillOpacity:K===M.id?.4:.15,strokeColor:X,strokeWeight:K===M.id?5:3,strokeOpacity:1,clickable:!q},onClick:()=>_d(M)},`zone-${M.id}`)}),[Bt.zones,Ue.zones,Er,Yt,_d,K,q]),qx=u.useMemo(()=>{if(!Bt.plots||!Ue.plots)return null;const M=X=>{var tt;if(Array.isArray(X.gpsPoints)&&X.gpsPoints.length>0)return X.gpsPoints;if(Array.isArray(X.gpsPoint)&&X.gpsPoint.length>0)return X.gpsPoint;const we=(tt=X.polygons)==null?void 0:tt[0];return Array.isArray(we)?we:we!=null&&we.points&&Array.isArray(we.points)?we.points:[]};return a.filter(X=>M(X).length>2).flatMap(X=>{const we=K===X.id,tt={fillColor:we?"#FFFFFF":wh,fillOpacity:we?.6:.4,strokeColor:we?"#FFFFFF":wh,strokeWeight:we?4:3,clickable:!q},Ze=X.polygons??[];if(Ze.length>0)return Ze.map((Ds,km)=>{const Td=Array.isArray(Ds)?Ds:(Ds==null?void 0:Ds.points)??[];return Td.length<3?null:o.jsx(Oh,{paths:Td.map(xl=>({lat:xl.latitude??xl._latitude,lng:xl.longitude??xl._longitude})),options:tt,onClick:()=>dl(X)},`${X.id}_${km}`)}
4057).filter(Boolean);const Ki=M(X);return[o.jsx(Oh,{paths:Ki.map(Ds=>({lat:Ds.latitude??Ds._latitude,lng:Ds.longitude??Ds._longitude})),options:tt,onClick:()=>dl(X)},X.id)]})},[Bt.plots,Ue.plots,a,dl,K,q]),Sd=u.useRef([]);u.useEffect(()=>{const M=y.current;if(!M||!Wt||(Sd.current.forEach(we=>we.setMap(null)),Sd.current=[],!Bt.paths||!Ue.paths))return;const X=Js.filter(un).map(we=>{const tt=new google.maps.Polyline({path:we.gpsPoints.map(qi),strokeColor:fo[we.activity]??Kc,strokeWeight:5,strokeOpacity:1,clickable:!q,zIndex:1,map:M});return tt.addListener("click",()=>Sc(we)),tt});return Sd.current=X,()=>{X.forEach(we=>we.setMap(null))}},[Wt,Bt.paths,Ue.paths,Js,un,q,Sc]);const kd=u.useRef([]);u.useEffect(()=>{const M=y.current;if(!M||!Wt||(kd.current.forEach(we=>we.setMap(null)),kd.current=[],!Bt.huntingZones||!Ue.huntingZones))return;const X=P.filter(we=>{var tt;return(((tt=we.gpsPoint)==null?void 0:tt.length)??0)>=3}).map(we=>new google.maps.Polygon({paths:we.gpsPoint.map(qi),fillColor:vp,fillOpacity:.18,strokeColor:vp,strokeWeight:2.5,strokeOpacity:1,clickable:!1,map:M}));return kd.current=X,()=>{X.forEach(we=>we.setMap(null))}},[Wt,Bt.huntingZones,Ue.huntingZones,P]);const gl=u.useMemo(()=>!Bt.damages||!Ue.damages?null:To.map(M=>{const X=K===M.id;return o.jsx(ho,{position:qi(M.position),icon:{url:Cd(M),scaledSize:new google.maps.Size(X?48:34,X?48:34)},clickable:!q,zIndex:X?999:void 0,onClick:()=>_c(M)},`damage-${M.id}`)}),[Bt.damages,Ue.damages,To,_c,K,q]),Do=u.useMemo(()=>!Bt.burrows||!Ue.burrows?null:Gi.map(M=>{const X=K===M.id;return o.jsx(ho,{position:qi(M.position),icon:{url:ul(M),scaledSize:new google.maps.Size(X?48:34,X?48:34)},clickable:!q,zIndex:X?999:void 0,onClick:()=>Ec(M)},`burrow-${M.id}`)}),[Bt.burrows,Ue.burrows,Gi,Ec,K,q]),Pd=(F==null?void 0:F.kind)==="poi"&&F.mode==="edit"?F.poiId:void 0,Em=u.useMemo(()=>!Bt.pois||!Ue.pois?null:Ao.filter(M=>M.id!==Pd&&xn(M)).map(M=>{const X=K===M.id;return o.jsx(ho,{position:qi(M.position),icon:{url:uo[M.type]??uo.Autre,scaledSize:new google.maps.Size(X?44:32,X?44:32)},clickable:!q,zIndex:X?998:void 0,onClick:()=>fl(M)},`poi-${M.id}`)}),[Bt.pois,Ue.pois,Ao,xn,fl,K,q,Pd]),Sm=u.useMemo(()=>!Bt.emergencies||!Ue.emergencies?null:N.map(M=>o.jsx(ho,{position:{lat:M.location.latitude,lng:M.location.longitude},icon:{url:Fo.emergencySOS,scaledSize:new google.maps.Size(44,44)},clickable:!q,zIndex:1e3,onClick:()=>hl(M)},`emergency-${M.id}`)),[Bt.emergencies,Ue.emergencies,N,hl,q]);if(d)return o.jsx("div",{className:"h-full flex items-center justify-center bg-background",children:o.jsx("div",{className:"animate-spin rounded-full h-10 w-10 border-2 border-primary/20 border-t-primary"})});const ci=he.trim().toLowerCase(),Lo=(...M)=>!ci||M.some(X=>(X??"").toLowerCase().includes(ci)),gs=[];Bt.pois&&Ue.pois&&gs.push({key:"pois",label:"Points dâintérêt",icon:Rn,color:eg,rows:jd.filter(M=>xn(M)&&Lo(M.name,M.type)).map(M=>({id:M.id,title:M.name||"POI",subtitle:M.type,iconUrl:uo[M.type]??uo.Autre,trailing:"chevron",onClick:()=>fl(M)}))}),Bt.paths&&Ue.paths&&gs.push({key:"paths",label:"Chemins",icon:nc,color:Kc,rows:ym.filter(M=>un(M)&&Lo(M.name,Vl[M.activity])).map(M=>({id:M.id,title:M.name||"Chemin",subtitle:`${Vl[M.activity]} · ${M.gpsPoints.length} pts`,dotColor:fo[M.activity]??Kc,onClick:()=>Sc(M)}))}),Bt.zones&&Ue.zones&&gs.push({key:"zones",label:"Territoires",icon:ur,color:Zc,rows:wm.filter(M=>Yt(M)&&Lo(M.name)).map(M=>({id:M.id,title:M.name||"Territoire",subtitle:M.companyId?"Société assignée":"Sans société",Icon:ur,onClick:()=>_d(M)}))}),Bt.huntingZones&&Ue.huntingZones&&gs.push({key:"huntingZones",label:"Zones de battue",icon:ur,color:vp,rows:P.filter(M=>{var X;return(((X=M.gpsPoint)==null?void 0:X.length)??0)>=3&&Lo(M.name)}).map(M=>{var X;return{id:M.id,title:M.name||"Zone de battue",subtitle:((X=M.usages)!=null&&X.length?M.usages:["battue","affut"]).map(we=>we==="affut"?"Affût":"Battue").join(" · "),Icon:ur,onClick:()=>{const we=Nc(M.gpsPoint);we&&yn(we.lat,we.lng,13)}}})}),Bt.damages&&Ue.damages&&gs.push({key:"damages",label:"Dégâts",icon:an,color:Ib,rows:xm.filter(M=>Lo(Hu[M.animalSpecies],M.note)).map(M=>({id:M.id,title:Hu[M.animalSpecies],subtitle:yf[ai(M)],Icon:an,onClick:()=>_c(M)}))}),Bt.burrows&&Ue.burrows&&gs.push({key:"burrows",label:"Terriers",icon:wa,color:Tb,rows:bd.filter(M=>Lo(qu[M.animalType],M.note)).map(M=>({id:M.id,title:qu[M.animalType],subtitle:dx[M.status],Icon:wa,onClick:()=>Ec(M)}))}),Bt.plots&&Ue.plots&&gs.push({key:"plots",label:"Cultures",icon:Si,color:wh,rows:Ux.filter(M=>Lo(M.name)).map(M=>
4057({id:M.id,title:M.name||"Parcelle",subtitle:M.surface!=null?`${M.surface.toFixed(1)} ha`:void 0,Icon:Si,onClick:()=>dl(M)}))}),Bt.emergencies&&Ue.emergencies&&gs.push({key:"emergencies",label:"Alertes SOS",icon:xb,color:Ab,rows:N.filter(M=>Lo(M.userPseudo)).map(M=>({id:M.id,title:M.userPseudo||"SOS",subtitle:"Alerte",Icon:xb,onClick:()=>hl(M)}))});const Tc=gs.reduce((M,X)=>M+X.rows.length,0),no=[{key:"pois",label:"POI",color:eg,count:Ao.length},{key:"paths",label:"Chemins",color:Kc,count:Js.length},{key:"huntingZones",label:"Zones de battue",color:vp,count:P.length},{key:"zones",label:"Zones",color:Zc,count:Er.length},{key:"damages",label:"Dégâts",color:Ib,count:To.length},{key:"burrows",label:"Terriers",color:Tb,count:Gi.length},{key:"plots",label:"Cultures",color:wh,count:a.length},{key:"emergencies",label:"SOS",color:Ab,count:N.length}].filter(M=>Bt[M.key]),Gx=j||W,vl=[];if(Bt.pois&&Ue.pois){const M=Array.from(new Set(Ao.map(X=>X.type)));M.length>1&&vl.push({layer:"pois",color:eg,options:ND.filter(X=>M.includes(X)).map(X=>({value:X,label:X}))})}if(Bt.paths&&Ue.paths){const M=Array.from(new Set(Js.map(X=>X.activity)));M.length>1&&vl.push({layer:"paths",color:Kc,options:M.map(X=>({value:X,label:Vl[X]??X}))})}if(Bt.zones&&Ue.zones&&Er.length>0){const M=Array.from(new Set(Er.map(X=>X.zoneType))).filter(Boolean);vl.push({layer:"zones",color:Zc,options:[...M.length>1?M.map(X=>({value:X,label:qa[X]??X})):[],{value:"assigned",label:"Assignées"},{value:"unassigned",label:"Non assignées"}]})}const Mo=vl.length>0,Ac=Te.pois.size+Te.paths.size+Te.zones.size>0,Id=M=>o.jsxs(M1,{children:[o.jsx(O1,{asChild:!0,children:M}),o.jsxs(F1,{align:"end",className:"w-60",children:[oe&&o.jsxs(Ul,{className:"gap-2.5 cursor-pointer",disabled:!En,onSelect:()=>Ed(),children:[o.jsx(Rn,{className:"h-4 w-4 text-primary"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-medium",children:"Point dâintérêt"}),o.jsx("p",{className:"text-[11px] text-muted-foreground",children:En?"Mirador, parking, agrainoirâ¦":"Réservé aux abonnés Premium"})]})]}),De&&o.jsxs(Ul,{className:"gap-2.5 cursor-pointer",onSelect:()=>kc(),children:[o.jsx(nc,{className:"h-4 w-4 text-primary"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-medium",children:"Chemin"}),o.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Tracé dâun parcours"})]})]}),s&&o.jsxs(Ul,{className:"gap-2.5 cursor-pointer",onSelect:()=>t(xe.zoneNew),children:[o.jsx(ur,{className:"h-4 w-4 text-primary"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-medium",children:"Zone"}),o.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Territoire, réserve, zone humide⦠ou import KML"})]})]})]})]});return o.jsxs("div",{className:"h-full w-full relative overflow-hidden",children:[o.jsxs(Qs,{mapContainerStyle:{width:"100%",height:"100%"},center:B,zoom:ve,onClick:Nd,onLoad:ml,onIdle:pl,options:_m,children:[Hx,qx,gl,Do,Em,Sm,(F==null?void 0:F.kind)==="poi"&&F.position&&o.jsx(ho,{position:F.position,draggable:!0,zIndex:1002,icon:{url:uo[F.type]??uo.Autre,scaledSize:new google.maps.Size(46,46)},onDragEnd:M=>M.latLng&&O(X=>X&&X.kind==="poi"?{...X,position:{lat:M.latLng.lat(),lng:M.latLng.lng()}}:X)}),(F==null?void 0:F.kind)==="path"&&o.jsxs(o.Fragment,{children:[F.points.length>=2&&o.jsx(qD,{path:F.points,options:{strokeColor:fo[F.activity],strokeWeight:5,strokeOpacity:1,clickable:!1,zIndex:6}}),F.points.map((M,X)=>o.jsx(ho,{position:M,draggable:!0,zIndex:1002,title:`Point ${X+1} : cliquez pour supprimer`,icon:{path:google.maps.SymbolPath.CIRCLE,scale:6,fillColor:fo[F.activity],fillOpacity:1,strokeColor:"#FFFFFF",strokeWeight:2},onClick:()=>O(we=>we&&we.kind==="path"?{...we,points:we.points.filter((tt,Ze)=>Ze!==X)}:we),onDragEnd:we=>we.latLng&&O(tt=>tt&&tt.kind==="path"?{...tt,points:tt.points.map((Ze,Ki)=>Ki===X?{lat:we.latLng.lat(),lng:we.latLng.lng()}:Ze)}:tt)},`draft-pt-${X}`))]})]}),no.length>0&&o.jsx("div",{className:"cc-noscroll absolute top-3 left-3 z-20 flex items-center gap-2 overflow-x-auto",style:{right:v&&Ct?172:12},children:no.map(M=>{const X=Ue[M.key];return o.jsxs("button",{onClick:()=>vt(M.key),title:X?"Masquer ce calque":"Afficher ce calque",className:`h-9 pl-2.5 pr-2 roun
4057ded-full border flex items-center gap-2 text-[13px] font-semibold whitespace-nowrap flex-shrink-0 shadow-sm transition-all ${X?"text-white border-transparent":"bg-card border-border text-foreground/80 hover:bg-muted"}`,style:X?{backgroundColor:M.color}:void 0,children:[o.jsx("span",{className:"h-2.5 w-2.5 rounded-full flex-shrink-0",style:{backgroundColor:X?"#ffffff":M.color}}),M.label,o.jsx("span",{className:`rounded-full px-1.5 text-[11px] font-bold leading-[18px] ${X?"bg-white/25 text-white":"bg-muted text-muted-foreground"}`,children:M.count})]},M.key)})}),Mo&&o.jsxs("div",{className:"cc-noscroll absolute left-3 z-20 flex items-center gap-2 overflow-x-auto",style:{top:56,right:v&&Ct?172:12},children:[o.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] font-semibold text-muted-foreground bg-card/90 border border-border rounded-lg px-2 py-1 flex-shrink-0 shadow-sm",children:[o.jsx(d1,{className:"h-3 w-3"})," Filtrer"]}),vl.flatMap(M=>M.options.map(X=>{const we=Te[M.layer].has(X.value);return o.jsxs("button",{onClick:()=>Ut(M.layer,X.value),className:`h-8 px-3 rounded-full border text-[12px] font-semibold whitespace-nowrap flex items-center gap-1.5 flex-shrink-0 shadow-sm transition-all ${we?"text-white border-transparent":"bg-card border-border text-foreground/80 hover:bg-muted"}`,style:we?{backgroundColor:M.color}:void 0,children:[o.jsx("span",{className:"h-2 w-2 rounded-full flex-shrink-0",style:{backgroundColor:we?"#ffffff":M.color}}),X.label]},M.layer+X.value)})),Ac&&o.jsx("button",{onClick:cn,className:"h-8 px-2.5 rounded-full text-[12px] font-semibold text-muted-foreground underline flex-shrink-0 hover:text-foreground whitespace-nowrap",children:"Effacer"})]}),Ct&&v&&o.jsx("div",{className:"absolute top-3 right-3 z-30",children:Id(o.jsxs("button",{className:"h-11 px-5 rounded-xl bg-primary text-primary-foreground flex items-center gap-2 text-[15px] font-bold hover:bg-primary/90 transition-colors shadow-xl ring-1 ring-black/5",children:[o.jsx(hr,{className:"h-5 w-5"})," Ajouter"]}))}),o.jsx("div",{className:`absolute z-[26] flex gap-1 p-1 rounded-xl bg-card/95 backdrop-blur border border-border shadow-lg ${v?"left-1/2 -translate-x-1/2 bottom-4":""}`,style:v?void 0:{left:12,top:Mo?100:60},children:[{id:"plan",label:"Plan"},{id:"satellite",label:"Satellite"},{id:"ign",label:"IGN"}].map(M=>o.jsx("button",{onClick:()=>Cm(M.id),className:`h-8 px-3 rounded-lg text-[12.5px] font-semibold transition-colors ${Ro===M.id?"bg-primary text-primary-foreground shadow-sm":"text-foreground/70 hover:bg-muted"}`,children:M.label},M.id))}),(v?ot:!F)&&o.jsxs("div",{className:v?"absolute left-3 z-20 w-[384px] flex flex-col rounded-2xl bg-card border border-border shadow-2xl overflow-hidden":"absolute bottom-0 left-0 right-0 z-20 flex flex-col rounded-t-2xl bg-card border-t border-border shadow-2xl overflow-hidden transition-[height] duration-300 ease-out",style:v?{top:Mo?100:64,maxHeight:`calc(100% - ${(Mo?100:64)+16}px)`}:{height:je?"72vh":"auto",maxHeight:"85vh"},children:[!v&&o.jsx("button",{onClick:()=>Ve(M=>!M),className:"w-full flex flex-col items-center pt-2.5 pb-1.5 flex-shrink-0","aria-label":je?"Réduire la liste":"Agrandir la liste",children:o.jsx("span",{className:"h-1.5 w-11 rounded-full bg-border"})}),o.jsxs("div",{className:"px-4 pt-1.5 pb-2 flex items-center justify-between gap-2 flex-shrink-0",children:[o.jsxs("button",{type:"button",onClick:v?void 0:()=>Ve(M=>!M),className:`flex items-center gap-2 min-w-0 text-left ${v?"cursor-default":"cursor-pointer"}`,children:[o.jsx("div",{className:"h-8 w-8 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:o.jsx(iY,{className:"h-4 w-4 text-primary"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("h2",{className:"text-sm font-bold text-foreground font-heading leading-tight",children:"Explorer la carte"}),o.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight",children:Gx?"Chargementâ¦":`${Tc} résultat${Tc>1?"s":""} visible${Tc>1?"s":""}`})]}),!v&&o.jsx(jf,{className:`h-4 w-4 text-muted-foreground flex-shrink-0 transition-transform ${je?"rotate-180":""}`})]}),Ct&&!v&&Id(o.jsxs("button",{className:"h-9 px-3 rounded-xl bg-primary text-primary-foreground flex items-center gap-1.5 text-sm font-semibold hover:bg-primary/90 transition-colors flex-shrink-0",children:[o.jsx(hr,{className:"h-4 w-4"})," Ajouter"]})),v&&o.jsx("button",{onClick:()=>Se(!1),title:"Réduire le panneau",className:"h-8 w-8 flex items-center justify-center rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted flex-shrink-0",children:o.jsx(br,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"px-4 pb-2.5 flex-shrink-0",children:o.jsxs("div",{className:"relative",children:[o.jsx(Ws,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}
4057),o.jsx("input",{value:he,onChange:M=>J(M.target.value),placeholder:"Rechercher un POI, un chemin, un dégâtâ¦",className:"w-full h-10 pl-9 pr-9 rounded-xl bg-muted border border-transparent focus:border-primary focus:bg-card outline-none text-sm transition-colors"}),he&&o.jsx("button",{onClick:()=>J(""),className:"absolute right-2.5 top-1/2 -translate-y-1/2 h-6 w-6 rounded-full hover:bg-border flex items-center justify-center",children:o.jsx(br,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})}),(v||je)&&o.jsx("div",{className:"flex-1 overflow-y-auto border-t border-border min-h-0",children:gs.length===0?o.jsxs("div",{className:"py-14 text-center text-muted-foreground px-6",children:[o.jsx(Ws,{className:"h-7 w-7 mx-auto mb-3 text-muted-foreground/30"}),o.jsx("p",{className:"text-sm",children:"Aucun calque actif"}),o.jsx("p",{className:"text-xs text-muted-foreground/70 mt-1",children:"Activez un calque ci-dessus pour voir son contenu."})]}):gs.map(M=>o.jsxs("div",{className:"border-b border-border/60 last:border-b-0",children:[o.jsxs("button",{onClick:()=>me(M.key),className:"w-full sticky top-0 z-10 bg-card/95 backdrop-blur px-4 py-2.5 flex items-center justify-between hover:bg-muted/50 transition-colors",children:[o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"h-2.5 w-2.5 rounded-sm",style:{backgroundColor:M.color}}),o.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-foreground",children:M.label}),o.jsx("span",{className:"text-xs text-muted-foreground",children:M.rows.length})]}),o.jsx(jf,{className:`h-4 w-4 text-muted-foreground transition-transform ${Ye[M.key]?"":"-rotate-90"}`})]}),Ye[M.key]&&o.jsx("div",{className:"px-2 pb-2 space-y-0.5",children:M.rows.length>0?M.rows.map(X=>o.jsx(Cee,{row:X,color:M.color,active:K===X.id,onHover:ue},X.id)):o.jsx("p",{className:"px-3 py-2.5 text-xs text-muted-foreground",children:he?"Aucun résultat pour cette recherche.":"Aucun élément dans cette zone."})})]},M.key))})]}),v&&!ot&&o.jsxs("button",{onClick:()=>Se(!0),className:"absolute left-3 z-20 h-11 px-4 flex items-center gap-2 rounded-xl bg-card border border-border shadow-xl text-sm font-semibold text-foreground hover:bg-muted transition-colors",style:{top:Mo?100:64},children:[o.jsx(qL,{className:"h-4 w-4"})," Voir la liste",o.jsx("span",{className:"rounded-full bg-muted px-1.5 text-[11px] font-bold text-muted-foreground",children:Tc})]}),U&&!F&&o.jsx(Nee,{item:U,isWide:v,onClose:()=>ee(null),onViewDetails:to,getDamageStatus:ai,onEditPoi:U.type==="poi"&&Zn(U.data)?()=>bm(U.data):void 0,onDelete:U.type==="path"&&_r(U.data)?()=>li(U.data):void 0}),F&&o.jsx(fee,{draft:F,companies:I,companiesLoading:S,allowNoCompany:qe,canChooseActivity:r,saving:Y,onChange:Bx,onClearPoints:()=>O(M=>M&&M.kind==="path"?{...M,points:[]}:M),onCancel:()=>O(null),onSave:jm,onDelete:F.kind==="poi"&&F.mode==="edit"?Wx:void 0})]})}function Cee({row:t,color:e,active:n,onHover:r}){const s=t.trailing==="edit"?fd:nr;return o.jsxs("button",{onClick:t.onClick,onMouseEnter:()=>r(t.id),onMouseLeave:()=>r(null),className:`w-full flex items-center gap-3 px-2.5 py-2 rounded-xl text-left transition-colors ${n?"bg-primary/10":"hover:bg-muted"}`,children:[o.jsx("span",{className:"h-9 w-9 rounded-lg flex items-center justify-center flex-shrink-0",style:{backgroundColor:`${e}1A`},children:t.iconUrl?o.jsx("img",{src:t.iconUrl,alt:"",className:"h-5 w-5 object-contain"}):t.dotColor?o.jsx("span",{className:"h-3.5 w-3.5 rounded-full",style:{backgroundColor:t.dotColor}}):t.Icon?o.jsx(t.Icon,{className:"h-4 w-4",style:{color:e}}):null}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:"block font-medium text-sm text-foreground truncate",children:t.title}),t.subtitle&&o.jsx("span",{className:"block text-xs text-muted-foreground truncate",children:t.subtitle})]}),o.jsx(s,{className:"h-4 w-4 text-muted-foreground/50 flex-shrink-0"})]})}function Nee({item:t,isWide:e,onClose:n,onViewDetails:r,getDamageStatus:s,onEditPoi:i,onDelete:a}){var g,v,x;const l=t.type==="damage"?t.data.photoUrls||[]:t.type==="burrow"?t.data.photoUrls||[]:[],c={plot:{icon:Si,label:"Zone de culture",color:wh},damage:{icon:an,label:"Dégât signalé",color:Ib},burrow:{icon:wa,label:"Terrier",color:Tb},zone:{icon:ur,label:"Territoire de chasse",color:Zc},emergency:{icon:xb,label:"ALERTE SOS",color:Ab},poi:{icon:Rn,label:"Point dâintérêt",color:eg},path:{icon:nc,label:"Chemin",color:Kc}},d=c[t.type]||c.plot,h=d.icon,f=e?"absolute top-0 right-0 bottom-0 z-40 w-[404px] max-w-[92%] animate-in slide-in-from-right-8 duration-200":"absolute inset-x-0 bottom-0 z-40 animate-in slide-in-from-bottom-8 duration-200",p=e?"h-full flex flex-col bg-card shadow-2xl border-l border-border overflow-hidden":"flex flex-col bg-card rounded-t-2xl shadow-2xl border-t border-border overflow-hidden max-h-[85vh]";return o.jsx("div",{className:f,children:o.jsxs("div",{className:p,children:[!e&&o.jsx("div",{className:"w-full flex justify-center pt-2.5 pb-0.5 flex-shrink-0",children:o.jsx("span",{className:"h-1.5 w-11 rounded-full bg-border"})}),l.length>0&&o.jsxs("div",{className:"relative h-40 w-full overflow-hidden flex-shrink-0",children:[o.jsx("img",{src:l[0],alt:"",className:"w-full h-full object-cover"}),o.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/50 via-trans
4057parent to-transparent"}),o.jsx("button",{className:"absolute top-2.5 right-2.5 h-8 w-8 rounded-full bg-black/40 backdrop-blur-sm flex items-center justify-center hover:bg-black/60 transition-colors",onClick:n,children:o.jsx(br,{className:"h-4 w-4 text-white"})})]}),o.jsxs("div",{className:"p-4 relative flex-1 overflow-y-auto",children:[l.length===0&&o.jsx("button",{className:"absolute top-3 right-3 h-7 w-7 rounded-full bg-muted flex items-center justify-center hover:bg-muted/80 transition-colors",onClick:n,children:o.jsx(br,{className:"h-3.5 w-3.5 text-muted-foreground"})}),o.jsxs("div",{className:"flex items-center gap-2 mb-2 pr-8",children:[o.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[11px] font-semibold",style:{backgroundColor:`${d.color}15`,color:d.color},children:[o.jsx(h,{className:"h-3 w-3"}),d.label]}),t.type==="damage"&&o.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:yf[s(t.data)]}),t.type==="burrow"&&o.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:dx[t.data.status]})]}),t.type==="plot"&&o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-base font-bold text-foreground font-heading",children:t.data.name}),o.jsxs("p",{className:"text-sm text-muted-foreground mt-0.5",children:[(g=t.data.surface)==null?void 0:g.toFixed(1)," ha"]})]}),t.type==="damage"&&o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-base font-bold text-foreground font-heading",children:Hu[t.data.animalSpecies]}),t.data.note&&o.jsx("p",{className:"text-sm text-muted-foreground mt-0.5 line-clamp-2",children:t.data.note})]}),t.type==="burrow"&&o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-base font-bold text-foreground font-heading",children:qu[t.data.animalType]}),t.data.note&&o.jsx("p",{className:"text-sm text-muted-foreground mt-0.5 line-clamp-2",children:t.data.note})]}),t.type==="poi"&&o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-base font-bold text-foreground font-heading",children:t.data.name}),o.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:t.data.type}),t.data.description&&o.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:t.data.description}),i&&o.jsxs(Z,{variant:"outline",className:"w-full mt-3 rounded-lg",onClick:i,children:[o.jsx(fd,{className:"h-4 w-4 mr-1.5"}),"Modifier le POI"]})]}),t.type==="path"&&o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-base font-bold text-foreground font-heading",children:t.data.name}),o.jsxs("p",{className:"text-sm text-muted-foreground mt-0.5",children:[Vl[t.data.activity]," · ",t.data.gpsPoints.length," points"]}),a&&o.jsxs(Z,{variant:"outline",className:"w-full mt-3 rounded-lg text-destructive hover:text-destructive hover:bg-destructive/10",onClick:a,children:[o.jsx(Vt,{className:"h-4 w-4 mr-1.5"}),"Supprimer le chemin"]})]}),t.type==="zone"&&o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-base font-bold text-foreground font-heading",children:t.data.name}),o.jsxs("div",{className:"flex flex-wrap gap-2 mt-2",children:[o.jsxs("div",{className:`flex items-center gap-1.5 text-xs px-2 py-1 rounded-full ${t.data.companyId?"bg-green-500/15 text-green-600":"bg-amber-500/15 text-amber-600"}`,children:[o.jsx(qn,{className:"h-3 w-3"}),t.data.companyId?"Société assignée":"Pas de société"]}),o.jsxs("div",{className:`flex items-center gap-1.5 text-xs px-2 py-1 rounded-full ${(v=t.data.louvetierEmails)!=null&&v.length?"bg-green-500/15 text-green-600":"bg-amber-500/15 text-amber-600"}`,children:[o.jsx(cr,{className:"h-3 w-3"}),(x=t.data.louvetierEmails)!=null&&x.length?`${t.data.louvetierEmails.length} louvetier(s)`:"Pas de louvetier"]})]})]}),t.type==="emergency"&&o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-base font-bold text-red-500",children:t.data.userPseudo}),o.jsxs("div",{className:"mt-2 space-y-1.5",children:[t.data.userEmail&&o.jsxs("a",{href:`mailto:${t.data.userEmail}`,className:"flex items-center gap-2 text-sm text-foreground/80 hover:text-primary",children:[o.jsx(rs,{className:"h-3.5 w-3.5"}),t.data.userEmail]}),t.data.userPhone&&o.jsxs("a",{href:`tel:${t.data.userPhone}
4057`,className:"flex items-center gap-2 text-sm text-foreground/80 hover:text-primary",children:[o.jsx(rm,{className:"h-3.5 w-3.5"}),t.data.userPhone]})]}),o.jsxs("a",{href:`https://www.google.com/maps?q=${t.data.location.latitude},${t.data.location.longitude}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 mt-3 px-4 py-2 bg-red-500 text-white rounded-lg hover:bg-red-600 transition-colors text-sm font-medium",children:[o.jsx(xx,{className:"h-3.5 w-3.5"}),"Google Maps"]})]}),(t.type==="plot"||t.type==="damage"||t.type==="burrow"||t.type==="zone")&&o.jsxs(Z,{className:"w-full mt-3 rounded-lg",onClick:r,children:["Voir les détails",o.jsx(nr,{className:"h-4 w-4 ml-1"})]})]})]})})}function ei(t,e=300){const[n,r]=u.useState(t);return u.useEffect(()=>{const s=setTimeout(()=>{r(t)},e);return()=>{clearTimeout(s)}},[t,e]),n}function ke({className:t,...e}){return o.jsx("div",{"data-slot":"card",className:Oe("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border",t),...e})}function Qt({className:t,...e}){return o.jsx("div",{"data-slot":"card-header",className:Oe("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 pt-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",t),...e})}function Xt({className:t,...e}){return o.jsx("h4",{"data-slot":"card-title",className:Oe("leading-none",t),...e})}function la({className:t,...e}){return o.jsx("p",{"data-slot":"card-description",className:Oe("text-muted-foreground",t),...e})}function Pe({className:t,...e}){return o.jsx("div",{"data-slot":"card-content",className:Oe("px-6 [&:last-child]:pb-6",t),...e})}function Ya({className:t,...e}){return o.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:o.jsx("table",{"data-slot":"table",className:Oe("w-full caption-bottom text-sm",t),...e})})}function Qa({className:t,...e}){return o.jsx("thead",{"data-slot":"table-header",className:Oe("[&_tr]:border-b",t),...e})}function Xa({className:t,...e}){return o.jsx("tbody",{"data-slot":"table-body",className:Oe("[&_tr:last-child]:border-0",t),...e})}function Fr({className:t,...e}){return o.jsx("tr",{"data-slot":"table-row",className:Oe("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",t),...e})}function dt({className:t,...e}){return o.jsx("th",{"data-slot":"table-head",className:Oe("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...e})}function ht({className:t,...e}){return o.jsx("td",{"data-slot":"table-cell",className:Oe("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...e})}var L4="AlertDialog",[_ee]=Rs(L4,[jL]),Hi=jL(),M4=t=>{const{__scopeAlertDialog:e,...n}=t,r=Hi(e);return o.jsx(o1,{...r,...n,modal:!0})};M4.displayName=L4;var Eee="AlertDialogTrigger",O4=u.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...r}=t,s=Hi(n);return o.jsx(AK,{...s,...r,ref:e})});O4.displayName=Eee;var See="AlertDialogPortal",F4=t=>{const{__scopeAlertDialog:e,...n}=t,r=Hi(e);return o.jsx(i1,{...r,...n})};F4.displayName=See;var kee="AlertDialogOverlay",z4=u.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...r}=t,s=Hi(n);return o.jsx(a1,{...s,...r,ref:e})});z4.displayName=kee;var Eu="AlertDialogContent",[Pee,Iee]=_ee(Eu),Tee=IG("AlertDialogContent"),$4=u.forwardRef((t,e)=>{const{__scopeAlertDialog:n,children:r,...s}=t,i=Hi(n),a=u.useRef(null),l=At(e,a),c=u.useRef(null);return o.jsx(kK,{contentName:Eu,titleName:V4,docsSlug:"alert-dialog",children:o.jsx(Pee,{scope:n,cancelRef:c,children:o.jsxs(l1,{role:"alertdialog",...i,...s,ref:l,onOpenAutoFocus:Le(s.onOpenAutoFocus,d=>{var h;d.preventDefault(),(h=c.current)==null||h.focus({preventScroll:!0})}),onPointerDownOutside:d=>d.preventDefault(),onInteractOutside:d=>d.preventDefault(),children:[o.jsx(Tee,{children:r}),o.jsx(Ree,{contentRef:a})]})})})});$4.displayName=Eu;var V4="AlertDialogTitle",U4=u.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...r}=t,s=Hi(n);return o.jsx(c1,{...s,...r,ref:e})});U4.displayName=V4;var B4="AlertDialogDescription",W4=u.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...r}=t,s=Hi(n);return o.jsx(FL,{...s,...r,ref:e})});W4.displayName=B4;var Aee="AlertDialogAction",H4=u.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...r}=t,s=Hi(n);return o.jsx(vx,{...s,...r,ref:e})});H4.displayName=Aee;var q4="AlertDialogCancel",G4=u.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...r}=t,{cancelRef:s}=Iee(q4,n),i=Hi(n),a=At(e,s);return o.jsx(vx,{...i,...r,ref:a})});G4.displayName=q4;var Ree=({contentRef:t})=>{const e=`\`${Eu}\` requires a description for the component to be accessible for screen reader users. 4058
4059You can add a description to the \`${Eu}\` by passing a \`${B4}\` component as a child, which also benefits sighted users by adding visible context to the dialog. 4060 4061Alternatively, 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 \`${Eu}\`. 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. 4062 4063For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return u.useEffect(()=>{var r;document.getElementById((r=t.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(e)},[e,t]),null},Dee=M4,Lee=O4,Mee=F4,Oee=z4,Fee=$4,zee=H4,$ee=G4,Vee=U4,Uee=W4;function Dn({...t}){return o.jsx(Dee,{"data-slot":"alert-dialog",...t})}function cm({...t}){return o.jsx(Lee,{"data-slot":"alert-dialog-trigger",...t})}function Bee({...t}){return o.jsx(Mee,{"data-slot":"alert-dialog-portal",...t})}function Wee({className:t,...e}){return o.jsx(Oee,{"data-slot":"alert-dialog-overlay",className:Oe("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...e})}function Ln({className:t,...e}){return o.jsxs(Bee,{children:[o.jsx(Wee,{}),o.jsx(Fee,{"data-slot":"alert-dialog-content",className:Oe("bg-background 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 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",t),...e})]})}function Mn({className:t,...e}){return o.jsx("div",{"data-slot":"alert-dialog-header",className:Oe("flex flex-col gap-2 text-center sm:text-left",t),...e})}function On({className:t,...e}){return o.jsx("div",{"data-slot":"alert-dialog-footer",className:Oe("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function Fn({className:t,...e}){return o.jsx(Vee,{"data-slot":"alert-dialog-title",className:Oe("text-lg font-semibold",t),...e})}function zn({className:t,...e}){return o.jsx(Uee,{"data-slot":"alert-dialog-description",className:Oe("text-muted-foreground text-sm",t),...e})}function $n({className:t,...e}){return o.jsx(zee,{className:Oe(bf(),t),...e})}function Vn({className:t,...e}){return o.jsx($ee,{className:Oe(bf({variant:"outline"}),t),...e})}var Ax="Checkbox",[Hee]=Rs(Ax),[qee,z1]=Hee(Ax);function Gee(t){const{__scopeCheckbox:e,checked:n,children:r,defaultChecked:s,disabled:i,form:a,name:l,onCheckedChange:c,required:d,value:h="on",internal_do_not_use_render:f}=t,[p,g]=Co({prop:n,defaultProp:s??!1,onChange:c,caller:Ax}),[v,x]=u.useState(null),[y,b]=u.useState(null),w=u.useRef(!1),j=v?!!a||!!v.closest("form"):!0,E={checked:p,disabled:i,setChecked:g,control:v,setControl:x,name:l,form:a,value:h,hasConsumerStoppedPropagationRef:w,required:d,defaultChecked:La(s)?!1:s,isFormControl:j,bubbleInput:y,setBubbleInput:b};return o.jsx(qee,{scope:e,...E,children:Zee(f)?f(E):r})}var Z4="CheckboxTrigger",K4=u.forwardRef(({__scopeCheckbox:t,onKeyDown:e,onClick:n,...r},s)=>{const{control:i,value:a,disabled:l,checked:c,required:d,setControl:h,setChecked:f,hasConsumerStoppedPropagationRef:p,isFormControl:g,bubbleInput:v}=z1(Z4,t),x=At(s,h),y=u.useRef(c);return u.useEffect(()=>{const b=i==null?void 0:i.form;if(b){const w=()=>f(y.current);return b.addEventListener("reset",w),()=>b.removeEventListener("reset",w)}},[i,f]),o.jsx(Je.button,{type:"button",role:"checkbox","aria-checked":La(c)?"mixed":c,"aria-required":d,"data-state":tO(c),"data-disabled":l?"":void 0,disabled:l,value:a,...r,ref:x,onKeyDown:Le(e,b=>{b.key==="Enter"&&b.preventDefault()}),onClick:Le(n,b=>{f(w=>La(w)?!0:!w),v&&g&&(p.current=b.isPropagationStopped(),p.current||b.stopPropagation())})})});K4.displayName=Z4;var Y4=u.forwardRef((t,e)=>{const{__scopeCheckbox:n,name:r,checked:s,defaultChecked:i,required:a,disabled:l,value:c,onCheckedChange:d,form:h,...f}=t;return o.jsx(Gee,{__scopeCheckbox:n,checked:s,defaultChecked:i,disabled:l,required:a,onCheckedChange:d,name:r,form:h,value:c,internal_do_not_use_render:({isFormControl:p})=>o.jsxs(o.Fragment,{children:[o.jsx(K4,{...f,ref:e,__scopeCheckbox:n}),p&&o.jsx(eO,{__scopeCheckbox:n})]})})});Y4.displayName=Ax;var Q4="CheckboxIndicator",X4=u.forwardRef((t,e)=>{const{__scopeCheckbox:n,forceMount:r,...s}=t,i=z1(Q4,n);return o.jsx(Xs,{present:r||La(i.checked)||i.checked===!0,children:o.jsx(Je.span,{"data-state":tO(i.checked),"data-disabled":i.disabled?"":void 0,...s,ref:e,style:{pointerEvents:"none",...t.style}})})});X4.displayName=Q4;var J4="CheckboxBubbleInput",eO=u.forwardRef(({__scopeCheckbox:t,...e},n)=>{const{control:r,hasConsumerStoppedPropagationRef:s,checked:i,defaultChecked:a,required:l,disabled:c,name:d,value:h,form:f,bubbleInput:p,setBubbleInput:g}=z1(J4,t),v=At(n,g),x=xM(i),y=lM(r);u.useEffect(()=>{const w=p;if(!w)return;const j=window.HTMLInputElement.prototype,P=Object.getOwnPropertyDescriptor(j,"checked").set,A=!s.current;if(x!==i&&P){const N=new Event("click",{bubbles:A});w.indeterminate=La(i),P.call(w,La(i)?!1:i),w.dispatchEvent(N)}},[p,x,i,s]);const b=u.useRef(La(i)?!1:i);return o.jsx(Je.input,{type:"checkbox","aria-hidden":!0,defaultChecked:a??b.current,required:l,disabled:c,name:d,value:h,form:f,...e,tabIndex:-1,ref:v,style:{...e.style,...y,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});eO.displayName=J4;function Zee(t){return typeof t=="function"}function La(t){return t==="indeterminate"}function tO(t){return La(t)?"indeterminate":t?"checked":"unchecked"}function Ks({className:t,...e}){const n=e.checked==="indeterminate";return o.jsx(Y4,{"data-slot":"checkbox",className:Oe("peer border border-border bg-card data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=checked]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground data-[state=indeterminate]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...e,children:o.jsx(X4,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:n?o.jsx(KK,{className:"size-3.5"}):o.jsx(Xn,{className:"size-3.5"})})})}const Qd=20,Kee={all:"Toutes les zones",without_company:"Sans société",without_louvetier:"Sans louvetier",without_both:"Sans société ni louvetier"};function Yee(){const{user:t,isSuperAdmin:e,canCreateZones:n}=nn(),r=t?JW(t):!1,s=Ft(),[i,a]=u.useState({zones:[],totalCount:0,offset:0,hasMore:!1}),[l,c]=u.useState(!0),[d,h]=u.useState(""),[f,p]=u.useState("all"),[g,v]=u.useState(0),[x,y]=u.useState([]),[b,w]=u.useState("all"),[j,E]=u.useState("all"),[P,A]=u.useState(new Set),[N,_]=u.useState(null),[k,L]=u.useState(!1),[I,S]=u.useState(!1),T=ei(d,300),V=T.length>=3?T:"";u.useEffect(()=>{e&&As().then(y)},[e]);const $=u.useCallback(async()=>{c(!0);try{const U=e&&b!=="all"?parseInt(b):void 0,ee=await er.getZonesPaginated(Qd,g*Qd,V||void 0,f!=="all"?f:void 0,U,j!=="all"?[j]:void 0);a(ee)}catch(U){console.error("Error loading zones:",U)}finally{c(!1)}},[g,V,f,b,e,j]);u.useEffect(()=>{$()},[$]),u.useEffect(()=>
4063{v(0)},[V]);const H=U=>{p(U),v(0)},W=U=>{w(U),v(0)},D=async()=>{if(N){L(!0);try{await er.deleteZone(N.id),s.success("Zone supprimée"),_(null),$()}catch(U){console.error("Error deleting zone:",U),s.error(U.message||"Erreur lors de la suppression")}finally{L(!1)}}},F=async()=>{if(P.size!==0){L(!0);try{const{deleted:U}=await er.deleteZonesBulk({zoneIds:[...P]});s.success(`${U} zone(s) supprimée(s)`),A(new Set),S(!1),$()}catch(U){console.error("Error bulk deleting zones:",U),s.error(U.message||"Erreur lors de la suppression")}finally{L(!1)}}},O=i.zones.map(U=>U.id),Y=O.length>0&&O.every(U=>P.has(U)),G=()=>{A(U=>{const ee=new Set(U);return Y?O.forEach(K=>ee.delete(K)):O.forEach(K=>ee.add(K)),ee})},q=U=>{A(ee=>{const K=new Set(ee);return K.has(U)?K.delete(U):K.add(U),K})},re=Math.ceil(i.totalCount/Qd);return o.jsxs("div",{className:"p-4 md:p-8 space-y-5 md:space-y-6 max-w-[1400px]",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-foreground font-heading",children:"Gestion des zones"}),o.jsx("p",{className:"text-muted-foreground mt-1",children:e?"Territoires et zones d'information":`Territoires et zones d'information du département ${t==null?void 0:t.departmentLabel} (${t==null?void 0:t.departmentCode})`})]}
4063),n&&o.jsx(Fa,{to:xe.zoneNew,children:o.jsxs(Z,{className:"shadow-sm",children:[o.jsx(hr,{className:"h-4 w-4 mr-2"}),"Nouvelle zone"]})})]}),o.jsx(ke,{children:o.jsx(Pe,{className:"pt-6",children:o.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[o.jsxs("div",{className:"relative flex-1 min-w-[250px] max-w-md",children:[o.jsx(Ws,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground/60"}),o.jsx(Ne,{placeholder:"Rechercher une zone...",value:d,onChange:U=>h(U.target.value),className:"pl-10"})]}),e&&x.length>0&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Rn,{className:"h-4 w-4 text-muted-foreground/60"}),o.jsxs(_t,{value:b,onValueChange:W,children:[o.jsx(St,{className:"w-[250px]",children:o.jsx(Et,{placeholder:"Tous les départements"})}),o.jsxs(kt,{className:"max-h-[300px]",children:[o.jsx(Ke,{value:"all",children:"Tous les départements"}),x.map(U=>o.jsxs(Ke,{value:U.code,children:[U.code," - ",U.nom]},U.code))]})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ur,{className:"h-4 w-4 text-muted-foreground/60"}),o.jsxs(_t,{value:j,onValueChange:U=>{E(U),v(0)},children:[o.jsx(St,{className:"w-[220px]",children:o.jsx(Et,{})}),o.jsxs(kt,{children:[o.jsx(Ke,{value:"all",children:"Tous les types"}),Object.keys(qa).map(U=>o.jsx(Ke,{value:U,children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"w-2.5 h-2.5 rounded-full",style:{backgroundColor:Wu[U]}}),qa[U]]})},U))]})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(d1,{className:"h-4 w-4 text-muted-foreground/60"}),o.jsxs(_t,{value:f,onValueChange:H,children:[o.jsx(St,{className:"w-[220px]",children:o.jsx(Et,{})}),o.jsx(kt,{children:Object.entries(Kee).map(([U,ee])=>o.jsx(Ke,{value:U,children:ee},U))})]})]}),o.jsxs("div",{className:"text-sm text-muted-foreground",children:[i.totalCount," zone",i.totalCount>1?"s":""]})]})})}),o.jsx(ke,{children:o.jsx(Pe,{className:"pt-6",children:l?o.jsxs("div",{className:"text-center py-16",children:[o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-primary/20 border-t-primary mx-auto"}),o.jsx("p",{className:"text-muted-foreground mt-4 text-sm",children:"Chargement..."})]}):i.zones.length===0?o.jsxs("div",{className:"text-center py-16 text-muted-foreground",children:[o.jsx("div",{className:"inline-flex items-center justify-center h-14 w-14 rounded-full bg-muted mb-4",children:o.jsx(ur,{className:"h-6 w-6 text-muted-foreground/60"})}),o.jsx("p",{className:"font-medium",children:"Aucune zone trouvée"}),(d||f!=="all")&&o.jsx("p",{className:"text-sm mt-1.5 text-muted-foreground/70",children:"Essayez de modifier vos critères de recherche"})]}):o.jsxs(o.Fragment,{children:[r&&P.size>0&&o.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-border bg-muted/50 px-3 py-2 mb-3",children:[o.jsxs("span",{className:"text-sm text-foreground",children:[P.size," zone(s) sélectionnée(s)"]}),o.jsxs(Z,{variant:"outline",size:"sm",className:"text-red-600 hover:text-red-700 hover:bg-red-500/10 border-red-500/20",onClick:()=>S(!0),children:[o.jsx(Vt,{className:"h-4 w-4 mr-1.5"}),"Supprimer la sélection"]})]}),o.jsx("div",{className:"overflow-x-auto",children:o.jsxs(Ya,{children:[o.jsx(Qa,{children:o.jsxs(Fr,{children:[r&&o.jsx(dt,{className:"w-10",children:o.jsx(Ks,{checked:Y,onCheckedChange:G,"aria-label":"Tout sélectionner"})}),o.jsx(dt,{children:"Nom"}),o.jsx(dt,{children:"Type"}),e&&o.jsx(dt,{children:"Département"}),o.jsx(dt,{children:"Société"}),o.jsx(dt,{children:"Piégeurs"}),o.jsx(dt,{children:"Louvetiers"}),o.jsx(dt,{className:"w-12"})]})}),o.jsx(Xa,{children:i.zones.map(U=>o.jsx(Qee,{zone:U,showDepartment:e,departments:x,canDelete:r,selected:P.has(U.id),onToggleSelect:q,onDelete:_},U.id))})]})}),o.jsxs("div",{className:"flex items-center justify-end mt-4 pt-4 border-t gap-4",children:[o.jsxs("div",{className:"text-sm text-muted-foreground",children:[Qd*g+1,"-",Math.min(Qd*(g+1),i.totalCount)," sur ",i.totalCount]}),re>1&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"text-sm text-muted-foreground",children:["Page ",g+1," sur ",re]}),o.jsxs("div",{className:"flex gap-1",children:[o.jsx(Z,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>v(0),disabled:g===0,title:"Première page",children:o.jsx(zL,{className:"h-4 w-4"})}),o.jsx(Z,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>v(U=>Math.max(0,U-1)),disabled:g===0,title:"Page précédente",children:o.jsx(vc,{className:"h-4 w-4"})}),o.jsx(Z,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>v(U=>U+1),disabled:!i.hasMore,title:"Page suivante",children:o.jsx(nr,{className:"h-4 w-4"})}),o.jsx(Z,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>v(re-1),disabled:!i.hasMore,title:"Dernière page",children:o.jsx($L,{className:"h-4 w-4"})})]})]})]})]})})}),o.jsx(Dn,{open:!!N,onOpenChange:U=>!U&&_(null),children:o.jsxs(Ln,{children:[o.jsxs(Mn,{children:[o.jsx(Fn,{children:"Supprimer cette zone ?"}),o.jsxs(zn,{children:['Ãtes-vous sûr de vouloir supprimer la zone "',N==null?void 0:N.name,'" ? Cette action est irréversible.']}
4063)]}),o.jsxs(On,{children:[o.jsx(Vn,{disabled:k,children:"Annuler"}),o.jsx($n,{onClick:D,disabled:k,className:"bg-red-600 hover:bg-red-700",children:k?"Suppression...":"Supprimer"})]})]})}),o.jsx(Dn,{open:I,onOpenChange:U=>!U&&S(!1),children:o.jsxs(Ln,{children:[o.jsxs(Mn,{children:[o.jsxs(Fn,{children:["Supprimer ",P.size," zone(s) ?"]}),o.jsx(zn,{children:"Les zones sélectionnées seront définitivement supprimées. Cette action est irréversible."})]}),o.jsxs(On,{children:[o.jsx(Vn,{disabled:k,children:"Annuler"}),o.jsx($n,{onClick:F,disabled:k,className:"bg-red-600 hover:bg-red-700",children:k?"Suppression...":"Supprimer"})]})]})})]})}function Qee({zone:t,showDepartment:e,departments:n=[],canDelete:r,selected:s,onToggleSelect:i,onDelete:a}){var p,g;const l=qt(),c=!!t.companyId,d=((p=t.trapperEmails)==null?void 0:p.length)||0,h=((g=t.louvetierEmails)==null?void 0:g.length)||0,f=v=>{v.stopPropagation(),a(t)};return o.jsxs(Fr,{className:"hover:bg-muted cursor-pointer",onClick:()=>l(mt.zone(t.id)),children:[r&&o.jsx(ht,{onClick:v=>v.stopPropagation(),children:o.jsx(Ks,{checked:s,onCheckedChange:()=>i(t.id),"aria-label":`Sélectionner ${t.name}`})}),o.jsx(ht,{children:o.jsx("div",{className:"font-medium",children:t.name})}),o.jsx(ht,{children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:Wu[t.zoneType]??"#795548"}}),o.jsx("span",{className:"text-sm text-muted-foreground",children:qa[t.zoneType]??t.zoneType})]})}),e&&o.jsx(ht,{children:o.jsx("div",{className:"text-sm text-muted-foreground",children:qg(t.departmentCode,n)})}),o.jsx(ht,{children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(qn,{className:"h-4 w-4 text-muted-foreground/60"}),c?o.jsx(We,{variant:"secondary",children:"Assignée"}):o.jsx(We,{variant:"outline",className:"text-orange-500 border-orange-500/20",children:"Non assignée"})]})}),o.jsx(ht,{children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(cr,{className:"h-4 w-4 text-muted-foreground/60"}),d>0?o.jsxs(We,{variant:"secondary",children:[d," piégeur",d>1?"s":""]}):o.jsx(We,{variant:"outline",className:"text-orange-500 border-orange-500/20",children:"Aucun"})]})}),o.jsx(ht,{children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(cr,{className:"h-4 w-4 text-muted-foreground/60"}),h>0?o.jsxs(We,{variant:"secondary",children:[h," louvetier",h>1?"s":""]}):o.jsx(We,{variant:"outline",className:"text-orange-500 border-orange-500/20",children:"Aucun"})]})}),o.jsx(ht,{children:o.jsxs("div",{className:"flex items-center gap-1",children:[r&&o.jsx(Z,{variant:"ghost",size:"icon",className:"text-red-500 hover:text-red-700 hover:bg-red-500/10",onClick:f,title:"Supprimer",children:o.jsx(Vt,{className:"h-4 w-4"})}),o.jsx(Fa,{to:mt.zone(t.id),onClick:v=>v.stopPropagation(),children:o.jsx(Z,{variant:"ghost",size:"icon",children:o.jsx(nr,{className:"h-4 w-4"})})})]})})]})}class hv{static async parseKMLFile(e){try{if(!e.name.toLowerCase().endsWith(".kml"))return{isValid:!1,error:"Le fichier doit avoir l'extension .kml"};if(e.size>this.MAX_FILE_SIZE)return{isValid:!1,error:"Le fichier est trop volumineux (maximum 20MB)"};if(!this.ALLOWED_MIME_TYPES.includes(e.type)&&e.type!=="")return{isValid:!1,error:"Type de fichier non autorisé"};const n=await this.readFileAsText(e),s=new DOMParser().parseFromString(n,"text/xml");return s.querySelector("parsererror")?{isValid:!1,error:"Le fichier n'est pas un XML valide"}:s.querySelector("kml")?{isValid:!0,zones:this.parseZonesFromKML(s)}:{isValid:!1,error:"Le fichier ne contient pas d'élément KML valide"}}catch(n){return console.error("Erreur lors du parsing KML:",n),{isValid:!1,error:"Erreur lors de l'analyse du fichier"}}}static readFileAsText(e){return new Promise((n,r)=>{const s=new FileReader;s.onload=i=>{var a;(a=i.target)!=null&&a.result?n(i.target.result):r(new Error("Impossible de lire le fichier"))},s.onerror=()=>r(new Error("Erreur de lecture du fichier")),s.readAsText(e)})}static parseZonesFromKML(e){var s,i,a,l,c;const n=[],r=e.querySelectorAll("Placemark");for(const d of r){const h=d.querySelector("Polygon");
4063if(!h)continue;const f=(i=(s=d.querySelector("name"))==null?void 0:s.textContent)==null?void 0:i.trim();if(!f)continue;const p=((l=(a=d.querySelector("description"))==null?void 0:a.textContent)==null?void 0:l.trim())??"",g=h.querySelector("outerBoundaryIs LinearRing coordinates")??h.querySelector("coordinates"),v=(c=g==null?void 0:g.textContent)==null?void 0:c.trim();if(v)try{const x=this.parseCoordinates(v);if(x.length<3)continue;n.push({name:f,description:p,coordinates:x})}catch(x){console.warn(`Impossible de parser les coordonnées pour ${f}:`,x);continue}}return n}static parseCoordinates(e){const n=[],r=e.split(/\s+/).filter(s=>s.trim());for(const s of r){const i=s.split(",");if(i.length<2)continue;const a=parseFloat(i[0]),l=parseFloat(i[1]);isNaN(a)||isNaN(l)||l<-90||l>90||a<-180||a>180||n.push({latitude:l,longitude:a})}return n}}Xx(hv,"MAX_FILE_SIZE",20*1024*1024),Xx(hv,"ALLOWED_MIME_TYPES",["application/vnd.google-earth.kml+xml","application/xml","text/xml","application/octet-stream"]);const sw={"01":{lat:46.2044,lng:5.2257},"02":{lat:49.5639,lng:3.6247},75:{lat:48.8566,lng:2.3522},13:{lat:43.2965,lng:5.3698},69:{lat:45.764,lng:4.8357},31:{lat:43.6047,lng:1.4442},33:{lat:44.8378,lng:-.5792},59:{lat:50.6292,lng:3.0573},67:{lat:48.5734,lng:7.7521},44:{lat:47.2184,lng:-1.5536}},Xee={lat:46.603354,lng:1.888334},Jee=6,NP=10;function Rx({isOpen:t,onClose:e,onSave:n,initialCoordinates:r=[],departmentCode:s}){const i=Ft(),[a,l]=u.useState([]),[c,d]=u.useState(0),h=u.useRef(null),f=u.useRef(null),p=u.useRef([]),g="#F66D51";u.useEffect(()=>{t&&(l([...r]),d(_=>_+1))},[t]),u.useEffect(()=>{if(h.current){if(f.current)if(a.length>=3){const _=a.map(k=>({lat:k.latitude,lng:k.longitude}));f.current.setPath(_)}else f.current.setPath([]);v()}},[a]);const v=u.useCallback(()=>{h.current&&(p.current.forEach(_=>_.setMap(null)),p.current=[],a.forEach((_,k)=>{const L=new google.maps.Marker({position:{lat:_.latitude,lng:_.longitude},map:h.current,draggable:!0,icon:{path:google.maps.SymbolPath.CIRCLE,fillColor:g,fillOpacity:1,strokeColor:"white",strokeWeight:2,scale:8},title:`Point ${k+1} - Cliquez pour supprimer`,cursor:"pointer"});L.addListener("click",()=>{j(k)}),L.addListener("dragend",I=>{I.latLng&&E(k,I.latLng.lat(),I.latLng.lng())}),p.current.push(L)}))},[a,g]),x=u.useCallback(_=>{h.current=_;const k=r.length>=3?r.map(L=>({lat:L.latitude,lng:L.longitude})):[];f.current=new google.maps.Polygon({paths:k,fillColor:g,fillOpacity:.4,strokeColor:g,strokeOpacity:1,strokeWeight:3,clickable:!1,map:_}),r.length>0&&(r.forEach((L,I)=>{const S=new google.maps.Marker({position:{lat:L.latitude,lng:L.longitude},map:_,draggable:!0,icon:{path:google.maps.SymbolPath.CIRCLE,fillColor:g,fillOpacity:1,strokeColor:"white",strokeWeight:2,scale:8},title:`Point ${I+1} - Cliquez pour supprimer`,cursor:"pointer"});S.addListener("click",()=>{j(I)}),S.addListener("dragend",T=>{T.latLng&&E(I,T.latLng.lat(),T.latLng.lng())}),p.current.push(S)}),setTimeout(()=>{if(h.current&&r.length>0){const L=new google.maps.LatLngBounds;r.forEach(I=>{L.extend({lat:I.latitude,lng:I.longitude})}),h.current.fitBounds(L,50)}},100))},[r,g]),y=u.useCallback(()=>{if(r.length>0){const _=r.reduce((L,I)=>L+I.latitude,0),k=r.reduce((L,I)=>L+I.longitude,0);return{lat:_/r.length,lng:k/r.length}}return s&&sw[s]?sw[s]:Xee},[s,r]),b=u.useCallback(()=>r.length>0||s&&sw[s]?NP:Jee,[s,r.length]),w=_=>{if(!_.latLng)return;const k=_.latLng.lat(),L=_.latLng.lng(),I={latitude:k,longitude:L};l(S=>[...S,I])},j=_=>{l(k=>{const L=k.filter((I,S)=>S!==_);return L.length>0&&L.length<3&&i.info("Au moins 3 points sont nécessaires pour définir une zone"),L})},E=(_,k,L)=>{l(I=>{const S=[...I];return S[_]={latitude:k,longitude:L},S})},P=()=>{l([])},A=()=>{if(a.length<3){i.error("Au moins 3 points sont nécessaires pour définir une zone");return}n(a),e()},N=()=>{p.current.forEach(_=>_.setMap(null)),p.current=[],f.current&&(f.current.setMap(null),f.current=null),l([]),e()};return u.useEffect(()=>()=>{p.current.forEach(_=>_.setMap(null)),f.current&&f.current.setMap(null)},[]),o.jsx(rr,{open:t,onOpenChange:_=>!_&&N(),children:o.jsxs(sr,{className:"max-w-[95vw] w-[900px] h-[85vh] max-h-[85vh] p-0 flex flex-col",children:[o.jsx(or,{className:"px-6 py-4 border-b flex-shrink-0",children:o.jsx(Gn,{children:"Dessiner la zone sur la carte"})}),o.jsx("div",{className:"px-6 py-3 bg-muted border-b flex-shrink-0",children:o.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[o.jsx(Rn,{className:"w-4 h-4 text-muted-foreground
4063/60"}),a.length===0&&"Cliquez sur la carte pour placer des points",a.length>0&&a.length<3&&`${a.length} point(s) placé(s) - minimum 3 requis`,a.length>=3&&o.jsxs("span",{children:[a.length," points - Cliquez sur un point pour le supprimer, ou glissez-le pour le déplacer"]})]})}),o.jsx("div",{className:"flex-1 relative min-h-0",children:o.jsx(Qs,{mapContainerStyle:{width:"100%",height:"100%"},center:y(),zoom:b(),onLoad:x,onClick:w,options:{disableDefaultUI:!1,zoomControl:!0,mapTypeControl:!0,streetViewControl:!1,fullscreenControl:!0,draggableCursor:"crosshair",mapTypeId:"hybrid"}},`map-${c}`)}),o.jsx(ks,{className:"px-6 py-4 border-t flex-shrink-0",children:o.jsxs("div",{className:"flex items-center justify-between w-full",children:[o.jsxs(Z,{variant:"outline",onClick:P,disabled:a.length===0,className:"text-red-600 hover:text-red-700 hover:bg-red-500/10",children:[o.jsx(Vt,{className:"w-4 h-4 mr-2"}),"Effacer tout"]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(Z,{variant:"outline",onClick:N,children:[o.jsx(br,{className:"w-4 h-4 mr-2"}),"Annuler"]}),o.jsxs(Z,{onClick:A,disabled:a.length<3,children:[o.jsx(Xn,{className:"w-4 h-4 mr-2"}),"Valider (",a.length," points)"]})]})]})})]})})}var Dx="Popover",[nO]=Rs(Dx,[gd]),um=gd(),[ete,al]=nO(Dx),rO=t=>{const{__scopePopover:e,children:n,open:r,defaultOpen:s,onOpenChange:i,modal:a=!1}=t,l=um(e),c=u.useRef(null),[d,h]=u.useState(!1),[f,p]=Co({prop:r,defaultProp:s??!1,onChange:i,caller:Dx});return o.jsx(C1,{...l,children:o.jsx(ete,{scope:e,contentId:yo(),triggerRef:c,open:f,onOpenChange:p,onOpenToggle:u.useCallback(()=>p(g=>!g),[p]),hasCustomAnchor:d,onCustomAnchorAdd:u.useCallback(()=>h(!0),[]),onCustomAnchorRemove:u.useCallback(()=>h(!1),[]),modal:a,children:n})})};rO.displayName=Dx;var sO="PopoverAnchor",tte=u.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,s=al(sO,n),i=um(n),{onCustomAnchorAdd:a,onCustomAnchorRemove:l}=s;return u.useEffect(()=>(a(),()=>l()),[a,l]),o.jsx(Nx,{...i,...r,ref:e})});tte.displayName=sO;var oO="PopoverTrigger",iO=u.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,s=al(oO,n),i=um(n),a=At(e,s.triggerRef),l=o.jsx(Je.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":dO(s.open),...r,ref:a,onClick:Le(t.onClick,s.onOpenToggle)});return s.hasCustomAnchor?l:o.jsx(Nx,{asChild:!0,...i,children:l})});iO.displayName=oO;var $1="PopoverPortal",[nte,rte]=nO($1,{forceMount:void 0}),aO=t=>{const{__scopePopover:e,forceMount:n,children:r,container:s}=t,i=al($1,e);return o.jsx(nte,{scope:e,forceMount:n,children:o.jsx(Xs,{present:n||i.open,children:o.jsx(em,{asChild:!0,container:s,children:r})})})};aO.displayName=$1;var Zu="PopoverContent",lO=u.forwardRef((t,e)=>{const n=rte(Zu,t.__scopePopover),{forceMount:r=n.forceMount,...s}=t,i=al(Zu,t.__scopePopover);return o.jsx(Xs,{present:r||i.open,children:i.modal?o.jsx(ote,{...s,ref:e}):o.jsx(ite,{...s,ref:e})})});lO.displayName=Zu;var ste=Ga("PopoverContent.RemoveScroll"),ote=u.forwardRef((t,e)=>{const n=al(Zu,t.__scopePopover),r=u.useRef(null),s=At(e,r),i=u.useRef(!1);return u.useEffect(()=>{const a=r.current;if(a)return nm(a)},[]),o.jsx(tm,{as:ste,allowPinchZoom:!0,children:o.jsx(cO,{...t,ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Le(t.onCloseAutoFocus,a=>{var l;a.preventDefault(),i.current||(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Le(t.onPointerDownOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;i.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:Le(t.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),ite=u.forwardRef((t,e)=>{const n=al(Zu,t.__scopePopover),r=u.useRef(!1),s=u.useRef(!1);return o.jsx(cO,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var a,l;(a=t.onCloseAutoFocus)==null||a.call(t,i),i.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),i.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:i=>{var c,d;(c=t.onInteractOutside)==null||c.call(t,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const a=i.target;((d=n.triggerRef.current)==null?void 0:d.contains(a))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&s.current&&i.preventDefault()}})}),cO=u.forwardRef((t,e)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:h,...f}=t,p=al(Zu,n),g=um(n);return mx(),o.jsx(Jf,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:i,children:o.jsx(Xf,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:h,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onDismiss:()=>p.onOpenChange(!1),children:o.jsx(N1,{"data-state":dO(p.open),role:"dialog",id:p.contentId,...g,...f,ref:e,style:{...f.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)"}})})})}),uO="PopoverClose",ate=u.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,s=al(uO,n);return o.jsx(Je.button,{type:"button",...r,ref:e,onClick:Le(t.onClick,()=>s.onOpenChange(!1))})});ate.displayName=uO;var lte="PopoverArrow",cte=u.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,s=um(n);return o.jsx(_1,{...s,...r,ref:e})});cte.displayName=lte;function dO(t){return t?"open":"closed"}var ute=rO,dte=iO,hte=aO,fte=lO;function hO({...t}){return o.jsx(ute,{"data-slot":"popover",...t})}function fO({...t}){return o.jsx(dte,{"data-slot":"popover-trigger",...t})}function mO({className:t,align:e="center",sideOffset:n=4,...r}){return o.jsx(hte,{children:o.jsx(fte,{"data-slot":"popover-content",align:e,sideOffset:n,className:Oe("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:sli
4063de-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...r})})}var _P=1,mte=.9,pte=.8,gte=.17,ow=.1,iw=.999,vte=.9999,xte=.99,yte=/[\\\/_+.#"@\[\(\{&]/,wte=/[\\\/_+.#"@\[\(\{&]/g,bte=/[\s-]/,pO=/[\s-]/g;function Rb(t,e,n,r,s,i,a){if(i===e.length)return s===t.length?_P:xte;var l=`${s},${i}`;if(a[l]!==void 0)return a[l];for(var c=r.charAt(i),d=n.indexOf(c,s),h=0,f,p,g,v;d>=0;)f=Rb(t,e,n,r,d+1,i+1,a),f>h&&(d===s?f*=_P:yte.test(t.charAt(d-1))?(f*=pte,g=t.slice(s,d-1).match(wte),g&&s>0&&(f*=Math.pow(iw,g.length))):bte.test(t.charAt(d-1))?(f*=mte,v=t.slice(s,d-1).match(pO),v&&s>0&&(f*=Math.pow(iw,v.length))):(f*=gte,s>0&&(f*=Math.pow(iw,d-s))),t.charAt(d)!==e.charAt(i)&&(f*=vte)),(f<ow&&n.charAt(d-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(d-1)!==r.charAt(i))&&(p=Rb(t,e,n,r,d+1,i+2,a),p*ow>f&&(f=p*ow)),f>h&&(h=f),d=n.indexOf(c,d+1);return a[l]=h,h}function EP(t){return t.toLowerCase().replace(pO," ")}function jte(t,e){return Rb(t,e,EP(t),EP(e),0,0,{})}function Qr(){return Qr=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Qr.apply(null,arguments)}function Su(t,e,{checkForDefaultPrevented:n=!0}={}){return function(s){if(t==null||t(s),n===!1||!s.defaultPrevented)return e==null?void 0:e(s)}}function Cte(t,e){typeof t=="function"?t(e):t!=null&&(t.current=e)}function gO(...t){return e=>t.forEach(n=>Cte(n,e))}function dm(...t){return u.useCallback(gO(...t),t)}function Nte(t,e){const n=u.createContext(e);function r(i){const{children:a,...l}=i,c=u.useMemo(()=>l,Object.values(l));return u.createElement(n.Provider,{value:c},a)}function s(i){const a=u.useContext(n);if(a)return a;if(e!==void 0)return e;throw new Error(`\`${i}\` must be used within \`${t}\``)}return r.displayName=t+"Provider",[r,s]}function _te(t,e=[]){let n=[];function r(i,a){const l=u.createContext(a),c=n.length;n=[...n,a];function d(f){const{scope:p,children:g,...v}=f,x=(p==null?void 0:p[t][c])||l,y=u.useMemo(()=>v,Object.values(v));return u.createElement(x.Provider,{value:y},g)}function h(f,p){const g=(p==null?void 0:p[t][c])||l,v=u.useContext(g);if(v)return v;if(a!==void 0)return a;throw new Error(`\`${f}\` must be used within \`${i}\``)}return d.displayName=i+"Provider",[d,h]}const s=()=>{const i=n.map(a=>u.createContext(a));return function(l){const c=(l==null?void 0:l[t])||i;return u.useMemo(()=>({[`__scope${t}`]:{...l,[t]:c}}),[l,c])}};return s.scopeName=t,[r,Ete(s,...e)]}function Ete(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(i){const a=r.reduce((l,{useScope:c,scopeName:d})=>{const f=c(i)[`__scope${d}`];return{...l,...f}},{});return u.useMemo(()=>({[`__scope${e.scopeName}`]:a}),[a])}};return n.scopeName=e.scopeName,n}const Db=globalThis!=null&&globalThis.document?u.useLayoutEffect:()=>{},Ste=wv.useId||(()=>{});let kte=0;function aw(t){const[e,n]=u.useState(Ste());return Db(()=>{n(r=>r??String(kte++))},[t]),t||(e?`radix-${e}`:"")}function lc(t){const e=u.useRef(t);return u.useEffect(()=>{e.current=t}),u.useMemo(()=>(...n)=>{var r;return(r=e.current)===null||r===void 0?void 0:r.call(e,...n)},[])}function Pte({prop:t,defaultProp:e,onChange:n=()=>{}}){const[r,s]=Ite({defaultProp:e,onChange:n}),i=t!==void 0,a=i?t:r,l=lc(n),c=u.useCallback(d=>{if(i){const f=typeof d=="function"?d(t):d;f!==t&&l(f)}else s(d)},[i,t,s,l]);return[a,c]}function Ite({defaultProp:t,onChange:e}){const n=u.useState(t),[r]=n,s=u.useRef(r),i=lc(e);return u.useEffect(()=>{s.current!==r&&(i(r),s.current=r)},[r,s,i]),n}const V1=u.forwardRef((t,e)=>{const{children:n,...r}=t,s=u.Children.toArray(n),i=s.find(Ate);if(i){const a=i.props.children,l=s.map(c=>c===i?u.Children.count(a)>1?u.Children.only(null):u.isValidElement(a)?a.props.children:null:c);return u.createElement(Lb,Qr({},r,{ref:e}),u.isValidElement(a)?u.cloneElement(a,void 0,l):null)}return u.createElement(Lb,Qr({},r,{ref:e}),n)});V1.displayName="Slot";const Lb=u.forwardRef((t,e)=>{const{children:n,...r}=t;return u.isValidElement(n)?u.cloneElement(n,{...Rte(r,n.props),ref:gO(e,n.ref)}):u.Children.count(n)>1?u.Children.only(null):null});Lb.displayName="SlotClone";const Tte=({children:t})=>u.createElement(u.Fragment,null,t);function Ate(t){return u.isValidElement(t)&&t.type===Tte}function Rte(t,e){const n={...e};for(const r in e){const s=t[r],i=e[r];/^on[A-Z]/.test(r)?n[r]=(...l)=>{i==null||i(...l),s==null||s(...l)}:r==="style"?n[r]={...s,...i}
4063:r==="className"&&(n[r]=[s,i].filter(Boolean).join(" "))}return{...t,...n}}const Dte=["a","button","div","h2","h3","img","li","nav","ol","p","span","svg","ul"],Lx=Dte.reduce((t,e)=>{const n=u.forwardRef((r,s)=>{const{asChild:i,...a}=r,l=i?V1:e;return u.useEffect(()=>{window[Symbol.for("radix-ui")]=!0},[]),u.createElement(l,Qr({},a,{ref:s}))});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{});function Lte(t,e){t&&ps.flushSync(()=>t.dispatchEvent(e))}function Mte(t){const e=lc(t);u.useEffect(()=>{const n=r=>{r.key==="Escape"&&e(r)};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[e])}const Mb="dismissableLayer.update",Ote="dismissableLayer.pointerDownOutside",Fte="dismissableLayer.focusOutside";let SP;const zte=u.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),$te=u.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:i,onInteractOutside:a,onDismiss:l,...c}=t,d=u.useContext(zte),[h,f]=u.useState(null),[,p]=u.useState({}),g=dm(e,A=>f(A)),v=Array.from(d.layers),[x]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(x),b=h?v.indexOf(h):-1,w=d.layersWithOutsidePointerEventsDisabled.size>0,j=b>=y,E=Vte(A=>{const N=A.target,_=[...d.branches].some(k=>k.contains(N));!j||_||(s==null||s(A),a==null||a(A),A.defaultPrevented||l==null||l())}),P=Ute(A=>{const N=A.target;[...d.branches].some(k=>k.contains(N))||(i==null||i(A),a==null||a(A),A.defaultPrevented||l==null||l())});return Mte(A=>{b===d.layers.size-1&&(r==null||r(A),!A.defaultPrevented&&l&&(A.preventDefault(),l()))}),u.useEffect(()=>{if(h)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(SP=document.body.style.pointerEvents,document.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(h)),d.layers.add(h),kP(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(document.body.style.pointerEvents=SP)}},[h,n,d]),u.useEffect(()=>()=>{h&&(d.layers.delete(h),d.layersWithOutsidePointerEventsDisabled.delete(h),kP())},[h,d]),u.useEffect(()=>{const A=()=>p({});return document.addEventListener(Mb,A),()=>document.removeEventListener(Mb,A)},[]),u.createElement(Lx.div,Qr({},c,{ref:g,style:{pointerEvents:w?j?"auto":"none":void 0,...t.style},onFocusCapture:Su(t.onFocusCapture,P.onFocusCapture),onBlurCapture:Su(t.onBlurCapture,P.onBlurCapture),onPointerDownCapture:Su(t.onPointerDownCapture,E.onPointerDownCapture)}))});function Vte(t){const e=lc(t),n=u.useRef(!1),r=u.useRef(()=>{});return u.useEffect(()=>{const s=a=>{if(a.target&&!n.current){let d=function(){vO(Ote,e,c,{discrete:!0})};var l=d;const c={originalEvent:a};a.pointerType==="touch"?(document.removeEventListener("click",r.current),r.current=d,document.addEventListener("click",r.current,{once:!0})):d()}n.current=!1},i=window.setTimeout(()=>{document.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),document.removeEventListener("pointerdown",s),document.removeEventListener("click",r.current)}},[e]),{onPointerDownCapture:()=>n.current=!0}}function Ute(t){const e=lc(t),n=u.useRef(!1);return u.useEffect(()=>{const r=s=>{s.target&&!n.current&&vO(Fte,e,{originalEvent:s},{discrete:!1})};return document.addEventListener("focusin",r),()=>document.removeEventListener("focusin",r)},[e]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function kP(){const t=new CustomEvent(Mb);document.dispatchEvent(t)}function vO(t,e,n,{discrete:r}){const s=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&s.addEventListener(t,e,{once:!0}),r?Lte(s,i):s.dispatchEvent(i)}const lw="focusScope.autoFocusOnMount",cw="focusScope.autoFocusOnUnmount",PP={bubbles:!1,cancelable:!0},Bte=u.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:s,onUnmountAutoFocus:i,...a}=t,[l,c]=u.useState(null),d=lc(s),h=lc(i),f=u.useRef(null),p=dm(e,x=>c(x)),g=u.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;u.useEffect(()=>{if(r){let b=function(j){if(g.paused||!l)return;const E=j.target;l.contains(E)?f.current=E:_l(f.current,{select:!0})},w=function(j){g.paused||!l||l.contains(j.relatedTarget)||_l(f.current,{select:!0})};var x=b,y=w;return document.addEventListener("focusin",b),document.addEventListener("focusout",w),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",w)}}},[r,l,g.paused]),u.useEffect(()=>{if(l){TP.add(g);const x=document.activeElement;if(!l.contains(x)){const b=new CustomEvent(lw,PP);l.addEventListener(lw,d),l.dispatchEvent(b),b.defaultPrevented||(Wte(Kte(xO(l)),{select:!0}),document.activeElement===x&&_l(l))}return()=>{l.removeEventListener(lw,d),setTimeout(()=>{const b=new CustomEvent(cw,PP);l.addEventListener(cw,h),l.dispatchEvent(b),b.defaultPrevented||_l(x??document.body,{select:!0}),l.removeEventListener(cw,h),TP.remove(g)},0)}}},[l,d,h,g]);const v=u.useCallback(x=>{if(!n&&!r||g.paused)return;const y=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,b=document.activeElement;if(y&&b){const w=x.currentTarget,[j,E]=Hte(w);
4063j&&E?!x.shiftKey&&b===E?(x.preventDefault(),n&&_l(j,{select:!0})):x.shiftKey&&b===j&&(x.preventDefault(),n&&_l(E,{select:!0})):b===w&&x.preventDefault()}},[n,r,g.paused]);return u.createElement(Lx.div,Qr({tabIndex:-1},a,{ref:p,onKeyDown:v}))});function Wte(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(_l(r,{select:e}),document.activeElement!==n)return}function Hte(t){const e=xO(t),n=IP(e,t),r=IP(e.reverse(),t);return[n,r]}function xO(t){const e=[],n=document.createTreeWalker(t,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();)e.push(n.currentNode);return e}function IP(t,e){for(const n of t)if(!qte(n,{upTo:e}))return n}function qte(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function Gte(t){return t instanceof HTMLInputElement&&"select"in t}function _l(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&Gte(t)&&e&&t.select()}}const TP=Zte();function Zte(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=AP(t,e),t.unshift(e)},remove(e){var n;t=AP(t,e),(n=t[0])===null||n===void 0||n.resume()}}}function AP(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function Kte(t){return t.filter(e=>e.tagName!=="A")}const Yte=u.forwardRef((t,e)=>{var n;const{container:r=globalThis==null||(n=globalThis.document)===null||n===void 0?void 0:n.body,...s}=t;return r?Fj.createPortal(u.createElement(Lx.div,Qr({},s,{ref:e})),r):null});function Qte(t,e){return u.useReducer((n,r)=>{const s=e[n][r];return s??n},t)}const Mx=t=>{const{present:e,children:n}=t,r=Xte(e),s=typeof n=="function"?n({present:r.isPresent}):u.Children.only(n),i=dm(r.ref,s.ref);return typeof n=="function"||r.isPresent?u.cloneElement(s,{ref:i}):null};Mx.displayName="Presence";function Xte(t){const[e,n]=u.useState(),r=u.useRef({}),s=u.useRef(t),i=u.useRef("none"),a=t?"mounted":"unmounted",[l,c]=Qte(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return u.useEffect(()=>{const d=xp(r.current);i.current=l==="mounted"?d:"none"},[l]),Db(()=>{const d=r.current,h=s.current;if(h!==t){const p=i.current,g=xp(d);t?c("MOUNT"):g==="none"||(d==null?void 0:d.display)==="none"?c("UNMOUNT"):c(h&&p!==g?"ANIMATION_OUT":"UNMOUNT"),s.current=t}},[t,c]),Db(()=>{if(e){const d=f=>{const g=xp(r.current).includes(f.animationName);f.target===e&&g&&ps.flushSync(()=>c("ANIMATION_END"))},h=f=>{f.target===e&&(i.current=xp(r.current))};return e.addEventListener("animationstart",h),e.addEventListener("animationcancel",d),e.addEventListener("animationend",d),()=>{e.removeEventListener("animationstart",h),e.removeEventListener("animationcancel",d),e.removeEventListener("animationend",d)}}else c("ANIMATION_END")},[e,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:u.useCallback(d=>{d&&(r.current=getComputedStyle(d)),n(d)},[])}}function xp(t){return(t==null?void 0:t.animationName)||"none"}let uw=0;function Jte(){u.useEffect(()=>{var t,e;const n=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",(t=n[0])!==null&&t!==void 0?t:RP()),document.body.insertAdjacentElement("beforeend",(e=n[1])!==null&&e!==void 0?e:RP()),uw++,()=>{uw===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(r=>r.remove()),uw--}},[])}function RP(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.cssText="outline: none; opacity: 0; position: fixed; pointer-events: none",t}var yO=hL(),dw=function(){},Ox=u.forwardRef(function(t,e){var n=u.useRef(null),r=u.useState({onScrollCapture:dw,onWheelCapture:dw,onTouchMoveCapture:dw}),s=r[0],i=r[1],a=t.forwardProps,l=t.children,c=t.className,d=t.removeScrollBar,h=t.enabled,f=t.shards,p=t.sideCar,g=t.noIsolation,v=t.inert,x=t.allowPinchZoom,y=t.as,b=y===void 0?"div":y,w=nd(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as"]),j=p,E=dL([n,e]),P=Mr(Mr({},w),s);return u.createElement(u.Fragment,null,h&&u.createElement(j,{sideCar:yO,removeScrollBar:d,shards:f,noIsolation:g,inert:v,setCallbacks:i,allowPinchZoom:!!x,lockRef:n}),a?u.cloneElement(u.Children.only(l),Mr(Mr({},P),{ref:E})):u.createElement(b,Mr({},P,{className:c,ref:E}),l))});Ox.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Ox.classNames={fullWidth:zh,zeroRight:Fh};var Ob=!1;if(typeof window<"u")try{var yp=Object.defineProperty({},"passive",{get:function(){return Ob=!0,!0}});
vendor: 4,476 bytes, lines 4063-4066
4063window.addEventListener("test",yp,yp),window.removeEventListener("test",yp,yp)}catch{Ob=!1}var $c=Ob?{passive:!1}:!1,ene=function(t){var e=window.getComputedStyle(t);return e.overflowY!=="hidden"&&!(e.overflowY===e.overflowX&&e.overflowY==="visible")},tne=function(t){var e=window.getComputedStyle(t);return e.overflowX!=="hidden"&&!(e.overflowY===e.overflowX&&e.overflowX==="visible")},DP=function(t,e){var n=e;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var r=wO(t,n);if(r){var s=bO(t,n),i=s[1],a=s[2];if(i>a)return!0}n=n.parentNode}while(n&&n!==document.body);return!1},nne=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},rne=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},wO=function(t,e){return t==="v"?ene(e):tne(e)},bO=function(t,e){return t==="v"?nne(e):rne(e)},sne=function(t,e){return t==="h"&&e==="rtl"?-1:1},one=function(t,e,n,r,s){var i=sne(t,window.getComputedStyle(e).direction),a=i*r,l=n.target,c=e.contains(l),d=!1,h=a>0,f=0,p=0;do{var g=bO(t,l),v=g[0],x=g[1],y=g[2],b=x-y-i*v;(v||b)&&wO(t,l)&&(f+=b,p+=v),l=l.parentNode}while(!c&&l!==document.body||c&&(e.contains(l)||e===l));return(h&&f===0||!h&&p===0)&&(d=!0),d},wp=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},LP=function(t){return[t.deltaX,t.deltaY]},MP=function(t){return t&&"current"in t?t.current:t},ine=function(t,e){return t[0]===e[0]&&t[1]===e[1]},ane=function(t){return` 4064 .block-interactivity-`.concat(t,` {pointer-events: none;} 4065 .allow-interactivity-`).concat(t,` {pointer-events: all;} 4066`)},lne=0,Vc=[];function cne(t){var e=u.useRef([]),n=u.useRef([0,0]),r=u.useRef(),s=u.useState(lne++)[0],i=u.useState(function(){return t1()})[0],a=u.useRef(t);u.useEffect(function(){a.current=t},[t]),u.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(s));var x=oA([t.lockRef.current],(t.shards||[]).map(MP),!0).filter(Boolean);return x.forEach(function(y){return y.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),x.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(s))})}}},[t.inert,t.lockRef.current,t.shards]);var l=u.useCallback(function(x,y){if("touches"in x&&x.touches.length===2)return!a.current.allowPinchZoom;var b=wp(x),w=n.current,j="deltaX"in x?x.deltaX:w[0]-b[0],E="deltaY"in x?x.deltaY:w[1]-b[1],P,A=x.target,N=Math.abs(j)>Math.abs(E)?"h":"v";if("touches"in x&&N==="h"&&A.type==="range")return!1;var _=DP(N,A);if(!_)return!0;if(_?P=N:(P=N==="v"?"h":"v",_=DP(N,A)),!_)return!1;if(!r.current&&"changedTouches"in x&&(j||E)&&(r.current=P),!P)return!0;var k=r.current||P;return one(k,y,x,k==="h"?j:E)},[]),c=u.useCallback(function(x){var y=x;if(!(!Vc.length||Vc[Vc.length-1]!==i)){var b="deltaY"in y?LP(y):wp(y),w=e.current.filter(function(P){return P.name===y.type&&P.target===y.target&&ine(P.delta,b)})[0];if(w&&w.should){y.preventDefault();return}if(!w){var j=(a.current.shards||[]).map(MP).filter(Boolean).filter(function(P){return P.contains(y.target)}),E=j.length>0?l(y,j[0]):!a.current.noIsolation;E&&y.preventDefault()}}},[]),d=u.useCallback(function(x,y,b,w){var j={name:x,delta:y,target:b,should:w};e.current.push(j),setTimeout(function(){e.current=e.current.filter(function(E){return E!==j})},1)},[]),h=u.useCallback(function(x){n.current=wp(x),r.current=void 0},[]),f=u.useCallback(function(x){d(x.type,LP(x),x.target,l(x,t.lockRef.current))},[]),p=u.useCallback(function(x){d(x.type,wp(x),x.target,l(x,t.lockRef.current))},[]);u.useEffect(function(){return Vc.push(i),t.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",c,$c),document.addEventListener("touchmove",c,$c),document.addEventListener("touchstart",h,$c),function(){Vc=Vc.filter(function(x){return x!==i}),document.removeEventListener("wheel",c,$c),document.removeEventListener("touchmove",c,$c),document.removeEventListener("touchstart",h,$c)}},[]);var g=t.removeScrollBar,v=t.inert;return u.createElement(u.Fragment,null,v?u.createElement(i,{styles:ane(s)}):null,g?u.createElement(gL,{gapMode:"margin"}):null)}const une=mL(yO,cne);var jO=u.forwardRef(function(t,e){return u.createElement(Ox,Mr({},t,{ref:e,sideCar:une}))});jO.classNames=Ox.classNames;const CO="Dialog",[NO]=_te(CO),[dne,jc]=NO(CO),hne=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:s,onOpenChange:i,modal:
4066a=!0}=t,l=u.useRef(null),c=u.useRef(null),[d=!1,h]=Pte({prop:r,defaultProp:s,onChange:i});return u.createElement(dne,{scope:e,triggerRef:l,contentRef:c,contentId:aw(),titleId:aw(),descriptionId:aw(),open:d,onOpenChange:h,onOpenToggle:u.useCallback(()=>h(f=>!f),[h]),modal:a},n)},_O="DialogPortal",[fne,EO]=NO(_O,{forceMount:void 0}),mne=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:s}=t,i=jc(_O,e);return u.createElement(fne,{scope:e,forceMount:n},u.Children.map(r,a=>u.createElement(Mx,{present:n||i.open},u.createElement(Yte,{asChild:!0,container:s},a))))},Fb="DialogOverlay",pne=u.forwardRef((t,e)=>{const n=EO(Fb,t.__scopeDialog),{forceMount:r=n.forceMount,...s}=t,i=jc(Fb,t.__scopeDialog);return i.modal?u.createElement(Mx,{present:r||i.open},u.createElement(gne,Qr({},s,{ref:e}))):null}),gne=u.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,s=jc(Fb,n);return u.createElement(jO,{as:V1,allowPinchZoom:!0,shards:[s.contentRef]},u.createElement(Lx.div,Qr({"data-state":kO(s.open)},r,{ref:e,style:{pointerEvents:"auto",...r.style}})))}),Ku="DialogContent",vne=u.forwardRef((t,e)=>{const n=EO(Ku,t.__scopeDialog),{forceMount:r=n.forceMount,...s}=t,i=jc(Ku,t.__scopeDialog);return u.createElement(Mx,{present:r||i.open},i.modal?u.createElement(xne,Qr({},s,{ref:e})):u.createElement(yne,Qr({},s,{ref:e})))}),xne=u.forwardRef((t,e)=>{const n=jc(Ku,t.__scopeDialog),r=u.useRef(null),s=dm(e,n.contentRef,r);return u.useEffect(()=>{const i=r.current;if(i)return nm(i)},[]),u.createElement(SO,Qr({},t,{ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Su(t.onCloseAutoFocus,i=>{var a;i.preventDefault(),(a=n.triggerRef.current)===null||a===void 0||a.focus()}),onPointerDownOutside:Su(t.onPointerDownOutside,i=>{const a=i.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0;(a.button===2||l)&&i.preventDefault()}),onFocusOutside:Su(t.onFocusOutside,i=>i.preventDefault())}))}),yne=u.forwardRef((t,e)=>{const n=jc(Ku,t.__scopeDialog),r=u.useRef(!1);return u.createElement(SO,Qr({},t,{ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i;if((i=t.onCloseAutoFocus)===null||i===void 0||i.call(t,s),!s.defaultPrevented){var a;r.current||(a=n.triggerRef.current)===null||a===void 0||a.focus(),s.preventDefault()}r.current=!1},onInteractOutside:s=>{var i,a;(i=t.onInteractOutside)===null||i===void 0||i.call(t,s),s.defaultPrevented||(r.current=!0);const l=s.target;((a=n.triggerRef.current)===null||a===void 0?void 0:a.contains(l))&&s.preventDefault()}}))}),SO=u.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:i,...a}=t,l=jc(Ku,n),c=u.useRef(null),d=dm(e,c);return Jte(),u.createElement(u.Fragment,null,u.createElement(Bte,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:i},u.createElement($te,Qr({role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":kO(l.open)},a,{ref:d,onDismiss:()=>l.onOpenChange(!1)}))),!1)}),wne="DialogTitle";function kO(t){return t?"open":"closed"}const bne="DialogTitleWarning";Nte(bne,{contentName:Ku,titleName:wne,docsSlug:"dialog"});const jne=hne,Cne=mne,Nne=pne,_ne=vne;var Ene='[cmdk-list-sizer=""]',Xd='[cmdk-group=""]',hw='[cmdk-group-items=""]',Sne='[cmdk-group-heading=""]',U1='[cmdk-item=""]',OP=`${U1}:not([aria-disabled="true"])`,zb="cmdk-item-select",pi="data-value",kne=(t,e)=>jte(t,e),PO=u.createContext(void 0),hm=()=>u.useContext(PO),IO=u.createContext(void 0),B1=()=>u.useContext(IO),TO=u.createContext(void 0),AO=u.forwardRef((t,e)=>{let n=u.useRef(null),r=Yc(()=>{var O,Y,G;return{search:"",value:(G=(Y=t.value)!=null?Y:(O=t.defaultValue)==null?void 0:O.toLowerCase())!=null?G:"",filtered:{count:0,items:new Map,groups:new Set}}}),s=Yc(()=>new Set),i=Yc(()=>new Map),a=Yc(()=>new Map),l=Yc(()=>new Set),c=RO(t),{label:d,children:h,value:f,onValueChange:p,filter:g,shouldFilter:v,vimBindings:x=!0,...y}=t,b=u.useId(),w=u.useId(),j=u.useId(),E=zne();wd(()=>{if(f!==void 0){let O=f.trim().toLowerCase();r.current.value=O,E(6,I),P.emit()}},[f]);let P=u.useMemo(()=>({subscribe:O=>(l.current.add(O),()=>l.current.delete(O)),snapshot:()=>r.current,setState:(O,Y,G)=>{var q,re,U;if(!Object.is(r.current[O],Y)){if(r.current[O]=Y,O==="search")L(),_(),E(1,k);else if(O==="value")if(((q=c.current)==null?void 0:q.value)!==void 0){let ee=Y??"";
4066(U=(re=c.current).onValueChange)==null||U.call(re,ee);return}else G||E(5,I);P.emit()}},emit:()=>{l.current.forEach(O=>O())}}),[]),A=u.useMemo(()=>({value:(O,Y)=>{Y!==a.current.get(O)&&(a.current.set(O,Y),r.current.filtered.items.set(O,N(Y)),E(2,()=>{_(),P.emit()}))},item:(O,Y)=>(s.current.add(O),Y&&(i.current.has(Y)?i.current.get(Y).add(O):i.current.set(Y,new Set([O]))),E(3,()=>{L(),_(),r.current.value||k(),P.emit()}),()=>{a.current.delete(O),s.current.delete(O),r.current.filtered.items.delete(O);let G=S();E(4,()=>{L(),(G==null?void 0:G.getAttribute("id"))===O&&k(),P.emit()})}),group:O=>(i.current.has(O)||i.current.set(O,new Set),()=>{a.current.delete(O),i.current.delete(O)}),filter:()=>c.current.shouldFilter,label:d||t["aria-label"],commandRef:n,listId:b,inputId:j,labelId:w}),[]);function N(O){var Y,G;let q=(G=(Y=c.current)==null?void 0:Y.filter)!=null?G:kne;return O?q(O,r.current.search):0}function _(){if(!n.current||!r.current.search||c.current.shouldFilter===!1)return;let O=r.current.filtered.items,Y=[];r.current.filtered.groups.forEach(q=>{let re=i.current.get(q),U=0;re.forEach(ee=>{let K=O.get(ee);U=Math.max(K,U)}),Y.push([q,U])});let G=n.current.querySelector(Ene);T().sort((q,re)=>{var U,ee;let K=q.getAttribute(pi),ue=re.getAttribute(pi);return((U=O.get(ue))!=null?U:0)-((ee=O.get(K))!=null?ee:0)}).forEach(q=>{let re=q.closest(hw);re?re.appendChild(q.parentElement===re?q:q.closest(`${hw} > *`)):G.appendChild(q.parentElement===G?q:q.closest(`${hw} > *`))}),Y.sort((q,re)=>re[1]-q[1]).forEach(q=>{let re=n.current.querySelector(`${Xd}[${pi}="${q[0]}"]`);re==null||re.parentElement.appendChild(re)})}function k(){let O=T().find(G=>!G.ariaDisabled),Y=O==null?void 0:O.getAttribute(pi);P.setState("value",Y||void 0)}function L(){if(!r.current.search||c.current.shouldFilter===!1){r.current.filtered.count=s.current.size;return}r.current.filtered.groups=new Set;let O=0;for(let Y of s.current){let G=a.current.get(Y),q=N(G);r.current.filtered.items.set(Y,q),q>0&&O++}for(let[Y,G]of i.current)for(let q of G)if(r.current.filtered.items.get(q)>0){r.current.filtered.groups.add(Y);break}r.current.filtered.count=O}function I(){var O,Y,G;let q=S();q&&(((O=q.parentElement)==null?void 0:O.firstChild)===q&&((G=(Y=q.closest(Xd))==null?void 0:Y.querySelector(Sne))==null||G.scrollIntoView({block:"nearest"})),q.scrollIntoView({block:"nearest"}))}function S(){var O;return(O=n.current)==null?void 0:O.querySelector(`${U1}[aria-selected="true"]`)}function T(){return Array.from(n.current.querySelectorAll(OP))}function V(O){let Y=T()[O];Y&&P.setState("value",Y.getAttribute(pi))}function $(O){var Y;let G=S(),q=T(),re=q.findIndex(ee=>ee===G),U=q[re+O];(Y=c.current)!=null&&Y.loop&&(U=re+O<0?q[q.length-1]:re+O===q.length?q[0]:q[re+O]),U&&P.setState("value",U.getAttribute(pi))}function H(O){let Y=S(),G=Y==null?void 0:Y.closest(Xd),q;for(;G&&!q;)G=O>0?One(G,Xd):Fne(G,Xd),q=G==null?void 0:G.querySelector(OP);q?P.setState("value",q.getAttribute(pi)):$(O)}let W=()=>V(T().length-1),D=O=>{O.preventDefault(),O.metaKey?W():O.altKey?H(1):$(1)},F=O=>{O.preventDefault(),O.metaKey?V(0):O.altKey?H(-1):$(-1)};return u.createElement("div",{ref:fm([n,e]),...y,"cmdk-root":"",onKeyDown:O=>{var Y;if((Y=y.onKeyDown)==null||Y.call(y,O),!O.defaultPrevented)switch(O.key){case"n":case"j":{x&&O.ctrlKey&&D(O);break}case"ArrowDown":{D(O);break}case"p":case"k":{x&&O.ctrlKey&&F(O);break}case"ArrowUp":{F(O);break}case"Home":{O.preventDefault(),V(0);break}case"End":{O.preventDefault(),W();break}case"Enter":if(!O.nativeEvent.isComposing){O.preventDefault();let G=S();if(G){let q=new Event(zb);G.dispatchEvent(q)}}}}},u.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:$ne},d),u.createElement(IO.Provider,{value:P},u.createElement(PO.Provider,{value:A},h)))}),Pne=u.forwardRef((t,e)=>{var n,r;let s=u.useId(),i=u.useRef(null),a=u.useContext(TO),l=hm(),c=RO(t),d=(r=(n=c.current)==null?void 0:n.forceMount)!=null?r:a==null?void 0:a.forceMount;wd(()=>l.item(s,a==null?void 0:a.id),[]);let h=DO(s,i,[t.value,t.children,i]),f=B1(),p=cc(P=>P.value&&P.value===h.current),g=cc(P=>d||l.filter()===!1?!0:P.search?P.filtered.items.get(s)>0:!0);u.useEffect(()=>{let P=i.current;if(!(!P||t.disabled))return P.addEventListener(zb,v),()=>P.removeEventListener(zb,v)},[g,t.onSelect,t.disabled]);function v(){var P,A;x(),(A=(P=c.current).onSelect)==null||A.call(P,h.current)}function x(){f.setState("value",h.current,!0)}if(!g)return null;let{disabled:y,value:b,onSelect:w,forceMount:j,...E}=t;return u.createElement("div",{ref:fm([i,e]),...E,id:s,"cmdk-item":"",role:"option","aria-disabled":y||void 0,"aria-selected":p||void 0,"data-disabled":y||void 0,"data-selected":p||void 0,onPointerMove:y?void 0:x,onClick:y?void 0:v},t.children)}),Ine=u.forwardRef((t,e)=>{let{heading:n,children:r,forceMount:s,...i}=t,a=u.useId(),l=u.useRef(null),c=u.useRef(null),d=u.useId(),h=hm(),f=cc(v=>s||h.filter()===!1?!0:v.search?v.filtered.groups.has(a):!0);wd(()=>h.group(a),[]),DO(a,l,[t.value,t.heading,c]);let p=u.useMemo(()=>({id:a,forceMount:s}),[s]),g=u.createElement(TO.Provider,{value:p},r);return u.createElement("div",{ref:fm([l,e]),...i,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&u.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:d},n),u.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?d:void 0},g))}),Tne=u.forwardRef((t,e)=>{let{alwaysRender:n,...r}=t,s=u.useRef(null),i=cc(a=>!a.search);return!n&&!i?null:u.createElement("div",{ref:fm([s,e]),...r,"cmdk-separator":"",role:"separator"})}),Ane=u.forwardRef((t,e)=>{let{onValueChange:n,...r}=t,s=t.value!=null,i=B1(),a=cc(h=>h.search),l=cc(h=>
4066h.value),c=hm(),d=u.useMemo(()=>{var h;let f=(h=c.commandRef.current)==null?void 0:h.querySelector(`${U1}[${pi}="${l}"]`);return f==null?void 0:f.getAttribute("id")},[l,c.commandRef]);return u.useEffect(()=>{t.value!=null&&i.setState("search",t.value)},[t.value]),u.createElement("input",{ref:e,...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":d,id:c.inputId,type:"text",value:s?t.value:a,onChange:h=>{s||i.setState("search",h.target.value),n==null||n(h.target.value)}})}),Rne=u.forwardRef((t,e)=>{let{children:n,...r}=t,s=u.useRef(null),i=u.useRef(null),a=hm();return u.useEffect(()=>{if(i.current&&s.current){let l=i.current,c=s.current,d,h=new ResizeObserver(()=>{d=requestAnimationFrame(()=>{let f=l.offsetHeight;c.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return h.observe(l),()=>{cancelAnimationFrame(d),h.unobserve(l)}}},[]),u.createElement("div",{ref:fm([s,e]),...r,"cmdk-list":"",role:"listbox","aria-label":"Suggestions",id:a.listId,"aria-labelledby":a.inputId},u.createElement("div",{ref:i,"cmdk-list-sizer":""},n))}),Dne=u.forwardRef((t,e)=>{let{open:n,onOpenChange:r,overlayClassName:s,contentClassName:i,container:a,...l}=t;return u.createElement(jne,{open:n,onOpenChange:r},u.createElement(Cne,{container:a},u.createElement(Nne,{"cmdk-overlay":"",className:s}),u.createElement(_ne,{"aria-label":t.label,"cmdk-dialog":"",className:i},u.createElement(AO,{ref:e,...l}))))}),Lne=u.forwardRef((t,e)=>{let n=u.useRef(!0),r=cc(s=>s.filtered.count===0);return u.useEffect(()=>{n.current=!1},[]),n.current||!r?null:u.createElement("div",{ref:e,...t,"cmdk-empty":"",role:"presentation"})}),Mne=u.forwardRef((t,e)=>{let{progress:n,children:r,...s}=t;return u.createElement("div",{ref:e,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":"Loading..."},u.createElement("div",{"aria-hidden":!0},r))}),yd=Object.assign(AO,{List:Rne,Item:Pne,Input:Ane,Group:Ine,Separator:Tne,Dialog:Dne,Empty:Lne,Loading:Mne});function One(t,e){let n=t.nextElementSibling;for(;n;){if(n.matches(e))return n;n=n.nextElementSibling}}function Fne(t,e){let n=t.previousElementSibling;for(;n;){if(n.matches(e))return n;n=n.previousElementSibling}}function RO(t){let e=u.useRef(t);return wd(()=>{e.current=t}),e}var wd=typeof window>"u"?u.useEffect:u.useLayoutEffect;function Yc(t){let e=u.useRef();return e.current===void 0&&(e.current=t()),e}function fm(t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}function cc(t){let e=B1(),n=()=>t(e.snapshot());return u.useSyncExternalStore(e.subscribe,n,n)}function DO(t,e,n){let r=u.useRef(),s=hm();return wd(()=>{var i;let a=(()=>{var l;for(let c of n){if(typeof c=="string")return c.trim().toLowerCase();if(typeof c=="object"&&"current"in c)return c.current?(l=c.current.textContent)==null?void 0:l.trim().toLowerCase():r.current}})();s.value(t,a),(i=e.current)==null||i.setAttribute(pi,a),r.current=a}),r}var zne=()=>{let[t,e]=u.useState(),n=Yc(()=>new Map);return wd(()=>{n.current.forEach(r=>r()),n.current=new Map},[t]),(r,s)=>{n.current.set(r,s),e({})}},$ne={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function LO({className:t,...e}){return o.jsx(yd,{"data-slot":"command",className:Oe("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",t),...e})}function MO({className:t,...e}){return o.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[o.jsx(Ws,{className:"size-4 shrink-0 opacity-50"}),o.jsx(yd.Input,{"data-slot":"command-input",className:Oe("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",t),...e})]})}function OO({className:t,...e}){return o.jsx(yd.List,{"data-slot":"command-list",className:Oe("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",t),...e})}function FO({...t}){return o.jsx(yd.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...t})}function zO({className:t,...e}){return o.jsx(yd.Group,{"data-slot":"command-group",className:Oe("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",t),...e})}function $O({className:t,...e}){return o.jsx(yd.Item,{"data-slot":"command-item",className:Oe("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...e})}
4066function FP({companies:t,value:e,onChange:n,placeholder:r="Société...",className:s}){const[i,a]=u.useState(!1),l=t.find(c=>c.id===e);return o.jsxs(hO,{open:i,onOpenChange:a,modal:!0,children:[o.jsx(fO,{asChild:!0,children:o.jsxs(Z,{type:"button",variant:"outline",role:"combobox","aria-expanded":i,className:Kn("justify-between font-normal",s),children:[o.jsx("span",{className:Kn("truncate",!l&&"text-muted-foreground"),children:l?l.name:r}),o.jsx(u1,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),o.jsx(mO,{className:"w-[280px] p-0",align:"end",children:o.jsxs(LO,{children:[o.jsx(MO,{placeholder:"Rechercher une société..."}),o.jsxs(OO,{className:"max-h-[240px]",children:[o.jsx(FO,{children:"Aucune société trouvée."}),o.jsx(zO,{children:t.map(c=>o.jsxs($O,{value:`${c.name} ${c.id}`,onSelect:()=>{n(c.id),a(!1)},children:[o.jsx(Xn,{className:Kn("mr-2 h-4 w-4",e===c.id?"opacity-100":"opacity-0")}),c.name]},c.id))})]})]})})]})}const fw="#757575";function mw({polygons:t}){const e=u.useRef([]),n=t.map(s=>`${s.color}:${s.points.length}`).join("|"),r=u.useCallback(s=>{e.current.forEach(a=>a.setMap(null)),e.current=[];const i=new google.maps.LatLngBounds;t.forEach(a=>{const l=a.points.map(c=>({lat:c.latitude,lng:c.longitude}));l.forEach(c=>i.extend(c)),l.length>=3&&e.current.push(new google.maps.Polygon({paths:l,fillColor:a.color,fillOpacity:.3,strokeColor:a.color,strokeOpacity:1,strokeWeight:2,clickable:!1,map:s}))}),i.isEmpty()||s.fitBounds(i,{top:20,right:20,bottom:20,left:20})},[t]);return u.useEffect(()=>()=>{e.current.forEach(s=>s.setMap(null)),e.current=[]},[]),o.jsx(Qs,{mapContainerStyle:{width:"100%",height:"100%"},center:{lat:46.603354,lng:1.888334},zoom:6,onLoad:r,options:{disableDefaultUI:!0,draggable:!1,scrollwheel:!1,disableDoubleClickZoom:!0,mapTypeId:"hybrid"}},n)}function Vne({isOpen:t,zoneType:e,existing:n,existingCompanyName:r,incoming:s,onResolve:i,onClose:a}){var p,g,v,x;const[l,c]=u.useState(!1),d=Wu[e],h=(n==null?void 0:n.gpsPoint)??[],f=(s==null?void 0:s.coordinates)??[];return o.jsx(rr,{open:t,onOpenChange:y=>!y&&a(),children:o.jsxs(sr,{className:"sm:max-w-6xl w-[95vw] top-4 translate-y-0 max-h-[calc(100svh-4rem)] flex flex-col gap-0 p-0 overflow-hidden",children:[o.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-4 p-6",children:[o.jsxs(or,{className:"pr-8",children:[o.jsxs(Gn,{children:["« ",s==null?void 0:s.name," » existe déjà "]}),o.jsx(ir,{children:"Une zone du même nom et du même type existe dans votre département. Comparez les deux tracés puis choisissez quoi faire."})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:fw}}),"Existante"]}),o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:d}}),"Fichier importé"]})]}),o.jsxs(Z,{type:"button",variant:"outline",size:"sm",onClick:()=>c(!l),children:[o.jsx(Si,{className:"w-4 h-4 mr-1.5"}),l?"Côte à côte":"Superposer"]})]}),l?o.jsx("div",{className:"border border-border rounded-lg overflow-hidden h-[50svh] min-h-[300px]",children:o.jsx(mw,{polygons:[{points:h,color:fw},{points:f,color:d}]})}):o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("div",{className:"border border-border rounded-lg overflow-hidden h-[40svh] min-h-[260px]",children:o.jsx(mw,{polygons:[{points:h,color:fw}]})}),o.jsxs("div",{className:"mt-2 text-sm space-y-0.5",children:[o.jsx("p",{className:"font-medium text-foreground",children:"Zone existante"}),o.jsxs("p",{className:"text-muted-foreground",children:[h.length," points"]}),r&&o.jsxs("p",{className:"text-muted-foreground",children:["Société : ",r]}),(((p=n==null?void 0:n.louvetierEmails)==null?void 0:p.length)??0)>0&&o.jsxs("p",{className:"text-muted-foreground",children:[(g=n==null?void 0:n.louvetierEmails)==null?void 0:g.length," louvetier(s) assigné(s)"]}),(((v=n==null?void 0:n.trapperEmails)==null?void 0:v.length)??0)>0&&o.jsxs("p",{className:"text-muted-foreground",children:[(x=n==null?void 0:n.trapperEmails)==null?void 0:x.length," piégeur(s) assigné(s)"]})]})]}),o.jsxs("div",{children:[o.jsx("div",{className:"border border-border rounded-lg overflow-hidden h-[40svh] min-h-[260px]",children:o.jsx(mw,{polygons:[{points:f,color:d}]})}),o.jsxs("div",{className:"mt-2 text-sm space-y-0.5",children:[o.jsx("p",{className:"font-medium text-foreground",children:"Fichier importé"}),o.jsxs("p",{className:"text-muted-foreground",children:[f.length," points"]})]})]})]}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"« Garder la nouvelle » met à jour le tracé de la zone existante : sa société, ses louvetiers et piégeurs restent en place. « Garder les deux » crée une zone indépendante en plus. « Garder l'ancienne » ignore cette ligne du fichier."})]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2 border-t border-border bg-card px-6 py-4",children:[o.jsxs(Z,{type:"button",variant:"outline",onClick:()=>i("keep_old"),children:[o.jsx(LK,{className:"w-4 h-4 mr-1.5"}),"Garder l'ancienne"]}),o.jsxs(Z,{type:"button",onClick:()=>i("keep_new"),children:[o.jsx(ft,{className:"w-4 h-4 mr-1.5"}),"Garder la nouvelle"]}),o.jsxs(Z,{type:"button",variant:"outline",onClick:()=>i("keep_both"),children:[o.jsx(Xp,{className:"w-4 h-4 mr-1.5"}),"Garder les deux"]})]})]})})}function $b(t,e){return t.conflict&&!t.resolution?"needs_resolution":t.resolution==="keep_old"?"ignored":(!t.conflict||t.resolution==="keep_both")&&e==="huntingTerritory"&&!t.companyId?"needs_company":"ready"}const Une={keep_old:"Ignorée (existante conservée)",keep_new:"Remplacera l'existante",keep_both:"Créée en plus"},zP=["#F66D51","#3B82F6","#10B981","#A855F7","#F59E0B","#EC4899"];function Bne({isOpen:t,zoneType:e,rows:n,onRowsChange:r,companies:s,lockedCompany:i,onClose:a,onConfirm:l,importing:c,progress:d,result:h,failed:f,onResume:p,onGoToMap:g,onGoToList:v}){var S;const[x,y]=u.useState(null),w=e==="huntingTerritory"&&!i,j=u.useMemo(()=>{const T=new Map;
4066return s.forEach(V=>T.set(V.id,V.name)),T},[s]),E=u.useMemo(()=>n.map(T=>$b(T,e)),[n,e]),P=E.filter(T=>T==="needs_resolution"||T==="needs_company").length,A=n.filter(T=>T.conflict).length,N=E.filter(T=>T==="ready").length,_=u.useCallback((T,V)=>{r(n.map($=>$.index===T?{...$,...V}:$))},[n,r]),k=u.useCallback(T=>{r(n.map(V=>{if(!V.conflict)return V;const $=T==="keep_new"?V.conflict.companyId??"":V.companyId;return{...V,resolution:T,companyId:$}}))},[n,r]),L=u.useCallback(T=>{r(n.map(V=>({...V,companyId:T})))},[n,r]),I=x!==null?n.find(T=>T.index===x):void 0;return o.jsxs(o.Fragment,{children:[o.jsx(rr,{open:t,onOpenChange:T=>!T&&!c&&a(),children:o.jsxs(sr,{className:Kn("max-h-[calc(100svh-4rem)] flex flex-col gap-0 p-0 overflow-hidden",!h&&"sm:max-w-6xl w-[95vw] top-4 translate-y-0"),children:[o.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-4 p-6",children:[o.jsx(or,{className:"pr-8",children:h?o.jsxs(o.Fragment,{children:[o.jsxs(Gn,{className:"flex items-center gap-2",children:[o.jsx(ew,{className:"w-5 h-5 text-green-600"}),"Import terminé"]}),o.jsxs(ir,{children:[h.created," zone",h.created>1?"s":""," créée",h.created>1?"s":"",h.updated>0&&`, ${h.updated} mise(s) à jour`,h.skipped.length>0&&`, ${h.skipped.length} écartée(s)`,"."]})]}):o.jsxs(o.Fragment,{children:[o.jsxs(Gn,{className:"flex items-center gap-2",children:[o.jsx(Si,{className:"w-5 h-5"}),n.length," zone",n.length>1?"s":""," détectée",n.length>1?"s":"",o.jsx(We,{variant:"secondary",className:"ml-1",children:qa[e]})]}),o.jsx(ir,{children:A>0?`${A}
4066 zone(s) du fichier portent le nom d'une zone existante : comparez et choisissez pour chacune avant de valider.`:"Toutes les zones du fichier seront créées avec le type sélectionné."})]})}),h?o.jsx(Wne,{result:h,onGoToMap:g,onGoToList:v}):o.jsxs(o.Fragment,{children:[o.jsx(Hne,{zones:n}),i&&o.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-sm text-foreground",children:[o.jsx(ew,{className:"w-4 h-4 text-green-600 flex-shrink-0"}),"Toutes les zones seront assignées à « ",i.name," »"]}),(A>0||w&&n.length>1)&&o.jsxs("div",{className:"rounded-lg border border-border divide-y divide-border",children:[w&&n.length>1&&(s.length>0?o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 px-4 py-3",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-medium text-foreground",children:"Assigner une société à toutes les lignes"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Applique le choix d'un coup, chaque ligne reste modifiable ensuite."})]}),o.jsx(FP,{companies:s,value:"",onChange:L,placeholder:"Choisir une société...",className:"w-[260px]"})]}):null),A>0&&o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 px-4 py-3",children:[o.jsxs("div",{children:[o.jsxs("p",{className:"text-sm font-medium text-foreground",children:[A," conflit",A>1?"s":""," avec des zones existantes"]}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Appliquer le même choix partout, ou trancher ligne par ligne via « Comparer »."})]}),o.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[o.jsx("button",{type:"button",className:"px-3 py-1.5 text-sm hover:bg-accent border-r border-border",onClick:()=>k("keep_old"),children:"Garder l'ancienne"}),o.jsx("button",{type:"button",className:"px-3 py-1.5 text-sm hover:bg-accent border-r border-border",onClick:()=>k("keep_new"),children:"Garder la nouvelle"}),o.jsx("button",{type:"button",className:"px-3 py-1.5 text-sm hover:bg-accent",onClick:()=>k("keep_both"),children:"Garder les deux"})]})]})]}),o.jsx("div",{className:"rounded-lg border border-border divide-y divide-border",children:n.map(T=>{const V=$b(T,e),$=V==="needs_resolution"||V==="needs_company";return o.jsxs("div",{className:`flex flex-wrap items-center gap-x-3 gap-y-2 px-3 py-2 ${$?"bg-orange-500/10":"bg-green-500/10"}`,children:[$?o.jsx(an,{className:"w-4 h-4 text-orange-500 flex-shrink-0"}):o.jsx(ew,{className:"w-4 h-4 text-green-600 flex-shrink-0"}),o.jsxs("div",{className:"flex-1 min-w-[180px]",children:[o.jsx("p",{className:"text-sm font-medium text-foreground line-clamp-3 break-words",children:T.name}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:[T.coordinates.length," points",T.resolution&&` · ${Une[T.resolution]}`,V==="needs_company"&&" · société requise",V==="needs_resolution"&&" · conflit à traiter"]})]}),o.jsxs("div",{className:"flex items-center gap-2 ml-auto max-w-full",children:[T.conflict&&o.jsxs(Z,{type:"button",variant:V==="needs_resolution"?"default":"outline",size:"sm",className:"flex-shrink-0",onClick:()=>y(T.index),children:[o.jsx(nY,{className:"w-3.5 h-3.5 mr-1"}),"Comparer"]}),w&&s.length>0&&V!=="ignored"&&o.jsx(FP,{companies:s,value:T.companyId,onChange:H=>_(T.index,{companyId:H}),placeholder:T.resolution==="keep_new"?"Société conservée":"Société...",className:"h-8 w-[200px] max-w-[55vw] text-xs"})]})]},T.index)})})]})]}),!h&&o.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 border-t border-border bg-card px-6 py-4",children:[P>0&&!c&&o.jsxs("span",{className:"text-sm text-orange-500 mr-auto",children:[P," ligne",P>1?"s":""," à traiter"]}),o.jsx(Z,{type:"button",variant:"outline",onClick:a,disabled:c,children:"Annuler"}),f?o.jsxs(Z,{type:"button",onClick:p,disabled:c,children:[o.jsx(ft,{className:"w-4 h-4 mr-2"}),"Reprendre l'import"]}):o.jsx(Z,{type:"button",onClick:l,disabled:c||P>0||N===0,children:c?o.jsxs(o.Fragment,{children:[o.jsx(ft,{className:"w-4 h-4 mr-2 animate-spin"}),"Import⦠",d?`${d.done}/${d.total}`:""]}):o.jsxs(o.Fragment,{children:[o.jsx(No,{className:"w-4 h-4 mr-2"}),"Valider l'import (",N,")"]})})]})]})}),o.jsx(Vne,{isOpen:x!==null&&!!(I!=null&&I.conflict),zoneType:e,existing:(I==null?void 0:I.conflict)??null,existingCompanyName:(S=I==null?void 0:I.conflict)!=null&&S.companyId?j.get(I.conflict.companyId):void 0,incoming:I?{name:I.name,coordinates:I.coordinates}:null,onResolve:T=>{var V;I&&_(I.index,{resolution:T,companyId:T==="keep_new"?((V=I.conflict)==null?void 0:V.companyId)??"":I.companyId}),y(null)},onClose:()=>y(null)})]})}function Wne({result:t,onGoToMap:e,onGoToList:n}){return o.jsxs("div",{className:"space-y-4",children:[t.skipped.length>0&&o.jsx("div",{className:"max-h-40 overflow-y-auto rounded-lg border border-orange-500/30 bg-
4066orange-500/5 p-3 space-y-1",children:t.skipped.map((r,s)=>o.jsxs("p",{className:"text-sm text-foreground",children:[o.jsx("span",{className:"font-medium",children:r.name||`Ligne ${r.index+1}`}),o.jsxs("span",{className:"text-muted-foreground",children:[" : ",r.reason]})]},s))}),o.jsxs("div",{className:"flex gap-2 justify-end",children:[o.jsxs(Z,{type:"button",variant:"outline",onClick:n,children:[o.jsx(qL,{className:"w-4 h-4 mr-2"}),"Voir la liste"]}),o.jsxs(Z,{type:"button",onClick:e,children:[o.jsx(h1,{className:"w-4 h-4 mr-2"}),"Voir sur la carte"]})]})]})}function Hne({zones:t}){const e=u.useRef([]),n=t.map(s=>`${s.name}:${s.coordinates.length}`).join("|"),r=u.useCallback(s=>{e.current.forEach(a=>a.setMap(null)),e.current=[];const i=new google.maps.LatLngBounds;t.forEach((a,l)=>{const c=zP[l%zP.length],d=a.coordinates.map(h=>({lat:h.latitude,lng:h.longitude}));if(d.forEach(h=>i.extend(h)),a.coordinates.length>=3){const h=new google.maps.Polygon({paths:d,fillColor:c,fillOpacity:.35,strokeColor:c,strokeOpacity:1,strokeWeight:2,clickable:!1,map:s});e.current.push(h)}}),i.isEmpty()||s.fitBounds(i,{top:30,right:30,bottom:30,left:30})},[t]);return u.useEffect(()=>()=>{e.current.forEach(s=>s.setMap(null)),e.current=[]},[]),o.jsx("div",{className:"border border-border rounded-lg overflow-hidden h-[220px]",children:o.jsx(Qs,{mapContainerStyle:{width:"100%",height:"100%"},center:{lat:46.603354,lng:1.888334},zoom:6,onLoad:r,options:{disableDefaultUI:!0,zoomControl:!1,mapTypeControl:!1,streetViewControl:!1,fullscreenControl:!1,draggable:!1,scrollwheel:!1,disableDoubleClickZoom:!0,mapTypeId:"hybrid"}},n)})}const $P=50,qne=Object.keys(qa).filter(t=>t!=="other");function Vb(t){return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}function VP(t){return Vb(t).replace(/\b(acca|aica|societe|ste|association|communale|intercommunale|agreee|chasse|de|du|des|la|le|les|d|l)\b/g," ").replace(/\s+/g," ").trim()}function Gne(){var vt;const t=qt(),e=Ft(),{user:n,isSuperAdmin:r}=nn(),[s]=pz(),[i,a]=u.useState("manual"),[l,c]=u.useState(""),[d,h]=u.useState(""),[f,p]=u.useState(""),[g,v]=u.useState([]),[x,y]=u.useState(""),[b,w]=u.useState([]),[j,E]=u.useState(!1),[P,A]=u.useState(""),[N,_]=u.useState(!1),[k,L]=u.useState([]),[I,S]=u.useState(!1),[T,V]=u.useState(null),[$,H]=u.useState(!1),[W,D]=u.useState(null),[F,O]=u.useState(null),[Y,G]=u.useState(!1),q=u.useRef(null),{activeCompanyId:re,companies:U}=cd(),ee=!!n&&!r&&!Bs(n,"federation")&&ED(n),K=u.useMemo(()=>U.filter(me=>me.role==="admin"||me.role==="writer").map(({id:me,name:ot})=>({id:me,name:ot})),[U]),[ue,be]=u.useState(""),le=ee?ue||null:s.get("companyId"),[B,Q]=u.useState(null),ve=f==="huntingTerritory",Ae=x?parseInt(x):void 0,he=ve&&!B&&!!Ae&&!j&&b.length===0;u.useEffect(()=>{As().then(me=>{if(v(me),!r&&!ee&&(n!=null&&n.departmentCode)){const ot=String(n.departmentCode).padStart(2,"0");y(ot)}})}
4066,[r,ee,n==null?void 0:n.departmentCode]),u.useEffect(()=>{if(!ee||ue||K.length===0)return;const me=s.get("companyId"),ot=Se=>!!Se&&K.some(Te=>Te.id===Se);be(ot(me)?me:ot(re)?re:K[0].id)},[ee,ue,re,K,s]),u.useEffect(()=>{if(!r||!B||x)return;const me=B.departmentCode?String(B.departmentCode).padStart(2,"0"):B.zipCode?ec(B.zipCode):"";me&&y(me)},[r,B,x]),u.useEffect(()=>{if(!ee||!B)return;const me=B.departmentCode?String(B.departmentCode).padStart(2,"0"):B.zipCode?ec(B.zipCode):"";me&&y(me)},[ee,B]),u.useEffect(()=>{if(!Ae||ee){w([]);return}let me=!1;return E(!0),Ot.getCompaniesPaginated(100,void 0,Ae).then(ot=>{me||w(ot.companies.map(Se=>({id:Se.id,name:Se.name})).sort((Se,Te)=>Se.name.localeCompare(Te.name)))}).catch(ot=>console.error("Error loading companies:",ot)).finally(()=>{me||E(!1)}),()=>{me=!0}},[Ae,ee]),u.useEffect(()=>{Q(null),le&&Ot.getCompanyById(le).then(me=>{me?Q(me):e.error("Société non trouvée")}).catch(me=>{console.error("Error loading prefilled company:",me),e.error("Erreur lors du chargement de la société")})},[le,e]);const J=()=>{if(!f){e.error("Sélectionnez d'abord le type de zone");return}if(!x){e.error("Sélectionnez d'abord un département");return}if(he){e.error("Aucune société dans ce département : créez-les avant d'importer des territoires");return}const me=document.createElement("input");me.type="file",me.accept=".kml",me.onchange=async ot=>{var Te;const Se=(Te=ot.target.files)==null?void 0:Te[0];if(Se)try{const He=await hv.parseKMLFile(Se);if(!He.isValid){e.error(He.error||"Format non supporté");return}if(!He.zones||He.zones.length===0){e.error("Le fichier KML ne contient pas de zones valides");return}await je(He.zones)}catch(He){console.error("Erreur lors de l'import KML:",He),e.error("Impossible d'analyser le fichier KML")}},me.click()},je=async me=>{let ot=[];try{ot=(await er.getZonesPaginated(5e3,0,void 0,void 0,Ae,[f])).zones}catch(He){console.error("Error loading existing zones:",He)}const Se=new Map;for(const He of ot){const Ut=Vb(He.name||"");Ut&&!Se.has(Ut)&&Se.set(Ut,He)}const Te=new Map;if(f==="huntingTerritory")for(const He of b){const Ut=VP(He.name);Ut&&Te.set(Ut,Te.has(Ut)?"":He.id)}O(null),G(!1),q.current=null,V(me.map((He,Ut)=>{const cn=Se.get(Vb(He.name))??null,xn=(f==="huntingTerritory"||ee||le)&&(le||Te.get(VP(He.name)))||"";return{index:Ut,name:He.name,description:He.description,coordinates:He.coordinates,companyId:xn,conflict:cn,resolution:null}}))},Ve=u.useCallback(async()=>{const me=q.current;if(!me||!f)return;const ot=me.chunks.reduce((Te,He)=>Te+He.length,0),Se=()=>me.chunks.slice(0,me.nextChunk).reduce((Te,He)=>Te+He.length,0);H(!0),G(!1),D({done:Se(),total:ot});try{for(;me.nextChunk<me.chunks.length;){const Te=me.nextChunk,He=await er.createZonesBulk({importId:me.importId,chunkIndex:Te,zoneType:f,departmentCode:Ae,companyId:ee?le??void 0:void 0,zones:me.chunks[Te]});me.acc.created+=He.created,me.acc.updated+=He.updated,me.acc.skipped.push(...He.skipped),me.nextChunk=Te+1,D({done:Se(),total:ot})}f==="huntingTerritory"&&await er.finalizeZoneImport({importId:me.importId,departmentCode:Ae,companyId:ee?le??void 0:void 0}),O({...me.acc,skipped:[...me.acc.skipped]}),e.success(`${me.acc.created+me.acc.updated} zones importées`)}catch(Te){console.error("Error bulk importing zones:",Te),G(!0),e.error("L'import a été interrompu. Cliquez sur « Reprendre » pour continuer.")}finally{H(!1),D(null)}},[f,Ae,ee,le,e]),Ye=u.useCallback(async()=>{if(!T||!f)return;const me=T.filter(Se=>$b(Se,f)==="ready").map(Se=>{const Te=Se.resolution==="keep_new"&&Se.conflict;return{name:Se.name.trim(),description:Se.description||void 0,gpsPoint:Se.coordinates,companyId:Se.companyId||void 0,targetZoneId:Te?Se.conflict.id:void 0}});if(me.length===0)return;const ot=[];for(let Se=0;Se<me.length;Se+=$P)ot.push(me.slice(Se,Se+$P));q.current={importId:crypto.randomUUID(),chunks:ot,nextChunk:0,acc:{created:0,updated:0,skipped:[]}},await Ve()},[T,f,Ve]),Jt=()=>{V(null),O(null),G(!1),q.current=null},Ue=me=>{L(me),e.success(`${me.length} points définis pour la zone`)},rn=async me=>{if(me.preventDefault(),!l.trim()){e.error("Le nom de la zone est requis");return}if(!f){e.error("Veuillez sélectionner le type de zone");return}if(r&&!x){e.error("Veuillez sélectionner un département");return}const ot=le||P||void 0;if(ve&&!ot){e.error("Un territoire doit être assigné à une société");return}if(k.length<3){e.error("Veuillez définir au moins 3 points pour délimiter la zone");return}_(!0);try{const Se=await er.createZone({name:l.trim(),description:d.trim()||void 0,zoneType:f,departmentCode:Ae,gpsPoint:k,companyId:ot});e.success("Zone créée avec succès"),t(ee?mt.myCompany("zautre"):mt.zone(Se.id))}catch(Se){console.error("Error creating zone:",Se),e.error("Erreur lors de la création de la zone")}finally{_(!1)}};return o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx("div",{className:"bg-card border-b border-border px-6 py-4",children:o.jsx("div",{className:"flex items-center justify-between max-w-7xl mx-auto",children:o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs(Z,{variant:"outline",onClick:()=>
4066t(xe.zones),children:[o.jsx(Nr,{className:"w-4 h-4 mr-2"}),"Retour"]}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-foreground font-heading",children:"Créer des zones"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Territoire ou zone d'information, à l'unité ou en lot via un fichier KML"})]})]})})}),o.jsx("div",{className:"max-w-3xl mx-auto p-6",children:o.jsx("form",{onSubmit:rn,children:o.jsxs(ke,{children:[o.jsx(Qt,{children:o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(ur,{className:"w-5 h-5"}),"Informations de la zone"]})}),o.jsxs(Pe,{className:"space-y-6",children:[ee&&K.length>1&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"lockedCompany",children:"Société *"}),o.jsxs(_t,{value:ue,onValueChange:be,children:[o.jsx(St,{id:"lockedCompany",children:o.jsx(Et,{placeholder:"Sélectionnez une société"})}),o.jsx(kt,{children:K.map(me=>o.jsx(Ke,{value:me.id,children:me.name},me.id))})]}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Les zones créées seront rattachées à cette société."})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"department",children:"Département *"}),r?o.jsxs(_t,{value:x,onValueChange:y,children:[o.jsx(St,{children:o.jsx(Et,{placeholder:"Sélectionnez un département"})}),o.jsx(kt,{className:"max-h-[300px]",children:g.map(me=>o.jsxs(Ke,{value:me.code,children:[me.code," - ",me.nom]},me.code))})]}):o.jsx("div",{className:"text-sm text-foreground/80 py-2 px-3 bg-muted rounded-md border",children:x?o.jsxs(o.Fragment,{children:[((vt=g.find(me=>me.code===x))==null?void 0:vt.nom)||(n==null?void 0:n.departmentLabel)," ","(",x,")"]}):"Chargementâ¦"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"zoneType",children:"Type de zone *"}),o.jsxs(_t,{value:f||void 0,onValueChange:me=>p(me),children:[o.jsx(St,{children:o.jsx(Et,{placeholder:"Sélectionnez le type de zone"})}),o.jsx(kt,{children:qne.map(me=>o.jsx(Ke,{value:me,children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Wu[me]}}),qa[me]]})},me))})]})]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[o.jsx("button",{type:"button",onClick:()=>a("manual"),className:`p-4 border-2 rounded-lg text-left transition-colors ${i==="manual"?"border-primary bg-primary/5":"border-border hover:border-primary/40"}`,children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0",children:o.jsx(_f,{className:"w-5 h-5 text-primary"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"font-medium text-foreground",children:"Création manuelle"}),o.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Une zone, dessinée sur la carte"})]})]})}),o.jsx("button",{type:"button",onClick:()=>a("import"),className:`p-4 border-2 rounded-lg text-left transition-colors ${i==="import"?"border-primary bg-primary/5":"border-border hover:border-primary/40"}`,children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0",children:o.jsx(No,{className:"w-5 h-5 text-primary"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"font-medium text-foreground",children:"Import KML"}),o.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Une ou plusieurs zones depuis un fichier"})]})]})})]}),i==="import"?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[o.jsx("p",{children:"Toutes les zones du fichier seront créées d'un coup, avec le département et le type choisis ci-dessus. Le nom et la description de chaque zone viennent du fichier."}),(ve||B)&&o.jsx("p",{children:B?`Elles seront assignées à « ${B.name} ».`:"L'assignation aux sociétés se fait dans l'aperçu, avant validation."})]}),he&&o.jsxs("div",{className:"flex items-start gap-2.5 rounded-lg border border-orange-500/30 bg-
4066orange-500/5 px-4 py-3 text-sm text-foreground",children:[o.jsx(an,{className:"w-4 h-4 text-orange-500 flex-shrink-0 mt-0.5"}),o.jsx("p",{children:"Aucune société dans ce département. Un territoire doit être assigné à une société : créez d'abord les sociétés, puis revenez importer le fichier."})]}),o.jsx("button",{type:"button",onClick:J,disabled:!f||!x||j||he,className:"w-full p-8 border-2 border-dashed border-border rounded-lg hover:border-primary hover:bg-primary/5 transition-colors disabled:opacity-50 disabled:hover:border-border disabled:hover:bg-transparent group",children:o.jsxs("div",{className:"flex flex-col items-center text-center",children:[o.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center mb-3 group-hover:bg-primary/20 transition-colors",children:o.jsx(No,{className:"w-6 h-6 text-primary"})}),o.jsx("h3",{className:"font-medium text-foreground",children:"Choisir un fichier KML"}),o.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:!f||!x?"Sélectionnez d'abord le département et le type de zone":j?"Chargement des sociétés...":he?"Aucune société dans ce département":".kml, 20 Mo maximum"})]})})]}):o.jsxs(o.Fragment,{children:[ve&&(B?o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{children:"Société assignée"}),o.jsxs("div",{className:"flex items-center gap-3 p-3 bg-primary/5 border border-primary/20 rounded-lg",children:[o.jsx(qn,{className:"w-5 h-5 text-primary"}),o.jsxs("div",{className:"flex-1",children:[o.jsx("p",{className:"font-medium text-sm",children:B.name}),B.city&&o.jsx("p",{className:"text-xs text-muted-foreground",children:B.city})]})]})]}):o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"company",children:"Société *"}),o.jsxs(_t,{value:P||void 0,onValueChange:A,disabled:b.length===0,children:[o.jsx(St,{children:o.jsx(Et,{placeholder:b.length===0?"Aucune société dans ce département":"Sélectionnez la société"})}),o.jsx(kt,{className:"max-h-[300px]",children:b.map(me=>o.jsx(Ke,{value:me.id,children:me.name},me.id))})]}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Un territoire de chasse doit être assigné à une société."})]})),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"name",children:"Nom de la zone *"}),o.jsx(Ne,{id:"name",value:l,onChange:me=>c(me.target.value),placeholder:"Ex: Forêt de Fontainebleau",required:!0})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"description",children:"Description"}),o.jsx(bc,{id:"description",value:d,onChange:me=>h(me.target.value),placeholder:"Description optionnelle de la zone...",rows:3})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsx(ne,{children:"Délimitation géographique *"}),k.length===0?o.jsx("button",{type:"button",onClick:()=>S(!0),className:"w-full p-6 border-2 border-dashed border-border rounded-lg hover:border-primary hover:bg-primary/5 transition-colors text-left group",children:o.jsxs("div",{className:"flex flex-col items-center text-center",children:[o.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center mb-3 group-hover:bg-primary/20 transition-colors",children:o.jsx(_f,{className:"w-6 h-6 text-primary"})}),o.jsx("h3",{className:"font-medium text-foreground",children:"Dessiner sur la carte"}),o.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Placez les points directement sur la carte"})]})}):o.jsx(Zne,{coordinates:k,color:f?Wu[f]:"#F66D51",onModify:()=>S(!0),onDelete:()=>L([])})]}),o.jsxs("div",{className:"flex gap-3 pt-4 border-t",children:[o.jsxs(Z,{type:"submit",disabled:N||k.length<3,children:[N?o.jsx(ft,{className:"w-4 h-4 mr-2 animate-spin"}):o.jsx(xc,{className:"w-4 h-4 mr-2"}),"Créer la zone"]}),o.jsx(Z,{type:"button",variant:"outline",onClick:()=>t(xe.zones),children:"Annuler"})]})]})]})]})})}),o.jsx(Rx,{isOpen:I,onClose:()=>S(!1),onSave:Ue,initialCoordinates:k,departmentCode:x}),o.jsx(Bne,{isOpen:!!T&&T.length>0&&!!f,zoneType:f||"other",rows:T??[],onRowsChange:V,companies:b,lockedCompany:B?{id:B.id,name:B.name}
4066:null,onClose:Jt,onConfirm:Ye,importing:$,progress:W,result:F,failed:Y,onResume:Ve,onGoToMap:()=>t(xe.home),onGoToList:()=>t(ee?mt.myCompany("zautre"):xe.zones)})]})}function Zne({coordinates:t,color:e,onModify:n,onDelete:r}){const s=u.useRef(null),i=t.map(c=>`${c.latitude},${c.longitude}`).join("|"),a=u.useCallback(c=>{if(s.current&&s.current.setMap(null),t.length>=3){const d=t.map(h=>({lat:h.latitude,lng:h.longitude}));s.current=new google.maps.Polygon({paths:d,fillColor:e,fillOpacity:.4,strokeColor:e,strokeOpacity:1,strokeWeight:3,clickable:!1,map:c})}if(t.length>0){const d=new google.maps.LatLngBounds;t.forEach(h=>{d.extend({lat:h.latitude,lng:h.longitude})}),c.fitBounds(d,{top:30,right:30,bottom:30,left:30})}},[t,e]);u.useEffect(()=>()=>{s.current&&s.current.setMap(null)},[]);const l=()=>{if(t.length===0)return{lat:46.603354,lng:1.888334};const c=t.reduce((h,f)=>h+f.latitude,0),d=t.reduce((h,f)=>h+f.longitude,0);return{lat:c/t.length,lng:d/t.length}};return o.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[o.jsxs("div",{className:"h-[250px] relative",children:[o.jsx(Qs,{mapContainerStyle:{width:"100%",height:"100%"},center:l(),zoom:12,onLoad:a,options:{disableDefaultUI:!0,zoomControl:!1,mapTypeControl:!1,streetViewControl:!1,fullscreenControl:!1,draggable:!1,scrollwheel:!1,disableDoubleClickZoom:!0,mapTypeId:"hybrid"}},i),o.jsxs("div",{className:"absolute top-3 left-3 bg-card/90 backdrop-blur-sm px-3 py-1.5 rounded-full text-sm font-medium text-foreground/80 shadow-sm",children:[t.length," points"]})]}),o.jsxs("div",{className:"flex items-center justify-end gap-2 p-3 bg-muted border-t",children:[o.jsxs(Z,{type:"button",variant:"outline",size:"sm",onClick:n,children:[o.jsx(_f,{className:"w-4 h-4 mr-1"}),"Modifier"]}),o.jsxs(Z,{type:"button",variant:"outline",size:"sm",onClick:r,className:"text-red-600 hover:text-red-700 hover:bg-red-500/10",children:[o.jsx(Vt,{className:"w-4 h-4 mr-1"}),"Supprimer"]})]})]})}function pt({className:t,...e}){return o.jsx("div",{"data-slot":"skeleton",className:Oe("bg-muted animate-pulse rounded-md",t),...e})}function Fx(){return o.jsx("div",{className:"bg-card border-b border-border px-4 md:px-8 py-4",children:o.jsxs("div",{className:"flex items-center justify-between max-w-4xl mx-auto",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(pt,{className:"h-9 w-20 rounded-lg"}),o.jsx(Hn,{orientation:"vertical",className:"h-6"}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(pt,{className:"h-5 w-40"}),o.jsx(pt,{className:"h-4 w-24"})]})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(pt,{className:"h-9 w-24 rounded-lg"}),o.jsx(pt,{className:"h-9 w-28 rounded-lg"})]})]})})}function W1({showMap:t=!0}){return o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6",children:[o.jsx(pt,{className:"h-5 w-32 mb-4"}),o.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[o.jsxs("div",{className:"flex-1 space-y-4",children:[o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-4",children:[1,2,3].map(e=>o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(pt,{className:"h-3 w-16"}),o.jsx(pt,{className:"h-4 w-32"})]},e))}),o.jsx(Hn,{}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(pt,{className:"h-3 w-20"}),o.jsx(pt,{className:"h-4 w-full max-w-xs"})]})]}),t&&o.jsx(pt,{className:"lg:w-72 h-52 rounded-xl flex-shrink-0"})]})]})})}function Kne(){return o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6",children:[o.jsx(pt,{className:"h-5 w-24 mb-4"}),o.jsx("div",{className:"flex gap-3",children:[1,2,3].map(t=>o.jsx(pt,{className:"w-36 h-28 rounded-lg flex-shrink-0"},t))})]})})}function Yne(){return o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6",children:[o.jsx(pt,{className:"h-5 w-40 mb-4"}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(pt,{className:"h-3 w-24"}),o.jsx(pt,{className:"h-12 w-full rounded-xl"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(pt,{className:"h-3 w-32"}),o.jsx(pt,{className:"h-12 w-full rounded-xl"})]})]}),o.jsx(pt,{className:"h-9 w-48 mt-4 rounded-lg"})]})})}function Qne({rows:t=2}){return o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6",children:[o.jsx(pt,{className:"h-5 w-28 mb-4"}),o.jsx("div",{className:"space-y-3",children:Array.from({length:t}).map((e,n)=>o.jsxs("div",{className:"p-4 rounded-lg border border-border space-y-2",children:[o.jsxs("div",{className:"flex justify-between",children:[o.jsx(pt,{className:"h-4 w-28"}),o.jsx(pt,{className:"h-3 w-20"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsx(pt,{className:"h-3 w-24"}),o.jsx(pt,{className:"h-3 w-20"})]})]},n))})]})})}function Tf({rows:t=3}){return o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6",children:[o.jsx(pt,{className:"h-5 w-24 mb-4"}),o.jsx("div",{className:"space-y-2",children:Array.from({length:t}).map((e,n)=>o.jsxs("div",{className:"flex items-center gap-3 p-2.5 rounded-lg",children:[o.jsx(pt,{className:"h-8 w-8 rounded-full"}),o.jsxs("div",{className:"flex-1 space-y-1.5",children:[o.jsx(pt,{className:"h-4 w-28"}),o.jsx(pt,{className:"h-3 w-36"})]}),o.jsx(pt,{className:"h-5 w-16 rounded-md"})]},n))})]})})}function VO(){return o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6 space-y-4",children:[o.jsx(pt,{className:"h-5 w-28"}),o.jsxs("div",{className:"space-y-3",children:[o.jsx(pt,{className:"h-12 w-full rounded-xl"}),o.jsx(pt,{className:"h-20 w-full rounded-xl"})]})]})}
4066),o.jsx(pt,{className:"h-64 rounded-xl"})]})}function H1(){return o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx(Fx,{}),o.jsxs("div",{className:"max-w-4xl mx-auto px-4 md:px-8 py-6 space-y-6",children:[o.jsx(W1,{}),o.jsx(Kne,{}),o.jsx(Yne,{}),o.jsx(Qne,{})]})]})}function Xne(){return o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx(Fx,{}),o.jsxs("div",{className:"max-w-7xl mx-auto p-6 space-y-6",children:[o.jsx(VO,{}),o.jsx(Tf,{}),o.jsx(Tf,{})]})]})}function Jne(){return o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx(Fx,{}),o.jsxs("div",{className:"max-w-5xl mx-auto p-6 space-y-6",children:[o.jsx(W1,{showMap:!1}),o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6 space-y-4",children:[o.jsx(pt,{className:"h-5 w-20"}),o.jsx("div",{className:"flex flex-wrap gap-2",children:[1,2,3,4].map(t=>o.jsx(pt,{className:"h-8 w-24 rounded-lg"},t))})]})}),o.jsx(Tf,{rows:2})]})]})}function UO(){return o.jsxs("div",{className:"p-4 md:p-8 max-w-2xl mx-auto space-y-6",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx(pt,{className:"h-14 w-14 rounded-full"}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(pt,{className:"h-6 w-40"}),o.jsx(pt,{className:"h-4 w-28"})]})]}),o.jsx(W1,{showMap:!1}),o.jsx(Tf,{rows:3})]})}const ere={async getLouvetiersByDepartment(t){try{return(await pe(ge,"getLouvetiers")({departmentCode:t})).data.louvetiers||[]}catch(e){return console.error("Error fetching louvetiers:",e),[]}},async getLouvetierById(t){try{const e=await ms(Ht(Xe,"users",t));return e.exists()?{id:e.id,...e.data()}:null}catch(e){return console.error("Error fetching louvetier:",e),null}},async searchLouvetiers(t,e){try{return(await pe(ge,"searchLouvetiers")({departmentCode:t,searchTerm:e})).data.louvetiers||[]}catch(n){return console.error("Error searching louvetiers:",n),[]}},async createLouvetier(t){const n=await pe(ge,"createLouvetier")(t),{louvetierId:r}=n.data,s=await this.getLouvetierById(r);if(!s)throw new Error("Failed to create louvetier");return s},async updateLouvetier(t,e){await pe(ge,"updateLouvetier")({louvetierId:t,...e})},async deleteLouvetier(t){await pe(ge,"deleteLouvetier")({louvetierId:t})},async getLouvetiersByZone(t){try{return(await pe(ge,"getLouvetiersByZone")({zoneId:t})).data.louvetiers||[]}catch(e){return console.error("Error fetching louvetiers by zone:",e),[]}}},tre={async getTrappersByDepartment(t){try{return(await pe(ge,"getTrappers")({departmentCode:t})).data.trappers||[]}catch(e){return console.error("Error fetching trappers:",e),[]}},async getTrapperById(t){try{const e=await ms(Ht(Xe,"users",t));return e.exists()?{id:e.id,...e.data()}:null}catch(e){return console.error("Error fetching trapper:",e),null}},async searchTrappers(t,e){try{return(await pe(ge,"searchTrappers")({departmentCode:t,searchTerm:e})).data.trappers||[]}catch(n){return console.error("Error searching trappers:",n),[]}},async getTrappersByZone(t){try{return(await pe(ge,"getTrappersByZone")({zoneId:t})).data.trappers||[]}catch(e){return console.error("Error fetching trappers by zone:",e),[]}},async createTrapper(t){const n=await pe(ge,"createTrapper")(t),{trapperId:r}=n.data,s=await this.getTrapperById(r);if(!s)throw new Error("Failed to create trapper");return s}};function UP(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}function nre(){const{zoneId:t}=Ys(),e=qt(),n=Ft(),{user:r,isSuperAdmin:s}=nn(),[i,a]=u.useState(null),[l,c]=u.useState(!0),[d,h]=u.useState(!1),[f,p]=u.useState(""),[g,v]=u.useState(""),[x,y]=u.useState(""),[b,w]=u.useState(null),[j,E]=u.useState([]),[P,A]=u.useState([]),[N,_]=u.useState(""),[k,L]=u.useState(""),[I,S]=u.useState(null),[T,V]=u.useState([]),[$,H]=u.useState([]),[W,D]=u.useState(""),[F,O]=u.useState([]),[Y,G]=u.useState(!1),[q,re]=u.useState(""),[U,ee]=u.useState([]),[K,ue]=u.useState(!1),[be,le]=u.useState(""),[B,Q]=u.useState([]),[ve,Ae]=u.useState(!1),[he,J]=u.useState(!1),[je,Ve]=u.useState(!1),[Ye,Jt]=u.useState(!1),Ue=ei(W,500),rn=ei(q,500),vt=ei(be,500),me=Bs(r,"federation"),ot=Bs(r,"ddt"),Se=Bs(r,"asso_piegeurs"),Te=s||me,He=s||me||ot,Ut=s||me,cn=s||ot,xn=s||me||Se,un=u.useMemo(()=>
4066{if(!i)return!1;if(N!==g||k!==x)return!0;const oe=(b==null?void 0:b.id)||null,De=(I==null?void 0:I.id)||null;return oe!==De||JSON.stringify([...j].sort())!==JSON.stringify([...T].sort())||JSON.stringify([...P].sort())!==JSON.stringify([...$].sort())},[i,N,k,g,x,b,I,j,T,P,$]),Yt=u.useCallback(async()=>{if(t){c(!0),p("");try{const oe=await er.getZoneById(t);if(!oe){p("Zone non trouvée");return}a(oe),_(oe.name),L(oe.description||""),v(oe.name),y(oe.description||"");let De=null;oe.companyId&&(De=await Ot.getCompanyById(oe.companyId)),w(De),S(De);const $t=oe.louvetierEmails||[],En=oe.trapperEmails||[];E($t),V($t),A(En),H(En)}catch(oe){console.error("Error loading zone:",oe),p("Erreur lors du chargement de la zone")}finally{c(!1)}}},[t]);u.useEffect(()=>{Yt()},[Yt]),u.useEffect(()=>{if(Ue.length<3){O([]);return}(async()=>{G(!0);try{const De=await Ot.searchCompanies(Ue);O(De)}catch(De){console.error("Error searching companies:",De)}finally{G(!1)}})()},[Ue]),u.useEffect(()=>{if(rn.length<3){ee([]);return}(async()=>{ue(!0);try{const De=await ere.searchLouvetiers(r.departmentCode,rn);ee(De.filter($t=>!T.includes($t.email.toLowerCase())))}catch(De){console.error("Error searching louvetiers:",De)}finally{ue(!1)}})()},[rn,r,T]),u.useEffect(()=>{if(vt.length<3){Q([]);return}(async()=>{Ae(!0);try{const De=await tre.searchTrappers(r.departmentCode,vt);Q(De.filter($t=>!$.includes($t.email.toLowerCase())))}catch(De){console.error("Error searching trappers:",De)}finally{Ae(!1)}})()},[vt,r,$]);const st=oe=>{S(oe),D(""),O([])},de=()=>{S(null)},ze=oe=>{const De=oe.toLowerCase().trim();T.includes(De)||V([...T,De]),re(""),ee([])},Qe=oe=>{V(T.filter(De=>De!==oe))},It=oe=>{const De=oe.toLowerCase().trim();$.includes(De)||H([...$,De]),le(""),Q([])},se=oe=>{H($.filter(De=>De!==oe))},Re=async()=>{if(i){h(!0);try{const oe={};N!==g&&(oe.name=N),k!==x&&(oe.description=k);const De=(b==null?void 0:b.id)||null,$t=(I==null?void 0:I.id)||null;De!==$t&&(oe.companyId=$t),JSON.stringify([...j].sort())!==JSON.stringify([...T].sort())&&(oe.louvetierEmails=T),JSON.stringify([...P].sort())!==JSON.stringify([...$].sort())&&(oe.trapperEmails=$),Object.keys(oe).length>0&&await er.updateZone(i.id,oe),n.success("Zone mise à jour"),await Yt()}catch(oe){console.error("Error saving zone:",oe),n.error("Erreur lors de la sauvegarde")}finally{h(!1)}}},ae=()=>{_(g),L(x),S(b),V(j),H(P)}
4066,et=async oe=>{if(i){Ve(!1),h(!0);try{await er.updateZone(i.id,{gpsPoint:oe}),n.success("Tracé mis à jour"),await Yt()}catch(De){console.error("Error saving geometry:",De),n.error("Erreur lors de la mise à jour du tracé")}finally{h(!1)}}},xt=async()=>{if(i){Jt(!0);try{await er.deleteZone(i.id),n.success("Zone supprimée"),e(xe.zones)}catch(oe){console.error("Error deleting zone:",oe),n.error(oe.message||"Erreur lors de la suppression"),J(!1)}finally{Jt(!1)}}};if(l)return o.jsx(Xne,{});if(!i)return o.jsxs("div",{className:"p-6",children:[o.jsxs(yr,{variant:"destructive",children:[o.jsx(an,{className:"h-4 w-4"}),o.jsx(wr,{children:f||"Zone non trouvée"})]}),o.jsxs(Z,{onClick:()=>e(xe.zones),className:"mt-4",children:[o.jsx(Nr,{className:"w-4 h-4 mr-2"}),"Retour à la liste"]})]});const zt=UP(q.trim())&&U.length===0&&!K&&!T.includes(q.trim().toLowerCase()),$e=UP(be.trim())&&B.length===0&&!ve&&!$.includes(be.trim().toLowerCase());return o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx("div",{className:"bg-card border-b border-border px-4 md:px-8 py-4",children:o.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 max-w-[1400px]",children:[o.jsxs("div",{className:"flex items-center gap-3 md:gap-4",children:[o.jsxs(Z,{variant:"outline",onClick:()=>e(xe.zones),children:[o.jsx(Nr,{className:"w-4 h-4 mr-2"}),"Retour"]}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-foreground font-heading",children:i.name}),o.jsx("p",{className:"text-sm text-muted-foreground",children:qa[i.zoneType]??"Zone"})]})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(Z,{variant:"outline",onClick:Yt,disabled:d,children:[o.jsx(ft,{className:"w-4 h-4 mr-2"}),"Actualiser"]}),He&&un&&o.jsx(Z,{variant:"outline",onClick:ae,disabled:d,children:"Annuler"}),He&&o.jsxs(Z,{onClick:Re,disabled:d||!un,children:[d?o.jsx(ft,{className:"w-4 h-4 mr-2 animate-spin"}):o.jsx(xc,{className:"w-4 h-4 mr-2"}),"Enregistrer"]}),He&&o.jsxs(Z,{variant:"outline",onClick:()=>J(!0),disabled:d,className:"text-red-600 hover:text-red-700 hover:bg-red-500/10 border-red-500/20",children:[o.jsx(Vt,{className:"w-4 h-4 mr-2"}),"Supprimer"]})]})]})}),o.jsxs("div",{className:"max-w-7xl mx-auto p-6 space-y-6",children:[f&&o.jsxs(yr,{variant:"destructive",children:[o.jsx(an,{className:"h-4 w-4"}),o.jsx(wr,{children:f})]}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[o.jsxs(ke,{children:[o.jsx(Qt,{children:o.jsx(Xt,{children:"Informations"})}),o.jsxs(Pe,{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"name",children:"Nom"}),o.jsx(Ne,{id:"name",value:N,onChange:oe=>_(oe.target.value),disabled:!Te})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"description",children:"Description"}),o.jsx(bc,{id:"description",value:k,onChange:oe=>L(oe.target.value),rows:3,disabled:!Te})]})]})]}),o.jsxs(ke,{children:[o.jsx(Qt,{children:o.jsxs(Xt,{className:"flex items-center justify-between gap-2",children:[o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx(ur,{className:"w-5 h-5"}),"Carte"]}),Te&&o.jsx(Z,{type:"button",variant:"outline",size:"sm",onClick:()=>Ve(!0),disabled:d,children:"Modifier le tracé"})]})}),o.jsx(Pe,{children:o.jsx(rre,{gpsPoints:i.gpsPoint})})]})]}),Ut&&o.jsxs(ke,{children:[o.jsx(Qt,{children:o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(qn,{className:"w-5 h-5"}),"Société de chasse"]})}),o.jsxs(Pe,{children:[I?o.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted rounded-lg cursor-pointer hover:bg-muted transition-colors",onClick:()=>e(mt.company(I.id)),children:[o.jsxs("div",{children:[o.jsx("p",{className:"font-medium",children:I.name}),I.city&&o.jsx("p",{className:"text-sm text-muted-foreground",children:I.city})]}),o.jsx("div",{className:"flex items-center gap-1",children:o.jsx(Z,{variant:"ghost",size:"icon",onClick:oe=>{oe.stopPropagation(),de()},disabled:d,children:o.jsx(br,{className:"h-4 w-4"})})})]}):o.jsxs("div",{className:"text-center py-4 text-muted-foreground",children:[o.jsx(qn,{
4066className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/40"}),o.jsx("p",{className:"text-sm",children:"Aucune société assignée"})]}),!I&&o.jsxs("div",{className:"mt-4 space-y-2",children:[o.jsx(Hn,{}),o.jsx(ne,{children:"Assigner une société"}),o.jsxs("div",{className:"relative",children:[o.jsx(Ws,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground/60"}),o.jsx(Ne,{placeholder:"Rechercher une société...",value:W,onChange:oe=>D(oe.target.value),className:"pl-10"})]}),Y&&o.jsx("p",{className:"text-sm text-muted-foreground",children:"Recherche..."}),F.length>0&&o.jsx("div",{className:"border rounded-lg divide-y max-h-[200px] overflow-y-auto",children:F.map(oe=>o.jsxs("button",{className:"w-full p-2 text-left hover:bg-muted flex items-center justify-between",onClick:()=>st(oe),children:[o.jsx("span",{children:oe.name}),o.jsx(hr,{className:"h-4 w-4 text-muted-foreground/60"})]},oe.id))})]})]})]}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[xn&&o.jsxs(ke,{children:[o.jsx(Qt,{children:o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(cr,{className:"w-5 h-5"}),"Piégeurs (",$.length,")"]})}),o.jsxs(Pe,{children:[$.length>0?o.jsx("div",{className:"space-y-2",children:$.map(oe=>o.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted rounded-lg",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-green-500/15 flex items-center justify-center",children:o.jsx(cr,{className:"h-5 w-5 text-green-600"})}),o.jsx("p",{className:"font-medium",children:oe})]}),o.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>se(oe),disabled:d,children:o.jsx(Vt,{className:"h-4 w-4 text-red-500"})})]},oe))}):o.jsxs("div",{className:"text-center py-6 text-muted-foreground",children:[o.jsx(cr,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/40"}),o.jsx("p",{className:"text-sm",children:"Aucun piégeur assigné"})]}),o.jsxs("div",{className:"mt-4 space-y-2",children:[o.jsx(Hn,{}),o.jsx(ne,{children:"Ajouter un piégeur"}),o.jsxs("div",{className:"relative",children:[o.jsx(Ws,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground/60"}),o.jsx(Ne,{placeholder:"Rechercher ou saisir un email...",value:be,onChange:oe=>le(oe.target.value),className:"pl-10"})]}),ve&&o.jsx("p",{className:"text-sm text-muted-foreground",children:"Recherche..."}),B.length>0&&o.jsx("div",{className:"border rounded-lg divide-y max-h-[200px] overflow-y-auto",children:B.map(oe=>o.jsxs("button",{className:"w-full p-2 text-left hover:bg-muted flex items-center justify-between",onClick:()=>It(oe.email),children:[o.jsxs("div",{children:[o.jsx("span",{className:"font-medium",children:oe.firstName&&oe.lastName?`${oe.firstName} ${oe.lastName}`:oe.pseudo||oe.email}),o.jsx("span",{className:"text-sm text-muted-foreground ml-2",children:oe.email})]}),o.jsx(hr,{className:"h-4 w-4 text-muted-foreground/60"})]},oe.id))}),$e&&o.jsxs("button",{className:"w-full p-3 border border-dashed rounded-lg hover:bg-muted flex items-center justify-center gap-2 text-sm text-muted-foreground",onClick:()=>It(be.trim()),children:[o.jsx(sc,{className:"h-4 w-4"}),"Ajouter ",be.trim()]})]})]})]}),cn&&o.jsxs(ke,{children:[o.jsx(Qt,{children:o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(cr,{className:"w-5 h-5"}),"Louvetiers (",T.length,")"]})}),o.jsxs(Pe,{children:[T.length>0?o.jsx("div",{className:"space-y-2",children:T.map(oe=>o.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted rounded-lg",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-blue-500/100/15 flex items-center justify-center",children:o.jsx(cr,{className:"h-5 w-5 text-blue-600"})}),o.jsx("p",{className:"font-medium",children:oe})]}),o.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>Qe(oe),disabled:d,children:o.jsx(Vt,{className:"h-4 w-4 text-red-500"})})]},oe))}):o.jsxs("div",{className:"text-center py-6 text-muted-foreground",children:[o.jsx(cr,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground
4066/40"}),o.jsx("p",{className:"text-sm",children:"Aucun louvetier assigné"})]}),o.jsxs("div",{className:"mt-4 space-y-2",children:[o.jsx(Hn,{}),o.jsx(ne,{children:"Ajouter un louvetier"}),o.jsxs("div",{className:"relative",children:[o.jsx(Ws,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground/60"}),o.jsx(Ne,{placeholder:"Rechercher ou saisir un email...",value:q,onChange:oe=>re(oe.target.value),className:"pl-10"})]}),K&&o.jsx("p",{className:"text-sm text-muted-foreground",children:"Recherche..."}),U.length>0&&o.jsx("div",{className:"border rounded-lg divide-y max-h-[200px] overflow-y-auto",children:U.map(oe=>o.jsxs("button",{className:"w-full p-2 text-left hover:bg-muted flex items-center justify-between",onClick:()=>ze(oe.email),children:[o.jsxs("div",{children:[o.jsx("span",{className:"font-medium",children:oe.firstName&&oe.lastName?`${oe.firstName} ${oe.lastName}`:oe.email}),o.jsx("span",{className:"text-sm text-muted-foreground ml-2",children:oe.email})]}),o.jsx(hr,{className:"h-4 w-4 text-muted-foreground/60"})]},oe.id))}),zt&&o.jsxs("button",{className:"w-full p-3 border border-dashed rounded-lg hover:bg-muted flex items-center justify-center gap-2 text-sm text-muted-foreground",onClick:()=>ze(q.trim()),children:[o.jsx(sc,{className:"h-4 w-4"}),"Ajouter ",q.trim()]})]})]})]})]})]}),o.jsx(Rx,{isOpen:je,onClose:()=>Ve(!1),onSave:et,initialCoordinates:i.gpsPoint??[],departmentCode:i.departmentCode?String(i.departmentCode).padStart(2,"0"):void 0}),o.jsx(Dn,{open:he,onOpenChange:J,children:o.jsxs(Ln,{children:[o.jsxs(Mn,{children:[o.jsx(Fn,{children:"Supprimer cette zone ?"}),o.jsxs(zn,{children:['Ãtes-vous sûr de vouloir supprimer la zone "',i.name,'" ? Cette action est irréversible.']})]}),o.jsxs(On,{children:[o.jsx(Vn,{disabled:Ye,children:"Annuler"}),o.jsx($n,{onClick:xt,disabled:Ye,className:"bg-red-600 hover:bg-red-700",children:Ye?"Suppression...":"Supprimer"})]})]})})]})}function rre({gpsPoints:t}){const e="#F66D51",n=u.useRef(null),r=t&&t.length>=3,s=(t==null?void 0:t.map(l=>`${l.latitude},${l.longitude}`).join("|"))||"empty",i=u.useCallback(l=>{if(n.current&&n.current.setMap(null),r){const c=t.map(h=>({lat:h.latitude,lng:h.longitude}));n.current=new google.maps.Polygon({paths:c,fillColor:e,fillOpacity:.4,strokeColor:e,strokeOpacity:1,strokeWeight:3,clickable:!1,map:l});const d=new google.maps.LatLngBounds;t.forEach(h=>{d.extend({lat:h.latitude,lng:h.longitude})}),l.fitBounds(d,{top:40,right:40,bottom:40,left:40})}},[t,r,e]);u.useEffect(()=>()=>{n.current&&n.current.setMap(null)},[]);const a=()=>{if(!r)return{lat:46.603354,lng:1.888334};const l=t.reduce((d,h)=>d+h.latitude,0),c=t.reduce((d,h)=>d+h.longitude,0);return{lat:l/t.length,lng:c/t.length}};return r?o.jsx("div",{className:"rounded-lg overflow-hidden border border-border",children:o.jsxs("div",{className:"h-[300px] relative",children:[o.jsx(Qs,{mapContainerStyle:{width:"100%",height:"100%"},center:a(),zoom:12,onLoad:i,options:{disableDefaultUI:!0,zoomControl:!0,mapTypeControl:!0,streetViewControl:!1,fullscreenControl:!0,mapTypeId:"hybrid"}},s),o.jsxs("div",{className:"absolute top-3 left-3 bg-card/90 backdrop-blur-sm px-3 py-1.5 rounded-full text-sm font-medium text-foreground/80 shadow-sm",children:[t.length," points"]})]})}):o.jsx("div",{className:"bg-muted rounded-lg h-[300px] flex items-center justify-center text-muted-foreground",children:o.jsxs("div",{className:"text-center",children:[o.jsx(ur,{className:"h-12 w-12 mx-auto mb-2 text-muted-foreground/40"}),o.jsx("p",{children:"Aucune zone définie"}),o.jsxs("p",{className:"text-sm",children:[(t==null?void 0:t.length)||0," points GPS"]})]})})}const BP=20;function sre(){const t=qt(),{user:e,isSuperAdmin:n}=nn(),r=e?Bs(e,"federation")&&!n:!1,[s,i]=u.useState({companies:[],totalCount:0,hasMore:!1,lastDocId:null,isSearchResult:!1}),[a,l]=u.useState(!0),[c,d]=u.useState(""),[h,f]=u.useState([]),[p,g]=u.useState(r?String((e==null?void 0:e.departmentCode)||""):"all"),[v,x]=u.useState("all"),[y,b]=u.useState([null]),[w,j]=u.useState(0),E=ei(c,300),P=E.length>=3?E:"";u.useEffect(()=>{As().then(f)},[]);const A=u.useCallback(async(I=null)=>{l(!0);try{const S=r?e==null?void 0:e.departmentCode:p!=="all"?parseInt(p):void 0,T=await Ot.getCompaniesPaginated(BP,P||void 0,S,I,v!=="all"?v:void 0);i(T)}catch(S){console.error("Error loading companies:",S)}finally{l(!1)}},[P,p,r,e==null?void 0:e.departmentCode,v]);u.useEffect(()=>{b([null]),j(0),A(null)},[P,p,v,A]);const N=I=>{g(I)},_=()=>{if(s.hasMore&&s.lastDocId&&!s.isSearchResult){const I=[...y,s.lastDocId];b(I),j(w+1),A(s.lastDocId)}},k=()=>
4066{if(w>0&&!s.isSearchResult){const I=y[w-1];j(w-1),A(I)}},L=Math.ceil(s.totalCount/BP);return o.jsxs("div",{className:"p-4 md:p-8 space-y-5 md:space-y-6 max-w-[1400px]",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-foreground font-heading",children:"Gestion des sociétés"}),o.jsx("p",{className:"text-muted-foreground mt-1",children:r?`Sociétés de chasse du département ${(e==null?void 0:e.departmentLabel)||""}`:"Sociétés de chasse nationales"})]}),n&&o.jsxs(Z,{onClick:()=>t(xe.companyNew),children:[o.jsx(hr,{className:"h-4 w-4 mr-2"}),"Nouvelle société"]})]}),o.jsx(ke,{children:o.jsx(Pe,{className:"pt-6",children:o.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[o.jsxs("div",{className:"relative flex-1 min-w-[250px] max-w-md",children:[o.jsx(Ws,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground/60"}),o.jsx(Ne,{placeholder:"Rechercher par nom",value:c,onChange:I=>d(I.target.value),className:"pl-10"})]}),h.length>0&&!r&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Rn,{className:"h-4 w-4 text-muted-foreground/60"}),o.jsxs(_t,{value:p,onValueChange:N,children:[o.jsx(St,{className:"w-[250px]",children:o.jsx(Et,{placeholder:"Tous les départements"})}),o.jsxs(kt,{className:"max-h-[300px]",children:[o.jsx(Ke,{value:"all",children:"Tous les départements"}),h.map(I=>o.jsxs(Ke,{value:I.code,children:[I.code," - ",I.nom]},I.code))]})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ur,{className:"h-4 w-4 text-muted-foreground/60"}),o.jsxs(_t,{value:v,onValueChange:I=>x(I),children:[o.jsx(St,{className:"w-[220px]",children:o.jsx(Et,{})}),o.jsxs(kt,{children:[o.jsx(Ke,{value:"all",children:"Avec ou sans territoire"}),o.jsx(Ke,{value:"with_territory",children:"Avec territoire"}),o.jsx(Ke,{value:"without_territory",children:"Sans territoire"})]})]})]}),o.jsxs("div",{className:"text-sm text-muted-foreground",children:[s.totalCount," société",s.totalCount>1?"s":""]})]})})}),o.jsx(ke,{children:o.jsx(Pe,{className:"pt-6",children:a?o.jsxs("div",{className:"text-center py-16",children:[o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-primary/20 border-t-primary mx-auto"}),o.jsx("p",{className:"text-muted-foreground mt-4 text-sm",children:"Chargement..."})]}):s.companies.length===0?o.jsxs("div",{className:"text-center py-16 text-muted-foreground",children:[o.jsx("div",{className:"inline-flex items-center justify-center h-14 w-14 rounded-full bg-muted mb-4",children:o.jsx(qn,{className:"h-6 w-6 text-muted-foreground/60"})}),o.jsx("p",{className:"font-medium",children:"Aucune société trouvée"}),(c||p!=="all")&&o.jsx("p",{className:"text-sm mt-1.5 text-muted-foreground/70",children:"Essayez de modifier vos critères de recherche"})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"overflow-x-auto",children:o.jsxs(Ya,{children:[o.jsx(Qa,{children:o.jsxs(Fr,{children:[o.jsx(dt,{children:"Nom"}),o.jsx(dt,{children:"Département"}),o.jsx(dt,{children:"Ville"}),o.jsx(dt,{children:"Territoire"}),o.jsx(dt,{children:"Téléphone"}),o.jsx(dt,{className:"w-12"})]})}),o.jsx(Xa,{children:s.companies.map(I=>o.jsx(ore,{company:I,departments:h},I.id))})]})}),!s.isSearchResult&&o.jsxs("div",{className:"flex items-center justify-between mt-4 pt-4 border-t",children:[o.jsxs("div",{className:"text-sm text-muted-foreground",children:[s.totalCount," société",s.totalCount>1?"s":""]}),o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs("div",{className:"text-sm text-muted-foreground",children:["Page ",w+1,L>0&&o.jsxs(o.Fragment,{children:[" / ",L]})]}),o.jsxs("div",{className:"flex gap-1",children:[o.jsx(Z,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:k,disabled:w===0,title:"Page précédente",children:o.jsx(vc,{className:"h-4 w-4"})}),o.jsx(Z,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:_,disabled:!s.hasMore,title:"Page suivante",children:o.jsx(nr,{className:"h-4 w-4"})})]})]})]})]})})})]})}function ore({company:t,departments:e}){const n=qt();return o.jsxs(Fr,{className:"hover:bg-muted cursor-pointer",onClick:()=>n(mt.company(t.id)),children:[o.jsx(ht,{children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-emerald-100 flex items-center justify-center",children:o.jsx(qn,{
4066className:"h-5 w-5 text-emerald-600"})}),o.jsx("div",{className:"font-medium",children:t.name})]})}),o.jsx(ht,{children:o.jsx("div",{className:"text-sm text-muted-foreground",children:t.zipCode?qg(ec(t.zipCode),e):"-"})}),o.jsx(ht,{children:o.jsxs("div",{className:"text-sm text-muted-foreground",children:[t.city||"-",t.zipCode?` (${t.zipCode})`:""]})}),o.jsx(ht,{children:t.hasTerritory===void 0?o.jsx("span",{className:"text-sm text-muted-foreground",children:"-"}):t.hasTerritory?o.jsx(We,{variant:"secondary",children:"Territoire"}):o.jsx(We,{variant:"outline",className:"text-orange-500 border-orange-500/20",children:"Aucun territoire"})}),o.jsx(ht,{children:o.jsx("div",{className:"text-sm text-muted-foreground",children:t.phone||"-"})}),o.jsx(ht,{children:o.jsx(Z,{variant:"ghost",size:"icon",children:o.jsx(nr,{className:"h-4 w-4"})})})]})}function ire(t,e=new Date){var s,i,a,l;if(t.status==="cancelled")return"cancelled";const n=((i=(s=t.startDate)==null?void 0:s.toDate)==null?void 0:i.call(s))??null,r=((l=(a=t.endDate)==null?void 0:a.toDate)==null?void 0:l.call(a))??null;return!n||!r?t.status:e<n?"scheduled":e>r?"done":"inProgress"}function are(t,e){return{id:t,companyId:e.companyId??"",creatorId:e.creatorId??"",chefDeBattueId:e.chefDeBattueId??"",name:e.name??"Battue",huntingZoneId:e.huntingZoneId??"",huntingZoneName:e.huntingZoneName??void 0,startDate:e.startDate??e.date??null,endD
4066ate:e.endDate??e.date??null,status:e.status??"draft",posteIds:Array.isArray(e.posteIds)?e.posteIds:[],registeredHunterIds:Array.isArray(e.registeredHunterIds)?e.registeredHunterIds:[],presence:e.presence??{},assignments:e.assignments??{},externalHunters:Array.isArray(e.externalHunters)?e.externalHunters:[],rabatteurIds:Array.isArray(e.rabatteurIds)?e.rabatteurIds:[],groups:Array.isArray(e.groups)?e.groups:[],createdAt:e.createdAt??null}}const Bl={async listByCompany(t){const e=Gr(jn(Xe,"battues"),is("companyId","==",t)),r=(await Yr(e)).docs.map(s=>are(s.id,s.data()));return r.sort((s,i)=>{var c,d,h,f;const a=((d=(c=s.startDate)==null?void 0:c.toMillis)==null?void 0:d.call(c))??0;return(((f=(h=i.startDate)==null?void 0:h.toMillis)==null?void 0:f.call(h))??0)-a}),r},async create(t){return(await ld(jn(Xe,"battues"),{companyId:t.companyId,creatorId:t.creatorId,chefDeBattueId:t.chefDeBattueId,name:t.name,huntingZoneId:t.huntingZoneId,huntingZoneName:t.huntingZoneName??null,startDate:gn.fromDate(t.startDate),endDate:gn.fromDate(t.endDate),status:t.status??"scheduled",posteIds:t.posteIds??[],registeredHunterIds:t.registeredHunterIds??[],presence:t.presence??{},assignments:{},externalHunters:[],rabatteurIds:t.rabatteurIds??[],groups:[],createdAt:Or()})).id},async update(t,e){const n={};e.name!==void 0&&(n.name=e.name),e.chefDeBattueId!==void 0&&(n.chefDeBattueId=e.chefDeBattueId),e.huntingZoneId!==void 0&&(n.huntingZoneId=e.huntingZoneId),e.huntingZoneName!==void 0&&(n.huntingZoneName=e.huntingZoneName),e.startDate!==void 0&&(n.startDate=gn.fromDate(e.startDate)),e.endDate!==void 0&&(n.endDate=gn.fromDate(e.endDate)),e.status!==void 0&&(n.status=e.status),e.posteIds!==void 0&&(n.posteIds=e.posteIds),e.registeredHunterIds!==void 0&&(n.registeredHunterIds=e.registeredHunterIds),e.rabatteurIds!==void 0&&(n.rabatteurIds=e.rabatteurIds),await Ba(Ht(Xe,"battues",t),n)},async updateFields(t,e){const n={...e};e.groups&&(n.groups=e.groups.map(r=>({id:r.id,name:r.name,refereeId:r.refereeId??null,posteIds:r.posteIds??[],memberIds:r.memberIds??[]}))),await Ba(Ht(Xe,"battues",t),n)},async remove(t){await Qf(Ht(Xe,"battues",t))}},pw={reader:"Classique",writer:"Référent",admin:"Admin"},gw=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function lre({companyId:t,canManage:e,isAdmin:n,currentUserId:r}){const s=Ft(),[i,a]=u.useState([]),[l,c]=u.useState([]),[d,h]=u.useState([]),[f,p]=u.useState(!0),[g,v]=u.useState(""),[x,y]=u.useState("reader"),[b,w]=u.useState(!1),[j,E]=u.useState(null),[P,A]=u.useState(!1),N=u.useCallback(async()=>{p(!0);try{const $={admin:0,writer:1,reader:2},[{members:H},W,D]=await Promise.all([Ot.getCompanyMembers(t),e?Ot.listPendingJoinRequests(t).catch(()=>[]):Promise.resolve([]),e?Ot.listPendingInvitations(t).catch(()=>[]):Promise.resolve([])]);H.sort((F,O)=>($[F.role]??3)-($[O.role]??3)||bn(F).localeCompare(bn(O))),a(H),c(W),h(D)}catch($){console.error("Error loading members:",$),s.error("Erreur lors du chargement des membres")}finally{p(!1)}},[t,e,s]);u.useEffect(()=>{N()},[N]);const _=async()=>{const $=g.trim();if(gw.test($)){w(!0);try{const{added:H}=await Ot.inviteMemberByEmail(t,$,x);s.success(H?"Membre ajouté à la société.":"Invitation envoyée par email."),v(""),y("reader"),await N()}catch(H){const W=(H==null?void 0:H.message)||"";W.includes("already")||W.includes("déjà ")?s.error("Cette personne est déjà membre de la société."):s.error("Une erreur est survenue. Veuillez réessayer.")}finally{w(!1)}}},k=async($,H)=>{if($.role==="admin")return;const W=$.role;a(D=>D.map(F=>F.id===$.id?{...F,role:H}:F));try{await Ot.updateMemberCompanyRole(t,$.id,H),s.success("Rôle mis à jour")}catch(D){a(F=>F.map(O=>O.id===$.id?{...O,role:W}:O)),s.error((D==null?void 0:D.message)||"Erreur lors de la mise à jour du rôle")}},L=async()=>{if(j){A(!0);try{await Ot.removeMember(t,j.id),s.success("Membre retiré"),E(null),await N()}catch($){s.error(($==null?void 0:$.message)||"Erreur lors du retrait du membre")}finally{A(!1)}}},I=async $=>{try{await Ot.approveJoinRequest($.id),s.success("Demande acceptée"),await N()}catch(H){s.error((H==null?void 0:H.message)||"Une erreur est survenue. Veuillez réessayer.")}},S=async $=>{try{await Ot.rejectJoinRequest($.id),s.success("Demande refusée"),await N()}catch(H){s.error((H==null?void 0:H.message)||"Une erreur est survenue. Veuillez réessayer.")}},T=async $=>{try{await Ot.revokeInvitation($.id),s.success("Invitation annulée"),await N()}catch(H){s.error((H==null?void 0:H.message)||"Une erreur est survenue. Veuillez réessayer.")}},V=n?["reader","writer","admin"]:["reader"];return o.jsxs(ke,{children:[o.jsx(Qt,{children:o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(cr,{className:"w-5 h-5"}),"Membres",o.jsx(We,{variant:"secondary",className:"ml-1",children:i.length})]})}),o.jsxs(Pe,{className:"space-y-4",children:[e&&o.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 sm:items-center pb-4 border-b",children:[o.jsxs("div",{className:"relative flex-1",children:[o.jsx(rs,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground
4066/60"}),o.jsx(Ne,{type:"email",placeholder:"[email protected]",value:g,onChange:$=>v($.target.value),onKeyDown:$=>{$.key==="Enter"&&gw.test(g.trim())&&_()},className:"pl-10"})]}),V.length>1&&o.jsxs(_t,{value:x,onValueChange:$=>y($),children:[o.jsx(St,{className:"sm:w-36",children:o.jsx(Et,{})}),o.jsx(kt,{children:V.map($=>o.jsx(Ke,{value:$,children:pw[$]},$))})]}),o.jsx(Z,{onClick:_,disabled:b||!gw.test(g.trim()),children:b?o.jsx(ft,{className:"h-4 w-4 animate-spin"}):o.jsxs(o.Fragment,{children:[o.jsx(hr,{className:"h-4 w-4 mr-2"}),"Inviter"]})})]}),e&&l.length>0&&o.jsxs("div",{className:"space-y-2 pb-4 border-b",children:[o.jsxs("p",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:["Demandes en attente (",l.length,")"]}),l.map($=>o.jsxs("div",{className:"flex items-center gap-3 p-2.5 rounded-lg bg-amber-500/10",children:[o.jsx("span",{className:"h-8 w-8 rounded-full bg-amber-500/20 flex items-center justify-center flex-shrink-0",children:o.jsx(hd,{className:"h-4 w-4 text-amber-600"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm font-medium truncate",children:$.userPseudo||$.userEmail}),o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:$.userEmail})]}),o.jsxs(Z,{size:"sm",variant:"outline",className:"text-destructive",onClick:()=>S($),children:[o.jsx(br,{className:"h-4 w-4 mr-1"}),"Refuser"]}),o.jsxs(Z,{size:"sm",onClick:()=>I($),children:[o.jsx(Xn,{className:"h-4 w-4 mr-1"}),"Accepter"]})]},$.id))]}),f?o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx(ft,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):i.length===0?o.jsx("p",{className:"text-sm text-muted-foreground py-2",children:"Aucun membre."}):o.jsx("div",{className:"space-y-2",children:i.map($=>{var O;const H=$.role,W=$.id===r,D=H==="admin",F=n&&!D&&!W;return o.jsxs("div",{className:"flex items-center gap-3 p-2.5 rounded-lg bg-muted/50",children:[o.jsx("div",{className:`h-8 w-8 rounded-full flex items-center justify-center flex-shrink-0 ${D?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"}`,children:D?o.jsx(rc,{className:"h-3.5 w-3.5"}):o.jsx("span",{className:"text-[11px] font-semibold",children:((O=bn($)[0])==null?void 0:O.toUpperCase())||"?"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("p",{className:"text-sm font-medium truncate",children:[bn($),W&&o.jsx("span",{className:"text-muted-foreground font-normal",children:" (vous)"})]}),o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:kx($)})]}),F?o.jsxs(o.Fragment,{children:[o.jsxs(_t,{value:$.role,onValueChange:Y=>k($,Y),children:[o.jsx(St,{className:"w-32 h-8 text-xs",children:o.jsx(Et,{})}),o.jsxs(kt,{children:[o.jsx(Ke,{value:"reader",children:"Classique"}),o.jsx(Ke,{value:"writer",children:"Référent"}),o.jsx(Ke,{value:"admin",children:"Admin"})]})]}),o.jsx(Z,{variant:"ghost",size:"icon",className:"text-red-600 hover:text-red-700 hover:bg-red-500/10",onClick:()=>E($),title:"Retirer",children:o.jsx(Vt,{className:"h-4 w-4"})})]}):o.jsx(We,{variant:"outline",children:pw[H]||$.role})]},$.id)})}),e&&d.length>0&&o.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[o.jsxs("p",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:["Invitations en attente (",d.length,")"]}),d.map($=>o.jsxs("div",{className:"flex items-center gap-3 p-2.5 rounded-lg bg-muted/40 opacity-90",children:[o.jsx("span",{className:"h-8 w-8 rounded-full bg-muted flex items-center justify-center flex-shrink-0",children:o.jsx(rs,{className:"h-4 w-4 text-muted-foreground"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm font-medium truncate",children:$.email}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:[pw[$.role]||$.role," · en attente"]})]}),o.jsx(Z,{variant:"ghost",size:"sm",className:"text-destructive",onClick:()=>T($),children:"Annuler"})]},$.id))]})]}),o.jsx(Dn,{open:!!j,onOpenChange:$=>!$&&E(null),children:o.jsxs(Ln,{children:[o.jsxs(Mn,{children:[o.jsx(Fn,{children:"Retirer le membre"}),o.jsx(zn,{children:j?`Ãtes-vous sûr de vouloir supprimer ${bn(j)} ?`:""})]}),o.jsxs(On,{children:[o.jsx(Vn,{disabled:P,children:"Annuler"}),o.jsx($n,{onClick:$=>{$.preventDefault(),L()},disabled:P,className:"bg-red-600 hover:bg-red-700",children:P?"Retraitâ¦":"Supprimer"})]})]})})]})}function zx({markers:t=[],polylines:e=[],polygons:n=[],height:r=300,onClick:s}){const[i,a]=u.useState(null),l=u.useRef([]),c=u.useMemo(()=>JSON.stringify({markers:t,polylines:e,polygons:n}),[t,e,n]);return u.useEffect(()=>{i&&Pb(i,D4())},[i]),u.useEffect(()=>{if(!i)return;l.current.forEach(h=>h.setMap(null)),l.current=[];const d=[];if(n.forEach(h=>{l.current.push(new google.maps.Polygon({paths:h.path,fillColor:h.color,fillOpacity:.2,strokeColor:h.color,strokeWeight:2,clickable:!1,map:i})),d.push(...h.path)}),e.forEach(h=>{l.current.push(new google.maps.Polyline({path:h.path,strokeColor:h.color,strokeWeight:4,strokeOpacity:1,clickable:!1,map:i})),d.push(...h.path)}),t.forEach(h=>{l.current.push(new google.maps.Marker({position:{lat:h.lat,lng:h.lng}
4066,map:i,clickable:!1,icon:h.iconUrl?{url:h.iconUrl,scaledSize:new google.maps.Size(28,28)}:void 0})),d.push({lat:h.lat,lng:h.lng})}),d.length===1)i.setCenter(d[0]),i.setZoom(14);else if(d.length>1){const h=new google.maps.LatLngBounds;d.forEach(f=>h.extend(f)),i.fitBounds(h,32),google.maps.event.addListenerOnce(i,"idle",()=>{(i.getZoom()??0)>16&&i.setZoom(16)})}return()=>{l.current.forEach(h=>h.setMap(null)),l.current=[]}},[i,c]),o.jsxs("div",{className:`relative rounded-xl overflow-hidden border border-border ${s?"cursor-pointer":""}`,style:{height:r},onClick:s,children:[o.jsx(Qs,{mapContainerStyle:{width:"100%",height:"100%"},center:{lat:46.6,lng:1.88},zoom:5,onLoad:a,onUnmount:()=>a(null),options:{disableDefaultUI:!0,gestureHandling:"none",keyboardShortcuts:!1,clickableIcons:!1}}),s&&o.jsx("span",{className:"absolute top-2 left-2 text-[10.5px] font-semibold text-white bg-black/45 rounded-md px-2 py-0.5 pointer-events-none",children:"Aperçu : ouvrir la carte"})]})}const cre="#5E9A74",ure={battue:{label:"Battue",icon:BL},affut:{label:"Affût",icon:VL}};function dre({companyId:t,canManage:e,basePath:n}){const r=qt(),s=n??mt.company(t),i=Ft(),[a,l]=u.useState([]),[c,d]=u.useState(!0),[h,f]=u.useState(null),[p,g]=u.useState(!1),v=u.useCallback(async()=>{d(!0);try{l(await go.listByCompany(t))}catch(y){console.error("Error loading hunting zones:",y),i.error("Erreur lors du chargement des zones de chasse")}finally{d(!1)}},[t,i]);u.useEffect(()=>{v()},[v]);const x=async()=>{if(h){g(!0);try{await go.remove(h.id),i.success("Zone de chasse supprimée"),f(null),await v()}catch(y){console.error("Error deleting hunting zone:",y),i.error("Erreur lors de la suppression")}finally{g(!1)}}};return o.jsxs(ke,{children:[o.jsx(Qt,{children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(ur,{className:"w-5 h-5"}),"Zones de chasse"]}),e&&o.jsxs(Z,{size:"sm",onClick:()=>r(mt.huntingZoneNew(s)),children:[o.jsx(hr,{className:"w-4 h-4 mr-2"}),"Créer une zone"]})]})}),o.jsx(Pe,{children:c?o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx(ft,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):a.length===0?o.jsx("p",{className:"text-sm text-muted-foreground py-2",children:"Aucune zone de chasse pour cette société."}):o.jsxs(o.Fragment,{children:[a.some(y=>{var b;return(((b=y.gpsPoint)==null?void 0:b.length)??0)>=3})&&o.jsx("div",{className:"mb-4",children:o.jsx(zx,{polygons:a.filter(y=>{var b;return(((b=y.gpsPoint)==null?void 0:b.length)??0)>=3}).map(y=>({path:y.gpsPoint.map(b=>({lat:b.latitude,lng:b.longitude})),color:cre}))})}),o.jsx("div",{className:"divide-y divide-border",children:a.map(y=>{var b;return o.jsxs("div",{className:"flex items-center justify-between gap-3 py-3",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"font-medium text-sm truncate",children:y.name}),o.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:((b=y.usages)!=null&&b.length?y.usages:["battue","affut"]).map(w=>{const j=ure[w];if(!j)return null;const E=j.icon;return o.jsxs(We,{variant:"secondary",className:"gap-1",children:[o.jsx(E,{className:"w-3 h-3"}),j.label]},w)})})]}),e&&o.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[o.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>r(mt.huntingZoneEdit(s,y.id)),title:"Modifier",children:o.jsx(fd,{className:"w-4 h-4"})}),o.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>f(y),title:"Supprimer",className:"text-red-600 hover:text-red-700 hover:bg-red-500/10",children:o.jsx(Vt,{className:"w-4 h-4"})})]})]},y.id)})})]})}),o.jsx(Dn,{open:!!h,onOpenChange:y=>!y&&f(null),children:o.jsxs(Ln,{children:[o.jsxs(Mn,{children:[o.jsx(Fn,{children:"Supprimer la zone de chasse"}),o.jsx(zn,{children:h?`La zone « ${h.name} » sera définitivement supprimée. Cette action est irréversible.`:""})]}),o.jsxs(On,{children:[o.jsx(Vn,{disabled:p,children:"Annuler"}),o.jsx($n,{onClick:y=>{y.preventDefault(),x()},disabled:p,className:"bg-red-600 hover:bg-red-700",children:p?"Suppressionâ¦":"Supprimer"})]})]})})]})}function Rt(t){const e=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&e==="[object Date]"?new t.constructor(+t):typeof t=="number"||e==="[object Number]"||typeof t=="string"||e==="[object String]"?new Date(t):new Date(NaN)}function Ps(t,e){return t instanceof Date?new t.constructor(e):new Date(e)}function qr(t,e){const n=Rt(t);return isNaN(e)?Ps(t,NaN):(e&&n.setDate(n.getDate()+e),n)}function So(t,e){const n=Rt(t);if(isNaN(e))return Ps(t,NaN);if(!e)return n;const r=n.getDate(),s=Ps(t,n.getTime());s.setMonth(n.getMonth()+e+1,0);const i=s.getDate();return r>=i?s:(n.setFullYear(s.getFullYear(),s.getMonth(),r),n)}const q1=6048e5,hre=864e5;let fre={};function mm(){return fre}function si(t,e){var l,c,d,h;const n=mm(),r=(e==null?void 0:e.weekStartsOn)??((c=(l=e==null?void 0:e.locale)==null?void 0:l.options)==null?void 0:c.weekStartsOn)??n.weekStartsOn??((h=(d=n.locale)==null?void 0:d.options)==null?void 0:h.weekStartsOn)??0,s=Rt(t),i=s.getDay(),a=(i<r?7:0)+i-r;return s.setDate(s.getDate()-a),s.setHours(0,0,0,0),s}function uc(t){return si(t,{weekStartsOn:1}
4066)}function BO(t){const e=Rt(t),n=e.getFullYear(),r=Ps(t,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);const s=uc(r),i=Ps(t,0);i.setFullYear(n,0,4),i.setHours(0,0,0,0);const a=uc(i);return e.getTime()>=s.getTime()?n+1:e.getTime()>=a.getTime()?n:n-1}function Yu(t){const e=Rt(t);return e.setHours(0,0,0,0),e}function fv(t){const e=Rt(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function qo(t,e){const n=Yu(t),r=Yu(e),s=+n-fv(n),i=+r-fv(r);return Math.round((s-i)/hre)}function mre(t){const e=BO(t),n=Ps(t,0);return n.setFullYear(e,0,4),n.setHours(0,0,0,0),uc(n)}function Ub(t,e){const n=e*7;return qr(t,n)}function pre(t,e){return So(t,e*12)}function gre(t){let e;return t.forEach(function(n){const r=Rt(n);(e===void 0||e<r||isNaN(Number(r)))&&(e=r)}),e||new Date(NaN)}function vre(t){let e;return t.forEach(n=>{const r=Rt(n);(!e||e>r||isNaN(+r))&&(e=r)}),e||new Date(NaN)}function Zr(t,e){const n=Yu(t),r=Yu(e);return+n==+r}function G1(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function xre(t){if(!G1(t)&&typeof t!="number")return!1;const e=Rt(t);return!isNaN(Number(e))}function Af(t,e){const n=Rt(t),r=Rt(e),s=n.getFullYear()-r.getFullYear(),i=n.getMonth()-r.getMonth();return s*12+i}function yre(t,e,n){const r=si(t,n),s=si(e,n),i=+r-fv(r),a=+s-fv(s);return Math.round((i-a)/q1)}function Z1(t){const e=Rt(t),n=e.getMonth();return e.setFullYear(e.getFullYear(),n+1,0),e.setHours(23,59,59,999),e}function fs(t){const e=Rt(t);return e.setDate(1),e.setHours(0,0,0,0),e}function WO(t){const e=Rt(t),n=Ps(t,0);return n.setFullYear(e.getFullYear(),0,1),n.setHours(0,0,0,0),n}function K1(t,e){var l,c,d,h;const n=mm(),r=(e==null?void 0:e.weekStartsOn)??((c=(l=e==null?void 0:e.locale)==null?void 0:l.options)==null?void 0:c.weekStartsOn)??n.weekStartsOn??((h=(d=n.locale)==null?void 0:d.options)==null?void 0:h.weekStartsOn)??0,s=Rt(t),i=s.getDay(),a=(i<r?-7:0)+6-(i-r);return s.setDate(s.getDate()+a),s.setHours(23,59,59,999),s}function HO(t){return K1(t,{weekStartsOn:1})}const wre={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"}},bre=(t,e,n)=>{let r;const s=wre[t];return typeof s=="string"?r=s:e===1?r=s.one:r=s.other.replace("{{count}}",e.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function ku(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const jre={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Cre={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Nre={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},_re={date:ku({formats:jre,defaultWidth:"full"}),time:ku({formats:Cre,defaultWidth:"full"}),dateTime:ku({formats:Nre,defaultWidth:"full"})},Ere={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Sre=(t,e,n,r)=>Ere[t];function Uo(t){return(e,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let s;if(r==="formatting"&&t.formattingValues){const a=t.defaultFormattingWidth||t.defaultWidth,l=n!=null&&n.width?String(n.width):a;s=t.formattingValues[l]||t.formattingValues[a]}else{const a=t.defaultWidth,l=n!=null&&n.width?String(n.width):t.defaultWidth;s=t.values[l]||t.values[a]}const i=t.argumentCallback?t.argumentCallback(e):e;return s[i]}}const kre={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Pre={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Ire={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"]},Tre={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Frid
4066ay","Saturday"]},Are={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"}},Rre={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"}},Dre=(t,e)=>{const n=Number(t),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"},Lre={ordinalNumber:Dre,era:Uo({values:kre,defaultWidth:"wide"}),quarter:Uo({values:Pre,defaultWidth:"wide",argumentCallback:t=>t-1}),month:Uo({values:Ire,defaultWidth:"wide"}),day:Uo({values:Tre,defaultWidth:"wide"}),dayPeriod:Uo({values:Are,defaultWidth:"wide",formattingValues:Rre,defaultFormattingWidth:"wide"})};function Bo(t){return(e,n={})=>{const r=n.width,s=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],i=e.match(s);if(!i)return null;const a=i[0],l=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],c=Array.isArray(l)?Ore(l,f=>f.test(a)):Mre(l,f=>f.test(a));let d;d=t.valueCallback?t.valueCallback(c):c,d=n.valueCallback?n.valueCallback(d):d;const h=e.slice(a.length);return{value:d,rest:h}}}function Mre(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function Ore(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function qO(t){return(e,n={})=>{const r=e.match(t.matchPattern);if(!r)return null;const s=r[0],i=e.match(t.parsePattern);if(!i)return null;let a=t.valueCallback?t.valueCallback(i[0]):i[0];a=n.valueCallback?n.valueCallback(a):a;const l=e.slice(s.length);return{value:a,rest:l}}}const Fre=/^(\d+)(th|st|nd|rd)?/i,zre=/\d+/i,$re={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},Vre={any:[/^b/i,/^(a|c)/i]},Ure={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Bre={any:[/1/i,/2/i,/3/i,/4/i]},Wre={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]},qre={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},Gre={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]},Zre={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},Kre={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}},Yre={ordinalNumber:qO({matchPattern:Fre,parsePattern:zre,valueCallback:t=>parseInt(t,10)}),era:Bo({matchPatterns:$re,defaultMatchWidth:"wide",parsePatterns:Vre,defaultParseWidth:"any"}),quarter:Bo({matchPatterns:Ure,defaultMatchWidth:"wide",parsePatterns:Bre,defaultParseWidth:"any",valueCallback:t=>t+1}),month:Bo({matchPatterns:Wre,defaultMatchWidth:"wide",parsePatterns:Hre,defaultParseWidth:"any"}),day:Bo({matchPatterns:qre,defaultMatchWidth:"wide",parsePatterns:Gre,defaultParseWidth:"any"}),dayPeriod:Bo({matchPatterns:Zre,defaultMatchWidth:"any",parsePatterns:Kre,defaultParseWidth:"any"})},GO={code:"en-US",formatDistance:bre,formatLong:_re,formatRelative:Sre,localize:Lre,match:Yre,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Qre(t){const e=Rt(t);return qo(e,WO(e))+1}function ZO(t){const e=Rt(t),n=+uc(e)-+mre(e);return Math.round(n/q1)+1}function KO(t,e){var h,f,p,g;const n=Rt(t),r=n.getFullYear(),s=mm(),i=(e==null?void 0:e.firstWeekContainsDate)??((f=(h=e==null?void 0:e.locale)==null?void 0:h.options)==null?void 0:f.firstWeekContainsDate)??s.firstWeekContainsDate??((g=(p=s.locale)==null?void 0:p.options)==null?void 0:g.firstWeekContainsDate)??1,a=Ps(t,0);a.setFullYear(r+1,0,i),a.setHours(0,0,0,0);const l=si(a,e),c=Ps(t,0);c.setFullYear(r,0,i),c.setHours(0,0,0,0);const d=si(c,e);return n.getTime()>=l.getTime()?r+1:n.getTime()>=d.getTime()?r:r-1}function Xre(t,e){var l,c,d,h;const n=mm(),r=(e==null?void 0:e.firstWeekContainsDate)??((c=(l=e==null?void 0:e.locale)==null?void 0:l.options)==null?void 0:c.firstWeekContainsDate)??n.firstWeekContainsDate??((h=(d=n.locale)==null?void 0:d.options)==null?void 0:h.firstWeekContainsDate)??1,s=KO(t,e),i=Ps(t,0);return i.setFullYear(s,0,r),i.setHours(0,0,0,0),si(i,e)}function YO(t,e){const n=Rt(t),r=+si(n,e)-+Xre(n,e);return Math.round(r/q1)+1}function Gt(t,e){const n=t<0?"-":"",r=Math.abs(t).toString().padStart(e,"0");return n+r}const ea={y(t,e){const n=t.getFullYear(),r=n>0?n:1-n;return Gt(e==="yy"?r%100:r,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):Gt(n+1,2)},d(t,e){return Gt(t.getDate(),e.length)},a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){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(t,e){return Gt(t.getHours()%12||12,e.length)},H(t,e){return Gt(t.getHours(),e.length)},m(t,e){return Gt(t.getMinutes(),e.length)},s(t,e){return Gt(t.getSeconds(),e.length)},S(t,e){const n=e.length,r=t.getMilliseconds(),s=Math.trunc(r*Math.pow(10,n-3));return Gt(s,e.length)}},Uc={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},WP={G:function(t,e,n){const r=t.getFullYear()>0?1:0;switch(e){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(t,e,n){if(e==="yo"){const r=t.getFullYear(),s=r>0?r:1-r;return n.ordinalNumber(s,{unit:"year"})}return ea.y(t,e)},Y:function(t,e,n,r){const s=KO(t,r),i=s>0?s:1-s;if(e==="YY"){const a=i%100;return Gt(a,2)}return e==="Yo"?n.ordinalNumber(i,{unit:"year"}):Gt(i,e.length)},R:function(t,e){const n=BO(t);return Gt(n,e.length)},u:function(t,e){const n=t.getFullYear();return Gt(n,e.length)},Q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(r);case"QQ":return Gt(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(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(r);case"qq":return Gt(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(t,e,n){const r=t.getMonth();switch(e){case"M":case"MM":return ea.M(t,e);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(t,e,n){const r=t.getMonth();switch(e){case"L":return String(r+1);case"LL":return Gt(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(t,e,n,r){const s=YO(t,r);return e==="wo"?n.ordinalNumber(s,{unit:"week"}):Gt(s,e.length)},I:function(t,e,n){const r=ZO(t);return e==="Io"?n.ordinalNumber(r,{unit:"week"}):Gt(r,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):ea.d(t,e)},D:function(t,e,n){const r=Qre(t);return e==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):Gt(r,e.length)},E:function(t,e,n){const r=t.getDay();switch(e){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(t,e,n,r){const s=t.getDay(),i=(s-r.weekStartsOn+8)%7||7;switch(e){case"e":return String(i);case"ee":return Gt(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(t,e,n,r){const s=t.getDay(),i=(s-r.weekStartsOn+8)%7||7;switch(e){case"c":return String(i);case"cc":return Gt(i,e.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(t,e,n){const r=t.getDay(),s=r===0?7:r;switch(e){case"i":return String(s);case"ii":return Gt(s,e.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(t,e,n){const s=t.getHours()/12>=1?"pm":"am";switch(e){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(t,e,n){const r=t.getHours();let s;switch(r===12?s=Uc.noon:r===0?s=Uc.midnight:s=r/12>
4066=1?"pm":"am",e){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(t,e,n){const r=t.getHours();let s;switch(r>=17?s=Uc.evening:r>=12?s=Uc.afternoon:r>=4?s=Uc.morning:s=Uc.night,e){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(t,e,n){if(e==="ho"){let r=t.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return ea.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):ea.H(t,e)},K:function(t,e,n){const r=t.getHours()%12;return e==="Ko"?n.ordinalNumber(r,{unit:"hour"}):Gt(r,e.length)},k:function(t,e,n){let r=t.getHours();return r===0&&(r=24),e==="ko"?n.ordinalNumber(r,{unit:"hour"}):Gt(r,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):ea.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):ea.s(t,e)},S:function(t,e){return ea.S(t,e)},X:function(t,e,n){const r=t.getTimezoneOffset();if(r===0)return"Z";switch(e){case"X":return qP(r);case"XXXX":case"XX":return El(r);case"XXXXX":case"XXX":default:return El(r,":")}},x:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"x":return qP(r);case"xxxx":case"xx":return El(r);case"xxxxx":case"xxx":default:return El(r,":")}},O:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+HP(r,":");case"OOOO":default:return"GMT"+El(r,":")}},z:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+HP(r,":");case"zzzz":default:return"GMT"+El(r,":")}},t:function(t,e,n){const r=Math.trunc(t.getTime()/1e3);return Gt(r,e.length)},T:function(t,e,n){const r=t.getTime();return Gt(r,e.length)}};function HP(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),s=Math.trunc(r/60),i=r%60;return i===0?n+String(s):n+String(s)+e+Gt(i,2)}function qP(t,e){return t%60===0?(t>0?"-":"+")+Gt(Math.abs(t)/60,2):El(t,e)}function El(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),s=Gt(Math.trunc(r/60),2),i=Gt(r%60,2);return n+s+e+i}const GP=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},QO=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},Jre=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],r=n[1],s=n[2];if(!s)return GP(t,e);let i;switch(r){case"P":i=e.dateTime({width:"short"});break;case"PP":i=e.dateTime({width:"medium"});break;case"PPP":i=e.dateTime({width:"long"});break;case"PPPP":default:i=e.dateTime({width:"full"});break}return i.replace("{{date}}",GP(r,e)).replace("{{time}}",QO(s,e))},ese={p:QO,P:Jre},tse=/^D+$/,nse=/^Y+$/,rse=["D","DD","YY","YYYY"];function sse(t){return tse.test(t)}function ose(t){return nse.test(t)}function ise(t,e,n){const r=ase(t,e,n);if(console.warn(r),rse.includes(t))throw new RangeError(r)}function ase(t,e,n){const r=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const lse=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,cse=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,use=/^'([^]*?)'?$/,dse=/''/g,hse=/[a-zA-Z]/;function ll(t,e,n){var h,f,p,g,v,x,y,b;const r=mm(),s=(n==null?void 0:n.locale)??r.locale??GO,i=(n==null?void 0:n.firstWeekContainsDate)??((f=(h=n==null?void 0:n.locale)==null?void 0:h.options)==null?void 0:f.firstWeekContainsDate)??r.firstWeekContainsDate??((g=(p=r.locale)==null?void 0:p.options)==null?void 0:g.firstWeekContainsDate)??1,a=(n==null?void 0:n.weekStartsOn)??((x=(v=n==null?void 0:n.locale)==null?void 0:v.options)==null?void 0:x.weekStartsOn)??r.weekStartsOn??((b=(y=r.locale)==null?void 0:y.options)==null?void 0:b.weekStartsOn)??0,l=Rt(t);if(!xre(l))throw new RangeError("Invalid time value");let c=e.match(cse).map(w=>{const j=w[0];if(j==="p"||j==="P"){const E=ese[j];return E(w,s.formatLong)}return w}).join("").match(lse).map(w=>{if(w==="''")return{isToken:!1,value:"'"};const j=w[0];if(j==="'")return{isToken:!1,value:fse(w)};if(WP[j])return{isToken:!0,value:w};
4066if(j.match(hse))throw new RangeError("Format string contains an unescaped latin alphabet character `"+j+"`");return{isToken:!1,value:w}});s.localize.preprocessor&&(c=s.localize.preprocessor(l,c));const d={firstWeekContainsDate:i,weekStartsOn:a,locale:s};return c.map(w=>{if(!w.isToken)return w.value;const j=w.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&ose(j)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&sse(j))&&ise(j,e,String(t));const E=WP[j[0]];return E(l,j,s.localize,d)}).join("")}function fse(t){const e=t.match(use);return e?e[1].replace(dse,"'"):t}function mse(t){const e=Rt(t),n=e.getFullYear(),r=e.getMonth(),s=Ps(t,0);return s.setFullYear(n,r+1,0),s.setHours(0,0,0,0),s.getDate()}function pse(t){return Math.trunc(+Rt(t)/1e3)}function gse(t){const e=Rt(t),n=e.getMonth();return e.setFullYear(e.getFullYear(),n+1,0),e.setHours(0,0,0,0),e}function vse(t,e){return yre(gse(t),fs(t),e)+1}function Bb(t,e){const n=Rt(t),r=Rt(e);return n.getTime()>r.getTime()}function XO(t,e){const n=Rt(t),r=Rt(e);return+n<+r}function Y1(t,e){const n=Rt(t),r=Rt(e);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()}function xse(t,e){const n=Rt(t),r=Rt(e);return n.getFullYear()===r.getFullYear()}function vw(t,e){return qr(t,-e)}function xw(t,e){const n=Rt(t),r=n.getFullYear(),s=n.getDate(),i=Ps(t,0);i.setFullYear(r,e,15),i.setHours(0,0,0,0);const a=mse(i);return n.setMonth(e,Math.min(s,a)),n}function ZP(t,e){const n=Rt(t);return isNaN(+n)?Ps(t,NaN):(n.setFullYear(e),n)}const yse={lessThanXSeconds:{one:"moins dâune seconde",other:"moins de {{count}} secondes"},xSeconds:{one:"1 seconde",other:"{{count}} secondes"},halfAMinute:"30 secondes",lessThanXMinutes:{one:"moins dâune minute",other:"moins de {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"environ 1 heure",other:"environ {{count}} heures"},xHours:{one:"1 heure",other:"{{count}} heures"},xDays:{one:"1 jour",other:"{{count}} jours"},aboutXWeeks:{one:"environ 1 semaine",other:"environ {{count}} semaines"},xWeeks:{one:"1 semaine",other:"{{count}} semaines"},aboutXMonths:{one:"environ 1 mois",other:"environ {{count}} mois"},xMonths:{one:"1 mois",other:"{{count}} mois"},aboutXYears:{one:"environ 1 an",other:"environ {{count}} ans"},xYears:{one:"1 an",other:"{{count}} ans"},overXYears:{one:"plus dâun an",other:"plus de {{count}} ans"},almostXYears:{one:"presquâun an",other:"presque {{count}} ans"}},wse=(t,e,n)=>{let r;const s=yse[t];return typeof s=="string"?r=s:e===1?r=s.one:r=s.other.replace("{{count}}",String(e)),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"dans "+r:"il y a "+r:r},bse={full:"EEEE d MMMM y",long:"d MMMM y",medium:"d MMM y",short:"dd/MM/y"},jse={full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},Cse={full:"{{date}} 'à ' {{time}}",long:"{{date}} 'à ' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Nse={date:ku({formats:bse,defaultWidth:"full"}),time:ku({formats:jse,defaultWidth:"full"}),dateTime:ku({formats:Cse,defaultWidth:"full"})},_se={lastWeek:"eeee 'dernier à ' p",yesterday:"'hier à ' p",today:"'aujourdâhui à ' p",tomorrow:"'demain à ' p'",nextWeek:"eeee 'prochain à ' p",other:"P"},Ese=(t,e,n,r)=>_se[t],Sse={narrow:["av. J.-C","ap. J.-C"],abbreviated:["av. J.-C","ap. J.-C"],wide:["avant Jésus-Christ","après Jésus-Christ"]},kse={narrow:["T1","T2","T3","T4"],abbreviated:["1er trim.","2ème trim.","3ème trim.","4ème trim."],wide:["1er trimestre","2ème trimestre","3ème trimestre","4ème trimestre"]},Pse={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["janv.","févr.","mars","avr.","mai","juin","juil.","août","sept.","oct.","nov.","déc."],wide:["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"]},Ise={narrow:["D","L","M","M","J","V","S"],short:["di","lu","ma","me","je","ve","sa"],abbreviated:["dim.","lun.","mar.","mer.","jeu.","ven.","sam."],wide:["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"]},Tse={narrow:{am:"AM",pm:"PM",midnight:"minuit",noon:"midi",morning:"mat.",afternoon:"ap.m.",evening:"soir",night:"mat."},abbreviated:{am:"AM",pm:"PM",midnight:"minuit",noon:"midi",morning:"matin",afternoon:"après-midi",evening:"soir",night:"matin"},wide:{am:"AM",pm:"PM",midnight:"minuit",noon:"midi",morning:"du matin",afternoon:"de lâaprès-midi",evening:"du soir",night:"du matin"}},Ase=(t,e)=>{const n=Number(t),r=e==null?void 0:e.unit;if(n===0)return"0";const s=["year","week","hour","minute","second"];let i;return n===1?i=r&&s.includes(r)?"ère":"er":i="ème",n+i},Rse=["MMM","MMMM"],Dse={preprocessor:(t,e)=>t.getDate()===1||!e.some(r=>r.isToken&&Rse.includes(r.value))?e:e.map(r=>r.isToken&&r.value==="do"?{isToken:!0,value:"d"}:r),ordinalNumber:Ase,era:Uo({values:Sse,defaultWidth:"wide"}),quarter:Uo({values:kse,defaultWidth:"wide",argumentCallback:t=>t-1}),month:Uo({values:Pse,defaultWidth:"wide"}),day:Uo({values:Ise,defaultWidth:"wide"}),dayPeriod:Uo({values:Tse,defaultWidth:"wide"})},Lse=/^(\d+)(ième|ère|ème|er|e)?/i,Mse=/\d+/i,Ose={narrow:/^(av\.J\.C|ap\.J\.C|ap\.J\.-C)/i,abbreviated:/^(av\.J\.-C|av\.J-C|apr\.J\.-C|apr\.J-C|ap\.J-C)/i,wide:/^(avant Jésus-Christ|après Jésus-Christ)/i},Fse={any:[/^av/i,/^ap/i]},zse={narrow:/^T?[1234]/i,abbreviated:/^[1234](er|ème|e)? trim\.?/i,wide:/^[1234](er|ème|e)? trimestre/i},$se={any:[/1/i,/2/i,/3/i,/4/i]},Vse={narrow:/^[jfmasond]/i,abbreviated:/^(janv|févr|mars|avr|mai|juin|juill|juil|août|sept|oct|nov|déc)\.?/i,wide:/^(janv
4066ier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|décembre)/i},Use={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,/^av/i,/^ma/i,/^juin/i,/^juil/i,/^ao/i,/^s/i,/^o/i,/^n/i,/^d/i]},Bse={narrow:/^[lmjvsd]/i,short:/^(di|lu|ma|me|je|ve|sa)/i,abbreviated:/^(dim|lun|mar|mer|jeu|ven|sam)\.?/i,wide:/^(dimanche|lundi|mardi|mercredi|jeudi|vendredi|samedi)/i},Wse={narrow:[/^d/i,/^l/i,/^m/i,/^m/i,/^j/i,/^v/i,/^s/i],any:[/^di/i,/^lu/i,/^ma/i,/^me/i,/^je/i,/^ve/i,/^sa/i]},Hse={narrow:/^(a|p|minuit|midi|mat\.?|ap\.?m\.?|soir|nuit)/i,any:/^([ap]\.?\s?m\.?|du matin|de l'après[-\s]midi|du soir|de la nuit)/i},qse={any:{am:/^a/i,pm:/^p/i,midnight:/^min/i,noon:/^mid/i,morning:/mat/i,afternoon:/ap/i,evening:/soir/i,night:/nuit/i}},Gse={ordinalNumber:qO({matchPattern:Lse,parsePattern:Mse,valueCallback:t=>parseInt(t)}),era:Bo({matchPatterns:Ose,defaultMatchWidth:"wide",parsePatterns:Fse,defaultParseWidth:"any"}),quarter:Bo({matchPatterns:zse,defaultMatchWidth:"wide",parsePatterns:$se,defaultParseWidth:"any",valueCallback:t=>t+1}),month:Bo({matchPatterns:Vse,defaultMatchWidth:"wide",parsePatterns:Use,defaultParseWidth:"any"}),day:Bo({matchPatterns:Bse,defaultMatchWidth:"wide",parsePatterns:Wse,defaultParseWidth:"any"}),dayPeriod:Bo({matchPatterns:Hse,defaultMatchWidth:"any",parsePatterns:qse,defaultParseWidth:"any"})},KP={code:"fr",formatDistance:wse,formatLong:Nse,formatRelative:Ese,localize:Dse,match:Gse,options:{weekStartsOn:1,firstWeekContainsDate:4}};var nt=function(){return nt=Object.assign||function(e){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)&&(e[i]=n[i])}return e},nt.apply(this,arguments)};function Zse(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n}function JO(t,e,n){for(var r=0,s=e.length,i;r<s;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return t.concat(i||Array.prototype.slice.call(e))}function pm(t){return t.mode==="multiple"}function gm(t){return t.mode==="range"}function $x(t){return t.mode==="single"}var Kse={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 Yse(t,e){return ll(t,"LLLL y",e)}function Qse(t,e){return ll(t,"d",e)}function Xse(t,e){return ll(t,"LLLL",e)}function Jse(t){return"".concat(t)}function eoe(t,e){return ll(t,"cccccc",e)}function toe(t,e){return ll(t,"yyyy",e)}var noe=Object.freeze({__proto__:null,formatCaption:Yse,formatDay:Qse,formatMonthCaption:Xse,formatWeekNumber:Jse,formatWeekdayName:eoe,formatYearCaption:toe}),roe=function(t,e,n){return ll(t,"do MMMM (EEEE)",n)},soe=function(){return"Month: "},ooe=function(){return"Go to next month"},ioe=function(){return"Go to previous month"},aoe=function(t,e){return ll(t,"cccc",e)},loe=function(t){return"Week n. ".concat(t)},coe=function(){return"Year: "},uoe=Object.freeze({__proto__:null,labelDay:roe,labelMonthDropdown:soe,labelNext:ooe,labelPrevious:ioe,labelWeekNumber:loe,labelWeekday:aoe,labelYearDropdown:coe});function doe(){var t="buttons",e=Kse,n=GO,r={},s={},i=1,a={},l=new Date;return{captionLayout:t,classNames:e,formatters:noe,labels:uoe,locale:n,modifiersClassNames:r,modifiers:s,numberOfMonths:i,styles:a,today:l,mode:"default"}}function hoe(t){var e=t.fromYear,n=t.toYear,r=t.fromMonth,s=t.toMonth,i=t.fromDate,a=t.toDate;
4066return r?i=fs(r):e&&(i=new Date(e,0,1)),s?a=Z1(s):n&&(a=new Date(n,11,31)),{fromDate:i?Yu(i):void 0,toDate:a?Yu(a):void 0}}var e3=u.createContext(void 0);function foe(t){var e,n=t.initialProps,r=doe(),s=hoe(n),i=s.fromDate,a=s.toDate,l=(e=n.captionLayout)!==null&&e!==void 0?e:r.captionLayout;l!=="buttons"&&(!i||!a)&&(l="buttons");var c;($x(n)||pm(n)||gm(n))&&(c=n.onSelect);var d=nt(nt(nt({},r),n),{captionLayout:l,classNames:nt(nt({},r.classNames),n.classNames),components:nt({},n.components),formatters:nt(nt({},r.formatters),n.formatters),fromDate:i,labels:nt(nt({},r.labels),n.labels),mode:n.mode||r.mode,modifiers:nt(nt({},r.modifiers),n.modifiers),modifiersClassNames:nt(nt({},r.modifiersClassNames),n.modifiersClassNames),onSelect:c,styles:nt(nt({},r.styles),n.styles),toDate:a});return o.jsx(e3.Provider,{value:d,children:t.children})}function ln(){var t=u.useContext(e3);if(!t)throw new Error("useDayPicker must be used within a DayPickerProvider.");return t}function t3(t){var e=ln(),n=e.locale,r=e.classNames,s=e.styles,i=e.formatters.formatCaption;return o.jsx("div",{className:r.caption_label,style:s.caption_label,"aria-live":"polite",role:"presentation",id:t.id,children:i(t.displayMonth,{locale:n})})}function moe(t){return o.jsx("svg",nt({width:"8px",height:"8px",viewBox:"0 0 120 120","data-testid":"iconDropdown"},t,{children:o.jsx("path",{d:"M4.22182541,48.2218254 C8.44222828,44.0014225 15.2388494,43.9273804 19.5496459,47.9996989 L19.7781746,48.2218254 L60,88.443 L100.221825,48.2218254 C104.442228,44.0014225 111.238849,43.9273804 115.549646,47.9996989 L115.778175,48.2218254 C119.998577,52.4422283 120.07262,59.2388494 116.000301,63.5496459 L115.778175,63.7781746 L67.7781746,111.778175 C63.5577717,115.998577 56.7611506,116.07262 52.4503541,112.000301 L52.2218254,111.778175 L4.22182541,63.7781746 C-0.0739418023,59.4824074 -0.0739418023,52.5175926 4.22182541,48.2218254 Z",fill:"currentColor",fillRule:"nonzero"})}))}function n3(t){var e,n,r=t.onChange,s=t.value,i=t.children,a=t.caption,l=t.className,c=t.style,d=ln(),h=(n=(e=d.components)===null||e===void 0?void 0:e.IconDropdown)!==null&&n!==void 0?n:moe;return o.jsxs("div",{className:l,style:c,children:[o.jsx("span",{className:d.classNames.vhidden,children:t["aria-label"]}),o.jsx("select",{name:t.name,"aria-label":t["aria-label"],className:d.classNames.dropdown,style:d.styles.dropdown,value:s,onChange:r,children:i}),o.jsxs("div",{className:d.classNames.caption_label,style:d.styles.caption_label,"aria-hidden":"true",children:[a,o.jsx(h,{className:d.classNames.dropdown_icon,style:d.styles.dropdown_icon})]})]})}function poe(t){var e,n=ln(),r=n.fromDate,s=n.toDate,i=n.styles,a=n.locale,l=n.formatters.formatMonthCaption,c=n.classNames,d=n.components,h=n.labels.labelMonthDropdown;if(!r)return o.jsx(o.Fragment,{});if(!s)return o.jsx(o.Fragment,{});var f=[];if(xse(r,s))for(var p=fs(r),g=r.getMonth();g<=s.getMonth();g++)f.push(xw(p,g));else for(var p=fs(new Date),g=0;g<=11;g++)f.push(xw(p,g));var v=function(y){var b=Number(y.target.value),w=xw(fs(t.displayMonth),b);t.onChange(w)},x=(e=d==null?void 0:d.Dropdown)!==null&&e!==void 0?e:n3;return o.jsx(x,{name:"months","aria-label":h(),className:c.dropdown_month,style:i.dropdown_month,onChange:v,value:t.displayMonth.getMonth(),caption:l(t.displayMonth,{locale:a}),children:f.map(function(y){return o.jsx("option",{value:y.getMonth(),children:l(y,{locale:a})},y.getMonth())})})}function goe(t){var e,n=t.displayMonth,r=ln(),s=r.fromDate,i=r.toDate,a=r.locale,l=r.styles,c=r.classNames,d=r.components,h=r.formatters.formatYearCaption,f=r.labels.labelYearDropdown,p=[];if(!s)return o.jsx(o.Fragment,{});if(!i)return o.jsx(o.Fragment,{});for(var g=s.getFullYear(),v=i.getFullYear(),x=g;x<=v;x++)p.push(ZP(WO(new Date),x));var y=function(w){var j=ZP(fs(n),Number(w.target.value));t.onChange(j)},b=(e=d==null?void 0:d.Dropdown)!==null&&e!==void 0?e:n3;return o.jsx(b,{name:"years","aria-label":f(),className:c.dropdown_year,style:l.dropdown_year,onChange:y,value:n.getFullYear(),caption:h(n,{locale:a}),children:p.map(function(w){return o.jsx("option",{value:w.getFullYear(),children:h(w,{locale:a})},w.getFullYear())})})}function voe(t,e){var n=u.useState(t),r=n[0],s=n[1],i=e===void 0?r:e;return[i,s]}function xoe(t){var e=t.month,n=t.defaultMonth,r=t.today,s=e||n||r||new Date,i=t.toDate,a=t.fromDate,l=t.numberOfMonths,c=l===void 0?1:l;if(i&&Af(i,s)<0){var d=-1*(c-1);s=So(i,d)}return a&&Af(s,a)<0&&(s=a),fs(s)}function yoe(){var t=ln(),e=xoe(t),n=voe(e,t.month),r=n[0],s=n[1],i=function(a){var l;if(!t.disableNavigation){var c=fs(a);s(c),(l=t.onMonthChange)===null||l===void 0||l.call(t,c)}};return[r,i]}function woe(t,e){for(var n=e.reverseMonths,r=e.numberOfMonths,s=fs(t),i=fs(So(s,r)),a=Af(i,s),l=[],c=0;c<a;c++){var d=So(s,c);l.push(d)}return n&&(l=l.reverse()),l}function boe(t,e){if(!e.disableNavigation){var n=e.toDate,r=e.pagedNavigation,s=e.numberOfMonths,i=s===void 0?1:s,a=r?i:1,l=fs(t);if(!n)return So(l,a);var c=Af(n,t);if(!(c<i))return So(l,a)}}function joe(t,e){if(!e.disableNavigation){var n=e.fromDate,r=e.pagedNavigation,s=e.numberOfMonths,i=s===void 0?1:s,a=r?i:1,l=fs(t);if(!n)return So(l,-a);var c=Af(l,n);if(!(c<=0))return So(l,-a)}}var r3=u.createContext(void 0);function Coe(t){var e=ln(),n=yoe(),r=n[0],s=n[1],i=woe(r,e),a=boe(r,e),l=joe(r,e),c=function(f){return i.some(function(p){return Y1(f,p)})},d=function(f,p){c(f)||(p&&XO(f,p)?s(So(f,1+e.numberOfMonths*-1)):s(f))},h={currentMonth:r,displayMonths:i,goToMonth:s,goToDate:d,previousMonth:l,nextMonth:a,isDateDisplayed:c};return o.jsx(r3.Provider,{value:h,children:t.children})}function vm(){var t=u.useContext(r3);
4066if(!t)throw new Error("useNavigation must be used within a NavigationProvider");return t}function YP(t){var e,n=ln(),r=n.classNames,s=n.styles,i=n.components,a=vm().goToMonth,l=function(h){a(So(h,t.displayIndex?-t.displayIndex:0))},c=(e=i==null?void 0:i.CaptionLabel)!==null&&e!==void 0?e:t3,d=o.jsx(c,{id:t.id,displayMonth:t.displayMonth});return o.jsxs("div",{className:r.caption_dropdowns,style:s.caption_dropdowns,children:[o.jsx("div",{className:r.vhidden,children:d}),o.jsx(poe,{onChange:l,displayMonth:t.displayMonth}),o.jsx(goe,{onChange:l,displayMonth:t.displayMonth})]})}function Noe(t){return o.jsx("svg",nt({width:"16px",height:"16px",viewBox:"0 0 120 120"},t,{children:o.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 _oe(t){return o.jsx("svg",nt({width:"16px",height:"16px",viewBox:"0 0 120 120"},t,{children:o.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 mv=u.forwardRef(function(t,e){var n=ln(),r=n.classNames,s=n.styles,i=[r.button_reset,r.button];t.className&&i.push(t.className);var a=i.join(" "),l=nt(nt({},s.button_reset),s.button);return t.style&&Object.assign(l,t.style),o.jsx("button",nt({},t,{ref:e,type:"button",className:a,style:l}))});function Eoe(t){var e,n,r=ln(),s=r.dir,i=r.locale,a=r.classNames,l=r.styles,c=r.labels,d=c.labelPrevious,h=c.labelNext,f=r.components;if(!t.nextMonth&&!t.previousMonth)return o.jsx(o.Fragment,{});var p=d(t.previousMonth,{locale:i}),g=[a.nav_button,a.nav_button_previous].join(" "),v=h(t.nextMonth,{locale:i}),x=[a.nav_button,a.nav_button_next].join(" "),y=(e=f==null?void 0:f.IconRight)!==null&&e!==void 0?e:_oe,b=(n=f==null?void 0:f.IconLeft)!==null&&n!==void 0?n:Noe;return o.jsxs("div",{className:a.nav,style:l.nav,children:[!t.hidePrevious&&o.jsx(mv,{name:"previous-month","aria-label":p,className:g,style:l.nav_button_previous,disabled:!t.previousMonth,onClick:t.onPreviousClick,children:s==="rtl"?o.jsx(y,{className:a.nav_icon,style:l.nav_icon}):o.jsx(b,{className:a.nav_icon,style:l.nav_icon})}),!t.hideNext&&o.jsx(mv,{name:"next-month","aria-label":v,className:x,style:l.nav_button_next,disabled:!t.nextMonth,onClick:t.onNextClick,children:s==="rtl"?o.jsx(b,{className:a.nav_icon,style:l.nav_icon}):o.jsx(y,{className:a.nav_icon,style:l.nav_icon})})]})}function QP(t){var e=ln().numberOfMonths,n=vm(),r=n.previousMonth,s=n.nextMonth,i=n.goToMonth,a=n.displayMonths,l=a.findIndex(function(v){return Y1(t.displayMonth,v)}),c=l===0,d=l===a.length-1,h=e>1&&(c||!d),f=e>1&&(d||!c),p=function(){r&&i(r)},g=function(){s&&i(s)};return o.jsx(Eoe,{displayMonth:t.displayMonth,hideNext:h,hidePrevious:f,nextMonth:s,previousMonth:r,onPreviousClick:p,onNextClick:g})}function Soe(t){var e,n=ln(),r=n.classNames,s=n.disableNavigation,i=n.styles,a=n.captionLayout,l=n.components,c=(e=l==null?void 0:l.CaptionLabel)!==null&&e!==void 0?e:t3,d;return s?d=o.jsx(c,{id:t.id,displayMonth:t.displayMonth}):a==="dropdown"?d=o.jsx(YP,{displayMonth:t.displayMonth,id:t.id}):a==="dropdown-buttons"?d=o.jsxs(o.Fragment,{children:[o.jsx(YP,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),o.jsx(QP,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id})]}):d=o.jsxs(o.Fragment,{children:[o.jsx(c,{id:t.id,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),o.jsx(QP,{displayMonth:t.displayMonth,id:t.id})]}),o.jsx("div",{className:r.caption,style:i.caption,children:d})}function koe(t){var e=ln(),n=e.footer,r=e.styles,s=e.classNames.tfoot;return n?o.jsx("tfoot",{className:s,style:r.tfoot,children:o.jsx("tr",{children:o.jsx("td",{colSpan:8,children:n})})}):o.jsx(o.Fragment,{})}function Poe(t,e,n){for(var r=n?uc(new Date):si(new Date,{locale:t,weekStartsOn:e}),s=[],i=0;i<7;i++){var a=qr(r,i);s.push(a)}return s}function Ioe(){var t=ln(),e=t.classNames,n=t.styles,r=t.showWeekNumber,s=t.locale,i=t.weekStartsOn,a=t.ISOWeek,l=t.formatters.formatWeekdayName,c=t.labels.labelWeekday,d=Poe(s,i,a);return o.jsxs("tr",{style:n.head_row,className:e.head_row,children:[r&&o.jsx("td",{style:n.head_cell,className:e.head_cell}),d.map(function(h,f){return o.jsx("th",{scope:"col",className:e.head_cell,style:n.head_cell,"aria-label":c(h,{locale:s}),children:l(h,{locale:s})},f)})]})}function Toe(){var t,e=ln(),n=e.classNames,r=e.styles,s=e.components,i=(t=s==null?void 0:s.HeadRow)!==null&&t!==void 0?t:Ioe;return o.jsx("thead",{style:r.head,className:n.head,children:o.jsx(i,{})})}function Aoe(t){var e=ln(),n=e.locale,r=e.formatters.formatDay;return o.jsx(o.Fragment,{children:r(t.date,{locale:n})})}var Q1=u.createContext(void 0);function Roe(t){if(!pm(t.initialProps)){var e={selected:void 0,modifiers:{disabled:[]}};return o.jsx(Q1.Provider,{value:e,children:t.children})}return o.jsx(Doe,{initialProps:t.initialProps,children:t.children})}function Doe(t){var e=t.initialProps,n=t.children,r=e.selected,s=e.min,i=e.max,a=function(d,h,f){var p,g;(p=e.onDayClick)===null||p===void 0||p.call(e,d,h,f);var v=!!(h.selected&&s&&(r==null?void 0:r.length)===s);if(!v){var x=!!(!h.selected&&i&&(r==null?void 0:r.length)===i);if(!x){var y=r?JO([],r):[];if(h.selected){var b=y.findIndex(function(w){return Zr(d,w)});y.splice(b,1)}else y.push(d);(g=e.onSelect)===null||g===void 0||g.call(e,y,d,h,f)}}},l={disabled:[]};r&&l.disabled.push(function(d){var h=i&&r.length>i-1,f=r.some(function(p){return Zr(p,d)});return!!(h&&!f)});var c={selected:r,onDayClick:a,modifiers:l};return o.jsx(Q1.Provider,{value:c,children:n})}function X1(){var t=u.useContext(Q1);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function Loe(t,e){var n=e||{},r=n.from,s=n.to;return r&&s?Zr(s,t)&&Zr(r,t)?void 0:Zr(s,t)?{from:s,to:void 0}:Zr(r,t)?void 0:Bb(r,t)?{from:t,to:s}:{from:r,to:t}:s?Bb(t,s)?{from:s,to:t}:{from:t,to:s}:r?XO(t,r)?{from:t,to:r}:{from:r,to:t}:{from:t,to:void 0}}var J1=u.createContext(void 0);function Moe(t){if(!gm(t.initialProps)){var e={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return o.jsx(J1.Provider,{value:e,children:t.children})}return o.jsx(Ooe,{initialProps:t.initialProps,children:t.children})}function Ooe(t){var e=t.initialProps,n=t.children,r=e.selected,s=r||{},i=s.from,a=s.to,l=e.min,c=e.max,d=function(g,v,x){var y,b;(y=e.onDayClick)===null||y===void 0||y.call(e,g,v,x);var w=Loe(g,r);(b=e.onSelect)===null||b===void 0||b.call(e,w,g,v,x)},h={range_start:[],range_end:[],range_middle:[],disabled:[]};if(i?(h.range_start=[i],a?(h.range_end=[a],Zr(i,a)||(h.range_middle=[{after:i,before:a}])):h.range_end=[i]):a&&(h.range_start=[a],h.range_end=[a]),l&&(i&&!a&&h.disabled.push({after:vw(i,l-1),before:qr(i,l-1)}),i&&a&&h.disabled.push({after:i,before:qr(i,l-1)}),!i&&a&&h.disabled.push({after:vw(a,l-1),before:qr(a,l-1)})),c){if(i&&!a&&(h.disabled.push({before:qr(i,-c+1)}),h.disabled.push({after:qr(i,c-1)})),i&&a){var f=qo(a,i)+1,p=c-f;h.disabled.push({before:vw(i,p)}),h.disabled.push({after:qr(a,p)})}!i&&a&&(h.disabled.push({before:qr(a,-c+1)}),h.disabled.push({after:qr(a,c-1)}))}return o.jsx(J1.Provider,{value:{selected:r,onDayClick:d,modifiers:h},children:n})}function eN(){var t=u.useContext(J1);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function tg(t){return Array.isArray(t)?JO([],t):t!==void 0?[t]:[]}function Foe(t){var e={};return Object.entries(t).forEach(function(n){var r=n[0],s=n[1];e[r]=tg(s)}),e}var ko;(function(t){t.Outside="outside",t.Disabled="disabled",t.Selected="selected",t.Hidden="hidden",t.Today="today",t.RangeStart="range_start",t.RangeEnd="range_end",t.RangeMiddle="range_middle"})(ko||(ko={}));var zoe=ko.Selected,hi=ko.Disabled,$oe=ko.Hidden,Voe=ko.Today,yw=ko.RangeEnd,ww=ko.RangeMiddle,bw=ko.RangeStart,Uoe=ko.Outside;function Boe(t,e,n){var r,s=(r={}
4066,r[zoe]=tg(t.selected),r[hi]=tg(t.disabled),r[$oe]=tg(t.hidden),r[Voe]=[t.today],r[yw]=[],r[ww]=[],r[bw]=[],r[Uoe]=[],r);return t.fromDate&&s[hi].push({before:t.fromDate}),t.toDate&&s[hi].push({after:t.toDate}),pm(t)?s[hi]=s[hi].concat(e.modifiers[hi]):gm(t)&&(s[hi]=s[hi].concat(n.modifiers[hi]),s[bw]=n.modifiers[bw],s[ww]=n.modifiers[ww],s[yw]=n.modifiers[yw]),s}var s3=u.createContext(void 0);function Woe(t){var e=ln(),n=X1(),r=eN(),s=Boe(e,n,r),i=Foe(e.modifiers),a=nt(nt({},s),i);return o.jsx(s3.Provider,{value:a,children:t.children})}function o3(){var t=u.useContext(s3);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function Hoe(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function qoe(t){return!!(t&&typeof t=="object"&&"from"in t)}function Goe(t){return!!(t&&typeof t=="object"&&"after"in t)}function Zoe(t){return!!(t&&typeof t=="object"&&"before"in t)}function Koe(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function Yoe(t,e){var n,r=e.from,s=e.to;if(r&&s){var i=qo(s,r)<0;i&&(n=[s,r],r=n[0],s=n[1]);var a=qo(t,r)>=0&&qo(s,t)>=0;return a}return s?Zr(s,t):r?Zr(r,t):!1}function Qoe(t){return G1(t)}function Xoe(t){return Array.isArray(t)&&t.every(G1)}function Joe(t,e){return e.some(function(n){if(typeof n=="boolean")return n;if(Qoe(n))return Zr(t,n);if(Xoe(n))return n.includes(t);if(qoe(n))return Yoe(t,n);if(Koe(n))return n.dayOfWeek.includes(t.getDay());if(Hoe(n)){var r=qo(n.before,t),s=qo(n.after,t),i=r>0,a=s<0,l=Bb(n.before,n.after);return l?a&&i:i||a}return Goe(n)?qo(t,n.after)>0:Zoe(n)?qo(n.before,t)>0:typeof n=="function"?n(t):!1})}function tN(t,e,n){var r=Object.keys(e).reduce(function(i,a){var l=e[a];return Joe(t,l)&&i.push(a),i},[]),s={};return r.forEach(function(i){return s[i]=!0}),n&&!Y1(t,n)&&(s.outside=!0),s}function eie(t,e){for(var n=fs(t[0]),r=Z1(t[t.length-1]),s,i,a=n;a<=r;){var l=tN(a,e),c=!l.disabled&&!l.hidden;if(!c){a=qr(a,1);continue}if(l.selected)return a;l.today&&!i&&(i=a),s||(s=a),a=qr(a,1)}return i||s}var tie=365;function i3(t,e){var n=e.moveBy,r=e.direction,s=e.context,i=e.modifiers,a=e.retry,l=a===void 0?{count:0,lastFocused:t}:a,c=s.weekStartsOn,d=s.fromDate,h=s.toDate,f=s.locale,p={day:qr,week:Ub,month:So,year:pre,startOfWeek:function(y){return s.ISOWeek?uc(y):si(y,{locale:f,weekStartsOn:c})},endOfWeek:function(y){return s.ISOWeek?HO(y):K1(y,{locale:f,weekStartsOn:c})}},g=p[n](t,r==="after"?1:-1);r==="before"&&d?g=gre([d,g]):r==="after"&&h&&(g=vre([h,g]));var v=!0;if(i){var x=tN(g,i);v=!x.disabled&&!x.hidden}return v?g:l.count>tie?l.lastFocused:i3(g,{moveBy:n,direction:r,context:s,modifiers:i,retry:nt(nt({},l),{count:l.count+1})})}var a3=u.createContext(void 0);
4066function nie(t){var e=vm(),n=o3(),r=u.useState(),s=r[0],i=r[1],a=u.useState(),l=a[0],c=a[1],d=eie(e.displayMonths,n),h=s??(l&&e.isDateDisplayed(l))?l:d,f=function(){c(s),i(void 0)},p=function(y){i(y)},g=ln(),v=function(y,b){if(s){var w=i3(s,{moveBy:y,direction:b,context:g,modifiers:n});Zr(s,w)||(e.goToDate(w,s),p(w))}},x={focusedDay:s,focusTarget:h,blur:f,focus:p,focusDayAfter:function(){return v("day","after")},focusDayBefore:function(){return v("day","before")},focusWeekAfter:function(){return v("week","after")},focusWeekBefore:function(){return v("week","before")},focusMonthBefore:function(){return v("month","before")},focusMonthAfter:function(){return v("month","after")},focusYearBefore:function(){return v("year","before")},focusYearAfter:function(){return v("year","after")},focusStartOfWeek:function(){return v("startOfWeek","before")},focusEndOfWeek:function(){return v("endOfWeek","after")}};return o.jsx(a3.Provider,{value:x,children:t.children})}function nN(){var t=u.useContext(a3);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}
4066function rie(t,e){var n=o3(),r=tN(t,n,e);return r}var rN=u.createContext(void 0);function sie(t){if(!$x(t.initialProps)){var e={selected:void 0};return o.jsx(rN.Provider,{value:e,children:t.children})}return o.jsx(oie,{initialProps:t.initialProps,children:t.children})}function oie(t){var e=t.initialProps,n=t.children,r=function(i,a,l){var c,d,h;if((c=e.onDayClick)===null||c===void 0||c.call(e,i,a,l),a.selected&&!e.required){(d=e.onSelect)===null||d===void 0||d.call(e,void 0,i,a,l);return}(h=e.onSelect)===null||h===void 0||h.call(e,i,i,a,l)},s={selected:e.selected,onDayClick:r};return o.jsx(rN.Provider,{value:s,children:n})}function l3(){var t=u.useContext(rN);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function iie(t,e){var n=ln(),r=l3(),s=X1(),i=eN(),a=nN(),l=a.focusDayAfter,c=a.focusDayBefore,d=a.focusWeekAfter,h=a.focusWeekBefore,f=a.blur,p=a.focus,g=a.focusMonthBefore,v=a.focusMonthAfter,x=a.focusYearBefore,y=a.focusYearAfter,b=a.focusStartOfWeek,w=a.focusEndOfWeek,j=function(W){var D,F,O,Y;$x(n)?(D=r.onDayClick)===null||D===void 0||D.call(r,t,e,W):pm(n)?(F=s.onDayClick)===null||F===void 0||F.call(s,t,e,W):gm(n)?(O=i.onDayClick)===null||O===void 0||O.call(i,t,e,W):(Y=n.onDayClick)===null||Y===void 0||Y.call(n,t,e,W)},E=function(W){var D;p(t),(D=n.onDayFocus)===null||D===void 0||D.call(n,t,e,W)},P=function(W){var D;f(),(D=n.onDayBlur)===null||D===void 0||D.call(n,t,e,W)},A=function(W){var D;(D=n.onDayMouseEnter)===null||D===void 0||D.call(n,t,e,W)},N=function(W){var D;(D=n.onDayMouseLeave)===null||D===void 0||D.call(n,t,e,W)},_=function(W){var D;(D=n.onDayPointerEnter)===null||D===void 0||D.call(n,t,e,W)},k=function(W){var D;(D=n.onDayPointerLeave)===null||D===void 0||D.call(n,t,e,W)},L=function(W){var D;(D=n.onDayTouchCancel)===null||D===void 0||D.call(n,t,e,W)},I=function(W){var D;(D=n.onDayTouchEnd)===null||D===void 0||D.call(n,t,e,W)},S=function(W){var D;(D=n.onDayTouchMove)===null||D===void 0||D.call(n,t,e,W)},T=function(W){var D;(D=n.onDayTouchStart)===null||D===void 0||D.call(n,t,e,W)},V=function(W){var D;(D=n.onDayKeyUp)===null||D===void 0||D.call(n,t,e,W)},$=function(W){var D;switch(W.key){case"ArrowLeft":W.preventDefault(),W.stopPropagation(),n.dir==="rtl"?l():c();break;case"ArrowRight":W.preventDefault(),W.stopPropagation(),n.dir==="rtl"?c():l();break;case"ArrowDown":W.preventDefault(),W.stopPropagation(),d();break;case"ArrowUp":W.preventDefault(),W.stopPropagation(),h();break;case"PageUp":W.preventDefault(),W.stopPropagation(),W.shiftKey?x():g();break;case"PageDown":W.preventDefault(),W.stopPropagation(),W.shiftKey?y():v();break;case"Home":W.preventDefault(),W.stopPropagation(),b();break;case"End":W.preventDefault(),W.stopPropagation(),w();break}(D=n.onDayKeyDown)===null||D===void 0||D.call(n,t,e,W)},H={onClick:j,onFocus:E,onBlur:P,onKeyDown:$,onKeyUp:V,onMouseEnter:A,onMouseLeave:N,onPointerEnter:_,onPointerLeave:k,onTouchCancel:L,onTouchEnd:I,onTouchMove:S,onTouchStart:T};return H}function aie(){var t=ln(),e=l3(),n=X1(),r=eN(),s=$x(t)?e.selected:pm(t)?n.selected:gm(t)?r.selected:void 0;return s}function lie(t){return Object.values(ko).includes(t)}function cie(t,e){var n=[t.classNames.day];return Object.keys(e).forEach(function(r){var s=t.modifiersClassNames[r];if(s)n.push(s);else if(lie(r)){var i=t.classNames["day_".concat(r)];i&&n.push(i)}}),n}function uie(t,e){var n=nt({},t.styles.day);return Object.keys(e).forEach(function(r){var s;n=nt(nt({},n),(s=t.modifiersStyles)===null||s===void 0?void 0:s[r])}),n}function die(t,e,n){var r,s,i,a=ln(),l=nN(),c=rie(t,e),d=iie(t,c),h=aie(),f=!!(a.onDayCl
4066ick||a.mode!=="default");u.useEffect(function(){var A;c.outside||l.focusedDay&&f&&Zr(l.focusedDay,t)&&((A=n.current)===null||A===void 0||A.focus())},[l.focusedDay,t,n,f,c.outside]);var p=cie(a,c).join(" "),g=uie(a,c),v=!!(c.outside&&!a.showOutsideDays||c.hidden),x=(i=(s=a.components)===null||s===void 0?void 0:s.DayContent)!==null&&i!==void 0?i:Aoe,y=o.jsx(x,{date:t,displayMonth:e,activeModifiers:c}),b={style:g,className:p,children:y,role:"gridcell"},w=l.focusTarget&&Zr(l.focusTarget,t)&&!c.outside,j=l.focusedDay&&Zr(l.focusedDay,t),E=nt(nt(nt({},b),(r={disabled:c.disabled,role:"gridcell"},r["aria-selected"]=c.selected,r.tabIndex=j||w?0:-1,r)),d),P={isButton:f,isHidden:v,activeModifiers:c,selectedDays:h,buttonProps:E,divProps:b};return P}function hie(t){var e=u.useRef(null),n=die(t.date,t.displayMonth,e);return n.isHidden?o.jsx("div",{role:"gridcell"}):n.isButton?o.jsx(mv,nt({name:"day",ref:e},n.buttonProps)):o.jsx("div",nt({},n.divProps))}function fie(t){var e=t.number,n=t.dates,r=ln(),s=r.onWeekNumberClick,i=r.styles,a=r.classNames,l=r.locale,c=r.labels.labelWeekNumber,d=r.formatters.formatWeekNumber,h=d(Number(e),{locale:l});if(!s)return o.jsx("span",{className:a.weeknumber,style:i.weeknumber,children:h});var f=c(Number(e),{locale:l}),p=function(g){s(e,n,g)};return o.jsx(mv,{name:"week-number","aria-label":f,className:a.weeknumber,style:i.weeknumber,onClick:p,children:h})}function mie(t){var e,n,r=ln(),s=r.styles,i=r.classNames,a=r.showWeekNumber,l=r.components,c=(e=l==null?void 0:l.Day)!==null&&e!==void 0?e:hie,d=(n=l==null?void 0:l.WeekNumber)!==null&&n!==void 0?n:fie,h;return a&&(h=o.jsx("td",{className:i.cell,style:s.cell,children:o.jsx(d,{number:t.weekNumber,dates:t.dates})})),o.jsxs("tr",{className:i.row,style:s.row,children:[h,t.dates.map(function(f){return o.jsx("td",{className:i.cell,style:s.cell,role:"presentation",children:o.jsx(c,{displayMonth:t.displayMonth,date:f})},pse(f))})]})}function XP(t,e,n){for(var r=n!=null&&n.ISOWeek?HO(e):K1(e,n),s=n!=null&&n.ISOWeek?uc(t):si(t,n),i=qo(r,s),a=[],l=0;l<=i;l++)a.push(qr(s,l));var c=a.reduce(function(d,h){var f=n!=null&&n.ISOWeek?ZO(h):YO(h,n),p=d.find(function(g){return g.weekNumber===f});return p?(p.dates.push(h),d):(d.push({weekNumber:f,dates:[h]}),d)},[]);return c}function pie(t,e){var n=XP(fs(t),Z1(t),e);if(e!=null&&e.useFixedWeeks){var r=vse(t,e);if(r<6){var s=n[n.length-1],i=s.dates[s.dates.length-1],a=Ub(i,6-r),l=XP(Ub(i,1),a,e);n.push.apply(n,l)}}return n}function gie(t){var e,n,r,s=ln(),i=s.locale,a=s.classNames,l=s.styles,c=s.hideHead,d=s.fixedWeeks,h=s.components,f=s.weekStartsOn,p=s.firstWeekContainsDate,g=s.ISOWeek,v=pie(t.displayMonth,{useFixedWeeks:!!d,ISOWeek:g,locale:i,weekStartsOn:f,firstWeekContainsDate:p}),x=(e=h==null?void 0:h.Head)!==null&&e!==void 0?e:Toe,y=(n=h==null?void 0:h.Row)!==null&&n!==void 0?n:mie,b=(r=h==null?void 0:h.Footer)!==null&&r!==void 0?r:koe;return o.jsxs("table",{id:t.id,className:a.table,style:l.table,role:"grid","aria-labelledby":t["aria-labelledby"],children:[!c&&o.jsx(x,{}),o.jsx("tbody",{className:a.tbody,style:l.tbody,children:v.map(function(w){return o.jsx(y,{displayMonth:t.displayMonth,dates:w.dates,weekNumber:w.weekNumber},w.weekNumber)})}),o.jsx(b,{displayMonth:t.displayMonth})]})}function vie(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var xie=vie()?u.useLayoutEffect:u.useEffect,jw=!1,yie=0;function JP(){return"react-day-picker-".concat(++yie)}function wie(t){var e,n=t??(jw?JP():null),r=u.useState(n),s=r[0],i=r[1];return xie(function(){s===null&&i(JP())},[]),u.useEffect(function(){jw===!1&&(jw=!0)},[]),(e=t??s)!==null&&e!==void 0?e:void 0}function bie(t){var e,n,r=ln(),s=r.dir,i=r.classNames,a=r.styles,l=r.components,c=vm().displayMonths,d=wie(r.id?"".concat(r.id,"-").concat(t.displayIndex):void 0),h=r.id?"".concat(r.id,"-grid-").concat(t.displayIndex):void 0,f=[i.month],p=a.month,g=t.displayIndex===0,v=t.displayIndex===c.length-1,x=!g&&!v;s==="rtl"&&(e=[g,v],v=e[0],g=e[1]),g&&(f.push(i.caption_start),p=nt(nt({},p),a.caption_start)),v&&(f.push(i.caption_end),p=nt(nt({},p),a.caption_end)),x&&(f.push(i.caption_between),p=nt(nt({},p),a.caption_between));var y=(n=l==null?void 0:l.Caption)!==null&&n!==void 0?n:Soe;return o.jsxs("div",{className:f.join(" "),style:p,children:[o.jsx(y,{id:d,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),o.jsx(gie,{id:h,"aria-labelledby":d,displayMonth:t.displayMonth})]},t.displayIndex)}function jie(t){var e=ln(),n=e.classNames,r=e.styles;return o.jsx("div",{className:n.months,style:r.months,children:t.children})}function Cie(t){var e,n,r=t.initialProps,s=ln(),i=nN(),a=vm(),l=u.useState(!1),c=l[0],d=l[1];u.useEffect(function(){s.initialFocus&&i.focusTarget&&(c||(i.focus(i.focusTarget),d(!0)))},[s.initialFocus,c,i.focus,i.focusTarget,i]);var h=[s.classNames.root,s.className];s.numberOfMonths>1&&h.push(s.classNames.multiple_months),s.showWeekNumber&&h.push(s.classNames.with_weeknumber);var f=nt(nt({},s.styles.root),s.style),p=Object.keys(r).filter(function(v){return v.startsWith("data-")}).reduce(function(v,x){var y;return nt(nt({},v),(y={},y[x]=r[x],y))},{}),g=(n=(e=r.components)===null||e===void 0?void 0:e.Months)!==null&&n!==void 0?n:jie;return o.jsx("div",nt({className:h.join(" "),style:f,dir:s.dir,id:s.id,nonce:r.nonce,title:r.title,lang:r.lang},p,{children:o.jsx(g,{children:a.displayMonths.map(function(v,x){return o.jsx(bie,{displayIndex:x,displayMonth:v},x)})})}))}function Nie(t){var e=t.children,n=Zse(t,["children"]);return o.jsx(foe,{initialProps:n,children:o.jsx(Coe,{children:o.jsx(sie,{initialProps:n,children:o.jsx(Roe,{initialProps:n,children:o.jsx(Moe,{initialProps:n,children:o.jsx(Woe,{children:o.jsx(nie,{children:e})})})})})})})}function _ie(t){return o.jsx(Nie,nt({},t,{children:o.jsx(Cie,{initialProps:t})}))}function Eie({className:t,classNames:e,showOutsideDays:n=!0,...r}){return o.jsx(_ie,{showOutsideDays:n,className:Oe("p-3",t),classNames:{months:"flex flex-col sm:flex-row gap-2",month:"flex flex-col gap-4",caption:"flex justify-center pt-1 relative items-center w-full",caption_label:"text-sm font-medium",nav:"flex items-center gap-1",nav_button:Oe(bf({variant:"outline"}),"size-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-x-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:Oe("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-range-end)]:rounded-r-md",r.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:Oe(bf({variant:"ghost"}),"size-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start aria-selected:bg-primary aria-selected:text-primary-foreground",day_range_end:"day-range-end aria-selected:bg-primary aria-selected:text-primary-foreground",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...e},components:{IconLeft:({className:s,...i})=>o.jsx(vc,{className:Oe("size-4",s),...i}),IconRight:({className:s,...i})=>o.jsx(nr,{className:Oe("size-4",s),...i})},...r})}const Cw="__none__";function Sie(t,e,n){let r=!1;for(let s=0,i=n.length-1;s<n.length;i=s++){const a=n[s].longitude,l=n[s].latitude,c=n[i].longitude,d=n[i].latitude;l>t!=d>t&&e<(c-a)*(t-l)/(d-l)+a&&(r=!r)}return r}function kie(t){const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`}function eI(t){return`${String(t.getHours()).padStart(2,"0")}
4066:${String(t.getMinutes()).padStart(2,"0")}`}function Pie({open:t,onOpenChange:e,companyId:n,creatorId:r,zones:s,members:i,postes:a,battue:l,onSaved:c}){const d=Ft(),h=!!l,[f,p]=u.useState(""),[g,v]=u.useState(""),[x,y]=u.useState(""),[b,w]=u.useState("08:00"),[j,E]=u.useState("17:00"),[P,A]=u.useState(""),[N,_]=u.useState(new Set),[k,L]=u.useState(!1);u.useEffect(()=>{var H,W,D,F;if(t)if(l){const O=((W=(H=l.startDate)==null?void 0:H.toDate)==null?void 0:W.call(H))??null,Y=((F=(D=l.endDate)==null?void 0:D.toDate)==null?void 0:F.call(D))??null;p(l.name??""),v(l.huntingZoneId??""),y(O?kie(O):""),w(O?eI(O):"08:00"),E(Y?eI(Y):"17:00"),A(l.chefDeBattueId??""),_(new Set(l.posteIds??[]))}else p(""),v(""),y(""),w("08:00"),E("17:00"),A(""),_(new Set)},[t,l,s,a]);const I=u.useMemo(()=>[...i].sort((H,W)=>bn(H).localeCompare(bn(W))),[i]);function S(H){var D;const W=(D=s.find(F=>F.id===H))==null?void 0:D.gpsPoint;return!W||W.length<3?a:a.filter(F=>Sie(F.lat,F.lng,W))}const T=u.useMemo(()=>S(g),[s,a,g]),V=H=>{const W=H===Cw?"":H;v(W),_(new Set(W?S(W).map(D=>D.id):[]))},$=async()=>{var ee;if(!f.trim()){d.error("Le nom de la battue est requis");return}if(!x){d.error("Sélectionnez une date");return}if(!P){d.error("Désignez un organisateur");return}const[H,W,D]=x.split("-").map(Number),[F,O]=b.split(":").map(Number),[Y,G]=j.split(":").map(Number),q=new Date(H,W-1,D,F,O),re=new Date(H,W-1,D,Y,G);if(re<=q){d.error("L'heure de fin doit être après l'heure de début");return}const U=((ee=s.find(K=>K.id===g))==null?void 0:ee.name)??null;L(!0);try{h&&l?(await Bl.update(l.id,{name:f.trim(),huntingZoneId:g,huntingZoneName:U,startDate:q,endDate:re,chefDeBattueId:P,posteIds:[...N]}),d.success("Battue mise à jour")):(await Bl.create({companyId:n,creatorId:r,chefDeBattueId:P,name:f.trim(),huntingZoneId:g,huntingZoneName:U,startDate:q,endDate:re,registeredHunterIds:[P],presence:{[P]:!0},posteIds:[...N]}),d.success("Battue créée")),e(!1),c()}catch(K){console.error("Error saving battue:",K),d.error("Erreur lors de l'enregistrement de la battue")}finally{L(!1)}};return o.jsx(rr,{open:t,onOpenChange:e,children:o.jsxs(sr,{className:"max-h-[90vh] overflow-y-auto sm:max-w-lg",children:[o.jsxs(or,{children:[o.jsx(Gn,{children:h?"Modifier la battue":"Nouvelle battue"}),o.jsx(ir,{children:"L'assignation des postes et la présence se font dans l'application le jour de la battue."})]}),o.jsxs("div",{className:"space-y-4 py-2",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"battue-name",children:"Nom *"}),o.jsx(Ne,{id:"battue-name",value:f,onChange:H=>p(H.target.value),placeholder:"Ex: Battue du bois nord"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{children:"Zone de chasse"}),o.jsxs(_t,{value:g||Cw,onValueChange:V,children:[o.jsx(St,{children:o.jsx(Et,{placeholder:"Zone à définir plus tard"})}),o.jsxs(kt,{children:[o.jsx(Ke,{value:Cw,children:"Zone à définir plus tard"}),s.map(H=>o.jsx(Ke,{value:H.id,children:H.name},H.id))]})]})]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"battue-date",children:"Date *"}),o.jsx(Ne,{id:"battue-date",type:"date",value:x,onChange:H=>y(H.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"battue-start",children:"Début"}),o.jsx(Ne,{id:"battue-start",type:"time",value:b,onChange:H=>w(H.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"battue-end",children:"Fin"}),o.jsx(Ne,{id:"battue-end",type:"time",value:j,onChange:H=>E(H.target.value)})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{children:"Organisateur *"}),o.jsxs(_t,{value:P,onValueChange:A,children:[o.jsx(St,{children:o.jsx(Et,{placeholder:"Désigner un organisateur"})}),o.jsx(kt,{children:I.map(H=>o.jsx(Ke,{value:H.id,children:bn(H)},H.id))})]})]}),!h&&o.jsx("p",{className:"text-xs text-muted-foreground rounded-lg border border-dashed p-3",children:"Les participants, rôles et groupes se gèrent via « Gérer » une fois la battue créée. Le statut s'active automatiquement sur le créneau horaire."}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ne,{children:["Postes (",N.size," / ",T.length,")"]}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Miradors / postes au sol situés dans la zone, utilisés pour le tirage au sort."}),o.jsx("div",{className:"max-h-40 overflow-y-auto rounded-lg border divide-y",children:T.length===0?o.jsx("p",{className:"text-sm text-muted-foreground p-3",children:"Aucun poste dans cette zone (ajoutez des POI Mirador / Poste au sol sur la carte)."}):T.map(H=>o.jsxs("label",{className:"flex items-center gap-3 p-2.5 cursor-pointer",children:[o.jsx(Ks,{checked:N.has(H.id),onCheckedChange:()=>_(W=>{const D=new Set(W);return D.has(H.id)?D.delete(H.id):D.add(H.id),D})}),o.jsxs("span",{className:"flex-1 min-w-0 text-sm truncate",children:[H.name||"Poste",o.jsxs("span",{className:"text-muted-foreground",children:[" · ",H.type]})]})]},H.id))})]})]}),o.jsxs(ks,{children:[o.jsx(Z,{variant:"outline",onClick:()=>e(!1),disabled:k,children:"Annuler"}),o.jsxs(Z,{onClick:$,disabled:k,children:[k&&o.jsx(ft,{className:"h-4 w-4 mr-2 animate-spin"}),h?"Enregistrer":"Créer la battue"]})]})]})})}var c3="Toggle",u3=u.forwardRef((t,e)=>
4066{const{pressed:n,defaultPressed:r,onPressedChange:s,...i}=t,[a,l]=Co({prop:n,onChange:s,defaultProp:r??!1,caller:c3});return o.jsx(Je.button,{type:"button","aria-pressed":a,"data-state":a?"on":"off","data-disabled":t.disabled?"":void 0,...i,ref:e,onClick:Le(t.onClick,()=>{t.disabled||l(!a)})})});u3.displayName=c3;var cl="ToggleGroup",[d3]=Rs(cl,[xd]),h3=xd(),sN=Ce.forwardRef((t,e)=>{const{type:n,...r}=t;if(n==="single"){const s=r;return o.jsx(Iie,{...s,ref:e})}if(n==="multiple"){const s=r;return o.jsx(Tie,{...s,ref:e})}throw new Error(`Missing prop \`type\` expected on \`${cl}\``)});sN.displayName=cl;var[f3,m3]=d3(cl),Iie=Ce.forwardRef((t,e)=>{const{value:n,defaultValue:r,onValueChange:s=()=>{},...i}=t,[a,l]=Co({prop:n,defaultProp:r??"",onChange:s,caller:cl});return o.jsx(f3,{scope:t.__scopeToggleGroup,type:"single",value:Ce.useMemo(()=>a?[a]:[],[a]),onItemActivate:l,onItemDeactivate:Ce.useCallback(()=>l(""),[l]),children:o.jsx(p3,{...i,ref:e})})}),Tie=Ce.forwardRef((t,e)=>{const{value:n,defaultValue:r,onValueChange:s=()=>{},...i}=t,[a,l]=Co({prop:n,defaultProp:r??[],onChange:s,caller:cl}),c=Ce.useCallback(h=>l((f=[])=>[...f,h]),[l]),d=Ce.useCallback(h=>l((f=[])=>f.filter(p=>p!==h)),[l]);return o.jsx(f3,{scope:t.__scopeToggleGroup,type:"multiple",value:a,onItemActivate:c,onItemDeactivate:d,children:o.jsx(p3,{...i,ref:e})})});sN.displayName=cl;var[Aie,Rie]=d3(cl),p3=Ce.forwardRef((t,e)=>{const{__scopeToggleGroup:n,disabled:r=!1,rovingFocus:s=!0,orientation:i,dir:a,loop:l=!0,...c}=t,d=h3(n),h=sm(a),f={role:"group",dir:h,...c};return o.jsx(Aie,{scope:n,rovingFocus:s,disabled:r,children:s?o.jsx(S1,{asChild:!0,...d,orientation:i,dir:h,loop:l,children:o.jsx(Je.div,{...f,ref:e})}):o.jsx(Je.div,{...f,ref:e})})}),pv="ToggleGroupItem",g3=Ce.forwardRef((t,e)=>{const n=m3(pv,t.__scopeToggleGroup),r=Rie(pv,t.__scopeToggleGroup),s=h3(t.__scopeToggleGroup),i=n.value.includes(t.value),a=r.disabled||t.disabled,l={...t,pressed:i,disabled:a},c=Ce.useRef(null);return r.rovingFocus?o.jsx(k1,{asChild:!0,...s,focusable:!a,active:i,ref:c,children:o.jsx(tI,{...l,ref:e})}):o.jsx(tI,{...l,ref:e})});g3.displayName=pv;var tI=Ce.forwardRef((t,e)=>{const{__scopeToggleGroup:n,value:r,...s}=t,i=m3(pv,n),a={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},l=i.type==="single"?a:void 0;return o.jsx(u3,{...l,...s,ref:e,onPressedChange:c=>{c?i.onItemActivate(r):i.onItemDeactivate(r)}})}),Die=sN,Lie=g3;const Mie=fx("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 px-2 min-w-9",sm:"h-8 px-1.5 min-w-8",lg:"h-10 px-2.5 min-w-10"}},defaultVariants:{variant:"default",size:"default"}}),v3=u.createContext({size:"default",variant:"default"});function Oie({className:t,variant:e,size:n,children:r,...s}){return o.jsx(Die,{"data-slot":"toggle-group","data-variant":e,"data-size":n,className:Oe("group/toggle-group flex w-fit items-center rounded-md data-[variant=outline]:shadow-xs",t),...s,children:o.jsx(v3.Provider,{value:{variant:e,size:n},children:r})})}function nI({className:t,children:e,variant:n,size:r,...s}){const i=u.useContext(v3);return o.jsx(Lie,{"data-slot":"toggle-group-item","data-variant":i.variant||n,"data-size":i.size||r,className:Oe(Mie({variant:i.variant||n,size:i.size||r}),"min-w-0 flex-1 shrink-0 rounded-none shadow-none first:rounded-l-md last:rounded-r-md focus:z-10 focus-visible:z-10 data-[variant=outline]:border-l-0 data-[variant=outline]:first:border-l",t),...s,children:e})}const ta="__none__",bp=t=>{const e=[...t];for(let n=e.length-1;n>0;n--){const r=Math.floor(Math.random()*(n+1));[e[n],e[r]]=[e[r],e[n]]}return e};
4066function Fie({open:t,onOpenChange:e,battue:n,members:r,postes:s,onSaved:i}){const a=Ft(),[l,c]=u.useState({}),[d,h]=u.useState([]),[f,p]=u.useState([]),[g,v]=u.useState({}),[x,y]=u.useState([]),[b,w]=u.useState([]),[j,E]=u.useState(""),[P,A]=u.useState(!1);u.useEffect(()=>{t&&(c(n.presence??{}),h(n.registeredHunterIds??[]),p(n.rabatteurIds??[]),v(n.assignments??{}),y(n.groups??[]),w(n.externalHunters??[]))},[t,n]);const N=B=>{Bl.updateFields(n.id,B).then(i).catch(Q=>a.error((Q==null?void 0:Q.message)||"Erreur lors de lâenregistrement"))},_=B=>{var Q,ve;return((Q=r.find(Ae=>Ae.id===B))==null?void 0:Q.name)||((ve=b.find(Ae=>Ae.id===B))==null?void 0:ve.name)||"â"},k=B=>{var Q;return((Q=s.find(ve=>ve.id===B))==null?void 0:Q.name)||"Poste"},L=B=>f.includes(B),I=B=>B===n.chefDeBattueId||l[B]===!0,S=u.useMemo(()=>{const B=r.filter(ve=>I(ve.id)&&!L(ve.id)).map(ve=>ve.id),Q=b.filter(ve=>I(ve.id)).map(ve=>ve.id);return[...B,...Q]},[r,b,l,f]),T=x.length>0,V=(B,Q)=>{if(B===n.chefDeBattueId)return;const ve=!I(B),Ae={...l,[B]:ve};c(Ae);const he={presence:Ae};if(!Q){const J=new Set(d);ve?J.add(B):J.delete(B);const je=[...J];h(je),he.registeredHunterIds=je}if(!ve){if(f.includes(B)){const J=f.filter(je=>je!==B);p(J),he.rabatteurIds=J}if(g[B]){const J={...g};delete J[B],v(J),he.assignments=J}}N(he)},$=B=>{const Q=L(B)?f.filter(ve=>ve!==B):[...f,B];p(Q),N({rabatteurIds:Q})},H=()=>{const B=j.trim();if(!B)return;const Q={id:`ext_${Date.now()}`,name:B},ve=[...b,Q];w(ve),E(""),N({externalHunters:ve})},W=B=>{const Q=b.filter(J=>J.id!==B),ve={...l};delete ve[B];const Ae={...g};delete Ae[B];const he=x.map(J=>J.memberIds.includes(B)?{...J,memberIds:J.memberIds.filter(je=>je!==B),refereeId:J.refereeId===B?void 0:J.refereeId}:J);w(Q),c(ve),v(Ae),y(he),N({externalHunters:Q,presence:ve,assignments:Ae,groups:he})},D=(B,Q)=>{const ve={...g};Q===ta?delete ve[B]:ve[B]=Q,v(ve),N({assignments:ve})},F=()=>{const B=bp(n.posteIds);if(B.length===0){a.error("Aucun poste sélectionné pour cette battue.");return}const Q=bp(S),ve={};Q.forEach((Ae,he)=>{ve[Ae]=B[he%B.length]}),v(ve),N({assignments:ve}),a.success("Tirage effectué")},O=B=>{y(B);const Q={};Object.entries(g).forEach(([Ae,he])=>{(B.length===0?n.posteIds.includes(he):B.some(je=>je.memberIds.includes(Ae)&&je.posteIds.includes(he)))&&(Q[Ae]=he)});const ve=Object.keys(Q).length!==Object.keys(g).length;ve&&v(Q),N(ve?{groups:B,assignments:Q}:{groups:B})},Y=()=>O([{id:`grp_${Date.now()}`,name:"Groupe 1",posteIds:[],memberIds:[]}]),G=()=>O([]),q=()=>{x.some(Q=>Q.memberIds.length>0||Q.posteIds.length>0||Q.refereeId)?A(!0):G()},re=()=>O([...x,{id:`grp_${Date.now()}`,name:`Groupe ${x.length+1}`,posteIds:[],memberIds:[]}]),U=B=>O(x.filter(Q=>Q.id!==B)),ee=(B,Q)=>O(x.map(ve=>ve.id===B?{...ve,...Q}:ve)),K=B=>{const Q=new Set(S),ve=bp(B.memberIds.filter(J=>Q.has(J))),Ae=bp(B.posteIds),he={...g};B.memberIds.forEach(J=>{delete he[J]}),Ae.length>0&&ve.forEach((J,je)=>{he[J]=Ae[je%Ae.length]}),v(he),N({assignments:he}),a.success(`Tirage : ${B.name}`)},ue=B=>new Set(x.filter(Q=>Q.id!==B).flatMap(Q=>Q.memberIds)),be=B=>new Set(x.filter(Q=>Q.id!==B).flatMap(Q=>Q.posteIds)),le=[...[...r].sort((B,Q)=>B.name.localeCompare(Q.name)).map(B=>({id:B.id,name:B.name,external:!1})),...b.map(B=>({id:B.id,name:B.name,external:!0}))];return o.jsx(rr,{open:t,onOpenChange:B=>{e(B),B||i()},children:o.jsxs(sr,{className:"max-h-[92vh] overflow-y-auto sm:max-w-2xl",children:[o.jsxs(or,{children:[o.jsxs(Gn,{children:["Gérer ",n.name]}),o.jsx(ir,{children:"Présence, rôles, groupes et tirage au sort des postes."})]}),o.jsxs("div",{className:"space-y-6 py-2",children:[o.jsxs("section",{children:[o.jsx("h3",{className:"text-sm font-bold font-heading mb-2",children:"Participants"}),o.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Cochez les chasseurs présents, puis choisissez leur rôle."}),o.jsx("div",{className:"rounded-lg border divide-y max-h-72 overflow-y-auto",children:le.length===0?o.jsx("p",{className:"text-sm text-muted-foreground p-3",children:"Aucun membre dans cette société."}):le.map(B=>{const Q=B.id===n.chefDeBattueId,ve=I(B.id);return o.jsxs("div",{className:"flex items-center gap-3 p-2.5",children:[o.jsx(Ks,{checked:ve,disabled:Q,onCheckedChange:()=>V(B.id,B.external)}),o.jsxs("span",{className:"flex-1 min-w-0 text-sm truncate",children:[B.name,Q&&o.jsx(We,{variant:"secondary",className:"ml-2 text-[10px]",children:"Organisateur"}),B.external&&o.jsx(We,{variant:"secondary",className:"ml-2 text-[10px]",children:"Hors app"})]}),B.external?o.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>W(B.id),children:o.jsx(Vt,{className:"h-4 w-4"})}):ve&&o.jsx("button",{type:"button",onClick:()=>$(B.id),className:"text-xs rounded-full px-2.5 py-1 border transition-colors "+(L(B.id)?"bg-primary/10 border-primary/30 text-primary":"border-border text-muted-foreground hover:bg-muted"),children:"Rabatteur"})]},B.id)})}),o.jsxs("div",{className:"flex gap-2 mt-2",children:[o.jsx(Ne,{value:j,onChange:B=>E(B.target.value),placeholder:"Chasseur hors applicationâ¦",onKeyDown:B=>{B.key==="Enter"&&H()},className:"h-9"}),o.jsxs(Z,{variant:"outline",size:"sm",onClick:H,disabled:!j.trim(),children:[o.jsx(sc,{className:"h-4 w-4 mr-1.5"}),"Ajouter"]})]})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"text-sm font-bold font-heading mb-2",children:"Groupes"}),o.jsxs(Oie,{type:"single",variant:"outline",value:T?"multi":"single",onValueChange:B=>{B&&(B==="multi"&&!T&&Y(),B==="single"&&T&&q())},className:"w-full grid grid-cols-2",children:[o.jsx(nI,{value:"single",className:"text-xs",children:"Un seul groupe"}),o.jsx(nI,{value:"multi",className:"text-xs",children:"Plusieurs groupes"})]}),T?o.jsxs("div",{className:"space-y-3 mt-3",children:[x.map(B=>{const Q=ue(B.id),ve=be(B.id),Ae=B.memberIds.filter(he=>S.includes(he));return o.jsxs("div",{className:"rounded-lg border p-3 space-y-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ne,{value:B.name,onChange:he=>ee(B.id,{name:he.target.value}),className:"h-8 font-medium"}),o.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>U(B.id),children:o.jsx(Vt,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:"Chef de groupe"}),o.jsxs(_t,{value:B.refereeId||ta,onValueChange:he=>ee(B.id,{refereeId:he===ta?void 0:he}),children:[o.jsx(St,{className:"h-8 flex-1 text-xs",children:o.jsx(Et,{placeholder:"à désigner"})}),o.jsxs(kt,{children:[o.jsx(Ke,{value:ta,children:"Aucun chef de groupe"}),B.memberIds.map(he=>o.jsx(Ke,{value:he,children:_(he)},he))]})]})]}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-1.5",children:"Chasseurs"}),o.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[S.map(he=>{const J=B.memberIds.includes(he),je=Q.has(he);return o.jsx("button",{type:"button",disabled:je&&!J,onClick:()=>ee(B.id,{memberIds:J?B.memberIds.filter(Ve=>Ve!==he):[...B.memberIds,he]}),className:"text-xs rounded-full px-2 py-1 border "+(J?"bg-primary/10 border-primary/30 text-primary":je?"opacity-40 border-border":"border-border hover:bg-muted"),children:_(he)},he)}),S.length===0&&o.jsx("span",{className:"text-xs text-muted-foreground",children:"Aucun chasseur présent."})]})]}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-1.5",children:"Postes"}),o.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[n.posteIds.map(he=>{const J=B.posteIds.includes(he),je=ve.has(he);return o.jsx("button",{type:"button",disabled:je&&!J,onClick:()=>ee(B.id,{posteIds:J?B.posteIds.filter(Ve=>Ve!==he):[...B.posteIds,he]}),className:"text-xs rounded-full px-2 py-1 border "+(J?"bg-amber-500/10 border-amber-500/30 text-amber-700":je?"opacity-40 border-border":"border-border hover:bg-muted"),children:k(he)},he)}),n.posteIds.length===0&&o.jsx("span",{className:"text-xs text-muted-foreground",children:"Aucun poste sur la battue."})]})]}),o.jsxs("div",{className:"pt-2 border-t",children:[o.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Attribution"}),o.jsxs(Z,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>K(B),disabled:Ae.length===0||B.posteIds.length===0,children:[o.jsx(Xk,{className:"h-3.5 w-3.5 mr-1.5"}),"Tirer au sort"]})]}),B.memberIds.length===0||B.posteIds.length===0?o.jsx("p",{className:"text-xs text-muted-foreground",children:"Choisissez des chasseurs et des postes pour attribuer."}):Ae.length===0?o.jsx("p",{className:"text-xs text-muted-foreground",children:"Aucun chasseur présent à placer."}):o.jsx("div",{className:"space-y-1.5",children:Ae.map(he=>o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:"flex-1 min-w-0 text-sm truncate",children:_(he)}),o.jsxs(_t,{value:B.posteIds.includes(g[he])?g[he]:ta,onValueChange:J=>D(he,J),children:[o.jsx(St,{className:"h-8 w-44 text-xs",children:o.jsx(Et,{placeholder:"Poste"})}),o.jsxs(kt,{children:[o.jsx(Ke,{value:ta,children:"Non placé"}),B.posteIds.map(J=>o.jsx(Ke,{value:J,children:k(J)},J))]})]})]},he))})]})]},B.id)}),o.jsxs(Z,{variant:"outline",size:"sm",onClick:re,children:[o.jsx(hr,{className:"h-4 w-4 mr-1.5"}),"Ajouter un groupe"]})]}):o.jsxs("div",{className:"mt-3 space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("span",{className:"text-sm text-muted-foreground",children:[S.length," chasseur(s) présent(s) · ",n.posteIds.length," poste(s)"]}),o.jsxs(Z,{size:"sm",variant:"outline",onClick:F,disabled:n.posteIds.length===0||S.length===0,children:[o.jsx(Xk,{className:"h-4 w-4 mr-1.5"}),"Tirer les postes au sort"]})]}),S.length===0?o.jsx("p",{className:"text-sm text-muted-foreground",children:"Marquez des chasseurs présents pour les affecter."}):o.jsx("div",{className:"rounded-lg border divide-y",children:S.map(B=>o.jsxs("div",{className:"flex items-center gap-3 p-2.5",children:[o.jsx("span",{className:"flex-1 min-w-0 text-sm truncate",children:_(B)}),o.jsxs(_t,{value:g[B]||ta,onValueChange:Q=>D(B,Q),children:[o.jsx(St,{className:"h-8 w-44 text-xs",children:o.jsx(Et,{placeholder:"Poste"})}),o.jsxs(kt,{children:[o.jsx(Ke,{value:ta,children:"Non placé"}),n.posteIds.map(Q=>o.jsx(Ke,{value:Q,children:k(Q)},Q))]})]})]},B))})]})]})]}),o.jsx(Dn,{open:P,onOpenChange:A,children:o.jsxs(Ln,{children:[o.jsxs(Mn,{children:[o.jsx(Fn,{children:"Revenir à un seul groupe"}),o.jsx(zn,{children:"Les groupes créés seront supprimés. Les affectations de postes déjà faites sont conservées."})]}),o.jsxs(On,{children:[o.jsx(Vn,{children:"Annuler"}),o.jsx($n,{onClick:()=>{G(),A(!1)},children:"Confirmer"})]})]})})]})})}const rI=t=>{var e;return((e=t==null?void 0:t.toDate)==null?void 0:e.call(t))??null},zie=["Mirador","Poste au sol"],$ie={scheduled:"text-amber-600 border-amber-500/30 bg-amber-500/10",draft:"text-muted-foreground",inProgress:"text-orange-600 border-orange-500/30 bg-
4066orange-500/10",done:"text-primary border-primary/30 bg-primary/10",cancelled:"text-red-600 border-red-500/30 bg-red-500/10"};function Vie(t){var n;const e=((n=t==null?void 0:t.toDate)==null?void 0:n.call(t))??null;return e?e.toLocaleDateString("fr-FR",{weekday:"short",day:"2-digit",month:"short"})+" "+e.toLocaleTimeString("fr-FR",{hour:"2-digit",minute:"2-digit"}):""}function Uie({companyId:t,creatorId:e,canManage:n}){const r=Ft(),[s,i]=u.useState([]),[a,l]=u.useState([]),[c,d]=u.useState([]),[h,f]=u.useState([]),[p,g]=u.useState(!0),[v,x]=u.useState(!1),[y,b]=u.useState(null),[w,j]=u.useState(null),[E,P]=u.useState(null),[A,N]=u.useState(!1),[_,k]=u.useState(new Date),L=s.map(D=>rI(D.startDate)).filter(D=>D!==null),I=_?s.filter(D=>{const F=rI(D.startDate);return F&&Zr(F,_)}):s,S=u.useCallback(async()=>{try{i(await Bl.listByCompany(t))}catch(D){console.error("Error loading battues:",D),r.error("Erreur lors du chargement des battues")}},[t,r]),T=u.useCallback(async()=>{g(!0);try{const[D,F,O,Y]=await Promise.all([Bl.listByCompany(t),go.listByCompany(t).catch(()=>[]),Ot.getCompanyMembers(t).then(G=>G.members).catch(()=>[]),vi.getPoisByCompanies([t]).catch(()=>[])]);i(D),l(F),d(O),f(Y.filter(G=>zie.includes(G.type)).map(G=>({id:G.id,name:G.name,type:G.type,lat:G.position.latitude,lng:G.position.longitude})))}catch(D){console.error("Error loading battues section:",D),r.error("Erreur lors du chargement")}finally{g(!1)}},[t,r]);u.useEffect(()=>{T()},[T]);const V=D=>{const F=c.find(O=>O.id===D);return F?bn(F):"â"},$=()=>{b(null),x(!0)},H=D=>{b(D),x(!0)},W=async()=>{if(E){N(!0);try{await Bl.remove(E.id),r.success("Battue supprimée"),P(null),await S()}catch(D){console.error("Error deleting battue:",D),r.error("Erreur lors de la suppression")}finally{N(!1)}}};return o.jsxs(ke,{children:[o.jsx(Qt,{children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(vb,{className:"w-5 h-5"}),"Battues",o.jsx(We,{variant:"secondary",className:"ml-1",children:s.length})]}),n&&o.jsxs(Z,{size:"sm",onClick:$,disabled:a.length===0,children:[o.jsx(hr,{className:"w-4 h-4 mr-2"}),"Créer une battue"]})]})}),o.jsx(Pe,{children:p?o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx(ft,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):n&&a.length===0?o.jsx("p",{className:"text-sm text-muted-foreground py-2",children:"Créez d'abord une zone de chasse pour pouvoir programmer une battue."}):o.jsxs("div",{className:"grid gap-6 lg:grid-cols-[auto_1fr]",children:[o.jsx("div",{className:"mx-auto lg:mx-0",children:o.jsx(Eie,{mode:"single",locale:KP,selected:_,onSelect:k,modifiers:{hasBattue:L},modifiersClassNames:{hasBattue:"relative font-semibold after:absolute after:bottom-1 after:left-1/2 after:-translate-x-1/2 after:h-1.5 after:w-1.5 after:rounded-full after:bg-orange-500"}})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"text-sm font-semibold font-heading mb-2 capitalize",children:_?ll(_,"EEEE d MMMM yyyy",{locale:KP}):"Toutes les battues"}),I.length===0?o.jsx("p",{className:"text-sm text-muted-foreground py-6 text-center",children:"Aucune battue ce jour."}):o.jsx("div",{className:"divide-y divide-border",children:I.map(D=>o.jsxs("div",{className:"flex items-center justify-between gap-3 py-3",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx("p",{className:"font-medium text-sm truncate",children:D.name}),(()=>{const F=ire(D);return o.jsx(We,{variant:"outline",className:$ie[F]||"",children:BW[F]||F})})()]}),o.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground flex-wrap",children:[o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(vb,{className:"w-3 h-3"}),Vie(D.startDate)]}),o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(ur,{className:"w-3 h-3"}),D.huntingZoneName||"Zone à définir"]}),o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(cr,{className:"w-3 h-3"}),D.registeredHunterIds.length]}),o.jsxs("span",{children:["Organisateur : ",V(D.chefDeBattueId)]})]})]}),n&&o.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[o.jsx(Z,{variant:"outline",size:"sm",onClick:()=>j(D),title:"Présence, groupes, tirage au sort",children:"Gérer"}),o.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>H(D),title:"Modifier",children:o.jsx(fd,{className:"w-4 h-4"})}),o.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>P(D),title:"Supprimer",className:"text-red-600 hover:text-red-700 hover:bg-red-500/10",children:o.jsx(Vt,{className:"w-4 h-4"})})]})]},D.id))})]})]})}),n&&o.jsx(Pie,{open:v,onOpenChange:x,companyId:t,creatorId:e,zone
4066s:a,members:c,postes:h,battue:y,onSaved:S}),n&&w&&o.jsx(Fie,{open:!!w,onOpenChange:D=>{D||j(null)},battue:w,members:c.map(D=>({id:D.id,name:bn(D)})),postes:h.map(D=>({id:D.id,name:D.name})),onSaved:S}),o.jsx(Dn,{open:!!E,onOpenChange:D=>!D&&P(null),children:o.jsxs(Ln,{children:[o.jsxs(Mn,{children:[o.jsx(Fn,{children:"Supprimer la battue"}),o.jsx(zn,{children:E?`La battue « ${E.name} » sera supprimée.`:""})]}),o.jsxs(On,{children:[o.jsx(Vn,{disabled:A,children:"Annuler"}),o.jsx($n,{onClick:D=>{D.preventDefault(),W()},disabled:A,className:"bg-red-600 hover:bg-red-700",children:A?"Suppressionâ¦":"Supprimer"})]})]})})]})}function Bie(t,e){return{id:t,companyId:e.companyId??"",name:e.name??"",storagePath:e.storagePath??"",downloadUrl:e.downloadUrl??"",uploadedBy:e.uploadedBy??"",uploadedByName:e.uploadedByName??void 0,contentType:e.contentType??void 0,size:typeof e.size=="number"?e.size:void 0,uploadedAt:e.uploadedAt??null}}const Nw={async listByCompany(t){const e=Gr(jn(Xe,"companyDocuments"),is("companyId","==",t)),r=(await Yr(e)).docs.map(s=>Bie(s.id,s.data()));return r.sort((s,i)=>{var c,d,h,f;const a=((d=(c=s.uploadedAt)==null?void 0:c.toMillis)==null?void 0:d.call(c))??0;return(((f=(h=i.uploadedAt)==null?void 0:h.toMillis)==null?void 0:f.call(h))??0)-a}),r},async upload(t,e,n,r){const s=`company_documents/${t}/${Date.now()}_${e.name}`,i=Wa(Ha,s);await sb(i,e);const a=await xf(i),l=e.name.includes(".")?e.name.split(".").pop()??null:null;return(await ld(jn(Xe,"companyDocuments"),{companyId:t,name:e.name,storagePath:s,downloadUrl:a,uploadedBy:n,uploadedByName:r??null,contentType:l,size:e.size,uploadedAt:Or()})).id},async remove(t){if(await Qf(Ht(Xe,"companyDocuments",t.id)),t.storagePath)try{await vW(Wa(Ha,t.storagePath))}catch(e){console.warn("Storage delete failed:",e)}}};function Wie(t){return t?t<1024?`${t} o`:t<1024*1024?`${(t/1024).toFixed(0)} Ko`:`${(t/(1024*1024)).toFixed(1)} Mo`:""}function Hie(t){var n;const e=((n=t==null?void 0:t.toDate)==null?void 0:n.call(t))??null;return e?e.toLocaleDateString("fr-FR",{day:"2-digit",month:"2-digit",year:"numeric"}):""}function qie({companyId:t,canManage:e,currentUserId:n,currentUserName:r}){const s=Ft(),i=u.useRef(null),[a,l]=u.useState([]),[c,d]=u.useState(!0),[h,f]=u.useState(!1),[p,g]=u.useState(null),[v,x]=u.useState(!1),y=u.useCallback(async()=>{d(!0);try{l(await Nw.listByCompany(t))}catch(j){console.error("Error loading documents:",j),s.error("Erreur lors du chargement des documents")}finally{d(!1)}},[t,s]);u.useEffect(()=>{y()},[y]);const b=async j=>{var P;const E=(P=j.target.files)==null?void 0:P[0];if(j.target.value="",!!E){f(!0);try{await Nw.upload(t,E,n,r),s.success("Document ajouté"),await y()}catch(A){console.error("Error uploading document:",A),s.error("Erreur lors de l'envoi du document")}finally{f(!1)}}},w=async()=>{if(p){x(!0);try{await Nw.remove(p),s.success("Document supprimé"),g(null),await y()}catch(j){console.error("Error deleting document:",j),s.error("Erreur lors de la suppression")}finally{x(!1)}}};return o.jsxs(ke,{children:[o.jsx(Qt,{children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(sv,{className:"w-5 h-5"}),"Documents"]}),e&&o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:i,type:"file",className:"hidden",onChange:b}),o.jsxs(Z,{size:"sm",onClick:()=>{var j;return(j=i.current)==null?void 0:j.click()},disabled:h,children:[h?o.jsx(ft,{className:"w-4 h-4 mr-2 animate-spin"}):o.jsx(No,{className:"w-4 h-4 mr-2"}),"Téléverser"]})]})]})}),o.jsx(Pe,{children:c?o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx(ft,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):a.length===0?o.jsxs("p",{className:"text-sm text-muted-foreground py-2",children:["Aucun document. ",e?"Ajoutez le règlement intérieur ou des consignes.":""]}):o.jsx("div",{className:"divide-y divide-border",children:a.map(j=>o.jsxs("div",{className:"flex items-center gap-3 py-3",children:[o.jsx("div",{className:"h-9 w-9 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:o.jsx(sv,{className:"h-4 w-4 text-primary"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm font-medium truncate",children:j.name}),o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:[Wie(j.size),Hie(j.uploadedAt),j.uploadedByName].filter(
4066Boolean).join(" · ")})]}),o.jsx("a",{href:j.downloadUrl,target:"_blank",rel:"noopener noreferrer",children:o.jsx(Z,{variant:"ghost",size:"icon",title:"Télécharger",children:o.jsx(Nf,{className:"h-4 w-4"})})}),e&&o.jsx(Z,{variant:"ghost",size:"icon",className:"text-red-600 hover:text-red-700 hover:bg-red-500/10",onClick:()=>g(j),title:"Supprimer",children:o.jsx(Vt,{className:"h-4 w-4"})})]},j.id))})}),o.jsx(Dn,{open:!!p,onOpenChange:j=>!j&&g(null),children:o.jsxs(Ln,{children:[o.jsxs(Mn,{children:[o.jsx(Fn,{children:"Supprimer le document"}),o.jsx(zn,{children:p?`« ${p.name} » sera définitivement supprimé.`:""})]}),o.jsxs(On,{children:[o.jsx(Vn,{disabled:v,children:"Annuler"}),o.jsx($n,{onClick:j=>{j.preventDefault(),w()},disabled:v,className:"bg-red-600 hover:bg-red-700",children:v?"Suppressionâ¦":"Supprimer"})]})]})})]})}function Gie(t){return`company_${t}`}const jp={async ensureCompanyConversation(t,e,n){const r=Gie(t),s=Ht(Xe,"conversations",r);return(await ms(s)).exists()||await tb(s,{id:r,type:"company_general",companyId:t,title:e,participantIds:n?[n]:[],lastMessage:null,lastMessageAt:null,lastMessageSenderId:null,createdAt:Or()}),r},subscribeMessages(t,e){const n=Gr(jn(Xe,"conversations",t,"messages"),OC("createdAt","asc"),s7(200));return nb(n,r=>{const s=r.docs.map(i=>{const a=i.data();return{id:i.id,senderId:a.senderId??"",senderName:a.senderName??"",text:a.text??"",createdAt:a.createdAt??null}});e(s)})},async sendMessage(t,e,n,r){const s=Ht(Xe,"conversations",t);await ld(jn(s,"messages"),{senderId:n,senderName:r,text:e,createdAt:Or()}),await Ba(s,{lastMessage:e,lastMessageAt:Or(),lastMessageSenderId:n})},async markAsRead(t,e){if(e)try{await Ba(Ht(Xe,"conversations",t),{[`lastReadAt.${e}`]:Or()})}catch{}}};function Zie(t){var n;const e=((n=t==null?void 0:t.toDate)==null?void 0:n.call(t))??null;return e?e.toLocaleTimeString("fr-FR",{hour:"2-digit",minute:"2-digit"}):""}function Cp(t){var n;const e=((n=t==null?void 0:t.toDate)==null?void 0:n.call(t))??null;return e?e.toLocaleDateString("fr-FR",{weekday:"long",day:"2-digit",month:"long"}):""}function Kie({companyId:t,companyName:e,currentUserId:n,currentUserName:r,canSend:s}){const i=Ft(),{isPremium:a,loading:l}=A4(),[c,d]=u.useState(null),[h,f]=u.useState([]),[p,g]=u.useState(!0),[v,x]=u.useState(""),[y,b]=u.useState(!1),w=u.useRef(null);u.useEffect(()=>{if(l||!a)return;let E,P=!1;return(async()=>{try{const A=await jp.ensureCompanyConversation(t,e,n);if(P)return;d(A),E=jp.subscribeMessages(A,N=>{f(N),g(!1),jp.markAsRead(A,n)})}catch(A){console.error("Error initialising messaging:",A),i.error("Erreur lors du chargement de la messagerie"),g(!1)}})(),()=>{P=!0,E&&E()}},[t,e,n,i,a,l]),u.useEffect(()=>{const E=w.current;E&&(E.scrollTop=E.scrollHeight)},[h]);const j=u.useCallback(async()=>{const E=v.trim();if(!(!E||!c)){b(!0);try{await jp.sendMessage(c,E,n,r),x("")}catch(P){console.error("Error sending message:",P),i.error("Erreur lors de l'envoi du message")}finally{b(!1)}}},[v,c,n,r,i]);return l?o.jsx(ke,{children:o.jsx(Pe,{className:"flex items-center justify-center h-[40vh]",children:o.jsx(ft,{className:"w-5 h-5 animate-spin text-muted-foreground"})})}):a?o.jsx(ke,{children:o.jsxs(Pe,{className:"p-0 flex flex-col h-[60vh]",children:[o.jsx("div",{ref:w,className:"flex-1 overflow-y-auto p-4 space-y-2",children:p?o.jsx("div",{className:"flex items-center justify-center h-full",children:o.jsx(ft,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):h.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center text-muted-foreground",children:[o.jsx(GL,{className:"w-8 h-8 mb-2 opacity-40"}),o.jsx("p",{className:"text-sm",children:"Aucun message pour le moment."})]}):h.map((E,P)=>{const A=E.senderId===n,N=h[P-1],_=Cp(E.createdAt)&&Cp(E.createdAt)!==Cp(N==null?void 0:N.createdAt);return o.jsxs("div",{children:[_&&o.jsx("div",{className:"flex justify-center my-3",children:o.jsx("span",{className:"text-[11px] text-muted-foreground bg-muted px-2.5 py-0.5 rounded-full capitalize",children:Cp(E.createdAt)})}),o.jsx("div",{className:A?"flex justify-end":"flex justify-start",children:o.jsxs("div",{className:"max-w-[75%] rounded-2xl px-3.5 py-2 "+(A?"bg-primary text-primary-foreground rounded-br-sm":"bg-muted text-foreground rounded-bl-sm"),children:[!A&&o.jsx("p",{className:"text-[11px] font-semibold opacity-70 mb-0.5",children:E.senderName||"Membre"}),o.jsx("p",{className:"text-sm whitespace-pre-wrap break-words",children:E.text}),o.jsx("p",{className:"text-[10px] mt-0.5 text-right "+(A?"text-primary-foreground
4066/70":"text-muted-foreground"),children:Zie(E.createdAt)})]})})]},E.id)})}),o.jsx("div",{className:"border-t p-3",children:s?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ne,{value:v,onChange:E=>x(E.target.value),onKeyDown:E=>{E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),j())},placeholder:"Ãcrire un messageâ¦",disabled:y}),o.jsx(Z,{onClick:j,disabled:y||!v.trim(),size:"icon",children:y?o.jsx(ft,{className:"h-4 w-4 animate-spin"}):o.jsx(rY,{className:"h-4 w-4"})})]}):o.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm text-muted-foreground py-1.5",children:[o.jsx(HK,{className:"h-4 w-4"}),"Seuls les admins peuvent écrire dans cette messagerie."]})})]})}):o.jsx(ke,{children:o.jsxs(Pe,{className:"flex flex-col items-center justify-center text-center h-[40vh] gap-3 px-6",children:[o.jsx("div",{className:"inline-flex items-center justify-center h-14 w-14 rounded-full bg-app-yellow/15",children:o.jsx(mo,{className:"h-6 w-6 text-app-yellow"})}),o.jsx("p",{className:"font-semibold text-foreground",children:"Messagerie premium"}),o.jsx("p",{className:"text-sm text-muted-foreground max-w-sm",children:"La messagerie de société est réservée aux comptes premium. Activez le premium pour échanger avec les membres de votre société."})]})})}function Yie({companyId:t,canManage:e}){const n=qt(),r=Ft(),[s,i]=u.useState([]),[a,l]=u.useState(!0),[c,d]=u.useState(null),[h,f]=u.useState(!1),p=u.useCallback(async()=>{l(!0);try{const v=await vi.getPoisByCompanies([t]);i(v)}catch(v){console.error("Error loading POIs:",v)}finally{l(!1)}},[t]);u.useEffect(()=>{p()},[p]);const g=async()=>{if(c){f(!0);try{await vi.deletePoi(c.id),r.success("POI supprimé"),d(null),p()}catch(v){r.error((v==null?void 0:v.message)||"Erreur lors de la suppression")}finally{f(!1)}}};return o.jsxs("div",{className:"bg-card rounded-2xl border border-border p-5 sm:p-6",children:[o.jsxs("div",{className:"flex items-center gap-2.5 mb-1",children:[o.jsx("h2",{className:"text-lg font-bold font-heading",children:"Points dâintérêt"}),o.jsx(We,{variant:"secondary",children:s.length}),o.jsxs(Z,{size:"sm",className:"ml-auto",onClick:()=>n("/",{state:{createKind:"poi",companyId:t}}),children:[o.jsx(Rn,{className:"h-4 w-4 mr-1.5"})," Ajouter un POI"]})]}),o.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Miradors, parkings, agrainoirs⦠gérés depuis la carte."}),!a&&s.length>0&&o.jsx("div",{className:"mb-4",children:o.jsx(zx,{markers:s.filter(v=>{var x,y;return((x=v.position)==null?void 0:x.latitude)!=null&&((y=v.position)==null?void 0:y.longitude)!=null}).map(v=>({lat:v.position.latitude,lng:v.position.longitude,iconUrl:uo[v.type]??uo.Autre})),onClick:()=>n("/")})}),a?o.jsx("div",{className:"py-10 flex justify-center",children:o.jsx("div",{className:"animate-spin rounded-full h-7 w-7 border-2 border-primary/20 border-t-primary"})}):s.length===0?o.jsxs("div",{className:"py-10 text-center text-muted-foreground",children:[o.jsx("p",{className:"font-medium text-sm",children:"Aucun POI"}),o.jsx("p",{className:"text-xs mt-1",children:"Ajoutez un point dâintérêt depuis la carte."})]}):o.jsx("div",{className:"divide-y divide-border",children:s.map(v=>o.jsxs("div",{className:"flex items-center gap-3 py-3",children:[o.jsx("span",{className:"h-9 w-9 rounded-lg bg-muted flex items-center justify-center flex-shrink-0",children:o.jsx("img",{src:uo[v.type]??uo.Autre,alt:"",className:"h-5 w-5 object-contain"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm font-semibold truncate",children:v.name||"POI"}),o.jsx("div",{className:"text-xs text-muted-foreground truncate",children:v.type})]}),o.jsx(Z,{variant:"outline",size:"icon",className:"h-9 w-9 flex-shrink-0",title:"Voir sur la carte",onClick:()=>n("/"),children:o.jsx(xx,{className:"h-4 w-4"})}),e&&o.jsx(Z,{variant:"outline",size:"icon",className:"h-9 w-9 flex-shrink-0 text-destructive hover:text-destructive",title:"Supprimer",onClick:()=>d(v),children:o.jsx(Vt,{className:"h-4 w-4"})})]},v.id))}),o.jsx(Dn,{open:!!c,onOpenChange:v=>!v&&d(null),children:o.jsxs(Ln,{children:[o.jsxs(Mn,{children:[o.jsx(Fn,{children:"Supprimer ce POI ?"}),o.jsxs(zn,{children:["« ",(c==null?void 0:c.name)||"POI"," » sera définitivement supprimé."]}
4066)]}),o.jsxs(On,{children:[o.jsx(Vn,{children:"Annuler"}),o.jsx($n,{onClick:g,disabled:h,className:"bg-destructive hover:bg-destructive/90",children:h?"Suppressionâ¦":"Supprimer"})]})]})})]})}function Qie({companyId:t,canManage:e}){const n=qt(),r=Ft(),[s,i]=u.useState([]),[a,l]=u.useState(!0),[c,d]=u.useState(null),[h,f]=u.useState(!1),p=u.useCallback(async()=>{l(!0);try{const v=await Ll.getPathsByCompanies([t]);i(v)}catch(v){console.error("Error loading paths:",v)}finally{l(!1)}},[t]);u.useEffect(()=>{p()},[p]);const g=async()=>{if(c){f(!0);try{await Ll.deletePath(c.id),r.success("Chemin supprimé"),d(null),p()}catch(v){r.error((v==null?void 0:v.message)||"Erreur lors de la suppression")}finally{f(!1)}}};return o.jsxs("div",{className:"bg-card rounded-2xl border border-border p-5 sm:p-6",children:[o.jsxs("div",{className:"flex items-center gap-2.5 mb-1",children:[o.jsx("h2",{className:"text-lg font-bold font-heading",children:"Chemins"}),o.jsx(We,{variant:"secondary",children:s.length}),o.jsxs(Z,{size:"sm",className:"ml-auto",onClick:()=>n("/",{state:{createKind:"path",companyId:t}}),children:[o.jsx(nc,{className:"h-4 w-4 mr-1.5"})," Ajouter un chemin"]})]}),o.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Parcours et chemins de contournement, tracés depuis la carte."}),!a&&s.length>0&&o.jsx("div",{className:"mb-4",children:o.jsx(zx,{polylines:s.filter(v=>v.gpsPoints.length>=2).map(v=>({path:v.gpsPoints.map(x=>({lat:x.latitude,lng:x.longitude})),color:fo[v.activity]??"#4E8DD0"})),onClick:()=>n("/")})}),a?o.jsx("div",{className:"py-10 flex justify-center",children:o.jsx("div",{className:"animate-spin rounded-full h-7 w-7 border-2 border-primary/20 border-t-primary"})}):s.length===0?o.jsxs("div",{className:"py-10 text-center text-muted-foreground",children:[o.jsx("p",{className:"font-medium text-sm",children:"Aucun chemin"}),o.jsx("p",{className:"text-xs mt-1",children:"Tracez un chemin depuis la carte."})]}):o.jsx("div",{className:"divide-y divide-border",children:s.map(v=>o.jsxs("div",{className:"flex items-center gap-3 py-3",children:[o.jsx("span",{className:"h-9 w-9 rounded-lg flex items-center justify-center flex-shrink-0",style:{backgroundColor:`${fo[v.activity]??"#4E8DD0"}1A`},children:o.jsx(nc,{className:"h-4 w-4",style:{color:fo[v.activity]??"#4E8DD0"}})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm font-semibold truncate",children:v.name||"Chemin"}),o.jsxs("div",{className:"text-xs text-muted-foreground truncate",children:[Vl[v.activity]," · ",v.gpsPoints.length," pts"]})]}),o.jsx(Z,{variant:"outline",size:"icon",className:"h-9 w-9 flex-shrink-0",title:"Voir sur la carte",onClick:()=>n("/"),children:o.jsx(xx,{className:"h-4 w-4"})}),e&&o.jsx(Z,{variant:"outline",size:"icon",className:"h-9 w-9 flex-shrink-0 text-destructive hover:text-destructive",title:"Supprimer",onClick:()=>d(v),children:o.jsx(Vt,{className:"h-4 w-4"})})]},v.id))}),o.jsx(Dn,{open:!!c,onOpenChange:v=>!v&&d(null),children:o.jsxs(Ln,{children:[o.jsxs(Mn,{children:[o.jsx(Fn,{children:"Supprimer ce chemin ?"}),o.jsxs(zn,{children:["« ",(c==null?void 0:c.name)||"Chemin"," » sera définitivement supprimé."]})]}),o.jsxs(On,{children:[o.jsx(Vn,{children:"Annuler"}),o.jsx($n,{onClick:g,disabled:h,className:"bg-destructive hover:bg-destructive/90",children:h?"Suppressionâ¦":"Supprimer"})]})]})})]})}const _w="#F66D51";function Xie({companyId:t,canManage:e,canDelete:n,canCreate:r}){const s=r??e,{user:i}=nn(),a=qt(),l=Ft(),[c,d]=u.useState([]),[h,f]=u.useState(!0),[p,g]=u.useState(null),[v,x]=u.useState(!1),[y,b]=u.useState(!1),[w,j]=u.useState(null),[E,P]=u.useState(""),[A,N]=u.useState([]),[_,k]=u.useState(!1),[L,I]=u.useState(!1),S=u.useCallback(async()=>{f(!0);try{d(await er.listCompanyTerritories(t))}catch(W){console.error("Error loading territories:",W)}finally{f(!1)}},[t]);u.useEffect(()=>{S()},[S]);const T=()=>a(mt.zoneNewForCompany(t)),V=W=>{j(W),P(W.name||""),N(W.gpsPoint||[]),b(!0)},$=async()=>{if(!E.trim()){l.error("Le nom est requis");return}if(A.length<3){l.error("Tracez la zone (au moins 3 points)");return}I(!0);try{w?(await er.updateTerritory(w.id,{name:E.trim(),gpsPoint:A}),l.success("Zone mise à jour")):(await er.createTerritory({name:E.trim(),gpsPoint:A,companyId:t,departmentCode:i==null?void 0:i.departmentCode}),l.success("Zone créée")),b(!1),S()}catch(W){l.error((W==null?void 0:W.message)||"Erreur lors de lâenregistrement")}finally{I(!1)}},H=async()=>
4066{if(p){x(!0);try{await er.deleteTerritory(p.id),l.success("Zone supprimée"),g(null),S()}catch(W){l.error((W==null?void 0:W.message)||"Erreur lors de la suppression")}finally{x(!1)}}};return o.jsxs("div",{className:"bg-card rounded-2xl border border-border p-5 sm:p-6",children:[o.jsxs("div",{className:"flex items-center gap-2.5 mb-1",children:[o.jsx("h2",{className:"text-lg font-bold font-heading",children:"Autres zones"}),o.jsx(We,{variant:"secondary",children:c.length}),s&&o.jsxs(Z,{size:"sm",className:"ml-auto",onClick:T,children:[o.jsx(hr,{className:"h-4 w-4 mr-1.5"})," Créer une zone"]})]}),o.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Territoires (hors battue) de la société."}),!h&&c.length>0&&o.jsx("div",{className:"mb-4",children:o.jsx(zx,{polygons:c.filter(W=>{var D;return(((D=W.gpsPoint)==null?void 0:D.length)??0)>=3}).map(W=>({path:W.gpsPoint.map(D=>({lat:D.latitude,lng:D.longitude})),color:_w}))})}),h?o.jsx("div",{className:"py-10 flex justify-center",children:o.jsx("div",{className:"animate-spin rounded-full h-7 w-7 border-2 border-primary/20 border-t-primary"})}):c.length===0?o.jsxs("div",{className:"py-10 text-center text-muted-foreground",children:[o.jsx("p",{className:"font-medium text-sm",children:"Aucune autre zone"}),o.jsx("p",{className:"text-xs mt-1",children:s?"Créez une zone pour cette société.":"Aucun territoire rattaché à cette société."})]}):o.jsx("div",{className:"divide-y divide-border",children:c.map(W=>{var D;return o.jsxs("div",{className:"flex items-center gap-3 py-3",children:[o.jsx("span",{className:"h-9 w-9 rounded-lg flex items-center justify-center flex-shrink-0",style:{backgroundColor:`${_w}1A`},children:o.jsx(ur,{className:"h-4 w-4",style:{color:_w}})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm font-semibold truncate",children:W.name||"Territoire"}),o.jsxs("div",{className:"text-xs text-muted-foreground truncate",children:[((D=W.gpsPoint)==null?void 0:D.length)??0," points"]})]}),e&&o.jsx(Z,{variant:"outline",size:"icon",className:"h-9 w-9 flex-shrink-0",title:"Modifier",onClick:()=>V(W),children:o.jsx(fd,{className:"h-4 w-4"})}),n&&o.jsx(Z,{variant:"outline",size:"icon",className:"h-9 w-9 flex-shrink-0 text-destructive hover:text-destructive",title:"Supprimer",onClick:()=>g(W),children:o.jsx(Vt,{className:"h-4 w-4"})})]},W.id)})}),o.jsx(rr,{open:y,onOpenChange:b,children:o.jsxs(sr,{className:"sm:max-w-md",children:[o.jsxs(or,{children:[o.jsx(Gn,{children:w?"Modifier la zone":"Créer une zone"}),o.jsx(ir,{children:"Renseignez le nom et tracez le contour sur la carte."})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ne,{htmlFor:"z-name",children:"Nom *"}),o.jsx(Ne,{id:"z-name",value:E,onChange:W=>P(W.target.value),placeholder:"Nom du territoire"})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ne,{children:"Contour"}),o.jsxs(Z,{variant:"outline",className:"w-full justify-start",onClick:()=>k(!0),children:[o.jsx(JK,{className:"h-4 w-4 mr-2"}),A.length>=3?`${A.length} points définis`:"Tracer sur la carte"]})]})]}),o.jsxs(ks,{children:[o.jsx(Z,{variant:"outline",onClick:()=>b(!1),children:"Annuler"}),o.jsx(Z,{onClick:$,disabled:L||!E.trim()||A.length<3,children:L?"Enregistrementâ¦":w?"Enregistrer":"Créer"})]})]})}),o.jsx(Rx,{isOpen:_,onClose:()=>k(!1),onSave:W=>{N(W),l.success(`${W.length} points définis`)},initialCoordinates:A,departmentCode:(i==null?void 0:i.departmentCode)!=null?String(i.departmentCode):void 0}),o.jsx(Dn,{open:!!p,onOpenChange:W=>!W&&g(null),children:o.jsxs(Ln,{children:[o.jsxs(Mn,{children:[o.jsx(Fn,{children:"Supprimer cette zone ?"}),o.jsxs(zn,{children:["« ",(p==null?void 0:p.name)||"Territoire"," » sera définitivement supprimé."]})]}),o.jsxs(On,{children:[o.jsx(Vn,{children:"Annuler"}),o.jsx($n,{onClick:H,disabled:v,className:"bg-destructive hover:bg-destructive/90",children:v?"Suppressionâ¦":"Supprimer"})]})]})})]})}const sa={async getCompanySubscription(t){return(await pe(ge,"getCompanySubscription")({companyId:t})).data},async createCheckout(t,e=mt.myCompany("subscription")){var i;const n=window.location.origin,s=await pe(ge,"createSubscriptionCheckout")({priceType:"asso",companyId:t,successUrl:`${n}${e}?subscription=success`,cancelUrl:`${n}${e}?subscription=cancel`});if(!((i=s.data)!=null&&i.url))throw new Error("Impossible d'ouvrir le paiement.");return s.data.url},async openBillingPortal(t=mt.myCompany("subscription")){var r;const n=await pe(ge,"createBillingPortalSession")({returnUrl:`${window.location.origin}${t}`});if(!((r=n.data)!=null&&r.url))throw new Error("Impossible d'ouvrir le portail.");return n.data.url},async getCompanyInvoices(t){var r;return((r=(await pe(ge,"getPaymentHistory")({companyId:t})).data)==null?void 0:r.payments)||[]},async grant(t,e){await pe(ge,"grantCompanySubscription")({companyId:t,endDate:e})},async move(t,e){await pe(ge,"moveCompanySubscription")({fromCompanyId:t,toCompanyId:e})},async grantDepartment(t,e){return(await pe(ge,"grantDepartmentSubscriptions")({departmentCode:t,endDate:e})).data}},Jie={stripe:"Abonnement en ligne",appstore:"Abonnement App Store",playstore:"Abonnement Google Play",manual:"Offert"},sI=t=>t?new Date(t).toLocaleDateString("fr-FR",{day:"2-digit",month:"long",year:"numeric"}):null,eae=t=>t==="appstore"||t==="playstore";function tae({companyId:t,companyName:e}){var W;const{user:n,isSuperAdmin:r}=nn(),s=Ft(),i=((W=n==null?void 0:n.companyRoles)==null?void 0:W[t])==="admin",[a,l]=u.useState(null),[c,d]=u.useState([]),[h,f]=u.useState(!0),[p,g]=u.useState(!1),[v,x]=u.useState(""),[y,b]=u.useState(!1),[w,j]=u.useState(""),[E,P]=u.useState([]),[A,N]=u.useState(null),_=u.useCallback(async()=>{f(!0);try{const D=await sa.getCompanySubscription(t);l(D),D.provider==="stripe"?d(await sa.getCompanyInvoices(t)):d([])}catch(D){console.error("Error loading subscription:",D),s.error((D==null?void 0:D.message)||"Impossible de charger l'abonnement")}finally{f(!1)}},[t]);u.useEffect(()=>{_()},[_]);const k=async(D,F)=>{g(!0);try{window.location.href=await D()}catch(O){s.error((O==null?void 0:O.message)||F),g(!1)}},L=async()=>
4066{if(v){g(!0);try{await sa.grant(t,new Date(v).toISOString()),s.success("Premium octroyé à la société"),x(""),await _()}catch(D){s.error((D==null?void 0:D.message)||"Erreur lors de l'octroi")}finally{g(!1)}}},I=async()=>{g(!0);try{await sa.grant(t,null),s.success("Octroi retiré"),b(!1),await _()}catch(D){s.error((D==null?void 0:D.message)||"Erreur lors du retrait")}finally{g(!1)}};if(h)return o.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[o.jsx(ft,{className:"h-4 w-4 animate-spin"})," Chargement de l'abonnementâ¦"]});const S=async()=>{if(!(w.trim().length<2))try{const D=await Ot.searchCompanies(w.trim(),8);P(D.filter(F=>F.id!==t))}catch(D){s.error((D==null?void 0:D.message)||"Erreur lors de la recherche")}},T=async()=>{if(A){g(!0);try{await sa.move(t,A.id),s.success(`Abonnement déplacé vers ${A.name}`),N(null),j(""),P([]),await _()}catch(D){s.error((D==null?void 0:D.message)||"Erreur lors du déplacement")}finally{g(!1)}}},V=(a==null?void 0:a.isActive)??!1,$=a!=null&&a.provider?Jie[a.provider]:null,H=sI((a==null?void 0:a.endDate)??null);return o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx(Cf,{className:"h-4 w-4 text-muted-foreground"}),o.jsxs("span",{className:"font-medium",children:["Abonnement",e?` de ${e}`:""]}),o.jsx(We,{variant:V?"default":"secondary",children:V?"Actif":"Aucun abonnement"}),V&&$&&o.jsx(We,{variant:"outline",children:$})]}),V?o.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[H&&o.jsxs("p",{children:["Prochaine échéance : ",H]}),eae((a==null?void 0:a.provider)??null)&&o.jsxs("p",{children:["Abonnement historique souscrit dans l'application",a!=null&&a.payerName?` par ${a.payerName}`:"",". Il se renouvelle et se résilie depuis le compte Apple ou Google de son titulaire."]}),(a==null?void 0:a.provider)==="manual"&&o.jsx("p",{children:"Premium offert par l'équipe Chassé-Croisé."})]}):o.jsx("p",{className:"text-sm text-muted-foreground",children:"Cette société n'a pas d'abonnement. Un abonnement couvre une seule société : si vous en gérez plusieurs, chacune a le sien."}),o.jsxs("div",{className:"flex gap-2 flex-wrap",children:[!V&&i&&o.jsxs(Z,{disabled:p,onClick:()=>k(()=>sa.createCheckout(t),"Impossible d'ouvrir le paiement"),children:[o.jsx(Cf,{className:"h-4 w-4 mr-2"})," Souscrire"]}),(a==null?void 0:a.provider)==="stripe"&&i&&o.jsxs(Z,{variant:"outline",disabled:p,onClick:()=>k(()=>sa.openBillingPortal(),"Impossible d'ouvrir le portail"),children:[o.jsx(xx,{className:"h-4 w-4 mr-2"})," Gérer / résilier"]}),!i&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"L'abonnement se souscrit et se résilie par un admin de cette société."})]})]}),c.length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2",children:[o.jsx(sv,{className:"h-4 w-4 text-muted-foreground"})," Factures"]}),o.jsx("div",{className:"rounded-lg border divide-y",children:c.map(D=>o.jsxs("div",{className:"flex items-center justify-between gap-3 p-3 text-sm",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"font-medium truncate",children:D.description}),o.jsx("p",{className:"text-muted-foreground text-xs",children:sI(D.date)})]}),o.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[o.jsxs("span",{className:"font-medium",children:[D.amount.toFixed(2)," ",D.currency]}),D.invoicePdf&&o.jsx("a",{href:D.invoicePdf,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline text-xs",children:"PDF"})]})]},D.id))})]}),r&&o.jsxs("div",{className:"rounded-lg border border-dashed p-4 space-y-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(zK,{className:"h-4 w-4 text-muted-foreground"}),o.jsx("span",{className:"font-medium text-sm",children:"Offrir le premium à cette société"})]}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Tous les membres de la société bénéficient du premium jusqu'à la date choisie."}),o.jsxs("div",{className:"flex items-end gap-2 flex-wrap",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ne,{className:"text-xs",children:"Date de fin"}
4066),o.jsx(Ne,{type:"date",value:v,onChange:D=>x(D.target.value),className:"w-44"})]}),o.jsx(Z,{size:"sm",disabled:p||!v,onClick:L,children:"Octroyer"}),(a==null?void 0:a.provider)==="manual"&&o.jsx(Z,{size:"sm",variant:"outline",disabled:p,onClick:()=>b(!0),children:"Retirer l'octroi"})]}),(a==null?void 0:a.exists)&&V&&o.jsxs("div",{className:"pt-3 border-t space-y-2",children:[o.jsx("span",{className:"font-medium text-sm",children:"Déplacer l'abonnement vers une autre société"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"La ligne est déplacée telle quelle (payeur, échéance, contenu) ; cette société perd le premium, la société de destination le récupère."}),o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx(Ne,{placeholder:"Rechercher la société de destinationâ¦",value:w,onChange:D=>j(D.target.value),onKeyDown:D=>D.key==="Enter"&&S(),className:"w-72"}),o.jsx(Z,{size:"sm",variant:"outline",onClick:S,disabled:p,children:"Rechercher"})]}),E.length>0&&o.jsx("div",{className:"space-y-1",children:E.map(D=>o.jsxs("button",{type:"button",onClick:()=>N(D),className:"block w-full text-left text-sm px-2 py-1 rounded hover:bg-muted",children:[D.name,D.city?o.jsxs("span",{className:"text-muted-foreground",children:[" (",D.city,")"]}):null]},D.id))})]})]}),o.jsx(Dn,{open:A!==null,onOpenChange:D=>!D&&N(null),children:o.jsxs(Ln,{children:[o.jsxs(Mn,{children:[o.jsx(Fn,{children:"Déplacer l'abonnement ?"}),o.jsxs(zn,{children:["L'abonnement de « ",e||"cette société"," » sera déplacé vers « ",A==null?void 0:A.name," ». Cette société perdra immédiatement le premium."]})]}),o.jsxs(On,{children:[o.jsx(Vn,{disabled:p,children:"Annuler"}),o.jsx($n,{onClick:T,disabled:p,children:"Déplacer"})]})]})}),o.jsx(Dn,{open:y,onOpenChange:b,children:o.jsxs(Ln,{children:[o.jsxs(Mn,{children:[o.jsx(Fn,{children:"Retirer l'octroi ?"}),o.jsx(zn,{children:"Les membres de cette société perdront immédiatement l'accès aux fonctionnalités premium."})]}),o.jsxs(On,{children:[o.jsx(Vn,{disabled:p,children:"Annuler"}),o.jsx($n,{onClick:I,disabled:p,children:"Retirer"})]})]})})]})}function x3({companyId:t,canEdit:e,isAdmin:n,canCreateTerritories:r,currentUserId:s,currentUserName:i,basePath:a,activeTab:l,onTabChange:c,renderHeader:d,hiddenTabs:h=[],extraTabs:f=[],onCompanyLoaded:p}){const g=Ft(),[v,x]=u.useState(null),[y,b]=u.useState(!0),[w,j]=u.useState(!1),[E,P]=u.useState("infos"),A=l??E,N=Q=>c?c(Q):P(Q),[_,k]=u.useState({members:0,pois:0,paths:0,zones:0,territories:0,battues:0}),[L,I]=u.useState(""),[S,T]=u.useState(""),[V,$]=u.useState(""),[H,W]=u.useState(""),[D,F]=u.useState(""),[O,Y]=u.useState(!1),[G,q]=u.useState([]);u.useEffect(()=>{As().then(q).catch(()=>{})},[]);const re=u.useCallback(async()=>{if(t){b(!0);try{const Q=await Ot.getCompanyById(t);x(Q),p==null||p(Q),Q&&(I(Q.name||""),T(Q.address||""),$(Q.city||""),W(Q.zipCode!=null?String(Q.zipCode):""),F(Q.phone||""))}catch(Q){console.error("Error loading company:",Q)}finally{b(!1)}}},[t]);u.useEffect(()=>{re()},[re]),u.useEffect(()=>{P("infos")},[t]);const U=h.includes("members");u.useEffect(()=>{if(!t)return;let Q=!1;return(async()=>{const[ve,Ae,he,J,je,Ve]=await Promise.all([U?Promise.resolve(0):Ot.getCompanyMembers(t).then(Ye=>Ye.members.length).catch(()=>0),go.listByCompany(t).then(Ye=>Ye.length).catch(()=>0),Bl.listByCompany(t).then(Ye=>Ye.length).catch(()=>0),vi.getPoisByCompanies([t]).then(Ye=>Ye.length).catch(()=>0),Ll.getPathsByCompanies([t]).then(Ye=>Ye.length).catch(()=>0),Ot.getCompanyZones(t).then(Ye=>Ye.zones.length).catch(()=>0)]);Q||k({members:ve,zones:Ae,battues:he,pois:J,paths:je,territories:Ve})})(),()=>{Q=!0}},[t,U]);const ee=async()=>{const Q=(v==null?void 0:v.identificationCode)||(v==null?void 0:v.companyCode);if(Q)try{await navigator.clipboard.writeText(Q),j(!0),setTimeout(()=>j(!1),2e3)}catch{g.error("Impossible de copier")}},K=async()=>{if(!t||!L.trim()){g.error("Le nom est requis");return}Y(!0);try{await Ot.updateCompanyFields(t,{name:L.trim(),address:S.trim()||void 0,city:V.trim()||void 0,zipCode:H?parseInt(H,10):void 0,phone:D.trim()||void 0}),g.success("Société mise à jour"),re()}catch(Q){console.error("Error updating company:",Q),g.error((Q==null?void 0:Q.message)||"Erreur lors de la mise à jour")}finally{Y(!1)}},ue=(v==null?void 0:v.identificationCode)||(v==null?void 0:v.companyCode),le=[...[{id:"infos",label:"Infos",icon:qn},{id:"members",label:"Membres",icon:cr,count:_.members},{id:"pois",label:"POI",icon:Rn,count:_.pois},{id:"paths",label:"Chemins",icon:nc,count:_.paths},{id:"zbattue",label:"Zones de battue",icon:ur,count:_.zones},{id:"zautre",label:"Autres zones",icon:VK,count:_.territories},{id:"battues",label:"Battues",icon:vb,count:_.battues},{id:"documents",label:"Documents",icon:sv},{id:"messaging",label:"Messagerie",icon:GL},...n?[{id:"subscription",label:"Abonnement",icon:Cf}]:[]].filter(Q=>!h.includes(Q.id)),...f.map(Q=>({id:Q.id,label:Q.label,icon:Q.icon,count:Q.count}))],B=le.some(Q=>Q.id===A)?A:"infos";return o.jsxs("div",{className:"h-full flex flex-col",children:[d({company:v,code:ue}),y?o.jsx("div",{className:"flex-1",children:o.jsx(UO,{})}):o.jsxs("div",{className:"flex-1 flex flex-col lg:flex-row overflow-hidden",children:[o.jsxs("nav",{className:"hidden lg:flex lg:flex-col lg:w-72 flex-shrink-0 border-r border-border bg-card overflow-y-auto",children:[o.jsxs("div",{className:"p-4 border-b border-border",children:[o.jsx("div",{className:"text-[11px] font-semibold text-muted-foreground",children:"Code société"}),o.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[o.jsx("span",{className:"font-mono font-bold text-[17px] tracking-wide",children:ue||"â"}),ue&&o.jsx(Z,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:ee,children:w?o.jsx(Xn,{className:"h-3.5 w-3.5 text-primary"}):o.jsx(Xp,{className:"h-3.5 w-3.5"})})]}),o.jsxs("div",{className:"flex gap-5 mt-4",children:[!U&&o.jsxs("div",{children:[o.jsx("div",{className:"font-heading font-bold text-lg leading-none",children:_.members}),o.jsx("div",{className:"text-[11px] text-muted-foreground mt-0.5",children:"membres"})]}),o.jsxs("div",{children:[o.jsx("div",{className:"font-heading font-bold text-lg leading-none",children:_.zones}),o.jsx("div",{className:"text-[11px] text-muted-foreground mt-0.5",children:"zones"})]}),o.jsxs("div",{children:[o.jsx("div",{className:"font-heading font-bold text-lg leading-none",children:_.battues}),o.jsx("div",{className:"text-[11px] text-muted-foreground mt-0.5",children:"battues"})]})]})]}),o.jsx("div",{className:"p-2 flex flex-col gap-0.5",children:le.map(Q=>{const ve=B===Q.id;return o.jsxs("button",{onClick:()=>N(Q.id),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl text-sm font-medium transition-colors ${ve?"bg-primary/10 text-primary":"text-foreground
4066/80 hover:bg-muted"}`,children:[o.jsx(Q.icon,{className:"h-[18px] w-[18px] flex-shrink-0"}),o.jsx("span",{className:"flex-1 text-left",children:Q.label}),Q.count!=null&&o.jsx(We,{variant:"secondary",className:"h-5 min-w-5 justify-center px-1.5",children:Q.count})]},Q.id)})})]}),o.jsx("div",{className:"lg:hidden border-b border-border bg-card overflow-x-auto cc-noscroll flex gap-2 px-3 py-2 flex-shrink-0",children:le.map(Q=>{const ve=B===Q.id;return o.jsxs("button",{onClick:()=>N(Q.id),className:`h-9 px-3.5 rounded-full border text-[13px] font-semibold whitespace-nowrap flex items-center gap-1.5 flex-shrink-0 transition-colors ${ve?"bg-primary text-primary-foreground border-transparent":"bg-card border-border text-foreground/80 hover:bg-muted"}`,children:[o.jsx(Q.icon,{className:"h-4 w-4"}),Q.label]},Q.id)})}),o.jsx("div",{className:"flex-1 overflow-y-auto bg-background",children:o.jsxs("div",{className:"p-4 md:p-6 max-w-3xl mx-auto",children:[v&&B==="infos"&&o.jsxs("div",{className:"bg-card rounded-2xl border border-border p-5 sm:p-6",children:[o.jsx("h2",{className:"text-lg font-bold font-heading",children:"Informations"}),o.jsx("p",{className:"text-sm text-muted-foreground mb-5",children:"Coordonnées de la société"}),e?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ne,{htmlFor:"c-name",children:"Nom *"}),o.jsx(Ne,{id:"c-name",value:L,onChange:Q=>I(Q.target.value)})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ne,{htmlFor:"c-phone",children:"Téléphone"}),o.jsx(Ne,{id:"c-phone",value:D,onChange:Q=>F(Q.target.value)})]}),o.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[o.jsx(ne,{htmlFor:"c-address",children:"Adresse"}),o.jsx(Ne,{id:"c-address",value:S,onChange:Q=>T(Q.target.value)})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ne,{htmlFor:"c-zip",children:"Code postal"}),o.jsx(Ne,{id:"c-zip",value:H,onChange:Q=>W(Q.target.value)})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ne,{htmlFor:"c-city",children:"Ville"}),o.jsx(Ne,{id:"c-city",value:V,onChange:Q=>$(Q.target.value)})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ne,{children:"Département"}),o.jsx("div",{className:"flex items-center h-10 px-3 border rounded-md bg-muted text-sm text-muted-foreground",children:H?qg(ec(H),G):"Non renseigné"})]})]}),o.jsxs("div",{className:"flex items-center gap-3 mt-5 pt-4 border-t",children:[ue&&o.jsxs("div",{children:[o.jsx("div",{className:"text-[11px] text-muted-foreground font-medium",children:"Code société"}),o.jsx("div",{className:"font-mono font-bold text-[17px] tracking-wide",children:ue})]}),ue&&o.jsx(Z,{variant:"outline",size:"icon",onClick:ee,children:w?o.jsx(Xn,{className:"h-4 w-4 text-primary"}):o.jsx(Xp,{className:"h-4 w-4"})}),o.jsxs(Z,{className:"ml-auto",onClick:K,disabled:O||!L.trim(),children:[O?o.jsx(ft,{className:"h-4 w-4 mr-2 animate-spin"}):o.jsx(xc,{className:"h-4 w-4 mr-2"}),"Enregistrer"]})]})]}):o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ne,{className:"text-muted-foreground text-xs",children:"Nom"}),o.jsx("p",{className:"text-sm font-medium",children:v.name})]}),(v.address||v.city)&&o.jsxs("div",{className:"space-y-1",children:[o.jsxs(ne,{className:"text-muted-foreground text-xs flex items-center gap-1.5",children:[o.jsx(Rn,{className:"h-3 w-3"})," Adresse"]}),o.jsx("p",{className:"text-sm font-medium",children:[v.address,v.zipCode,v.city].filter(Boolean).join(", ")})]}),v.phone&&o.jsxs("div",{className:"space-y-1",children:[o.jsxs(ne,{className:"text-muted-foreground text-xs flex items-center gap-1.5",children:[o.jsx(rm,{className:"h-3 w-3"})," Téléphone"]}),o.jsx("p",{className:"text-sm font-medium",children:v.phone})]}),v.zipCode!=null&&o.jsxs("div",{className:"space-y-1",children:[o.jsxs(ne,{className:"text-muted-foreground text-xs flex items-center gap-1.5",children:[o.jsx(Rn,{className:"h-3 w-3"})," Département"]}),o.jsx("p",{className:"text-sm font-medium",children:qg(ec(v.zipCode),G)})]}),ue&&o.jsxs("div",{className:"space-y-1",children:[o.jsxs(ne,{className:"text-muted-foreground text-xs flex items-center gap-1.5",children:[o.jsx(BK,{className:"h-3 w-3"})," Code société"]}
4066),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("p",{className:"text-sm font-mono font-medium",children:ue}),o.jsx(Z,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:ee,children:w?o.jsx(Xn,{className:"h-3.5 w-3.5 text-primary"}):o.jsx(Xp,{className:"h-3.5 w-3.5"})})]})]})]})]}),B==="members"&&o.jsx(lre,{companyId:t,canManage:e,isAdmin:n,currentUserId:s}),B==="pois"&&o.jsx(Yie,{companyId:t,canManage:e}),B==="paths"&&o.jsx(Qie,{companyId:t,canManage:e}),B==="zbattue"&&o.jsx(dre,{companyId:t,canManage:e,basePath:a}),B==="zautre"&&o.jsx(Xie,{companyId:t,canManage:e,canDelete:n,canCreate:e||r}),B==="battues"&&o.jsx(Uie,{companyId:t,creatorId:s||"",canManage:e}),B==="documents"&&o.jsx(qie,{companyId:t,canManage:e,currentUserId:s||"",currentUserName:i}),v&&B==="messaging"&&!h.includes("messaging")&&o.jsx(Kie,{companyId:t,companyName:v.name,currentUserId:s||"",currentUserName:i||"",canSend:n||!v.messagingRestricted}),B==="subscription"&&n&&o.jsx(tae,{companyId:t,companyName:v==null?void 0:v.name}),f.map(Q=>B===Q.id?o.jsx("div",{children:Q.content},Q.id):null)]})})]})]})}function nae(){var W;const{id:t,onglet:e}=Ys(),n=qt(),r=Ft(),{user:s}=nn(),[i,a]=u.useState(null),[l,c]=u.useState(!1),[d,h]=u.useState(0),[f,p]=u.useState([]),[g,v]=u.useState([]),[x,y]=u.useState(!1),[b,w]=u.useState(null),[j,E]=u.useState(!1),P=t?(W=s==null?void 0:s.companyRoles)==null?void 0:W[t]:void 0,A=!!(s!=null&&s.isSuperAdmin),N=!!s&&!A&&!P&&rH(s,i),_=A||P==="admin"||P==="writer"||N,k=A||P==="admin"||N,L=u.useCallback(async()=>{if(t)try{const{members:D}=await Ot.getCompanyMembers(t).catch(()=>({members:[]}));p(D)}catch(D){console.error("Error loading members:",D)}},[t]);u.useEffect(()=>{L()},[L]);const I=async()=>{if(t){c(!0);try{await Ot.deleteCompany(t),r.success("Société supprimée"),n(xe.companies)}catch(D){console.error("Error deleting company:",D),r.error(D.message||"Erreur lors de la suppression")}finally{c(!1)}}},S=async D=>{if(!t||g.includes(D))return;const F=[...g,D];v(F);try{await Ot.updateCompany(t,{notificationRecipientIds:F})}catch(O){console.error("Error saving notification recipients:",O),r.error(O.message||"Erreur lors de la sauvegarde"),v(g)}},T=async D=>{if(!t)return;const F=g.filter(O=>O!==D);v(F);try{await Ot.updateCompany(t,{notificationRecipientIds:F})}catch(O){console.error("Error saving notification recipients:",O),r.error(O.message||"Erreur lors de la sauvegarde"),v(g)}};if(!t)return o.jsx("div",{className:"p-6",children:o.jsx("p",{className:"text-muted-foreground",children:"Société introuvable"})});const V={id:"notifications",label:"Notifications",icon:gb,content:o.jsxs("div",{className:"bg-card rounded-2xl border border-border p-5 sm:p-6 space-y-4",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-bold font-heading",children:"Destinataires des notifications"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Par défaut, les signalements sont envoyés aux administrateurs de la société. Ajoutez ci-dessous des destinataires supplémentaires."})]}),f.filter(D=>D.role==="admin").length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{className:"text-sm font-medium",children:"Administrateurs (toujours notifiés)"}),o.jsx("div",{className:"space-y-1",children:f.filter(D=>D.role==="admin").map(D=>o.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg bg-muted border border-border",children:[o.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center",children:o.jsx(mo,{className:"h-4 w-4 text-amber-500"})}),o.jsxs("div",{children:[o.jsx("p",{className:"font-medium text-sm",children:bn(D)}),o.jsx("p",{className:"text-xs text-muted-foreground",children:D.email})]})]},D.id))})]}),g.length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{className:"text-sm font-medium",children:"Destinataires additionnels"}),o.jsx("div",{className:"space-y-1",children:g.map(D=>{const F=f.find(O=>O.id===D);return o.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-blue-500/10 border border-blue-100",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-8 h-8 rounded-full bg-blue-500/15 flex items-center justify-center",children:o.jsx(gb,{className:"h-4 w-4 text-blue-600"})}),o.jsxs("div",{children:[o.jsx("p",{className:"font-medium text-sm",children:F?bn(F):D}),F&&o.jsx("p",{className:"text-xs text-muted-foreground",children:F.email})]})]}),_&&o.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground
4066/60 hover:text-red-600",onClick:()=>T(D),children:o.jsx(br,{className:"h-4 w-4"})})]},D)})})]}),_&&f.filter(D=>D.role!=="admin"&&!g.includes(D.id)).length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{className:"text-sm font-medium",children:"Ajouter un destinataire"}),o.jsxs(_t,{onValueChange:D=>S(D),value:"",children:[o.jsx(St,{className:"flex-1",children:o.jsx(Et,{placeholder:"Sélectionner un membre..."})}),o.jsx(kt,{children:f.filter(D=>D.role!=="admin"&&!g.includes(D.id)).map(D=>o.jsxs(Ke,{value:D.id,children:[bn(D)," (",D.email,")"]},D.id))})]})]})]})},$={id:"danger",label:"Danger",icon:an,content:o.jsxs("div",{className:"bg-card rounded-2xl border border-red-300 dark:border-red-900 p-5 sm:p-6",children:[o.jsxs("h2",{className:"text-lg font-bold font-heading text-red-600 flex items-center gap-2",children:[o.jsx(an,{className:"w-5 h-5"})," Zone de danger"]}),o.jsxs("div",{className:"flex items-center justify-between gap-3 mt-4",children:[o.jsx("p",{className:"text-sm text-muted-foreground",children:"Supprimer définitivement toutes les zones de chasse (battue et affût) de cette société."}),o.jsxs(Z,{variant:"outline",size:"sm",className:"shrink-0 border-red-300 text-red-600 hover:bg-red-500/10 hover:text-red-700",onClick:async()=>{w(null),y(!0);try{const D=await go.listByCompany(t);w(D.length)}catch(D){console.error("Error counting hunting zones:",D),y(!1),r.error("Erreur lors du chargement des zones de chasse")}},children:[o.jsx(Vt,{className:"w-4 h-4 mr-2"}),"Supprimer toutes les zones"]})]})]})},H=[V];return A&&H.push($),o.jsxs(o.Fragment,{children:[o.jsx(x3,{companyId:t,canEdit:_,isAdmin:k,canCreateTerritories:!0,currentUserId:s==null?void 0:s.id,currentUserName:s?bn(s):void 0,basePath:mt.company(t),activeTab:qT(e),onTabChange:D=>n(Sg(mt.company(t),D)),hiddenTabs:[...P?[]:["messaging"],...N?["subscription"]:[]],extraTabs:H,onCompanyLoaded:D=>{a(D),v((D==null?void 0:D.notificationRecipientIds)||[])},renderHeader:({company:D})=>o.jsxs("div",{className:"flex-shrink-0",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 md:px-6 py-3 border-b border-border bg-card",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>n(xe.companies),children:o.jsx(Nr,{className:"h-5 w-5"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("h1",{className:"text-lg font-bold font-heading truncate",children:(D==null?void 0:D.name)||"â"}),(D==null?void 0:D.city)&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:D.city})]})]}),A&&o.jsxs(Dn,{children:[o.jsx(cm,{asChild:!0,children:o.jsxs(Z,{variant:"outline",size:"sm",className:"text-red-600 hover:text-red-700 hover:bg-red-500/10 shrink-0",children:[o.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Supprimer"]})}),o.jsxs(Ln,{children:[o.jsxs(Mn,{children:[o.jsx(Fn,{children:"Supprimer cette société ?"}),o.jsx(zn,{children:"Cette action est irréversible. La société sera définitivement supprimée."})]}),o.jsxs(On,{children:[o.jsx(Vn,{children:"Annuler"}),o.jsxs($n,{onClick:I,className:"bg-red-600 hover:bg-red-700",disabled:l,children:[l?o.jsx(ft,{className:"h-4 w-4 mr-2 animate-spin"}):o.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Supprimer"]})]})]})]})]}),N&&o.jsxs(yr,{className:"rounded-none border-x-0 border-t-0 bg-amber-500/10 border-amber-500/20",children:[o.jsx(oY,{className:"h-4 w-4"}),o.jsx(pZ,{children:"Gestion au titre de la fédération"}),o.jsxs(wr,{children:["Vous intervenez sur cette société comme fédération du département ",(s==null?void 0:s.departmentLabel)||(s==null?void 0:s.departmentCode),". Ses administrateurs restent seuls maîtres de l'abonnement et de la messagerie."]})]})]})},d),o.jsx(Dn,{open:x,onOpenChange:D=>!D&&!j&&y(!1),children:o.jsxs(Ln,{children:[o.jsxs(Mn,{children:[o.jsx(Fn,{children:"Supprimer toutes les zones de chasse"}),o.jsx(zn,{children:b===null?"Comptage des zones en coursâ¦":b===0?"Cette société n'a aucune zone de chasse.":`${b} zone(s) de chasse (battue et affût) de « ${(i==null?void 0:i.name)??"cette société"}
4066 » seront définitivement supprimées. Cette action est irréversible.`})]}),o.jsxs(On,{children:[o.jsx(Vn,{disabled:j,children:"Annuler"}),o.jsx($n,{onClick:async D=>{D.preventDefault(),E(!0);try{const F=await go.removeAllByCompany(t);r.success(`${F} zone(s) de chasse supprimée(s)`),y(!1),h(O=>O+1)}catch(F){console.error("Error deleting all hunting zones:",F),r.error("Erreur lors de la suppression des zones")}finally{E(!1)}},disabled:j||b===null||b===0,className:"bg-red-600 hover:bg-red-700",children:j?"Suppressionâ¦":"Tout supprimer"})]})]})})]})}const rae=[{value:"hunt",label:"Chasse"},{value:"walk",label:"Marche"},{value:"ride",label:"Ãquitation"},{value:"cycle",label:"Cyclisme"},{value:"bike",label:"VTT"}];function sae(){const t=qt(),{user:e}=nn(),[n,r]=u.useState(!1),[s,i]=u.useState(""),[a,l]=u.useState(""),[c,d]=u.useState("hunt"),[h,f]=u.useState(""),[p,g]=u.useState(""),[v,x]=u.useState(""),[y,b]=u.useState(""),[w,j]=u.useState(""),[E,P]=u.useState(""),[A,N]=u.useState(!1),_=async k=>{if(k.preventDefault(),i(""),!a.trim()){i("Le nom de la société est requis");return}if(!p.trim()){i("La ville est requise");return}if(!v){i("Le code postal est requis");return}r(!0);try{const L={name:a.trim(),address:h.trim(),city:p.trim(),zipCode:parseInt(v),phone:y.trim(),identificationCode:w.trim(),companyCode:E.trim(),kind:c,isPrivacy:A,user:(e==null?void 0:e.id)||"",creatorName:(e==null?void 0:e.pseudo)||""},I=await Ot.createCompany(L);t(mt.company(I.id))}catch(L){console.error("Error creating company:",L),i(L.message||"Erreur lors de la création de la société")}finally{r(!1)}};return o.jsxs("div",{className:"p-4 md:p-6 space-y-4 md:space-y-6 max-w-3xl mx-auto",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>t(xe.companies),children:o.jsx(Nr,{className:"h-5 w-5"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-foreground font-heading",children:"Nouvelle société"}),o.jsx("p",{className:"text-muted-foreground mt-1",children:"Créer une société de chasse"})]})]}),o.jsx("form",{onSubmit:_,children:o.jsxs(ke,{children:[o.jsx(Qt,{children:o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(qn,{className:"h-5 w-5"}),"Informations de la société"]})}),o.jsxs(Pe,{className:"space-y-6",children:[s&&o.jsx(yr,{variant:"destructive",children:o.jsx(wr,{children:s})}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"name",children:"Nom de la société *"}),o.jsx(Ne,{id:"name",value:a,onChange:k=>l(k.target.value),placeholder:"Ex: ACCA de Saint-Martin",required:!0})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"kind",children:"Type d'activité"}),o.jsxs(_t,{value:c,onValueChange:d,children:[o.jsx(St,{children:o.jsx(Et,{placeholder:"Sélectionner un type"})}),o.jsx(kt,{children:rae.map(k=>o.jsx(Ke,{value:k.value,children:k.label},k.value))})]})]})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs(ne,{className:"flex items-center gap-2 text-base font-medium",children:[o.jsx(UK,{className:"h-4 w-4"}),"Adresse"]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"address",children:"Rue"}),o.jsx(Ne,{id:"address",value:h,onChange:k=>f(k.target.value),placeholder:"Ex: 12 rue de la Forêt"})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"zipCode",children:"Code postal *"}),o.jsx(Ne,{id:"zipCode",type:"number",value:v,onChange:k=>x(k.target.value),placeholder:"Ex: 75001",required:!0})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"city",children:"Ville *"}),o.jsx(Ne,{id:"city",value:p,onChange:k=>g(k.target.value),placeholder:"Ex: Paris",required:!0})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ne,{htmlFor:"phone",className:"flex items-center gap-2",children:[o.jsx(rm,{className:"h-4 w-4"}),"Téléphone"]}),o.jsx(Ne,{id:"phone",type:"tel",value:y,onChange:k=>b(k.target.value),placeholder:"Ex: 01 23 45 67 89"})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsx(ne,{className:"text-base font-medium",children:"Identification"}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"identificationCode",children:"Code d'identification"}),o.jsx(Ne,{id:"identificationCode",value:w,onChange:k=>j(k.target.value),placeholder:"Ex: SIRET, RNA..."})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"companyCode",children:"Code société"}),o.jsx(Ne,{id:"companyCode",value:E,onChange:k=>P(k.target.value),placeholder:"Code interne"})]})]})]}),o.jsxs("div",{className:"flex items-center space-x-2",children:[o.jsx(Ks,{id:"isPrivate",checked:A,onCheckedChange:k=>N(k===!0)}),o.jsx(ne,{htmlFor:"isPrivate",className:"cursor-pointer",children:"Société privée"})]}),o.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[o.jsx(Z,{type:"button",variant:"outline",onClick:()=>t(xe.companies),disabled:n,children:"Annuler"}),o.jsx(Z,{type:"submit",disabled:n,children:n?o.jsxs(o.Fragment,{children:[o.jsx(hs,{className:"mr-2 h-4 w-4 animate-spin"}),"Création..."]}
4066):o.jsxs(o.Fragment,{children:[o.jsx(qn,{className:"mr-2 h-4 w-4"}),"Créer la société"]})})]})]})]})})]})}const oae=[{value:"battue",label:"Battue",icon:BL},{value:"affut",label:"Affût",icon:VL}];function iae({selected:t,onChange:e}){const n=r=>{t.includes(r)?t.length>1&&e(t.filter(s=>s!==r)):e([...t,r])};return o.jsxs("div",{className:"space-y-2",children:[o.jsx("div",{className:"flex gap-2",children:oae.map(({value:r,label:s,icon:i})=>{const a=t.includes(r);return o.jsxs(Z,{type:"button",variant:a?"default":"outline",onClick:()=>n(r),children:[o.jsx(i,{className:"w-4 h-4 mr-2"}),s]},r)})}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Une zone peut servir à la battue, à l'affût, ou aux deux."})]})}const gv=["#F66D51","#3B82F6","#10B981","#A855F7","#F59E0B","#EC4899"];function aae({isOpen:t,zones:e,onClose:n,onConfirm:r,importing:s,progress:i}){return o.jsx(rr,{open:t,onOpenChange:a=>!a&&!s&&n(),children:o.jsxs(sr,{className:"sm:max-w-2xl",children:[o.jsxs(or,{children:[o.jsxs(Gn,{className:"flex items-center gap-2",children:[o.jsx(Si,{className:"w-5 h-5"}),e.length," zones détectées"]}),o.jsx(ir,{children:"Le fichier KML contient plusieurs zones. Toutes seront créées en une fois avec les paramètres communs sélectionnés (usages / département)."})]}),o.jsx(lae,{zones:e}),o.jsx("div",{className:"max-h-52 overflow-y-auto rounded-lg border border-border divide-y divide-border",children:e.map((a,l)=>o.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[o.jsx("span",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:gv[l%gv.length]}}),o.jsx("span",{className:"flex-1 text-sm font-medium text-foreground truncate",children:a.name}),o.jsxs("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:[a.coordinates.length," points"]})]},`${a.name}-${l}`))}),o.jsxs(ks,{children:[o.jsx(Z,{type:"button",variant:"outline",onClick:n,disabled:s,children:"Annuler"}),o.jsx(Z,{type:"button",onClick:r,disabled:s,children:s?o.jsxs(o.Fragment,{children:[o.jsx(ft,{className:"w-4 h-4 mr-2 animate-spin"}),"Import⦠",i?`${i.done}/${i.total}`:""]}):o.jsxs(o.Fragment,{children:[o.jsx(No,{className:"w-4 h-4 mr-2"}),"Tout importer (",e.length,")"]})})]})]})})}function lae({zones:t}){const e=u.useRef([]),n=t.map(s=>`${s.name}:${s.coordinates.length}`).join("|"),r=u.useCallback(s=>{e.current.forEach(a=>a.setMap(null)),e.current=[];const i=new google.maps.LatLngBounds;t.forEach((a,l)=>{const c=gv[l%gv.length],d=a.coordinates.map(h=>({lat:h.latitude,lng:h.longitude}));if(d.forEach(h=>i.extend(h)),a.coordinates.length>=3){const h=new google.maps.Polygon({paths:d,fillColor:c,fillOpacity:.35,strokeColor:c,strokeOpacity:1,strokeWeight:2,clickable:!1,map:s});e.current.push(h)}}),i.isEmpty()||s.fitBounds(i,{top:30,right:30,bottom:30,left:30})},[t]);return u.useEffect(()=>()=>{e.current.forEach(s=>s.setMap(null)),e.current=[]},[]),o.jsx("div",{className:"border border-border rounded-lg overflow-hidden h-[260px]",children:o.jsx(Qs,{mapContainerStyle:{width:"100%",height:"100%"},center:{lat:46.603354,lng:1.888334},zoom:6,onLoad:r,options:{disableDefaultUI:!0,zoomControl:!1,mapTypeControl:!1,streetViewControl:!1,fullscreenControl:!1,draggable:!1,scrollwheel:!1,disableDoubleClickZoom:!0,mapTypeId:"hybrid"}},n)})}function Np(){const{companyId:t,zoneId:e}=Ys(),n=qt(),r=Ft(),{user:s}=nn(),i=!!e,a=!t,l=t??(s?KC(s):void 0),c=a?mt.myCompany("zbattue"):l?mt.company(l,"zbattue"):xe.companies,[d,h]=u.useState(null),[f,p]=u.useState(""),[g,v]=u.useState(""),[x,y]=u.useState(["battue","affut"]),[b,w]=u.useState([]),[j,E]=u.useState(!1),[P,A]=u.useState(!0),[N,_]=u.useState(!1),[k,L]=u.useState([]),[I,S]=u.useState(!1),[T,V]=u.useState(null);u.useEffect(()=>{if(!l)return;let F=!1;return(async()=>{var O;try{const Y=await Ot.getCompanyById(l);if(F)return;if(h(Y),i){const q=(await go.listByCompany(l)).find(re=>re.id===e);if(F)return;if(!q){r.error("Zone introuvable"),n(c);return}p(q.name),v(q.description||""),y((O=q.usages)!=null&&O.length?q.usages:["battue","affut"]),w(q.gpsPoint||[])}}catch(Y){console.error("Error loading hunting zone form:",Y),r.error("Erreur lors du chargement")}finally{F||A(!1)}})(),()=>{F=!0}},[l,e]);const $=(d==null?void 0:d.zipCode)!=null?String(ec(d.zipCode)):void 0,H=()=>{const F=document.createElement("input");F.type="file",F.accept=".kml",F.onchange=async O=>{var G;const Y=(G=O.target.files)==null?void 0:G[0];if(Y)try{const q=await hv.parseKMLFile(Y);if(!q.isValid){r.error(q.error||"Format non supporté");return}if(!q.zones||q.zones.length===0){r.error("Le fichier KML ne contient pas de zones valides");return}if(q.zones.length>1){L(q.zones);return}const re=q.zones[0];f||p(re.name),w(re.coordinates),r.success(`${re.coordinates.length} points importés depuis le fichier KML`)}catch(q){console.error("Erreur lors de l'import KML:",q),r.error("Impossible d'analyser le fichier KML")}},F.click()},W=async()=>
4066{if(!l)return;S(!0),V({done:0,total:k.length});let F=0;try{for(const O of k)await go.create({companyId:l,name:O.name.trim(),usages:x,gpsPoint:O.coordinates}),F+=1,V({done:F,total:k.length});r.success(`${F} zones de chasse créées`),n(c)}catch(O){console.error("Error bulk importing hunting zones:",O),r.error(F>0?`${F} zone(s) créée(s), puis une erreur est survenue`:"Erreur lors de l'import des zones")}finally{S(!1),V(null)}},D=async F=>{if(F.preventDefault(),!!l){if(!f.trim()){r.error("Le nom de la zone est requis");return}if(b.length<3){r.error("Veuillez définir au moins 3 points pour délimiter la zone");return}_(!0);try{i&&e?(await go.update({zoneId:e,name:f.trim(),description:g.trim(),usages:x,gpsPoint:b}),r.success("Zone de chasse mise à jour")):(await go.create({companyId:l,name:f.trim(),description:g.trim()||void 0,usages:x,gpsPoint:b}),r.success("Zone de chasse créée")),n(c)}catch(O){console.error("Error saving hunting zone:",O),r.error("Erreur lors de l'enregistrement de la zone")}finally{_(!1)}}};return o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx("div",{className:"bg-card border-b border-border px-6 py-4",children:o.jsx("div",{className:"flex items-center justify-between max-w-7xl mx-auto",children:o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs(Z,{variant:"outline",onClick:()=>n(c),children:[o.jsx(Nr,{className:"w-4 h-4 mr-2"}),"Retour"]}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-foreground font-heading",children:i?"Modifier la zone de chasse":"Nouvelle zone de chasse"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:d?d.name:"Zone de société"})]})]})})}),o.jsx("div",{className:"max-w-3xl mx-auto p-6",children:P?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(ft,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):o.jsx("form",{onSubmit:D,children:o.jsxs(ke,{children:[o.jsx(Qt,{children:o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(ur,{className:"w-5 h-5"}),"Informations de la zone"]})}),o.jsxs(Pe,{className:"space-y-6",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"name",children:"Nom de la zone *"}),o.jsx(Ne,{id:"name",value:f,onChange:F=>p(F.target.value),placeholder:"Ex: Bois Nord",required:!0})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"description",children:"Description"}),o.jsx(bc,{id:"description",value:g,onChange:F=>v(F.target.value),placeholder:"Description optionnelle de la zone...",rows:3})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{children:"Usage de la zone *"}),o.jsx(iae,{selected:x,onChange:y})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsx(ne,{children:"Délimitation géographique *"}),b.length===0?o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[o.jsx("button",{type:"button",onClick:()=>E(!0),className:"p-6 border-2 border-dashed border-border rounded-lg hover:border-primary hover:bg-primary/5 transition-colors text-left group",children:o.jsxs("div",{className:"flex flex-col items-center text-center",children:[o.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center mb-3 group-hover:bg-primary/20 transition-colors",children:o.jsx(_f,{className:"w-6 h-6 text-primary"})}),o.jsx("h3",{className:"font-medium text-foreground",children:"Dessiner sur la carte"}),o.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Placez les points directement sur la carte"})]})}),o.jsx("button",{type:"button",onClick:H,className:"p-6 border-2 border-dashed border-border rounded-lg hover:border-primary hover:bg-primary/5 transition-colors text-left group",children:o.jsxs("div",{className:"flex flex-col items-center text-center",children:[o.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center mb-3 group-hover:bg-primary/20 transition-colors",children:o.jsx(No,{className:"w-6 h-6 text-primary"})}),o.jsx("h3",{className:"font-medium text-foreground",children:"Importer fichier KML"}),o.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Importez un fichier KML existant"})]})})]}):o.jsx(cae,{coordinates:b,onModify:()=>E(!0),onDelete:()=>w([])})]}),o.jsxs("div",{className:"flex gap-3 pt-4 border-t",children:[o.jsxs(Z,{type:"submit",disabled:N||b.length<3,children:[N?o.jsx(ft,{className:"w-4 h-4 mr-2 animate-spin"}):o.jsx(xc,{className:"w-4 h-4 mr-2"}),i?"Enregistrer":"Créer la zone"]}),o.jsx(Z,{type:"button",variant:"outline",onClick:()=>n(c),children:"Annuler"})]})]})]})})}),o.jsx(Rx,{isOpen:j,onClose:()=>E(!1),onSave:F=>{w(F),r.success(`${F.length} points définis pour la zone`)},initialCoordinates:b,departmentCode:$}),o.jsx(aae,{isOpen:k.length>1,zones:k,onClose:()=>L([]),onConfirm:W,importing:I,progress:T})]})}function cae({coordinates:t,onModify:e,onDelete:n}){const r="#F66D51",s=u.useRef(null),i=t.map(c=>`${c.latitude},${c.longitude}`).join("|"),a=u.useCallback(c=>{if(s.current&&s.current.setMap(null),t.length>
4066=3&&(s.current=new google.maps.Polygon({paths:t.map(d=>({lat:d.latitude,lng:d.longitude})),fillColor:r,fillOpacity:.4,strokeColor:r,strokeOpacity:1,strokeWeight:3,clickable:!1,map:c})),t.length>0){const d=new google.maps.LatLngBounds;t.forEach(h=>d.extend({lat:h.latitude,lng:h.longitude})),c.fitBounds(d,{top:30,right:30,bottom:30,left:30})}},[t]);u.useEffect(()=>()=>{s.current&&s.current.setMap(null)},[]);const l=()=>{if(t.length===0)return{lat:46.603354,lng:1.888334};const c=t.reduce((h,f)=>h+f.latitude,0),d=t.reduce((h,f)=>h+f.longitude,0);return{lat:c/t.length,lng:d/t.length}};return o.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[o.jsxs("div",{className:"h-[250px] relative",children:[o.jsx(Qs,{mapContainerStyle:{width:"100%",height:"100%"},center:l(),zoom:12,onLoad:a,options:{disableDefaultUI:!0,zoomControl:!1,mapTypeControl:!1,streetViewControl:!1,fullscreenControl:!1,draggable:!1,scrollwheel:!1,disableDoubleClickZoom:!0,mapTypeId:"hybrid"}},i),o.jsxs("div",{className:"absolute top-3 left-3 bg-card/90 backdrop-blur-sm px-3 py-1.5 rounded-full text-sm font-medium text-foreground/80 shadow-sm",children:[t.length," points"]})]}),o.jsxs("div",{className:"flex items-center justify-end gap-2 p-3 bg-muted border-t",children:[o.jsxs(Z,{type:"button",variant:"outline",size:"sm",onClick:e,children:[o.jsx(_f,{className:"w-4 h-4 mr-1"}),"Modifier"]}),o.jsxs(Z,{type:"button",variant:"outline",size:"sm",onClick:n,className:"text-red-600 hover:text-red-700 hover:bg-red-500/10",children:[o.jsx(Vt,{className:"w-4 h-4 mr-1"}),"Supprimer"]})]})]})}const Jd=20;function uae(t){const n=new DOMParser().parseFromString(t,"text/xml"),r=[];return n.querySelectorAll("Placemark").forEach(i=>{let a=null,l=null;i.querySelectorAll("SimpleData").forEach(f=>{const p=f.getAttribute("name");p==="code_insee"?a=parseInt(f.textContent||"",10):p==="nom"&&(l=f.textContent||"")}),(!a||!l)&&i.querySelectorAll("Data").forEach(p=>{const g=p.getAttribute("name"),v=p.querySelector("value"),x=(v==null?void 0:v.textContent)||"";g==="code_insee"?a=parseInt(x,10):g==="nom"&&(l=x)});const d=i.querySelectorAll("coordinates");if(d.length===0||!a||!l)return;const h=[];d.forEach(f=>{(f.textContent||"").trim().split(/[\s\n]+/).forEach(v=>{const x=v.split(",");if(x.length>=2){const y=parseFloat(x[0]),b=parseFloat(x[1]);!isNaN(b)&&!isNaN(y)&&h.push({latitude:b,longitude:y})}})}),h.length>=3&&r.push({code:a,name:l,coordinates:h})}),r}function dae(){const t=qt(),e=u.useRef(null),[n,r]=u.useState({departments:[],totalCount:0,offset:0,hasMore:!1}),[s,i]=u.useState(!0),[a,l]=u.useState(""),[c,d]=u.useState(0),[h,f]=u.useState(!1),[p,g]=u.useState(!1),[v,x]=u.useState(!1),[y,b]=u.useState(null),w=ei(a,300),j=w.length>=2?w:"",E=async N=>{var k;const _=(k=N.target.files)==null?void 0:k[0];if(_){x(!0),b("Lecture du fichier...");try{const L=await _.text();b("Parsing du KML...");const I=uae(L);if(I.length===0){b("Aucun département trouvé dans le KML"),setTimeout(()=>b(null),3e3);return}b(`${I.length} départements trouvés, import en cours...`);let S=0,T=0,V=0;for(const $ of I)try{const H=$.coordinates.map(G=>G.latitude),W=$.coordinates.map(G=>G.longitude),D={north:Math.max(...H),south:Math.min(...H),east:Math.max(...W),west:Math.min(...W)},F=jn(Xe,"departments"),O=Gr(F,is("code","==",$.code)),Y=await Yr(O);if(Y.empty){const G=Ht(F);await tb(G,{code:$.code,label:$.name,bounds:D,createdAt:Or(),updatedAt:Or()}),S++}else{const G=Y.docs[0];await tb(G.ref,{bounds:D,updatedAt:Or()},{merge:!0}),T++}b(`Import: ${S} créés, ${T} mis à jour...`)}catch(H){console.error(`Erreur pour département ${$.code}:`,H),V++}b(`Import terminé: ${S} créés, ${T} mis à jour, ${V} erreurs`),P(),setTimeout(()=>b(null),5e3)}catch(L){console.error("Erreur import KML:",L),b("Erreur lors de l'import"),setTimeout(()=>b(null),3e3)}finally{x(!1),e.current&&(e.current.value="")}}},P=u.useCallback(async()=>{i(!0);try{const N=h||p?{missingFederation:h,missingDdt:p}:void 0,_=await ys.getDepartmentsPaginated(Jd,c*Jd,j||void 0,N);r(_)}catch(N){console.error("Error loading departments:",N)}finally{i(!1)}},[c,j,h,p]);u.useEffect(()=>{P()},[P]),u.useEffect(()=>{d(0)},[j]);const A=Math.ceil(n.totalCount/Jd);return o.jsxs("div",{className:"p-4 md:p-8 space-y-5 md:space-y-6 max-w-[1400px]",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-foreground font-heading",children:"Gestion des départements"}),o.jsx("p",{className:"text-muted-foreground mt-1",children:"Configurez les fédérations et DDT par département"})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{ref:e,type:"file",accept:".kml",onChange:E,className:"hidden"}),o.jsxs(Z,{variant:"outline",onClick:()=>{var N;return(N=e.current)==null?void 0:N.click()},disabled:v,children:[v?o.jsx(hs,{className:"h-4 w-4 mr-2 animate-spin"}):o.jsx(No,{className:"h-4 w-4 mr-2"}),"Importer KML"]}),o.jsxs(Z,{onClick:()=>t(xe.departmentNew),children:[o.jsx(hr,{className:"h-4 w-4 mr-2"}),"Nouveau département"]})]})]}),y&&o.jsxs("div",{className:"bg-blue-500/10 border border-blue-200 rounded-lg p-4 flex items-center gap-3",children:[v&&o.jsx(hs,{className:"h-5 w-5 text-blue-600 animate-spin"}),o.jsx("span",{className:"text-sm text-blue-800",children:y})]}),o.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/20 rounded-lg p-4 flex items-start gap-3",children:[o.jsx(rv,{className:"h-5 w-5 text-amber-500 flex-shrink-0 mt-0.5"}),o.jsxs("div",{className:"text-sm text-amber-400",children:[o.jsx("p",{className:"font-medium",children:"Note importante"}),o.jsx("p",{className:"mt-1",children:"Si un département n'a pas de fédération ou de DDT configurée, c'est vous (super admin) qui recevrez les notifications correspondantes."})]})]}),o.jsx(ke,{children:o.jsx(Pe,{className:"pt-6",children:o.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[o.jsxs("div",{className:"relative flex-1 min-w-[250px] max-w-md",children:[o.jsx(Ws,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground
4066/60"}),o.jsx(Ne,{placeholder:"Rechercher par code ou nom...",value:a,onChange:N=>l(N.target.value),className:"pl-10"})]}),o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs("div",{className:"flex items-center space-x-2",children:[o.jsx(Ks,{id:"missingFederation",checked:h,onCheckedChange:N=>{f(N===!0),d(0)}}),o.jsx(ne,{htmlFor:"missingFederation",className:"text-sm cursor-pointer",children:"Fédération manquante"})]}),o.jsxs("div",{className:"flex items-center space-x-2",children:[o.jsx(Ks,{id:"missingDdt",checked:p,onCheckedChange:N=>{g(N===!0),d(0)}}),o.jsx(ne,{htmlFor:"missingDdt",className:"text-sm cursor-pointer",children:"DDT manquante"})]})]}),o.jsxs("div",{className:"text-sm text-muted-foreground",children:[n.totalCount," département",n.totalCount>1?"s":""," configuré",n.totalCount>1?"s":""]})]})})}),o.jsx(ke,{children:o.jsx(Pe,{className:"pt-6",children:s?o.jsxs("div",{className:"text-center py-12",children:[o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-primary/20 border-t-primary mx-auto"}),o.jsx("p",{className:"text-muted-foreground mt-4",children:"Chargement..."})]}):n.departments.length===0?o.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[o.jsx(Rn,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground/40"}),o.jsx("p",{children:"Aucun département configuré"}),(a||h||p)&&o.jsx("p",{className:"text-sm mt-2",children:"Essayez de modifier vos critères de recherche"})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"overflow-x-auto",children:o.jsxs(Ya,{children:[o.jsx(Qa,{children:o.jsxs(Fr,{children:[o.jsx(dt,{children:"Département"}),o.jsx(dt,{children:"Utilisateurs"}),o.jsx(dt,{children:"Sociétés"}),o.jsx(dt,{children:"Fédération"}),o.jsx(dt,{children:"DDT"}),o.jsx(dt,{className:"w-12"})]})}),o.jsx(Xa,{children:n.departments.map(N=>o.jsx(hae,{department:N},N.id))})]})}),o.jsxs("div",{className:"flex items-center justify-end mt-4 pt-4 border-t gap-4",children:[o.jsxs("div",{className:"text-sm text-muted-foreground",children:[Jd*c+1,"-",Math.min(Jd*(c+1),n.totalCount)," sur ",n.totalCount]}),A>1&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"text-sm text-muted-foreground",children:["Page ",c+1," sur ",A]}),o.jsxs("div",{className:"flex gap-1",children:[o.jsx(Z,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>d(0),disabled:c===0,title:"Première page",children:o.jsx(zL,{className:"h-4 w-4"})}),o.jsx(Z,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>d(N=>Math.max(0,N-1)),disabled:c===0,title:"Page précédente",children:o.jsx(vc,{className:"h-4 w-4"})}),o.jsx(Z,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>d(N=>N+1),disabled:!n.hasMore,title:"Page suivante",children:o.jsx(nr,{className:"h-4 w-4"})}),o.jsx(Z,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>d(A-1),disabled:!n.hasMore,title:"Dernière page",children:o.jsx($L,{className:"h-4 w-4"})})]})]})]})]})})})]})}function hae({department:t}){var s,i,a,l,c,d,h,f;const e=qt(),n=!!((s=t.federation)!=null&&s.contactEmail)||!!((a=(i=t.federation)==null?void 0:i.notificationEmails)!=null&&a.length),r=!!((l=t.ddt)!=null&&l.contactEmail)||!!((d=(c=t.ddt)==null?void 0:c.notificationEmails)!=null&&d.length);return o.jsxs(Fr,{className:"hover:bg-muted cursor-pointer",onClick:()=>e(mt.department(t.id)),children:[o.jsx(ht,{children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-blue-500/100/15 flex items-center justify-center",children:o.jsx(Rn,{className:"h-5 w-5 text-blue-600"})}),o.jsx("div",{children:o.jsxs("div",{className:"font-medium",children:[String(t.code).padStart(2,"0")," - ",t.label]})})]})}),o.jsx(ht,{children:t.userCount===null||t.userCount===void 0?o.jsx("span",{className:"text-sm text-muted-foreground/60",children:"â"}):o.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[o.jsx(cr,{className:"h-3.5 w-3.5 text-muted-foreground/60"}),o.jsx("span",{className:t.userCount>0?"font-medium":"text-muted-foreground",children:t.userCount})]})}),o.jsx(ht,{children:t.companyCount===null||t.companyCount===void 0?o.jsx("span",{className:"text-sm text-muted-foreground
4066/60",children:"â"}):o.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[o.jsx(qn,{className:"h-3.5 w-3.5 text-muted-foreground/60"}),o.jsx("span",{className:t.companyCount>0?"font-medium":"text-muted-foreground",children:t.companyCount})]})}),o.jsx(ht,{children:n?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(We,{variant:"outline",className:"bg-green-500/10 text-green-500 border-green-500/20",children:[o.jsx(ns,{className:"h-3 w-3 mr-1"}),"Configurée"]}),o.jsxs("div",{className:"text-sm text-muted-foreground",children:[o.jsx(qn,{className:"h-3.5 w-3.5 inline mr-1"}),(h=t.federation)==null?void 0:h.name]})]}):o.jsxs(We,{variant:"outline",className:"bg-amber-500/10 text-amber-500 border-amber-500/20",children:[o.jsx(rv,{className:"h-3 w-3 mr-1"}),"Non configurée"]})}),o.jsx(ht,{children:r?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(We,{variant:"outline",className:"bg-green-500/10 text-green-500 border-green-500/20",children:[o.jsx(ns,{className:"h-3 w-3 mr-1"}),"Configurée"]}),o.jsxs("div",{className:"text-sm text-muted-foreground",children:[o.jsx(rc,{className:"h-3.5 w-3.5 inline mr-1"}),(f=t.ddt)==null?void 0:f.name]})]}):o.jsxs(We,{variant:"outline",className:"bg-amber-500/10 text-amber-500 border-amber-500/20",children:[o.jsx(rv,{className:"h-3 w-3 mr-1"}),"Non configurée"]})}),o.jsx(ht,{children:o.jsx(Z,{variant:"ghost",size:"icon",children:o.jsx(nr,{className:"h-4 w-4"})})})]})}const qs={async getUsersPaginated(t=20,e,n,r,s){try{const a=await pe(ge,"getUsersPaginated")({limit:Math.min(t,100),filter:e,searchTerm:n,lastDocId:r,departmentCode:s});return{users:a.data.users||[],hasMore:a.data.hasMore||!1,lastDocId:a.data.lastDocId||null,isSearchResult:a.data.isSearchResult||!1,totalCount:a.data.totalCount}}catch(i){return console.error("Error fetching paginated users:",i),{users:[],hasMore:!1,lastDocId:null,isSearchResult:!1}}},async countUsersByDepartment(t){return(await this.getUsersPaginated(1,void 0,void 0,null,t)).totalCount??null},async getUserById(t){try{const e=await ms(Ht(Xe,"users",t));return e.exists()?{id:e.id,...e.data()}:null}catch(e){return console.error("Error getting user:",e),null}},async updateMyProfile(t,e){await Ba(Ht(Xe,"users",t),{...e,updatedAt:Or()})},async updateUser(t,e){await pe(ge,"updateUserSecure")({userId:t,...e})},async addRoleToUser(t,e){await pe(ge,"addRoleToUser")({userId:t,role:e})},async removeRoleFromUser(t,e){await pe(ge,"removeRoleFromUser")({userId:t,role:e})},async createUser(t){return{userId:(await pe(ge,"createUserAdmin")({email:t.email,pseudo:t.pseudo||t.email.split("@")[0],departmentCode:t.departmentCode,departmentLabel:t.departmentLabel,roles:t.roles||["user"]})).data.userId}},async assignRoleByEmail(t){await pe(ge,"assignRoleByEmail")({email:t.email,role:t.role,departmentCode:t.departmentCode})},async getPendingFarmers(){try{return(await pe(ge,"getPendingFarmers")({})).data.pendingFarmers||[]}catch(t){return console.error("Error fetching pending farmers:",t),[]}},async deleteUser(t){await pe(ge,"deleteUser")({userId:t})},async getUsersExportCount(t){try{return(await pe(ge,"getUsersExportCount")(t)).data.count||0}catch(e){return console.error("Error getting users export count:",e),0}},async exportUsersCSV(t){return(await pe(ge,"exportUsersCSV")(t)).data.users||[]}},fae=()=>{const t=new Date;return t.setFullYear(t.getFullYear()+1),t.toISOString().split("T")[0]},oI=t=>new Date(t).toLocaleDateString("fr-FR",{day:"numeric",month:"long",year:"numeric"});function mae({departmentCode:t,departmentLabel:e}){const n=Ft(),[r,s]=u.useState(null),[i,a]=u.useState(fae),[l,c]=u.useState(!1),[d,h]=u.useState(null);u.useEffect(()=>{let g=!1;return Ot.getCompaniesPaginated(100,void 0,t).then(v=>{g||s(v.totalCount)}).catch(v=>console.warn("Could not count department companies:",v)),()=>{g=!0}},[t]);const f=async()=>{c(!0);try{const g=await sa.grantDepartment(t,new Date(i).toISOString());h(g),n.success(g.granted>0?`${g.granted} société${g.granted>1?"s":""} passée${g.granted>1?"s":""} en premium`:"Aucune société à mettre à jour")}catch(g){n.error((g==null?void 0:g.message)||"Erreur lors de l'octroi")}finally{c(!1)}},p=r===null?"Chargement des sociétésâ¦":`${r} société${r>1?"s":""} dans ce département`;return o.jsxs(ke,{children:[o.jsxs(Qt,{children:[o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(mo,{className:"h-5 w-5 text-amber-500"}),"Premium des sociétés"]}),o.jsxs(la,{children:["Offrir le premium à toutes les sociétés de chasse du département",e?` ${e}`:"",". Tous leurs membres en bénéficient jusqu'à la date choisie ; les chasseurs sans société ne sont pas concernés."]})]}),o.jsxs(Pe,{className:"space-y-4",children:[o.jsx("p",{className:"text-sm text-muted-foreground",children:p}),o.jsxs("div",{className:"flex items-end gap-2 flex-wrap",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ne,{htmlFor:"department-premium-end",className:"text-xs",children:"Date de fin"}),o.jsx(Ne,{id:"department-premium-end",type:"date",value:i,min:new Date().toISOString().split("T")[0],onChange:g=>a(g.target.value),className:"w-44"})]}),o.jsxs(Dn,{children:[o.jsx(cm,{asChild:!0,children:o.jsxs(Z,{disabled:l||!i||r===0,children:[l&&o.jsx(ft,{className:"h-4 w-4 mr-2 animate-spin"}),"Offrir le premium"]})}),o.jsxs(Ln,{children:[o.jsxs(Mn,{children:[o.jsx(Fn,{children:"Passer le département en premium ?"}),o.jsxs(zn,{children:[r!==null&&o.jsxs(o.Fragment,{children:[r," société",r>1?"s":""," du département",e?` ${e}`:""," seront premium jusqu'au"," ",oI(i),"."," "]}),"Les sociétés qui ont déjà un abonnement payant ne sont pas touchées."]})]}),o.jsxs(On,{children:[o.jsx(Vn,{disabled:l,children:"Annuler"}),o.jsx($n,{onClick:f,disabled:l,children:"Offrir le premium"})]})]})]})]}),d&&o.jsxs("div",{className:"rounded-lg border p-3 text-sm space-y-2",children:[o.jsxs("p",{children:[d.granted," société",d.granted>
40661?"s":""," sur ",d.total," premium jusqu'au ",oI(d.endDate),"."]}),d.skipped.length>0&&o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"text-muted-foreground",children:"Non modifiées, elles ont déjà un abonnement payant :"}),o.jsx("ul",{className:"list-disc pl-5 text-muted-foreground",children:d.skipped.map(g=>o.jsx("li",{children:g.name},g.companyId))})]})]})]})]})}const pae=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function _p({id:t,emails:e,onChange:n}){const[r,s]=u.useState(""),[i,a]=u.useState(!1),l=()=>{const c=r.toLowerCase().trim();if(c){if(!pae.test(c)){a(!0);return}e.includes(c)||n([...e,c]),s("")}};return o.jsxs("div",{className:"space-y-2",children:[e.length>0&&o.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(c=>o.jsxs(We,{variant:"secondary",className:"gap-1 font-normal",children:[c,o.jsx("button",{type:"button","aria-label":`Retirer ${c}`,className:"ml-0.5 hover:text-red-500",onClick:()=>n(e.filter(d=>d!==c)),children:o.jsx(br,{className:"h-3 w-3"})})]},c))}),o.jsx(Ne,{id:t,type:"email",placeholder:"[email protected] puis Entrée",value:r,onChange:c=>{s(c.target.value),a(!1)},onKeyDown:c=>{(c.key==="Enter"||c.key===",")&&(c.preventDefault(),l())},onBlur:l,className:i?"border-red-500":void 0}),i&&o.jsx("p",{className:"text-xs text-red-500",children:"Format d'email invalide"})]})}function gae(){const{departmentId:t}=Ys(),e=qt(),n=Ft(),r=t==="nouveau",[s,i]=u.useState(null),[a,l]=u.useState(null),[c,d]=u.useState(!r),[h,f]=u.useState(!1),[p,g]=u.useState(""),[v,x]=u.useState(""),[y,b]=u.useState([]),[w,j]=u.useState([]),[E,P]=u.useState(""),[A,N]=u.useState(""),[_,k]=u.useState(""),[L,I]=u.useState(""),[S,T]=u.useState([]),[V,$]=u.useState(null),[H,W]=u.useState(null),[D,F]=u.useState(null),[O,Y]=u.useState(!1),G=u.useRef(null),[q,re]=u.useState(""),[U,ee]=u.useState(""),[K,ue]=u.useState(""),[be,le]=u.useState(""),[B,Q]=u.useState([]),[ve,Ae]=u.useState(""),[he,J]=u.useState(""),[je,Ve]=u.useState(""),[Ye,Jt]=u.useState(""),[Ue,rn]=u.useState([]),[vt,me]=u.useState(""),[ot,Se]=u.useState(""),[Te,He]=u.useState(""),[Ut,cn]=u.useState(""),[xn,un]=u.useState([]),[Yt,st]=u.useState(!1),[de,ze]=u.useState(!1);u.useEffect(()=>{(async()=>{const[et,xt]=await Promise.all([As(),r?ys.getConfiguredDepartmentCodes():Promise.resolve([])]);b(et),j(xt)})()},[r]);const Qe=u.useCallback(async()=>{if(!(r||!t)){d(!0),g("");try{const ae=await ys.getDepartmentById(t);if(ae){if(i(ae),x(String(ae.code)),ae.federation&&(P(ae.federation.name||""),N(ae.federation.contactFirstName||""),k(ae.federation.contactLastName||""),I(ae.federation.contactEmail||""),T(ae.federation.notificationEmails||[]),ae.federation.logoPath)){F(ae.federation.logoPath);try{const et=Wa(Ha,ae.federation.logoPath),xt=await xf(et);W(xt)}catch(et){console.warn("Could not load federation logo:",et)}}ae.ddt&&(re(ae.ddt.name||""),ee(ae.ddt.contactFirstName||""),ue(ae.ddt.contactLastName||""),le(ae.ddt.contactEmail||""),Q(ae.ddt.notificationEmails||[])),ae.chambreAgriculture&&(Ae(ae.chambreAgriculture.name||""),J(ae.chambreAgriculture.contactFirstName||""),Ve(ae.chambreAgriculture.contactLastName||""),Jt(ae.chambreAgriculture.contactEmail||""),rn(ae.chambreAgriculture.notificationEmails||[])),ae.assoPiegeurs&&(me(ae.assoPiegeurs.name||""),Se(ae.assoPiegeurs.contactFirstName||""),He(ae.assoPiegeurs.contactLastName||""),cn(ae.assoPiegeurs.contactEmail||""),un(ae.assoPiegeurs.notificationEmails||[])),st(ae.notifyFederationAlways||!1),ze(ae.notifyDdtAlways||!1),qs.countUsersByDepartment(ae.code).then(l).catch(et=>{console.warn("Could not count department users:",et)})}else g("Département non trouvé")}catch(ae){g("Erreur lors du chargement"),console.error(ae)}finally{d(!1)}}},[t,r]);u.useEffect(()=>{Qe()},[Qe]);const It=async()=>{if(r&&!v){n.error("Veuillez sélectionner un département");return}f(!0),g("");try{const ae=E?{name:E,contactFirstName:A||void 0,contactLastName:_||void 0,contactEmail:L||void 0,notificationEmails:S}:void 0,et=q?{name:q,contactFirstName:U||void 0,contactLastName:K||void 0,contactEmail:be||void 0,notificationEmails:B}:void 0,xt=ve?{name:ve,contactFirstName:he||void 0,contactLastName:je||void 0,contactEmail:Ye||void 0,notificationEmails:Ue}:void 0,zt=vt?{name:vt,contactFirstName:ot||void 0,contactLastName:Te||void 0,contactEmail:Ut||void 0,notificationEmails:xn}:void 0;if(r){const $e=y.find(De=>De.code===v);if(!$e){n.error("Département invalide");return}const oe=await ys.createDepartment({code:parseInt(v),label:$e.nom,federation:ae,ddt:et,chambreAgriculture:xt,assoPiegeurs:zt});V&&oe.id&&E&&await ys.uploadFederationLogo(oe.id,V),n.success("Département créé avec succès"),e(xe.departments)}else s&&(await ys.updateDepartment(s.id,{federation:ae||null,ddt:et||null,chambreAgriculture:xt||null,assoPiegeurs:zt||null,notifyFederationAlways:Yt,notifyDdtAlways:de}),V?await ys.uploadFederationLogo(s.id,V):O&&D&&await ys.deleteFederationLogo(s.id),n.success("Département mis à jour"),Qe())}catch(ae){const et=(ae==null?void 0:ae.message)||"Erreur lors de la sauvegarde";g(et),n.error(et)}finally{f(!1)}},se=async()=>
4066{if(s)try{await ys.deleteDepartment(s.id),n.success("Département supprimé"),e(xe.departments)}catch(ae){n.error((ae==null?void 0:ae.message)||"Erreur lors de la suppression")}},Re=!E||!q;return c?o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx(Fx,{}),o.jsxs("div",{className:"max-w-5xl mx-auto p-6 space-y-6",children:[o.jsx(VO,{}),o.jsx(Tf,{})]})]}):p&&!r?o.jsxs("div",{className:"p-6",children:[o.jsxs(yr,{variant:"destructive",children:[o.jsx(an,{className:"h-4 w-4"}),o.jsx(wr,{children:p})]}),o.jsxs(Z,{variant:"outline",onClick:()=>e(xe.departments),className:"mt-4",children:[o.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Retour à la liste"]})]}):o.jsxs("div",{className:"p-4 md:p-6 space-y-4 md:space-y-6 max-w-4xl",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>e(xe.departments),children:o.jsx(Nr,{className:"h-5 w-5"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-foreground font-heading",children:r?"Nouveau département":`${String(s==null?void 0:s.code).padStart(2,"0")} - ${s==null?void 0:s.label}`}),o.jsxs("p",{className:"text-muted-foreground mt-1 flex items-center gap-2",children:[r?"Configurer un nouveau département":"Modifier la configuration",!r&&a!==null&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/40",children:"·"}),o.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[o.jsx(cr,{className:"h-3.5 w-3.5"}),a," utilisateur",a>1?"s":""]})]})]})]})]}),o.jsxs("div",{className:"flex gap-2",children:[!r&&o.jsxs(Dn,{children:[o.jsx(cm,{asChild:!0,children:o.jsxs(Z,{variant:"outline",className:"text-red-600 hover:text-red-700",children:[o.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Supprimer"]})}),o.jsxs(Ln,{children:[o.jsxs(Mn,{children:[o.jsx(Fn,{children:"Supprimer ce département ?"}),o.jsx(zn,{children:"Cette action est irréversible. Les données de configuration de la fédération et de la DDT seront supprimées."})]}),o.jsxs(On,{children:[o.jsx(Vn,{children:"Annuler"}),o.jsx($n,{onClick:se,className:"bg-red-600 hover:bg-red-700",children:"Supprimer"})]})]})]}),o.jsxs(Z,{onClick:It,disabled:h,children:[o.jsx(xc,{className:"h-4 w-4 mr-2"}),h?"Enregistrement...":"Enregistrer"]})]})]}),p&&o.jsxs(yr,{variant:"destructive",children:[o.jsx(an,{className:"h-4 w-4"}),o.jsx(wr,{children:p})]}),Re&&o.jsxs(yr,{className:"bg-amber-500/10 border-amber-500/20",children:[o.jsx(rv,{className:"h-4 w-4 text-amber-500"}),o.jsxs(wr,{className:"text-amber-400",children:[o.jsx("strong",{children:"Attention :"})," Si vous ne configurez pas de fédération ou de DDT, c'est vous (super admin) qui recevrez les notifications correspondantes pour ce département."]})]}),r&&o.jsxs(ke,{children:[o.jsxs(Qt,{children:[o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(Rn,{className:"h-5 w-5"}),"Département"]}),o.jsx(la,{children:"Sélectionnez le département à configurer"})]}),o.jsx(Pe,{children:o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{children:"Département *"}),o.jsxs(_t,{value:v,onValueChange:x,children:[o.jsx(St,{className:"w-full",children:o.jsx(Et,{placeholder:"Sélectionnez un département"})}),o.jsx(kt,{className:"max-h-[300px]",children:y.map(ae=>{const et=w.includes(parseInt(ae.code));return o.jsxs(Ke,{value:ae.code,disabled:et,className:et?"text-muted-foreground/60":"",children:[ae.code," - ",ae.nom,et&&" (déjà configuré)"]},ae.code)})})]})]})})]}),o.jsxs(ke,{children:[o.jsxs(Qt,{children:[o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(qn,{className:"h-5 w-5 text-emerald-600"}),"Fédération de chasse"]}),o.jsx(la,{children:"Informations de la fédération départementale de chasse"})]}),o.jsxs(Pe,{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"fedeName",children:"Nom de la fédération"}),o.jsx(Ne,{id:"fedeName",placeholder:"Ex: Fédération des chasseurs du Rhône",value:E,onChange:ae=>P(ae.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{children:"Logo de la fédération"}),o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("div",{className:"w-48 h-24 border-2 border-dashed rounded-lg flex items-center justify-center cursor-pointer hover:border-emerald-500 transition-colors overflow-hidden bg-muted",onClick:()=>{var ae;return(ae=G.current)==null?void 0:ae.click()},children:H?o.jsx("img",{src:H,alt:"Logo fédération",className:"max-w-full max-h-full object-contain"}
4066):o.jsxs("div",{className:"text-center text-muted-foreground/60",children:[o.jsx(No,{className:"h-6 w-6 mx-auto mb-1"}),o.jsx("span",{className:"text-xs",children:"Cliquez pour ajouter"})]})}),o.jsx("input",{ref:G,type:"file",accept:"image/*",onChange:ae=>{var xt;const et=(xt=ae.target.files)==null?void 0:xt[0];if(et){$(et),Y(!1);const zt=new FileReader;zt.onload=$e=>{var oe;W((oe=$e.target)==null?void 0:oe.result)},zt.readAsDataURL(et)}},className:"hidden"}),H&&o.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>{$(null),W(null),Y(!0),G.current&&(G.current.value="")},children:[o.jsx(br,{className:"h-4 w-4 mr-1"}),"Supprimer"]})]})]}),o.jsx(Hn,{}),o.jsx("div",{className:"space-y-1",children:o.jsxs(ne,{className:"text-sm text-muted-foreground flex items-center gap-1",children:[o.jsx(po,{className:"h-4 w-4"}),"Personne en charge"]})}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"fedeFirstName",children:"Prénom"}),o.jsx(Ne,{id:"fedeFirstName",placeholder:"Prénom",value:A,onChange:ae=>N(ae.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"fedeLastName",children:"Nom"}),o.jsx(Ne,{id:"fedeLastName",placeholder:"Nom",value:_,onChange:ae=>k(ae.target.value)})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ne,{htmlFor:"fedeEmail",className:"flex items-center gap-1",children:[o.jsx(rs,{className:"h-4 w-4"}),"Email"]}),o.jsx(Ne,{id:"fedeEmail",type:"email",placeholder:"[email protected]",value:L,onChange:ae=>I(ae.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ne,{htmlFor:"fedeExtraEmails",className:"flex items-center gap-1",children:[o.jsx(rs,{className:"h-4 w-4"}),"Emails supplémentaires"]}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Recevront aussi les notifications destinées à la fédération, sans compte représentant."}),o.jsx(_p,{id:"fedeExtraEmails",emails:S,onChange:T})]})]})]}),o.jsxs(ke,{children:[o.jsxs(Qt,{children:[o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(rc,{className:"h-5 w-5 text-blue-600"}),"DDT (Direction Départementale des Territoires)"]}),o.jsx(la,{children:"Informations de la DDT départementale"})]}),o.jsxs(Pe,{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"ddtName",children:"Nom de la DDT"}),o.jsx(Ne,{id:"ddtName",placeholder:"Ex: DDT du Rhône",value:q,onChange:ae=>re(ae.target.value)})]}),o.jsx(Hn,{}),o.jsx("div",{className:"space-y-1",children:o.jsxs(ne,{className:"text-sm text-muted-foreground flex items-center gap-1",children:[o.jsx(po,{className:"h-4 w-4"}),"Personne en charge"]})}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"ddtFirstName",children:"Prénom"}),o.jsx(Ne,{id:"ddtFirstName",placeholder:"Prénom",value:U,onChange:ae=>ee(ae.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"ddtLastName",children:"Nom"}),o.jsx(Ne,{id:"ddtLastName",placeholder:"Nom",value:K,onChange:ae=>ue(ae.target.value)})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ne,{htmlFor:"ddtEmail",className:"flex items-center gap-1",children:[o.jsx(rs,{className:"h-4 w-4"}),"Email"]}),o.jsx(Ne,{id:"ddtEmail",type:"email",placeholder:"[email protected]",value:be,onChange:ae=>le(ae.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ne,{htmlFor:"ddtExtraEmails",className:"flex items-center gap-1",children:[o.jsx(rs,{className:"h-4 w-4"}),"Emails supplémentaires"]}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Recevront aussi les notifications destinées à la DDT, sans compte représentant."}),o.jsx(_p,{id:"ddtExtraEmails",emails:B,onChange:Q})]})]})]}),o.jsxs(ke,{children:[o.jsxs(Qt,{children:[o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(lY,{className:"h-5 w-5 text-amber-500"}),"Chambre d'agriculture"]}),o.jsx(la,{children:"Gère les agriculteurs du département"})]}),o.jsxs(Pe,{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"chambreName",children:"Nom de la chambre"}),o.jsx(Ne,{id:"chambreName",placeholder:"Ex: Chambre d'agriculture du Rhône",value:ve,onChange:ae=>Ae(ae.target.value)})]}),o.jsx(Hn,{}),o.jsx("div",{className:"space-y-1",children:o.jsxs(ne,{className:"text-sm text-muted-foreground flex items-center gap-1",children:[o.jsx(po,{className:"h-4 w-4"}),"Personne en charge"]})}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"chambreFirstName",children:"Prénom"}),o.jsx(Ne,{id:"chambreFirstName",placeholder:"Prénom",value:he,onCh
4066ange:ae=>J(ae.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"chambreLastName",children:"Nom"}),o.jsx(Ne,{id:"chambreLastName",placeholder:"Nom",value:je,onChange:ae=>Ve(ae.target.value)})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ne,{htmlFor:"chambreEmail",className:"flex items-center gap-1",children:[o.jsx(rs,{className:"h-4 w-4"}),"Email"]}),o.jsx(Ne,{id:"chambreEmail",type:"email",placeholder:"[email protected]",value:Ye,onChange:ae=>Jt(ae.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ne,{htmlFor:"chambreExtraEmails",className:"flex items-center gap-1",children:[o.jsx(rs,{className:"h-4 w-4"}),"Emails supplémentaires"]}),o.jsx(_p,{id:"chambreExtraEmails",emails:Ue,onChange:rn})]})]})]}),o.jsxs(ke,{children:[o.jsxs(Qt,{children:[o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(ZL,{className:"h-5 w-5 text-orange-600"}),"Association de piégeurs"]}),o.jsx(la,{children:"Gère les piégeurs et leur assignation aux zones du département"})]}),o.jsxs(Pe,{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"assoName",children:"Nom de l'association"}),o.jsx(Ne,{id:"assoName",placeholder:"Ex: Association des piégeurs du Rhône",value:vt,onChange:ae=>me(ae.target.value)})]}),o.jsx(Hn,{}),o.jsx("div",{className:"space-y-1",children:o.jsxs(ne,{className:"text-sm text-muted-foreground flex items-center gap-1",children:[o.jsx(po,{className:"h-4 w-4"}),"Personne en charge"]})}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"assoFirstName",children:"Prénom"}),o.jsx(Ne,{id:"assoFirstName",placeholder:"Prénom",value:ot,onChange:ae=>Se(ae.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"assoLastName",children:"Nom"}),o.jsx(Ne,{id:"assoLastName",placeholder:"Nom",value:Te,onChange:ae=>He(ae.target.value)})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ne,{htmlFor:"assoEmail",className:"flex items-center gap-1",children:[o.jsx(rs,{className:"h-4 w-4"}),"Email"]}),o.jsx(Ne,{id:"assoEmail",type:"email",placeholder:"[email protected]",value:Ut,onChange:ae=>cn(ae.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ne,{htmlFor:"assoExtraEmails",className:"flex items-center gap-1",children:[o.jsx(rs,{className:"h-4 w-4"}),"Emails supplémentaires"]}),o.jsx(_p,{id:"assoExtraEmails",emails:xn,onChange:un})]})]})]}),!r&&o.jsxs(ke,{children:[o.jsxs(Qt,{children:[o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(gb,{className:"h-5 w-5 text-amber-500"}),"Préférences de notification"]}),o.jsx(la,{children:"Par défaut, seuls les chasseurs et louvetiers assignés sont notifiés. Activez ces options pour toujours notifier la fédération ou la DDT en plus."})]}),o.jsxs(Pe,{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-start space-x-3",children:[o.jsx(Ks,{id:"notifyFederationAlways",checked:Yt,onCheckedChange:ae=>st(ae===!0)}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ne,{htmlFor:"notifyFederationAlways",className:"font-medium cursor-pointer",children:"Toujours notifier la fédération"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"La fédération recevra les notifications de dégâts même si des chasseurs sont assignés à la zone."})]})]}),o.jsx(Hn,{}),o.jsxs("div",{className:"flex items-start space-x-3",children:[o.jsx(Ks,{id:"notifyDdtAlways",checked:de,onCheckedChange:ae=>ze(ae===!0)}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ne,{htmlFor:"notifyDdtAlways",className:"font-medium cursor-pointer",children:"Toujours notifier la DDT"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"La DDT recevra les notifications de dégâts même si des louvetiers sont assignés à la zone."})]})]})]})]}),!r&&s&&o.jsx(mae,{departmentCode:s.code,departmentLabel:s.label})]})}function vae({open:t,onOpenChange:e,onUserCreated:n}){const[r,s]=u.useState(""),[i,a]=u.useState(""),[l,c]=u.useState(""),[d,h]=u.useState([]),[f,p]=u.useState(!1),[g,v]=u.useState("");u.useEffect(()=>{As().then(h)},[]);const x=()=>{s(""),a(""),c(""),v("")},y=()=>{x(),e(!1)},b=j=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(j),w=async()=>{var E,P;if(v(""),!r.trim()){v("L'email est obligatoire");return}if(!b(r.trim())){v("L'email n'est pas valide");return}if(!l){v("Le département est obligatoire");return}const j=d.find(A=>A.code===l);if(!j){v("Département invalide");return}p(!0);try{const{userId:A}=await qs.createUser({email:r.trim().toLowerCase(),pseudo:i.trim()||void 0,departmentCode:parseInt(l),departmentLabel:j.nom});y(),n(A)}catch(A){console.error("Error creating user:",A),(E=A.message)!=null&&E.includes("email-already-exists")||(P=A.message)!=null&&P.includes("already in use")?v("Un utilisateur avec cet email existe déjà "):v(A.message||"Erreur lors de la création de l'utilisateur")}finally{p(!1)}};return o.jsx(rr,{open:t,onOpenChange:y,children:o.jsxs(sr,{className:"sm:max-w-[425px]",children:[o.jsxs(or,{children:[o.jsxs(Gn,{className:"flex items-center gap-2",children:[o.jsx(sc,{className:"h-5 w-5"}),"Ajouter un utilisateur"]}),o.jsx(ir,{children:"Créez un nouvel utilisateur avec son adresse email. Un mot de passe temporaire lui sera envoyé."})]}),o.jsxs("div",{className:"space-y-4 py-4",children:[g&&o.jsxs(yr,{variant:"destructive",children:[o.jsx(an,{className:"h-4 w-4"}),o.jsx(wr,{children:g})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"email",children:"Email *"}),o.jsx(Ne,{id:"email",type:"email",placeholder:"[email protected]",value:r,onChange:j=>s(j.target.value),disabled:f})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"pseudo",children:"Pseudo (optionnel)"}),o.jsx(Ne,{id:"pseudo",placeholder:"Pseudo de l'utilisateur",value:i,onChange:j=>a(j.target.value),disabled:f}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Si non renseigné, le pseudo sera généré à partir de l'email"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"department",children:"Département *"}),o.jsxs(_t,{value:l,onValueChange:c,disabled:f,children:[o.jsx(St,{children:o.jsx(Et,{placeholder:"Sélectionner un département"})}),o.jsx(kt,{className:"max-h-[300px]",children:d.map(j=>o.jsxs(Ke,{value:j.code,children:[j.code," - ",j.nom]},j.code))})]})]})]}),o.jsxs(ks,{children:[o.jsx(Z,{variant:"outline",onClick:y,disabled:f,children:"Annuler"}),o.jsx(Z,{onClick:w,disabled:f,children:f?o.jsxs(o.Fragment,{children:[o.jsx(hs,{className:"h-4 w-4 mr-2 animate-spin"}),"Création..."]}):o.jsxs(o.Fragment,{children:[o.jsx(sc,{className:"h-4 w-4 mr-2"}),"Créer l'utilisateur"]})})]})]})})}const xae={hunter:"Chasseur",walker:"Marcheur",cyclist:"Cycliste",horseman:"Cavalier",rider:"Moto",public:"Chemins publics",federation:"Fédération de chasse"};function yae({open:t,onOpenChange:e}){const[n,r]=u.useState(""),[s,i]=u.useState(""),[a,l]=u.useState([]),[c,d]=u.useState(null),[h,f]=u.useState(!1),[p,g]=u.useState(!1),v=`dept-${n}_act-${s}`,x=ei(v,300);u.useEffect(()=>{As().then(l)},[]);const y=u.useCallback(()=>{const j={};return n&&(j.departmentCode=parseInt(n)),s&&(j.activity=s),j},[n,s]);u.useEffect(()=>{if(!t)return;f(!0);const j=y();qs.getUsersExportCount(j).then(E=>{d(E),f(!1)})},[t,x,y]);const b=()=>{r(""),i(""),d(null),e(!1)},w=async()=>{g(!0);try{const j=y(),E=await qs.exportUsersCSV(j),P="id,email,activity,creationDate",A=E.map(S=>{const T=S.email.includes(",")?`"${S.email}"`:S.email;let V="";if(S.creationDate){const $=new Date(S.creationDate);isNaN($.getTime())||(V=`${String($.getDate()).padStart(2,"0")}/${String($.getMonth()+1).padStart(2,"0")}/${$.getFullYear()}`)}return`${S.id},${T},${S.activity},${V}`}),N=[P,...A].join(` 4067`),_=new Blob([N],{type:"text/csv;charset=utf-8;"}),k=URL.createObjectURL(_),L=document.createElement("a");L.href=k;const I=new Date().toISOString().slice(0,10);L.download=`utilisateurs_${I}.csv`,document.body.appendChild(L),L.click(),document.body.removeChild(L),URL.revokeObjectURL(k),b()}catch(j){console.error("Error exporting users:",j)}finally{g(!1)}};return o.jsx(rr,{open:t,onOpenChange:b,children:o.jsxs(sr,{className:"sm:max-w-[450px]",children:[o.jsxs(or,{children:[o.jsxs(Gn,{className:"flex items-center gap-2",children:[o.jsx(Nf,{className:"h-5 w-5"}),"Exporter les utilisateurs"]}
4067),o.jsx(ir,{children:"Exportez la liste des utilisateurs au format CSV. Les filtres sont combinables."})]}),o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{children:"Département"}),o.jsxs(_t,{value:n||"_all",onValueChange:j=>r(j==="_all"?"":j),children:[o.jsx(St,{children:o.jsx(Et,{})}),o.jsxs(kt,{className:"max-h-[300px]",children:[o.jsx(Ke,{value:"_all",children:"Tous les départements"}),a.map(j=>o.jsxs(Ke,{value:j.code,children:[j.code," - ",j.nom]},j.code))]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{children:"Activité"}),o.jsxs(_t,{value:s||"_all",onValueChange:j=>i(j==="_all"?"":j),children:[o.jsx(St,{children:o.jsx(Et,{})}),o.jsxs(kt,{children:[o.jsx(Ke,{value:"_all",children:"Toutes les activités"}),Object.entries(xae).map(([j,E])=>o.jsx(Ke,{value:j,children:E},j))]})]})]}),o.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted rounded-lg",children:[o.jsx(cr,{className:"h-4 w-4 text-muted-foreground"}),h?o.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[o.jsx(hs,{className:"h-3.5 w-3.5 animate-spin"}),"Comptage..."]}):c!==null?o.jsxs("span",{className:"text-sm text-foreground/80",children:[o.jsx("span",{className:"font-semibold",children:c.toLocaleString("fr-FR")})," utilisateur",c>1?"s":""," concerné",c>1?"s":""]}):null]})]}),o.jsxs(ks,{children:[o.jsx(Z,{variant:"outline",onClick:b,disabled:p,children:"Annuler"}),o.jsx(Z,{onClick:w,disabled:p||c===0,children:p?o.jsxs(o.Fragment,{children:[o.jsx(hs,{className:"h-4 w-4 mr-2 animate-spin"}),"Export..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Nf,{className:"h-4 w-4 mr-2"}),"Exporter en CSV"]})})]})]})})}const iI=20,aI=100,wae={all:"Tous les utilisateurs",with_roles:"Avec rôles spéciaux",super_admin:"Super Admin",farmer:"Agriculteurs",louvetier:"Louvetiers",trapper:"Piégeurs",federation:"Fédérations",ddt:"DDT",chambre_agriculture:"Chambres d'agriculture",asso_piegeurs:"Associations de piégeurs"};function bae(){const t=qt(),e=Ft(),{user:n,isSuperAdmin:r}=nn(),s=n?Bs(n,"chambre_agriculture")&&!r:!1,[i,a]=u.useState([]),[l,c]=u.useState(!1),[d,h]=u.useState(null),[f,p]=u.useState(!1),[g,v]=u.useState(void 0),[x,y]=u.useState(!0),[b,w]=u.useState(""),[j,E]=u.useState(s?"farmer":"all"),[P,A]=u.useState([]),[N,_]=u.useState("all"),[k,L]=u.useState([null]),[I,S]=u.useState(0),[T,V]=u.useState(!1),[$,H]=u.useState(!1),W=ei(b,300),D=W.length>=3?W:"";u.useEffect(()=>{As().then(A)},[]);const F=u.useCallback(async(ee=null)=>{y(!0);try{const K=s?n==null?void 0:n.departmentCode:N!=="all"?parseInt(N):void 0,ue=s?"farmer":j!=="all"?j:void 0,be=await qs.getUsersPaginated(iI,ue,D||void 0,ee,K);a(be.users),c(be.hasMore),h(be.lastDocId),p(be.isSearchResult),v(be.totalCount)}catch(K){console.error("Error loading users:",K)}finally{y(!1)}},[j,N,D,s,n==null?void 0:n.departmentCode]);u.useEffect(()=>{L([null]),S(0),F(null)},[j,N,D]);const O=ee=>{E(ee)},Y=ee=>{_(ee)},G=ee=>{e.success("Utilisateur créé avec succès"),F(null),t(mt.user(ee))},q=()=>{if(l&&d&&!f){const ee=[...k,d];L(ee),S(I+1),F(d)}},re=()=>{if(I>0&&!f){const ee=k[I-1];S(I-1),F(ee)}},U=ee=>{var be;const K=[];ee.isSuperAdmin&&K.push(o.jsx(We,{variant:"destructive",className:"text-xs",children:"Admin"},"admin"));const ue=["farmer","louvetier","trapper","federation","ddt","chambre_agriculture","asso_piegeurs"];return(be=ee.roles)==null||be.filter(le=>ue.includes(le)).forEach(le=>{K.push(o.jsx(We,{variant:"secondary",className:"text-xs",children:bu[le]},le))}),K.length>0?K:o.jsx("span",{className:"text-muted-foreground/60 text-sm",children:"Utilisateur"})};return o.jsxs("div",{className:"p-4 md:p-8 space-y-5 md:space-y-6 max-w-[1400px]",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-foreground font-heading",children:s?"Gestion des agriculteurs":"Gestion des utilisateurs"}),o.jsx("p",{className:"text-muted-foreground mt-1",children:s?`Agriculteurs du département ${(n==null?void 0:n.departmentLabel)||""}`:"Attribuer des rôles et gérer les permissions"})]}),r&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(Z,{variant:"outline",onClick:()=>H(!0),children:[o.jsx(Nf,{className:"h-4 w-4 mr-2"}),"Exporter CSV"]}),o.jsxs(Z,{onClick:()=>V(!0),children:[o.jsx(sc,{className:"h-4 w-4 mr-2"}),"Ajouter un utilisateur"]})]})]}),o.jsx(ke,{children:o.jsx(Pe,{className:"pt-6",children:o.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[o.jsxs("div",{className:"relative flex-1 min-w-[250px] max-w-md",children:[o.jsx(Ws,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground
4067/60"}),o.jsx(Ne,{placeholder:"Rechercher par email (min. 3 car.)...",value:b,onChange:ee=>w(ee.target.value),className:"pl-10"})]}),!s&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(d1,{className:"h-4 w-4 text-muted-foreground/60"}),o.jsxs(_t,{value:j,onValueChange:O,children:[o.jsx(St,{className:"w-[200px]",children:o.jsx(Et,{})}),o.jsx(kt,{children:Object.entries(wae).map(([ee,K])=>o.jsx(Ke,{value:ee,children:K},ee))})]})]}),!s&&P.length>0&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Rn,{className:"h-4 w-4 text-muted-foreground/60"}),o.jsxs(_t,{value:N,onValueChange:Y,children:[o.jsx(St,{className:"w-[220px]",children:o.jsx(Et,{placeholder:"Tous les départements"})}),o.jsxs(kt,{className:"max-h-[300px]",children:[o.jsx(Ke,{value:"all",children:"Tous les départements"}),P.map(ee=>o.jsxs(Ke,{value:ee.code,children:[ee.code," - ",ee.nom]},ee.code))]})]})]}),!x&&g!==void 0&&o.jsxs("div",{className:"text-sm text-muted-foreground",children:[g," utilisateur",g>1?"s":"",f&&g>=aI&&` (max ${aI})`]})]})})}),o.jsx(ke,{children:o.jsx(Pe,{className:"pt-6",children:x?o.jsxs("div",{className:"text-center py-12",children:[o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-primary/20 border-t-primary mx-auto"}),o.jsx("p",{className:"text-muted-foreground mt-4",children:"Chargement..."})]}):i.length===0?o.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[o.jsx(cr,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground/40"}),o.jsx("p",{children:"Aucun utilisateur trouvé"}),(j!=="all"||N!=="all"||b)&&o.jsx("p",{className:"text-sm mt-2",children:"Essayez de modifier vos critères de recherche"})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"overflow-x-auto",children:o.jsxs(Ya,{children:[o.jsx(Qa,{children:o.jsxs(Fr,{children:[o.jsx(dt,{children:"Utilisateur"}),o.jsx(dt,{children:"Département"}),o.jsx(dt,{children:"Rôles"}),o.jsx(dt,{className:"w-12"})]})}),o.jsx(Xa,{children:i.map(ee=>o.jsx(jae,{user:ee,getRoleBadges:U},ee.id))})]})}),!f&&o.jsx("div",{className:"flex items-center justify-end mt-4 pt-4 border-t",children:o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs("div",{className:"text-sm text-muted-foreground",children:["Page ",I+1,g!==void 0&&o.jsxs(o.Fragment,{children:[" / ",Math.ceil(g/iI)]})]}),o.jsxs("div",{className:"flex gap-1",children:[o.jsx(Z,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:re,disabled:I===0,title:"Page précédente",children:o.jsx(vc,{className:"h-4 w-4"})}),o.jsx(Z,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:q,disabled:!l,title:"Page suivante",children:o.jsx(nr,{className:"h-4 w-4"})})]})]})})]})})}),o.jsx(vae,{open:T,onOpenChange:V,onUserCreated:G}),o.jsx(yae,{open:$,onOpenChange:H})]})}function jae({user:t,getRoleBadges:e}){const n=qt();return o.jsxs(Fr,{className:"hover:bg-muted cursor-pointer",onClick:()=>n(mt.user(t.id)),children:[o.jsx(ht,{children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-muted flex items-center justify-center",children:t.isSuperAdmin?o.jsx(rc,{className:"h-5 w-5 text-amber-500"}):o.jsx(cr,{className:"h-5 w-5 text-muted-foreground/60"})}),o.jsxs("div",{children:[o.jsx("div",{className:"font-medium",children:bn(t)}),o.jsx("div",{className:"text-sm text-muted-foreground",children:kx(t)})]})]})}),o.jsx(ht,{children:o.jsxs("div",{className:"text-sm",children:[t.departmentLabel||"-",t.departmentCode?o.jsxs("span",{className:"text-muted-foreground/60 ml-1",children:["(",t.departmentCode,")"]}):null]})}),o.jsx(ht,{children:o.jsx("div",{className:"flex flex-wrap gap-1",children:e(t)})}),o.jsx(ht,{children:o.jsx(Fa,{to:mt.user(t.id),children:o.jsx(Z,{variant:"ghost",size:"icon",children:o.jsx(nr,{className:"h-4 w-4"})})})})]})}function lI(){const{userId:t}=Ys(),e=qt(),n=Ft(),{user:r,isSuperAdmin:s}=nn(),i=r?Bs(r,"chambre_agriculture")&&!s:!1,[a,l]=u.useState(null),[c,d]=u.useState(!0),[h,f]=u.useState(!1),[p,g]=u.useState(""),[v,x]=u.useState({}),[y,b]=u.useState(""),[w,j]=u.useState(""),[E,P]=u.useState(""),[A,N]=u.useState(""),[_,k]=u.useState(""),[L,I]=u.useState([]),[S,T]=u.useState({}),[V,$]=u.useState([]),[H,W]=u.useState(!1),[D,F]=u.useState(!1),[O,Y]=u.useState(!1),[G,q]=u.useState(null),[re,U]=u.useState([]),[ee,K]=u.useState(!0),[ue,be]=u.useState(!1),[le,B]=u.useState(""),[Q,ve]=u.useState(!1),[Ae,he]=u.useState(null),[J,je]=u.useState(null),[Ve,Ye]=u.useState(!0),[Jt,Ue]=u.useState(!1),[rn,vt]=u.useState(""),[me,ot]=u.useState(!1);u.useEffect(()=>{As().then(I)},[]);const Se=u.useCallback(async()=>{var se;if(t){d(!0),g("");try{const Re=await qs.getUserById(t);if(Re){if(l(Re),b(Re.pseudo||""),P(Re.firstName||""),N(Re.lastName||""),j(Re.phoneNumber||""),k(((se=Re.departmentCode)==null?void 0:se.toString())||""),$(Re.roles||[]),W(Re.isSuperAdmin||!1),T(Re.companyRoles||{}),Re.companyRoles&&Object.keys(Re.companyRoles).length>0){const ae=Object.keys(Re.companyRoles),et={};await Promise.all(ae.map(async xt=>
4067{try{const zt=await Ot.getCompanyById(xt);zt&&(et[xt]=zt.name)}catch(zt){console.error(`Error fetching company ${xt}:`,zt)}})),x(et)}}else g("Utilisateur non trouvé")}catch(Re){console.error("Error loading user:",Re),g("Erreur lors du chargement de l'utilisateur")}finally{d(!1)}}},[t]),Te=u.useCallback(async()=>{if(t){K(!0);try{const se=await Pl.getUserPremium(t);Y(se.isPremium),q(se.premiumEndDate),U(se.sources)}catch(se){console.error("Error loading premium status:",se)}finally{K(!1)}}},[t]),He=u.useCallback(async()=>{if(t){Ye(!0);try{const se=await Pl.getProtectionCultures(t);ve(se.hasEntitlement),he(se.source),je(se.expiresDate)}catch(se){console.error("Error loading protectionCultures status:",se)}finally{Ye(!1)}}},[t]);u.useEffect(()=>{Se(),i||(Te(),He())},[Se,Te,He,i]);const Ut=async()=>{if(a){f(!0),g("");try{const se=L.find(ae=>ae.code===_),Re=s?{firstName:E.trim(),lastName:A.trim()}:{};await qs.updateUser(a.id,{pseudo:y,...Re,phoneNumber:w,departmentCode:_?parseInt(_):void 0,departmentLabel:se==null?void 0:se.nom,roles:V,isSuperAdmin:H,companyRoles:S}),l({...a,pseudo:y,...Re,phoneNumber:w,departmentCode:_?parseInt(_):a.departmentCode,departmentLabel:(se==null?void 0:se.nom)||a.departmentLabel,roles:V,isSuperAdmin:H,companyRoles:S}),n.success("Utilisateur mis à jour")}catch(se){console.error("Error updating user:",se),g(se.message||"Erreur lors de la sauvegarde"),n.error("Erreur lors de la sauvegarde")}finally{f(!1)}}},cn=se=>{$(Re=>Re.includes(se)?Re.filter(ae=>ae!==se):[...Re,se])},xn=(se,Re)=>{T(ae=>({...ae,[se]:Re}))},un=async()=>{if(!(!t||!le))try{await Pl.grantUserPremium(t,le),await Te(),n.success(O?"Premium prolongé":"Premium activé"),be(!1),B("")}catch(se){console.error("Error updating premium:",se),n.error(se.message||"Erreur lors de la mise à jour du premium")}},Yt=async()=>{if(!(!t||!rn)){ot(!0);try{await Pl.updateProtectionCultures(t,rn),await He(),n.success(Q?"Protection des cultures prolongée":"Protection des cultures activée"),Ue(!1),vt("")}catch(se){console.error("Error updating protectionCultures:",se),n.error(se.message||"Erreur lors de la mise à jour")}finally{ot(!1)}}},st=async()=>{if(t)try{await Pl.updateProtectionCultures(t,null),await He(),n.success("Protection des cultures désactivée")}catch(se){console.error("Error revoking protectionCultures:",se),n.error(se.message||"Erreur lors de la désactivation")}},de=async()=>{if(t){F(!0);try{await qs.deleteUser(t),n.success("Utilisateur supprimé"),e(i?xe.farmers:xe.users)}catch(se){console.error("Error deleting user:",se),n.error(se.message||"Erreur lors de la suppression")}finally{F(!1)}}},Qe=(()=>{if(H)return Object.keys(ab);const se=new Set;return V.forEach(Re=>{var ae;(ae=CD[Re])==null||ae.forEach(et=>se.add(et))}),Array.from(se)})(),It=()=>{var oe;if(!a)return!1;const se=y!==(a.pseudo||""),Re=E!==(a.firstName||"")||A!==(a.lastName||""),ae=w!==(a.phoneNumber||""),et=_!==(((oe=a.departmentCode)==null?void 0:oe.toString())||""),xt=JSON.stringify(V.sort())!==JSON.stringify((a.roles||[]).sort()),zt=H!==(a.isSuperAdmin||!1),$e=JSON.stringify(S)!==JSON.stringify(a.companyRoles||{});return se||Re||ae||et||xt||zt||$e};return c?o.jsx(Jne,{}):a?o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx("div",{className:"bg-card border-b border-border px-4 md:px-8 py-4",children:o.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 max-w-5xl mx-auto",children:[o.jsxs("div",{className:"flex items-center gap-3 md:gap-4",children:[o.jsxs(Z,{variant:"outline",onClick:()=>e(i?xe.farmers:xe.users),children:[o.jsx(Nr,{className:"w-4 h-4 mr-2"}),"Retour"]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-muted flex items-center justify-center",children:a.isSuperAdmin?o.jsx(mo,{className:"h-5 w-5 text-amber-500"}):o.jsx(po,{className:"h-5 w-5 text-muted-foreground"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-xl font-semibold text-foreground font-heading",children:bn(a)}),o.jsx("p",{className:"text-sm text-muted-foreground",children:kx(a)})]})]})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(Z,{variant:"outline",onClick:Se,disabled:h,children:[o.jsx(ft,{className:`w-4 h-4 mr-2 ${h?"animate-spin":""}`}),"Actualiser"]}),o.jsxs(Z,{onClick:Ut,disabled:h||!It(),children:[h?o.jsx(ft,{className:"w-4 h-4 mr-2 animate-spin"}):o.jsx(xc,{className:"w-4 h-4 mr-2"}),"Enregistrer"]})]})]})}),o.jsxs("div",{className:"max-w-5xl mx-auto p-6 space-y-6",children:[p&&o.jsxs(yr,{variant:"destructive",children:[o.jsx(an,{className:"h-4 w-4"}),o.jsx(wr,{children:p})]}),o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[o.jsx(po,{className:"w-5 h-5 text-muted-foreground"}),o.jsx("h2",{className:"text-lg font-semibold",children:"Informations"})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"pseudo",children:"Pseudo"}),o.jsx(Ne,{id:"pseudo",value:y,onChange:se=>b(se.target.value),placeholder:"Pseudo de l'utilisateur"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"firstName",children:"Prénom"}),o.jsx(Ne,{id:"firstName",value:E,onChange:se=>P(se.target.value),disabled:!s,className:s?"":"bg-muted",placeholder:"Non renseigné"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"lastName",children:"Nom"}),o.jsx(Ne,{id:"lastName",value:A,onChange:se=>N(se.target.value),disabled:!s,className:s?"":"bg-muted",placeholder:"Non renseigné"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ne,{className:"flex items-center gap-1",children:[o.jsx(rs,{className:"h-3 w-3"})," Email"]}),o.jsx(Ne,{value:a.email,disabled:!0,className:"bg-muted"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ne,{htmlFor:"phone",className:"flex items-center gap-1",children:[o.jsx(rm,{className:"h-3 w-3"})," Téléphone"]}),o.jsx(Ne,{id:"phone",value:w,onChange:se=>j(se.target.value),placeholder:"06 12 34 56 78"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ne,{className:"flex items-center gap-1",children:[o.jsx(Rn,{className:"h-3 w-3"})," Département"]}),o.jsxs(_t,{value:_,onValueChange:k,children:[o.jsx(St,{children:o.jsx(Et,{placeholder:"Sélectionner"})}),o.jsx(kt,{className:"max-h-[300px]",children:L.map(se=>o.jsxs(Ke,{value:se.code,children:[se.code," - ",se.nom]},se.code))})]})]}),a.createdAt&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ne,{className:"flex items-center gap-1",children:[o.jsx(Da,{className:"h-3 w-3"})," Inscrit le"]}),o.jsx(Ne,{value:new Date(a.createdAt.seconds*1e3).toLocaleDateString("fr-FR"),disabled:!0,className:"bg-muted"})]}),!i&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ne,{className:"flex items-center gap-1",children:[o.jsx(Gc,{
4067className:"h-3 w-3"})," Statut Premium personnel"]}),ee?o.jsx("div",{className:"h-9 flex items-center",children:o.jsx(ft,{className:"h-4 w-4 animate-spin text-muted-foreground/60"})}):o.jsx("div",{className:"flex items-center gap-2",children:O?o.jsxs(o.Fragment,{children:[o.jsxs(We,{className:"bg-amber-500/15 text-amber-400 hover:bg-amber-500/15",children:[o.jsx(Gc,{className:"h-3 w-3 mr-1"}),"Premium",G&&` jusqu'au ${new Date(G).toLocaleDateString("fr-FR")}`]}),re.length>0&&o.jsxs("span",{className:"text-xs text-muted-foreground",title:re.map(se=>`${se.kind} : ${se.detail}`).join(` 4068`),children:["(",re.map(se=>se.detail).join(" · "),")"]}),o.jsxs(Z,{size:"sm",variant:"outline",onClick:()=>be(!0),children:[o.jsx(Gc,{className:"h-3 w-3 mr-1"}),"Prolonger"]})]}):o.jsxs(Z,{size:"sm",variant:"outline",onClick:()=>be(!0),children:[o.jsx(Gc,{className:"h-3 w-3 mr-1"}),"Activer Premium"]})}),o.jsx(rr,{open:ue,onOpenChange:be,children:o.jsxs(sr,{children:[o.jsxs(or,{children:[o.jsx(Gn,{children:O?"Prolonger le Premium":"Activer le Premium"}),o.jsx(ir,{children:"Définissez une date de fin pour le statut premium de cet utilisateur."})]}),o.jsxs("div",{className:"py-4",children:[o.jsx(ne,{htmlFor:"premium-date",children:"Date de fin du premium"}),o.jsx(Ne,{id:"premium-date",type:"date",value:le,onChange:se=>B(se.target.value),className:"mt-2",min:new Date().toISOString().split("T")[0]})]}),o.jsxs(ks,{children:[o.jsx(Z,{variant:"outline",onClick:()=>be(!1),children:"Annuler"}
4068),o.jsxs(Z,{onClick:un,disabled:!le,children:[o.jsx(Gc,{className:"h-4 w-4 mr-2"}),O?"Prolonger":"Activer"]})]})]})})]})]})]})}),!i&&o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[o.jsx(qn,{className:"w-5 h-5 text-muted-foreground"}),o.jsx("h2",{className:"text-lg font-semibold",children:"Sociétés de chasse"}),Object.keys(S).length>0&&o.jsx(We,{variant:"secondary",children:Object.keys(S).length})]}),Object.keys(S).length>0?o.jsx("div",{className:"border rounded-lg overflow-hidden",children:o.jsxs("table",{className:"w-full",children:[o.jsx("thead",{className:"bg-muted border-b",children:o.jsxs("tr",{children:[o.jsx("th",{className:"text-left text-sm font-medium text-muted-foreground px-4 py-3",children:"Société"}),o.jsx("th",{className:"text-left text-sm font-medium text-muted-foreground px-4 py-3 w-48",children:"Rôle"}),o.jsx("th",{className:"w-10"})]})}),o.jsx("tbody",{className:"divide-y",children:Object.entries(S).map(([se,Re])=>o.jsxs("tr",{className:"hover:bg-muted cursor-pointer transition-colors",onClick:()=>e(mt.company(se)),children:[o.jsx("td",{className:"px-4 py-3",children:o.jsx("span",{className:"font-medium text-foreground",children:v[se]||se})}),o.jsx("td",{className:"px-4 py-3",onClick:ae=>ae.stopPropagation(),children:o.jsxs(_t,{value:Re,onValueChange:ae=>xn(se,ae),children:[o.jsx(St,{className:"w-full",children:o.jsx(Et,{})}),o.jsxs(kt,{children:[o.jsx(Ke,{value:"admin",children:"Administrateur"}),o.jsx(Ke,{value:"writer",children:"Contributeur"}),o.jsx(Ke,{value:"reader",children:"Lecteur"})]})]})}),o.jsx("td",{className:"px-4 py-3 text-muted-foreground/60",children:o.jsx(nr,{className:"h-5 w-5"})})]},se))})]})}):o.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[o.jsx(qn,{className:"h-10 w-10 mx-auto mb-3 text-muted-foreground/40"}),o.jsx("p",{children:"Aucune société"})]})]})}),o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[o.jsx(rc,{className:"w-5 h-5 text-muted-foreground"}),o.jsx("h2",{className:"text-lg font-semibold",children:"Rôles"})]}),o.jsx("p",{className:"text-sm text-muted-foreground mb-6",children:i?"Gérer le rôle agriculteur pour cet utilisateur":"Sélectionnez les rôles à attribuer à cet utilisateur"}),i?o.jsx("div",{className:`p-4 rounded-lg border-2 cursor-pointer transition-all ${V.includes("farmer")?"border-green-500 bg-green-500/10":"border-border hover:border-border"}`,onClick:()=>cn("farmer"),children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"font-medium",children:bu.farmer}),o.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:zy.farmer})]}),o.jsx("div",{className:`w-6 h-6 rounded-full border-2 flex items-center justify-center flex-shrink-0 ${V.includes("farmer")?"border-green-500 bg-green-500":"border-border"}`,children:V.includes("farmer")&&o.jsx(Xn,{className:"h-4 w-4 text-white"})})]})}):o.jsxs("div",{className:"space-y-6",children:[o.jsx("div",{className:`p-4 rounded-lg border-2 cursor-pointer transition-all ${H?"border-amber-500 bg-amber-500/10":"border-border hover:border-border"}`,onClick:()=>W(!H),children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(mo,{className:`h-5 w-5 ${H?"text-amber-500":"text-muted-foreground/60"}`}),o.jsxs("div",{children:[o.jsx("p",{className:"font-medium",children:"Super Admin"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Accès total à toutes les fonctionnalités"})]})]}),o.jsx("div",{className:`w-6 h-6 rounded-full border-2 flex items-center justify-center ${H?"border-amber-500 bg-amber-500":"border-border"}`,children:H&&o.jsx(Xn,{className:"h-4 w-4 text-white"})})]})}),o.jsx(Hn,{}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-medium text-foreground/80 mb-2",children:"Rôles organisationnels"}),o.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Organisations qui gèrent les acteurs d'un département"}),o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:VW.map(se=>{const Re=V.includes(se);return o.jsx("div",{className:`p-4 rounded-lg border-2 cursor-pointer transition-all ${Re?"border-purple-500 bg-purple-50":"border-border hover:border-border"}`,onClick:()=>cn(se),children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"font-medium",children:bu[se]}),o.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:zy[se]})]}),o.jsx("div",{className:`w-6 h-6 rounded-full border-2 flex items-center justify-center flex-shrink-0 ${Re?"border-purple-500 bg-purple-500":"border-border"}`,children:Re&&o.jsx(Xn,{className:"h-4 w-4 text-white"})})]})},se)})})]}),o.jsx(Hn,{}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-medium text-foreground
4068/80 mb-2",children:"Rôles de terrain"}),o.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Acteurs qui interviennent sur le terrain"}),o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:UW.map(se=>{const Re=V.includes(se);return o.jsx("div",{className:`p-4 rounded-lg border-2 cursor-pointer transition-all ${Re?"border-green-500 bg-green-500/10":"border-border hover:border-border"}`,onClick:()=>cn(se),children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"font-medium",children:bu[se]}),o.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:zy[se]})]}),o.jsx("div",{className:`w-6 h-6 rounded-full border-2 flex items-center justify-center flex-shrink-0 ${Re?"border-green-500 bg-green-500":"border-border"}`,children:Re&&o.jsx(Xn,{className:"h-4 w-4 text-white"})})]})},se)})})]})]})]})}),!i&&o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[o.jsx(Xn,{className:"w-5 h-5 text-muted-foreground"}),o.jsx("h2",{className:"text-lg font-semibold",children:"Permissions actives"}),o.jsx(We,{variant:"secondary",children:Qe.length})]}),o.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Permissions accordées par les rôles sélectionnés"}),H?o.jsx("div",{className:"p-4 bg-amber-500/10 rounded-lg border border-amber-500/20",children:o.jsxs("p",{className:"text-amber-400 font-medium flex items-center gap-2",children:[o.jsx(mo,{className:"h-4 w-4"}),"Toutes les permissions (Super Admin)"]})}):Qe.length>0?o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:Qe.map(se=>o.jsxs("div",{className:"flex items-center gap-2 p-2 bg-green-500/10 rounded text-sm",children:[o.jsx(Xn,{className:"h-4 w-4 text-green-600 flex-shrink-0"}),o.jsx("span",{className:"text-green-800",children:ab[se]})]},se))}):o.jsxs("div",{className:"text-center py-6 text-muted-foreground",children:[o.jsx(rc,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/40"}),o.jsx("p",{className:"text-sm",children:"Permissions de base uniquement"})]}),o.jsx(Hn,{className:"my-4"}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ne,{className:"flex items-center gap-1",children:[o.jsx(kl,{className:"h-3 w-3"})," Protection des cultures"]}),Ve?o.jsx("div",{className:"h-9 flex items-center",children:o.jsx(ft,{className:"h-4 w-4 animate-spin text-muted-foreground/60"})}):o.jsx("div",{className:"flex items-center gap-2",children:Q?o.jsxs(o.Fragment,{children:[o.jsxs(We,{className:"bg-green-500/15 text-green-800 hover:bg-green-500/15",children:[o.jsx(kl,{className:"h-3 w-3 mr-1"}),"Actif",J&&` jusqu'au ${new Date(J).toLocaleDateString("fr-FR")}`]}),Ae==="company.admin"&&o.jsx("span",{className:"text-xs text-muted-foreground",children:"(via société)"}),o.jsxs(Z,{size:"sm",variant:"outline",onClick:()=>Ue(!0),children:[o.jsx(kl,{className:"h-3 w-3 mr-1"}),"Prolonger"]}),o.jsx(Z,{size:"sm",variant:"outline",className:"text-red-600 hover:text-red-700",onClick:st,children:"Révoquer"})]}):o.jsxs(Z,{size:"sm",variant:"outline",onClick:()=>Ue(!0),children:[o.jsx(kl,{className:"h-3 w-3 mr-1"}),"Activer"]})}),o.jsx(rr,{open:Jt,onOpenChange:Ue,children:o.jsxs(sr,{children:[o.jsxs(or,{children:[o.jsx(Gn,{children:Q?"Prolonger Protection des cultures":"Activer Protection des cultures"}),o.jsx(ir,{children:"Définissez une date de fin pour l'entitlement protectionCultures de cet utilisateur."})]}),o.jsxs("div",{className:"py-4",children:[o.jsx(ne,{htmlFor:"protection-cultures-date",children:"Date de fin"}),o.jsx(Ne,{id:"protection-cultures-date",type:"date",value:rn,onChange:se=>vt(se.target.value),className:"mt-2",min:new Date().toISOString().split("T")[0]})]}),o.jsxs(ks,{children:[o.jsx(Z,{variant:"outline",onClick:()=>Ue(!1),children:"Annuler"}),o.jsxs(Z,{onClick:Yt,disabled:!rn||me,children:[me?o.jsx(ft,{className:"h-4 w-4 mr-2 animate-spin"}):o.jsx(kl,{className:"h-4 w-4 mr-2"}),me?"En cours...":Q?"Prolonger":"Activer"]})]})]})})]})]})}),s&&o.jsx(ke,{className:"border-red-500/20",children:o.jsxs(Pe,{className:"p-6",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[o.jsx(an,{className:"w-5 h-5 text-red-600"}),o.jsx("h2",{className:"text-lg font-semibold text-red-600",children:"Zone de danger"})]}),o.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"La suppression est irréversible. Le compte sera supprimé de Firebase Auth et de Firestore."}),o.jsxs(Dn,{children:[o.jsx(cm,{asChild:!0,children:o.jsxs(Z,{variant:"outline",className:"text-red-600 hover:text-red-700 hover:bg-red-500/10",children:[o.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Supprimer cet utilisateur"]})}),o.jsxs(Ln,{children:[o.jsxs(Mn,{children:[o.jsx(Fn,{children:"Supprimer cet utilisateur ?"}),o.jsxs(zn,{children:["Cette action est irréversible. Le compte de ",o.jsx("strong",{children:bn(a)})," sera définitivement supprimé (authentification et données)."]})]}),o.jsxs(On,{children:[o.jsx(Vn,{children:"Annuler"}),o.jsxs($n,{onClick:de,className:"bg-red-600 hover:bg-red-700",disabled:D,children:[D?o.jsx(ft,{className:"h-4 w-4 mr-2 animate-spin"}):o.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Supprimer"]})]})]})]})]})})]})]}):o.jsxs("div",{className:"p-6",children:[o.jsxs(yr,{variant:"destructive",children:[o.jsx(an,{className:"h-4 w-4"}),o.jsx(wr,{children:p||"Utilisateur non trouvé"})]}),o.jsxs(Z,{onClick:()=>e(i?xe.farmers:xe.users),className:"mt-4",children:[o.jsx(Nr,{className:"w-4 h-4 mr-2"}),"Retour à la liste"]})]})}var oN="Progress",iN=100,[Cae]=Rs(oN),[Nae,_ae]=Cae(oN),y3=u.forwardRef((t,e)=>{const{__scopeProgress:n,value:r=null,max:s,getValueLabel:i=Eae,...a}=t;(s||s===0)&&!cI(s)&&console.error(Sae(`${s}`,"Progress"));const l=cI(s)?s:iN;r!==null&&!uI(r,l)&&console.error(kae(`${r}`,"Progress"));const c=uI(r,l)?r:null,d=vv(c)?i(c,l):void 0;return o.jsx(Nae,{scope:n,value:c,max:l,children:o.jsx(Je.div,{"aria-valuemax":l,"aria-valuemin":0,"aria-valuenow":vv(c)?c:void 0,"aria-valuetext":d,role:"progressbar","data-state":j3(c,l),"data-value":c??void 0,"data-max":l,...a,ref:e})})});y3.displayName=oN;var w3="ProgressIndicator",b3=u.forwardRef((t,e)=>{const{__scopeProgress:n,...r}=t,s=_ae(w3,n);return o.jsx(Je.div,{"data-state":j3(s.value,s.max),"data-value":s.value??void 0,"data-max":s.max,...r,ref:e})});b3.displayName=w3;function Eae(t,e){return`${Math.round(t/e*100)}%`}function j3(t,e){return t==null?"indeterminate":t===e?"complete":"loading"}function vv(t){return typeof t=="number"}function cI(t){return vv(t)&&!isNaN(t)&&t>0}function uI(t,e){return vv(t)&&!isNaN(t)&&t<=e&&t>=0}function Sae(t,e){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${e}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${iN}\`.`}function kae(t,e){return`Invalid prop \`value\` of value \`${t}\` supplied to \`${e}\`. The \`value\` prop must be: 4069 - a positive number 4070 - less than the value passed to \`max\` (or ${iN} if no \`max\` prop is set) 4071 - \`null\` or \`undefined\` if the progress is indeterminate. 4072 4073Defaulting to \`null\`.`}var Pae=y3,Iae=b3;function Tae({className:t,value:e,...n}){return o.jsx(Pae,{"data-slot":"progress",className:Oe("bg-primary/20 relative h-2 w-full overflow-hidden rounded-full",t),...n,children:o.jsx(Iae,{"data-slot":"progress-indicator",className:"bg-primary h-full w-full flex-1 transition-all",style:{transform:`translateX(-${100-(e||0)}%)`}})})}const dI=200,hI=(t,e)=>{const n=[];for(let r=0;r<t.length;r+=e)n.push(t.slice(r,r+e));return n},eh={async list(t){return(await pe(ge,"getPremiumEmails")({departmentCode:t})).data},async importEntries(t,e,n){const r=pe(ge,"upsertPremiumEmails"),s={total:0,companiesGranted:0,pending:0,duplicates:0,invalid:[]};let i=0;for(const a of hI(t,dI)){const c=(await r({entries:a,departmentCode:e})).data;s.total+=c.total,s.companiesGranted+=c.companiesGranted,s.pending+=c.pending,s.duplicates+=c.duplicates,s.invalid.push(...c.invalid||[]),i+=a.length,n==null||n(i,t.length)}return s},async setCompaniesCount(t,e){var s;return((s=(await pe(ge,"updatePremiumEmail")({email:t,companiesCount:e})).data)==null?void 0:s.companiesGranted)||0},async accountCompanies(t){var r;return((r=(await pe(ge,"getUserCompanies")({userId:t})).data)==null?void 0:r.companies)||[]},async remove(t){var r;const e=pe(ge,"removePremiumEmails");let n=0;for(const s of hI(t,dI)){const i=await e({emails:s});n+=((r=i.data)==null?void 0:r.removed)||0}return n}},Aae={admin:"Admin",writer:"Référent",reader:"Classique"},Rae=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Dae=t=>{const e=t.split(/[\s,;
4073]+/).filter(Boolean),n=[],r=new Set;let s=0;for(const i of e){const a=i.toLowerCase().replace(/^["']|["']$/g,"");if(!Rae.test(a)){s++;continue}r.has(a)||(r.add(a),n.push(a))}return{emails:n,ignored:s}};function Lae(){const t=Ft(),{user:e,isSuperAdmin:n}=nn(),[r,s]=u.useState(n?null:(e==null?void 0:e.departmentCode)??null),[i,a]=u.useState([]),[l,c]=u.useState(""),[d,h]=u.useState(null),[f,p]=u.useState(0),[g,v]=u.useState(!1),[x,y]=u.useState(0),[b,w]=u.useState(null),j=u.useRef(null),[E,P]=u.useState([]),[A,N]=u.useState(!1),[_,k]=u.useState(null),[L,I]=u.useState(!0),[S,T]=u.useState(!1),[V,$]=u.useState(""),[H,W]=u.useState(null),[D,F]=u.useState(null),[O,Y]=u.useState(null),[G,q]=u.useState(null),re=ei(V,300);u.useEffect(()=>{n&&As().then(a)},[n]);const U=u.useMemo(()=>{const J=new Map;for(const je of i){const Ve=Number(je.code.replace(/[AB]$/,"0"))||Number(je.code);!Ve||J.has(Ve)||J.set(Ve,`${je.code} - ${je.nom}`)}return[...J.entries()].sort(([je],[Ve])=>je-Ve)},[i]),ee=u.useCallback(async()=>{if(r===null){I(!1);return}I(!0),T(!1);try{const J=await eh.list(r);P(J.rows),N(J.protectionCulturesIncluded),k(J.contractEndDate)}catch(J){(J==null?void 0:J.code)==="functions/failed-precondition"||/contrat/i.test((J==null?void 0:J.message)||"")?(T(!0),P([])):t.error((J==null?void 0:J.message)||"Erreur lors du chargement de la liste")}finally{I(!1)}},[r,t]);u.useEffect(()=>{ee()},[ee]);const K=u.useMemo(()=>{const J=re.trim().toLowerCase();return J?E.filter(je=>je.email.includes(J)):E},[E,re]),ue=J=>{const{emails:je,ignored:Ve}=Dae(J);if(je.length===0){t.error("Aucun email valide trouvé");return}h(je.map(Ye=>({email:Ye,companiesCount:1}))),p(Ve),w(null)},be=async J=>{const je=await J.text();c(je),ue(je)},le=(J,je)=>h(Ve=>(Ve==null?void 0:Ve.map(Ye=>Ye.email===J?{...Ye,companiesCount:je}:Ye))??null),B=async()=>{if(!(!d||d.length===0||r===null)){v(!0),y(0);try{const J=await eh.importEntries(d,r,(je,Ve)=>y(Math.round(je/Ve*100)));w(J),h(null),c(""),t.success(`${J.companiesGranted} société${J.companiesGranted>1?"s":""} passée${J.companiesGranted>1?"s":""} premium, ${J.pending} email${J.pending>1?"s":""} en attente`),await ee()}catch(J){t.error((J==null?void 0:J.message)||"Erreur lors de l'import")}finally{v(!1)}}},Q=async(J,je)=>{if(!(je<1||je===J.companiesCount)){W(J.email);try{const Ve=await eh.setCompaniesCount(J.email,je);Ve>0?(t.success(`${Ve} société${Ve>1?"s":""} passée${Ve>1?"s":""} premium`),await ee()):P(Ye=>Ye.map(Jt=>Jt.email===J.email?{...Jt,companiesCount:je}:Jt))}catch(Ve){t.error((Ve==null?void 0:Ve.message)||"Erreur lors de la mise à jour")}finally{W(null)}}},ve=async()=>{if(!D)return;const J=D;F(null);try{await eh.remove([J]),P(je=>je.filter(Ve=>Ve.email!==J)),t.success("Email retiré de la liste")}catch(je){t.error((je==null?void 0:je.message)||"Erreur lors du retrait")}},Ae=J=>J.servedCompanyIds.length>=J.companiesCount?o.jsxs(We,{variant:"outline",className:"gap-1 bg-green-500/10 text-green-600 border-green-500/20",children:[o.jsx(qn,{className:"h-3 w-3"}),"Servi"]}):o.jsxs(We,{variant:"secondary",className:"gap-1",children:[o.jsx(hd,{className:"h-3 w-3"}),J.appliedUserId?"Attend une société":"Attend un compte"]}),he=async J=>{if(J.appliedUserId){Y(J),q(null);try{q(await eh.accountCompanies(J.appliedUserId))}catch(je){t.error((je==null?void 0:je.message)||"Impossible de charger les sociétés de ce compte"),Y(null)}}};return o.jsxs("div",{className:"p-4 md:p-8 space-y-5 md:space-y-6 max-w-[1400px]",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-foreground font-heading",children:"Accès premium"}),o.jsxs("p",{className:"text-muted-foreground mt-1",children:["Chaque email fait passer premium les sociétés de la personne, dès maintenant ou quand elle les crée,"," ",_?`jusqu'à l'échéance du contrat (${new Date(_).toLocaleDateString("fr-FR")})`:"jusqu'à la fin du contrat",". Prolonger le contrat prolonge les sociétés."]})]}),n&&o.jsxs(_t,{value:r!==null?String(r):void 0,onValueChange:J=>s(Number(J)),children:[o.jsx(St,{className:"w-64",children:o.jsx(Et,{placeholder:"Choisir un département"})}),o.jsx(kt,{children:U.map(([J,je])=>o.jsx(Ke,{value:String(J),children:je},J))})]})]}),r===null?o.jsx(ke,{children:o.jsxs(Pe,{className:"pt-6 text-center py-12 text-muted-foreground",children:[o.jsx(mo,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground
4073/40"}),o.jsx("p",{children:"Choisissez un département pour gérer sa liste."})]})}):S?o.jsx(ke,{children:o.jsxs(Pe,{className:"pt-6 text-center py-12 text-muted-foreground",children:[o.jsx(FK,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground/40"}),o.jsx("p",{className:"font-medium text-foreground",children:"Pas de contrat premium actif"}),o.jsxs("p",{className:"text-sm mt-2",children:["Ce département n'a pas de contrat : aucune distribution de premium n'est possible.",n?" Activez le contrat sur la fiche du département.":" Rapprochez-vous de Chassé & Croisé."]})]})}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[o.jsx(kl,{className:`h-4 w-4 ${A?"text-green-600":"text-muted-foreground/40"}`}),A?"Les octrois de ce département emportent le premium et la protection des cultures.":"Les octrois de ce département emportent le premium seul (option protection des cultures non souscrite)."]}),o.jsxs(ke,{children:[o.jsxs(Qt,{children:[o.jsxs(Xt,{className:"flex items-center gap-2 text-lg",children:[o.jsx(mo,{className:"h-5 w-5 text-app-yellow"}),"Distribuer le premium"]}),o.jsx(la,{children:"Collez les emails (un par ligne, ou séparés par des virgules) ou importez un CSV. Le nombre de sociétés se règle ensuite, email par email."})]}),o.jsxs(Pe,{className:"space-y-4",children:[o.jsxs("div",{className:"grid gap-4 md:grid-cols-[1fr_240px]",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"emails",children:"Emails"}),o.jsx(bc,{id:"emails",rows:6,placeholder:`[email protected] 4074[email protected]`,value:l,onChange:J=>c(J.target.value),disabled:g})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{className:"invisible md:visible",children:" "}),o.jsx("input",{ref:j,type:"file",accept:".csv,.txt",className:"hidden",onChange:J=>{var Ve;const je=(Ve=J.target.files)==null?void 0:Ve[0];je&&be(je),J.target.value=""}}),o.jsxs(Z,{type:"button",variant:"outline",className:"w-full",onClick:()=>{var J;return(J=j.current)==null?void 0:J.click()},disabled:g,children:[o.jsx(No,{className:"h-4 w-4 mr-2"}),"Importer un CSV"]}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Les colonnes autres que l'email sont ignorées."})]})]}),!d&&o.jsx(Z,{type:"button",onClick:()=>ue(l),disabled:!l.trim()||g,children:"Préparer la liste"}),d&&o.jsxs("div",{className:"space-y-3 rounded-lg border p-3",children:[o.jsxs("div",{className:"text-sm",children:[o.jsxs("span",{className:"font-medium",children:[d.length," email",d.length>1?"s":""]}),f>0&&o.jsxs("span",{className:"text-muted-foreground",children:[" · ",f," entrée(s) ignorée(s)"]})]}),o.jsx("div",{className:"max-h-72 overflow-y-auto rounded-md border",children:o.jsxs(Ya,{children:[o.jsx(Qa,{children:o.jsxs(Fr,{children:[o.jsx(dt,{children:"Email"}),o.jsx(dt,{className:"w-40",children:"Sociétés"})]})}),o.jsx(Xa,{children:d.map(J=>o.jsxs(Fr,{children:[o.jsx(ht,{className:"font-mono text-xs",children:J.email}),o.jsx(ht,{children:o.jsx(Ne,{type:"number",min:1,max:20,value:J.companiesCount??1,onChange:je=>le(J.email,Math.max(1,Number(je.target.value)||1)),className:"w-20",disabled:g})})]},J.email))})]})}),g&&o.jsx(Tae,{value:x}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(Z,{type:"button",onClick:B,disabled:g,children:g?"Distributionâ¦":`Distribuer à ${d.length} email${d.length>1?"s":""}`}),o.jsx(Z,{type:"button",variant:"ghost",onClick:()=>h(null),disabled:g,children:"Annuler"})]})]}),b&&o.jsxs("div",{className:"rounded-lg border bg-muted/40 p-3 text-sm space-y-1",children:[o.jsxs("p",{children:[o.jsx("span",{className:"font-medium",children:b.companiesGranted})," société(s) passée(s) premium immédiatement,"," ",o.jsx("span",{className:"font-medium",children:b.pending})," email(s) en attente (compte ou société à créer)."]}),b.duplicates>0&&o.jsxs("p",{className:"text-muted-foreground",children:[b.duplicates," doublon(s) fusionné(s)."]}),b.invalid.length>0&&o.jsxs("p",{className:"text-muted-foreground",children:[b.invalid.length," email(s) invalide(s) : ",b.invalid.slice(0,5).join(", "),b.invalid.length>5&&"â¦"]})]})]})]}),o.jsx(ke,{children:o.jsxs(Pe,{className:"pt-6 space-y-4",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[o.jsxs("div",{className:"relative flex-1 min-w-[250px] max-w-md",children:[o.jsx(Ws,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground
4074/60"}),o.jsx(Ne,{placeholder:"Rechercher un emailâ¦",value:V,onChange:J=>$(J.target.value),className:"pl-10"})]}),o.jsxs("div",{className:"text-sm text-muted-foreground",children:[E.length," email",E.length>1?"s":""," ·"," ",E.reduce((J,je)=>J+je.servedCompanyIds.length,0)," société(s) servie(s)"]})]}),L?o.jsxs("div",{className:"text-center py-12",children:[o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-green-600 mx-auto"}),o.jsx("p",{className:"text-muted-foreground mt-4",children:"Chargement..."})]}):K.length===0?o.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[o.jsx(mo,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground/40"}),o.jsx("p",{children:E.length===0?"Aucun email dans la liste":"Aucun résultat"})]}):o.jsx("div",{className:"overflow-x-auto",children:o.jsxs(Ya,{children:[o.jsx(Qa,{children:o.jsxs(Fr,{children:[o.jsx(dt,{children:"Email"}),o.jsx(dt,{children:"Statut"}),o.jsx(dt,{children:"Sociétés servies"}),o.jsx(dt,{className:"w-32",children:"Nombre"}),o.jsx(dt,{className:"w-12"})]})}),o.jsx(Xa,{children:K.map(J=>o.jsxs(Fr,{children:[o.jsx(ht,{className:"font-mono text-xs",children:J.appliedUserId?o.jsx("button",{type:"button",onClick:()=>he(J),title:"Voir les sociétés de ce compte",className:"underline decoration-dotted underline-offset-2 hover:text-primary",children:J.email}):J.email}),o.jsx(ht,{children:Ae(J)}),o.jsxs(ht,{className:"text-sm",children:[J.servedCompanyIds.length," / ",J.companiesCount]}),o.jsx(ht,{children:o.jsx(Ne,{type:"number",min:1,max:20,defaultValue:J.companiesCount,disabled:H===J.email,onBlur:je=>Q(J,Number(je.target.value)||1),className:"w-20"})}),o.jsx(ht,{children:o.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>F(J.email),title:"Retirer de la liste",children:o.jsx(Vt,{className:"h-4 w-4 text-destructive"})})})]},J.email))})]})}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Retirer un email arrête la distribution à venir ; les sociétés déjà passées premium le restent jusqu'à l'échéance de leur octroi."})]})})]}),o.jsx(rr,{open:O!==null,onOpenChange:J=>!J&&Y(null),children:o.jsxs(sr,{children:[o.jsxs(or,{children:[o.jsx(Gn,{className:"font-mono text-sm",children:O==null?void 0:O.email}),o.jsx(ir,{children:n?"Sociétés de ce compte.":"Sociétés de ce compte dans votre département ; celles servies par la liste sont marquées."})]}),G===null?o.jsx("p",{className:"text-sm text-muted-foreground",children:"Chargementâ¦"}):G.length===0?o.jsx("p",{className:"text-sm text-muted-foreground",children:"Aucune société."}):o.jsx("div",{className:"rounded-lg border divide-y",children:G.map(J=>o.jsxs(Fa,{to:mt.company(J.id),className:"flex items-center justify-between gap-3 p-3 text-sm hover:bg-muted",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"font-medium truncate",children:J.name}),o.jsx("p",{className:"text-xs text-muted-foreground",children:[J.city,Aae[J.role]||J.role].filter(
4074Boolean).join(" · ")})]}),(O==null?void 0:O.servedCompanyIds.includes(J.id))&&o.jsxs(We,{variant:"outline",className:"shrink-0 gap-1 bg-green-500/10 text-green-600 border-green-500/20",children:[o.jsx(mo,{className:"h-3 w-3"}),"Premium servi"]})]},J.id))})]})}),o.jsx(Dn,{open:D!==null,onOpenChange:J=>!J&&F(null),children:o.jsxs(Ln,{children:[o.jsxs(Mn,{children:[o.jsx(Fn,{children:"Retirer cet email de la liste ?"}),o.jsx(zn,{children:"La distribution à venir s'arrête pour cet email. Les sociétés déjà passées premium le restent jusqu'à l'échéance de leur octroi."})]}),o.jsxs(On,{children:[o.jsx(Vn,{children:"Annuler"}),o.jsx($n,{onClick:ve,children:"Retirer"})]})]})})]})}const Mae=t=>t?new Date(t._seconds*1e3).toLocaleDateString("fr-FR"):"Jusquâà nouvel ordre",Oae=t=>!!t&&t._seconds*1e3<=Date.now(),Ew=()=>{const t=new Date;return t.setFullYear(t.getFullYear()+1),t.toISOString().split("T")[0]};function Fae(){const t=Ft(),[e,n]=u.useState([]),[r,s]=u.useState(!0),[i,a]=u.useState(!1),[l,c]=u.useState(!1),[d,h]=u.useState(null),[f,p]=u.useState(""),[g,v]=u.useState(Ew),[x,y]=u.useState(!1),[b,w]=u.useState(!1),[j,E]=u.useState(null),P=u.useCallback(async()=>{s(!0);try{n(await ys.getAllDepartments())}catch(S){t.error((S==null?void 0:S.message)||"Erreur lors du chargement")}finally{s(!1)}},[t]);u.useEffect(()=>{P()},[P]);const A=u.useMemo(()=>e.filter(S=>S.premiumContract).sort((S,T)=>Number(S.code)-Number(T.code)),[e]),N=u.useMemo(()=>e.filter(S=>!S.premiumContract).sort((S,T)=>Number(S.code)-Number(T.code)),[e]),_=()=>{h(null),p(""),v(Ew()),y(!1),w(!1),c(!0)},k=S=>{h(S),p(S.id),v(S.premiumContractEndDate?new Date(S.premiumContractEndDate._seconds*1e3).toISOString().split("T")[0]:Ew()),y(!S.premiumContractEndDate),w(S.protectionCulturesIncluded||!1),c(!0)},L=async()=>{const S=(d==null?void 0:d.id)||f;if(S){a(!0);try{await ys.updateDepartment(S,{premiumContract:!0,protectionCulturesIncluded:b,premiumContractEndDate:x?null:new Date(g).toISOString()}),t.success(d?"Contrat mis à jour":"Contrat ajouté"),c(!1),await P()}catch(T){t.error((T==null?void 0:T.message)||"Erreur lors de l'enregistrement")}finally{a(!1)}}},I=async()=>{if(!j)return;const S=j;E(null);try{await ys.updateDepartment(S.id,{premiumContract:!1,protectionCulturesIncluded:!1,premiumContractEndDate:null}),t.success("Contrat retiré"),await P()}catch(T){t.error((T==null?void 0:T.message)||"Erreur lors du retrait")}};return o.jsxs("div",{className:"p-4 md:p-8 space-y-5 md:space-y-6 max-w-[1100px]",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-foreground font-heading",children:"Contrats"}),o.jsx("p",{className:"text-muted-foreground mt-1",children:"Un contrat autorise la fédération du département à distribuer le premium à ses sociétés. La distribution à venir s'arrête à l'échéance ; les octrois déjà posés courent jusqu'à leur propre fin."})]}),o.jsxs(Z,{onClick:_,children:[o.jsx(hr,{className:"h-4 w-4 mr-2"}),"Ajouter un contrat"]})]}),o.jsx(ke,{children:o.jsx(Pe,{className:"pt-6",children:r?o.jsxs("div",{className:"text-center py-12",children:[o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-green-600 mx-auto"}),o.jsx("p",{className:"text-muted-foreground mt-4",children:"Chargement..."})]}):A.length===0?o.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[o.jsx(UL,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground/40"}),o.jsx("p",{children:"Aucun contrat"}),o.jsx("p",{className:"text-sm mt-2",children:"Ajoutez un contrat pour permettre à une fédération de distribuer le premium."})]}):o.jsxs(Ya,{children:[o.jsx(Qa,{children:o.jsxs(Fr,{children:[o.jsx(dt,{children:"Département"}),o.jsx(dt,{children:"Protection des cultures"}),o.jsx(dt,{children:"Ãchéance"}),o.jsx(dt,{className:"w-24"})]})}),o.jsx(Xa,{children:A.map(S=>o.jsxs(Fr,{children:[o.jsxs(ht,{className:"font-medium",children:[String(S.code).padStart(2,"0")," - ",S.label]}),o.jsx(ht,{children:S.protectionCulturesIncluded?o.jsxs(We,{variant:"outline",className:"gap-1 bg-green-500/10 text-green-600 border-green-500/20",children:[o.jsx(kl,{className:"h-3 w-3"}),"Incluse"]}):o.jsx("span",{className:"text-sm text-muted-foreground",children:"Premium seul"})}),o.jsxs(ht,{className:"text-sm",children:[Mae(S.premiumContractEndDate),Oae(S.premiumContractEndDate)&&o.jsx(We,{variant:"outline",className:"ml-2 text-[10px] border-red-500/40 text-red-600",children:"expiré"})]}),o.jsx(ht,{children:o.jsxs("div",{className:"flex gap-1",children:[o.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>k(S),title:"Modifier",children:o.jsx(fd,{className:"h-4 w-4"})}),o.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>E(S),title:"Retirer",children:o.jsx(Vt,{className:"h-4 w-4 text-destructive"})})]})})]},S.id))})]})})}),o.jsx(rr,{open:l,onOpenChange:c,children:o.jsxs(sr,{children:[o.jsxs(or,{children:[o.jsx(Gn,{children:d?"Modifier le contrat":"Ajouter un contrat"}),o.jsx(ir,{children:d?`${String(d.code).padStart(2,"0")} - ${d.label}`:"La fédération du département pourra distribuer le premium à ses sociétés."})]}),o.jsxs("div",{className:"space-y-4 py-2",children:[!d&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ne,{children:"Département"}),o.jsxs(_t,{value:f,onValueChange:p,children:[o.jsx(St,{children:o.jsx(Et,{placeholder:"Choisir un département configuré"})}),o.jsx(kt,{children:N.map(S=>o.jsxs(Ke,{value:S.id,children:[String(S.code).padStart(2,"0")," - ",S.label]},S.id))})]}),N.length===0&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"Tous les départements configurés ont déjà un contrat."})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ne,{htmlFor:"contract-end",children:"Ãchéance"}),o.jsx(Ne,{id:"contract-end",type:"date",value:g,onChange:S=>v(S.target.value),disabled:x}),o.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[o.jsx(Ks,{id:"no-end",checked:x,onCheckedChange:S=>y(S===!0)}),o.jsx(ne,{htmlFor:"no-end",className:"text-sm cursor-pointer",children:"Jusqu'à nouvel ordre"})]})]}),o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(Ks,{id:"cultures",checked:b,onCheckedChange:S=>w(S===!0)}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ne,{htmlFor:"cultures",className:"cursor-pointer",children:"Option protection des cultures"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Les octrois de la fédération emportent aussi la protection des cultures."})]})]})]}),o.jsxs(ks,{children:[o.jsx(Z,{variant:"outline",onClick:()=>c(!1),disabled:i,children:"Annuler"}),o.jsxs(Z,{onClick:L,disabled:i||!d&&!f||!x&&!g,children:[i&&o.jsx(hs,{className:"h-4 w-4 mr-2 animate-spin"}),d?"Enregistrer":"Ajouter"]})]})]})}),o.jsx(Dn,{open:j!==null,onOpenChange:S=>!S&&E(null),children:o.jsxs(Ln,{children:[o.jsxs(Mn,{children:[o.jsx(Fn,{children:"Retirer ce contrat ?"}),o.jsxs(zn,{children:["La fédération de « ",j==null?void 0:j.label," » ne pourra plus distribuer de premium. Les octrois dé
4074jà posés courent jusqu'à leur propre échéance."]})]}),o.jsxs(On,{children:[o.jsx(Vn,{children:"Annuler"}),o.jsx($n,{onClick:I,children:"Retirer"})]})]})})]})}function zae({open:t,onOpenChange:e,onFarmerAdded:n}){const{user:r}=nn(),[s,i]=u.useState(""),[a,l]=u.useState(!1),[c,d]=u.useState(""),h=()=>{i(""),d("")},f=()=>{h(),e(!1)},p=v=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v),g=async()=>{if(d(""),!s.trim()){d("L'email est obligatoire");return}if(!p(s.trim())){d("L'email n'est pas valide");return}if(!(r!=null&&r.departmentCode)){d("Département non défini pour votre compte");return}l(!0);try{await qs.assignRoleByEmail({email:s.trim().toLowerCase(),role:"farmer",departmentCode:r.departmentCode}),f(),n()}catch(v){console.error("Error assigning farmer role:",v),d(v.message||"Erreur lors de l'ajout de l'agriculteur")}finally{l(!1)}};return o.jsx(rr,{open:t,onOpenChange:f,children:o.jsxs(sr,{className:"sm:max-w-[425px]",children:[o.jsxs(or,{children:[o.jsxs(Gn,{className:"flex items-center gap-2",children:[o.jsx(Ef,{className:"h-5 w-5"}),"Ajouter un agriculteur"]}),o.jsx(ir,{children:"Assignez le rôle agriculteur à un utilisateur via son email. Si l'utilisateur n'existe pas encore, le rôle lui sera attribué lors de son inscription."})]}),o.jsxs("div",{className:"space-y-4 py-4",children:[c&&o.jsxs(yr,{variant:"destructive",children:[o.jsx(an,{className:"h-4 w-4"}),o.jsx(wr,{children:c})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"email",children:"Email *"}),o.jsx(Ne,{id:"email",type:"email",placeholder:"[email protected]",value:s,onChange:v=>i(v.target.value),disabled:a}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Si l'utilisateur existe déjà , le rôle sera ajouté immédiatement. Sinon, il recevra le rôle lors de son inscription."})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{children:"Département"}),o.jsxs("div",{className:"text-sm text-foreground/80 bg-muted p-2 rounded-md",children:[r==null?void 0:r.departmentCode," - ",r==null?void 0:r.departmentLabel]})]})]}),o.jsxs(ks,{children:[o.jsx(Z,{variant:"outline",onClick:f,disabled:a,children:"Annuler"}),o.jsx(Z,{onClick:g,disabled:a,children:a?o.jsxs(o.Fragment,{children:[o.jsx(hs,{className:"h-4 w-4 mr-2 animate-spin"}),"Ajout..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Ef,{className:"h-4 w-4 mr-2"}),"Ajouter"]})})]})]})})}const fI=20;function $ae(){const t=Ft(),{user:e,isSuperAdmin:n}=nn(),[r,s]=u.useState([]),[i,a]=u.useState(!1),[l,c]=u.useState(null),[d,h]=u.useState(!1),[f,p]=u.useState(void 0),[g,v]=u.useState(!0),[x,y]=u.useState(""),[b,w]=u.useState([null]),[j,E]=u.useState(0),[P,A]=u.useState(!1),N=ei(x,300),_=N.length>=3?N:"",k=u.useCallback(async(T=null)=>{v(!0);try{const[V,$]=await Promise.all([qs.getUsersPaginated(fI,"farmer",_||void 0,T),T===null&&!_?qs.getPendingFarmers():Promise.resolve([])]),H=V.users.map(O=>({id:O.id,email:O.email,pseudo:O.pseudo,firstName:O.firstName,lastName:O.lastName,phoneNumber:O.phoneNumber,isPending:!1})),W=new Set(H.map(O=>O.email.toLowerCase())),D=$.filter(O=>!W.has(O.email.toLowerCase())).map(O=>({id:O.id,email:O.email,isPending:!0,assignedAt:O.assignedAt})),F=[...D,...H];s(F),a(V.hasMore),c(V.lastDocId),h(V.isSearchResult),p(V.totalCount!==void 0?V.totalCount+D.length:void 0)}catch(V){console.error("Error loading farmers:",V)}finally{v(!1)}},[_]);u.useEffect(()=>{w([null]),E(0),k(null)},[_]);const L=()=>{t.success("Agriculteur ajouté avec succès"),k(null)},I=()=>{if(i&&l&&!d){const T=[...b,l];w(T),E(j+1),k(l)}},S=()=>{if(j>0&&!d){const T=b[j-1];E(j-1),k(T)}};return o.jsxs("div",{className:"p-4 md:p-8 space-y-5 md:space-y-6 max-w-[1400px]",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-foreground font-heading",children:"Gestion des agriculteurs"}),o.jsx("p",{className:"text-muted-foreground mt-1",children:n?"Tous les agriculteurs":`Agriculteurs du département ${(e==null?void 0:e.departmentLabel)||""}`})]}),o.jsxs(Z,{onClick:()=>A(!0),children:[o.jsx(sc,{className:"h-4 w-4 mr-2"}),"Ajouter un agriculteur"]})]}),o.jsx(ke,{children:o.jsx(Pe,{className:"pt-6",children:o.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[o.jsxs("div",{className:"relative flex-1 min-w-[250px] max-w-md",children:[o.jsx(Ws,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground
4074/60"}),o.jsx(Ne,{placeholder:"Rechercher par email (min. 3 car.)...",value:x,onChange:T=>y(T.target.value),className:"pl-10"})]}),o.jsxs("div",{className:"text-sm text-muted-foreground",children:[r.length," résultat",r.length>1?"s":"",d&&" (max 100)"]})]})})}),o.jsx(ke,{children:o.jsx(Pe,{className:"pt-6",children:g?o.jsxs("div",{className:"text-center py-12",children:[o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-green-600 mx-auto"}),o.jsx("p",{className:"text-muted-foreground mt-4",children:"Chargement..."})]}):r.length===0?o.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[o.jsx(Ef,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground/40"}),o.jsx("p",{children:"Aucun agriculteur trouvé"}),_&&o.jsx("p",{className:"text-sm mt-2",children:"Essayez de modifier vos critères de recherche"})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"overflow-x-auto",children:o.jsxs(Ya,{children:[o.jsx(Qa,{children:o.jsxs(Fr,{children:[o.jsx(dt,{children:"Agriculteur"}),o.jsx(dt,{children:"Statut"}),o.jsx(dt,{children:"Téléphone"}),o.jsx(dt,{className:"w-12"})]})}),o.jsx(Xa,{children:r.map(T=>o.jsx(Vae,{farmer:T},T.id))})]})}),!d&&o.jsxs("div",{className:"flex items-center justify-between mt-4 pt-4 border-t",children:[o.jsx("div",{className:"text-sm text-muted-foreground",children:f!==void 0&&o.jsxs(o.Fragment,{children:[f," agriculteur",f>1?"s":""]})}),o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs("div",{className:"text-sm text-muted-foreground",children:["Page ",j+1,f!==void 0&&o.jsxs(o.Fragment,{children:[" / ",Math.ceil(f/fI)]})]}),o.jsxs("div",{className:"flex gap-1",children:[o.jsx(Z,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:S,disabled:j===0,title:"Page précédente",children:o.jsx(vc,{className:"h-4 w-4"})}),o.jsx(Z,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:I,disabled:!i,title:"Page suivante",children:o.jsx(nr,{className:"h-4 w-4"})})]})]})]})]})})}),o.jsx(zae,{open:P,onOpenChange:A,onFarmerAdded:L})]})}function Vae({farmer:t}){const e=qt(),n=()=>{t.isPending||e(mt.farmer(t.id))};return o.jsxs(Fr,{className:`hover:bg-muted ${t.isPending?"opacity-75":"cursor-pointer"}`,onClick:n,children:[o.jsx(ht,{children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${t.isPending?"bg-orange-500/15":"bg-green-500/15"}`,children:o.jsx(Ef,{className:`h-5 w-5 ${t.isPending?"text-orange-600":"text-green-600"}`})}),o.jsxs("div",{children:[o.jsx("div",{className:"font-medium",children:bn({firstName:t.firstName,lastName:t.lastName,pseudo:t.pseudo})||t.email.split("@")[0]}),o.jsx("div",{className:"text-sm text-muted-foreground",children:t.email})]})]})}),o.jsx(ht,{children:t.isPending?o.jsxs(We,{variant:"outline",className:"text-orange-500 border-orange-500/20 bg-orange-500/10",children:[o.jsx(hd,{className:"h-3 w-3 mr-1"}),"En attente"]}):o.jsxs(We,{variant:"outline",className:"text-green-500 border-green-500/20 bg-green-500/10",children:[o.jsx(Xn,{className:"h-3 w-3 mr-1"}),"Inscrit"]})}),o.jsx(ht,{children:o.jsx("div",{className:"text-sm text-muted-foreground",children:t.phoneNumber||"-"})}),o.jsx(ht,{children:!t.isPending&&o.jsx(Z,{variant:"ghost",size:"icon",children:o.jsx(nr,{className:"h-4 w-4"})})})]})}var Vx="Tabs",[Uae]=Rs(Vx,[xd]),C3=xd(),[Bae,aN]=Uae(Vx),N3=u.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:s,defaultValue:i,orientation:a="horizontal",dir:l,activationMode:c="automatic",...d}=t,h=sm(l),[f,p]=Co({prop:r,onChange:s,defaultProp:i??"",caller:Vx});return o.jsx(Bae,{scope:n,baseId:yo(),value:f,onValueChange:p,orientation:a,dir:h,activationMode:c,children:o.jsx(Je.div,{dir:h,"data-orientation":a,...d,ref:e})})});N3.displayName=Vx;var _3="TabsList",E3=u.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...s}=t,i=aN(_3,n),a=C3(n);return o.jsx(S1,{asChild:!0,...a,orientation:i.orientation,dir:i.dir,loop:r,children:o.jsx(Je.div,{role:"tablist","aria-orientation":i.orientation,...s,ref:e})})});E3.displayName=_3;var S3="TabsTrigger",k3=u.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:s=!1,...i}=t,a=aN(S3,n),l=C3(n),c=T3(a.baseId,r),d=A3(a.baseId,r),h=r===a.value;return o.jsx(k1,{asChild:!0,...l,focusable:!s,active:h,children:o.jsx(Je.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":d,"data-state":h?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:c,...i,ref:e,onMouseDown:Le(t.onMouseDown,f=>{!s&&f.button===0&&f.ctrlKey===!1?a.onValueChange(r):f.preventDefault()}),onKeyDown:Le(t.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&a.onValueChange(r)}),onFocus:Le(t.onFocus,()=>{const f=a.activationMode!=="manual";!h&&!s&&f&&a.onValueChange(r)})})})});k3.displayName=S3;var P3="TabsContent",I3=u.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:s,children:i,...a}=t,l=aN(P3,n),c=T3(l.baseId,r),d=A3(l.baseId,r),h=r===l.value,f=u.useRef(h);return u.useEffect(()=>{const p=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(p)},[]),o.jsx(Xs,{present:s||h,children:({present:p})=>o.jsx(Je.div,{"data-state":h?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!p,id:d,tabIndex:0,...a,ref:e,style:{...t.style,animationDuration:f.current?"0s":void 0},children:p&&i})})});I3.displayName=P3;function T3(t,e){return`${t}-trigger-${e}`}function A3(t,e){return`${t}-content-${e}`}var Wae=N3,Hae=E3,qae=k3,Gae=I3;function Zae({className:t,...e}){return o.jsx(Wae,{"data-slot":"tabs",className:Oe("flex flex-col gap-2",t),...e})}function Kae({className:t,...e}){return o.jsx(Hae,{"data-slot":"tabs-list",className:Oe("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-xl p-[3px] flex",t),...e})}function Sw({className:t,...e}){return o.jsx(qae,{"data-slot":"tabs-trigger",className:Oe("data-[state=active]:bg-card dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-xl border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focu
4074s-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...e})}function kw({className:t,...e}){return o.jsx(Gae,{"data-slot":"tabs-content",className:Oe("flex-1 outline-none",t),...e})}const mI="#105736",fi={damagePending:"/pins/damage_pending.png",damageInProgress:"/pins/damage_in_progress.png",damageResolved:"/pins/damage_resolved.png",damageClosed:"/pins/damage_closed.png",burrowSpotted:"/pins/burrow_spotted.png",burrowMonitoring:"/pins/burrow_monitoring.png",burrowInactive:"/pins/burrow_inactive.png"},Yae=t=>{if(!t)return null;const e=t.latitude??t._latitude??t.lat,n=t.longitude??t._longitude??t.lng;return typeof e=="number"&&typeof n=="number"?{latitude:e,longitude:n}:null},Bc=t=>t!=null&&typeof t.latitude=="number"&&typeof t.longitude=="number";function Qae(){var I;const{plotId:t}=Ys(),e=qt(),[n,r]=u.useState(null),[s,i]=u.useState([]),[a,l]=u.useState([]),[c,d]=u.useState([]),[h,f]=u.useState(""),[p,g]=u.useState(!0),[v,x]=u.useState(""),[y,b]=u.useState("seedings"),w=u.useCallback(async()=>{if(t){g(!0),x("");try{const[S,T,V,$]=await Promise.all([Ar.getCropZoneById(t),Ar.getSeedingsByCropZone(t),Ar.getDamagesByCropZone(t),Ar.getBurrowsByCropZone(t)]);if(S){if(r(S),i(T),l(V),d($),S.farmerId){const H=await Ar.getCropZoneFarmer(S.farmerId);H&&f(bn(H))}}else x("Zone de culture non trouvée")}catch(S){console.error("Error loading cropZone:",S),x("Erreur lors du chargement de la zone de culture")}finally{g(!1)}}},[t]);u.useEffect(()=>{w()},[w]);const E=(()=>{var V;if(!n)return[];const S=n;let T=[];return Array.isArray((V=S.polygons)==null?void 0:V[0])&&S.polygons[0].length>0?T=S.polygons[0]:Array.isArray(S.polygons)&&S.polygons.length>0?T=S.polygons:Array.isArray(S.gpsPoints)&&S.gpsPoints.length>0?T=S.gpsPoints:Array.isArray(S.gpsPoint)&&S.gpsPoint.length>0&&(T=S.gpsPoint),T.map(Yae).filter($=>$!==null)})(),P=S=>Bc(S)?{lat:S.latitude,lng:S.longitude}:{lat:0,lng:0},A=()=>{if(!E.length)return{lat:46.603354,lng:1.888334};const S=E.filter(Bc);if(S.length===0)return{lat:46.603354,lng:1.888334};const T=S.reduce((V,$)=>({lat:V.lat+$.latitude,lng:V.lng+$.longitude}),{lat:0,lng:0});return{lat:T.lat/S.length,lng:T.lng/S.length}},N=S=>S.status||"pending",_=S=>{switch(N(S)){case"pending":return fi.damagePending;case"inProgress":return fi.damageInProgress;case"resolved":return fi.damageResolved;case"closedWithoutAction":return fi.damageClosed;default:return fi.damagePending}},k=S=>{switch(S.status){case"activeSpotted":return fi.burrowSpotted;case"monitoring":return fi.burrowMonitoring;case"inactive":return fi.burrowInactive;default:return fi.burrowSpotted}},L=S=>S?(S.seconds?new Date(S.seconds*1e3):new Date(S)).toLocaleDateString("fr-FR"):"-";return p?o.jsx(H1,{}):n?o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx("div",{className:"bg-card border-b border-border px-6 py-4",children:o.jsxs("div",{className:"flex items-center justify-between max-w-7xl mx-auto",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs(Z,{variant:"outline",onClick:()=>e("/"),children:[o.jsx(Nr,{className:"w-4 h-4 mr-2"}),"Retour"]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-12 h-12 rounded-full bg-green-500/15 flex items-center justify-center",children:o.jsx(Si,{className:"h-6 w-6 text-green-600"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-foreground font-heading",children:n.name}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Zone de culture"})]})]})]}),o.jsxs(Z,{variant:"outline",onClick:w,children:[o.jsx(ft,{className:"w-4 h-4 mr-2"}),"Actualiser"]})]})}),o.jsxs("div",{className:"max-w-7xl mx-auto p-6 space-y-6",children:[v&&o.jsxs(yr,{variant:"destructive",children:[o.jsx(an,{className:"h-4 w-4"}),o.jsx(wr,{children:v})]}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[o.jsxs("div",{className:"space-y-6",children:[o.jsx(ke,{children:o.jsx(Pe,{className:"p-0 overflow-hidden rounded-lg",children:o.jsx("div",{className:"h-[250px] relative",children:E.filter(
4074Bc).length>2?o.jsxs(Qs,{mapContainerStyle:{width:"100%",height:"100%"},center:A(),zoom:15,options:{streetViewControl:!1,mapTypeControl:!1,fullscreenControl:!1,zoomControl:!0},children:[o.jsx(Oh,{paths:E.filter(Bc).map(P),options:{fillColor:mI,fillOpacity:.3,strokeColor:mI,strokeWeight:2}}),a.filter(S=>Bc(S.position)).map(S=>o.jsx(ho,{position:P(S.position),icon:{url:_(S),scaledSize:new google.maps.Size(28,28)}},`damage-${S.id}`)),c.filter(S=>Bc(S.position)).map(S=>o.jsx(ho,{position:P(S.position),icon:{url:k(S),scaledSize:new google.maps.Size(28,28)}},`burrow-${S.id}`))]}):o.jsx("div",{className:"h-full flex items-center justify-center bg-muted",children:o.jsxs("div",{className:"text-center text-muted-foreground",children:[o.jsx(h1,{className:"h-12 w-12 mx-auto mb-2 text-muted-foreground/40"}),o.jsx("p",{children:"Pas de données GPS"})]})})})})}),o.jsxs(ke,{children:[o.jsx(Qt,{children:o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(Si,{className:"w-5 h-5"}),"Informations"]})}),o.jsxs(Pe,{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg",children:[o.jsx(tY,{className:"h-5 w-5 text-muted-foreground/60"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Surface"}),o.jsxs("p",{className:"font-medium",children:[(I=n.surface)==null?void 0:I.toFixed(1)," hectares"]})]})]}),o.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg",children:[o.jsx(po,{className:"h-5 w-5 text-muted-foreground/60"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Agriculteur"}),o.jsx("p",{className:"font-medium",children:h||"-"})]})]})]})]}),o.jsx(ke,{children:o.jsx(Pe,{className:"pt-6",children:o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4 text-center",children:[o.jsxs("div",{className:"p-3 bg-green-500/10 rounded-lg",children:[o.jsx(pp,{className:"h-6 w-6 mx-auto text-green-600 mb-1"}),o.jsx("p",{className:"text-2xl font-bold text-green-700",children:s.length}),o.jsx("p",{className:"text-xs text-green-600",children:"Semis"})]}),o.jsxs("div",{className:"p-3 bg-orange-500/10 rounded-lg",children:[o.jsx(an,{className:"h-6 w-6 mx-auto text-orange-600 mb-1"}),o.jsx("p",{className:"text-2xl font-bold text-orange-700",children:a.length}),o.jsx("p",{className:"text-xs text-orange-600",children:"Dégâts"})]}),o.jsxs("div",{className:"p-3 bg-red-500/10 rounded-lg",children:[o.jsx(wa,{className:"h-6 w-6 mx-auto text-red-600 mb-1"}),o.jsx("p",{className:"text-2xl font-bold text-red-700",children:c.length}),o.jsx("p",{className:"text-xs text-red-600",children:"Terriers"})]})]})})})]}),o.jsx("div",{className:"lg:col-span-2",children:o.jsx(ke,{className:"h-full",children:o.jsx(Pe,{className:"pt-6",children:o.jsxs(Zae,{value:y,onValueChange:S=>b(S),children:[o.jsxs(Kae,{className:"w-full",children:[o.jsxs(Sw,{value:"seedings",className:"flex-1",children:[o.jsx(pp,{className:"h-4 w-4 mr-2"}),"Semis (",s.length,")"]}),o.jsxs(Sw,{value:"damages",className:"flex-1",children:[o.jsx(an,{className:"h-4 w-4 mr-2"}),"Dégâts (",a.length,")"]}),o.jsxs(Sw,{value:"burrows",className:"flex-1",children:[o.jsx(wa,{className:"h-4 w-4 mr-2"}),"Terriers (",c.length,")"]})]}),o.jsx(kw,{value:"seedings",className:"mt-4",children:s.length===0?o.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[o.jsx(pp,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground/40"}),o.jsx("p",{children:"Aucun semis enregistré"})]}):o.jsx("div",{className:"space-y-3",children:s.map(S=>{var T,V;return o.jsx("div",{className:"p-4 border rounded-lg hover:bg-muted transition-colors",children:o.jsx("div",{className:"flex items-center justify-between",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-green-500/15 flex items-center justify-center",children:o.jsx(pp,{className:"h-5 w-5 text-green-600"})}),o.jsxs("div",{children:[o.jsx(We,{variant:"secondary",children:WW[S.seedType]}),o.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-muted-foreground",children:[o.jsx(Da,{className:"h-3 w-3"}
4074),o.jsxs("span",{children:[L((T=S.period)==null?void 0:T.begin)," - ",L((V=S.period)==null?void 0:V.end)]})]})]})]})})},S.id)})})}),o.jsx(kw,{value:"damages",className:"mt-4",children:a.length===0?o.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[o.jsx(an,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground/40"}),o.jsx("p",{children:"Aucun dégât signalé"})]}):o.jsx("div",{className:"space-y-3",children:a.map(S=>{const T=N(S);return o.jsx("div",{className:"p-4 border rounded-lg hover:bg-muted transition-colors cursor-pointer",onClick:()=>e(mt.damage(S.id)),children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-orange-500/15 flex items-center justify-center",children:o.jsx(an,{className:"h-5 w-5 text-orange-600"})}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(We,{variant:"outline",style:{color:Nl[T]==="orange"?"#ea580c":Nl[T]==="blue"?"#2563eb":Nl[T]==="green"?"#16a34a":"#6b7280",borderColor:Nl[T]==="orange"?"#fed7aa":Nl[T]==="blue"?"#bfdbfe":Nl[T]==="green"?"#bbf7d0":"#e5e7eb"},children:yf[T]}),o.jsx(We,{variant:"secondary",children:Hu[S.animalSpecies]})]}),o.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-muted-foreground",children:[o.jsx(Da,{className:"h-3 w-3"}),o.jsx("span",{children:L(S.creationDate)})]}),S.note&&o.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-1",children:S.note})]})]}),o.jsx(nr,{className:"h-5 w-5 text-muted-foreground/60"})]})},S.id)})})}),o.jsx(kw,{value:"burrows",className:"mt-4",children:c.length===0?o.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[o.jsx(wa,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground/40"}),o.jsx("p",{children:"Aucun terrier signalé"})]}):o.jsx("div",{className:"space-y-3",children:c.map(S=>o.jsx("div",{className:"p-4 border rounded-lg hover:bg-muted transition-colors cursor-pointer",onClick:()=>e(mt.burrow(S.id)),children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/15 flex items-center justify-center",children:o.jsx(wa,{className:"h-5 w-5 text-red-600"})}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(We,{variant:"outline",style:{color:mh[S.status]==="red"?"#dc2626":mh[S.status]==="orange"?"#ea580c":"#6b7280",borderColor:mh[S.status]==="red"?"#fecaca":mh[S.status]==="orange"?"#fed7aa":"#e5e7eb"},children:dx[S.status]}),o.jsx(We,{variant:"secondary",children:qu[S.animalType]})]}),o.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-muted-foreground",children:[o.jsx(Da,{className:"h-3 w-3"}),o.jsx("span",{children:L(S.creationDate)})]}),S.note&&o.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-1",children:S.note})]})]}),o.jsx(nr,{className:"h-5 w-5 text-muted-foreground/60"})]})},S.id))})})]})})})})]})]})]}):o.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-6",children:o.jsx("div",{className:"max-w-md w-full",children:o.jsx(ke,{children:o.jsx(Pe,{className:"pt-6",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"w-16 h-16 rounded-full bg-orange-500/15 flex items-center justify-center mx-auto mb-4",children:o.jsx(Si,{className:"h-8 w-8 text-orange-600"})}),o.jsx("h2",{className:"text-xl font-semibold text-foreground mb-2",children:"Zone de culture introuvable"}),o.jsx("p",{className:"text-muted-foreground mb-6",children:"Cette zone de culture n'existe pas ou a été supprimée par son propriétaire."}),o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsxs(Z,{onClick:()=>e(-1),variant:"default",className:"w-full",children:[o.jsx(Nr,{className:"w-4 h-4 mr-2"}),"Retour à la page précédente"]}),o.jsx(Z,{onClick:()=>e("/"),variant:"outline",className:"w-full",children:"Retour à la carte"})]})]})})})})})}const th={damagePending:"/pins/damage_pending.png",damageInProgress:"/pins/damage_in_progress.png",damageResolved:"/pins/damage_resolved.png",damageClosed:"/pins/damage_closed.png"},Xae=["pending","inProgress","resolved","closedWithoutAction"];function Jae(){var D,F;const{damageId:t}=Ys(),e=qt(),n=Ft(),{user:r}=nn(),[s,i]=u.useState(null),[a,l]=u.useState(!0),[c,d]=u.useState(!1),[h,f]=u.useState(""),[p,g]=u.useState("pending"),[v,x]=u.useState(""),[y,b]=u.useState(!1),[w,j]=u.useState(!1),[E,P]=u.useState(!1),A=!!(r!=null&&r.id&&(s!=null&&s.farmerId)&&r.id===s.farmerId),N=(r==null?void 0:r.isSuperAdmin)||((D=r==null?void 0:r.roles)==null?void 0:D.includes("federation"))||((F=r==null?void 0:r.roles)==null?void 0:F.includes("ddt"))||A,_=u.useCallback(async()=>
4074{if(t){l(!0),f("");try{const O=await ph.getDamageById(t);O?(i(O),g(O.status||"pending")):f("Dégât non trouvé")}catch(O){console.error("Error loading damage:",O),f("Erreur lors du chargement du dégât")}finally{l(!1)}}},[t]);u.useEffect(()=>{_()},[_]);const k=()=>(s==null?void 0:s.status)||"pending",L=()=>{switch(k()){case"pending":return th.damagePending;case"inProgress":return th.damageInProgress;case"resolved":return th.damageResolved;case"closedWithoutAction":return th.damageClosed;default:return th.damagePending}},I=O=>O?(O.seconds?new Date(O.seconds*1e3):new Date(O)).toLocaleDateString("fr-FR",{day:"numeric",month:"long",year:"numeric",hour:"2-digit",minute:"2-digit"}):"-",S=async()=>{if(t){d(!0);try{const O=await ph.downloadShuttleForm(t),Y=window.URL.createObjectURL(O),G=document.createElement("a");G.href=Y,G.download=`fiche-navette-${t}.pdf`,document.body.appendChild(G),G.click(),document.body.removeChild(G),window.URL.revokeObjectURL(Y),n.success("Fiche navette téléchargée")}catch(O){console.error("Error downloading PDF:",O),n.error(O.message||"Erreur lors du téléchargement")}finally{d(!1)}}},T=async()=>{if(t){b(!0);try{await ph.updateDamageStatus(t,p,v||void 0),n.success("Modifications enregistrées"),x(""),await _()}catch(O){console.error("Error updating status:",O),n.error(O.message||"Erreur lors de la mise à jour")}finally{b(!1)}}},V=async()=>{if(t){P(!0);try{await ph.deleteDamage(t),n.success("Dégât supprimé"),e("/")}catch(O){console.error("Error deleting damage:",O),n.error(O.message||"Erreur lors de la suppression"),j(!1)}finally{P(!1)}}},$=O=>{switch(Nl[O]){case"orange":return"bg-orange-500/15 text-orange-600 border-orange-500/20";case"blue":return"bg-blue-500/15 text-blue-600 border-blue-500/20";case"green":return"bg-green-500/15 text-green-600 border-green-500/20";default:return"bg-muted text-muted-foreground border-border"}};if(a)return o.jsx(H1,{});if(!s)return o.jsxs("div",{className:"p-6",children:[o.jsxs(yr,{variant:"destructive",children:[o.jsx(an,{className:"h-4 w-4"}),o.jsx(wr,{children:h||"Dégât non trouvé"})]}),o.jsxs(Z,{onClick:()=>e("/"),className:"mt-4",children:[o.jsx(Nr,{className:"w-4 h-4 mr-2"}),"Retour à la carte"]})]});const H=k(),W=s.photoUrls||[];return o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx("div",{className:"bg-card border-b border-border px-4 md:px-8 py-4",children:o.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 max-w-4xl mx-auto",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>e("/"),children:[o.jsx(Nr,{className:"w-4 h-4 mr-1"}),"Retour"]}),o.jsx(Hn,{orientation:"vertical",className:"h-6"}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-lg font-bold text-foreground font-heading",children:Hu[s.animalSpecies]}),o.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[o.jsx(We,{className:`text-[11px] border ${$(H)}`,children:yf[H]}),s.city&&o.jsx("span",{className:"text-xs text-muted-foreground",children:s.city})]})]})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(Z,{variant:"outline",size:"sm",onClick:_,children:[o.jsx(ft,{className:"w-3.5 h-3.5 mr-1.5"}),"Actualiser"]}),o.jsxs(Z,{size:"sm",onClick:S,disabled:c,children:[c?o.jsx(ft,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):o.jsx(Nf,{className:"w-3.5 h-3.5 mr-1.5"}),"Fiche navette"]})]})]})}),o.jsxs("div",{className:"max-w-4xl mx-auto px-4 md:px-8 py-6 space-y-6",children:[h&&o.jsxs(yr,{variant:"destructive",children:[o.jsx(an,{className:"h-4 w-4"}),o.jsx(wr,{children:h})]}),o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6",children:[o.jsxs("h2",{className:"font-semibold text-foreground mb-4 flex items-center gap-2",children:[o.jsx(XK,{className:"h-4 w-4 text-muted-foreground"}),"Informations"]}),o.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[o.jsxs("div",{className:"flex-1 space-y-4",children:[o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-4",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-muted-foreground mb-0.5",children:"Espèce"}),o.jsx("p",{className:"text-sm font-medium",children:Hu[s.animalSpecies]})]}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-muted-foreground mb-0.5",children:"Date du signalement"}),o.jsx("p",{className:"text-sm font-medium",children:I(s.creationDate)})]}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-muted-foreground mb-0.5",children:"Commune"}),o.jsx("p",{className:"text-sm font-medium",children:s.city||"-"})]})]}),s.note&&o.jsxs(o.Fragment,{children:[o.jsx(Hn,{}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Note de l'agriculteur"}),o.jsx("p",{className:"text-sm leading-relaxed",children:s.note})]})]})]}),s.position&&o.jsx("div",{className:"lg:w-72 h-52 rounded-xl overflow-hidden border border-border flex-shrink-0",children:o.jsx(Qs,{mapContainerStyle:{width:"100%",height:"100%"},center:{lat:s.position.latitude,lng:s.position.longitude},zoom:15,options:{streetViewControl:!1,mapTypeControl:!1,fullscreenControl:!1,zoomControl:!0},children:o.jsx(ho,{position:{lat:s.position.latitude,lng:s.position.longitude},icon:{url:L(),scaledSize:new google.maps.Size(40,40)}})})})]})]})}),W.length>0&&o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6",children:[o.jsxs("h2",{className:"font-semibold text-foreground mb-4 flex items-center gap-2",children:[o.jsx(WL,{className:"h-4 w-4 text-muted-foreground"}),"Photos (",W.length,")"]}),o.jsx("div",{className:"flex gap-3 overflow-x-auto pb-1",children:W.map((O,Y)=>o.jsx("a",{href:O,target:"_blank",rel:"noopener noreferrer",className:"flex-shrink-0 w-36 h-28 rounded-lg overflow-hidden hover:opacity-90 transition-opacity",children:o.jsx("img",{src:O,alt:`Photo ${Y+1}`,className:"w-full h-full object-cover"})},Y))})]})}),N&&o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6",children:[o.jsx("h2",{className:"font-semibold text-foreground mb-4",children:"Gestion du signalement"}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{children:"Modifier le statut"}),o.jsxs(_t,{value:p,onValueChange:O=>g(O),children:[o.jsx(St,{children:o.jsx(Et,{})}),o.jsx(kt,{children:Xae.map(O=>o.jsx(Ke,{value:O,children:yf[O]},O))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{children:"Observations / Commentaires"}
4074),o.jsx(bc,{value:v,onChange:O=>x(O.target.value),placeholder:"Ajouter une observation...",rows:2})]})]}),o.jsxs(Z,{onClick:T,disabled:y||p===H&&!v.trim(),className:"mt-4",children:[y?o.jsx(ft,{className:"w-4 h-4 mr-2 animate-spin"}):o.jsx(Xn,{className:"w-4 h-4 mr-2"}),"Enregistrer les modifications"]})]})}),o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6",children:[o.jsxs("h2",{className:"font-semibold text-foreground mb-4 flex items-center gap-2",children:[o.jsx(hd,{className:"h-4 w-4 text-muted-foreground"}),"Interventions"]}),!s.interventions||s.interventions.length===0?o.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"Aucune intervention enregistrée"}):o.jsx("div",{className:"space-y-3",children:s.interventions.slice().sort((O,Y)=>{var G,q;return(((G=O.dateIntervention)==null?void 0:G.seconds)||0)-(((q=Y.dateIntervention)==null?void 0:q.seconds)||0)}).map((O,Y)=>o.jsxs("div",{className:"p-4 rounded-lg border border-border",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsxs("span",{className:"font-medium text-sm",children:["Intervention ",Y+1]}),O.dateIntervention&&o.jsx("span",{className:"text-xs text-muted-foreground",children:I(O.dateIntervention)})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[(O.nom||O.prenom)&&o.jsxs("div",{children:[o.jsx("span",{className:"text-muted-foreground text-xs",children:"Intervenant"}),o.jsx("p",{children:[O.nom,O.prenom].filter(Boolean).join(" ")})]}),O.qualite&&o.jsxs("div",{children:[o.jsx("span",{className:"text-muted-foreground text-xs",children:"Qualité"}),o.jsx("p",{children:O.qualite==="chasseur"?"Chasseur":O.qualite==="louvetier"?"Louvetier":O.qualite})]}),O.typeIntervention&&o.jsxs("div",{children:[o.jsx("span",{className:"text-muted-foreground text-xs",children:"Type"}),o.jsx("p",{children:O.typeIntervention==="affut"?"Affût":O.typeIntervention==="battue"?"Battue":O.typeIntervention==="tirDeNuit"?"Tir de nuit":O.typeIntervention==="autre"&&O.autreTypeIntervention?`Autre (${O.autreTypeIntervention})`:O.typeIntervention})]}),O.prelevements&&o.jsxs("div",{children:[o.jsx("span",{className:"text-muted-foreground text-xs",children:"Prélèvements"}),o.jsx("p",{children:O.prelevements})]})]}),O.observations&&o.jsxs("div",{className:"mt-2 text-sm",children:[o.jsx("span",{className:"text-muted-foreground text-xs",children:"Observations"}),o.jsx("p",{children:O.observations})]})]},Y))})]})}),s.cropZoneId&&o.jsx(ke,{className:"cursor-pointer hover:shadow-md transition-all",onClick:()=>e(mt.plot(s.cropZoneId)),children:o.jsx(Pe,{className:"p-4",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:o.jsx(Rn,{className:"h-5 w-5 text-primary"})}),o.jsxs("div",{children:[o.jsx("p",{className:"font-medium text-sm",children:"Zone de culture associée"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Voir les détails"})]})]}),o.jsx(nr,{className:"h-4 w-4 text-muted-foreground/40"})]})})}),N&&o.jsx(ke,{className:"border-destructive/20",children:o.jsxs(Pe,{className:"p-6",children:[o.jsx("h2",{className:"font-semibold text-destructive mb-2 text-sm",children:"Zone de danger"}),w?o.jsxs("div",{className:"space-y-3",children:[o.jsx("p",{className:"text-sm text-destructive font-medium",children:"Ãtes-vous sûr ? Cette action est irréversible."}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(Z,{variant:"outline",size:"sm",onClick:()=>j(!1),disabled:E,children:"Annuler"}),o.jsxs(Z,{variant:"destructive",size:"sm",onClick:V,disabled:E,children:[E&&o.jsx(ft,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),"Confirmer"]})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"La suppression de ce dégât est irréversible."}),o.jsxs(Z,{variant:"outline",size:"sm",className:"border-destructive/30 text-destructive hover:bg-destructive/10",onClick:()=>j(!0),children:[o.jsx(Vt,{className:"w-3.5 h-3.5 mr-1.5"}),"Supprimer ce dégât"]})]})]})})]})]})}const nh={burrowSpotted:"/pins/burrow_spotted.png",burrowMonitoring:"/pins/burrow_monitoring.png",burrowInactive:"/pins/burrow_inactive.png"};function ele(){var A,N;const{burrowId:t}=Ys(),e=qt(),n=Ft(),{user:r}=nn(),[s,i]=u.useState(null),[a,l]=u.useState(!0),[c,d]=u.useState(""),[h,f]=u.useState(!1),[p,g]=u.useState(!1),v=!!(r!=null&&r.id&&(s!=null&&s.farmerId)&&r.id===s.farmerId),x=(r==null?void 0:r.isSuperAdmin)||((A=r==null?void 0:r.roles)==null?void 0:A.includes("federation"))||((N=r==null?void 0:r.roles)==null?void 0:N.includes("ddt"))||v,y=u.useCallback(async()=>
4074{if(t){l(!0),d("");try{const _=await cb.getBurrowById(t);_?i(_):d("Terrier non trouvé")}catch(_){console.error("Error loading burrow:",_),d("Erreur lors du chargement du terrier")}finally{l(!1)}}},[t]);u.useEffect(()=>{y()},[y]);const b=async()=>{if(t){g(!0);try{await cb.deleteBurrow(t),n.success("Terrier supprimé"),e("/")}catch(_){console.error("Error deleting burrow:",_),n.error(_.message||"Erreur lors de la suppression"),f(!1)}finally{g(!1)}}},w=()=>{if(!s)return nh.burrowSpotted;switch(s.status){case"activeSpotted":return nh.burrowSpotted;case"monitoring":return nh.burrowMonitoring;case"inactive":return nh.burrowInactive;default:return nh.burrowSpotted}},j=_=>_?(_.seconds?new Date(_.seconds*1e3):new Date(_)).toLocaleDateString("fr-FR",{day:"numeric",month:"long",year:"numeric",hour:"2-digit",minute:"2-digit"}):"-",E=_=>{switch(mh[_]){case"red":return"bg-red-500/15 text-red-600 border-red-500/20";case"orange":return"bg-orange-500/15 text-orange-600 border-orange-500/20";default:return"bg-muted text-muted-foreground border-border"}};if(a)return o.jsx(H1,{});if(!s)return o.jsxs("div",{className:"p-6",children:[o.jsxs(yr,{variant:"destructive",children:[o.jsx(an,{className:"h-4 w-4"}),o.jsx(wr,{children:c||"Terrier non trouvé"})]}),o.jsxs(Z,{onClick:()=>e("/"),className:"mt-4",children:[o.jsx(Nr,{className:"w-4 h-4 mr-2"}),"Retour à la carte"]})]});const P=s.photoUrls||[];return o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx("div",{className:"bg-card border-b border-border px-4 md:px-8 py-4",children:o.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 max-w-4xl mx-auto",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>e("/"),children:[o.jsx(Nr,{className:"w-4 h-4 mr-1"}),"Retour"]}),o.jsx(Hn,{orientation:"vertical",className:"h-6"}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-lg font-bold text-foreground font-heading",children:qu[s.animalType]}),o.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[o.jsx(We,{className:`text-[11px] border ${E(s.status)}`,children:dx[s.status]}),s.city&&o.jsx("span",{className:"text-xs text-muted-foreground",children:s.city})]})]})]}),o.jsxs(Z,{variant:"outline",size:"sm",onClick:y,children:[o.jsx(ft,{className:"w-3.5 h-3.5 mr-1.5"}),"Actualiser"]})]})}),o.jsxs("div",{className:"max-w-4xl mx-auto px-4 md:px-8 py-6 space-y-6",children:[c&&o.jsxs(yr,{variant:"destructive",children:[o.jsx(an,{className:"h-4 w-4"}),o.jsx(wr,{children:c})]}),o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6",children:[o.jsxs("h2",{className:"font-semibold text-foreground mb-4 flex items-center gap-2",children:[o.jsx(wa,{className:"h-4 w-4 text-muted-foreground"}),"Informations"]}),o.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[o.jsxs("div",{className:"flex-1 space-y-4",children:[o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-4",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-muted-foreground mb-0.5",children:"Type d'animal"}),o.jsx("p",{className:"text-sm font-medium",children:qu[s.animalType]})]}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-muted-foreground mb-0.5",children:"Date du signalement"}),o.jsx("p",{className:"text-sm font-medium",children:j(s.creationDate)})]}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-muted-foreground mb-0.5",children:"Commune"}),o.jsx("p",{className:"text-sm font-medium",children:s.city||"-"})]})]}),s.note&&o.jsxs(o.Fragment,{children:[o.jsx(Hn,{}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Note de l'agriculteur"}),o.jsx("p",{className:"text-sm leading-relaxed",children:s.note})]})]})]}),s.position&&o.jsx("div",{className:"lg:w-72 h-52 rounded-xl overflow-hidden border border-border flex-shrink-0",children:o.jsx(Qs,{mapContainerStyle:{width:"100%",height:"100%"},center:{lat:s.position.latitude,lng:s.position.longitude},zoom:15,options:{streetViewControl:!1,mapTypeControl:!1,fullscreenControl:!1,zoomControl:!0},children:o.jsx(ho,{position:{lat:s.position.latitude,lng:s.position.longitude},icon:{url:w(),scaledSize:new google.maps.Size(40,40)}})})})]})]})}),P.length>0&&o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6",children:[o.jsxs("h2",{className:"font-semibold text-foreground mb-4 flex items-center gap-2",children:[o.jsx(WL,{className:"h-4 w-4 text-muted-foreground"}),"Photos (",P.length,")"]}),o.jsx("div",{className:"flex gap-3 overflow-x-auto pb-1",children:P.map((_,k)=>o.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",className:"flex-shrink-0 w-36 h-28 rounded-lg overflow-hidden hover:opacity-90 transition-opacity",children:o.jsx("img",{src:_,alt:`Photo ${k+1}`,className:"w-full h-full object-cover"})},k))})]})}),s.cropZoneId&&o.jsx(ke,{className:"cursor-pointer hover:shadow-md transition-all",onClick:()=>e(mt.plot(s.cropZoneId)),children:o.jsx(Pe,{className:"p-4",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:o.jsx(Rn,{className:"h-5 w-5 text-primary"})}),o.jsxs("div",{children:[o.jsx("p",{className:"font-medium text-sm",children:"Zone de culture associée"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Voir les détails"})]})]}
4074),o.jsx(nr,{className:"h-4 w-4 text-muted-foreground/40"})]})})}),x&&o.jsx(ke,{className:"border-destructive/20",children:o.jsxs(Pe,{className:"p-6",children:[o.jsx("h2",{className:"font-semibold text-destructive mb-2 text-sm",children:"Zone de danger"}),h?o.jsxs("div",{className:"space-y-3",children:[o.jsx("p",{className:"text-sm text-destructive font-medium",children:"Ãtes-vous sûr ? Cette action est irréversible."}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(Z,{variant:"outline",size:"sm",onClick:()=>f(!1),disabled:p,children:"Annuler"}),o.jsxs(Z,{variant:"destructive",size:"sm",onClick:b,disabled:p,children:[p&&o.jsx(ft,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),"Confirmer"]})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"La suppression de ce terrier est irréversible."}),o.jsxs(Z,{variant:"outline",size:"sm",className:"border-destructive/30 text-destructive hover:bg-destructive/10",onClick:()=>f(!0),children:[o.jsx(Vt,{className:"w-3.5 h-3.5 mr-1.5"}),"Supprimer ce terrier"]})]})]})})]})]})}const tle=["mp4","mov","m4v","webm"],nle="video/mp4,video/quicktime,video/webm",Pw=20;function R3(t){var n;const e=(n=t.split(".").pop())==null?void 0:n.toLowerCase();return!!e&&tle.includes(e)}const Ni={async getAllSponsors(){const e=await pe(ge,"getSponsors")();if(!e.data.success)throw new Error("Failed to get sponsors");return(e.data.sponsors||[]).map(n=>({...n,position:n.position?{latitude:n.position._latitude??n.position.latitude??0,longitude:n.position._longitude??n.position.longitude??0}:{latitude:0,longitude:0}}))},async getSponsorById(t){try{const e=await ms(Ht(Xe,"ads",t));if(!e.exists())return null;const n={id:e.id,...e.data()};return{...n,position:n.position?{latitude:n.position._latitude??n.position.latitude??0,longitude:n.position._longitude??n.position.longitude??0}:{latitude:0,longitude:0}}}catch(e){return console.error("Error fetching sponsor:",e),null}},async createSponsor(t,e,n){var c,d,h,f;const r=pe(ge,"createSponsor"),s=(d=(c=t.startDate)==null?void 0:c.toDate)!=null&&d.call(c)?t.startDate.toDate().getTime():new Date(t.startDate).getTime(),i=(f=(h=t.endDate)==null?void 0:h.toDate)!=null&&f.call(h)?t.endDate.toDate().getTime():new Date(t.endDate).getTime(),a=await r({...t,startDate:s,endDate:i});if(!a.data.success)throw new Error("Failed to create sponsor");const l=a.data.sponsorId;return e&&await this.uploadImage(l,e),n&&await this.uploadLogo(l,n),l},async updateSponsor(t,e,n,r){var l,c,d,h;const s=pe(ge,"updateSponsor"),i={sponsorId:t,...e};if(e.startDate&&(i.startDate=(c=(l=e.startDate)==null?void 0:l.toDate)!=null&&c.call(l)?e.startDate.toDate().getTime():new Date(e.startDate).getTime()),e.endDate&&(i.endDate=(h=(d=e.endDate)==null?void 0:d.toDate)!=null&&h.call(d)?e.endDate.toDate().getTime():new Date(e.endDate).getTime()),!(await s(i)).data.success)throw new Error("Failed to update sponsor");n&&await this.uploadImage(t,n),r&&await this.uploadLogo(t,r)},async uploadImage(t,e){const n=e.name.split(".").pop()||"jpg",r=`${t}.${n}`,s=Wa(Ha,`ads/${r}`);return await sb(s,e),await pe(ge,"updateSponsor")({sponsorId:t,imageName:r}),r},async uploadLogo(t,e){const n=e.name.split(".").pop()||"jpg",r=`${t}_logo.${n}`,s=Wa(Ha,`ads/${r}`);return await sb(s,e),await pe(ge,"updateSponsor")({sponsorId:t,logoName:r}),r},async deleteSponsor(t){if(!(await pe(ge,"deleteSponsor")({sponsorId:t})).data.success)throw new Error("Failed to delete sponsor")},categorizeSponsors(t){var i,a,l,c,d,h;const e=new Date,n=[],r=[],s=[];for(const f of t){const p=((a=(i=f.startDate)==null?void 0:i.toDate)==null?void 0:a.call(i))||new Date(((l=f.startDate)==null?void 0:l._seconds)*1e3||f.startDate),g=((d=(c=f.endDate)==null?void 0:c.toDate)==null?void 0:d.call(c))||new Date(((h=f.endDate)==null?void 0:h._seconds)*1e3||f.endDate),v=new Date(p.getFullYear(),p.getMonth(),p.getDate()),x=new Date(g.getFullYear(),g.getMonth(),g.getDate(),23,59,59,999);e<v?n.push(f):e>x?s.push(f):r.push(f)}return n.sort((f,p)=>{var x,y,b,w,j,E;const g=((y=(x=f.startDate)==null?void 0:x.toDate)==null?void 0:y.call(x))||new Date(((b=f.startDate)==null?void 0:b._seconds)*1e3||f.startDate),v=((j=(w=p.startDate)==null?void 0:w.toDate)==null?void 0:j.call(w))||new Date(((E=p.startDate)==null?void 0:E._seconds)*1e3||p.startDate);return g.getTime()-v.getTime()}),r.sort((f,p)=>{var x,y,b,w,j,E;const g=((y=(x=f.endDate)==null?void 0:x.toDate)==null?void 0:y.call(x))||new Date(((b=f.endDate)==null?void 0:b._seconds)*1e3||f.endDate),v=((j=(w=p.endDate)==null?void 0:w.toDate)==null?void 0:j.call(w))||new Date(((E=p.endDate)==null?void 0:E._seconds)*1e3||p.endDate);return g.getTime()-v.getTime()}),s.sort((f,p)=>{var x,y,b,w,j,E;const g=((y=(x=f.endDate)==null?void 0:x.toDate)==null?void 0:y.call(x))||new Date(((b=f.endDate)==null?void 0:b._seconds)*1e3||f.endDate);return(((j=(w=p.endDate)==null?void 0:w.toDate)==null?void 0:j.call(w))||new Date(((E=p.endDate)==null?void 0:E._seconds)*1e3||p.endDate)).getTime()-g.getTime()}),{upcoming:n,active:r,expired:s}}},xv=t=>t.adRotation!==!1;function rle(t){if(!t)return null;if(t instanceof Date)return t;if(typeof t.toDate=="function")return t.toDate();if(t._seconds!==void 0)return new Date(t._seconds*1e3);if(t.seconds!==void 0)return new Date(t.seconds*1e3);const e=new Date(t);return isNaN(e.getTime())?null:e}function pI(t){const e=rle(t);if(!e)return"";const n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${e.getFullYear()}-${n}-${r}`}function gI(t){const e={};for(const n of t)e[n.id]={adRotation:xv(n),startDate:pI(n.startDate),endDate:pI(n.endDate)};return e}function sle({open:t,onOpenChange:e,sponsors:n,onSaved:r}){const s=Ft(),[i,a]=u.useState({}),[l,c]=u.useState({}),[d,h]=u.useState(!1);u.useEffect(()=>{t&&(a(gI(n)),c({}))},[t,n]);const f=gI(n),p=Object.keys(i).filter(E=>{const P=f[E],A=i[E];return!P||!A?!1:P.adRotation!==A.adRotation||P.startDate!==A.startDate||P.endDate!==A.endDate}),g=(E,P)=>{a(A=>({...A,[E]:{...A[E],...P}}))},v=async()=>
4074{if(p.length!==0){h(!0);try{for(const E of p){const P=f[E],A=i[E],N={};P.adRotation!==A.adRotation&&(N.adRotation=A.adRotation),P.startDate!==A.startDate&&A.startDate&&(N.startDate=new Date(A.startDate)),P.endDate!==A.endDate&&A.endDate&&(N.endDate=new Date(A.endDate)),await Ni.updateSponsor(E,N)}s.success(p.length===1?"Sponsor mis à jour":`${p.length} sponsors mis à jour`),r(),e(!1)}catch(E){console.error("Error saving ad rotation:",E),s.error("Erreur lors de l'enregistrement")}finally{h(!1)}}},{upcoming:x,active:y,expired:b}=Ni.categorizeSponsors(n),w=[{title:"En cours",items:y},{title:"à venir",items:x},{title:"Expirés",items:b}].filter(E=>E.items.length>0),j=Object.values(i).filter(E=>E.adRotation).length;return o.jsx(rr,{open:t,onOpenChange:e,children:o.jsxs(sr,{className:"max-w-3xl max-h-[85vh] flex flex-col",children:[o.jsxs(or,{children:[o.jsx(Gn,{children:"Gérer la rotation publicitaire"}),o.jsx(ir,{children:"Cochez les sponsors à diffuser dans la publicité d'ouverture. Un sponsor n'est réellement diffusé que pendant sa période, et auprès du public qu'il cible."})]}),o.jsx("div",{className:"flex-1 overflow-y-auto space-y-6 pr-1 -mr-1",children:w.length===0?o.jsx("p",{className:"text-sm text-muted-foreground py-6 text-center",children:"Aucun sponsor."}):w.map(E=>o.jsxs("section",{className:"space-y-2",children:[o.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[E.title,o.jsx(We,{variant:"outline",children:E.items.length})]}),E.items.map(P=>{const A=i[P.id];if(!A)return null;const N=!!l[P.id];return o.jsxs("div",{className:"p-3 rounded-lg border space-y-3",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(Ks,{id:`rotation-${P.id}`,checked:A.adRotation,onCheckedChange:_=>g(P.id,{adRotation:_===!0}),className:"mt-1"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx(ne,{htmlFor:`rotation-${P.id}`,className:"font-medium cursor-pointer block truncate",children:P.name||P.description||"Sans nom"}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:[A.startDate||"â"," â ",A.endDate||"â"]})]}),o.jsxs(Z,{variant:"ghost",size:"sm",className:"shrink-0",onClick:()=>c(_=>({..._,[P.id]:!N})),children:[o.jsx(Da,{className:"h-4 w-4 mr-1"}),N?"Masquer":"Dates"]})]}),N&&o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 pl-7",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ne,{className:"text-xs text-muted-foreground",children:"Début"}),o.jsx(Ne,{type:"date",value:A.startDate,onChange:_=>g(P.id,{startDate:_.target.value})})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ne,{className:"text-xs text-muted-foreground",children:"Fin"}),o.jsx(Ne,{type:"date",value:A.endDate,onChange:_=>g(P.id,{endDate:_.target.value})})]})]})]},P.id)})]},E.title))}),o.jsxs(ks,{className:"flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[o.jsxs("p",{className:"text-sm text-muted-foreground sm:mr-auto",children:[j," sponsor",j>1?"s":""," dans la rotation",p.length>0&&` · ${p.length} modification${p.length>1?"s":""} non enregistrée${p.length>1?"s":""}`]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(Z,{variant:"outline",onClick:()=>e(!1),disabled:d,children:"Annuler"}),o.jsxs(Z,{onClick:v,disabled:d||p.length===0,children:[d&&o.jsx(ft,{className:"h-4 w-4 mr-2 animate-spin"}),"Enregistrer"]})]})]})]})})}const zo="all";function ole(t){const e=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return`${t.getFullYear()}-${e}-${n}`}function ile(t){const e=new Date,n=new Set;for(let i=0;i<7;i++)n.add(ole(new Date(e.getTime()-i*24*60*60*1e3)));let r=0,s=0;for(const i of t)for(const[a,l]of Object.entries(i.stats||{}))!l||!n.has(a)||(r+=l.reads||0,s+=l.taps||0);return{reads:r,taps:s}}function ale(){const t=qt(),[e,n]=u.useState([]),[r,s]=u.useState(!0),[i,a]=u.useState(!1),[l,c]=u.useState([]),[d,h]=u.useState(zo),[f,p]=u.useState(zo);u.useEffect(()=>{g(),As().then(c)},[]);const g=async()=>{s(!0);try{const I=await Ni.getAllSponsors();n(I)}catch(I){console.error("Error loading sponsors:",I)}finally{s(!1)}},v=Array.from(new Set(e.flatMap(I=>I.departmentCodes||[]).filter(I=>I>0))).sort((I,S)=>I-S),x=I=>{var S;return((S=l.find(T=>parseInt(T.code,10)===I||T.code===String(I).padStart(2,"0")))==null?void 0:S.nom)||""},y=I=>{if(d===zo)return!0;const S=I.departmentCodes||[];return S.length===0||S.includes(0)?!0:S.includes(parseInt(d,10))},b=I=>f===zo?!0:(I.activityCodes||[]).includes(parseInt(f,10)),w=d!==zo||f!==zo,j=e.filter(I=>y(I)&&b(I)),{upcoming:E,active:P,expired:A}=Ni.categorizeSponsors(j),N=e.filter(xv),_=Ni.categorizeSponsors(e).active.filter(xv),k=ile(N),L=I=>{var T;if(!I)return"-";const S=((T=I==null?void 0:I.toDate)==null?void 0:T.call(I))||new Date((I==null?void 0:I._seconds)*1e3||I);return isNaN(S.getTime())?"-":S.toLocaleDateString("fr-FR",{day:"2-digit",month:"2-digit",year:"numeric"})};return o.jsxs("div",{className:"p-4 md:p-8 space-y-5 md:space-y-6 max-w-[1400px]",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-foreground font-heading",children:"Gestion des sponsors"}),o.jsx("p",{className:"text-muted-foreground mt-1",children:"Gérez les publicités et partenariats"})]}),o.jsxs(Z,{onClick:()=>t(xe.sponsorNew),children:[o.jsx(hr,{className:"h-4 w-4 mr-2"}),"Nouveau sponsor"]})]}),!r&&e.length>0&&o.jsxs(ke,{children:[o.jsx(Qt,{children:o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(eY,{className:"h-5 w-5"}),"Publicité à l'ouverture"]})}),o.jsxs(Pe,{className:"space-y-4",children:[o.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[o.jsx(Ep,{label:"Dans la rotation",value:`${N.length} / ${e.length}`,hint:"Sponsors cochés"}),o.jsx(Ep,{label:"Diffusés aujourd'hui",value:_.length,hint:"Cochés et dans leur période"}),o.jsx(Ep,{label:"Affichages",value:k.reads,hint:"7 derniers jours"}),o.jsx(Ep,{label:"Clics",value:k.taps,hint:"7 derniers jours"})]}),o.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[o.jsx("p",{className:"text-sm text-muted-foreground",children:_.length===0?"â ï¸ Aucun sponsor n'est diffusé actuellement : aucune publicité ne s'affiche à l'ouverture de l'application.":_.length===1?"Un seul sponsor est diffusé : il s'affiche à chaque ouverture de l'application.":"à chaque ouverture, un sponsor est tiré au hasard parmi ceux qui ciblent l'utilisateur, jamais le même que la fois précédente."}),o.jsxs(Z,{variant:"outline",className:"shrink-0",onClick:()=>a(!0),children:[o.jsx(sY,{className:"h-4 w-4 mr-2"}),"Gérer les sponsors"]})]})]})]}),o.jsx(sle,{open:i,onOpenChange:a,sponsors:e,onSaved:g}),r?o.jsxs("div",{className:"text-center py-12",children:[o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-primary/20 border-t-primary mx-auto"}),o.jsx("p",{className:"text-muted-foreground mt-4",children:"Chargement..."})]}):e.length===0?o.jsx(ke,{children:o.jsxs(Pe,{className:"text-center py-12",children:[o.jsx(yx,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground
4074/40"}),o.jsx("p",{className:"text-muted-foreground",children:"Aucun sponsor configuré"}),o.jsxs(Z,{className:"mt-4",onClick:()=>t(xe.sponsorNew),children:[o.jsx(hr,{className:"h-4 w-4 mr-2"}),"Ajouter un sponsor"]})]})}):o.jsxs("div",{className:"space-y-8",children:[o.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-end gap-3",children:[o.jsxs("div",{className:"space-y-1 w-full lg:w-64",children:[o.jsx(ne,{className:"text-xs text-muted-foreground",children:"Visible dans"}),o.jsxs(_t,{value:d,onValueChange:h,children:[o.jsx(St,{children:o.jsx(Et,{placeholder:"Tous les départements"})}),o.jsxs(kt,{children:[o.jsx(Ke,{value:zo,children:"Tous les départements"}),v.map(I=>{const S=x(I);return o.jsxs(Ke,{value:String(I),children:[String(I).padStart(2,"0"),S&&` - ${S}`]},I)})]})]})]}),o.jsxs("div",{className:"space-y-1 w-full lg:w-56",children:[o.jsx(ne,{className:"text-xs text-muted-foreground",children:"Visible pour"}),o.jsxs(_t,{value:f,onValueChange:p,children:[o.jsx(St,{children:o.jsx(Et,{placeholder:"Toutes les activités"})}),o.jsxs(kt,{children:[o.jsx(Ke,{value:zo,children:"Toutes les activités"}),Object.entries(GC).map(([I,S])=>o.jsx(Ke,{value:I,children:ZC[S]},I))]})]})]}),w&&o.jsxs(Z,{variant:"ghost",onClick:()=>{h(zo),p(zo)},children:[o.jsx(br,{className:"h-4 w-4 mr-1"}),"Réinitialiser"]}),o.jsx("p",{className:"text-sm text-muted-foreground lg:ml-auto lg:pb-2",children:w?`${j.length} sponsor${j.length>1?"s":""} sur ${e.length}`:`${e.length} sponsor${e.length>1?"s":""}`})]}),w&&j.length===0&&o.jsx(ke,{children:o.jsx(Pe,{className:"text-center py-10",children:o.jsx("p",{className:"text-muted-foreground",children:"Aucun sponsor ne correspond à ce ciblage."})})}),P.length>0&&o.jsx(Iw,{title:"En cours",icon:o.jsx(ns,{className:"h-5 w-5 text-green-600"}),sponsors:P,formatDate:L,onSponsorClick:I=>t(mt.sponsor(I)),badgeVariant:"success"}),E.length>0&&o.jsx(Iw,{title:"à venir",icon:o.jsx(hd,{className:"h-5 w-5 text-blue-600"}),sponsors:E,formatDate:L,onSponsorClick:I=>t(mt.sponsor(I)),badgeVariant:"info"}),A.length>0&&o.jsx(Iw,{title:"Expirés",icon:o.jsx(KL,{className:"h-5 w-5 text-muted-foreground/60"}),sponsors:A,formatDate:L,onSponsorClick:I=>t(mt.sponsor(I)),badgeVariant:"secondary"})]})]})}function Iw({title:t,icon:e,sponsors:n,formatDate:r,onSponsorClick:s,badgeVariant:i}){return o.jsxs(ke,{children:[o.jsx(Qt,{children:o.jsxs(Xt,{className:"flex items-center gap-2",children:[e,t,o.jsx(We,{variant:"outline",className:"ml-2",children:n.length})]})}),o.jsx(Pe,{children:o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:n.map(a=>o.jsx(lle,{sponsor:a,formatDate:r,onClick:()=>s(a.id),badgeVariant:i},a.id))})})]})}function lle({sponsor:t,formatDate:e,onClick:n}){const r=xv(t),[s,i]=u.useState(null);u.useEffect(()=>{if(t.imageName){const l=Wa(Ha,`ads/${t.imageName}`);xf(l).then(i).catch(()=>i(null))}},[t.imageName]);const a=()=>!t.activityCodes||t.activityCodes.length===0?"Toutes activités":t.activityCodes.map(l=>ZC[GC[l]]||"").filter(Boolean).join(", ");return o.jsxs("div",{className:"border rounded-lg overflow-hidden cursor-pointer hover:shadow-md transition-shadow",onClick:n,children:[o.jsx("div",{className:"h-32 flex items-center justify-center bg-muted",children:s?R3(t.imageName)?o.jsx("video",{src:s,className:`w-full h-full object-cover ${r?"":"opacity-40 grayscale"}`,muted:!0,loop:!0,autoPlay:!0,playsInline:!0}):o.jsx("img",{src:s,alt:t.name||t.description,className:`w-full h-full object-cover ${r?"":"opacity-40 grayscale"}`}):o.jsx(yx,{className:"h-12 w-12 text-muted-foreground/60"})}),o.jsxs("div",{className:"p-4 space-y-3",children:[o.jsx("p",{className:"font-medium text-foreground line-clamp-2",children:t.name||t.description||"Sans nom"}),o.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[o.jsx(Da,{className:"h-4 w-4"}),o.jsxs("span",{children:[e(t.startDate)," â ",e(t.endDate)]})]}),t.city&&o.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[o.jsx(Rn,{className:"h-4 w-4"}),o.jsx("span",{children:t.city})]}),o.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(gh,{className:"h-4 w-4"}),o.jsx("span",{children:t.nbRead||0})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(vh,{className:"h-4 w-4"}),o.jsx("span",{children:t.nbTap||0})]})]}),o.jsxs("div",{className:"flex flex-wrap gap-1",children:[t.departmentCodes&&t.departmentCodes.length>0?t.departmentCodes.slice(0,3).map(l=>o.jsx(We,{variant:"outline",className:"text-xs",children:l},l)):o.jsx(We,{variant:"outline",className:"text-xs",children:"Tous départements"}),t.departmentCodes&&t.departmentCodes.length>3&&o.jsxs(We,{variant:"outline",className:"text-xs",children:["+",t.departmentCodes.length-3]})]}
4074),o.jsx("p",{className:"text-xs text-muted-foreground/60",children:a()}),!r&&o.jsx(We,{variant:"outline",className:"text-xs",children:"Hors rotation"})]})]})}function Ep({label:t,value:e,hint:n}){return o.jsxs("div",{className:"p-3 rounded-lg border bg-muted/40 min-w-0",children:[o.jsx("p",{className:"text-sm text-muted-foreground truncate",children:t}),o.jsx("p",{className:"text-2xl font-bold mt-1",children:e}),o.jsx("p",{className:"text-xs text-muted-foreground truncate",title:n,children:n})]})}const Sp=1500,vI=["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"];function rh(t){const[e,n]=t.split("-"),r=parseInt(n,10)-1;return vI[r]?`${vI[r]} ${e}`:t}function Tw(t){const e=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return`${t.getFullYear()}-${e}-${n}`}function kp(t,e){let n=0,r=0;for(const[s,i]of Object.entries(t))!i||!e(s)||(n+=i.reads||0,r+=i.taps||0);return{reads:n,taps:r}}function Pp(t,e){if(e===0)return t===0?"â":"nouveau";if(t===e)return"stable";const n=Math.round((t-e)/e*100);return n>0?`+${n} %`:`${n} %`}function cle(t){const e=t||{},n=new Date,r=[];for(let f=0;f<14;f++)r.push(Tw(new Date(n.getTime()-f*24*60*60*1e3)));const s=new Set(r.slice(0,7)),i=new Set(r.slice(7,14)),a=Tw(n).slice(0,7),l=new Date(n.getFullYear(),n.getMonth()-1,15),c=Tw(l).slice(0,7),d={};for(const[f,p]of Object.entries(e)){if(!p)continue;const g=f.slice(0,7),v=d[g]||{reads:0,taps:0};v.reads+=p.reads||0,v.taps+=p.taps||0,d[g]=v}const h=Object.entries(d).map(([f,p])=>({key:f,...p})).sort((f,p)=>p.key.localeCompare(f.key));return{last7Days:kp(e,f=>s.has(f)),previous7Days:kp(e,f=>i.has(f)),currentMonth:kp(e,f=>f.startsWith(a)),previousMonth:kp(e,f=>f.startsWith(c)),currentMonthKey:a,previousMonthKey:c,monthlyRows:h,maxMonthlyReads:h.reduce((f,p)=>Math.max(f,p.reads),0),hasData:h.length>0}}function xI(t){return t.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"")}function ule(t,e){return xI(t).includes(xI(e))?1:0}const dle={name:"",adTitle:"",description:"",city:"",latitude:"",longitude:"",linkUrl:"",clientEmail:"",activities:[],departments:[],startDate:"",endDate:""};function Aw(t){return JSON.stringify({...t,activities:[...t.activities].sort((e,n)=>e-n),departments:[...t.departments].sort((e,n)=>e-n)})}function Ip({icon:t,label:e,period:n,value:r,trend:s,comparison:i}){const a=s.startsWith("+")||s==="nouveau",l=s.startsWith("-"),c=a?"text-emerald-600":l?"text-red-600":"text-muted-foreground";return o.jsxs("div",{className:"p-3 rounded-lg border bg-muted/40 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground min-w-0",children:[t,o.jsx("span",{className:"truncate",children:e})]}),o.jsx("div",{className:"text-xs text-muted-foreground/80",children:n}),o.jsxs("div",{className:"flex items-baseline gap-2 mt-1 flex-wrap",children:[o.jsx("span",{className:"text-2xl font-bold",children:r}),o.jsx("span",{className:`text-sm font-medium ${c}`,children:s})]}),o.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",title:i,children:i})]})}function hle(){const{id:t}=Ys(),e=qt(),n=Ft(),r=t==="nouveau",s=u.useRef(null),i=u.useRef(null),[a,l]=u.useState(!r),[c,d]=u.useState(!1),[h,f]=u.useState(!1),[p,g]=u.useState(null),[v,x]=u.useState([]),[y,b]=u.useState(""),[w,j]=u.useState(""),[E,P]=u.useState(""),[A,N]=u.useState(""),[_,k]=u.useState(""),[L,I]=u.useState(""),[S,T]=u.useState(null),[V,$]=u.useState(null),[H,W]=u.useState(""),[D,F]=u.useState(""),[O,Y]=u.useState(null),[G,q]=u.useState(null),[re,U]=u.useState(!1),[ee,K]=u.useState([]),[ue,be]=u.useState([]),[le,B]=u.useState(!1),[Q,ve]=u.useState(""),[Ae,he]=u.useState(""),J=u.useMemo(()=>{const de=[];let ze=!1;for(const Qe of v){if(Qe.code==="2A"||Qe.code==="2B"){ze||(de.push({code:20,label:"Corse (2A / 2B)"}),ze=!0);continue}const It=parseInt(Qe.code,10);Number.isNaN(It)||de.push({code:It,label:Qe.nom})}return de.sort((Qe,It)=>Qe.code-It.code)},[v]),[je,Ve]=u.useState(()=>Aw(dle)),Jt=Aw({name:y,adTitle:H,description:D,city:A,latitude:_,longitude:L,linkUrl:w,clientEmail:E,activities:ee,departments:ue,startDate:Q,endDate:Ae})!==je||!!O||!!S;u.useEffect(()=>{As().then(x),!r&&t&&Ue()},[t,r]),u.useEffect(()=>{if(G!=null&&G.startsWith("blob:"))return()=>URL.revokeObjectURL(G)},[G]);const Ue=async()=>{var de,ze,Qe,It;if(t){l(!0);try{const se=await Ni.getSponsorById(t);if(se){g(se);const Re={name:se.name||"",adTitle:se.adTitle||"",description:se.description||"",city:se.city||"",latitude:((ze=(de=se.position)==null?void 0:de.latitude)==null?void 0:ze.toString())||"",longitude:((It=(Qe=se.position)==null?void 0:Qe.longitude)==null?void 0:It.toString())||"",linkUrl:se.linkUrl||"",clientEmail:se.clientEmail||"",activities:se.activityCodes||[],departments:se.departmentCodes||[],startDate:vt(se.startDate)?rn(vt(se.startDate)):"",endDate:vt(se.endDate)?rn(vt(se.endDate)):""};if(b(Re.name),W(Re.adTitle),F(Re.description),N(Re.city),k(Re.latitude),I(Re.longitude),j(Re.linkUrl),P(Re.clientEmail),K(Re.activities),be(Re.departments),ve(Re.startDate),he(Re.endDate),Ve(Aw(Re)),Y(null),T(null),se.imageName){U(R3(se.imageName));try{const ae=Wa(Ha,`ads/${se.imageName}`),et=await xf(ae);q(et)}catch(ae){console.warn("Could not load sponsor image:",ae)}}if(se.logoName)try{const ae=Wa(Ha,`ads/${se.logoName}`),et=await xf(ae);$(et)}catch(ae){console.warn("Could not load sponsor logo:",ae)}}else n.error("Sponsor non trouvé"),e(xe.sponsors)}catch(se){console.error("Error loading sponsor:",se),n.error("Erreur lors du chargement")}finally{l(!1)}}},rn=de=>de.toISOString().split("T")[0],vt=de=>{if(!de)return null;if(de instanceof Date)return de;if(typeof de.toDate=="function")return de.toDate();if(de._seconds!==void 0)return new Date(de._seconds*1e3);if(de.seconds!==void 0)return new Date(de.seconds*1e3);const ze=new Date(de);return isNaN(ze.getTime())?null:ze},me=de=>{var It;const ze=(It=de.target.files)==null?void 0:It[0];if(!ze)return;const Qe=ze.type.startsWith("video/");if(Qe&&ze.size>Pw*1024*1024){n.error(`La vidéo doit faire moins de ${Pw} Mo.`),de.target.value="";return}Y(ze),U(Qe),q(URL.createObjectURL(ze))},ot=()=>{Y(null),q(null),U(!1),s.current&&(s.current.value="")},Se=de=>{var Qe;const ze=(Qe=de.target.files)==null?void 0:Qe[0];if(ze){T(ze);const It=new FileReader;It.onload=se=>{var Re;$((Re=se.target)==null?void 0:Re.result)}
4074,It.readAsDataURL(ze)}},Te=()=>{T(null),$(null),i.current&&(i.current.value="")},He=de=>{K(ze=>ze.includes(de)?ze.filter(Qe=>Qe!==de):[...ze,de])},Ut=de=>{be(ze=>ze.includes(de)?ze.filter(Qe=>Qe!==de):[...ze,de].sort((Qe,It)=>Qe-It))},cn=de=>{be(ze=>ze.filter(Qe=>Qe!==de))},xn=de=>{var ze;return((ze=J.find(Qe=>Qe.code===de))==null?void 0:ze.label)||""},un=async()=>{if(!y.trim()){n.error("Le nom du sponsor est requis");return}if(!Q||!Ae){n.error("Les dates de début et de fin sont requises");return}d(!0);try{const de={name:y.trim(),adTitle:H.trim(),description:D.trim(),city:A.trim(),position:{latitude:parseFloat(_)||0,longitude:parseFloat(L)||0},startDate:gn.fromDate(new Date(Q)),endDate:gn.fromDate(new Date(Ae)),linkUrl:w.trim(),clientEmail:E.trim(),activityCodes:ee,departmentCodes:ue,imageName:(p==null?void 0:p.imageName)||"",logoName:(p==null?void 0:p.logoName)||""};if(r){const ze=await Ni.createSponsor(de,O||void 0,S||void 0);n.success("Sponsor créé avec succès"),e(mt.sponsor(ze))}else t&&(await Ni.updateSponsor(t,de,O||void 0,S||void 0),n.success("Sponsor mis à jour"),Ue())}catch(de){console.error("Error saving sponsor:",de),n.error("Erreur lors de la sauvegarde")}finally{d(!1)}},Yt=async()=>{if(!(!t||r)){f(!0);try{await Ni.deleteSponsor(t),n.success("Sponsor supprimé"),e(xe.sponsors)}catch(de){console.error("Error deleting sponsor:",de),n.error("Erreur lors de la suppression")}finally{f(!1)}}};if(a)return o.jsx(UO,{});const st=cle(p==null?void 0:p.stats);return o.jsxs("div",{className:"p-4 md:p-6 space-y-4 md:space-y-6 max-w-5xl mx-auto",children:[o.jsxs("div",{className:"sticky top-0 z-20 -mx-4 md:-mx-6 px-4 md:px-6 py-3 bg-background border-b flex items-center justify-between gap-3",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>e(xe.sponsors),children:o.jsx(Nr,{className:"h-5 w-5"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("h1",{className:"text-xl md:text-2xl font-bold text-foreground font-heading truncate",children:r?"Nouveau sponsor":y||"Modifier le sponsor"}),!r&&p&&o.jsxs("div",{className:"hidden sm:flex items-center gap-4 text-sm text-muted-foreground",children:[o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(gh,{className:"h-4 w-4"}),p.nbRead||0," vues au total"]}),o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(vh,{className:"h-4 w-4"}),p.nbTap||0," clics au total"]})]})]})]}),o.jsxs(Z,{className:"shrink-0",onClick:un,disabled:c||!Jt,children:[c?o.jsx(ft,{className:"h-4 w-4 mr-2 animate-spin"}):o.jsx(xc,{className:"h-4 w-4 mr-2"}),r?"Créer":"Enregistrer"]})]}),!r&&p&&o.jsxs(ke,{children:[o.jsx(Qt,{children:o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(MK,{className:"w-5 h-5"}),"Statistiques"]})}),o.jsx(Pe,{children:st.hasData?o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:[o.jsx(Ip,{icon:o.jsx(gh,{className:"h-4 w-4 shrink-0"}),label:"Affichages",period:"7 derniers jours",value:st.last7Days.reads,trend:Pp(st.last7Days.reads,st.previous7Days.reads),comparison:`7 j précédents : ${st.previous7Days.reads}`}),o.jsx(Ip,{icon:o.jsx(vh,{className:"h-4 w-4 shrink-0"}),label:"Clics",period:"7 derniers jours",value:st.last7Days.taps,trend:Pp(st.last7Days.taps,st.previous7Days.taps),comparison:`7 j précédents : ${st.previous7Days.taps}`}),o.jsx(Ip,{icon:o.jsx(gh,{className:"h-4 w-4 shrink-0"}
4074),label:"Affichages",period:rh(st.currentMonthKey),value:st.currentMonth.reads,trend:Pp(st.currentMonth.reads,st.previousMonth.reads),comparison:`${rh(st.previousMonthKey)} : ${st.previousMonth.reads}`}),o.jsx(Ip,{icon:o.jsx(vh,{className:"h-4 w-4 shrink-0"}),label:"Clics",period:rh(st.currentMonthKey),value:st.currentMonth.taps,trend:Pp(st.currentMonth.taps,st.previousMonth.taps),comparison:`${rh(st.previousMonthKey)} : ${st.previousMonth.taps}`})]}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-semibold mb-3",children:"Historique par mois"}),o.jsx("div",{className:"space-y-4",children:st.monthlyRows.map(({key:de,reads:ze,taps:Qe})=>o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm",children:[o.jsx("span",{className:"font-medium capitalize truncate",children:rh(de)}),o.jsxs("span",{className:"flex items-center gap-4 text-muted-foreground shrink-0",children:[o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(gh,{className:"h-4 w-4"}),ze]}),o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(vh,{className:"h-4 w-4"}),Qe]})]})]}),o.jsx("div",{className:"h-2 rounded-full bg-muted overflow-hidden",children:o.jsx("div",{className:"h-full bg-primary",style:{width:`${st.maxMonthlyReads?ze/st.maxMonthlyReads*100:0}%`}})})]},de))})]})]}):o.jsx("p",{className:"text-sm text-muted-foreground",children:"Aucune statistique enregistrée pour le moment."})})]}),o.jsxs(ke,{children:[o.jsx(Qt,{children:o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(qn,{className:"w-5 h-5"}),"Le sponsor"]})}),o.jsxs(Pe,{className:"space-y-6",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row items-start gap-4",children:[o.jsxs("div",{className:"space-y-2 shrink-0",children:[o.jsx(ne,{children:"Logo"}),o.jsx("div",{className:"w-32 h-32 border-2 border-dashed rounded-lg flex items-center justify-center cursor-pointer hover:border-blue-500 transition-colors overflow-hidden bg-muted",onClick:()=>{var de;return(de=i.current)==null?void 0:de.click()},children:V?o.jsx("img",{src:V,alt:"Logo",className:"w-full h-full object-contain"}):o.jsxs("div",{className:"text-center text-muted-foreground/60",children:[o.jsx(No,{className:"h-8 w-8 mx-auto mb-1"}),o.jsx("span",{className:"text-xs",children:"Cliquez pour ajouter"})]})}),o.jsx("input",{ref:i,type:"file",accept:"image/*",onChange:Se,className:"hidden"}),V&&o.jsxs(Z,{variant:"outline",size:"sm",className:"w-full",onClick:Te,children:[o.jsx(br,{className:"h-4 w-4 mr-1"}),"Supprimer"]})]}),o.jsxs("div",{className:"flex-1 w-full space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"name",children:"Nom *"}),o.jsx(Ne,{id:"name",value:y,onChange:de=>b(de.target.value),placeholder:"Nom du sponsor"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"clientEmail",children:"Email de contact"}),o.jsxs("div",{className:"relative",children:[o.jsx(rs,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground/60"}),o.jsx(Ne,{id:"clientEmail",type:"email",value:E,onChange:de=>P(de.target.value),placeholder:"[email protected]",className:"pl-10"})]}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Usage interne : destinataire du rapport de statistiques hebdomadaire. Jamais affiché dans l'application."})]})]})]}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"linkUrl",children:"Site web (facultatif)"}),o.jsxs("div",{className:"relative",children:[o.jsx(WK,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground/60"}),o.jsx(Ne,{id:"linkUrl",value:w,onChange:de=>j(de.target.value),placeholder:"https://...",className:"pl-10"})]}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Ouvert lorsqu'un utilisateur clique sur la publicité. Sans lien, le bouton devient « Compris » et referme simplement la publicité."})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ne,{className:"flex items-center gap-2",children:[o.jsx(Rn,{className:"w-4 h-4"}),"Localisation"]}),o.jsx(Ne,{value:A,onChange:de=>N(de.target.value),placeholder:"Ville"}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsx(Ne,{type:"number",step:"any",value:_,onCh
4074ange:de=>k(de.target.value),placeholder:"Latitude"}),o.jsx(Ne,{type:"number",step:"any",value:L,onChange:de=>I(de.target.value),placeholder:"Longitude"})]}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Position du marqueur sur la carte. Laisser vide si le sponsor n'a pas de point de vente."})]})]})]})]}),o.jsxs(ke,{children:[o.jsx(Qt,{children:o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(yx,{className:"w-5 h-5"}),"La publicité"]})}),o.jsxs(Pe,{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{children:"Visuel"}),o.jsxs("div",{className:"flex items-start gap-4",children:[o.jsx("div",{className:"w-48 h-32 border-2 border-dashed rounded-lg flex items-center justify-center cursor-pointer hover:border-blue-500 transition-colors overflow-hidden bg-muted shrink-0",onClick:()=>{var de;return(de=s.current)==null?void 0:de.click()},children:G?re?o.jsx("video",{src:G,className:"w-full h-full object-cover",muted:!0,loop:!0,autoPlay:!0,playsInline:!0}):o.jsx("img",{src:G,alt:"Preview",className:"w-full h-full object-cover"}):o.jsxs("div",{className:"text-center text-muted-foreground/60",children:[o.jsx(No,{className:"h-8 w-8 mx-auto mb-1"}),o.jsx("span",{className:"text-xs",children:"Cliquez pour ajouter"})]})}),o.jsx("input",{ref:s,type:"file",accept:`image/*,${nle}`,onChange:me,className:"hidden"}),G&&o.jsxs(Z,{variant:"outline",size:"sm",onClick:ot,children:[o.jsx(br,{className:"h-4 w-4 mr-1"}),"Supprimer"]})]}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Image ou vidéo, affichée en plein écran à l'ouverture de l'application. La vidéo démarre automatiquement, en boucle et sans son (l'utilisateur peut l'activer)."," ",Pw," Mo maximum : elle est téléchargée à chaque affichage."]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"adTitle",children:"Titre"}),o.jsx(Ne,{id:"adTitle",value:H,onChange:de=>W(de.target.value),placeholder:"Titre affiché dans la publicité"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Laisser vide pour reprendre le nom du sponsor."})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"description",children:"Description"}),o.jsx(bc,{id:"description",value:D,onChange:de=>F(de.target.value.slice(0,Sp)),placeholder:"Texte de présentation du sponsor.",rows:6,maxLength:Sp}),o.jsxs("p",{className:`text-xs text-right ${D.length>=Sp?"text-destructive":"text-muted-foreground"}`,children:[D.length," / ",Sp]}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Dans l'application, les 5 premières lignes sont affichées ; au-delà , un bouton « Voir plus » déplie le texte."})]})]})]}),o.jsxs(ke,{children:[o.jsx(Qt,{children:o.jsxs(Xt,{className:"flex items-center gap-2",children:[o.jsx(ZL,{className:"w-5 h-5"}),"Cible"]})}),o.jsxs(Pe,{className:"space-y-6",children:[o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{children:"Activités"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:ee.length===0?"â ï¸ Aucune activité sélectionnée : la publicité ne sera visible par personne.":"Visible uniquement pour les activités sélectionnées."}),o.jsx("div",{className:"flex flex-wrap gap-2 pt-1",children:Object.entries(GC).map(([de,ze])=>o.jsx(We,{variant:ee.includes(parseInt(de))?"default":"outline",className:"cursor-pointer",onClick:()=>He(parseInt(de)),children:ZC[ze]},de))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{children:"Départements"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:ue.length===0?"Visible dans tous les départements.":"Visible uniquement dans les départements sélectionnés."}),o.jsx("div",{className:"pt-1",children:o.jsxs(hO,{open:le,onOpenChange:B,children:[o.jsx(fO,{asChild:!0,children:o.jsxs(Z,{variant:"outline",role:"combobox","aria-expanded":le,className:"w-full justify-between font-normal",children:[ue.length===0?"Rechercher un départementâ¦":`${ue.length} département${ue.length>1?"s":""} sélectionné${ue.length>
40741?"s":""}`,o.jsx(u1,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),o.jsx(mO,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:o.jsxs(LO,{filter:ule,children:[o.jsx(MO,{placeholder:"Code ou nom du départementâ¦"}),o.jsxs(OO,{children:[o.jsx(FO,{children:"Aucun département trouvé."}),o.jsx(zO,{children:J.map(de=>{const ze=String(de.code).padStart(2,"0"),Qe=ue.includes(de.code);return o.jsxs($O,{value:`${ze} ${de.label}`,onSelect:()=>Ut(de.code),children:[o.jsx(Xn,{className:Kn("mr-2 h-4 w-4",Qe?"opacity-100":"opacity-0")}),o.jsx("span",{className:"font-mono text-xs text-muted-foreground mr-2",children:ze}),de.label]},de.code)})})]})]})})]})}),ue.length>0&&o.jsx("div",{className:"flex flex-wrap gap-2 pt-1",children:ue.map(de=>{const ze=xn(de);return o.jsxs(We,{variant:"secondary",className:"cursor-pointer",onClick:()=>cn(de),children:[String(de).padStart(2,"0"),ze&&` - ${ze}`,o.jsx(br,{className:"h-3 w-3 ml-1"})]},de)})})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ne,{className:"flex items-center gap-2",children:[o.jsx(Da,{className:"w-4 h-4"}),"Période de diffusion *"]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ne,{htmlFor:"startDate",className:"text-xs text-muted-foreground",children:"Début"}),o.jsx(Ne,{id:"startDate",type:"date",value:Q,onChange:de=>ve(de.target.value)})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ne,{htmlFor:"endDate",className:"text-xs text-muted-foreground",children:"Fin"}),o.jsx(Ne,{id:"endDate",type:"date",value:Ae,onChange:de=>he(de.target.value)})]})]}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Les deux dates sont incluses : la publicité est diffusée du premier au dernier jour choisi, journées entières."})]})]})]}),!r&&o.jsxs(ke,{className:"border-destructive/50",children:[o.jsx(Qt,{children:o.jsxs(Xt,{className:"flex items-center gap-2 text-destructive",children:[o.jsx(an,{className:"w-5 h-5"}),"Zone de danger"]})}),o.jsx(Pe,{children:o.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"font-medium",children:"Supprimer ce sponsor"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Le sponsor, son image, son logo et ses statistiques seront définitivement perdus. Pour le retirer temporairement de la publicité, utilisez plutôt l'interrupteur « Dans la pub » depuis la liste des sponsors."})]}),o.jsxs(Dn,{children:[o.jsx(cm,{asChild:!0,children:o.jsxs(Z,{variant:"destructive",disabled:h,className:"shrink-0",children:[h?o.jsx(ft,{className:"h-4 w-4 mr-2 animate-spin"}):o.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Supprimer"]})}),o.jsxs(Ln,{children:[o.jsxs(Mn,{children:[o.jsx(Fn,{children:"Supprimer ce sponsor ?"}),o.jsx(zn,{children:"Cette action est irréversible. Le sponsor, son image et son logo seront définitivement supprimés."})]}),o.jsxs(On,{children:[o.jsx(Vn,{children:"Annuler"}),o.jsx($n,{onClick:Yt,children:"Supprimer"})]})]})]})]})})]})]})}const fle="modulepreload",mle=function(t){return"/"+t},yI={},ple=function(e,n,r){let s=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(n.map(c=>{if(c=mle(c),c in yI)return;yI[c]=!0;const d=c.endsWith(".css"),h=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${h}`))return;const f=document.createElement("link");if(f.rel=d?"stylesheet":fle,d||(f.as="script"),f.crossOrigin="",f.href=c,l&&f.setAttribute("nonce",l),document.head.appendChild(f),d)return new Promise((p,g)=>{f.addEventListener("load",p),f.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return s.then(a=>{for(const l of a||[])l.status==="rejected"&&i(l.reason);return e().catch(i)})},Rw={async getPaymentHistory(){try{return(await pe(ge,"getPaymentHistory")()).data.payments||[]}catch(t){return console.error("Error getting payment history:",t),[]}},async getPrices(){try{const e=await pe(ge,"getStripePrices")();return{solo:e.data.solo,asso:e.data.asso}}catch(t){throw console.error("Error getting Stripe prices:",t),new Error(t.message||"Erreur lors de la récupération des prix")}},async createSubscriptionCheckout(t,e){try{const r=await pe(ge,"createSubscriptionCheckout")({priceType:t,userId:e,successUrl:`${window.location.origin}${xe.profile}?subscription=success`,cancelUrl:`${window.location.origin}${xe.profile}?subscription=cancel`});return{sessionId:r.data.sessionId,url:r.data.url}}catch(n){throw console.error("Error creating subscription checkout:",n),new Error(n.message||"Erreur lors de la création de l'abonnement")}},async createNoAdsCheckout(t){try{const n=await pe(ge,"createNoAdsCheckout")({userId:t,successUrl:`${window.location.origin}${xe.profile}?noAds=success`,cancelUrl:`${window.location.origin}${xe.profile}?noAds=cancel`});return{sessionId:n.data.sessionId,url:n.data.url}}catch(e){throw console.error("Error creating noAds checkout:",e),new Error(e.message||"Erreur lors de la création du paiement")}},async createMissionCheckout(t,e){try{const r=await pe(ge,"createMissionCheckout")({missionId:t,candidatureId:e,successUrl:`${window.location.origin}${mt.paymentReturn("succes")}`,cancelUrl:`${window.location.origin}${mt.paymentReturn("annule")}`});return{sessionId:r.data.sessionId,url:r.data.url}}catch(n){throw console.error("Error creating mission checkout:",n),new Error(n.message||"Erreur lors de la création du paiement")}}};function gle(){var re,U,ee;const{user:t,refreshUser:e}=nn(),{activeCompanyId:n}=cd(),r=Ft(),s=qt(),[i,a]=u.useState(!1),[l,c]=u.useState(!1),[d,h]=u.useState(!1),[f,p]=u.useState(null),[g,v]=u.useState(null),[x,y]=u.useState(null),[b,w]=u.useState([]),[j,E]=u.useState(""),[P,A]=u.useState(""),[N,_]=u.useState(""),[k,L]=u.useState(""),[I,S]=u.useState(!1);if(u.useEffect(()=>{E((t==null?void 0:t.firstName)||""),A((t==null?void 0:t.lastName)||""),_((t==null?void 0:t.pseudo)||""),L((t==null?void 0:t.phoneNumber)||"")},[t==null?void 0:t.id,t==null?void 0:t.firstName,t==null?void 0:t.lastName,t==null?void 0:t.pseudo,t==null?void 0:t.phoneNumber]),u.useEffect(()=>{t&&(Rw.getPrices().then(v).catch(()=>{}),Rw.getPaymentHistory().then(w).catch(()=>{}),ple(async()=>{const{premiumService:K}=await Promise.resolve().then(()=>dee);return{premiumService:K}},void 0).then(({premiumService:K})=>{K.getUserPremium(t.id,n).then(y).catch(()=>{})}))},[t==null?void 0:t.id,n]),!t)return null;const T=["farmer","louvetier","trapper","federation","ddt","chambre_agriculture","asso_piegeurs"],V=((re=t.roles)==null?void 0:re.filter(K=>
4074T.includes(K)))||[],$=Object.keys(t.companyRoles||{}).length>0,H=$?"asso":"solo",W=$?"Chasseur Association":"Chasseur Solo",D=async K=>{p(K);try{const ue=await Rw.createSubscriptionCheckout(K);window.location.href=ue.url}catch(ue){r.error(ue.message||"Erreur lors de la souscription"),p(null)}},F=async()=>{c(!0);try{await f1.resetPassword(t.email),h(!0)}catch{r.error("Erreur lors de l'envoi de l'email")}finally{c(!1)}},O=j.trim()!==(t.firstName||"")||P.trim()!==(t.lastName||"")||N.trim()!==(t.pseudo||"")||k.trim()!==(t.phoneNumber||""),Y=async()=>{if(!N.trim()){r.error("Le pseudo est obligatoire");return}S(!0);try{await qs.updateMyProfile(t.id,{firstName:j.trim(),lastName:P.trim(),pseudo:N.trim(),phoneNumber:k.trim()}),await e(),r.success("Profil mis à jour")}catch{r.error("Erreur lors de la mise à jour du profil")}finally{S(!1)}},G=(U=t.createdAt)!=null&&U.seconds?new Date(t.createdAt.seconds*1e3).toLocaleDateString("fr-FR",{day:"numeric",month:"long",year:"numeric"}):null,q=K=>K.split(" ").map(ue=>ue[0]).join("").toUpperCase().slice(0,2);return o.jsxs("div",{className:"p-4 md:p-8 max-w-2xl mx-auto space-y-6",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("div",{className:"h-14 w-14 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0",children:o.jsx("span",{className:"text-lg font-bold text-primary",children:q(bn(t))})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("h1",{className:"text-2xl font-bold text-foreground font-heading truncate",children:bn(t)}),o.jsx("p",{className:"text-muted-foreground text-sm",children:kx(t)})]})]}),o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6 space-y-5",children:[o.jsxs("div",{className:"flex items-center gap-2 text-foreground",children:[o.jsx(po,{className:"h-4 w-4 text-muted-foreground"}),o.jsx("h2",{className:"font-semibold",children:"Informations personnelles"})]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs(ne,{htmlFor:"profile-first-name",className:"text-muted-foreground text-xs flex items-center gap-1.5",children:[o.jsx(po,{className:"h-3 w-3"})," Prénom"]}),o.jsx(Ne,{id:"profile-first-name",value:j,onChange:K=>E(K.target.value),placeholder:"Non renseigné"})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs(ne,{htmlFor:"profile-last-name",className:"text-muted-foreground text-xs flex items-center gap-1.5",children:[o.jsx(po,{className:"h-3 w-3"})," Nom"]}),o.jsx(Ne,{id:"profile-last-name",value:P,onChange:K=>A(K.target.value),placeholder:"Non renseigné"})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs(ne,{htmlFor:"profile-pseudo",className:"text-muted-foreground text-xs flex items-center gap-1.5",children:[o.jsx(po,{className:"h-3 w-3"})," Pseudo"]}),o.jsx(Ne,{id:"profile-pseudo",value:N,onChange:K=>_(K.target.value)})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs(ne,{className:"text-muted-foreground text-xs flex items-center gap-1.5",children:[o.jsx(rs,{className:"h-3 w-3"})," Email"]}),o.jsx("p",{className:"text-sm font-medium",children:t.email})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs(ne,{htmlFor:"profile-phone",className:"text-muted-foreground text-xs flex items-center gap-1.5",children:[o.jsx(rm,{className:"h-3 w-3"})," Téléphone"]}),o.jsx(Ne,{id:"profile-phone",type:"tel",value:k,onChange:K=>L(K.target.value),placeholder:"Non renseigné"})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs(ne,{className:"text-muted-foreground text-xs flex items-center gap-1.5",children:[o.jsx(Rn,{className:"h-3 w-3"})," Département"]}),o.jsx("p",{className:"text-sm font-medium",children:t.departmentLabel?`${t.departmentLabel} (${t.departmentCode})`:"Non renseigné"})]}),G&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs(ne,{className:"text-muted-foreground text-xs flex items-center gap-1.5",children:[o.jsx(Da,{className:"h-3 w-3"})," Inscrit le"]}),o.jsx("p",{className:"text-sm font-medium",children:G})]})]}),o.jsx("div",{className:"flex justify-end",children:o.jsxs(Z,{onClick:Y,disabled:!O||I,children:[I?o.jsx(hs,{className:"h-4 w-4 animate-spin mr-2"}):null,"Enregistrer"]})})]})}),o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6 space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-2 text-foreground",children:[o.jsx(rc,{className:"h-4 w-4 text-muted-foreground"}),o.jsx("h2",{className:"font-semibold",children:"Rôles et permissions"})]}),o.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.isSuperAdmin&&o.jsx(We,{className:"bg-app-red/10 text-app-red border-app-red/20",children:"Super Admin"}),V.length>0?V.map(K=>o.jsx(We,{variant:"secondary",children:bu[K]},K)):!t.isSuperAdmin&&o.jsx("span",{className:"text-sm text-muted-foreground",children:"Utilisateur standard"})]})]})}),o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6 space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-2 text-foreground",children:[o.jsx(Cf,{className:"h-4 w-4 text-muted-foreground"}),o.jsx("h2",{className:"font-semibold",children:"Profiter de Chassé & Croisé"})]}),x!=null&&x.isPremium?o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(We,{className:"bg-green-500/10 text-green-600 border-green-500/20",children:[o.jsx(Gc,{
4074className:"h-3 w-3 mr-1"}),"Premium actif"]}),x.premiumEndDate&&o.jsxs("span",{className:"text-sm text-muted-foreground ml-auto",children:["jusqu'au ",new Date(x.premiumEndDate).toLocaleDateString("fr-FR")]})]}),x.source==="revenuecat"&&o.jsx("p",{className:"text-sm text-muted-foreground",children:"Géré depuis l'application mobile. Pour modifier votre abonnement, rendez-vous dans les paramètres de l'app."}),((ee=x.sources)==null?void 0:ee.some(K=>K.scope==="company"))&&o.jsx("p",{className:"text-sm text-muted-foreground",children:"Activé via votre société de chasse."})]}):o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsx(ke,{className:"border-2 border-primary/50 flex flex-col",children:o.jsxs(Pe,{className:"p-5 flex flex-col flex-1",children:[o.jsx("h3",{className:"font-semibold text-center",children:"Gratuit"}),o.jsx("p",{className:"text-2xl font-bold mt-2 text-center",children:"0 ⬠/ an"}),o.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Inclus pour tous"}),o.jsxs("ul",{className:"mt-4 space-y-2 text-sm text-muted-foreground flex-1",children:[o.jsxs("li",{className:"flex items-start gap-2",children:[o.jsx(ns,{className:"h-4 w-4 text-primary flex-shrink-0 mt-0.5"}),"Alerte en approche d'une battue (1km, 300m, zone)"]}),o.jsxs("li",{className:"flex items-start gap-2",children:[o.jsx(ns,{className:"h-4 w-4 text-primary flex-shrink-0 mt-0.5"}),"Alerte proximité d'un autre usager (~80m)"]})]})]})}),o.jsx(ke,{className:"border-2 flex flex-col",children:o.jsxs(Pe,{className:"p-5 flex flex-col flex-1",children:[o.jsx("h3",{className:"font-semibold text-center",children:"Premium"}),o.jsx("p",{className:"text-2xl font-bold mt-2 text-center text-primary",children:H==="asso"?(g==null?void 0:g.asso.formatted)??"...":(g==null?void 0:g.solo.formatted)??"..."}),o.jsx("p",{className:"text-xs text-muted-foreground text-center",children:W}),o.jsxs("ul",{className:"mt-4 space-y-2 text-sm text-muted-foreground flex-1",children:[o.jsxs("li",{className:"flex items-start gap-2",children:[o.jsx(ns,{className:"h-4 w-4 text-primary flex-shrink-0 mt-0.5"}),"Fonctionnalités de la version gratuite incluses"]}),o.jsxs("li",{className:"flex items-start gap-2",children:[o.jsx(ns,{className:"h-4 w-4 text-primary flex-shrink-0 mt-0.5"}),"Délimitation du territoire chassable"]}),o.jsxs("li",{className:"flex items-start gap-2",children:[o.jsx(ns,{className:"h-4 w-4 text-primary flex-shrink-0 mt-0.5"}),"Découpage : réserve, zone privée"]}),o.jsxs("li",{className:"flex items-start gap-2",children:[o.jsx(ns,{className:"h-4 w-4 text-primary flex-shrink-0 mt-0.5"}),"Points d'intérêt : poste, affût, observation"]}),H==="asso"&&o.jsxs(o.Fragment,{children:[o.jsxs("li",{className:"flex items-start gap-2",children:[o.jsx(ns,{className:"h-4 w-4 text-primary flex-shrink-0 mt-0.5"}),"Protection des cultures"]}),o.jsxs("li",{className:"flex items-start gap-2",children:[o.jsx(ns,{className:"h-4 w-4 text-primary flex-shrink-0 mt-0.5"}),"Messagerie société"]})]})]})]})})]}),$?o.jsx(Z,{className:"w-full",variant:"outline",onClick:()=>s(xe.myCompany),children:"Gérer l'abonnement de ma société"}):o.jsxs(Z,{className:"w-full",disabled:f!==null,onClick:()=>D("solo"),children:[f?o.jsx(hs,{className:"h-4 w-4 animate-spin mr-2"}):null,"Passer au Premium"]})]})]})}),b.length>0&&o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6 space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-2 text-foreground",children:[o.jsx(Cf,{className:"h-4 w-4 text-muted-foreground"}),o.jsx("h2",{className:"font-semibold",children:"Historique des achats"})]}),o.jsx("div",{className:"space-y-3",children:b.map(K=>o.jsxs("div",{className:"flex items-center justify-between py-2 border-b last:border-b-0",children:[o.jsxs("div",{className:"space-y-0.5",children:[o.jsx("p",{className:"text-sm font-medium",children:K.description}),o.jsx("p",{className:"text-xs text-muted-foreground",children:K.date?new Date(K.date).toLocaleDateString("fr-FR",{day:"numeric",month:"long",year:"numeric"}):"-"})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("span",{className:"text-sm font-semibold",children:[K.amount.toFixed(2).replace(".",",")," â¬"]}),K.invoiceUrl&&o.jsx("a",{href:K.invoiceUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline",children:"Facture"})]})]},K.id))})]})}),o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6 space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-2 text-foreground",children:[o.jsx(HL,{className:"h-4 w-4 text-muted-foreground"}),o.jsx("h2",{className:"font-semibold",children:"Sécurité"})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-medium",children:"Mot de passe"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Recevez un email pour le modifier"})]}),o.jsx(Z,{variant:"outline",size:"sm",onClick:()=>{h(!1),a(!0)},children:"Modifier"})]})]})}),o.jsx(rr,{open:i,onOpenChange:a,children:o.jsxs(sr,{className:"sm:max-w-md",children:[o.jsxs(or,{children:[o.jsx(Gn,{children:"Modifier le mot de passe"}),o.jsxs(ir,{children:["Un email sera envoyé à ",o.jsx("strong",{children:t.email})," avec un lien de réinitialisation."]})]}),d?o.jsxs("div",{className:"py-4 text-center space-y-3",children:[o.jsx(ns,{className:"h-10 w-10 text-primary mx-auto"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Email envoyé ! Vérifiez votre boîte de réception."}),o.jsx(Z,{onClick:()=>a(!1),className:"w-full",children:"Fermer"})]}):o.jsxs("div",{className:"flex gap-2 pt-2",children:[o.jsx(Z,{variant:"outline",className:"flex-1",onClick:()=>a(!1),children:"Annuler"}),o.jsxs(Z,{className:"flex-1",onClick:F,disabled:l,children:[l?o.jsx(hs,{className:"h-4 w-4 animate-spin mr-2"}):null,"Envoyer"]})]})]})})]})}
4074const wI={reader:"Classique",writer:"Référent",admin:"Admin"},bI=t=>(t||"?").trim().slice(0,1).toUpperCase();function vle(){var T;const{user:t}=nn(),e=Ft(),n=qt(),{onglet:r}=Ys(),{activeCompanyId:s,setActiveCompanyId:i,companies:a}=cd(),[l,c]=u.useState(!1),[d,h]=u.useState(""),[f,p]=u.useState(!1),[g,v]=u.useState(!1),[x,y]=u.useState(!1),[b,w]=u.useState(!1),[j,E]=u.useState({name:"",city:"",zipCode:"",address:"",phone:""}),P=s,A=P&&((T=t==null?void 0:t.companyRoles)==null?void 0:T[P])||"reader",N=A==="admin",_=A==="admin"||A==="writer",k=async()=>{var $,H;const V=d.trim().toUpperCase();if(V.length<5){e.error("Le code doit comporter au moins 5 caractères");return}p(!0);try{await Ot.requestCompanyJoin(V),v(!0),c(!1),h(""),e.success("Demande envoyée")}catch(W){const D=($=W==null?void 0:W.message)!=null&&$.includes("Aucune société")?"Aucune société trouvée pour ce code":(H=W==null?void 0:W.message)!=null&&H.includes("déjà ")?W.message:"Erreur lors de la demande";e.error(D)}finally{p(!1)}},L=async()=>{if(!j.name.trim()){e.error("Le nom est requis");return}w(!0);try{await Ot.createCompany({name:j.name.trim(),address:j.address.trim(),city:j.city.trim(),zipCode:j.zipCode?parseInt(j.zipCode,10):0,phone:j.phone.trim(),identificationCode:"",companyCode:"",kind:"hunt",isPrivacy:!1,user:(t==null?void 0:t.id)||"",creatorName:(t==null?void 0:t.pseudo)||""}),e.success("Société créée"),window.location.reload()}catch(V){console.error("Error creating company:",V),e.error((V==null?void 0:V.message)||"Erreur lors de la création")}finally{w(!1)}},I=o.jsx(rr,{open:l,onOpenChange:c,children:o.jsxs(sr,{className:"sm:max-w-md",children:[o.jsxs(or,{children:[o.jsx(Gn,{children:"Rejoindre une société"}),o.jsx(ir,{children:"Saisissez le code communiqué par un responsable de la société."})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ne,{htmlFor:"join-code",className:"text-muted-foreground text-xs",children:"Code société"}),o.jsx(Ne,{id:"join-code",value:d,onChange:V=>h(V.target.value.toUpperCase()),onKeyDown:V=>{V.key==="Enter"&&!f&&k()},placeholder:"Ex. AB12C",maxLength:10,autoCapitalize:"characters",className:"font-mono tracking-widest uppercase"})]}),o.jsxs(ks,{children:[o.jsx(Z,{variant:"outline",onClick:()=>c(!1),children:"Annuler"}),o.jsx(Z,{onClick:k,disabled:f||d.trim().length<5,children:f?"Envoiâ¦":"Envoyer la demande"})]})]})}),S=o.jsx(rr,{open:x,onOpenChange:y,children:o.jsxs(sr,{className:"sm:max-w-lg",children:[o.jsxs(or,{children:[o.jsx(Gn,{children:"Créer une société"}),o.jsx(ir,{children:"Vous en deviendrez lâadministrateur."})]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[o.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[o.jsx(ne,{htmlFor:"nc-name",children:"Nom *"}),o.jsx(Ne,{id:"nc-name",value:j.name,onChange:V=>E($=>({...$,name:V.target.value}))})]}),o.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[o.jsx(ne,{htmlFor:"nc-address",children:"Adresse"}),o.jsx(Ne,{id:"nc-address",value:j.address,onChange:V=>E($=>({...$,address:V.target.value}))})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ne,{htmlFor:"nc-zip",children:"Code postal"}),o.jsx(Ne,{id:"nc-zip",value:j.zipCode,onChange:V=>E($=>({...$,zipCode:V.target.value}))})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ne,{htmlFor:"nc-city",children:"Ville"}),o.jsx(Ne,{id:"nc-city",value:j.city,onChange:V=>E($=>({...$,city:V.target.value}))})]}),o.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[o.jsx(ne,{htmlFor:"nc-phone",children:"Téléphone"}),o.jsx(Ne,{id:"nc-phone",value:j.phone,onChange:V=>E($=>({...$,phone:V.target.value}))})]})]}),o.jsxs(ks,{children:[o.jsx(Z,{variant:"outline",onClick:()=>y(!1),children:"Annuler"}),o.jsx(Z,{onClick:L,disabled:b||!j.name.trim(),children:b?"Créationâ¦":"Créer"})]})]})});return P?o.jsxs(o.Fragment,{children:[o.jsx(x3,{companyId:P,canEdit:_,isAdmin:N,currentUserId:t==null?void 0:t.id,currentUserName:t?bn(t):void 0,basePath:xe.myCompany,activeTab:qT(r),onTabChange:V=>n(Sg(xe.myCompany,V)),hiddenTabs:_?[]:["members"],renderHeader:({company:V})=>o.jsxs("div",{className:"flex items-center gap-3 px-4 md:px-6 py-3 border-b border-border bg-card flex-shrink-0",children:[o.jsxs(M1,{children:[o.jsx(O1,{asChild:!0,children:o.jsxs("button",{className:"flex items-center gap-2.5 pl-1.5 pr-3 py-1.5 rounded-xl border border-border bg-background hover:bg-muted transition-colors",children:[o.jsx("span",{className:"h-9 w-9 rounded-lg bg-primary/10 text-primary flex items-center justify-center font-bold text-sm flex-shrink-0",children:bI((V==null?void 0:V.name)||"")}),o.jsxs("span",{className:"text-left min-w-0",children:[o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"font-bold font-heading text-[15px] truncate max-w-[40vw] sm:max-w-none",children:(V==null?void 0:V.name)||"â"}),o.jsx(We,{variant:"secondary",className:"hidden sm:inline-flex",children:wI[A]})]}),o.jsx("span",{className:"block text-[11px] text-muted-foreground",children:"Changer de société"})]}),o.jsx(jf,{className:"h-4 w-4 text-muted-foreground flex-shrink-0 ml-1"})]})}),o.jsxs(F1,{align:"start",className:"w-64",children:[o.jsx(T4,{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:"Mes sociétés"}),a.map($=>o.jsxs(Ul,{className:"gap-2.5 cursor-pointer",onSelect:()=>
4074i($.id),children:[o.jsx("span",{className:"h-8 w-8 rounded-lg bg-primary/10 text-primary flex items-center justify-center font-bold text-xs flex-shrink-0",children:bI($.name)}),o.jsxs("span",{className:"flex-1 min-w-0",children:[o.jsx("span",{className:"block text-sm font-semibold truncate",children:$.name}),o.jsx("span",{className:"block text-[11px] text-muted-foreground",children:wI[$.role]})]}),$.id===P&&o.jsx(Xn,{className:"h-4 w-4 text-primary flex-shrink-0"})]},$.id)),o.jsx(tee,{}),o.jsxs(Ul,{className:"gap-2.5 cursor-pointer text-primary",onSelect:()=>y(!0),children:[o.jsx(hr,{className:"h-4 w-4"})," Créer une société"]}),o.jsxs(Ul,{className:"gap-2.5 cursor-pointer",onSelect:()=>c(!0),children:[o.jsx(Jk,{className:"h-4 w-4"})," Rejoindre avec un code"]})]})]}),o.jsx("div",{className:"ml-auto hidden lg:block text-[15px] font-semibold text-muted-foreground font-heading",children:"Mes sociétés"})]})}),I,S]}):o.jsxs("div",{className:"p-4 md:p-8 max-w-md mx-auto",children:[o.jsxs("div",{className:"text-center pt-12 pb-8",children:[o.jsx("div",{className:"inline-flex items-center justify-center h-14 w-14 rounded-full bg-muted mb-4",children:o.jsx(qn,{className:"h-6 w-6 text-muted-foreground/60"})}),o.jsx("p",{className:"font-medium text-foreground",children:"Aucune société"}),o.jsx("p",{className:"text-sm text-muted-foreground mt-1.5",children:"Vous n'êtes membre d'aucune société de chasse."})]}),g?o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6 text-center space-y-3",children:[o.jsx("div",{className:"inline-flex items-center justify-center h-12 w-12 rounded-full bg-primary/10",children:o.jsx(hd,{className:"h-5 w-5 text-primary"})}),o.jsx("p",{className:"font-medium text-foreground",children:"Demande envoyée"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Votre demande doit être validée par un responsable de la société."})]})}):o.jsx(ke,{children:o.jsxs(Pe,{className:"p-6 space-y-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-foreground",children:[o.jsx(qK,{className:"h-4 w-4 text-muted-foreground"}),o.jsx("h2",{className:"font-semibold",children:"Rejoindre ou créer une société"})]}),o.jsxs(Z,{className:"w-full",onClick:()=>c(!0),children:[o.jsx(Jk,{className:"h-4 w-4 mr-2"})," Rejoindre avec un code"]}),o.jsxs(Z,{variant:"outline",className:"w-full",onClick:()=>y(!0),children:[o.jsx(hr,{className:"h-4 w-4 mr-2"})," Créer une société"]})]})}),I,S]})}function jI(){const{statut:t}=Ys(),e=t==="succes";return o.jsx("div",{className:"min-h-[70vh] flex items-center justify-center p-6",children:o.jsxs("div",{className:"max-w-md w-full rounded-2xl border border-border bg-card p-8 text-center space-y-4",children:[e?o.jsx(ns,{className:"h-12 w-12 mx-auto text-green-600"}):o.jsx(KL,{className:"h-12 w-12 mx-auto text-muted-foreground"}),o.jsx("h1",{className:"text-xl font-bold font-heading",children:e?"Paiement enregistré":"Paiement annulé"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:e?"Merci. Vous pouvez fermer cette page et revenir à l'application Chassé & Croisé.":"Aucun montant n'a été prélevé. Vous pouvez fermer cette page et revenir à l'application."})]})})}const xle=({...t})=>o.jsx(TH,{theme:"system",className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...t});function yle({to:t}){const e=Ys(),{search:n,hash:r}=Ui();return o.jsx(Ms,{to:{pathname:_F(t,e),search:n,hash:r},replace:!0})}function hn({children:t,requireZoneManager:e=!1,requireZoneCreator:n=!1,requireSuperAdmin:r=!1,requireUserManager:s=!1,requireFarmerManager:i=!1,requireCompanyManager:a=!1,requireCompanyEditor:l=!1}){const{user:c,loading:d,canManageZones:h,canCreateZones:f,canManageUsers:p,canManageFarmers:g,canViewCompanies:v,isSuperAdmin:x,isCompanyEditor:y}=nn();return d?o.jsx("div",{className:"min-h-screen flex items-center justify-center",children:o.jsx("div",{className:"animate-spin rounded-full h-32 w-32 border-2 border-primary/20 border-t-primary"})}):c?e&&!h?o.jsx(Ms,{to:"/",replace:!0}):n&&!f?o.jsx(Ms,{to:"/",replace:!0}):r&&!x?o.jsx(Ms,{to:"/",replace:!0}):s&&!p?o.jsx(Ms,{to:"/",replace:!0}):i&&!g?o.jsx(Ms,{to:"/",replace:!0}
4074):a&&!v?o.jsx(Ms,{to:"/",replace:!0}):l&&!y?o.jsx(Ms,{to:xe.myCompany,replace:!0}):o.jsx(o.Fragment,{children:t}):o.jsx(Ms,{to:xe.login,replace:!0})}function wle(){const{user:t,loading:e}=nn();return e?o.jsx("div",{className:"min-h-screen flex items-center justify-center",children:o.jsx("div",{className:"animate-spin rounded-full h-32 w-32 border-2 border-primary/20 border-t-primary"})}):t?o.jsxs(F_,{children:[o.jsxs(bt,{path:"/",element:o.jsx(see,{}),children:[o.jsx(bt,{index:!0,element:o.jsx(jee,{})}),o.jsx(bt,{path:xe.profile,element:o.jsx(hn,{children:o.jsx(gle,{})})}),o.jsx(bt,{path:sn.myCompany,element:o.jsx(hn,{children:o.jsx(vle,{})})}),o.jsx(bt,{path:sn.myCompanyHuntingZoneNew,element:o.jsx(hn,{requireCompanyEditor:!0,children:o.jsx(Np,{})})}),o.jsx(bt,{path:sn.myCompanyHuntingZoneEdit,element:o.jsx(hn,{requireCompanyEditor:!0,children:o.jsx(Np,{})})}),o.jsx(bt,{path:xe.zones,element:o.jsx(hn,{requireZoneManager:!0,children:o.jsx(Yee,{})})}),o.jsx(bt,{path:xe.zoneNew,element:o.jsx(hn,{requireZoneCreator:!0,children:o.jsx(Gne,{})})}),o.jsx(bt,{path:sn.zone,element:o.jsx(hn,{requireZoneManager:!0,children:o.jsx(nre,{})})}),o.jsx(bt,{path:xe.companies,element:o.jsx(hn,{requireCompanyManager:!0,children:o.jsx(sre,{})})}),o.jsx(bt,{path:xe.companyNew,element:o.jsx(hn,{requireSuperAdmin:!0,children:o.jsx(sae,{})})}),o.jsx(bt,{path:sn.company,element:o.jsx(hn,{requireCompanyManager:!0,children:o.jsx(nae,{})})}),o.jsx(bt,{path:sn.companyHuntingZoneNew,element:o.jsx(hn,{requireZoneManager:!0,children:o.jsx(Np,{})})}),o.jsx(bt,{path:sn.companyHuntingZoneEdit,element:o.jsx(hn,{requireZoneManager:!0,children:o.jsx(Np,{})})}),o.jsx(bt,{path:xe.departments,element:o.jsx(hn,{requireSuperAdmin:!0,children:o.jsx(dae,{})})}),o.jsx(bt,{path:sn.department,element:o.jsx(hn,{requireSuperAdmin:!0,children:o.jsx(gae,{})})}),o.jsx(bt,{path:xe.users,element:o.jsx(hn,{requireUserManager:!0,children:o.jsx(bae,{})})}),o.jsx(bt,{path:sn.user,element:o.jsx(hn,{requireUserManager:!0,children:o.jsx(lI,{})})}),o.jsx(bt,{path:xe.contracts,element:o.jsx(hn,{requireSuperAdmin:!0,children:o.jsx(Fae,{})})}),o.jsx(bt,{path:xe.premiumAccess,element:o.jsx(hn,{requireCompanyManager:!0,children:o.jsx(Lae,{})})}),o.jsx(bt,{path:xe.farmers,element:o.jsx(hn,{requireFarmerManager:!0,children:o.jsx($ae,{})})}),o.jsx(bt,{path:sn.farmer,element:o.jsx(hn,{requireFarmerManager:!0,children:o.jsx(lI,{})})}),o.jsx(bt,{path:xe.sponsors,element:o.jsx(hn,{requireSuperAdmin:!0,children:o.jsx(ale,{})})}),o.jsx(bt,{path:sn.sponsor,element:o.jsx(hn,{requireSuperAdmin:!0,children:o.jsx(hle,{})})}),o.jsx(bt,{path:sn.plot,element:o.jsx(hn,{children:o.jsx(Qae,{})})}),o.jsx(bt,{path:sn.damage,element:o.jsx(hn,{children:o.jsx(Jae,{})})}),o.jsx(bt,{path:sn.burrow,element:o.jsx(hn,{children:o.jsx(ele,{})})}),o.jsx(bt,{path:sn.payment,element:o.jsx(jI,{})}),gz.map(({from:n,to:r})=>o.jsx(bt,{path:n,element:o.jsx(yle,{to:r})},n))]}),o.jsx(bt,{path:"*",element:o.jsx(Ms,{to:"/",replace:!0})})]}):o.jsxs(F_,{children:[o.jsx(bt,{path:xe.login,element:o.jsx(dY,{})}),o.jsx(bt,{path:xe.signup,element:o.jsx(gX,{})}),o.jsx(bt,{path:sn.payment,element:o.jsx(jI,{})}),vz.map(({from:n,to:r})=>o.jsx(bt,{path:n,element:o.jsx(Ms,{to:r,replace:!0})},n)),o.jsx(bt,{path:"*",element:o.jsx(Ms,{to:xe.login,replace:!0})})]})}function ble(){return o.jsx(zH,{children:o.jsx(AH,{children:o.jsx(sH,{children:o.jsx(OH,{children:o.jsx(BH,{children:o.jsx(VH,{children:o.jsx(kG,{children:o.jsxs(dz,{children:[o.jsx(wle,{}),o.jsx(xle,{})]})})})})})})})})}Dw.createRoot(document.getElementById("root")).render(o.jsx(Ce.StrictMode,{children:o.jsx(ble,{})}));
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.