87 lines
489 KiB
JavaScript
87 lines
489 KiB
JavaScript
function jp(t,e){for(var r=0;r<e.length;r++){const n=e[r];if(typeof n!="string"&&!Array.isArray(n)){for(const s in n)if(s!=="default"&&!(s in t)){const i=Object.getOwnPropertyDescriptor(n,s);i&&Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:()=>n[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"]'))n(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"&&n(a)}).observe(document,{childList:!0,subtree:!0});function r(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 n(s){if(s.ep)return;s.ep=!0;const i=r(s);fetch(s.href,i)}})();var Ar=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function kd(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function gs(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:function(){return t[n]}})}),r}var _d={exports:{}},Xi={},Ed={exports:{}},W={};/**
|
||
* @license React
|
||
* react.production.min.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/var ms=Symbol.for("react.element"),Np=Symbol.for("react.portal"),Tp=Symbol.for("react.fragment"),Pp=Symbol.for("react.strict_mode"),Cp=Symbol.for("react.profiler"),Ap=Symbol.for("react.provider"),Op=Symbol.for("react.context"),Rp=Symbol.for("react.forward_ref"),zp=Symbol.for("react.suspense"),Ip=Symbol.for("react.memo"),Lp=Symbol.for("react.lazy"),Ou=Symbol.iterator;function Dp(t){return t===null||typeof t!="object"?null:(t=Ou&&t[Ou]||t["@@iterator"],typeof t=="function"?t:null)}var Sd={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},jd=Object.assign,Nd={};function yn(t,e,r){this.props=t,this.context=e,this.refs=Nd,this.updater=r||Sd}yn.prototype.isReactComponent={};yn.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")};yn.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function Td(){}Td.prototype=yn.prototype;function Sl(t,e,r){this.props=t,this.context=e,this.refs=Nd,this.updater=r||Sd}var jl=Sl.prototype=new Td;jl.constructor=Sl;jd(jl,yn.prototype);jl.isPureReactComponent=!0;var Ru=Array.isArray,Pd=Object.prototype.hasOwnProperty,Nl={current:null},Cd={key:!0,ref:!0,__self:!0,__source:!0};function Ad(t,e,r){var n,s={},i=null,a=null;if(e!=null)for(n in e.ref!==void 0&&(a=e.ref),e.key!==void 0&&(i=""+e.key),e)Pd.call(e,n)&&!Cd.hasOwnProperty(n)&&(s[n]=e[n]);var o=arguments.length-2;if(o===1)s.children=r;else if(1<o){for(var u=Array(o),c=0;c<o;c++)u[c]=arguments[c+2];s.children=u}if(t&&t.defaultProps)for(n in o=t.defaultProps,o)s[n]===void 0&&(s[n]=o[n]);return{$$typeof:ms,type:t,key:i,ref:a,props:s,_owner:Nl.current}}function Mp(t,e){return{$$typeof:ms,type:t.type,key:e,ref:t.ref,props:t.props,_owner:t._owner}}function Tl(t){return typeof t=="object"&&t!==null&&t.$$typeof===ms}function Fp(t){var e={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(r){return e[r]})}var zu=/\/+/g;function _a(t,e){return typeof t=="object"&&t!==null&&t.key!=null?Fp(""+t.key):e.toString(36)}function ei(t,e,r,n,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 ms:case Np:a=!0}}if(a)return a=t,s=s(a),t=n===""?"."+_a(a,0):n,Ru(s)?(r="",t!=null&&(r=t.replace(zu,"$&/")+"/"),ei(s,e,r,"",function(c){return c})):s!=null&&(Tl(s)&&(s=Mp(s,r+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(zu,"$&/")+"/")+t)),e.push(s)),1;if(a=0,n=n===""?".":n+":",Ru(t))for(var o=0;o<t.length;o++){i=t[o];var u=n+_a(i,o);a+=ei(i,e,r,u,s)}else if(u=Dp(t),typeof u=="function")for(t=u.call(t),o=0;!(i=t.next()).done;)i=i.value,u=n+_a(i,o++),a+=ei(i,e,r,u,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 Es(t,e,r){if(t==null)return t;var n=[],s=0;return ei(t,n,"","",function(i){return e.call(r,i,s++)}),n}function $p(t){if(t._status===-1){var e=t._result;e=e(),e.then(function(r){(t._status===0||t._status===-1)&&(t._status=1,t._result=r)},function(r){(t._status===0||t._status===-1)&&(t._status=2,t._result=r)}),t._status===-1&&(t._status=0,t._result=e)}if(t._status===1)return t._result.default;throw t._result}var Le={current:null},ti={transition:null},Bp={ReactCurrentDispatcher:Le,ReactCurrentBatchConfig:ti,ReactCurrentOwner:Nl};function Od(){throw Error("act(...) is not supported in production builds of React.")}W.Children={map:Es,forEach:function(t,e,r){Es(t,function(){e.apply(this,arguments)},r)},count:function(t){var e=0;return Es(t,function(){e++}),e},toArray:function(t){return Es(t,function(e){return e})||[]},only:function(t){if(!Tl(t))throw Error("React.Children.only expected to receive a single React element child.");return t}};W.Component=yn;W.Fragment=Tp;W.Profiler=Cp;W.PureComponent=Sl;W.StrictMode=Pp;W.Suspense=zp;W.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Bp;W.act=Od;W.cloneElement=function(t,e,r){if(t==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var n=jd({},t.props),s=t.key,i=t.ref,a=t._owner;if(e!=null){if(e.ref!==void 0&&(i=e.ref,a=Nl.current),e.key!==void 0&&(s=""+e.key),t.type&&t.type.defaultProps)var o=t.type.defaultProps;for(u in e)Pd.call(e,u)&&!Cd.hasOwnProperty(u)&&(n[u]=e[u]===void 0&&o!==void 0?o[u]:e[u])}var u=arguments.length-2;if(u===1)n.children=r;else if(1<u){o=Array(u);for(var c=0;c<u;c++)o[c]=arguments[c+2];n.children=o}return{$$typeof:ms,type:t.type,key:s,ref:i,props:n,_owner:a}};W.createContext=function(t){return t={$$typeof:Op,_currentValue:t,_currentValue2:t,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},t.Provider={$$typeof:Ap,_context:t},t.Consumer=t};W.createElement=Ad;W.createFactory=function(t){var e=Ad.bind(null,t);return e.type=t,e};W.createRef=function(){return{current:null}};W.forwardRef=function(t){return{$$typeof:Rp,render:t}};W.isValidElement=Tl;W.lazy=function(t){return{$$typeof:Lp,_payload:{_status:-1,_result:t},_init:$p}};W.memo=function(t,e){return{$$typeof:Ip,type:t,compare:e===void 0?null:e}};W.startTransition=function(t){var e=ti.transition;ti.transition={};try{t()}finally{ti.transition=e}};W.unstable_act=Od;W.useCallback=function(t,e){return Le.current.useCallback(t,e)};W.useContext=function(t){return Le.current.useContext(t)};W.useDebugValue=function(){};W.useDeferredValue=function(t){return Le.current.useDeferredValue(t)};W.useEffect=function(t,e){return Le.current.useEffect(t,e)};W.useId=function(){return Le.current.useId()};W.useImperativeHandle=function(t,e,r){return Le.current.useImperativeHandle(t,e,r)};W.useInsertionEffect=function(t,e){return Le.current.useInsertionEffect(t,e)};W.useLayoutEffect=function(t,e){return Le.current.useLayoutEffect(t,e)};W.useMemo=function(t,e){return Le.current.useMemo(t,e)};W.useReducer=function(t,e,r){return Le.current.useReducer(t,e,r)};W.useRef=function(t){return Le.current.useRef(t)};W.useState=function(t){return Le.current.useState(t)};W.useSyncExternalStore=function(t,e,r){return Le.current.useSyncExternalStore(t,e,r)};W.useTransition=function(){return Le.current.useTransition()};W.version="18.3.1";Ed.exports=W;var T=Ed.exports;const v=kd(T);/**
|
||
* @license React
|
||
* react-jsx-runtime.production.min.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/var Up=T,Hp=Symbol.for("react.element"),Vp=Symbol.for("react.fragment"),Wp=Object.prototype.hasOwnProperty,Kp=Up.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,qp={key:!0,ref:!0,__self:!0,__source:!0};function Rd(t,e,r){var n,s={},i=null,a=null;r!==void 0&&(i=""+r),e.key!==void 0&&(i=""+e.key),e.ref!==void 0&&(a=e.ref);for(n in e)Wp.call(e,n)&&!qp.hasOwnProperty(n)&&(s[n]=e[n]);if(t&&t.defaultProps)for(n in e=t.defaultProps,e)s[n]===void 0&&(s[n]=e[n]);return{$$typeof:Hp,type:t,key:i,ref:a,props:s,_owner:Kp.current}}Xi.Fragment=Vp;Xi.jsx=Rd;Xi.jsxs=Rd;_d.exports=Xi;var l=_d.exports,co={},zd={exports:{}},Ze={},Id={exports:{}},Ld={};/**
|
||
* @license React
|
||
* scheduler.production.min.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/(function(t){function e(R,M){var H=R.length;R.push(M);e:for(;0<H;){var X=H-1>>>1,ie=R[X];if(0<s(ie,M))R[X]=M,R[H]=ie,H=X;else break e}}function r(R){return R.length===0?null:R[0]}function n(R){if(R.length===0)return null;var M=R[0],H=R.pop();if(H!==M){R[0]=H;e:for(var X=0,ie=R.length,St=ie>>>1;X<St;){var We=2*(X+1)-1,lr=R[We],at=We+1,jt=R[at];if(0>s(lr,H))at<ie&&0>s(jt,lr)?(R[X]=jt,R[at]=H,X=at):(R[X]=lr,R[We]=H,X=We);else if(at<ie&&0>s(jt,H))R[X]=jt,R[at]=H,X=at;else break e}}return M}function s(R,M){var H=R.sortIndex-M.sortIndex;return H!==0?H:R.id-M.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var a=Date,o=a.now();t.unstable_now=function(){return a.now()-o}}var u=[],c=[],d=1,h=null,f=3,y=!1,w=!1,x=!1,b=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,m=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function g(R){for(var M=r(c);M!==null;){if(M.callback===null)n(c);else if(M.startTime<=R)n(c),M.sortIndex=M.expirationTime,e(u,M);else break;M=r(c)}}function k(R){if(x=!1,g(R),!w)if(r(u)!==null)w=!0,he(E);else{var M=r(c);M!==null&&Re(k,M.startTime-R)}}function E(R,M){w=!1,x&&(x=!1,p(_),_=-1),y=!0;var H=f;try{for(g(M),h=r(u);h!==null&&(!(h.expirationTime>M)||R&&!A());){var X=h.callback;if(typeof X=="function"){h.callback=null,f=h.priorityLevel;var ie=X(h.expirationTime<=M);M=t.unstable_now(),typeof ie=="function"?h.callback=ie:h===r(u)&&n(u),g(M)}else n(u);h=r(u)}if(h!==null)var St=!0;else{var We=r(c);We!==null&&Re(k,We.startTime-M),St=!1}return St}finally{h=null,f=H,y=!1}}var S=!1,j=null,_=-1,N=5,C=-1;function A(){return!(t.unstable_now()-C<N)}function U(){if(j!==null){var R=t.unstable_now();C=R;var M=!0;try{M=j(!0,R)}finally{M?Y():(S=!1,j=null)}}else S=!1}var Y;if(typeof m=="function")Y=function(){m(U)};else if(typeof MessageChannel<"u"){var G=new MessageChannel,ye=G.port2;G.port1.onmessage=U,Y=function(){ye.postMessage(null)}}else Y=function(){b(U,0)};function he(R){j=R,S||(S=!0,Y())}function Re(R,M){_=b(function(){R(t.unstable_now())},M)}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(R){R.callback=null},t.unstable_continueExecution=function(){w||y||(w=!0,he(E))},t.unstable_forceFrameRate=function(R){0>R||125<R?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):N=0<R?Math.floor(1e3/R):5},t.unstable_getCurrentPriorityLevel=function(){return f},t.unstable_getFirstCallbackNode=function(){return r(u)},t.unstable_next=function(R){switch(f){case 1:case 2:case 3:var M=3;break;default:M=f}var H=f;f=M;try{return R()}finally{f=H}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(R,M){switch(R){case 1:case 2:case 3:case 4:case 5:break;default:R=3}var H=f;f=R;try{return M()}finally{f=H}},t.unstable_scheduleCallback=function(R,M,H){var X=t.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?X+H:X):H=X,R){case 1:var ie=-1;break;case 2:ie=250;break;case 5:ie=1073741823;break;case 4:ie=1e4;break;default:ie=5e3}return ie=H+ie,R={id:d++,callback:M,priorityLevel:R,startTime:H,expirationTime:ie,sortIndex:-1},H>X?(R.sortIndex=H,e(c,R),r(u)===null&&R===r(c)&&(x?(p(_),_=-1):x=!0,Re(k,H-X))):(R.sortIndex=ie,e(u,R),w||y||(w=!0,he(E))),R},t.unstable_shouldYield=A,t.unstable_wrapCallback=function(R){var M=f;return function(){var H=f;f=M;try{return R.apply(this,arguments)}finally{f=H}}}})(Ld);Id.exports=Ld;var Gp=Id.exports;/**
|
||
* @license React
|
||
* react-dom.production.min.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/var Jp=T,Ye=Gp;function P(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,r=1;r<arguments.length;r++)e+="&args[]="+encodeURIComponent(arguments[r]);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 Dd=new Set,Qn={};function Pr(t,e){on(t,e),on(t+"Capture",e)}function on(t,e){for(Qn[t]=e,t=0;t<e.length;t++)Dd.add(e[t])}var Rt=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ho=Object.prototype.hasOwnProperty,Qp=/^[: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]*$/,Iu={},Lu={};function Yp(t){return ho.call(Lu,t)?!0:ho.call(Iu,t)?!1:Qp.test(t)?Lu[t]=!0:(Iu[t]=!0,!1)}function Zp(t,e,r,n){if(r!==null&&r.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return n?!1:r!==null?!r.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function Xp(t,e,r,n){if(e===null||typeof e>"u"||Zp(t,e,r,n))return!0;if(n)return!1;if(r!==null)switch(r.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 De(t,e,r,n,s,i,a){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=n,this.attributeNamespace=s,this.mustUseProperty=r,this.propertyName=t,this.type=e,this.sanitizeURL=i,this.removeEmptyString=a}var Ne={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Ne[t]=new De(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];Ne[e]=new De(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Ne[t]=new De(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Ne[t]=new De(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){Ne[t]=new De(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Ne[t]=new De(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Ne[t]=new De(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Ne[t]=new De(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Ne[t]=new De(t,5,!1,t.toLowerCase(),null,!1,!1)});var Pl=/[\-:]([a-z])/g;function Cl(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(Pl,Cl);Ne[e]=new De(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(Pl,Cl);Ne[e]=new De(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(Pl,Cl);Ne[e]=new De(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){Ne[t]=new De(t,1,!1,t.toLowerCase(),null,!1,!1)});Ne.xlinkHref=new De("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){Ne[t]=new De(t,1,!1,t.toLowerCase(),null,!0,!0)});function Al(t,e,r,n){var s=Ne.hasOwnProperty(e)?Ne[e]:null;(s!==null?s.type!==0:n||!(2<e.length)||e[0]!=="o"&&e[0]!=="O"||e[1]!=="n"&&e[1]!=="N")&&(Xp(e,r,s,n)&&(r=null),n||s===null?Yp(e)&&(r===null?t.removeAttribute(e):t.setAttribute(e,""+r)):s.mustUseProperty?t[s.propertyName]=r===null?s.type===3?!1:"":r:(e=s.attributeName,n=s.attributeNamespace,r===null?t.removeAttribute(e):(s=s.type,r=s===3||s===4&&r===!0?"":""+r,n?t.setAttributeNS(n,e,r):t.setAttribute(e,r))))}var Dt=Jp.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Ss=Symbol.for("react.element"),Fr=Symbol.for("react.portal"),$r=Symbol.for("react.fragment"),Ol=Symbol.for("react.strict_mode"),fo=Symbol.for("react.profiler"),Md=Symbol.for("react.provider"),Fd=Symbol.for("react.context"),Rl=Symbol.for("react.forward_ref"),po=Symbol.for("react.suspense"),go=Symbol.for("react.suspense_list"),zl=Symbol.for("react.memo"),$t=Symbol.for("react.lazy"),$d=Symbol.for("react.offscreen"),Du=Symbol.iterator;function _n(t){return t===null||typeof t!="object"?null:(t=Du&&t[Du]||t["@@iterator"],typeof t=="function"?t:null)}var ce=Object.assign,Ea;function On(t){if(Ea===void 0)try{throw Error()}catch(r){var e=r.stack.trim().match(/\n( *(at )?)/);Ea=e&&e[1]||""}return`
|
||
`+Ea+t}var Sa=!1;function ja(t,e){if(!t||Sa)return"";Sa=!0;var r=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(c){var n=c}Reflect.construct(t,[],e)}else{try{e.call()}catch(c){n=c}t.call(e.prototype)}else{try{throw Error()}catch(c){n=c}t()}}catch(c){if(c&&n&&typeof c.stack=="string"){for(var s=c.stack.split(`
|
||
`),i=n.stack.split(`
|
||
`),a=s.length-1,o=i.length-1;1<=a&&0<=o&&s[a]!==i[o];)o--;for(;1<=a&&0<=o;a--,o--)if(s[a]!==i[o]){if(a!==1||o!==1)do if(a--,o--,0>o||s[a]!==i[o]){var u=`
|
||
`+s[a].replace(" at new "," at ");return t.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",t.displayName)),u}while(1<=a&&0<=o);break}}}finally{Sa=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?On(t):""}function eg(t){switch(t.tag){case 5:return On(t.type);case 16:return On("Lazy");case 13:return On("Suspense");case 19:return On("SuspenseList");case 0:case 2:case 15:return t=ja(t.type,!1),t;case 11:return t=ja(t.type.render,!1),t;case 1:return t=ja(t.type,!0),t;default:return""}}function mo(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 $r:return"Fragment";case Fr:return"Portal";case fo:return"Profiler";case Ol:return"StrictMode";case po:return"Suspense";case go:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case Fd:return(t.displayName||"Context")+".Consumer";case Md:return(t._context.displayName||"Context")+".Provider";case Rl:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case zl:return e=t.displayName||null,e!==null?e:mo(t.type)||"Memo";case $t:e=t._payload,t=t._init;try{return mo(t(e))}catch{}}return null}function tg(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 mo(e);case 8:return e===Ol?"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 rr(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Bd(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function rg(t){var e=Bd(t)?"checked":"value",r=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),n=""+t[e];if(!t.hasOwnProperty(e)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var s=r.get,i=r.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return s.call(this)},set:function(a){n=""+a,i.call(this,a)}}),Object.defineProperty(t,e,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(a){n=""+a},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function js(t){t._valueTracker||(t._valueTracker=rg(t))}function Ud(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var r=e.getValue(),n="";return t&&(n=Bd(t)?t.checked?"true":"false":t.value),t=n,t!==r?(e.setValue(t),!0):!1}function yi(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 yo(t,e){var r=e.checked;return ce({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function Mu(t,e){var r=e.defaultValue==null?"":e.defaultValue,n=e.checked!=null?e.checked:e.defaultChecked;r=rr(e.value!=null?e.value:r),t._wrapperState={initialChecked:n,initialValue:r,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function Hd(t,e){e=e.checked,e!=null&&Al(t,"checked",e,!1)}function vo(t,e){Hd(t,e);var r=rr(e.value),n=e.type;if(r!=null)n==="number"?(r===0&&t.value===""||t.value!=r)&&(t.value=""+r):t.value!==""+r&&(t.value=""+r);else if(n==="submit"||n==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?wo(t,e.type,r):e.hasOwnProperty("defaultValue")&&wo(t,e.type,rr(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Fu(t,e,r){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var n=e.type;if(!(n!=="submit"&&n!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,r||e===t.value||(t.value=e),t.defaultValue=e}r=t.name,r!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,r!==""&&(t.name=r)}function wo(t,e,r){(e!=="number"||yi(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var Rn=Array.isArray;function Zr(t,e,r,n){if(t=t.options,e){e={};for(var s=0;s<r.length;s++)e["$"+r[s]]=!0;for(r=0;r<t.length;r++)s=e.hasOwnProperty("$"+t[r].value),t[r].selected!==s&&(t[r].selected=s),s&&n&&(t[r].defaultSelected=!0)}else{for(r=""+rr(r),e=null,s=0;s<t.length;s++){if(t[s].value===r){t[s].selected=!0,n&&(t[s].defaultSelected=!0);return}e!==null||t[s].disabled||(e=t[s])}e!==null&&(e.selected=!0)}}function xo(t,e){if(e.dangerouslySetInnerHTML!=null)throw Error(P(91));return ce({},e,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function $u(t,e){var r=e.value;if(r==null){if(r=e.children,e=e.defaultValue,r!=null){if(e!=null)throw Error(P(92));if(Rn(r)){if(1<r.length)throw Error(P(93));r=r[0]}e=r}e==null&&(e=""),r=e}t._wrapperState={initialValue:rr(r)}}function Vd(t,e){var r=rr(e.value),n=rr(e.defaultValue);r!=null&&(r=""+r,r!==t.value&&(t.value=r),e.defaultValue==null&&t.defaultValue!==r&&(t.defaultValue=r)),n!=null&&(t.defaultValue=""+n)}function Bu(t){var e=t.textContent;e===t._wrapperState.initialValue&&e!==""&&e!==null&&(t.value=e)}function Wd(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 bo(t,e){return t==null||t==="http://www.w3.org/1999/xhtml"?Wd(e):t==="http://www.w3.org/2000/svg"&&e==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var Ns,Kd=function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(e,r,n,s){MSApp.execUnsafeLocalFunction(function(){return t(e,r,n,s)})}:t}(function(t,e){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=e;else{for(Ns=Ns||document.createElement("div"),Ns.innerHTML="<svg>"+e.valueOf().toString()+"</svg>",e=Ns.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function Yn(t,e){if(e){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=e;return}}t.textContent=e}var $n={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},ng=["Webkit","ms","Moz","O"];Object.keys($n).forEach(function(t){ng.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),$n[e]=$n[t]})});function qd(t,e,r){return e==null||typeof e=="boolean"||e===""?"":r||typeof e!="number"||e===0||$n.hasOwnProperty(t)&&$n[t]?(""+e).trim():e+"px"}function Gd(t,e){t=t.style;for(var r in e)if(e.hasOwnProperty(r)){var n=r.indexOf("--")===0,s=qd(r,e[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,s):t[r]=s}}var sg=ce({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 ko(t,e){if(e){if(sg[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(P(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(P(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(P(61))}if(e.style!=null&&typeof e.style!="object")throw Error(P(62))}}function _o(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 Eo=null;function Il(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var So=null,Xr=null,en=null;function Uu(t){if(t=ws(t)){if(typeof So!="function")throw Error(P(280));var e=t.stateNode;e&&(e=sa(e),So(t.stateNode,t.type,e))}}function Jd(t){Xr?en?en.push(t):en=[t]:Xr=t}function Qd(){if(Xr){var t=Xr,e=en;if(en=Xr=null,Uu(t),e)for(t=0;t<e.length;t++)Uu(e[t])}}function Yd(t,e){return t(e)}function Zd(){}var Na=!1;function Xd(t,e,r){if(Na)return t(e,r);Na=!0;try{return Yd(t,e,r)}finally{Na=!1,(Xr!==null||en!==null)&&(Zd(),Qd())}}function Zn(t,e){var r=t.stateNode;if(r===null)return null;var n=sa(r);if(n===null)return null;r=n[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":(n=!n.disabled)||(t=t.type,n=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!n;break e;default:t=!1}if(t)return null;if(r&&typeof r!="function")throw Error(P(231,e,typeof r));return r}var jo=!1;if(Rt)try{var En={};Object.defineProperty(En,"passive",{get:function(){jo=!0}}),window.addEventListener("test",En,En),window.removeEventListener("test",En,En)}catch{jo=!1}function ig(t,e,r,n,s,i,a,o,u){var c=Array.prototype.slice.call(arguments,3);try{e.apply(r,c)}catch(d){this.onError(d)}}var Bn=!1,vi=null,wi=!1,No=null,ag={onError:function(t){Bn=!0,vi=t}};function og(t,e,r,n,s,i,a,o,u){Bn=!1,vi=null,ig.apply(ag,arguments)}function lg(t,e,r,n,s,i,a,o,u){if(og.apply(this,arguments),Bn){if(Bn){var c=vi;Bn=!1,vi=null}else throw Error(P(198));wi||(wi=!0,No=c)}}function Cr(t){var e=t,r=t;if(t.alternate)for(;e.return;)e=e.return;else{t=e;do e=t,e.flags&4098&&(r=e.return),t=e.return;while(t)}return e.tag===3?r:null}function eh(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 Hu(t){if(Cr(t)!==t)throw Error(P(188))}function ug(t){var e=t.alternate;if(!e){if(e=Cr(t),e===null)throw Error(P(188));return e!==t?null:t}for(var r=t,n=e;;){var s=r.return;if(s===null)break;var i=s.alternate;if(i===null){if(n=s.return,n!==null){r=n;continue}break}if(s.child===i.child){for(i=s.child;i;){if(i===r)return Hu(s),t;if(i===n)return Hu(s),e;i=i.sibling}throw Error(P(188))}if(r.return!==n.return)r=s,n=i;else{for(var a=!1,o=s.child;o;){if(o===r){a=!0,r=s,n=i;break}if(o===n){a=!0,n=s,r=i;break}o=o.sibling}if(!a){for(o=i.child;o;){if(o===r){a=!0,r=i,n=s;break}if(o===n){a=!0,n=i,r=s;break}o=o.sibling}if(!a)throw Error(P(189))}}if(r.alternate!==n)throw Error(P(190))}if(r.tag!==3)throw Error(P(188));return r.stateNode.current===r?t:e}function th(t){return t=ug(t),t!==null?rh(t):null}function rh(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var e=rh(t);if(e!==null)return e;t=t.sibling}return null}var nh=Ye.unstable_scheduleCallback,Vu=Ye.unstable_cancelCallback,cg=Ye.unstable_shouldYield,dg=Ye.unstable_requestPaint,fe=Ye.unstable_now,hg=Ye.unstable_getCurrentPriorityLevel,Ll=Ye.unstable_ImmediatePriority,sh=Ye.unstable_UserBlockingPriority,xi=Ye.unstable_NormalPriority,fg=Ye.unstable_LowPriority,ih=Ye.unstable_IdlePriority,ea=null,_t=null;function pg(t){if(_t&&typeof _t.onCommitFiberRoot=="function")try{_t.onCommitFiberRoot(ea,t,void 0,(t.current.flags&128)===128)}catch{}}var gt=Math.clz32?Math.clz32:yg,gg=Math.log,mg=Math.LN2;function yg(t){return t>>>=0,t===0?32:31-(gg(t)/mg|0)|0}var Ts=64,Ps=4194304;function zn(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 bi(t,e){var r=t.pendingLanes;if(r===0)return 0;var n=0,s=t.suspendedLanes,i=t.pingedLanes,a=r&268435455;if(a!==0){var o=a&~s;o!==0?n=zn(o):(i&=a,i!==0&&(n=zn(i)))}else a=r&~s,a!==0?n=zn(a):i!==0&&(n=zn(i));if(n===0)return 0;if(e!==0&&e!==n&&!(e&s)&&(s=n&-n,i=e&-e,s>=i||s===16&&(i&4194240)!==0))return e;if(n&4&&(n|=r&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=n;0<e;)r=31-gt(e),s=1<<r,n|=t[r],e&=~s;return n}function vg(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 wg(t,e){for(var r=t.suspendedLanes,n=t.pingedLanes,s=t.expirationTimes,i=t.pendingLanes;0<i;){var a=31-gt(i),o=1<<a,u=s[a];u===-1?(!(o&r)||o&n)&&(s[a]=vg(o,e)):u<=e&&(t.expiredLanes|=o),i&=~o}}function To(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function ah(){var t=Ts;return Ts<<=1,!(Ts&4194240)&&(Ts=64),t}function Ta(t){for(var e=[],r=0;31>r;r++)e.push(t);return e}function ys(t,e,r){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-gt(e),t[e]=r}function xg(t,e){var r=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 n=t.eventTimes;for(t=t.expirationTimes;0<r;){var s=31-gt(r),i=1<<s;e[s]=0,n[s]=-1,t[s]=-1,r&=~i}}function Dl(t,e){var r=t.entangledLanes|=e;for(t=t.entanglements;r;){var n=31-gt(r),s=1<<n;s&e|t[n]&e&&(t[n]|=e),r&=~s}}var Z=0;function oh(t){return t&=-t,1<t?4<t?t&268435455?16:536870912:4:1}var lh,Ml,uh,ch,dh,Po=!1,Cs=[],Gt=null,Jt=null,Qt=null,Xn=new Map,es=new Map,Ut=[],bg="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 Wu(t,e){switch(t){case"focusin":case"focusout":Gt=null;break;case"dragenter":case"dragleave":Jt=null;break;case"mouseover":case"mouseout":Qt=null;break;case"pointerover":case"pointerout":Xn.delete(e.pointerId);break;case"gotpointercapture":case"lostpointercapture":es.delete(e.pointerId)}}function Sn(t,e,r,n,s,i){return t===null||t.nativeEvent!==i?(t={blockedOn:e,domEventName:r,eventSystemFlags:n,nativeEvent:i,targetContainers:[s]},e!==null&&(e=ws(e),e!==null&&Ml(e)),t):(t.eventSystemFlags|=n,e=t.targetContainers,s!==null&&e.indexOf(s)===-1&&e.push(s),t)}function kg(t,e,r,n,s){switch(e){case"focusin":return Gt=Sn(Gt,t,e,r,n,s),!0;case"dragenter":return Jt=Sn(Jt,t,e,r,n,s),!0;case"mouseover":return Qt=Sn(Qt,t,e,r,n,s),!0;case"pointerover":var i=s.pointerId;return Xn.set(i,Sn(Xn.get(i)||null,t,e,r,n,s)),!0;case"gotpointercapture":return i=s.pointerId,es.set(i,Sn(es.get(i)||null,t,e,r,n,s)),!0}return!1}function hh(t){var e=vr(t.target);if(e!==null){var r=Cr(e);if(r!==null){if(e=r.tag,e===13){if(e=eh(r),e!==null){t.blockedOn=e,dh(t.priority,function(){uh(r)});return}}else if(e===3&&r.stateNode.current.memoizedState.isDehydrated){t.blockedOn=r.tag===3?r.stateNode.containerInfo:null;return}}}t.blockedOn=null}function ri(t){if(t.blockedOn!==null)return!1;for(var e=t.targetContainers;0<e.length;){var r=Co(t.domEventName,t.eventSystemFlags,e[0],t.nativeEvent);if(r===null){r=t.nativeEvent;var n=new r.constructor(r.type,r);Eo=n,r.target.dispatchEvent(n),Eo=null}else return e=ws(r),e!==null&&Ml(e),t.blockedOn=r,!1;e.shift()}return!0}function Ku(t,e,r){ri(t)&&r.delete(e)}function _g(){Po=!1,Gt!==null&&ri(Gt)&&(Gt=null),Jt!==null&&ri(Jt)&&(Jt=null),Qt!==null&&ri(Qt)&&(Qt=null),Xn.forEach(Ku),es.forEach(Ku)}function jn(t,e){t.blockedOn===e&&(t.blockedOn=null,Po||(Po=!0,Ye.unstable_scheduleCallback(Ye.unstable_NormalPriority,_g)))}function ts(t){function e(s){return jn(s,t)}if(0<Cs.length){jn(Cs[0],t);for(var r=1;r<Cs.length;r++){var n=Cs[r];n.blockedOn===t&&(n.blockedOn=null)}}for(Gt!==null&&jn(Gt,t),Jt!==null&&jn(Jt,t),Qt!==null&&jn(Qt,t),Xn.forEach(e),es.forEach(e),r=0;r<Ut.length;r++)n=Ut[r],n.blockedOn===t&&(n.blockedOn=null);for(;0<Ut.length&&(r=Ut[0],r.blockedOn===null);)hh(r),r.blockedOn===null&&Ut.shift()}var tn=Dt.ReactCurrentBatchConfig,ki=!0;function Eg(t,e,r,n){var s=Z,i=tn.transition;tn.transition=null;try{Z=1,Fl(t,e,r,n)}finally{Z=s,tn.transition=i}}function Sg(t,e,r,n){var s=Z,i=tn.transition;tn.transition=null;try{Z=4,Fl(t,e,r,n)}finally{Z=s,tn.transition=i}}function Fl(t,e,r,n){if(ki){var s=Co(t,e,r,n);if(s===null)Ma(t,e,n,_i,r),Wu(t,n);else if(kg(s,t,e,r,n))n.stopPropagation();else if(Wu(t,n),e&4&&-1<bg.indexOf(t)){for(;s!==null;){var i=ws(s);if(i!==null&&lh(i),i=Co(t,e,r,n),i===null&&Ma(t,e,n,_i,r),i===s)break;s=i}s!==null&&n.stopPropagation()}else Ma(t,e,n,null,r)}}var _i=null;function Co(t,e,r,n){if(_i=null,t=Il(n),t=vr(t),t!==null)if(e=Cr(t),e===null)t=null;else if(r=e.tag,r===13){if(t=eh(e),t!==null)return t;t=null}else if(r===3){if(e.stateNode.current.memoizedState.isDehydrated)return e.tag===3?e.stateNode.containerInfo:null;t=null}else e!==t&&(t=null);return _i=t,null}function fh(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(hg()){case Ll:return 1;case sh:return 4;case xi:case fg:return 16;case ih:return 536870912;default:return 16}default:return 16}}var Kt=null,$l=null,ni=null;function ph(){if(ni)return ni;var t,e=$l,r=e.length,n,s="value"in Kt?Kt.value:Kt.textContent,i=s.length;for(t=0;t<r&&e[t]===s[t];t++);var a=r-t;for(n=1;n<=a&&e[r-n]===s[i-n];n++);return ni=s.slice(t,1<n?1-n:void 0)}function si(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 As(){return!0}function qu(){return!1}function Xe(t){function e(r,n,s,i,a){this._reactName=r,this._targetInst=s,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null;for(var o in t)t.hasOwnProperty(o)&&(r=t[o],this[o]=r?r(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?As:qu,this.isPropagationStopped=qu,this}return ce(e.prototype,{preventDefault:function(){this.defaultPrevented=!0;var r=this.nativeEvent;r&&(r.preventDefault?r.preventDefault():typeof r.returnValue!="unknown"&&(r.returnValue=!1),this.isDefaultPrevented=As)},stopPropagation:function(){var r=this.nativeEvent;r&&(r.stopPropagation?r.stopPropagation():typeof r.cancelBubble!="unknown"&&(r.cancelBubble=!0),this.isPropagationStopped=As)},persist:function(){},isPersistent:As}),e}var vn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Bl=Xe(vn),vs=ce({},vn,{view:0,detail:0}),jg=Xe(vs),Pa,Ca,Nn,ta=ce({},vs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ul,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!==Nn&&(Nn&&t.type==="mousemove"?(Pa=t.screenX-Nn.screenX,Ca=t.screenY-Nn.screenY):Ca=Pa=0,Nn=t),Pa)},movementY:function(t){return"movementY"in t?t.movementY:Ca}}),Gu=Xe(ta),Ng=ce({},ta,{dataTransfer:0}),Tg=Xe(Ng),Pg=ce({},vs,{relatedTarget:0}),Aa=Xe(Pg),Cg=ce({},vn,{animationName:0,elapsedTime:0,pseudoElement:0}),Ag=Xe(Cg),Og=ce({},vn,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),Rg=Xe(Og),zg=ce({},vn,{data:0}),Ju=Xe(zg),Ig={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Lg={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"},Dg={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Mg(t){var e=this.nativeEvent;return e.getModifierState?e.getModifierState(t):(t=Dg[t])?!!e[t]:!1}function Ul(){return Mg}var Fg=ce({},vs,{key:function(t){if(t.key){var e=Ig[t.key]||t.key;if(e!=="Unidentified")return e}return t.type==="keypress"?(t=si(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?Lg[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ul,charCode:function(t){return t.type==="keypress"?si(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?si(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),$g=Xe(Fg),Bg=ce({},ta,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Qu=Xe(Bg),Ug=ce({},vs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ul}),Hg=Xe(Ug),Vg=ce({},vn,{propertyName:0,elapsedTime:0,pseudoElement:0}),Wg=Xe(Vg),Kg=ce({},ta,{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}),qg=Xe(Kg),Gg=[9,13,27,32],Hl=Rt&&"CompositionEvent"in window,Un=null;Rt&&"documentMode"in document&&(Un=document.documentMode);var Jg=Rt&&"TextEvent"in window&&!Un,gh=Rt&&(!Hl||Un&&8<Un&&11>=Un),Yu=" ",Zu=!1;function mh(t,e){switch(t){case"keyup":return Gg.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function yh(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Br=!1;function Qg(t,e){switch(t){case"compositionend":return yh(e);case"keypress":return e.which!==32?null:(Zu=!0,Yu);case"textInput":return t=e.data,t===Yu&&Zu?null:t;default:return null}}function Yg(t,e){if(Br)return t==="compositionend"||!Hl&&mh(t,e)?(t=ph(),ni=$l=Kt=null,Br=!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 gh&&e.locale!=="ko"?null:e.data;default:return null}}var Zg={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 Xu(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e==="input"?!!Zg[t.type]:e==="textarea"}function vh(t,e,r,n){Jd(n),e=Ei(e,"onChange"),0<e.length&&(r=new Bl("onChange","change",null,r,n),t.push({event:r,listeners:e}))}var Hn=null,rs=null;function Xg(t){Ph(t,0)}function ra(t){var e=Vr(t);if(Ud(e))return t}function em(t,e){if(t==="change")return e}var wh=!1;if(Rt){var Oa;if(Rt){var Ra="oninput"in document;if(!Ra){var ec=document.createElement("div");ec.setAttribute("oninput","return;"),Ra=typeof ec.oninput=="function"}Oa=Ra}else Oa=!1;wh=Oa&&(!document.documentMode||9<document.documentMode)}function tc(){Hn&&(Hn.detachEvent("onpropertychange",xh),rs=Hn=null)}function xh(t){if(t.propertyName==="value"&&ra(rs)){var e=[];vh(e,rs,t,Il(t)),Xd(Xg,e)}}function tm(t,e,r){t==="focusin"?(tc(),Hn=e,rs=r,Hn.attachEvent("onpropertychange",xh)):t==="focusout"&&tc()}function rm(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return ra(rs)}function nm(t,e){if(t==="click")return ra(e)}function sm(t,e){if(t==="input"||t==="change")return ra(e)}function im(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var yt=typeof Object.is=="function"?Object.is:im;function ns(t,e){if(yt(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;var r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(n=0;n<r.length;n++){var s=r[n];if(!ho.call(e,s)||!yt(t[s],e[s]))return!1}return!0}function rc(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function nc(t,e){var r=rc(t);t=0;for(var n;r;){if(r.nodeType===3){if(n=t+r.textContent.length,t<=e&&n>=e)return{node:r,offset:e-t};t=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=rc(r)}}function bh(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?bh(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function kh(){for(var t=window,e=yi();e instanceof t.HTMLIFrameElement;){try{var r=typeof e.contentWindow.location.href=="string"}catch{r=!1}if(r)t=e.contentWindow;else break;e=yi(t.document)}return e}function Vl(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 am(t){var e=kh(),r=t.focusedElem,n=t.selectionRange;if(e!==r&&r&&r.ownerDocument&&bh(r.ownerDocument.documentElement,r)){if(n!==null&&Vl(r)){if(e=n.start,t=n.end,t===void 0&&(t=e),"selectionStart"in r)r.selectionStart=e,r.selectionEnd=Math.min(t,r.value.length);else if(t=(e=r.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var s=r.textContent.length,i=Math.min(n.start,s);n=n.end===void 0?i:Math.min(n.end,s),!t.extend&&i>n&&(s=n,n=i,i=s),s=nc(r,i);var a=nc(r,n);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>n?(t.addRange(e),t.extend(a.node,a.offset)):(e.setEnd(a.node,a.offset),t.addRange(e)))}}for(e=[],t=r;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof r.focus=="function"&&r.focus(),r=0;r<e.length;r++)t=e[r],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var om=Rt&&"documentMode"in document&&11>=document.documentMode,Ur=null,Ao=null,Vn=null,Oo=!1;function sc(t,e,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;Oo||Ur==null||Ur!==yi(n)||(n=Ur,"selectionStart"in n&&Vl(n)?n={start:n.selectionStart,end:n.selectionEnd}:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection(),n={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}),Vn&&ns(Vn,n)||(Vn=n,n=Ei(Ao,"onSelect"),0<n.length&&(e=new Bl("onSelect","select",null,e,r),t.push({event:e,listeners:n}),e.target=Ur)))}function Os(t,e){var r={};return r[t.toLowerCase()]=e.toLowerCase(),r["Webkit"+t]="webkit"+e,r["Moz"+t]="moz"+e,r}var Hr={animationend:Os("Animation","AnimationEnd"),animationiteration:Os("Animation","AnimationIteration"),animationstart:Os("Animation","AnimationStart"),transitionend:Os("Transition","TransitionEnd")},za={},_h={};Rt&&(_h=document.createElement("div").style,"AnimationEvent"in window||(delete Hr.animationend.animation,delete Hr.animationiteration.animation,delete Hr.animationstart.animation),"TransitionEvent"in window||delete Hr.transitionend.transition);function na(t){if(za[t])return za[t];if(!Hr[t])return t;var e=Hr[t],r;for(r in e)if(e.hasOwnProperty(r)&&r in _h)return za[t]=e[r];return t}var Eh=na("animationend"),Sh=na("animationiteration"),jh=na("animationstart"),Nh=na("transitionend"),Th=new Map,ic="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 sr(t,e){Th.set(t,e),Pr(e,[t])}for(var Ia=0;Ia<ic.length;Ia++){var La=ic[Ia],lm=La.toLowerCase(),um=La[0].toUpperCase()+La.slice(1);sr(lm,"on"+um)}sr(Eh,"onAnimationEnd");sr(Sh,"onAnimationIteration");sr(jh,"onAnimationStart");sr("dblclick","onDoubleClick");sr("focusin","onFocus");sr("focusout","onBlur");sr(Nh,"onTransitionEnd");on("onMouseEnter",["mouseout","mouseover"]);on("onMouseLeave",["mouseout","mouseover"]);on("onPointerEnter",["pointerout","pointerover"]);on("onPointerLeave",["pointerout","pointerover"]);Pr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Pr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Pr("onBeforeInput",["compositionend","keypress","textInput","paste"]);Pr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Pr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Pr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var In="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(" "),cm=new Set("cancel close invalid load scroll toggle".split(" ").concat(In));function ac(t,e,r){var n=t.type||"unknown-event";t.currentTarget=r,lg(n,e,void 0,t),t.currentTarget=null}function Ph(t,e){e=(e&4)!==0;for(var r=0;r<t.length;r++){var n=t[r],s=n.event;n=n.listeners;e:{var i=void 0;if(e)for(var a=n.length-1;0<=a;a--){var o=n[a],u=o.instance,c=o.currentTarget;if(o=o.listener,u!==i&&s.isPropagationStopped())break e;ac(s,o,c),i=u}else for(a=0;a<n.length;a++){if(o=n[a],u=o.instance,c=o.currentTarget,o=o.listener,u!==i&&s.isPropagationStopped())break e;ac(s,o,c),i=u}}}if(wi)throw t=No,wi=!1,No=null,t}function ne(t,e){var r=e[Do];r===void 0&&(r=e[Do]=new Set);var n=t+"__bubble";r.has(n)||(Ch(e,t,2,!1),r.add(n))}function Da(t,e,r){var n=0;e&&(n|=4),Ch(r,t,n,e)}var Rs="_reactListening"+Math.random().toString(36).slice(2);function ss(t){if(!t[Rs]){t[Rs]=!0,Dd.forEach(function(r){r!=="selectionchange"&&(cm.has(r)||Da(r,!1,t),Da(r,!0,t))});var e=t.nodeType===9?t:t.ownerDocument;e===null||e[Rs]||(e[Rs]=!0,Da("selectionchange",!1,e))}}function Ch(t,e,r,n){switch(fh(e)){case 1:var s=Eg;break;case 4:s=Sg;break;default:s=Fl}r=s.bind(null,e,r,t),s=void 0,!jo||e!=="touchstart"&&e!=="touchmove"&&e!=="wheel"||(s=!0),n?s!==void 0?t.addEventListener(e,r,{capture:!0,passive:s}):t.addEventListener(e,r,!0):s!==void 0?t.addEventListener(e,r,{passive:s}):t.addEventListener(e,r,!1)}function Ma(t,e,r,n,s){var i=n;if(!(e&1)&&!(e&2)&&n!==null)e:for(;;){if(n===null)return;var a=n.tag;if(a===3||a===4){var o=n.stateNode.containerInfo;if(o===s||o.nodeType===8&&o.parentNode===s)break;if(a===4)for(a=n.return;a!==null;){var u=a.tag;if((u===3||u===4)&&(u=a.stateNode.containerInfo,u===s||u.nodeType===8&&u.parentNode===s))return;a=a.return}for(;o!==null;){if(a=vr(o),a===null)return;if(u=a.tag,u===5||u===6){n=i=a;continue e}o=o.parentNode}}n=n.return}Xd(function(){var c=i,d=Il(r),h=[];e:{var f=Th.get(t);if(f!==void 0){var y=Bl,w=t;switch(t){case"keypress":if(si(r)===0)break e;case"keydown":case"keyup":y=$g;break;case"focusin":w="focus",y=Aa;break;case"focusout":w="blur",y=Aa;break;case"beforeblur":case"afterblur":y=Aa;break;case"click":if(r.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":y=Gu;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":y=Tg;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":y=Hg;break;case Eh:case Sh:case jh:y=Ag;break;case Nh:y=Wg;break;case"scroll":y=jg;break;case"wheel":y=qg;break;case"copy":case"cut":case"paste":y=Rg;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":y=Qu}var x=(e&4)!==0,b=!x&&t==="scroll",p=x?f!==null?f+"Capture":null:f;x=[];for(var m=c,g;m!==null;){g=m;var k=g.stateNode;if(g.tag===5&&k!==null&&(g=k,p!==null&&(k=Zn(m,p),k!=null&&x.push(is(m,k,g)))),b)break;m=m.return}0<x.length&&(f=new y(f,w,null,r,d),h.push({event:f,listeners:x}))}}if(!(e&7)){e:{if(f=t==="mouseover"||t==="pointerover",y=t==="mouseout"||t==="pointerout",f&&r!==Eo&&(w=r.relatedTarget||r.fromElement)&&(vr(w)||w[zt]))break e;if((y||f)&&(f=d.window===d?d:(f=d.ownerDocument)?f.defaultView||f.parentWindow:window,y?(w=r.relatedTarget||r.toElement,y=c,w=w?vr(w):null,w!==null&&(b=Cr(w),w!==b||w.tag!==5&&w.tag!==6)&&(w=null)):(y=null,w=c),y!==w)){if(x=Gu,k="onMouseLeave",p="onMouseEnter",m="mouse",(t==="pointerout"||t==="pointerover")&&(x=Qu,k="onPointerLeave",p="onPointerEnter",m="pointer"),b=y==null?f:Vr(y),g=w==null?f:Vr(w),f=new x(k,m+"leave",y,r,d),f.target=b,f.relatedTarget=g,k=null,vr(d)===c&&(x=new x(p,m+"enter",w,r,d),x.target=g,x.relatedTarget=b,k=x),b=k,y&&w)t:{for(x=y,p=w,m=0,g=x;g;g=Or(g))m++;for(g=0,k=p;k;k=Or(k))g++;for(;0<m-g;)x=Or(x),m--;for(;0<g-m;)p=Or(p),g--;for(;m--;){if(x===p||p!==null&&x===p.alternate)break t;x=Or(x),p=Or(p)}x=null}else x=null;y!==null&&oc(h,f,y,x,!1),w!==null&&b!==null&&oc(h,b,w,x,!0)}}e:{if(f=c?Vr(c):window,y=f.nodeName&&f.nodeName.toLowerCase(),y==="select"||y==="input"&&f.type==="file")var E=em;else if(Xu(f))if(wh)E=sm;else{E=rm;var S=tm}else(y=f.nodeName)&&y.toLowerCase()==="input"&&(f.type==="checkbox"||f.type==="radio")&&(E=nm);if(E&&(E=E(t,c))){vh(h,E,r,d);break e}S&&S(t,f,c),t==="focusout"&&(S=f._wrapperState)&&S.controlled&&f.type==="number"&&wo(f,"number",f.value)}switch(S=c?Vr(c):window,t){case"focusin":(Xu(S)||S.contentEditable==="true")&&(Ur=S,Ao=c,Vn=null);break;case"focusout":Vn=Ao=Ur=null;break;case"mousedown":Oo=!0;break;case"contextmenu":case"mouseup":case"dragend":Oo=!1,sc(h,r,d);break;case"selectionchange":if(om)break;case"keydown":case"keyup":sc(h,r,d)}var j;if(Hl)e:{switch(t){case"compositionstart":var _="onCompositionStart";break e;case"compositionend":_="onCompositionEnd";break e;case"compositionupdate":_="onCompositionUpdate";break e}_=void 0}else Br?mh(t,r)&&(_="onCompositionEnd"):t==="keydown"&&r.keyCode===229&&(_="onCompositionStart");_&&(gh&&r.locale!=="ko"&&(Br||_!=="onCompositionStart"?_==="onCompositionEnd"&&Br&&(j=ph()):(Kt=d,$l="value"in Kt?Kt.value:Kt.textContent,Br=!0)),S=Ei(c,_),0<S.length&&(_=new Ju(_,t,null,r,d),h.push({event:_,listeners:S}),j?_.data=j:(j=yh(r),j!==null&&(_.data=j)))),(j=Jg?Qg(t,r):Yg(t,r))&&(c=Ei(c,"onBeforeInput"),0<c.length&&(d=new Ju("onBeforeInput","beforeinput",null,r,d),h.push({event:d,listeners:c}),d.data=j))}Ph(h,e)})}function is(t,e,r){return{instance:t,listener:e,currentTarget:r}}function Ei(t,e){for(var r=e+"Capture",n=[];t!==null;){var s=t,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=Zn(t,r),i!=null&&n.unshift(is(t,i,s)),i=Zn(t,e),i!=null&&n.push(is(t,i,s))),t=t.return}return n}function Or(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function oc(t,e,r,n,s){for(var i=e._reactName,a=[];r!==null&&r!==n;){var o=r,u=o.alternate,c=o.stateNode;if(u!==null&&u===n)break;o.tag===5&&c!==null&&(o=c,s?(u=Zn(r,i),u!=null&&a.unshift(is(r,u,o))):s||(u=Zn(r,i),u!=null&&a.push(is(r,u,o)))),r=r.return}a.length!==0&&t.push({event:e,listeners:a})}var dm=/\r\n?/g,hm=/\u0000|\uFFFD/g;function lc(t){return(typeof t=="string"?t:""+t).replace(dm,`
|
||
`).replace(hm,"")}function zs(t,e,r){if(e=lc(e),lc(t)!==e&&r)throw Error(P(425))}function Si(){}var Ro=null,zo=null;function Io(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 Lo=typeof setTimeout=="function"?setTimeout:void 0,fm=typeof clearTimeout=="function"?clearTimeout:void 0,uc=typeof Promise=="function"?Promise:void 0,pm=typeof queueMicrotask=="function"?queueMicrotask:typeof uc<"u"?function(t){return uc.resolve(null).then(t).catch(gm)}:Lo;function gm(t){setTimeout(function(){throw t})}function Fa(t,e){var r=e,n=0;do{var s=r.nextSibling;if(t.removeChild(r),s&&s.nodeType===8)if(r=s.data,r==="/$"){if(n===0){t.removeChild(s),ts(e);return}n--}else r!=="$"&&r!=="$?"&&r!=="$!"||n++;r=s}while(r);ts(e)}function Yt(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 cc(t){t=t.previousSibling;for(var e=0;t;){if(t.nodeType===8){var r=t.data;if(r==="$"||r==="$!"||r==="$?"){if(e===0)return t;e--}else r==="/$"&&e++}t=t.previousSibling}return null}var wn=Math.random().toString(36).slice(2),kt="__reactFiber$"+wn,as="__reactProps$"+wn,zt="__reactContainer$"+wn,Do="__reactEvents$"+wn,mm="__reactListeners$"+wn,ym="__reactHandles$"+wn;function vr(t){var e=t[kt];if(e)return e;for(var r=t.parentNode;r;){if(e=r[zt]||r[kt]){if(r=e.alternate,e.child!==null||r!==null&&r.child!==null)for(t=cc(t);t!==null;){if(r=t[kt])return r;t=cc(t)}return e}t=r,r=t.parentNode}return null}function ws(t){return t=t[kt]||t[zt],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function Vr(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(P(33))}function sa(t){return t[as]||null}var Mo=[],Wr=-1;function ir(t){return{current:t}}function se(t){0>Wr||(t.current=Mo[Wr],Mo[Wr]=null,Wr--)}function re(t,e){Wr++,Mo[Wr]=t.current,t.current=e}var nr={},Oe=ir(nr),Ue=ir(!1),Er=nr;function ln(t,e){var r=t.type.contextTypes;if(!r)return nr;var n=t.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===e)return n.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in r)s[i]=e[i];return n&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=s),s}function He(t){return t=t.childContextTypes,t!=null}function ji(){se(Ue),se(Oe)}function dc(t,e,r){if(Oe.current!==nr)throw Error(P(168));re(Oe,e),re(Ue,r)}function Ah(t,e,r){var n=t.stateNode;if(e=e.childContextTypes,typeof n.getChildContext!="function")return r;n=n.getChildContext();for(var s in n)if(!(s in e))throw Error(P(108,tg(t)||"Unknown",s));return ce({},r,n)}function Ni(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||nr,Er=Oe.current,re(Oe,t),re(Ue,Ue.current),!0}function hc(t,e,r){var n=t.stateNode;if(!n)throw Error(P(169));r?(t=Ah(t,e,Er),n.__reactInternalMemoizedMergedChildContext=t,se(Ue),se(Oe),re(Oe,t)):se(Ue),re(Ue,r)}var Pt=null,ia=!1,$a=!1;function Oh(t){Pt===null?Pt=[t]:Pt.push(t)}function vm(t){ia=!0,Oh(t)}function ar(){if(!$a&&Pt!==null){$a=!0;var t=0,e=Z;try{var r=Pt;for(Z=1;t<r.length;t++){var n=r[t];do n=n(!0);while(n!==null)}Pt=null,ia=!1}catch(s){throw Pt!==null&&(Pt=Pt.slice(t+1)),nh(Ll,ar),s}finally{Z=e,$a=!1}}return null}var Kr=[],qr=0,Ti=null,Pi=0,et=[],tt=0,Sr=null,Ct=1,At="";function dr(t,e){Kr[qr++]=Pi,Kr[qr++]=Ti,Ti=t,Pi=e}function Rh(t,e,r){et[tt++]=Ct,et[tt++]=At,et[tt++]=Sr,Sr=t;var n=Ct;t=At;var s=32-gt(n)-1;n&=~(1<<s),r+=1;var i=32-gt(e)+s;if(30<i){var a=s-s%5;i=(n&(1<<a)-1).toString(32),n>>=a,s-=a,Ct=1<<32-gt(e)+s|r<<s|n,At=i+t}else Ct=1<<i|r<<s|n,At=t}function Wl(t){t.return!==null&&(dr(t,1),Rh(t,1,0))}function Kl(t){for(;t===Ti;)Ti=Kr[--qr],Kr[qr]=null,Pi=Kr[--qr],Kr[qr]=null;for(;t===Sr;)Sr=et[--tt],et[tt]=null,At=et[--tt],et[tt]=null,Ct=et[--tt],et[tt]=null}var Qe=null,Je=null,oe=!1,ft=null;function zh(t,e){var r=rt(5,null,null,0);r.elementType="DELETED",r.stateNode=e,r.return=t,e=t.deletions,e===null?(t.deletions=[r],t.flags|=16):e.push(r)}function fc(t,e){switch(t.tag){case 5:var r=t.type;return e=e.nodeType!==1||r.toLowerCase()!==e.nodeName.toLowerCase()?null:e,e!==null?(t.stateNode=e,Qe=t,Je=Yt(e.firstChild),!0):!1;case 6:return e=t.pendingProps===""||e.nodeType!==3?null:e,e!==null?(t.stateNode=e,Qe=t,Je=null,!0):!1;case 13:return e=e.nodeType!==8?null:e,e!==null?(r=Sr!==null?{id:Ct,overflow:At}:null,t.memoizedState={dehydrated:e,treeContext:r,retryLane:1073741824},r=rt(18,null,null,0),r.stateNode=e,r.return=t,t.child=r,Qe=t,Je=null,!0):!1;default:return!1}}function Fo(t){return(t.mode&1)!==0&&(t.flags&128)===0}function $o(t){if(oe){var e=Je;if(e){var r=e;if(!fc(t,e)){if(Fo(t))throw Error(P(418));e=Yt(r.nextSibling);var n=Qe;e&&fc(t,e)?zh(n,r):(t.flags=t.flags&-4097|2,oe=!1,Qe=t)}}else{if(Fo(t))throw Error(P(418));t.flags=t.flags&-4097|2,oe=!1,Qe=t}}}function pc(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;Qe=t}function Is(t){if(t!==Qe)return!1;if(!oe)return pc(t),oe=!0,!1;var e;if((e=t.tag!==3)&&!(e=t.tag!==5)&&(e=t.type,e=e!=="head"&&e!=="body"&&!Io(t.type,t.memoizedProps)),e&&(e=Je)){if(Fo(t))throw Ih(),Error(P(418));for(;e;)zh(t,e),e=Yt(e.nextSibling)}if(pc(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(P(317));e:{for(t=t.nextSibling,e=0;t;){if(t.nodeType===8){var r=t.data;if(r==="/$"){if(e===0){Je=Yt(t.nextSibling);break e}e--}else r!=="$"&&r!=="$!"&&r!=="$?"||e++}t=t.nextSibling}Je=null}}else Je=Qe?Yt(t.stateNode.nextSibling):null;return!0}function Ih(){for(var t=Je;t;)t=Yt(t.nextSibling)}function un(){Je=Qe=null,oe=!1}function ql(t){ft===null?ft=[t]:ft.push(t)}var wm=Dt.ReactCurrentBatchConfig;function Tn(t,e,r){if(t=r.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(r._owner){if(r=r._owner,r){if(r.tag!==1)throw Error(P(309));var n=r.stateNode}if(!n)throw Error(P(147,t));var s=n,i=""+t;return e!==null&&e.ref!==null&&typeof e.ref=="function"&&e.ref._stringRef===i?e.ref:(e=function(a){var o=s.refs;a===null?delete o[i]:o[i]=a},e._stringRef=i,e)}if(typeof t!="string")throw Error(P(284));if(!r._owner)throw Error(P(290,t))}return t}function Ls(t,e){throw t=Object.prototype.toString.call(e),Error(P(31,t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t))}function gc(t){var e=t._init;return e(t._payload)}function Lh(t){function e(p,m){if(t){var g=p.deletions;g===null?(p.deletions=[m],p.flags|=16):g.push(m)}}function r(p,m){if(!t)return null;for(;m!==null;)e(p,m),m=m.sibling;return null}function n(p,m){for(p=new Map;m!==null;)m.key!==null?p.set(m.key,m):p.set(m.index,m),m=m.sibling;return p}function s(p,m){return p=tr(p,m),p.index=0,p.sibling=null,p}function i(p,m,g){return p.index=g,t?(g=p.alternate,g!==null?(g=g.index,g<m?(p.flags|=2,m):g):(p.flags|=2,m)):(p.flags|=1048576,m)}function a(p){return t&&p.alternate===null&&(p.flags|=2),p}function o(p,m,g,k){return m===null||m.tag!==6?(m=qa(g,p.mode,k),m.return=p,m):(m=s(m,g),m.return=p,m)}function u(p,m,g,k){var E=g.type;return E===$r?d(p,m,g.props.children,k,g.key):m!==null&&(m.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===$t&&gc(E)===m.type)?(k=s(m,g.props),k.ref=Tn(p,m,g),k.return=p,k):(k=di(g.type,g.key,g.props,null,p.mode,k),k.ref=Tn(p,m,g),k.return=p,k)}function c(p,m,g,k){return m===null||m.tag!==4||m.stateNode.containerInfo!==g.containerInfo||m.stateNode.implementation!==g.implementation?(m=Ga(g,p.mode,k),m.return=p,m):(m=s(m,g.children||[]),m.return=p,m)}function d(p,m,g,k,E){return m===null||m.tag!==7?(m=_r(g,p.mode,k,E),m.return=p,m):(m=s(m,g),m.return=p,m)}function h(p,m,g){if(typeof m=="string"&&m!==""||typeof m=="number")return m=qa(""+m,p.mode,g),m.return=p,m;if(typeof m=="object"&&m!==null){switch(m.$$typeof){case Ss:return g=di(m.type,m.key,m.props,null,p.mode,g),g.ref=Tn(p,null,m),g.return=p,g;case Fr:return m=Ga(m,p.mode,g),m.return=p,m;case $t:var k=m._init;return h(p,k(m._payload),g)}if(Rn(m)||_n(m))return m=_r(m,p.mode,g,null),m.return=p,m;Ls(p,m)}return null}function f(p,m,g,k){var E=m!==null?m.key:null;if(typeof g=="string"&&g!==""||typeof g=="number")return E!==null?null:o(p,m,""+g,k);if(typeof g=="object"&&g!==null){switch(g.$$typeof){case Ss:return g.key===E?u(p,m,g,k):null;case Fr:return g.key===E?c(p,m,g,k):null;case $t:return E=g._init,f(p,m,E(g._payload),k)}if(Rn(g)||_n(g))return E!==null?null:d(p,m,g,k,null);Ls(p,g)}return null}function y(p,m,g,k,E){if(typeof k=="string"&&k!==""||typeof k=="number")return p=p.get(g)||null,o(m,p,""+k,E);if(typeof k=="object"&&k!==null){switch(k.$$typeof){case Ss:return p=p.get(k.key===null?g:k.key)||null,u(m,p,k,E);case Fr:return p=p.get(k.key===null?g:k.key)||null,c(m,p,k,E);case $t:var S=k._init;return y(p,m,g,S(k._payload),E)}if(Rn(k)||_n(k))return p=p.get(g)||null,d(m,p,k,E,null);Ls(m,k)}return null}function w(p,m,g,k){for(var E=null,S=null,j=m,_=m=0,N=null;j!==null&&_<g.length;_++){j.index>_?(N=j,j=null):N=j.sibling;var C=f(p,j,g[_],k);if(C===null){j===null&&(j=N);break}t&&j&&C.alternate===null&&e(p,j),m=i(C,m,_),S===null?E=C:S.sibling=C,S=C,j=N}if(_===g.length)return r(p,j),oe&&dr(p,_),E;if(j===null){for(;_<g.length;_++)j=h(p,g[_],k),j!==null&&(m=i(j,m,_),S===null?E=j:S.sibling=j,S=j);return oe&&dr(p,_),E}for(j=n(p,j);_<g.length;_++)N=y(j,p,_,g[_],k),N!==null&&(t&&N.alternate!==null&&j.delete(N.key===null?_:N.key),m=i(N,m,_),S===null?E=N:S.sibling=N,S=N);return t&&j.forEach(function(A){return e(p,A)}),oe&&dr(p,_),E}function x(p,m,g,k){var E=_n(g);if(typeof E!="function")throw Error(P(150));if(g=E.call(g),g==null)throw Error(P(151));for(var S=E=null,j=m,_=m=0,N=null,C=g.next();j!==null&&!C.done;_++,C=g.next()){j.index>_?(N=j,j=null):N=j.sibling;var A=f(p,j,C.value,k);if(A===null){j===null&&(j=N);break}t&&j&&A.alternate===null&&e(p,j),m=i(A,m,_),S===null?E=A:S.sibling=A,S=A,j=N}if(C.done)return r(p,j),oe&&dr(p,_),E;if(j===null){for(;!C.done;_++,C=g.next())C=h(p,C.value,k),C!==null&&(m=i(C,m,_),S===null?E=C:S.sibling=C,S=C);return oe&&dr(p,_),E}for(j=n(p,j);!C.done;_++,C=g.next())C=y(j,p,_,C.value,k),C!==null&&(t&&C.alternate!==null&&j.delete(C.key===null?_:C.key),m=i(C,m,_),S===null?E=C:S.sibling=C,S=C);return t&&j.forEach(function(U){return e(p,U)}),oe&&dr(p,_),E}function b(p,m,g,k){if(typeof g=="object"&&g!==null&&g.type===$r&&g.key===null&&(g=g.props.children),typeof g=="object"&&g!==null){switch(g.$$typeof){case Ss:e:{for(var E=g.key,S=m;S!==null;){if(S.key===E){if(E=g.type,E===$r){if(S.tag===7){r(p,S.sibling),m=s(S,g.props.children),m.return=p,p=m;break e}}else if(S.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===$t&&gc(E)===S.type){r(p,S.sibling),m=s(S,g.props),m.ref=Tn(p,S,g),m.return=p,p=m;break e}r(p,S);break}else e(p,S);S=S.sibling}g.type===$r?(m=_r(g.props.children,p.mode,k,g.key),m.return=p,p=m):(k=di(g.type,g.key,g.props,null,p.mode,k),k.ref=Tn(p,m,g),k.return=p,p=k)}return a(p);case Fr:e:{for(S=g.key;m!==null;){if(m.key===S)if(m.tag===4&&m.stateNode.containerInfo===g.containerInfo&&m.stateNode.implementation===g.implementation){r(p,m.sibling),m=s(m,g.children||[]),m.return=p,p=m;break e}else{r(p,m);break}else e(p,m);m=m.sibling}m=Ga(g,p.mode,k),m.return=p,p=m}return a(p);case $t:return S=g._init,b(p,m,S(g._payload),k)}if(Rn(g))return w(p,m,g,k);if(_n(g))return x(p,m,g,k);Ls(p,g)}return typeof g=="string"&&g!==""||typeof g=="number"?(g=""+g,m!==null&&m.tag===6?(r(p,m.sibling),m=s(m,g),m.return=p,p=m):(r(p,m),m=qa(g,p.mode,k),m.return=p,p=m),a(p)):r(p,m)}return b}var cn=Lh(!0),Dh=Lh(!1),Ci=ir(null),Ai=null,Gr=null,Gl=null;function Jl(){Gl=Gr=Ai=null}function Ql(t){var e=Ci.current;se(Ci),t._currentValue=e}function Bo(t,e,r){for(;t!==null;){var n=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,n!==null&&(n.childLanes|=e)):n!==null&&(n.childLanes&e)!==e&&(n.childLanes|=e),t===r)break;t=t.return}}function rn(t,e){Ai=t,Gl=Gr=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(Be=!0),t.firstContext=null)}function st(t){var e=t._currentValue;if(Gl!==t)if(t={context:t,memoizedValue:e,next:null},Gr===null){if(Ai===null)throw Error(P(308));Gr=t,Ai.dependencies={lanes:0,firstContext:t}}else Gr=Gr.next=t;return e}var wr=null;function Yl(t){wr===null?wr=[t]:wr.push(t)}function Mh(t,e,r,n){var s=e.interleaved;return s===null?(r.next=r,Yl(e)):(r.next=s.next,s.next=r),e.interleaved=r,It(t,n)}function It(t,e){t.lanes|=e;var r=t.alternate;for(r!==null&&(r.lanes|=e),r=t,t=t.return;t!==null;)t.childLanes|=e,r=t.alternate,r!==null&&(r.childLanes|=e),r=t,t=t.return;return r.tag===3?r.stateNode:null}var Bt=!1;function Zl(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Fh(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 Ot(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function Zt(t,e,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,J&2){var s=n.pending;return s===null?e.next=e:(e.next=s.next,s.next=e),n.pending=e,It(t,r)}return s=n.interleaved,s===null?(e.next=e,Yl(n)):(e.next=s.next,s.next=e),n.interleaved=e,It(t,r)}function ii(t,e,r){if(e=e.updateQueue,e!==null&&(e=e.shared,(r&4194240)!==0)){var n=e.lanes;n&=t.pendingLanes,r|=n,e.lanes=r,Dl(t,r)}}function mc(t,e){var r=t.updateQueue,n=t.alternate;if(n!==null&&(n=n.updateQueue,r===n)){var s=null,i=null;if(r=r.firstBaseUpdate,r!==null){do{var a={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};i===null?s=i=a:i=i.next=a,r=r.next}while(r!==null);i===null?s=i=e:i=i.next=e}else s=i=e;r={baseState:n.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:n.shared,effects:n.effects},t.updateQueue=r;return}t=r.lastBaseUpdate,t===null?r.firstBaseUpdate=e:t.next=e,r.lastBaseUpdate=e}function Oi(t,e,r,n){var s=t.updateQueue;Bt=!1;var i=s.firstBaseUpdate,a=s.lastBaseUpdate,o=s.shared.pending;if(o!==null){s.shared.pending=null;var u=o,c=u.next;u.next=null,a===null?i=c:a.next=c,a=u;var d=t.alternate;d!==null&&(d=d.updateQueue,o=d.lastBaseUpdate,o!==a&&(o===null?d.firstBaseUpdate=c:o.next=c,d.lastBaseUpdate=u))}if(i!==null){var h=s.baseState;a=0,d=c=u=null,o=i;do{var f=o.lane,y=o.eventTime;if((n&f)===f){d!==null&&(d=d.next={eventTime:y,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var w=t,x=o;switch(f=e,y=r,x.tag){case 1:if(w=x.payload,typeof w=="function"){h=w.call(y,h,f);break e}h=w;break e;case 3:w.flags=w.flags&-65537|128;case 0:if(w=x.payload,f=typeof w=="function"?w.call(y,h,f):w,f==null)break e;h=ce({},h,f);break e;case 2:Bt=!0}}o.callback!==null&&o.lane!==0&&(t.flags|=64,f=s.effects,f===null?s.effects=[o]:f.push(o))}else y={eventTime:y,lane:f,tag:o.tag,payload:o.payload,callback:o.callback,next:null},d===null?(c=d=y,u=h):d=d.next=y,a|=f;if(o=o.next,o===null){if(o=s.shared.pending,o===null)break;f=o,o=f.next,f.next=null,s.lastBaseUpdate=f,s.shared.pending=null}}while(!0);if(d===null&&(u=h),s.baseState=u,s.firstBaseUpdate=c,s.lastBaseUpdate=d,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);Nr|=a,t.lanes=a,t.memoizedState=h}}function yc(t,e,r){if(t=e.effects,e.effects=null,t!==null)for(e=0;e<t.length;e++){var n=t[e],s=n.callback;if(s!==null){if(n.callback=null,n=r,typeof s!="function")throw Error(P(191,s));s.call(n)}}}var xs={},Et=ir(xs),os=ir(xs),ls=ir(xs);function xr(t){if(t===xs)throw Error(P(174));return t}function Xl(t,e){switch(re(ls,e),re(os,t),re(Et,xs),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:bo(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=bo(e,t)}se(Et),re(Et,e)}function dn(){se(Et),se(os),se(ls)}function $h(t){xr(ls.current);var e=xr(Et.current),r=bo(e,t.type);e!==r&&(re(os,t),re(Et,r))}function eu(t){os.current===t&&(se(Et),se(os))}var le=ir(0);function Ri(t){for(var e=t;e!==null;){if(e.tag===13){var r=e.memoizedState;if(r!==null&&(r=r.dehydrated,r===null||r.data==="$?"||r.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 Ba=[];function tu(){for(var t=0;t<Ba.length;t++)Ba[t]._workInProgressVersionPrimary=null;Ba.length=0}var ai=Dt.ReactCurrentDispatcher,Ua=Dt.ReactCurrentBatchConfig,jr=0,ue=null,ve=null,xe=null,zi=!1,Wn=!1,us=0,xm=0;function Te(){throw Error(P(321))}function ru(t,e){if(e===null)return!1;for(var r=0;r<e.length&&r<t.length;r++)if(!yt(t[r],e[r]))return!1;return!0}function nu(t,e,r,n,s,i){if(jr=i,ue=e,e.memoizedState=null,e.updateQueue=null,e.lanes=0,ai.current=t===null||t.memoizedState===null?Em:Sm,t=r(n,s),Wn){i=0;do{if(Wn=!1,us=0,25<=i)throw Error(P(301));i+=1,xe=ve=null,e.updateQueue=null,ai.current=jm,t=r(n,s)}while(Wn)}if(ai.current=Ii,e=ve!==null&&ve.next!==null,jr=0,xe=ve=ue=null,zi=!1,e)throw Error(P(300));return t}function su(){var t=us!==0;return us=0,t}function xt(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return xe===null?ue.memoizedState=xe=t:xe=xe.next=t,xe}function it(){if(ve===null){var t=ue.alternate;t=t!==null?t.memoizedState:null}else t=ve.next;var e=xe===null?ue.memoizedState:xe.next;if(e!==null)xe=e,ve=t;else{if(t===null)throw Error(P(310));ve=t,t={memoizedState:ve.memoizedState,baseState:ve.baseState,baseQueue:ve.baseQueue,queue:ve.queue,next:null},xe===null?ue.memoizedState=xe=t:xe=xe.next=t}return xe}function cs(t,e){return typeof e=="function"?e(t):e}function Ha(t){var e=it(),r=e.queue;if(r===null)throw Error(P(311));r.lastRenderedReducer=t;var n=ve,s=n.baseQueue,i=r.pending;if(i!==null){if(s!==null){var a=s.next;s.next=i.next,i.next=a}n.baseQueue=s=i,r.pending=null}if(s!==null){i=s.next,n=n.baseState;var o=a=null,u=null,c=i;do{var d=c.lane;if((jr&d)===d)u!==null&&(u=u.next={lane:0,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),n=c.hasEagerState?c.eagerState:t(n,c.action);else{var h={lane:d,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null};u===null?(o=u=h,a=n):u=u.next=h,ue.lanes|=d,Nr|=d}c=c.next}while(c!==null&&c!==i);u===null?a=n:u.next=o,yt(n,e.memoizedState)||(Be=!0),e.memoizedState=n,e.baseState=a,e.baseQueue=u,r.lastRenderedState=n}if(t=r.interleaved,t!==null){s=t;do i=s.lane,ue.lanes|=i,Nr|=i,s=s.next;while(s!==t)}else s===null&&(r.lanes=0);return[e.memoizedState,r.dispatch]}function Va(t){var e=it(),r=e.queue;if(r===null)throw Error(P(311));r.lastRenderedReducer=t;var n=r.dispatch,s=r.pending,i=e.memoizedState;if(s!==null){r.pending=null;var a=s=s.next;do i=t(i,a.action),a=a.next;while(a!==s);yt(i,e.memoizedState)||(Be=!0),e.memoizedState=i,e.baseQueue===null&&(e.baseState=i),r.lastRenderedState=i}return[i,n]}function Bh(){}function Uh(t,e){var r=ue,n=it(),s=e(),i=!yt(n.memoizedState,s);if(i&&(n.memoizedState=s,Be=!0),n=n.queue,iu(Wh.bind(null,r,n,t),[t]),n.getSnapshot!==e||i||xe!==null&&xe.memoizedState.tag&1){if(r.flags|=2048,ds(9,Vh.bind(null,r,n,s,e),void 0,null),be===null)throw Error(P(349));jr&30||Hh(r,e,s)}return s}function Hh(t,e,r){t.flags|=16384,t={getSnapshot:e,value:r},e=ue.updateQueue,e===null?(e={lastEffect:null,stores:null},ue.updateQueue=e,e.stores=[t]):(r=e.stores,r===null?e.stores=[t]:r.push(t))}function Vh(t,e,r,n){e.value=r,e.getSnapshot=n,Kh(e)&&qh(t)}function Wh(t,e,r){return r(function(){Kh(e)&&qh(t)})}function Kh(t){var e=t.getSnapshot;t=t.value;try{var r=e();return!yt(t,r)}catch{return!0}}function qh(t){var e=It(t,1);e!==null&&mt(e,t,1,-1)}function vc(t){var e=xt();return typeof t=="function"&&(t=t()),e.memoizedState=e.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:cs,lastRenderedState:t},e.queue=t,t=t.dispatch=_m.bind(null,ue,t),[e.memoizedState,t]}function ds(t,e,r,n){return t={tag:t,create:e,destroy:r,deps:n,next:null},e=ue.updateQueue,e===null?(e={lastEffect:null,stores:null},ue.updateQueue=e,e.lastEffect=t.next=t):(r=e.lastEffect,r===null?e.lastEffect=t.next=t:(n=r.next,r.next=t,t.next=n,e.lastEffect=t)),t}function Gh(){return it().memoizedState}function oi(t,e,r,n){var s=xt();ue.flags|=t,s.memoizedState=ds(1|e,r,void 0,n===void 0?null:n)}function aa(t,e,r,n){var s=it();n=n===void 0?null:n;var i=void 0;if(ve!==null){var a=ve.memoizedState;if(i=a.destroy,n!==null&&ru(n,a.deps)){s.memoizedState=ds(e,r,i,n);return}}ue.flags|=t,s.memoizedState=ds(1|e,r,i,n)}function wc(t,e){return oi(8390656,8,t,e)}function iu(t,e){return aa(2048,8,t,e)}function Jh(t,e){return aa(4,2,t,e)}function Qh(t,e){return aa(4,4,t,e)}function Yh(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 Zh(t,e,r){return r=r!=null?r.concat([t]):null,aa(4,4,Yh.bind(null,e,t),r)}function au(){}function Xh(t,e){var r=it();e=e===void 0?null:e;var n=r.memoizedState;return n!==null&&e!==null&&ru(e,n[1])?n[0]:(r.memoizedState=[t,e],t)}function ef(t,e){var r=it();e=e===void 0?null:e;var n=r.memoizedState;return n!==null&&e!==null&&ru(e,n[1])?n[0]:(t=t(),r.memoizedState=[t,e],t)}function tf(t,e,r){return jr&21?(yt(r,e)||(r=ah(),ue.lanes|=r,Nr|=r,t.baseState=!0),e):(t.baseState&&(t.baseState=!1,Be=!0),t.memoizedState=r)}function bm(t,e){var r=Z;Z=r!==0&&4>r?r:4,t(!0);var n=Ua.transition;Ua.transition={};try{t(!1),e()}finally{Z=r,Ua.transition=n}}function rf(){return it().memoizedState}function km(t,e,r){var n=er(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},nf(t))sf(e,r);else if(r=Mh(t,e,r,n),r!==null){var s=Ie();mt(r,t,n,s),af(r,e,n)}}function _m(t,e,r){var n=er(t),s={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(nf(t))sf(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,o=i(a,r);if(s.hasEagerState=!0,s.eagerState=o,yt(o,a)){var u=e.interleaved;u===null?(s.next=s,Yl(e)):(s.next=u.next,u.next=s),e.interleaved=s;return}}catch{}finally{}r=Mh(t,e,s,n),r!==null&&(s=Ie(),mt(r,t,n,s),af(r,e,n))}}function nf(t){var e=t.alternate;return t===ue||e!==null&&e===ue}function sf(t,e){Wn=zi=!0;var r=t.pending;r===null?e.next=e:(e.next=r.next,r.next=e),t.pending=e}function af(t,e,r){if(r&4194240){var n=e.lanes;n&=t.pendingLanes,r|=n,e.lanes=r,Dl(t,r)}}var Ii={readContext:st,useCallback:Te,useContext:Te,useEffect:Te,useImperativeHandle:Te,useInsertionEffect:Te,useLayoutEffect:Te,useMemo:Te,useReducer:Te,useRef:Te,useState:Te,useDebugValue:Te,useDeferredValue:Te,useTransition:Te,useMutableSource:Te,useSyncExternalStore:Te,useId:Te,unstable_isNewReconciler:!1},Em={readContext:st,useCallback:function(t,e){return xt().memoizedState=[t,e===void 0?null:e],t},useContext:st,useEffect:wc,useImperativeHandle:function(t,e,r){return r=r!=null?r.concat([t]):null,oi(4194308,4,Yh.bind(null,e,t),r)},useLayoutEffect:function(t,e){return oi(4194308,4,t,e)},useInsertionEffect:function(t,e){return oi(4,2,t,e)},useMemo:function(t,e){var r=xt();return e=e===void 0?null:e,t=t(),r.memoizedState=[t,e],t},useReducer:function(t,e,r){var n=xt();return e=r!==void 0?r(e):e,n.memoizedState=n.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},n.queue=t,t=t.dispatch=km.bind(null,ue,t),[n.memoizedState,t]},useRef:function(t){var e=xt();return t={current:t},e.memoizedState=t},useState:vc,useDebugValue:au,useDeferredValue:function(t){return xt().memoizedState=t},useTransition:function(){var t=vc(!1),e=t[0];return t=bm.bind(null,t[1]),xt().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,r){var n=ue,s=xt();if(oe){if(r===void 0)throw Error(P(407));r=r()}else{if(r=e(),be===null)throw Error(P(349));jr&30||Hh(n,e,r)}s.memoizedState=r;var i={value:r,getSnapshot:e};return s.queue=i,wc(Wh.bind(null,n,i,t),[t]),n.flags|=2048,ds(9,Vh.bind(null,n,i,r,e),void 0,null),r},useId:function(){var t=xt(),e=be.identifierPrefix;if(oe){var r=At,n=Ct;r=(n&~(1<<32-gt(n)-1)).toString(32)+r,e=":"+e+"R"+r,r=us++,0<r&&(e+="H"+r.toString(32)),e+=":"}else r=xm++,e=":"+e+"r"+r.toString(32)+":";return t.memoizedState=e},unstable_isNewReconciler:!1},Sm={readContext:st,useCallback:Xh,useContext:st,useEffect:iu,useImperativeHandle:Zh,useInsertionEffect:Jh,useLayoutEffect:Qh,useMemo:ef,useReducer:Ha,useRef:Gh,useState:function(){return Ha(cs)},useDebugValue:au,useDeferredValue:function(t){var e=it();return tf(e,ve.memoizedState,t)},useTransition:function(){var t=Ha(cs)[0],e=it().memoizedState;return[t,e]},useMutableSource:Bh,useSyncExternalStore:Uh,useId:rf,unstable_isNewReconciler:!1},jm={readContext:st,useCallback:Xh,useContext:st,useEffect:iu,useImperativeHandle:Zh,useInsertionEffect:Jh,useLayoutEffect:Qh,useMemo:ef,useReducer:Va,useRef:Gh,useState:function(){return Va(cs)},useDebugValue:au,useDeferredValue:function(t){var e=it();return ve===null?e.memoizedState=t:tf(e,ve.memoizedState,t)},useTransition:function(){var t=Va(cs)[0],e=it().memoizedState;return[t,e]},useMutableSource:Bh,useSyncExternalStore:Uh,useId:rf,unstable_isNewReconciler:!1};function ut(t,e){if(t&&t.defaultProps){e=ce({},e),t=t.defaultProps;for(var r in t)e[r]===void 0&&(e[r]=t[r]);return e}return e}function Uo(t,e,r,n){e=t.memoizedState,r=r(n,e),r=r==null?e:ce({},e,r),t.memoizedState=r,t.lanes===0&&(t.updateQueue.baseState=r)}var oa={isMounted:function(t){return(t=t._reactInternals)?Cr(t)===t:!1},enqueueSetState:function(t,e,r){t=t._reactInternals;var n=Ie(),s=er(t),i=Ot(n,s);i.payload=e,r!=null&&(i.callback=r),e=Zt(t,i,s),e!==null&&(mt(e,t,s,n),ii(e,t,s))},enqueueReplaceState:function(t,e,r){t=t._reactInternals;var n=Ie(),s=er(t),i=Ot(n,s);i.tag=1,i.payload=e,r!=null&&(i.callback=r),e=Zt(t,i,s),e!==null&&(mt(e,t,s,n),ii(e,t,s))},enqueueForceUpdate:function(t,e){t=t._reactInternals;var r=Ie(),n=er(t),s=Ot(r,n);s.tag=2,e!=null&&(s.callback=e),e=Zt(t,s,n),e!==null&&(mt(e,t,n,r),ii(e,t,n))}};function xc(t,e,r,n,s,i,a){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(n,i,a):e.prototype&&e.prototype.isPureReactComponent?!ns(r,n)||!ns(s,i):!0}function of(t,e,r){var n=!1,s=nr,i=e.contextType;return typeof i=="object"&&i!==null?i=st(i):(s=He(e)?Er:Oe.current,n=e.contextTypes,i=(n=n!=null)?ln(t,s):nr),e=new e(r,i),t.memoizedState=e.state!==null&&e.state!==void 0?e.state:null,e.updater=oa,t.stateNode=e,e._reactInternals=t,n&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=s,t.__reactInternalMemoizedMaskedChildContext=i),e}function bc(t,e,r,n){t=e.state,typeof e.componentWillReceiveProps=="function"&&e.componentWillReceiveProps(r,n),typeof e.UNSAFE_componentWillReceiveProps=="function"&&e.UNSAFE_componentWillReceiveProps(r,n),e.state!==t&&oa.enqueueReplaceState(e,e.state,null)}function Ho(t,e,r,n){var s=t.stateNode;s.props=r,s.state=t.memoizedState,s.refs={},Zl(t);var i=e.contextType;typeof i=="object"&&i!==null?s.context=st(i):(i=He(e)?Er:Oe.current,s.context=ln(t,i)),s.state=t.memoizedState,i=e.getDerivedStateFromProps,typeof i=="function"&&(Uo(t,e,i,r),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&&oa.enqueueReplaceState(s,s.state,null),Oi(t,r,s,n),s.state=t.memoizedState),typeof s.componentDidMount=="function"&&(t.flags|=4194308)}function hn(t,e){try{var r="",n=e;do r+=eg(n),n=n.return;while(n);var s=r}catch(i){s=`
|
||
Error generating stack: `+i.message+`
|
||
`+i.stack}return{value:t,source:e,stack:s,digest:null}}function Wa(t,e,r){return{value:t,source:null,stack:r??null,digest:e??null}}function Vo(t,e){try{console.error(e.value)}catch(r){setTimeout(function(){throw r})}}var Nm=typeof WeakMap=="function"?WeakMap:Map;function lf(t,e,r){r=Ot(-1,r),r.tag=3,r.payload={element:null};var n=e.value;return r.callback=function(){Di||(Di=!0,el=n),Vo(t,e)},r}function uf(t,e,r){r=Ot(-1,r),r.tag=3;var n=t.type.getDerivedStateFromError;if(typeof n=="function"){var s=e.value;r.payload=function(){return n(s)},r.callback=function(){Vo(t,e)}}var i=t.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(r.callback=function(){Vo(t,e),typeof n!="function"&&(Xt===null?Xt=new Set([this]):Xt.add(this));var a=e.stack;this.componentDidCatch(e.value,{componentStack:a!==null?a:""})}),r}function kc(t,e,r){var n=t.pingCache;if(n===null){n=t.pingCache=new Nm;var s=new Set;n.set(e,s)}else s=n.get(e),s===void 0&&(s=new Set,n.set(e,s));s.has(r)||(s.add(r),t=Bm.bind(null,t,e,r),e.then(t,t))}function _c(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 Ec(t,e,r,n,s){return t.mode&1?(t.flags|=65536,t.lanes=s,t):(t===e?t.flags|=65536:(t.flags|=128,r.flags|=131072,r.flags&=-52805,r.tag===1&&(r.alternate===null?r.tag=17:(e=Ot(-1,1),e.tag=2,Zt(r,e,1))),r.lanes|=1),t)}var Tm=Dt.ReactCurrentOwner,Be=!1;function ze(t,e,r,n){e.child=t===null?Dh(e,null,r,n):cn(e,t.child,r,n)}function Sc(t,e,r,n,s){r=r.render;var i=e.ref;return rn(e,s),n=nu(t,e,r,n,i,s),r=su(),t!==null&&!Be?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~s,Lt(t,e,s)):(oe&&r&&Wl(e),e.flags|=1,ze(t,e,n,s),e.child)}function jc(t,e,r,n,s){if(t===null){var i=r.type;return typeof i=="function"&&!pu(i)&&i.defaultProps===void 0&&r.compare===null&&r.defaultProps===void 0?(e.tag=15,e.type=i,cf(t,e,i,n,s)):(t=di(r.type,null,n,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(r=r.compare,r=r!==null?r:ns,r(a,n)&&t.ref===e.ref)return Lt(t,e,s)}return e.flags|=1,t=tr(i,n),t.ref=e.ref,t.return=e,e.child=t}function cf(t,e,r,n,s){if(t!==null){var i=t.memoizedProps;if(ns(i,n)&&t.ref===e.ref)if(Be=!1,e.pendingProps=n=i,(t.lanes&s)!==0)t.flags&131072&&(Be=!0);else return e.lanes=t.lanes,Lt(t,e,s)}return Wo(t,e,r,n,s)}function df(t,e,r){var n=e.pendingProps,s=n.children,i=t!==null?t.memoizedState:null;if(n.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},re(Qr,qe),qe|=r;else{if(!(r&1073741824))return t=i!==null?i.baseLanes|r:r,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,re(Qr,qe),qe|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},n=i!==null?i.baseLanes:r,re(Qr,qe),qe|=n}else i!==null?(n=i.baseLanes|r,e.memoizedState=null):n=r,re(Qr,qe),qe|=n;return ze(t,e,s,r),e.child}function hf(t,e){var r=e.ref;(t===null&&r!==null||t!==null&&t.ref!==r)&&(e.flags|=512,e.flags|=2097152)}function Wo(t,e,r,n,s){var i=He(r)?Er:Oe.current;return i=ln(e,i),rn(e,s),r=nu(t,e,r,n,i,s),n=su(),t!==null&&!Be?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~s,Lt(t,e,s)):(oe&&n&&Wl(e),e.flags|=1,ze(t,e,r,s),e.child)}function Nc(t,e,r,n,s){if(He(r)){var i=!0;Ni(e)}else i=!1;if(rn(e,s),e.stateNode===null)li(t,e),of(e,r,n),Ho(e,r,n,s),n=!0;else if(t===null){var a=e.stateNode,o=e.memoizedProps;a.props=o;var u=a.context,c=r.contextType;typeof c=="object"&&c!==null?c=st(c):(c=He(r)?Er:Oe.current,c=ln(e,c));var d=r.getDerivedStateFromProps,h=typeof d=="function"||typeof a.getSnapshotBeforeUpdate=="function";h||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(o!==n||u!==c)&&bc(e,a,n,c),Bt=!1;var f=e.memoizedState;a.state=f,Oi(e,n,a,s),u=e.memoizedState,o!==n||f!==u||Ue.current||Bt?(typeof d=="function"&&(Uo(e,r,d,n),u=e.memoizedState),(o=Bt||xc(e,r,o,n,f,u,c))?(h||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=n,e.memoizedState=u),a.props=n,a.state=u,a.context=c,n=o):(typeof a.componentDidMount=="function"&&(e.flags|=4194308),n=!1)}else{a=e.stateNode,Fh(t,e),o=e.memoizedProps,c=e.type===e.elementType?o:ut(e.type,o),a.props=c,h=e.pendingProps,f=a.context,u=r.contextType,typeof u=="object"&&u!==null?u=st(u):(u=He(r)?Er:Oe.current,u=ln(e,u));var y=r.getDerivedStateFromProps;(d=typeof y=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(o!==h||f!==u)&&bc(e,a,n,u),Bt=!1,f=e.memoizedState,a.state=f,Oi(e,n,a,s);var w=e.memoizedState;o!==h||f!==w||Ue.current||Bt?(typeof y=="function"&&(Uo(e,r,y,n),w=e.memoizedState),(c=Bt||xc(e,r,c,n,f,w,u)||!1)?(d||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(n,w,u),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(n,w,u)),typeof a.componentDidUpdate=="function"&&(e.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof a.componentDidUpdate!="function"||o===t.memoizedProps&&f===t.memoizedState||(e.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||o===t.memoizedProps&&f===t.memoizedState||(e.flags|=1024),e.memoizedProps=n,e.memoizedState=w),a.props=n,a.state=w,a.context=u,n=c):(typeof a.componentDidUpdate!="function"||o===t.memoizedProps&&f===t.memoizedState||(e.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||o===t.memoizedProps&&f===t.memoizedState||(e.flags|=1024),n=!1)}return Ko(t,e,r,n,i,s)}function Ko(t,e,r,n,s,i){hf(t,e);var a=(e.flags&128)!==0;if(!n&&!a)return s&&hc(e,r,!1),Lt(t,e,i);n=e.stateNode,Tm.current=e;var o=a&&typeof r.getDerivedStateFromError!="function"?null:n.render();return e.flags|=1,t!==null&&a?(e.child=cn(e,t.child,null,i),e.child=cn(e,null,o,i)):ze(t,e,o,i),e.memoizedState=n.state,s&&hc(e,r,!0),e.child}function ff(t){var e=t.stateNode;e.pendingContext?dc(t,e.pendingContext,e.pendingContext!==e.context):e.context&&dc(t,e.context,!1),Xl(t,e.containerInfo)}function Tc(t,e,r,n,s){return un(),ql(s),e.flags|=256,ze(t,e,r,n),e.child}var qo={dehydrated:null,treeContext:null,retryLane:0};function Go(t){return{baseLanes:t,cachePool:null,transitions:null}}function pf(t,e,r){var n=e.pendingProps,s=le.current,i=!1,a=(e.flags&128)!==0,o;if((o=a)||(o=t!==null&&t.memoizedState===null?!1:(s&2)!==0),o?(i=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(s|=1),re(le,s&1),t===null)return $o(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=n.children,t=n.fallback,i?(n=e.mode,i=e.child,a={mode:"hidden",children:a},!(n&1)&&i!==null?(i.childLanes=0,i.pendingProps=a):i=ca(a,n,0,null),t=_r(t,n,r,null),i.return=e,t.return=e,i.sibling=t,e.child=i,e.child.memoizedState=Go(r),e.memoizedState=qo,t):ou(e,a));if(s=t.memoizedState,s!==null&&(o=s.dehydrated,o!==null))return Pm(t,e,a,n,o,s,r);if(i){i=n.fallback,a=e.mode,s=t.child,o=s.sibling;var u={mode:"hidden",children:n.children};return!(a&1)&&e.child!==s?(n=e.child,n.childLanes=0,n.pendingProps=u,e.deletions=null):(n=tr(s,u),n.subtreeFlags=s.subtreeFlags&14680064),o!==null?i=tr(o,i):(i=_r(i,a,r,null),i.flags|=2),i.return=e,n.return=e,n.sibling=i,e.child=n,n=i,i=e.child,a=t.child.memoizedState,a=a===null?Go(r):{baseLanes:a.baseLanes|r,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=t.childLanes&~r,e.memoizedState=qo,n}return i=t.child,t=i.sibling,n=tr(i,{mode:"visible",children:n.children}),!(e.mode&1)&&(n.lanes=r),n.return=e,n.sibling=null,t!==null&&(r=e.deletions,r===null?(e.deletions=[t],e.flags|=16):r.push(t)),e.child=n,e.memoizedState=null,n}function ou(t,e){return e=ca({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function Ds(t,e,r,n){return n!==null&&ql(n),cn(e,t.child,null,r),t=ou(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function Pm(t,e,r,n,s,i,a){if(r)return e.flags&256?(e.flags&=-257,n=Wa(Error(P(422))),Ds(t,e,a,n)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(i=n.fallback,s=e.mode,n=ca({mode:"visible",children:n.children},s,0,null),i=_r(i,s,a,null),i.flags|=2,n.return=e,i.return=e,n.sibling=i,e.child=n,e.mode&1&&cn(e,t.child,null,a),e.child.memoizedState=Go(a),e.memoizedState=qo,i);if(!(e.mode&1))return Ds(t,e,a,null);if(s.data==="$!"){if(n=s.nextSibling&&s.nextSibling.dataset,n)var o=n.dgst;return n=o,i=Error(P(419)),n=Wa(i,n,void 0),Ds(t,e,a,n)}if(o=(a&t.childLanes)!==0,Be||o){if(n=be,n!==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&(n.suspendedLanes|a)?0:s,s!==0&&s!==i.retryLane&&(i.retryLane=s,It(t,s),mt(n,t,s,-1))}return fu(),n=Wa(Error(P(421))),Ds(t,e,a,n)}return s.data==="$?"?(e.flags|=128,e.child=t.child,e=Um.bind(null,t),s._reactRetry=e,null):(t=i.treeContext,Je=Yt(s.nextSibling),Qe=e,oe=!0,ft=null,t!==null&&(et[tt++]=Ct,et[tt++]=At,et[tt++]=Sr,Ct=t.id,At=t.overflow,Sr=e),e=ou(e,n.children),e.flags|=4096,e)}function Pc(t,e,r){t.lanes|=e;var n=t.alternate;n!==null&&(n.lanes|=e),Bo(t.return,e,r)}function Ka(t,e,r,n,s){var i=t.memoizedState;i===null?t.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:n,tail:r,tailMode:s}:(i.isBackwards=e,i.rendering=null,i.renderingStartTime=0,i.last=n,i.tail=r,i.tailMode=s)}function gf(t,e,r){var n=e.pendingProps,s=n.revealOrder,i=n.tail;if(ze(t,e,n.children,r),n=le.current,n&2)n=n&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&&Pc(t,r,e);else if(t.tag===19)Pc(t,r,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}n&=1}if(re(le,n),!(e.mode&1))e.memoizedState=null;else switch(s){case"forwards":for(r=e.child,s=null;r!==null;)t=r.alternate,t!==null&&Ri(t)===null&&(s=r),r=r.sibling;r=s,r===null?(s=e.child,e.child=null):(s=r.sibling,r.sibling=null),Ka(e,!1,s,r,i);break;case"backwards":for(r=null,s=e.child,e.child=null;s!==null;){if(t=s.alternate,t!==null&&Ri(t)===null){e.child=s;break}t=s.sibling,s.sibling=r,r=s,s=t}Ka(e,!0,r,null,i);break;case"together":Ka(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function li(t,e){!(e.mode&1)&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}function Lt(t,e,r){if(t!==null&&(e.dependencies=t.dependencies),Nr|=e.lanes,!(r&e.childLanes))return null;if(t!==null&&e.child!==t.child)throw Error(P(153));if(e.child!==null){for(t=e.child,r=tr(t,t.pendingProps),e.child=r,r.return=e;t.sibling!==null;)t=t.sibling,r=r.sibling=tr(t,t.pendingProps),r.return=e;r.sibling=null}return e.child}function Cm(t,e,r){switch(e.tag){case 3:ff(e),un();break;case 5:$h(e);break;case 1:He(e.type)&&Ni(e);break;case 4:Xl(e,e.stateNode.containerInfo);break;case 10:var n=e.type._context,s=e.memoizedProps.value;re(Ci,n._currentValue),n._currentValue=s;break;case 13:if(n=e.memoizedState,n!==null)return n.dehydrated!==null?(re(le,le.current&1),e.flags|=128,null):r&e.child.childLanes?pf(t,e,r):(re(le,le.current&1),t=Lt(t,e,r),t!==null?t.sibling:null);re(le,le.current&1);break;case 19:if(n=(r&e.childLanes)!==0,t.flags&128){if(n)return gf(t,e,r);e.flags|=128}if(s=e.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),re(le,le.current),n)break;return null;case 22:case 23:return e.lanes=0,df(t,e,r)}return Lt(t,e,r)}var mf,Jo,yf,vf;mf=function(t,e){for(var r=e.child;r!==null;){if(r.tag===5||r.tag===6)t.appendChild(r.stateNode);else if(r.tag!==4&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===e)break;for(;r.sibling===null;){if(r.return===null||r.return===e)return;r=r.return}r.sibling.return=r.return,r=r.sibling}};Jo=function(){};yf=function(t,e,r,n){var s=t.memoizedProps;if(s!==n){t=e.stateNode,xr(Et.current);var i=null;switch(r){case"input":s=yo(t,s),n=yo(t,n),i=[];break;case"select":s=ce({},s,{value:void 0}),n=ce({},n,{value:void 0}),i=[];break;case"textarea":s=xo(t,s),n=xo(t,n),i=[];break;default:typeof s.onClick!="function"&&typeof n.onClick=="function"&&(t.onclick=Si)}ko(r,n);var a;r=null;for(c in s)if(!n.hasOwnProperty(c)&&s.hasOwnProperty(c)&&s[c]!=null)if(c==="style"){var o=s[c];for(a in o)o.hasOwnProperty(a)&&(r||(r={}),r[a]="")}else c!=="dangerouslySetInnerHTML"&&c!=="children"&&c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&c!=="autoFocus"&&(Qn.hasOwnProperty(c)?i||(i=[]):(i=i||[]).push(c,null));for(c in n){var u=n[c];if(o=s!=null?s[c]:void 0,n.hasOwnProperty(c)&&u!==o&&(u!=null||o!=null))if(c==="style")if(o){for(a in o)!o.hasOwnProperty(a)||u&&u.hasOwnProperty(a)||(r||(r={}),r[a]="");for(a in u)u.hasOwnProperty(a)&&o[a]!==u[a]&&(r||(r={}),r[a]=u[a])}else r||(i||(i=[]),i.push(c,r)),r=u;else c==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,o=o?o.__html:void 0,u!=null&&o!==u&&(i=i||[]).push(c,u)):c==="children"?typeof u!="string"&&typeof u!="number"||(i=i||[]).push(c,""+u):c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&(Qn.hasOwnProperty(c)?(u!=null&&c==="onScroll"&&ne("scroll",t),i||o===u||(i=[])):(i=i||[]).push(c,u))}r&&(i=i||[]).push("style",r);var c=i;(e.updateQueue=c)&&(e.flags|=4)}};vf=function(t,e,r,n){r!==n&&(e.flags|=4)};function Pn(t,e){if(!oe)switch(t.tailMode){case"hidden":e=t.tail;for(var r=null;e!==null;)e.alternate!==null&&(r=e),e=e.sibling;r===null?t.tail=null:r.sibling=null;break;case"collapsed":r=t.tail;for(var n=null;r!==null;)r.alternate!==null&&(n=r),r=r.sibling;n===null?e||t.tail===null?t.tail=null:t.tail.sibling=null:n.sibling=null}}function Pe(t){var e=t.alternate!==null&&t.alternate.child===t.child,r=0,n=0;if(e)for(var s=t.child;s!==null;)r|=s.lanes|s.childLanes,n|=s.subtreeFlags&14680064,n|=s.flags&14680064,s.return=t,s=s.sibling;else for(s=t.child;s!==null;)r|=s.lanes|s.childLanes,n|=s.subtreeFlags,n|=s.flags,s.return=t,s=s.sibling;return t.subtreeFlags|=n,t.childLanes=r,e}function Am(t,e,r){var n=e.pendingProps;switch(Kl(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Pe(e),null;case 1:return He(e.type)&&ji(),Pe(e),null;case 3:return n=e.stateNode,dn(),se(Ue),se(Oe),tu(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(t===null||t.child===null)&&(Is(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,ft!==null&&(nl(ft),ft=null))),Jo(t,e),Pe(e),null;case 5:eu(e);var s=xr(ls.current);if(r=e.type,t!==null&&e.stateNode!=null)yf(t,e,r,n,s),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!n){if(e.stateNode===null)throw Error(P(166));return Pe(e),null}if(t=xr(Et.current),Is(e)){n=e.stateNode,r=e.type;var i=e.memoizedProps;switch(n[kt]=e,n[as]=i,t=(e.mode&1)!==0,r){case"dialog":ne("cancel",n),ne("close",n);break;case"iframe":case"object":case"embed":ne("load",n);break;case"video":case"audio":for(s=0;s<In.length;s++)ne(In[s],n);break;case"source":ne("error",n);break;case"img":case"image":case"link":ne("error",n),ne("load",n);break;case"details":ne("toggle",n);break;case"input":Mu(n,i),ne("invalid",n);break;case"select":n._wrapperState={wasMultiple:!!i.multiple},ne("invalid",n);break;case"textarea":$u(n,i),ne("invalid",n)}ko(r,i),s=null;for(var a in i)if(i.hasOwnProperty(a)){var o=i[a];a==="children"?typeof o=="string"?n.textContent!==o&&(i.suppressHydrationWarning!==!0&&zs(n.textContent,o,t),s=["children",o]):typeof o=="number"&&n.textContent!==""+o&&(i.suppressHydrationWarning!==!0&&zs(n.textContent,o,t),s=["children",""+o]):Qn.hasOwnProperty(a)&&o!=null&&a==="onScroll"&&ne("scroll",n)}switch(r){case"input":js(n),Fu(n,i,!0);break;case"textarea":js(n),Bu(n);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(n.onclick=Si)}n=s,e.updateQueue=n,n!==null&&(e.flags|=4)}else{a=s.nodeType===9?s:s.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=Wd(r)),t==="http://www.w3.org/1999/xhtml"?r==="script"?(t=a.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof n.is=="string"?t=a.createElement(r,{is:n.is}):(t=a.createElement(r),r==="select"&&(a=t,n.multiple?a.multiple=!0:n.size&&(a.size=n.size))):t=a.createElementNS(t,r),t[kt]=e,t[as]=n,mf(t,e,!1,!1),e.stateNode=t;e:{switch(a=_o(r,n),r){case"dialog":ne("cancel",t),ne("close",t),s=n;break;case"iframe":case"object":case"embed":ne("load",t),s=n;break;case"video":case"audio":for(s=0;s<In.length;s++)ne(In[s],t);s=n;break;case"source":ne("error",t),s=n;break;case"img":case"image":case"link":ne("error",t),ne("load",t),s=n;break;case"details":ne("toggle",t),s=n;break;case"input":Mu(t,n),s=yo(t,n),ne("invalid",t);break;case"option":s=n;break;case"select":t._wrapperState={wasMultiple:!!n.multiple},s=ce({},n,{value:void 0}),ne("invalid",t);break;case"textarea":$u(t,n),s=xo(t,n),ne("invalid",t);break;default:s=n}ko(r,s),o=s;for(i in o)if(o.hasOwnProperty(i)){var u=o[i];i==="style"?Gd(t,u):i==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,u!=null&&Kd(t,u)):i==="children"?typeof u=="string"?(r!=="textarea"||u!=="")&&Yn(t,u):typeof u=="number"&&Yn(t,""+u):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Qn.hasOwnProperty(i)?u!=null&&i==="onScroll"&&ne("scroll",t):u!=null&&Al(t,i,u,a))}switch(r){case"input":js(t),Fu(t,n,!1);break;case"textarea":js(t),Bu(t);break;case"option":n.value!=null&&t.setAttribute("value",""+rr(n.value));break;case"select":t.multiple=!!n.multiple,i=n.value,i!=null?Zr(t,!!n.multiple,i,!1):n.defaultValue!=null&&Zr(t,!!n.multiple,n.defaultValue,!0);break;default:typeof s.onClick=="function"&&(t.onclick=Si)}switch(r){case"button":case"input":case"select":case"textarea":n=!!n.autoFocus;break e;case"img":n=!0;break e;default:n=!1}}n&&(e.flags|=4)}e.ref!==null&&(e.flags|=512,e.flags|=2097152)}return Pe(e),null;case 6:if(t&&e.stateNode!=null)vf(t,e,t.memoizedProps,n);else{if(typeof n!="string"&&e.stateNode===null)throw Error(P(166));if(r=xr(ls.current),xr(Et.current),Is(e)){if(n=e.stateNode,r=e.memoizedProps,n[kt]=e,(i=n.nodeValue!==r)&&(t=Qe,t!==null))switch(t.tag){case 3:zs(n.nodeValue,r,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&zs(n.nodeValue,r,(t.mode&1)!==0)}i&&(e.flags|=4)}else n=(r.nodeType===9?r:r.ownerDocument).createTextNode(n),n[kt]=e,e.stateNode=n}return Pe(e),null;case 13:if(se(le),n=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(oe&&Je!==null&&e.mode&1&&!(e.flags&128))Ih(),un(),e.flags|=98560,i=!1;else if(i=Is(e),n!==null&&n.dehydrated!==null){if(t===null){if(!i)throw Error(P(318));if(i=e.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(P(317));i[kt]=e}else un(),!(e.flags&128)&&(e.memoizedState=null),e.flags|=4;Pe(e),i=!1}else ft!==null&&(nl(ft),ft=null),i=!0;if(!i)return e.flags&65536?e:null}return e.flags&128?(e.lanes=r,e):(n=n!==null,n!==(t!==null&&t.memoizedState!==null)&&n&&(e.child.flags|=8192,e.mode&1&&(t===null||le.current&1?we===0&&(we=3):fu())),e.updateQueue!==null&&(e.flags|=4),Pe(e),null);case 4:return dn(),Jo(t,e),t===null&&ss(e.stateNode.containerInfo),Pe(e),null;case 10:return Ql(e.type._context),Pe(e),null;case 17:return He(e.type)&&ji(),Pe(e),null;case 19:if(se(le),i=e.memoizedState,i===null)return Pe(e),null;if(n=(e.flags&128)!==0,a=i.rendering,a===null)if(n)Pn(i,!1);else{if(we!==0||t!==null&&t.flags&128)for(t=e.child;t!==null;){if(a=Ri(t),a!==null){for(e.flags|=128,Pn(i,!1),n=a.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),e.subtreeFlags=0,n=r,r=e.child;r!==null;)i=r,t=n,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}),r=r.sibling;return re(le,le.current&1|2),e.child}t=t.sibling}i.tail!==null&&fe()>fn&&(e.flags|=128,n=!0,Pn(i,!1),e.lanes=4194304)}else{if(!n)if(t=Ri(a),t!==null){if(e.flags|=128,n=!0,r=t.updateQueue,r!==null&&(e.updateQueue=r,e.flags|=4),Pn(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!oe)return Pe(e),null}else 2*fe()-i.renderingStartTime>fn&&r!==1073741824&&(e.flags|=128,n=!0,Pn(i,!1),e.lanes=4194304);i.isBackwards?(a.sibling=e.child,e.child=a):(r=i.last,r!==null?r.sibling=a:e.child=a,i.last=a)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=fe(),e.sibling=null,r=le.current,re(le,n?r&1|2:r&1),e):(Pe(e),null);case 22:case 23:return hu(),n=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(e.flags|=8192),n&&e.mode&1?qe&1073741824&&(Pe(e),e.subtreeFlags&6&&(e.flags|=8192)):Pe(e),null;case 24:return null;case 25:return null}throw Error(P(156,e.tag))}function Om(t,e){switch(Kl(e),e.tag){case 1:return He(e.type)&&ji(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return dn(),se(Ue),se(Oe),tu(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return eu(e),null;case 13:if(se(le),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(P(340));un()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return se(le),null;case 4:return dn(),null;case 10:return Ql(e.type._context),null;case 22:case 23:return hu(),null;case 24:return null;default:return null}}var Ms=!1,Ce=!1,Rm=typeof WeakSet=="function"?WeakSet:Set,z=null;function Jr(t,e){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){de(t,e,n)}else r.current=null}function Qo(t,e,r){try{r()}catch(n){de(t,e,n)}}var Cc=!1;function zm(t,e){if(Ro=ki,t=kh(),Vl(t)){if("selectionStart"in t)var r={start:t.selectionStart,end:t.selectionEnd};else e:{r=(r=t.ownerDocument)&&r.defaultView||window;var n=r.getSelection&&r.getSelection();if(n&&n.rangeCount!==0){r=n.anchorNode;var s=n.anchorOffset,i=n.focusNode;n=n.focusOffset;try{r.nodeType,i.nodeType}catch{r=null;break e}var a=0,o=-1,u=-1,c=0,d=0,h=t,f=null;t:for(;;){for(var y;h!==r||s!==0&&h.nodeType!==3||(o=a+s),h!==i||n!==0&&h.nodeType!==3||(u=a+n),h.nodeType===3&&(a+=h.nodeValue.length),(y=h.firstChild)!==null;)f=h,h=y;for(;;){if(h===t)break t;if(f===r&&++c===s&&(o=a),f===i&&++d===n&&(u=a),(y=h.nextSibling)!==null)break;h=f,f=h.parentNode}h=y}r=o===-1||u===-1?null:{start:o,end:u}}else r=null}r=r||{start:0,end:0}}else r=null;for(zo={focusedElem:t,selectionRange:r},ki=!1,z=e;z!==null;)if(e=z,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,z=t;else for(;z!==null;){e=z;try{var w=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(w!==null){var x=w.memoizedProps,b=w.memoizedState,p=e.stateNode,m=p.getSnapshotBeforeUpdate(e.elementType===e.type?x:ut(e.type,x),b);p.__reactInternalSnapshotBeforeUpdate=m}break;case 3:var g=e.stateNode.containerInfo;g.nodeType===1?g.textContent="":g.nodeType===9&&g.documentElement&&g.removeChild(g.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(P(163))}}catch(k){de(e,e.return,k)}if(t=e.sibling,t!==null){t.return=e.return,z=t;break}z=e.return}return w=Cc,Cc=!1,w}function Kn(t,e,r){var n=e.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var s=n=n.next;do{if((s.tag&t)===t){var i=s.destroy;s.destroy=void 0,i!==void 0&&Qo(e,r,i)}s=s.next}while(s!==n)}}function la(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var r=e=e.next;do{if((r.tag&t)===t){var n=r.create;r.destroy=n()}r=r.next}while(r!==e)}}function Yo(t){var e=t.ref;if(e!==null){var r=t.stateNode;switch(t.tag){case 5:t=r;break;default:t=r}typeof e=="function"?e(t):e.current=t}}function wf(t){var e=t.alternate;e!==null&&(t.alternate=null,wf(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[kt],delete e[as],delete e[Do],delete e[mm],delete e[ym])),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 xf(t){return t.tag===5||t.tag===3||t.tag===4}function Ac(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||xf(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 Zo(t,e,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,e?r.nodeType===8?r.parentNode.insertBefore(t,e):r.insertBefore(t,e):(r.nodeType===8?(e=r.parentNode,e.insertBefore(t,r)):(e=r,e.appendChild(t)),r=r._reactRootContainer,r!=null||e.onclick!==null||(e.onclick=Si));else if(n!==4&&(t=t.child,t!==null))for(Zo(t,e,r),t=t.sibling;t!==null;)Zo(t,e,r),t=t.sibling}function Xo(t,e,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,e?r.insertBefore(t,e):r.appendChild(t);else if(n!==4&&(t=t.child,t!==null))for(Xo(t,e,r),t=t.sibling;t!==null;)Xo(t,e,r),t=t.sibling}var Ee=null,dt=!1;function Ft(t,e,r){for(r=r.child;r!==null;)bf(t,e,r),r=r.sibling}function bf(t,e,r){if(_t&&typeof _t.onCommitFiberUnmount=="function")try{_t.onCommitFiberUnmount(ea,r)}catch{}switch(r.tag){case 5:Ce||Jr(r,e);case 6:var n=Ee,s=dt;Ee=null,Ft(t,e,r),Ee=n,dt=s,Ee!==null&&(dt?(t=Ee,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):Ee.removeChild(r.stateNode));break;case 18:Ee!==null&&(dt?(t=Ee,r=r.stateNode,t.nodeType===8?Fa(t.parentNode,r):t.nodeType===1&&Fa(t,r),ts(t)):Fa(Ee,r.stateNode));break;case 4:n=Ee,s=dt,Ee=r.stateNode.containerInfo,dt=!0,Ft(t,e,r),Ee=n,dt=s;break;case 0:case 11:case 14:case 15:if(!Ce&&(n=r.updateQueue,n!==null&&(n=n.lastEffect,n!==null))){s=n=n.next;do{var i=s,a=i.destroy;i=i.tag,a!==void 0&&(i&2||i&4)&&Qo(r,e,a),s=s.next}while(s!==n)}Ft(t,e,r);break;case 1:if(!Ce&&(Jr(r,e),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(o){de(r,e,o)}Ft(t,e,r);break;case 21:Ft(t,e,r);break;case 22:r.mode&1?(Ce=(n=Ce)||r.memoizedState!==null,Ft(t,e,r),Ce=n):Ft(t,e,r);break;default:Ft(t,e,r)}}function Oc(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new Rm),e.forEach(function(n){var s=Hm.bind(null,t,n);r.has(n)||(r.add(n),n.then(s,s))})}}function ot(t,e){var r=e.deletions;if(r!==null)for(var n=0;n<r.length;n++){var s=r[n];try{var i=t,a=e,o=a;e:for(;o!==null;){switch(o.tag){case 5:Ee=o.stateNode,dt=!1;break e;case 3:Ee=o.stateNode.containerInfo,dt=!0;break e;case 4:Ee=o.stateNode.containerInfo,dt=!0;break e}o=o.return}if(Ee===null)throw Error(P(160));bf(i,a,s),Ee=null,dt=!1;var u=s.alternate;u!==null&&(u.return=null),s.return=null}catch(c){de(s,e,c)}}if(e.subtreeFlags&12854)for(e=e.child;e!==null;)kf(e,t),e=e.sibling}function kf(t,e){var r=t.alternate,n=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(ot(e,t),wt(t),n&4){try{Kn(3,t,t.return),la(3,t)}catch(x){de(t,t.return,x)}try{Kn(5,t,t.return)}catch(x){de(t,t.return,x)}}break;case 1:ot(e,t),wt(t),n&512&&r!==null&&Jr(r,r.return);break;case 5:if(ot(e,t),wt(t),n&512&&r!==null&&Jr(r,r.return),t.flags&32){var s=t.stateNode;try{Yn(s,"")}catch(x){de(t,t.return,x)}}if(n&4&&(s=t.stateNode,s!=null)){var i=t.memoizedProps,a=r!==null?r.memoizedProps:i,o=t.type,u=t.updateQueue;if(t.updateQueue=null,u!==null)try{o==="input"&&i.type==="radio"&&i.name!=null&&Hd(s,i),_o(o,a);var c=_o(o,i);for(a=0;a<u.length;a+=2){var d=u[a],h=u[a+1];d==="style"?Gd(s,h):d==="dangerouslySetInnerHTML"?Kd(s,h):d==="children"?Yn(s,h):Al(s,d,h,c)}switch(o){case"input":vo(s,i);break;case"textarea":Vd(s,i);break;case"select":var f=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var y=i.value;y!=null?Zr(s,!!i.multiple,y,!1):f!==!!i.multiple&&(i.defaultValue!=null?Zr(s,!!i.multiple,i.defaultValue,!0):Zr(s,!!i.multiple,i.multiple?[]:"",!1))}s[as]=i}catch(x){de(t,t.return,x)}}break;case 6:if(ot(e,t),wt(t),n&4){if(t.stateNode===null)throw Error(P(162));s=t.stateNode,i=t.memoizedProps;try{s.nodeValue=i}catch(x){de(t,t.return,x)}}break;case 3:if(ot(e,t),wt(t),n&4&&r!==null&&r.memoizedState.isDehydrated)try{ts(e.containerInfo)}catch(x){de(t,t.return,x)}break;case 4:ot(e,t),wt(t);break;case 13:ot(e,t),wt(t),s=t.child,s.flags&8192&&(i=s.memoizedState!==null,s.stateNode.isHidden=i,!i||s.alternate!==null&&s.alternate.memoizedState!==null||(cu=fe())),n&4&&Oc(t);break;case 22:if(d=r!==null&&r.memoizedState!==null,t.mode&1?(Ce=(c=Ce)||d,ot(e,t),Ce=c):ot(e,t),wt(t),n&8192){if(c=t.memoizedState!==null,(t.stateNode.isHidden=c)&&!d&&t.mode&1)for(z=t,d=t.child;d!==null;){for(h=z=d;z!==null;){switch(f=z,y=f.child,f.tag){case 0:case 11:case 14:case 15:Kn(4,f,f.return);break;case 1:Jr(f,f.return);var w=f.stateNode;if(typeof w.componentWillUnmount=="function"){n=f,r=f.return;try{e=n,w.props=e.memoizedProps,w.state=e.memoizedState,w.componentWillUnmount()}catch(x){de(n,r,x)}}break;case 5:Jr(f,f.return);break;case 22:if(f.memoizedState!==null){zc(h);continue}}y!==null?(y.return=f,z=y):zc(h)}d=d.sibling}e:for(d=null,h=t;;){if(h.tag===5){if(d===null){d=h;try{s=h.stateNode,c?(i=s.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(o=h.stateNode,u=h.memoizedProps.style,a=u!=null&&u.hasOwnProperty("display")?u.display:null,o.style.display=qd("display",a))}catch(x){de(t,t.return,x)}}}else if(h.tag===6){if(d===null)try{h.stateNode.nodeValue=c?"":h.memoizedProps}catch(x){de(t,t.return,x)}}else if((h.tag!==22&&h.tag!==23||h.memoizedState===null||h===t)&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===t)break e;for(;h.sibling===null;){if(h.return===null||h.return===t)break e;d===h&&(d=null),h=h.return}d===h&&(d=null),h.sibling.return=h.return,h=h.sibling}}break;case 19:ot(e,t),wt(t),n&4&&Oc(t);break;case 21:break;default:ot(e,t),wt(t)}}function wt(t){var e=t.flags;if(e&2){try{e:{for(var r=t.return;r!==null;){if(xf(r)){var n=r;break e}r=r.return}throw Error(P(160))}switch(n.tag){case 5:var s=n.stateNode;n.flags&32&&(Yn(s,""),n.flags&=-33);var i=Ac(t);Xo(t,i,s);break;case 3:case 4:var a=n.stateNode.containerInfo,o=Ac(t);Zo(t,o,a);break;default:throw Error(P(161))}}catch(u){de(t,t.return,u)}t.flags&=-3}e&4096&&(t.flags&=-4097)}function Im(t,e,r){z=t,_f(t)}function _f(t,e,r){for(var n=(t.mode&1)!==0;z!==null;){var s=z,i=s.child;if(s.tag===22&&n){var a=s.memoizedState!==null||Ms;if(!a){var o=s.alternate,u=o!==null&&o.memoizedState!==null||Ce;o=Ms;var c=Ce;if(Ms=a,(Ce=u)&&!c)for(z=s;z!==null;)a=z,u=a.child,a.tag===22&&a.memoizedState!==null?Ic(s):u!==null?(u.return=a,z=u):Ic(s);for(;i!==null;)z=i,_f(i),i=i.sibling;z=s,Ms=o,Ce=c}Rc(t)}else s.subtreeFlags&8772&&i!==null?(i.return=s,z=i):Rc(t)}}function Rc(t){for(;z!==null;){var e=z;if(e.flags&8772){var r=e.alternate;try{if(e.flags&8772)switch(e.tag){case 0:case 11:case 15:Ce||la(5,e);break;case 1:var n=e.stateNode;if(e.flags&4&&!Ce)if(r===null)n.componentDidMount();else{var s=e.elementType===e.type?r.memoizedProps:ut(e.type,r.memoizedProps);n.componentDidUpdate(s,r.memoizedState,n.__reactInternalSnapshotBeforeUpdate)}var i=e.updateQueue;i!==null&&yc(e,i,n);break;case 3:var a=e.updateQueue;if(a!==null){if(r=null,e.child!==null)switch(e.child.tag){case 5:r=e.child.stateNode;break;case 1:r=e.child.stateNode}yc(e,a,r)}break;case 5:var o=e.stateNode;if(r===null&&e.flags&4){r=o;var u=e.memoizedProps;switch(e.type){case"button":case"input":case"select":case"textarea":u.autoFocus&&r.focus();break;case"img":u.src&&(r.src=u.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(e.memoizedState===null){var c=e.alternate;if(c!==null){var d=c.memoizedState;if(d!==null){var h=d.dehydrated;h!==null&&ts(h)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(P(163))}Ce||e.flags&512&&Yo(e)}catch(f){de(e,e.return,f)}}if(e===t){z=null;break}if(r=e.sibling,r!==null){r.return=e.return,z=r;break}z=e.return}}function zc(t){for(;z!==null;){var e=z;if(e===t){z=null;break}var r=e.sibling;if(r!==null){r.return=e.return,z=r;break}z=e.return}}function Ic(t){for(;z!==null;){var e=z;try{switch(e.tag){case 0:case 11:case 15:var r=e.return;try{la(4,e)}catch(u){de(e,r,u)}break;case 1:var n=e.stateNode;if(typeof n.componentDidMount=="function"){var s=e.return;try{n.componentDidMount()}catch(u){de(e,s,u)}}var i=e.return;try{Yo(e)}catch(u){de(e,i,u)}break;case 5:var a=e.return;try{Yo(e)}catch(u){de(e,a,u)}}}catch(u){de(e,e.return,u)}if(e===t){z=null;break}var o=e.sibling;if(o!==null){o.return=e.return,z=o;break}z=e.return}}var Lm=Math.ceil,Li=Dt.ReactCurrentDispatcher,lu=Dt.ReactCurrentOwner,nt=Dt.ReactCurrentBatchConfig,J=0,be=null,me=null,je=0,qe=0,Qr=ir(0),we=0,hs=null,Nr=0,ua=0,uu=0,qn=null,Fe=null,cu=0,fn=1/0,Tt=null,Di=!1,el=null,Xt=null,Fs=!1,qt=null,Mi=0,Gn=0,tl=null,ui=-1,ci=0;function Ie(){return J&6?fe():ui!==-1?ui:ui=fe()}function er(t){return t.mode&1?J&2&&je!==0?je&-je:wm.transition!==null?(ci===0&&(ci=ah()),ci):(t=Z,t!==0||(t=window.event,t=t===void 0?16:fh(t.type)),t):1}function mt(t,e,r,n){if(50<Gn)throw Gn=0,tl=null,Error(P(185));ys(t,r,n),(!(J&2)||t!==be)&&(t===be&&(!(J&2)&&(ua|=r),we===4&&Ht(t,je)),Ve(t,n),r===1&&J===0&&!(e.mode&1)&&(fn=fe()+500,ia&&ar()))}function Ve(t,e){var r=t.callbackNode;wg(t,e);var n=bi(t,t===be?je:0);if(n===0)r!==null&&Vu(r),t.callbackNode=null,t.callbackPriority=0;else if(e=n&-n,t.callbackPriority!==e){if(r!=null&&Vu(r),e===1)t.tag===0?vm(Lc.bind(null,t)):Oh(Lc.bind(null,t)),pm(function(){!(J&6)&&ar()}),r=null;else{switch(oh(n)){case 1:r=Ll;break;case 4:r=sh;break;case 16:r=xi;break;case 536870912:r=ih;break;default:r=xi}r=Af(r,Ef.bind(null,t))}t.callbackPriority=e,t.callbackNode=r}}function Ef(t,e){if(ui=-1,ci=0,J&6)throw Error(P(327));var r=t.callbackNode;if(nn()&&t.callbackNode!==r)return null;var n=bi(t,t===be?je:0);if(n===0)return null;if(n&30||n&t.expiredLanes||e)e=Fi(t,n);else{e=n;var s=J;J|=2;var i=jf();(be!==t||je!==e)&&(Tt=null,fn=fe()+500,kr(t,e));do try{Fm();break}catch(o){Sf(t,o)}while(!0);Jl(),Li.current=i,J=s,me!==null?e=0:(be=null,je=0,e=we)}if(e!==0){if(e===2&&(s=To(t),s!==0&&(n=s,e=rl(t,s))),e===1)throw r=hs,kr(t,0),Ht(t,n),Ve(t,fe()),r;if(e===6)Ht(t,n);else{if(s=t.current.alternate,!(n&30)&&!Dm(s)&&(e=Fi(t,n),e===2&&(i=To(t),i!==0&&(n=i,e=rl(t,i))),e===1))throw r=hs,kr(t,0),Ht(t,n),Ve(t,fe()),r;switch(t.finishedWork=s,t.finishedLanes=n,e){case 0:case 1:throw Error(P(345));case 2:hr(t,Fe,Tt);break;case 3:if(Ht(t,n),(n&130023424)===n&&(e=cu+500-fe(),10<e)){if(bi(t,0)!==0)break;if(s=t.suspendedLanes,(s&n)!==n){Ie(),t.pingedLanes|=t.suspendedLanes&s;break}t.timeoutHandle=Lo(hr.bind(null,t,Fe,Tt),e);break}hr(t,Fe,Tt);break;case 4:if(Ht(t,n),(n&4194240)===n)break;for(e=t.eventTimes,s=-1;0<n;){var a=31-gt(n);i=1<<a,a=e[a],a>s&&(s=a),n&=~i}if(n=s,n=fe()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*Lm(n/1960))-n,10<n){t.timeoutHandle=Lo(hr.bind(null,t,Fe,Tt),n);break}hr(t,Fe,Tt);break;case 5:hr(t,Fe,Tt);break;default:throw Error(P(329))}}}return Ve(t,fe()),t.callbackNode===r?Ef.bind(null,t):null}function rl(t,e){var r=qn;return t.current.memoizedState.isDehydrated&&(kr(t,e).flags|=256),t=Fi(t,e),t!==2&&(e=Fe,Fe=r,e!==null&&nl(e)),t}function nl(t){Fe===null?Fe=t:Fe.push.apply(Fe,t)}function Dm(t){for(var e=t;;){if(e.flags&16384){var r=e.updateQueue;if(r!==null&&(r=r.stores,r!==null))for(var n=0;n<r.length;n++){var s=r[n],i=s.getSnapshot;s=s.value;try{if(!yt(i(),s))return!1}catch{return!1}}}if(r=e.child,e.subtreeFlags&16384&&r!==null)r.return=e,e=r;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 Ht(t,e){for(e&=~uu,e&=~ua,t.suspendedLanes|=e,t.pingedLanes&=~e,t=t.expirationTimes;0<e;){var r=31-gt(e),n=1<<r;t[r]=-1,e&=~n}}function Lc(t){if(J&6)throw Error(P(327));nn();var e=bi(t,0);if(!(e&1))return Ve(t,fe()),null;var r=Fi(t,e);if(t.tag!==0&&r===2){var n=To(t);n!==0&&(e=n,r=rl(t,n))}if(r===1)throw r=hs,kr(t,0),Ht(t,e),Ve(t,fe()),r;if(r===6)throw Error(P(345));return t.finishedWork=t.current.alternate,t.finishedLanes=e,hr(t,Fe,Tt),Ve(t,fe()),null}function du(t,e){var r=J;J|=1;try{return t(e)}finally{J=r,J===0&&(fn=fe()+500,ia&&ar())}}function Tr(t){qt!==null&&qt.tag===0&&!(J&6)&&nn();var e=J;J|=1;var r=nt.transition,n=Z;try{if(nt.transition=null,Z=1,t)return t()}finally{Z=n,nt.transition=r,J=e,!(J&6)&&ar()}}function hu(){qe=Qr.current,se(Qr)}function kr(t,e){t.finishedWork=null,t.finishedLanes=0;var r=t.timeoutHandle;if(r!==-1&&(t.timeoutHandle=-1,fm(r)),me!==null)for(r=me.return;r!==null;){var n=r;switch(Kl(n),n.tag){case 1:n=n.type.childContextTypes,n!=null&&ji();break;case 3:dn(),se(Ue),se(Oe),tu();break;case 5:eu(n);break;case 4:dn();break;case 13:se(le);break;case 19:se(le);break;case 10:Ql(n.type._context);break;case 22:case 23:hu()}r=r.return}if(be=t,me=t=tr(t.current,null),je=qe=e,we=0,hs=null,uu=ua=Nr=0,Fe=qn=null,wr!==null){for(e=0;e<wr.length;e++)if(r=wr[e],n=r.interleaved,n!==null){r.interleaved=null;var s=n.next,i=r.pending;if(i!==null){var a=i.next;i.next=s,n.next=a}r.pending=n}wr=null}return t}function Sf(t,e){do{var r=me;try{if(Jl(),ai.current=Ii,zi){for(var n=ue.memoizedState;n!==null;){var s=n.queue;s!==null&&(s.pending=null),n=n.next}zi=!1}if(jr=0,xe=ve=ue=null,Wn=!1,us=0,lu.current=null,r===null||r.return===null){we=1,hs=e,me=null;break}e:{var i=t,a=r.return,o=r,u=e;if(e=je,o.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){var c=u,d=o,h=d.tag;if(!(d.mode&1)&&(h===0||h===11||h===15)){var f=d.alternate;f?(d.updateQueue=f.updateQueue,d.memoizedState=f.memoizedState,d.lanes=f.lanes):(d.updateQueue=null,d.memoizedState=null)}var y=_c(a);if(y!==null){y.flags&=-257,Ec(y,a,o,i,e),y.mode&1&&kc(i,c,e),e=y,u=c;var w=e.updateQueue;if(w===null){var x=new Set;x.add(u),e.updateQueue=x}else w.add(u);break e}else{if(!(e&1)){kc(i,c,e),fu();break e}u=Error(P(426))}}else if(oe&&o.mode&1){var b=_c(a);if(b!==null){!(b.flags&65536)&&(b.flags|=256),Ec(b,a,o,i,e),ql(hn(u,o));break e}}i=u=hn(u,o),we!==4&&(we=2),qn===null?qn=[i]:qn.push(i),i=a;do{switch(i.tag){case 3:i.flags|=65536,e&=-e,i.lanes|=e;var p=lf(i,u,e);mc(i,p);break e;case 1:o=u;var m=i.type,g=i.stateNode;if(!(i.flags&128)&&(typeof m.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(Xt===null||!Xt.has(g)))){i.flags|=65536,e&=-e,i.lanes|=e;var k=uf(i,o,e);mc(i,k);break e}}i=i.return}while(i!==null)}Tf(r)}catch(E){e=E,me===r&&r!==null&&(me=r=r.return);continue}break}while(!0)}function jf(){var t=Li.current;return Li.current=Ii,t===null?Ii:t}function fu(){(we===0||we===3||we===2)&&(we=4),be===null||!(Nr&268435455)&&!(ua&268435455)||Ht(be,je)}function Fi(t,e){var r=J;J|=2;var n=jf();(be!==t||je!==e)&&(Tt=null,kr(t,e));do try{Mm();break}catch(s){Sf(t,s)}while(!0);if(Jl(),J=r,Li.current=n,me!==null)throw Error(P(261));return be=null,je=0,we}function Mm(){for(;me!==null;)Nf(me)}function Fm(){for(;me!==null&&!cg();)Nf(me)}function Nf(t){var e=Cf(t.alternate,t,qe);t.memoizedProps=t.pendingProps,e===null?Tf(t):me=e,lu.current=null}function Tf(t){var e=t;do{var r=e.alternate;if(t=e.return,e.flags&32768){if(r=Om(r,e),r!==null){r.flags&=32767,me=r;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{we=6,me=null;return}}else if(r=Am(r,e,qe),r!==null){me=r;return}if(e=e.sibling,e!==null){me=e;return}me=e=t}while(e!==null);we===0&&(we=5)}function hr(t,e,r){var n=Z,s=nt.transition;try{nt.transition=null,Z=1,$m(t,e,r,n)}finally{nt.transition=s,Z=n}return null}function $m(t,e,r,n){do nn();while(qt!==null);if(J&6)throw Error(P(327));r=t.finishedWork;var s=t.finishedLanes;if(r===null)return null;if(t.finishedWork=null,t.finishedLanes=0,r===t.current)throw Error(P(177));t.callbackNode=null,t.callbackPriority=0;var i=r.lanes|r.childLanes;if(xg(t,i),t===be&&(me=be=null,je=0),!(r.subtreeFlags&2064)&&!(r.flags&2064)||Fs||(Fs=!0,Af(xi,function(){return nn(),null})),i=(r.flags&15990)!==0,r.subtreeFlags&15990||i){i=nt.transition,nt.transition=null;var a=Z;Z=1;var o=J;J|=4,lu.current=null,zm(t,r),kf(r,t),am(zo),ki=!!Ro,zo=Ro=null,t.current=r,Im(r),dg(),J=o,Z=a,nt.transition=i}else t.current=r;if(Fs&&(Fs=!1,qt=t,Mi=s),i=t.pendingLanes,i===0&&(Xt=null),pg(r.stateNode),Ve(t,fe()),e!==null)for(n=t.onRecoverableError,r=0;r<e.length;r++)s=e[r],n(s.value,{componentStack:s.stack,digest:s.digest});if(Di)throw Di=!1,t=el,el=null,t;return Mi&1&&t.tag!==0&&nn(),i=t.pendingLanes,i&1?t===tl?Gn++:(Gn=0,tl=t):Gn=0,ar(),null}function nn(){if(qt!==null){var t=oh(Mi),e=nt.transition,r=Z;try{if(nt.transition=null,Z=16>t?16:t,qt===null)var n=!1;else{if(t=qt,qt=null,Mi=0,J&6)throw Error(P(331));var s=J;for(J|=4,z=t.current;z!==null;){var i=z,a=i.child;if(z.flags&16){var o=i.deletions;if(o!==null){for(var u=0;u<o.length;u++){var c=o[u];for(z=c;z!==null;){var d=z;switch(d.tag){case 0:case 11:case 15:Kn(8,d,i)}var h=d.child;if(h!==null)h.return=d,z=h;else for(;z!==null;){d=z;var f=d.sibling,y=d.return;if(wf(d),d===c){z=null;break}if(f!==null){f.return=y,z=f;break}z=y}}}var w=i.alternate;if(w!==null){var x=w.child;if(x!==null){w.child=null;do{var b=x.sibling;x.sibling=null,x=b}while(x!==null)}}z=i}}if(i.subtreeFlags&2064&&a!==null)a.return=i,z=a;else e:for(;z!==null;){if(i=z,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Kn(9,i,i.return)}var p=i.sibling;if(p!==null){p.return=i.return,z=p;break e}z=i.return}}var m=t.current;for(z=m;z!==null;){a=z;var g=a.child;if(a.subtreeFlags&2064&&g!==null)g.return=a,z=g;else e:for(a=m;z!==null;){if(o=z,o.flags&2048)try{switch(o.tag){case 0:case 11:case 15:la(9,o)}}catch(E){de(o,o.return,E)}if(o===a){z=null;break e}var k=o.sibling;if(k!==null){k.return=o.return,z=k;break e}z=o.return}}if(J=s,ar(),_t&&typeof _t.onPostCommitFiberRoot=="function")try{_t.onPostCommitFiberRoot(ea,t)}catch{}n=!0}return n}finally{Z=r,nt.transition=e}}return!1}function Dc(t,e,r){e=hn(r,e),e=lf(t,e,1),t=Zt(t,e,1),e=Ie(),t!==null&&(ys(t,1,e),Ve(t,e))}function de(t,e,r){if(t.tag===3)Dc(t,t,r);else for(;e!==null;){if(e.tag===3){Dc(e,t,r);break}else if(e.tag===1){var n=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof n.componentDidCatch=="function"&&(Xt===null||!Xt.has(n))){t=hn(r,t),t=uf(e,t,1),e=Zt(e,t,1),t=Ie(),e!==null&&(ys(e,1,t),Ve(e,t));break}}e=e.return}}function Bm(t,e,r){var n=t.pingCache;n!==null&&n.delete(e),e=Ie(),t.pingedLanes|=t.suspendedLanes&r,be===t&&(je&r)===r&&(we===4||we===3&&(je&130023424)===je&&500>fe()-cu?kr(t,0):uu|=r),Ve(t,e)}function Pf(t,e){e===0&&(t.mode&1?(e=Ps,Ps<<=1,!(Ps&130023424)&&(Ps=4194304)):e=1);var r=Ie();t=It(t,e),t!==null&&(ys(t,e,r),Ve(t,r))}function Um(t){var e=t.memoizedState,r=0;e!==null&&(r=e.retryLane),Pf(t,r)}function Hm(t,e){var r=0;switch(t.tag){case 13:var n=t.stateNode,s=t.memoizedState;s!==null&&(r=s.retryLane);break;case 19:n=t.stateNode;break;default:throw Error(P(314))}n!==null&&n.delete(e),Pf(t,r)}var Cf;Cf=function(t,e,r){if(t!==null)if(t.memoizedProps!==e.pendingProps||Ue.current)Be=!0;else{if(!(t.lanes&r)&&!(e.flags&128))return Be=!1,Cm(t,e,r);Be=!!(t.flags&131072)}else Be=!1,oe&&e.flags&1048576&&Rh(e,Pi,e.index);switch(e.lanes=0,e.tag){case 2:var n=e.type;li(t,e),t=e.pendingProps;var s=ln(e,Oe.current);rn(e,r),s=nu(null,e,n,t,s,r);var i=su();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,He(n)?(i=!0,Ni(e)):i=!1,e.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Zl(e),s.updater=oa,e.stateNode=s,s._reactInternals=e,Ho(e,n,t,r),e=Ko(null,e,n,!0,i,r)):(e.tag=0,oe&&i&&Wl(e),ze(null,e,s,r),e=e.child),e;case 16:n=e.elementType;e:{switch(li(t,e),t=e.pendingProps,s=n._init,n=s(n._payload),e.type=n,s=e.tag=Wm(n),t=ut(n,t),s){case 0:e=Wo(null,e,n,t,r);break e;case 1:e=Nc(null,e,n,t,r);break e;case 11:e=Sc(null,e,n,t,r);break e;case 14:e=jc(null,e,n,ut(n.type,t),r);break e}throw Error(P(306,n,""))}return e;case 0:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:ut(n,s),Wo(t,e,n,s,r);case 1:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:ut(n,s),Nc(t,e,n,s,r);case 3:e:{if(ff(e),t===null)throw Error(P(387));n=e.pendingProps,i=e.memoizedState,s=i.element,Fh(t,e),Oi(e,n,null,r);var a=e.memoizedState;if(n=a.element,i.isDehydrated)if(i={element:n,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},e.updateQueue.baseState=i,e.memoizedState=i,e.flags&256){s=hn(Error(P(423)),e),e=Tc(t,e,n,r,s);break e}else if(n!==s){s=hn(Error(P(424)),e),e=Tc(t,e,n,r,s);break e}else for(Je=Yt(e.stateNode.containerInfo.firstChild),Qe=e,oe=!0,ft=null,r=Dh(e,null,n,r),e.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(un(),n===s){e=Lt(t,e,r);break e}ze(t,e,n,r)}e=e.child}return e;case 5:return $h(e),t===null&&$o(e),n=e.type,s=e.pendingProps,i=t!==null?t.memoizedProps:null,a=s.children,Io(n,s)?a=null:i!==null&&Io(n,i)&&(e.flags|=32),hf(t,e),ze(t,e,a,r),e.child;case 6:return t===null&&$o(e),null;case 13:return pf(t,e,r);case 4:return Xl(e,e.stateNode.containerInfo),n=e.pendingProps,t===null?e.child=cn(e,null,n,r):ze(t,e,n,r),e.child;case 11:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:ut(n,s),Sc(t,e,n,s,r);case 7:return ze(t,e,e.pendingProps,r),e.child;case 8:return ze(t,e,e.pendingProps.children,r),e.child;case 12:return ze(t,e,e.pendingProps.children,r),e.child;case 10:e:{if(n=e.type._context,s=e.pendingProps,i=e.memoizedProps,a=s.value,re(Ci,n._currentValue),n._currentValue=a,i!==null)if(yt(i.value,a)){if(i.children===s.children&&!Ue.current){e=Lt(t,e,r);break e}}else for(i=e.child,i!==null&&(i.return=e);i!==null;){var o=i.dependencies;if(o!==null){a=i.child;for(var u=o.firstContext;u!==null;){if(u.context===n){if(i.tag===1){u=Ot(-1,r&-r),u.tag=2;var c=i.updateQueue;if(c!==null){c=c.shared;var d=c.pending;d===null?u.next=u:(u.next=d.next,d.next=u),c.pending=u}}i.lanes|=r,u=i.alternate,u!==null&&(u.lanes|=r),Bo(i.return,r,e),o.lanes|=r;break}u=u.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(P(341));a.lanes|=r,o=a.alternate,o!==null&&(o.lanes|=r),Bo(a,r,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}ze(t,e,s.children,r),e=e.child}return e;case 9:return s=e.type,n=e.pendingProps.children,rn(e,r),s=st(s),n=n(s),e.flags|=1,ze(t,e,n,r),e.child;case 14:return n=e.type,s=ut(n,e.pendingProps),s=ut(n.type,s),jc(t,e,n,s,r);case 15:return cf(t,e,e.type,e.pendingProps,r);case 17:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:ut(n,s),li(t,e),e.tag=1,He(n)?(t=!0,Ni(e)):t=!1,rn(e,r),of(e,n,s),Ho(e,n,s,r),Ko(null,e,n,!0,t,r);case 19:return gf(t,e,r);case 22:return df(t,e,r)}throw Error(P(156,e.tag))};function Af(t,e){return nh(t,e)}function Vm(t,e,r,n){this.tag=t,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function rt(t,e,r,n){return new Vm(t,e,r,n)}function pu(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Wm(t){if(typeof t=="function")return pu(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Rl)return 11;if(t===zl)return 14}return 2}function tr(t,e){var r=t.alternate;return r===null?(r=rt(t.tag,e,t.key,t.mode),r.elementType=t.elementType,r.type=t.type,r.stateNode=t.stateNode,r.alternate=t,t.alternate=r):(r.pendingProps=e,r.type=t.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=t.flags&14680064,r.childLanes=t.childLanes,r.lanes=t.lanes,r.child=t.child,r.memoizedProps=t.memoizedProps,r.memoizedState=t.memoizedState,r.updateQueue=t.updateQueue,e=t.dependencies,r.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},r.sibling=t.sibling,r.index=t.index,r.ref=t.ref,r}function di(t,e,r,n,s,i){var a=2;if(n=t,typeof t=="function")pu(t)&&(a=1);else if(typeof t=="string")a=5;else e:switch(t){case $r:return _r(r.children,s,i,e);case Ol:a=8,s|=8;break;case fo:return t=rt(12,r,e,s|2),t.elementType=fo,t.lanes=i,t;case po:return t=rt(13,r,e,s),t.elementType=po,t.lanes=i,t;case go:return t=rt(19,r,e,s),t.elementType=go,t.lanes=i,t;case $d:return ca(r,s,i,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case Md:a=10;break e;case Fd:a=9;break e;case Rl:a=11;break e;case zl:a=14;break e;case $t:a=16,n=null;break e}throw Error(P(130,t==null?t:typeof t,""))}return e=rt(a,r,e,s),e.elementType=t,e.type=n,e.lanes=i,e}function _r(t,e,r,n){return t=rt(7,t,n,e),t.lanes=r,t}function ca(t,e,r,n){return t=rt(22,t,n,e),t.elementType=$d,t.lanes=r,t.stateNode={isHidden:!1},t}function qa(t,e,r){return t=rt(6,t,null,e),t.lanes=r,t}function Ga(t,e,r){return e=rt(4,t.children!==null?t.children:[],t.key,e),e.lanes=r,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function Km(t,e,r,n,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=Ta(0),this.expirationTimes=Ta(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ta(0),this.identifierPrefix=n,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function gu(t,e,r,n,s,i,a,o,u){return t=new Km(t,e,r,o,u),e===1?(e=1,i===!0&&(e|=8)):e=0,i=rt(3,null,null,e),t.current=i,i.stateNode=t,i.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},Zl(i),t}function qm(t,e,r){var n=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Fr,key:n==null?null:""+n,children:t,containerInfo:e,implementation:r}}function Of(t){if(!t)return nr;t=t._reactInternals;e:{if(Cr(t)!==t||t.tag!==1)throw Error(P(170));var e=t;do{switch(e.tag){case 3:e=e.stateNode.context;break e;case 1:if(He(e.type)){e=e.stateNode.__reactInternalMemoizedMergedChildContext;break e}}e=e.return}while(e!==null);throw Error(P(171))}if(t.tag===1){var r=t.type;if(He(r))return Ah(t,r,e)}return e}function Rf(t,e,r,n,s,i,a,o,u){return t=gu(r,n,!0,t,s,i,a,o,u),t.context=Of(null),r=t.current,n=Ie(),s=er(r),i=Ot(n,s),i.callback=e??null,Zt(r,i,s),t.current.lanes=s,ys(t,s,n),Ve(t,n),t}function da(t,e,r,n){var s=e.current,i=Ie(),a=er(s);return r=Of(r),e.context===null?e.context=r:e.pendingContext=r,e=Ot(i,a),e.payload={element:t},n=n===void 0?null:n,n!==null&&(e.callback=n),t=Zt(s,e,a),t!==null&&(mt(t,s,a,i),ii(t,s,a)),a}function $i(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 Mc(t,e){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var r=t.retryLane;t.retryLane=r!==0&&r<e?r:e}}function mu(t,e){Mc(t,e),(t=t.alternate)&&Mc(t,e)}function Gm(){return null}var zf=typeof reportError=="function"?reportError:function(t){console.error(t)};function yu(t){this._internalRoot=t}ha.prototype.render=yu.prototype.render=function(t){var e=this._internalRoot;if(e===null)throw Error(P(409));da(t,e,null,null)};ha.prototype.unmount=yu.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var e=t.containerInfo;Tr(function(){da(null,t,null,null)}),e[zt]=null}};function ha(t){this._internalRoot=t}ha.prototype.unstable_scheduleHydration=function(t){if(t){var e=ch();t={blockedOn:null,target:t,priority:e};for(var r=0;r<Ut.length&&e!==0&&e<Ut[r].priority;r++);Ut.splice(r,0,t),r===0&&hh(t)}};function vu(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function fa(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function Fc(){}function Jm(t,e,r,n,s){if(s){if(typeof n=="function"){var i=n;n=function(){var c=$i(a);i.call(c)}}var a=Rf(e,n,t,0,null,!1,!1,"",Fc);return t._reactRootContainer=a,t[zt]=a.current,ss(t.nodeType===8?t.parentNode:t),Tr(),a}for(;s=t.lastChild;)t.removeChild(s);if(typeof n=="function"){var o=n;n=function(){var c=$i(u);o.call(c)}}var u=gu(t,0,!1,null,null,!1,!1,"",Fc);return t._reactRootContainer=u,t[zt]=u.current,ss(t.nodeType===8?t.parentNode:t),Tr(function(){da(e,u,r,n)}),u}function pa(t,e,r,n,s){var i=r._reactRootContainer;if(i){var a=i;if(typeof s=="function"){var o=s;s=function(){var u=$i(a);o.call(u)}}da(e,a,t,s)}else a=Jm(r,e,t,s,n);return $i(a)}lh=function(t){switch(t.tag){case 3:var e=t.stateNode;if(e.current.memoizedState.isDehydrated){var r=zn(e.pendingLanes);r!==0&&(Dl(e,r|1),Ve(e,fe()),!(J&6)&&(fn=fe()+500,ar()))}break;case 13:Tr(function(){var n=It(t,1);if(n!==null){var s=Ie();mt(n,t,1,s)}}),mu(t,1)}};Ml=function(t){if(t.tag===13){var e=It(t,134217728);if(e!==null){var r=Ie();mt(e,t,134217728,r)}mu(t,134217728)}};uh=function(t){if(t.tag===13){var e=er(t),r=It(t,e);if(r!==null){var n=Ie();mt(r,t,e,n)}mu(t,e)}};ch=function(){return Z};dh=function(t,e){var r=Z;try{return Z=t,e()}finally{Z=r}};So=function(t,e,r){switch(e){case"input":if(vo(t,r),e=r.name,r.type==="radio"&&e!=null){for(r=t;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll("input[name="+JSON.stringify(""+e)+'][type="radio"]'),e=0;e<r.length;e++){var n=r[e];if(n!==t&&n.form===t.form){var s=sa(n);if(!s)throw Error(P(90));Ud(n),vo(n,s)}}}break;case"textarea":Vd(t,r);break;case"select":e=r.value,e!=null&&Zr(t,!!r.multiple,e,!1)}};Yd=du;Zd=Tr;var Qm={usingClientEntryPoint:!1,Events:[ws,Vr,sa,Jd,Qd,du]},Cn={findFiberByHostInstance:vr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Ym={bundleType:Cn.bundleType,version:Cn.version,rendererPackageName:Cn.rendererPackageName,rendererConfig:Cn.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Dt.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=th(t),t===null?null:t.stateNode},findFiberByHostInstance:Cn.findFiberByHostInstance||Gm,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 $s=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!$s.isDisabled&&$s.supportsFiber)try{ea=$s.inject(Ym),_t=$s}catch{}}Ze.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Qm;Ze.createPortal=function(t,e){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!vu(e))throw Error(P(200));return qm(t,e,null,r)};Ze.createRoot=function(t,e){if(!vu(t))throw Error(P(299));var r=!1,n="",s=zf;return e!=null&&(e.unstable_strictMode===!0&&(r=!0),e.identifierPrefix!==void 0&&(n=e.identifierPrefix),e.onRecoverableError!==void 0&&(s=e.onRecoverableError)),e=gu(t,1,!1,null,null,r,!1,n,s),t[zt]=e.current,ss(t.nodeType===8?t.parentNode:t),new yu(e)};Ze.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(P(188)):(t=Object.keys(t).join(","),Error(P(268,t)));return t=th(e),t=t===null?null:t.stateNode,t};Ze.flushSync=function(t){return Tr(t)};Ze.hydrate=function(t,e,r){if(!fa(e))throw Error(P(200));return pa(null,t,e,!0,r)};Ze.hydrateRoot=function(t,e,r){if(!vu(t))throw Error(P(405));var n=r!=null&&r.hydratedSources||null,s=!1,i="",a=zf;if(r!=null&&(r.unstable_strictMode===!0&&(s=!0),r.identifierPrefix!==void 0&&(i=r.identifierPrefix),r.onRecoverableError!==void 0&&(a=r.onRecoverableError)),e=Rf(e,null,t,1,r??null,s,!1,i,a),t[zt]=e.current,ss(t),n)for(t=0;t<n.length;t++)r=n[t],s=r._getVersion,s=s(r._source),e.mutableSourceEagerHydrationData==null?e.mutableSourceEagerHydrationData=[r,s]:e.mutableSourceEagerHydrationData.push(r,s);return new ha(e)};Ze.render=function(t,e,r){if(!fa(e))throw Error(P(200));return pa(null,t,e,!1,r)};Ze.unmountComponentAtNode=function(t){if(!fa(t))throw Error(P(40));return t._reactRootContainer?(Tr(function(){pa(null,null,t,!1,function(){t._reactRootContainer=null,t[zt]=null})}),!0):!1};Ze.unstable_batchedUpdates=du;Ze.unstable_renderSubtreeIntoContainer=function(t,e,r,n){if(!fa(r))throw Error(P(200));if(t==null||t._reactInternals===void 0)throw Error(P(38));return pa(t,e,r,!1,n)};Ze.version="18.3.1-next-f1338f8080-20240426";function If(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(If)}catch(t){console.error(t)}}If(),zd.exports=Ze;var Zm=zd.exports,$c=Zm;co.createRoot=$c.createRoot,co.hydrateRoot=$c.hydrateRoot;var Xm={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const ey=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ty=(t,e)=>{const r=T.forwardRef(({color:n="currentColor",size:s=24,strokeWidth:i=2,absoluteStrokeWidth:a,children:o,...u},c)=>T.createElement("svg",{ref:c,...Xm,width:s,height:s,stroke:n,strokeWidth:a?Number(i)*24/Number(s):i,className:`lucide lucide-${ey(t)}`,...u},[...e.map(([d,h])=>T.createElement(d,h)),...(Array.isArray(o)?o:[o])||[]]));return r.displayName=`${t}`,r};var Q=ty;const Lf=Q("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]),ry=Q("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"}]]),ny=Q("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),Bi=Q("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),sy=Q("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]),iy=Q("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"}]]),ay=Q("Brain",[["path",{d:"M9.5 2A2.5 2.5 0 0 1 12 4.5v15a2.5 2.5 0 0 1-4.96.44 2.5 2.5 0 0 1-2.96-3.08 3 3 0 0 1-.34-5.58 2.5 2.5 0 0 1 1.32-4.24 2.5 2.5 0 0 1 1.98-3A2.5 2.5 0 0 1 9.5 2Z",key:"1mhkh5"}],["path",{d:"M14.5 2A2.5 2.5 0 0 0 12 4.5v15a2.5 2.5 0 0 0 4.96.44 2.5 2.5 0 0 0 2.96-3.08 3 3 0 0 0 .34-5.58 2.5 2.5 0 0 0-1.32-4.24 2.5 2.5 0 0 0-1.98-3A2.5 2.5 0 0 0 14.5 2Z",key:"1d6s00"}]]),Bc=Q("Calendar",[["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",ry:"2",key:"eu3xkr"}],["line",{x1:"16",x2:"16",y1:"2",y2:"6",key:"m3sa8f"}],["line",{x1:"8",x2:"8",y1:"2",y2:"6",key:"18kwsl"}],["line",{x1:"3",x2:"21",y1:"10",y2:"10",key:"xt86sb"}]]),sl=Q("CheckCircle2",[["path",{d:"M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10z",key:"14v8dr"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),Ja=Q("Check",[["polyline",{points:"20 6 9 17 4 12",key:"10jjfj"}]]),Df=Q("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),oy=Q("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),ly=Q("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),uy=Q("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),cy=Q("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]),Mf=Q("FileDown",[["path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]),dy=Q("FileText",[["path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}],["line",{x1:"16",x2:"8",y1:"13",y2:"13",key:"14keom"}],["line",{x1:"16",x2:"8",y1:"17",y2:"17",key:"17nazh"}],["line",{x1:"10",x2:"8",y1:"9",y2:"9",key:"1a5vjj"}]]),hy=Q("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"}]]),fy=Q("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"}]]),py=Q("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]),gy=Q("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),my=Q("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"}]]),yy=Q("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),Ff=Q("ShieldCheck",[["path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",key:"3xmgem"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),vy=Q("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]),$f=Q("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"}]]),wy=Q("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"}]]),Bf=Q("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"}]]),xy=Q("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),Uf=Q("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]),by=Q("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"}]]),ky=Q("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"}]]),_y=["M","D","M","D","F","S","S"],il=t=>{const e=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return`${e}-${r}-${n}`},Ey=t=>{if(!t||!t.includes("-"))return null;const[e,r,n]=t.split("-").map(Number);return new Date(e,r-1,n)},Sy=t=>{const e=new Date(t.getFullYear(),t.getMonth(),1),r=(e.getDay()+6)%7,n=new Date(e.getFullYear(),e.getMonth(),1-r);return Array.from({length:42},(s,i)=>{const a=new Date(n.getFullYear(),n.getMonth(),n.getDate()+i);return{key:il(a),date:a,isoValue:il(a),isCurrentMonth:a.getMonth()===t.getMonth()}})},jy=({patTypes:t,assessments:e,overview:r,assessmentShareTokens:n={},testsVisible:s=!0,onCreate:i,onEdit:a,onDelete:o,getPatTypeColor:u,getAchievement:c})=>{const d=T.useRef(null),[h,f]=T.useState(!1),[y,w]=T.useState(null),[x,b]=T.useState({key:"datum",direction:"desc"}),[p,m]=T.useState({name:"",datum:""}),[g,k]=T.useState(()=>{const L=new Date;return new Date(L.getFullYear(),L.getMonth(),1)}),E=Object.keys(t||{}),S=e.filter(L=>!L.isFinalized),j=e.filter(L=>L.isFinalized),_=L=>L.exercises.reduce((O,K)=>O+(K.points||0),0),N=L=>String(L||"").toLowerCase().trim(),C=L=>{if(!L||!L.includes("-"))return"";const[O,K,ee]=L.split("-");return`${ee}.${K}.${O}`},A=L=>{if(!L||!L.includes("-"))return L||"";const[O,K,ee]=L.split("-");return`${O}.${K}.${ee}`},U=T.useMemo(()=>new Intl.DateTimeFormat("de-DE",{month:"long",year:"numeric"}).format(g),[g]),Y=T.useMemo(()=>Sy(g),[g]);T.useEffect(()=>{if(!y)return;const L=K=>{d.current&&!d.current.contains(K.target)&&w(null)},O=K=>{K.key==="Escape"&&w(null)};return document.addEventListener("mousedown",L),document.addEventListener("keydown",O),()=>{document.removeEventListener("mousedown",L),document.removeEventListener("keydown",O)}},[y]);const G=L=>{const O=!p.name||N(L.name).includes(N(p.name)),K=!p.datum||N(L.datum).includes(N(p.datum));return O&&K},ye=(L,O)=>O==="name"?(L.name||"").toLowerCase():O==="datum"?L.datum||"":O==="result"?_(L):"",he=L=>[...L].sort((O,K)=>{const ee=ye(O,x.key),Ke=ye(K,x.key);return ee<Ke?x.direction==="asc"?-1:1:ee>Ke?x.direction==="asc"?1:-1:0}),Re=T.useMemo(()=>he(S.filter(G)),[S,x,p]),R=T.useMemo(()=>he(j.filter(G)),[j,x,p]),M=L=>{b(O=>O.key===L?{key:L,direction:O.direction==="asc"?"desc":"asc"}:{key:L,direction:L==="datum"?"desc":"asc"})},H=L=>x.key!==L?l.jsx(sy,{className:"w-4 h-4 text-gray-400 dark:text-gray-500","aria-hidden":"true"}):x.direction==="asc"?l.jsx(uy,{className:"w-4 h-4","aria-hidden":"true"}):l.jsx(Df,{className:"w-4 h-4","aria-hidden":"true"}),X=(L,O)=>{m(K=>({...K,[L]:O}))},ie=L=>{const K=Ey(L)||new Date;k(new Date(K.getFullYear(),K.getMonth(),1))},St=L=>{w(O=>O!==L?(ie(p.datum),L):null)},We=L=>{X("datum",L),ie(L),w(null)},lr=()=>{X("datum",""),ie(""),w(null)},at=()=>{We(il(new Date))},jt=(L,O,K,ee,Ke)=>{const vt=y===L;return l.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-lg border border-gray-100 dark:border-gray-800 overflow-hidden",children:[l.jsxs("div",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-800/70",children:[l.jsx("h2",{className:"text-lg font-bold text-gray-800 dark:text-gray-100",children:O}),l.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:["Anzahl: ",K.length,K.length!==ee?` von ${ee}`:""]})]}),ee===0?l.jsx("div",{className:"px-6 py-8 text-sm text-gray-500 dark:text-gray-400",children:Ke}):l.jsx("div",{className:"overflow-x-auto",children:l.jsxs("table",{className:"w-full",children:[l.jsx("thead",{className:"bg-gray-100 dark:bg-gray-800 text-left",children:l.jsxs("tr",{children:[l.jsx("th",{className:"px-6 py-3 text-sm font-semibold text-gray-700 dark:text-gray-200",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("button",{type:"button",onClick:()=>M("name"),className:"inline-flex items-center gap-2 hover:text-gray-900 dark:hover:text-white transition",children:["Name",H("name")]}),l.jsx("input",{type:"text",value:p.name,onChange:q=>X("name",q.target.value),"aria-label":"Nach Name filtern",className:"w-40 rounded border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-950 px-3 py-2 text-sm font-normal text-gray-700 dark:text-gray-200"})]})}),l.jsx("th",{className:"px-6 py-3 text-sm font-semibold text-gray-700 dark:text-gray-200",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("button",{type:"button",onClick:()=>M("datum"),className:"inline-flex items-center gap-2 hover:text-gray-900 dark:hover:text-white transition",children:["Datum",H("datum")]}),l.jsxs("div",{ref:vt?d:null,className:"relative",children:[l.jsxs("button",{type:"button",onClick:()=>St(L),"aria-label":"Nach Datum filtern","aria-expanded":vt,className:"flex w-36 items-center justify-between rounded border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-950 px-3 py-2 text-left text-sm font-normal text-gray-700 dark:text-gray-200",children:[l.jsx("span",{children:C(p.datum)||"tt.mm.jjjj"}),l.jsx(Bc,{className:"h-4 w-4 text-gray-500 dark:text-gray-400","aria-hidden":"true"})]}),vt&&l.jsxs("div",{className:"absolute left-0 top-full z-20 mt-2 w-80 rounded-xl border border-gray-200 bg-white p-3 shadow-2xl dark:border-gray-700 dark:bg-gray-900",children:[l.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[l.jsx("button",{type:"button",onClick:()=>k(q=>new Date(q.getFullYear(),q.getMonth()-1,1)),className:"rounded-lg p-2 text-gray-500 transition hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-white","aria-label":"Vorheriger Monat",children:l.jsx(oy,{className:"h-4 w-4","aria-hidden":"true"})}),l.jsx("span",{className:"text-sm font-semibold capitalize text-gray-800 dark:text-gray-100",children:U}),l.jsx("button",{type:"button",onClick:()=>k(q=>new Date(q.getFullYear(),q.getMonth()+1,1)),className:"rounded-lg p-2 text-gray-500 transition hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-white","aria-label":"Nächster Monat",children:l.jsx(ly,{className:"h-4 w-4","aria-hidden":"true"})})]}),l.jsx("div",{className:"grid grid-cols-7 gap-1 text-center text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:_y.map((q,_s)=>l.jsx("span",{children:q},`${q}-${_s}`))}),l.jsx("div",{className:"mt-2 grid grid-cols-7 gap-1",children:Y.map(q=>{const _s=q.isoValue===p.datum;return l.jsx("button",{type:"button",onClick:()=>We(q.isoValue),className:`flex h-10 items-center justify-center rounded-lg text-sm transition ${_s?"bg-indigo-600 text-white":q.isCurrentMonth?"text-gray-800 hover:bg-gray-100 dark:text-gray-100 dark:hover:bg-gray-800":"text-gray-400 hover:bg-gray-100 dark:text-gray-600 dark:hover:bg-gray-800"}`,children:q.date.getDate()},q.key)})}),l.jsxs("div",{className:"mt-3 flex items-center justify-between border-t border-gray-200 pt-3 dark:border-gray-700",children:[l.jsx("button",{type:"button",onClick:at,className:"rounded-lg bg-gray-100 px-3 py-2 text-sm font-medium text-gray-700 transition hover:bg-gray-200 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",children:"Heute"}),l.jsx("button",{type:"button",onClick:lr,className:"rounded-lg bg-gray-100 px-3 py-2 text-sm font-medium text-gray-700 transition hover:bg-gray-200 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",children:"Löschen"})]})]})]})]})}),l.jsx("th",{className:"px-6 py-3 text-sm font-semibold text-gray-700 dark:text-gray-200",children:l.jsx("div",{className:"flex items-center gap-3",children:l.jsxs("button",{type:"button",onClick:()=>M("result"),className:"inline-flex items-center gap-2 hover:text-gray-900 dark:hover:text-white transition",children:["Ergebnis",H("result")]})})}),l.jsx("th",{className:"px-6 py-3 text-sm font-semibold text-gray-700 dark:text-gray-200 text-right"})]})}),l.jsx("tbody",{children:K.length===0?l.jsx("tr",{className:"border-t border-gray-200 dark:border-gray-800",children:l.jsx("td",{colSpan:"4",className:"px-6 py-8 text-sm text-gray-500 dark:text-gray-400",children:Ke})}):K.map(q=>{const Ep=!!n[q.id],Au=_(q),ka=c(q.patType,Au);return l.jsxs("tr",{className:"border-t border-gray-200 dark:border-gray-800 hover:bg-gray-50 dark:hover:bg-gray-800/40",children:[l.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:l.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[l.jsx("span",{className:"font-semibold text-gray-900 dark:text-gray-100",children:q.name}),l.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-semibold ${u(q.patType)}`,children:q.patType}),Ep&&l.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-semibold ${s?"bg-sky-100 text-sky-800 dark:bg-sky-900/40 dark:text-sky-200":"bg-amber-100 text-amber-800 dark:bg-amber-900/40 dark:text-amber-200"}`,children:s?"Freigabe aktiv":"Freigabe pausiert"}),q.isFinalized&&l.jsx("span",{className:"px-3 py-1 rounded-full text-xs font-semibold bg-emerald-100 text-emerald-800 dark:bg-emerald-900/40 dark:text-emerald-200",children:"Final abgeschlossen"})]})}),l.jsx("td",{className:"px-6 py-4 text-sm text-gray-600 dark:text-gray-300 whitespace-nowrap",children:l.jsxs("div",{className:"inline-flex items-center gap-2",children:[l.jsx(Bc,{className:"w-4 h-4","aria-hidden":"true"}),A(q.datum)]})}),l.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("span",{className:"text-xl font-bold text-green-600 dark:text-green-300",children:Au.toFixed(0)}),l.jsx("span",{className:`inline-flex px-2 py-1 rounded text-xs font-semibold ${ka.color} ${ka.text}`,children:ka.name})]})}),l.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:l.jsxs("div",{className:"flex items-center justify-end gap-2",children:[l.jsx("button",{onClick:()=>a(q),className:"bg-indigo-600 text-white px-4 py-2 rounded hover:bg-indigo-700 transition text-sm",children:"Öffnen"}),l.jsx("button",{onClick:Sp=>{Sp.stopPropagation(),o(q.id)},className:"text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 p-2",title:"Löschen",children:l.jsx(xy,{className:"w-5 h-5","aria-hidden":"true"})})]})})]},q.id)})})]})})]})};return l.jsx("div",{className:"min-h-screen bg-gradient-to-br from-green-50 to-blue-100 dark:from-gray-950 dark:to-gray-900 p-6 text-gray-900 dark:text-gray-100",children:l.jsxs("div",{className:"max-w-7xl mx-auto",children:[l.jsx("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-lg p-6 mb-6 border border-gray-100 dark:border-gray-800",children:l.jsxs("div",{className:"flex items-center justify-between mb-6",children:[l.jsx("h1",{className:"text-3xl font-bold text-gray-800 dark:text-gray-100",children:"PAT Test Manager"}),l.jsxs("div",{className:"relative",children:[l.jsxs("button",{onClick:()=>f(L=>!L),className:"bg-green-600 text-white px-4 py-2 rounded-lg hover:bg-green-700 transition flex items-center justify-center gap-2",children:[l.jsx(gy,{className:"w-4 h-4"}),"Neue Bewertung"]}),h&&l.jsx("div",{className:"absolute right-0 top-full mt-2 w-48 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 shadow-lg z-10 overflow-hidden",children:E.map(L=>l.jsx("button",{type:"button",onClick:()=>{f(!1),i(L)},className:"w-full px-4 py-3 text-left text-sm font-medium text-gray-800 dark:text-gray-100 hover:bg-gray-100 dark:hover:bg-gray-800 transition",children:L},L))})]})]})}),r&&l.jsx("div",{className:"mt-6",children:r}),e.length>0&&l.jsxs("div",{className:"space-y-6",children:[jt("open","Noch offene Bewertungen",Re,S.length,"Keine offenen Bewertungen mit den aktuellen Suchfiltern gefunden"),jt("finalized","Abgeschlossene Bewertungen",R,j.length,"Keine abgeschlossenen Bewertungen mit den aktuellen Suchfiltern gefunden")]}),e.length===0&&l.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-lg p-12 text-center border border-gray-100 dark:border-gray-800",children:[l.jsx(by,{className:"w-16 h-16 mx-auto mb-4 text-gray-300 dark:text-gray-700","aria-hidden":"true"}),l.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-4",children:"Noch keine Bewertungen vorhanden"}),l.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Lege oben eine neue Bewertung an und wähle dabei PAT Start, PAT 1, PAT 2 oder PAT 3"})]})]})})},Ny=t=>String(t||"").replace(/\D/g,""),Ty=(t,e=null)=>{var r;return e&&((r=t==null?void 0:t.subValueRanges)!=null&&r[e])?t.subValueRanges[e]:{minValue:t==null?void 0:t.minValue,maxValue:t==null?void 0:t.maxValue}},Hf=(t,e,r=null)=>{const n=Ny(e);if(!n)return"";const s=Number.parseInt(n,10),i=Ty(t,r),a=Number.isFinite(i==null?void 0:i.minValue)?i.minValue:0,o=Number.isFinite(i==null?void 0:i.maxValue)?i.maxValue:null,u=o===null?Math.max(s,a):Math.min(Math.max(s,a),o);return String(u)},Qa=t=>`px-3 py-2 border border-gray-300 dark:border-gray-700 rounded text-center bg-white dark:bg-gray-900 ${t?"opacity-70 cursor-not-allowed bg-gray-100 dark:bg-gray-800":""}`,Py=({exercise:t,exIndex:e,onChange:r,disabled:n=!1})=>{const s=(a,o=null)=>u=>{r(e,a,Hf(t,u.target.value,o),o)};if(t.subA&&t.subB){const[a="a)",o="b)"]=t.subLabels||[];return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"grid grid-cols-5 gap-2 mb-2",children:[l.jsx("div",{}),l.jsx("div",{className:"font-semibold",children:a}),t.subA.map((u,c)=>l.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",autoComplete:"off",value:u,onChange:s(c,"a"),disabled:n,className:Qa(n)},`a-${c}`))]}),l.jsxs("div",{className:"grid grid-cols-5 gap-2 mb-2",children:[l.jsx("div",{}),l.jsx("div",{className:"font-semibold",children:o}),t.subB.map((u,c)=>l.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",autoComplete:"off",value:u,onChange:s(c,"b"),disabled:n,className:Qa(n)},`b-${c}`))]})]})}const i=t.values.length===4?"grid-cols-6":t.values.length===5?"grid-cols-7":"grid-cols-5";return l.jsxs("div",{className:`grid ${i} gap-2 mb-2`,children:[l.jsx("div",{}),l.jsx("div",{}),t.values.map((a,o)=>l.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",autoComplete:"off",value:a,onChange:s(o),disabled:n,className:Qa(n)},o))]})},Cy=({show:t,onSave:e,onDiscard:r,onCancel:n})=>t?l.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:l.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl p-6 max-w-md w-full mx-4 border border-gray-200 dark:border-gray-800",children:[l.jsx("h3",{className:"text-xl font-bold text-gray-800 dark:text-gray-100 mb-4",children:"Ungespeicherte Änderungen"}),l.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6",children:"Sie haben ungespeicherte Änderungen. Möchten Sie diese speichern?"}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx("button",{onClick:e,className:"flex-1 bg-green-600 text-white px-4 py-3 rounded-lg hover:bg-green-700 transition font-semibold",children:"Ja, speichern"}),l.jsx("button",{onClick:r,className:"flex-1 bg-red-600 text-white px-4 py-3 rounded-lg hover:bg-red-700 transition font-semibold",children:"Nein, verwerfen"}),l.jsx("button",{onClick:n,className:"flex-1 bg-gray-500 dark:bg-gray-700 text-white px-4 py-3 rounded-lg hover:bg-gray-600 dark:hover:bg-gray-600 transition font-semibold",children:"Abbrechen"})]})]})}):null,Ay="modulepreload",Oy=function(t){return"/"+t},Uc={},Hc=function(e,r,n){let s=Promise.resolve();if(r&&r.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(r.map(u=>{if(u=Oy(u),u in Uc)return;Uc[u]=!0;const c=u.endsWith(".css"),d=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${d}`))return;const h=document.createElement("link");if(h.rel=c?"stylesheet":Ay,c||(h.as="script"),h.crossOrigin="",h.href=u,o&&h.setAttribute("nonce",o),document.head.appendChild(h),c)return new Promise((f,y)=>{h.addEventListener("load",f),h.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${u}`)))})}))}function i(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return s.then(a=>{for(const o of a||[])o.status==="rejected"&&i(o.reason);return e().catch(i)})},Se=14,Ry=12,hi=22,pt=210-Se*2,zy=Se+10,Ya=10.5,Vc=3,Vf=t=>{if(!t)return"—";const e=new Date(t);return Number.isNaN(e.getTime())?t:new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}).format(e)},Za=t=>(t||"pat-test").toLowerCase().replace(/[^a-z0-9-_]+/gi,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),Jn=t=>t===""||t===null||typeof t>"u"?"—":String(t),Xa=(t,e=26)=>{const r=String(t||"—");return r.length>e?`${r.slice(0,e-1)}…`:r},Wc="Versuch",Iy=t=>18+(!!(t.subA&&t.subB)?30:21)+21,Ly=t=>{var i;if(t.subA&&t.subB){const a=Math.max(t.subA.length,t.subB.length),o=[Wc,...Array.from({length:a},(d,h)=>`${h+1}`)],u=32,c=(pt-u)/a;return{head:[o],body:[["a.)",...Array.from({length:a},(d,h)=>Jn(t.subA[h]))],["b.)",...Array.from({length:a},(d,h)=>Jn(t.subB[h]))]],columnStyles:{0:{cellWidth:u,halign:"center"},...Object.fromEntries(Array.from({length:a},(d,h)=>[h+1,{cellWidth:c,halign:"center"}]))}}}const e=((i=t.values)==null?void 0:i.length)||0,r=[Wc,...Array.from({length:e},(a,o)=>`${o+1}`)],n=32,s=e>0?(pt-n)/e:pt-n;return{head:[r],body:[["Ist",...(t.values||[]).map(Jn)]],columnStyles:{0:{cellWidth:n,halign:"center"},...Object.fromEntries(Array.from({length:e},(a,o)=>[o+1,{cellWidth:s,halign:"center"}]))}}},Dy=t=>({head:[["Soll","Durchschnitt ist","Faktor","Punkte"]],body:[[Jn(t.soll),(t.durchschnitt||0).toFixed(2),Jn(t.faktor),(t.points||0).toFixed(0)]],columnStyles:{0:{cellWidth:pt/4,halign:"center"},1:{cellWidth:pt/4,halign:"center"},2:{cellWidth:pt/4,halign:"center"},3:{cellWidth:pt/4,halign:"center"}}}),My=({assessment:t,totalPoints:e,achievement:r})=>({head:[["Name","PAT Typ","Datum","Gesamtpunkte","Bewertung"]],body:[[t.name||"—",t.patType||"—",Vf(t.datum),String(Math.round(e||0)),(r==null?void 0:r.name)||"—"]],columnStyles:{0:{cellWidth:42},1:{cellWidth:28},2:{cellWidth:34},3:{cellWidth:34,halign:"center"},4:{cellWidth:44}}}),Fy=({assessment:t,achievement:e,pageNumber:r,pageCount:n})=>[`Name: ${Xa(t==null?void 0:t.name,20)}`,`PAT Typ: ${Xa(t==null?void 0:t.patType,14)}`,`Datum: ${Vf(t==null?void 0:t.datum)}`,`Bewertung: ${Xa(e==null?void 0:e.name,18)}`,`Seite ${r}/${n}`],$y=(t,e,r)=>{const n=t.internal.pageSize.getHeight();return e+r<=n-hi?e:(t.addPage(),zy)},By=(t,{assessment:e,achievement:r})=>{const n=t.getNumberOfPages(),s=t.internal.pageSize.getHeight(),i=t.internal.pageSize.getWidth(),a=s-8,o=[Se,Se+47,Se+88,Se+130,i-Se];for(let u=1;u<=n;u+=1){const[c,d,h,f,y]=Fy({assessment:e,achievement:r,pageNumber:u,pageCount:n});t.setPage(u),t.setDrawColor(226,232,240),t.setLineWidth(.3),t.line(Se,a-4,i-Se,a-4),t.setFont("helvetica","normal"),t.setFontSize(8.5),t.setTextColor(100,116,139),t.text(c,o[0],a),t.text(d,o[1],a),t.text(h,o[2],a),t.text(f,o[3],a),t.text(y,o[4],a,{align:"right"})}},Uy=async({assessment:t,totalPoints:e,achievement:r})=>{if(!t)return;const[{jsPDF:n},{default:s}]=await Promise.all([Hc(()=>import("./jspdf.es.min-CLjTnO_I.js").then(o=>o.j),[]),Hc(()=>import("./jspdf.plugin.autotable-CyVc7Jkq.js"),[])]),i=new n({unit:"mm",format:"a4"});i.setFillColor(16,185,129),i.roundedRect(Se,Ry,pt,18,4,4,"F"),i.setFont("helvetica","bold"),i.setFontSize(20),i.setTextColor(255,255,255),i.text("PAT Test Details",20,24),s(i,{startY:38,margin:{left:Se,right:Se,bottom:hi},theme:"grid",styles:{font:"helvetica",fontSize:Ya,cellPadding:4,textColor:[31,41,55],lineColor:[226,232,240],lineWidth:.3},headStyles:{fillColor:[241,245,249],textColor:[71,85,105],fontStyle:"bold"},bodyStyles:{fillColor:[255,255,255]},tableWidth:pt,...My({assessment:t,totalPoints:e,achievement:r})}),(t.exercises||[]).forEach((o,u)=>{var d,h;const c=$y(i,(((d=i.lastAutoTable)==null?void 0:d.finalY)||38)+8,Iy(o));i.setFont("helvetica","bold"),i.setFontSize(14),i.setTextColor(17,24,39),i.text(o.name||`Übung ${u+1}`,Se,c),s(i,{startY:c+4,margin:{left:Se,right:Se,bottom:hi},theme:"grid",styles:{font:"helvetica",fontSize:Ya,cellPadding:Vc,halign:"center",textColor:[31,41,55],lineColor:[226,232,240],lineWidth:.3},headStyles:{fillColor:[239,246,255],textColor:[30,64,175],fontStyle:"bold",halign:"center"},bodyStyles:{fillColor:[255,255,255],halign:"center"},tableWidth:pt,pageBreak:"avoid",rowPageBreak:"avoid",...Ly(o)}),s(i,{startY:(((h=i.lastAutoTable)==null?void 0:h.finalY)||c+4)+3,margin:{left:Se,right:Se,bottom:hi},theme:"grid",styles:{font:"helvetica",fontSize:Ya,cellPadding:Vc,textColor:[31,41,55],lineColor:[226,232,240],lineWidth:.3},headStyles:{fillColor:[236,253,245],textColor:[6,95,70],fontStyle:"bold"},bodyStyles:{fillColor:[255,255,255],halign:"center"},didParseCell:({section:f,column:y,cell:w})=>{f==="body"&&y.index===3&&(w.styles.fillColor=[241,245,249])},tableWidth:pt,pageBreak:"avoid",rowPageBreak:"avoid",...Dy(o)})});const a=[Za(t.name),Za(t.patType),Za(t.datum)].filter(Boolean).join("_");By(i,{assessment:t,achievement:r}),i.save(`${a||"pat-test"}.pdf`)},Hy=({currentAssessment:t,hasUnsavedChanges:e,onBack:r,onSave:n,onAssessmentChange:s,onUpdateExercise:i,onMarkDirty:a,showSaveDialog:o,onSaveAndExit:u,onDiscardAndExit:c,onCancelExit:d,getPatTypeColor:h,getAchievement:f,calculateTotal:y,isReadOnly:w=!1,canFinalize:x=!1,finalizeDisabledReason:b="",onFinalize:p,isShareActive:m=!1,testsVisible:g=!0,canShare:k=!1,shareDisabledReason:E="",onShare:S,onRevokeShare:j})=>{if(!t)return null;const _=y(),N=f(t==null?void 0:t.patType,_),C=async()=>{await Uy({assessment:t,totalPoints:_,achievement:N})};return l.jsx("div",{className:"min-h-screen bg-gray-100 dark:bg-gray-950 p-6 text-gray-900 dark:text-gray-100",children:l.jsxs("div",{className:"max-w-5xl mx-auto",children:[l.jsx(Cy,{show:o,onSave:u,onDiscard:c,onCancel:d}),l.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-lg p-6 border border-gray-200 dark:border-gray-800",children:[l.jsxs("div",{className:"flex justify-between items-center mb-6",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx("button",{onClick:r,className:"text-gray-600 dark:text-gray-300 hover:text-gray-800 dark:hover:text-gray-100 font-medium",children:"← Zurück zur Übersicht"}),e&&l.jsx("span",{className:"text-orange-500 dark:text-orange-300 text-sm font-semibold",children:"● Ungespeicherte Änderungen"}),l.jsx("span",{className:`px-4 py-2 rounded-full text-sm font-semibold ${h(t==null?void 0:t.patType)}`,children:t==null?void 0:t.patType}),m&&l.jsx("span",{className:`px-4 py-2 rounded-full text-sm font-semibold ${g?"bg-sky-100 text-sky-800 dark:bg-sky-900/40 dark:text-sky-200":"bg-amber-100 text-amber-800 dark:bg-amber-900/40 dark:text-amber-200"}`,children:g?"Freigabe aktiv":"Freigabe pausiert"}),(t==null?void 0:t.isFinalized)&&l.jsx("span",{className:"px-4 py-2 rounded-full text-sm font-semibold bg-emerald-100 text-emerald-800 dark:bg-emerald-900/40 dark:text-emerald-200",children:"Final abgeschlossen"})]}),l.jsxs("div",{className:"flex gap-2",children:[!w&&l.jsxs(l.Fragment,{children:[l.jsxs("button",{onClick:n,className:"bg-green-600 text-white px-4 py-2 rounded-lg hover:bg-green-700 transition flex items-center gap-2 text-sm",children:[l.jsx(my,{className:"w-4 h-4","aria-hidden":"true"}),"Speichern"]}),l.jsxs("button",{onClick:p,disabled:!x,title:b||"Test final abschließen",className:`px-4 py-2 rounded-lg transition flex items-center gap-2 text-sm ${x?"bg-emerald-700 text-white hover:bg-emerald-800":"bg-gray-300 dark:bg-gray-700 text-gray-500 dark:text-gray-400 cursor-not-allowed"}`,children:[l.jsx(sl,{className:"w-4 h-4","aria-hidden":"true"}),"Final Abschließen"]})]}),l.jsxs("button",{onClick:C,className:"bg-amber-600 text-white px-4 py-2 rounded-lg hover:bg-amber-700 transition flex items-center gap-2 text-sm",children:[l.jsx(Mf,{className:"w-4 h-4","aria-hidden":"true"}),"PDF"]}),l.jsxs("button",{onClick:S,disabled:!k,title:E||"Test als Link teilen",className:`px-4 py-2 rounded-lg transition flex items-center gap-2 text-sm ${k?"bg-sky-600 text-white hover:bg-sky-700":"bg-gray-300 dark:bg-gray-700 text-gray-500 dark:text-gray-400 cursor-not-allowed"}`,children:[l.jsx(yy,{className:"w-4 h-4","aria-hidden":"true"}),"Teilen"]}),m&&l.jsx("button",{onClick:j,className:"border border-rose-300 text-rose-700 dark:border-rose-700 dark:text-rose-300 px-4 py-2 rounded-lg hover:bg-rose-50 dark:hover:bg-rose-950/40 transition text-sm",children:"Freigabe aufheben"})]})]}),w&&l.jsxs("div",{className:"mb-6 rounded-lg border border-emerald-200 bg-emerald-50 px-4 py-3 text-emerald-800 dark:border-emerald-900/60 dark:bg-emerald-950/40 dark:text-emerald-200",children:[l.jsxs("div",{className:"flex items-center gap-2 font-semibold",children:[l.jsx(hy,{className:"h-4 w-4","aria-hidden":"true"}),"Nur Lese-Modus"]}),l.jsx("p",{className:"mt-1 text-sm",children:"Diese Bewertung wurde final abgeschlossen und kann nicht mehr bearbeitet werden."})]}),l.jsxs("div",{className:"grid grid-cols-4 gap-2 mb-6 bg-gray-50 dark:bg-gray-800 p-4 rounded",children:[l.jsx("div",{className:"font-bold",children:"Datum / Name"}),l.jsx("div",{}),l.jsx("input",{type:"date",value:(t==null?void 0:t.datum)||"",disabled:w,onChange:A=>{s({...t,datum:A.target.value}),a()},className:`px-3 py-2 border border-gray-300 dark:border-gray-700 rounded bg-white dark:bg-gray-900 ${w?"opacity-70 cursor-not-allowed bg-gray-100 dark:bg-gray-800":""}`}),l.jsx("input",{type:"text",value:(t==null?void 0:t.name)||"",disabled:w,onChange:A=>{s({...t,name:A.target.value}),a()},placeholder:"Name",className:`px-3 py-2 border border-gray-300 dark:border-gray-700 rounded bg-white dark:bg-gray-900 ${w?"opacity-70 cursor-not-allowed bg-gray-100 dark:bg-gray-800":""}`})]}),t==null?void 0:t.exercises.map((A,U)=>l.jsxs("div",{className:"mb-6 border-b pb-4 border-gray-200 dark:border-gray-800",children:[l.jsx("div",{className:"font-bold text-lg mb-2 text-gray-700 dark:text-gray-200",children:A.name}),l.jsx(Py,{exercise:A,exIndex:U,onChange:i,disabled:w}),l.jsxs("div",{className:"grid grid-cols-5 gap-2 mb-1 bg-blue-50 dark:bg-blue-900/30 p-2 rounded",children:[l.jsxs("div",{className:"font-semibold",children:["Durchschnitt Soll ",A.soll]}),l.jsx("div",{className:"font-semibold",children:"Ist"}),l.jsx("div",{className:"font-bold text-center",children:A.durchschnitt.toFixed(2)})]}),l.jsxs("div",{className:"grid grid-cols-5 gap-2 mb-1",children:[l.jsx("div",{children:"Faktor"}),l.jsx("div",{}),l.jsx("div",{className:"text-center font-semibold",children:A.faktor})]}),l.jsxs("div",{className:"grid grid-cols-5 gap-2 bg-green-50 dark:bg-green-900/30 p-2 rounded",children:[l.jsx("div",{className:"font-bold",children:"Points"}),l.jsx("div",{}),l.jsx("div",{className:"text-center font-bold text-green-600 dark:text-green-300",children:A.points.toFixed(0)})]})]},U)),l.jsxs("div",{className:"mt-6 bg-gradient-to-r from-green-100 to-blue-100 dark:from-gray-800 dark:to-gray-700 p-6 rounded-lg",children:[l.jsxs("div",{className:"flex justify-between items-center mb-4",children:[l.jsx("span",{className:"text-2xl font-bold text-gray-800 dark:text-gray-100",children:"Ergebnis"}),l.jsx("span",{className:"text-4xl font-bold text-green-600 dark:text-green-300",children:_.toFixed(0)})]}),l.jsxs("div",{className:`mt-4 px-6 py-4 rounded-lg ${N.color} ${N.text} text-center`,children:[l.jsx("p",{className:"text-2xl font-bold",children:N.name}),N.subtitle&&l.jsx("p",{className:"text-lg mt-2",children:N.subtitle})]})]})]})]})})},Wf=t=>{let e=0,r=0;t.subA&&t.subB?[...t.subA,...t.subB].forEach(i=>{const a=parseFloat(i);isNaN(a)||(e+=a,r++)}):t.values.forEach(i=>{const a=parseFloat(i);isNaN(a)||(e+=a,r++)});const n=r>0?e/r:0,s=n*t.faktor;return{durchschnitt:n,points:s}},ga=(t=[])=>t.reduce((e,r)=>e+(r.points||0),0),al=t=>({"PAT Start":"bg-green-100 text-green-800","PAT 1":"bg-blue-100 text-blue-800","PAT 2":"bg-purple-100 text-purple-800","PAT 3":"bg-orange-100 text-orange-800"})[t]||"bg-gray-100 text-gray-800",ol=(t,e)=>{const r={"PAT Start":[{min:1e3,color:"bg-yellow-400",text:"text-black",name:"2. Schwarz-Weiss Sport WPA",subtitle:"Freizeit-Spieler"},{min:800,color:"bg-white",text:"text-black",name:"1. Weiss",subtitle:""},{min:600,color:"bg-gray-200",text:"text-gray-800",name:"PAT Start Teilnahme",subtitle:""},{min:0,color:"bg-gray-100",text:"text-gray-500",name:"Nicht bestanden",subtitle:""}],"PAT 1":[{min:1e3,color:"bg-green-700",text:"text-white",name:"4. Dunkelgrün",subtitle:"ca. Bezirksliga"},{min:800,color:"bg-green-300",text:"text-black",name:"3. Hellgrün",subtitle:"ca. Kreisliga"},{min:600,color:"bg-gray-200",text:"text-gray-800",name:"PAT 1 Teilnahme",subtitle:""},{min:0,color:"bg-gray-100",text:"text-gray-500",name:"Nicht bestanden",subtitle:""}],"PAT 2":[{min:1e3,color:"bg-blue-700",text:"text-white",name:"6. Dunkelblau",subtitle:"ca. Verbandsliga"},{min:800,color:"bg-blue-300",text:"text-black",name:"5. Hellblau",subtitle:"ca. Landesliga"},{min:600,color:"bg-gray-200",text:"text-gray-800",name:"PAT 2 Teilnahme",subtitle:""},{min:0,color:"bg-gray-100",text:"text-gray-500",name:"Nicht bestanden",subtitle:""}],"PAT 3":[{min:1e3,color:"bg-pink-400",text:"text-white",name:"10. Pink",subtitle:"Ein Weltstar!"},{min:850,color:"bg-yellow-400",text:"text-black",name:"9. Gold",subtitle:"internationaler Topsportler"},{min:700,color:"bg-red-600",text:"text-white",name:"8. Rot",subtitle:"ca. 1. Bundesliga"},{min:550,color:"bg-black",text:"text-white",name:"7. Schwarz",subtitle:"ca. 2. Bundesliga"},{min:0,color:"bg-gray-100",text:"text-gray-500",name:"Nicht bestanden",subtitle:""}]},n=r[t]||r["PAT Start"];return n.find(s=>e>=s.min)||n[n.length-1]},Bs=(t,e=0)=>{const r=Number(t);return Number.isFinite(r)?r:e},Nt=(t,e=4)=>{const r=10**e;return Math.round(t*r)/r},Ui=t=>t.length?t.reduce((e,r)=>e+r,0)/t.length:0,Vy=t=>{if(t.length<=1)return 0;const e=Ui(t),r=Ui(t.map(n=>(n-e)**2));return Math.sqrt(r)},Wy=(t=[])=>[...t].sort((e,r)=>{const n=new Date((e==null?void 0:e.datum)||0).getTime(),s=new Date((r==null?void 0:r.datum)||0).getTime();if(n===s){const i=new Date((e==null?void 0:e.created_at)||0).getTime();return new Date((r==null?void 0:r.created_at)||0).getTime()-i}return s-n}),Ky=t=>!t||typeof t!="object"?[]:Array.isArray(t.subA)||Array.isArray(t.subB)?[...t.subA||[],...t.subB||[]].map(e=>Number(e)).filter(e=>Number.isFinite(e)):(t.values||[]).map(e=>Number(e)).filter(e=>Number.isFinite(e)),qy=(t,e="zero")=>{if(!t)return e==="zero"?0:null;const r=Number(t.durchschnitt);if(Number.isFinite(r))return r;const n=Ky(t);return n.length?Ui(n):e==="zero"?0:null},Gy=t=>{if(!t)return"—";const e=new Date(t);return Number.isNaN(e.getTime())?t:new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}).format(e)},Kf=(t=[],e,r={})=>{const n=Bs(r.windowSize,5),s=r.missingStrategy||"zero",a=Wy(t.filter(x=>(x==null?void 0:x.patType)===e)).slice(0,n);if(!a.length)return{windowedAssessments:[],exerciseMetrics:[],topWeaknesses:[],topStrengths:[],trendSeries:[],radarSeries:[],isLimitedData:!1,patType:e,windowSize:n};const o=a[0],u=(o==null?void 0:o.exercises)||[],c=Math.max(...u.map(x=>Bs(x==null?void 0:x.faktor,0)),1),d=u.map((x,b)=>{const p=a.map(he=>{var M;const Re=(M=he==null?void 0:he.exercises)==null?void 0:M[b],R=qy(Re,s);return R===null?0:R}),m=Ui(p),g=Bs(x==null?void 0:x.soll,0),k=Bs(x==null?void 0:x.faktor,0),E=g>0?g:1,S=Math.max(0,(g-m)/E),j=c>0?k/c:0,_=Math.min(1,Vy(p)/E),N=S*j*(1+_),C=Math.max(0,(m-g)/E),A=1-_,U=C*j*Math.max(A,.1),Y=p[0]||0,G=p[p.length-1]||0,ye=Y-G;return{index:b,name:(x==null?void 0:x.name)||`Übung ${b+1}`,soll:g,factor:k,actualMean:Nt(m,4),latestActual:Nt(Y,4),trendDelta:Nt(ye,4),gapScore:Nt(S,4),consistencyScore:Nt(_,4),priorityScore:Nt(N,4),strengthScore:Nt(U,4),actualSeries:p.map(he=>Nt(he,4))}}),h=[...d].sort((x,b)=>b.priorityScore-x.priorityScore).slice(0,3),f=[...d].sort((x,b)=>b.strengthScore-x.strengthScore).slice(0,3),y=[...a].reverse().map(x=>({assessmentId:x.id,datum:x.datum,label:Gy(x.datum),totalPoints:Math.round(ga(x.exercises||[]))})),w=[...d].sort((x,b)=>b.factor-x.factor).slice(0,6).map(x=>({name:x.name,soll:x.soll,actual:x.actualMean,ratio:x.soll>0?Nt(Math.min(1.2,x.actualMean/x.soll),4):0,priorityScore:x.priorityScore}));return{windowedAssessments:a,exerciseMetrics:d,topWeaknesses:h,topStrengths:f,trendSeries:y,radarSeries:w,isLimitedData:a.length<n,patType:e,windowSize:n}};var wu={},Hi={},ll=function(t,e){return ll=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])},ll(t,e)};function qf(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");ll(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Vi=function(){return Vi=Object.assign||function(e){for(var r,n=1,s=arguments.length;n<s;n++){r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},Vi.apply(this,arguments)};function xn(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(t);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(t,n[s])&&(r[n[s]]=t[n[s]]);return r}function Gf(t,e,r,n){var s=arguments.length,i=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(t,e,r,n);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(i=(s<3?a(i):s>3?a(e,r,i):a(e,r))||i);return s>3&&i&&Object.defineProperty(e,r,i),i}function Jf(t,e){return function(r,n){e(r,n,t)}}function Qf(t,e,r,n,s,i){function a(p){if(p!==void 0&&typeof p!="function")throw new TypeError("Function expected");return p}for(var o=n.kind,u=o==="getter"?"get":o==="setter"?"set":"value",c=!e&&t?n.static?t:t.prototype:null,d=e||(c?Object.getOwnPropertyDescriptor(c,n.name):{}),h,f=!1,y=r.length-1;y>=0;y--){var w={};for(var x in n)w[x]=x==="access"?{}:n[x];for(var x in n.access)w.access[x]=n.access[x];w.addInitializer=function(p){if(f)throw new TypeError("Cannot add initializers after decoration has completed");i.push(a(p||null))};var b=(0,r[y])(o==="accessor"?{get:d.get,set:d.set}:d[u],w);if(o==="accessor"){if(b===void 0)continue;if(b===null||typeof b!="object")throw new TypeError("Object expected");(h=a(b.get))&&(d.get=h),(h=a(b.set))&&(d.set=h),(h=a(b.init))&&s.unshift(h)}else(h=a(b))&&(o==="field"?s.unshift(h):d[u]=h)}c&&Object.defineProperty(c,n.name,d),f=!0}function Yf(t,e,r){for(var n=arguments.length>2,s=0;s<e.length;s++)r=n?e[s].call(t,r):e[s].call(t);return n?r:void 0}function Zf(t){return typeof t=="symbol"?t:"".concat(t)}function Xf(t,e,r){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:r?"".concat(r," ",e):e})}function e0(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function I(t,e,r,n){function s(i){return i instanceof r?i:new r(function(a){a(i)})}return new(r||(r=Promise))(function(i,a){function o(d){try{c(n.next(d))}catch(h){a(h)}}function u(d){try{c(n.throw(d))}catch(h){a(h)}}function c(d){d.done?i(d.value):s(d.value).then(o,u)}c((n=n.apply(t,e||[])).next())})}function t0(t,e){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,s,i,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=o(0),a.throw=o(1),a.return=o(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(c){return function(d){return u([c,d])}}function u(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(r=0)),r;)try{if(n=1,s&&(i=c[0]&2?s.return:c[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,c[1])).done)return i;switch(s=0,i&&(c=[c[0]&2,i.value]),c[0]){case 0:case 1:i=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,s=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(i=r.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){r.label=c[1];break}if(c[0]===6&&r.label<i[1]){r.label=i[1],i=c;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(c);break}i[2]&&r.ops.pop(),r.trys.pop();continue}c=e.call(t,r)}catch(d){c=[6,d],s=0}finally{n=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}var ma=Object.create?function(t,e,r,n){n===void 0&&(n=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,s)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]};function r0(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&ma(e,t,r)}function Wi(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function xu(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],a;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(o){a={error:o}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return i}function n0(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(xu(arguments[e]));return t}function s0(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),s=0,e=0;e<r;e++)for(var i=arguments[e],a=0,o=i.length;a<o;a++,s++)n[s]=i[a];return n}function i0(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))}function pn(t){return this instanceof pn?(this.v=t,this):new pn(t)}function a0(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),s,i=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",a),s[Symbol.asyncIterator]=function(){return this},s;function a(y){return function(w){return Promise.resolve(w).then(y,h)}}function o(y,w){n[y]&&(s[y]=function(x){return new Promise(function(b,p){i.push([y,x,b,p])>1||u(y,x)})},w&&(s[y]=w(s[y])))}function u(y,w){try{c(n[y](w))}catch(x){f(i[0][3],x)}}function c(y){y.value instanceof pn?Promise.resolve(y.value.v).then(d,h):f(i[0][2],y)}function d(y){u("next",y)}function h(y){u("throw",y)}function f(y,w){y(w),i.shift(),i.length&&u(i[0][0],i[0][1])}}function o0(t){var e,r;return e={},n("next"),n("throw",function(s){throw s}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(s,i){e[s]=t[s]?function(a){return(r=!r)?{value:pn(t[s](a)),done:!1}:i?i(a):a}:i}}function l0(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof Wi=="function"?Wi(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(i){r[i]=t[i]&&function(a){return new Promise(function(o,u){a=t[i](a),s(o,u,a.done,a.value)})}}function s(i,a,o,u){Promise.resolve(u).then(function(c){i({value:c,done:o})},a)}}function u0(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}var Jy=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e},ul=function(t){return ul=Object.getOwnPropertyNames||function(e){var r=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[r.length]=n);return r},ul(t)};function c0(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r=ul(t),n=0;n<r.length;n++)r[n]!=="default"&&ma(e,t,r[n]);return Jy(e,t),e}function d0(t){return t&&t.__esModule?t:{default:t}}function h0(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)}function f0(t,e,r,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r}function p0(t,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof t=="function"?e===t:t.has(e)}function g0(t,e,r){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var n,s;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=e[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=e[Symbol.dispose],r&&(s=n)}if(typeof n!="function")throw new TypeError("Object not disposable.");s&&(n=function(){try{s.call(this)}catch(i){return Promise.reject(i)}}),t.stack.push({value:e,dispose:n,async:r})}else r&&t.stack.push({async:!0});return e}var Qy=typeof SuppressedError=="function"?SuppressedError:function(t,e,r){var n=new Error(r);return n.name="SuppressedError",n.error=t,n.suppressed=e,n};function m0(t){function e(i){t.error=t.hasError?new Qy(i,t.error,"An error was suppressed during disposal."):i,t.hasError=!0}var r,n=0;function s(){for(;r=t.stack.pop();)try{if(!r.async&&n===1)return n=0,t.stack.push(r),Promise.resolve().then(s);if(r.dispose){var i=r.dispose.call(r.value);if(r.async)return n|=2,Promise.resolve(i).then(s,function(a){return e(a),s()})}else n|=1}catch(a){e(a)}if(n===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return s()}function y0(t,e){return typeof t=="string"&&/^\.\.?\//.test(t)?t.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,n,s,i,a){return n?e?".jsx":".js":s&&(!i||!a)?r:s+i+"."+a.toLowerCase()+"js"}):t}const Yy={__extends:qf,__assign:Vi,__rest:xn,__decorate:Gf,__param:Jf,__esDecorate:Qf,__runInitializers:Yf,__propKey:Zf,__setFunctionName:Xf,__metadata:e0,__awaiter:I,__generator:t0,__createBinding:ma,__exportStar:r0,__values:Wi,__read:xu,__spread:n0,__spreadArrays:s0,__spreadArray:i0,__await:pn,__asyncGenerator:a0,__asyncDelegator:o0,__asyncValues:l0,__makeTemplateObject:u0,__importStar:c0,__importDefault:d0,__classPrivateFieldGet:h0,__classPrivateFieldSet:f0,__classPrivateFieldIn:p0,__addDisposableResource:g0,__disposeResources:m0,__rewriteRelativeImportExtension:y0},Zy=Object.freeze(Object.defineProperty({__proto__:null,__addDisposableResource:g0,get __assign(){return Vi},__asyncDelegator:o0,__asyncGenerator:a0,__asyncValues:l0,__await:pn,__awaiter:I,__classPrivateFieldGet:h0,__classPrivateFieldIn:p0,__classPrivateFieldSet:f0,__createBinding:ma,__decorate:Gf,__disposeResources:m0,__esDecorate:Qf,__exportStar:r0,__extends:qf,__generator:t0,__importDefault:d0,__importStar:c0,__makeTemplateObject:u0,__metadata:e0,__param:Jf,__propKey:Zf,__read:xu,__rest:xn,__rewriteRelativeImportExtension:y0,__runInitializers:Yf,__setFunctionName:Xf,__spread:n0,__spreadArray:i0,__spreadArrays:s0,__values:Wi,default:Yy},Symbol.toStringTag,{value:"Module"})),Xy=t=>t?(...e)=>t(...e):(...e)=>fetch(...e);let ya=class extends Error{constructor(e,r="FunctionsError",n){super(e),this.name=r,this.context=n}},v0=class extends ya{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}},cl=class extends ya{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}},dl=class extends ya{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}};var Ki;(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})(Ki||(Ki={}));class ev{constructor(e,{headers:r={},customFetch:n,region:s=Ki.Any}={}){this.url=e,this.headers=r,this.region=s,this.fetch=Xy(n)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){return I(this,arguments,void 0,function*(r,n={}){var s;let i,a;try{const{headers:o,method:u,body:c,signal:d,timeout:h}=n;let f={},{region:y}=n;y||(y=this.region);const w=new URL(`${this.url}/${r}`);y&&y!=="any"&&(f["x-region"]=y,w.searchParams.set("forceFunctionRegion",y));let x;c&&(o&&!Object.prototype.hasOwnProperty.call(o,"Content-Type")||!o)?typeof Blob<"u"&&c instanceof Blob||c instanceof ArrayBuffer?(f["Content-Type"]="application/octet-stream",x=c):typeof c=="string"?(f["Content-Type"]="text/plain",x=c):typeof FormData<"u"&&c instanceof FormData?x=c:(f["Content-Type"]="application/json",x=JSON.stringify(c)):x=c;let b=d;h&&(a=new AbortController,i=setTimeout(()=>a.abort(),h),d?(b=a.signal,d.addEventListener("abort",()=>a.abort())):b=a.signal);const p=yield this.fetch(w.toString(),{method:u||"POST",headers:Object.assign(Object.assign(Object.assign({},f),this.headers),o),body:x,signal:b}).catch(E=>{throw new v0(E)}),m=p.headers.get("x-relay-error");if(m&&m==="true")throw new cl(p);if(!p.ok)throw new dl(p);let g=((s=p.headers.get("Content-Type"))!==null&&s!==void 0?s:"text/plain").split(";")[0].trim(),k;return g==="application/json"?k=yield p.json():g==="application/octet-stream"||g==="application/pdf"?k=yield p.blob():g==="text/event-stream"?k=p:g==="multipart/form-data"?k=yield p.formData():k=yield p.text(),{data:k,error:null,response:p}}catch(o){return{data:null,error:o,response:o instanceof dl||o instanceof cl?o.context:void 0}}finally{i&&clearTimeout(i)}})}}const tv=Object.freeze(Object.defineProperty({__proto__:null,get FunctionRegion(){return Ki},FunctionsClient:ev,FunctionsError:ya,FunctionsFetchError:v0,FunctionsHttpError:dl,FunctionsRelayError:cl},Symbol.toStringTag,{value:"Module"})),w0=gs(tv);var Ae={};const bn=gs(Zy);var Us={},Hs={},Vs={},Ws={},Ks={},qs={},Kc;function x0(){if(Kc)return qs;Kc=1,Object.defineProperty(qs,"__esModule",{value:!0});class t extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}}return qs.default=t,qs}var qc;function b0(){if(qc)return Ks;qc=1,Object.defineProperty(Ks,"__esModule",{value:!0});const e=bn.__importDefault(x0());let r=class{constructor(s){var i,a;this.shouldThrowOnError=!1,this.method=s.method,this.url=s.url,this.headers=new Headers(s.headers),this.schema=s.schema,this.body=s.body,this.shouldThrowOnError=(i=s.shouldThrowOnError)!==null&&i!==void 0?i:!1,this.signal=s.signal,this.isMaybeSingle=(a=s.isMaybeSingle)!==null&&a!==void 0?a:!1,s.fetch?this.fetch=s.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(s,i){return this.headers=new Headers(this.headers),this.headers.set(s,i),this}then(s,i){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");const a=this.fetch;let o=a(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{var c,d,h,f;let y=null,w=null,x=null,b=u.status,p=u.statusText;if(u.ok){if(this.method!=="HEAD"){const E=await u.text();E===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((c=this.headers.get("Accept"))===null||c===void 0)&&c.includes("application/vnd.pgrst.plan+text"))?w=E:w=JSON.parse(E))}const g=(d=this.headers.get("Prefer"))===null||d===void 0?void 0:d.match(/count=(exact|planned|estimated)/),k=(h=u.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");g&&k&&k.length>1&&(x=parseInt(k[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(w)&&(w.length>1?(y={code:"PGRST116",details:`Results contain ${w.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},w=null,x=null,b=406,p="Not Acceptable"):w.length===1?w=w[0]:w=null)}else{const g=await u.text();try{y=JSON.parse(g),Array.isArray(y)&&u.status===404&&(w=[],y=null,b=200,p="OK")}catch{u.status===404&&g===""?(b=204,p="No Content"):y={message:g}}if(y&&this.isMaybeSingle&&(!((f=y==null?void 0:y.details)===null||f===void 0)&&f.includes("0 rows"))&&(y=null,b=200,p="OK"),y&&this.shouldThrowOnError)throw new e.default(y)}return{error:y,data:w,count:x,status:b,statusText:p}});return this.shouldThrowOnError||(o=o.catch(u=>{var c,d,h,f,y,w;let x="";const b=u==null?void 0:u.cause;if(b){const p=(c=b==null?void 0:b.message)!==null&&c!==void 0?c:"",m=(d=b==null?void 0:b.code)!==null&&d!==void 0?d:"";x=`${(h=u==null?void 0:u.name)!==null&&h!==void 0?h:"FetchError"}: ${u==null?void 0:u.message}`,x+=`
|
||
|
||
Caused by: ${(f=b==null?void 0:b.name)!==null&&f!==void 0?f:"Error"}: ${p}`,m&&(x+=` (${m})`),b!=null&&b.stack&&(x+=`
|
||
${b.stack}`)}else x=(y=u==null?void 0:u.stack)!==null&&y!==void 0?y:"";return{error:{message:`${(w=u==null?void 0:u.name)!==null&&w!==void 0?w:"FetchError"}: ${u==null?void 0:u.message}`,details:x,hint:"",code:""},data:null,count:null,status:0,statusText:""}})),o.then(s,i)}returns(){return this}overrideTypes(){return this}};return Ks.default=r,Ks}var Gc;function k0(){if(Gc)return Ws;Gc=1,Object.defineProperty(Ws,"__esModule",{value:!0});const e=bn.__importDefault(b0());let r=class extends e.default{select(s){let i=!1;const a=(s??"*").split("").map(o=>/\s/.test(o)&&!i?"":(o==='"'&&(i=!i),o)).join("");return this.url.searchParams.set("select",a),this.headers.append("Prefer","return=representation"),this}order(s,{ascending:i=!0,nullsFirst:a,foreignTable:o,referencedTable:u=o}={}){const c=u?`${u}.order`:"order",d=this.url.searchParams.get(c);return this.url.searchParams.set(c,`${d?`${d},`:""}${s}.${i?"asc":"desc"}${a===void 0?"":a?".nullsfirst":".nullslast"}`),this}limit(s,{foreignTable:i,referencedTable:a=i}={}){const o=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(o,`${s}`),this}range(s,i,{foreignTable:a,referencedTable:o=a}={}){const u=typeof o>"u"?"offset":`${o}.offset`,c=typeof o>"u"?"limit":`${o}.limit`;return this.url.searchParams.set(u,`${s}`),this.url.searchParams.set(c,`${i-s+1}`),this}abortSignal(s){return this.signal=s,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:s=!1,verbose:i=!1,settings:a=!1,buffers:o=!1,wal:u=!1,format:c="text"}={}){var d;const h=[s?"analyze":null,i?"verbose":null,a?"settings":null,o?"buffers":null,u?"wal":null].filter(Boolean).join("|"),f=(d=this.headers.get("Accept"))!==null&&d!==void 0?d:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${c}; for="${f}"; options=${h};`),c==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(s){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${s}`),this}};return Ws.default=r,Ws}var Jc;function bu(){if(Jc)return Vs;Jc=1,Object.defineProperty(Vs,"__esModule",{value:!0});const e=bn.__importDefault(k0()),r=new RegExp("[,()]");let n=class extends e.default{eq(i,a){return this.url.searchParams.append(i,`eq.${a}`),this}neq(i,a){return this.url.searchParams.append(i,`neq.${a}`),this}gt(i,a){return this.url.searchParams.append(i,`gt.${a}`),this}gte(i,a){return this.url.searchParams.append(i,`gte.${a}`),this}lt(i,a){return this.url.searchParams.append(i,`lt.${a}`),this}lte(i,a){return this.url.searchParams.append(i,`lte.${a}`),this}like(i,a){return this.url.searchParams.append(i,`like.${a}`),this}likeAllOf(i,a){return this.url.searchParams.append(i,`like(all).{${a.join(",")}}`),this}likeAnyOf(i,a){return this.url.searchParams.append(i,`like(any).{${a.join(",")}}`),this}ilike(i,a){return this.url.searchParams.append(i,`ilike.${a}`),this}ilikeAllOf(i,a){return this.url.searchParams.append(i,`ilike(all).{${a.join(",")}}`),this}ilikeAnyOf(i,a){return this.url.searchParams.append(i,`ilike(any).{${a.join(",")}}`),this}regexMatch(i,a){return this.url.searchParams.append(i,`match.${a}`),this}regexIMatch(i,a){return this.url.searchParams.append(i,`imatch.${a}`),this}is(i,a){return this.url.searchParams.append(i,`is.${a}`),this}isDistinct(i,a){return this.url.searchParams.append(i,`isdistinct.${a}`),this}in(i,a){const o=Array.from(new Set(a)).map(u=>typeof u=="string"&&r.test(u)?`"${u}"`:`${u}`).join(",");return this.url.searchParams.append(i,`in.(${o})`),this}contains(i,a){return typeof a=="string"?this.url.searchParams.append(i,`cs.${a}`):Array.isArray(a)?this.url.searchParams.append(i,`cs.{${a.join(",")}}`):this.url.searchParams.append(i,`cs.${JSON.stringify(a)}`),this}containedBy(i,a){return typeof a=="string"?this.url.searchParams.append(i,`cd.${a}`):Array.isArray(a)?this.url.searchParams.append(i,`cd.{${a.join(",")}}`):this.url.searchParams.append(i,`cd.${JSON.stringify(a)}`),this}rangeGt(i,a){return this.url.searchParams.append(i,`sr.${a}`),this}rangeGte(i,a){return this.url.searchParams.append(i,`nxl.${a}`),this}rangeLt(i,a){return this.url.searchParams.append(i,`sl.${a}`),this}rangeLte(i,a){return this.url.searchParams.append(i,`nxr.${a}`),this}rangeAdjacent(i,a){return this.url.searchParams.append(i,`adj.${a}`),this}overlaps(i,a){return typeof a=="string"?this.url.searchParams.append(i,`ov.${a}`):this.url.searchParams.append(i,`ov.{${a.join(",")}}`),this}textSearch(i,a,{config:o,type:u}={}){let c="";u==="plain"?c="pl":u==="phrase"?c="ph":u==="websearch"&&(c="w");const d=o===void 0?"":`(${o})`;return this.url.searchParams.append(i,`${c}fts${d}.${a}`),this}match(i){return Object.entries(i).forEach(([a,o])=>{this.url.searchParams.append(a,`eq.${o}`)}),this}not(i,a,o){return this.url.searchParams.append(i,`not.${a}.${o}`),this}or(i,{foreignTable:a,referencedTable:o=a}={}){const u=o?`${o}.or`:"or";return this.url.searchParams.append(u,`(${i})`),this}filter(i,a,o){return this.url.searchParams.append(i,`${a}.${o}`),this}};return Vs.default=n,Vs}var Qc;function _0(){if(Qc)return Hs;Qc=1,Object.defineProperty(Hs,"__esModule",{value:!0});const e=bn.__importDefault(bu());let r=class{constructor(s,{headers:i={},schema:a,fetch:o}){this.url=s,this.headers=new Headers(i),this.schema=a,this.fetch=o}select(s,i){const{head:a=!1,count:o}=i??{},u=a?"HEAD":"GET";let c=!1;const d=(s??"*").split("").map(h=>/\s/.test(h)&&!c?"":(h==='"'&&(c=!c),h)).join("");return this.url.searchParams.set("select",d),o&&this.headers.append("Prefer",`count=${o}`),new e.default({method:u,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(s,{count:i,defaultToNull:a=!0}={}){var o;const u="POST";if(i&&this.headers.append("Prefer",`count=${i}`),a||this.headers.append("Prefer","missing=default"),Array.isArray(s)){const c=s.reduce((d,h)=>d.concat(Object.keys(h)),[]);if(c.length>0){const d=[...new Set(c)].map(h=>`"${h}"`);this.url.searchParams.set("columns",d.join(","))}}return new e.default({method:u,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}upsert(s,{onConflict:i,ignoreDuplicates:a=!1,count:o,defaultToNull:u=!0}={}){var c;const d="POST";if(this.headers.append("Prefer",`resolution=${a?"ignore":"merge"}-duplicates`),i!==void 0&&this.url.searchParams.set("on_conflict",i),o&&this.headers.append("Prefer",`count=${o}`),u||this.headers.append("Prefer","missing=default"),Array.isArray(s)){const h=s.reduce((f,y)=>f.concat(Object.keys(y)),[]);if(h.length>0){const f=[...new Set(h)].map(y=>`"${y}"`);this.url.searchParams.set("columns",f.join(","))}}return new e.default({method:d,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(c=this.fetch)!==null&&c!==void 0?c:fetch})}update(s,{count:i}={}){var a;const o="PATCH";return i&&this.headers.append("Prefer",`count=${i}`),new e.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}delete({count:s}={}){var i;const a="DELETE";return s&&this.headers.append("Prefer",`count=${s}`),new e.default({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}};return Hs.default=r,Hs}var Yc;function rv(){if(Yc)return Us;Yc=1,Object.defineProperty(Us,"__esModule",{value:!0});const t=bn,e=t.__importDefault(_0()),r=t.__importDefault(bu());let n=class E0{constructor(i,{headers:a={},schema:o,fetch:u}={}){this.url=i,this.headers=new Headers(a),this.schemaName=o,this.fetch=u}from(i){if(!i||typeof i!="string"||i.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");const a=new URL(`${this.url}/${i}`);return new e.default(a,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(i){return new E0(this.url,{headers:this.headers,schema:i,fetch:this.fetch})}rpc(i,a={},{head:o=!1,get:u=!1,count:c}={}){var d;let h;const f=new URL(`${this.url}/rpc/${i}`);let y;o||u?(h=o?"HEAD":"GET",Object.entries(a).filter(([x,b])=>b!==void 0).map(([x,b])=>[x,Array.isArray(b)?`{${b.join(",")}}`:`${b}`]).forEach(([x,b])=>{f.searchParams.append(x,b)})):(h="POST",y=a);const w=new Headers(this.headers);return c&&w.set("Prefer",`count=${c}`),new r.default({method:h,url:f,headers:w,schema:this.schemaName,body:y,fetch:(d=this.fetch)!==null&&d!==void 0?d:fetch})}};return Us.default=n,Us}Object.defineProperty(Ae,"__esModule",{value:!0});Ae.PostgrestError=Ae.PostgrestBuilder=Ae.PostgrestTransformBuilder=Ae.PostgrestFilterBuilder=Ae.PostgrestQueryBuilder=Ae.PostgrestClient=void 0;const kn=bn,S0=kn.__importDefault(rv());Ae.PostgrestClient=S0.default;const j0=kn.__importDefault(_0());Ae.PostgrestQueryBuilder=j0.default;const N0=kn.__importDefault(bu());Ae.PostgrestFilterBuilder=N0.default;const T0=kn.__importDefault(k0());Ae.PostgrestTransformBuilder=T0.default;const P0=kn.__importDefault(b0());Ae.PostgrestBuilder=P0.default;const C0=kn.__importDefault(x0());Ae.PostgrestError=C0.default;Ae.default={PostgrestClient:S0.default,PostgrestQueryBuilder:j0.default,PostgrestFilterBuilder:N0.default,PostgrestTransformBuilder:T0.default,PostgrestBuilder:P0.default,PostgrestError:C0.default};class A0{constructor(){}static detectEnvironment(){var e;if(typeof WebSocket<"u")return{type:"native",constructor:WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocket<"u")return{type:"native",constructor:globalThis.WebSocket};if(typeof global<"u"&&typeof global.WebSocket<"u")return{type:"native",constructor:global.WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&globalThis.EdgeRuntime||typeof navigator<"u"&&(!((e=navigator.userAgent)===null||e===void 0)&&e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};if(typeof process<"u"){const r=process.versions;if(r&&r.node){const n=r.node,s=parseInt(n.replace(/^v/,"").split(".")[0]);return s>=22?typeof globalThis.WebSocket<"u"?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${s} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${s} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option:
|
||
import ws from "ws"
|
||
new RealtimeClient(url, { transport: ws })`}}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const e=this.detectEnvironment();if(e.constructor)return e.constructor;let r=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(r+=`
|
||
|
||
Suggested solution: ${e.workaround}`),new Error(r)}static createWebSocket(e,r){const n=this.getWebSocketConstructor();return new n(e,r)}static isWebSocketSupported(){try{const e=this.detectEnvironment();return e.type==="native"||e.type==="ws"}catch{return!1}}}const nv="2.86.2",sv=`realtime-js/${nv}`,O0="1.0.0",iv="2.0.0",Zc=O0,hl=1e4,av=1e3,ov=100;var mr;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(mr||(mr={}));var pe;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(pe||(pe={}));var ht;(function(t){t.close="phx_close",t.error="phx_error",t.join="phx_join",t.reply="phx_reply",t.leave="phx_leave",t.access_token="access_token"})(ht||(ht={}));var fl;(function(t){t.websocket="websocket"})(fl||(fl={}));var yr;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(yr||(yr={}));class lv{constructor(e){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=e??[]}encode(e,r){if(e.event===this.BROADCAST_EVENT&&!(e.payload instanceof ArrayBuffer)&&typeof e.payload.event=="string")return r(this._binaryEncodeUserBroadcastPush(e));let n=[e.join_ref,e.ref,e.topic,e.event,e.payload];return r(JSON.stringify(n))}_binaryEncodeUserBroadcastPush(e){var r;return this._isArrayBuffer((r=e.payload)===null||r===void 0?void 0:r.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)}_encodeBinaryUserBroadcastPush(e){var r,n;const s=(n=(r=e.payload)===null||r===void 0?void 0:r.payload)!==null&&n!==void 0?n:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,s)}_encodeJsonUserBroadcastPush(e){var r,n;const s=(n=(r=e.payload)===null||r===void 0?void 0:r.payload)!==null&&n!==void 0?n:{},a=new TextEncoder().encode(JSON.stringify(s)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,a)}_encodeUserBroadcastPush(e,r,n){var s,i;const a=e.topic,o=(s=e.ref)!==null&&s!==void 0?s:"",u=(i=e.join_ref)!==null&&i!==void 0?i:"",c=e.payload.event,d=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},h=Object.keys(d).length===0?"":JSON.stringify(d);if(u.length>255)throw new Error(`joinRef length ${u.length} exceeds maximum of 255`);if(o.length>255)throw new Error(`ref length ${o.length} exceeds maximum of 255`);if(a.length>255)throw new Error(`topic length ${a.length} exceeds maximum of 255`);if(c.length>255)throw new Error(`userEvent length ${c.length} exceeds maximum of 255`);if(h.length>255)throw new Error(`metadata length ${h.length} exceeds maximum of 255`);const f=this.USER_BROADCAST_PUSH_META_LENGTH+u.length+o.length+a.length+c.length+h.length,y=new ArrayBuffer(this.HEADER_LENGTH+f);let w=new DataView(y),x=0;w.setUint8(x++,this.KINDS.userBroadcastPush),w.setUint8(x++,u.length),w.setUint8(x++,o.length),w.setUint8(x++,a.length),w.setUint8(x++,c.length),w.setUint8(x++,h.length),w.setUint8(x++,r),Array.from(u,p=>w.setUint8(x++,p.charCodeAt(0))),Array.from(o,p=>w.setUint8(x++,p.charCodeAt(0))),Array.from(a,p=>w.setUint8(x++,p.charCodeAt(0))),Array.from(c,p=>w.setUint8(x++,p.charCodeAt(0))),Array.from(h,p=>w.setUint8(x++,p.charCodeAt(0)));var b=new Uint8Array(y.byteLength+n.byteLength);return b.set(new Uint8Array(y),0),b.set(new Uint8Array(n),y.byteLength),b.buffer}decode(e,r){if(this._isArrayBuffer(e)){let n=this._binaryDecode(e);return r(n)}if(typeof e=="string"){const n=JSON.parse(e),[s,i,a,o,u]=n;return r({join_ref:s,ref:i,topic:a,event:o,payload:u})}return r({})}_binaryDecode(e){const r=new DataView(e),n=r.getUint8(0),s=new TextDecoder;switch(n){case this.KINDS.userBroadcast:return this._decodeUserBroadcast(e,r,s)}}_decodeUserBroadcast(e,r,n){const s=r.getUint8(1),i=r.getUint8(2),a=r.getUint8(3),o=r.getUint8(4);let u=this.HEADER_LENGTH+4;const c=n.decode(e.slice(u,u+s));u=u+s;const d=n.decode(e.slice(u,u+i));u=u+i;const h=n.decode(e.slice(u,u+a));u=u+a;const f=e.slice(u,e.byteLength),y=o===this.JSON_ENCODING?JSON.parse(n.decode(f)):f,w={type:this.BROADCAST_EVENT,event:d,payload:y};return a>0&&(w.meta=JSON.parse(h)),{join_ref:null,ref:null,topic:c,event:this.BROADCAST_EVENT,payload:w}}_isArrayBuffer(e){var r;return e instanceof ArrayBuffer||((r=e==null?void 0:e.constructor)===null||r===void 0?void 0:r.name)==="ArrayBuffer"}_pick(e,r){return!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([n])=>r.includes(n)))}}class R0{constructor(e,r){this.callback=e,this.timerCalc=r,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=r}reset(){this.tries=0,clearTimeout(this.timer),this.timer=void 0}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}var te;(function(t){t.abstime="abstime",t.bool="bool",t.date="date",t.daterange="daterange",t.float4="float4",t.float8="float8",t.int2="int2",t.int4="int4",t.int4range="int4range",t.int8="int8",t.int8range="int8range",t.json="json",t.jsonb="jsonb",t.money="money",t.numeric="numeric",t.oid="oid",t.reltime="reltime",t.text="text",t.time="time",t.timestamp="timestamp",t.timestamptz="timestamptz",t.timetz="timetz",t.tsrange="tsrange",t.tstzrange="tstzrange"})(te||(te={}));const Xc=(t,e,r={})=>{var n;const s=(n=r.skipTypes)!==null&&n!==void 0?n:[];return e?Object.keys(e).reduce((i,a)=>(i[a]=uv(a,t,e,s),i),{}):{}},uv=(t,e,r,n)=>{const s=e.find(o=>o.name===t),i=s==null?void 0:s.type,a=r[t];return i&&!n.includes(i)?z0(i,a):pl(a)},z0=(t,e)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return fv(e,r)}switch(t){case te.bool:return cv(e);case te.float4:case te.float8:case te.int2:case te.int4:case te.int8:case te.numeric:case te.oid:return dv(e);case te.json:case te.jsonb:return hv(e);case te.timestamp:return pv(e);case te.abstime:case te.date:case te.daterange:case te.int4range:case te.int8range:case te.money:case te.reltime:case te.text:case te.time:case te.timestamptz:case te.timetz:case te.tsrange:case te.tstzrange:return pl(e);default:return pl(e)}},pl=t=>t,cv=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},dv=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},hv=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(e){return console.log(`JSON parse error: ${e}`),t}return t},fv=(t,e)=>{if(typeof t!="string")return t;const r=t.length-1,n=t[r];if(t[0]==="{"&&n==="}"){let i;const a=t.slice(1,r);try{i=JSON.parse("["+a+"]")}catch{i=a?a.split(","):[]}return i.map(o=>z0(e,o))}return t},pv=t=>typeof t=="string"?t.replace(" ","T"):t,I0=t=>{const e=new URL(t);return e.protocol=e.protocol.replace(/^ws/i,"http"),e.pathname=e.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),e.pathname===""||e.pathname==="/"?e.pathname="/api/broadcast":e.pathname=e.pathname+"/api/broadcast",e.href};class eo{constructor(e,r,n={},s=hl){this.channel=e,this.event=r,this.payload=n,this.timeout=s,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,r){var n;return this._hasReceived(e)&&r((n=this.receivedResp)===null||n===void 0?void 0:n.response),this.recHooks.push({status:e,callback:r}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const e=r=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=r,this._matchReceive(r)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,r){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:r})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:r}){this.recHooks.filter(n=>n.status===e).forEach(n=>n.callback(r))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}var gl;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(gl||(gl={}));let L0=class fi{constructor(e,r){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const n=(r==null?void 0:r.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(n.state,{},s=>{const{onJoin:i,onLeave:a,onSync:o}=this.caller;this.joinRef=this.channel._joinRef(),this.state=fi.syncState(this.state,s,i,a),this.pendingDiffs.forEach(u=>{this.state=fi.syncDiff(this.state,u,i,a)}),this.pendingDiffs=[],o()}),this.channel._on(n.diff,{},s=>{const{onJoin:i,onLeave:a,onSync:o}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(s):(this.state=fi.syncDiff(this.state,s,i,a),o())}),this.onJoin((s,i,a)=>{this.channel._trigger("presence",{event:"join",key:s,currentPresences:i,newPresences:a})}),this.onLeave((s,i,a)=>{this.channel._trigger("presence",{event:"leave",key:s,currentPresences:i,leftPresences:a})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,r,n,s){const i=this.cloneDeep(e),a=this.transformState(r),o={},u={};return this.map(i,(c,d)=>{a[c]||(u[c]=d)}),this.map(a,(c,d)=>{const h=i[c];if(h){const f=d.map(b=>b.presence_ref),y=h.map(b=>b.presence_ref),w=d.filter(b=>y.indexOf(b.presence_ref)<0),x=h.filter(b=>f.indexOf(b.presence_ref)<0);w.length>0&&(o[c]=w),x.length>0&&(u[c]=x)}else o[c]=d}),this.syncDiff(i,{joins:o,leaves:u},n,s)}static syncDiff(e,r,n,s){const{joins:i,leaves:a}={joins:this.transformState(r.joins),leaves:this.transformState(r.leaves)};return n||(n=()=>{}),s||(s=()=>{}),this.map(i,(o,u)=>{var c;const d=(c=e[o])!==null&&c!==void 0?c:[];if(e[o]=this.cloneDeep(u),d.length>0){const h=e[o].map(y=>y.presence_ref),f=d.filter(y=>h.indexOf(y.presence_ref)<0);e[o].unshift(...f)}n(o,d,u)}),this.map(a,(o,u)=>{let c=e[o];if(!c)return;const d=u.map(h=>h.presence_ref);c=c.filter(h=>d.indexOf(h.presence_ref)<0),e[o]=c,s(o,c,u),c.length===0&&delete e[o]}),e}static map(e,r){return Object.getOwnPropertyNames(e).map(n=>r(n,e[n]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((r,n)=>{const s=e[n];return"metas"in s?r[n]=s.metas.map(i=>(i.presence_ref=i.phx_ref,delete i.phx_ref,delete i.phx_ref_prev,i)):r[n]=s,r},{})}static cloneDeep(e){return JSON.parse(JSON.stringify(e))}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}};var ml;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(ml||(ml={}));var sn;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(sn||(sn={}));var bt;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(bt||(bt={}));const gv=pe;let D0=class M0{constructor(e,r={config:{}},n){var s,i;if(this.topic=e,this.params=r,this.socket=n,this.bindings={},this.state=pe.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},r.config),this.timeout=this.socket.timeout,this.joinPush=new eo(this,ht.join,this.params,this.timeout),this.rejoinTimer=new R0(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=pe.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(a=>a.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=pe.closed,this.socket._remove(this)}),this._onError(a=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,a),this.state=pe.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=pe.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",a=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,a),this.state=pe.errored,this.rejoinTimer.scheduleTimeout())}),this._on(ht.reply,{},(a,o)=>{this._trigger(this._replyEventName(o),a)}),this.presence=new L0(this),this.broadcastEndpointURL=I0(this.socket.endPoint),this.private=this.params.config.private||!1,!this.private&&(!((i=(s=this.params.config)===null||s===void 0?void 0:s.broadcast)===null||i===void 0)&&i.replay))throw`tried to use replay on public channel '${this.topic}'. It must be a private channel.`}subscribe(e,r=this.timeout){var n,s,i;if(this.socket.isConnected()||this.socket.connect(),this.state==pe.closed){const{config:{broadcast:a,presence:o,private:u}}=this.params,c=(s=(n=this.bindings.postgres_changes)===null||n===void 0?void 0:n.map(y=>y.filter))!==null&&s!==void 0?s:[],d=!!this.bindings[sn.PRESENCE]&&this.bindings[sn.PRESENCE].length>0||((i=this.params.config.presence)===null||i===void 0?void 0:i.enabled)===!0,h={},f={broadcast:a,presence:Object.assign(Object.assign({},o),{enabled:d}),postgres_changes:c,private:u};this.socket.accessTokenValue&&(h.access_token=this.socket.accessTokenValue),this._onError(y=>e==null?void 0:e(bt.CHANNEL_ERROR,y)),this._onClose(()=>e==null?void 0:e(bt.CLOSED)),this.updateJoinPayload(Object.assign({config:f},h)),this.joinedOnce=!0,this._rejoin(r),this.joinPush.receive("ok",async({postgres_changes:y})=>{var w;if(this.socket.setAuth(),y===void 0){e==null||e(bt.SUBSCRIBED);return}else{const x=this.bindings.postgres_changes,b=(w=x==null?void 0:x.length)!==null&&w!==void 0?w:0,p=[];for(let m=0;m<b;m++){const g=x[m],{filter:{event:k,schema:E,table:S,filter:j}}=g,_=y&&y[m];if(_&&_.event===k&&_.schema===E&&_.table===S&&_.filter===j)p.push(Object.assign(Object.assign({},g),{id:_.id}));else{this.unsubscribe(),this.state=pe.errored,e==null||e(bt.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=p,e&&e(bt.SUBSCRIBED);return}}).receive("error",y=>{this.state=pe.errored,e==null||e(bt.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(y).join(", ")||"error")))}).receive("timeout",()=>{e==null||e(bt.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(e,r={}){return await this.send({type:"presence",event:"track",payload:e},r.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,r,n){return this.state===pe.joined&&e===sn.PRESENCE&&(this.socket.log("channel",`resubscribe to ${this.topic} due to change in presence callbacks on joined channel`),this.unsubscribe().then(()=>this.subscribe())),this._on(e,r,n)}async httpSend(e,r,n={}){var s;const i=this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"";if(r==null)return Promise.reject("Payload is required for httpSend()");const a={method:"POST",headers:{Authorization:i,apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:e,payload:r,private:this.private}]})},o=await this._fetchWithTimeout(this.broadcastEndpointURL,a,(s=n.timeout)!==null&&s!==void 0?s:this.timeout);if(o.status===202)return{success:!0};let u=o.statusText;try{const c=await o.json();u=c.error||c.message||u}catch{}return Promise.reject(new Error(u))}async send(e,r={}){var n,s;if(!this._canPush()&&e.type==="broadcast"){console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");const{event:i,payload:a}=e,u={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:a,private:this.private}]})};try{const c=await this._fetchWithTimeout(this.broadcastEndpointURL,u,(n=r.timeout)!==null&&n!==void 0?n:this.timeout);return await((s=c.body)===null||s===void 0?void 0:s.cancel()),c.ok?"ok":"error"}catch(c){return c.name==="AbortError"?"timed out":"error"}}else return new Promise(i=>{var a,o,u;const c=this._push(e.type,e,r.timeout||this.timeout);e.type==="broadcast"&&!(!((u=(o=(a=this.params)===null||a===void 0?void 0:a.config)===null||o===void 0?void 0:o.broadcast)===null||u===void 0)&&u.ack)&&i("ok"),c.receive("ok",()=>i("ok")),c.receive("error",()=>i("error")),c.receive("timeout",()=>i("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=pe.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(ht.close,"leave",this._joinRef())};this.joinPush.destroy();let n=null;return new Promise(s=>{n=new eo(this,ht.leave,{},e),n.receive("ok",()=>{r(),s("ok")}).receive("timeout",()=>{r(),s("timed out")}).receive("error",()=>{s("error")}),n.send(),this._canPush()||n.trigger("ok",{})}).finally(()=>{n==null||n.destroy()})}teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=pe.closed,this.bindings={}}async _fetchWithTimeout(e,r,n){const s=new AbortController,i=setTimeout(()=>s.abort(),n),a=await this.socket.fetch(e,Object.assign(Object.assign({},r),{signal:s.signal}));return clearTimeout(i),a}_push(e,r,n=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let s=new eo(this,e,r,n);return this._canPush()?s.send():this._addToPushBuffer(s),s}_addToPushBuffer(e){if(e.startTimeout(),this.pushBuffer.push(e),this.pushBuffer.length>ov){const r=this.pushBuffer.shift();r&&(r.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${r.event}`,r.payload))}}_onMessage(e,r,n){return r}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,r,n){var s,i;const a=e.toLocaleLowerCase(),{close:o,error:u,leave:c,join:d}=ht;if(n&&[o,u,c,d].indexOf(a)>=0&&n!==this._joinRef())return;let f=this._onMessage(a,r,n);if(r&&!f)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(a)?(s=this.bindings.postgres_changes)===null||s===void 0||s.filter(y=>{var w,x,b;return((w=y.filter)===null||w===void 0?void 0:w.event)==="*"||((b=(x=y.filter)===null||x===void 0?void 0:x.event)===null||b===void 0?void 0:b.toLocaleLowerCase())===a}).map(y=>y.callback(f,n)):(i=this.bindings[a])===null||i===void 0||i.filter(y=>{var w,x,b,p,m,g;if(["broadcast","presence","postgres_changes"].includes(a))if("id"in y){const k=y.id,E=(w=y.filter)===null||w===void 0?void 0:w.event;return k&&((x=r.ids)===null||x===void 0?void 0:x.includes(k))&&(E==="*"||(E==null?void 0:E.toLocaleLowerCase())===((b=r.data)===null||b===void 0?void 0:b.type.toLocaleLowerCase()))}else{const k=(m=(p=y==null?void 0:y.filter)===null||p===void 0?void 0:p.event)===null||m===void 0?void 0:m.toLocaleLowerCase();return k==="*"||k===((g=r==null?void 0:r.event)===null||g===void 0?void 0:g.toLocaleLowerCase())}else return y.type.toLocaleLowerCase()===a}).map(y=>{if(typeof f=="object"&&"ids"in f){const w=f.data,{schema:x,table:b,commit_timestamp:p,type:m,errors:g}=w;f=Object.assign(Object.assign({},{schema:x,table:b,commit_timestamp:p,eventType:m,new:{},old:{},errors:g}),this._getPayloadRecords(w))}y.callback(f,n)})}_isClosed(){return this.state===pe.closed}_isJoined(){return this.state===pe.joined}_isJoining(){return this.state===pe.joining}_isLeaving(){return this.state===pe.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,r,n){const s=e.toLocaleLowerCase(),i={type:s,filter:r,callback:n};return this.bindings[s]?this.bindings[s].push(i):this.bindings[s]=[i],this}_off(e,r){const n=e.toLocaleLowerCase();return this.bindings[n]&&(this.bindings[n]=this.bindings[n].filter(s=>{var i;return!(((i=s.type)===null||i===void 0?void 0:i.toLocaleLowerCase())===n&&M0.isEqual(s.filter,r))})),this}static isEqual(e,r){if(Object.keys(e).length!==Object.keys(r).length)return!1;for(const n in e)if(e[n]!==r[n])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(ht.close,{},e)}_onError(e){this._on(ht.error,{},r=>e(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=pe.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const r={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(r.new=Xc(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(r.old=Xc(e.columns,e.old_record)),r}};const to=()=>{},Gs={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},mv=[1e3,2e3,5e3,1e4],yv=1e4,vv=`
|
||
addEventListener("message", (e) => {
|
||
if (e.data.event === "start") {
|
||
setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
|
||
}
|
||
});`;let wv=class{constructor(e,r){var n;if(this.accessTokenValue=null,this.apiKey=null,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=hl,this.transport=null,this.heartbeatIntervalMs=Gs.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=to,this.ref=0,this.reconnectTimer=null,this.vsn=Zc,this.logger=to,this.conn=null,this.sendBuffer=[],this.serializer=new lv,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._connectionState="disconnected",this._wasManualDisconnect=!1,this._authPromise=null,this._resolveFetch=s=>s?(...i)=>s(...i):(...i)=>fetch(...i),!(!((n=r==null?void 0:r.params)===null||n===void 0)&&n.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=r.params.apikey,this.endPoint=`${e}/${fl.websocket}`,this.httpEndpoint=I0(e),this._initializeOptions(r),this._setupReconnectionTimer(),this.fetch=this._resolveFetch(r==null?void 0:r.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.conn!==null&&this.isConnected())){if(this._setConnectionState("connecting"),this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this.transport)this.conn=new this.transport(this.endpointURL());else try{this.conn=A0.createWebSocket(this.endpointURL())}catch(e){this._setConnectionState("disconnected");const r=e.message;throw r.includes("Node.js")?new Error(`${r}
|
||
|
||
To use Realtime in Node.js, you need to provide a WebSocket implementation:
|
||
|
||
Option 1: Use Node.js 22+ which has native WebSocket support
|
||
Option 2: Install and provide the "ws" package:
|
||
|
||
npm install ws
|
||
|
||
import ws from "ws"
|
||
const client = new RealtimeClient(url, {
|
||
...options,
|
||
transport: ws
|
||
})`):new Error(`WebSocket not available: ${r}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:this.vsn}))}disconnect(e,r){if(!this.isDisconnecting())if(this._setConnectionState("disconnecting",!0),this.conn){const n=setTimeout(()=>{this._setConnectionState("disconnected")},100);this.conn.onclose=()=>{clearTimeout(n),this._setConnectionState("disconnected")},typeof this.conn.close=="function"&&(e?this.conn.close(e,r??""):this.conn.close()),this._teardownConnection()}else this._setConnectionState("disconnected")}getChannels(){return this.channels}async removeChannel(e){const r=await e.unsubscribe();return this.channels.length===0&&this.disconnect(),r}async removeAllChannels(){const e=await Promise.all(this.channels.map(r=>r.unsubscribe()));return this.channels=[],this.disconnect(),e}log(e,r,n){this.logger(e,r,n)}connectionState(){switch(this.conn&&this.conn.readyState){case mr.connecting:return yr.Connecting;case mr.open:return yr.Open;case mr.closing:return yr.Closing;default:return yr.Closed}}isConnected(){return this.connectionState()===yr.Open}isConnecting(){return this._connectionState==="connecting"}isDisconnecting(){return this._connectionState==="disconnecting"}channel(e,r={config:{}}){const n=`realtime:${e}`,s=this.getChannels().find(i=>i.topic===n);if(s)return s;{const i=new D0(`realtime:${e}`,r,this);return this.channels.push(i),i}}push(e){const{topic:r,event:n,payload:s,ref:i}=e,a=()=>{this.encode(e,o=>{var u;(u=this.conn)===null||u===void 0||u.send(o)})};this.log("push",`${r} ${n} (${i})`,s),this.isConnected()?a():this.sendBuffer.push(a)}async setAuth(e=null){this._authPromise=this._performAuth(e);try{await this._authPromise}finally{this._authPromise=null}}async sendHeartbeat(){var e;if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(r){this.log("error","error in heartbeat callback",r)}return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(r){this.log("error","error in heartbeat callback",r)}this._wasManualDisconnect=!1,(e=this.conn)===null||e===void 0||e.close(av,"heartbeat timeout"),setTimeout(()=>{var r;this.isConnected()||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout()},Gs.HEARTBEAT_TIMEOUT_FALLBACK);return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(r){this.log("error","error in heartbeat callback",r)}this._setAuthSafely("heartbeat")}onHeartbeat(e){this.heartbeatCallback=e}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let r=this.channels.find(n=>n.topic===e&&(n._isJoined()||n._isJoining()));r&&(this.log("transport",`leaving duplicate topic "${e}"`),r.unsubscribe())}_remove(e){this.channels=this.channels.filter(r=>r.topic!==e.topic)}_onConnMessage(e){this.decode(e.data,r=>{if(r.topic==="phoenix"&&r.event==="phx_reply")try{this.heartbeatCallback(r.payload.status==="ok"?"ok":"error")}catch(c){this.log("error","error in heartbeat callback",c)}r.ref&&r.ref===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null);const{topic:n,event:s,payload:i,ref:a}=r,o=a?`(${a})`:"",u=i.status||"";this.log("receive",`${u} ${n} ${s} ${o}`.trim(),i),this.channels.filter(c=>c._isMember(n)).forEach(c=>c._trigger(s,i,a)),this._triggerStateCallbacks("message",r)})}_clearTimer(e){var r;e==="heartbeat"&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):e==="reconnect"&&((r=this.reconnectTimer)===null||r===void 0||r.reset())}_clearAllTimers(){this._clearTimer("heartbeat"),this._clearTimer("reconnect")}_setupConnectionHandlers(){this.conn&&("binaryType"in this.conn&&(this.conn.binaryType="arraybuffer"),this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e))}_teardownConnection(){if(this.conn){if(this.conn.readyState===mr.open||this.conn.readyState===mr.connecting)try{this.conn.close()}catch(e){this.log("error","Error closing connection",e)}this.conn.onopen=null,this.conn.onerror=null,this.conn.onmessage=null,this.conn.onclose=null,this.conn=null}this._clearAllTimers(),this.channels.forEach(e=>e.teardown())}_onConnOpen(){this._setConnectionState("connected"),this.log("transport",`connected to ${this.endpointURL()}`),(this._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve())).then(()=>{this.flushSendBuffer()}).catch(r=>{this.log("error","error waiting for auth on connect",r),this.flushSendBuffer()}),this._clearTimer("reconnect"),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this._triggerStateCallbacks("open")}_startHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=r=>{this.log("worker","worker error",r.message),this.workerRef.terminate()},this.workerRef.onmessage=r=>{r.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_onConnClose(e){var r;this._setConnectionState("disconnected"),this.log("transport","close",e),this._triggerChanError(),this._clearTimer("heartbeat"),this._wasManualDisconnect||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout(),this._triggerStateCallbacks("close",e)}_onConnError(e){this._setConnectionState("disconnected"),this.log("transport",`${e}`),this._triggerChanError(),this._triggerStateCallbacks("error",e)}_triggerChanError(){this.channels.forEach(e=>e._trigger(ht.error))}_appendParams(e,r){if(Object.keys(r).length===0)return e;const n=e.match(/\?/)?"&":"?",s=new URLSearchParams(r);return`${e}${n}${s}`}_workerObjectUrl(e){let r;if(e)r=e;else{const n=new Blob([vv],{type:"application/javascript"});r=URL.createObjectURL(n)}return r}_setConnectionState(e,r=!1){this._connectionState=e,e==="connecting"?this._wasManualDisconnect=!1:e==="disconnecting"&&(this._wasManualDisconnect=r)}async _performAuth(e=null){let r;e?r=e:this.accessToken?r=await this.accessToken():r=this.accessTokenValue,this.accessTokenValue!=r&&(this.accessTokenValue=r,this.channels.forEach(n=>{const s={access_token:r,version:sv};r&&n.updateJoinPayload(s),n.joinedOnce&&n._isJoined()&&n._push(ht.access_token,{access_token:r})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(e="general"){this.setAuth().catch(r=>{this.log("error",`error setting auth in ${e}`,r)})}_triggerStateCallbacks(e,r){try{this.stateChangeCallbacks[e].forEach(n=>{try{n(r)}catch(s){this.log("error",`error in ${e} callback`,s)}})}catch(n){this.log("error",`error triggering ${e} callbacks`,n)}}_setupReconnectionTimer(){this.reconnectTimer=new R0(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},Gs.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(e){var r,n,s,i,a,o,u,c,d,h,f,y;switch(this.transport=(r=e==null?void 0:e.transport)!==null&&r!==void 0?r:null,this.timeout=(n=e==null?void 0:e.timeout)!==null&&n!==void 0?n:hl,this.heartbeatIntervalMs=(s=e==null?void 0:e.heartbeatIntervalMs)!==null&&s!==void 0?s:Gs.HEARTBEAT_INTERVAL,this.worker=(i=e==null?void 0:e.worker)!==null&&i!==void 0?i:!1,this.accessToken=(a=e==null?void 0:e.accessToken)!==null&&a!==void 0?a:null,this.heartbeatCallback=(o=e==null?void 0:e.heartbeatCallback)!==null&&o!==void 0?o:to,this.vsn=(u=e==null?void 0:e.vsn)!==null&&u!==void 0?u:Zc,e!=null&&e.params&&(this.params=e.params),e!=null&&e.logger&&(this.logger=e.logger),(e!=null&&e.logLevel||e!=null&&e.log_level)&&(this.logLevel=e.logLevel||e.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=(c=e==null?void 0:e.reconnectAfterMs)!==null&&c!==void 0?c:w=>mv[w-1]||yv,this.vsn){case O0:this.encode=(d=e==null?void 0:e.encode)!==null&&d!==void 0?d:(w,x)=>x(JSON.stringify(w)),this.decode=(h=e==null?void 0:e.decode)!==null&&h!==void 0?h:(w,x)=>x(JSON.parse(w));break;case iv:this.encode=(f=e==null?void 0:e.encode)!==null&&f!==void 0?f:this.serializer.encode.bind(this.serializer),this.decode=(y=e==null?void 0:e.decode)!==null&&y!==void 0?y:this.serializer.decode.bind(this.serializer);break;default:throw new Error(`Unsupported serializer version: ${this.vsn}`)}if(this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=e==null?void 0:e.workerUrl}}};const xv=Object.freeze(Object.defineProperty({__proto__:null,REALTIME_CHANNEL_STATES:gv,get REALTIME_LISTEN_TYPES(){return sn},get REALTIME_POSTGRES_CHANGES_LISTEN_EVENT(){return ml},get REALTIME_PRESENCE_LISTEN_EVENTS(){return gl},get REALTIME_SUBSCRIBE_STATES(){return bt},RealtimeChannel:D0,RealtimeClient:wv,RealtimePresence:L0,WebSocketFactory:A0},Symbol.toStringTag,{value:"Module"})),F0=gs(xv);class bs extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function ae(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class $0 extends bs{constructor(e,r,n){super(e),this.name="StorageApiError",this.status=r,this.statusCode=n}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class qi extends bs{constructor(e,r){super(e),this.name="StorageUnknownError",this.originalError=r}}const ku=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),bv=()=>Response,yl=t=>{if(Array.isArray(t))return t.map(r=>yl(r));if(typeof t=="function"||t!==Object(t))return t;const e={};return Object.entries(t).forEach(([r,n])=>{const s=r.replace(/([-_][a-z])/gi,i=>i.toUpperCase().replace(/[-_]/g,""));e[s]=yl(n)}),e},kv=t=>{if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},_v=t=>!t||typeof t!="string"||t.length===0||t.length>100||t.trim()!==t||t.includes("/")||t.includes("\\")?!1:/^[\w!.\*'() &$@=;:+,?-]+$/.test(t),ro=t=>{var e;return t.msg||t.message||t.error_description||(typeof t.error=="string"?t.error:(e=t.error)===null||e===void 0?void 0:e.message)||JSON.stringify(t)},Ev=(t,e,r)=>I(void 0,void 0,void 0,function*(){const n=yield bv();t instanceof n&&!(r!=null&&r.noResolveJson)?t.json().then(s=>{const i=t.status||500,a=(s==null?void 0:s.statusCode)||i+"";e(new $0(ro(s),i,a))}).catch(s=>{e(new qi(ro(s),s))}):e(new qi(ro(t),t))}),Sv=(t,e,r,n)=>{const s={method:t,headers:(e==null?void 0:e.headers)||{}};return t==="GET"||!n?s:(kv(n)?(s.headers=Object.assign({"Content-Type":"application/json"},e==null?void 0:e.headers),s.body=JSON.stringify(n)):s.body=n,e!=null&&e.duplex&&(s.duplex=e.duplex),Object.assign(Object.assign({},s),r))};function ks(t,e,r,n,s,i){return I(this,void 0,void 0,function*(){return new Promise((a,o)=>{t(r,Sv(e,n,s,i)).then(u=>{if(!u.ok)throw u;return n!=null&&n.noResolveJson?u:u.json()}).then(u=>a(u)).catch(u=>Ev(u,o,n))})})}function fs(t,e,r,n){return I(this,void 0,void 0,function*(){return ks(t,"GET",e,r,n)})}function ct(t,e,r,n,s){return I(this,void 0,void 0,function*(){return ks(t,"POST",e,n,s,r)})}function vl(t,e,r,n,s){return I(this,void 0,void 0,function*(){return ks(t,"PUT",e,n,s,r)})}function jv(t,e,r,n){return I(this,void 0,void 0,function*(){return ks(t,"HEAD",e,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}function _u(t,e,r,n,s){return I(this,void 0,void 0,function*(){return ks(t,"DELETE",e,n,s,r)})}class Nv{constructor(e,r){this.downloadFn=e,this.shouldThrowOnError=r}then(e,r){return this.execute().then(e,r)}execute(){return I(this,void 0,void 0,function*(){try{return{data:(yield this.downloadFn()).body,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(ae(e))return{data:null,error:e};throw e}})}}var B0;class Tv{constructor(e,r){this.downloadFn=e,this.shouldThrowOnError=r,this[B0]="BlobDownloadBuilder",this.promise=null}asStream(){return new Nv(this.downloadFn,this.shouldThrowOnError)}then(e,r){return this.getPromise().then(e,r)}catch(e){return this.getPromise().catch(e)}finally(e){return this.getPromise().finally(e)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}execute(){return I(this,void 0,void 0,function*(){try{return{data:yield(yield this.downloadFn()).blob(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(ae(e))return{data:null,error:e};throw e}})}}B0=Symbol.toStringTag;const Pv={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},ed={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class Cv{constructor(e,r={},n,s){this.shouldThrowOnError=!1,this.url=e,this.headers=r,this.bucketId=n,this.fetch=ku(s)}throwOnError(){return this.shouldThrowOnError=!0,this}uploadOrUpdate(e,r,n,s){return I(this,void 0,void 0,function*(){try{let i;const a=Object.assign(Object.assign({},ed),s);let o=Object.assign(Object.assign({},this.headers),e==="POST"&&{"x-upsert":String(a.upsert)});const u=a.metadata;typeof Blob<"u"&&n instanceof Blob?(i=new FormData,i.append("cacheControl",a.cacheControl),u&&i.append("metadata",this.encodeMetadata(u)),i.append("",n)):typeof FormData<"u"&&n instanceof FormData?(i=n,i.has("cacheControl")||i.append("cacheControl",a.cacheControl),u&&!i.has("metadata")&&i.append("metadata",this.encodeMetadata(u))):(i=n,o["cache-control"]=`max-age=${a.cacheControl}`,o["content-type"]=a.contentType,u&&(o["x-metadata"]=this.toBase64(this.encodeMetadata(u))),(typeof ReadableStream<"u"&&i instanceof ReadableStream||i&&typeof i=="object"&&"pipe"in i&&typeof i.pipe=="function")&&!a.duplex&&(a.duplex="half")),s!=null&&s.headers&&(o=Object.assign(Object.assign({},o),s.headers));const c=this._removeEmptyFolders(r),d=this._getFinalPath(c),h=yield(e=="PUT"?vl:ct)(this.fetch,`${this.url}/object/${d}`,i,Object.assign({headers:o},a!=null&&a.duplex?{duplex:a.duplex}:{}));return{data:{path:c,id:h.Id,fullPath:h.Key},error:null}}catch(i){if(this.shouldThrowOnError)throw i;if(ae(i))return{data:null,error:i};throw i}})}upload(e,r,n){return I(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,r,n)})}uploadToSignedUrl(e,r,n,s){return I(this,void 0,void 0,function*(){const i=this._removeEmptyFolders(e),a=this._getFinalPath(i),o=new URL(this.url+`/object/upload/sign/${a}`);o.searchParams.set("token",r);try{let u;const c=Object.assign({upsert:ed.upsert},s),d=Object.assign(Object.assign({},this.headers),{"x-upsert":String(c.upsert)});typeof Blob<"u"&&n instanceof Blob?(u=new FormData,u.append("cacheControl",c.cacheControl),u.append("",n)):typeof FormData<"u"&&n instanceof FormData?(u=n,u.append("cacheControl",c.cacheControl)):(u=n,d["cache-control"]=`max-age=${c.cacheControl}`,d["content-type"]=c.contentType);const h=yield vl(this.fetch,o.toString(),u,{headers:d});return{data:{path:i,fullPath:h.Key},error:null}}catch(u){if(this.shouldThrowOnError)throw u;if(ae(u))return{data:null,error:u};throw u}})}createSignedUploadUrl(e,r){return I(this,void 0,void 0,function*(){try{let n=this._getFinalPath(e);const s=Object.assign({},this.headers);r!=null&&r.upsert&&(s["x-upsert"]="true");const i=yield ct(this.fetch,`${this.url}/object/upload/sign/${n}`,{},{headers:s}),a=new URL(this.url+i.url),o=a.searchParams.get("token");if(!o)throw new bs("No token returned by API");return{data:{signedUrl:a.toString(),path:e,token:o},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(ae(n))return{data:null,error:n};throw n}})}update(e,r,n){return I(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,r,n)})}move(e,r,n){return I(this,void 0,void 0,function*(){try{return{data:yield ct(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:r,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(ae(s))return{data:null,error:s};throw s}})}copy(e,r,n){return I(this,void 0,void 0,function*(){try{return{data:{path:(yield ct(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:r,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers})).Key},error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(ae(s))return{data:null,error:s};throw s}})}createSignedUrl(e,r,n){return I(this,void 0,void 0,function*(){try{let s=this._getFinalPath(e),i=yield ct(this.fetch,`${this.url}/object/sign/${s}`,Object.assign({expiresIn:r},n!=null&&n.transform?{transform:n.transform}:{}),{headers:this.headers});const a=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return i={signedUrl:encodeURI(`${this.url}${i.signedURL}${a}`)},{data:i,error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(ae(s))return{data:null,error:s};throw s}})}createSignedUrls(e,r,n){return I(this,void 0,void 0,function*(){try{const s=yield ct(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:r,paths:e},{headers:this.headers}),i=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return{data:s.map(a=>Object.assign(Object.assign({},a),{signedUrl:a.signedURL?encodeURI(`${this.url}${a.signedURL}${i}`):null})),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(ae(s))return{data:null,error:s};throw s}})}download(e,r){const s=typeof(r==null?void 0:r.transform)<"u"?"render/image/authenticated":"object",i=this.transformOptsToQueryString((r==null?void 0:r.transform)||{}),a=i?`?${i}`:"",o=this._getFinalPath(e),u=()=>fs(this.fetch,`${this.url}/${s}/${o}${a}`,{headers:this.headers,noResolveJson:!0});return new Tv(u,this.shouldThrowOnError)}info(e){return I(this,void 0,void 0,function*(){const r=this._getFinalPath(e);try{const n=yield fs(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:yl(n),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(ae(n))return{data:null,error:n};throw n}})}exists(e){return I(this,void 0,void 0,function*(){const r=this._getFinalPath(e);try{return yield jv(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(ae(n)&&n instanceof qi){const s=n.originalError;if([400,404].includes(s==null?void 0:s.status))return{data:!1,error:n}}throw n}})}getPublicUrl(e,r){const n=this._getFinalPath(e),s=[],i=r!=null&&r.download?`download=${r.download===!0?"":r.download}`:"";i!==""&&s.push(i);const o=typeof(r==null?void 0:r.transform)<"u"?"render/image":"object",u=this.transformOptsToQueryString((r==null?void 0:r.transform)||{});u!==""&&s.push(u);let c=s.join("&");return c!==""&&(c=`?${c}`),{data:{publicUrl:encodeURI(`${this.url}/${o}/public/${n}${c}`)}}}remove(e){return I(this,void 0,void 0,function*(){try{return{data:yield _u(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ae(r))return{data:null,error:r};throw r}})}list(e,r,n){return I(this,void 0,void 0,function*(){try{const s=Object.assign(Object.assign(Object.assign({},Pv),r),{prefix:e||""});return{data:yield ct(this.fetch,`${this.url}/object/list/${this.bucketId}`,s,{headers:this.headers},n),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(ae(s))return{data:null,error:s};throw s}})}listV2(e,r){return I(this,void 0,void 0,function*(){try{const n=Object.assign({},e);return{data:yield ct(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,n,{headers:this.headers},r),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(ae(n))return{data:null,error:n};throw n}})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return typeof Buffer<"u"?Buffer.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e.replace(/^\/+/,"")}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){const r=[];return e.width&&r.push(`width=${e.width}`),e.height&&r.push(`height=${e.height}`),e.resize&&r.push(`resize=${e.resize}`),e.format&&r.push(`format=${e.format}`),e.quality&&r.push(`quality=${e.quality}`),r.join("&")}}const U0="2.86.2",H0={"X-Client-Info":`storage-js/${U0}`};class Av{constructor(e,r={},n,s){this.shouldThrowOnError=!1;const i=new URL(e);s!=null&&s.useNewHostname&&/supabase\.(co|in|red)$/.test(i.hostname)&&!i.hostname.includes("storage.supabase.")&&(i.hostname=i.hostname.replace("supabase.","storage.supabase.")),this.url=i.href.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},H0),r),this.fetch=ku(n)}throwOnError(){return this.shouldThrowOnError=!0,this}listBuckets(e){return I(this,void 0,void 0,function*(){try{const r=this.listBucketOptionsToQueryString(e);return{data:yield fs(this.fetch,`${this.url}/bucket${r}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ae(r))return{data:null,error:r};throw r}})}getBucket(e){return I(this,void 0,void 0,function*(){try{return{data:yield fs(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ae(r))return{data:null,error:r};throw r}})}createBucket(e){return I(this,arguments,void 0,function*(r,n={public:!1}){try{return{data:yield ct(this.fetch,`${this.url}/bucket`,{id:r,name:r,type:n.type,public:n.public,file_size_limit:n.fileSizeLimit,allowed_mime_types:n.allowedMimeTypes},{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(ae(s))return{data:null,error:s};throw s}})}updateBucket(e,r){return I(this,void 0,void 0,function*(){try{return{data:yield vl(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(ae(n))return{data:null,error:n};throw n}})}emptyBucket(e){return I(this,void 0,void 0,function*(){try{return{data:yield ct(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ae(r))return{data:null,error:r};throw r}})}deleteBucket(e){return I(this,void 0,void 0,function*(){try{return{data:yield _u(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ae(r))return{data:null,error:r};throw r}})}listBucketOptionsToQueryString(e){const r={};return e&&("limit"in e&&(r.limit=String(e.limit)),"offset"in e&&(r.offset=String(e.offset)),e.search&&(r.search=e.search),e.sortColumn&&(r.sortColumn=e.sortColumn),e.sortOrder&&(r.sortOrder=e.sortOrder)),Object.keys(r).length>0?"?"+new URLSearchParams(r).toString():""}}var ps=class extends Error{constructor(t,e){var r;super(t),this.name="IcebergError",this.status=e.status,this.icebergType=e.icebergType,this.icebergCode=e.icebergCode,this.details=e.details,this.isCommitStateUnknown=e.icebergType==="CommitStateUnknownException"||[500,502,504].includes(e.status)&&((r=e.icebergType)==null?void 0:r.includes("CommitState"))===!0}isNotFound(){return this.status===404}isConflict(){return this.status===409}isAuthenticationTimeout(){return this.status===419}};function Ov(t,e,r){const n=new URL(e,t);if(r)for(const[s,i]of Object.entries(r))i!==void 0&&n.searchParams.set(s,i);return n.toString()}async function Rv(t){return!t||t.type==="none"?{}:t.type==="bearer"?{Authorization:`Bearer ${t.token}`}:t.type==="header"?{[t.name]:t.value}:t.type==="custom"?await t.getHeaders():{}}function zv(t){const e=t.fetchImpl??globalThis.fetch;return{async request({method:r,path:n,query:s,body:i,headers:a}){const o=Ov(t.baseUrl,n,s),u=await Rv(t.auth),c=await e(o,{method:r,headers:{...i?{"Content-Type":"application/json"}:{},...u,...a},body:i?JSON.stringify(i):void 0}),d=await c.text(),h=(c.headers.get("content-type")||"").includes("application/json"),f=h&&d?JSON.parse(d):d;if(!c.ok){const y=h?f:void 0,w=y==null?void 0:y.error;throw new ps((w==null?void 0:w.message)??`Request failed with status ${c.status}`,{status:c.status,icebergType:w==null?void 0:w.type,icebergCode:w==null?void 0:w.code,details:y})}return{status:c.status,headers:c.headers,data:f}}}}function Js(t){return t.join("")}var Iv=class{constructor(t,e=""){this.client=t,this.prefix=e}async listNamespaces(t){const e=t?{parent:Js(t.namespace)}:void 0;return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces`,query:e})).data.namespaces.map(n=>({namespace:n}))}async createNamespace(t,e){const r={namespace:t.namespace,properties:e==null?void 0:e.properties};return(await this.client.request({method:"POST",path:`${this.prefix}/namespaces`,body:r})).data}async dropNamespace(t){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${Js(t.namespace)}`})}async loadNamespaceMetadata(t){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Js(t.namespace)}`})).data.properties}}async namespaceExists(t){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${Js(t.namespace)}`}),!0}catch(e){if(e instanceof ps&&e.status===404)return!1;throw e}}async createNamespaceIfNotExists(t,e){try{return await this.createNamespace(t,e)}catch(r){if(r instanceof ps&&r.status===409)return;throw r}}};function Rr(t){return t.join("")}var Lv=class{constructor(t,e="",r){this.client=t,this.prefix=e,this.accessDelegation=r}async listTables(t){return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Rr(t.namespace)}/tables`})).data.identifiers}async createTable(t,e){const r={};return this.accessDelegation&&(r["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${Rr(t.namespace)}/tables`,body:e,headers:r})).data.metadata}async updateTable(t,e){const r=await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${Rr(t.namespace)}/tables/${t.name}`,body:e});return{"metadata-location":r.data["metadata-location"],metadata:r.data.metadata}}async dropTable(t,e){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${Rr(t.namespace)}/tables/${t.name}`,query:{purgeRequested:String((e==null?void 0:e.purge)??!1)}})}async loadTable(t){const e={};return this.accessDelegation&&(e["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Rr(t.namespace)}/tables/${t.name}`,headers:e})).data.metadata}async tableExists(t){const e={};this.accessDelegation&&(e["X-Iceberg-Access-Delegation"]=this.accessDelegation);try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${Rr(t.namespace)}/tables/${t.name}`,headers:e}),!0}catch(r){if(r instanceof ps&&r.status===404)return!1;throw r}}async createTableIfNotExists(t,e){try{return await this.createTable(t,e)}catch(r){if(r instanceof ps&&r.status===409)return await this.loadTable({namespace:t.namespace,name:e.name});throw r}}},Dv=class{constructor(t){var n;let e="v1";t.catalogName&&(e+=`/${t.catalogName}`);const r=t.baseUrl.endsWith("/")?t.baseUrl:`${t.baseUrl}/`;this.client=zv({baseUrl:r,auth:t.auth,fetchImpl:t.fetch}),this.accessDelegation=(n=t.accessDelegation)==null?void 0:n.join(","),this.namespaceOps=new Iv(this.client,e),this.tableOps=new Lv(this.client,e,this.accessDelegation)}async listNamespaces(t){return this.namespaceOps.listNamespaces(t)}async createNamespace(t,e){return this.namespaceOps.createNamespace(t,e)}async dropNamespace(t){await this.namespaceOps.dropNamespace(t)}async loadNamespaceMetadata(t){return this.namespaceOps.loadNamespaceMetadata(t)}async listTables(t){return this.tableOps.listTables(t)}async createTable(t,e){return this.tableOps.createTable(t,e)}async updateTable(t,e){return this.tableOps.updateTable(t,e)}async dropTable(t,e){await this.tableOps.dropTable(t,e)}async loadTable(t){return this.tableOps.loadTable(t)}async namespaceExists(t){return this.namespaceOps.namespaceExists(t)}async tableExists(t){return this.tableOps.tableExists(t)}async createNamespaceIfNotExists(t,e){return this.namespaceOps.createNamespaceIfNotExists(t,e)}async createTableIfNotExists(t,e){return this.tableOps.createTableIfNotExists(t,e)}};class V0{constructor(e,r={},n){this.shouldThrowOnError=!1,this.url=e.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},H0),r),this.fetch=ku(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(e){return I(this,void 0,void 0,function*(){try{return{data:yield ct(this.fetch,`${this.url}/bucket`,{name:e},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ae(r))return{data:null,error:r};throw r}})}listBuckets(e){return I(this,void 0,void 0,function*(){try{const r=new URLSearchParams;(e==null?void 0:e.limit)!==void 0&&r.set("limit",e.limit.toString()),(e==null?void 0:e.offset)!==void 0&&r.set("offset",e.offset.toString()),e!=null&&e.sortColumn&&r.set("sortColumn",e.sortColumn),e!=null&&e.sortOrder&&r.set("sortOrder",e.sortOrder),e!=null&&e.search&&r.set("search",e.search);const n=r.toString(),s=n?`${this.url}/bucket?${n}`:`${this.url}/bucket`;return{data:yield fs(this.fetch,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ae(r))return{data:null,error:r};throw r}})}deleteBucket(e){return I(this,void 0,void 0,function*(){try{return{data:yield _u(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ae(r))return{data:null,error:r};throw r}})}from(e){if(!_v(e))throw new bs("Invalid bucket name: File, folder, and bucket names must follow AWS object key naming guidelines and should avoid the use of any other characters.");return new Dv({baseUrl:this.url,catalogName:e,auth:{type:"custom",getHeaders:()=>I(this,void 0,void 0,function*(){return this.headers})},fetch:this.fetch})}}const Eu={"X-Client-Info":`storage-js/${U0}`,"Content-Type":"application/json"};class Su extends Error{constructor(e){super(e),this.__isStorageVectorsError=!0,this.name="StorageVectorsError"}}function $e(t){return typeof t=="object"&&t!==null&&"__isStorageVectorsError"in t}class pi extends Su{constructor(e,r,n){super(e),this.name="StorageVectorsApiError",this.status=r,this.statusCode=n}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class W0 extends Su{constructor(e,r){super(e),this.name="StorageVectorsUnknownError",this.originalError=r}}var wl;(function(t){t.InternalError="InternalError",t.S3VectorConflictException="S3VectorConflictException",t.S3VectorNotFoundException="S3VectorNotFoundException",t.S3VectorBucketNotEmpty="S3VectorBucketNotEmpty",t.S3VectorMaxBucketsExceeded="S3VectorMaxBucketsExceeded",t.S3VectorMaxIndexesExceeded="S3VectorMaxIndexesExceeded"})(wl||(wl={}));const va=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),Mv=()=>Response,K0=t=>{if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},Fv=t=>Array.from(new Float32Array(t)),$v=(t,e)=>{if(e!==void 0&&t.float32.length!==e)throw new Error(`Vector dimension mismatch: expected ${e}, got ${t.float32.length}`)},td=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),Bv=(t,e,r)=>I(void 0,void 0,void 0,function*(){if(t&&typeof t=="object"&&"status"in t&&"ok"in t&&typeof t.status=="number"&&!(r!=null&&r.noResolveJson)){const s=t.status||500,i=t;if(typeof i.json=="function")i.json().then(a=>{const o=(a==null?void 0:a.statusCode)||(a==null?void 0:a.code)||s+"";e(new pi(td(a),s,o))}).catch(()=>{const a=s+"",o=i.statusText||`HTTP ${s} error`;e(new pi(o,s,a))});else{const a=s+"",o=i.statusText||`HTTP ${s} error`;e(new pi(o,s,a))}}else e(new W0(td(t),t))}),Uv=(t,e,r,n)=>{const s={method:t,headers:(e==null?void 0:e.headers)||{}};return n?(K0(n)?(s.headers=Object.assign({"Content-Type":"application/json"},e==null?void 0:e.headers),s.body=JSON.stringify(n)):s.body=n,Object.assign(Object.assign({},s),r)):s};function Hv(t,e,r,n,s,i){return I(this,void 0,void 0,function*(){return new Promise((a,o)=>{t(r,Uv(e,n,s,i)).then(u=>{if(!u.ok)throw u;if(n!=null&&n.noResolveJson)return u;const c=u.headers.get("content-type");return!c||!c.includes("application/json")?{}:u.json()}).then(u=>a(u)).catch(u=>Bv(u,o,n))})})}function Ge(t,e,r,n,s){return I(this,void 0,void 0,function*(){return Hv(t,"POST",e,n,s,r)})}class q0{constructor(e,r={},n){this.shouldThrowOnError=!1,this.url=e.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},Eu),r),this.fetch=va(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createIndex(e){return I(this,void 0,void 0,function*(){try{return{data:(yield Ge(this.fetch,`${this.url}/CreateIndex`,e,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if($e(r))return{data:null,error:r};throw r}})}getIndex(e,r){return I(this,void 0,void 0,function*(){try{return{data:yield Ge(this.fetch,`${this.url}/GetIndex`,{vectorBucketName:e,indexName:r},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if($e(n))return{data:null,error:n};throw n}})}listIndexes(e){return I(this,void 0,void 0,function*(){try{return{data:yield Ge(this.fetch,`${this.url}/ListIndexes`,e,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if($e(r))return{data:null,error:r};throw r}})}deleteIndex(e,r){return I(this,void 0,void 0,function*(){try{return{data:(yield Ge(this.fetch,`${this.url}/DeleteIndex`,{vectorBucketName:e,indexName:r},{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if($e(n))return{data:null,error:n};throw n}})}}class G0{constructor(e,r={},n){this.shouldThrowOnError=!1,this.url=e.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},Eu),r),this.fetch=va(n)}throwOnError(){return this.shouldThrowOnError=!0,this}putVectors(e){return I(this,void 0,void 0,function*(){try{if(e.vectors.length<1||e.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return{data:(yield Ge(this.fetch,`${this.url}/PutVectors`,e,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if($e(r))return{data:null,error:r};throw r}})}getVectors(e){return I(this,void 0,void 0,function*(){try{return{data:yield Ge(this.fetch,`${this.url}/GetVectors`,e,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if($e(r))return{data:null,error:r};throw r}})}listVectors(e){return I(this,void 0,void 0,function*(){try{if(e.segmentCount!==void 0){if(e.segmentCount<1||e.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");if(e.segmentIndex!==void 0&&(e.segmentIndex<0||e.segmentIndex>=e.segmentCount))throw new Error(`segmentIndex must be between 0 and ${e.segmentCount-1}`)}return{data:yield Ge(this.fetch,`${this.url}/ListVectors`,e,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if($e(r))return{data:null,error:r};throw r}})}queryVectors(e){return I(this,void 0,void 0,function*(){try{return{data:yield Ge(this.fetch,`${this.url}/QueryVectors`,e,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if($e(r))return{data:null,error:r};throw r}})}deleteVectors(e){return I(this,void 0,void 0,function*(){try{if(e.keys.length<1||e.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return{data:(yield Ge(this.fetch,`${this.url}/DeleteVectors`,e,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if($e(r))return{data:null,error:r};throw r}})}}class J0{constructor(e,r={},n){this.shouldThrowOnError=!1,this.url=e.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},Eu),r),this.fetch=va(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(e){return I(this,void 0,void 0,function*(){try{return{data:(yield Ge(this.fetch,`${this.url}/CreateVectorBucket`,{vectorBucketName:e},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if($e(r))return{data:null,error:r};throw r}})}getBucket(e){return I(this,void 0,void 0,function*(){try{return{data:yield Ge(this.fetch,`${this.url}/GetVectorBucket`,{vectorBucketName:e},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if($e(r))return{data:null,error:r};throw r}})}listBuckets(){return I(this,arguments,void 0,function*(e={}){try{return{data:yield Ge(this.fetch,`${this.url}/ListVectorBuckets`,e,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if($e(r))return{data:null,error:r};throw r}})}deleteBucket(e){return I(this,void 0,void 0,function*(){try{return{data:(yield Ge(this.fetch,`${this.url}/DeleteVectorBucket`,{vectorBucketName:e},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if($e(r))return{data:null,error:r};throw r}})}}class Q0 extends J0{constructor(e,r={}){super(e,r.headers||{},r.fetch)}from(e){return new Y0(this.url,this.headers,e,this.fetch)}createBucket(e){const r=Object.create(null,{createBucket:{get:()=>super.createBucket}});return I(this,void 0,void 0,function*(){return r.createBucket.call(this,e)})}getBucket(e){const r=Object.create(null,{getBucket:{get:()=>super.getBucket}});return I(this,void 0,void 0,function*(){return r.getBucket.call(this,e)})}listBuckets(){const e=Object.create(null,{listBuckets:{get:()=>super.listBuckets}});return I(this,arguments,void 0,function*(r={}){return e.listBuckets.call(this,r)})}deleteBucket(e){const r=Object.create(null,{deleteBucket:{get:()=>super.deleteBucket}});return I(this,void 0,void 0,function*(){return r.deleteBucket.call(this,e)})}}class Y0 extends q0{constructor(e,r,n,s){super(e,r,s),this.vectorBucketName=n}createIndex(e){const r=Object.create(null,{createIndex:{get:()=>super.createIndex}});return I(this,void 0,void 0,function*(){return r.createIndex.call(this,Object.assign(Object.assign({},e),{vectorBucketName:this.vectorBucketName}))})}listIndexes(){const e=Object.create(null,{listIndexes:{get:()=>super.listIndexes}});return I(this,arguments,void 0,function*(r={}){return e.listIndexes.call(this,Object.assign(Object.assign({},r),{vectorBucketName:this.vectorBucketName}))})}getIndex(e){const r=Object.create(null,{getIndex:{get:()=>super.getIndex}});return I(this,void 0,void 0,function*(){return r.getIndex.call(this,this.vectorBucketName,e)})}deleteIndex(e){const r=Object.create(null,{deleteIndex:{get:()=>super.deleteIndex}});return I(this,void 0,void 0,function*(){return r.deleteIndex.call(this,this.vectorBucketName,e)})}index(e){return new Z0(this.url,this.headers,this.vectorBucketName,e,this.fetch)}}class Z0 extends G0{constructor(e,r,n,s,i){super(e,r,i),this.vectorBucketName=n,this.indexName=s}putVectors(e){const r=Object.create(null,{putVectors:{get:()=>super.putVectors}});return I(this,void 0,void 0,function*(){return r.putVectors.call(this,Object.assign(Object.assign({},e),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}getVectors(e){const r=Object.create(null,{getVectors:{get:()=>super.getVectors}});return I(this,void 0,void 0,function*(){return r.getVectors.call(this,Object.assign(Object.assign({},e),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}listVectors(){const e=Object.create(null,{listVectors:{get:()=>super.listVectors}});return I(this,arguments,void 0,function*(r={}){return e.listVectors.call(this,Object.assign(Object.assign({},r),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}queryVectors(e){const r=Object.create(null,{queryVectors:{get:()=>super.queryVectors}});return I(this,void 0,void 0,function*(){return r.queryVectors.call(this,Object.assign(Object.assign({},e),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}deleteVectors(e){const r=Object.create(null,{deleteVectors:{get:()=>super.deleteVectors}});return I(this,void 0,void 0,function*(){return r.deleteVectors.call(this,Object.assign(Object.assign({},e),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}}class Vv extends Av{constructor(e,r={},n,s){super(e,r,n,s)}from(e){return new Cv(this.url,this.headers,e,this.fetch)}get vectors(){return new Q0(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new V0(this.url+"/iceberg",this.headers,this.fetch)}}const Wv=Object.freeze(Object.defineProperty({__proto__:null,StorageAnalyticsClient:V0,StorageApiError:$0,StorageClient:Vv,StorageError:bs,StorageUnknownError:qi,StorageVectorsApiError:pi,StorageVectorsClient:Q0,StorageVectorsError:Su,get StorageVectorsErrorCode(){return wl},StorageVectorsUnknownError:W0,VectorBucketApi:J0,VectorBucketScope:Y0,VectorDataApi:G0,VectorIndexApi:q0,VectorIndexScope:Z0,isPlainObject:K0,isStorageError:ae,isStorageVectorsError:$e,normalizeToFloat32:Fv,resolveFetch:va,resolveResponse:Mv,validateVectorDimension:$v},Symbol.toStringTag,{value:"Module"})),Kv=gs(Wv);var X0={},wa={};Object.defineProperty(wa,"__esModule",{value:!0});wa.version=void 0;wa.version="2.86.2";(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_REALTIME_OPTIONS=t.DEFAULT_AUTH_OPTIONS=t.DEFAULT_DB_OPTIONS=t.DEFAULT_GLOBAL_OPTIONS=t.DEFAULT_HEADERS=void 0;const e=wa;let r="";typeof Deno<"u"?r="deno":typeof document<"u"?r="web":typeof navigator<"u"&&navigator.product==="ReactNative"?r="react-native":r="node",t.DEFAULT_HEADERS={"X-Client-Info":`supabase-js-${r}/${e.version}`},t.DEFAULT_GLOBAL_OPTIONS={headers:t.DEFAULT_HEADERS},t.DEFAULT_DB_OPTIONS={schema:"public"},t.DEFAULT_AUTH_OPTIONS={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},t.DEFAULT_REALTIME_OPTIONS={}})(X0);var ep={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.fetchWithAuth=t.resolveHeadersConstructor=t.resolveFetch=void 0;const e=s=>s?(...i)=>s(...i):(...i)=>fetch(...i);t.resolveFetch=e;const r=()=>Headers;t.resolveHeadersConstructor=r;const n=(s,i,a)=>{const o=(0,t.resolveFetch)(a),u=(0,t.resolveHeadersConstructor)();return async(c,d)=>{var h;const f=(h=await i())!==null&&h!==void 0?h:s;let y=new u(d==null?void 0:d.headers);return y.has("apikey")||y.set("apikey",s),y.has("Authorization")||y.set("Authorization",`Bearer ${f}`),o(c,Object.assign(Object.assign({},d),{headers:y}))}};t.fetchWithAuth=n})(ep);var or={};Object.defineProperty(or,"__esModule",{value:!0});or.isBrowser=void 0;or.uuid=qv;or.ensureTrailingSlash=tp;or.applySettingDefaults=Jv;or.validateSupabaseUrl=Qv;function qv(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=Math.random()*16|0,r=t=="x"?e:e&3|8;return r.toString(16)})}function tp(t){return t.endsWith("/")?t:t+"/"}const Gv=()=>typeof window<"u";or.isBrowser=Gv;function Jv(t,e){var r,n;const{db:s,auth:i,realtime:a,global:o}=t,{db:u,auth:c,realtime:d,global:h}=e,f={db:Object.assign(Object.assign({},u),s),auth:Object.assign(Object.assign({},c),i),realtime:Object.assign(Object.assign({},d),a),storage:{},global:Object.assign(Object.assign(Object.assign({},h),o),{headers:Object.assign(Object.assign({},(r=h==null?void 0:h.headers)!==null&&r!==void 0?r:{}),(n=o==null?void 0:o.headers)!==null&&n!==void 0?n:{})}),accessToken:async()=>""};return t.accessToken?f.accessToken=t.accessToken:delete f.accessToken,f}function Qv(t){const e=t==null?void 0:t.trim();if(!e)throw new Error("supabaseUrl is required.");if(!e.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(tp(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var xa={};const rp="2.86.2",Dr=30*1e3,xl=3,no=xl*Dr,Yv="http://localhost:9999",Zv="supabase.auth.token",Xv={"X-Client-Info":`gotrue-js/${rp}`},bl="X-Supabase-Api-Version",np={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},e1=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,t1=10*60*1e3;let gn=class extends Error{constructor(e,r,n){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}};function D(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}let sp=class extends gn{constructor(e,r,n){super(e,r,n),this.name="AuthApiError",this.status=r,this.code=n}};function ip(t){return D(t)&&t.name==="AuthApiError"}let Vt=class extends gn{constructor(e,r){super(e),this.name="AuthUnknownError",this.originalError=r}},Mt=class extends gn{constructor(e,r,n,s){super(e,n,s),this.name=r,this.status=n}},Me=class extends Mt{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}};function ap(t){return D(t)&&t.name==="AuthSessionMissingError"}let fr=class extends Mt{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}},Ln=class extends Mt{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}},Dn=class extends Mt{constructor(e,r=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}};function op(t){return D(t)&&t.name==="AuthImplicitGrantRedirectError"}let kl=class extends Mt{constructor(e,r=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}},Gi=class extends Mt{constructor(e,r){super(e,"AuthRetryableFetchError",r,void 0)}};function gi(t){return D(t)&&t.name==="AuthRetryableFetchError"}let _l=class extends Mt{constructor(e,r,n){super(e,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}};function r1(t){return D(t)&&t.name==="AuthWeakPasswordError"}let Ji=class extends Mt{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}};const Qi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),rd=`
|
||
\r=`.split(""),n1=(()=>{const t=new Array(128);for(let e=0;e<t.length;e+=1)t[e]=-1;for(let e=0;e<rd.length;e+=1)t[rd[e].charCodeAt(0)]=-2;for(let e=0;e<Qi.length;e+=1)t[Qi[e].charCodeAt(0)]=e;return t})();function nd(t,e,r){if(t!==null)for(e.queue=e.queue<<8|t,e.queuedBits+=8;e.queuedBits>=6;){const n=e.queue>>e.queuedBits-6&63;r(Qi[n]),e.queuedBits-=6}else if(e.queuedBits>0)for(e.queue=e.queue<<6-e.queuedBits,e.queuedBits=6;e.queuedBits>=6;){const n=e.queue>>e.queuedBits-6&63;r(Qi[n]),e.queuedBits-=6}}function lp(t,e,r){const n=n1[t];if(n>-1)for(e.queue=e.queue<<6|n,e.queuedBits+=6;e.queuedBits>=8;)r(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(n===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function sd(t){const e=[],r=a=>{e.push(String.fromCodePoint(a))},n={utf8seq:0,codepoint:0},s={queue:0,queuedBits:0},i=a=>{a1(a,n,r)};for(let a=0;a<t.length;a+=1)lp(t.charCodeAt(a),s,i);return e.join("")}function s1(t,e){if(t<=127){e(t);return}else if(t<=2047){e(192|t>>6),e(128|t&63);return}else if(t<=65535){e(224|t>>12),e(128|t>>6&63),e(128|t&63);return}else if(t<=1114111){e(240|t>>18),e(128|t>>12&63),e(128|t>>6&63),e(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function i1(t,e){for(let r=0;r<t.length;r+=1){let n=t.charCodeAt(r);if(n>55295&&n<=56319){const s=(n-55296)*1024&65535;n=(t.charCodeAt(r+1)-56320&65535|s)+65536,r+=1}s1(n,e)}}function a1(t,e,r){if(e.utf8seq===0){if(t<=127){r(t);return}for(let n=1;n<6;n+=1)if(!(t>>7-n&1)){e.utf8seq=n;break}if(e.utf8seq===2)e.codepoint=t&31;else if(e.utf8seq===3)e.codepoint=t&15;else if(e.utf8seq===4)e.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|t&63,e.utf8seq-=1,e.utf8seq===0&&r(e.codepoint)}}function an(t){const e=[],r={queue:0,queuedBits:0},n=s=>{e.push(s)};for(let s=0;s<t.length;s+=1)lp(t.charCodeAt(s),r,n);return new Uint8Array(e)}function o1(t){const e=[];return i1(t,r=>e.push(r)),new Uint8Array(e)}function br(t){const e=[],r={queue:0,queuedBits:0},n=s=>{e.push(s)};return t.forEach(s=>nd(s,r,n)),nd(null,r,n),e.join("")}function l1(t){return Math.round(Date.now()/1e3)+t}function u1(){return Symbol("auth-callback")}const _e=()=>typeof window<"u"&&typeof document<"u",ur={tested:!1,writable:!1},up=()=>{if(!_e())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(ur.tested)return ur.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),ur.tested=!0,ur.writable=!0}catch{ur.tested=!0,ur.writable=!1}return ur.writable};function c1(t){const e={},r=new URL(t);if(r.hash&&r.hash[0]==="#")try{new URLSearchParams(r.hash.substring(1)).forEach((s,i)=>{e[i]=s})}catch{}return r.searchParams.forEach((n,s)=>{e[s]=n}),e}const cp=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),d1=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",Mr=async(t,e,r)=>{await t.setItem(e,JSON.stringify(r))},cr=async(t,e)=>{const r=await t.getItem(e);if(!r)return null;try{return JSON.parse(r)}catch{return r}},ke=async(t,e)=>{await t.removeItem(e)};class ba{constructor(){this.promise=new ba.promiseConstructor((e,r)=>{this.resolve=e,this.reject=r})}}ba.promiseConstructor=Promise;function so(t){const e=t.split(".");if(e.length!==3)throw new Ji("Invalid JWT structure");for(let n=0;n<e.length;n++)if(!e1.test(e[n]))throw new Ji("JWT not in base64url format");return{header:JSON.parse(sd(e[0])),payload:JSON.parse(sd(e[1])),signature:an(e[2]),raw:{header:e[0],payload:e[1]}}}async function h1(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}function f1(t,e){return new Promise((n,s)=>{(async()=>{for(let i=0;i<1/0;i++)try{const a=await t(i);if(!e(i,null,a)){n(a);return}}catch(a){if(!e(i,a)){s(a);return}}})()})}function p1(t){return("0"+t.toString(16)).substr(-2)}function g1(){const e=new Uint32Array(56);if(typeof crypto>"u"){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",n=r.length;let s="";for(let i=0;i<56;i++)s+=r.charAt(Math.floor(Math.random()*n));return s}return crypto.getRandomValues(e),Array.from(e,p1).join("")}async function m1(t){const r=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",r),s=new Uint8Array(n);return Array.from(s).map(i=>String.fromCharCode(i)).join("")}async function y1(t){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),t;const r=await m1(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function zr(t,e,r=!1){const n=g1();let s=n;r&&(s+="/PASSWORD_RECOVERY"),await Mr(t,`${e}-code-verifier`,s);const i=await y1(n);return[i,n===i?"plain":"s256"]}const v1=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function w1(t){const e=t.headers.get(bl);if(!e||!e.match(v1))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function x1(t){if(!t)throw new Error("Missing exp claim");const e=Math.floor(Date.now()/1e3);if(t<=e)throw new Error("JWT has expired")}function b1(t){switch(t){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const k1=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function Ir(t){if(!k1.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function io(){const t={};return new Proxy(t,{get:(e,r)=>{if(r==="__isUserNotAvailableProxy")return!0;if(typeof r=="symbol"){const n=r.toString();if(n==="Symbol(Symbol.toPrimitive)"||n==="Symbol(Symbol.toStringTag)"||n==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${r}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function _1(t,e){return new Proxy(t,{get:(r,n,s)=>{if(n==="__isInsecureUserWarningProxy")return!0;if(typeof n=="symbol"){const i=n.toString();if(i==="Symbol(Symbol.toPrimitive)"||i==="Symbol(Symbol.toStringTag)"||i==="Symbol(util.inspect.custom)"||i==="Symbol(nodejs.util.inspect.custom)")return Reflect.get(r,n,s)}return!e.value&&typeof n=="string"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),e.value=!0),Reflect.get(r,n,s)}})}function id(t){return JSON.parse(JSON.stringify(t))}const pr=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),E1=[502,503,504];async function ad(t){var e;if(!d1(t))throw new Gi(pr(t),0);if(E1.includes(t.status))throw new Gi(pr(t),t.status);let r;try{r=await t.json()}catch(i){throw new Vt(pr(i),i)}let n;const s=w1(t);if(s&&s.getTime()>=np["2024-01-01"].timestamp&&typeof r=="object"&&r&&typeof r.code=="string"?n=r.code:typeof r=="object"&&r&&typeof r.error_code=="string"&&(n=r.error_code),n){if(n==="weak_password")throw new _l(pr(r),t.status,((e=r.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(n==="session_not_found")throw new Me}else if(typeof r=="object"&&r&&typeof r.weak_password=="object"&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((i,a)=>i&&typeof a=="string",!0))throw new _l(pr(r),t.status,r.weak_password.reasons);throw new sp(pr(r),t.status||500,n)}const S1=(t,e,r,n)=>{const s={method:t,headers:(e==null?void 0:e.headers)||{}};return t==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e==null?void 0:e.headers),s.body=JSON.stringify(n),Object.assign(Object.assign({},s),r))};async function F(t,e,r,n){var s;const i=Object.assign({},n==null?void 0:n.headers);i[bl]||(i[bl]=np["2024-01-01"].name),n!=null&&n.jwt&&(i.Authorization=`Bearer ${n.jwt}`);const a=(s=n==null?void 0:n.query)!==null&&s!==void 0?s:{};n!=null&&n.redirectTo&&(a.redirect_to=n.redirectTo);const o=Object.keys(a).length?"?"+new URLSearchParams(a).toString():"",u=await j1(t,e,r+o,{headers:i,noResolveJson:n==null?void 0:n.noResolveJson},{},n==null?void 0:n.body);return n!=null&&n.xform?n==null?void 0:n.xform(u):{data:Object.assign({},u),error:null}}async function j1(t,e,r,n,s,i){const a=S1(e,n,s,i);let o;try{o=await t(r,Object.assign({},a))}catch(u){throw console.error(u),new Gi(pr(u),0)}if(o.ok||await ad(o),n!=null&&n.noResolveJson)return o;try{return await o.json()}catch(u){await ad(u)}}function lt(t){var e;let r=null;P1(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=l1(t.expires_in)));const n=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:r,user:n},error:null}}function od(t){const e=lt(t);return!e.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((r,n)=>r&&typeof n=="string",!0)&&(e.data.weak_password=t.weak_password),e}function Wt(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function N1(t){return{data:t,error:null}}function T1(t){const{action_link:e,email_otp:r,hashed_token:n,redirect_to:s,verification_type:i}=t,a=xn(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),o={action_link:e,email_otp:r,hashed_token:n,redirect_to:s,verification_type:i},u=Object.assign({},a);return{data:{properties:o,user:u},error:null}}function ld(t){return t}function P1(t){return t.access_token&&t.refresh_token&&t.expires_in}const mi=["global","local","others"];let ju=class{constructor({url:e="",headers:r={},fetch:n}){this.url=e,this.headers=r,this.fetch=cp(n),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),updateClient:this._updateOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)}}async signOut(e,r=mi[0]){if(mi.indexOf(r)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${mi.join(", ")}`);try{return await F(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(n){if(D(n))return{data:null,error:n};throw n}}async inviteUserByEmail(e,r={}){try{return await F(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:Wt})}catch(n){if(D(n))return{data:{user:null},error:n};throw n}}async generateLink(e){try{const{options:r}=e,n=xn(e,["options"]),s=Object.assign(Object.assign({},n),r);return"newEmail"in n&&(s.new_email=n==null?void 0:n.newEmail,delete s.newEmail),await F(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:T1,redirectTo:r==null?void 0:r.redirectTo})}catch(r){if(D(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(e){try{return await F(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:Wt})}catch(r){if(D(r))return{data:{user:null},error:r};throw r}}async listUsers(e){var r,n,s,i,a,o,u;try{const c={nextPage:null,lastPage:0,total:0},d=await F(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(r=e==null?void 0:e.page)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:"",per_page:(i=(s=e==null?void 0:e.perPage)===null||s===void 0?void 0:s.toString())!==null&&i!==void 0?i:""},xform:ld});if(d.error)throw d.error;const h=await d.json(),f=(a=d.headers.get("x-total-count"))!==null&&a!==void 0?a:0,y=(u=(o=d.headers.get("link"))===null||o===void 0?void 0:o.split(","))!==null&&u!==void 0?u:[];return y.length>0&&(y.forEach(w=>{const x=parseInt(w.split(";")[0].split("=")[1].substring(0,1)),b=JSON.parse(w.split(";")[1].split("=")[1]);c[`${b}Page`]=x}),c.total=parseInt(f)),{data:Object.assign(Object.assign({},h),c),error:null}}catch(c){if(D(c))return{data:{users:[]},error:c};throw c}}async getUserById(e){Ir(e);try{return await F(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:Wt})}catch(r){if(D(r))return{data:{user:null},error:r};throw r}}async updateUserById(e,r){Ir(e);try{return await F(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:r,headers:this.headers,xform:Wt})}catch(n){if(D(n))return{data:{user:null},error:n};throw n}}async deleteUser(e,r=!1){Ir(e);try{return await F(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:r},xform:Wt})}catch(n){if(D(n))return{data:{user:null},error:n};throw n}}async _listFactors(e){Ir(e.userId);try{const{data:r,error:n}=await F(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:s=>({data:{factors:s},error:null})});return{data:r,error:n}}catch(r){if(D(r))return{data:null,error:r};throw r}}async _deleteFactor(e){Ir(e.userId),Ir(e.id);try{return{data:await F(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(r){if(D(r))return{data:null,error:r};throw r}}async _listOAuthClients(e){var r,n,s,i,a,o,u;try{const c={nextPage:null,lastPage:0,total:0},d=await F(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(r=e==null?void 0:e.page)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:"",per_page:(i=(s=e==null?void 0:e.perPage)===null||s===void 0?void 0:s.toString())!==null&&i!==void 0?i:""},xform:ld});if(d.error)throw d.error;const h=await d.json(),f=(a=d.headers.get("x-total-count"))!==null&&a!==void 0?a:0,y=(u=(o=d.headers.get("link"))===null||o===void 0?void 0:o.split(","))!==null&&u!==void 0?u:[];return y.length>0&&(y.forEach(w=>{const x=parseInt(w.split(";")[0].split("=")[1].substring(0,1)),b=JSON.parse(w.split(";")[1].split("=")[1]);c[`${b}Page`]=x}),c.total=parseInt(f)),{data:Object.assign(Object.assign({},h),c),error:null}}catch(c){if(D(c))return{data:{clients:[]},error:c};throw c}}async _createOAuthClient(e){try{return await F(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(D(r))return{data:null,error:r};throw r}}async _getOAuthClient(e){try{return await F(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(D(r))return{data:null,error:r};throw r}}async _updateOAuthClient(e,r){try{return await F(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${e}`,{body:r,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(D(n))return{data:null,error:n};throw n}}async _deleteOAuthClient(e){try{return await F(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(D(r))return{data:null,error:r};throw r}}async _regenerateOAuthClientSecret(e){try{return await F(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(D(r))return{data:null,error:r};throw r}}};function ud(t={}){return{getItem:e=>t[e]||null,setItem:(e,r)=>{t[e]=r},removeItem:e=>{delete t[e]}}}const gr={debug:!!(globalThis&&up()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class Nu extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}let dp=class extends Nu{};class C1 extends Nu{}async function hp(t,e,r){gr.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const n=new globalThis.AbortController;return e>0&&setTimeout(()=>{n.abort(),gr.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},e),await Promise.resolve().then(()=>globalThis.navigator.locks.request(t,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:n.signal},async s=>{if(s){gr.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,s.name);try{return await r()}finally{gr.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,s.name)}}else{if(e===0)throw gr.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new dp(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(gr.debug)try{const i=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(i,null," "))}catch(i){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",i)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await r()}}))}const cd={};async function A1(t,e,r){var n;const s=(n=cd[t])!==null&&n!==void 0?n:Promise.resolve(),i=Promise.race([s.catch(()=>null),e>=0?new Promise((a,o)=>{setTimeout(()=>{o(new C1(`Acquring process lock with name "${t}" timed out`))},e)}):null].filter(a=>a)).catch(a=>{if(a&&a.isAcquireTimeout)throw a;return null}).then(async()=>await r());return cd[t]=i.catch(async a=>{if(a&&a.isAcquireTimeout)return await s,null;throw a}),await i}function O1(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}function fp(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function R1(t){return parseInt(t,16)}function z1(t){const e=new TextEncoder().encode(t);return"0x"+Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}function I1(t){var e;const{chainId:r,domain:n,expirationTime:s,issuedAt:i=new Date,nonce:a,notBefore:o,requestId:u,resources:c,scheme:d,uri:h,version:f}=t;{if(!Number.isInteger(r))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${r}`);if(!n)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(a&&a.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${a}`);if(!h)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(f!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${f}`);if(!((e=t.statement)===null||e===void 0)&&e.includes(`
|
||
`))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${t.statement}`)}const y=fp(t.address),w=d?`${d}://${n}`:n,x=t.statement?`${t.statement}
|
||
`:"",b=`${w} wants you to sign in with your Ethereum account:
|
||
${y}
|
||
|
||
${x}`;let p=`URI: ${h}
|
||
Version: ${f}
|
||
Chain ID: ${r}${a?`
|
||
Nonce: ${a}`:""}
|
||
Issued At: ${i.toISOString()}`;if(s&&(p+=`
|
||
Expiration Time: ${s.toISOString()}`),o&&(p+=`
|
||
Not Before: ${o.toISOString()}`),u&&(p+=`
|
||
Request ID: ${u}`),c){let m=`
|
||
Resources:`;for(const g of c){if(!g||typeof g!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${g}`);m+=`
|
||
- ${g}`}p+=m}return`${b}
|
||
${p}`}class ge extends Error{constructor({message:e,code:r,cause:n,name:s}){var i;super(e,{cause:n}),this.__isWebAuthnError=!0,this.name=(i=s??(n instanceof Error?n.name:void 0))!==null&&i!==void 0?i:"Unknown Error",this.code=r}}class Yi extends ge{constructor(e,r){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r,message:e}),this.name="WebAuthnUnknownError",this.originalError=r}}function L1({error:t,options:e}){var r,n,s;const{publicKey:i}=e;if(!i)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new ge({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((r=i.authenticatorSelection)===null||r===void 0?void 0:r.requireResidentKey)===!0)return new ge({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(e.mediation==="conditional"&&((n=i.authenticatorSelection)===null||n===void 0?void 0:n.userVerification)==="required")return new ge({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((s=i.authenticatorSelection)===null||s===void 0?void 0:s.userVerification)==="required")return new ge({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if(t.name==="InvalidStateError")return new ge({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new ge({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return i.pubKeyCredParams.filter(o=>o.type==="public-key").length===0?new ge({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new ge({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if(t.name==="SecurityError"){const a=window.location.hostname;if(pp(a)){if(i.rp.id!==a)return new ge({message:`The RP ID "${i.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new ge({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(i.user.id.byteLength<1||i.user.id.byteLength>64)return new ge({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if(t.name==="UnknownError")return new ge({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new ge({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function D1({error:t,options:e}){const{publicKey:r}=e;if(!r)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new ge({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new ge({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const n=window.location.hostname;if(pp(n)){if(r.rpId!==n)return new ge({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new ge({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new ge({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new ge({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class M1{createNewAbortSignal(){if(this.controller){const r=new Error("Cancelling existing WebAuthn API call for new one");r.name="AbortError",this.controller.abort(r)}const e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){const e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}const F1=new M1;function $1(t){if(!t)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(t);const{challenge:e,user:r,excludeCredentials:n}=t,s=xn(t,["challenge","user","excludeCredentials"]),i=an(e).buffer,a=Object.assign(Object.assign({},r),{id:an(r.id).buffer}),o=Object.assign(Object.assign({},s),{challenge:i,user:a});if(n&&n.length>0){o.excludeCredentials=new Array(n.length);for(let u=0;u<n.length;u++){const c=n[u];o.excludeCredentials[u]=Object.assign(Object.assign({},c),{id:an(c.id).buffer,type:c.type||"public-key",transports:c.transports})}}return o}function B1(t){if(!t)throw new Error("Credential request options are required");if(typeof PublicKeyCredential<"u"&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseRequestOptionsFromJSON=="function")return PublicKeyCredential.parseRequestOptionsFromJSON(t);const{challenge:e,allowCredentials:r}=t,n=xn(t,["challenge","allowCredentials"]),s=an(e).buffer,i=Object.assign(Object.assign({},n),{challenge:s});if(r&&r.length>0){i.allowCredentials=new Array(r.length);for(let a=0;a<r.length;a++){const o=r[a];i.allowCredentials[a]=Object.assign(Object.assign({},o),{id:an(o.id).buffer,type:o.type||"public-key",transports:o.transports})}}return i}function U1(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const r=t;return{id:t.id,rawId:t.id,response:{attestationObject:br(new Uint8Array(t.response.attestationObject)),clientDataJSON:br(new Uint8Array(t.response.clientDataJSON))},type:"public-key",clientExtensionResults:t.getClientExtensionResults(),authenticatorAttachment:(e=r.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function H1(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const r=t,n=t.getClientExtensionResults(),s=t.response;return{id:t.id,rawId:t.id,response:{authenticatorData:br(new Uint8Array(s.authenticatorData)),clientDataJSON:br(new Uint8Array(s.clientDataJSON)),signature:br(new Uint8Array(s.signature)),userHandle:s.userHandle?br(new Uint8Array(s.userHandle)):void 0},type:"public-key",clientExtensionResults:n,authenticatorAttachment:(e=r.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function pp(t){return t==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(t)}function dd(){var t,e;return!!(_e()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&typeof((t=navigator==null?void 0:navigator.credentials)===null||t===void 0?void 0:t.create)=="function"&&typeof((e=navigator==null?void 0:navigator.credentials)===null||e===void 0?void 0:e.get)=="function")}async function V1(t){try{const e=await navigator.credentials.create(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new Yi("Browser returned unexpected credential type",e)}:{data:null,error:new Yi("Empty credential response",e)}}catch(e){return{data:null,error:L1({error:e,options:t})}}}async function W1(t){try{const e=await navigator.credentials.get(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new Yi("Browser returned unexpected credential type",e)}:{data:null,error:new Yi("Empty credential response",e)}}catch(e){return{data:null,error:D1({error:e,options:t})}}}const K1={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},q1={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function Zi(...t){const e=s=>s!==null&&typeof s=="object"&&!Array.isArray(s),r=s=>s instanceof ArrayBuffer||ArrayBuffer.isView(s),n={};for(const s of t)if(s)for(const i in s){const a=s[i];if(a!==void 0)if(Array.isArray(a))n[i]=a;else if(r(a))n[i]=a;else if(e(a)){const o=n[i];e(o)?n[i]=Zi(o,a):n[i]=Zi(a)}else n[i]=a}return n}function G1(t,e){return Zi(K1,t,e||{})}function J1(t,e){return Zi(q1,t,e||{})}class Q1{constructor(e){this.client=e,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(e){return this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))}async _challenge({factorId:e,webauthn:r,friendlyName:n,signal:s},i){try{const{data:a,error:o}=await this.client.mfa.challenge({factorId:e,webauthn:r});if(!a)return{data:null,error:o};const u=s??F1.createNewAbortSignal();if(a.webauthn.type==="create"){const{user:c}=a.webauthn.credential_options.publicKey;c.name||(c.name=`${c.id}:${n}`),c.displayName||(c.displayName=c.name)}switch(a.webauthn.type){case"create":{const c=G1(a.webauthn.credential_options.publicKey,i==null?void 0:i.create),{data:d,error:h}=await V1({publicKey:c,signal:u});return d?{data:{factorId:e,challengeId:a.id,webauthn:{type:a.webauthn.type,credential_response:d}},error:null}:{data:null,error:h}}case"request":{const c=J1(a.webauthn.credential_options.publicKey,i==null?void 0:i.request),{data:d,error:h}=await W1(Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:c,signal:u}));return d?{data:{factorId:e,challengeId:a.id,webauthn:{type:a.webauthn.type,credential_response:d}},error:null}:{data:null,error:h}}}}catch(a){return D(a)?{data:null,error:a}:{data:null,error:new Vt("Unexpected error in challenge",a)}}}async _verify({challengeId:e,factorId:r,webauthn:n}){return this.client.mfa.verify({factorId:r,challengeId:e,webauthn:n})}async _authenticate({factorId:e,webauthn:{rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:n=typeof window<"u"?[window.location.origin]:void 0,signal:s}={}},i){if(!r)return{data:null,error:new gn("rpId is required for WebAuthn authentication")};try{if(!dd())return{data:null,error:new Vt("Browser does not support WebAuthn",null)};const{data:a,error:o}=await this.challenge({factorId:e,webauthn:{rpId:r,rpOrigins:n},signal:s},{request:i});if(!a)return{data:null,error:o};const{webauthn:u}=a;return this._verify({factorId:e,challengeId:a.challengeId,webauthn:{type:u.type,rpId:r,rpOrigins:n,credential_response:u.credential_response}})}catch(a){return D(a)?{data:null,error:a}:{data:null,error:new Vt("Unexpected error in authenticate",a)}}}async _register({friendlyName:e,webauthn:{rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:n=typeof window<"u"?[window.location.origin]:void 0,signal:s}={}},i){if(!r)return{data:null,error:new gn("rpId is required for WebAuthn registration")};try{if(!dd())return{data:null,error:new Vt("Browser does not support WebAuthn",null)};const{data:a,error:o}=await this._enroll({friendlyName:e});if(!a)return await this.client.mfa.listFactors().then(d=>{var h;return(h=d.data)===null||h===void 0?void 0:h.all.find(f=>f.factor_type==="webauthn"&&f.friendly_name===e&&f.status!=="unverified")}).then(d=>d?this.client.mfa.unenroll({factorId:d==null?void 0:d.id}):void 0),{data:null,error:o};const{data:u,error:c}=await this._challenge({factorId:a.id,friendlyName:a.friendly_name,webauthn:{rpId:r,rpOrigins:n},signal:s},{create:i});return u?this._verify({factorId:a.id,challengeId:u.challengeId,webauthn:{rpId:r,rpOrigins:n,type:u.webauthn.type,credential_response:u.webauthn.credential_response}}):{data:null,error:c}}catch(a){return D(a)?{data:null,error:a}:{data:null,error:new Vt("Unexpected error in register",a)}}}}O1();const Y1={url:Yv,storageKey:Zv,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:Xv,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1};async function hd(t,e,r){return await r()}const Lr={};let Tu=class El{get jwks(){var e,r;return(r=(e=Lr[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(e){Lr[this.storageKey]=Object.assign(Object.assign({},Lr[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,r;return(r=(e=Lr[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){Lr[this.storageKey]=Object.assign(Object.assign({},Lr[this.storageKey]),{cachedAt:e})}constructor(e){var r,n,s;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;const i=Object.assign(Object.assign({},Y1),e);if(this.storageKey=i.storageKey,this.instanceID=(r=El.nextInstanceID[this.storageKey])!==null&&r!==void 0?r:0,El.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!i.debug,typeof i.debug=="function"&&(this.logger=i.debug),this.instanceID>0&&_e()){const a=`${this._logPrefix()} Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.`;console.warn(a),this.logDebugMessages&&console.trace(a)}if(this.persistSession=i.persistSession,this.autoRefreshToken=i.autoRefreshToken,this.admin=new ju({url:i.url,headers:i.headers,fetch:i.fetch}),this.url=i.url,this.headers=i.headers,this.fetch=cp(i.fetch),this.lock=i.lock||hd,this.detectSessionInUrl=i.detectSessionInUrl,this.flowType=i.flowType,this.hasCustomAuthorizationHeader=i.hasCustomAuthorizationHeader,this.throwOnError=i.throwOnError,i.lock?this.lock=i.lock:_e()&&(!((n=globalThis==null?void 0:globalThis.navigator)===null||n===void 0)&&n.locks)?this.lock=hp:this.lock=hd,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this),webauthn:new Q1(this)},this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this),listGrants:this._listOAuthGrants.bind(this),revokeGrant:this._revokeOAuthGrant.bind(this)},this.persistSession?(i.storage?this.storage=i.storage:up()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=ud(this.memoryStorage)),i.userStorage&&(this.userStorage=i.userStorage)):(this.memoryStorage={},this.storage=ud(this.memoryStorage)),_e()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(a){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",a)}(s=this.broadcastChannel)===null||s===void 0||s.addEventListener("message",async a=>{this._debug("received broadcast notification from other tab or client",a),await this._notifyAllSubscribers(a.data.event,a.data.session,!1)})}this.initialize()}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${rp}) ${new Date().toISOString()}`}_debug(...e){return this.logDebugMessages&&this.logger(this._logPrefix(),...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var e;try{let r={},n="none";if(_e()&&(r=c1(window.location.href),this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce")),_e()&&this.detectSessionInUrl&&n!=="none"){const{data:s,error:i}=await this._getSessionFromURL(r,n);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),op(i)){const u=(e=i.details)===null||e===void 0?void 0:e.code;if(u==="identity_already_exists"||u==="identity_not_found"||u==="single_identity_not_deletable")return{error:i}}return await this._removeSession(),{error:i}}const{session:a,redirectType:o}=s;return this._debug("#_initialize()","detected session in URL",a,"redirect type",o),await this._saveSession(a),setTimeout(async()=>{o==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",a):await this._notifyAllSubscribers("SIGNED_IN",a)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(r){return D(r)?this._returnResult({error:r}):this._returnResult({error:new Vt("Unexpected error during initialization",r)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var r,n,s;try{const i=await F(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(n=(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.captchaToken}},xform:lt}),{data:a,error:o}=i;if(o||!a)return this._returnResult({data:{user:null,session:null},error:o});const u=a.session,c=a.user;return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",u)),this._returnResult({data:{user:c,session:u},error:null})}catch(i){if(D(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signUp(e){var r,n,s;try{let i;if("email"in e){const{email:d,password:h,options:f}=e;let y=null,w=null;this.flowType==="pkce"&&([y,w]=await zr(this.storage,this.storageKey)),i=await F(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:f==null?void 0:f.emailRedirectTo,body:{email:d,password:h,data:(r=f==null?void 0:f.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken},code_challenge:y,code_challenge_method:w},xform:lt})}else if("phone"in e){const{phone:d,password:h,options:f}=e;i=await F(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:d,password:h,data:(n=f==null?void 0:f.data)!==null&&n!==void 0?n:{},channel:(s=f==null?void 0:f.channel)!==null&&s!==void 0?s:"sms",gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken}},xform:lt})}else throw new Ln("You must provide either an email or phone number and a password");const{data:a,error:o}=i;if(o||!a)return await ke(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:o});const u=a.session,c=a.user;return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",u)),this._returnResult({data:{user:c,session:u},error:null})}catch(i){if(await ke(this.storage,`${this.storageKey}-code-verifier`),D(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signInWithPassword(e){try{let r;if("email"in e){const{email:i,password:a,options:o}=e;r=await F(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:i,password:a,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},xform:od})}else if("phone"in e){const{phone:i,password:a,options:o}=e;r=await F(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:i,password:a,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},xform:od})}else throw new Ln("You must provide either an email or phone number and a password");const{data:n,error:s}=r;if(s)return this._returnResult({data:{user:null,session:null},error:s});if(!n||!n.session||!n.user){const i=new fr;return this._returnResult({data:{user:null,session:null},error:i})}return n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),this._returnResult({data:Object.assign({user:n.user,session:n.session},n.weak_password?{weakPassword:n.weak_password}:null),error:s})}catch(r){if(D(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signInWithOAuth(e){var r,n,s,i;return await this._handleProviderSignIn(e.provider,{redirectTo:(r=e.options)===null||r===void 0?void 0:r.redirectTo,scopes:(n=e.options)===null||n===void 0?void 0:n.scopes,queryParams:(s=e.options)===null||s===void 0?void 0:s.queryParams,skipBrowserRedirect:(i=e.options)===null||i===void 0?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){const{chain:r}=e;switch(r){case"ethereum":return await this.signInWithEthereum(e);case"solana":return await this.signInWithSolana(e);default:throw new Error(`@supabase/auth-js: Unsupported chain "${r}"`)}}async signInWithEthereum(e){var r,n,s,i,a,o,u,c,d,h,f;let y,w;if("message"in e)y=e.message,w=e.signature;else{const{chain:x,wallet:b,statement:p,options:m}=e;let g;if(_e())if(typeof b=="object")g=b;else{const N=window;if("ethereum"in N&&typeof N.ethereum=="object"&&"request"in N.ethereum&&typeof N.ethereum.request=="function")g=N.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof b!="object"||!(m!=null&&m.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");g=b}const k=new URL((r=m==null?void 0:m.url)!==null&&r!==void 0?r:window.location.href),E=await g.request({method:"eth_requestAccounts"}).then(N=>N).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!E||E.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const S=fp(E[0]);let j=(n=m==null?void 0:m.signInWithEthereum)===null||n===void 0?void 0:n.chainId;if(!j){const N=await g.request({method:"eth_chainId"});j=R1(N)}const _={domain:k.host,address:S,statement:p,uri:k.href,version:"1",chainId:j,nonce:(s=m==null?void 0:m.signInWithEthereum)===null||s===void 0?void 0:s.nonce,issuedAt:(a=(i=m==null?void 0:m.signInWithEthereum)===null||i===void 0?void 0:i.issuedAt)!==null&&a!==void 0?a:new Date,expirationTime:(o=m==null?void 0:m.signInWithEthereum)===null||o===void 0?void 0:o.expirationTime,notBefore:(u=m==null?void 0:m.signInWithEthereum)===null||u===void 0?void 0:u.notBefore,requestId:(c=m==null?void 0:m.signInWithEthereum)===null||c===void 0?void 0:c.requestId,resources:(d=m==null?void 0:m.signInWithEthereum)===null||d===void 0?void 0:d.resources};y=I1(_),w=await g.request({method:"personal_sign",params:[z1(y),S]})}try{const{data:x,error:b}=await F(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:y,signature:w},!((h=e.options)===null||h===void 0)&&h.captchaToken?{gotrue_meta_security:{captcha_token:(f=e.options)===null||f===void 0?void 0:f.captchaToken}}:null),xform:lt});if(b)throw b;if(!x||!x.session||!x.user){const p=new fr;return this._returnResult({data:{user:null,session:null},error:p})}return x.session&&(await this._saveSession(x.session),await this._notifyAllSubscribers("SIGNED_IN",x.session)),this._returnResult({data:Object.assign({},x),error:b})}catch(x){if(D(x))return this._returnResult({data:{user:null,session:null},error:x});throw x}}async signInWithSolana(e){var r,n,s,i,a,o,u,c,d,h,f,y;let w,x;if("message"in e)w=e.message,x=e.signature;else{const{chain:b,wallet:p,statement:m,options:g}=e;let k;if(_e())if(typeof p=="object")k=p;else{const S=window;if("solana"in S&&typeof S.solana=="object"&&("signIn"in S.solana&&typeof S.solana.signIn=="function"||"signMessage"in S.solana&&typeof S.solana.signMessage=="function"))k=S.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof p!="object"||!(g!=null&&g.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");k=p}const E=new URL((r=g==null?void 0:g.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in k&&k.signIn){const S=await k.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},g==null?void 0:g.signInWithSolana),{version:"1",domain:E.host,uri:E.href}),m?{statement:m}:null));let j;if(Array.isArray(S)&&S[0]&&typeof S[0]=="object")j=S[0];else if(S&&typeof S=="object"&&"signedMessage"in S&&"signature"in S)j=S;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in j&&"signature"in j&&(typeof j.signedMessage=="string"||j.signedMessage instanceof Uint8Array)&&j.signature instanceof Uint8Array)w=typeof j.signedMessage=="string"?j.signedMessage:new TextDecoder().decode(j.signedMessage),x=j.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in k)||typeof k.signMessage!="function"||!("publicKey"in k)||typeof k!="object"||!k.publicKey||!("toBase58"in k.publicKey)||typeof k.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");w=[`${E.host} wants you to sign in with your Solana account:`,k.publicKey.toBase58(),...m?["",m,""]:[""],"Version: 1",`URI: ${E.href}`,`Issued At: ${(s=(n=g==null?void 0:g.signInWithSolana)===null||n===void 0?void 0:n.issuedAt)!==null&&s!==void 0?s:new Date().toISOString()}`,...!((i=g==null?void 0:g.signInWithSolana)===null||i===void 0)&&i.notBefore?[`Not Before: ${g.signInWithSolana.notBefore}`]:[],...!((a=g==null?void 0:g.signInWithSolana)===null||a===void 0)&&a.expirationTime?[`Expiration Time: ${g.signInWithSolana.expirationTime}`]:[],...!((o=g==null?void 0:g.signInWithSolana)===null||o===void 0)&&o.chainId?[`Chain ID: ${g.signInWithSolana.chainId}`]:[],...!((u=g==null?void 0:g.signInWithSolana)===null||u===void 0)&&u.nonce?[`Nonce: ${g.signInWithSolana.nonce}`]:[],...!((c=g==null?void 0:g.signInWithSolana)===null||c===void 0)&&c.requestId?[`Request ID: ${g.signInWithSolana.requestId}`]:[],...!((h=(d=g==null?void 0:g.signInWithSolana)===null||d===void 0?void 0:d.resources)===null||h===void 0)&&h.length?["Resources",...g.signInWithSolana.resources.map(j=>`- ${j}`)]:[]].join(`
|
||
`);const S=await k.signMessage(new TextEncoder().encode(w),"utf8");if(!S||!(S instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");x=S}}try{const{data:b,error:p}=await F(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:w,signature:br(x)},!((f=e.options)===null||f===void 0)&&f.captchaToken?{gotrue_meta_security:{captcha_token:(y=e.options)===null||y===void 0?void 0:y.captchaToken}}:null),xform:lt});if(p)throw p;if(!b||!b.session||!b.user){const m=new fr;return this._returnResult({data:{user:null,session:null},error:m})}return b.session&&(await this._saveSession(b.session),await this._notifyAllSubscribers("SIGNED_IN",b.session)),this._returnResult({data:Object.assign({},b),error:p})}catch(b){if(D(b))return this._returnResult({data:{user:null,session:null},error:b});throw b}}async _exchangeCodeForSession(e){const r=await cr(this.storage,`${this.storageKey}-code-verifier`),[n,s]=(r??"").split("/");try{const{data:i,error:a}=await F(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:n},xform:lt});if(await ke(this.storage,`${this.storageKey}-code-verifier`),a)throw a;if(!i||!i.session||!i.user){const o=new fr;return this._returnResult({data:{user:null,session:null,redirectType:null},error:o})}return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",i.session)),this._returnResult({data:Object.assign(Object.assign({},i),{redirectType:s??null}),error:a})}catch(i){if(await ke(this.storage,`${this.storageKey}-code-verifier`),D(i))return this._returnResult({data:{user:null,session:null,redirectType:null},error:i});throw i}}async signInWithIdToken(e){try{const{options:r,provider:n,token:s,access_token:i,nonce:a}=e,o=await F(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:n,id_token:s,access_token:i,nonce:a,gotrue_meta_security:{captcha_token:r==null?void 0:r.captchaToken}},xform:lt}),{data:u,error:c}=o;if(c)return this._returnResult({data:{user:null,session:null},error:c});if(!u||!u.session||!u.user){const d=new fr;return this._returnResult({data:{user:null,session:null},error:d})}return u.session&&(await this._saveSession(u.session),await this._notifyAllSubscribers("SIGNED_IN",u.session)),this._returnResult({data:u,error:c})}catch(r){if(D(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signInWithOtp(e){var r,n,s,i,a;try{if("email"in e){const{email:o,options:u}=e;let c=null,d=null;this.flowType==="pkce"&&([c,d]=await zr(this.storage,this.storageKey));const{error:h}=await F(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:o,data:(r=u==null?void 0:u.data)!==null&&r!==void 0?r:{},create_user:(n=u==null?void 0:u.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:u==null?void 0:u.captchaToken},code_challenge:c,code_challenge_method:d},redirectTo:u==null?void 0:u.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:h})}if("phone"in e){const{phone:o,options:u}=e,{data:c,error:d}=await F(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:o,data:(s=u==null?void 0:u.data)!==null&&s!==void 0?s:{},create_user:(i=u==null?void 0:u.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:u==null?void 0:u.captchaToken},channel:(a=u==null?void 0:u.channel)!==null&&a!==void 0?a:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:c==null?void 0:c.message_id},error:d})}throw new Ln("You must provide either an email or phone number.")}catch(o){if(await ke(this.storage,`${this.storageKey}-code-verifier`),D(o))return this._returnResult({data:{user:null,session:null},error:o});throw o}}async verifyOtp(e){var r,n;try{let s,i;"options"in e&&(s=(r=e.options)===null||r===void 0?void 0:r.redirectTo,i=(n=e.options)===null||n===void 0?void 0:n.captchaToken);const{data:a,error:o}=await F(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:s,xform:lt});if(o)throw o;if(!a)throw new Error("An error occurred on token verification.");const u=a.session,c=a.user;return u!=null&&u.access_token&&(await this._saveSession(u),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",u)),this._returnResult({data:{user:c,session:u},error:null})}catch(s){if(D(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async signInWithSSO(e){var r,n,s,i,a;try{let o=null,u=null;this.flowType==="pkce"&&([o,u]=await zr(this.storage,this.storageKey));const c=await F(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(n=(r=e.options)===null||r===void 0?void 0:r.redirectTo)!==null&&n!==void 0?n:void 0}),!((s=e==null?void 0:e.options)===null||s===void 0)&&s.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:o,code_challenge_method:u}),headers:this.headers,xform:N1});return!((i=c.data)===null||i===void 0)&&i.url&&_e()&&!(!((a=e.options)===null||a===void 0)&&a.skipBrowserRedirect)&&window.location.assign(c.data.url),this._returnResult(c)}catch(o){if(await ke(this.storage,`${this.storageKey}-code-verifier`),D(o))return this._returnResult({data:null,error:o});throw o}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:r},error:n}=e;if(n)throw n;if(!r)throw new Me;const{error:s}=await F(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return this._returnResult({data:{user:null,session:null},error:s})})}catch(e){if(D(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){try{const r=`${this.url}/resend`;if("email"in e){const{email:n,type:s,options:i}=e,{error:a}=await F(this.fetch,"POST",r,{headers:this.headers,body:{email:n,type:s,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}},redirectTo:i==null?void 0:i.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:a})}else if("phone"in e){const{phone:n,type:s,options:i}=e,{data:a,error:o}=await F(this.fetch,"POST",r,{headers:this.headers,body:{phone:n,type:s,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:a==null?void 0:a.message_id},error:o})}throw new Ln("You must provide either an email or phone number and a type")}catch(r){if(D(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async r=>r))}async _acquireLock(e,r){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),s=(async()=>(await n,await r()))();return this.pendingInLock.push((async()=>{try{await s}catch{}})()),s}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const n=r();for(this.pendingInLock.push((async()=>{try{await n}catch{}})()),await n;this.pendingInLock.length;){const s=[...this.pendingInLock];await Promise.all(s),this.pendingInLock.splice(0,s.length)}return await n}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const r=await this.__loadSession();return await e(r)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const r=await cr(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),r!==null&&(this._isValidSession(r)?e=r:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const n=e.expires_at?e.expires_at*1e3-Date.now()<no:!1;if(this._debug("#__loadSession()",`session has${n?"":" not"} expired`,"expires_at",e.expires_at),!n){if(this.userStorage){const a=await cr(this.userStorage,this.storageKey+"-user");a!=null&&a.user?e.user=a.user:e.user=io()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){const a={value:this.suppressGetSessionWarning};e.user=_1(e.user,a),a.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:e},error:null}}const{data:s,error:i}=await this._callRefreshToken(e.refresh_token);return i?this._returnResult({data:{session:null},error:i}):this._returnResult({data:{session:s},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;const r=await this._acquireLock(-1,async()=>await this._getUser());return r.data.user&&(this.suppressGetSessionWarning=!0),r}async _getUser(e){try{return e?await F(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:Wt}):await this._useSession(async r=>{var n,s,i;const{data:a,error:o}=r;if(o)throw o;return!(!((n=a.session)===null||n===void 0)&&n.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new Me}:await F(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(i=(s=a.session)===null||s===void 0?void 0:s.access_token)!==null&&i!==void 0?i:void 0,xform:Wt})})}catch(r){if(D(r))return ap(r)&&(await this._removeSession(),await ke(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:r});throw r}}async updateUser(e,r={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(e,r))}async _updateUser(e,r={}){try{return await this._useSession(async n=>{const{data:s,error:i}=n;if(i)throw i;if(!s.session)throw new Me;const a=s.session;let o=null,u=null;this.flowType==="pkce"&&e.email!=null&&([o,u]=await zr(this.storage,this.storageKey));const{data:c,error:d}=await F(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r==null?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:o,code_challenge_method:u}),jwt:a.access_token,xform:Wt});if(d)throw d;return a.user=c.user,await this._saveSession(a),await this._notifyAllSubscribers("USER_UPDATED",a),this._returnResult({data:{user:a.user},error:null})})}catch(n){if(await ke(this.storage,`${this.storageKey}-code-verifier`),D(n))return this._returnResult({data:{user:null},error:n});throw n}}async setSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new Me;const r=Date.now()/1e3;let n=r,s=!0,i=null;const{payload:a}=so(e.access_token);if(a.exp&&(n=a.exp,s=n<=r),s){const{data:o,error:u}=await this._callRefreshToken(e.refresh_token);if(u)return this._returnResult({data:{user:null,session:null},error:u});if(!o)return{data:{user:null,session:null},error:null};i=o}else{const{data:o,error:u}=await this._getUser(e.access_token);if(u)throw u;i={access_token:e.access_token,refresh_token:e.refresh_token,user:o.user,token_type:"bearer",expires_in:n-r,expires_at:n},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return this._returnResult({data:{user:i.user,session:i},error:null})}catch(r){if(D(r))return this._returnResult({data:{session:null,user:null},error:r});throw r}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async r=>{var n;if(!e){const{data:a,error:o}=r;if(o)throw o;e=(n=a.session)!==null&&n!==void 0?n:void 0}if(!(e!=null&&e.refresh_token))throw new Me;const{data:s,error:i}=await this._callRefreshToken(e.refresh_token);return i?this._returnResult({data:{user:null,session:null},error:i}):s?this._returnResult({data:{user:s.user,session:s},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(r){if(D(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async _getSessionFromURL(e,r){try{if(!_e())throw new Dn("No browser detected.");if(e.error||e.error_description||e.error_code)throw new Dn(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(r){case"implicit":if(this.flowType==="pkce")throw new kl("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new Dn("Not a valid implicit grant flow url.");break;default:}if(r==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new kl("No code detected.");const{data:m,error:g}=await this._exchangeCodeForSession(e.code);if(g)throw g;const k=new URL(window.location.href);return k.searchParams.delete("code"),window.history.replaceState(window.history.state,"",k.toString()),{data:{session:m.session,redirectType:null},error:null}}const{provider_token:n,provider_refresh_token:s,access_token:i,refresh_token:a,expires_in:o,expires_at:u,token_type:c}=e;if(!i||!o||!a||!c)throw new Dn("No session defined in URL");const d=Math.round(Date.now()/1e3),h=parseInt(o);let f=d+h;u&&(f=parseInt(u));const y=f-d;y*1e3<=Dr&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${y}s, should have been closer to ${h}s`);const w=f-h;d-w>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",w,f,d):d-w<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",w,f,d);const{data:x,error:b}=await this._getUser(i);if(b)throw b;const p={provider_token:n,provider_refresh_token:s,access_token:i,expires_in:h,expires_at:f,refresh_token:a,token_type:c,user:x.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:p,redirectType:e.type},error:null})}catch(n){if(D(n))return this._returnResult({data:{session:null,redirectType:null},error:n});throw n}}_isImplicitGrantCallback(e){return!!(e.access_token||e.error_description)}async _isPKCECallback(e){const r=await cr(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&r)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async r=>{var n;const{data:s,error:i}=r;if(i)return this._returnResult({error:i});const a=(n=s.session)===null||n===void 0?void 0:n.access_token;if(a){const{error:o}=await this.admin.signOut(a,e);if(o&&!(ip(o)&&(o.status===404||o.status===401||o.status===403)))return this._returnResult({error:o})}return e!=="others"&&(await this._removeSession(),await ke(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(e){const r=u1(),n={id:r,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",r),this.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,n),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(r)})))(),{data:{subscription:n}}}async _emitInitialSession(e){return await this._useSession(async r=>{var n,s;try{const{data:{session:i},error:a}=r;if(a)throw a;await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",i)),this._debug("INITIAL_SESSION","callback id",e,"session",i)}catch(i){await((s=this.stateChangeEmitters.get(e))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",i),console.error(i)}})}async resetPasswordForEmail(e,r={}){let n=null,s=null;this.flowType==="pkce"&&([n,s]=await zr(this.storage,this.storageKey,!0));try{return await F(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:n,code_challenge_method:s,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:r.redirectTo})}catch(i){if(await ke(this.storage,`${this.storageKey}-code-verifier`),D(i))return this._returnResult({data:null,error:i});throw i}}async getUserIdentities(){var e;try{const{data:r,error:n}=await this.getUser();if(n)throw n;return this._returnResult({data:{identities:(e=r.user.identities)!==null&&e!==void 0?e:[]},error:null})}catch(r){if(D(r))return this._returnResult({data:null,error:r});throw r}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var r;try{const{data:n,error:s}=await this._useSession(async i=>{var a,o,u,c,d;const{data:h,error:f}=i;if(f)throw f;const y=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(a=e.options)===null||a===void 0?void 0:a.redirectTo,scopes:(o=e.options)===null||o===void 0?void 0:o.scopes,queryParams:(u=e.options)===null||u===void 0?void 0:u.queryParams,skipBrowserRedirect:!0});return await F(this.fetch,"GET",y,{headers:this.headers,jwt:(d=(c=h.session)===null||c===void 0?void 0:c.access_token)!==null&&d!==void 0?d:void 0})});if(s)throw s;return _e()&&!(!((r=e.options)===null||r===void 0)&&r.skipBrowserRedirect)&&window.location.assign(n==null?void 0:n.url),this._returnResult({data:{provider:e.provider,url:n==null?void 0:n.url},error:null})}catch(n){if(D(n))return this._returnResult({data:{provider:e.provider,url:null},error:n});throw n}}async linkIdentityIdToken(e){return await this._useSession(async r=>{var n;try{const{error:s,data:{session:i}}=r;if(s)throw s;const{options:a,provider:o,token:u,access_token:c,nonce:d}=e,h=await F(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(n=i==null?void 0:i.access_token)!==null&&n!==void 0?n:void 0,body:{provider:o,id_token:u,access_token:c,nonce:d,link_identity:!0,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:lt}),{data:f,error:y}=h;return y?this._returnResult({data:{user:null,session:null},error:y}):!f||!f.session||!f.user?this._returnResult({data:{user:null,session:null},error:new fr}):(f.session&&(await this._saveSession(f.session),await this._notifyAllSubscribers("USER_UPDATED",f.session)),this._returnResult({data:f,error:y}))}catch(s){if(await ke(this.storage,`${this.storageKey}-code-verifier`),D(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}})}async unlinkIdentity(e){try{return await this._useSession(async r=>{var n,s;const{data:i,error:a}=r;if(a)throw a;return await F(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(s=(n=i.session)===null||n===void 0?void 0:n.access_token)!==null&&s!==void 0?s:void 0})})}catch(r){if(D(r))return this._returnResult({data:null,error:r});throw r}}async _refreshAccessToken(e){const r=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(r,"begin");try{const n=Date.now();return await f1(async s=>(s>0&&await h1(200*Math.pow(2,s-1)),this._debug(r,"refreshing attempt",s),await F(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:lt})),(s,i)=>{const a=200*Math.pow(2,s);return i&&gi(i)&&Date.now()+a-n<Dr})}catch(n){if(this._debug(r,"error",n),D(n))return this._returnResult({data:{session:null,user:null},error:n});throw n}finally{this._debug(r,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,r){const n=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:r.redirectTo,scopes:r.scopes,queryParams:r.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",r,"url",n),_e()&&!r.skipBrowserRedirect&&window.location.assign(n),{data:{provider:e,url:n},error:null}}async _recoverAndRefresh(){var e,r;const n="#_recoverAndRefresh()";this._debug(n,"begin");try{const s=await cr(this.storage,this.storageKey);if(s&&this.userStorage){let a=await cr(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!a&&(a={user:s.user},await Mr(this.userStorage,this.storageKey+"-user",a)),s.user=(e=a==null?void 0:a.user)!==null&&e!==void 0?e:io()}else if(s&&!s.user&&!s.user){const a=await cr(this.storage,this.storageKey+"-user");a&&(a!=null&&a.user)?(s.user=a.user,await ke(this.storage,this.storageKey+"-user"),await Mr(this.storage,this.storageKey,s)):s.user=io()}if(this._debug(n,"session from storage",s),!this._isValidSession(s)){this._debug(n,"session is not valid"),s!==null&&await this._removeSession();return}const i=((r=s.expires_at)!==null&&r!==void 0?r:1/0)*1e3-Date.now()<no;if(this._debug(n,`session has${i?"":" not"} expired with margin of ${no}s`),i){if(this.autoRefreshToken&&s.refresh_token){const{error:a}=await this._callRefreshToken(s.refresh_token);a&&(console.error(a),gi(a)||(this._debug(n,"refresh failed with a non-retryable error, removing the session",a),await this._removeSession()))}}else if(s.user&&s.user.__isUserNotAvailableProxy===!0)try{const{data:a,error:o}=await this._getUser(s.access_token);!o&&(a!=null&&a.user)?(s.user=a.user,await this._saveSession(s),await this._notifyAllSubscribers("SIGNED_IN",s)):this._debug(n,"could not get user data, skipping SIGNED_IN notification")}catch(a){console.error("Error getting user data:",a),this._debug(n,"error getting user data, skipping SIGNED_IN notification",a)}else await this._notifyAllSubscribers("SIGNED_IN",s)}catch(s){this._debug(n,"error",s),console.error(s);return}finally{this._debug(n,"end")}}async _callRefreshToken(e){var r,n;if(!e)throw new Me;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const s=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{this.refreshingDeferred=new ba;const{data:i,error:a}=await this._refreshAccessToken(e);if(a)throw a;if(!i.session)throw new Me;await this._saveSession(i.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",i.session);const o={data:i.session,error:null};return this.refreshingDeferred.resolve(o),o}catch(i){if(this._debug(s,"error",i),D(i)){const a={data:null,error:i};return gi(i)||await this._removeSession(),(r=this.refreshingDeferred)===null||r===void 0||r.resolve(a),a}throw(n=this.refreshingDeferred)===null||n===void 0||n.reject(i),i}finally{this.refreshingDeferred=null,this._debug(s,"end")}}async _notifyAllSubscribers(e,r,n=!0){const s=`#_notifyAllSubscribers(${e})`;this._debug(s,"begin",r,`broadcast = ${n}`);try{this.broadcastChannel&&n&&this.broadcastChannel.postMessage({event:e,session:r});const i=[],a=Array.from(this.stateChangeEmitters.values()).map(async o=>{try{await o.callback(e,r)}catch(u){i.push(u)}});if(await Promise.all(a),i.length>0){for(let o=0;o<i.length;o+=1)console.error(i[o]);throw i[0]}}finally{this._debug(s,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await ke(this.storage,`${this.storageKey}-code-verifier`);const r=Object.assign({},e),n=r.user&&r.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!n&&r.user&&await Mr(this.userStorage,this.storageKey+"-user",{user:r.user});const s=Object.assign({},r);delete s.user;const i=id(s);await Mr(this.storage,this.storageKey,i)}else{const s=id(r);await Mr(this.storage,this.storageKey,s)}}async _removeSession(){this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await ke(this.storage,this.storageKey),await ke(this.storage,this.storageKey+"-code-verifier"),await ke(this.storage,this.storageKey+"-user"),this.userStorage&&await ke(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&_e()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}catch(r){console.error("removing visibilitychange callback failed",r)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),Dr);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async r=>{const{data:{session:n}}=r;if(!n||!n.refresh_token||!n.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const s=Math.floor((n.expires_at*1e3-e)/Dr);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts ${Dr}ms, refresh threshold is ${xl} ticks`),s<=xl&&await this._callRefreshToken(n.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof Nu)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!_e()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const r=`#_onVisibilityChanged(${e})`;this._debug(r,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(r,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,r,n){const s=[`provider=${encodeURIComponent(r)}`];if(n!=null&&n.redirectTo&&s.push(`redirect_to=${encodeURIComponent(n.redirectTo)}`),n!=null&&n.scopes&&s.push(`scopes=${encodeURIComponent(n.scopes)}`),this.flowType==="pkce"){const[i,a]=await zr(this.storage,this.storageKey),o=new URLSearchParams({code_challenge:`${encodeURIComponent(i)}`,code_challenge_method:`${encodeURIComponent(a)}`});s.push(o.toString())}if(n!=null&&n.queryParams){const i=new URLSearchParams(n.queryParams);s.push(i.toString())}return n!=null&&n.skipBrowserRedirect&&s.push(`skip_http_redirect=${n.skipBrowserRedirect}`),`${e}?${s.join("&")}`}async _unenroll(e){try{return await this._useSession(async r=>{var n;const{data:s,error:i}=r;return i?this._returnResult({data:null,error:i}):await F(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if(D(r))return this._returnResult({data:null,error:r});throw r}}async _enroll(e){try{return await this._useSession(async r=>{var n,s;const{data:i,error:a}=r;if(a)return this._returnResult({data:null,error:a});const o=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:e.factorType==="totp"?{issuer:e.issuer}:{}),{data:u,error:c}=await F(this.fetch,"POST",`${this.url}/factors`,{body:o,headers:this.headers,jwt:(n=i==null?void 0:i.session)===null||n===void 0?void 0:n.access_token});return c?this._returnResult({data:null,error:c}):(e.factorType==="totp"&&u.type==="totp"&&(!((s=u==null?void 0:u.totp)===null||s===void 0)&&s.qr_code)&&(u.totp.qr_code=`data:image/svg+xml;utf-8,${u.totp.qr_code}`),this._returnResult({data:u,error:null}))})}catch(r){if(D(r))return this._returnResult({data:null,error:r});throw r}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;const{data:s,error:i}=r;if(i)return this._returnResult({data:null,error:i});const a=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:e.webauthn.type==="create"?U1(e.webauthn.credential_response):H1(e.webauthn.credential_response)})}:{code:e.code}),{data:o,error:u}=await F(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:a,headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token});return u?this._returnResult({data:null,error:u}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+o.expires_in},o)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",o),this._returnResult({data:o,error:u}))})}catch(r){if(D(r))return this._returnResult({data:null,error:r});throw r}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;const{data:s,error:i}=r;if(i)return this._returnResult({data:null,error:i});const a=await F(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token});if(a.error)return a;const{data:o}=a;if(o.type!=="webauthn")return{data:o,error:null};switch(o.webauthn.type){case"create":return{data:Object.assign(Object.assign({},o),{webauthn:Object.assign(Object.assign({},o.webauthn),{credential_options:Object.assign(Object.assign({},o.webauthn.credential_options),{publicKey:$1(o.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},o),{webauthn:Object.assign(Object.assign({},o.webauthn),{credential_options:Object.assign(Object.assign({},o.webauthn.credential_options),{publicKey:B1(o.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(r){if(D(r))return this._returnResult({data:null,error:r});throw r}})}async _challengeAndVerify(e){const{data:r,error:n}=await this._challenge({factorId:e.factorId});return n?this._returnResult({data:null,error:n}):await this._verify({factorId:e.factorId,challengeId:r.id,code:e.code})}async _listFactors(){var e;const{data:{user:r},error:n}=await this.getUser();if(n)return{data:null,error:n};const s={all:[],phone:[],totp:[],webauthn:[]};for(const i of(e=r==null?void 0:r.factors)!==null&&e!==void 0?e:[])s.all.push(i),i.status==="verified"&&s[i.factor_type].push(i);return{data:s,error:null}}async _getAuthenticatorAssuranceLevel(){var e,r;const{data:{session:n},error:s}=await this.getSession();if(s)return this._returnResult({data:null,error:s});if(!n)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:i}=so(n.access_token);let a=null;i.aal&&(a=i.aal);let o=a;((r=(e=n.user.factors)===null||e===void 0?void 0:e.filter(d=>d.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(o="aal2");const c=i.amr||[];return{data:{currentLevel:a,nextLevel:o,currentAuthenticationMethods:c},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async r=>{const{data:{session:n},error:s}=r;return s?this._returnResult({data:null,error:s}):n?await F(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:n.access_token,xform:i=>({data:i,error:null})}):this._returnResult({data:null,error:new Me})})}catch(r){if(D(r))return this._returnResult({data:null,error:r});throw r}}async _approveAuthorization(e,r){try{return await this._useSession(async n=>{const{data:{session:s},error:i}=n;if(i)return this._returnResult({data:null,error:i});if(!s)return this._returnResult({data:null,error:new Me});const a=await F(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:s.access_token,body:{action:"approve"},xform:o=>({data:o,error:null})});return a.data&&a.data.redirect_url&&_e()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(a.data.redirect_url),a})}catch(n){if(D(n))return this._returnResult({data:null,error:n});throw n}}async _denyAuthorization(e,r){try{return await this._useSession(async n=>{const{data:{session:s},error:i}=n;if(i)return this._returnResult({data:null,error:i});if(!s)return this._returnResult({data:null,error:new Me});const a=await F(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:s.access_token,body:{action:"deny"},xform:o=>({data:o,error:null})});return a.data&&a.data.redirect_url&&_e()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(a.data.redirect_url),a})}catch(n){if(D(n))return this._returnResult({data:null,error:n});throw n}}async _listOAuthGrants(){try{return await this._useSession(async e=>{const{data:{session:r},error:n}=e;return n?this._returnResult({data:null,error:n}):r?await F(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:r.access_token,xform:s=>({data:s,error:null})}):this._returnResult({data:null,error:new Me})})}catch(e){if(D(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async r=>{const{data:{session:n},error:s}=r;return s?this._returnResult({data:null,error:s}):n?(await F(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:n.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new Me})})}catch(r){if(D(r))return this._returnResult({data:null,error:r});throw r}}async fetchJwk(e,r={keys:[]}){let n=r.keys.find(o=>o.kid===e);if(n)return n;const s=Date.now();if(n=this.jwks.keys.find(o=>o.kid===e),n&&this.jwks_cached_at+t1>s)return n;const{data:i,error:a}=await F(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(a)throw a;return!i.keys||i.keys.length===0||(this.jwks=i,this.jwks_cached_at=s,n=i.keys.find(o=>o.kid===e),!n)?null:n}async getClaims(e,r={}){try{let n=e;if(!n){const{data:y,error:w}=await this.getSession();if(w||!y.session)return this._returnResult({data:null,error:w});n=y.session.access_token}const{header:s,payload:i,signature:a,raw:{header:o,payload:u}}=so(n);r!=null&&r.allowExpired||x1(i.exp);const c=!s.alg||s.alg.startsWith("HS")||!s.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(s.kid,r!=null&&r.keys?{keys:r.keys}:r==null?void 0:r.jwks);if(!c){const{error:y}=await this.getUser(n);if(y)throw y;return{data:{claims:i,header:s,signature:a},error:null}}const d=b1(s.alg),h=await crypto.subtle.importKey("jwk",c,d,!0,["verify"]);if(!await crypto.subtle.verify(d,h,a,o1(`${o}.${u}`)))throw new Ji("Invalid JWT signature");return{data:{claims:i,header:s,signature:a},error:null}}catch(n){if(D(n))return this._returnResult({data:null,error:n});throw n}}};Tu.nextInstanceID={};const Z1=ju,X1=Tu,ew=Object.freeze(Object.defineProperty({__proto__:null,AuthAdminApi:Z1,AuthApiError:sp,AuthClient:X1,AuthError:gn,AuthImplicitGrantRedirectError:Dn,AuthInvalidCredentialsError:Ln,AuthInvalidJwtError:Ji,AuthInvalidTokenResponseError:fr,AuthPKCEGrantCodeExchangeError:kl,AuthRetryableFetchError:Gi,AuthSessionMissingError:Me,AuthUnknownError:Vt,AuthWeakPasswordError:_l,CustomAuthError:Mt,GoTrueAdminApi:ju,GoTrueClient:Tu,NavigatorLockAcquireTimeoutError:dp,SIGN_OUT_SCOPES:mi,isAuthApiError:ip,isAuthError:D,isAuthImplicitGrantRedirectError:op,isAuthRetryableFetchError:gi,isAuthSessionMissingError:ap,isAuthWeakPasswordError:r1,lockInternals:gr,navigatorLock:hp,processLock:A1},Symbol.toStringTag,{value:"Module"})),gp=gs(ew);Object.defineProperty(xa,"__esModule",{value:!0});xa.SupabaseAuthClient=void 0;const tw=gp;class rw extends tw.AuthClient{constructor(e){super(e)}}xa.SupabaseAuthClient=rw;Object.defineProperty(Hi,"__esModule",{value:!0});const nw=w0,sw=Ae,iw=F0,aw=Kv,Qs=X0,ow=ep,fd=or,lw=xa;let uw=class{constructor(e,r,n){var s,i,a;this.supabaseUrl=e,this.supabaseKey=r;const o=(0,fd.validateSupabaseUrl)(e);if(!r)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",o),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",o),this.storageUrl=new URL("storage/v1",o),this.functionsUrl=new URL("functions/v1",o);const u=`sb-${o.hostname.split(".")[0]}-auth-token`,c={db:Qs.DEFAULT_DB_OPTIONS,realtime:Qs.DEFAULT_REALTIME_OPTIONS,auth:Object.assign(Object.assign({},Qs.DEFAULT_AUTH_OPTIONS),{storageKey:u}),global:Qs.DEFAULT_GLOBAL_OPTIONS},d=(0,fd.applySettingDefaults)(n??{},c);this.storageKey=(s=d.auth.storageKey)!==null&&s!==void 0?s:"",this.headers=(i=d.global.headers)!==null&&i!==void 0?i:{},d.accessToken?(this.accessToken=d.accessToken,this.auth=new Proxy({},{get:(h,f)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(f)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((a=d.auth)!==null&&a!==void 0?a:{},this.headers,d.global.fetch),this.fetch=(0,ow.fetchWithAuth)(r,this._getAccessToken.bind(this),d.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},d.realtime)),this.accessToken&&this.accessToken().then(h=>this.realtime.setAuth(h)).catch(h=>console.warn("Failed to set initial Realtime auth token:",h)),this.rest=new sw.PostgrestClient(new URL("rest/v1",o).href,{headers:this.headers,schema:d.db.schema,fetch:this.fetch}),this.storage=new aw.StorageClient(this.storageUrl.href,this.headers,this.fetch,n==null?void 0:n.storage),d.accessToken||this._listenForAuthEvents()}get functions(){return new nw.FunctionsClient(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,r={},n={head:!1,get:!1,count:void 0}){return this.rest.rpc(e,r,n)}channel(e,r={config:{}}){return this.realtime.channel(e,r)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var e,r;if(this.accessToken)return await this.accessToken();const{data:n}=await this.auth.getSession();return(r=(e=n.session)===null||e===void 0?void 0:e.access_token)!==null&&r!==void 0?r:this.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:r,detectSessionInUrl:n,storage:s,userStorage:i,storageKey:a,flowType:o,lock:u,debug:c,throwOnError:d},h,f){const y={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new lw.SupabaseAuthClient({url:this.authUrl.href,headers:Object.assign(Object.assign({},y),h),storageKey:a,autoRefreshToken:e,persistSession:r,detectSessionInUrl:n,storage:s,userStorage:i,flowType:o,lock:u,debug:c,throwOnError:d,fetch:f,hasCustomAuthorizationHeader:Object.keys(this.headers).some(w=>w.toLowerCase()==="authorization")})}_initRealtimeClient(e){return new iw.RealtimeClient(this.realtimeUrl.href,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e==null?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((r,n)=>{this._handleTokenChanged(r,"CLIENT",n==null?void 0:n.access_token)})}_handleTokenChanged(e,r,n){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==n?(this.changedAccessToken=n,this.realtime.setAuth(n)):e==="SIGNED_OUT"&&(this.realtime.setAuth(),r=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};Hi.default=uw;(function(t){var e=Ar&&Ar.__createBinding||(Object.create?function(d,h,f,y){y===void 0&&(y=f);var w=Object.getOwnPropertyDescriptor(h,f);(!w||("get"in w?!h.__esModule:w.writable||w.configurable))&&(w={enumerable:!0,get:function(){return h[f]}}),Object.defineProperty(d,y,w)}:function(d,h,f,y){y===void 0&&(y=f),d[y]=h[f]}),r=Ar&&Ar.__exportStar||function(d,h){for(var f in d)f!=="default"&&!Object.prototype.hasOwnProperty.call(h,f)&&e(h,d,f)},n=Ar&&Ar.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(t,"__esModule",{value:!0}),t.createClient=t.SupabaseClient=t.FunctionRegion=t.FunctionsError=t.FunctionsRelayError=t.FunctionsFetchError=t.FunctionsHttpError=t.PostgrestError=void 0;const s=n(Hi);r(gp,t);var i=Ae;Object.defineProperty(t,"PostgrestError",{enumerable:!0,get:function(){return i.PostgrestError}});var a=w0;Object.defineProperty(t,"FunctionsHttpError",{enumerable:!0,get:function(){return a.FunctionsHttpError}}),Object.defineProperty(t,"FunctionsFetchError",{enumerable:!0,get:function(){return a.FunctionsFetchError}}),Object.defineProperty(t,"FunctionsRelayError",{enumerable:!0,get:function(){return a.FunctionsRelayError}}),Object.defineProperty(t,"FunctionsError",{enumerable:!0,get:function(){return a.FunctionsError}}),Object.defineProperty(t,"FunctionRegion",{enumerable:!0,get:function(){return a.FunctionRegion}}),r(F0,t);var o=Hi;Object.defineProperty(t,"SupabaseClient",{enumerable:!0,get:function(){return n(o).default}});const u=(d,h,f)=>new s.default(d,h,f);t.createClient=u;function c(){if(typeof window<"u"||typeof process>"u")return!1;const d=process.version;if(d==null)return!1;const h=d.match(/^v(\d+)\./);return h?parseInt(h[1],10)<=18:!1}c()&&console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217")})(wu);const mp=kd(wu),cw=jp({__proto__:null,default:mp},[wu]),{PostgrestError:O2,FunctionsHttpError:R2,FunctionsFetchError:z2,FunctionsRelayError:I2,FunctionsError:L2,FunctionRegion:D2,SupabaseClient:M2,createClient:dw,GoTrueAdminApi:F2,GoTrueClient:$2,AuthAdminApi:B2,AuthClient:U2,navigatorLock:H2,NavigatorLockAcquireTimeoutError:V2,lockInternals:W2,processLock:K2,SIGN_OUT_SCOPES:q2,AuthError:G2,AuthApiError:J2,AuthUnknownError:Q2,CustomAuthError:Y2,AuthSessionMissingError:Z2,AuthInvalidTokenResponseError:X2,AuthInvalidCredentialsError:ek,AuthImplicitGrantRedirectError:tk,AuthPKCEGrantCodeExchangeError:rk,AuthRetryableFetchError:nk,AuthWeakPasswordError:sk,AuthInvalidJwtError:ik,isAuthError:ak,isAuthApiError:ok,isAuthSessionMissingError:lk,isAuthImplicitGrantRedirectError:uk,isAuthRetryableFetchError:ck,isAuthWeakPasswordError:dk,RealtimePresence:hk,RealtimeChannel:fk,RealtimeClient:pk,REALTIME_LISTEN_TYPES:gk,REALTIME_POSTGRES_CHANGES_LISTEN_EVENT:mk,REALTIME_PRESENCE_LISTEN_EVENTS:yk,REALTIME_SUBSCRIBE_STATES:vk,REALTIME_CHANNEL_STATES:wk}=mp||cw,hw="https://vzudjibddwcvfdnyvhhs.supabase.co",fw="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZ6dWRqaWJkZHdjdmZkbnl2aGhzIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjUwMjk4MDksImV4cCI6MjA4MDYwNTgwOX0.wE8R1mpd2FY6m6d5-Hf3hlCG8OfeCkra6SjUvbt1mD0",V=dw(hw,fw),pw=t=>Array.isArray(t)?t.map(e=>({type:(e==null?void 0:e.type)||"task",title:(e==null?void 0:e.title)||"",durationMin:Number((e==null?void 0:e.durationMin)||0),repetitions:(e==null?void 0:e.repetitions)??null,intensity:(e==null?void 0:e.intensity)||null,instructions:(e==null?void 0:e.instructions)||""})):[],gw=t=>({weekNo:Number((t==null?void 0:t.weekNo)||(t==null?void 0:t.week_no)||1),sessionNo:Number((t==null?void 0:t.sessionNo)||(t==null?void 0:t.session_no)||1),mainExercise:(t==null?void 0:t.mainExercise)||(t==null?void 0:t.main_exercise)||"Basistechnik",secondaryExercises:Array.isArray(t==null?void 0:t.secondaryExercises)?t.secondaryExercises:Array.isArray(t==null?void 0:t.secondary_exercises)?t.secondary_exercises:[],tasks:pw(t==null?void 0:t.tasks),state:(t==null?void 0:t.state)||"open",notes:(t==null?void 0:t.notes)||""}),yp=async({patType:t,analysisSnapshot:e,durationWeeks:r,sessionsPerWeek:n,sessions:s})=>{if(!V)return{ok:!1,error:new Error("Supabase ist nicht konfiguriert.")};try{const i={p_pat_type:t,p_analysis_snapshot:e,p_duration_weeks:Number(r),p_sessions_per_week:Number(n),p_sessions:(s||[]).map(gw)},{data:a,error:o}=await V.rpc("create_training_plan_with_sessions",i);if(o)throw o;return{ok:!0,planId:a}}catch(i){return{ok:!1,error:i}}},pd=[0,1,0,2,0,1,0,1,2,0],gd=(t,e,r)=>e.includes(t)?t:r,mw=t=>t>=.7?"hoch":t>=.4?"mittel":"leicht",yw=()=>({type:"warmup",title:"Warm-up",durationMin:10,instructions:"Lockere Stoßserie, Fokus auf saubere Ansprechposition und Rhythmus."}),vw=(t,e)=>{const r={hoch:24,mittel:18,leicht:12};return{type:"main",title:`Hauptblock: ${t}`,durationMin:e==="hoch"?35:28,repetitions:r[e],intensity:e,instructions:"Dokumentiere Trefferquote pro Serie und halte Pausen kurz (30-45 Sek.)."}},md=(t,e)=>({type:"secondary",title:`Nebenblock ${e}: ${t}`,durationMin:18,repetitions:10,intensity:"mittel",instructions:"Konstanter Ablauf, Fokus auf Präzision statt Tempo."}),ww=()=>({type:"cooldown",title:"Cool-down",durationMin:8,instructions:"Kurze Reflexion: 2 Dinge die gut liefen, 1 Punkt für den nächsten Tag."}),xw=(t,e)=>{if(!e.length)return{name:"Generelle Basistechnik",gapScore:.3,priorityScore:.3};const n=pd[t%pd.length]%e.length;return e[n]},bw=(t,e,r)=>{const n=[...e.map(i=>i==null?void 0:i.name),...r.map(i=>i==null?void 0:i.name)].filter(Boolean),s=[...new Set(n)].filter(i=>i!==t);return s.length>=2?s.slice(0,2):s.length===1?[s[0],"Positionsspiel Basis"]:["Positionsspiel Basis","Stoßroutine Stabilisierung"]},Pu=({topWeaknesses:t=[],topStrengths:e=[],durationWeeks:r=4,sessionsPerWeek:n=3,sessionMix:s="1-main-2-secondary"}={})=>{const i=gd(Number(r),[2,4,6],4),a=gd(Number(n),[2,3,4],3),o=i*a,u=Array.from({length:o},(c,d)=>{const h=Math.floor(d/a)+1,f=d%a+1,y=xw(d,t),w=mw(Number((y==null?void 0:y.gapScore)||0)),x=bw(y==null?void 0:y.name,t,e),b=[yw(),vw((y==null?void 0:y.name)||"Basistechnik",w),md(x[0],1),md(x[1],2),ww()];return{weekNo:h,sessionNo:f,mainExercise:(y==null?void 0:y.name)||"Basistechnik",secondaryExercises:x,sessionMix:s,intensity:w,state:"open",notes:"",tasks:b,meta:{gapScore:Number((y==null?void 0:y.gapScore)||0),priorityScore:Number((y==null?void 0:y.priorityScore)||0)}}});return{durationWeeks:i,sessionsPerWeek:a,sessions:u}},kw=t=>({id:t.id,patType:t.pat_type,status:t.status,analysisSnapshot:t.analysis_snapshot||{},durationWeeks:t.duration_weeks,sessionsPerWeek:t.sessions_per_week,generatedAt:t.generated_at,archivedAt:t.archived_at,createdAt:t.created_at,updatedAt:t.updated_at,sessions:[]}),_w=t=>({id:t.id,planId:t.plan_id,weekNo:t.week_no,sessionNo:t.session_no,mainExercise:t.main_exercise,secondaryExercises:t.secondary_exercises||[],tasks:t.tasks||[],state:t.state||"open",notes:t.notes||"",completedAt:t.completed_at,createdAt:t.created_at,updatedAt:t.updated_at}),Ys=(t,e,r)=>!t||!t.sessions.some(s=>s.id===e)?t:{...t,sessions:t.sessions.map(s=>s.id===e?{...s,...r}:s)},Ew=({user:t,patType:e})=>{const[r,n]=T.useState(null),[s,i]=T.useState([]),[a,o]=T.useState(!1),[u,c]=T.useState(!1),[d,h]=T.useState(""),f=T.useMemo(()=>!!(V&&(t!=null&&t.id)),[t]),y=T.useCallback(async()=>{if(!f||!e){n(null),i([]);return}o(!0),h("");try{const{data:p,error:m}=await V.from("training_plans").select("*").eq("user_id",t.id).eq("pat_type",e).order("generated_at",{ascending:!1});if(m)throw m;const g=(p||[]).map(kw),k=g.map(N=>N.id);let E=new Map;if(k.length){const{data:N,error:C}=await V.from("training_plan_sessions").select("*").in("plan_id",k).order("week_no",{ascending:!0}).order("session_no",{ascending:!0});if(C)throw C;E=(N||[]).reduce((A,U)=>{const Y=_w(U),G=A.get(Y.planId)||[];return G.push(Y),A.set(Y.planId,G),A},new Map)}const S=g.map(N=>({...N,sessions:E.get(N.id)||[]})),j=S.find(N=>N.status==="active")||S[0]||null,_=S.filter(N=>!j||N.id!==j.id);n(j),i(_)}catch(p){h(p.message||"Fehler beim Laden der Trainingspläne.")}finally{o(!1)}},[f,e,t==null?void 0:t.id]);T.useEffect(()=>{y()},[y]);const w=T.useCallback(async({analysis:p,durationWeeks:m=4,sessionsPerWeek:g=3,sessions:k=null})=>{if(!f||!e)return{ok:!1,error:new Error("Supabase oder PAT-Typ nicht verfügbar.")};c(!0),h("");try{const E=k||Pu({topWeaknesses:(p==null?void 0:p.topWeaknesses)||[],topStrengths:(p==null?void 0:p.topStrengths)||[],durationWeeks:m,sessionsPerWeek:g}).sessions,S=await yp({patType:e,analysisSnapshot:p,durationWeeks:m,sessionsPerWeek:g,sessions:E});if(!S.ok)throw S.error;return await y(),{ok:!0,planId:S.planId}}catch(E){return h(E.message||"Fehler beim Speichern des Trainingsplans."),{ok:!1,error:E}}finally{c(!1)}},[f,y,e]),x=T.useCallback(async(p,m)=>{if(!f)return{ok:!1};const g=m==="done"?new Date().toISOString():null,k=r,E=s;n(j=>Ys(j,p,{state:m,completedAt:g})),i(j=>j.map(_=>Ys(_,p,{state:m,completedAt:g})));const{error:S}=await V.from("training_plan_sessions").update({state:m,completed_at:g}).eq("id",p);return S?(n(k),i(E),h(S.message||"Session-Status konnte nicht gespeichert werden."),{ok:!1,error:S}):{ok:!0}},[r,f,s]),b=T.useCallback(async(p,m)=>{if(!f)return{ok:!1};const g={...m},k=r,E=s;n(_=>Ys(_,p,g)),i(_=>_.map(N=>Ys(N,p,g)));const S={};Object.prototype.hasOwnProperty.call(g,"mainExercise")&&(S.main_exercise=g.mainExercise),Object.prototype.hasOwnProperty.call(g,"secondaryExercises")&&(S.secondary_exercises=g.secondaryExercises),Object.prototype.hasOwnProperty.call(g,"tasks")&&(S.tasks=g.tasks),Object.prototype.hasOwnProperty.call(g,"notes")&&(S.notes=g.notes);const{error:j}=await V.from("training_plan_sessions").update(S).eq("id",p);return j?(n(k),i(E),h(j.message||"Session-Änderung konnte nicht gespeichert werden."),{ok:!1,error:j}):{ok:!0}},[r,f,s]);return{activePlan:r,historyPlans:s,loading:a,saving:u,error:d,loadPlans:y,saveGeneratedPlan:w,updateSessionState:x,updateSessionPartial:b}},Sw=(t,e=26)=>t.length>e?`${t.slice(0,e-1)}…`:t;function jw({metrics:t=[]}){const e=[...t].sort((h,f)=>f.priorityScore-h.priorityScore).slice(0,8);if(!e.length)return l.jsx("div",{className:"rounded-2xl border border-dashed border-gray-300 dark:border-gray-700 bg-white/70 dark:bg-gray-900/70 p-4 text-sm text-gray-600 dark:text-gray-300",children:"Kein Gap-Chart verfügbar."});const r=760,n=220,s=24,i=38,a=20,u=a+24+i*e.length,c=Math.max(...e.map(h=>h.priorityScore),.01),d=r-n-s;return l.jsxs("div",{className:"rounded-2xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 p-4 shadow-sm h-full flex flex-col",children:[l.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100 mb-3",children:"Gap-Bar-Chart (Priorität)"}),l.jsx("svg",{viewBox:`0 0 ${r} ${u}`,className:"w-full h-auto",role:"img","aria-label":"Gap-Balkendiagramm",children:e.map((h,f)=>{const y=a+f*i,w=h.priorityScore/c*d;return l.jsxs("g",{children:[l.jsx("text",{x:10,y:y+20,className:"fill-gray-700 dark:fill-gray-200",style:{fontSize:12,fontWeight:500},children:Sw(h.name)}),l.jsx("rect",{x:n,y:y+8,width:d,height:16,rx:8,className:"fill-gray-200 dark:fill-gray-800"}),l.jsx("rect",{x:n,y:y+8,width:Math.max(3,w),height:16,rx:8,className:"fill-rose-500"}),l.jsx("text",{x:n+Math.max(8,w)+8,y:y+20,className:"fill-gray-700 dark:fill-gray-300",style:{fontSize:11,fontWeight:600},children:h.priorityScore.toFixed(2)})]},h.name)})})]})}const Zs=(t,e,r,n)=>({x:t+r*Math.cos(n),y:e+r*Math.sin(n)}),Nw=(t,e=16)=>t.length>e?`${t.slice(0,e-1)}…`:t;function Tw({radarSeries:t=[]}){const e=t.slice(0,6);if(!e.length)return l.jsx("div",{className:"rounded-2xl border border-dashed border-gray-300 dark:border-gray-700 bg-white/70 dark:bg-gray-900/70 p-4 text-sm text-gray-600 dark:text-gray-300",children:"Kein Radarprofil verfügbar."});const r=420,n=320,s=r/2,i=n/2,a=105,o=Math.PI*2/e.length,u=(d,h)=>{const f=-Math.PI/2+h*o;return Zs(s,i,a*(Math.max(0,Math.min(1.2,d))/1.2),f)},c=e.map((d,h)=>{const f=u(d.ratio,h);return`${f.x},${f.y}`}).join(" ");return l.jsxs("div",{className:"rounded-2xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 p-4 shadow-sm h-full flex flex-col",children:[l.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100 mb-3",children:"Radar-Profil (Ist/Soll)"}),l.jsxs("svg",{viewBox:`0 0 ${r} ${n}`,className:"w-full h-auto max-w-[420px] mx-auto",role:"img","aria-label":"Radarprofil",children:[[.25,.5,.75,1].map(d=>l.jsx("polygon",{points:e.map((h,f)=>{const y=-Math.PI/2+f*o,w=Zs(s,i,a*d,y);return`${w.x},${w.y}`}).join(" "),fill:"none",className:"stroke-gray-300 dark:stroke-gray-700",strokeWidth:"1"},d)),e.map((d,h)=>{const f=-Math.PI/2+h*o,y=Zs(s,i,a+16,f),w=Zs(s,i,a,f);return l.jsxs("g",{children:[l.jsx("line",{x1:s,y1:i,x2:w.x,y2:w.y,className:"stroke-gray-300 dark:stroke-gray-700",strokeWidth:"1"}),l.jsx("text",{x:y.x,y:y.y,textAnchor:"middle",className:"fill-gray-600 dark:fill-gray-300",style:{fontSize:10},children:Nw(d.name)})]},d.name)}),l.jsx("polygon",{points:c,className:"fill-sky-300/40 dark:fill-sky-500/30 stroke-sky-600 dark:stroke-sky-400",strokeWidth:"2"})]})]})}const Pw=t=>Math.round(Math.max(0,Math.min(1.5,t))*100);function Cw({strengths:t=[]}){return t.length?l.jsxs("div",{className:"rounded-2xl border border-emerald-200 dark:border-emerald-900 bg-white dark:bg-gray-900 p-5 shadow-sm",children:[l.jsx("h3",{className:"text-lg font-semibold text-emerald-700 dark:text-emerald-300 mb-4",children:"Top-3 Stärken"}),l.jsx("div",{className:"space-y-3",children:t.map((e,r)=>l.jsxs("div",{className:"rounded-xl border border-emerald-100 dark:border-emerald-900/60 bg-emerald-50/60 dark:bg-emerald-950/20 p-3",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("p",{className:"font-semibold text-gray-900 dark:text-gray-100",children:[r+1,". ",e.name]}),l.jsx("span",{className:"text-xs px-2 py-1 rounded-full bg-emerald-200/70 dark:bg-emerald-800/60 text-emerald-800 dark:text-emerald-200 font-semibold",children:Pw(e.strengthScore)})]}),l.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2 text-xs text-gray-600 dark:text-gray-300",children:[l.jsxs("p",{children:["Ist: ",e.actualMean.toFixed(2)]}),l.jsxs("p",{children:["Soll: ",e.soll.toFixed(2)]}),l.jsxs("p",{children:["Trend: ",e.trendDelta.toFixed(2)]})]})]},e.name))})]}):l.jsx("div",{className:"rounded-2xl border border-dashed border-gray-300 dark:border-gray-700 bg-white/70 dark:bg-gray-900/70 p-4 text-sm text-gray-600 dark:text-gray-300",children:"Keine Stärken-Daten verfügbar."})}const yd=t=>{if(!t)return"—";const e=new Date(t);return Number.isNaN(e.getTime())?t:new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(e)},Aw=(t,e)=>t.type!=="main"?t:{...t,intensity:e,repetitions:{hoch:24,mittel:18,leicht:12}[e]||18},Ow=t=>t?"bg-indigo-600 text-white border-indigo-600":"bg-white dark:bg-gray-900 text-gray-700 dark:text-gray-200 border-gray-300 dark:border-gray-700";function Rw({patType:t,analysis:e,activePlan:r,historyPlans:n,loading:s,saving:i,error:a,onSavePlan:o,onUpdateSessionState:u,onUpdateSessionPartial:c,onReload:d}){const[h,f]=T.useState(4),[y,w]=T.useState(3),[x,b]=T.useState([]),[p,m]=T.useState(""),g=T.useMemo(()=>{const _=x.length,N=x.filter(U=>U.intensity==="hoch").length,C=x.filter(U=>U.intensity==="mittel").length,A=x.filter(U=>U.intensity==="leicht").length;return{total:_,high:N,medium:C,low:A}},[x]),k=()=>{const _=Pu({topWeaknesses:(e==null?void 0:e.topWeaknesses)||[],topStrengths:(e==null?void 0:e.topStrengths)||[],durationWeeks:h,sessionsPerWeek:y,sessionMix:"1-main-2-secondary"});b(_.sessions),m("Neuer Entwurf erstellt. Du kannst jetzt Intensität und Übungen je Session anpassen.")},E=(_,N)=>{b(C=>C.map((A,U)=>{if(U!==_)return A;const Y={...A,...N};return Object.prototype.hasOwnProperty.call(N,"intensity")&&(Y.tasks=Y.tasks.map(G=>Aw(G,N.intensity))),Y}))},S=async()=>{var N;if(!x.length){m("Erstelle zuerst einen Entwurf.");return}const _=await o({analysis:e,durationWeeks:h,sessionsPerWeek:y,sessions:x});if(!(_!=null&&_.ok)){m(((N=_==null?void 0:_.error)==null?void 0:N.message)||"Trainingsplan konnte nicht gespeichert werden.");return}m("Trainingsplan gespeichert. Der vorherige aktive Plan wurde archiviert."),b([])},j=(_,N)=>{const C=_.secondaryExercises.join(", ");return l.jsxs("div",{className:"rounded-xl border border-sky-100 dark:border-sky-900/60 bg-sky-50/60 dark:bg-sky-950/20 p-3",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsxs("p",{className:"text-sm font-semibold text-sky-800 dark:text-sky-200",children:["Woche ",_.weekNo," · Einheit ",_.sessionNo]}),l.jsx("span",{className:"text-xs text-sky-700 dark:text-sky-300",children:_.intensity})]}),l.jsxs("div",{className:"grid md:grid-cols-3 gap-2 text-sm",children:[l.jsx("input",{value:_.mainExercise,onChange:A=>E(N,{mainExercise:A.target.value}),className:"px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900",placeholder:"Hauptübung"}),l.jsx("input",{value:C,onChange:A=>{const U=A.target.value.split(",").map(Y=>Y.trim()).filter(Boolean).slice(0,2);E(N,{secondaryExercises:U.length===2?U:[...U,"Positionsspiel Basis"].slice(0,2)})},className:"px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900",placeholder:"Nebenübungen, getrennt mit Komma"}),l.jsxs("select",{value:_.intensity,onChange:A=>E(N,{intensity:A.target.value}),className:"px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900",children:[l.jsx("option",{value:"hoch",children:"hoch"}),l.jsx("option",{value:"mittel",children:"mittel"}),l.jsx("option",{value:"leicht",children:"leicht"})]})]})]},`draft-${N}`)};return l.jsxs("section",{className:"rounded-2xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 p-5 shadow-sm",children:[l.jsxs("div",{className:"flex items-start justify-between flex-wrap gap-3 mb-4",children:[l.jsxs("div",{children:[l.jsxs("h3",{className:"text-xl font-semibold text-gray-900 dark:text-gray-100",children:["Trainingsplan (",t,")"]}),l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"1 aktiver Plan + Historie, Session-Status: offen / erledigt / übersprungen."})]}),l.jsx("button",{onClick:d,type:"button",className:"px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-700 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-800",children:"Neu laden"})]}),a&&l.jsx("div",{className:"mb-3 rounded-lg border border-red-300 dark:border-red-800 bg-red-50 dark:bg-red-900/30 p-3 text-sm text-red-700 dark:text-red-200",children:a}),l.jsxs("div",{className:"grid md:grid-cols-4 gap-3 mb-4",children:[l.jsxs("label",{className:"text-sm text-gray-700 dark:text-gray-200",children:["Dauer",l.jsxs("select",{value:h,onChange:_=>f(Number(_.target.value)),className:"mt-1 w-full px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900",children:[l.jsx("option",{value:2,children:"2 Wochen"}),l.jsx("option",{value:4,children:"4 Wochen"}),l.jsx("option",{value:6,children:"6 Wochen"})]})]}),l.jsxs("label",{className:"text-sm text-gray-700 dark:text-gray-200",children:["Einheiten/Woche",l.jsxs("select",{value:y,onChange:_=>w(Number(_.target.value)),className:"mt-1 w-full px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900",children:[l.jsx("option",{value:2,children:"2"}),l.jsx("option",{value:3,children:"3"}),l.jsx("option",{value:4,children:"4"})]})]}),l.jsx("button",{onClick:k,type:"button",className:"md:self-end px-4 py-2 rounded-lg bg-indigo-600 text-white hover:bg-indigo-700",children:"Plan (neu) generieren"}),l.jsx("button",{onClick:S,type:"button",disabled:i||!x.length,className:"md:self-end px-4 py-2 rounded-lg bg-emerald-600 text-white hover:bg-emerald-700 disabled:opacity-60",children:i?"Speichert…":"Entwurf speichern"})]}),p&&l.jsx("div",{className:"mb-4 rounded-lg border border-indigo-200 dark:border-indigo-800 bg-indigo-50 dark:bg-indigo-900/30 p-3 text-sm text-indigo-700 dark:text-indigo-200",children:p}),x.length>0&&l.jsxs("div",{className:"mb-6",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Entwurf (teilweise editierbar)"}),l.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Sessions: ",g.total," · hoch ",g.high," · mittel ",g.medium," · leicht ",g.low]})]}),l.jsx("div",{className:"max-h-80 overflow-y-auto space-y-2 pr-1",children:x.map(j)})]}),l.jsxs("div",{className:"grid lg:grid-cols-2 gap-4",children:[l.jsxs("div",{className:"rounded-xl border border-emerald-100 dark:border-emerald-900/60 p-3 bg-emerald-50/50 dark:bg-emerald-950/20",children:[l.jsx("h4",{className:"font-semibold text-emerald-800 dark:text-emerald-200 mb-2",children:"Aktiver Plan"}),s?l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Lädt…"}):r?l.jsxs(l.Fragment,{children:[l.jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-300 mb-2",children:["Generiert: ",yd(r.generatedAt)," · ",r.durationWeeks," Wochen · ",r.sessionsPerWeek," Einheiten/Woche"]}),l.jsx("div",{className:"max-h-80 overflow-y-auto space-y-2 pr-1",children:r.sessions.map(_=>l.jsxs("div",{className:"rounded-lg border border-emerald-200/70 dark:border-emerald-800 bg-white dark:bg-gray-900 p-3",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[l.jsxs("p",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:["W",_.weekNo," · E",_.sessionNo]}),l.jsx("div",{className:"flex gap-1",children:["open","done","skipped"].map(N=>l.jsx("button",{type:"button",onClick:()=>u(_.id,N),className:`text-xs px-2 py-1 border rounded ${Ow(_.state===N)}`,children:N==="open"?"offen":N==="done"?"erledigt":"übersprungen"},N))})]}),l.jsx("input",{defaultValue:_.mainExercise,onBlur:N=>c(_.id,{mainExercise:N.target.value}),className:"w-full mb-2 px-3 py-2 text-sm rounded border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900"}),l.jsx("input",{defaultValue:_.secondaryExercises.join(", "),onBlur:N=>c(_.id,{secondaryExercises:N.target.value.split(",").map(C=>C.trim()).filter(Boolean).slice(0,2)}),className:"w-full mb-2 px-3 py-2 text-sm rounded border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900"}),l.jsx("textarea",{defaultValue:_.notes||"",onBlur:N=>c(_.id,{notes:N.target.value}),placeholder:"Notiz",className:"w-full px-3 py-2 text-sm rounded border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900",rows:2})]},_.id))})]}):l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Noch kein aktiver Trainingsplan vorhanden."})]}),l.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-gray-800 p-3 bg-gray-50 dark:bg-gray-950/40",children:[l.jsx("h4",{className:"font-semibold text-gray-900 dark:text-gray-100 mb-2",children:"Plan-Historie"}),n.length?l.jsx("div",{className:"space-y-2 max-h-80 overflow-y-auto pr-1",children:n.map(_=>l.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 p-3",children:[l.jsx("p",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:yd(_.generatedAt)}),l.jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-300",children:[_.durationWeeks," Wochen · ",_.sessionsPerWeek," Einheiten/Woche · ",_.sessions.length," Sessions"]})]},_.id))}):l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Keine archivierten Pläne vorhanden."})]})]})]})}function zw({trendSeries:t=[]}){if(t.length<2)return l.jsx("div",{className:"rounded-2xl border border-dashed border-gray-300 dark:border-gray-700 bg-white/70 dark:bg-gray-900/70 p-4 text-sm text-gray-600 dark:text-gray-300",children:"Für den Trend werden mindestens 2 Assessments benötigt."});const e=760,r=280,n=50,s=20,i=16,a=52,o=t.map(x=>x.totalPoints),u=Math.min(...o),d=Math.max(...o)-u||1,h=e-n-s,f=r-i-a,y=t.map((x,b)=>{const p=n+b/(t.length-1)*h,m=(x.totalPoints-u)/d,g=i+f-m*f;return{...x,x:p,y:g}}),w=y.map((x,b)=>`${b===0?"M":"L"}${x.x},${x.y}`).join(" ");return l.jsxs("div",{className:"rounded-2xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 p-4 shadow-sm",children:[l.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100 mb-3",children:"Trend (Gesamtpunkte)"}),l.jsxs("svg",{viewBox:`0 0 ${e} ${r}`,className:"w-full h-auto",role:"img","aria-label":"Trenddiagramm",children:[l.jsx("line",{x1:n,y1:i,x2:n,y2:i+f,className:"stroke-gray-300 dark:stroke-gray-700",strokeWidth:"1"}),l.jsx("line",{x1:n,y1:i+f,x2:n+h,y2:i+f,className:"stroke-gray-300 dark:stroke-gray-700",strokeWidth:"1"}),l.jsx("path",{d:w,fill:"none",className:"stroke-indigo-500",strokeWidth:"3",strokeLinecap:"round"}),y.map(x=>l.jsxs("g",{children:[l.jsx("circle",{cx:x.x,cy:x.y,r:"4",className:"fill-indigo-500"}),l.jsx("text",{x:x.x,y:x.y-10,textAnchor:"middle",className:"fill-gray-700 dark:fill-gray-200",style:{fontSize:11,fontWeight:600},children:x.totalPoints}),l.jsx("text",{x:x.x,y:r-18,textAnchor:"middle",className:"fill-gray-500 dark:fill-gray-400",style:{fontSize:10},children:x.label})]},x.assessmentId))]})]})}const Iw=t=>Math.round(Math.max(0,Math.min(1.5,t))*100);function Lw({weaknesses:t=[]}){return t.length?l.jsxs("div",{className:"rounded-2xl border border-rose-200 dark:border-rose-900 bg-white dark:bg-gray-900 p-5 shadow-sm",children:[l.jsx("h3",{className:"text-lg font-semibold text-rose-700 dark:text-rose-300 mb-4",children:"Top-3 Schwächen"}),l.jsx("div",{className:"space-y-3",children:t.map((e,r)=>l.jsxs("div",{className:"rounded-xl border border-rose-100 dark:border-rose-900/60 bg-rose-50/60 dark:bg-rose-950/20 p-3",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("p",{className:"font-semibold text-gray-900 dark:text-gray-100",children:[r+1,". ",e.name]}),l.jsx("span",{className:"text-xs px-2 py-1 rounded-full bg-rose-200/70 dark:bg-rose-800/60 text-rose-800 dark:text-rose-200 font-semibold",children:Iw(e.priorityScore)})]}),l.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2 text-xs text-gray-600 dark:text-gray-300",children:[l.jsxs("p",{children:["Gap: ",e.gapScore.toFixed(2)]}),l.jsxs("p",{children:["Konstanz: ",e.consistencyScore.toFixed(2)]}),l.jsxs("p",{children:["Trend: ",e.trendDelta.toFixed(2)]})]})]},e.name))})]}):l.jsx("div",{className:"rounded-2xl border border-dashed border-gray-300 dark:border-gray-700 bg-white/70 dark:bg-gray-900/70 p-4 text-sm text-gray-600 dark:text-gray-300",children:"Keine Schwächen-Daten verfügbar."})}function Dw({assessments:t,selectedPatType:e,onPatTypeChange:r,patTypes:n,user:s}){const i=Object.keys(n||{});T.useEffect(()=>{!e&&i.length&&r(i[0])},[r,i,e]);const a=T.useMemo(()=>Kf(t,e,{windowSize:5,missingStrategy:"zero"}),[t,e]),o=t.filter(g=>g.patType===e),u=t.length>0,{activePlan:c,historyPlans:d,loading:h,saving:f,error:y,saveGeneratedPlan:w,updateSessionState:x,updateSessionPartial:b,loadPlans:p}=Ew({user:s,patType:e}),m=({durationWeeks:g,sessionsPerWeek:k,sessions:E})=>w({analysis:a,durationWeeks:g,sessionsPerWeek:k,sessions:E});return l.jsx("div",{className:"min-h-screen bg-gradient-to-br from-cyan-50 via-white to-emerald-50 dark:from-gray-950 dark:via-gray-950 dark:to-gray-900 p-6 text-gray-900 dark:text-gray-100",children:l.jsxs("div",{className:"max-w-7xl mx-auto space-y-6",children:[l.jsxs("section",{className:"rounded-2xl border border-gray-200 dark:border-gray-800 bg-white/90 dark:bg-gray-900/80 backdrop-blur p-5 shadow-sm",children:[l.jsx("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:l.jsxs("div",{children:[l.jsx("p",{className:"text-xs uppercase tracking-[0.2em] text-cyan-700 dark:text-cyan-300",children:"Analyse"}),l.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:"Wo solltest du besser werden?"}),l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:"Priorisierung nach Gap × Faktor × Konstanz basierend auf den letzten 5 Assessments."})]})}),l.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:i.map(g=>{const k=g===e;return l.jsx("button",{type:"button",onClick:()=>r(g),className:`px-4 py-2 rounded-lg border text-sm font-semibold transition ${k?"bg-gray-900 text-white dark:bg-gray-100 dark:text-gray-900 border-gray-900 dark:border-gray-100":"bg-white dark:bg-gray-900 text-gray-700 dark:text-gray-200 border-gray-300 dark:border-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800"}`,children:g},g)})}),l.jsxs("div",{className:"mt-4 flex flex-wrap gap-2 text-xs",children:[l.jsxs("span",{className:"px-3 py-1 rounded-full border border-cyan-200 dark:border-cyan-800 bg-cyan-50 dark:bg-cyan-900/30 text-cyan-700 dark:text-cyan-200 font-semibold",children:[l.jsx(Lf,{className:"w-3 h-3 inline-block mr-1"}),"Assessments: ",o.length]}),l.jsxs("span",{className:"px-3 py-1 rounded-full border border-indigo-200 dark:border-indigo-800 bg-indigo-50 dark:bg-indigo-900/30 text-indigo-700 dark:text-indigo-200 font-semibold",children:[l.jsx(Bf,{className:"w-3 h-3 inline-block mr-1"}),"Analysefenster: ",a.windowedAssessments.length,"/5"]}),a.isLimitedData&&l.jsxs("span",{className:"px-3 py-1 rounded-full border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-900/30 text-amber-700 dark:text-amber-200 font-semibold",children:[l.jsx(ry,{className:"w-3 h-3 inline-block mr-1"}),"Begrenzte Datenbasis"]})]})]}),u?o.length===0?l.jsxs("section",{className:"rounded-2xl border border-dashed border-gray-300 dark:border-gray-700 bg-white/80 dark:bg-gray-900/70 p-6 text-center",children:[l.jsxs("h2",{className:"text-xl font-semibold text-gray-900 dark:text-gray-100 mb-1",children:["Keine Bewertungen für ",e]}),l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Wähle einen anderen PAT-Typ oder erstelle eine neue Bewertung."})]}):l.jsxs(l.Fragment,{children:[l.jsxs("section",{className:"grid lg:grid-cols-2 gap-4",children:[l.jsx("div",{className:"h-full",children:l.jsx(jw,{metrics:a.exerciseMetrics})}),l.jsx("div",{className:"h-full",children:l.jsx(Tw,{radarSeries:a.radarSeries})}),l.jsx("div",{className:"lg:col-span-2",children:l.jsx(zw,{trendSeries:a.trendSeries})})]}),l.jsxs("section",{className:"grid lg:grid-cols-2 gap-4",children:[l.jsx(Lw,{weaknesses:a.topWeaknesses}),l.jsx(Cw,{strengths:a.topStrengths})]}),l.jsx(Rw,{patType:e,analysis:a,activePlan:c,historyPlans:d,loading:h,saving:f,error:y,onSavePlan:m,onUpdateSessionState:x,onUpdateSessionPartial:b,onReload:p})]}):l.jsxs("section",{className:"rounded-2xl border border-dashed border-gray-300 dark:border-gray-700 bg-white/80 dark:bg-gray-900/70 p-6 text-center",children:[l.jsx(ay,{className:"w-10 h-10 mx-auto mb-3 text-gray-400 dark:text-gray-500"}),l.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-gray-100 mb-1",children:"Noch keine Daten für die Analyse"}),l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:'Lege zuerst eine Bewertung im Bereich "Bewertungen" an.'})]})]})})}const Mw={"PAT Start":[{name:"1) Stoß-Geschwindigkeit",values:["","",""],soll:3,durchschnitt:0,faktor:33.33,points:0},{name:"2) Stoß-Gradlinigkeit",values:["","","",""],soll:2,durchschnitt:0,faktor:50,points:0},{name:"3) Winkelbälle",values:["","",""],soll:3,durchschnitt:0,faktor:33.33,points:0},{name:"4) Nachlauf Wirkung",values:["","",""],soll:9,durchschnitt:0,faktor:11.11,points:0},{name:"5) Rücklauf-Wirkung",values:["","",""],soll:7,durchschnitt:0,faktor:14.29,points:0},{name:"6) Kl. Positions-Spiel",subA:["","",""],subB:["","",""],soll:4,durchschnitt:0,faktor:25,points:0},{name:"7) Gr. Pos. Bereich",subA:["","",""],subB:["","",""],soll:5,durchschnitt:0,faktor:20,points:0},{name:"8) Press Bande",values:["","",""],soll:3,durchschnitt:0,faktor:33.33,points:0},{name:"9) Standardbälle",values:["","","","",""],soll:2,durchschnitt:0,faktor:50,points:0},{name:"10) 8-Ball Situation",values:["","",""],soll:3,durchschnitt:0,faktor:33.33,points:0}],"PAT 1":[{name:"1) Geschwindigkeit",values:["","",""],soll:3.33,durchschnitt:0,faktor:30,points:0,minValue:0,maxValue:4},{name:"2) Geradlinigkeit (Speed 2)",values:["","","",""],soll:2.5,durchschnitt:0,faktor:40,points:0,minValue:0,maxValue:3},{name:"3) Nachlauf",values:["","",""],soll:11,durchschnitt:0,faktor:9.1,points:0,minValue:0,maxValue:12},{name:"4) Rücklauf",values:["","",""],soll:10,durchschnitt:0,faktor:10,points:0,minValue:0,maxValue:12},{name:"5) Kl. Pos.-Bereich",subA:["","",""],subB:["","",""],subLabels:["1","2"],soll:3.33,durchschnitt:0,faktor:30,points:0,minValue:0,maxValue:5},{name:"6) Gr. Pos.-Bereich",subA:["","",""],subB:["","",""],subLabels:["1","2"],soll:3.33,durchschnitt:0,faktor:30,points:0,minValue:0,maxValue:6},{name:"7) Press Bande",subA:["","",""],subB:["","",""],subLabels:["1","2"],soll:4,durchschnitt:0,faktor:25,points:0,subValueRanges:{a:{minValue:0,maxValue:6},b:{minValue:0,maxValue:10}}},{name:"8) Endlos-Übung (Max: 9)",values:["","",""],soll:4.5,durchschnitt:0,faktor:22.22,points:0,minValue:0,maxValue:9},{name:"9) Standardbälle",values:["","","","",""],soll:2,durchschnitt:0,faktor:50,points:0,minValue:0,maxValue:3},{name:"10) 9-Ball Situation 5",values:["","",""],soll:4.5,durchschnitt:0,faktor:22.22,points:0,minValue:0,maxValue:9}],"PAT 2":[{name:"1) Übung PAT 2-1",values:["","",""],soll:3,durchschnitt:0,faktor:33.33,points:0},{name:"2) Übung PAT 2-2",values:["","",""],soll:3,durchschnitt:0,faktor:33.33,points:0},{name:"3) Übung PAT 2-3",values:["","",""],soll:3,durchschnitt:0,faktor:33.33,points:0}],"PAT 3":[{name:"1) Übung PAT 3-1",values:["","",""],soll:3,durchschnitt:0,faktor:33.33,points:0},{name:"2) Übung PAT 3-2",values:["","",""],soll:3,durchschnitt:0,faktor:33.33,points:0},{name:"3) Übung PAT 3-3",values:["","",""],soll:3,durchschnitt:0,faktor:33.33,points:0}]},Yr=t=>t?JSON.parse(JSON.stringify(t)):null,mn=t=>t===null||typeof t>"u"?!1:typeof t=="string"?t.trim()!=="":!0,Fw=(t={})=>t.subA&&t.subB?[...t.subA||[],...t.subB||[]].every(mn):(t.values||[]).every(mn),vp=t=>{if(!t||!mn(t.name)||!mn(t.datum))return!1;const e=t.exercises||[];return e.length?e.every(Fw):!1},wp=t=>t?t.isFinalized?"Dieser Test wurde bereits final abgeschlossen":!mn(t.name)||!mn(t.datum)?"Bitte zuerst Name und Datum ausfüllen":vp(t)?"":"Bitte alle Übungsfelder ausfüllen, bevor du final abschließt":"Kein Test geöffnet",$w=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Date.now().toString(),ao=t=>({id:t.id,patType:t.pat_type,datum:t.datum,name:t.name,exercises:Yr(t.exercises||[]),isFinalized:!!t.is_finalized,finalizedAt:t.finalized_at||null,finalizationReminderSentAt:t.finalization_reminder_sent_at||null}),Bw=(t,e)=>({id:t.id,user_id:e,pat_type:t.patType,datum:t.datum,name:t.name,exercises:Yr(t.exercises),is_finalized:!!t.isFinalized,finalized_at:t.finalizedAt||null,finalization_reminder_sent_at:t.finalizationReminderSentAt||null}),Uw=(t,e,r={})=>{const{onAfterSave:n}=r,[s,i]=T.useState([]),[a,o]=T.useState(null),[u,c]=T.useState(!1),d=T.useMemo(()=>!!V&&!!(e!=null&&e.id),[e]);T.useEffect(()=>{d&&h()},[d]);const h=async()=>{if(d)try{const{data:g,error:k}=await V.from("assessments").select("*").eq("user_id",e.id).order("created_at",{ascending:!1});if(k)throw k;i((g||[]).map(ao))}catch(g){console.error("Fehler beim Laden:",g),alert("Fehler beim Laden der Daten aus Supabase: "+g.message)}},f=g=>{const k={id:$w(),patType:g,datum:new Date().toISOString().split("T")[0],name:"",exercises:Yr(t[g]),isFinalized:!1,finalizedAt:null,finalizationReminderSentAt:null};o(k),c(!1)},y=g=>{o(Yr(g)),c(!1)},w=async({finalize:g=!1}={})=>{if(!(a!=null&&a.name)||!(a!=null&&a.datum))return alert("Bitte Name und Datum ausfüllen"),{ok:!1};if(a!=null&&a.isFinalized&&!g)return alert("Final abgeschlossene Bewertungen können nicht mehr geändert werden."),{ok:!1};if(g){const E=wp(a);if(E||!vp(a))return alert(E||"Bitte alle Felder ausfüllen, bevor du final abschließt."),{ok:!1}}if(!d)return alert("Supabase ist nicht konfiguriert. Bitte .env prüfen."),{ok:!1};const k=s.find(E=>E.id===a.id);try{const E=Yr(a);E.name=E.name.trim(),g&&(E.isFinalized=!0,E.finalizedAt=new Date().toISOString(),E.finalizationReminderSentAt=null);const S=Bw(E,e.id);let j=null,_=[];if(k){const{data:N,error:C}=await V.from("assessments").update(S).eq("id",a.id).eq("user_id",e.id).select().single();if(C)throw C;j=ao(N),_=s.map(A=>A.id===j.id?j:A),i(_),o(j)}else{const{data:N,error:C}=await V.from("assessments").insert(S).select().single();if(C)throw C;j=ao(N),_=[j,...s.filter(A=>A.id!==j.id)],i(_),o(j)}if(typeof n=="function")try{await n({savedAssessment:j,assessments:_})}catch(N){console.warn("Post-save hook failed:",N)}return c(!1),{ok:!0,assessment:j,assessments:_}}catch(E){return alert("Fehler beim Speichern in Supabase: "+E.message),{ok:!1,error:E}}};return{assessments:s,currentAssessment:a,setCurrentAssessment:o,hasUnsavedChanges:u,setHasUnsavedChanges:c,createNewAssessment:f,openAssessment:y,handleSave:async()=>w(),finalizeAssessment:async()=>w({finalize:!0}),deleteAssessment:async g=>{if(!confirm("Möchten Sie diese Bewertung wirklich löschen?"))return;if(!d){alert("Supabase ist nicht konfiguriert. Bitte .env prüfen.");return}const{error:k}=await V.from("assessments").delete().eq("id",g).eq("user_id",e.id);if(k){alert("Fehler beim Löschen: "+k.message);return}i(E=>E.filter(S=>S.id!==g))},updateExerciseValue:(g,k,E,S=null)=>{if(!a||a.isFinalized)return;const j=Yr(a),_=Hf(j.exercises[g],E,S);S==="a"?j.exercises[g].subA[k]=_:S==="b"?j.exercises[g].subB[k]=_:j.exercises[g].values[k]=_;const{durchschnitt:N,points:C}=Wf(j.exercises[g]);j.exercises[g].durchschnitt=N,j.exercises[g].points=C,o(j),c(!0)},calculateTotal:()=>ga((a==null?void 0:a.exercises)||[])}},Hw=t=>{if(!t)return"—";const e=new Date(t);return Number.isNaN(e.getTime())?t:new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}).format(e)};function Vw({assessments:t,loading:e=!1,error:r}){var s,i,a,o,u,c,d,h;const n=T.useMemo(()=>{if(e||!t)return{total:0,average:0,latest:null,best:null};if(!(t!=null&&t.length))return{total:0,average:0,latest:null,best:null};const f=t.map(b=>({...b,totalPoints:Math.round(ga(b.exercises||[]))})),y=f.reduce((b,p)=>b+(p.totalPoints||0),0)/(f.length||1),w=f[0],x=f.reduce((b,p)=>!b||(p.totalPoints||0)>(b.totalPoints||0)?p:b,null);return{total:f.length,average:Math.round(y),latest:w,best:x}},[t]);return l.jsxs("div",{className:"bg-white/90 dark:bg-gray-900/80 border border-gray-100 dark:border-gray-800 rounded-2xl shadow-lg p-6 mb-6",children:[l.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3 mb-4",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-xs uppercase tracking-[0.2em] text-emerald-600 dark:text-emerald-300",children:"Live Übersicht"}),l.jsx("h2",{className:"text-xl font-bold text-gray-900 dark:text-gray-100",children:"Aktuelle Statistik"}),l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Basis: alle Bewertungen, geladen beim Seitenaufruf"})]}),l.jsx("span",{className:"rounded-full border border-emerald-200/70 dark:border-emerald-700 px-3 py-1 text-xs font-semibold text-emerald-700 dark:text-emerald-200 bg-emerald-50 dark:bg-emerald-900/40",children:e?"Lädt…":"Stand: jetzt"})]}),r&&l.jsx("div",{className:"mb-3 rounded-lg border border-red-200 dark:border-red-800 bg-red-50 dark:bg-red-900/30 p-3 text-sm text-red-700 dark:text-red-200",children:r}),e?l.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[1,2,3,4].map(f=>l.jsx("div",{className:"h-28 rounded-2xl border border-gray-200/60 dark:border-gray-800 bg-gray-100 dark:bg-gray-800 animate-pulse"},f))}):n.total===0?l.jsx("div",{className:"rounded-xl border border-dashed border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-800/60 p-4 text-sm text-gray-600 dark:text-gray-300",children:"Noch keine Bewertungen vorhanden. Lege eine neue Bewertung an, um hier Live-Werte zu sehen."}):l.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[l.jsxs("div",{className:"rounded-2xl border border-emerald-200/70 dark:border-emerald-800 bg-gradient-to-br from-emerald-50 via-white to-emerald-50 dark:from-emerald-900/30 dark:via-gray-900 dark:to-emerald-900/20 p-4 shadow-sm",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm font-semibold text-emerald-700 dark:text-emerald-200",children:"Bewertungen"}),l.jsx(Lf,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-300","aria-hidden":"true"})]}),l.jsx("p",{className:"mt-3 text-3xl font-bold text-emerald-800 dark:text-emerald-100",children:n.total}),l.jsx("p",{className:"text-xs text-emerald-700/80 dark:text-emerald-200/70",children:"In der PAT Datenbank hinterlegt"})]}),l.jsxs("div",{className:"rounded-2xl border border-sky-200/70 dark:border-sky-800 bg-gradient-to-br from-sky-50 via-white to-sky-50 dark:from-sky-900/30 dark:via-gray-900 dark:to-sky-900/20 p-4 shadow-sm",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm font-semibold text-sky-700 dark:text-sky-200",children:"Ø Gesamtpunkte"}),l.jsx(Uf,{className:"h-4 w-4 text-sky-600 dark:text-sky-300","aria-hidden":"true"})]}),l.jsx("p",{className:"mt-3 text-3xl font-bold text-sky-800 dark:text-sky-100",children:n.average}),l.jsx("p",{className:"text-xs text-sky-700/80 dark:text-sky-200/70",children:"Durchschnitt aller Assessments"})]}),l.jsxs("div",{className:"rounded-2xl border border-indigo-200/70 dark:border-indigo-800 bg-gradient-to-br from-indigo-50 via-white to-indigo-50 dark:from-indigo-900/30 dark:via-gray-900 dark:to-indigo-900/20 p-4 shadow-sm",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm font-semibold text-indigo-700 dark:text-indigo-200",children:"Letzte Bewertung"}),l.jsx(cy,{className:"h-4 w-4 text-indigo-600 dark:text-indigo-300","aria-hidden":"true"})]}),l.jsx("p",{className:"mt-3 text-lg font-semibold text-indigo-900 dark:text-indigo-100",children:((s=n.latest)==null?void 0:s.name)||((i=n.latest)==null?void 0:i.patType)||"Unbenannt"}),l.jsxs("p",{className:"text-xs text-indigo-700/80 dark:text-indigo-200/70",children:[Hw((a=n.latest)==null?void 0:a.datum)," · ",((o=n.latest)==null?void 0:o.patType)||"PAT"]})]}),l.jsxs("div",{className:"rounded-2xl border border-amber-200/70 dark:border-amber-800 bg-gradient-to-br from-amber-50 via-white to-amber-50 dark:from-amber-900/30 dark:via-gray-900 dark:to-amber-900/20 p-4 shadow-sm",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm font-semibold text-amber-700 dark:text-amber-200",children:"Top Ergebnis"}),l.jsx(iy,{className:"h-4 w-4 text-amber-600 dark:text-amber-300","aria-hidden":"true"})]}),l.jsx("p",{className:"mt-3 text-3xl font-bold text-amber-800 dark:text-amber-100",children:((u=n.best)==null?void 0:u.totalPoints)??0}),l.jsxs("p",{className:"text-xs text-amber-700/80 dark:text-amber-200/70",children:[((c=n.best)==null?void 0:c.name)||((d=n.best)==null?void 0:d.patType)||"—"," · ",((h=n.best)==null?void 0:h.patType)||"PAT"]})]})]})]})}const Ww=(t={})=>{const e={name:t.name||"",soll:t.soll??0,faktor:t.faktor??0};t.subA&&t.subB?(e.subA=t.subA,e.subB=t.subB,t.subLabels&&(e.subLabels=t.subLabels)):e.values=t.values||[];const{durchschnitt:r,points:n}=Wf({...e,values:e.values||[]});return{...e,durchschnitt:r,points:n}},Kw=t=>({id:t.id,patType:t.pat_type,datum:t.datum,name:t.name,exercises:(t.exercises||[]).map(Ww)}),xp=t=>Array.isArray(t)?t[0]||null:t||null,qw=t=>{if(typeof window>"u")return`?share=${t}`;const e=new URL(window.location.origin+window.location.pathname);return e.searchParams.set("share",t),e.toString()},bp=t=>((t==null?void 0:t.message)||"").includes("Tests are hidden in the profile")?new Error("Deine Tests sind im Profil aktuell nicht sichtbar."):t,Gw=async t=>{if(!t)throw new Error("Kein Test zum Teilen gefunden.");if(!V)throw new Error("Supabase ist nicht konfiguriert.");const{data:e,error:r}=await V.rpc("create_or_get_assessment_share",{p_assessment_id:t.id});if(r)throw bp(r);const n=xp(e);if(!(n!=null&&n.share_token))throw new Error("Kein Freigabetoken erhalten.");return{token:n.share_token,url:qw(n.share_token)}},Jw=async(t=[])=>{if(!V)throw new Error("Supabase ist nicht konfiguriert.");if(!t.length)return{};const{data:e,error:r}=await V.from("assessment_shares").select("assessment_id, share_token").in("assessment_id",t);if(r)throw r;return(e||[]).reduce((n,s)=>(n[s.assessment_id]=s.share_token,n),{})},Qw=async t=>{if(!V)throw new Error("Supabase ist nicht konfiguriert.");const{error:e}=await V.from("assessment_shares").delete().eq("assessment_id",t);if(e)throw e},Yw=async t=>{if(!V)throw new Error("Supabase ist nicht konfiguriert.");const{data:e,error:r}=await V.rpc("get_shared_assessment",{p_share_token:t});if(r)throw bp(r);const n=xp(e);return n?Kw(n):null},Zw=async t=>{var e;return typeof navigator>"u"||!((e=navigator.clipboard)!=null&&e.writeText)?!1:(await navigator.clipboard.writeText(t),!0)},Xw=()=>typeof window<"u"&&["localhost","127.0.0.1"].includes(window.location.hostname);function ex({user:t,activeTab:e="assessments",onEditingStateChange:r,testsVisible:n=!1,isProfileLoading:s=!1}){const i=T.useMemo(()=>Mw||{},[]),a=Object.keys(i),[o,u]=T.useState(!0),[c,d]=T.useState(()=>a[0]||""),[h,f]=T.useState(!1),[y,w]=T.useState({});T.useEffect(()=>{r==null||r(!o)},[r,o]),T.useEffect(()=>{a.length&&(!c||!a.includes(c))&&d(a[0])},[a,c]);const x=T.useCallback(async({savedAssessment:O,assessments:K})=>{var q;if(!(O!=null&&O.patType)||!(K!=null&&K.length))return;const ee=Kf(K,O.patType,{windowSize:5,missingStrategy:"zero"});if(!ee.windowedAssessments.length)return;const Ke=Pu({topWeaknesses:ee.topWeaknesses,topStrengths:ee.topStrengths,durationWeeks:4,sessionsPerWeek:3,sessionMix:"1-main-2-secondary"}),vt=await yp({patType:O.patType,analysisSnapshot:ee,durationWeeks:4,sessionsPerWeek:3,sessions:Ke.sessions});vt.ok||console.warn("Automatische Plan-Neugenerierung fehlgeschlagen:",((q=vt.error)==null?void 0:q.message)||vt.error)},[]),{assessments:b,currentAssessment:p,setCurrentAssessment:m,hasUnsavedChanges:g,setHasUnsavedChanges:k,createNewAssessment:E,openAssessment:S,handleSave:j,finalizeAssessment:_,deleteAssessment:N,updateExerciseValue:C,calculateTotal:A}=Uw(i,t,{onAfterSave:x}),U=b,Y=T.useMemo(()=>U.map(O=>O.id),[U]),G=T.useMemo(()=>b.some(O=>O.id===(p==null?void 0:p.id)),[b,p==null?void 0:p.id]),ye=!!(p!=null&&p.id&&y[p.id]),he=!!(p!=null&&p.isFinalized);T.useEffect(()=>{let O=!1;return(async()=>{if(!(t!=null&&t.id)||!Y.length){w({});return}try{const ee=await Jw(Y);O||w(ee)}catch(ee){console.warn("Freigaben konnten nicht geladen werden:",ee),O||w({})}})(),()=>{O=!0}},[t==null?void 0:t.id,Y]);const Re=()=>{g&&!he?f(!0):u(!0)},R=async()=>{const O=await j();return O!=null&&O.ok&&alert("Erfolgreich gespeichert!"),O},M=T.useCallback(async()=>{const O=await _();O!=null&&O.ok&&alert("Bewertung wurde final abgeschlossen und ist jetzt nur noch lesbar.")},[_]),H=async()=>{if(!(p!=null&&p.name)||!(p!=null&&p.datum)){alert("Bitte Name und Datum ausfüllen bevor Sie speichern");return}const O=await R();O!=null&&O.ok&&(f(!1),u(!0))},X=()=>{f(!1),k(!1),u(!0)},ie=()=>{f(!1)},St=T.useCallback(async O=>{try{const{token:K,url:ee}=await Gw(O),Ke=(O==null?void 0:O.name)||(O==null?void 0:O.patType)||"dieser Test",vt=Xw()?`
|
||
|
||
Hinweis: Der Link zeigt aktuell auf localhost und ist nur erreichbar, wenn die App von außen erreichbar ist.`:"";w(q=>({...q,[O.id]:K}));try{if(await Zw(ee)){alert(`Freigabelink für "${Ke}" wurde in die Zwischenablage kopiert.${vt}`);return}}catch(q){console.warn("Kopieren in die Zwischenablage fehlgeschlagen:",q)}window.prompt(`Freigabelink für "${Ke}"${vt}`,ee)}catch(K){alert(`Freigabelink konnte nicht erstellt werden: ${K.message||K}`)}},[]),We=T.useCallback(async O=>{const K=(O==null?void 0:O.name)||(O==null?void 0:O.patType)||"dieser Test";try{await Qw(O.id),w(ee=>{const Ke={...ee};return delete Ke[O.id],Ke}),alert(`Freigabe für "${K}" wurde aufgehoben.`)}catch(ee){alert(`Freigabe konnte nicht aufgehoben werden: ${ee.message||ee}`)}},[]),lr=T.useCallback(()=>{if(p){if(s){alert("Profil wird noch geladen. Bitte versuche es gleich noch einmal.");return}if(!n){alert('Aktiviere im Profil zuerst "Tests sichtbar", bevor du Tests teilst.');return}if(!G){alert("Bitte den Test zuerst speichern, bevor du ihn teilen kannst.");return}if(g){alert("Bitte erst speichern, damit der aktuelle Stand geteilt wird.");return}St(p)}},[p,St,g,G,s,n]),at=T.useCallback(()=>{!p||!ye||We(p)},[p,We,ye]),jt=G?g?"Bitte erst speichern, damit der aktuelle Stand geteilt wird":s?"Profil wird geladen":n?"":'Aktiviere im Profil "Tests sichtbar"':"Bitte zuerst speichern",L=wp(p);return o?e==="analysis"?l.jsx(Dw,{assessments:U,selectedPatType:c,onPatTypeChange:d,patTypes:i,user:t}):l.jsx(jy,{patTypes:i,assessments:U,overview:l.jsx(Vw,{assessments:U}),assessmentShareTokens:y,testsVisible:n,selectedPatType:c,onPatTypeChange:d,onCreate:O=>{E(O),u(!1)},onEdit:O=>{S(O),u(!1)},onDelete:N,getPatTypeColor:al,getAchievement:ol}):l.jsx(Hy,{currentAssessment:p,hasUnsavedChanges:g,onBack:Re,onSave:R,onAssessmentChange:m,onUpdateExercise:C,onMarkDirty:()=>k(!0),showSaveDialog:h,onSaveAndExit:H,onDiscardAndExit:X,onCancelExit:ie,getPatTypeColor:al,getAchievement:ol,calculateTotal:A,isReadOnly:he,canFinalize:!L,finalizeDisabledReason:L,onFinalize:M,isShareActive:ye,testsVisible:n,canShare:n&&!s&&G&&!g,shareDisabledReason:jt,onShare:lr,onRevokeShare:at})}function tx({onAuth:t,themeToggle:e,onBack:r}){const[n,s]=T.useState("login"),[i,a]=T.useState(""),[o,u]=T.useState(""),[c,d]=T.useState(""),[h,f]=T.useState(""),[y,w]=T.useState(!1),x=async b=>{if(b.preventDefault(),!!V){w(!0),f(""),d("");try{if(n==="login"){const{data:p,error:m}=await V.auth.signInWithPassword({email:i,password:o});m?f(m.message):(d("Erfolgreich angemeldet"),t==null||t(p.session))}else{const{data:p,error:m}=await V.auth.signUp({email:i,password:o});m?f(m.message):p.session?t==null||t(p.session):d("Registrierung abgeschlossen. Prüfe dein Postfach zur Bestätigung.")}}catch(p){f(p.message)}finally{w(!1)}}};return l.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-sky-100 via-blue-50 to-emerald-100 dark:from-gray-950 dark:via-gray-900 dark:to-gray-950 flex items-center justify-center p-6 text-gray-900 dark:text-gray-100",children:[l.jsx("div",{className:"absolute top-4 left-4 flex items-center gap-3",children:r&&l.jsxs("button",{type:"button",onClick:r,className:"inline-flex items-center gap-2 rounded-full border border-gray-200/70 bg-white/70 px-3 py-2 text-sm font-medium text-gray-800 shadow-sm backdrop-blur transition hover:-translate-y-[1px] hover:shadow-md dark:border-gray-800 dark:bg-gray-900/70 dark:text-gray-100",children:[l.jsx(ny,{className:"h-4 w-4"}),"Zurück"]})}),l.jsx("div",{className:"absolute top-4 right-4",children:e}),l.jsxs("div",{className:"w-full max-w-lg bg-white/90 dark:bg-gray-900/80 backdrop-blur rounded-2xl shadow-xl border border-white/70 dark:border-gray-800",children:[l.jsxs("div",{className:"px-8 py-6 border-b border-gray-100 dark:border-gray-800",children:[l.jsx("p",{className:"text-sm uppercase tracking-wide text-indigo-600 dark:text-indigo-300 font-semibold",children:"PAT Stats"}),l.jsx("h1",{className:"text-3xl font-bold text-gray-900 dark:text-gray-100 mt-1",children:"Anmelden oder registrieren"}),l.jsx("p",{className:"text-gray-600 dark:text-gray-300 mt-2",children:"Melde dich mit deinem PAT-Test Konto an, um deine Bewertungen sicher zu verwalten."})]}),l.jsxs("form",{onSubmit:x,className:"px-8 py-6 space-y-4",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[l.jsx("button",{type:"button",onClick:()=>s("login"),className:`px-4 py-2 rounded-full transition ${n==="login"?"bg-indigo-600 text-white":"text-gray-600 dark:text-gray-300 hover:bg-indigo-50 dark:hover:bg-indigo-900/40"}`,children:"Login"}),l.jsx("button",{type:"button",onClick:()=>s("register"),className:`px-4 py-2 rounded-full transition ${n==="register"?"bg-emerald-600 text-white":"text-gray-600 dark:text-gray-300 hover:bg-emerald-50 dark:hover:bg-emerald-900/40"}`,children:"Registrieren"})]}),l.jsxs("label",{className:"block",children:[l.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:"E-Mail"}),l.jsx("input",{type:"email",value:i,onChange:b=>a(b.target.value),required:!0,className:"mt-1 w-full px-4 py-3 rounded-lg border border-gray-200 dark:border-gray-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-800 dark:text-gray-100",placeholder:"you@example.com"})]}),l.jsxs("label",{className:"block",children:[l.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:"Passwort"}),l.jsx("input",{type:"password",value:o,onChange:b=>u(b.target.value),required:!0,className:"mt-1 w-full px-4 py-3 rounded-lg border border-gray-200 dark:border-gray-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-800 dark:text-gray-100",placeholder:"••••••••"})]}),h&&l.jsx("div",{className:"p-3 rounded-lg bg-red-50 dark:bg-red-900/30 border border-red-200 dark:border-red-800 text-red-700 dark:text-red-200 text-sm",children:h}),c&&l.jsx("div",{className:"p-3 rounded-lg bg-emerald-50 dark:bg-emerald-900/30 border border-emerald-200 dark:border-emerald-800 text-emerald-700 dark:text-emerald-200 text-sm",children:c}),l.jsx("button",{type:"submit",disabled:y,className:"w-full py-3 rounded-lg font-semibold text-white bg-gradient-to-r from-indigo-600 to-emerald-600 shadow-md hover:shadow-lg transition disabled:opacity-60 disabled:cursor-not-allowed",children:y?"Wird gesendet...":n==="login"?"Einloggen":"Konto erstellen"})]})]})]})}const rx=[{label:"Datenschutz",path:"/datenschutz"},{label:"Impressum",path:"/impressum"},{label:"Kontakt",path:"/kontakt"}];function kp({children:t,themeToggle:e,onGetStarted:r,onNavigate:n,navLinks:s=[],currentPath:i="/"}){return l.jsxs("div",{className:"public-site",children:[l.jsx("div",{className:"public-site__backdrop"}),l.jsx("div",{className:"public-site__grid"}),l.jsxs("header",{className:"public-site__nav",children:[l.jsxs("button",{type:"button",className:"public-site__brand",onClick:()=>n("/"),children:[l.jsx("span",{className:"public-site__brand-mark",children:l.jsx(Bf,{className:"h-5 w-5","aria-hidden":"true"})}),l.jsxs("span",{className:"public-site__brand-copy",children:[l.jsx("span",{className:"public-site__brand-title",children:"PAT Manager"}),l.jsx("span",{className:"public-site__brand-subtitle",children:"Digitale Leistungsdiagnostik für Billard"})]})]}),l.jsx("nav",{className:"public-site__nav-links","aria-label":"Öffentliche Navigation",children:s.map(a=>l.jsx("button",{type:"button",className:`public-site__nav-link${a.active?" is-active":""}`,onClick:a.onClick,children:a.label},a.label))}),l.jsxs("div",{className:"public-site__nav-actions",children:[e&&l.jsx("div",{className:"public-site__theme-toggle",children:e}),l.jsxs("button",{type:"button",className:"public-site__cta public-site__cta--nav",onClick:r,children:["Anmelden",l.jsx(Bi,{className:"h-4 w-4","aria-hidden":"true"})]})]})]}),l.jsx("main",{className:"public-site__main",children:t}),l.jsx("footer",{className:"public-site__footer",children:l.jsxs("div",{className:"public-site__footer-inner",children:[l.jsxs("div",{className:"public-site__footer-links",children:[l.jsx("button",{type:"button",className:"public-site__footer-link",onClick:r,children:"Anmelden"}),rx.map(a=>l.jsx("button",{type:"button",className:`public-site__footer-link${i===a.path?" is-active":""}`,onClick:()=>n(a.path),children:a.label},a.path))]}),l.jsx("p",{className:"public-site__footer-meta",children:"PAT Manager · Öffentliche Seiten"})]})})]})}const nx=[{title:"Smarte Auswertungen",body:"Automatische Berechnungen für jede PAT-Kategorie mit klaren Kennzahlen, Trends und Fortschrittsbildern.",icon:$f},{title:"Sichere Speicherung",body:"Nutzergebundene Datenhaltung, finale Abschlüsse und kontrollierte Freigaben für Trainer, Verein und Staff.",icon:Ff},{title:"Team-ready",body:"Bewertungen erfassen, öffnen, teilen und wieder sperren, ohne Excel-Chaos oder doppelte Listen.",icon:ky},{title:"Performance-Insights",body:"Schwächen erkennen, Entwicklung verfolgen und Training gezielt auf die kritischen Übungen ausrichten.",icon:Uf},{title:"Mobile Erfassung",body:"Direkte Eingabe am Tisch mit klaren Grenzen pro Übung und sofortiger Berechnung der Punkte.",icon:vy},{title:"Export & Reports",body:"Saubere PDF-Ausgabe, öffentliche Freigabelinks und strukturierte Ergebnisansichten für Athleten und Staff.",icon:Mf}],sx=[{title:"Vorlage wählen",body:"PAT Start, PAT 1, PAT 2 oder PAT 3 auswählen und die Bewertung sofort anlegen."},{title:"Werte erfassen",body:"Einzelwerte direkt eingeben, automatisch begrenzen lassen und live berechnen."},{title:"Abschließen & teilen",body:"Bewertung final abschließen, als PDF exportieren oder per Link freigeben."}],ix=[{value:"100%",label:"Digitaler Ablauf"},{value:"0€",label:"Kostenlos starten"},{value:"SSL",label:"Verschlüsselte Übertragung"},{value:"24/7",label:"Jederzeit verfügbar"}],Xs=t=>{if(typeof document>"u")return;const e=document.getElementById(t);e&&e.scrollIntoView({behavior:"smooth",block:"start"})};function ax({onGetStarted:t,onNavigate:e,themeToggle:r}){return l.jsxs(kp,{themeToggle:r,onGetStarted:t,onNavigate:e,currentPath:"/",navLinks:[{label:"Features",onClick:()=>Xs("features")},{label:"So funktioniert es",onClick:()=>Xs("how-it-works")},{label:"Statistiken",onClick:()=>Xs("stats")}],children:[l.jsxs("section",{className:"public-hero",children:[l.jsxs("div",{children:[l.jsxs("span",{className:"public-hero__badge",children:[l.jsx($f,{className:"h-4 w-4","aria-hidden":"true"}),"Jetzt live verfügbar"]}),l.jsxs("h1",{className:"public-hero__title",children:["Professionelle",l.jsx("span",{className:"public-hero__title-accent",children:" PAT-Test Verwaltung"})]}),l.jsx("p",{className:"public-hero__copy",children:"Erfasse, analysiere und verfolge Pool Ability Tests digital. Von der Eingabe bis zum Report läuft alles in einer klaren Oberfläche für Trainer, Vereine und Spieler."}),l.jsxs("div",{className:"public-hero__actions",children:[l.jsxs("button",{type:"button",className:"public-site__button",onClick:t,children:["Kostenlos testen",l.jsx(Bi,{className:"h-4 w-4","aria-hidden":"true"})]}),l.jsx("button",{type:"button",className:"public-site__button--secondary",onClick:()=>Xs("features"),children:"Mehr erfahren"})]}),l.jsxs("div",{className:"public-hero__meta",children:[l.jsxs("span",{className:"public-chip",children:[l.jsx(sl,{className:"h-4 w-4 text-blue-300","aria-hidden":"true"}),"PAT Start bis PAT 3"]}),l.jsxs("span",{className:"public-chip",children:[l.jsx(sl,{className:"h-4 w-4 text-blue-300","aria-hidden":"true"}),"Teilen, PDF und Finalisierung"]})]})]}),l.jsxs("div",{className:"public-preview__panel",children:[l.jsxs("div",{className:"public-preview__head",children:[l.jsx("strong",{children:"Live Übersicht"}),l.jsx("span",{className:"public-preview__status",children:"Online"})]}),l.jsxs("div",{className:"public-preview__grid",children:[l.jsxs("div",{className:"public-preview__card",children:[l.jsx("div",{className:"public-preview__label",children:"PAT 1 · Übung 1"}),l.jsx("div",{className:"public-preview__value public-preview__value--accent",children:"4 / 4"}),l.jsx("div",{className:"public-progress",children:l.jsx("span",{style:{width:"100%"}})})]}),l.jsxs("div",{className:"public-preview__card",children:[l.jsx("div",{className:"public-preview__label",children:"Gesamtpunktzahl"}),l.jsx("div",{className:"public-preview__value public-preview__value--success",children:"87%"}),l.jsx("div",{className:"public-progress",children:l.jsx("span",{style:{width:"87%"}})})]})]}),l.jsxs("div",{className:"public-preview__meta",children:[l.jsxs("div",{className:"public-preview__meta-card",children:[l.jsx("div",{className:"public-preview__label",children:"Aktive Bewertung"}),l.jsx("strong",{children:"Stefan · PAT 1"})]}),l.jsxs("div",{className:"public-preview__meta-card",children:[l.jsx("div",{className:"public-preview__label",children:"Status"}),l.jsx("strong",{children:"Freigabe aktiv"})]}),l.jsxs("div",{className:"public-preview__meta-card",children:[l.jsx("div",{className:"public-preview__label",children:"Workflow"}),l.jsx("strong",{children:"Erfassen · Finalisieren"})]}),l.jsxs("div",{className:"public-preview__meta-card",children:[l.jsx("div",{className:"public-preview__label",children:"Auswertung"}),l.jsx("strong",{children:"PDF & Analyse"})]})]})]})]}),l.jsxs("section",{className:"public-section",id:"features",children:[l.jsxs("div",{className:"public-section__header",children:[l.jsx("span",{className:"public-section__tag",children:"Funktionen"}),l.jsx("h2",{className:"public-section__title",children:"Alles, was du für PAT-Tests brauchst"}),l.jsx("p",{className:"public-section__copy",children:"Von der digitalen Erfassung bis zur teamweiten Auswertung. Die neue Startseite orientiert sich an deiner Vorlage, sitzt aber sauber im bestehenden Produktstil."})]}),l.jsx("div",{className:"public-features",children:nx.map(({title:n,body:s,icon:i})=>l.jsxs("article",{className:"public-card",children:[l.jsx("span",{className:"public-card__icon",children:l.jsx(i,{className:"h-5 w-5","aria-hidden":"true"})}),l.jsx("h3",{className:"public-card__title",children:n}),l.jsx("p",{className:"public-card__copy",children:s})]},n))})]}),l.jsxs("section",{className:"public-section",id:"how-it-works",children:[l.jsxs("div",{className:"public-section__header",children:[l.jsx("span",{className:"public-section__tag",children:"Prozess"}),l.jsx("h2",{className:"public-section__title",children:"So läuft PAT mit uns"}),l.jsx("p",{className:"public-section__copy",children:"Von der Testvorlage bis zum Report bleibt der Ablauf kurz, klar und sicher."})]}),l.jsx("div",{className:"public-steps",children:sx.map((n,s)=>l.jsxs("article",{className:"public-card public-step",children:[l.jsx("span",{className:"public-step__number",children:s+1}),l.jsx("h3",{className:"public-step__title",children:n.title}),l.jsx("p",{className:"public-step__copy",children:n.body})]},n.title))})]}),l.jsxs("section",{className:"public-section",id:"stats",children:[l.jsxs("div",{className:"public-section__header",children:[l.jsx("span",{className:"public-section__tag",children:"Statistiken"}),l.jsx("h2",{className:"public-section__title",children:"Klare Vorteile für den Alltag am Tisch"}),l.jsx("p",{className:"public-section__copy",children:"Weniger Listenpflege, weniger Medienbrüche und deutlich schneller von der Eingabe zur Auswertung."})]}),l.jsx("div",{className:"public-stats",children:ix.map(n=>l.jsxs("article",{className:"public-stats__card",children:[l.jsx("div",{className:"public-stats__value",children:n.value}),l.jsx("div",{className:"public-stats__label",children:n.label})]},n.label))})]}),l.jsx("section",{className:"public-section",children:l.jsxs("div",{className:"public-cta-panel",children:[l.jsxs("div",{children:[l.jsx("span",{className:"public-section__tag",children:"Bereit?"}),l.jsx("h2",{className:"public-cta-panel__title",children:"Starte deine nächste PAT-Bewertung ohne Tabellenchaos."}),l.jsx("p",{className:"public-cta-panel__copy",children:"Login öffnen, Bewertung anlegen, Werte eintragen und Ergebnisse direkt sauber speichern oder teilen."})]}),l.jsxs("div",{className:"public-cta-panel__actions",children:[l.jsxs("button",{type:"button",className:"public-site__button",onClick:t,children:["Jetzt kostenlos ausprobieren",l.jsx(Bi,{className:"h-4 w-4","aria-hidden":"true"})]}),l.jsx("button",{type:"button",className:"public-site__button--secondary",onClick:()=>e("/kontakt"),children:"Kontakt öffnen"})]})]})})]})}const ox=t=>{if(!t)return"—";const e=new Date(t);return Number.isNaN(e.getTime())?t:new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}).format(e)},lx=t=>t===""||t===null||typeof t>"u"?"—":t,oo=({label:t,values:e=[]})=>l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l.jsx("span",{className:"min-w-10 text-sm font-semibold text-gray-600 dark:text-gray-300",children:t}),e.map((r,n)=>l.jsx("span",{className:"min-w-12 rounded-md border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 px-3 py-2 text-center text-sm font-medium text-gray-800 dark:text-gray-100",children:lx(r)},`${t}-${n}`))]});function ux({assessment:t}){if(!t)return null;const e=ga(t.exercises||[]),r=ol(t.patType,e);return l.jsx("div",{className:"min-h-screen bg-gray-100 dark:bg-gray-950 p-6 text-gray-900 dark:text-gray-100",children:l.jsx("div",{className:"max-w-5xl mx-auto",children:l.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-lg p-6 border border-gray-200 dark:border-gray-800",children:[l.jsxs("div",{className:"flex justify-between items-start gap-4 mb-6 flex-wrap",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-xs uppercase tracking-[0.2em] text-sky-700 dark:text-sky-300",children:"Geteilter Test"}),l.jsx("h1",{className:"text-3xl font-bold text-gray-800 dark:text-gray-100 mt-2",children:t.name||"PAT Test"}),l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 mt-2",children:"Dieser Link zeigt nur diesen einen Test im Nur-Lesen-Modus."})]}),l.jsx("span",{className:`px-4 py-2 rounded-full text-sm font-semibold ${al(t.patType)}`,children:t.patType})]}),l.jsxs("div",{className:"grid md:grid-cols-3 gap-3 mb-6 bg-gray-50 dark:bg-gray-800 p-4 rounded-lg",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Datum"}),l.jsx("p",{className:"mt-1 text-lg font-semibold",children:ox(t.datum)})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Gesamtpunkte"}),l.jsx("p",{className:"mt-1 text-lg font-semibold text-green-600 dark:text-green-300",children:e.toFixed(0)})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Bewertung"}),l.jsx("p",{className:"mt-1 text-lg font-semibold",children:r.name})]})]}),(t.exercises||[]).map((n,s)=>{var i,a;return l.jsxs("div",{className:"mb-6 border-b pb-4 border-gray-200 dark:border-gray-800",children:[l.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3 flex-wrap",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"font-bold text-lg text-gray-700 dark:text-gray-200",children:n.name}),l.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Soll ",n.soll," · Faktor ",n.faktor]})]}),l.jsxs("div",{className:"rounded-lg bg-green-50 dark:bg-green-900/30 px-4 py-2",children:[l.jsx("p",{className:"text-xs uppercase tracking-wide text-green-700 dark:text-green-300",children:"Points"}),l.jsx("p",{className:"text-xl font-bold text-green-700 dark:text-green-200",children:(n.points||0).toFixed(0)})]})]}),l.jsx("div",{className:"space-y-3",children:n.subA&&n.subB?l.jsxs(l.Fragment,{children:[l.jsx(oo,{label:((i=n.subLabels)==null?void 0:i[0])||"a)",values:n.subA}),l.jsx(oo,{label:((a=n.subLabels)==null?void 0:a[1])||"b)",values:n.subB})]}):l.jsx(oo,{label:"Werte",values:n.values||[]})}),l.jsxs("div",{className:"grid md:grid-cols-3 gap-3 mt-4",children:[l.jsxs("div",{className:"rounded-lg bg-blue-50 dark:bg-blue-900/30 px-4 py-3",children:[l.jsx("p",{className:"text-xs uppercase tracking-wide text-blue-700 dark:text-blue-300",children:"Durchschnitt"}),l.jsx("p",{className:"text-lg font-semibold text-blue-700 dark:text-blue-200",children:(n.durchschnitt||0).toFixed(2)})]}),l.jsxs("div",{className:"rounded-lg bg-gray-50 dark:bg-gray-800 px-4 py-3",children:[l.jsx("p",{className:"text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Soll"}),l.jsx("p",{className:"text-lg font-semibold",children:n.soll})]}),l.jsxs("div",{className:"rounded-lg bg-gray-50 dark:bg-gray-800 px-4 py-3",children:[l.jsx("p",{className:"text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Faktor"}),l.jsx("p",{className:"text-lg font-semibold",children:n.faktor})]})]})]},`${n.name}-${s}`)}),l.jsxs("div",{className:"mt-6 bg-gradient-to-r from-green-100 to-blue-100 dark:from-gray-800 dark:to-gray-700 p-6 rounded-lg",children:[l.jsxs("div",{className:"flex justify-between items-center gap-4 flex-wrap mb-4",children:[l.jsx("span",{className:"text-2xl font-bold text-gray-800 dark:text-gray-100",children:"Ergebnis"}),l.jsx("span",{className:"text-4xl font-bold text-green-600 dark:text-green-300",children:e.toFixed(0)})]}),l.jsxs("div",{className:`mt-4 px-6 py-4 rounded-lg ${r.color} ${r.text} text-center`,children:[l.jsx("p",{className:"text-2xl font-bold",children:r.name}),r.subtitle&&l.jsx("p",{className:"text-lg mt-2",children:r.subtitle})]})]})]})})})}function cx({shareToken:t,themeToggle:e}){const[r,n]=T.useState(null),[s,i]=T.useState(!0),[a,o]=T.useState("");return T.useEffect(()=>{let u=!1;return(async()=>{if(!t){o("Freigabelink fehlt."),i(!1);return}i(!0),o("");try{const d=await Yw(t);if(u)return;if(!d){n(null),o("Dieser Freigabelink ist ungültig, deaktiviert oder aktuell nicht öffentlich sichtbar.");return}n(d)}catch(d){if(u)return;n(null),o(d.message||"Geteilter Test konnte nicht geladen werden.")}finally{u||i(!1)}})(),()=>{u=!0}},[t]),l.jsxs("div",{className:"min-h-screen bg-gray-100 dark:bg-gray-950 text-gray-900 dark:text-gray-100",children:[l.jsx("div",{className:"absolute top-4 right-4 z-20",children:e}),s?l.jsx("div",{className:"min-h-screen flex items-center justify-center p-6",children:l.jsx("div",{className:"bg-white dark:bg-gray-900 rounded-xl border border-gray-200 dark:border-gray-800 shadow-sm p-6",children:"Geteilter Test wird geladen..."})}):a?l.jsx("div",{className:"min-h-screen flex items-center justify-center p-6",children:l.jsxs("div",{className:"max-w-xl w-full bg-white dark:bg-gray-900 rounded-xl border border-gray-200 dark:border-gray-800 shadow-sm p-6",children:[l.jsx("p",{className:"text-xs uppercase tracking-[0.2em] text-rose-600 dark:text-rose-300",children:"Freigabe"}),l.jsx("h1",{className:"text-2xl font-bold mt-2",children:"Geteilter Test nicht verfügbar"}),l.jsx("p",{className:"text-gray-600 dark:text-gray-300 mt-3",children:a})]})}):l.jsx(ux,{assessment:r})]})}const vd={"/datenschutz":{tag:"Datenschutz",title:"Datenschutzhinweise für PAT Manager",intro:"Diese Seite ist als saubere öffentliche Datenschutzansicht angelegt. Inhaltlich solltest du sie vor dem Livegang noch mit deinen finalen Verantwortlichen, Kontaktdaten und juristisch geprüften Angaben vervollständigen.",cards:[{title:"Verantwortliche Stelle",body:"Trage hier den Vereinsnamen, die verantwortliche Person oder das Unternehmen ein, das PAT Manager betreibt. Ergänze außerdem Anschrift und eine echte Kontaktmöglichkeit."},{title:"Welche Daten verarbeitet werden",body:"Je nach Nutzung können Anmeldedaten, Bewertungsdaten, Freigaben, PDF-Exporte und technische Zugriffsdaten verarbeitet werden. Bei geteilten Bewertungen sehen anonyme Nutzer nur die explizit freigegebene Ansicht."},{title:"Zweck der Verarbeitung",body:"Die Verarbeitung dient der Durchführung von PAT-Bewertungen, der Auswertung von Leistungsdaten, der Teamorganisation sowie dem sicheren Speichern und Teilen einzelner Testergebnisse."},{title:"Speicherung und Dienstleister",body:"Die Anwendung nutzt Supabase als technische Datenbasis. Prüfe vor dem produktiven Einsatz die Auftragsverarbeitung, Speicherregion und die tatsächlich eingesetzten Zusatzdienste."},{title:"Rechte der betroffenen Personen",items:["Auskunft über gespeicherte Daten","Berichtigung unrichtiger Daten","Löschung oder Einschränkung der Verarbeitung","Widerspruch gegen einzelne Verarbeitungen","Beschwerde bei der zuständigen Aufsichtsbehörde"]},{title:"Wichtiger Hinweis",wide:!0,notice:"Diese Datenschutzseite ist eine strukturierte Vorlage. Vor der Veröffentlichung müssen echte Kontaktdaten, Rechtsgrundlagen, Speicherfristen und Dienstleisterangaben ergänzt und geprüft werden."}]},"/impressum":{tag:"Impressum",title:"Impressum für PAT Manager",intro:"Die Seite ist technisch fertig eingebunden, damit deine Footer- und Navigationslinks nicht mehr ins Leere laufen. Die konkreten Pflichtangaben musst du jetzt noch mit deinen echten Daten ergänzen.",cards:[{title:"Angaben gemäß § 5 TMG",body:"Ergänze hier Betreibername, Rechtsform, vertretungsberechtigte Person sowie die vollständige ladungsfähige Anschrift."},{title:"Kontakt",body:"Trage hier eine echte E-Mail-Adresse, optional Telefonnummer und weitere Kommunikationswege ein, unter denen Nutzer dich rechtssicher erreichen können."},{title:"Verantwortlich für den Inhalt",body:"Wenn erforderlich, ergänze die verantwortliche Person nach § 18 Abs. 2 MStV mit Name und Anschrift."},{title:"Haftungs- und Linkhinweise",body:"Wenn du externe Dienste, Inhalte oder Verlinkungen nutzt, prüfe bitte deine endgültigen Texte zu Haftung, Urheberrecht und externen Verweisen."},{title:"Wichtiger Hinweis",wide:!0,notice:"Dieses Impressum enthält absichtlich keine erfundenen Unternehmensdaten. Bitte ersetze die Platzhalter vor Veröffentlichung durch deine echten Pflichtangaben."}]},"/kontakt":{tag:"Kontakt",title:"Kontakt und Rückfragen",intro:"Hier ist eine öffentliche Kontaktseite im Stil der neuen Startseite eingebunden. Wenn du reale Ansprechpartner und Kanäle ergänzt, kannst du sie direkt produktiv nutzen.",cards:[{title:"Produkt & Demo",body:"Nutze diesen Bereich für Anfragen zu PAT Manager, Demos, Vereinsnutzung oder Einführung im Trainingsalltag."},{title:"Technischer Support",body:"Hier kannst du später Support-Zeiten, E-Mail-Adresse, Reaktionszeiten oder einen Helpdesk-Link ergänzen."},{title:"Kooperationen",body:"Platz für Kontakte zu Vereinen, Trainern, Leistungszentren oder Partnern, die das System einsetzen oder testen möchten."},{title:"Empfohlene nächste Ergänzungen",items:["Echte Support-E-Mail oder Kontaktformular verknüpfen","Antwortzeiten und Zuständigkeiten ergänzen","Optional Telefonnummer oder Vereinsanschrift angeben"]},{title:"Schnellzugriff",wide:!0,action:!0,body:"Wenn du direkt in die Anwendung wechseln willst, kannst du von hier aus sofort den Login öffnen und weiterarbeiten."}]}};function dx({path:t,onGetStarted:e,onNavigate:r,themeToggle:n}){const s=vd[t]||vd["/kontakt"];return l.jsx(kp,{themeToggle:n,onGetStarted:e,onNavigate:r,currentPath:t,navLinks:[{label:"Startseite",onClick:()=>r("/")},{label:"Datenschutz",onClick:()=>r("/datenschutz"),active:t==="/datenschutz"},{label:"Impressum",onClick:()=>r("/impressum"),active:t==="/impressum"},{label:"Kontakt",onClick:()=>r("/kontakt"),active:t==="/kontakt"}],children:l.jsxs("section",{className:"public-page",children:[l.jsxs("div",{className:"public-page__hero",children:[l.jsxs("span",{className:"public-section__tag",children:[t==="/kontakt"?l.jsx(fy,{className:"h-4 w-4","aria-hidden":"true"}):l.jsx(dy,{className:"h-4 w-4","aria-hidden":"true"}),s.tag]}),l.jsx("h1",{className:"public-page__title",children:s.title}),l.jsx("p",{className:"public-page__copy",children:s.intro})]}),l.jsx("div",{className:"public-page__grid",children:s.cards.map(i=>l.jsxs("article",{className:`public-page__card${i.wide?" public-page__card--wide":""}`,children:[l.jsx("h2",{className:"public-page__card-title",children:i.title}),i.body&&l.jsx("p",{className:"public-page__card-copy",children:i.body}),i.items&&l.jsx("ul",{className:"public-page__list",children:i.items.map(a=>l.jsx("li",{children:a},a))}),i.notice&&l.jsx("div",{className:"public-page__notice",children:i.notice}),i.action&&l.jsxs("div",{className:"public-hero__actions",children:[l.jsxs("button",{type:"button",className:"public-site__button",onClick:e,children:["Login öffnen",l.jsx(Bi,{className:"h-4 w-4","aria-hidden":"true"})]}),l.jsx("button",{type:"button",className:"public-site__button--secondary",onClick:()=>r("/"),children:"Zur Startseite"})]})]},i.title))}),l.jsx("section",{className:"public-section",children:l.jsxs("div",{className:"public-cta-panel",children:[l.jsxs("div",{children:[l.jsxs("span",{className:"public-section__tag",children:[l.jsx(Ff,{className:"h-4 w-4","aria-hidden":"true"}),"Öffentliche Seiten fertig"]}),l.jsx("h2",{className:"public-cta-panel__title",children:"Die verlinkten Info-Seiten sind jetzt Bestandteil der App."}),l.jsx("p",{className:"public-cta-panel__copy",children:"Ergänze jetzt noch deine echten Vereins-, Kontakt- und Rechtstexte. Danach laufen Navigation und Footer sauber ohne Platzhalterlinks."})]}),l.jsxs("div",{className:"public-cta-panel__actions",children:[l.jsx("button",{type:"button",className:"public-site__button",onClick:()=>r("/"),children:"Zur Startseite"}),l.jsx("button",{type:"button",className:"public-site__button--secondary",onClick:e,children:"App öffnen"})]})]})})]})})}const hx=[{code:"AR",name:"Argentinien"},{code:"AU",name:"Australien"},{code:"AT",name:"Österreich"},{code:"BE",name:"Belgien"},{code:"BA",name:"Bosnien und Herzegowina"},{code:"BR",name:"Brasilien"},{code:"BG",name:"Bulgarien"},{code:"CA",name:"Kanada"},{code:"CL",name:"Chile"},{code:"CN",name:"China"},{code:"CO",name:"Kolumbien"},{code:"CZ",name:"Tschechien"},{code:"DK",name:"Dänemark"},{code:"DE",name:"Deutschland"},{code:"EE",name:"Estland"},{code:"FI",name:"Finnland"},{code:"FR",name:"Frankreich"},{code:"GR",name:"Griechenland"},{code:"GB",name:"Vereinigtes Königreich"},{code:"IE",name:"Irland"},{code:"IS",name:"Island"},{code:"IN",name:"Indien"},{code:"IT",name:"Italien"},{code:"JP",name:"Japan"},{code:"HR",name:"Kroatien"},{code:"LV",name:"Lettland"},{code:"LI",name:"Liechtenstein"},{code:"LT",name:"Litauen"},{code:"LU",name:"Luxemburg"},{code:"MT",name:"Malta"},{code:"MX",name:"Mexiko"},{code:"NL",name:"Niederlande"},{code:"NZ",name:"Neuseeland"},{code:"NO",name:"Norwegen"},{code:"PL",name:"Polen"},{code:"PT",name:"Portugal"},{code:"RO",name:"Rumänien"},{code:"SE",name:"Schweden"},{code:"CH",name:"Schweiz"},{code:"SK",name:"Slowakei"},{code:"SI",name:"Slowenien"},{code:"ES",name:"Spanien"},{code:"ZA",name:"Südafrika"},{code:"KR",name:"Südkorea"},{code:"TR",name:"Türkei"},{code:"UA",name:"Ukraine"},{code:"HU",name:"Ungarn"},{code:"US",name:"Vereinigte Staaten"}],_p=[...hx].sort((t,e)=>t.name.localeCompare(e.name,"de")),Cu=(t="")=>{const e=String(t||"").trim().toUpperCase();return e&&_p.find(r=>r.code===e)||null},Mn=(t="")=>{const e=Cu(t);return e?e.name:String(t||"").trim()};var fx=["title"],px=["title"],gx=["title"],mx=["title"],yx=["title"],vx=["title"],wx=["title"],xx=["title"],bx=["title"],kx=["title"],_x=["title"],Ex=["title"],Sx=["title"],jx=["title"],Nx=["title"],Tx=["title"],Px=["title"],Cx=["title"],Ax=["title"],Ox=["title"],Rx=["title"],zx=["title"],Ix=["title"],Lx=["title"],Dx=["title"],Mx=["title"],Fx=["title"],$x=["title"],Bx=["title"],Ux=["title"],Hx=["title"],Vx=["title"],Wx=["title"],Kx=["title"],qx=["title"],Gx=["title"],Jx=["title"],Qx=["title"],Yx=["title"],Zx=["title"],Xx=["title"],eb=["title"],tb=["title"],rb=["title"],nb=["title"],sb=["title"],ib=["title"],ab=["title"];function $(){return $=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},$.apply(this,arguments)}function B(t,e){if(t==null)return{};var r=ob(t,e),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)n=i[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function ob(t,e){if(t==null)return{};var r={},n=Object.keys(t),s,i;for(i=0;i<n.length;i++)s=n[i],!(e.indexOf(s)>=0)&&(r[s]=t[s]);return r}var lb=function(e){var r=e.title,n=B(e,fx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFF",d:"M0 0h512v342H0z"}),v.createElement("path",{fill:"#338AF3",d:"M0 0h512v114H0zm0 228h512v114H0z"}),v.createElement("circle",{fill:"#FFDA44",stroke:"#d6ab00",strokeWidth:5,cx:256.5,cy:171,r:40}))},ub=function(e){var r=e.title,n=B(e,px);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFF",d:"M0 114h513v114H0z"}),v.createElement("path",{fill:"#D80027",d:"M0 0h513v114H0zm0 228h513v114H0z"}))},cb=function(e){var r=e.title,n=B(e,gx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#00008b",d:"M0 0h513v342H0z"}),v.createElement("path",{d:"m188 212.6 11 22.9 24.7-5.7-11 22.8 19.9 15.8-24.8 5.6.1 25.4-19.9-15.9-19.8 15.9.1-25.4-24.8-5.6 19.9-15.8-11.1-22.8 24.8 5.7zm197.9 28.5 5.2 10.9 11.8-2.7-5.3 10.9 9.5 7.5-11.8 2.6v12.2l-9.4-7.6-9.5 7.6.1-12.2-11.8-2.6 9.5-7.5-5.3-10.9 11.8 2.7zm-48.6-116 5.2 10.9 11.8-2.7-5.3 10.9 9.5 7.5-11.8 2.7v12.1l-9.4-7.6-9.5 7.6.1-12.1-11.9-2.7 9.5-7.5-5.3-10.9L332 136zm48.6-66.2 5.2 10.9 11.8-2.7-5.3 10.9 9.5 7.5-11.8 2.7v12.1l-9.4-7.6-9.5 7.6.1-12.1-11.8-2.7 9.5-7.5-5.3-10.9 11.8 2.7zm42.5 49.7 5.2 10.9 11.8-2.7-5.3 10.9 9.5 7.5-11.8 2.6V150l-9.4-7.6-9.5 7.6v-12.2l-11.8-2.6 9.5-7.5-5.3-10.9 11.8 2.7zM398 166.5l4.1 12.7h13.3l-10.8 7.8 4.2 12.7-10.8-7.9-10.8 7.9 4.1-12.7-10.7-7.8h13.3z",fill:"#FFF"}),v.createElement("path",{fill:"#00008b",d:"M0 0h256.5v171H0z"}),v.createElement("g",{fill:"#FFF"},v.createElement("path",{d:"M256.5 0v30.6l-45.3 25.2h45.3v59.4h-59.2l59.2 32.9V171h-26.7l-73.7-40.9V171h-55.7v-48.7L12.8 171H0v-30.6l45.3-25.2H0V55.8h59.2L0 22.9V0h26.7l73.7 40.9V0h55.7v48.7L243.7 0z"}),v.createElement("path",{d:"M156.1 115.2 256.5 171v-15.8l-72-40zm-55.7-59.4L0 0v15.8l72 40z"})),v.createElement("g",{fill:"red"},v.createElement("path",{d:"M144.3 0h-32.1v69.5H0v32h112.2V171h32.1v-69.5h112.2v-32H144.3z"}),v.createElement("path",{d:"M156.1 115.2 256.5 171v-15.8l-72-40zm-84.1 0-72 40V171l100.4-55.8zm28.4-59.4L0 0v15.8l72 40zm84.1 0 72-40V0L156.1 55.8z"})))},db=function(e){var r=e.title,n=B(e,mx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#10338C",d:"M0 0h513v342H0z"}),v.createElement("path",{fill:"#F6C500",d:"M99.9 0h342v342"}),v.createElement("g",{fill:"#FFF"},v.createElement("path",{d:"M19.9 21.1 40.3 6.2 60.9 21 54 0H26.7z"}),v.createElement("path",{d:"M92.3 25.5 84.4 1.3l-7.8 24.2H51.3l20.5 14.8-7.8 24 20.4-14.8L105 64.3l-7.9-24 20.5-14.9z"}),v.createElement("path",{d:"m136.3 69.2-7.8-24-7.8 24H95.5l20.4 14.9-7.8 24 20.4-14.8 20.6 14.8-7.8-24 20.4-14.9z"}),v.createElement("path",{d:"m179.4 112.3-7.8-24.1-7.8 24.1h-25.3l20.5 14.9-7.8 24 20.4-14.8 20.6 14.8-7.9-24 20.5-15z"}),v.createElement("path",{d:"m222.5 155.3-7.8-24-7.8 24h-25.4l20.6 15-7.8 24 20.4-14.9 20.4 14.9-7.8-24 20.6-15z"}),v.createElement("path",{d:"m265.6 198.4-7.8-24-7.8 24h-25.4l20.6 14.9-7.8 24.1 20.4-14.9 20.4 14.9-7.8-24.2 20.5-14.8z"}),v.createElement("path",{d:"m308.7 241.5-7.9-24-7.8 24h-25.3l20.5 14.8-7.9 24.2 20.6-14.9 20.4 14.8-7.8-24.1 20.5-14.8z"}),v.createElement("path",{d:"m351.7 284.6-7.8-24.2-7.8 24.2h-25.3l20.4 14.8-7.8 24.1 20.5-14.9 20.5 14.9-7.8-24.1 20.4-14.8z"}),v.createElement("path",{d:"m387 303.5-7.9 24.1-25.3.1 19.8 14.3h26.6l19.9-14.4h-25.3z"})))},hb=function(e){var r=e.title,n=B(e,yx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#fdda25",d:"M0 0h513v342H0z"}),v.createElement("path",{d:"M0 0h171v342H0z"}),v.createElement("path",{fill:"#ef3340",d:"M342 0h171v342H342z"}))},fb=function(e){var r=e.title,n=B(e,vx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#00966e",d:"M0 0h513v342H0z"}),v.createElement("path",{fill:"#FFF",d:"M0 0h513v114H0z"}),v.createElement("path",{fill:"#d62612",d:"M0 228h513v114H0z"}))},pb=function(e){var r=e.title,n=B(e,wx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#009b3a",d:"M0 0h513v342H0z"}),v.createElement("path",{fill:"#fedf00",d:"m256.5 19.3 204.9 151.4L256.5 322 50.6 170.7z"}),v.createElement("circle",{fill:"#FFF",cx:256.5,cy:171,r:80.4}),v.createElement("path",{fill:"#002776",d:"M215.9 165.7c-13.9 0-27.4 2.1-40.1 6 .6 43.9 36.3 79.3 80.3 79.3 27.2 0 51.3-13.6 65.8-34.3-24.9-31-63.2-51-106-51zm119 20.3c.9-5 1.5-10.1 1.5-15.4 0-44.4-36-80.4-80.4-80.4-33.1 0-61.5 20.1-73.9 48.6 10.9-2.2 22.1-3.4 33.6-3.4 46.8.1 89 19.5 119.2 50.6z"}))},gb=function(e){var r=e.title,n=B(e,xx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFF",d:"M0 0h513v342H0z"}),v.createElement("path",{d:"M0 0h142v342H0zm371 0h142v342H371zm-64.5 206 50.4-25.2-25.2-12.6V143l-50.4 25.2 25.2-50.4h-25.2L256.1 80l-25.2 37.8h-25.2l25.2 50.4-50.4-25.2v25.2l-25.2 12.6 50.4 25.2-12.6 25.2h50.4V269h25.2v-37.8h50.4z",fill:"red"}))},mb=function(e){var r=e.title,n=B(e,bx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 768 512"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"red",d:"M0 0h768v512H0V0z"}),v.createElement("path",{fill:"#FFF",d:"M336 96h96v112h112v96H432v112h-96V304H224v-96h112V96z"}))},yb=function(e){var r=e.title,n=B(e,kx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#D80027",d:"M0 0h513v342H0z"}),v.createElement("path",{fill:"#FFF",d:"M196 0h317v171H196z"}),v.createElement("path",{fill:"#0037A1",d:"M0 0h196v171H0z"}),v.createElement("path",{fill:"#FFF",d:"M98 24.5 113.1 71H162l-39.6 28.7 15.2 46.5L98 117.5l-39.6 28.7 15.2-46.5L34 71h48.9z"}))},vb=function(e){var r=e.title,n=B(e,_x);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#D80027",d:"M0 0h513v342H0z"}),v.createElement("path",{d:"m226.8 239.2-9.7-15.6-17.9 4.4 11.9-14.1-9.7-15.6 17.1 6.9 11.8-14.1-1.3 18.4 17.1 6.9-17.9 4.4zM290.6 82l-10.1 15.4 11.6 14.3-17.7-4.8-10.1 15.5-1-18.4-17.7-4.8 17.2-6.6-1-18.4 11.6 14.3zm-54.4-56.6-2 18.3 16.8 7.6-18 3.8-2 18.3-9.2-16-17.9 3.8 12.3-13.7-9.2-15.9 16.8 7.5zm56.6 136.4-14.9 10.9 5.8 17.5-14.9-10.8-14.9 11 5.6-17.6-14.9-10.7 18.4-.1 5.6-17.6 5.8 17.5zM115 46.3l17.3 53.5h56.2l-45.4 32.9 17.3 53.5-45.4-33-45.5 33 17.4-53.5-45.5-32.9h56.3z",fill:"#FFDA44"}))},wb=function(e){var r=e.title,n=B(e,Ex);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFDA44",d:"M0 0h513v342H0z"}),v.createElement("path",{fill:"#D80027",d:"M0 256.5h513V342H0z"}),v.createElement("path",{fill:"#0052B4",d:"M0 171h513v85.5H0z"}))},xb=function(e){var r=e.title,n=B(e,Sx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#11457e",d:"M0 0h513v342H0z"}),v.createElement("path",{fill:"#d7141a",d:"M513 171v171H0l256.5-171z"}),v.createElement("path",{fill:"#FFF",d:"M513 0v171H256.5L0 0z"}))},bb=function(e){var r=e.title,n=B(e,jx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#D80027",d:"M0 0h513v342H0z"}),v.createElement("path",{d:"M0 0h513v114H0z"}),v.createElement("path",{fill:"#FFDA44",d:"M0 228h513v114H0z"}))},kb=function(e){var r=e.title,n=B(e,Nx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#c60c30",d:"M0 0h513v342H0z"}),v.createElement("path",{fill:"#FFF",d:"M190 0h-60v140H0v60h130v142h60V200h323v-60H190z"}))},_b=function(e){var r=e.title,n=B(e,Tx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#111",d:"M0 0h513v342H0z"}),v.createElement("path",{fill:"#368FD8",d:"M0 0h513v114H0z"}),v.createElement("path",{fill:"#FFF",d:"M0 228h513v114H0z"}))},Eb=function(e){var r=e.title,n=B(e,Px);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 22.5 15"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFF",d:"M0 0h22.5v15H0V0z"}),v.createElement("path",{fill:"#D03433",d:"M0 0h22.5v4H0V0zm0 11h22.5v4H0v-4z"}),v.createElement("path",{fill:"#FBCA46",d:"M0 4h22.5v7H0V4z"}),v.createElement("path",{fill:"#FFF",d:"M7.8 7h1v.5h-1V7z"}),v.createElement("path",{fill:"#A41517",d:"M7.2 8.5c0 .3.3.5.6.5s.6-.2.6-.5L8.5 7H7.1l.1 1.5zM6.6 7c0-.3.2-.5.4-.5h1.5c.3 0 .5.2.5.4V7l-.1 1.5c-.1.6-.5 1-1.1 1-.6 0-1-.4-1.1-1L6.6 7z"}),v.createElement("path",{fill:"#A41517",d:"M6.8 7.5h2V8h-.5l-.5 1-.5-1h-.5v-.5zM5.3 6h1v3.5h-1V6zm4 0h1v3.5h-1V6zm-2.5-.5c0-.3.2-.5.5-.5h1c.3 0 .5.2.5.5v.2c0 .2-.1.3-.3.3H7c-.1 0-.2-.1-.2-.2v-.3z"}))},Sb=function(e){var r=e.title,n=B(e,Cx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFF",d:"M0 0h513v342H0z"}),v.createElement("path",{fill:"#2E52B2",d:"M513 129.3V212H203.7v130H121V212H0v-82.7h121V0h82.7v129.3z"}))},jb=function(e){var r=e.title,n=B(e,Ax);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFF",d:"M0 0h513v342H0z"}),v.createElement("path",{fill:"#00318A",d:"M0 0h171v342H0z"}),v.createElement("path",{fill:"#D80027",d:"M342 0h171v342H342z"}))},Nb=function(e){var r=e.title,n=B(e,Ox);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("g",{fill:"#FFF"},v.createElement("path",{d:"M0 0h513v341.3H0V0z"}),v.createElement("path",{d:"M311.7 230 513 341.3v-31.5L369.3 230h-57.6zM200.3 111.3 0 0v31.5l143.7 79.8h56.6z"})),v.createElement("path",{d:"M393.8 230 513 295.7V230H393.8zm-82.1 0L513 341.3v-31.5L369.3 230h-57.6zm146.9 111.3-147-81.7v81.7h147zM90.3 230 0 280.2V230h90.3zm110 14.2v97.2H25.5l174.8-97.2zm-82.1-132.9L0 45.6v65.7h118.2zm82.1 0L0 0v31.5l143.7 79.8h56.6zM53.4 0l147 81.7V0h-147zm368.3 111.3L513 61.1v50.2h-91.3zm-110-14.2V0h174.9L311.7 97.1z",fill:"#012169"}),v.createElement("g",{fill:"#c8102e"},v.createElement("path",{d:"M288 0h-64v138.7H0v64h224v138.7h64V202.7h224v-64H288V0z"}),v.createElement("path",{d:"M311.7 230 513 341.3v-31.5L369.3 230h-57.6zm-168 0L0 309.9v31.5L200.3 230h-56.6zm56.6-118.7L0 0v31.5l143.7 79.8h56.6zm168 0L513 31.5V0L311.7 111.3h56.6z"})))},Tb=function(e){var r=e.title,n=B(e,Rx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFF",d:"M0 0h513v342H0z"}),v.createElement("g",{fill:"#0d5eaf"},v.createElement("path",{d:"M0 0h513v38H0zm0 76h513v38H0zm0 76h513v38H0zm0 76h513v38H0zm0 76h513v38H0z"}),v.createElement("path",{d:"M0 0h190v190H0z"})),v.createElement("g",{fill:"#FFF"},v.createElement("path",{d:"M0 76h190v38H0z"}),v.createElement("path",{d:"M76 0h38v190H76z"})))},Pb=function(e){var r=e.title,n=B(e,zx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFF",d:"M0 0h513v342H0z"}),v.createElement("path",{fill:"#D80027",d:"M0 0h513v114H0z"}),v.createElement("path",{fill:"#0052B4",d:"M0 228h513v114H0z"}),v.createElement("path",{d:"M309.3 113.2v-44l17.5-14.4 17.7 14.4v44zm-105.6 0v-44l-17.3-14.4-17.9 14.4v44zm35.2 0v-44l17.6-14.4 17.6 14.4v44z",fill:"#338AF3"}),v.createElement("path",{d:"M309.3 113.2h-35.2v-44l17.5-14.4 17.7 14.4zm-70.4 0h-35.2v-44l17.5-14.4 17.7 14.4z",fill:"#0052B4"}),v.createElement("path",{stroke:"#D80027",fill:"#FFF",d:"M168.5 113.2v101.9c0 24.3 14.4 46.2 35.4 59.4 21.3 13.4 42.1 14.7 52.6 14.7s31.4-1.7 52.6-14.8c21-13 35.4-35.1 35.4-59.3V113.2h-176z"}),v.createElement("path",{d:"M168.5 113.2h35.2v35.2h-35.2zm70.4 0h35.2v35.2h-35.2zm70.4 0h35.2v35.2h-35.2zm-105.6 35.2h35.2v35.2h-35.2zm70.4 0h35.2v35.2h-35.2zm-105.6 35.2h35.2v35.2h-35.2zm35.2 35.2h35.2V254h-35.2zm35.2-35.2h35.2v35.2h-35.2zm70.4 0h35.2v35.2h-35.2zm-35.2 35.2h35.2V254h-35.2zm35.2 55.5c8.6-5.4 16.2-12.3 22-20.3h-22v20.3zM181.7 254c5.8 8 13.3 14.9 22 20.4V254h-22zm57.2 0v33.7c7.2 1.2 13.3 1.5 17.6 1.5 4.3 0 10.4-.3 17.6-1.6V254h-35.2z",fill:"#D80027"}))},Cb=function(e){var r=e.title,n=B(e,Ix);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFF",d:"M0 0h513v342H0z"}),v.createElement("path",{fill:"#D80027",d:"M0 0h513v114H0z"}),v.createElement("path",{fill:"#6DA544",d:"M0 228h513v114H0z"}))},Ab=function(e){var r=e.title,n=B(e,Lx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFF",d:"M0 0h513v342H0z"}),v.createElement("path",{fill:"#6DA544",d:"M0 0h171v342H0z"}),v.createElement("path",{fill:"#FF9811",d:"M342 0h171v342H342z"}))},Ob=function(e){var r=e.title,n=B(e,Dx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#ff6820",d:"M0 0h513v114H0V0z"}),v.createElement("path",{fill:"#FFF",d:"M0 114h513v114H0V114z"}),v.createElement("path",{fill:"#046a38",d:"M0 228h513v114H0V228z"}),v.createElement("path",{fill:"none",stroke:"#07038d",strokeWidth:4,d:"M256.5 136.8c18.9 0 34.2 15.3 34.2 34.2s-15.3 34.2-34.2 34.2-34.2-15.3-34.2-34.2 15.3-34.2 34.2-34.2z"}),v.createElement("path",{d:"m265.3 138.2-17.6 65.7m17.6-65.7-17.6 65.7m25.8-62.3-34 58.9m41-53.5-48 48m53.4-41L227 188m62.3-25.8-65.7 17.6m66.9-8.8h-68m66.8 8.8-65.7-17.6m62.3 25.8L227 154m53.5 41-48-48m41 53.4-34-58.9m25.8 62.3-17.6-65.7m8.8 66.9v-68m-8.8 66.8 17.6-65.7m-25.8 62.3 34-58.9m-41 53.5 48.1-48.1M227.1 188l58.9-34m-62.3 25.8 65.7-17.6m-66.9 8.8h68m-66.8-8.8 65.7 17.6M227.1 154l58.9 34m-53.5-41 48.1 48.1m-41.1-53.5 34 58.9m-25.8-62.3 17.6 65.7",stroke:"#07038d",strokeWidth:2}))},Rb=function(e){var r=e.title,n=B(e,Mx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#0052B4",d:"M0 0h513v342H0z"}),v.createElement("path",{fill:"#FFF",d:"M513 210.6H202.2v130.7h-79.8V210.6H0v-79.8h122.4V0h79.8v130.8H513v18.5l-1 42.7z"}),v.createElement("path",{fill:"#D80027",d:"M513 149.3V192H183.7v149.3H141V192H0v-42.7h141V0h42.7v149.3z"}))},zb=function(e){var r=e.title,n=B(e,Fx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#F4F5F0",d:"M342 0H0v341.3h512V0z"}),v.createElement("path",{fill:"#008C45",d:"M0 0h171v342H0z"}),v.createElement("path",{fill:"#CD212A",d:"M342 0h171v342H342z"}))},Ib=function(e){var r=e.title,n=B(e,$x);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFF",d:"M0 0h512v342H0z"}),v.createElement("circle",{fill:"#D80027",cx:256.5,cy:171,r:96}))},Lb=function(e){var r=e.title,n=B(e,Bx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFF",d:"M0 0h513v342H0z"}),v.createElement("path",{d:"M84.6 107.8 132 36.6m-29.7 83 47.4-71.1m-29.6 83 47.4-71.1m177.9 221.3 47.4-71.1m-29.6 82.9 47.4-71.1m-29.6 83 47.4-71.1M132 305.4l-47.4-71.1m65.2 59.2-47.4-71.1m65.2 59.3-47.4-71.1m272.6-79.1-47.4-71.1m65.2 59.2-47.4-71.1m65.2 59.3L381 36.6",stroke:"#000",strokeWidth:14.25}),v.createElement("path",{d:"m357.3 238.2 59.3 39.5m-299.4-13.8L135 252m222.3-148.2L378 90m17.8-11.9 17.8-11.9",stroke:"#FFF",strokeWidth:12.5}),v.createElement("circle",{fill:"#CA163A",cx:256.5,cy:171,r:85.5}),v.createElement("path",{fill:"#0E4896",d:"M185.3 123.6c-13.1 19.6-7.8 46.2 11.9 59.3s46.2 7.8 59.3-11.9 39.6-24.9 59.3-11.9c19.6 13.1 24.9 39.6 11.9 59.3-26.2 39.3-79.3 49.9-118.6 23.7s-49.9-79.3-23.8-118.5z"}))},Db=function(e){var r=e.title,n=B(e,Ux);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#D80027",d:"M0 0h513v342H0z"}),v.createElement("path",{fill:"#0052B4",d:"M0 0h513v171H0z"}),v.createElement("path",{fill:"#FFDA44",d:"M149.3 98.1c0-14-11.3-25.3-25.3-25.3-6.5 0-12.4 2.4-16.9 6.4V64.4h8.4V47.5h-8.4v-8.4H90.3v8.4h-8.4v16.9h8.4v14.9c-4.5-4-10.4-6.4-16.9-6.4-14 0-25.3 11.3-25.3 25.3 0 7.5 3.3 14.2 8.4 18.8v14.9h84.3V117c5.3-4.7 8.5-11.5 8.5-18.9z"}))},Mb=function(e){var r=e.title,n=B(e,Hx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#6DA544",d:"M0 0h513v342H0z"}),v.createElement("path",{fill:"#FFDA44",d:"M0 0h513v114H0z"}),v.createElement("path",{fill:"#D80027",d:"M0 228h513v114H0z"}))},Fb=function(e){var r=e.title,n=B(e,Vx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFF",d:"M0 0h513v342H0z"}),v.createElement("path",{fill:"#D80027",d:"M0 0h513v114H0z"}),v.createElement("path",{fill:"#338AF3",d:"M0 228h513v114H0z"}))},$b=function(e){var r=e.title,n=B(e,Wx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFF",d:"M0 0h513v342H0z"}),v.createElement("path",{className:"prefix__st1",d:"M0 0h513v127.6H0zm0 214.4h513V342H0z",fill:"#A2001D"}))},Bb=function(e){var r=e.title,n=B(e,Kx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFF",d:"M0 0h513v342H0z"}),v.createElement("path",{fill:"#cf142b",d:"M256 0h256.5v342H256z"}),v.createElement("path",{stroke:"#cf142b",strokeWidth:10,d:"M101.2 68.2V33H66v35.2H30.8v35.2H66v35.2h35.2v-35.2h35.2V68.2z"}),v.createElement("path",{fill:"#fff",stroke:"#acacac",strokeWidth:5,d:"M101.2 68.2V33H66v35.2H30.8v35.2H66v35.2h35.2v-35.2h35.2V68.2z"}),v.createElement("circle",{cx:85,cy:85,r:26,fill:"none",stroke:"#acacac",strokeWidth:5}),v.createElement("circle",{cx:85,cy:85,r:18,fill:"#dedede",stroke:"#acacac",strokeWidth:5}))},Ub=function(e){var r=e.title,n=B(e,qx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#dc2339",d:"M342 0H0v341.3h513V0z"}),v.createElement("path",{fill:"#11865d",d:"M0 0h171v342H0z"}),v.createElement("path",{fill:"#FFF",d:"M171 0h171v342H171z"}),v.createElement("path",{fill:"#8C9157",d:"M195.8 171.2c0 21.6 11.5 41.7 30.3 52.5 5.8 3.4 13.2 1.4 16.6-4.4 3.4-5.8 1.4-13.2-4.4-16.6-11.3-6.5-18.2-18.5-18.2-31.5 0-6.7-5.4-12.1-12.1-12.1-6.7 0-12.2 5.4-12.2 12.1zm93.4 51.1c17.5-11.1 28-30.4 28-51.1 0-6.7-5.4-12.1-12.1-12.1s-12.1 5.4-12.1 12.1c0 12.4-6.3 24-16.8 30.7-5.7 3.5-7.5 10.9-4.1 16.7s10.9 7.5 16.7 4.1c0-.2.2-.3.4-.4z"}),v.createElement("ellipse",{fill:"#C59262",cx:256.5,cy:159.1,rx:24.3,ry:36.4}))},Hb=function(e){var r=e.title,n=B(e,Gx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFF",d:"M0 114h513v114H0z"}),v.createElement("path",{fill:"#cd1f2a",d:"M0 0h513v114H0z"}),v.createElement("path",{fill:"#1d4185",d:"M0 228h513v114H0z"}))},Vb=function(e){var r=e.title,n=B(e,Jx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#D80027",d:"M0 0h513v342H0z"}),v.createElement("path",{fill:"#FFF",d:"M513 211H202.6v131h-79.9V211H0v-80h122.7V0h79.9v131H513v61.4z"}),v.createElement("path",{fill:"#1f3f7a",d:"M513 149.6v42.8H184V342h-42.7V192.4H0v-42.8h141.3V0H184v149.6z"}))},Wb=function(e){var r=e.title,n=B(e,Qx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#012169",d:"M0 0h513v342H0z"}),v.createElement("path",{d:"m448.9 107.7 4.2 13.1h13.8l-11.1 8.1L460 142l-11.1-8.1-11.1 8.1 4.2-13.1-11.1-8.1h13.7zm-64.2 145.9 5.1 15.6h16.4l-13.2 9.7 5 15.6-13.3-9.7-13.2 9.7 5-15.6-13.3-9.7h16.5zm.1-210.2 4.7 14.6h15.3l-12.4 8.9 4.7 14.6-12.3-9-12.4 9 4.7-14.6-12.3-8.9H380zm-64.2 86 4.7 14.5h15.3l-12.3 9 4.7 14.5-12.4-8.9-12.3 8.9 4.7-14.5-12.4-9h15.3z",fill:"#D80027",stroke:"#FFF",strokeWidth:2,strokeMiterlimit:10}),v.createElement("path",{fill:"#012169",d:"M0 0h256.5v171H0z"}),v.createElement("g",{fill:"#FFF"},v.createElement("path",{d:"M256.5 0v30.6l-45.3 25.2h45.3v59.4h-59.2l59.2 32.9V171h-26.7l-73.7-40.9V171h-55.7v-48.7L12.8 171H0v-30.6l45.3-25.2H0V55.8h59.2L0 22.9V0h26.7l73.7 40.9V0h55.7v48.7L243.7 0z"}),v.createElement("path",{d:"M156.1 115.2 256.5 171v-15.8l-72-40zm-55.7-59.4L0 0v15.8l72 40z"})),v.createElement("g",{fill:"#D80027"},v.createElement("path",{d:"M144.3 0h-32.1v69.5H0v32h112.2V171h32.1v-69.5h112.2v-32H144.3z"}),v.createElement("path",{d:"M156.1 115.2 256.5 171v-15.8l-72-40zm-84.1 0-72 40V171l100.4-55.8zm28.4-59.4L0 0v15.8l72 40zm84.1 0 72-40V0L156.1 55.8z"})))},Kb=function(e){var r=e.title,n=B(e,Yx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 85.333 512 341.333"},n),r&&v.createElement("title",null,r),v.createElement("g",{fill:"#FFF"},v.createElement("path",{d:"M0 85.337h512v341.326H0z"}),v.createElement("path",{d:"M0 85.337h512V256H0z"})),v.createElement("path",{fill:"#D80027",d:"M0 256h512v170.663H0z"}))},qb=function(e){var r=e.title,n=B(e,Zx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 85.333 512 341.333"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#D80027",d:"M0 85.337h512v341.326H0z"}),v.createElement("path",{fill:"#6DA544",d:"M196.641 85.337v341.326H0V85.337z"}),v.createElement("circle",{fill:"#FFDA44",cx:196.641,cy:256,r:64}),v.createElement("path",{fill:"#D80027",d:"M160.638 224v40.001c0 19.882 16.118 36 36 36s36-16.118 36-36V224h-72z"}),v.createElement("path",{fill:"#FFF",d:"M196.638 276c-6.617 0-12-5.383-12-12v-16h24.001v16c-.001 6.616-5.385 12-12.001 12z"}))},Gb=function(e){var r=e.title,n=B(e,Xx);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 85.333 512 341.333"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFDA44",d:"M0 85.331h512v341.326H0z"}),v.createElement("path",{fill:"#0052B4",d:"M0 85.331h170.663v341.337H0z"}),v.createElement("path",{fill:"#D80027",d:"M341.337 85.331H512v341.337H341.337z"}))},Jb=function(e){var r=e.title,n=B(e,eb);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 85.333 512 341.333"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#0052B4",d:"M0 85.333h512V426.67H0z"}),v.createElement("path",{fill:"#FFDA44",d:"M192 85.33h-64v138.666H0v64h128v138.666h64V287.996h320v-64H192z"}))},Qb=function(e){var r=e.title,n=B(e,tb);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 85.333 512 341.333"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFF",d:"M0 85.337h512v341.326H0z"}),v.createElement("path",{fill:"#0052B4",d:"M0 199.112h512v113.775H0z"}),v.createElement("path",{fill:"#D80027",d:"M0 312.888h512v113.775H0z"}),v.createElement("path",{fill:"#FFF",d:"M233.606 196.639v14.837c0 34.081-44.522 44.522-44.522 44.522s-44.522-10.44-44.522-44.522v-14.837l-.145-44.188 89.043-.266.146 44.454z"}),v.createElement("path",{fill:"#0052B4",d:"M233.606 196.639v14.837c0 34.081-44.522 44.522-44.522 44.522s-44.522-10.44-44.522-44.522v-14.837l-.145-44.188 89.043-.266.146 44.454z"}),v.createElement("path",{fill:"#FFF",d:"M233.606 196.639v14.837c0 34.081-44.522 44.522-44.522 44.522s-44.522-10.44-44.522-44.522v-14.837l14.848 14.837 29.674-22.261 29.685 22.261 14.837-14.837z"}))},Yb=function(e){var r=e.title,n=B(e,rb);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 85.333 512 341.333"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFF",d:"M0 85.337h512v341.326H0z"}),v.createElement("path",{fill:"#0052B4",d:"M0 196.641h512v118.717H0z"}),v.createElement("path",{fill:"#D80027",d:"M0 315.359h512v111.304H0z"}),v.createElement("path",{fill:"#FFF",d:"M129.468 181.799v85.136c0 48.429 63.267 63.267 63.267 63.267S256 315.362 256 266.935v-85.136H129.468z"}),v.createElement("path",{fill:"#D80027",d:"M146.126 184.294v81.941c0 5.472 1.215 10.64 3.623 15.485h85.97c2.408-4.844 3.623-10.012 3.623-15.485v-81.941h-93.216z"}),v.createElement("path",{fill:"#FFF",d:"M221.301 241.427h-21.425v-14.283h14.284v-14.283h-14.284v-14.284h-14.283v14.284h-14.282v14.283h14.282v14.283h-21.426v14.284h21.426v14.283h14.283v-14.283h21.425z"}),v.createElement("path",{fill:"#0052B4",d:"M169.232 301.658c9.204 5.783 18.66 9.143 23.502 10.636 4.842-1.494 14.298-4.852 23.502-10.636 9.282-5.833 15.79-12.506 19.484-19.939a24.878 24.878 0 0 0-14.418-4.583c-1.956 0-3.856.232-5.682.657-3.871-8.796-12.658-14.94-22.884-14.94-10.227 0-19.013 6.144-22.884 14.94a25.048 25.048 0 0 0-5.682-.657 24.88 24.88 0 0 0-14.418 4.583c3.691 7.433 10.198 14.106 19.48 19.939z"}))},Zb=function(e){var r=e.title,n=B(e,nb);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#E30A17",d:"M0 0h513v342H0z"}),v.createElement("path",{fill:"#FFF",d:"M259.7 118.6c-13.1-9.5-29-14.6-45.3-14.5-40.8 0-73.8 30.8-73.8 68.9s33.1 68.9 73.8 68.9c17.1 0 32.9-5.4 45.3-14.5-30 38.6-85.7 45.6-124.3 15.5s-45.6-85.7-15.5-124.3 85.7-45.6 124.3-15.5c5.8 4.5 11 9.8 15.5 15.5zm39.9 65.8-18.1 21.9 1.2-28.4-26.4-10.4 27.3-7.6 1.8-28.3 15.6 23.7 27.5-7.1-17.5 22 15.3 23.9-26.7-9.7z"}))},Xb=function(e){var r=e.title,n=B(e,sb);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 85.333 512 341.333"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFDA44",d:"M0 85.337h512v341.326H0z"}),v.createElement("path",{fill:"#338AF3",d:"M0 85.337h512V256H0z"}))},e2=function(e){var r=e.title,n=B(e,ib);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 513 342"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFF",d:"M0 0h513v342H0z"}),v.createElement("path",{d:"M0 0h513v26.3H0zm0 52.6h513v26.3H0zm0 52.6h513v26.3H0zm0 52.6h513v26.3H0zm0 52.7h513v26.3H0zm0 52.6h513v26.3H0zm0 52.6h513V342H0z",fill:"#D80027"}),v.createElement("path",{fill:"#2E52B2",d:"M0 0h256.5v184.1H0z"}),v.createElement("path",{d:"m47.8 138.9-4-12.8-4.4 12.8H26.2l10.7 7.7-4 12.8 10.9-7.9 10.6 7.9-4.1-12.8 10.9-7.7zm56.3 0-4.1-12.8-4.2 12.8H82.6l10.7 7.7-4 12.8 10.7-7.9 10.8 7.9-4-12.8 10.7-7.7zm56.5 0-4.3-12.8-4 12.8h-13.5l11 7.7-4.2 12.8 10.7-7.9 11 7.9-4.2-12.8 10.7-7.7zm56.2 0-4-12.8-4.2 12.8h-13.3l10.8 7.7-4 12.8 10.7-7.9 10.8 7.9-4.3-12.8 11-7.7zM100 75.3l-4.2 12.8H82.6L93.3 96l-4 12.6 10.7-7.8 10.8 7.8-4-12.6 10.7-7.9h-13.4zm-56.2 0-4.4 12.8H26.2L36.9 96l-4 12.6 10.9-7.8 10.6 7.8L50.3 96l10.9-7.9H47.8zm112.5 0-4 12.8h-13.5l11 7.9-4.2 12.6 10.7-7.8 11 7.8-4.2-12.6 10.7-7.9h-13.2zm56.5 0-4.2 12.8h-13.3l10.8 7.9-4 12.6 10.7-7.8 10.8 7.8-4.3-12.6 11-7.9h-13.5zm-169-50.6-4.4 12.6H26.2l10.7 7.9-4 12.7L43.8 50l10.6 7.9-4.1-12.7 10.9-7.9H47.8zm56.2 0-4.2 12.6H82.6l10.7 7.9-4 12.7L100 50l10.8 7.9-4-12.7 10.7-7.9h-13.4zm56.3 0-4 12.6h-13.5l11 7.9-4.2 12.7 10.7-7.9 11 7.9-4.2-12.7 10.7-7.9h-13.2zm56.5 0-4.2 12.6h-13.3l10.8 7.9-4 12.7 10.7-7.9 10.8 7.9-4.3-12.7 11-7.9h-13.5z",fill:"#FFF"}))},t2=function(e){var r=e.title,n=B(e,ab);return v.createElement("svg",$({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 85.333 512 341.333"},n),r&&v.createElement("title",null,r),v.createElement("path",{fill:"#FFF",d:"M0 85.337h512v341.326H0z"}),v.createElement("path",{d:"M114.024 256.001 0 141.926v228.17z"}),v.createElement("path",{fill:"#ffb915",d:"M161.192 256 0 94.7v47.226l114.024 114.075L0 370.096v47.138z"}),v.createElement("path",{fill:"#007847",d:"M509.833 289.391c.058-.44.804-.878 2.167-1.318v-65.464H222.602L85.33 85.337H0V94.7L161.192 256 0 417.234v9.429h85.33l137.272-137.272h287.231z"}),v.createElement("path",{fill:"#000c8a",d:"M503.181 322.783H236.433l-103.881 103.88H512v-103.88z"}),v.createElement("path",{fill:"#e1392d",d:"M503.181 189.217H512V85.337H132.552l103.881 103.88z"}))};const r2=(t="")=>String(t||"").trim().toUpperCase(),n2={AR:lb,AT:ub,AU:cb,BA:db,BE:hb,BG:fb,BR:pb,CA:gb,CH:mb,CL:yb,CN:vb,CO:wb,CZ:xb,DE:bb,DK:kb,EE:_b,ES:Eb,FI:Sb,FR:jb,GB:Nb,GR:Tb,HR:Pb,HU:Cb,IE:Ab,IN:Ob,IS:Rb,IT:zb,JP:Ib,KR:Lb,LI:Db,LT:Mb,LU:Fb,LV:$b,MT:Bb,MX:Ub,NL:Hb,NO:Vb,NZ:Wb,PL:Kb,PT:qb,RO:Gb,SE:Jb,SI:Qb,SK:Yb,TR:Zb,UA:Xb,US:e2,ZA:t2};function Fn({countryCode:t="",title:e="",className:r="h-4 w-6 rounded-[2px] shadow-sm"}){const n=r2(t),s=n2[n];return s?l.jsx(s,{title:e||n,className:r}):l.jsx("span",{className:"inline-flex h-4 w-6 items-center justify-center rounded-[2px] bg-gray-200 text-[10px] dark:bg-gray-700",title:e||"Kein Land",children:"🌍"})}const lo={message:"",error:""};function s2({session:t,profile:e,loading:r,error:n,onSave:s,onDelete:i,onSessionChange:a}){var _,N;const[o,u]=T.useState(e),[c,d]=T.useState(lo),[h,f]=T.useState(!1),[y,w]=T.useState(!1),[x,b]=T.useState(!1),p=T.useRef(null),m=Cu(o.country),g=!!o.country&&!m;T.useEffect(()=>{u(e)},[e]),T.useEffect(()=>{if(!x)return;const C=U=>{p.current&&!p.current.contains(U.target)&&b(!1)},A=U=>{U.key==="Escape"&&b(!1)};return document.addEventListener("mousedown",C),document.addEventListener("keydown",A),()=>{document.removeEventListener("mousedown",C),document.removeEventListener("keydown",A)}},[x]);const k=C=>A=>{const U=C==="testsVisible"?A.target.checked:A.target.value;u(Y=>({...Y,[C]:U}))},E=C=>{u(A=>({...A,country:C})),b(!1)},S=async C=>{var U;C.preventDefault(),f(!0),d(lo);const A=await s(o);A!=null&&A.ok?(A.session&&(a==null||a(A.session)),d({message:A.emailUpdateRequested?"Profil gespeichert. Die neue Mailadresse muss ggf. noch per E-Mail bestätigt werden.":"Profil gespeichert.",error:""})):d({message:"",error:((U=A==null?void 0:A.error)==null?void 0:U.message)||"Profil konnte nicht gespeichert werden."}),f(!1)},j=async()=>{var U;if(!window.confirm(`Profil wirklich löschen?
|
||
|
||
Dabei werden alle Tests dieses Benutzers sowie vorhandene Analysepläne dauerhaft entfernt.`))return;w(!0),d(lo);const A=await(i==null?void 0:i());A!=null&&A.ok?d({message:"Profil und alle Tests wurden gelöscht. Das Konto bleibt bestehen und kann neu eingerichtet werden.",error:""}):d({message:"",error:((U=A==null?void 0:A.error)==null?void 0:U.message)||"Profil konnte nicht gelöscht werden."}),w(!1)};return l.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-sky-50 to-emerald-100 dark:from-gray-950 dark:via-gray-900 dark:to-gray-950 p-6 text-gray-900 dark:text-gray-100",children:l.jsx("div",{className:"max-w-4xl mx-auto",children:l.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-2xl shadow-lg border border-gray-200 dark:border-gray-800 overflow-hidden",children:[l.jsxs("div",{className:"px-6 py-5 border-b border-gray-200 dark:border-gray-800",children:[l.jsx("p",{className:"text-xs uppercase tracking-[0.25em] text-sky-700 dark:text-sky-300",children:"Benutzerprofil"}),l.jsx("h1",{className:"text-3xl font-bold mt-2",children:"Profil verwalten"}),l.jsx("p",{className:"mt-2 text-sm text-gray-600 dark:text-gray-300",children:"Name, Vorname, Mailadresse, Land und die Sichtbarkeit deiner Testfreigaben werden hier gepflegt."})]}),r?l.jsx("div",{className:"px-6 py-10 text-sm text-gray-600 dark:text-gray-300",children:"Profil wird geladen..."}):l.jsxs("form",{onSubmit:S,className:"px-6 py-6 space-y-6",children:[l.jsxs("div",{className:"grid md:grid-cols-2 gap-5",children:[l.jsxs("label",{className:"block",children:[l.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:"Vorname"}),l.jsx("input",{type:"text",value:o.firstName||"",onChange:k("firstName"),className:"mt-1 w-full px-4 py-3 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-sky-500",placeholder:"Max"})]}),l.jsxs("label",{className:"block",children:[l.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:"Nachname"}),l.jsx("input",{type:"text",value:o.lastName||"",onChange:k("lastName"),className:"mt-1 w-full px-4 py-3 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-sky-500",placeholder:"Mustermann"})]}),l.jsxs("label",{className:"block md:col-span-2",children:[l.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:"Mailadresse"}),l.jsx("input",{type:"email",value:o.email||((_=t==null?void 0:t.user)==null?void 0:_.email)||"",onChange:k("email"),required:!0,className:"mt-1 w-full px-4 py-3 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-sky-500",placeholder:"you@example.com"}),l.jsx("span",{className:"mt-2 block text-xs text-gray-500 dark:text-gray-400",children:"Wenn du die Mailadresse änderst, wird dir eine Bestätigung an die neue Adresse gesendet."})]}),l.jsxs("label",{className:"block",children:[l.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:"Land"}),l.jsxs("div",{ref:p,className:"relative mt-1",children:[l.jsxs("button",{type:"button",onClick:()=>b(C=>!C),className:"flex w-full items-center justify-between rounded-lg border border-gray-200 bg-white px-4 py-3 text-left text-sm text-gray-800 transition hover:border-sky-400 focus:outline-none focus:ring-2 focus:ring-sky-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100",children:[l.jsxs("span",{className:"inline-flex items-center gap-3",children:[l.jsx(Fn,{countryCode:(m==null?void 0:m.code)||o.country,title:(m==null?void 0:m.name)||Mn(o.country)||"Land auswählen",className:"h-5 w-7 rounded-[3px] shadow-sm ring-1 ring-black/10"}),l.jsx("span",{className:"font-medium",children:(m==null?void 0:m.name)||Mn(o.country)||"Land auswählen"})]}),l.jsx(Df,{className:`h-4 w-4 text-gray-500 transition ${x?"rotate-180":""}`,"aria-hidden":"true"})]}),x&&l.jsxs("div",{className:"absolute left-0 right-0 z-20 mt-2 max-h-72 overflow-y-auto rounded-xl border border-gray-200 bg-white p-2 shadow-2xl dark:border-gray-700 dark:bg-gray-900",children:[l.jsxs("button",{type:"button",onClick:()=>E(""),className:`flex w-full items-center justify-between rounded-lg px-3 py-2 text-left text-sm transition ${o.country?"text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-800":"bg-sky-50 text-sky-700 dark:bg-sky-950/40 dark:text-sky-200"}`,children:[l.jsxs("span",{className:"inline-flex items-center gap-3",children:[l.jsx(Fn,{countryCode:"",title:"Kein Land ausgewählt",className:"h-5 w-7 rounded-[3px] shadow-sm"}),l.jsx("span",{children:"Kein Land ausgewählt"})]}),!o.country&&l.jsx(Ja,{className:"h-4 w-4","aria-hidden":"true"})]}),g&&l.jsxs("button",{type:"button",onClick:()=>E(o.country),className:"flex w-full items-center justify-between rounded-lg px-3 py-2 text-left text-sm text-gray-700 transition hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-800",children:[l.jsxs("span",{className:"inline-flex items-center gap-3",children:[l.jsx(Fn,{countryCode:o.country,title:Mn(o.country),className:"h-5 w-7 rounded-[3px] shadow-sm ring-1 ring-black/10"}),l.jsx("span",{children:Mn(o.country)})]}),l.jsx(Ja,{className:"h-4 w-4","aria-hidden":"true"})]}),_p.map(C=>{const A=C.code===o.country;return l.jsxs("button",{type:"button",onClick:()=>E(C.code),className:`flex w-full items-center justify-between rounded-lg px-3 py-2 text-left text-sm transition ${A?"bg-sky-50 text-sky-700 dark:bg-sky-950/40 dark:text-sky-200":"text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-800"}`,children:[l.jsxs("span",{className:"inline-flex items-center gap-3",children:[l.jsx(Fn,{countryCode:C.code,title:C.name,className:"h-5 w-7 rounded-[3px] shadow-sm ring-1 ring-black/10"}),l.jsx("span",{children:C.name})]}),A&&l.jsx(Ja,{className:"h-4 w-4","aria-hidden":"true"})]},C.code)})]})]}),l.jsx("span",{className:"mt-2 block text-xs text-gray-500 dark:text-gray-400",children:"Die ausgewählte Flagge wird später auch im Kopfbereich neben deiner Mailadresse angezeigt."})]}),l.jsxs("div",{className:"block",children:[l.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:"Ranglistenplatz"}),l.jsxs("div",{className:"mt-1 rounded-lg border border-dashed border-amber-300 bg-amber-50 px-4 py-3 dark:border-amber-900/70 dark:bg-amber-950/30",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx("span",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:"Platzhalter"}),l.jsx("span",{className:"rounded-full bg-white px-3 py-1 text-sm font-semibold text-amber-700 shadow-sm dark:bg-gray-900 dark:text-amber-300",children:"# -"})]}),l.jsx("p",{className:"mt-2 text-xs text-amber-700/80 dark:text-amber-200/80",children:"Hier kann spater der Ranglistenplatz des Benutzers angezeigt werden."})]})]})]}),l.jsx("div",{className:"rounded-xl border border-sky-200 dark:border-sky-900/70 bg-sky-50 dark:bg-sky-950/30 p-5",children:l.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Tests sichtbar"}),l.jsx("p",{className:"mt-2 text-sm text-gray-600 dark:text-gray-300 max-w-2xl",children:"Ist dieser Schalter aktiv, funktionieren deine Freigabelinks. Wenn du ihn deaktivierst, bleiben vorhandene Links gespeichert, sind aber nicht mehr öffentlich sichtbar."})]}),l.jsxs("label",{className:"inline-flex items-center gap-3 rounded-full border border-sky-300 dark:border-sky-800 px-4 py-2 bg-white dark:bg-gray-900",children:[l.jsx("input",{type:"checkbox",checked:!!o.testsVisible,onChange:k("testsVisible"),className:"h-4 w-4 rounded border-gray-300 text-sky-600 focus:ring-sky-500"}),l.jsx("span",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:o.testsVisible?"Sichtbar":"Nicht sichtbar"})]})]})}),(n||c.error)&&l.jsx("div",{className:"rounded-lg border border-rose-200 dark:border-rose-900/70 bg-rose-50 dark:bg-rose-950/30 px-4 py-3 text-sm text-rose-700 dark:text-rose-200",children:c.error||n}),c.message&&l.jsx("div",{className:"rounded-lg border border-emerald-200 dark:border-emerald-900/70 bg-emerald-50 dark:bg-emerald-950/30 px-4 py-3 text-sm text-emerald-700 dark:text-emerald-200",children:c.message}),l.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[l.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Konto-ID: ",l.jsx("span",{className:"font-mono",children:((N=t==null?void 0:t.user)==null?void 0:N.id)||"—"})]}),l.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[l.jsx("button",{type:"button",onClick:j,disabled:y||h,className:"px-5 py-3 rounded-lg border border-rose-300 bg-white text-rose-700 font-semibold hover:bg-rose-50 transition disabled:opacity-60 disabled:cursor-not-allowed dark:border-rose-800 dark:bg-gray-900 dark:text-rose-300 dark:hover:bg-rose-950/40",children:y?"Löscht...":"Profil löschen"}),l.jsx("button",{type:"submit",disabled:h||y,className:"px-5 py-3 rounded-lg bg-sky-600 text-white font-semibold hover:bg-sky-700 transition disabled:opacity-60 disabled:cursor-not-allowed",children:h?"Speichert...":"Profil speichern"})]})]})]})]})})})}const wd=(t="")=>t.trim().toLowerCase(),An=(t="")=>({firstName:"",lastName:"",country:"",testsVisible:!1,email:t}),xd=(t,e="")=>({firstName:(t==null?void 0:t.first_name)||"",lastName:(t==null?void 0:t.last_name)||"",country:(t==null?void 0:t.country)||"",testsVisible:!!(t!=null&&t.tests_visible),email:e}),i2=(t,e)=>({user_id:e,first_name:t.firstName.trim(),last_name:t.lastName.trim(),country:t.country.trim(),tests_visible:!!t.testsVisible}),a2=t=>{var f,y;const e=((f=t==null?void 0:t.user)==null?void 0:f.id)||"",r=T.useMemo(()=>{var w;return wd(((w=t==null?void 0:t.user)==null?void 0:w.email)||"")},[(y=t==null?void 0:t.user)==null?void 0:y.email]),[n,s]=T.useState(()=>An(r)),[i,a]=T.useState(!!e),[o,u]=T.useState("");T.useEffect(()=>{if(!e){s(An(r)),a(!1);return}s(w=>({...w,email:r})),a(!0)},[r,e]);const c=T.useCallback(async()=>{if(!V||!e){s(An(r)),a(!1),u("");return}a(!0),u("");try{const{data:w,error:x}=await V.from("user_profiles").select("first_name, last_name, country, tests_visible").eq("user_id",e).maybeSingle();if(x)throw x;s(xd(w,r))}catch(w){s(An(r)),u(w.message||"Profil konnte nicht geladen werden.")}finally{a(!1)}},[r,e]);T.useEffect(()=>{c()},[c]);const d=T.useCallback(async w=>{if(!V||!e)return{ok:!1,error:new Error("Supabase ist nicht konfiguriert.")};const x=wd(w.email);if(!x)return{ok:!1,error:new Error("Bitte eine gültige E-Mail-Adresse eintragen.")};try{let b=!1;if(x!==r){const{error:E}=await V.auth.updateUser({email:x});if(E)throw E;b=!0}const{data:p,error:m}=await V.from("user_profiles").upsert(i2(w,e),{onConflict:"user_id"}).select("first_name, last_name, country, tests_visible").single();if(m)throw m;const g=xd(p,b?x:r);s(g),u("");const{data:k}=await V.auth.getSession();return{ok:!0,profile:g,session:k.session,emailUpdateRequested:b}}catch(b){const p=b instanceof Error?b:new Error((b==null?void 0:b.message)||"Profil konnte nicht gespeichert werden.");return u(p.message),{ok:!1,error:p}}},[r,e]),h=T.useCallback(async()=>{if(!V||!e)return{ok:!1,error:new Error("Supabase ist nicht konfiguriert.")};try{const{error:w}=await V.rpc("delete_current_user_profile_data");if(w)throw w;const x=An(r);return s(x),u(""),{ok:!0,profile:x}}catch(w){const x=w instanceof Error?w:new Error((w==null?void 0:w.message)||"Profil konnte nicht gelöscht werden.");return u(x.message),{ok:!1,error:x}}},[r,e]);return{profile:n,loading:i,error:o,saveProfile:d,deleteProfileData:h,refreshProfile:c}},uo=()=>typeof window>"u"?"":new URLSearchParams(window.location.search).get("share")||"",bd=()=>{if(typeof window>"u")return"/";const t=window.location.hash||"";return t.startsWith("#/")?t.slice(1):"/"};function o2(){var Y;const[t,e]=T.useState(null),[r,n]=T.useState(!0),[s,i]=T.useState(!1),[a,o]=T.useState("assessments"),[u,c]=T.useState(!1),[d,h]=T.useState(()=>uo()),[f,y]=T.useState(()=>bd()),[w,x]=T.useState(()=>{if(typeof window>"u")return"light";const G=localStorage.getItem("theme");return G==="light"||G==="dark"?G:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}),{profile:b,loading:p,error:m,saveProfile:g,deleteProfileData:k}=a2(t);T.useEffect(()=>{const G=document.documentElement;w==="dark"?G.classList.add("dark"):G.classList.remove("dark"),localStorage.setItem("theme",w)},[w]),T.useEffect(()=>{const G=()=>{h(uo()),y(bd())};return window.addEventListener("popstate",G),window.addEventListener("hashchange",G),()=>{window.removeEventListener("popstate",G),window.removeEventListener("hashchange",G)}},[]),T.useEffect(()=>{if(d){n(!1);return}if(!V){n(!1);return}(async()=>{const{data:he,error:Re}=await V.auth.getSession();Re||e(he.session),n(!1)})();const{data:ye}=V.auth.onAuthStateChange((he,Re)=>{e(Re)});return()=>{ye==null||ye.subscription.unsubscribe()}},[d]),T.useEffect(()=>{u&&a!=="assessments"&&o("assessments")},[a,u]);const E=async()=>{V&&(await V.auth.signOut(),e(null),i(!1),o("assessments"),c(!1),j("/"))},S=()=>x(G=>G==="dark"?"light":"dark"),j=G=>{if(typeof window>"u")return;const ye=G||"/",he=ye==="/"?"":`#${ye}`;if(window.location.hash===he){y(ye),window.scrollTo({top:0,behavior:"smooth"});return}const Re=`${window.location.pathname}${window.location.search}${he}`;window.history.pushState({},"",Re),y(ye),h(uo()),window.scrollTo({top:0,behavior:"smooth"})},_=()=>l.jsxs("button",{onClick:S,className:"flex items-center gap-2 px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-800 dark:text-gray-100 shadow-sm hover:shadow transition","aria-label":"Darstellung wechseln",type:"button",children:[w==="dark"?l.jsx(wy,{className:"w-4 h-4"}):l.jsx(py,{className:"w-4 h-4"}),l.jsx("span",{className:"text-sm font-medium",children:w==="dark"?"Light Mode":"Dark Mode"})]});if(d)return l.jsx(cx,{shareToken:d,themeToggle:_()});if(!V)return l.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-950 text-gray-900 dark:text-gray-100 flex items-center justify-center p-6",children:[l.jsx("div",{className:"absolute top-4 right-4",children:_()}),l.jsxs("div",{className:"max-w-xl w-full bg-white/90 dark:bg-gray-900/80 border border-dashed border-gray-300 dark:border-gray-700 rounded-xl shadow-sm p-6",children:[l.jsx("h2",{className:"text-2xl font-bold text-gray-800 dark:text-gray-100 mb-2",children:"Supabase noch nicht konfiguriert"}),l.jsxs("p",{className:"text-gray-600 dark:text-gray-300",children:["Lege eine ",l.jsx("code",{children:".env"})," an (siehe ",l.jsx("code",{children:".env.example"}),") und trage",l.jsx("code",{children:" VITE_SUPABASE_URL "})," sowie ",l.jsx("code",{children:"VITE_SUPABASE_ANON_KEY"})," ein, um Login und Registrierung zu aktivieren."]}),l.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-3",children:"Anschließend Vite neu starten, damit die Variablen geladen werden."})]})]});if(r)return l.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-950 text-gray-600 dark:text-gray-300",children:[l.jsx("div",{className:"absolute top-4 right-4",children:_()}),l.jsx("span",{children:"Auth wird geladen..."})]});if(!t)return s?l.jsx(tx,{onAuth:e,themeToggle:_(),onBack:()=>i(!1)}):f==="/datenschutz"||f==="/impressum"||f==="/kontakt"?l.jsx(dx,{path:f,onGetStarted:()=>i(!0),onNavigate:j,themeToggle:_()}):l.jsx(ax,{onGetStarted:()=>i(!0),onNavigate:j,themeToggle:_()});const N=[b==null?void 0:b.firstName,b==null?void 0:b.lastName].filter(Boolean).join(" "),C=Cu(b==null?void 0:b.country),A=Mn(b==null?void 0:b.country),U=!!N;return l.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-950 text-gray-900 dark:text-gray-100",children:[l.jsx("header",{className:"bg-white/80 dark:bg-gray-900/70 backdrop-blur border-b border-gray-200 dark:border-gray-800",children:l.jsxs("div",{className:"max-w-7xl mx-auto px-6 py-3 flex items-center justify-between gap-3 flex-wrap",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Angemeldet"}),l.jsxs("div",{className:"flex items-center gap-2 flex-wrap text-sm font-semibold text-gray-800 dark:text-gray-100",children:[A&&l.jsx(Fn,{countryCode:(C==null?void 0:C.code)||(b==null?void 0:b.country),title:A,className:"h-4 w-6 rounded-[2px] shadow-sm ring-1 ring-black/10"}),l.jsx("span",{children:U?N:(Y=t==null?void 0:t.user)==null?void 0:Y.email})]})]}),l.jsxs("nav",{className:"flex items-center gap-2",children:[l.jsx("button",{type:"button",onClick:()=>o("assessments"),className:`px-4 py-2 rounded-lg border text-sm font-semibold transition ${a==="assessments"?"bg-gray-900 text-white dark:bg-gray-100 dark:text-gray-900 border-gray-900 dark:border-gray-100":"bg-white dark:bg-gray-900 text-gray-700 dark:text-gray-200 border-gray-300 dark:border-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800"}`,children:"Bewertungen"}),l.jsx("button",{type:"button",onClick:()=>o("analysis"),disabled:u,className:`px-4 py-2 rounded-lg border text-sm font-semibold transition ${a==="analysis"?"bg-gray-900 text-white dark:bg-gray-100 dark:text-gray-900 border-gray-900 dark:border-gray-100":"bg-white dark:bg-gray-900 text-gray-700 dark:text-gray-200 border-gray-300 dark:border-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800"} ${u?"opacity-50 cursor-not-allowed":""}`,title:u?"Analyse ist während der Bearbeitung deaktiviert":"Analyse öffnen",children:"Analyse"}),l.jsx("button",{type:"button",onClick:()=>o("profile"),disabled:u,className:`px-4 py-2 rounded-lg border text-sm font-semibold transition ${a==="profile"?"bg-gray-900 text-white dark:bg-gray-100 dark:text-gray-900 border-gray-900 dark:border-gray-100":"bg-white dark:bg-gray-900 text-gray-700 dark:text-gray-200 border-gray-300 dark:border-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800"} ${u?"opacity-50 cursor-not-allowed":""}`,title:u?"Profil ist während der Bearbeitung deaktiviert":"Profil öffnen",children:"Profil"})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[_(),l.jsx("button",{onClick:E,className:"px-4 py-2 bg-gray-900 dark:bg-gray-100 text-white dark:text-gray-900 rounded-lg hover:bg-gray-800 dark:hover:bg-gray-200 transition",children:"Abmelden"})]})]})}),a!=="profile"&&l.jsx(ex,{user:t==null?void 0:t.user,activeTab:a,onEditingStateChange:c,testsVisible:!!(b!=null&&b.testsVisible),isProfileLoading:p}),a==="profile"&&l.jsx(s2,{session:t,profile:b,loading:p,error:m,onSave:g,onDelete:k,onSessionChange:e})]})}co.createRoot(document.getElementById("root")).render(l.jsx(v.StrictMode,{children:l.jsx(o2,{})}));export{Hc as _,Ar as c,kd as g};
|