Files

502 lines
906 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
function ZA(e,t){for(var n=0;n<t.length;n++){const a=t[n];if(typeof a!="string"&&!Array.isArray(a)){for(const i in a)if(i!=="default"&&!(i in e)){const l=Object.getOwnPropertyDescriptor(a,i);l&&Object.defineProperty(e,i,l.get?l:{enumerable:!0,get:()=>a[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))a(i);new MutationObserver(i=>{for(const l of i)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&a(c)}).observe(document,{childList:!0,subtree:!0});function n(i){const l={};return i.integrity&&(l.integrity=i.integrity),i.referrerPolicy&&(l.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?l.credentials="include":i.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function a(i){if(i.ep)return;i.ep=!0;const l=n(i);fetch(i.href,l)}})();function xS(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var np={exports:{}},xl={};/**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var tw;function ek(){if(tw)return xl;tw=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(a,i,l){var c=null;if(l!==void 0&&(c=""+l),i.key!==void 0&&(c=""+i.key),"key"in i){l={};for(var f in i)f!=="key"&&(l[f]=i[f])}else l=i;return i=l.ref,{$$typeof:e,type:a,key:c,ref:i!==void 0?i:null,props:l}}return xl.Fragment=t,xl.jsx=n,xl.jsxs=n,xl}var nw;function tk(){return nw||(nw=1,np.exports=ek()),np.exports}var d=tk(),rp={exports:{}},Ye={};/**
* @license React
* react.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var rw;function nk(){if(rw)return Ye;rw=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),c=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),x=Symbol.iterator;function w(R){return R===null||typeof R!="object"?null:(R=x&&R[x]||R["@@iterator"],typeof R=="function"?R:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,C={};function N(R,O,I){this.props=R,this.context=O,this.refs=C,this.updater=I||E}N.prototype.isReactComponent={},N.prototype.setState=function(R,O){if(typeof R!="object"&&typeof R!="function"&&R!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,R,O,"setState")},N.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function A(){}A.prototype=N.prototype;function T(R,O,I){this.props=R,this.context=O,this.refs=C,this.updater=I||E}var M=T.prototype=new A;M.constructor=T,S(M,N.prototype),M.isPureReactComponent=!0;var $=Array.isArray;function L(){}var P={H:null,A:null,T:null,S:null},U=Object.prototype.hasOwnProperty;function J(R,O,I){var H=I.ref;return{$$typeof:e,type:R,key:O,ref:H!==void 0?H:null,props:I}}function ce(R,O){return J(R.type,O,R.props)}function re(R){return typeof R=="object"&&R!==null&&R.$$typeof===e}function me(R){var O={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(I){return O[I]})}var fe=/\/+/g;function ge(R,O){return typeof R=="object"&&R!==null&&R.key!=null?me(""+R.key):O.toString(36)}function de(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(L,L):(R.status="pending",R.then(function(O){R.status==="pending"&&(R.status="fulfilled",R.value=O)},function(O){R.status==="pending"&&(R.status="rejected",R.reason=O)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function k(R,O,I,H,q){var ee=typeof R;(ee==="undefined"||ee==="boolean")&&(R=null);var te=!1;if(R===null)te=!0;else switch(ee){case"bigint":case"string":case"number":te=!0;break;case"object":switch(R.$$typeof){case e:case t:te=!0;break;case b:return te=R._init,k(te(R._payload),O,I,H,q)}}if(te)return q=q(R),te=H===""?"."+ge(R,0):H,$(q)?(I="",te!=null&&(I=te.replace(fe,"$&/")+"/"),k(q,O,I,"",function(je){return je})):q!=null&&(re(q)&&(q=ce(q,I+(q.key==null||R&&R.key===q.key?"":(""+q.key).replace(fe,"$&/")+"/")+te)),O.push(q)),1;te=0;var Q=H===""?".":H+":";if($(R))for(var se=0;se<R.length;se++)H=R[se],ee=Q+ge(H,se),te+=k(H,O,I,ee,q);else if(se=w(R),typeof se=="function")for(R=se.call(R),se=0;!(H=R.next()).done;)H=H.value,ee=Q+ge(H,se++),te+=k(H,O,I,ee,q);else if(ee==="object"){if(typeof R.then=="function")return k(de(R),O,I,H,q);throw O=String(R),Error("Objects are not valid as a React child (found: "+(O==="[object Object]"?"object with keys {"+Object.keys(R).join(", ")+"}":O)+"). If you meant to render a collection of children, use an array instead.")}return te}function K(R,O,I){if(R==null)return R;var H=[],q=0;return k(R,H,"","",function(ee){return O.call(I,ee,q++)}),H}function F(R){if(R._status===-1){var O=R._result;O=O(),O.then(function(I){(R._status===0||R._status===-1)&&(R._status=1,R._result=I)},function(I){(R._status===0||R._status===-1)&&(R._status=2,R._result=I)}),R._status===-1&&(R._status=0,R._result=O)}if(R._status===1)return R._result.default;throw R._result}var Y=typeof reportError=="function"?reportError:function(R){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var O=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof R=="object"&&R!==null&&typeof R.message=="string"?String(R.message):String(R),error:R});if(!window.dispatchEvent(O))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",R);return}console.error(R)},V={map:K,forEach:function(R,O,I){K(R,function(){O.apply(this,arguments)},I)},count:function(R){var O=0;return K(R,function(){O++}),O},toArray:function(R){return K(R,function(O){return O})||[]},only:function(R){if(!re(R))throw Error("React.Children.only expected to receive a single React element child.");return R}};return Ye.Activity=g,Ye.Children=V,Ye.Component=N,Ye.Fragment=n,Ye.Profiler=i,Ye.PureComponent=T,Ye.StrictMode=a,Ye.Suspense=h,Ye.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=P,Ye.__COMPILER_RUNTIME={__proto__:null,c:function(R){return P.H.useMemoCache(R)}},Ye.cache=function(R){return function(){return R.apply(null,arguments)}},Ye.cacheSignal=function(){return null},Ye.cloneElement=function(R,O,I){if(R==null)throw Error("The argument must be a React element, but you passed "+R+".");var H=S({},R.props),q=R.key;if(O!=null)for(ee in O.key!==void 0&&(q=""+O.key),O)!U.call(O,ee)||ee==="key"||ee==="__self"||ee==="__source"||ee==="ref"&&O.ref===void 0||(H[ee]=O[ee]);var ee=arguments.length-2;if(ee===1)H.children=I;else if(1<ee){for(var te=Array(ee),Q=0;Q<ee;Q++)te[Q]=arguments[Q+2];H.children=te}return J(R.type,q,H)},Ye.createContext=function(R){return R={$$typeof:c,_currentValue:R,_currentValue2:R,_threadCount:0,Provider:null,Consumer:null},R.Provider=R,R.Consumer={$$typeof:l,_context:R},R},Ye.createElement=function(R,O,I){var H,q={},ee=null;if(O!=null)for(H in O.key!==void 0&&(ee=""+O.key),O)U.call(O,H)&&H!=="key"&&H!=="__self"&&H!=="__source"&&(q[H]=O[H]);var te=arguments.length-2;if(te===1)q.children=I;else if(1<te){for(var Q=Array(te),se=0;se<te;se++)Q[se]=arguments[se+2];q.children=Q}if(R&&R.defaultProps)for(H in te=R.defaultProps,te)q[H]===void 0&&(q[H]=te[H]);return J(R,ee,q)},Ye.createRef=function(){return{current:null}},Ye.forwardRef=function(R){return{$$typeof:f,render:R}},Ye.isValidElement=re,Ye.lazy=function(R){return{$$typeof:b,_payload:{_status:-1,_result:R},_init:F}},Ye.memo=function(R,O){return{$$typeof:m,type:R,compare:O===void 0?null:O}},Ye.startTransition=function(R){var O=P.T,I={};P.T=I;try{var H=R(),q=P.S;q!==null&&q(I,H),typeof H=="object"&&H!==null&&typeof H.then=="function"&&H.then(L,Y)}catch(ee){Y(ee)}finally{O!==null&&I.types!==null&&(O.types=I.types),P.T=O}},Ye.unstable_useCacheRefresh=function(){return P.H.useCacheRefresh()},Ye.use=function(R){return P.H.use(R)},Ye.useActionState=function(R,O,I){return P.H.useActionState(R,O,I)},Ye.useCallback=function(R,O){return P.H.useCallback(R,O)},Ye.useContext=function(R){return P.H.useContext(R)},Ye.useDebugValue=function(){},Ye.useDeferredValue=function(R,O){return P.H.useDeferredValue(R,O)},Ye.useEffect=function(R,O){return P.H.useEffect(R,O)},Ye.useEffectEvent=function(R){return P.H.useEffectEvent(R)},Ye.useId=function(){return P.H.useId()},Ye.useImperativeHandle=function(R,O,I){return P.H.useImperativeHandle(R,O,I)},Ye.useInsertionEffect=function(R,O){return P.H.useInsertionEffect(R,O)},Ye.useLayoutEffect=function(R,O){return P.H.useLayoutEffect(R,O)},Ye.useMemo=function(R,O){return P.H.useMemo(R,O)},Ye.useOptimistic=function(R,O){return P.H.useOptimistic(R,O)},Ye.useReducer=function(R,O,I){return P.H.useReducer(R,O,I)},Ye.useRef=function(R){return P.H.useRef(R)},Ye.useState=function(R){return P.H.useState(R)},Ye.useSyncExternalStore=function(R,O,I){return P.H.useSyncExternalStore(R,O,I)},Ye.useTransition=function(){return P.H.useTransition()},Ye.version="19.2.6",Ye}var aw;function rf(){return aw||(aw=1,rp.exports=nk()),rp.exports}var v=rf();const ve=xS(v),Vg=ZA({__proto__:null,default:ve},[v]);var ap={exports:{}},wl={},sp={exports:{}},ip={};/**
* @license React
* scheduler.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var sw;function rk(){return sw||(sw=1,(function(e){function t(k,K){var F=k.length;k.push(K);e:for(;0<F;){var Y=F-1>>>1,V=k[Y];if(0<i(V,K))k[Y]=K,k[F]=V,F=Y;else break e}}function n(k){return k.length===0?null:k[0]}function a(k){if(k.length===0)return null;var K=k[0],F=k.pop();if(F!==K){k[0]=F;e:for(var Y=0,V=k.length,R=V>>>1;Y<R;){var O=2*(Y+1)-1,I=k[O],H=O+1,q=k[H];if(0>i(I,F))H<V&&0>i(q,I)?(k[Y]=q,k[H]=F,Y=H):(k[Y]=I,k[O]=F,Y=O);else if(H<V&&0>i(q,F))k[Y]=q,k[H]=F,Y=H;else break e}}return K}function i(k,K){var F=k.sortIndex-K.sortIndex;return F!==0?F:k.id-K.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var c=Date,f=c.now();e.unstable_now=function(){return c.now()-f}}var h=[],m=[],b=1,g=null,x=3,w=!1,E=!1,S=!1,C=!1,N=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;function M(k){for(var K=n(m);K!==null;){if(K.callback===null)a(m);else if(K.startTime<=k)a(m),K.sortIndex=K.expirationTime,t(h,K);else break;K=n(m)}}function $(k){if(S=!1,M(k),!E)if(n(h)!==null)E=!0,L||(L=!0,me());else{var K=n(m);K!==null&&de($,K.startTime-k)}}var L=!1,P=-1,U=5,J=-1;function ce(){return C?!0:!(e.unstable_now()-J<U)}function re(){if(C=!1,L){var k=e.unstable_now();J=k;var K=!0;try{e:{E=!1,S&&(S=!1,A(P),P=-1),w=!0;var F=x;try{t:{for(M(k),g=n(h);g!==null&&!(g.expirationTime>k&&ce());){var Y=g.callback;if(typeof Y=="function"){g.callback=null,x=g.priorityLevel;var V=Y(g.expirationTime<=k);if(k=e.unstable_now(),typeof V=="function"){g.callback=V,M(k),K=!0;break t}g===n(h)&&a(h),M(k)}else a(h);g=n(h)}if(g!==null)K=!0;else{var R=n(m);R!==null&&de($,R.startTime-k),K=!1}}break e}finally{g=null,x=F,w=!1}K=void 0}}finally{K?me():L=!1}}}var me;if(typeof T=="function")me=function(){T(re)};else if(typeof MessageChannel<"u"){var fe=new MessageChannel,ge=fe.port2;fe.port1.onmessage=re,me=function(){ge.postMessage(null)}}else me=function(){N(re,0)};function de(k,K){P=N(function(){k(e.unstable_now())},K)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(k){k.callback=null},e.unstable_forceFrameRate=function(k){0>k||125<k?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):U=0<k?Math.floor(1e3/k):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_next=function(k){switch(x){case 1:case 2:case 3:var K=3;break;default:K=x}var F=x;x=K;try{return k()}finally{x=F}},e.unstable_requestPaint=function(){C=!0},e.unstable_runWithPriority=function(k,K){switch(k){case 1:case 2:case 3:case 4:case 5:break;default:k=3}var F=x;x=k;try{return K()}finally{x=F}},e.unstable_scheduleCallback=function(k,K,F){var Y=e.unstable_now();switch(typeof F=="object"&&F!==null?(F=F.delay,F=typeof F=="number"&&0<F?Y+F:Y):F=Y,k){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5e3}return V=F+V,k={id:b++,callback:K,priorityLevel:k,startTime:F,expirationTime:V,sortIndex:-1},F>Y?(k.sortIndex=F,t(m,k),n(h)===null&&k===n(m)&&(S?(A(P),P=-1):S=!0,de($,F-Y))):(k.sortIndex=V,t(h,k),E||w||(E=!0,L||(L=!0,me()))),k},e.unstable_shouldYield=ce,e.unstable_wrapCallback=function(k){var K=x;return function(){var F=x;x=K;try{return k.apply(this,arguments)}finally{x=F}}}})(ip)),ip}var iw;function ak(){return iw||(iw=1,sp.exports=rk()),sp.exports}var op={exports:{}},yn={};/**
* @license React
* react-dom.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ow;function sk(){if(ow)return yn;ow=1;var e=rf();function t(h){var m="https://react.dev/errors/"+h;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var b=2;b<arguments.length;b++)m+="&args[]="+encodeURIComponent(arguments[b])}return"Minified React error #"+h+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var a={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},i=Symbol.for("react.portal");function l(h,m,b){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:g==null?null:""+g,children:h,containerInfo:m,implementation:b}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(h,m){if(h==="font")return"";if(typeof m=="string")return m==="use-credentials"?m:""}return yn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,yn.createPortal=function(h,m){var b=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11)throw Error(t(299));return l(h,m,null,b)},yn.flushSync=function(h){var m=c.T,b=a.p;try{if(c.T=null,a.p=2,h)return h()}finally{c.T=m,a.p=b,a.d.f()}},yn.preconnect=function(h,m){typeof h=="string"&&(m?(m=m.crossOrigin,m=typeof m=="string"?m==="use-credentials"?m:"":void 0):m=null,a.d.C(h,m))},yn.prefetchDNS=function(h){typeof h=="string"&&a.d.D(h)},yn.preinit=function(h,m){if(typeof h=="string"&&m&&typeof m.as=="string"){var b=m.as,g=f(b,m.crossOrigin),x=typeof m.integrity=="string"?m.integrity:void 0,w=typeof m.fetchPriority=="string"?m.fetchPriority:void 0;b==="style"?a.d.S(h,typeof m.precedence=="string"?m.precedence:void 0,{crossOrigin:g,integrity:x,fetchPriority:w}):b==="script"&&a.d.X(h,{crossOrigin:g,integrity:x,fetchPriority:w,nonce:typeof m.nonce=="string"?m.nonce:void 0})}},yn.preinitModule=function(h,m){if(typeof h=="string")if(typeof m=="object"&&m!==null){if(m.as==null||m.as==="script"){var b=f(m.as,m.crossOrigin);a.d.M(h,{crossOrigin:b,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0})}}else m==null&&a.d.M(h)},yn.preload=function(h,m){if(typeof h=="string"&&typeof m=="object"&&m!==null&&typeof m.as=="string"){var b=m.as,g=f(b,m.crossOrigin);a.d.L(h,b,{crossOrigin:g,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0,type:typeof m.type=="string"?m.type:void 0,fetchPriority:typeof m.fetchPriority=="string"?m.fetchPriority:void 0,referrerPolicy:typeof m.referrerPolicy=="string"?m.referrerPolicy:void 0,imageSrcSet:typeof m.imageSrcSet=="string"?m.imageSrcSet:void 0,imageSizes:typeof m.imageSizes=="string"?m.imageSizes:void 0,media:typeof m.media=="string"?m.media:void 0})}},yn.preloadModule=function(h,m){if(typeof h=="string")if(m){var b=f(m.as,m.crossOrigin);a.d.m(h,{as:typeof m.as=="string"&&m.as!=="script"?m.as:void 0,crossOrigin:b,integrity:typeof m.integrity=="string"?m.integrity:void 0})}else a.d.m(h)},yn.requestFormReset=function(h){a.d.r(h)},yn.unstable_batchedUpdates=function(h,m){return h(m)},yn.useFormState=function(h,m,b){return c.H.useFormState(h,m,b)},yn.useFormStatus=function(){return c.H.useHostTransitionStatus()},yn.version="19.2.6",yn}var lw;function wS(){if(lw)return op.exports;lw=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),op.exports=sk(),op.exports}/**
* @license React
* react-dom-client.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var cw;function ik(){if(cw)return wl;cw=1;var e=ak(),t=rf(),n=wS();function a(r){var s="https://react.dev/errors/"+r;if(1<arguments.length){s+="?args[]="+encodeURIComponent(arguments[1]);for(var o=2;o<arguments.length;o++)s+="&args[]="+encodeURIComponent(arguments[o])}return"Minified React error #"+r+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function l(r){var s=r,o=r;if(r.alternate)for(;s.return;)s=s.return;else{r=s;do s=r,(s.flags&4098)!==0&&(o=s.return),r=s.return;while(r)}return s.tag===3?o:null}function c(r){if(r.tag===13){var s=r.memoizedState;if(s===null&&(r=r.alternate,r!==null&&(s=r.memoizedState)),s!==null)return s.dehydrated}return null}function f(r){if(r.tag===31){var s=r.memoizedState;if(s===null&&(r=r.alternate,r!==null&&(s=r.memoizedState)),s!==null)return s.dehydrated}return null}function h(r){if(l(r)!==r)throw Error(a(188))}function m(r){var s=r.alternate;if(!s){if(s=l(r),s===null)throw Error(a(188));return s!==r?null:r}for(var o=r,u=s;;){var p=o.return;if(p===null)break;var y=p.alternate;if(y===null){if(u=p.return,u!==null){o=u;continue}break}if(p.child===y.child){for(y=p.child;y;){if(y===o)return h(p),r;if(y===u)return h(p),s;y=y.sibling}throw Error(a(188))}if(o.return!==u.return)o=p,u=y;else{for(var _=!1,j=p.child;j;){if(j===o){_=!0,o=p,u=y;break}if(j===u){_=!0,u=p,o=y;break}j=j.sibling}if(!_){for(j=y.child;j;){if(j===o){_=!0,o=y,u=p;break}if(j===u){_=!0,u=y,o=p;break}j=j.sibling}if(!_)throw Error(a(189))}}if(o.alternate!==u)throw Error(a(190))}if(o.tag!==3)throw Error(a(188));return o.stateNode.current===o?r:s}function b(r){var s=r.tag;if(s===5||s===26||s===27||s===6)return r;for(r=r.child;r!==null;){if(s=b(r),s!==null)return s;r=r.sibling}return null}var g=Object.assign,x=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),T=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),$=Symbol.for("react.suspense"),L=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),J=Symbol.for("react.activity"),ce=Symbol.for("react.memo_cache_sentinel"),re=Symbol.iterator;function me(r){return r===null||typeof r!="object"?null:(r=re&&r[re]||r["@@iterator"],typeof r=="function"?r:null)}var fe=Symbol.for("react.client.reference");function ge(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===fe?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case S:return"Fragment";case N:return"Profiler";case C:return"StrictMode";case $:return"Suspense";case L:return"SuspenseList";case J:return"Activity"}if(typeof r=="object")switch(r.$$typeof){case E:return"Portal";case T:return r.displayName||"Context";case A:return(r._context.displayName||"Context")+".Consumer";case M:var s=r.render;return r=r.displayName,r||(r=s.displayName||s.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case P:return s=r.displayName||null,s!==null?s:ge(r.type)||"Memo";case U:s=r._payload,r=r._init;try{return ge(r(s))}catch{}}return null}var de=Array.isArray,k=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,K=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},Y=[],V=-1;function R(r){return{current:r}}function O(r){0>V||(r.current=Y[V],Y[V]=null,V--)}function I(r,s){V++,Y[V]=r.current,r.current=s}var H=R(null),q=R(null),ee=R(null),te=R(null);function Q(r,s){switch(I(ee,s),I(q,r),I(H,null),s.nodeType){case 9:case 11:r=(r=s.documentElement)&&(r=r.namespaceURI)?Ex(r):0;break;default:if(r=s.tagName,s=s.namespaceURI)s=Ex(s),r=Nx(s,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}O(H),I(H,r)}function se(){O(H),O(q),O(ee)}function je(r){r.memoizedState!==null&&I(te,r);var s=H.current,o=Nx(s,r.type);s!==o&&(I(q,r),I(H,o))}function ze(r){q.current===r&&(O(H),O(q)),te.current===r&&(O(te),gl._currentValue=F)}var Ne,ne;function Me(r){if(Ne===void 0)try{throw Error()}catch(o){var s=o.stack.trim().match(/\n( *(at )?)/);Ne=s&&s[1]||"",ne=-1<o.stack.indexOf(`
at`)?" (<anonymous>)":-1<o.stack.indexOf("@")?"@unknown:0:0":""}return`
`+Ne+r+ne}var Je=!1;function ie(r,s){if(!r||Je)return"";Je=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var u={DetermineComponentFrameRoot:function(){try{if(s){var le=function(){throw Error()};if(Object.defineProperty(le.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(le,[])}catch(Z){var X=Z}Reflect.construct(r,[],le)}else{try{le.call()}catch(Z){X=Z}r.call(le.prototype)}}else{try{throw Error()}catch(Z){X=Z}(le=r())&&typeof le.catch=="function"&&le.catch(function(){})}}catch(Z){if(Z&&X&&typeof Z.stack=="string")return[Z.stack,X.stack]}return[null,null]}};u.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var p=Object.getOwnPropertyDescriptor(u.DetermineComponentFrameRoot,"name");p&&p.configurable&&Object.defineProperty(u.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var y=u.DetermineComponentFrameRoot(),_=y[0],j=y[1];if(_&&j){var D=_.split(`
`),W=j.split(`
`);for(p=u=0;u<D.length&&!D[u].includes("DetermineComponentFrameRoot");)u++;for(;p<W.length&&!W[p].includes("DetermineComponentFrameRoot");)p++;if(u===D.length||p===W.length)for(u=D.length-1,p=W.length-1;1<=u&&0<=p&&D[u]!==W[p];)p--;for(;1<=u&&0<=p;u--,p--)if(D[u]!==W[p]){if(u!==1||p!==1)do if(u--,p--,0>p||D[u]!==W[p]){var ae=`
`+D[u].replace(" at new "," at ");return r.displayName&&ae.includes("<anonymous>")&&(ae=ae.replace("<anonymous>",r.displayName)),ae}while(1<=u&&0<=p);break}}}finally{Je=!1,Error.prepareStackTrace=o}return(o=r?r.displayName||r.name:"")?Me(o):""}function De(r,s){switch(r.tag){case 26:case 27:case 5:return Me(r.type);case 16:return Me("Lazy");case 13:return r.child!==s&&s!==null?Me("Suspense Fallback"):Me("Suspense");case 19:return Me("SuspenseList");case 0:case 15:return ie(r.type,!1);case 11:return ie(r.type.render,!1);case 1:return ie(r.type,!0);case 31:return Me("Activity");default:return""}}function Xe(r){try{var s="",o=null;do s+=De(r,o),o=r,r=r.return;while(r);return s}catch(u){return`
Error generating stack: `+u.message+`
`+u.stack}}var We=Object.prototype.hasOwnProperty,Ct=e.unstable_scheduleCallback,pe=e.unstable_cancelCallback,$e=e.unstable_shouldYield,Ke=e.unstable_requestPaint,Le=e.unstable_now,ue=e.unstable_getCurrentPriorityLevel,qe=e.unstable_ImmediatePriority,gt=e.unstable_UserBlockingPriority,Xt=e.unstable_NormalPriority,jt=e.unstable_LowPriority,At=e.unstable_IdlePriority,on=e.log,gn=e.unstable_setDisableYieldValue,vn=null,Mt=null;function Jt(r){if(typeof on=="function"&&gn(r),Mt&&typeof Mt.setStrictMode=="function")try{Mt.setStrictMode(vn,r)}catch{}}var Dt=Math.clz32?Math.clz32:en,fr=Math.log,Yn=Math.LN2;function en(r){return r>>>=0,r===0?32:31-(fr(r)/Yn|0)|0}var he=256,Be=262144,et=4194304;function rt(r){var s=r&42;if(s!==0)return s;switch(r&-r){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return r&261888;case 262144:case 524288:case 1048576:case 2097152:return r&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return r&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return r}}function He(r,s,o){var u=r.pendingLanes;if(u===0)return 0;var p=0,y=r.suspendedLanes,_=r.pingedLanes;r=r.warmLanes;var j=u&134217727;return j!==0?(u=j&~y,u!==0?p=rt(u):(_&=j,_!==0?p=rt(_):o||(o=j&~r,o!==0&&(p=rt(o))))):(j=u&~y,j!==0?p=rt(j):_!==0?p=rt(_):o||(o=u&~r,o!==0&&(p=rt(o)))),p===0?0:s!==0&&s!==p&&(s&y)===0&&(y=p&-p,o=s&-s,y>=o||y===32&&(o&4194048)!==0)?s:p}function Et(r,s){return(r.pendingLanes&~(r.suspendedLanes&~r.pingedLanes)&s)===0}function we(r,s){switch(r){case 1:case 2:case 4:case 8:case 64:return s+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return s+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ft(){var r=et;return et<<=1,(et&62914560)===0&&(et=4194304),r}function kt(r){for(var s=[],o=0;31>o;o++)s.push(r);return s}function ht(r,s){r.pendingLanes|=s,s!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function $t(r,s,o,u,p,y){var _=r.pendingLanes;r.pendingLanes=o,r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0,r.expiredLanes&=o,r.entangledLanes&=o,r.errorRecoveryDisabledLanes&=o,r.shellSuspendCounter=0;var j=r.entanglements,D=r.expirationTimes,W=r.hiddenUpdates;for(o=_&~o;0<o;){var ae=31-Dt(o),le=1<<ae;j[ae]=0,D[ae]=-1;var X=W[ae];if(X!==null)for(W[ae]=null,ae=0;ae<X.length;ae++){var Z=X[ae];Z!==null&&(Z.lane&=-536870913)}o&=~le}u!==0&&ps(r,u,0),y!==0&&p===0&&r.tag!==0&&(r.suspendedLanes|=y&~(_&~s))}function ps(r,s,o){r.pendingLanes|=s,r.suspendedLanes&=~s;var u=31-Dt(s);r.entangledLanes|=s,r.entanglements[u]=r.entanglements[u]|1073741824|o&261930}function Sn(r,s){var o=r.entangledLanes|=s;for(r=r.entanglements;o;){var u=31-Dt(o),p=1<<u;p&s|r[u]&s&&(r[u]|=s),o&=~p}}function En(r,s){var o=s&-s;return o=(o&42)!==0?1:ai(o),(o&(r.suspendedLanes|s))!==0?0:o}function ai(r){switch(r){case 2:r=1;break;case 8:r=4;break;case 32:r=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:r=128;break;case 268435456:r=134217728;break;default:r=0}return r}function hr(r){return r&=-r,2<r?8<r?(r&134217727)!==0?32:268435456:8:2}function Gf(){var r=K.p;return r!==0?r:(r=window.event,r===void 0?32:Wx(r.type))}function uy(r,s){var o=K.p;try{return K.p=r,s()}finally{K.p=o}}var Ea=Math.random().toString(36).slice(2),ln="__reactFiber$"+Ea,Nn="__reactProps$"+Ea,si="__reactContainer$"+Ea,Kf="__reactEvents$"+Ea,HT="__reactListeners$"+Ea,qT="__reactHandles$"+Ea,dy="__reactResources$"+Ea,ko="__reactMarker$"+Ea;function Wf(r){delete r[ln],delete r[Nn],delete r[Kf],delete r[HT],delete r[qT]}function ii(r){var s=r[ln];if(s)return s;for(var o=r.parentNode;o;){if(s=o[si]||o[ln]){if(o=s.alternate,s.child!==null||o!==null&&o.child!==null)for(r=Ox(r);r!==null;){if(o=r[ln])return o;r=Ox(r)}return s}r=o,o=r.parentNode}return null}function oi(r){if(r=r[ln]||r[si]){var s=r.tag;if(s===5||s===6||s===13||s===31||s===26||s===27||s===3)return r}return null}function Oo(r){var s=r.tag;if(s===5||s===26||s===27||s===6)return r.stateNode;throw Error(a(33))}function li(r){var s=r[dy];return s||(s=r[dy]={hoistableStyles:new Map,hoistableScripts:new Map}),s}function tn(r){r[ko]=!0}var fy=new Set,hy={};function gs(r,s){ci(r,s),ci(r+"Capture",s)}function ci(r,s){for(hy[r]=s,r=0;r<s.length;r++)fy.add(s[r])}var VT=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),my={},py={};function FT(r){return We.call(py,r)?!0:We.call(my,r)?!1:VT.test(r)?py[r]=!0:(my[r]=!0,!1)}function xc(r,s,o){if(FT(s))if(o===null)r.removeAttribute(s);else{switch(typeof o){case"undefined":case"function":case"symbol":r.removeAttribute(s);return;case"boolean":var u=s.toLowerCase().slice(0,5);if(u!=="data-"&&u!=="aria-"){r.removeAttribute(s);return}}r.setAttribute(s,""+o)}}function wc(r,s,o){if(o===null)r.removeAttribute(s);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":r.removeAttribute(s);return}r.setAttribute(s,""+o)}}function Fr(r,s,o,u){if(u===null)r.removeAttribute(o);else{switch(typeof u){case"undefined":case"function":case"symbol":case"boolean":r.removeAttribute(o);return}r.setAttributeNS(s,o,""+u)}}function Xn(r){switch(typeof r){case"bigint":case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function gy(r){var s=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function GT(r,s,o){var u=Object.getOwnPropertyDescriptor(r.constructor.prototype,s);if(!r.hasOwnProperty(s)&&typeof u<"u"&&typeof u.get=="function"&&typeof u.set=="function"){var p=u.get,y=u.set;return Object.defineProperty(r,s,{configurable:!0,get:function(){return p.call(this)},set:function(_){o=""+_,y.call(this,_)}}),Object.defineProperty(r,s,{enumerable:u.enumerable}),{getValue:function(){return o},setValue:function(_){o=""+_},stopTracking:function(){r._valueTracker=null,delete r[s]}}}}function Yf(r){if(!r._valueTracker){var s=gy(r)?"checked":"value";r._valueTracker=GT(r,s,""+r[s])}}function vy(r){if(!r)return!1;var s=r._valueTracker;if(!s)return!0;var o=s.getValue(),u="";return r&&(u=gy(r)?r.checked?"true":"false":r.value),r=u,r!==o?(s.setValue(r),!0):!1}function _c(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}var KT=/[\n"\\]/g;function Jn(r){return r.replace(KT,function(s){return"\\"+s.charCodeAt(0).toString(16)+" "})}function Xf(r,s,o,u,p,y,_,j){r.name="",_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?r.type=_:r.removeAttribute("type"),s!=null?_==="number"?(s===0&&r.value===""||r.value!=s)&&(r.value=""+Xn(s)):r.value!==""+Xn(s)&&(r.value=""+Xn(s)):_!=="submit"&&_!=="reset"||r.removeAttribute("value"),s!=null?Jf(r,_,Xn(s)):o!=null?Jf(r,_,Xn(o)):u!=null&&r.removeAttribute("value"),p==null&&y!=null&&(r.defaultChecked=!!y),p!=null&&(r.checked=p&&typeof p!="function"&&typeof p!="symbol"),j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?r.name=""+Xn(j):r.removeAttribute("name")}function yy(r,s,o,u,p,y,_,j){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(r.type=y),s!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||s!=null)){Yf(r);return}o=o!=null?""+Xn(o):"",s=s!=null?""+Xn(s):o,j||s===r.value||(r.value=s),r.defaultValue=s}u=u??p,u=typeof u!="function"&&typeof u!="symbol"&&!!u,r.checked=j?r.checked:!!u,r.defaultChecked=!!u,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(r.name=_),Yf(r)}function Jf(r,s,o){s==="number"&&_c(r.ownerDocument)===r||r.defaultValue===""+o||(r.defaultValue=""+o)}function ui(r,s,o,u){if(r=r.options,s){s={};for(var p=0;p<o.length;p++)s["$"+o[p]]=!0;for(o=0;o<r.length;o++)p=s.hasOwnProperty("$"+r[o].value),r[o].selected!==p&&(r[o].selected=p),p&&u&&(r[o].defaultSelected=!0)}else{for(o=""+Xn(o),s=null,p=0;p<r.length;p++){if(r[p].value===o){r[p].selected=!0,u&&(r[p].defaultSelected=!0);return}s!==null||r[p].disabled||(s=r[p])}s!==null&&(s.selected=!0)}}function by(r,s,o){if(s!=null&&(s=""+Xn(s),s!==r.value&&(r.value=s),o==null)){r.defaultValue!==s&&(r.defaultValue=s);return}r.defaultValue=o!=null?""+Xn(o):""}function xy(r,s,o,u){if(s==null){if(u!=null){if(o!=null)throw Error(a(92));if(de(u)){if(1<u.length)throw Error(a(93));u=u[0]}o=u}o==null&&(o=""),s=o}o=Xn(s),r.defaultValue=o,u=r.textContent,u===o&&u!==""&&u!==null&&(r.value=u),Yf(r)}function di(r,s){if(s){var o=r.firstChild;if(o&&o===r.lastChild&&o.nodeType===3){o.nodeValue=s;return}}r.textContent=s}var WT=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function wy(r,s,o){var u=s.indexOf("--")===0;o==null||typeof o=="boolean"||o===""?u?r.setProperty(s,""):s==="float"?r.cssFloat="":r[s]="":u?r.setProperty(s,o):typeof o!="number"||o===0||WT.has(s)?s==="float"?r.cssFloat=o:r[s]=(""+o).trim():r[s]=o+"px"}function _y(r,s,o){if(s!=null&&typeof s!="object")throw Error(a(62));if(r=r.style,o!=null){for(var u in o)!o.hasOwnProperty(u)||s!=null&&s.hasOwnProperty(u)||(u.indexOf("--")===0?r.setProperty(u,""):u==="float"?r.cssFloat="":r[u]="");for(var p in s)u=s[p],s.hasOwnProperty(p)&&o[p]!==u&&wy(r,p,u)}else for(var y in s)s.hasOwnProperty(y)&&wy(r,y,s[y])}function Qf(r){if(r.indexOf("-")===-1)return!1;switch(r){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 YT=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),XT=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Sc(r){return XT.test(""+r)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":r}function Gr(){}var Zf=null;function eh(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var fi=null,hi=null;function Sy(r){var s=oi(r);if(s&&(r=s.stateNode)){var o=r[Nn]||null;e:switch(r=s.stateNode,s.type){case"input":if(Xf(r,o.value,o.defaultValue,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name),s=o.name,o.type==="radio"&&s!=null){for(o=r;o.parentNode;)o=o.parentNode;for(o=o.querySelectorAll('input[name="'+Jn(""+s)+'"][type="radio"]'),s=0;s<o.length;s++){var u=o[s];if(u!==r&&u.form===r.form){var p=u[Nn]||null;if(!p)throw Error(a(90));Xf(u,p.value,p.defaultValue,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name)}}for(s=0;s<o.length;s++)u=o[s],u.form===r.form&&vy(u)}break e;case"textarea":by(r,o.value,o.defaultValue);break e;case"select":s=o.value,s!=null&&ui(r,!!o.multiple,s,!1)}}}var th=!1;function Ey(r,s,o){if(th)return r(s,o);th=!0;try{var u=r(s);return u}finally{if(th=!1,(fi!==null||hi!==null)&&(uu(),fi&&(s=fi,r=hi,hi=fi=null,Sy(s),r)))for(s=0;s<r.length;s++)Sy(r[s])}}function Mo(r,s){var o=r.stateNode;if(o===null)return null;var u=o[Nn]||null;if(u===null)return null;o=u[s];e:switch(s){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(u=!u.disabled)||(r=r.type,u=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!u;break e;default:r=!1}if(r)return null;if(o&&typeof o!="function")throw Error(a(231,s,typeof o));return o}var Kr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),nh=!1;if(Kr)try{var Do={};Object.defineProperty(Do,"passive",{get:function(){nh=!0}}),window.addEventListener("test",Do,Do),window.removeEventListener("test",Do,Do)}catch{nh=!1}var Na=null,rh=null,Ec=null;function Ny(){if(Ec)return Ec;var r,s=rh,o=s.length,u,p="value"in Na?Na.value:Na.textContent,y=p.length;for(r=0;r<o&&s[r]===p[r];r++);var _=o-r;for(u=1;u<=_&&s[o-u]===p[y-u];u++);return Ec=p.slice(r,1<u?1-u:void 0)}function Nc(r){var s=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&s===13&&(r=13)):r=s,r===10&&(r=13),32<=r||r===13?r:0}function Cc(){return!0}function Cy(){return!1}function Cn(r){function s(o,u,p,y,_){this._reactName=o,this._targetInst=p,this.type=u,this.nativeEvent=y,this.target=_,this.currentTarget=null;for(var j in r)r.hasOwnProperty(j)&&(o=r[j],this[j]=o?o(y):y[j]);return this.isDefaultPrevented=(y.defaultPrevented!=null?y.defaultPrevented:y.returnValue===!1)?Cc:Cy,this.isPropagationStopped=Cy,this}return g(s.prototype,{preventDefault:function(){this.defaultPrevented=!0;var o=this.nativeEvent;o&&(o.preventDefault?o.preventDefault():typeof o.returnValue!="unknown"&&(o.returnValue=!1),this.isDefaultPrevented=Cc)},stopPropagation:function(){var o=this.nativeEvent;o&&(o.stopPropagation?o.stopPropagation():typeof o.cancelBubble!="unknown"&&(o.cancelBubble=!0),this.isPropagationStopped=Cc)},persist:function(){},isPersistent:Cc}),s}var vs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},jc=Cn(vs),Po=g({},vs,{view:0,detail:0}),JT=Cn(Po),ah,sh,Lo,Tc=g({},Po,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:oh,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==Lo&&(Lo&&r.type==="mousemove"?(ah=r.screenX-Lo.screenX,sh=r.screenY-Lo.screenY):sh=ah=0,Lo=r),ah)},movementY:function(r){return"movementY"in r?r.movementY:sh}}),jy=Cn(Tc),QT=g({},Tc,{dataTransfer:0}),ZT=Cn(QT),eR=g({},Po,{relatedTarget:0}),ih=Cn(eR),tR=g({},vs,{animationName:0,elapsedTime:0,pseudoElement:0}),nR=Cn(tR),rR=g({},vs,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),aR=Cn(rR),sR=g({},vs,{data:0}),Ty=Cn(sR),iR={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},oR={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"},lR={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function cR(r){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(r):(r=lR[r])?!!s[r]:!1}function oh(){return cR}var uR=g({},Po,{key:function(r){if(r.key){var s=iR[r.key]||r.key;if(s!=="Unidentified")return s}return r.type==="keypress"?(r=Nc(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?oR[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:oh,charCode:function(r){return r.type==="keypress"?Nc(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?Nc(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),dR=Cn(uR),fR=g({},Tc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ry=Cn(fR),hR=g({},Po,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:oh}),mR=Cn(hR),pR=g({},vs,{propertyName:0,elapsedTime:0,pseudoElement:0}),gR=Cn(pR),vR=g({},Tc,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),yR=Cn(vR),bR=g({},vs,{newState:0,oldState:0}),xR=Cn(bR),wR=[9,13,27,32],lh=Kr&&"CompositionEvent"in window,zo=null;Kr&&"documentMode"in document&&(zo=document.documentMode);var _R=Kr&&"TextEvent"in window&&!zo,Ay=Kr&&(!lh||zo&&8<zo&&11>=zo),ky=" ",Oy=!1;function My(r,s){switch(r){case"keyup":return wR.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Dy(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var mi=!1;function SR(r,s){switch(r){case"compositionend":return Dy(s);case"keypress":return s.which!==32?null:(Oy=!0,ky);case"textInput":return r=s.data,r===ky&&Oy?null:r;default:return null}}function ER(r,s){if(mi)return r==="compositionend"||!lh&&My(r,s)?(r=Ny(),Ec=rh=Na=null,mi=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return Ay&&s.locale!=="ko"?null:s.data;default:return null}}var NR={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 Py(r){var s=r&&r.nodeName&&r.nodeName.toLowerCase();return s==="input"?!!NR[r.type]:s==="textarea"}function Ly(r,s,o,u){fi?hi?hi.push(u):hi=[u]:fi=u,s=vu(s,"onChange"),0<s.length&&(o=new jc("onChange","change",null,o,u),r.push({event:o,listeners:s}))}var Io=null,$o=null;function CR(r){yx(r,0)}function Rc(r){var s=Oo(r);if(vy(s))return r}function zy(r,s){if(r==="change")return s}var Iy=!1;if(Kr){var ch;if(Kr){var uh="oninput"in document;if(!uh){var $y=document.createElement("div");$y.setAttribute("oninput","return;"),uh=typeof $y.oninput=="function"}ch=uh}else ch=!1;Iy=ch&&(!document.documentMode||9<document.documentMode)}function Uy(){Io&&(Io.detachEvent("onpropertychange",By),$o=Io=null)}function By(r){if(r.propertyName==="value"&&Rc($o)){var s=[];Ly(s,$o,r,eh(r)),Ey(CR,s)}}function jR(r,s,o){r==="focusin"?(Uy(),Io=s,$o=o,Io.attachEvent("onpropertychange",By)):r==="focusout"&&Uy()}function TR(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return Rc($o)}function RR(r,s){if(r==="click")return Rc(s)}function AR(r,s){if(r==="input"||r==="change")return Rc(s)}function kR(r,s){return r===s&&(r!==0||1/r===1/s)||r!==r&&s!==s}var In=typeof Object.is=="function"?Object.is:kR;function Uo(r,s){if(In(r,s))return!0;if(typeof r!="object"||r===null||typeof s!="object"||s===null)return!1;var o=Object.keys(r),u=Object.keys(s);if(o.length!==u.length)return!1;for(u=0;u<o.length;u++){var p=o[u];if(!We.call(s,p)||!In(r[p],s[p]))return!1}return!0}function Hy(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function qy(r,s){var o=Hy(r);r=0;for(var u;o;){if(o.nodeType===3){if(u=r+o.textContent.length,r<=s&&u>=s)return{node:o,offset:s-r};r=u}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=Hy(o)}}function Vy(r,s){return r&&s?r===s?!0:r&&r.nodeType===3?!1:s&&s.nodeType===3?Vy(r,s.parentNode):"contains"in r?r.contains(s):r.compareDocumentPosition?!!(r.compareDocumentPosition(s)&16):!1:!1}function Fy(r){r=r!=null&&r.ownerDocument!=null&&r.ownerDocument.defaultView!=null?r.ownerDocument.defaultView:window;for(var s=_c(r.document);s instanceof r.HTMLIFrameElement;){try{var o=typeof s.contentWindow.location.href=="string"}catch{o=!1}if(o)r=s.contentWindow;else break;s=_c(r.document)}return s}function dh(r){var s=r&&r.nodeName&&r.nodeName.toLowerCase();return s&&(s==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||s==="textarea"||r.contentEditable==="true")}var OR=Kr&&"documentMode"in document&&11>=document.documentMode,pi=null,fh=null,Bo=null,hh=!1;function Gy(r,s,o){var u=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;hh||pi==null||pi!==_c(u)||(u=pi,"selectionStart"in u&&dh(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),Bo&&Uo(Bo,u)||(Bo=u,u=vu(fh,"onSelect"),0<u.length&&(s=new jc("onSelect","select",null,s,o),r.push({event:s,listeners:u}),s.target=pi)))}function ys(r,s){var o={};return o[r.toLowerCase()]=s.toLowerCase(),o["Webkit"+r]="webkit"+s,o["Moz"+r]="moz"+s,o}var gi={animationend:ys("Animation","AnimationEnd"),animationiteration:ys("Animation","AnimationIteration"),animationstart:ys("Animation","AnimationStart"),transitionrun:ys("Transition","TransitionRun"),transitionstart:ys("Transition","TransitionStart"),transitioncancel:ys("Transition","TransitionCancel"),transitionend:ys("Transition","TransitionEnd")},mh={},Ky={};Kr&&(Ky=document.createElement("div").style,"AnimationEvent"in window||(delete gi.animationend.animation,delete gi.animationiteration.animation,delete gi.animationstart.animation),"TransitionEvent"in window||delete gi.transitionend.transition);function bs(r){if(mh[r])return mh[r];if(!gi[r])return r;var s=gi[r],o;for(o in s)if(s.hasOwnProperty(o)&&o in Ky)return mh[r]=s[o];return r}var Wy=bs("animationend"),Yy=bs("animationiteration"),Xy=bs("animationstart"),MR=bs("transitionrun"),DR=bs("transitionstart"),PR=bs("transitioncancel"),Jy=bs("transitionend"),Qy=new Map,ph="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");ph.push("scrollEnd");function mr(r,s){Qy.set(r,s),gs(s,[r])}var Ac=typeof reportError=="function"?reportError:function(r){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var s=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof r=="object"&&r!==null&&typeof r.message=="string"?String(r.message):String(r),error:r});if(!window.dispatchEvent(s))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",r);return}console.error(r)},Qn=[],vi=0,gh=0;function kc(){for(var r=vi,s=gh=vi=0;s<r;){var o=Qn[s];Qn[s++]=null;var u=Qn[s];Qn[s++]=null;var p=Qn[s];Qn[s++]=null;var y=Qn[s];if(Qn[s++]=null,u!==null&&p!==null){var _=u.pending;_===null?p.next=p:(p.next=_.next,_.next=p),u.pending=p}y!==0&&Zy(o,p,y)}}function Oc(r,s,o,u){Qn[vi++]=r,Qn[vi++]=s,Qn[vi++]=o,Qn[vi++]=u,gh|=u,r.lanes|=u,r=r.alternate,r!==null&&(r.lanes|=u)}function vh(r,s,o,u){return Oc(r,s,o,u),Mc(r)}function xs(r,s){return Oc(r,null,null,s),Mc(r)}function Zy(r,s,o){r.lanes|=o;var u=r.alternate;u!==null&&(u.lanes|=o);for(var p=!1,y=r.return;y!==null;)y.childLanes|=o,u=y.alternate,u!==null&&(u.childLanes|=o),y.tag===22&&(r=y.stateNode,r===null||r._visibility&1||(p=!0)),r=y,y=y.return;return r.tag===3?(y=r.stateNode,p&&s!==null&&(p=31-Dt(o),r=y.hiddenUpdates,u=r[p],u===null?r[p]=[s]:u.push(s),s.lane=o|536870912),y):null}function Mc(r){if(50<cl)throw cl=0,Cm=null,Error(a(185));for(var s=r.return;s!==null;)r=s,s=r.return;return r.tag===3?r.stateNode:null}var yi={};function LR(r,s,o,u){this.tag=r,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function $n(r,s,o,u){return new LR(r,s,o,u)}function yh(r){return r=r.prototype,!(!r||!r.isReactComponent)}function Wr(r,s){var o=r.alternate;return o===null?(o=$n(r.tag,s,r.key,r.mode),o.elementType=r.elementType,o.type=r.type,o.stateNode=r.stateNode,o.alternate=r,r.alternate=o):(o.pendingProps=s,o.type=r.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=r.flags&65011712,o.childLanes=r.childLanes,o.lanes=r.lanes,o.child=r.child,o.memoizedProps=r.memoizedProps,o.memoizedState=r.memoizedState,o.updateQueue=r.updateQueue,s=r.dependencies,o.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},o.sibling=r.sibling,o.index=r.index,o.ref=r.ref,o.refCleanup=r.refCleanup,o}function eb(r,s){r.flags&=65011714;var o=r.alternate;return o===null?(r.childLanes=0,r.lanes=s,r.child=null,r.subtreeFlags=0,r.memoizedProps=null,r.memoizedState=null,r.updateQueue=null,r.dependencies=null,r.stateNode=null):(r.childLanes=o.childLanes,r.lanes=o.lanes,r.child=o.child,r.subtreeFlags=0,r.deletions=null,r.memoizedProps=o.memoizedProps,r.memoizedState=o.memoizedState,r.updateQueue=o.updateQueue,r.type=o.type,s=o.dependencies,r.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),r}function Dc(r,s,o,u,p,y){var _=0;if(u=r,typeof r=="function")yh(r)&&(_=1);else if(typeof r=="string")_=BA(r,o,H.current)?26:r==="html"||r==="head"||r==="body"?27:5;else e:switch(r){case J:return r=$n(31,o,s,p),r.elementType=J,r.lanes=y,r;case S:return ws(o.children,p,y,s);case C:_=8,p|=24;break;case N:return r=$n(12,o,s,p|2),r.elementType=N,r.lanes=y,r;case $:return r=$n(13,o,s,p),r.elementType=$,r.lanes=y,r;case L:return r=$n(19,o,s,p),r.elementType=L,r.lanes=y,r;default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case T:_=10;break e;case A:_=9;break e;case M:_=11;break e;case P:_=14;break e;case U:_=16,u=null;break e}_=29,o=Error(a(130,r===null?"null":typeof r,"")),u=null}return s=$n(_,o,s,p),s.elementType=r,s.type=u,s.lanes=y,s}function ws(r,s,o,u){return r=$n(7,r,u,s),r.lanes=o,r}function bh(r,s,o){return r=$n(6,r,null,s),r.lanes=o,r}function tb(r){var s=$n(18,null,null,0);return s.stateNode=r,s}function xh(r,s,o){return s=$n(4,r.children!==null?r.children:[],r.key,s),s.lanes=o,s.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},s}var nb=new WeakMap;function Zn(r,s){if(typeof r=="object"&&r!==null){var o=nb.get(r);return o!==void 0?o:(s={value:r,source:s,stack:Xe(s)},nb.set(r,s),s)}return{value:r,source:s,stack:Xe(s)}}var bi=[],xi=0,Pc=null,Ho=0,er=[],tr=0,Ca=null,jr=1,Tr="";function Yr(r,s){bi[xi++]=Ho,bi[xi++]=Pc,Pc=r,Ho=s}function rb(r,s,o){er[tr++]=jr,er[tr++]=Tr,er[tr++]=Ca,Ca=r;var u=jr;r=Tr;var p=32-Dt(u)-1;u&=~(1<<p),o+=1;var y=32-Dt(s)+p;if(30<y){var _=p-p%5;y=(u&(1<<_)-1).toString(32),u>>=_,p-=_,jr=1<<32-Dt(s)+p|o<<p|u,Tr=y+r}else jr=1<<y|o<<p|u,Tr=r}function wh(r){r.return!==null&&(Yr(r,1),rb(r,1,0))}function _h(r){for(;r===Pc;)Pc=bi[--xi],bi[xi]=null,Ho=bi[--xi],bi[xi]=null;for(;r===Ca;)Ca=er[--tr],er[tr]=null,Tr=er[--tr],er[tr]=null,jr=er[--tr],er[tr]=null}function ab(r,s){er[tr++]=jr,er[tr++]=Tr,er[tr++]=Ca,jr=s.id,Tr=s.overflow,Ca=r}var cn=null,Tt=null,ut=!1,ja=null,nr=!1,Sh=Error(a(519));function Ta(r){var s=Error(a(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw qo(Zn(s,r)),Sh}function sb(r){var s=r.stateNode,o=r.type,u=r.memoizedProps;switch(s[ln]=r,s[Nn]=u,o){case"dialog":it("cancel",s),it("close",s);break;case"iframe":case"object":case"embed":it("load",s);break;case"video":case"audio":for(o=0;o<dl.length;o++)it(dl[o],s);break;case"source":it("error",s);break;case"img":case"image":case"link":it("error",s),it("load",s);break;case"details":it("toggle",s);break;case"input":it("invalid",s),yy(s,u.value,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name,!0);break;case"select":it("invalid",s);break;case"textarea":it("invalid",s),xy(s,u.value,u.defaultValue,u.children)}o=u.children,typeof o!="string"&&typeof o!="number"&&typeof o!="bigint"||s.textContent===""+o||u.suppressHydrationWarning===!0||_x(s.textContent,o)?(u.popover!=null&&(it("beforetoggle",s),it("toggle",s)),u.onScroll!=null&&it("scroll",s),u.onScrollEnd!=null&&it("scrollend",s),u.onClick!=null&&(s.onclick=Gr),s=!0):s=!1,s||Ta(r,!0)}function ib(r){for(cn=r.return;cn;)switch(cn.tag){case 5:case 31:case 13:nr=!1;return;case 27:case 3:nr=!0;return;default:cn=cn.return}}function wi(r){if(r!==cn)return!1;if(!ut)return ib(r),ut=!0,!1;var s=r.tag,o;if((o=s!==3&&s!==27)&&((o=s===5)&&(o=r.type,o=!(o!=="form"&&o!=="button")||Bm(r.type,r.memoizedProps)),o=!o),o&&Tt&&Ta(r),ib(r),s===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(a(317));Tt=kx(r)}else if(s===31){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(a(317));Tt=kx(r)}else s===27?(s=Tt,Ha(r.type)?(r=Gm,Gm=null,Tt=r):Tt=s):Tt=cn?ar(r.stateNode.nextSibling):null;return!0}function _s(){Tt=cn=null,ut=!1}function Eh(){var r=ja;return r!==null&&(An===null?An=r:An.push.apply(An,r),ja=null),r}function qo(r){ja===null?ja=[r]:ja.push(r)}var Nh=R(null),Ss=null,Xr=null;function Ra(r,s,o){I(Nh,s._currentValue),s._currentValue=o}function Jr(r){r._currentValue=Nh.current,O(Nh)}function Ch(r,s,o){for(;r!==null;){var u=r.alternate;if((r.childLanes&s)!==s?(r.childLanes|=s,u!==null&&(u.childLanes|=s)):u!==null&&(u.childLanes&s)!==s&&(u.childLanes|=s),r===o)break;r=r.return}}function jh(r,s,o,u){var p=r.child;for(p!==null&&(p.return=r);p!==null;){var y=p.dependencies;if(y!==null){var _=p.child;y=y.firstContext;e:for(;y!==null;){var j=y;y=p;for(var D=0;D<s.length;D++)if(j.context===s[D]){y.lanes|=o,j=y.alternate,j!==null&&(j.lanes|=o),Ch(y.return,o,r),u||(_=null);break e}y=j.next}}else if(p.tag===18){if(_=p.return,_===null)throw Error(a(341));_.lanes|=o,y=_.alternate,y!==null&&(y.lanes|=o),Ch(_,o,r),_=null}else _=p.child;if(_!==null)_.return=p;else for(_=p;_!==null;){if(_===r){_=null;break}if(p=_.sibling,p!==null){p.return=_.return,_=p;break}_=_.return}p=_}}function _i(r,s,o,u){r=null;for(var p=s,y=!1;p!==null;){if(!y){if((p.flags&524288)!==0)y=!0;else if((p.flags&262144)!==0)break}if(p.tag===10){var _=p.alternate;if(_===null)throw Error(a(387));if(_=_.memoizedProps,_!==null){var j=p.type;In(p.pendingProps.value,_.value)||(r!==null?r.push(j):r=[j])}}else if(p===te.current){if(_=p.alternate,_===null)throw Error(a(387));_.memoizedState.memoizedState!==p.memoizedState.memoizedState&&(r!==null?r.push(gl):r=[gl])}p=p.return}r!==null&&jh(s,r,o,u),s.flags|=262144}function Lc(r){for(r=r.firstContext;r!==null;){if(!In(r.context._currentValue,r.memoizedValue))return!0;r=r.next}return!1}function Es(r){Ss=r,Xr=null,r=r.dependencies,r!==null&&(r.firstContext=null)}function un(r){return ob(Ss,r)}function zc(r,s){return Ss===null&&Es(r),ob(r,s)}function ob(r,s){var o=s._currentValue;if(s={context:s,memoizedValue:o,next:null},Xr===null){if(r===null)throw Error(a(308));Xr=s,r.dependencies={lanes:0,firstContext:s},r.flags|=524288}else Xr=Xr.next=s;return o}var zR=typeof AbortController<"u"?AbortController:function(){var r=[],s=this.signal={aborted:!1,addEventListener:function(o,u){r.push(u)}};this.abort=function(){s.aborted=!0,r.forEach(function(o){return o()})}},IR=e.unstable_scheduleCallback,$R=e.unstable_NormalPriority,Ht={$$typeof:T,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Th(){return{controller:new zR,data:new Map,refCount:0}}function Vo(r){r.refCount--,r.refCount===0&&IR($R,function(){r.controller.abort()})}var Fo=null,Rh=0,Si=0,Ei=null;function UR(r,s){if(Fo===null){var o=Fo=[];Rh=0,Si=Om(),Ei={status:"pending",value:void 0,then:function(u){o.push(u)}}}return Rh++,s.then(lb,lb),s}function lb(){if(--Rh===0&&Fo!==null){Ei!==null&&(Ei.status="fulfilled");var r=Fo;Fo=null,Si=0,Ei=null;for(var s=0;s<r.length;s++)(0,r[s])()}}function BR(r,s){var o=[],u={status:"pending",value:null,reason:null,then:function(p){o.push(p)}};return r.then(function(){u.status="fulfilled",u.value=s;for(var p=0;p<o.length;p++)(0,o[p])(s)},function(p){for(u.status="rejected",u.reason=p,p=0;p<o.length;p++)(0,o[p])(void 0)}),u}var cb=k.S;k.S=function(r,s){G0=Le(),typeof s=="object"&&s!==null&&typeof s.then=="function"&&UR(r,s),cb!==null&&cb(r,s)};var Ns=R(null);function Ah(){var r=Ns.current;return r!==null?r:St.pooledCache}function Ic(r,s){s===null?I(Ns,Ns.current):I(Ns,s.pool)}function ub(){var r=Ah();return r===null?null:{parent:Ht._currentValue,pool:r}}var Ni=Error(a(460)),kh=Error(a(474)),$c=Error(a(542)),Uc={then:function(){}};function db(r){return r=r.status,r==="fulfilled"||r==="rejected"}function fb(r,s,o){switch(o=r[o],o===void 0?r.push(s):o!==s&&(s.then(Gr,Gr),s=o),s.status){case"fulfilled":return s.value;case"rejected":throw r=s.reason,mb(r),r;default:if(typeof s.status=="string")s.then(Gr,Gr);else{if(r=St,r!==null&&100<r.shellSuspendCounter)throw Error(a(482));r=s,r.status="pending",r.then(function(u){if(s.status==="pending"){var p=s;p.status="fulfilled",p.value=u}},function(u){if(s.status==="pending"){var p=s;p.status="rejected",p.reason=u}})}switch(s.status){case"fulfilled":return s.value;case"rejected":throw r=s.reason,mb(r),r}throw js=s,Ni}}function Cs(r){try{var s=r._init;return s(r._payload)}catch(o){throw o!==null&&typeof o=="object"&&typeof o.then=="function"?(js=o,Ni):o}}var js=null;function hb(){if(js===null)throw Error(a(459));var r=js;return js=null,r}function mb(r){if(r===Ni||r===$c)throw Error(a(483))}var Ci=null,Go=0;function Bc(r){var s=Go;return Go+=1,Ci===null&&(Ci=[]),fb(Ci,r,s)}function Ko(r,s){s=s.props.ref,r.ref=s!==void 0?s:null}function Hc(r,s){throw s.$$typeof===x?Error(a(525)):(r=Object.prototype.toString.call(s),Error(a(31,r==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":r)))}function pb(r){function s(B,z){if(r){var G=B.deletions;G===null?(B.deletions=[z],B.flags|=16):G.push(z)}}function o(B,z){if(!r)return null;for(;z!==null;)s(B,z),z=z.sibling;return null}function u(B){for(var z=new Map;B!==null;)B.key!==null?z.set(B.key,B):z.set(B.index,B),B=B.sibling;return z}function p(B,z){return B=Wr(B,z),B.index=0,B.sibling=null,B}function y(B,z,G){return B.index=G,r?(G=B.alternate,G!==null?(G=G.index,G<z?(B.flags|=67108866,z):G):(B.flags|=67108866,z)):(B.flags|=1048576,z)}function _(B){return r&&B.alternate===null&&(B.flags|=67108866),B}function j(B,z,G,oe){return z===null||z.tag!==6?(z=bh(G,B.mode,oe),z.return=B,z):(z=p(z,G),z.return=B,z)}function D(B,z,G,oe){var Ie=G.type;return Ie===S?ae(B,z,G.props.children,oe,G.key):z!==null&&(z.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===U&&Cs(Ie)===z.type)?(z=p(z,G.props),Ko(z,G),z.return=B,z):(z=Dc(G.type,G.key,G.props,null,B.mode,oe),Ko(z,G),z.return=B,z)}function W(B,z,G,oe){return z===null||z.tag!==4||z.stateNode.containerInfo!==G.containerInfo||z.stateNode.implementation!==G.implementation?(z=xh(G,B.mode,oe),z.return=B,z):(z=p(z,G.children||[]),z.return=B,z)}function ae(B,z,G,oe,Ie){return z===null||z.tag!==7?(z=ws(G,B.mode,oe,Ie),z.return=B,z):(z=p(z,G),z.return=B,z)}function le(B,z,G){if(typeof z=="string"&&z!==""||typeof z=="number"||typeof z=="bigint")return z=bh(""+z,B.mode,G),z.return=B,z;if(typeof z=="object"&&z!==null){switch(z.$$typeof){case w:return G=Dc(z.type,z.key,z.props,null,B.mode,G),Ko(G,z),G.return=B,G;case E:return z=xh(z,B.mode,G),z.return=B,z;case U:return z=Cs(z),le(B,z,G)}if(de(z)||me(z))return z=ws(z,B.mode,G,null),z.return=B,z;if(typeof z.then=="function")return le(B,Bc(z),G);if(z.$$typeof===T)return le(B,zc(B,z),G);Hc(B,z)}return null}function X(B,z,G,oe){var Ie=z!==null?z.key:null;if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return Ie!==null?null:j(B,z,""+G,oe);if(typeof G=="object"&&G!==null){switch(G.$$typeof){case w:return G.key===Ie?D(B,z,G,oe):null;case E:return G.key===Ie?W(B,z,G,oe):null;case U:return G=Cs(G),X(B,z,G,oe)}if(de(G)||me(G))return Ie!==null?null:ae(B,z,G,oe,null);if(typeof G.then=="function")return X(B,z,Bc(G),oe);if(G.$$typeof===T)return X(B,z,zc(B,G),oe);Hc(B,G)}return null}function Z(B,z,G,oe,Ie){if(typeof oe=="string"&&oe!==""||typeof oe=="number"||typeof oe=="bigint")return B=B.get(G)||null,j(z,B,""+oe,Ie);if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case w:return B=B.get(oe.key===null?G:oe.key)||null,D(z,B,oe,Ie);case E:return B=B.get(oe.key===null?G:oe.key)||null,W(z,B,oe,Ie);case U:return oe=Cs(oe),Z(B,z,G,oe,Ie)}if(de(oe)||me(oe))return B=B.get(G)||null,ae(z,B,oe,Ie,null);if(typeof oe.then=="function")return Z(B,z,G,Bc(oe),Ie);if(oe.$$typeof===T)return Z(B,z,G,zc(z,oe),Ie);Hc(z,oe)}return null}function Re(B,z,G,oe){for(var Ie=null,mt=null,Oe=z,Ze=z=0,ct=null;Oe!==null&&Ze<G.length;Ze++){Oe.index>Ze?(ct=Oe,Oe=null):ct=Oe.sibling;var pt=X(B,Oe,G[Ze],oe);if(pt===null){Oe===null&&(Oe=ct);break}r&&Oe&&pt.alternate===null&&s(B,Oe),z=y(pt,z,Ze),mt===null?Ie=pt:mt.sibling=pt,mt=pt,Oe=ct}if(Ze===G.length)return o(B,Oe),ut&&Yr(B,Ze),Ie;if(Oe===null){for(;Ze<G.length;Ze++)Oe=le(B,G[Ze],oe),Oe!==null&&(z=y(Oe,z,Ze),mt===null?Ie=Oe:mt.sibling=Oe,mt=Oe);return ut&&Yr(B,Ze),Ie}for(Oe=u(Oe);Ze<G.length;Ze++)ct=Z(Oe,B,Ze,G[Ze],oe),ct!==null&&(r&&ct.alternate!==null&&Oe.delete(ct.key===null?Ze:ct.key),z=y(ct,z,Ze),mt===null?Ie=ct:mt.sibling=ct,mt=ct);return r&&Oe.forEach(function(Ka){return s(B,Ka)}),ut&&Yr(B,Ze),Ie}function Ve(B,z,G,oe){if(G==null)throw Error(a(151));for(var Ie=null,mt=null,Oe=z,Ze=z=0,ct=null,pt=G.next();Oe!==null&&!pt.done;Ze++,pt=G.next()){Oe.index>Ze?(ct=Oe,Oe=null):ct=Oe.sibling;var Ka=X(B,Oe,pt.value,oe);if(Ka===null){Oe===null&&(Oe=ct);break}r&&Oe&&Ka.alternate===null&&s(B,Oe),z=y(Ka,z,Ze),mt===null?Ie=Ka:mt.sibling=Ka,mt=Ka,Oe=ct}if(pt.done)return o(B,Oe),ut&&Yr(B,Ze),Ie;if(Oe===null){for(;!pt.done;Ze++,pt=G.next())pt=le(B,pt.value,oe),pt!==null&&(z=y(pt,z,Ze),mt===null?Ie=pt:mt.sibling=pt,mt=pt);return ut&&Yr(B,Ze),Ie}for(Oe=u(Oe);!pt.done;Ze++,pt=G.next())pt=Z(Oe,B,Ze,pt.value,oe),pt!==null&&(r&&pt.alternate!==null&&Oe.delete(pt.key===null?Ze:pt.key),z=y(pt,z,Ze),mt===null?Ie=pt:mt.sibling=pt,mt=pt);return r&&Oe.forEach(function(QA){return s(B,QA)}),ut&&Yr(B,Ze),Ie}function _t(B,z,G,oe){if(typeof G=="object"&&G!==null&&G.type===S&&G.key===null&&(G=G.props.children),typeof G=="object"&&G!==null){switch(G.$$typeof){case w:e:{for(var Ie=G.key;z!==null;){if(z.key===Ie){if(Ie=G.type,Ie===S){if(z.tag===7){o(B,z.sibling),oe=p(z,G.props.children),oe.return=B,B=oe;break e}}else if(z.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===U&&Cs(Ie)===z.type){o(B,z.sibling),oe=p(z,G.props),Ko(oe,G),oe.return=B,B=oe;break e}o(B,z);break}else s(B,z);z=z.sibling}G.type===S?(oe=ws(G.props.children,B.mode,oe,G.key),oe.return=B,B=oe):(oe=Dc(G.type,G.key,G.props,null,B.mode,oe),Ko(oe,G),oe.return=B,B=oe)}return _(B);case E:e:{for(Ie=G.key;z!==null;){if(z.key===Ie)if(z.tag===4&&z.stateNode.containerInfo===G.containerInfo&&z.stateNode.implementation===G.implementation){o(B,z.sibling),oe=p(z,G.children||[]),oe.return=B,B=oe;break e}else{o(B,z);break}else s(B,z);z=z.sibling}oe=xh(G,B.mode,oe),oe.return=B,B=oe}return _(B);case U:return G=Cs(G),_t(B,z,G,oe)}if(de(G))return Re(B,z,G,oe);if(me(G)){if(Ie=me(G),typeof Ie!="function")throw Error(a(150));return G=Ie.call(G),Ve(B,z,G,oe)}if(typeof G.then=="function")return _t(B,z,Bc(G),oe);if(G.$$typeof===T)return _t(B,z,zc(B,G),oe);Hc(B,G)}return typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint"?(G=""+G,z!==null&&z.tag===6?(o(B,z.sibling),oe=p(z,G),oe.return=B,B=oe):(o(B,z),oe=bh(G,B.mode,oe),oe.return=B,B=oe),_(B)):o(B,z)}return function(B,z,G,oe){try{Go=0;var Ie=_t(B,z,G,oe);return Ci=null,Ie}catch(Oe){if(Oe===Ni||Oe===$c)throw Oe;var mt=$n(29,Oe,null,B.mode);return mt.lanes=oe,mt.return=B,mt}finally{}}}var Ts=pb(!0),gb=pb(!1),Aa=!1;function Oh(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Mh(r,s){r=r.updateQueue,s.updateQueue===r&&(s.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,callbacks:null})}function ka(r){return{lane:r,tag:0,payload:null,callback:null,next:null}}function Oa(r,s,o){var u=r.updateQueue;if(u===null)return null;if(u=u.shared,(vt&2)!==0){var p=u.pending;return p===null?s.next=s:(s.next=p.next,p.next=s),u.pending=s,s=Mc(r),Zy(r,null,o),s}return Oc(r,u,s,o),Mc(r)}function Wo(r,s,o){if(s=s.updateQueue,s!==null&&(s=s.shared,(o&4194048)!==0)){var u=s.lanes;u&=r.pendingLanes,o|=u,s.lanes=o,Sn(r,o)}}function Dh(r,s){var o=r.updateQueue,u=r.alternate;if(u!==null&&(u=u.updateQueue,o===u)){var p=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var _={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?p=y=_:y=y.next=_,o=o.next}while(o!==null);y===null?p=y=s:y=y.next=s}else p=y=s;o={baseState:u.baseState,firstBaseUpdate:p,lastBaseUpdate:y,shared:u.shared,callbacks:u.callbacks},r.updateQueue=o;return}r=o.lastBaseUpdate,r===null?o.firstBaseUpdate=s:r.next=s,o.lastBaseUpdate=s}var Ph=!1;function Yo(){if(Ph){var r=Ei;if(r!==null)throw r}}function Xo(r,s,o,u){Ph=!1;var p=r.updateQueue;Aa=!1;var y=p.firstBaseUpdate,_=p.lastBaseUpdate,j=p.shared.pending;if(j!==null){p.shared.pending=null;var D=j,W=D.next;D.next=null,_===null?y=W:_.next=W,_=D;var ae=r.alternate;ae!==null&&(ae=ae.updateQueue,j=ae.lastBaseUpdate,j!==_&&(j===null?ae.firstBaseUpdate=W:j.next=W,ae.lastBaseUpdate=D))}if(y!==null){var le=p.baseState;_=0,ae=W=D=null,j=y;do{var X=j.lane&-536870913,Z=X!==j.lane;if(Z?(lt&X)===X:(u&X)===X){X!==0&&X===Si&&(Ph=!0),ae!==null&&(ae=ae.next={lane:0,tag:j.tag,payload:j.payload,callback:null,next:null});e:{var Re=r,Ve=j;X=s;var _t=o;switch(Ve.tag){case 1:if(Re=Ve.payload,typeof Re=="function"){le=Re.call(_t,le,X);break e}le=Re;break e;case 3:Re.flags=Re.flags&-65537|128;case 0:if(Re=Ve.payload,X=typeof Re=="function"?Re.call(_t,le,X):Re,X==null)break e;le=g({},le,X);break e;case 2:Aa=!0}}X=j.callback,X!==null&&(r.flags|=64,Z&&(r.flags|=8192),Z=p.callbacks,Z===null?p.callbacks=[X]:Z.push(X))}else Z={lane:X,tag:j.tag,payload:j.payload,callback:j.callback,next:null},ae===null?(W=ae=Z,D=le):ae=ae.next=Z,_|=X;if(j=j.next,j===null){if(j=p.shared.pending,j===null)break;Z=j,j=Z.next,Z.next=null,p.lastBaseUpdate=Z,p.shared.pending=null}}while(!0);ae===null&&(D=le),p.baseState=D,p.firstBaseUpdate=W,p.lastBaseUpdate=ae,y===null&&(p.shared.lanes=0),za|=_,r.lanes=_,r.memoizedState=le}}function vb(r,s){if(typeof r!="function")throw Error(a(191,r));r.call(s)}function yb(r,s){var o=r.callbacks;if(o!==null)for(r.callbacks=null,r=0;r<o.length;r++)vb(o[r],s)}var ji=R(null),qc=R(0);function bb(r,s){r=ia,I(qc,r),I(ji,s),ia=r|s.baseLanes}function Lh(){I(qc,ia),I(ji,ji.current)}function zh(){ia=qc.current,O(ji),O(qc)}var Un=R(null),rr=null;function Ma(r){var s=r.alternate;I(Ut,Ut.current&1),I(Un,r),rr===null&&(s===null||ji.current!==null||s.memoizedState!==null)&&(rr=r)}function Ih(r){I(Ut,Ut.current),I(Un,r),rr===null&&(rr=r)}function xb(r){r.tag===22?(I(Ut,Ut.current),I(Un,r),rr===null&&(rr=r)):Da()}function Da(){I(Ut,Ut.current),I(Un,Un.current)}function Bn(r){O(Un),rr===r&&(rr=null),O(Ut)}var Ut=R(0);function Vc(r){for(var s=r;s!==null;){if(s.tag===13){var o=s.memoizedState;if(o!==null&&(o=o.dehydrated,o===null||Vm(o)||Fm(o)))return s}else if(s.tag===19&&(s.memoizedProps.revealOrder==="forwards"||s.memoizedProps.revealOrder==="backwards"||s.memoizedProps.revealOrder==="unstable_legacy-backwards"||s.memoizedProps.revealOrder==="together")){if((s.flags&128)!==0)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===r)break;for(;s.sibling===null;){if(s.return===null||s.return===r)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var Qr=0,Qe=null,xt=null,qt=null,Fc=!1,Ti=!1,Rs=!1,Gc=0,Jo=0,Ri=null,HR=0;function Lt(){throw Error(a(321))}function $h(r,s){if(s===null)return!1;for(var o=0;o<s.length&&o<r.length;o++)if(!In(r[o],s[o]))return!1;return!0}function Uh(r,s,o,u,p,y){return Qr=y,Qe=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,k.H=r===null||r.memoizedState===null?r0:tm,Rs=!1,y=o(u,p),Rs=!1,Ti&&(y=_b(s,o,u,p)),wb(r),y}function wb(r){k.H=el;var s=xt!==null&&xt.next!==null;if(Qr=0,qt=xt=Qe=null,Fc=!1,Jo=0,Ri=null,s)throw Error(a(300));r===null||Vt||(r=r.dependencies,r!==null&&Lc(r)&&(Vt=!0))}function _b(r,s,o,u){Qe=r;var p=0;do{if(Ti&&(Ri=null),Jo=0,Ti=!1,25<=p)throw Error(a(301));if(p+=1,qt=xt=null,r.updateQueue!=null){var y=r.updateQueue;y.lastEffect=null,y.events=null,y.stores=null,y.memoCache!=null&&(y.memoCache.index=0)}k.H=a0,y=s(o,u)}while(Ti);return y}function qR(){var r=k.H,s=r.useState()[0];return s=typeof s.then=="function"?Qo(s):s,r=r.useState()[0],(xt!==null?xt.memoizedState:null)!==r&&(Qe.flags|=1024),s}function Bh(){var r=Gc!==0;return Gc=0,r}function Hh(r,s,o){s.updateQueue=r.updateQueue,s.flags&=-2053,r.lanes&=~o}function qh(r){if(Fc){for(r=r.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}Fc=!1}Qr=0,qt=xt=Qe=null,Ti=!1,Jo=Gc=0,Ri=null}function xn(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return qt===null?Qe.memoizedState=qt=r:qt=qt.next=r,qt}function Bt(){if(xt===null){var r=Qe.alternate;r=r!==null?r.memoizedState:null}else r=xt.next;var s=qt===null?Qe.memoizedState:qt.next;if(s!==null)qt=s,xt=r;else{if(r===null)throw Qe.alternate===null?Error(a(467)):Error(a(310));xt=r,r={memoizedState:xt.memoizedState,baseState:xt.baseState,baseQueue:xt.baseQueue,queue:xt.queue,next:null},qt===null?Qe.memoizedState=qt=r:qt=qt.next=r}return qt}function Kc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Qo(r){var s=Jo;return Jo+=1,Ri===null&&(Ri=[]),r=fb(Ri,r,s),s=Qe,(qt===null?s.memoizedState:qt.next)===null&&(s=s.alternate,k.H=s===null||s.memoizedState===null?r0:tm),r}function Wc(r){if(r!==null&&typeof r=="object"){if(typeof r.then=="function")return Qo(r);if(r.$$typeof===T)return un(r)}throw Error(a(438,String(r)))}function Vh(r){var s=null,o=Qe.updateQueue;if(o!==null&&(s=o.memoCache),s==null){var u=Qe.alternate;u!==null&&(u=u.updateQueue,u!==null&&(u=u.memoCache,u!=null&&(s={data:u.data.map(function(p){return p.slice()}),index:0})))}if(s==null&&(s={data:[],index:0}),o===null&&(o=Kc(),Qe.updateQueue=o),o.memoCache=s,o=s.data[s.index],o===void 0)for(o=s.data[s.index]=Array(r),u=0;u<r;u++)o[u]=ce;return s.index++,o}function Zr(r,s){return typeof s=="function"?s(r):s}function Yc(r){var s=Bt();return Fh(s,xt,r)}function Fh(r,s,o){var u=r.queue;if(u===null)throw Error(a(311));u.lastRenderedReducer=o;var p=r.baseQueue,y=u.pending;if(y!==null){if(p!==null){var _=p.next;p.next=y.next,y.next=_}s.baseQueue=p=y,u.pending=null}if(y=r.baseState,p===null)r.memoizedState=y;else{s=p.next;var j=_=null,D=null,W=s,ae=!1;do{var le=W.lane&-536870913;if(le!==W.lane?(lt&le)===le:(Qr&le)===le){var X=W.revertLane;if(X===0)D!==null&&(D=D.next={lane:0,revertLane:0,gesture:null,action:W.action,hasEagerState:W.hasEagerState,eagerState:W.eagerState,next:null}),le===Si&&(ae=!0);else if((Qr&X)===X){W=W.next,X===Si&&(ae=!0);continue}else le={lane:0,revertLane:W.revertLane,gesture:null,action:W.action,hasEagerState:W.hasEagerState,eagerState:W.eagerState,next:null},D===null?(j=D=le,_=y):D=D.next=le,Qe.lanes|=X,za|=X;le=W.action,Rs&&o(y,le),y=W.hasEagerState?W.eagerState:o(y,le)}else X={lane:le,revertLane:W.revertLane,gesture:W.gesture,action:W.action,hasEagerState:W.hasEagerState,eagerState:W.eagerState,next:null},D===null?(j=D=X,_=y):D=D.next=X,Qe.lanes|=le,za|=le;W=W.next}while(W!==null&&W!==s);if(D===null?_=y:D.next=j,!In(y,r.memoizedState)&&(Vt=!0,ae&&(o=Ei,o!==null)))throw o;r.memoizedState=y,r.baseState=_,r.baseQueue=D,u.lastRenderedState=y}return p===null&&(u.lanes=0),[r.memoizedState,u.dispatch]}function Gh(r){var s=Bt(),o=s.queue;if(o===null)throw Error(a(311));o.lastRenderedReducer=r;var u=o.dispatch,p=o.pending,y=s.memoizedState;if(p!==null){o.pending=null;var _=p=p.next;do y=r(y,_.action),_=_.next;while(_!==p);In(y,s.memoizedState)||(Vt=!0),s.memoizedState=y,s.baseQueue===null&&(s.baseState=y),o.lastRenderedState=y}return[y,u]}function Sb(r,s,o){var u=Qe,p=Bt(),y=ut;if(y){if(o===void 0)throw Error(a(407));o=o()}else o=s();var _=!In((xt||p).memoizedState,o);if(_&&(p.memoizedState=o,Vt=!0),p=p.queue,Yh(Cb.bind(null,u,p,r),[r]),p.getSnapshot!==s||_||qt!==null&&qt.memoizedState.tag&1){if(u.flags|=2048,Ai(9,{destroy:void 0},Nb.bind(null,u,p,o,s),null),St===null)throw Error(a(349));y||(Qr&127)!==0||Eb(u,s,o)}return o}function Eb(r,s,o){r.flags|=16384,r={getSnapshot:s,value:o},s=Qe.updateQueue,s===null?(s=Kc(),Qe.updateQueue=s,s.stores=[r]):(o=s.stores,o===null?s.stores=[r]:o.push(r))}function Nb(r,s,o,u){s.value=o,s.getSnapshot=u,jb(s)&&Tb(r)}function Cb(r,s,o){return o(function(){jb(s)&&Tb(r)})}function jb(r){var s=r.getSnapshot;r=r.value;try{var o=s();return!In(r,o)}catch{return!0}}function Tb(r){var s=xs(r,2);s!==null&&kn(s,r,2)}function Kh(r){var s=xn();if(typeof r=="function"){var o=r;if(r=o(),Rs){Jt(!0);try{o()}finally{Jt(!1)}}}return s.memoizedState=s.baseState=r,s.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Zr,lastRenderedState:r},s}function Rb(r,s,o,u){return r.baseState=o,Fh(r,xt,typeof u=="function"?u:Zr)}function VR(r,s,o,u,p){if(Qc(r))throw Error(a(485));if(r=s.action,r!==null){var y={payload:p,action:r,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(_){y.listeners.push(_)}};k.T!==null?o(!0):y.isTransition=!1,u(y),o=s.pending,o===null?(y.next=s.pending=y,Ab(s,y)):(y.next=o.next,s.pending=o.next=y)}}function Ab(r,s){var o=s.action,u=s.payload,p=r.state;if(s.isTransition){var y=k.T,_={};k.T=_;try{var j=o(p,u),D=k.S;D!==null&&D(_,j),kb(r,s,j)}catch(W){Wh(r,s,W)}finally{y!==null&&_.types!==null&&(y.types=_.types),k.T=y}}else try{y=o(p,u),kb(r,s,y)}catch(W){Wh(r,s,W)}}function kb(r,s,o){o!==null&&typeof o=="object"&&typeof o.then=="function"?o.then(function(u){Ob(r,s,u)},function(u){return Wh(r,s,u)}):Ob(r,s,o)}function Ob(r,s,o){s.status="fulfilled",s.value=o,Mb(s),r.state=o,s=r.pending,s!==null&&(o=s.next,o===s?r.pending=null:(o=o.next,s.next=o,Ab(r,o)))}function Wh(r,s,o){var u=r.pending;if(r.pending=null,u!==null){u=u.next;do s.status="rejected",s.reason=o,Mb(s),s=s.next;while(s!==u)}r.action=null}function Mb(r){r=r.listeners;for(var s=0;s<r.length;s++)(0,r[s])()}function Db(r,s){return s}function Pb(r,s){if(ut){var o=St.formState;if(o!==null){e:{var u=Qe;if(ut){if(Tt){t:{for(var p=Tt,y=nr;p.nodeType!==8;){if(!y){p=null;break t}if(p=ar(p.nextSibling),p===null){p=null;break t}}y=p.data,p=y==="F!"||y==="F"?p:null}if(p){Tt=ar(p.nextSibling),u=p.data==="F!";break e}}Ta(u)}u=!1}u&&(s=o[0])}}return o=xn(),o.memoizedState=o.baseState=s,u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Db,lastRenderedState:s},o.queue=u,o=e0.bind(null,Qe,u),u.dispatch=o,u=Kh(!1),y=em.bind(null,Qe,!1,u.queue),u=xn(),p={state:s,dispatch:null,action:r,pending:null},u.queue=p,o=VR.bind(null,Qe,p,y,o),p.dispatch=o,u.memoizedState=r,[s,o,!1]}function Lb(r){var s=Bt();return zb(s,xt,r)}function zb(r,s,o){if(s=Fh(r,s,Db)[0],r=Yc(Zr)[0],typeof s=="object"&&s!==null&&typeof s.then=="function")try{var u=Qo(s)}catch(_){throw _===Ni?$c:_}else u=s;s=Bt();var p=s.queue,y=p.dispatch;return o!==s.memoizedState&&(Qe.flags|=2048,Ai(9,{destroy:void 0},FR.bind(null,p,o),null)),[u,y,r]}function FR(r,s){r.action=s}function Ib(r){var s=Bt(),o=xt;if(o!==null)return zb(s,o,r);Bt(),s=s.memoizedState,o=Bt();var u=o.queue.dispatch;return o.memoizedState=r,[s,u,!1]}function Ai(r,s,o,u){return r={tag:r,create:o,deps:u,inst:s,next:null},s=Qe.updateQueue,s===null&&(s=Kc(),Qe.updateQueue=s),o=s.lastEffect,o===null?s.lastEffect=r.next=r:(u=o.next,o.next=r,r.next=u,s.lastEffect=r),r}function $b(){return Bt().memoizedState}function Xc(r,s,o,u){var p=xn();Qe.flags|=r,p.memoizedState=Ai(1|s,{destroy:void 0},o,u===void 0?null:u)}function Jc(r,s,o,u){var p=Bt();u=u===void 0?null:u;var y=p.memoizedState.inst;xt!==null&&u!==null&&$h(u,xt.memoizedState.deps)?p.memoizedState=Ai(s,y,o,u):(Qe.flags|=r,p.memoizedState=Ai(1|s,y,o,u))}function Ub(r,s){Xc(8390656,8,r,s)}function Yh(r,s){Jc(2048,8,r,s)}function GR(r){Qe.flags|=4;var s=Qe.updateQueue;if(s===null)s=Kc(),Qe.updateQueue=s,s.events=[r];else{var o=s.events;o===null?s.events=[r]:o.push(r)}}function Bb(r){var s=Bt().memoizedState;return GR({ref:s,nextImpl:r}),function(){if((vt&2)!==0)throw Error(a(440));return s.impl.apply(void 0,arguments)}}function Hb(r,s){return Jc(4,2,r,s)}function qb(r,s){return Jc(4,4,r,s)}function Vb(r,s){if(typeof s=="function"){r=r();var o=s(r);return function(){typeof o=="function"?o():s(null)}}if(s!=null)return r=r(),s.current=r,function(){s.current=null}}function Fb(r,s,o){o=o!=null?o.concat([r]):null,Jc(4,4,Vb.bind(null,s,r),o)}function Xh(){}function Gb(r,s){var o=Bt();s=s===void 0?null:s;var u=o.memoizedState;return s!==null&&$h(s,u[1])?u[0]:(o.memoizedState=[r,s],r)}function Kb(r,s){var o=Bt();s=s===void 0?null:s;var u=o.memoizedState;if(s!==null&&$h(s,u[1]))return u[0];if(u=r(),Rs){Jt(!0);try{r()}finally{Jt(!1)}}return o.memoizedState=[u,s],u}function Jh(r,s,o){return o===void 0||(Qr&1073741824)!==0&&(lt&261930)===0?r.memoizedState=s:(r.memoizedState=o,r=W0(),Qe.lanes|=r,za|=r,o)}function Wb(r,s,o,u){return In(o,s)?o:ji.current!==null?(r=Jh(r,o,u),In(r,s)||(Vt=!0),r):(Qr&42)===0||(Qr&1073741824)!==0&&(lt&261930)===0?(Vt=!0,r.memoizedState=o):(r=W0(),Qe.lanes|=r,za|=r,s)}function Yb(r,s,o,u,p){var y=K.p;K.p=y!==0&&8>y?y:8;var _=k.T,j={};k.T=j,em(r,!1,s,o);try{var D=p(),W=k.S;if(W!==null&&W(j,D),D!==null&&typeof D=="object"&&typeof D.then=="function"){var ae=BR(D,u);Zo(r,s,ae,Vn(r))}else Zo(r,s,u,Vn(r))}catch(le){Zo(r,s,{then:function(){},status:"rejected",reason:le},Vn())}finally{K.p=y,_!==null&&j.types!==null&&(_.types=j.types),k.T=_}}function KR(){}function Qh(r,s,o,u){if(r.tag!==5)throw Error(a(476));var p=Xb(r).queue;Yb(r,p,s,F,o===null?KR:function(){return Jb(r),o(u)})}function Xb(r){var s=r.memoizedState;if(s!==null)return s;s={memoizedState:F,baseState:F,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Zr,lastRenderedState:F},next:null};var o={};return s.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Zr,lastRenderedState:o},next:null},r.memoizedState=s,r=r.alternate,r!==null&&(r.memoizedState=s),s}function Jb(r){var s=Xb(r);s.next===null&&(s=r.alternate.memoizedState),Zo(r,s.next.queue,{},Vn())}function Zh(){return un(gl)}function Qb(){return Bt().memoizedState}function Zb(){return Bt().memoizedState}function WR(r){for(var s=r.return;s!==null;){switch(s.tag){case 24:case 3:var o=Vn();r=ka(o);var u=Oa(s,r,o);u!==null&&(kn(u,s,o),Wo(u,s,o)),s={cache:Th()},r.payload=s;return}s=s.return}}function YR(r,s,o){var u=Vn();o={lane:u,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Qc(r)?t0(s,o):(o=vh(r,s,o,u),o!==null&&(kn(o,r,u),n0(o,s,u)))}function e0(r,s,o){var u=Vn();Zo(r,s,o,u)}function Zo(r,s,o,u){var p={lane:u,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Qc(r))t0(s,p);else{var y=r.alternate;if(r.lanes===0&&(y===null||y.lanes===0)&&(y=s.lastRenderedReducer,y!==null))try{var _=s.lastRenderedState,j=y(_,o);if(p.hasEagerState=!0,p.eagerState=j,In(j,_))return Oc(r,s,p,0),St===null&&kc(),!1}catch{}finally{}if(o=vh(r,s,p,u),o!==null)return kn(o,r,u),n0(o,s,u),!0}return!1}function em(r,s,o,u){if(u={lane:2,revertLane:Om(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Qc(r)){if(s)throw Error(a(479))}else s=vh(r,o,u,2),s!==null&&kn(s,r,2)}function Qc(r){var s=r.alternate;return r===Qe||s!==null&&s===Qe}function t0(r,s){Ti=Fc=!0;var o=r.pending;o===null?s.next=s:(s.next=o.next,o.next=s),r.pending=s}function n0(r,s,o){if((o&4194048)!==0){var u=s.lanes;u&=r.pendingLanes,o|=u,s.lanes=o,Sn(r,o)}}var el={readContext:un,use:Wc,useCallback:Lt,useContext:Lt,useEffect:Lt,useImperativeHandle:Lt,useLayoutEffect:Lt,useInsertionEffect:Lt,useMemo:Lt,useReducer:Lt,useRef:Lt,useState:Lt,useDebugValue:Lt,useDeferredValue:Lt,useTransition:Lt,useSyncExternalStore:Lt,useId:Lt,useHostTransitionStatus:Lt,useFormState:Lt,useActionState:Lt,useOptimistic:Lt,useMemoCache:Lt,useCacheRefresh:Lt};el.useEffectEvent=Lt;var r0={readContext:un,use:Wc,useCallback:function(r,s){return xn().memoizedState=[r,s===void 0?null:s],r},useContext:un,useEffect:Ub,useImperativeHandle:function(r,s,o){o=o!=null?o.concat([r]):null,Xc(4194308,4,Vb.bind(null,s,r),o)},useLayoutEffect:function(r,s){return Xc(4194308,4,r,s)},useInsertionEffect:function(r,s){Xc(4,2,r,s)},useMemo:function(r,s){var o=xn();s=s===void 0?null:s;var u=r();if(Rs){Jt(!0);try{r()}finally{Jt(!1)}}return o.memoizedState=[u,s],u},useReducer:function(r,s,o){var u=xn();if(o!==void 0){var p=o(s);if(Rs){Jt(!0);try{o(s)}finally{Jt(!1)}}}else p=s;return u.memoizedState=u.baseState=p,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:p},u.queue=r,r=r.dispatch=YR.bind(null,Qe,r),[u.memoizedState,r]},useRef:function(r){var s=xn();return r={current:r},s.memoizedState=r},useState:function(r){r=Kh(r);var s=r.queue,o=e0.bind(null,Qe,s);return s.dispatch=o,[r.memoizedState,o]},useDebugValue:Xh,useDeferredValue:function(r,s){var o=xn();return Jh(o,r,s)},useTransition:function(){var r=Kh(!1);return r=Yb.bind(null,Qe,r.queue,!0,!1),xn().memoizedState=r,[!1,r]},useSyncExternalStore:function(r,s,o){var u=Qe,p=xn();if(ut){if(o===void 0)throw Error(a(407));o=o()}else{if(o=s(),St===null)throw Error(a(349));(lt&127)!==0||Eb(u,s,o)}p.memoizedState=o;var y={value:o,getSnapshot:s};return p.queue=y,Ub(Cb.bind(null,u,y,r),[r]),u.flags|=2048,Ai(9,{destroy:void 0},Nb.bind(null,u,y,o,s),null),o},useId:function(){var r=xn(),s=St.identifierPrefix;if(ut){var o=Tr,u=jr;o=(u&~(1<<32-Dt(u)-1)).toString(32)+o,s="_"+s+"R_"+o,o=Gc++,0<o&&(s+="H"+o.toString(32)),s+="_"}else o=HR++,s="_"+s+"r_"+o.toString(32)+"_";return r.memoizedState=s},useHostTransitionStatus:Zh,useFormState:Pb,useActionState:Pb,useOptimistic:function(r){var s=xn();s.memoizedState=s.baseState=r;var o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return s.queue=o,s=em.bind(null,Qe,!0,o),o.dispatch=s,[r,s]},useMemoCache:Vh,useCacheRefresh:function(){return xn().memoizedState=WR.bind(null,Qe)},useEffectEvent:function(r){var s=xn(),o={impl:r};return s.memoizedState=o,function(){if((vt&2)!==0)throw Error(a(440));return o.impl.apply(void 0,arguments)}}},tm={readContext:un,use:Wc,useCallback:Gb,useContext:un,useEffect:Yh,useImperativeHandle:Fb,useInsertionEffect:Hb,useLayoutEffect:qb,useMemo:Kb,useReducer:Yc,useRef:$b,useState:function(){return Yc(Zr)},useDebugValue:Xh,useDeferredValue:function(r,s){var o=Bt();return Wb(o,xt.memoizedState,r,s)},useTransition:function(){var r=Yc(Zr)[0],s=Bt().memoizedState;return[typeof r=="boolean"?r:Qo(r),s]},useSyncExternalStore:Sb,useId:Qb,useHostTransitionStatus:Zh,useFormState:Lb,useActionState:Lb,useOptimistic:function(r,s){var o=Bt();return Rb(o,xt,r,s)},useMemoCache:Vh,useCacheRefresh:Zb};tm.useEffectEvent=Bb;var a0={readContext:un,use:Wc,useCallback:Gb,useContext:un,useEffect:Yh,useImperativeHandle:Fb,useInsertionEffect:Hb,useLayoutEffect:qb,useMemo:Kb,useReducer:Gh,useRef:$b,useState:function(){return Gh(Zr)},useDebugValue:Xh,useDeferredValue:function(r,s){var o=Bt();return xt===null?Jh(o,r,s):Wb(o,xt.memoizedState,r,s)},useTransition:function(){var r=Gh(Zr)[0],s=Bt().memoizedState;return[typeof r=="boolean"?r:Qo(r),s]},useSyncExternalStore:Sb,useId:Qb,useHostTransitionStatus:Zh,useFormState:Ib,useActionState:Ib,useOptimistic:function(r,s){var o=Bt();return xt!==null?Rb(o,xt,r,s):(o.baseState=r,[r,o.queue.dispatch])},useMemoCache:Vh,useCacheRefresh:Zb};a0.useEffectEvent=Bb;function nm(r,s,o,u){s=r.memoizedState,o=o(u,s),o=o==null?s:g({},s,o),r.memoizedState=o,r.lanes===0&&(r.updateQueue.baseState=o)}var rm={enqueueSetState:function(r,s,o){r=r._reactInternals;var u=Vn(),p=ka(u);p.payload=s,o!=null&&(p.callback=o),s=Oa(r,p,u),s!==null&&(kn(s,r,u),Wo(s,r,u))},enqueueReplaceState:function(r,s,o){r=r._reactInternals;var u=Vn(),p=ka(u);p.tag=1,p.payload=s,o!=null&&(p.callback=o),s=Oa(r,p,u),s!==null&&(kn(s,r,u),Wo(s,r,u))},enqueueForceUpdate:function(r,s){r=r._reactInternals;var o=Vn(),u=ka(o);u.tag=2,s!=null&&(u.callback=s),s=Oa(r,u,o),s!==null&&(kn(s,r,o),Wo(s,r,o))}};function s0(r,s,o,u,p,y,_){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(u,y,_):s.prototype&&s.prototype.isPureReactComponent?!Uo(o,u)||!Uo(p,y):!0}function i0(r,s,o,u){r=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(o,u),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(o,u),s.state!==r&&rm.enqueueReplaceState(s,s.state,null)}function As(r,s){var o=s;if("ref"in s){o={};for(var u in s)u!=="ref"&&(o[u]=s[u])}if(r=r.defaultProps){o===s&&(o=g({},o));for(var p in r)o[p]===void 0&&(o[p]=r[p])}return o}function o0(r){Ac(r)}function l0(r){console.error(r)}function c0(r){Ac(r)}function Zc(r,s){try{var o=r.onUncaughtError;o(s.value,{componentStack:s.stack})}catch(u){setTimeout(function(){throw u})}}function u0(r,s,o){try{var u=r.onCaughtError;u(o.value,{componentStack:o.stack,errorBoundary:s.tag===1?s.stateNode:null})}catch(p){setTimeout(function(){throw p})}}function am(r,s,o){return o=ka(o),o.tag=3,o.payload={element:null},o.callback=function(){Zc(r,s)},o}function d0(r){return r=ka(r),r.tag=3,r}function f0(r,s,o,u){var p=o.type.getDerivedStateFromError;if(typeof p=="function"){var y=u.value;r.payload=function(){return p(y)},r.callback=function(){u0(s,o,u)}}var _=o.stateNode;_!==null&&typeof _.componentDidCatch=="function"&&(r.callback=function(){u0(s,o,u),typeof p!="function"&&(Ia===null?Ia=new Set([this]):Ia.add(this));var j=u.stack;this.componentDidCatch(u.value,{componentStack:j!==null?j:""})})}function XR(r,s,o,u,p){if(o.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){if(s=o.alternate,s!==null&&_i(s,o,p,!0),o=Un.current,o!==null){switch(o.tag){case 31:case 13:return rr===null?du():o.alternate===null&&zt===0&&(zt=3),o.flags&=-257,o.flags|=65536,o.lanes=p,u===Uc?o.flags|=16384:(s=o.updateQueue,s===null?o.updateQueue=new Set([u]):s.add(u),Rm(r,u,p)),!1;case 22:return o.flags|=65536,u===Uc?o.flags|=16384:(s=o.updateQueue,s===null?(s={transitions:null,markerInstances:null,retryQueue:new Set([u])},o.updateQueue=s):(o=s.retryQueue,o===null?s.retryQueue=new Set([u]):o.add(u)),Rm(r,u,p)),!1}throw Error(a(435,o.tag))}return Rm(r,u,p),du(),!1}if(ut)return s=Un.current,s!==null?((s.flags&65536)===0&&(s.flags|=256),s.flags|=65536,s.lanes=p,u!==Sh&&(r=Error(a(422),{cause:u}),qo(Zn(r,o)))):(u!==Sh&&(s=Error(a(423),{cause:u}),qo(Zn(s,o))),r=r.current.alternate,r.flags|=65536,p&=-p,r.lanes|=p,u=Zn(u,o),p=am(r.stateNode,u,p),Dh(r,p),zt!==4&&(zt=2)),!1;var y=Error(a(520),{cause:u});if(y=Zn(y,o),ll===null?ll=[y]:ll.push(y),zt!==4&&(zt=2),s===null)return!0;u=Zn(u,o),o=s;do{switch(o.tag){case 3:return o.flags|=65536,r=p&-p,o.lanes|=r,r=am(o.stateNode,u,r),Dh(o,r),!1;case 1:if(s=o.type,y=o.stateNode,(o.flags&128)===0&&(typeof s.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(Ia===null||!Ia.has(y))))return o.flags|=65536,p&=-p,o.lanes|=p,p=d0(p),f0(p,r,o,u),Dh(o,p),!1}o=o.return}while(o!==null);return!1}var sm=Error(a(461)),Vt=!1;function dn(r,s,o,u){s.child=r===null?gb(s,null,o,u):Ts(s,r.child,o,u)}function h0(r,s,o,u,p){o=o.render;var y=s.ref;if("ref"in u){var _={};for(var j in u)j!=="ref"&&(_[j]=u[j])}else _=u;return Es(s),u=Uh(r,s,o,_,y,p),j=Bh(),r!==null&&!Vt?(Hh(r,s,p),ea(r,s,p)):(ut&&j&&wh(s),s.flags|=1,dn(r,s,u,p),s.child)}function m0(r,s,o,u,p){if(r===null){var y=o.type;return typeof y=="function"&&!yh(y)&&y.defaultProps===void 0&&o.compare===null?(s.tag=15,s.type=y,p0(r,s,y,u,p)):(r=Dc(o.type,null,u,s,s.mode,p),r.ref=s.ref,r.return=s,s.child=r)}if(y=r.child,!hm(r,p)){var _=y.memoizedProps;if(o=o.compare,o=o!==null?o:Uo,o(_,u)&&r.ref===s.ref)return ea(r,s,p)}return s.flags|=1,r=Wr(y,u),r.ref=s.ref,r.return=s,s.child=r}function p0(r,s,o,u,p){if(r!==null){var y=r.memoizedProps;if(Uo(y,u)&&r.ref===s.ref)if(Vt=!1,s.pendingProps=u=y,hm(r,p))(r.flags&131072)!==0&&(Vt=!0);else return s.lanes=r.lanes,ea(r,s,p)}return im(r,s,o,u,p)}function g0(r,s,o,u){var p=u.children,y=r!==null?r.memoizedState:null;if(r===null&&s.stateNode===null&&(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),u.mode==="hidden"){if((s.flags&128)!==0){if(y=y!==null?y.baseLanes|o:o,r!==null){for(u=s.child=r.child,p=0;u!==null;)p=p|u.lanes|u.childLanes,u=u.sibling;u=p&~y}else u=0,s.child=null;return v0(r,s,y,o,u)}if((o&536870912)!==0)s.memoizedState={baseLanes:0,cachePool:null},r!==null&&Ic(s,y!==null?y.cachePool:null),y!==null?bb(s,y):Lh(),xb(s);else return u=s.lanes=536870912,v0(r,s,y!==null?y.baseLanes|o:o,o,u)}else y!==null?(Ic(s,y.cachePool),bb(s,y),Da(),s.memoizedState=null):(r!==null&&Ic(s,null),Lh(),Da());return dn(r,s,p,o),s.child}function tl(r,s){return r!==null&&r.tag===22||s.stateNode!==null||(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.sibling}function v0(r,s,o,u,p){var y=Ah();return y=y===null?null:{parent:Ht._currentValue,pool:y},s.memoizedState={baseLanes:o,cachePool:y},r!==null&&Ic(s,null),Lh(),xb(s),r!==null&&_i(r,s,u,!0),s.childLanes=p,null}function eu(r,s){return s=nu({mode:s.mode,children:s.children},r.mode),s.ref=r.ref,r.child=s,s.return=r,s}function y0(r,s,o){return Ts(s,r.child,null,o),r=eu(s,s.pendingProps),r.flags|=2,Bn(s),s.memoizedState=null,r}function JR(r,s,o){var u=s.pendingProps,p=(s.flags&128)!==0;if(s.flags&=-129,r===null){if(ut){if(u.mode==="hidden")return r=eu(s,u),s.lanes=536870912,tl(null,r);if(Ih(s),(r=Tt)?(r=Ax(r,nr),r=r!==null&&r.data==="&"?r:null,r!==null&&(s.memoizedState={dehydrated:r,treeContext:Ca!==null?{id:jr,overflow:Tr}:null,retryLane:536870912,hydrationErrors:null},o=tb(r),o.return=s,s.child=o,cn=s,Tt=null)):r=null,r===null)throw Ta(s);return s.lanes=536870912,null}return eu(s,u)}var y=r.memoizedState;if(y!==null){var _=y.dehydrated;if(Ih(s),p)if(s.flags&256)s.flags&=-257,s=y0(r,s,o);else if(s.memoizedState!==null)s.child=r.child,s.flags|=128,s=null;else throw Error(a(558));else if(Vt||_i(r,s,o,!1),p=(o&r.childLanes)!==0,Vt||p){if(u=St,u!==null&&(_=En(u,o),_!==0&&_!==y.retryLane))throw y.retryLane=_,xs(r,_),kn(u,r,_),sm;du(),s=y0(r,s,o)}else r=y.treeContext,Tt=ar(_.nextSibling),cn=s,ut=!0,ja=null,nr=!1,r!==null&&ab(s,r),s=eu(s,u),s.flags|=4096;return s}return r=Wr(r.child,{mode:u.mode,children:u.children}),r.ref=s.ref,s.child=r,r.return=s,r}function tu(r,s){var o=s.ref;if(o===null)r!==null&&r.ref!==null&&(s.flags|=4194816);else{if(typeof o!="function"&&typeof o!="object")throw Error(a(284));(r===null||r.ref!==o)&&(s.flags|=4194816)}}function im(r,s,o,u,p){return Es(s),o=Uh(r,s,o,u,void 0,p),u=Bh(),r!==null&&!Vt?(Hh(r,s,p),ea(r,s,p)):(ut&&u&&wh(s),s.flags|=1,dn(r,s,o,p),s.child)}function b0(r,s,o,u,p,y){return Es(s),s.updateQueue=null,o=_b(s,u,o,p),wb(r),u=Bh(),r!==null&&!Vt?(Hh(r,s,y),ea(r,s,y)):(ut&&u&&wh(s),s.flags|=1,dn(r,s,o,y),s.child)}function x0(r,s,o,u,p){if(Es(s),s.stateNode===null){var y=yi,_=o.contextType;typeof _=="object"&&_!==null&&(y=un(_)),y=new o(u,y),s.memoizedState=y.state!==null&&y.state!==void 0?y.state:null,y.updater=rm,s.stateNode=y,y._reactInternals=s,y=s.stateNode,y.props=u,y.state=s.memoizedState,y.refs={},Oh(s),_=o.contextType,y.context=typeof _=="object"&&_!==null?un(_):yi,y.state=s.memoizedState,_=o.getDerivedStateFromProps,typeof _=="function"&&(nm(s,o,_,u),y.state=s.memoizedState),typeof o.getDerivedStateFromProps=="function"||typeof y.getSnapshotBeforeUpdate=="function"||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(_=y.state,typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount(),_!==y.state&&rm.enqueueReplaceState(y,y.state,null),Xo(s,u,y,p),Yo(),y.state=s.memoizedState),typeof y.componentDidMount=="function"&&(s.flags|=4194308),u=!0}else if(r===null){y=s.stateNode;var j=s.memoizedProps,D=As(o,j);y.props=D;var W=y.context,ae=o.contextType;_=yi,typeof ae=="object"&&ae!==null&&(_=un(ae));var le=o.getDerivedStateFromProps;ae=typeof le=="function"||typeof y.getSnapshotBeforeUpdate=="function",j=s.pendingProps!==j,ae||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(j||W!==_)&&i0(s,y,u,_),Aa=!1;var X=s.memoizedState;y.state=X,Xo(s,u,y,p),Yo(),W=s.memoizedState,j||X!==W||Aa?(typeof le=="function"&&(nm(s,o,le,u),W=s.memoizedState),(D=Aa||s0(s,o,D,u,X,W,_))?(ae||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount()),typeof y.componentDidMount=="function"&&(s.flags|=4194308)):(typeof y.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=u,s.memoizedState=W),y.props=u,y.state=W,y.context=_,u=D):(typeof y.componentDidMount=="function"&&(s.flags|=4194308),u=!1)}else{y=s.stateNode,Mh(r,s),_=s.memoizedProps,ae=As(o,_),y.props=ae,le=s.pendingProps,X=y.context,W=o.contextType,D=yi,typeof W=="object"&&W!==null&&(D=un(W)),j=o.getDerivedStateFromProps,(W=typeof j=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(_!==le||X!==D)&&i0(s,y,u,D),Aa=!1,X=s.memoizedState,y.state=X,Xo(s,u,y,p),Yo();var Z=s.memoizedState;_!==le||X!==Z||Aa||r!==null&&r.dependencies!==null&&Lc(r.dependencies)?(typeof j=="function"&&(nm(s,o,j,u),Z=s.memoizedState),(ae=Aa||s0(s,o,ae,u,X,Z,D)||r!==null&&r.dependencies!==null&&Lc(r.dependencies))?(W||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(u,Z,D),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(u,Z,D)),typeof y.componentDidUpdate=="function"&&(s.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof y.componentDidUpdate!="function"||_===r.memoizedProps&&X===r.memoizedState||(s.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||_===r.memoizedProps&&X===r.memoizedState||(s.flags|=1024),s.memoizedProps=u,s.memoizedState=Z),y.props=u,y.state=Z,y.context=D,u=ae):(typeof y.componentDidUpdate!="function"||_===r.memoizedProps&&X===r.memoizedState||(s.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||_===r.memoizedProps&&X===r.memoizedState||(s.flags|=1024),u=!1)}return y=u,tu(r,s),u=(s.flags&128)!==0,y||u?(y=s.stateNode,o=u&&typeof o.getDerivedStateFromError!="function"?null:y.render(),s.flags|=1,r!==null&&u?(s.child=Ts(s,r.child,null,p),s.child=Ts(s,null,o,p)):dn(r,s,o,p),s.memoizedState=y.state,r=s.child):r=ea(r,s,p),r}function w0(r,s,o,u){return _s(),s.flags|=256,dn(r,s,o,u),s.child}var om={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function lm(r){return{baseLanes:r,cachePool:ub()}}function cm(r,s,o){return r=r!==null?r.childLanes&~o:0,s&&(r|=qn),r}function _0(r,s,o){var u=s.pendingProps,p=!1,y=(s.flags&128)!==0,_;if((_=y)||(_=r!==null&&r.memoizedState===null?!1:(Ut.current&2)!==0),_&&(p=!0,s.flags&=-129),_=(s.flags&32)!==0,s.flags&=-33,r===null){if(ut){if(p?Ma(s):Da(),(r=Tt)?(r=Ax(r,nr),r=r!==null&&r.data!=="&"?r:null,r!==null&&(s.memoizedState={dehydrated:r,treeContext:Ca!==null?{id:jr,overflow:Tr}:null,retryLane:536870912,hydrationErrors:null},o=tb(r),o.return=s,s.child=o,cn=s,Tt=null)):r=null,r===null)throw Ta(s);return Fm(r)?s.lanes=32:s.lanes=536870912,null}var j=u.children;return u=u.fallback,p?(Da(),p=s.mode,j=nu({mode:"hidden",children:j},p),u=ws(u,p,o,null),j.return=s,u.return=s,j.sibling=u,s.child=j,u=s.child,u.memoizedState=lm(o),u.childLanes=cm(r,_,o),s.memoizedState=om,tl(null,u)):(Ma(s),um(s,j))}var D=r.memoizedState;if(D!==null&&(j=D.dehydrated,j!==null)){if(y)s.flags&256?(Ma(s),s.flags&=-257,s=dm(r,s,o)):s.memoizedState!==null?(Da(),s.child=r.child,s.flags|=128,s=null):(Da(),j=u.fallback,p=s.mode,u=nu({mode:"visible",children:u.children},p),j=ws(j,p,o,null),j.flags|=2,u.return=s,j.return=s,u.sibling=j,s.child=u,Ts(s,r.child,null,o),u=s.child,u.memoizedState=lm(o),u.childLanes=cm(r,_,o),s.memoizedState=om,s=tl(null,u));else if(Ma(s),Fm(j)){if(_=j.nextSibling&&j.nextSibling.dataset,_)var W=_.dgst;_=W,u=Error(a(419)),u.stack="",u.digest=_,qo({value:u,source:null,stack:null}),s=dm(r,s,o)}else if(Vt||_i(r,s,o,!1),_=(o&r.childLanes)!==0,Vt||_){if(_=St,_!==null&&(u=En(_,o),u!==0&&u!==D.retryLane))throw D.retryLane=u,xs(r,u),kn(_,r,u),sm;Vm(j)||du(),s=dm(r,s,o)}else Vm(j)?(s.flags|=192,s.child=r.child,s=null):(r=D.treeContext,Tt=ar(j.nextSibling),cn=s,ut=!0,ja=null,nr=!1,r!==null&&ab(s,r),s=um(s,u.children),s.flags|=4096);return s}return p?(Da(),j=u.fallback,p=s.mode,D=r.child,W=D.sibling,u=Wr(D,{mode:"hidden",children:u.children}),u.subtreeFlags=D.subtreeFlags&65011712,W!==null?j=Wr(W,j):(j=ws(j,p,o,null),j.flags|=2),j.return=s,u.return=s,u.sibling=j,s.child=u,tl(null,u),u=s.child,j=r.child.memoizedState,j===null?j=lm(o):(p=j.cachePool,p!==null?(D=Ht._currentValue,p=p.parent!==D?{parent:D,pool:D}:p):p=ub(),j={baseLanes:j.baseLanes|o,cachePool:p}),u.memoizedState=j,u.childLanes=cm(r,_,o),s.memoizedState=om,tl(r.child,u)):(Ma(s),o=r.child,r=o.sibling,o=Wr(o,{mode:"visible",children:u.children}),o.return=s,o.sibling=null,r!==null&&(_=s.deletions,_===null?(s.deletions=[r],s.flags|=16):_.push(r)),s.child=o,s.memoizedState=null,o)}function um(r,s){return s=nu({mode:"visible",children:s},r.mode),s.return=r,r.child=s}function nu(r,s){return r=$n(22,r,null,s),r.lanes=0,r}function dm(r,s,o){return Ts(s,r.child,null,o),r=um(s,s.pendingProps.children),r.flags|=2,s.memoizedState=null,r}function S0(r,s,o){r.lanes|=s;var u=r.alternate;u!==null&&(u.lanes|=s),Ch(r.return,s,o)}function fm(r,s,o,u,p,y){var _=r.memoizedState;_===null?r.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:u,tail:o,tailMode:p,treeForkCount:y}:(_.isBackwards=s,_.rendering=null,_.renderingStartTime=0,_.last=u,_.tail=o,_.tailMode=p,_.treeForkCount=y)}function E0(r,s,o){var u=s.pendingProps,p=u.revealOrder,y=u.tail;u=u.children;var _=Ut.current,j=(_&2)!==0;if(j?(_=_&1|2,s.flags|=128):_&=1,I(Ut,_),dn(r,s,u,o),u=ut?Ho:0,!j&&r!==null&&(r.flags&128)!==0)e:for(r=s.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&S0(r,o,s);else if(r.tag===19)S0(r,o,s);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===s)break e;for(;r.sibling===null;){if(r.return===null||r.return===s)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}switch(p){case"forwards":for(o=s.child,p=null;o!==null;)r=o.alternate,r!==null&&Vc(r)===null&&(p=o),o=o.sibling;o=p,o===null?(p=s.child,s.child=null):(p=o.sibling,o.sibling=null),fm(s,!1,p,o,y,u);break;case"backwards":case"unstable_legacy-backwards":for(o=null,p=s.child,s.child=null;p!==null;){if(r=p.alternate,r!==null&&Vc(r)===null){s.child=p;break}r=p.sibling,p.sibling=o,o=p,p=r}fm(s,!0,o,null,y,u);break;case"together":fm(s,!1,null,null,void 0,u);break;default:s.memoizedState=null}return s.child}function ea(r,s,o){if(r!==null&&(s.dependencies=r.dependencies),za|=s.lanes,(o&s.childLanes)===0)if(r!==null){if(_i(r,s,o,!1),(o&s.childLanes)===0)return null}else return null;if(r!==null&&s.child!==r.child)throw Error(a(153));if(s.child!==null){for(r=s.child,o=Wr(r,r.pendingProps),s.child=o,o.return=s;r.sibling!==null;)r=r.sibling,o=o.sibling=Wr(r,r.pendingProps),o.return=s;o.sibling=null}return s.child}function hm(r,s){return(r.lanes&s)!==0?!0:(r=r.dependencies,!!(r!==null&&Lc(r)))}function QR(r,s,o){switch(s.tag){case 3:Q(s,s.stateNode.containerInfo),Ra(s,Ht,r.memoizedState.cache),_s();break;case 27:case 5:je(s);break;case 4:Q(s,s.stateNode.containerInfo);break;case 10:Ra(s,s.type,s.memoizedProps.value);break;case 31:if(s.memoizedState!==null)return s.flags|=128,Ih(s),null;break;case 13:var u=s.memoizedState;if(u!==null)return u.dehydrated!==null?(Ma(s),s.flags|=128,null):(o&s.child.childLanes)!==0?_0(r,s,o):(Ma(s),r=ea(r,s,o),r!==null?r.sibling:null);Ma(s);break;case 19:var p=(r.flags&128)!==0;if(u=(o&s.childLanes)!==0,u||(_i(r,s,o,!1),u=(o&s.childLanes)!==0),p){if(u)return E0(r,s,o);s.flags|=128}if(p=s.memoizedState,p!==null&&(p.rendering=null,p.tail=null,p.lastEffect=null),I(Ut,Ut.current),u)break;return null;case 22:return s.lanes=0,g0(r,s,o,s.pendingProps);case 24:Ra(s,Ht,r.memoizedState.cache)}return ea(r,s,o)}function N0(r,s,o){if(r!==null)if(r.memoizedProps!==s.pendingProps)Vt=!0;else{if(!hm(r,o)&&(s.flags&128)===0)return Vt=!1,QR(r,s,o);Vt=(r.flags&131072)!==0}else Vt=!1,ut&&(s.flags&1048576)!==0&&rb(s,Ho,s.index);switch(s.lanes=0,s.tag){case 16:e:{var u=s.pendingProps;if(r=Cs(s.elementType),s.type=r,typeof r=="function")yh(r)?(u=As(r,u),s.tag=1,s=x0(null,s,r,u,o)):(s.tag=0,s=im(null,s,r,u,o));else{if(r!=null){var p=r.$$typeof;if(p===M){s.tag=11,s=h0(null,s,r,u,o);break e}else if(p===P){s.tag=14,s=m0(null,s,r,u,o);break e}}throw s=ge(r)||r,Error(a(306,s,""))}}return s;case 0:return im(r,s,s.type,s.pendingProps,o);case 1:return u=s.type,p=As(u,s.pendingProps),x0(r,s,u,p,o);case 3:e:{if(Q(s,s.stateNode.containerInfo),r===null)throw Error(a(387));u=s.pendingProps;var y=s.memoizedState;p=y.element,Mh(r,s),Xo(s,u,null,o);var _=s.memoizedState;if(u=_.cache,Ra(s,Ht,u),u!==y.cache&&jh(s,[Ht],o,!0),Yo(),u=_.element,y.isDehydrated)if(y={element:u,isDehydrated:!1,cache:_.cache},s.updateQueue.baseState=y,s.memoizedState=y,s.flags&256){s=w0(r,s,u,o);break e}else if(u!==p){p=Zn(Error(a(424)),s),qo(p),s=w0(r,s,u,o);break e}else{switch(r=s.stateNode.containerInfo,r.nodeType){case 9:r=r.body;break;default:r=r.nodeName==="HTML"?r.ownerDocument.body:r}for(Tt=ar(r.firstChild),cn=s,ut=!0,ja=null,nr=!0,o=gb(s,null,u,o),s.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling}else{if(_s(),u===p){s=ea(r,s,o);break e}dn(r,s,u,o)}s=s.child}return s;case 26:return tu(r,s),r===null?(o=Lx(s.type,null,s.pendingProps,null))?s.memoizedState=o:ut||(o=s.type,r=s.pendingProps,u=yu(ee.current).createElement(o),u[ln]=s,u[Nn]=r,fn(u,o,r),tn(u),s.stateNode=u):s.memoizedState=Lx(s.type,r.memoizedProps,s.pendingProps,r.memoizedState),null;case 27:return je(s),r===null&&ut&&(u=s.stateNode=Mx(s.type,s.pendingProps,ee.current),cn=s,nr=!0,p=Tt,Ha(s.type)?(Gm=p,Tt=ar(u.firstChild)):Tt=p),dn(r,s,s.pendingProps.children,o),tu(r,s),r===null&&(s.flags|=4194304),s.child;case 5:return r===null&&ut&&((p=u=Tt)&&(u=TA(u,s.type,s.pendingProps,nr),u!==null?(s.stateNode=u,cn=s,Tt=ar(u.firstChild),nr=!1,p=!0):p=!1),p||Ta(s)),je(s),p=s.type,y=s.pendingProps,_=r!==null?r.memoizedProps:null,u=y.children,Bm(p,y)?u=null:_!==null&&Bm(p,_)&&(s.flags|=32),s.memoizedState!==null&&(p=Uh(r,s,qR,null,null,o),gl._currentValue=p),tu(r,s),dn(r,s,u,o),s.child;case 6:return r===null&&ut&&((r=o=Tt)&&(o=RA(o,s.pendingProps,nr),o!==null?(s.stateNode=o,cn=s,Tt=null,r=!0):r=!1),r||Ta(s)),null;case 13:return _0(r,s,o);case 4:return Q(s,s.stateNode.containerInfo),u=s.pendingProps,r===null?s.child=Ts(s,null,u,o):dn(r,s,u,o),s.child;case 11:return h0(r,s,s.type,s.pendingProps,o);case 7:return dn(r,s,s.pendingProps,o),s.child;case 8:return dn(r,s,s.pendingProps.children,o),s.child;case 12:return dn(r,s,s.pendingProps.children,o),s.child;case 10:return u=s.pendingProps,Ra(s,s.type,u.value),dn(r,s,u.children,o),s.child;case 9:return p=s.type._context,u=s.pendingProps.children,Es(s),p=un(p),u=u(p),s.flags|=1,dn(r,s,u,o),s.child;case 14:return m0(r,s,s.type,s.pendingProps,o);case 15:return p0(r,s,s.type,s.pendingProps,o);case 19:return E0(r,s,o);case 31:return JR(r,s,o);case 22:return g0(r,s,o,s.pendingProps);case 24:return Es(s),u=un(Ht),r===null?(p=Ah(),p===null&&(p=St,y=Th(),p.pooledCache=y,y.refCount++,y!==null&&(p.pooledCacheLanes|=o),p=y),s.memoizedState={parent:u,cache:p},Oh(s),Ra(s,Ht,p)):((r.lanes&o)!==0&&(Mh(r,s),Xo(s,null,null,o),Yo()),p=r.memoizedState,y=s.memoizedState,p.parent!==u?(p={parent:u,cache:u},s.memoizedState=p,s.lanes===0&&(s.memoizedState=s.updateQueue.baseState=p),Ra(s,Ht,u)):(u=y.cache,Ra(s,Ht,u),u!==p.cache&&jh(s,[Ht],o,!0))),dn(r,s,s.pendingProps.children,o),s.child;case 29:throw s.pendingProps}throw Error(a(156,s.tag))}function ta(r){r.flags|=4}function mm(r,s,o,u,p){if((s=(r.mode&32)!==0)&&(s=!1),s){if(r.flags|=16777216,(p&335544128)===p)if(r.stateNode.complete)r.flags|=8192;else if(Q0())r.flags|=8192;else throw js=Uc,kh}else r.flags&=-16777217}function C0(r,s){if(s.type!=="stylesheet"||(s.state.loading&4)!==0)r.flags&=-16777217;else if(r.flags|=16777216,!Bx(s))if(Q0())r.flags|=8192;else throw js=Uc,kh}function ru(r,s){s!==null&&(r.flags|=4),r.flags&16384&&(s=r.tag!==22?ft():536870912,r.lanes|=s,Di|=s)}function nl(r,s){if(!ut)switch(r.tailMode){case"hidden":s=r.tail;for(var o=null;s!==null;)s.alternate!==null&&(o=s),s=s.sibling;o===null?r.tail=null:o.sibling=null;break;case"collapsed":o=r.tail;for(var u=null;o!==null;)o.alternate!==null&&(u=o),o=o.sibling;u===null?s||r.tail===null?r.tail=null:r.tail.sibling=null:u.sibling=null}}function Rt(r){var s=r.alternate!==null&&r.alternate.child===r.child,o=0,u=0;if(s)for(var p=r.child;p!==null;)o|=p.lanes|p.childLanes,u|=p.subtreeFlags&65011712,u|=p.flags&65011712,p.return=r,p=p.sibling;else for(p=r.child;p!==null;)o|=p.lanes|p.childLanes,u|=p.subtreeFlags,u|=p.flags,p.return=r,p=p.sibling;return r.subtreeFlags|=u,r.childLanes=o,s}function ZR(r,s,o){var u=s.pendingProps;switch(_h(s),s.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Rt(s),null;case 1:return Rt(s),null;case 3:return o=s.stateNode,u=null,r!==null&&(u=r.memoizedState.cache),s.memoizedState.cache!==u&&(s.flags|=2048),Jr(Ht),se(),o.pendingContext&&(o.context=o.pendingContext,o.pendingContext=null),(r===null||r.child===null)&&(wi(s)?ta(s):r===null||r.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,Eh())),Rt(s),null;case 26:var p=s.type,y=s.memoizedState;return r===null?(ta(s),y!==null?(Rt(s),C0(s,y)):(Rt(s),mm(s,p,null,u,o))):y?y!==r.memoizedState?(ta(s),Rt(s),C0(s,y)):(Rt(s),s.flags&=-16777217):(r=r.memoizedProps,r!==u&&ta(s),Rt(s),mm(s,p,r,u,o)),null;case 27:if(ze(s),o=ee.current,p=s.type,r!==null&&s.stateNode!=null)r.memoizedProps!==u&&ta(s);else{if(!u){if(s.stateNode===null)throw Error(a(166));return Rt(s),null}r=H.current,wi(s)?sb(s):(r=Mx(p,u,o),s.stateNode=r,ta(s))}return Rt(s),null;case 5:if(ze(s),p=s.type,r!==null&&s.stateNode!=null)r.memoizedProps!==u&&ta(s);else{if(!u){if(s.stateNode===null)throw Error(a(166));return Rt(s),null}if(y=H.current,wi(s))sb(s);else{var _=yu(ee.current);switch(y){case 1:y=_.createElementNS("http://www.w3.org/2000/svg",p);break;case 2:y=_.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;default:switch(p){case"svg":y=_.createElementNS("http://www.w3.org/2000/svg",p);break;case"math":y=_.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;case"script":y=_.createElement("div"),y.innerHTML="<script><\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof u.is=="string"?_.createElement("select",{is:u.is}):_.createElement("select"),u.multiple?y.multiple=!0:u.size&&(y.size=u.size);break;default:y=typeof u.is=="string"?_.createElement(p,{is:u.is}):_.createElement(p)}}y[ln]=s,y[Nn]=u;e:for(_=s.child;_!==null;){if(_.tag===5||_.tag===6)y.appendChild(_.stateNode);else if(_.tag!==4&&_.tag!==27&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===s)break e;for(;_.sibling===null;){if(_.return===null||_.return===s)break e;_=_.return}_.sibling.return=_.return,_=_.sibling}s.stateNode=y;e:switch(fn(y,p,u),p){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&ta(s)}}return Rt(s),mm(s,s.type,r===null?null:r.memoizedProps,s.pendingProps,o),null;case 6:if(r&&s.stateNode!=null)r.memoizedProps!==u&&ta(s);else{if(typeof u!="string"&&s.stateNode===null)throw Error(a(166));if(r=ee.current,wi(s)){if(r=s.stateNode,o=s.memoizedProps,u=null,p=cn,p!==null)switch(p.tag){case 27:case 5:u=p.memoizedProps}r[ln]=s,r=!!(r.nodeValue===o||u!==null&&u.suppressHydrationWarning===!0||_x(r.nodeValue,o)),r||Ta(s,!0)}else r=yu(r).createTextNode(u),r[ln]=s,s.stateNode=r}return Rt(s),null;case 31:if(o=s.memoizedState,r===null||r.memoizedState!==null){if(u=wi(s),o!==null){if(r===null){if(!u)throw Error(a(318));if(r=s.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(a(557));r[ln]=s}else _s(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Rt(s),r=!1}else o=Eh(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=o),r=!0;if(!r)return s.flags&256?(Bn(s),s):(Bn(s),null);if((s.flags&128)!==0)throw Error(a(558))}return Rt(s),null;case 13:if(u=s.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(p=wi(s),u!==null&&u.dehydrated!==null){if(r===null){if(!p)throw Error(a(318));if(p=s.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(a(317));p[ln]=s}else _s(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Rt(s),p=!1}else p=Eh(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=p),p=!0;if(!p)return s.flags&256?(Bn(s),s):(Bn(s),null)}return Bn(s),(s.flags&128)!==0?(s.lanes=o,s):(o=u!==null,r=r!==null&&r.memoizedState!==null,o&&(u=s.child,p=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(p=u.alternate.memoizedState.cachePool.pool),y=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(y=u.memoizedState.cachePool.pool),y!==p&&(u.flags|=2048)),o!==r&&o&&(s.child.flags|=8192),ru(s,s.updateQueue),Rt(s),null);case 4:return se(),r===null&&Lm(s.stateNode.containerInfo),Rt(s),null;case 10:return Jr(s.type),Rt(s),null;case 19:if(O(Ut),u=s.memoizedState,u===null)return Rt(s),null;if(p=(s.flags&128)!==0,y=u.rendering,y===null)if(p)nl(u,!1);else{if(zt!==0||r!==null&&(r.flags&128)!==0)for(r=s.child;r!==null;){if(y=Vc(r),y!==null){for(s.flags|=128,nl(u,!1),r=y.updateQueue,s.updateQueue=r,ru(s,r),s.subtreeFlags=0,r=o,o=s.child;o!==null;)eb(o,r),o=o.sibling;return I(Ut,Ut.current&1|2),ut&&Yr(s,u.treeForkCount),s.child}r=r.sibling}u.tail!==null&&Le()>lu&&(s.flags|=128,p=!0,nl(u,!1),s.lanes=4194304)}else{if(!p)if(r=Vc(y),r!==null){if(s.flags|=128,p=!0,r=r.updateQueue,s.updateQueue=r,ru(s,r),nl(u,!0),u.tail===null&&u.tailMode==="hidden"&&!y.alternate&&!ut)return Rt(s),null}else 2*Le()-u.renderingStartTime>lu&&o!==536870912&&(s.flags|=128,p=!0,nl(u,!1),s.lanes=4194304);u.isBackwards?(y.sibling=s.child,s.child=y):(r=u.last,r!==null?r.sibling=y:s.child=y,u.last=y)}return u.tail!==null?(r=u.tail,u.rendering=r,u.tail=r.sibling,u.renderingStartTime=Le(),r.sibling=null,o=Ut.current,I(Ut,p?o&1|2:o&1),ut&&Yr(s,u.treeForkCount),r):(Rt(s),null);case 22:case 23:return Bn(s),zh(),u=s.memoizedState!==null,r!==null?r.memoizedState!==null!==u&&(s.flags|=8192):u&&(s.flags|=8192),u?(o&536870912)!==0&&(s.flags&128)===0&&(Rt(s),s.subtreeFlags&6&&(s.flags|=8192)):Rt(s),o=s.updateQueue,o!==null&&ru(s,o.retryQueue),o=null,r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),u=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(u=s.memoizedState.cachePool.pool),u!==o&&(s.flags|=2048),r!==null&&O(Ns),null;case 24:return o=null,r!==null&&(o=r.memoizedState.cache),s.memoizedState.cache!==o&&(s.flags|=2048),Jr(Ht),Rt(s),null;case 25:return null;case 30:return null}throw Error(a(156,s.tag))}function eA(r,s){switch(_h(s),s.tag){case 1:return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 3:return Jr(Ht),se(),r=s.flags,(r&65536)!==0&&(r&128)===0?(s.flags=r&-65537|128,s):null;case 26:case 27:case 5:return ze(s),null;case 31:if(s.memoizedState!==null){if(Bn(s),s.alternate===null)throw Error(a(340));_s()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 13:if(Bn(s),r=s.memoizedState,r!==null&&r.dehydrated!==null){if(s.alternate===null)throw Error(a(340));_s()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 19:return O(Ut),null;case 4:return se(),null;case 10:return Jr(s.type),null;case 22:case 23:return Bn(s),zh(),r!==null&&O(Ns),r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 24:return Jr(Ht),null;case 25:return null;default:return null}}function j0(r,s){switch(_h(s),s.tag){case 3:Jr(Ht),se();break;case 26:case 27:case 5:ze(s);break;case 4:se();break;case 31:s.memoizedState!==null&&Bn(s);break;case 13:Bn(s);break;case 19:O(Ut);break;case 10:Jr(s.type);break;case 22:case 23:Bn(s),zh(),r!==null&&O(Ns);break;case 24:Jr(Ht)}}function rl(r,s){try{var o=s.updateQueue,u=o!==null?o.lastEffect:null;if(u!==null){var p=u.next;o=p;do{if((o.tag&r)===r){u=void 0;var y=o.create,_=o.inst;u=y(),_.destroy=u}o=o.next}while(o!==p)}}catch(j){bt(s,s.return,j)}}function Pa(r,s,o){try{var u=s.updateQueue,p=u!==null?u.lastEffect:null;if(p!==null){var y=p.next;u=y;do{if((u.tag&r)===r){var _=u.inst,j=_.destroy;if(j!==void 0){_.destroy=void 0,p=s;var D=o,W=j;try{W()}catch(ae){bt(p,D,ae)}}}u=u.next}while(u!==y)}}catch(ae){bt(s,s.return,ae)}}function T0(r){var s=r.updateQueue;if(s!==null){var o=r.stateNode;try{yb(s,o)}catch(u){bt(r,r.return,u)}}}function R0(r,s,o){o.props=As(r.type,r.memoizedProps),o.state=r.memoizedState;try{o.componentWillUnmount()}catch(u){bt(r,s,u)}}function al(r,s){try{var o=r.ref;if(o!==null){switch(r.tag){case 26:case 27:case 5:var u=r.stateNode;break;case 30:u=r.stateNode;break;default:u=r.stateNode}typeof o=="function"?r.refCleanup=o(u):o.current=u}}catch(p){bt(r,s,p)}}function Rr(r,s){var o=r.ref,u=r.refCleanup;if(o!==null)if(typeof u=="function")try{u()}catch(p){bt(r,s,p)}finally{r.refCleanup=null,r=r.alternate,r!=null&&(r.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(p){bt(r,s,p)}else o.current=null}function A0(r){var s=r.type,o=r.memoizedProps,u=r.stateNode;try{e:switch(s){case"button":case"input":case"select":case"textarea":o.autoFocus&&u.focus();break e;case"img":o.src?u.src=o.src:o.srcSet&&(u.srcset=o.srcSet)}}catch(p){bt(r,r.return,p)}}function pm(r,s,o){try{var u=r.stateNode;_A(u,r.type,o,s),u[Nn]=s}catch(p){bt(r,r.return,p)}}function k0(r){return r.tag===5||r.tag===3||r.tag===26||r.tag===27&&Ha(r.type)||r.tag===4}function gm(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||k0(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.tag===27&&Ha(r.type)||r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function vm(r,s,o){var u=r.tag;if(u===5||u===6)r=r.stateNode,s?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(r,s):(s=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,s.appendChild(r),o=o._reactRootContainer,o!=null||s.onclick!==null||(s.onclick=Gr));else if(u!==4&&(u===27&&Ha(r.type)&&(o=r.stateNode,s=null),r=r.child,r!==null))for(vm(r,s,o),r=r.sibling;r!==null;)vm(r,s,o),r=r.sibling}function au(r,s,o){var u=r.tag;if(u===5||u===6)r=r.stateNode,s?o.insertBefore(r,s):o.appendChild(r);else if(u!==4&&(u===27&&Ha(r.type)&&(o=r.stateNode),r=r.child,r!==null))for(au(r,s,o),r=r.sibling;r!==null;)au(r,s,o),r=r.sibling}function O0(r){var s=r.stateNode,o=r.memoizedProps;try{for(var u=r.type,p=s.attributes;p.length;)s.removeAttributeNode(p[0]);fn(s,u,o),s[ln]=r,s[Nn]=o}catch(y){bt(r,r.return,y)}}var na=!1,Ft=!1,ym=!1,M0=typeof WeakSet=="function"?WeakSet:Set,nn=null;function tA(r,s){if(r=r.containerInfo,$m=Nu,r=Fy(r),dh(r)){if("selectionStart"in r)var o={start:r.selectionStart,end:r.selectionEnd};else e:{o=(o=r.ownerDocument)&&o.defaultView||window;var u=o.getSelection&&o.getSelection();if(u&&u.rangeCount!==0){o=u.anchorNode;var p=u.anchorOffset,y=u.focusNode;u=u.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var _=0,j=-1,D=-1,W=0,ae=0,le=r,X=null;t:for(;;){for(var Z;le!==o||p!==0&&le.nodeType!==3||(j=_+p),le!==y||u!==0&&le.nodeType!==3||(D=_+u),le.nodeType===3&&(_+=le.nodeValue.length),(Z=le.firstChild)!==null;)X=le,le=Z;for(;;){if(le===r)break t;if(X===o&&++W===p&&(j=_),X===y&&++ae===u&&(D=_),(Z=le.nextSibling)!==null)break;le=X,X=le.parentNode}le=Z}o=j===-1||D===-1?null:{start:j,end:D}}else o=null}o=o||{start:0,end:0}}else o=null;for(Um={focusedElem:r,selectionRange:o},Nu=!1,nn=s;nn!==null;)if(s=nn,r=s.child,(s.subtreeFlags&1028)!==0&&r!==null)r.return=s,nn=r;else for(;nn!==null;){switch(s=nn,y=s.alternate,r=s.flags,s.tag){case 0:if((r&4)!==0&&(r=s.updateQueue,r=r!==null?r.events:null,r!==null))for(o=0;o<r.length;o++)p=r[o],p.ref.impl=p.nextImpl;break;case 11:case 15:break;case 1:if((r&1024)!==0&&y!==null){r=void 0,o=s,p=y.memoizedProps,y=y.memoizedState,u=o.stateNode;try{var Re=As(o.type,p);r=u.getSnapshotBeforeUpdate(Re,y),u.__reactInternalSnapshotBeforeUpdate=r}catch(Ve){bt(o,o.return,Ve)}}break;case 3:if((r&1024)!==0){if(r=s.stateNode.containerInfo,o=r.nodeType,o===9)qm(r);else if(o===1)switch(r.nodeName){case"HEAD":case"HTML":case"BODY":qm(r);break;default:r.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((r&1024)!==0)throw Error(a(163))}if(r=s.sibling,r!==null){r.return=s.return,nn=r;break}nn=s.return}}function D0(r,s,o){var u=o.flags;switch(o.tag){case 0:case 11:case 15:aa(r,o),u&4&&rl(5,o);break;case 1:if(aa(r,o),u&4)if(r=o.stateNode,s===null)try{r.componentDidMount()}catch(_){bt(o,o.return,_)}else{var p=As(o.type,s.memoizedProps);s=s.memoizedState;try{r.componentDidUpdate(p,s,r.__reactInternalSnapshotBeforeUpdate)}catch(_){bt(o,o.return,_)}}u&64&&T0(o),u&512&&al(o,o.return);break;case 3:if(aa(r,o),u&64&&(r=o.updateQueue,r!==null)){if(s=null,o.child!==null)switch(o.child.tag){case 27:case 5:s=o.child.stateNode;break;case 1:s=o.child.stateNode}try{yb(r,s)}catch(_){bt(o,o.return,_)}}break;case 27:s===null&&u&4&&O0(o);case 26:case 5:aa(r,o),s===null&&u&4&&A0(o),u&512&&al(o,o.return);break;case 12:aa(r,o);break;case 31:aa(r,o),u&4&&z0(r,o);break;case 13:aa(r,o),u&4&&I0(r,o),u&64&&(r=o.memoizedState,r!==null&&(r=r.dehydrated,r!==null&&(o=uA.bind(null,o),AA(r,o))));break;case 22:if(u=o.memoizedState!==null||na,!u){s=s!==null&&s.memoizedState!==null||Ft,p=na;var y=Ft;na=u,(Ft=s)&&!y?sa(r,o,(o.subtreeFlags&8772)!==0):aa(r,o),na=p,Ft=y}break;case 30:break;default:aa(r,o)}}function P0(r){var s=r.alternate;s!==null&&(r.alternate=null,P0(s)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(s=r.stateNode,s!==null&&Wf(s)),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}var Ot=null,jn=!1;function ra(r,s,o){for(o=o.child;o!==null;)L0(r,s,o),o=o.sibling}function L0(r,s,o){if(Mt&&typeof Mt.onCommitFiberUnmount=="function")try{Mt.onCommitFiberUnmount(vn,o)}catch{}switch(o.tag){case 26:Ft||Rr(o,s),ra(r,s,o),o.memoizedState?o.memoizedState.count--:o.stateNode&&(o=o.stateNode,o.parentNode.removeChild(o));break;case 27:Ft||Rr(o,s);var u=Ot,p=jn;Ha(o.type)&&(Ot=o.stateNode,jn=!1),ra(r,s,o),hl(o.stateNode),Ot=u,jn=p;break;case 5:Ft||Rr(o,s);case 6:if(u=Ot,p=jn,Ot=null,ra(r,s,o),Ot=u,jn=p,Ot!==null)if(jn)try{(Ot.nodeType===9?Ot.body:Ot.nodeName==="HTML"?Ot.ownerDocument.body:Ot).removeChild(o.stateNode)}catch(y){bt(o,s,y)}else try{Ot.removeChild(o.stateNode)}catch(y){bt(o,s,y)}break;case 18:Ot!==null&&(jn?(r=Ot,Tx(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,o.stateNode),Hi(r)):Tx(Ot,o.stateNode));break;case 4:u=Ot,p=jn,Ot=o.stateNode.containerInfo,jn=!0,ra(r,s,o),Ot=u,jn=p;break;case 0:case 11:case 14:case 15:Pa(2,o,s),Ft||Pa(4,o,s),ra(r,s,o);break;case 1:Ft||(Rr(o,s),u=o.stateNode,typeof u.componentWillUnmount=="function"&&R0(o,s,u)),ra(r,s,o);break;case 21:ra(r,s,o);break;case 22:Ft=(u=Ft)||o.memoizedState!==null,ra(r,s,o),Ft=u;break;default:ra(r,s,o)}}function z0(r,s){if(s.memoizedState===null&&(r=s.alternate,r!==null&&(r=r.memoizedState,r!==null))){r=r.dehydrated;try{Hi(r)}catch(o){bt(s,s.return,o)}}}function I0(r,s){if(s.memoizedState===null&&(r=s.alternate,r!==null&&(r=r.memoizedState,r!==null&&(r=r.dehydrated,r!==null))))try{Hi(r)}catch(o){bt(s,s.return,o)}}function nA(r){switch(r.tag){case 31:case 13:case 19:var s=r.stateNode;return s===null&&(s=r.stateNode=new M0),s;case 22:return r=r.stateNode,s=r._retryCache,s===null&&(s=r._retryCache=new M0),s;default:throw Error(a(435,r.tag))}}function su(r,s){var o=nA(r);s.forEach(function(u){if(!o.has(u)){o.add(u);var p=dA.bind(null,r,u);u.then(p,p)}})}function Tn(r,s){var o=s.deletions;if(o!==null)for(var u=0;u<o.length;u++){var p=o[u],y=r,_=s,j=_;e:for(;j!==null;){switch(j.tag){case 27:if(Ha(j.type)){Ot=j.stateNode,jn=!1;break e}break;case 5:Ot=j.stateNode,jn=!1;break e;case 3:case 4:Ot=j.stateNode.containerInfo,jn=!0;break e}j=j.return}if(Ot===null)throw Error(a(160));L0(y,_,p),Ot=null,jn=!1,y=p.alternate,y!==null&&(y.return=null),p.return=null}if(s.subtreeFlags&13886)for(s=s.child;s!==null;)$0(s,r),s=s.sibling}var pr=null;function $0(r,s){var o=r.alternate,u=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:Tn(s,r),Rn(r),u&4&&(Pa(3,r,r.return),rl(3,r),Pa(5,r,r.return));break;case 1:Tn(s,r),Rn(r),u&512&&(Ft||o===null||Rr(o,o.return)),u&64&&na&&(r=r.updateQueue,r!==null&&(u=r.callbacks,u!==null&&(o=r.shared.hiddenCallbacks,r.shared.hiddenCallbacks=o===null?u:o.concat(u))));break;case 26:var p=pr;if(Tn(s,r),Rn(r),u&512&&(Ft||o===null||Rr(o,o.return)),u&4){var y=o!==null?o.memoizedState:null;if(u=r.memoizedState,o===null)if(u===null)if(r.stateNode===null){e:{u=r.type,o=r.memoizedProps,p=p.ownerDocument||p;t:switch(u){case"title":y=p.getElementsByTagName("title")[0],(!y||y[ko]||y[ln]||y.namespaceURI==="http://www.w3.org/2000/svg"||y.hasAttribute("itemprop"))&&(y=p.createElement(u),p.head.insertBefore(y,p.querySelector("head > title"))),fn(y,u,o),y[ln]=r,tn(y),u=y;break e;case"link":var _=$x("link","href",p).get(u+(o.href||""));if(_){for(var j=0;j<_.length;j++)if(y=_[j],y.getAttribute("href")===(o.href==null||o.href===""?null:o.href)&&y.getAttribute("rel")===(o.rel==null?null:o.rel)&&y.getAttribute("title")===(o.title==null?null:o.title)&&y.getAttribute("crossorigin")===(o.crossOrigin==null?null:o.crossOrigin)){_.splice(j,1);break t}}y=p.createElement(u),fn(y,u,o),p.head.appendChild(y);break;case"meta":if(_=$x("meta","content",p).get(u+(o.content||""))){for(j=0;j<_.length;j++)if(y=_[j],y.getAttribute("content")===(o.content==null?null:""+o.content)&&y.getAttribute("name")===(o.name==null?null:o.name)&&y.getAttribute("property")===(o.property==null?null:o.property)&&y.getAttribute("http-equiv")===(o.httpEquiv==null?null:o.httpEquiv)&&y.getAttribute("charset")===(o.charSet==null?null:o.charSet)){_.splice(j,1);break t}}y=p.createElement(u),fn(y,u,o),p.head.appendChild(y);break;default:throw Error(a(468,u))}y[ln]=r,tn(y),u=y}r.stateNode=u}else Ux(p,r.type,r.stateNode);else r.stateNode=Ix(p,u,r.memoizedProps);else y!==u?(y===null?o.stateNode!==null&&(o=o.stateNode,o.parentNode.removeChild(o)):y.count--,u===null?Ux(p,r.type,r.stateNode):Ix(p,u,r.memoizedProps)):u===null&&r.stateNode!==null&&pm(r,r.memoizedProps,o.memoizedProps)}break;case 27:Tn(s,r),Rn(r),u&512&&(Ft||o===null||Rr(o,o.return)),o!==null&&u&4&&pm(r,r.memoizedProps,o.memoizedProps);break;case 5:if(Tn(s,r),Rn(r),u&512&&(Ft||o===null||Rr(o,o.return)),r.flags&32){p=r.stateNode;try{di(p,"")}catch(Re){bt(r,r.return,Re)}}u&4&&r.stateNode!=null&&(p=r.memoizedProps,pm(r,p,o!==null?o.memoizedProps:p)),u&1024&&(ym=!0);break;case 6:if(Tn(s,r),Rn(r),u&4){if(r.stateNode===null)throw Error(a(162));u=r.memoizedProps,o=r.stateNode;try{o.nodeValue=u}catch(Re){bt(r,r.return,Re)}}break;case 3:if(wu=null,p=pr,pr=bu(s.containerInfo),Tn(s,r),pr=p,Rn(r),u&4&&o!==null&&o.memoizedState.isDehydrated)try{Hi(s.containerInfo)}catch(Re){bt(r,r.return,Re)}ym&&(ym=!1,U0(r));break;case 4:u=pr,pr=bu(r.stateNode.containerInfo),Tn(s,r),Rn(r),pr=u;break;case 12:Tn(s,r),Rn(r);break;case 31:Tn(s,r),Rn(r),u&4&&(u=r.updateQueue,u!==null&&(r.updateQueue=null,su(r,u)));break;case 13:Tn(s,r),Rn(r),r.child.flags&8192&&r.memoizedState!==null!=(o!==null&&o.memoizedState!==null)&&(ou=Le()),u&4&&(u=r.updateQueue,u!==null&&(r.updateQueue=null,su(r,u)));break;case 22:p=r.memoizedState!==null;var D=o!==null&&o.memoizedState!==null,W=na,ae=Ft;if(na=W||p,Ft=ae||D,Tn(s,r),Ft=ae,na=W,Rn(r),u&8192)e:for(s=r.stateNode,s._visibility=p?s._visibility&-2:s._visibility|1,p&&(o===null||D||na||Ft||ks(r)),o=null,s=r;;){if(s.tag===5||s.tag===26){if(o===null){D=o=s;try{if(y=D.stateNode,p)_=y.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none";else{j=D.stateNode;var le=D.memoizedProps.style,X=le!=null&&le.hasOwnProperty("display")?le.display:null;j.style.display=X==null||typeof X=="boolean"?"":(""+X).trim()}}catch(Re){bt(D,D.return,Re)}}}else if(s.tag===6){if(o===null){D=s;try{D.stateNode.nodeValue=p?"":D.memoizedProps}catch(Re){bt(D,D.return,Re)}}}else if(s.tag===18){if(o===null){D=s;try{var Z=D.stateNode;p?Rx(Z,!0):Rx(D.stateNode,!1)}catch(Re){bt(D,D.return,Re)}}}else if((s.tag!==22&&s.tag!==23||s.memoizedState===null||s===r)&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===r)break e;for(;s.sibling===null;){if(s.return===null||s.return===r)break e;o===s&&(o=null),s=s.return}o===s&&(o=null),s.sibling.return=s.return,s=s.sibling}u&4&&(u=r.updateQueue,u!==null&&(o=u.retryQueue,o!==null&&(u.retryQueue=null,su(r,o))));break;case 19:Tn(s,r),Rn(r),u&4&&(u=r.updateQueue,u!==null&&(r.updateQueue=null,su(r,u)));break;case 30:break;case 21:break;default:Tn(s,r),Rn(r)}}function Rn(r){var s=r.flags;if(s&2){try{for(var o,u=r.return;u!==null;){if(k0(u)){o=u;break}u=u.return}if(o==null)throw Error(a(160));switch(o.tag){case 27:var p=o.stateNode,y=gm(r);au(r,y,p);break;case 5:var _=o.stateNode;o.flags&32&&(di(_,""),o.flags&=-33);var j=gm(r);au(r,j,_);break;case 3:case 4:var D=o.stateNode.containerInfo,W=gm(r);vm(r,W,D);break;default:throw Error(a(161))}}catch(ae){bt(r,r.return,ae)}r.flags&=-3}s&4096&&(r.flags&=-4097)}function U0(r){if(r.subtreeFlags&1024)for(r=r.child;r!==null;){var s=r;U0(s),s.tag===5&&s.flags&1024&&s.stateNode.reset(),r=r.sibling}}function aa(r,s){if(s.subtreeFlags&8772)for(s=s.child;s!==null;)D0(r,s.alternate,s),s=s.sibling}function ks(r){for(r=r.child;r!==null;){var s=r;switch(s.tag){case 0:case 11:case 14:case 15:Pa(4,s,s.return),ks(s);break;case 1:Rr(s,s.return);var o=s.stateNode;typeof o.componentWillUnmount=="function"&&R0(s,s.return,o),ks(s);break;case 27:hl(s.stateNode);case 26:case 5:Rr(s,s.return),ks(s);break;case 22:s.memoizedState===null&&ks(s);break;case 30:ks(s);break;default:ks(s)}r=r.sibling}}function sa(r,s,o){for(o=o&&(s.subtreeFlags&8772)!==0,s=s.child;s!==null;){var u=s.alternate,p=r,y=s,_=y.flags;switch(y.tag){case 0:case 11:case 15:sa(p,y,o),rl(4,y);break;case 1:if(sa(p,y,o),u=y,p=u.stateNode,typeof p.componentDidMount=="function")try{p.componentDidMount()}catch(W){bt(u,u.return,W)}if(u=y,p=u.updateQueue,p!==null){var j=u.stateNode;try{var D=p.shared.hiddenCallbacks;if(D!==null)for(p.shared.hiddenCallbacks=null,p=0;p<D.length;p++)vb(D[p],j)}catch(W){bt(u,u.return,W)}}o&&_&64&&T0(y),al(y,y.return);break;case 27:O0(y);case 26:case 5:sa(p,y,o),o&&u===null&&_&4&&A0(y),al(y,y.return);break;case 12:sa(p,y,o);break;case 31:sa(p,y,o),o&&_&4&&z0(p,y);break;case 13:sa(p,y,o),o&&_&4&&I0(p,y);break;case 22:y.memoizedState===null&&sa(p,y,o),al(y,y.return);break;case 30:break;default:sa(p,y,o)}s=s.sibling}}function bm(r,s){var o=null;r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),r=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(r=s.memoizedState.cachePool.pool),r!==o&&(r!=null&&r.refCount++,o!=null&&Vo(o))}function xm(r,s){r=null,s.alternate!==null&&(r=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==r&&(s.refCount++,r!=null&&Vo(r))}function gr(r,s,o,u){if(s.subtreeFlags&10256)for(s=s.child;s!==null;)B0(r,s,o,u),s=s.sibling}function B0(r,s,o,u){var p=s.flags;switch(s.tag){case 0:case 11:case 15:gr(r,s,o,u),p&2048&&rl(9,s);break;case 1:gr(r,s,o,u);break;case 3:gr(r,s,o,u),p&2048&&(r=null,s.alternate!==null&&(r=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==r&&(s.refCount++,r!=null&&Vo(r)));break;case 12:if(p&2048){gr(r,s,o,u),r=s.stateNode;try{var y=s.memoizedProps,_=y.id,j=y.onPostCommit;typeof j=="function"&&j(_,s.alternate===null?"mount":"update",r.passiveEffectDuration,-0)}catch(D){bt(s,s.return,D)}}else gr(r,s,o,u);break;case 31:gr(r,s,o,u);break;case 13:gr(r,s,o,u);break;case 23:break;case 22:y=s.stateNode,_=s.alternate,s.memoizedState!==null?y._visibility&2?gr(r,s,o,u):sl(r,s):y._visibility&2?gr(r,s,o,u):(y._visibility|=2,ki(r,s,o,u,(s.subtreeFlags&10256)!==0||!1)),p&2048&&bm(_,s);break;case 24:gr(r,s,o,u),p&2048&&xm(s.alternate,s);break;default:gr(r,s,o,u)}}function ki(r,s,o,u,p){for(p=p&&((s.subtreeFlags&10256)!==0||!1),s=s.child;s!==null;){var y=r,_=s,j=o,D=u,W=_.flags;switch(_.tag){case 0:case 11:case 15:ki(y,_,j,D,p),rl(8,_);break;case 23:break;case 22:var ae=_.stateNode;_.memoizedState!==null?ae._visibility&2?ki(y,_,j,D,p):sl(y,_):(ae._visibility|=2,ki(y,_,j,D,p)),p&&W&2048&&bm(_.alternate,_);break;case 24:ki(y,_,j,D,p),p&&W&2048&&xm(_.alternate,_);break;default:ki(y,_,j,D,p)}s=s.sibling}}function sl(r,s){if(s.subtreeFlags&10256)for(s=s.child;s!==null;){var o=r,u=s,p=u.flags;switch(u.tag){case 22:sl(o,u),p&2048&&bm(u.alternate,u);break;case 24:sl(o,u),p&2048&&xm(u.alternate,u);break;default:sl(o,u)}s=s.sibling}}var il=8192;function Oi(r,s,o){if(r.subtreeFlags&il)for(r=r.child;r!==null;)H0(r,s,o),r=r.sibling}function H0(r,s,o){switch(r.tag){case 26:Oi(r,s,o),r.flags&il&&r.memoizedState!==null&&HA(o,pr,r.memoizedState,r.memoizedProps);break;case 5:Oi(r,s,o);break;case 3:case 4:var u=pr;pr=bu(r.stateNode.containerInfo),Oi(r,s,o),pr=u;break;case 22:r.memoizedState===null&&(u=r.alternate,u!==null&&u.memoizedState!==null?(u=il,il=16777216,Oi(r,s,o),il=u):Oi(r,s,o));break;default:Oi(r,s,o)}}function q0(r){var s=r.alternate;if(s!==null&&(r=s.child,r!==null)){s.child=null;do s=r.sibling,r.sibling=null,r=s;while(r!==null)}}function ol(r){var s=r.deletions;if((r.flags&16)!==0){if(s!==null)for(var o=0;o<s.length;o++){var u=s[o];nn=u,F0(u,r)}q0(r)}if(r.subtreeFlags&10256)for(r=r.child;r!==null;)V0(r),r=r.sibling}function V0(r){switch(r.tag){case 0:case 11:case 15:ol(r),r.flags&2048&&Pa(9,r,r.return);break;case 3:ol(r);break;case 12:ol(r);break;case 22:var s=r.stateNode;r.memoizedState!==null&&s._visibility&2&&(r.return===null||r.return.tag!==13)?(s._visibility&=-3,iu(r)):ol(r);break;default:ol(r)}}function iu(r){var s=r.deletions;if((r.flags&16)!==0){if(s!==null)for(var o=0;o<s.length;o++){var u=s[o];nn=u,F0(u,r)}q0(r)}for(r=r.child;r!==null;){switch(s=r,s.tag){case 0:case 11:case 15:Pa(8,s,s.return),iu(s);break;case 22:o=s.stateNode,o._visibility&2&&(o._visibility&=-3,iu(s));break;default:iu(s)}r=r.sibling}}function F0(r,s){for(;nn!==null;){var o=nn;switch(o.tag){case 0:case 11:case 15:Pa(8,o,s);break;case 23:case 22:if(o.memoizedState!==null&&o.memoizedState.cachePool!==null){var u=o.memoizedState.cachePool.pool;u!=null&&u.refCount++}break;case 24:Vo(o.memoizedState.cache)}if(u=o.child,u!==null)u.return=o,nn=u;else e:for(o=r;nn!==null;){u=nn;var p=u.sibling,y=u.return;if(P0(u),u===o){nn=null;break e}if(p!==null){p.return=y,nn=p;break e}nn=y}}}var rA={getCacheForType:function(r){var s=un(Ht),o=s.data.get(r);return o===void 0&&(o=r(),s.data.set(r,o)),o},cacheSignal:function(){return un(Ht).controller.signal}},aA=typeof WeakMap=="function"?WeakMap:Map,vt=0,St=null,st=null,lt=0,yt=0,Hn=null,La=!1,Mi=!1,wm=!1,ia=0,zt=0,za=0,Os=0,_m=0,qn=0,Di=0,ll=null,An=null,Sm=!1,ou=0,G0=0,lu=1/0,cu=null,Ia=null,Qt=0,$a=null,Pi=null,oa=0,Em=0,Nm=null,K0=null,cl=0,Cm=null;function Vn(){return(vt&2)!==0&&lt!==0?lt&-lt:k.T!==null?Om():Gf()}function W0(){if(qn===0)if((lt&536870912)===0||ut){var r=Be;Be<<=1,(Be&3932160)===0&&(Be=262144),qn=r}else qn=536870912;return r=Un.current,r!==null&&(r.flags|=32),qn}function kn(r,s,o){(r===St&&(yt===2||yt===9)||r.cancelPendingCommit!==null)&&(Li(r,0),Ua(r,lt,qn,!1)),ht(r,o),((vt&2)===0||r!==St)&&(r===St&&((vt&2)===0&&(Os|=o),zt===4&&Ua(r,lt,qn,!1)),Ar(r))}function Y0(r,s,o){if((vt&6)!==0)throw Error(a(327));var u=!o&&(s&127)===0&&(s&r.expiredLanes)===0||Et(r,s),p=u?oA(r,s):Tm(r,s,!0),y=u;do{if(p===0){Mi&&!u&&Ua(r,s,0,!1);break}else{if(o=r.current.alternate,y&&!sA(o)){p=Tm(r,s,!1),y=!1;continue}if(p===2){if(y=s,r.errorRecoveryDisabledLanes&y)var _=0;else _=r.pendingLanes&-536870913,_=_!==0?_:_&536870912?536870912:0;if(_!==0){s=_;e:{var j=r;p=ll;var D=j.current.memoizedState.isDehydrated;if(D&&(Li(j,_).flags|=256),_=Tm(j,_,!1),_!==2){if(wm&&!D){j.errorRecoveryDisabledLanes|=y,Os|=y,p=4;break e}y=An,An=p,y!==null&&(An===null?An=y:An.push.apply(An,y))}p=_}if(y=!1,p!==2)continue}}if(p===1){Li(r,0),Ua(r,s,0,!0);break}e:{switch(u=r,y=p,y){case 0:case 1:throw Error(a(345));case 4:if((s&4194048)!==s)break;case 6:Ua(u,s,qn,!La);break e;case 2:An=null;break;case 3:case 5:break;default:throw Error(a(329))}if((s&62914560)===s&&(p=ou+300-Le(),10<p)){if(Ua(u,s,qn,!La),He(u,0,!0)!==0)break e;oa=s,u.timeoutHandle=Cx(X0.bind(null,u,o,An,cu,Sm,s,qn,Os,Di,La,y,"Throttled",-0,0),p);break e}X0(u,o,An,cu,Sm,s,qn,Os,Di,La,y,null,-0,0)}}break}while(!0);Ar(r)}function X0(r,s,o,u,p,y,_,j,D,W,ae,le,X,Z){if(r.timeoutHandle=-1,le=s.subtreeFlags,le&8192||(le&16785408)===16785408){le={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Gr},H0(s,y,le);var Re=(y&62914560)===y?ou-Le():(y&4194048)===y?G0-Le():0;if(Re=qA(le,Re),Re!==null){oa=y,r.cancelPendingCommit=Re(ax.bind(null,r,s,y,o,u,p,_,j,D,ae,le,null,X,Z)),Ua(r,y,_,!W);return}}ax(r,s,y,o,u,p,_,j,D)}function sA(r){for(var s=r;;){var o=s.tag;if((o===0||o===11||o===15)&&s.flags&16384&&(o=s.updateQueue,o!==null&&(o=o.stores,o!==null)))for(var u=0;u<o.length;u++){var p=o[u],y=p.getSnapshot;p=p.value;try{if(!In(y(),p))return!1}catch{return!1}}if(o=s.child,s.subtreeFlags&16384&&o!==null)o.return=s,s=o;else{if(s===r)break;for(;s.sibling===null;){if(s.return===null||s.return===r)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function Ua(r,s,o,u){s&=~_m,s&=~Os,r.suspendedLanes|=s,r.pingedLanes&=~s,u&&(r.warmLanes|=s),u=r.expirationTimes;for(var p=s;0<p;){var y=31-Dt(p),_=1<<y;u[y]=-1,p&=~_}o!==0&&ps(r,o,s)}function uu(){return(vt&6)===0?(ul(0),!1):!0}function jm(){if(st!==null){if(yt===0)var r=st.return;else r=st,Xr=Ss=null,qh(r),Ci=null,Go=0,r=st;for(;r!==null;)j0(r.alternate,r),r=r.return;st=null}}function Li(r,s){var o=r.timeoutHandle;o!==-1&&(r.timeoutHandle=-1,NA(o)),o=r.cancelPendingCommit,o!==null&&(r.cancelPendingCommit=null,o()),oa=0,jm(),St=r,st=o=Wr(r.current,null),lt=s,yt=0,Hn=null,La=!1,Mi=Et(r,s),wm=!1,Di=qn=_m=Os=za=zt=0,An=ll=null,Sm=!1,(s&8)!==0&&(s|=s&32);var u=r.entangledLanes;if(u!==0)for(r=r.entanglements,u&=s;0<u;){var p=31-Dt(u),y=1<<p;s|=r[p],u&=~y}return ia=s,kc(),o}function J0(r,s){Qe=null,k.H=el,s===Ni||s===$c?(s=hb(),yt=3):s===kh?(s=hb(),yt=4):yt=s===sm?8:s!==null&&typeof s=="object"&&typeof s.then=="function"?6:1,Hn=s,st===null&&(zt=1,Zc(r,Zn(s,r.current)))}function Q0(){var r=Un.current;return r===null?!0:(lt&4194048)===lt?rr===null:(lt&62914560)===lt||(lt&536870912)!==0?r===rr:!1}function Z0(){var r=k.H;return k.H=el,r===null?el:r}function ex(){var r=k.A;return k.A=rA,r}function du(){zt=4,La||(lt&4194048)!==lt&&Un.current!==null||(Mi=!0),(za&134217727)===0&&(Os&134217727)===0||St===null||Ua(St,lt,qn,!1)}function Tm(r,s,o){var u=vt;vt|=2;var p=Z0(),y=ex();(St!==r||lt!==s)&&(cu=null,Li(r,s)),s=!1;var _=zt;e:do try{if(yt!==0&&st!==null){var j=st,D=Hn;switch(yt){case 8:jm(),_=6;break e;case 3:case 2:case 9:case 6:Un.current===null&&(s=!0);var W=yt;if(yt=0,Hn=null,zi(r,j,D,W),o&&Mi){_=0;break e}break;default:W=yt,yt=0,Hn=null,zi(r,j,D,W)}}iA(),_=zt;break}catch(ae){J0(r,ae)}while(!0);return s&&r.shellSuspendCounter++,Xr=Ss=null,vt=u,k.H=p,k.A=y,st===null&&(St=null,lt=0,kc()),_}function iA(){for(;st!==null;)tx(st)}function oA(r,s){var o=vt;vt|=2;var u=Z0(),p=ex();St!==r||lt!==s?(cu=null,lu=Le()+500,Li(r,s)):Mi=Et(r,s);e:do try{if(yt!==0&&st!==null){s=st;var y=Hn;t:switch(yt){case 1:yt=0,Hn=null,zi(r,s,y,1);break;case 2:case 9:if(db(y)){yt=0,Hn=null,nx(s);break}s=function(){yt!==2&&yt!==9||St!==r||(yt=7),Ar(r)},y.then(s,s);break e;case 3:yt=7;break e;case 4:yt=5;break e;case 7:db(y)?(yt=0,Hn=null,nx(s)):(yt=0,Hn=null,zi(r,s,y,7));break;case 5:var _=null;switch(st.tag){case 26:_=st.memoizedState;case 5:case 27:var j=st;if(_?Bx(_):j.stateNode.complete){yt=0,Hn=null;var D=j.sibling;if(D!==null)st=D;else{var W=j.return;W!==null?(st=W,fu(W)):st=null}break t}}yt=0,Hn=null,zi(r,s,y,5);break;case 6:yt=0,Hn=null,zi(r,s,y,6);break;case 8:jm(),zt=6;break e;default:throw Error(a(462))}}lA();break}catch(ae){J0(r,ae)}while(!0);return Xr=Ss=null,k.H=u,k.A=p,vt=o,st!==null?0:(St=null,lt=0,kc(),zt)}function lA(){for(;st!==null&&!$e();)tx(st)}function tx(r){var s=N0(r.alternate,r,ia);r.memoizedProps=r.pendingProps,s===null?fu(r):st=s}function nx(r){var s=r,o=s.alternate;switch(s.tag){case 15:case 0:s=b0(o,s,s.pendingProps,s.type,void 0,lt);break;case 11:s=b0(o,s,s.pendingProps,s.type.render,s.ref,lt);break;case 5:qh(s);default:j0(o,s),s=st=eb(s,ia),s=N0(o,s,ia)}r.memoizedProps=r.pendingProps,s===null?fu(r):st=s}function zi(r,s,o,u){Xr=Ss=null,qh(s),Ci=null,Go=0;var p=s.return;try{if(XR(r,p,s,o,lt)){zt=1,Zc(r,Zn(o,r.current)),st=null;return}}catch(y){if(p!==null)throw st=p,y;zt=1,Zc(r,Zn(o,r.current)),st=null;return}s.flags&32768?(ut||u===1?r=!0:Mi||(lt&536870912)!==0?r=!1:(La=r=!0,(u===2||u===9||u===3||u===6)&&(u=Un.current,u!==null&&u.tag===13&&(u.flags|=16384))),rx(s,r)):fu(s)}function fu(r){var s=r;do{if((s.flags&32768)!==0){rx(s,La);return}r=s.return;var o=ZR(s.alternate,s,ia);if(o!==null){st=o;return}if(s=s.sibling,s!==null){st=s;return}st=s=r}while(s!==null);zt===0&&(zt=5)}function rx(r,s){do{var o=eA(r.alternate,r);if(o!==null){o.flags&=32767,st=o;return}if(o=r.return,o!==null&&(o.flags|=32768,o.subtreeFlags=0,o.deletions=null),!s&&(r=r.sibling,r!==null)){st=r;return}st=r=o}while(r!==null);zt=6,st=null}function ax(r,s,o,u,p,y,_,j,D){r.cancelPendingCommit=null;do hu();while(Qt!==0);if((vt&6)!==0)throw Error(a(327));if(s!==null){if(s===r.current)throw Error(a(177));if(y=s.lanes|s.childLanes,y|=gh,$t(r,o,y,_,j,D),r===St&&(st=St=null,lt=0),Pi=s,$a=r,oa=o,Em=y,Nm=p,K0=u,(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?(r.callbackNode=null,r.callbackPriority=0,fA(Xt,function(){return cx(),null})):(r.callbackNode=null,r.callbackPriority=0),u=(s.flags&13878)!==0,(s.subtreeFlags&13878)!==0||u){u=k.T,k.T=null,p=K.p,K.p=2,_=vt,vt|=4;try{tA(r,s,o)}finally{vt=_,K.p=p,k.T=u}}Qt=1,sx(),ix(),ox()}}function sx(){if(Qt===1){Qt=0;var r=$a,s=Pi,o=(s.flags&13878)!==0;if((s.subtreeFlags&13878)!==0||o){o=k.T,k.T=null;var u=K.p;K.p=2;var p=vt;vt|=4;try{$0(s,r);var y=Um,_=Fy(r.containerInfo),j=y.focusedElem,D=y.selectionRange;if(_!==j&&j&&j.ownerDocument&&Vy(j.ownerDocument.documentElement,j)){if(D!==null&&dh(j)){var W=D.start,ae=D.end;if(ae===void 0&&(ae=W),"selectionStart"in j)j.selectionStart=W,j.selectionEnd=Math.min(ae,j.value.length);else{var le=j.ownerDocument||document,X=le&&le.defaultView||window;if(X.getSelection){var Z=X.getSelection(),Re=j.textContent.length,Ve=Math.min(D.start,Re),_t=D.end===void 0?Ve:Math.min(D.end,Re);!Z.extend&&Ve>_t&&(_=_t,_t=Ve,Ve=_);var B=qy(j,Ve),z=qy(j,_t);if(B&&z&&(Z.rangeCount!==1||Z.anchorNode!==B.node||Z.anchorOffset!==B.offset||Z.focusNode!==z.node||Z.focusOffset!==z.offset)){var G=le.createRange();G.setStart(B.node,B.offset),Z.removeAllRanges(),Ve>_t?(Z.addRange(G),Z.extend(z.node,z.offset)):(G.setEnd(z.node,z.offset),Z.addRange(G))}}}}for(le=[],Z=j;Z=Z.parentNode;)Z.nodeType===1&&le.push({element:Z,left:Z.scrollLeft,top:Z.scrollTop});for(typeof j.focus=="function"&&j.focus(),j=0;j<le.length;j++){var oe=le[j];oe.element.scrollLeft=oe.left,oe.element.scrollTop=oe.top}}Nu=!!$m,Um=$m=null}finally{vt=p,K.p=u,k.T=o}}r.current=s,Qt=2}}function ix(){if(Qt===2){Qt=0;var r=$a,s=Pi,o=(s.flags&8772)!==0;if((s.subtreeFlags&8772)!==0||o){o=k.T,k.T=null;var u=K.p;K.p=2;var p=vt;vt|=4;try{D0(r,s.alternate,s)}finally{vt=p,K.p=u,k.T=o}}Qt=3}}function ox(){if(Qt===4||Qt===3){Qt=0,Ke();var r=$a,s=Pi,o=oa,u=K0;(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?Qt=5:(Qt=0,Pi=$a=null,lx(r,r.pendingLanes));var p=r.pendingLanes;if(p===0&&(Ia=null),hr(o),s=s.stateNode,Mt&&typeof Mt.onCommitFiberRoot=="function")try{Mt.onCommitFiberRoot(vn,s,void 0,(s.current.flags&128)===128)}catch{}if(u!==null){s=k.T,p=K.p,K.p=2,k.T=null;try{for(var y=r.onRecoverableError,_=0;_<u.length;_++){var j=u[_];y(j.value,{componentStack:j.stack})}}finally{k.T=s,K.p=p}}(oa&3)!==0&&hu(),Ar(r),p=r.pendingLanes,(o&261930)!==0&&(p&42)!==0?r===Cm?cl++:(cl=0,Cm=r):cl=0,ul(0)}}function lx(r,s){(r.pooledCacheLanes&=s)===0&&(s=r.pooledCache,s!=null&&(r.pooledCache=null,Vo(s)))}function hu(){return sx(),ix(),ox(),cx()}function cx(){if(Qt!==5)return!1;var r=$a,s=Em;Em=0;var o=hr(oa),u=k.T,p=K.p;try{K.p=32>o?32:o,k.T=null,o=Nm,Nm=null;var y=$a,_=oa;if(Qt=0,Pi=$a=null,oa=0,(vt&6)!==0)throw Error(a(331));var j=vt;if(vt|=4,V0(y.current),B0(y,y.current,_,o),vt=j,ul(0,!1),Mt&&typeof Mt.onPostCommitFiberRoot=="function")try{Mt.onPostCommitFiberRoot(vn,y)}catch{}return!0}finally{K.p=p,k.T=u,lx(r,s)}}function ux(r,s,o){s=Zn(o,s),s=am(r.stateNode,s,2),r=Oa(r,s,2),r!==null&&(ht(r,2),Ar(r))}function bt(r,s,o){if(r.tag===3)ux(r,r,o);else for(;s!==null;){if(s.tag===3){ux(s,r,o);break}else if(s.tag===1){var u=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Ia===null||!Ia.has(u))){r=Zn(o,r),o=d0(2),u=Oa(s,o,2),u!==null&&(f0(o,u,s,r),ht(u,2),Ar(u));break}}s=s.return}}function Rm(r,s,o){var u=r.pingCache;if(u===null){u=r.pingCache=new aA;var p=new Set;u.set(s,p)}else p=u.get(s),p===void 0&&(p=new Set,u.set(s,p));p.has(o)||(wm=!0,p.add(o),r=cA.bind(null,r,s,o),s.then(r,r))}function cA(r,s,o){var u=r.pingCache;u!==null&&u.delete(s),r.pingedLanes|=r.suspendedLanes&o,r.warmLanes&=~o,St===r&&(lt&o)===o&&(zt===4||zt===3&&(lt&62914560)===lt&&300>Le()-ou?(vt&2)===0&&Li(r,0):_m|=o,Di===lt&&(Di=0)),Ar(r)}function dx(r,s){s===0&&(s=ft()),r=xs(r,s),r!==null&&(ht(r,s),Ar(r))}function uA(r){var s=r.memoizedState,o=0;s!==null&&(o=s.retryLane),dx(r,o)}function dA(r,s){var o=0;switch(r.tag){case 31:case 13:var u=r.stateNode,p=r.memoizedState;p!==null&&(o=p.retryLane);break;case 19:u=r.stateNode;break;case 22:u=r.stateNode._retryCache;break;default:throw Error(a(314))}u!==null&&u.delete(s),dx(r,o)}function fA(r,s){return Ct(r,s)}var mu=null,Ii=null,Am=!1,pu=!1,km=!1,Ba=0;function Ar(r){r!==Ii&&r.next===null&&(Ii===null?mu=Ii=r:Ii=Ii.next=r),pu=!0,Am||(Am=!0,mA())}function ul(r,s){if(!km&&pu){km=!0;do for(var o=!1,u=mu;u!==null;){if(r!==0){var p=u.pendingLanes;if(p===0)var y=0;else{var _=u.suspendedLanes,j=u.pingedLanes;y=(1<<31-Dt(42|r)+1)-1,y&=p&~(_&~j),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,px(u,y))}else y=lt,y=He(u,u===St?y:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(y&3)===0||Et(u,y)||(o=!0,px(u,y));u=u.next}while(o);km=!1}}function hA(){fx()}function fx(){pu=Am=!1;var r=0;Ba!==0&&EA()&&(r=Ba);for(var s=Le(),o=null,u=mu;u!==null;){var p=u.next,y=hx(u,s);y===0?(u.next=null,o===null?mu=p:o.next=p,p===null&&(Ii=o)):(o=u,(r!==0||(y&3)!==0)&&(pu=!0)),u=p}Qt!==0&&Qt!==5||ul(r),Ba!==0&&(Ba=0)}function hx(r,s){for(var o=r.suspendedLanes,u=r.pingedLanes,p=r.expirationTimes,y=r.pendingLanes&-62914561;0<y;){var _=31-Dt(y),j=1<<_,D=p[_];D===-1?((j&o)===0||(j&u)!==0)&&(p[_]=we(j,s)):D<=s&&(r.expiredLanes|=j),y&=~j}if(s=St,o=lt,o=He(r,r===s?o:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),u=r.callbackNode,o===0||r===s&&(yt===2||yt===9)||r.cancelPendingCommit!==null)return u!==null&&u!==null&&pe(u),r.callbackNode=null,r.callbackPriority=0;if((o&3)===0||Et(r,o)){if(s=o&-o,s===r.callbackPriority)return s;switch(u!==null&&pe(u),hr(o)){case 2:case 8:o=gt;break;case 32:o=Xt;break;case 268435456:o=At;break;default:o=Xt}return u=mx.bind(null,r),o=Ct(o,u),r.callbackPriority=s,r.callbackNode=o,s}return u!==null&&u!==null&&pe(u),r.callbackPriority=2,r.callbackNode=null,2}function mx(r,s){if(Qt!==0&&Qt!==5)return r.callbackNode=null,r.callbackPriority=0,null;var o=r.callbackNode;if(hu()&&r.callbackNode!==o)return null;var u=lt;return u=He(r,r===St?u:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),u===0?null:(Y0(r,u,s),hx(r,Le()),r.callbackNode!=null&&r.callbackNode===o?mx.bind(null,r):null)}function px(r,s){if(hu())return null;Y0(r,s,!0)}function mA(){CA(function(){(vt&6)!==0?Ct(qe,hA):fx()})}function Om(){if(Ba===0){var r=Si;r===0&&(r=he,he<<=1,(he&261888)===0&&(he=256)),Ba=r}return Ba}function gx(r){return r==null||typeof r=="symbol"||typeof r=="boolean"?null:typeof r=="function"?r:Sc(""+r)}function vx(r,s){var o=s.ownerDocument.createElement("input");return o.name=s.name,o.value=s.value,r.id&&o.setAttribute("form",r.id),s.parentNode.insertBefore(o,s),r=new FormData(r),o.parentNode.removeChild(o),r}function pA(r,s,o,u,p){if(s==="submit"&&o&&o.stateNode===p){var y=gx((p[Nn]||null).action),_=u.submitter;_&&(s=(s=_[Nn]||null)?gx(s.formAction):_.getAttribute("formAction"),s!==null&&(y=s,_=null));var j=new jc("action","action",null,u,p);r.push({event:j,listeners:[{instance:null,listener:function(){if(u.defaultPrevented){if(Ba!==0){var D=_?vx(p,_):new FormData(p);Qh(o,{pending:!0,data:D,method:p.method,action:y},null,D)}}else typeof y=="function"&&(j.preventDefault(),D=_?vx(p,_):new FormData(p),Qh(o,{pending:!0,data:D,method:p.method,action:y},y,D))},currentTarget:p}]})}}for(var Mm=0;Mm<ph.length;Mm++){var Dm=ph[Mm],gA=Dm.toLowerCase(),vA=Dm[0].toUpperCase()+Dm.slice(1);mr(gA,"on"+vA)}mr(Wy,"onAnimationEnd"),mr(Yy,"onAnimationIteration"),mr(Xy,"onAnimationStart"),mr("dblclick","onDoubleClick"),mr("focusin","onFocus"),mr("focusout","onBlur"),mr(MR,"onTransitionRun"),mr(DR,"onTransitionStart"),mr(PR,"onTransitionCancel"),mr(Jy,"onTransitionEnd"),ci("onMouseEnter",["mouseout","mouseover"]),ci("onMouseLeave",["mouseout","mouseover"]),ci("onPointerEnter",["pointerout","pointerover"]),ci("onPointerLeave",["pointerout","pointerover"]),gs("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),gs("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),gs("onBeforeInput",["compositionend","keypress","textInput","paste"]),gs("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),gs("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),gs("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var dl="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(" "),yA=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(dl));function yx(r,s){s=(s&4)!==0;for(var o=0;o<r.length;o++){var u=r[o],p=u.event;u=u.listeners;e:{var y=void 0;if(s)for(var _=u.length-1;0<=_;_--){var j=u[_],D=j.instance,W=j.currentTarget;if(j=j.listener,D!==y&&p.isPropagationStopped())break e;y=j,p.currentTarget=W;try{y(p)}catch(ae){Ac(ae)}p.currentTarget=null,y=D}else for(_=0;_<u.length;_++){if(j=u[_],D=j.instance,W=j.currentTarget,j=j.listener,D!==y&&p.isPropagationStopped())break e;y=j,p.currentTarget=W;try{y(p)}catch(ae){Ac(ae)}p.currentTarget=null,y=D}}}}function it(r,s){var o=s[Kf];o===void 0&&(o=s[Kf]=new Set);var u=r+"__bubble";o.has(u)||(bx(s,r,2,!1),o.add(u))}function Pm(r,s,o){var u=0;s&&(u|=4),bx(o,r,u,s)}var gu="_reactListening"+Math.random().toString(36).slice(2);function Lm(r){if(!r[gu]){r[gu]=!0,fy.forEach(function(o){o!=="selectionchange"&&(yA.has(o)||Pm(o,!1,r),Pm(o,!0,r))});var s=r.nodeType===9?r:r.ownerDocument;s===null||s[gu]||(s[gu]=!0,Pm("selectionchange",!1,s))}}function bx(r,s,o,u){switch(Wx(s)){case 2:var p=GA;break;case 8:p=KA;break;default:p=Jm}o=p.bind(null,s,o,r),p=void 0,!nh||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(p=!0),u?p!==void 0?r.addEventListener(s,o,{capture:!0,passive:p}):r.addEventListener(s,o,!0):p!==void 0?r.addEventListener(s,o,{passive:p}):r.addEventListener(s,o,!1)}function zm(r,s,o,u,p){var y=u;if((s&1)===0&&(s&2)===0&&u!==null)e:for(;;){if(u===null)return;var _=u.tag;if(_===3||_===4){var j=u.stateNode.containerInfo;if(j===p)break;if(_===4)for(_=u.return;_!==null;){var D=_.tag;if((D===3||D===4)&&_.stateNode.containerInfo===p)return;_=_.return}for(;j!==null;){if(_=ii(j),_===null)return;if(D=_.tag,D===5||D===6||D===26||D===27){u=y=_;continue e}j=j.parentNode}}u=u.return}Ey(function(){var W=y,ae=eh(o),le=[];e:{var X=Qy.get(r);if(X!==void 0){var Z=jc,Re=r;switch(r){case"keypress":if(Nc(o)===0)break e;case"keydown":case"keyup":Z=dR;break;case"focusin":Re="focus",Z=ih;break;case"focusout":Re="blur",Z=ih;break;case"beforeblur":case"afterblur":Z=ih;break;case"click":if(o.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Z=jy;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Z=ZT;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Z=mR;break;case Wy:case Yy:case Xy:Z=nR;break;case Jy:Z=gR;break;case"scroll":case"scrollend":Z=JT;break;case"wheel":Z=yR;break;case"copy":case"cut":case"paste":Z=aR;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Z=Ry;break;case"toggle":case"beforetoggle":Z=xR}var Ve=(s&4)!==0,_t=!Ve&&(r==="scroll"||r==="scrollend"),B=Ve?X!==null?X+"Capture":null:X;Ve=[];for(var z=W,G;z!==null;){var oe=z;if(G=oe.stateNode,oe=oe.tag,oe!==5&&oe!==26&&oe!==27||G===null||B===null||(oe=Mo(z,B),oe!=null&&Ve.push(fl(z,oe,G))),_t)break;z=z.return}0<Ve.length&&(X=new Z(X,Re,null,o,ae),le.push({event:X,listeners:Ve}))}}if((s&7)===0){e:{if(X=r==="mouseover"||r==="pointerover",Z=r==="mouseout"||r==="pointerout",X&&o!==Zf&&(Re=o.relatedTarget||o.fromElement)&&(ii(Re)||Re[si]))break e;if((Z||X)&&(X=ae.window===ae?ae:(X=ae.ownerDocument)?X.defaultView||X.parentWindow:window,Z?(Re=o.relatedTarget||o.toElement,Z=W,Re=Re?ii(Re):null,Re!==null&&(_t=l(Re),Ve=Re.tag,Re!==_t||Ve!==5&&Ve!==27&&Ve!==6)&&(Re=null)):(Z=null,Re=W),Z!==Re)){if(Ve=jy,oe="onMouseLeave",B="onMouseEnter",z="mouse",(r==="pointerout"||r==="pointerover")&&(Ve=Ry,oe="onPointerLeave",B="onPointerEnter",z="pointer"),_t=Z==null?X:Oo(Z),G=Re==null?X:Oo(Re),X=new Ve(oe,z+"leave",Z,o,ae),X.target=_t,X.relatedTarget=G,oe=null,ii(ae)===W&&(Ve=new Ve(B,z+"enter",Re,o,ae),Ve.target=G,Ve.relatedTarget=_t,oe=Ve),_t=oe,Z&&Re)t:{for(Ve=bA,B=Z,z=Re,G=0,oe=B;oe;oe=Ve(oe))G++;oe=0;for(var Ie=z;Ie;Ie=Ve(Ie))oe++;for(;0<G-oe;)B=Ve(B),G--;for(;0<oe-G;)z=Ve(z),oe--;for(;G--;){if(B===z||z!==null&&B===z.alternate){Ve=B;break t}B=Ve(B),z=Ve(z)}Ve=null}else Ve=null;Z!==null&&xx(le,X,Z,Ve,!1),Re!==null&&_t!==null&&xx(le,_t,Re,Ve,!0)}}e:{if(X=W?Oo(W):window,Z=X.nodeName&&X.nodeName.toLowerCase(),Z==="select"||Z==="input"&&X.type==="file")var mt=zy;else if(Py(X))if(Iy)mt=AR;else{mt=TR;var Oe=jR}else Z=X.nodeName,!Z||Z.toLowerCase()!=="input"||X.type!=="checkbox"&&X.type!=="radio"?W&&Qf(W.elementType)&&(mt=zy):mt=RR;if(mt&&(mt=mt(r,W))){Ly(le,mt,o,ae);break e}Oe&&Oe(r,X,W),r==="focusout"&&W&&X.type==="number"&&W.memoizedProps.value!=null&&Jf(X,"number",X.value)}switch(Oe=W?Oo(W):window,r){case"focusin":(Py(Oe)||Oe.contentEditable==="true")&&(pi=Oe,fh=W,Bo=null);break;case"focusout":Bo=fh=pi=null;break;case"mousedown":hh=!0;break;case"contextmenu":case"mouseup":case"dragend":hh=!1,Gy(le,o,ae);break;case"selectionchange":if(OR)break;case"keydown":case"keyup":Gy(le,o,ae)}var Ze;if(lh)e:{switch(r){case"compositionstart":var ct="onCompositionStart";break e;case"compositionend":ct="onCompositionEnd";break e;case"compositionupdate":ct="onCompositionUpdate";break e}ct=void 0}else mi?My(r,o)&&(ct="onCompositionEnd"):r==="keydown"&&o.keyCode===229&&(ct="onCompositionStart");ct&&(Ay&&o.locale!=="ko"&&(mi||ct!=="onCompositionStart"?ct==="onCompositionEnd"&&mi&&(Ze=Ny()):(Na=ae,rh="value"in Na?Na.value:Na.textContent,mi=!0)),Oe=vu(W,ct),0<Oe.length&&(ct=new Ty(ct,r,null,o,ae),le.push({event:ct,listeners:Oe}),Ze?ct.data=Ze:(Ze=Dy(o),Ze!==null&&(ct.data=Ze)))),(Ze=_R?SR(r,o):ER(r,o))&&(ct=vu(W,"onBeforeInput"),0<ct.length&&(Oe=new Ty("onBeforeInput","beforeinput",null,o,ae),le.push({event:Oe,listeners:ct}),Oe.data=Ze)),pA(le,r,W,o,ae)}yx(le,s)})}function fl(r,s,o){return{instance:r,listener:s,currentTarget:o}}function vu(r,s){for(var o=s+"Capture",u=[];r!==null;){var p=r,y=p.stateNode;if(p=p.tag,p!==5&&p!==26&&p!==27||y===null||(p=Mo(r,o),p!=null&&u.unshift(fl(r,p,y)),p=Mo(r,s),p!=null&&u.push(fl(r,p,y))),r.tag===3)return u;r=r.return}return[]}function bA(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5&&r.tag!==27);return r||null}function xx(r,s,o,u,p){for(var y=s._reactName,_=[];o!==null&&o!==u;){var j=o,D=j.alternate,W=j.stateNode;if(j=j.tag,D!==null&&D===u)break;j!==5&&j!==26&&j!==27||W===null||(D=W,p?(W=Mo(o,y),W!=null&&_.unshift(fl(o,W,D))):p||(W=Mo(o,y),W!=null&&_.push(fl(o,W,D)))),o=o.return}_.length!==0&&r.push({event:s,listeners:_})}var xA=/\r\n?/g,wA=/\u0000|\uFFFD/g;function wx(r){return(typeof r=="string"?r:""+r).replace(xA,`
`).replace(wA,"")}function _x(r,s){return s=wx(s),wx(r)===s}function wt(r,s,o,u,p,y){switch(o){case"children":typeof u=="string"?s==="body"||s==="textarea"&&u===""||di(r,u):(typeof u=="number"||typeof u=="bigint")&&s!=="body"&&di(r,""+u);break;case"className":wc(r,"class",u);break;case"tabIndex":wc(r,"tabindex",u);break;case"dir":case"role":case"viewBox":case"width":case"height":wc(r,o,u);break;case"style":_y(r,u,y);break;case"data":if(s!=="object"){wc(r,"data",u);break}case"src":case"href":if(u===""&&(s!=="a"||o!=="href")){r.removeAttribute(o);break}if(u==null||typeof u=="function"||typeof u=="symbol"||typeof u=="boolean"){r.removeAttribute(o);break}u=Sc(""+u),r.setAttribute(o,u);break;case"action":case"formAction":if(typeof u=="function"){r.setAttribute(o,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof y=="function"&&(o==="formAction"?(s!=="input"&&wt(r,s,"name",p.name,p,null),wt(r,s,"formEncType",p.formEncType,p,null),wt(r,s,"formMethod",p.formMethod,p,null),wt(r,s,"formTarget",p.formTarget,p,null)):(wt(r,s,"encType",p.encType,p,null),wt(r,s,"method",p.method,p,null),wt(r,s,"target",p.target,p,null)));if(u==null||typeof u=="symbol"||typeof u=="boolean"){r.removeAttribute(o);break}u=Sc(""+u),r.setAttribute(o,u);break;case"onClick":u!=null&&(r.onclick=Gr);break;case"onScroll":u!=null&&it("scroll",r);break;case"onScrollEnd":u!=null&&it("scrollend",r);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(a(61));if(o=u.__html,o!=null){if(p.children!=null)throw Error(a(60));r.innerHTML=o}}break;case"multiple":r.multiple=u&&typeof u!="function"&&typeof u!="symbol";break;case"muted":r.muted=u&&typeof u!="function"&&typeof u!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(u==null||typeof u=="function"||typeof u=="boolean"||typeof u=="symbol"){r.removeAttribute("xlink:href");break}o=Sc(""+u),r.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":u!=null&&typeof u!="function"&&typeof u!="symbol"?r.setAttribute(o,""+u):r.removeAttribute(o);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":u&&typeof u!="function"&&typeof u!="symbol"?r.setAttribute(o,""):r.removeAttribute(o);break;case"capture":case"download":u===!0?r.setAttribute(o,""):u!==!1&&u!=null&&typeof u!="function"&&typeof u!="symbol"?r.setAttribute(o,u):r.removeAttribute(o);break;case"cols":case"rows":case"size":case"span":u!=null&&typeof u!="function"&&typeof u!="symbol"&&!isNaN(u)&&1<=u?r.setAttribute(o,u):r.removeAttribute(o);break;case"rowSpan":case"start":u==null||typeof u=="function"||typeof u=="symbol"||isNaN(u)?r.removeAttribute(o):r.setAttribute(o,u);break;case"popover":it("beforetoggle",r),it("toggle",r),xc(r,"popover",u);break;case"xlinkActuate":Fr(r,"http://www.w3.org/1999/xlink","xlink:actuate",u);break;case"xlinkArcrole":Fr(r,"http://www.w3.org/1999/xlink","xlink:arcrole",u);break;case"xlinkRole":Fr(r,"http://www.w3.org/1999/xlink","xlink:role",u);break;case"xlinkShow":Fr(r,"http://www.w3.org/1999/xlink","xlink:show",u);break;case"xlinkTitle":Fr(r,"http://www.w3.org/1999/xlink","xlink:title",u);break;case"xlinkType":Fr(r,"http://www.w3.org/1999/xlink","xlink:type",u);break;case"xmlBase":Fr(r,"http://www.w3.org/XML/1998/namespace","xml:base",u);break;case"xmlLang":Fr(r,"http://www.w3.org/XML/1998/namespace","xml:lang",u);break;case"xmlSpace":Fr(r,"http://www.w3.org/XML/1998/namespace","xml:space",u);break;case"is":xc(r,"is",u);break;case"innerText":case"textContent":break;default:(!(2<o.length)||o[0]!=="o"&&o[0]!=="O"||o[1]!=="n"&&o[1]!=="N")&&(o=YT.get(o)||o,xc(r,o,u))}}function Im(r,s,o,u,p,y){switch(o){case"style":_y(r,u,y);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(a(61));if(o=u.__html,o!=null){if(p.children!=null)throw Error(a(60));r.innerHTML=o}}break;case"children":typeof u=="string"?di(r,u):(typeof u=="number"||typeof u=="bigint")&&di(r,""+u);break;case"onScroll":u!=null&&it("scroll",r);break;case"onScrollEnd":u!=null&&it("scrollend",r);break;case"onClick":u!=null&&(r.onclick=Gr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!hy.hasOwnProperty(o))e:{if(o[0]==="o"&&o[1]==="n"&&(p=o.endsWith("Capture"),s=o.slice(2,p?o.length-7:void 0),y=r[Nn]||null,y=y!=null?y[o]:null,typeof y=="function"&&r.removeEventListener(s,y,p),typeof u=="function")){typeof y!="function"&&y!==null&&(o in r?r[o]=null:r.hasAttribute(o)&&r.removeAttribute(o)),r.addEventListener(s,u,p);break e}o in r?r[o]=u:u===!0?r.setAttribute(o,""):xc(r,o,u)}}}function fn(r,s,o){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":it("error",r),it("load",r);var u=!1,p=!1,y;for(y in o)if(o.hasOwnProperty(y)){var _=o[y];if(_!=null)switch(y){case"src":u=!0;break;case"srcSet":p=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(a(137,s));default:wt(r,s,y,_,o,null)}}p&&wt(r,s,"srcSet",o.srcSet,o,null),u&&wt(r,s,"src",o.src,o,null);return;case"input":it("invalid",r);var j=y=_=p=null,D=null,W=null;for(u in o)if(o.hasOwnProperty(u)){var ae=o[u];if(ae!=null)switch(u){case"name":p=ae;break;case"type":_=ae;break;case"checked":D=ae;break;case"defaultChecked":W=ae;break;case"value":y=ae;break;case"defaultValue":j=ae;break;case"children":case"dangerouslySetInnerHTML":if(ae!=null)throw Error(a(137,s));break;default:wt(r,s,u,ae,o,null)}}yy(r,y,j,D,W,_,p,!1);return;case"select":it("invalid",r),u=_=y=null;for(p in o)if(o.hasOwnProperty(p)&&(j=o[p],j!=null))switch(p){case"value":y=j;break;case"defaultValue":_=j;break;case"multiple":u=j;default:wt(r,s,p,j,o,null)}s=y,o=_,r.multiple=!!u,s!=null?ui(r,!!u,s,!1):o!=null&&ui(r,!!u,o,!0);return;case"textarea":it("invalid",r),y=p=u=null;for(_ in o)if(o.hasOwnProperty(_)&&(j=o[_],j!=null))switch(_){case"value":u=j;break;case"defaultValue":p=j;break;case"children":y=j;break;case"dangerouslySetInnerHTML":if(j!=null)throw Error(a(91));break;default:wt(r,s,_,j,o,null)}xy(r,u,p,y);return;case"option":for(D in o)if(o.hasOwnProperty(D)&&(u=o[D],u!=null))switch(D){case"selected":r.selected=u&&typeof u!="function"&&typeof u!="symbol";break;default:wt(r,s,D,u,o,null)}return;case"dialog":it("beforetoggle",r),it("toggle",r),it("cancel",r),it("close",r);break;case"iframe":case"object":it("load",r);break;case"video":case"audio":for(u=0;u<dl.length;u++)it(dl[u],r);break;case"image":it("error",r),it("load",r);break;case"details":it("toggle",r);break;case"embed":case"source":case"link":it("error",r),it("load",r);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(W in o)if(o.hasOwnProperty(W)&&(u=o[W],u!=null))switch(W){case"children":case"dangerouslySetInnerHTML":throw Error(a(137,s));default:wt(r,s,W,u,o,null)}return;default:if(Qf(s)){for(ae in o)o.hasOwnProperty(ae)&&(u=o[ae],u!==void 0&&Im(r,s,ae,u,o,void 0));return}}for(j in o)o.hasOwnProperty(j)&&(u=o[j],u!=null&&wt(r,s,j,u,o,null))}function _A(r,s,o,u){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var p=null,y=null,_=null,j=null,D=null,W=null,ae=null;for(Z in o){var le=o[Z];if(o.hasOwnProperty(Z)&&le!=null)switch(Z){case"checked":break;case"value":break;case"defaultValue":D=le;default:u.hasOwnProperty(Z)||wt(r,s,Z,null,u,le)}}for(var X in u){var Z=u[X];if(le=o[X],u.hasOwnProperty(X)&&(Z!=null||le!=null))switch(X){case"type":y=Z;break;case"name":p=Z;break;case"checked":W=Z;break;case"defaultChecked":ae=Z;break;case"value":_=Z;break;case"defaultValue":j=Z;break;case"children":case"dangerouslySetInnerHTML":if(Z!=null)throw Error(a(137,s));break;default:Z!==le&&wt(r,s,X,Z,u,le)}}Xf(r,_,j,D,W,ae,y,p);return;case"select":Z=_=j=X=null;for(y in o)if(D=o[y],o.hasOwnProperty(y)&&D!=null)switch(y){case"value":break;case"multiple":Z=D;default:u.hasOwnProperty(y)||wt(r,s,y,null,u,D)}for(p in u)if(y=u[p],D=o[p],u.hasOwnProperty(p)&&(y!=null||D!=null))switch(p){case"value":X=y;break;case"defaultValue":j=y;break;case"multiple":_=y;default:y!==D&&wt(r,s,p,y,u,D)}s=j,o=_,u=Z,X!=null?ui(r,!!o,X,!1):!!u!=!!o&&(s!=null?ui(r,!!o,s,!0):ui(r,!!o,o?[]:"",!1));return;case"textarea":Z=X=null;for(j in o)if(p=o[j],o.hasOwnProperty(j)&&p!=null&&!u.hasOwnProperty(j))switch(j){case"value":break;case"children":break;default:wt(r,s,j,null,u,p)}for(_ in u)if(p=u[_],y=o[_],u.hasOwnProperty(_)&&(p!=null||y!=null))switch(_){case"value":X=p;break;case"defaultValue":Z=p;break;case"children":break;case"dangerouslySetInnerHTML":if(p!=null)throw Error(a(91));break;default:p!==y&&wt(r,s,_,p,u,y)}by(r,X,Z);return;case"option":for(var Re in o)if(X=o[Re],o.hasOwnProperty(Re)&&X!=null&&!u.hasOwnProperty(Re))switch(Re){case"selected":r.selected=!1;break;default:wt(r,s,Re,null,u,X)}for(D in u)if(X=u[D],Z=o[D],u.hasOwnProperty(D)&&X!==Z&&(X!=null||Z!=null))switch(D){case"selected":r.selected=X&&typeof X!="function"&&typeof X!="symbol";break;default:wt(r,s,D,X,u,Z)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Ve in o)X=o[Ve],o.hasOwnProperty(Ve)&&X!=null&&!u.hasOwnProperty(Ve)&&wt(r,s,Ve,null,u,X);for(W in u)if(X=u[W],Z=o[W],u.hasOwnProperty(W)&&X!==Z&&(X!=null||Z!=null))switch(W){case"children":case"dangerouslySetInnerHTML":if(X!=null)throw Error(a(137,s));break;default:wt(r,s,W,X,u,Z)}return;default:if(Qf(s)){for(var _t in o)X=o[_t],o.hasOwnProperty(_t)&&X!==void 0&&!u.hasOwnProperty(_t)&&Im(r,s,_t,void 0,u,X);for(ae in u)X=u[ae],Z=o[ae],!u.hasOwnProperty(ae)||X===Z||X===void 0&&Z===void 0||Im(r,s,ae,X,u,Z);return}}for(var B in o)X=o[B],o.hasOwnProperty(B)&&X!=null&&!u.hasOwnProperty(B)&&wt(r,s,B,null,u,X);for(le in u)X=u[le],Z=o[le],!u.hasOwnProperty(le)||X===Z||X==null&&Z==null||wt(r,s,le,X,u,Z)}function Sx(r){switch(r){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function SA(){if(typeof performance.getEntriesByType=="function"){for(var r=0,s=0,o=performance.getEntriesByType("resource"),u=0;u<o.length;u++){var p=o[u],y=p.transferSize,_=p.initiatorType,j=p.duration;if(y&&j&&Sx(_)){for(_=0,j=p.responseEnd,u+=1;u<o.length;u++){var D=o[u],W=D.startTime;if(W>j)break;var ae=D.transferSize,le=D.initiatorType;ae&&Sx(le)&&(D=D.responseEnd,_+=ae*(D<j?1:(j-W)/(D-W)))}if(--u,s+=8*(y+_)/(p.duration/1e3),r++,10<r)break}}if(0<r)return s/r/1e6}return navigator.connection&&(r=navigator.connection.downlink,typeof r=="number")?r:5}var $m=null,Um=null;function yu(r){return r.nodeType===9?r:r.ownerDocument}function Ex(r){switch(r){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Nx(r,s){if(r===0)switch(s){case"svg":return 1;case"math":return 2;default:return 0}return r===1&&s==="foreignObject"?0:r}function Bm(r,s){return r==="textarea"||r==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.children=="bigint"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var Hm=null;function EA(){var r=window.event;return r&&r.type==="popstate"?r===Hm?!1:(Hm=r,!0):(Hm=null,!1)}var Cx=typeof setTimeout=="function"?setTimeout:void 0,NA=typeof clearTimeout=="function"?clearTimeout:void 0,jx=typeof Promise=="function"?Promise:void 0,CA=typeof queueMicrotask=="function"?queueMicrotask:typeof jx<"u"?function(r){return jx.resolve(null).then(r).catch(jA)}:Cx;function jA(r){setTimeout(function(){throw r})}function Ha(r){return r==="head"}function Tx(r,s){var o=s,u=0;do{var p=o.nextSibling;if(r.removeChild(o),p&&p.nodeType===8)if(o=p.data,o==="/$"||o==="/&"){if(u===0){r.removeChild(p),Hi(s);return}u--}else if(o==="$"||o==="$?"||o==="$~"||o==="$!"||o==="&")u++;else if(o==="html")hl(r.ownerDocument.documentElement);else if(o==="head"){o=r.ownerDocument.head,hl(o);for(var y=o.firstChild;y;){var _=y.nextSibling,j=y.nodeName;y[ko]||j==="SCRIPT"||j==="STYLE"||j==="LINK"&&y.rel.toLowerCase()==="stylesheet"||o.removeChild(y),y=_}}else o==="body"&&hl(r.ownerDocument.body);o=p}while(o);Hi(s)}function Rx(r,s){var o=r;r=0;do{var u=o.nextSibling;if(o.nodeType===1?s?(o._stashedDisplay=o.style.display,o.style.display="none"):(o.style.display=o._stashedDisplay||"",o.getAttribute("style")===""&&o.removeAttribute("style")):o.nodeType===3&&(s?(o._stashedText=o.nodeValue,o.nodeValue=""):o.nodeValue=o._stashedText||""),u&&u.nodeType===8)if(o=u.data,o==="/$"){if(r===0)break;r--}else o!=="$"&&o!=="$?"&&o!=="$~"&&o!=="$!"||r++;o=u}while(o)}function qm(r){var s=r.firstChild;for(s&&s.nodeType===10&&(s=s.nextSibling);s;){var o=s;switch(s=s.nextSibling,o.nodeName){case"HTML":case"HEAD":case"BODY":qm(o),Wf(o);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(o.rel.toLowerCase()==="stylesheet")continue}r.removeChild(o)}}function TA(r,s,o,u){for(;r.nodeType===1;){var p=o;if(r.nodeName.toLowerCase()!==s.toLowerCase()){if(!u&&(r.nodeName!=="INPUT"||r.type!=="hidden"))break}else if(u){if(!r[ko])switch(s){case"meta":if(!r.hasAttribute("itemprop"))break;return r;case"link":if(y=r.getAttribute("rel"),y==="stylesheet"&&r.hasAttribute("data-precedence"))break;if(y!==p.rel||r.getAttribute("href")!==(p.href==null||p.href===""?null:p.href)||r.getAttribute("crossorigin")!==(p.crossOrigin==null?null:p.crossOrigin)||r.getAttribute("title")!==(p.title==null?null:p.title))break;return r;case"style":if(r.hasAttribute("data-precedence"))break;return r;case"script":if(y=r.getAttribute("src"),(y!==(p.src==null?null:p.src)||r.getAttribute("type")!==(p.type==null?null:p.type)||r.getAttribute("crossorigin")!==(p.crossOrigin==null?null:p.crossOrigin))&&y&&r.hasAttribute("async")&&!r.hasAttribute("itemprop"))break;return r;default:return r}}else if(s==="input"&&r.type==="hidden"){var y=p.name==null?null:""+p.name;if(p.type==="hidden"&&r.getAttribute("name")===y)return r}else return r;if(r=ar(r.nextSibling),r===null)break}return null}function RA(r,s,o){if(s==="")return null;for(;r.nodeType!==3;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!o||(r=ar(r.nextSibling),r===null))return null;return r}function Ax(r,s){for(;r.nodeType!==8;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!s||(r=ar(r.nextSibling),r===null))return null;return r}function Vm(r){return r.data==="$?"||r.data==="$~"}function Fm(r){return r.data==="$!"||r.data==="$?"&&r.ownerDocument.readyState!=="loading"}function AA(r,s){var o=r.ownerDocument;if(r.data==="$~")r._reactRetry=s;else if(r.data!=="$?"||o.readyState!=="loading")s();else{var u=function(){s(),o.removeEventListener("DOMContentLoaded",u)};o.addEventListener("DOMContentLoaded",u),r._reactRetry=u}}function ar(r){for(;r!=null;r=r.nextSibling){var s=r.nodeType;if(s===1||s===3)break;if(s===8){if(s=r.data,s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"||s==="F!"||s==="F")break;if(s==="/$"||s==="/&")return null}}return r}var Gm=null;function kx(r){r=r.nextSibling;for(var s=0;r;){if(r.nodeType===8){var o=r.data;if(o==="/$"||o==="/&"){if(s===0)return ar(r.nextSibling);s--}else o!=="$"&&o!=="$!"&&o!=="$?"&&o!=="$~"&&o!=="&"||s++}r=r.nextSibling}return null}function Ox(r){r=r.previousSibling;for(var s=0;r;){if(r.nodeType===8){var o=r.data;if(o==="$"||o==="$!"||o==="$?"||o==="$~"||o==="&"){if(s===0)return r;s--}else o!=="/$"&&o!=="/&"||s++}r=r.previousSibling}return null}function Mx(r,s,o){switch(s=yu(o),r){case"html":if(r=s.documentElement,!r)throw Error(a(452));return r;case"head":if(r=s.head,!r)throw Error(a(453));return r;case"body":if(r=s.body,!r)throw Error(a(454));return r;default:throw Error(a(451))}}function hl(r){for(var s=r.attributes;s.length;)r.removeAttributeNode(s[0]);Wf(r)}var sr=new Map,Dx=new Set;function bu(r){return typeof r.getRootNode=="function"?r.getRootNode():r.nodeType===9?r:r.ownerDocument}var la=K.d;K.d={f:kA,r:OA,D:MA,C:DA,L:PA,m:LA,X:IA,S:zA,M:$A};function kA(){var r=la.f(),s=uu();return r||s}function OA(r){var s=oi(r);s!==null&&s.tag===5&&s.type==="form"?Jb(s):la.r(r)}var $i=typeof document>"u"?null:document;function Px(r,s,o){var u=$i;if(u&&typeof s=="string"&&s){var p=Jn(s);p='link[rel="'+r+'"][href="'+p+'"]',typeof o=="string"&&(p+='[crossorigin="'+o+'"]'),Dx.has(p)||(Dx.add(p),r={rel:r,crossOrigin:o,href:s},u.querySelector(p)===null&&(s=u.createElement("link"),fn(s,"link",r),tn(s),u.head.appendChild(s)))}}function MA(r){la.D(r),Px("dns-prefetch",r,null)}function DA(r,s){la.C(r,s),Px("preconnect",r,s)}function PA(r,s,o){la.L(r,s,o);var u=$i;if(u&&r&&s){var p='link[rel="preload"][as="'+Jn(s)+'"]';s==="image"&&o&&o.imageSrcSet?(p+='[imagesrcset="'+Jn(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(p+='[imagesizes="'+Jn(o.imageSizes)+'"]')):p+='[href="'+Jn(r)+'"]';var y=p;switch(s){case"style":y=Ui(r);break;case"script":y=Bi(r)}sr.has(y)||(r=g({rel:"preload",href:s==="image"&&o&&o.imageSrcSet?void 0:r,as:s},o),sr.set(y,r),u.querySelector(p)!==null||s==="style"&&u.querySelector(ml(y))||s==="script"&&u.querySelector(pl(y))||(s=u.createElement("link"),fn(s,"link",r),tn(s),u.head.appendChild(s)))}}function LA(r,s){la.m(r,s);var o=$i;if(o&&r){var u=s&&typeof s.as=="string"?s.as:"script",p='link[rel="modulepreload"][as="'+Jn(u)+'"][href="'+Jn(r)+'"]',y=p;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=Bi(r)}if(!sr.has(y)&&(r=g({rel:"modulepreload",href:r},s),sr.set(y,r),o.querySelector(p)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(pl(y)))return}u=o.createElement("link"),fn(u,"link",r),tn(u),o.head.appendChild(u)}}}function zA(r,s,o){la.S(r,s,o);var u=$i;if(u&&r){var p=li(u).hoistableStyles,y=Ui(r);s=s||"default";var _=p.get(y);if(!_){var j={loading:0,preload:null};if(_=u.querySelector(ml(y)))j.loading=5;else{r=g({rel:"stylesheet",href:r,"data-precedence":s},o),(o=sr.get(y))&&Km(r,o);var D=_=u.createElement("link");tn(D),fn(D,"link",r),D._p=new Promise(function(W,ae){D.onload=W,D.onerror=ae}),D.addEventListener("load",function(){j.loading|=1}),D.addEventListener("error",function(){j.loading|=2}),j.loading|=4,xu(_,s,u)}_={type:"stylesheet",instance:_,count:1,state:j},p.set(y,_)}}}function IA(r,s){la.X(r,s);var o=$i;if(o&&r){var u=li(o).hoistableScripts,p=Bi(r),y=u.get(p);y||(y=o.querySelector(pl(p)),y||(r=g({src:r,async:!0},s),(s=sr.get(p))&&Wm(r,s),y=o.createElement("script"),tn(y),fn(y,"link",r),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},u.set(p,y))}}function $A(r,s){la.M(r,s);var o=$i;if(o&&r){var u=li(o).hoistableScripts,p=Bi(r),y=u.get(p);y||(y=o.querySelector(pl(p)),y||(r=g({src:r,async:!0,type:"module"},s),(s=sr.get(p))&&Wm(r,s),y=o.createElement("script"),tn(y),fn(y,"link",r),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},u.set(p,y))}}function Lx(r,s,o,u){var p=(p=ee.current)?bu(p):null;if(!p)throw Error(a(446));switch(r){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(s=Ui(o.href),o=li(p).hoistableStyles,u=o.get(s),u||(u={type:"style",instance:null,count:0,state:null},o.set(s,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){r=Ui(o.href);var y=li(p).hoistableStyles,_=y.get(r);if(_||(p=p.ownerDocument||p,_={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(r,_),(y=p.querySelector(ml(r)))&&!y._p&&(_.instance=y,_.state.loading=5),sr.has(r)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},sr.set(r,o),y||UA(p,r,o,_.state))),s&&u===null)throw Error(a(528,""));return _}if(s&&u!==null)throw Error(a(529,""));return null;case"script":return s=o.async,o=o.src,typeof o=="string"&&s&&typeof s!="function"&&typeof s!="symbol"?(s=Bi(o),o=li(p).hoistableScripts,u=o.get(s),u||(u={type:"script",instance:null,count:0,state:null},o.set(s,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(a(444,r))}}function Ui(r){return'href="'+Jn(r)+'"'}function ml(r){return'link[rel="stylesheet"]['+r+"]"}function zx(r){return g({},r,{"data-precedence":r.precedence,precedence:null})}function UA(r,s,o,u){r.querySelector('link[rel="preload"][as="style"]['+s+"]")?u.loading=1:(s=r.createElement("link"),u.preload=s,s.addEventListener("load",function(){return u.loading|=1}),s.addEventListener("error",function(){return u.loading|=2}),fn(s,"link",o),tn(s),r.head.appendChild(s))}function Bi(r){return'[src="'+Jn(r)+'"]'}function pl(r){return"script[async]"+r}function Ix(r,s,o){if(s.count++,s.instance===null)switch(s.type){case"style":var u=r.querySelector('style[data-href~="'+Jn(o.href)+'"]');if(u)return s.instance=u,tn(u),u;var p=g({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return u=(r.ownerDocument||r).createElement("style"),tn(u),fn(u,"style",p),xu(u,o.precedence,r),s.instance=u;case"stylesheet":p=Ui(o.href);var y=r.querySelector(ml(p));if(y)return s.state.loading|=4,s.instance=y,tn(y),y;u=zx(o),(p=sr.get(p))&&Km(u,p),y=(r.ownerDocument||r).createElement("link"),tn(y);var _=y;return _._p=new Promise(function(j,D){_.onload=j,_.onerror=D}),fn(y,"link",u),s.state.loading|=4,xu(y,o.precedence,r),s.instance=y;case"script":return y=Bi(o.src),(p=r.querySelector(pl(y)))?(s.instance=p,tn(p),p):(u=o,(p=sr.get(y))&&(u=g({},o),Wm(u,p)),r=r.ownerDocument||r,p=r.createElement("script"),tn(p),fn(p,"link",u),r.head.appendChild(p),s.instance=p);case"void":return null;default:throw Error(a(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(u=s.instance,s.state.loading|=4,xu(u,o.precedence,r));return s.instance}function xu(r,s,o){for(var u=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=u.length?u[u.length-1]:null,y=p,_=0;_<u.length;_++){var j=u[_];if(j.dataset.precedence===s)y=j;else if(y!==p)break}y?y.parentNode.insertBefore(r,y.nextSibling):(s=o.nodeType===9?o.head:o,s.insertBefore(r,s.firstChild))}function Km(r,s){r.crossOrigin==null&&(r.crossOrigin=s.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=s.referrerPolicy),r.title==null&&(r.title=s.title)}function Wm(r,s){r.crossOrigin==null&&(r.crossOrigin=s.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=s.referrerPolicy),r.integrity==null&&(r.integrity=s.integrity)}var wu=null;function $x(r,s,o){if(wu===null){var u=new Map,p=wu=new Map;p.set(o,u)}else p=wu,u=p.get(o),u||(u=new Map,p.set(o,u));if(u.has(r))return u;for(u.set(r,null),o=o.getElementsByTagName(r),p=0;p<o.length;p++){var y=o[p];if(!(y[ko]||y[ln]||r==="link"&&y.getAttribute("rel")==="stylesheet")&&y.namespaceURI!=="http://www.w3.org/2000/svg"){var _=y.getAttribute(s)||"";_=r+_;var j=u.get(_);j?j.push(y):u.set(_,[y])}}return u}function Ux(r,s,o){r=r.ownerDocument||r,r.head.insertBefore(o,s==="title"?r.querySelector("head > title"):null)}function BA(r,s,o){if(o===1||s.itemProp!=null)return!1;switch(r){case"meta":case"title":return!0;case"style":if(typeof s.precedence!="string"||typeof s.href!="string"||s.href==="")break;return!0;case"link":if(typeof s.rel!="string"||typeof s.href!="string"||s.href===""||s.onLoad||s.onError)break;switch(s.rel){case"stylesheet":return r=s.disabled,typeof s.precedence=="string"&&r==null;default:return!0}case"script":if(s.async&&typeof s.async!="function"&&typeof s.async!="symbol"&&!s.onLoad&&!s.onError&&s.src&&typeof s.src=="string")return!0}return!1}function Bx(r){return!(r.type==="stylesheet"&&(r.state.loading&3)===0)}function HA(r,s,o,u){if(o.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var p=Ui(u.href),y=s.querySelector(ml(p));if(y){s=y._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(r.count++,r=_u.bind(r),s.then(r,r)),o.state.loading|=4,o.instance=y,tn(y);return}y=s.ownerDocument||s,u=zx(u),(p=sr.get(p))&&Km(u,p),y=y.createElement("link"),tn(y);var _=y;_._p=new Promise(function(j,D){_.onload=j,_.onerror=D}),fn(y,"link",u),o.instance=y}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(o,s),(s=o.state.preload)&&(o.state.loading&3)===0&&(r.count++,o=_u.bind(r),s.addEventListener("load",o),s.addEventListener("error",o))}}var Ym=0;function qA(r,s){return r.stylesheets&&r.count===0&&Eu(r,r.stylesheets),0<r.count||0<r.imgCount?function(o){var u=setTimeout(function(){if(r.stylesheets&&Eu(r,r.stylesheets),r.unsuspend){var y=r.unsuspend;r.unsuspend=null,y()}},6e4+s);0<r.imgBytes&&Ym===0&&(Ym=62500*SA());var p=setTimeout(function(){if(r.waitingForImages=!1,r.count===0&&(r.stylesheets&&Eu(r,r.stylesheets),r.unsuspend)){var y=r.unsuspend;r.unsuspend=null,y()}},(r.imgBytes>Ym?50:800)+s);return r.unsuspend=o,function(){r.unsuspend=null,clearTimeout(u),clearTimeout(p)}}:null}function _u(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Eu(this,this.stylesheets);else if(this.unsuspend){var r=this.unsuspend;this.unsuspend=null,r()}}}var Su=null;function Eu(r,s){r.stylesheets=null,r.unsuspend!==null&&(r.count++,Su=new Map,s.forEach(VA,r),Su=null,_u.call(r))}function VA(r,s){if(!(s.state.loading&4)){var o=Su.get(r);if(o)var u=o.get(null);else{o=new Map,Su.set(r,o);for(var p=r.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y<p.length;y++){var _=p[y];(_.nodeName==="LINK"||_.getAttribute("media")!=="not all")&&(o.set(_.dataset.precedence,_),u=_)}u&&o.set(null,u)}p=s.instance,_=p.getAttribute("data-precedence"),y=o.get(_)||u,y===u&&o.set(null,p),o.set(_,p),this.count++,u=_u.bind(this),p.addEventListener("load",u),p.addEventListener("error",u),y?y.parentNode.insertBefore(p,y.nextSibling):(r=r.nodeType===9?r.head:r,r.insertBefore(p,r.firstChild)),s.state.loading|=4}}var gl={$$typeof:T,Provider:null,Consumer:null,_currentValue:F,_currentValue2:F,_threadCount:0};function FA(r,s,o,u,p,y,_,j,D){this.tag=1,this.containerInfo=r,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=kt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=kt(0),this.hiddenUpdates=kt(null),this.identifierPrefix=u,this.onUncaughtError=p,this.onCaughtError=y,this.onRecoverableError=_,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=D,this.incompleteTransitions=new Map}function Hx(r,s,o,u,p,y,_,j,D,W,ae,le){return r=new FA(r,s,o,_,D,W,ae,le,j),s=1,y===!0&&(s|=24),y=$n(3,null,null,s),r.current=y,y.stateNode=r,s=Th(),s.refCount++,r.pooledCache=s,s.refCount++,y.memoizedState={element:u,isDehydrated:o,cache:s},Oh(y),r}function qx(r){return r?(r=yi,r):yi}function Vx(r,s,o,u,p,y){p=qx(p),u.context===null?u.context=p:u.pendingContext=p,u=ka(s),u.payload={element:o},y=y===void 0?null:y,y!==null&&(u.callback=y),o=Oa(r,u,s),o!==null&&(kn(o,r,s),Wo(o,r,s))}function Fx(r,s){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var o=r.retryLane;r.retryLane=o!==0&&o<s?o:s}}function Xm(r,s){Fx(r,s),(r=r.alternate)&&Fx(r,s)}function Gx(r){if(r.tag===13||r.tag===31){var s=xs(r,67108864);s!==null&&kn(s,r,67108864),Xm(r,67108864)}}function Kx(r){if(r.tag===13||r.tag===31){var s=Vn();s=ai(s);var o=xs(r,s);o!==null&&kn(o,r,s),Xm(r,s)}}var Nu=!0;function GA(r,s,o,u){var p=k.T;k.T=null;var y=K.p;try{K.p=2,Jm(r,s,o,u)}finally{K.p=y,k.T=p}}function KA(r,s,o,u){var p=k.T;k.T=null;var y=K.p;try{K.p=8,Jm(r,s,o,u)}finally{K.p=y,k.T=p}}function Jm(r,s,o,u){if(Nu){var p=Qm(u);if(p===null)zm(r,s,u,Cu,o),Yx(r,u);else if(YA(p,r,s,o,u))u.stopPropagation();else if(Yx(r,u),s&4&&-1<WA.indexOf(r)){for(;p!==null;){var y=oi(p);if(y!==null)switch(y.tag){case 3:if(y=y.stateNode,y.current.memoizedState.isDehydrated){var _=rt(y.pendingLanes);if(_!==0){var j=y;for(j.pendingLanes|=2,j.entangledLanes|=2;_;){var D=1<<31-Dt(_);j.entanglements[1]|=D,_&=~D}Ar(y),(vt&6)===0&&(lu=Le()+500,ul(0))}}break;case 31:case 13:j=xs(y,2),j!==null&&kn(j,y,2),uu(),Xm(y,2)}if(y=Qm(u),y===null&&zm(r,s,u,Cu,o),y===p)break;p=y}p!==null&&u.stopPropagation()}else zm(r,s,u,null,o)}}function Qm(r){return r=eh(r),Zm(r)}var Cu=null;function Zm(r){if(Cu=null,r=ii(r),r!==null){var s=l(r);if(s===null)r=null;else{var o=s.tag;if(o===13){if(r=c(s),r!==null)return r;r=null}else if(o===31){if(r=f(s),r!==null)return r;r=null}else if(o===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;r=null}else s!==r&&(r=null)}}return Cu=r,null}function Wx(r){switch(r){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(ue()){case qe:return 2;case gt:return 8;case Xt:case jt:return 32;case At:return 268435456;default:return 32}default:return 32}}var ep=!1,qa=null,Va=null,Fa=null,vl=new Map,yl=new Map,Ga=[],WA="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Yx(r,s){switch(r){case"focusin":case"focusout":qa=null;break;case"dragenter":case"dragleave":Va=null;break;case"mouseover":case"mouseout":Fa=null;break;case"pointerover":case"pointerout":vl.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":yl.delete(s.pointerId)}}function bl(r,s,o,u,p,y){return r===null||r.nativeEvent!==y?(r={blockedOn:s,domEventName:o,eventSystemFlags:u,nativeEvent:y,targetContainers:[p]},s!==null&&(s=oi(s),s!==null&&Gx(s)),r):(r.eventSystemFlags|=u,s=r.targetContainers,p!==null&&s.indexOf(p)===-1&&s.push(p),r)}function YA(r,s,o,u,p){switch(s){case"focusin":return qa=bl(qa,r,s,o,u,p),!0;case"dragenter":return Va=bl(Va,r,s,o,u,p),!0;case"mouseover":return Fa=bl(Fa,r,s,o,u,p),!0;case"pointerover":var y=p.pointerId;return vl.set(y,bl(vl.get(y)||null,r,s,o,u,p)),!0;case"gotpointercapture":return y=p.pointerId,yl.set(y,bl(yl.get(y)||null,r,s,o,u,p)),!0}return!1}function Xx(r){var s=ii(r.target);if(s!==null){var o=l(s);if(o!==null){if(s=o.tag,s===13){if(s=c(o),s!==null){r.blockedOn=s,uy(r.priority,function(){Kx(o)});return}}else if(s===31){if(s=f(o),s!==null){r.blockedOn=s,uy(r.priority,function(){Kx(o)});return}}else if(s===3&&o.stateNode.current.memoizedState.isDehydrated){r.blockedOn=o.tag===3?o.stateNode.containerInfo:null;return}}}r.blockedOn=null}function ju(r){if(r.blockedOn!==null)return!1;for(var s=r.targetContainers;0<s.length;){var o=Qm(r.nativeEvent);if(o===null){o=r.nativeEvent;var u=new o.constructor(o.type,o);Zf=u,o.target.dispatchEvent(u),Zf=null}else return s=oi(o),s!==null&&Gx(s),r.blockedOn=o,!1;s.shift()}return!0}function Jx(r,s,o){ju(r)&&o.delete(s)}function XA(){ep=!1,qa!==null&&ju(qa)&&(qa=null),Va!==null&&ju(Va)&&(Va=null),Fa!==null&&ju(Fa)&&(Fa=null),vl.forEach(Jx),yl.forEach(Jx)}function Tu(r,s){r.blockedOn===s&&(r.blockedOn=null,ep||(ep=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,XA)))}var Ru=null;function Qx(r){Ru!==r&&(Ru=r,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Ru===r&&(Ru=null);for(var s=0;s<r.length;s+=3){var o=r[s],u=r[s+1],p=r[s+2];if(typeof u!="function"){if(Zm(u||o)===null)continue;break}var y=oi(o);y!==null&&(r.splice(s,3),s-=3,Qh(y,{pending:!0,data:p,method:o.method,action:u},u,p))}}))}function Hi(r){function s(D){return Tu(D,r)}qa!==null&&Tu(qa,r),Va!==null&&Tu(Va,r),Fa!==null&&Tu(Fa,r),vl.forEach(s),yl.forEach(s);for(var o=0;o<Ga.length;o++){var u=Ga[o];u.blockedOn===r&&(u.blockedOn=null)}for(;0<Ga.length&&(o=Ga[0],o.blockedOn===null);)Xx(o),o.blockedOn===null&&Ga.shift();if(o=(r.ownerDocument||r).$$reactFormReplay,o!=null)for(u=0;u<o.length;u+=3){var p=o[u],y=o[u+1],_=p[Nn]||null;if(typeof y=="function")_||Qx(o);else if(_){var j=null;if(y&&y.hasAttribute("formAction")){if(p=y,_=y[Nn]||null)j=_.formAction;else if(Zm(p)!==null)continue}else j=_.action;typeof j=="function"?o[u+1]=j:(o.splice(u,3),u-=3),Qx(o)}}}function Zx(){function r(y){y.canIntercept&&y.info==="react-transition"&&y.intercept({handler:function(){return new Promise(function(_){return p=_})},focusReset:"manual",scroll:"manual"})}function s(){p!==null&&(p(),p=null),u||setTimeout(o,20)}function o(){if(!u&&!navigation.transition){var y=navigation.currentEntry;y&&y.url!=null&&navigation.navigate(y.url,{state:y.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var u=!1,p=null;return navigation.addEventListener("navigate",r),navigation.addEventListener("navigatesuccess",s),navigation.addEventListener("navigateerror",s),setTimeout(o,100),function(){u=!0,navigation.removeEventListener("navigate",r),navigation.removeEventListener("navigatesuccess",s),navigation.removeEventListener("navigateerror",s),p!==null&&(p(),p=null)}}}function tp(r){this._internalRoot=r}Au.prototype.render=tp.prototype.render=function(r){var s=this._internalRoot;if(s===null)throw Error(a(409));var o=s.current,u=Vn();Vx(o,u,r,s,null,null)},Au.prototype.unmount=tp.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var s=r.containerInfo;Vx(r.current,2,null,r,null,null),uu(),s[si]=null}};function Au(r){this._internalRoot=r}Au.prototype.unstable_scheduleHydration=function(r){if(r){var s=Gf();r={blockedOn:null,target:r,priority:s};for(var o=0;o<Ga.length&&s!==0&&s<Ga[o].priority;o++);Ga.splice(o,0,r),o===0&&Xx(r)}};var ew=t.version;if(ew!=="19.2.6")throw Error(a(527,ew,"19.2.6"));K.findDOMNode=function(r){var s=r._reactInternals;if(s===void 0)throw typeof r.render=="function"?Error(a(188)):(r=Object.keys(r).join(","),Error(a(268,r)));return r=m(s),r=r!==null?b(r):null,r=r===null?null:r.stateNode,r};var JA={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:k,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var ku=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ku.isDisabled&&ku.supportsFiber)try{vn=ku.inject(JA),Mt=ku}catch{}}return wl.createRoot=function(r,s){if(!i(r))throw Error(a(299));var o=!1,u="",p=o0,y=l0,_=c0;return s!=null&&(s.unstable_strictMode===!0&&(o=!0),s.identifierPrefix!==void 0&&(u=s.identifierPrefix),s.onUncaughtError!==void 0&&(p=s.onUncaughtError),s.onCaughtError!==void 0&&(y=s.onCaughtError),s.onRecoverableError!==void 0&&(_=s.onRecoverableError)),s=Hx(r,1,!1,null,null,o,u,null,p,y,_,Zx),r[si]=s.current,Lm(r),new tp(s)},wl.hydrateRoot=function(r,s,o){if(!i(r))throw Error(a(299));var u=!1,p="",y=o0,_=l0,j=c0,D=null;return o!=null&&(o.unstable_strictMode===!0&&(u=!0),o.identifierPrefix!==void 0&&(p=o.identifierPrefix),o.onUncaughtError!==void 0&&(y=o.onUncaughtError),o.onCaughtError!==void 0&&(_=o.onCaughtError),o.onRecoverableError!==void 0&&(j=o.onRecoverableError),o.formState!==void 0&&(D=o.formState)),s=Hx(r,1,!0,s,o??null,u,p,D,y,_,j,Zx),s.context=qx(null),o=s.current,u=Vn(),u=ai(u),p=ka(u),p.callback=null,Oa(o,p,u),o=u,s.current.lanes=o,ht(s,o),Ar(s),r[si]=s.current,Lm(r),new Au(s)},wl.version="19.2.6",wl}var uw;function ok(){if(uw)return ap.exports;uw=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),ap.exports=ik(),ap.exports}var lk=ok();/**
* react-router v7.15.1
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/var dw="popstate";function fw(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function ck(e={}){function t(a,i){var m;let l=(m=i.state)==null?void 0:m.masked,{pathname:c,search:f,hash:h}=l||a.location;return Xp("",{pathname:c,search:f,hash:h},i.state&&i.state.usr||null,i.state&&i.state.key||"default",l?{pathname:a.location.pathname,search:a.location.search,hash:a.location.hash}:void 0)}function n(a,i){return typeof i=="string"?i:Bl(i)}return dk(t,n,null,e)}function Pt(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Br(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function uk(){return Math.random().toString(36).substring(2,10)}function hw(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Xp(e,t,n=null,a,i){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?So(t):t,state:n,key:t&&t.key||a||uk(),mask:i}}function Bl({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function So(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let a=e.indexOf("?");a>=0&&(t.search=e.substring(a),e=e.substring(0,a)),e&&(t.pathname=e)}return t}function dk(e,t,n,a={}){let{window:i=document.defaultView,v5Compat:l=!1}=a,c=i.history,f="POP",h=null,m=b();m==null&&(m=0,c.replaceState({...c.state,idx:m},""));function b(){return(c.state||{idx:null}).idx}function g(){f="POP";let C=b(),N=C==null?null:C-m;m=C,h&&h({action:f,location:S.location,delta:N})}function x(C,N){f="PUSH";let A=fw(C)?C:Xp(S.location,C,N);m=b()+1;let T=hw(A,m),M=S.createHref(A.mask||A);try{c.pushState(T,"",M)}catch($){if($ instanceof DOMException&&$.name==="DataCloneError")throw $;i.location.assign(M)}l&&h&&h({action:f,location:S.location,delta:1})}function w(C,N){f="REPLACE";let A=fw(C)?C:Xp(S.location,C,N);m=b();let T=hw(A,m),M=S.createHref(A.mask||A);c.replaceState(T,"",M),l&&h&&h({action:f,location:S.location,delta:0})}function E(C){return fk(C)}let S={get action(){return f},get location(){return e(i,c)},listen(C){if(h)throw new Error("A history only accepts one active listener");return i.addEventListener(dw,g),h=C,()=>{i.removeEventListener(dw,g),h=null}},createHref(C){return t(i,C)},createURL:E,encodeLocation(C){let N=E(C);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:x,replace:w,go(C){return c.go(C)}};return S}function fk(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Pt(n,"No window.location.(origin|href) available to create URL");let a=typeof e=="string"?e:Bl(e);return a=a.replace(/ $/,"%20"),!t&&a.startsWith("//")&&(a=n+a),new URL(a,n)}function _S(e,t,n="/"){return hk(e,t,n,!1)}function hk(e,t,n,a,i){let l=typeof t=="string"?So(t):t,c=pa(l.pathname||"/",n);if(c==null)return null;let f=mk(e),h=null,m=Ck(c);for(let b=0;h==null&&b<f.length;++b)h=Ek(f[b],m,a);return h}function mk(e){let t=SS(e);return pk(t),t}function SS(e,t=[],n=[],a="",i=!1){let l=(c,f,h=i,m)=>{let b={relativePath:m===void 0?c.path||"":m,caseSensitive:c.caseSensitive===!0,childrenIndex:f,route:c};if(b.relativePath.startsWith("/")){if(!b.relativePath.startsWith(a)&&h)return;Pt(b.relativePath.startsWith(a),`Absolute route path "${b.relativePath}" nested under path "${a}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),b.relativePath=b.relativePath.slice(a.length)}let g=Sr([a,b.relativePath]),x=n.concat(b);c.children&&c.children.length>0&&(Pt(c.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${g}".`),SS(c.children,t,x,g,h)),!(c.path==null&&!c.index)&&t.push({path:g,score:_k(g,c.index),routesMeta:x})};return e.forEach((c,f)=>{var h;if(c.path===""||!((h=c.path)!=null&&h.includes("?")))l(c,f);else for(let m of ES(c.path))l(c,f,!0,m)}),t}function ES(e){let t=e.split("/");if(t.length===0)return[];let[n,...a]=t,i=n.endsWith("?"),l=n.replace(/\?$/,"");if(a.length===0)return i?[l,""]:[l];let c=ES(a.join("/")),f=[];return f.push(...c.map(h=>h===""?l:[l,h].join("/"))),i&&f.push(...c),f.map(h=>e.startsWith("/")&&h===""?"/":h)}function pk(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Sk(t.routesMeta.map(a=>a.childrenIndex),n.routesMeta.map(a=>a.childrenIndex)))}var gk=/^:[\w-]+$/,vk=3,yk=2,bk=1,xk=10,wk=-2,mw=e=>e==="*";function _k(e,t){let n=e.split("/"),a=n.length;return n.some(mw)&&(a+=wk),t&&(a+=yk),n.filter(i=>!mw(i)).reduce((i,l)=>i+(gk.test(l)?vk:l===""?bk:xk),a)}function Sk(e,t){return e.length===t.length&&e.slice(0,-1).every((a,i)=>a===t[i])?e[e.length-1]-t[t.length-1]:0}function Ek(e,t,n=!1){let{routesMeta:a}=e,i={},l="/",c=[];for(let f=0;f<a.length;++f){let h=a[f],m=f===a.length-1,b=l==="/"?t:t.slice(l.length)||"/",g=Nd({path:h.relativePath,caseSensitive:h.caseSensitive,end:m},b),x=h.route;if(!g&&m&&n&&!a[a.length-1].route.index&&(g=Nd({path:h.relativePath,caseSensitive:h.caseSensitive,end:!1},b)),!g)return null;Object.assign(i,g.params),c.push({params:i,pathname:Sr([l,g.pathname]),pathnameBase:Ak(Sr([l,g.pathnameBase])),route:x}),g.pathnameBase!=="/"&&(l=Sr([l,g.pathnameBase]))}return c}function Nd(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,a]=Nk(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let l=i[0],c=l.replace(/(.)\/+$/,"$1"),f=i.slice(1);return{params:a.reduce((m,{paramName:b,isOptional:g},x)=>{if(b==="*"){let E=f[x]||"";c=l.slice(0,l.length-E.length).replace(/(.)\/+$/,"$1")}const w=f[x];return g&&!w?m[b]=void 0:m[b]=(w||"").replace(/%2F/g,"/"),m},{}),pathname:l,pathnameBase:c,pattern:e}}function Nk(e,t=!1,n=!0){Br(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let a=[],i="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(c,f,h,m,b)=>{if(a.push({paramName:f,isOptional:h!=null}),h){let g=b.charAt(m+c.length);return g&&g!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(a.push({paramName:"*"}),i+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":e!==""&&e!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,t?void 0:"i"),a]}function Ck(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Br(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function pa(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,a=e.charAt(n);return a&&a!=="/"?null:e.slice(n)||"/"}var jk=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Tk(e,t="/"){let{pathname:n,search:a="",hash:i=""}=typeof e=="string"?So(e):e,l;return n?(n=CS(n),n.startsWith("/")?l=pw(n.substring(1),"/"):l=pw(n,t)):l=t,{pathname:l,search:kk(a),hash:Ok(i)}}function pw(e,t){let n=Cd(t).split("/");return e.split("/").forEach(i=>{i===".."?n.length>1&&n.pop():i!=="."&&n.push(i)}),n.length>1?n.join("/"):"/"}function lp(e,t,n,a){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(a)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Rk(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function NS(e){let t=Rk(e);return t.map((n,a)=>a===t.length-1?n.pathname:n.pathnameBase)}function Fg(e,t,n,a=!1){let i;typeof e=="string"?i=So(e):(i={...e},Pt(!i.pathname||!i.pathname.includes("?"),lp("?","pathname","search",i)),Pt(!i.pathname||!i.pathname.includes("#"),lp("#","pathname","hash",i)),Pt(!i.search||!i.search.includes("#"),lp("#","search","hash",i)));let l=e===""||i.pathname==="",c=l?"/":i.pathname,f;if(c==null)f=n;else{let g=t.length-1;if(!a&&c.startsWith("..")){let x=c.split("/");for(;x[0]==="..";)x.shift(),g-=1;i.pathname=x.join("/")}f=g>=0?t[g]:"/"}let h=Tk(i,f),m=c&&c!=="/"&&c.endsWith("/"),b=(l||c===".")&&n.endsWith("/");return!h.pathname.endsWith("/")&&(m||b)&&(h.pathname+="/"),h}var CS=e=>e.replace(/\/\/+/g,"/"),Sr=e=>CS(e.join("/")),Cd=e=>e.replace(/\/+$/,""),Ak=e=>Cd(e).replace(/^\/*/,"/"),kk=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Ok=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Mk=class{constructor(e,t,n,a=!1){this.status=e,this.statusText=t||"",this.internal=a,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Dk(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Pk(e){let t=e.map(n=>n.route.path).filter(Boolean);return Sr(t)||"/"}var jS=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function TS(e,t){let n=e;if(typeof n!="string"||!jk.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let a=n,i=!1;if(jS)try{let l=new URL(window.location.href),c=n.startsWith("//")?new URL(l.protocol+n):new URL(n),f=pa(c.pathname,t);c.origin===l.origin&&f!=null?n=f+c.search+c.hash:i=!0}catch{Br(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:a,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var RS=["POST","PUT","PATCH","DELETE"];new Set(RS);var Lk=["GET",...RS];new Set(Lk);var Eo=v.createContext(null);Eo.displayName="DataRouter";var af=v.createContext(null);af.displayName="DataRouterState";var AS=v.createContext(!1);function zk(){return v.useContext(AS)}var kS=v.createContext({isTransitioning:!1});kS.displayName="ViewTransition";var Ik=v.createContext(new Map);Ik.displayName="Fetchers";var $k=v.createContext(null);$k.displayName="Await";var cr=v.createContext(null);cr.displayName="Navigation";var tc=v.createContext(null);tc.displayName="Location";var xa=v.createContext({outlet:null,matches:[],isDataRoute:!1});xa.displayName="Route";var Gg=v.createContext(null);Gg.displayName="RouteError";var OS="REACT_ROUTER_ERROR",Uk="REDIRECT",Bk="ROUTE_ERROR_RESPONSE";function Hk(e){if(e.startsWith(`${OS}:${Uk}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function qk(e){if(e.startsWith(`${OS}:${Bk}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Mk(t.status,t.statusText,t.data)}catch{}}function Vk(e,{relative:t}={}){Pt(nc(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:a}=v.useContext(cr),{hash:i,pathname:l,search:c}=rc(e,{relative:t}),f=l;return n!=="/"&&(f=l==="/"?n:Sr([n,l])),a.createHref({pathname:f,search:c,hash:i})}function nc(){return v.useContext(tc)!=null}function wa(){return Pt(nc(),"useLocation() may be used only in the context of a <Router> component."),v.useContext(tc).location}var MS="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function DS(e){v.useContext(cr).static||v.useLayoutEffect(e)}function Fk(){let{isDataRoute:e}=v.useContext(xa);return e?a2():Gk()}function Gk(){Pt(nc(),"useNavigate() may be used only in the context of a <Router> component.");let e=v.useContext(Eo),{basename:t,navigator:n}=v.useContext(cr),{matches:a}=v.useContext(xa),{pathname:i}=wa(),l=JSON.stringify(NS(a)),c=v.useRef(!1);return DS(()=>{c.current=!0}),v.useCallback((h,m={})=>{if(Br(c.current,MS),!c.current)return;if(typeof h=="number"){n.go(h);return}let b=Fg(h,JSON.parse(l),i,m.relative==="path");e==null&&t!=="/"&&(b.pathname=b.pathname==="/"?t:Sr([t,b.pathname])),(m.replace?n.replace:n.push)(b,m.state,m)},[t,n,l,i,e])}v.createContext(null);function rc(e,{relative:t}={}){let{matches:n}=v.useContext(xa),{pathname:a}=wa(),i=JSON.stringify(NS(n));return v.useMemo(()=>Fg(e,JSON.parse(i),a,t==="path"),[e,i,a,t])}function Kk(e,t){return PS(e,t)}function PS(e,t,n){var C;Pt(nc(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=v.useContext(cr),{matches:i}=v.useContext(xa),l=i[i.length-1],c=l?l.params:{},f=l?l.pathname:"/",h=l?l.pathnameBase:"/",m=l&&l.route;{let N=m&&m.path||"";zS(f,!m||N.endsWith("*")||N.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${f}" (under <Route path="${N}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
Please change the parent <Route path="${N}"> to <Route path="${N==="/"?"*":`${N}/*`}">.`)}let b=wa(),g;if(t){let N=typeof t=="string"?So(t):t;Pt(h==="/"||((C=N.pathname)==null?void 0:C.startsWith(h)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${h}" but pathname "${N.pathname}" was given in the \`location\` prop.`),g=N}else g=b;let x=g.pathname||"/",w=x;if(h!=="/"){let N=h.replace(/^\//,"").split("/");w="/"+x.replace(/^\//,"").split("/").slice(N.length).join("/")}let E=n&&n.state.matches.length?n.state.matches.map(N=>Object.assign(N,{route:n.manifest[N.route.id]||N.route})):_S(e,{pathname:w});Br(m||E!=null,`No routes matched location "${g.pathname}${g.search}${g.hash}" `),Br(E==null||E[E.length-1].route.element!==void 0||E[E.length-1].route.Component!==void 0||E[E.length-1].route.lazy!==void 0,`Matched leaf route at location "${g.pathname}${g.search}${g.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let S=Qk(E&&E.map(N=>Object.assign({},N,{params:Object.assign({},c,N.params),pathname:Sr([h,a.encodeLocation?a.encodeLocation(N.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:N.pathname]),pathnameBase:N.pathnameBase==="/"?h:Sr([h,a.encodeLocation?a.encodeLocation(N.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:N.pathnameBase])})),i,n);return t&&S?v.createElement(tc.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...g},navigationType:"POP"}},S):S}function Wk(){let e=r2(),t=Dk(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,a="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:a},l={padding:"2px 4px",backgroundColor:a},c=null;return console.error("Error handled by React Router default ErrorBoundary:",e),c=v.createElement(v.Fragment,null,v.createElement("p",null,"💿 Hey developer 👋"),v.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",v.createElement("code",{style:l},"ErrorBoundary")," or"," ",v.createElement("code",{style:l},"errorElement")," prop on your route.")),v.createElement(v.Fragment,null,v.createElement("h2",null,"Unexpected Application Error!"),v.createElement("h3",{style:{fontStyle:"italic"}},t),n?v.createElement("pre",{style:i},n):null,c)}var Yk=v.createElement(Wk,null),LS=class extends v.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=qk(e.digest);n&&(e=n)}let t=e!==void 0?v.createElement(xa.Provider,{value:this.props.routeContext},v.createElement(Gg.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?v.createElement(Xk,{error:e},t):t}};LS.contextType=AS;var cp=new WeakMap;function Xk({children:e,error:t}){let{basename:n}=v.useContext(cr);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let a=Hk(t.digest);if(a){let i=cp.get(t);if(i)throw i;let l=TS(a.location,n);if(jS&&!cp.get(t))if(l.isExternal||a.reloadDocument)window.location.href=l.absoluteURL||l.to;else{const c=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(l.to,{replace:a.replace}));throw cp.set(t,c),c}return v.createElement("meta",{httpEquiv:"refresh",content:`0;url=${l.absoluteURL||l.to}`})}}return e}function Jk({routeContext:e,match:t,children:n}){let a=v.useContext(Eo);return a&&a.static&&a.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=t.route.id),v.createElement(xa.Provider,{value:e},n)}function Qk(e,t=[],n){let a=n==null?void 0:n.state;if(e==null){if(!a)return null;if(a.errors)e=a.matches;else if(t.length===0&&!a.initialized&&a.matches.length>0)e=a.matches;else return null}let i=e,l=a==null?void 0:a.errors;if(l!=null){let b=i.findIndex(g=>g.route.id&&(l==null?void 0:l[g.route.id])!==void 0);Pt(b>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(l).join(",")}`),i=i.slice(0,Math.min(i.length,b+1))}let c=!1,f=-1;if(n&&a){c=a.renderFallback;for(let b=0;b<i.length;b++){let g=i[b];if((g.route.HydrateFallback||g.route.hydrateFallbackElement)&&(f=b),g.route.id){let{loaderData:x,errors:w}=a,E=g.route.loader&&!x.hasOwnProperty(g.route.id)&&(!w||w[g.route.id]===void 0);if(g.route.lazy||E){n.isStatic&&(c=!0),f>=0?i=i.slice(0,f+1):i=[i[0]];break}}}}let h=n==null?void 0:n.onError,m=a&&h?(b,g)=>{var x,w;h(b,{location:a.location,params:((w=(x=a.matches)==null?void 0:x[0])==null?void 0:w.params)??{},pattern:Pk(a.matches),errorInfo:g})}:void 0;return i.reduceRight((b,g,x)=>{let w,E=!1,S=null,C=null;a&&(w=l&&g.route.id?l[g.route.id]:void 0,S=g.route.errorElement||Yk,c&&(f<0&&x===0?(zS("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),E=!0,C=null):f===x&&(E=!0,C=g.route.hydrateFallbackElement||null)));let N=t.concat(i.slice(0,x+1)),A=()=>{let T;return w?T=S:E?T=C:g.route.Component?T=v.createElement(g.route.Component,null):g.route.element?T=g.route.element:T=b,v.createElement(Jk,{match:g,routeContext:{outlet:b,matches:N,isDataRoute:a!=null},children:T})};return a&&(g.route.ErrorBoundary||g.route.errorElement||x===0)?v.createElement(LS,{location:a.location,revalidation:a.revalidation,component:S,error:w,children:A(),routeContext:{outlet:null,matches:N,isDataRoute:!0},onError:m}):A()},null)}function Kg(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Zk(e){let t=v.useContext(Eo);return Pt(t,Kg(e)),t}function e2(e){let t=v.useContext(af);return Pt(t,Kg(e)),t}function t2(e){let t=v.useContext(xa);return Pt(t,Kg(e)),t}function Wg(e){let t=t2(e),n=t.matches[t.matches.length-1];return Pt(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function n2(){return Wg("useRouteId")}function r2(){var a;let e=v.useContext(Gg),t=e2("useRouteError"),n=Wg("useRouteError");return e!==void 0?e:(a=t.errors)==null?void 0:a[n]}function a2(){let{router:e}=Zk("useNavigate"),t=Wg("useNavigate"),n=v.useRef(!1);return DS(()=>{n.current=!0}),v.useCallback(async(i,l={})=>{Br(n.current,MS),n.current&&(typeof i=="number"?await e.navigate(i):await e.navigate(i,{fromRouteId:t,...l}))},[e,t])}var gw={};function zS(e,t,n){!t&&!gw[e]&&(gw[e]=!0,Br(!1,n))}v.memo(s2);function s2({routes:e,manifest:t,future:n,state:a,isStatic:i,onError:l}){return PS(e,void 0,{manifest:t,state:a,isStatic:i,onError:l})}function IS(e){Pt(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function i2({basename:e="/",children:t=null,location:n,navigationType:a="POP",navigator:i,static:l=!1,useTransitions:c}){Pt(!nc(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let f=e.replace(/^\/*/,"/"),h=v.useMemo(()=>({basename:f,navigator:i,static:l,useTransitions:c,future:{}}),[f,i,l,c]);typeof n=="string"&&(n=So(n));let{pathname:m="/",search:b="",hash:g="",state:x=null,key:w="default",mask:E}=n,S=v.useMemo(()=>{let C=pa(m,f);return C==null?null:{location:{pathname:C,search:b,hash:g,state:x,key:w,mask:E},navigationType:a}},[f,m,b,g,x,w,a,E]);return Br(S!=null,`<Router basename="${f}"> is not able to match the URL "${m}${b}${g}" because it does not start with the basename, so the <Router> won't render anything.`),S==null?null:v.createElement(cr.Provider,{value:h},v.createElement(tc.Provider,{children:t,value:S}))}function o2({children:e,location:t}){return Kk(Jp(e),t)}function Jp(e,t=[]){let n=[];return v.Children.forEach(e,(a,i)=>{if(!v.isValidElement(a))return;let l=[...t,i];if(a.type===v.Fragment){n.push.apply(n,Jp(a.props.children,l));return}Pt(a.type===IS,`[${typeof a.type=="string"?a.type:a.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Pt(!a.props.index||!a.props.children,"An index route cannot have child routes.");let c={id:a.props.id||l.join("-"),caseSensitive:a.props.caseSensitive,element:a.props.element,Component:a.props.Component,index:a.props.index,path:a.props.path,middleware:a.props.middleware,loader:a.props.loader,action:a.props.action,hydrateFallbackElement:a.props.hydrateFallbackElement,HydrateFallback:a.props.HydrateFallback,errorElement:a.props.errorElement,ErrorBoundary:a.props.ErrorBoundary,hasErrorBoundary:a.props.hasErrorBoundary===!0||a.props.ErrorBoundary!=null||a.props.errorElement!=null,shouldRevalidate:a.props.shouldRevalidate,handle:a.props.handle,lazy:a.props.lazy};a.props.children&&(c.children=Jp(a.props.children,l)),n.push(c)}),n}var hd="get",md="application/x-www-form-urlencoded";function sf(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function l2(e){return sf(e)&&e.tagName.toLowerCase()==="button"}function c2(e){return sf(e)&&e.tagName.toLowerCase()==="form"}function u2(e){return sf(e)&&e.tagName.toLowerCase()==="input"}function d2(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function f2(e,t){return e.button===0&&(!t||t==="_self")&&!d2(e)}var Ou=null;function h2(){if(Ou===null)try{new FormData(document.createElement("form"),0),Ou=!1}catch{Ou=!0}return Ou}var m2=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function up(e){return e!=null&&!m2.has(e)?(Br(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${md}"`),null):e}function p2(e,t){let n,a,i,l,c;if(c2(e)){let f=e.getAttribute("action");a=f?pa(f,t):null,n=e.getAttribute("method")||hd,i=up(e.getAttribute("enctype"))||md,l=new FormData(e)}else if(l2(e)||u2(e)&&(e.type==="submit"||e.type==="image")){let f=e.form;if(f==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let h=e.getAttribute("formaction")||f.getAttribute("action");if(a=h?pa(h,t):null,n=e.getAttribute("formmethod")||f.getAttribute("method")||hd,i=up(e.getAttribute("formenctype"))||up(f.getAttribute("enctype"))||md,l=new FormData(f,e),!h2()){let{name:m,type:b,value:g}=e;if(b==="image"){let x=m?`${m}.`:"";l.append(`${x}x`,"0"),l.append(`${x}y`,"0")}else m&&l.append(m,g)}}else{if(sf(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=hd,a=null,i=md,c=e}return l&&i==="text/plain"&&(c=l,l=void 0),{action:a,method:n.toLowerCase(),encType:i,formData:l,body:c}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Yg(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function $S(e,t,n,a){let i=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?i.pathname.endsWith("/")?i.pathname=`${i.pathname}_.${a}`:i.pathname=`${i.pathname}.${a}`:i.pathname==="/"?i.pathname=`_root.${a}`:t&&pa(i.pathname,t)==="/"?i.pathname=`${Cd(t)}/_root.${a}`:i.pathname=`${Cd(i.pathname)}.${a}`,i}async function g2(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function v2(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function y2(e,t,n){let a=await Promise.all(e.map(async i=>{let l=t.routes[i.route.id];if(l){let c=await g2(l,n);return c.links?c.links():[]}return[]}));return _2(a.flat(1).filter(v2).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function vw(e,t,n,a,i,l){let c=(h,m)=>n[m]?h.route.id!==n[m].route.id:!0,f=(h,m)=>{var b;return n[m].pathname!==h.pathname||((b=n[m].route.path)==null?void 0:b.endsWith("*"))&&n[m].params["*"]!==h.params["*"]};return l==="assets"?t.filter((h,m)=>c(h,m)||f(h,m)):l==="data"?t.filter((h,m)=>{var g;let b=a.routes[h.route.id];if(!b||!b.hasLoader)return!1;if(c(h,m)||f(h,m))return!0;if(h.route.shouldRevalidate){let x=h.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:((g=n[0])==null?void 0:g.params)||{},nextUrl:new URL(e,window.origin),nextParams:h.params,defaultShouldRevalidate:!0});if(typeof x=="boolean")return x}return!0}):[]}function b2(e,t,{includeHydrateFallback:n}={}){return x2(e.map(a=>{let i=t.routes[a.route.id];if(!i)return[];let l=[i.module];return i.clientActionModule&&(l=l.concat(i.clientActionModule)),i.clientLoaderModule&&(l=l.concat(i.clientLoaderModule)),n&&i.hydrateFallbackModule&&(l=l.concat(i.hydrateFallbackModule)),i.imports&&(l=l.concat(i.imports)),l}).flat(1))}function x2(e){return[...new Set(e)]}function w2(e){let t={},n=Object.keys(e).sort();for(let a of n)t[a]=e[a];return t}function _2(e,t){let n=new Set;return new Set(t),e.reduce((a,i)=>{let l=JSON.stringify(w2(i));return n.has(l)||(n.add(l),a.push({key:l,link:i})),a},[])}function Xg(){let e=v.useContext(Eo);return Yg(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function S2(){let e=v.useContext(af);return Yg(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Jg=v.createContext(void 0);Jg.displayName="FrameworkContext";function Qg(){let e=v.useContext(Jg);return Yg(e,"You must render this element inside a <HydratedRouter> element"),e}function E2(e,t){let n=v.useContext(Jg),[a,i]=v.useState(!1),[l,c]=v.useState(!1),{onFocus:f,onBlur:h,onMouseEnter:m,onMouseLeave:b,onTouchStart:g}=t,x=v.useRef(null);v.useEffect(()=>{if(e==="render"&&c(!0),e==="viewport"){let S=N=>{N.forEach(A=>{c(A.isIntersecting)})},C=new IntersectionObserver(S,{threshold:.5});return x.current&&C.observe(x.current),()=>{C.disconnect()}}},[e]),v.useEffect(()=>{if(a){let S=setTimeout(()=>{c(!0)},100);return()=>{clearTimeout(S)}}},[a]);let w=()=>{i(!0)},E=()=>{i(!1),c(!1)};return n?e!=="intent"?[l,x,{}]:[l,x,{onFocus:_l(f,w),onBlur:_l(h,E),onMouseEnter:_l(m,w),onMouseLeave:_l(b,E),onTouchStart:_l(g,w)}]:[!1,x,{}]}function _l(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function N2({page:e,...t}){let n=zk(),{router:a}=Xg(),i=v.useMemo(()=>_S(a.routes,e,a.basename),[a.routes,e,a.basename]);return i?n?v.createElement(j2,{page:e,matches:i,...t}):v.createElement(T2,{page:e,matches:i,...t}):null}function C2(e){let{manifest:t,routeModules:n}=Qg(),[a,i]=v.useState([]);return v.useEffect(()=>{let l=!1;return y2(e,t,n).then(c=>{l||i(c)}),()=>{l=!0}},[e,t,n]),a}function j2({page:e,matches:t,...n}){let a=wa(),{future:i}=Qg(),{basename:l}=Xg(),c=v.useMemo(()=>{if(e===a.pathname+a.search+a.hash)return[];let f=$S(e,l,i.unstable_trailingSlashAwareDataRequests,"rsc"),h=!1,m=[];for(let b of t)typeof b.route.shouldRevalidate=="function"?h=!0:m.push(b.route.id);return h&&m.length>0&&f.searchParams.set("_routes",m.join(",")),[f.pathname+f.search]},[l,i.unstable_trailingSlashAwareDataRequests,e,a,t]);return v.createElement(v.Fragment,null,c.map(f=>v.createElement("link",{key:f,rel:"prefetch",as:"fetch",href:f,...n})))}function T2({page:e,matches:t,...n}){let a=wa(),{future:i,manifest:l,routeModules:c}=Qg(),{basename:f}=Xg(),{loaderData:h,matches:m}=S2(),b=v.useMemo(()=>vw(e,t,m,l,a,"data"),[e,t,m,l,a]),g=v.useMemo(()=>vw(e,t,m,l,a,"assets"),[e,t,m,l,a]),x=v.useMemo(()=>{if(e===a.pathname+a.search+a.hash)return[];let S=new Set,C=!1;if(t.forEach(A=>{var M;let T=l.routes[A.route.id];!T||!T.hasLoader||(!b.some($=>$.route.id===A.route.id)&&A.route.id in h&&((M=c[A.route.id])!=null&&M.shouldRevalidate)||T.hasClientLoader?C=!0:S.add(A.route.id))}),S.size===0)return[];let N=$S(e,f,i.unstable_trailingSlashAwareDataRequests,"data");return C&&S.size>0&&N.searchParams.set("_routes",t.filter(A=>S.has(A.route.id)).map(A=>A.route.id).join(",")),[N.pathname+N.search]},[f,i.unstable_trailingSlashAwareDataRequests,h,a,l,b,t,e,c]),w=v.useMemo(()=>b2(g,l),[g,l]),E=C2(g);return v.createElement(v.Fragment,null,x.map(S=>v.createElement("link",{key:S,rel:"prefetch",as:"fetch",href:S,...n})),w.map(S=>v.createElement("link",{key:S,rel:"modulepreload",href:S,...n})),E.map(({key:S,link:C})=>v.createElement("link",{key:S,nonce:n.nonce,...C,crossOrigin:C.crossOrigin??n.crossOrigin})))}function R2(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var A2=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{A2&&(window.__reactRouterVersion="7.15.1")}catch{}function k2({basename:e,children:t,useTransitions:n,window:a}){let i=v.useRef();i.current==null&&(i.current=ck({window:a,v5Compat:!0}));let l=i.current,[c,f]=v.useState({action:l.action,location:l.location}),h=v.useCallback(m=>{n===!1?f(m):v.startTransition(()=>f(m))},[n]);return v.useLayoutEffect(()=>l.listen(h),[l,h]),v.createElement(i2,{basename:e,children:t,location:c.location,navigationType:c.action,navigator:l,useTransitions:n})}var US=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,BS=v.forwardRef(function({onClick:t,discover:n="render",prefetch:a="none",relative:i,reloadDocument:l,replace:c,mask:f,state:h,target:m,to:b,preventScrollReset:g,viewTransition:x,defaultShouldRevalidate:w,...E},S){let{basename:C,navigator:N,useTransitions:A}=v.useContext(cr),T=typeof b=="string"&&US.test(b),M=TS(b,C);b=M.to;let $=Vk(b,{relative:i}),L=wa(),P=null;if(f){let de=Fg(f,[],L.mask?L.mask.pathname:"/",!0);C!=="/"&&(de.pathname=de.pathname==="/"?C:Sr([C,de.pathname])),P=N.createHref(de)}let[U,J,ce]=E2(a,E),re=P2(b,{replace:c,mask:f,state:h,target:m,preventScrollReset:g,relative:i,viewTransition:x,defaultShouldRevalidate:w,useTransitions:A});function me(de){t&&t(de),de.defaultPrevented||re(de)}let fe=!(M.isExternal||l),ge=v.createElement("a",{...E,...ce,href:(fe?P:void 0)||M.absoluteURL||$,onClick:fe?me:t,ref:R2(S,J),target:m,"data-discover":!T&&n==="render"?"true":void 0});return U&&!T?v.createElement(v.Fragment,null,ge,v.createElement(N2,{page:$})):ge});BS.displayName="Link";var O2=v.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:a="",end:i=!1,style:l,to:c,viewTransition:f,children:h,...m},b){let g=rc(c,{relative:m.relative}),x=wa(),w=v.useContext(af),{navigator:E,basename:S}=v.useContext(cr),C=w!=null&&U2(g)&&f===!0,N=E.encodeLocation?E.encodeLocation(g).pathname:g.pathname,A=x.pathname,T=w&&w.navigation&&w.navigation.location?w.navigation.location.pathname:null;n||(A=A.toLowerCase(),T=T?T.toLowerCase():null,N=N.toLowerCase()),T&&S&&(T=pa(T,S)||T);const M=N!=="/"&&N.endsWith("/")?N.length-1:N.length;let $=A===N||!i&&A.startsWith(N)&&A.charAt(M)==="/",L=T!=null&&(T===N||!i&&T.startsWith(N)&&T.charAt(N.length)==="/"),P={isActive:$,isPending:L,isTransitioning:C},U=$?t:void 0,J;typeof a=="function"?J=a(P):J=[a,$?"active":null,L?"pending":null,C?"transitioning":null].filter(Boolean).join(" ");let ce=typeof l=="function"?l(P):l;return v.createElement(BS,{...m,"aria-current":U,className:J,ref:b,style:ce,to:c,viewTransition:f},typeof h=="function"?h(P):h)});O2.displayName="NavLink";var M2=v.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:a,replace:i,state:l,method:c=hd,action:f,onSubmit:h,relative:m,preventScrollReset:b,viewTransition:g,defaultShouldRevalidate:x,...w},E)=>{let{useTransitions:S}=v.useContext(cr),C=I2(),N=$2(f,{relative:m}),A=c.toLowerCase()==="get"?"get":"post",T=typeof f=="string"&&US.test(f),M=$=>{if(h&&h($),$.defaultPrevented)return;$.preventDefault();let L=$.nativeEvent.submitter,P=(L==null?void 0:L.getAttribute("formmethod"))||c,U=()=>C(L||$.currentTarget,{fetcherKey:t,method:P,navigate:n,replace:i,state:l,relative:m,preventScrollReset:b,viewTransition:g,defaultShouldRevalidate:x});S&&n!==!1?v.startTransition(()=>U()):U()};return v.createElement("form",{ref:E,method:A,action:N,onSubmit:a?h:M,...w,"data-discover":!T&&e==="render"?"true":void 0})});M2.displayName="Form";function D2(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function HS(e){let t=v.useContext(Eo);return Pt(t,D2(e)),t}function P2(e,{target:t,replace:n,mask:a,state:i,preventScrollReset:l,relative:c,viewTransition:f,defaultShouldRevalidate:h,useTransitions:m}={}){let b=Fk(),g=wa(),x=rc(e,{relative:c});return v.useCallback(w=>{if(f2(w,t)){w.preventDefault();let E=n!==void 0?n:Bl(g)===Bl(x),S=()=>b(e,{replace:E,mask:a,state:i,preventScrollReset:l,relative:c,viewTransition:f,defaultShouldRevalidate:h});m?v.startTransition(()=>S()):S()}},[g,b,x,n,a,i,t,e,l,c,f,h,m])}var L2=0,z2=()=>`__${String(++L2)}__`;function I2(){let{router:e}=HS("useSubmit"),{basename:t}=v.useContext(cr),n=n2(),a=e.fetch,i=e.navigate;return v.useCallback(async(l,c={})=>{let{action:f,method:h,encType:m,formData:b,body:g}=p2(l,t);if(c.navigate===!1){let x=c.fetcherKey||z2();await a(x,n,c.action||f,{defaultShouldRevalidate:c.defaultShouldRevalidate,preventScrollReset:c.preventScrollReset,formData:b,body:g,formMethod:c.method||h,formEncType:c.encType||m,flushSync:c.flushSync})}else await i(c.action||f,{defaultShouldRevalidate:c.defaultShouldRevalidate,preventScrollReset:c.preventScrollReset,formData:b,body:g,formMethod:c.method||h,formEncType:c.encType||m,replace:c.replace,state:c.state,fromRouteId:n,flushSync:c.flushSync,viewTransition:c.viewTransition})},[a,i,t,n])}function $2(e,{relative:t}={}){let{basename:n}=v.useContext(cr),a=v.useContext(xa);Pt(a,"useFormAction must be used inside a RouteContext");let[i]=a.matches.slice(-1),l={...rc(e||".",{relative:t})},c=wa();if(e==null){l.search=c.search;let f=new URLSearchParams(l.search),h=f.getAll("index");if(h.some(b=>b==="")){f.delete("index"),h.filter(g=>g).forEach(g=>f.append("index",g));let b=f.toString();l.search=b?`?${b}`:""}}return(!e||e===".")&&i.route.index&&(l.search=l.search?l.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(l.pathname=l.pathname==="/"?n:Sr([n,l.pathname])),Bl(l)}function U2(e,{relative:t}={}){let n=v.useContext(kS);Pt(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:a}=HS("useViewTransitionState"),i=rc(e,{relative:t});if(!n.isTransitioning)return!1;let l=pa(n.currentLocation.pathname,a)||n.currentLocation.pathname,c=pa(n.nextLocation.pathname,a)||n.nextLocation.pathname;return Nd(i.pathname,c)!=null||Nd(i.pathname,l)!=null}var ac=wS();const qS=xS(ac);var Lr=function(){return Lr=Object.assign||function(t){for(var n,a=1,i=arguments.length;a<i;a++){n=arguments[a];for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(t[l]=n[l])}return t},Lr.apply(this,arguments)};function No(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,a=Object.getOwnPropertySymbols(e);i<a.length;i++)t.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(n[a[i]]=e[a[i]]);return n}function B2(e,t,n,a){function i(l){return l instanceof n?l:new n(function(c){c(l)})}return new(n||(n=Promise))(function(l,c){function f(b){try{m(a.next(b))}catch(g){c(g)}}function h(b){try{m(a.throw(b))}catch(g){c(g)}}function m(b){b.done?l(b.value):i(b.value).then(f,h)}m((a=a.apply(e,t||[])).next())})}function H2(e,t,n){if(n||arguments.length===2)for(var a=0,i=t.length,l;a<i;a++)(l||!(a in t))&&(l||(l=Array.prototype.slice.call(t,0,a)),l[a]=t[a]);return e.concat(l||Array.prototype.slice.call(t))}const q2=e=>e?(...t)=>e(...t):(...t)=>fetch(...t);class Zg extends Error{constructor(t,n="FunctionsError",a){super(t),this.name=n,this.context=a}toJSON(){return{name:this.name,message:this.message,context:this.context}}}class V2 extends Zg{constructor(t){super("Failed to send a request to the Edge Function","FunctionsFetchError",t)}}class yw extends Zg{constructor(t){super("Relay Error invoking the Edge Function","FunctionsRelayError",t)}}class bw extends Zg{constructor(t){super("Edge Function returned a non-2xx status code","FunctionsHttpError",t)}}var Qp;(function(e){e.Any="any",e.ApNortheast1="ap-northeast-1",e.ApNortheast2="ap-northeast-2",e.ApSouth1="ap-south-1",e.ApSoutheast1="ap-southeast-1",e.ApSoutheast2="ap-southeast-2",e.CaCentral1="ca-central-1",e.EuCentral1="eu-central-1",e.EuWest1="eu-west-1",e.EuWest2="eu-west-2",e.EuWest3="eu-west-3",e.SaEast1="sa-east-1",e.UsEast1="us-east-1",e.UsWest1="us-west-1",e.UsWest2="us-west-2"})(Qp||(Qp={}));class F2{constructor(t,{headers:n={},customFetch:a,region:i=Qp.Any}={}){this.url=t,this.headers=n,this.region=i,this.fetch=q2(a)}setAuth(t){this.headers.Authorization=`Bearer ${t}`}invoke(t){return B2(this,arguments,void 0,function*(n,a={}){var i;let l,c;try{const{headers:f,method:h,body:m,signal:b,timeout:g}=a;let x={},{region:w}=a;w||(w=this.region);const E=new URL(`${this.url}/${n}`);w&&w!=="any"&&(x["x-region"]=w,E.searchParams.set("forceFunctionRegion",w));let S;m&&(f&&!Object.prototype.hasOwnProperty.call(f,"Content-Type")||!f)?typeof Blob<"u"&&m instanceof Blob||m instanceof ArrayBuffer?(x["Content-Type"]="application/octet-stream",S=m):typeof m=="string"?(x["Content-Type"]="text/plain",S=m):typeof FormData<"u"&&m instanceof FormData?S=m:(x["Content-Type"]="application/json",S=JSON.stringify(m)):m&&typeof m!="string"&&!(typeof Blob<"u"&&m instanceof Blob)&&!(m instanceof ArrayBuffer)&&!(typeof FormData<"u"&&m instanceof FormData)?S=JSON.stringify(m):S=m;let C=b;g&&(c=new AbortController,l=setTimeout(()=>c.abort(),g),b?(C=c.signal,b.addEventListener("abort",()=>c.abort())):C=c.signal);const N=yield this.fetch(E.toString(),{method:h||"POST",headers:Object.assign(Object.assign(Object.assign({},x),this.headers),f),body:S,signal:C}).catch($=>{throw new V2($)}),A=N.headers.get("x-relay-error");if(A&&A==="true")throw new yw(N);if(!N.ok)throw new bw(N);let T=((i=N.headers.get("Content-Type"))!==null&&i!==void 0?i:"text/plain").split(";")[0].trim(),M;return T==="application/json"?M=yield N.json():T==="application/octet-stream"||T==="application/pdf"?M=yield N.blob():T==="text/event-stream"?M=N:T==="multipart/form-data"?M=yield N.formData():M=yield N.text(),{data:M,error:null,response:N}}catch(f){return{data:null,error:f,response:f instanceof bw||f instanceof yw?f.context:void 0}}finally{l&&clearTimeout(l)}})}}const VS=3,xw=e=>Math.min(1e3*2**e,3e4),G2=[520,503],FS=["GET","HEAD","OPTIONS"];var K2=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}toJSON(){return{name:this.name,message:this.message,details:this.details,hint:this.hint,code:this.code}}};function ww(e,t){return new Promise(n=>{if(t!=null&&t.aborted){n();return}const a=setTimeout(()=>{t==null||t.removeEventListener("abort",i),n()},e);function i(){clearTimeout(a),n()}t==null||t.addEventListener("abort",i)})}function W2(e,t,n,a){return!(!a||n>=VS||!FS.includes(e)||!G2.includes(t))}var Y2=class{constructor(e){var t,n,a,i,l;this.shouldThrowOnError=!1,this.retryEnabled=!0,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(n=e.isMaybeSingle)!==null&&n!==void 0?n:!1,this.shouldStripNulls=(a=e.shouldStripNulls)!==null&&a!==void 0?a:!1,this.urlLengthLimit=(i=e.urlLengthLimit)!==null&&i!==void 0?i:8e3,this.retryEnabled=(l=e.retry)!==null&&l!==void 0?l:!0,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}stripNulls(){if(this.headers.get("Accept")==="text/csv")throw new Error("stripNulls() cannot be used with csv()");return this.shouldStripNulls=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}retry(e){return this.retryEnabled=e,this}then(e,t){var n=this;if(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"),this.shouldStripNulls){const c=this.headers.get("Accept");c==="application/vnd.pgrst.object+json"?this.headers.set("Accept","application/vnd.pgrst.object+json;nulls=stripped"):(!c||c==="application/json")&&this.headers.set("Accept","application/vnd.pgrst.array+json;nulls=stripped")}const a=this.fetch;let l=(async()=>{let c=0;for(;;){const m=new Headers(n.headers);c>0&&m.set("X-Retry-Count",String(c));let b;try{b=await a(n.url.toString(),{method:n.method,headers:m,body:JSON.stringify(n.body,(g,x)=>typeof x=="bigint"?x.toString():x),signal:n.signal})}catch(g){if((g==null?void 0:g.name)==="AbortError"||(g==null?void 0:g.code)==="ABORT_ERR"||!FS.includes(n.method))throw g;if(n.retryEnabled&&c<VS){const x=xw(c);c++,await ww(x,n.signal);continue}throw g}if(W2(n.method,b.status,c,n.retryEnabled)){var f,h;const g=(f=(h=b.headers)===null||h===void 0?void 0:h.get("Retry-After"))!==null&&f!==void 0?f:null,x=g!==null?Math.max(0,parseInt(g,10)||0)*1e3:xw(c);await b.text(),c++,await ww(x,n.signal);continue}return await n.processResponse(b)}})();return this.shouldThrowOnError||(l=l.catch(c=>{var f;let h="",m="",b="";const g=c==null?void 0:c.cause;if(g){var x,w,E,S;const A=(x=g==null?void 0:g.message)!==null&&x!==void 0?x:"",T=(w=g==null?void 0:g.code)!==null&&w!==void 0?w:"";h=`${(E=c==null?void 0:c.name)!==null&&E!==void 0?E:"FetchError"}: ${c==null?void 0:c.message}`,h+=`
Caused by: ${(S=g==null?void 0:g.name)!==null&&S!==void 0?S:"Error"}: ${A}`,T&&(h+=` (${T})`),g!=null&&g.stack&&(h+=`
${g.stack}`)}else{var C;h=(C=c==null?void 0:c.stack)!==null&&C!==void 0?C:""}const N=this.url.toString().length;return(c==null?void 0:c.name)==="AbortError"||(c==null?void 0:c.code)==="ABORT_ERR"?(b="",m="Request was aborted (timeout or manual cancellation)",N>this.urlLengthLimit&&(m+=`. Note: Your request URL is ${N} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`)):((g==null?void 0:g.name)==="HeadersOverflowError"||(g==null?void 0:g.code)==="UND_ERR_HEADERS_OVERFLOW")&&(b="",m="HTTP headers exceeded server limits (typically 16KB)",N>this.urlLengthLimit&&(m+=`. Your request URL is ${N} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{success:!1,error:{message:`${(f=c==null?void 0:c.name)!==null&&f!==void 0?f:"FetchError"}: ${c==null?void 0:c.message}`,details:h,hint:m,code:b},data:null,count:null,status:0,statusText:""}})),l.then(e,t)}async processResponse(e){var t=this;let n=null,a=null,i=null,l=e.status,c=e.statusText;if(e.ok){var f,h;if(t.method!=="HEAD"){var m;const x=await e.text();x===""||(t.headers.get("Accept")==="text/csv"||t.headers.get("Accept")&&(!((m=t.headers.get("Accept"))===null||m===void 0)&&m.includes("application/vnd.pgrst.plan+text"))?a=x:a=JSON.parse(x))}const b=(f=t.headers.get("Prefer"))===null||f===void 0?void 0:f.match(/count=(exact|planned|estimated)/),g=(h=e.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");b&&g&&g.length>1&&(i=parseInt(g[1])),t.isMaybeSingle&&Array.isArray(a)&&(a.length>1?(n={code:"PGRST116",details:`Results contain ${a.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},a=null,i=null,l=406,c="Not Acceptable"):a.length===1?a=a[0]:a=null)}else{const b=await e.text();try{n=JSON.parse(b),Array.isArray(n)&&e.status===404&&(a=[],n=null,l=200,c="OK")}catch{e.status===404&&b===""?(l=204,c="No Content"):n={message:b}}if(n&&t.shouldThrowOnError)throw new K2(n)}return{success:n===null,error:n,data:a,count:i,status:l,statusText:c}}returns(){return this}overrideTypes(){return this}},X2=class extends Y2{select(e){let t=!1;const n=(e??"*").split("").map(a=>/\s/.test(a)&&!t?"":(a==='"'&&(t=!t),a)).join("");return this.url.searchParams.set("select",n),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:n,foreignTable:a,referencedTable:i=a}={}){const l=i?`${i}.order`:"order",c=this.url.searchParams.get(l);return this.url.searchParams.set(l,`${c?`${c},`:""}${e}.${t?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:n=t}={}){const a=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(a,`${e}`),this}range(e,t,{foreignTable:n,referencedTable:a=n}={}){const i=typeof a>"u"?"offset":`${a}.offset`,l=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(i,`${e}`),this.url.searchParams.set(l,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:n=!1,buffers:a=!1,wal:i=!1,format:l="text"}={}){var c;const f=[e?"analyze":null,t?"verbose":null,n?"settings":null,a?"buffers":null,i?"wal":null].filter(Boolean).join("|"),h=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${l}; for="${h}"; options=${f};`),l==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};const _w=new RegExp("[,()]");var eo=class extends X2{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}regexMatch(e,t){return this.url.searchParams.append(e,`match.${t}`),this}regexIMatch(e,t){return this.url.searchParams.append(e,`imatch.${t}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}isDistinct(e,t){return this.url.searchParams.append(e,`isdistinct.${t}`),this}in(e,t){const n=Array.from(new Set(t)).map(a=>typeof a=="string"&&_w.test(a)?`"${a}"`:`${a}`).join(",");return this.url.searchParams.append(e,`in.(${n})`),this}notIn(e,t){const n=Array.from(new Set(t)).map(a=>typeof a=="string"&&_w.test(a)?`"${a}"`:`${a}`).join(",");return this.url.searchParams.append(e,`not.in.(${n})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:n,type:a}={}){let i="";a==="plain"?i="pl":a==="phrase"?i="ph":a==="websearch"&&(i="w");const l=n===void 0?"":`(${n})`;return this.url.searchParams.append(e,`${i}fts${l}.${t}`),this}match(e){return Object.entries(e).filter(([t,n])=>n!==void 0).forEach(([t,n])=>{this.url.searchParams.append(t,`eq.${n}`)}),this}not(e,t,n){return this.url.searchParams.append(e,`not.${t}.${n}`),this}or(e,{foreignTable:t,referencedTable:n=t}={}){const a=n?`${n}.or`:"or";return this.url.searchParams.append(a,`(${e})`),this}filter(e,t,n){return this.url.searchParams.append(e,`${t}.${n}`),this}},J2=class{constructor(e,{headers:t={},schema:n,fetch:a,urlLengthLimit:i=8e3,retry:l}){this.url=e,this.headers=new Headers(t),this.schema=n,this.fetch=a,this.urlLengthLimit=i,this.retry=l}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(e,t){const{head:n=!1,count:a}=t??{},i=n?"HEAD":"GET";let l=!1;const c=(e??"*").split("").map(m=>/\s/.test(m)&&!l?"":(m==='"'&&(l=!l),m)).join(""),{url:f,headers:h}=this.cloneRequestState();return f.searchParams.set("select",c),a&&h.append("Prefer",`count=${a}`),new eo({method:i,url:f,headers:h,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}insert(e,{count:t,defaultToNull:n=!0}={}){var a;const i="POST",{url:l,headers:c}=this.cloneRequestState();if(t&&c.append("Prefer",`count=${t}`),n||c.append("Prefer","missing=default"),Array.isArray(e)){const f=e.reduce((h,m)=>h.concat(Object.keys(m)),[]);if(f.length>0){const h=[...new Set(f)].map(m=>`"${m}"`);l.searchParams.set("columns",h.join(","))}}return new eo({method:i,url:l,headers:c,schema:this.schema,body:e,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}upsert(e,{onConflict:t,ignoreDuplicates:n=!1,count:a,defaultToNull:i=!0}={}){var l;const c="POST",{url:f,headers:h}=this.cloneRequestState();if(h.append("Prefer",`resolution=${n?"ignore":"merge"}-duplicates`),t!==void 0&&f.searchParams.set("on_conflict",t),a&&h.append("Prefer",`count=${a}`),i||h.append("Prefer","missing=default"),Array.isArray(e)){const m=e.reduce((b,g)=>b.concat(Object.keys(g)),[]);if(m.length>0){const b=[...new Set(m)].map(g=>`"${g}"`);f.searchParams.set("columns",b.join(","))}}return new eo({method:c,url:f,headers:h,schema:this.schema,body:e,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}update(e,{count:t}={}){var n;const a="PATCH",{url:i,headers:l}=this.cloneRequestState();return t&&l.append("Prefer",`count=${t}`),new eo({method:a,url:i,headers:l,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}delete({count:e}={}){var t;const n="DELETE",{url:a,headers:i}=this.cloneRequestState();return e&&i.append("Prefer",`count=${e}`),new eo({method:n,url:a,headers:i,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};function Hl(e){"@babel/helpers - typeof";return Hl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Hl(e)}function Q2(e,t){if(Hl(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var a=n.call(e,t);if(Hl(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Z2(e){var t=Q2(e,"string");return Hl(t)=="symbol"?t:t+""}function eO(e,t,n){return(t=Z2(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Sw(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,a)}return n}function Mu(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Sw(Object(n),!0).forEach(function(a){eO(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Sw(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}var tO=class GS{constructor(t,{headers:n={},schema:a,fetch:i,timeout:l,urlLengthLimit:c=8e3,retry:f}={}){this.url=t,this.headers=new Headers(n),this.schemaName=a,this.urlLengthLimit=c;const h=i??globalThis.fetch;l!==void 0&&l>0?this.fetch=(m,b)=>{const g=new AbortController,x=setTimeout(()=>g.abort(),l),w=b==null?void 0:b.signal;if(w){if(w.aborted)return clearTimeout(x),h(m,b);const E=()=>{clearTimeout(x),g.abort()};return w.addEventListener("abort",E,{once:!0}),h(m,Mu(Mu({},b),{},{signal:g.signal})).finally(()=>{clearTimeout(x),w.removeEventListener("abort",E)})}return h(m,Mu(Mu({},b),{},{signal:g.signal})).finally(()=>clearTimeout(x))}:this.fetch=h,this.retry=f}from(t){if(!t||typeof t!="string"||t.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new J2(new URL(`${this.url}/${t}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}schema(t){return new GS(this.url,{headers:this.headers,schema:t,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}rpc(t,n={},{head:a=!1,get:i=!1,count:l}={}){var c;let f;const h=new URL(`${this.url}/rpc/${t}`);let m;const b=w=>w!==null&&typeof w=="object"&&(!Array.isArray(w)||w.some(b)),g=a&&Object.values(n).some(b);g?(f="POST",m=n):a||i?(f=a?"HEAD":"GET",Object.entries(n).filter(([w,E])=>E!==void 0).map(([w,E])=>[w,Array.isArray(E)?`{${E.join(",")}}`:`${E}`]).forEach(([w,E])=>{h.searchParams.append(w,E)})):(f="POST",m=n);const x=new Headers(this.headers);return g?x.set("Prefer",l?`count=${l},return=minimal`:"return=minimal"):l&&x.set("Prefer",`count=${l}`),new eo({method:f,url:h,headers:x,schema:this.schemaName,body:m,fetch:(c=this.fetch)!==null&&c!==void 0?c:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};class nO{constructor(){}static detectEnvironment(){var t;if(typeof WebSocket<"u")return{type:"native",wsConstructor:WebSocket};const n=globalThis;if(typeof globalThis<"u"&&typeof n.WebSocket<"u")return{type:"native",wsConstructor:n.WebSocket};const a=typeof global<"u"?global:void 0;if(a&&typeof a.WebSocket<"u")return{type:"native",wsConstructor:a.WebSocket};if(typeof globalThis<"u"&&typeof n.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"&&n.EdgeRuntime||typeof navigator<"u"&&(!((t=navigator.userAgent)===null||t===void 0)&&t.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};const i=globalThis.process;if(i){const l=i.versions;if(l&&l.node){const c=l.node,f=parseInt(c.replace(/^v/,"").split(".")[0]);return f>=22?typeof globalThis.WebSocket<"u"?{type:"native",wsConstructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${f} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${f} 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 t=this.detectEnvironment();if(t.wsConstructor)return t.wsConstructor;let n=t.error||"WebSocket not supported in this environment.";throw t.workaround&&(n+=`
Suggested solution: ${t.workaround}`),new Error(n)}static isWebSocketSupported(){try{const t=this.detectEnvironment();return t.type==="native"||t.type==="ws"}catch{return!1}}}const rO="2.106.2",aO=`realtime-js/${rO}`,sO="1.0.0",KS="2.0.0",iO=KS,oO=1e4,lO=100,es={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},WS={close:"phx_close",error:"phx_error",join:"phx_join",leave:"phx_leave",access_token:"access_token"},Zp={connecting:"connecting",closing:"closing",closed:"closed"};class cO{constructor(t){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=t??[]}encode(t,n){if(t.event===this.BROADCAST_EVENT&&!(t.payload instanceof ArrayBuffer)&&typeof t.payload.event=="string")return n(this._binaryEncodeUserBroadcastPush(t));let a=[t.join_ref,t.ref,t.topic,t.event,t.payload];return n(JSON.stringify(a))}_binaryEncodeUserBroadcastPush(t){var n;return this._isArrayBuffer((n=t.payload)===null||n===void 0?void 0:n.payload)?this._encodeBinaryUserBroadcastPush(t):this._encodeJsonUserBroadcastPush(t)}_encodeBinaryUserBroadcastPush(t){var n,a;const i=(a=(n=t.payload)===null||n===void 0?void 0:n.payload)!==null&&a!==void 0?a:new ArrayBuffer(0);return this._encodeUserBroadcastPush(t,this.BINARY_ENCODING,i)}_encodeJsonUserBroadcastPush(t){var n,a;const i=(a=(n=t.payload)===null||n===void 0?void 0:n.payload)!==null&&a!==void 0?a:{},c=new TextEncoder().encode(JSON.stringify(i)).buffer;return this._encodeUserBroadcastPush(t,this.JSON_ENCODING,c)}_encodeUserBroadcastPush(t,n,a){var i,l;const c=t.topic,f=(i=t.ref)!==null&&i!==void 0?i:"",h=(l=t.join_ref)!==null&&l!==void 0?l:"",m=t.payload.event,b=this.allowedMetadataKeys?this._pick(t.payload,this.allowedMetadataKeys):{},g=Object.keys(b).length===0?"":JSON.stringify(b);if(h.length>255)throw new Error(`joinRef length ${h.length} exceeds maximum of 255`);if(f.length>255)throw new Error(`ref length ${f.length} exceeds maximum of 255`);if(c.length>255)throw new Error(`topic length ${c.length} exceeds maximum of 255`);if(m.length>255)throw new Error(`userEvent length ${m.length} exceeds maximum of 255`);if(g.length>255)throw new Error(`metadata length ${g.length} exceeds maximum of 255`);const x=this.USER_BROADCAST_PUSH_META_LENGTH+h.length+f.length+c.length+m.length+g.length,w=new ArrayBuffer(this.HEADER_LENGTH+x);let E=new DataView(w),S=0;E.setUint8(S++,this.KINDS.userBroadcastPush),E.setUint8(S++,h.length),E.setUint8(S++,f.length),E.setUint8(S++,c.length),E.setUint8(S++,m.length),E.setUint8(S++,g.length),E.setUint8(S++,n),Array.from(h,N=>E.setUint8(S++,N.charCodeAt(0))),Array.from(f,N=>E.setUint8(S++,N.charCodeAt(0))),Array.from(c,N=>E.setUint8(S++,N.charCodeAt(0))),Array.from(m,N=>E.setUint8(S++,N.charCodeAt(0))),Array.from(g,N=>E.setUint8(S++,N.charCodeAt(0)));var C=new Uint8Array(w.byteLength+a.byteLength);return C.set(new Uint8Array(w),0),C.set(new Uint8Array(a),w.byteLength),C.buffer}decode(t,n){if(this._isArrayBuffer(t)){let a=this._binaryDecode(t);return n(a)}if(typeof t=="string"){const a=JSON.parse(t),[i,l,c,f,h]=a;return n({join_ref:i,ref:l,topic:c,event:f,payload:h})}return n({})}_binaryDecode(t){const n=new DataView(t),a=n.getUint8(0),i=new TextDecoder;switch(a){case this.KINDS.userBroadcast:return this._decodeUserBroadcast(t,n,i)}}_decodeUserBroadcast(t,n,a){const i=n.getUint8(1),l=n.getUint8(2),c=n.getUint8(3),f=n.getUint8(4);let h=this.HEADER_LENGTH+4;const m=a.decode(t.slice(h,h+i));h=h+i;const b=a.decode(t.slice(h,h+l));h=h+l;const g=a.decode(t.slice(h,h+c));h=h+c;const x=t.slice(h,t.byteLength),w=f===this.JSON_ENCODING?JSON.parse(a.decode(x)):x,E={type:this.BROADCAST_EVENT,event:b,payload:w};return c>0&&(E.meta=JSON.parse(g)),{join_ref:null,ref:null,topic:m,event:this.BROADCAST_EVENT,payload:E}}_isArrayBuffer(t){var n;return t instanceof ArrayBuffer||((n=t==null?void 0:t.constructor)===null||n===void 0?void 0:n.name)==="ArrayBuffer"}_pick(t,n){return!t||typeof t!="object"?{}:Object.fromEntries(Object.entries(t).filter(([a])=>n.includes(a)))}}var Nt;(function(e){e.abstime="abstime",e.bool="bool",e.date="date",e.daterange="daterange",e.float4="float4",e.float8="float8",e.int2="int2",e.int4="int4",e.int4range="int4range",e.int8="int8",e.int8range="int8range",e.json="json",e.jsonb="jsonb",e.money="money",e.numeric="numeric",e.oid="oid",e.reltime="reltime",e.text="text",e.time="time",e.timestamp="timestamp",e.timestamptz="timestamptz",e.timetz="timetz",e.tsrange="tsrange",e.tstzrange="tstzrange"})(Nt||(Nt={}));const Ew=(e,t,n={})=>{var a;const i=(a=n.skipTypes)!==null&&a!==void 0?a:[];return t?Object.keys(t).reduce((l,c)=>(l[c]=uO(c,e,t,i),l),{}):{}},uO=(e,t,n,a)=>{const i=t.find(f=>f.name===e),l=i==null?void 0:i.type,c=n[e];return l&&!a.includes(l)?YS(l,c):eg(c)},YS=(e,t)=>{if(e.charAt(0)==="_"){const n=e.slice(1,e.length);return mO(t,n)}switch(e){case Nt.bool:return dO(t);case Nt.float4:case Nt.float8:case Nt.int2:case Nt.int4:case Nt.int8:case Nt.numeric:case Nt.oid:return fO(t);case Nt.json:case Nt.jsonb:return hO(t);case Nt.timestamp:return pO(t);case Nt.abstime:case Nt.date:case Nt.daterange:case Nt.int4range:case Nt.int8range:case Nt.money:case Nt.reltime:case Nt.text:case Nt.time:case Nt.timestamptz:case Nt.timetz:case Nt.tsrange:case Nt.tstzrange:return eg(t);default:return eg(t)}},eg=e=>e,dO=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},fO=e=>{if(typeof e=="string"){const t=parseFloat(e);if(!Number.isNaN(t))return t}return e},hO=e=>{if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e},mO=(e,t)=>{if(typeof e!="string")return e;const n=e.length-1,a=e[n];if(e[0]==="{"&&a==="}"){let l;const c=e.slice(1,n);try{l=JSON.parse("["+c+"]")}catch{l=c?c.split(","):[]}return l.map(f=>YS(t,f))}return e},pO=e=>typeof e=="string"?e.replace(" ","T"):e,XS=e=>{const t=new URL(e);return t.protocol=t.protocol.replace(/^ws/i,"http"),t.pathname=t.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),t.pathname===""||t.pathname==="/"?t.pathname="/api/broadcast":t.pathname=t.pathname+"/api/broadcast",t.href};var Dl=e=>typeof e=="function"?e:function(){return e},gO=typeof self<"u"?self:null,to=typeof window<"u"?window:null,Dr=gO||to||globalThis,vO="2.0.0",yO=1e4,bO=1e3,Pr={connecting:0,open:1,closing:2,closed:3},On={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},fa={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},tg={longpoll:"longpoll",websocket:"websocket"},xO={complete:4},ng="base64url.bearer.phx.",Du=class{constructor(e,t,n,a){this.channel=e,this.event=t,this.payload=n||function(){return{}},this.receivedResp=null,this.timeout=a,this.timeoutTimer=null,this.recHooks=[],this.sent=!1,this.ref=void 0}resend(e){this.timeout=e,this.reset(),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()}))}receive(e,t){return this.hasReceived(e)&&t(this.receivedResp.response),this.recHooks.push({status:e,callback:t}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}destroy(){this.cancelRefEvent(),this.cancelTimeout()}matchReceive({status:e,response:t,_ref:n}){this.recHooks.filter(a=>a.status===e).forEach(a=>a.callback(t))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,e=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=e,this.matchReceive(e)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}trigger(e,t){this.channel.trigger(this.refEvent,{status:e,response:t})}},JS=class{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},wO=class{constructor(e,t,n){this.state=On.closed,this.topic=e,this.params=Dl(t||{}),this.socket=n,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new Du(this,fa.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new JS(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=On.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(a=>a.send()),this.pushBuffer=[]}),this.joinPush.receive("error",a=>{this.state=On.errored,this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,a),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic}`),this.state=On.closed,this.socket.remove(this)}),this.onError(a=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,a),this.isJoining()&&this.joinPush.reset(),this.state=On.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),new Du(this,fa.leave,Dl({}),this.timeout).send(),this.state=On.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(fa.reply,(a,i)=>{this.trigger(this.replyEventName(i),a)})}join(e=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=e,this.joinedOnce=!0,this.rejoin(),this.joinPush}teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=On.closed,this.bindings=[]}onClose(e){this.on(fa.close,e)}onError(e){return this.on(fa.error,t=>e(t))}on(e,t){let n=this.bindingRef++;return this.bindings.push({event:e,ref:n,callback:t}),n}off(e,t){this.bindings=this.bindings.filter(n=>!(n.event===e&&(typeof t>"u"||t===n.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(e,t,n=this.timeout){if(t=t||{},!this.joinedOnce)throw new Error(`tried to push '${e}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let a=new Du(this,e,function(){return t},n);return this.canPush()?a.send():(a.startTimeout(),this.pushBuffer.push(a)),a}leave(e=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=On.leaving;let t=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(fa.close,"leave")},n=new Du(this,fa.leave,Dl({}),e);return n.receive("ok",()=>t()).receive("timeout",()=>t()),n.send(),this.canPush()||n.trigger("ok",{}),n}onMessage(e,t,n){return t}filterBindings(e,t,n){return!0}isMember(e,t,n,a){return this.topic!==e?!1:a&&a!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:e,event:t,payload:n,joinRef:a}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(e=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=On.joining,this.joinPush.resend(e))}trigger(e,t,n,a){let i=this.onMessage(e,t,n,a);if(t&&!i)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let l=this.bindings.filter(c=>c.event===e&&this.filterBindings(c,t,n));for(let c=0;c<l.length;c++)l[c].callback(i,n,a||this.joinRef())}replyEventName(e){return`chan_reply_${e}`}isClosed(){return this.state===On.closed}isErrored(){return this.state===On.errored}isJoined(){return this.state===On.joined}isJoining(){return this.state===On.joining}isLeaving(){return this.state===On.leaving}},jd=class{static request(e,t,n,a,i,l,c){if(Dr.XDomainRequest){let f=new Dr.XDomainRequest;return this.xdomainRequest(f,e,t,a,i,l,c)}else if(Dr.XMLHttpRequest){let f=new Dr.XMLHttpRequest;return this.xhrRequest(f,e,t,n,a,i,l,c)}else{if(Dr.fetch&&Dr.AbortController)return this.fetchRequest(e,t,n,a,i,l,c);throw new Error("No suitable XMLHttpRequest implementation found")}}static fetchRequest(e,t,n,a,i,l,c){let f={method:e,headers:n,body:a},h=null;return i&&(h=new AbortController,setTimeout(()=>h.abort(),i),f.signal=h.signal),Dr.fetch(t,f).then(m=>m.text()).then(m=>this.parseJSON(m)).then(m=>c&&c(m)).catch(m=>{m.name==="AbortError"&&l?l():c&&c(null)}),h}static xdomainRequest(e,t,n,a,i,l,c){return e.timeout=i,e.open(t,n),e.onload=()=>{let f=this.parseJSON(e.responseText);c&&c(f)},l&&(e.ontimeout=l),e.onprogress=()=>{},e.send(a),e}static xhrRequest(e,t,n,a,i,l,c,f){e.open(t,n,!0),e.timeout=l;for(let[h,m]of Object.entries(a))e.setRequestHeader(h,m);return e.onerror=()=>f&&f(null),e.onreadystatechange=()=>{if(e.readyState===xO.complete&&f){let h=this.parseJSON(e.responseText);f(h)}},c&&(e.ontimeout=c),e.send(i),e}static parseJSON(e){if(!e||e==="")return null;try{return JSON.parse(e)}catch{return console&&console.log("failed to parse JSON response",e),null}}static serialize(e,t){let n=[];for(var a in e){if(!Object.prototype.hasOwnProperty.call(e,a))continue;let i=t?`${t}[${a}]`:a,l=e[a];typeof l=="object"?n.push(this.serialize(l,i)):n.push(encodeURIComponent(i)+"="+encodeURIComponent(l))}return n.join("&")}static appendParams(e,t){if(Object.keys(t).length===0)return e;let n=e.match(/\?/)?"&":"?";return`${e}${n}${this.serialize(t)}`}},_O=e=>{let t="",n=new Uint8Array(e),a=n.byteLength;for(let i=0;i<a;i++)t+=String.fromCharCode(n[i]);return btoa(t)},qi=class{constructor(e,t){t&&t.length===2&&t[1].startsWith(ng)&&(this.authToken=atob(t[1].slice(ng.length))),this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(e),this.readyState=Pr.connecting,setTimeout(()=>this.poll(),0)}normalizeEndpoint(e){return e.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+tg.websocket),"$1/"+tg.longpoll)}endpointURL(){return jd.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(e,t,n){this.close(e,t,n),this.readyState=Pr.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===Pr.open||this.readyState===Pr.connecting}poll(){const e={Accept:"application/json"};this.authToken&&(e["X-Phoenix-AuthToken"]=this.authToken),this.ajax("GET",e,null,()=>this.ontimeout(),t=>{if(t){var{status:n,token:a,messages:i}=t;if(n===410&&this.token!==null){this.onerror(410),this.closeAndRetry(3410,"session_gone",!1);return}this.token=a}else n=0;switch(n){case 200:i.forEach(l=>{setTimeout(()=>this.onmessage({data:l}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=Pr.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${n}`)}})}send(e){typeof e!="string"&&(e=_O(e)),this.currentBatch?this.currentBatch.push(e):this.awaitingBatchAck?this.batchBuffer.push(e):(this.currentBatch=[e],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(e){this.awaitingBatchAck=!0,this.ajax("POST",{"Content-Type":"application/x-ndjson"},e.join(`
`),()=>this.onerror("timeout"),t=>{this.awaitingBatchAck=!1,!t||t.status!==200?(this.onerror(t&&t.status),this.closeAndRetry(1011,"internal server error",!1)):this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[])})}close(e,t,n){for(let i of this.reqs)i.abort();this.readyState=Pr.closed;let a=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:e,reason:t,wasClean:n});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",a)):this.onclose(a)}ajax(e,t,n,a,i){let l,c=()=>{this.reqs.delete(l),a()};l=jd.request(e,this.endpointURL(),t,n,this.timeout,c,f=>{this.reqs.delete(l),this.isActive()&&i(f)}),this.reqs.add(l)}},SO=class Rl{constructor(t,n={}){let a=n.events||{state:"presence_state",diff:"presence_diff"};this.state={},this.pendingDiffs=[],this.channel=t,this.joinRef=null,this.caller={onJoin:function(){},onLeave:function(){},onSync:function(){}},this.channel.on(a.state,i=>{let{onJoin:l,onLeave:c,onSync:f}=this.caller;this.joinRef=this.channel.joinRef(),this.state=Rl.syncState(this.state,i,l,c),this.pendingDiffs.forEach(h=>{this.state=Rl.syncDiff(this.state,h,l,c)}),this.pendingDiffs=[],f()}),this.channel.on(a.diff,i=>{let{onJoin:l,onLeave:c,onSync:f}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(i):(this.state=Rl.syncDiff(this.state,i,l,c),f())})}onJoin(t){this.caller.onJoin=t}onLeave(t){this.caller.onLeave=t}onSync(t){this.caller.onSync=t}list(t){return Rl.list(this.state,t)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}static syncState(t,n,a,i){let l=this.clone(t),c={},f={};return this.map(l,(h,m)=>{n[h]||(f[h]=m)}),this.map(n,(h,m)=>{let b=l[h];if(b){let g=m.metas.map(S=>S.phx_ref),x=b.metas.map(S=>S.phx_ref),w=m.metas.filter(S=>x.indexOf(S.phx_ref)<0),E=b.metas.filter(S=>g.indexOf(S.phx_ref)<0);w.length>0&&(c[h]=m,c[h].metas=w),E.length>0&&(f[h]=this.clone(b),f[h].metas=E)}else c[h]=m}),this.syncDiff(l,{joins:c,leaves:f},a,i)}static syncDiff(t,n,a,i){let{joins:l,leaves:c}=this.clone(n);return a||(a=function(){}),i||(i=function(){}),this.map(l,(f,h)=>{let m=t[f];if(t[f]=this.clone(h),m){let b=t[f].metas.map(x=>x.phx_ref),g=m.metas.filter(x=>b.indexOf(x.phx_ref)<0);t[f].metas.unshift(...g)}a(f,m,h)}),this.map(c,(f,h)=>{let m=t[f];if(!m)return;let b=h.metas.map(g=>g.phx_ref);m.metas=m.metas.filter(g=>b.indexOf(g.phx_ref)<0),i(f,m,h),m.metas.length===0&&delete t[f]}),t}static list(t,n){return n||(n=function(a,i){return i}),this.map(t,(a,i)=>n(a,i))}static map(t,n){return Object.getOwnPropertyNames(t).map(a=>n(a,t[a]))}static clone(t){return JSON.parse(JSON.stringify(t))}},Pu={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(e,t){if(e.payload.constructor===ArrayBuffer)return t(this.binaryEncode(e));{let n=[e.join_ref,e.ref,e.topic,e.event,e.payload];return t(JSON.stringify(n))}},decode(e,t){if(e.constructor===ArrayBuffer)return t(this.binaryDecode(e));{let[n,a,i,l,c]=JSON.parse(e);return t({join_ref:n,ref:a,topic:i,event:l,payload:c})}},binaryEncode(e){let{join_ref:t,ref:n,event:a,topic:i,payload:l}=e,c=this.META_LENGTH+t.length+n.length+i.length+a.length,f=new ArrayBuffer(this.HEADER_LENGTH+c),h=new DataView(f),m=0;h.setUint8(m++,this.KINDS.push),h.setUint8(m++,t.length),h.setUint8(m++,n.length),h.setUint8(m++,i.length),h.setUint8(m++,a.length),Array.from(t,g=>h.setUint8(m++,g.charCodeAt(0))),Array.from(n,g=>h.setUint8(m++,g.charCodeAt(0))),Array.from(i,g=>h.setUint8(m++,g.charCodeAt(0))),Array.from(a,g=>h.setUint8(m++,g.charCodeAt(0)));var b=new Uint8Array(f.byteLength+l.byteLength);return b.set(new Uint8Array(f),0),b.set(new Uint8Array(l),f.byteLength),b.buffer},binaryDecode(e){let t=new DataView(e),n=t.getUint8(0),a=new TextDecoder;switch(n){case this.KINDS.push:return this.decodePush(e,t,a);case this.KINDS.reply:return this.decodeReply(e,t,a);case this.KINDS.broadcast:return this.decodeBroadcast(e,t,a)}},decodePush(e,t,n){let a=t.getUint8(1),i=t.getUint8(2),l=t.getUint8(3),c=this.HEADER_LENGTH+this.META_LENGTH-1,f=n.decode(e.slice(c,c+a));c=c+a;let h=n.decode(e.slice(c,c+i));c=c+i;let m=n.decode(e.slice(c,c+l));c=c+l;let b=e.slice(c,e.byteLength);return{join_ref:f,ref:null,topic:h,event:m,payload:b}},decodeReply(e,t,n){let a=t.getUint8(1),i=t.getUint8(2),l=t.getUint8(3),c=t.getUint8(4),f=this.HEADER_LENGTH+this.META_LENGTH,h=n.decode(e.slice(f,f+a));f=f+a;let m=n.decode(e.slice(f,f+i));f=f+i;let b=n.decode(e.slice(f,f+l));f=f+l;let g=n.decode(e.slice(f,f+c));f=f+c;let x=e.slice(f,e.byteLength),w={status:g,response:x};return{join_ref:h,ref:m,topic:b,event:fa.reply,payload:w}},decodeBroadcast(e,t,n){let a=t.getUint8(1),i=t.getUint8(2),l=this.HEADER_LENGTH+2,c=n.decode(e.slice(l,l+a));l=l+a;let f=n.decode(e.slice(l,l+i));l=l+i;let h=e.slice(l,e.byteLength);return{join_ref:null,ref:null,topic:c,event:f,payload:h}}},EO=class{constructor(e,t={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=t.timeout||yO,this.transport=t.transport||Dr.WebSocket||qi,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=t.longPollFallbackMs,this.fallbackTimer=null;let n=null;try{n=Dr&&Dr.sessionStorage}catch{}this.sessionStore=t.sessionStorage||n,this.establishedConnections=0,this.defaultEncoder=Pu.encode.bind(Pu),this.defaultDecoder=Pu.decode.bind(Pu),this.closeWasClean=!0,this.disconnecting=!1,this.binaryType=t.binaryType||"arraybuffer",this.connectClock=1,this.pageHidden=!1,this.encode=void 0,this.decode=void 0,this.transport!==qi?(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let a=null;to&&to.addEventListener&&(to.addEventListener("pagehide",i=>{this.conn&&(this.disconnect(),a=this.connectClock)}),to.addEventListener("pageshow",i=>{a===this.connectClock&&(a=null,this.connect())}),to.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.pageHidden=!0:(this.pageHidden=!1,!this.isConnected()&&!this.closeWasClean&&this.teardown(()=>this.connect()))})),this.heartbeatIntervalMs=t.heartbeatIntervalMs||3e4,this.autoSendHeartbeat=t.autoSendHeartbeat??!0,this.heartbeatCallback=t.heartbeatCallback??(()=>{}),this.rejoinAfterMs=i=>t.rejoinAfterMs?t.rejoinAfterMs(i):[1e3,2e3,5e3][i-1]||1e4,this.reconnectAfterMs=i=>t.reconnectAfterMs?t.reconnectAfterMs(i):[10,50,100,150,200,250,500,1e3,2e3][i-1]||5e3,this.logger=t.logger||null,!this.logger&&t.debug&&(this.logger=(i,l,c)=>{console.log(`${i}: ${l}`,c)}),this.longpollerTimeout=t.longpollerTimeout||2e4,this.params=Dl(t.params||{}),this.endPoint=`${e}/${tg.websocket}`,this.vsn=t.vsn||vO,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new JS(()=>{if(this.pageHidden){this.log("Not reconnecting as page is hidden!"),this.teardown();return}this.teardown(async()=>{t.beforeReconnect&&await t.beforeReconnect(),this.connect()})},this.reconnectAfterMs),this.authToken=t.authToken}getLongPollTransport(){return qi}replaceTransport(e){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=e}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let e=jd.appendParams(jd.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return e.charAt(0)!=="/"?e:e.charAt(1)==="/"?`${this.protocol()}:${e}`:`${this.protocol()}://${location.host}${e}`}disconnect(e,t,n){this.connectClock++,this.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,e&&e()},t,n)}connect(e){e&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=Dl(e)),!(this.conn&&!this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==qi?this.connectWithFallback(qi,this.longPollFallbackMs):this.transportConnect())}log(e,t,n){this.logger&&this.logger(e,t,n)}hasLogger(){return this.logger!==null}onOpen(e){let t=this.makeRef();return this.stateChangeCallbacks.open.push([t,e]),t}onClose(e){let t=this.makeRef();return this.stateChangeCallbacks.close.push([t,e]),t}onError(e){let t=this.makeRef();return this.stateChangeCallbacks.error.push([t,e]),t}onMessage(e){let t=this.makeRef();return this.stateChangeCallbacks.message.push([t,e]),t}onHeartbeat(e){this.heartbeatCallback=e}ping(e){if(!this.isConnected())return!1;let t=this.makeRef(),n=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:t});let a=this.onMessage(i=>{i.ref===t&&(this.off([a]),e(Date.now()-n))});return!0}transportName(e){switch(e){case qi:return"LongPoll";default:return e.name}}transportConnect(){this.connectClock++,this.closeWasClean=!1;let e;this.authToken&&(e=["phoenix",`${ng}${btoa(this.authToken).replace(/=/g,"")}`]),this.conn=new this.transport(this.endPointURL(),e),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=t=>this.onConnError(t),this.conn.onmessage=t=>this.onConnMessage(t),this.conn.onclose=t=>this.onConnClose(t)}getSession(e){return this.sessionStore&&this.sessionStore.getItem(e)}storeSession(e,t){this.sessionStore&&this.sessionStore.setItem(e,t)}connectWithFallback(e,t=2500){clearTimeout(this.fallbackTimer);let n=!1,a=!0,i,l,c=this.transportName(e),f=h=>{this.log("transport",`falling back to ${c}...`,h),this.off([i,l]),a=!1,this.replaceTransport(e),this.transportConnect()};if(this.getSession(`phx:fallback:${c}`))return f("memorized");this.fallbackTimer=setTimeout(f,t),l=this.onError(h=>{this.log("transport","error",h),a&&!n&&(clearTimeout(this.fallbackTimer),f(h))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(n=!0,!a){let h=this.transportName(e);return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${h}`,"true"),this.log("transport",`established ${h} fallback`)}clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(f,t),this.ping(h=>{this.log("transport","connected to primary after",h),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.disconnecting=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.autoSendHeartbeat&&this.resetHeartbeat(),this.triggerStateCallbacks("open")}heartbeatTimeout(){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(e){this.log("error","error in heartbeat callback",e)}this.triggerChanError(new Error("heartbeat timeout")),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),bO,"heartbeat timeout")}}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(e,t,n){if(!this.conn)return e&&e();const a=this.conn;this.waitForBufferDone(a,()=>{t?a.close(t,n||""):a.close(),this.waitForSocketClosed(a,()=>{this.conn===a&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),e&&e()})})}waitForBufferDone(e,t,n=1){if(n===5||!e.bufferedAmount){t();return}setTimeout(()=>{this.waitForBufferDone(e,t,n+1)},150*n)}waitForSocketClosed(e,t,n=1){if(n===5||e.readyState===Pr.closed){t();return}setTimeout(()=>{this.waitForSocketClosed(e,t,n+1)},150*n)}onConnClose(e){this.conn&&(this.conn.onclose=()=>{}),this.hasLogger()&&this.log("transport","close",e),this.triggerChanError(e),this.clearHeartbeats(),this.closeWasClean||this.reconnectTimer.scheduleTimeout(),this.triggerStateCallbacks("close",e)}onConnError(e){this.hasLogger()&&this.log("transport","error",e);let t=this.transport,n=this.establishedConnections;this.triggerStateCallbacks("error",e,t,n),(t===this.transport||n>0)&&this.triggerChanError(e)}triggerChanError(e){this.channels.forEach(t=>{t.isErrored()||t.isLeaving()||t.isClosed()||t.trigger(fa.error,e)})}connectionState(){switch(this.conn&&this.conn.readyState){case Pr.connecting:return"connecting";case Pr.open:return"open";case Pr.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(e){this.off(e.stateChangeRefs),this.channels=this.channels.filter(t=>t!==e)}off(e){for(let t in this.stateChangeCallbacks)this.stateChangeCallbacks[t]=this.stateChangeCallbacks[t].filter(([n])=>e.indexOf(n)===-1)}channel(e,t={}){let n=new wO(e,t,this);return this.channels.push(n),n}push(e){if(this.hasLogger()){let{topic:t,event:n,payload:a,ref:i,join_ref:l}=e;this.log("push",`${t} ${n} (${l}, ${i})`,a)}this.isConnected()?this.encode(e,t=>this.conn.send(t)):this.sendBuffer.push(()=>this.encode(e,t=>this.conn.send(t)))}makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}sendHeartbeat(){if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(e){this.log("error","error in heartbeat callback",e)}return}if(this.pendingHeartbeatRef){this.heartbeatTimeout();return}this.pendingHeartbeatRef=this.makeRef(),this.heartbeatSentAt=Date.now(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(e){this.log("error","error in heartbeat callback",e)}this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs)}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}onConnMessage(e){this.decode(e.data,t=>{let{topic:n,event:a,payload:i,ref:l,join_ref:c}=t;if(l&&l===this.pendingHeartbeatRef){const f=this.heartbeatSentAt?Date.now()-this.heartbeatSentAt:void 0;this.clearHeartbeats();try{this.heartbeatCallback(i.status==="ok"?"ok":"error",f)}catch(h){this.log("error","error in heartbeat callback",h)}this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.autoSendHeartbeat&&(this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}this.hasLogger()&&this.log("receive",`${i.status||""} ${n} ${a} ${l&&"("+l+")"||""}`.trim(),i);for(let f=0;f<this.channels.length;f++){const h=this.channels[f];h.isMember(n,a,i,c)&&h.trigger(a,i,l,c)}this.triggerStateCallbacks("message",t)})}triggerStateCallbacks(e,...t){try{this.stateChangeCallbacks[e].forEach(([n,a])=>{try{a(...t)}catch(i){this.log("error",`error in ${e} callback`,i)}})}catch(n){this.log("error",`error triggering ${e} callbacks`,n)}}leaveOpenTopic(e){let t=this.channels.find(n=>n.topic===e&&(n.isJoined()||n.isJoining()));t&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${e}"`),t.leave())}};class Pl{constructor(t,n){const a=CO(n);this.presence=new SO(t.getChannel(),a),this.presence.onJoin((i,l,c)=>{const f=Pl.onJoinPayload(i,l,c);t.getChannel().trigger("presence",f)}),this.presence.onLeave((i,l,c)=>{const f=Pl.onLeavePayload(i,l,c);t.getChannel().trigger("presence",f)}),this.presence.onSync(()=>{t.getChannel().trigger("presence",{event:"sync"})})}get state(){return Pl.transformState(this.presence.state)}static transformState(t){return t=NO(t),Object.getOwnPropertyNames(t).reduce((n,a)=>{const i=t[a];return n[a]=pd(i),n},{})}static onJoinPayload(t,n,a){const i=Nw(n),l=pd(a);return{event:"join",key:t,currentPresences:i,newPresences:l}}static onLeavePayload(t,n,a){const i=Nw(n),l=pd(a);return{event:"leave",key:t,currentPresences:i,leftPresences:l}}}function pd(e){return e.metas.map(t=>(t.presence_ref=t.phx_ref,delete t.phx_ref,delete t.phx_ref_prev,t))}function NO(e){return JSON.parse(JSON.stringify(e))}function CO(e){return(e==null?void 0:e.events)&&{events:e.events}}function Nw(e){return e!=null&&e.metas?pd(e):[]}var Cw;(function(e){e.SYNC="sync",e.JOIN="join",e.LEAVE="leave"})(Cw||(Cw={}));class jO{get state(){return this.presenceAdapter.state}constructor(t,n){this.channel=t,this.presenceAdapter=new Pl(this.channel.channelAdapter,n)}}function TO(e){if(e instanceof Error)return e;if(typeof e=="string")return new Error(e);if(e&&typeof e=="object"){const t=e;if(typeof t.code=="number"){const n=typeof t.reason=="string"&&t.reason?` (${t.reason})`:"";return new Error(`socket closed: ${t.code}${n}`,{cause:e})}return new Error("channel error: transport failure",{cause:e})}return new Error("channel error: connection lost")}class RO{constructor(t,n,a){const i=AO(a);this.channel=t.getSocket().channel(n,i),this.socket=t}get state(){return this.channel.state}set state(t){this.channel.state=t}get joinedOnce(){return this.channel.joinedOnce}get joinPush(){return this.channel.joinPush}get rejoinTimer(){return this.channel.rejoinTimer}on(t,n){return this.channel.on(t,n)}off(t,n){this.channel.off(t,n)}subscribe(t){return this.channel.join(t)}unsubscribe(t){return this.channel.leave(t)}teardown(){this.channel.teardown()}onClose(t){this.channel.onClose(t)}onError(t){return this.channel.onError(t)}push(t,n,a){let i;try{i=this.channel.push(t,n,a)}catch{throw new Error(`tried to push '${t}' to '${this.channel.topic}' before joining. Use channel.subscribe() before pushing events`)}if(this.channel.pushBuffer.length>lO){const l=this.channel.pushBuffer.shift();l.cancelTimeout(),this.socket.log("channel",`discarded push due to buffer overflow: ${l.event}`,l.payload())}return i}updateJoinPayload(t){const n=this.channel.joinPush.payload();this.channel.joinPush.payload=()=>Object.assign(Object.assign({},n),t)}canPush(){return this.socket.isConnected()&&this.state===es.joined}isJoined(){return this.state===es.joined}isJoining(){return this.state===es.joining}isClosed(){return this.state===es.closed}isLeaving(){return this.state===es.leaving}updateFilterBindings(t){this.channel.filterBindings=t}updatePayloadTransform(t){this.channel.onMessage=t}getChannel(){return this.channel}}function AO(e){return{config:Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},e.config)}}var jw;(function(e){e.ALL="*",e.INSERT="INSERT",e.UPDATE="UPDATE",e.DELETE="DELETE"})(jw||(jw={}));var io;(function(e){e.BROADCAST="broadcast",e.PRESENCE="presence",e.POSTGRES_CHANGES="postgres_changes",e.SYSTEM="system"})(io||(io={}));var ha;(function(e){e.SUBSCRIBED="SUBSCRIBED",e.TIMED_OUT="TIMED_OUT",e.CLOSED="CLOSED",e.CHANNEL_ERROR="CHANNEL_ERROR"})(ha||(ha={}));class Ll{get state(){return this.channelAdapter.state}set state(t){this.channelAdapter.state=t}get joinedOnce(){return this.channelAdapter.joinedOnce}get timeout(){return this.socket.timeout}get joinPush(){return this.channelAdapter.joinPush}get rejoinTimer(){return this.channelAdapter.rejoinTimer}constructor(t,n={config:{}},a){var i,l;if(this.topic=t,this.params=n,this.socket=a,this.bindings={},this.subTopic=t.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},n.config),this.channelAdapter=new RO(this.socket.socketAdapter,t,this.params),this.presence=new jO(this),this._onClose(()=>{this.socket._remove(this)}),this._updateFilterTransform(),this.broadcastEndpointURL=XS(this.socket.socketAdapter.endPointURL()),this.private=this.params.config.private||!1,!this.private&&(!((l=(i=this.params.config)===null||i===void 0?void 0:i.broadcast)===null||l===void 0)&&l.replay))throw new Error(`tried to use replay on public channel '${this.topic}'. It must be a private channel.`)}subscribe(t,n=this.timeout){var a,i,l;if(this.socket.isConnected()||this.socket.connect(),this.channelAdapter.isClosed()){const{config:{broadcast:c,presence:f,private:h}}=this.params,m=(i=(a=this.bindings.postgres_changes)===null||a===void 0?void 0:a.map(w=>w.filter))!==null&&i!==void 0?i:[],b=!!this.bindings[io.PRESENCE]&&this.bindings[io.PRESENCE].length>0||((l=this.params.config.presence)===null||l===void 0?void 0:l.enabled)===!0,g={},x={broadcast:c,presence:Object.assign(Object.assign({},f),{enabled:b}),postgres_changes:m,private:h};this.socket.accessTokenValue&&(g.access_token=this.socket.accessTokenValue),this._onError(w=>{t==null||t(ha.CHANNEL_ERROR,TO(w))}),this._onClose(()=>t==null?void 0:t(ha.CLOSED)),this.updateJoinPayload(Object.assign({config:x},g)),this._updateFilterMessage(),this.channelAdapter.subscribe(n).receive("ok",async({postgres_changes:w})=>{if(this.socket._isManualToken()||this.socket.setAuth(),w===void 0){t==null||t(ha.SUBSCRIBED);return}this._updatePostgresBindings(w,t)}).receive("error",w=>{this.state=es.errored;const E=Object.values(w).join(", ")||"error";t==null||t(ha.CHANNEL_ERROR,new Error(E,{cause:w}))}).receive("timeout",()=>{t==null||t(ha.TIMED_OUT)})}return this}_updatePostgresBindings(t,n){var a;const i=this.bindings.postgres_changes,l=(a=i==null?void 0:i.length)!==null&&a!==void 0?a:0,c=[];for(let f=0;f<l;f++){const h=i[f],{filter:{event:m,schema:b,table:g,filter:x}}=h,w=t&&t[f];if(w&&w.event===m&&Ll.isFilterValueEqual(w.schema,b)&&Ll.isFilterValueEqual(w.table,g)&&Ll.isFilterValueEqual(w.filter,x))c.push(Object.assign(Object.assign({},h),{id:w.id}));else{this.unsubscribe(),this.state=es.errored,n==null||n(ha.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=c,this.state!=es.errored&&n&&n(ha.SUBSCRIBED)}presenceState(){return this.presence.state}async track(t,n={}){return await this.send({type:"presence",event:"track",payload:t},n.timeout||this.timeout)}async untrack(t={}){return await this.send({type:"presence",event:"untrack"},t)}on(t,n,a){const i=this.channelAdapter.isJoined()||this.channelAdapter.isJoining(),l=t===io.PRESENCE||t===io.POSTGRES_CHANGES;if(i&&l)throw this.socket.log("channel",`cannot add \`${t}\` callbacks for ${this.topic} after \`subscribe()\`.`),new Error(`cannot add \`${t}\` callbacks for ${this.topic} after \`subscribe()\`.`);return this._on(t,n,a)}async httpSend(t,n,a={}){var i;if(n==null)return Promise.reject(new Error("Payload is required for httpSend()"));const l={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(l.Authorization=`Bearer ${this.socket.accessTokenValue}`);const c={method:"POST",headers:l,body:JSON.stringify({messages:[{topic:this.subTopic,event:t,payload:n,private:this.private}]})},f=await this._fetchWithTimeout(this.broadcastEndpointURL,c,(i=a.timeout)!==null&&i!==void 0?i:this.timeout);if(f.status===202)return{success:!0};let h=f.statusText;try{const m=await f.json();h=m.error||m.message||h}catch{}return Promise.reject(new Error(h))}async send(t,n={}){var a,i;if(!this.channelAdapter.canPush()&&t.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:l,payload:c}=t,f={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(f.Authorization=`Bearer ${this.socket.accessTokenValue}`);const h={method:"POST",headers:f,body:JSON.stringify({messages:[{topic:this.subTopic,event:l,payload:c,private:this.private}]})};try{const m=await this._fetchWithTimeout(this.broadcastEndpointURL,h,(a=n.timeout)!==null&&a!==void 0?a:this.timeout);return await((i=m.body)===null||i===void 0?void 0:i.cancel()),m.ok?"ok":"error"}catch(m){return m instanceof Error&&m.name==="AbortError"?"timed out":"error"}}else return new Promise(l=>{var c,f,h;const m=this.channelAdapter.push(t.type,t,n.timeout||this.timeout);t.type==="broadcast"&&!(!((h=(f=(c=this.params)===null||c===void 0?void 0:c.config)===null||f===void 0?void 0:f.broadcast)===null||h===void 0)&&h.ack)&&l("ok"),m.receive("ok",()=>l("ok")),m.receive("error",()=>l("error")),m.receive("timeout",()=>l("timed out"))})}updateJoinPayload(t){this.channelAdapter.updateJoinPayload(t)}async unsubscribe(t=this.timeout){return new Promise(n=>{this.channelAdapter.unsubscribe(t).receive("ok",()=>n("ok")).receive("timeout",()=>n("timed out")).receive("error",()=>n("error"))})}teardown(){this.channelAdapter.teardown()}async _fetchWithTimeout(t,n,a){const i=new AbortController,l=setTimeout(()=>i.abort(),a),c=await this.socket.fetch(t,Object.assign(Object.assign({},n),{signal:i.signal}));return clearTimeout(l),c}_on(t,n,a){const i=t.toLocaleLowerCase(),l=this.channelAdapter.on(t,a),c={type:i,filter:n,callback:a,ref:l};return this.bindings[i]?this.bindings[i].push(c):this.bindings[i]=[c],this._updateFilterMessage(),this}_onClose(t){this.channelAdapter.onClose(t)}_onError(t){this.channelAdapter.onError(t)}_updateFilterMessage(){this.channelAdapter.updateFilterBindings((t,n,a)=>{var i,l,c,f,h,m,b;const g=t.event.toLocaleLowerCase();if(this._notThisChannelEvent(g,a))return!1;const x=(i=this.bindings[g])===null||i===void 0?void 0:i.find(w=>w.ref===t.ref);if(!x)return!0;if(["broadcast","presence","postgres_changes"].includes(g))if("id"in x){const w=x.id,E=(l=x.filter)===null||l===void 0?void 0:l.event;return w&&((c=n.ids)===null||c===void 0?void 0:c.includes(w))&&(E==="*"||(E==null?void 0:E.toLocaleLowerCase())===((f=n.data)===null||f===void 0?void 0:f.type.toLocaleLowerCase()))}else{const w=(m=(h=x==null?void 0:x.filter)===null||h===void 0?void 0:h.event)===null||m===void 0?void 0:m.toLocaleLowerCase();return w==="*"||w===((b=n==null?void 0:n.event)===null||b===void 0?void 0:b.toLocaleLowerCase())}else return x.type.toLocaleLowerCase()===g})}_notThisChannelEvent(t,n){const{close:a,error:i,leave:l,join:c}=WS;return n&&[a,i,l,c].includes(t)&&n!==this.joinPush.ref}_updateFilterTransform(){this.channelAdapter.updatePayloadTransform((t,n,a)=>{if(typeof n=="object"&&"ids"in n){const i=n.data,{schema:l,table:c,commit_timestamp:f,type:h,errors:m}=i;return Object.assign(Object.assign({},{schema:l,table:c,commit_timestamp:f,eventType:h,new:{},old:{},errors:m}),this._getPayloadRecords(i))}return n})}copyBindings(t){if(this.joinedOnce)throw new Error("cannot copy bindings into joined channel");for(const n in t.bindings)for(const a of t.bindings[n])this._on(a.type,a.filter,a.callback)}static isFilterValueEqual(t,n){return(t??void 0)===(n??void 0)}_getPayloadRecords(t){const n={new:{},old:{}};return(t.type==="INSERT"||t.type==="UPDATE")&&(n.new=Ew(t.columns,t.record)),(t.type==="UPDATE"||t.type==="DELETE")&&(n.old=Ew(t.columns,t.old_record)),n}}class kO{constructor(t,n){this.socket=new EO(t,n)}get timeout(){return this.socket.timeout}get endPoint(){return this.socket.endPoint}get transport(){return this.socket.transport}get heartbeatIntervalMs(){return this.socket.heartbeatIntervalMs}get heartbeatCallback(){return this.socket.heartbeatCallback}set heartbeatCallback(t){this.socket.heartbeatCallback=t}get heartbeatTimer(){return this.socket.heartbeatTimer}get pendingHeartbeatRef(){return this.socket.pendingHeartbeatRef}get reconnectTimer(){return this.socket.reconnectTimer}get vsn(){return this.socket.vsn}get encode(){return this.socket.encode}get decode(){return this.socket.decode}get reconnectAfterMs(){return this.socket.reconnectAfterMs}get sendBuffer(){return this.socket.sendBuffer}get stateChangeCallbacks(){return this.socket.stateChangeCallbacks}connect(){this.socket.connect()}disconnect(t,n,a,i=1e4){return new Promise(l=>{setTimeout(()=>l("timeout"),i),this.socket.disconnect(()=>{t(),l("ok")},n,a)})}push(t){this.socket.push(t)}log(t,n,a){this.socket.log(t,n,a)}makeRef(){return this.socket.makeRef()}onOpen(t){this.socket.onOpen(t)}onClose(t){this.socket.onClose(t)}onError(t){this.socket.onError(t)}onMessage(t){this.socket.onMessage(t)}isConnected(){return this.socket.isConnected()}isConnecting(){return this.socket.connectionState()==Zp.connecting}isDisconnecting(){return this.socket.connectionState()==Zp.closing}connectionState(){return this.socket.connectionState()}endPointURL(){return this.socket.endPointURL()}sendHeartbeat(){this.socket.sendHeartbeat()}getSocket(){return this.socket}}const Tw={HEARTBEAT_INTERVAL:25e3},OO=[1e3,2e3,5e3,1e4],MO=1e4;function DO(){const e=new Map;return{get length(){return e.size},clear(){e.clear()},getItem(t){return e.has(t)?e.get(t):null},key(t){var n;return(n=Array.from(e.keys())[t])!==null&&n!==void 0?n:null},removeItem(t){e.delete(t)},setItem(t,n){e.set(t,String(n))}}}function PO(){try{if(typeof globalThis<"u"&&globalThis.sessionStorage)return globalThis.sessionStorage}catch{}return DO()}const LO=`
addEventListener("message", (e) => {
if (e.data.event === "start") {
setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
}
});`;class zO{get endPoint(){return this.socketAdapter.endPoint}get timeout(){return this.socketAdapter.timeout}get transport(){return this.socketAdapter.transport}get heartbeatCallback(){return this.socketAdapter.heartbeatCallback}get heartbeatIntervalMs(){return this.socketAdapter.heartbeatIntervalMs}get heartbeatTimer(){return this.worker?this._workerHeartbeatTimer:this.socketAdapter.heartbeatTimer}get pendingHeartbeatRef(){return this.worker?this._pendingWorkerHeartbeatRef:this.socketAdapter.pendingHeartbeatRef}get reconnectTimer(){return this.socketAdapter.reconnectTimer}get vsn(){return this.socketAdapter.vsn}get encode(){return this.socketAdapter.encode}get decode(){return this.socketAdapter.decode}get reconnectAfterMs(){return this.socketAdapter.reconnectAfterMs}get sendBuffer(){return this.socketAdapter.sendBuffer}get stateChangeCallbacks(){return this.socketAdapter.stateChangeCallbacks}constructor(t,n){var a;if(this.channels=new Array,this.accessTokenValue=null,this.accessToken=null,this.apiKey=null,this.httpEndpoint="",this.headers={},this.params={},this.ref=0,this.serializer=new cO,this._manuallySetToken=!1,this._authPromise=null,this._workerHeartbeatTimer=void 0,this._pendingWorkerHeartbeatRef=null,this._pendingDisconnectTimer=null,this._disconnectOnEmptyChannelsAfterMs=0,this._resolveFetch=l=>l?(...c)=>l(...c):(...c)=>fetch(...c),!(!((a=n==null?void 0:n.params)===null||a===void 0)&&a.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=n.params.apikey;const i=this._initializeOptions(n);this.socketAdapter=new kO(t,i),this.httpEndpoint=XS(t),this.fetch=this._resolveFetch(n==null?void 0:n.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.isConnected())){this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this._setupConnectionHandlers();try{this.socketAdapter.connect()}catch(t){const n=t.message;throw n.includes("Node.js")?new Error(`${n}
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: ${n}`)}this._handleNodeJsRaceCondition()}}endpointURL(){return this.socketAdapter.endPointURL()}async disconnect(t,n){return this._cancelPendingDisconnect(),this.isDisconnecting()?"ok":await this.socketAdapter.disconnect(()=>{clearInterval(this._workerHeartbeatTimer),this._terminateWorker()},t,n)}getChannels(){return this.channels}async removeChannel(t){const n=await t.unsubscribe();return n==="ok"&&t.teardown(),n}async removeAllChannels(){const t=this.channels.map(async a=>{const i=await a.unsubscribe();return a.teardown(),i}),n=await Promise.all(t);return await this.disconnect(),n}log(t,n,a){this.socketAdapter.log(t,n,a)}connectionState(){return this.socketAdapter.connectionState()||Zp.closed}isConnected(){return this.socketAdapter.isConnected()}isConnecting(){return this.socketAdapter.isConnecting()}isDisconnecting(){return this.socketAdapter.isDisconnecting()}channel(t,n={config:{}}){const a=`realtime:${t}`,i=this.getChannels().find(l=>l.topic===a);if(i)return i;{const l=new Ll(`realtime:${t}`,n,this);return this._cancelPendingDisconnect(),this.channels.push(l),l}}push(t){this.socketAdapter.push(t)}async setAuth(t=null){this._authPromise=this._performAuth(t);try{await this._authPromise}finally{this._authPromise=null}}_isManualToken(){return this._manuallySetToken}async sendHeartbeat(){this.socketAdapter.sendHeartbeat()}onHeartbeat(t){this.socketAdapter.heartbeatCallback=this._wrapHeartbeatCallback(t)}_makeRef(){return this.socketAdapter.makeRef()}_remove(t){this.channels=this.channels.filter(n=>n.topic!==t.topic),this.channels.length===0&&(this.log("transport","no channels remaining, scheduling disconnect"),this._schedulePendingDisconnect())}_schedulePendingDisconnect(){if(this._cancelPendingDisconnect(),this._disconnectOnEmptyChannelsAfterMs===0){this.log("transport","disconnecting immediately - no channels"),this.disconnect();return}this._pendingDisconnectTimer=setTimeout(()=>{this._pendingDisconnectTimer=null,this.channels.length===0&&(this.log("transport","deferred disconnect fired - no channels, disconnecting"),this.disconnect())},this._disconnectOnEmptyChannelsAfterMs),this.log("transport",`deferred disconnect scheduled in ${this._disconnectOnEmptyChannelsAfterMs}ms`)}_cancelPendingDisconnect(){this._pendingDisconnectTimer!==null&&(this.log("transport","pending disconnect cancelled - channel activity detected"),clearTimeout(this._pendingDisconnectTimer),this._pendingDisconnectTimer=null)}async _performAuth(t=null){let n,a=!1;if(t)n=t,a=!0;else if(this.accessToken)try{n=await this.accessToken()}catch(i){this.log("error","Error fetching access token from callback",i),n=this.accessTokenValue}else n=this.accessTokenValue;a?this._manuallySetToken=!0:this.accessToken&&(this._manuallySetToken=!1),this.accessTokenValue!=n&&(this.accessTokenValue=n,this.channels.forEach(i=>{const l={access_token:n,version:aO};n&&i.updateJoinPayload(l),i.joinedOnce&&i.channelAdapter.isJoined()&&i.channelAdapter.push(WS.access_token,{access_token:n})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(t="general"){this._isManualToken()||this.setAuth().catch(n=>{this.log("error",`Error setting auth in ${t}`,n)})}_setupConnectionHandlers(){this.socketAdapter.onOpen(()=>{(this._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve())).catch(n=>{this.log("error","error waiting for auth on connect",n)}),this.worker&&!this.workerRef&&this._startWorkerHeartbeat()}),this.socketAdapter.onClose(()=>{this.worker&&this.workerRef&&this._terminateWorker()}),this.socketAdapter.onMessage(t=>{t.ref&&t.ref===this._pendingWorkerHeartbeatRef&&(this._pendingWorkerHeartbeatRef=null)})}_handleNodeJsRaceCondition(){this.socketAdapter.isConnected()&&this.socketAdapter.getSocket().onConnOpen()}_wrapHeartbeatCallback(t){return(n,a)=>{n=="sent"&&this._setAuthSafely(),t&&t(n,a)}}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const t=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(t),this.workerRef.onerror=n=>{this.log("worker","worker error",n.message),this._terminateWorker(),this.disconnect()},this.workerRef.onmessage=n=>{n.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_terminateWorker(){this.workerRef&&(this.log("worker","terminating worker"),this.workerRef.terminate(),this.workerRef=void 0)}_workerObjectUrl(t){let n;if(t)n=t;else{const a=new Blob([LO],{type:"application/javascript"});n=URL.createObjectURL(a)}return n}_initializeOptions(t){var n,a,i,l,c,f,h,m,b,g,x,w;this.worker=(n=t==null?void 0:t.worker)!==null&&n!==void 0?n:!1,this.accessToken=(a=t==null?void 0:t.accessToken)!==null&&a!==void 0?a:null;const E={};E.timeout=(i=t==null?void 0:t.timeout)!==null&&i!==void 0?i:oO,E.heartbeatIntervalMs=(l=t==null?void 0:t.heartbeatIntervalMs)!==null&&l!==void 0?l:Tw.HEARTBEAT_INTERVAL,this._disconnectOnEmptyChannelsAfterMs=(c=t==null?void 0:t.disconnectOnEmptyChannelsAfterMs)!==null&&c!==void 0?c:2*((f=t==null?void 0:t.heartbeatIntervalMs)!==null&&f!==void 0?f:Tw.HEARTBEAT_INTERVAL),E.transport=(h=t==null?void 0:t.transport)!==null&&h!==void 0?h:nO.getWebSocketConstructor(),E.params=t==null?void 0:t.params,E.logger=t==null?void 0:t.logger,E.heartbeatCallback=this._wrapHeartbeatCallback(t==null?void 0:t.heartbeatCallback),E.sessionStorage=(m=t==null?void 0:t.sessionStorage)!==null&&m!==void 0?m:PO(),E.reconnectAfterMs=(b=t==null?void 0:t.reconnectAfterMs)!==null&&b!==void 0?b:(A=>OO[A-1]||MO);let S,C;const N=(g=t==null?void 0:t.vsn)!==null&&g!==void 0?g:iO;switch(N){case sO:S=(A,T)=>T(JSON.stringify(A)),C=(A,T)=>T(JSON.parse(A));break;case KS:S=this.serializer.encode.bind(this.serializer),C=this.serializer.decode.bind(this.serializer);break;default:throw new Error(`Unsupported serializer version: ${E.vsn}`)}if(E.vsn=N,E.encode=(x=t==null?void 0:t.encode)!==null&&x!==void 0?x:S,E.decode=(w=t==null?void 0:t.decode)!==null&&w!==void 0?w:C,E.beforeReconnect=this._reconnectAuth.bind(this),(t!=null&&t.logLevel||t!=null&&t.log_level)&&(this.logLevel=t.logLevel||t.log_level,E.params=Object.assign(Object.assign({},E.params),{log_level:this.logLevel})),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=t==null?void 0:t.workerUrl,E.autoSendHeartbeat=!this.worker}return E}async _reconnectAuth(){await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()}}var ql=class extends Error{constructor(e,t){var n;super(e),this.name="IcebergError",this.status=t.status,this.icebergType=t.icebergType,this.icebergCode=t.icebergCode,this.details=t.details,this.isCommitStateUnknown=t.icebergType==="CommitStateUnknownException"||[500,502,504].includes(t.status)&&((n=t.icebergType)==null?void 0:n.includes("CommitState"))===!0}isNotFound(){return this.status===404}isConflict(){return this.status===409}isAuthenticationTimeout(){return this.status===419}};function IO(e,t,n){const a=new URL(t,e);if(n)for(const[i,l]of Object.entries(n))l!==void 0&&a.searchParams.set(i,l);return a.toString()}async function $O(e){return!e||e.type==="none"?{}:e.type==="bearer"?{Authorization:`Bearer ${e.token}`}:e.type==="header"?{[e.name]:e.value}:e.type==="custom"?await e.getHeaders():{}}function UO(e){const t=e.fetchImpl??globalThis.fetch;return{async request({method:n,path:a,query:i,body:l,headers:c}){const f=IO(e.baseUrl,a,i),h=await $O(e.auth),m=await t(f,{method:n,headers:{...l?{"Content-Type":"application/json"}:{},...h,...c},body:l?JSON.stringify(l):void 0}),b=await m.text(),g=(m.headers.get("content-type")||"").includes("application/json"),x=g&&b?JSON.parse(b):b;if(!m.ok){const w=g?x:void 0,E=w==null?void 0:w.error;throw new ql((E==null?void 0:E.message)??`Request failed with status ${m.status}`,{status:m.status,icebergType:E==null?void 0:E.type,icebergCode:E==null?void 0:E.code,details:w})}return{status:m.status,headers:m.headers,data:x}}}}function Lu(e){return e.join("")}var BO=class{constructor(e,t=""){this.client=e,this.prefix=t}async listNamespaces(e){const t=e?{parent:Lu(e.namespace)}:void 0;return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces`,query:t})).data.namespaces.map(a=>({namespace:a}))}async createNamespace(e,t){const n={namespace:e.namespace,properties:t==null?void 0:t.properties};return(await this.client.request({method:"POST",path:`${this.prefix}/namespaces`,body:n})).data}async dropNamespace(e){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${Lu(e.namespace)}`})}async loadNamespaceMetadata(e){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Lu(e.namespace)}`})).data.properties}}async namespaceExists(e){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${Lu(e.namespace)}`}),!0}catch(t){if(t instanceof ql&&t.status===404)return!1;throw t}}async createNamespaceIfNotExists(e,t){try{return await this.createNamespace(e,t)}catch(n){if(n instanceof ql&&n.status===409)return;throw n}}};function Vi(e){return e.join("")}var HO=class{constructor(e,t="",n){this.client=e,this.prefix=t,this.accessDelegation=n}async listTables(e){return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Vi(e.namespace)}/tables`})).data.identifiers}async createTable(e,t){const n={};return this.accessDelegation&&(n["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${Vi(e.namespace)}/tables`,body:t,headers:n})).data.metadata}async updateTable(e,t){const n=await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${Vi(e.namespace)}/tables/${e.name}`,body:t});return{"metadata-location":n.data["metadata-location"],metadata:n.data.metadata}}async dropTable(e,t){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${Vi(e.namespace)}/tables/${e.name}`,query:{purgeRequested:String((t==null?void 0:t.purge)??!1)}})}async loadTable(e){const t={};return this.accessDelegation&&(t["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Vi(e.namespace)}/tables/${e.name}`,headers:t})).data.metadata}async tableExists(e){const t={};this.accessDelegation&&(t["X-Iceberg-Access-Delegation"]=this.accessDelegation);try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${Vi(e.namespace)}/tables/${e.name}`,headers:t}),!0}catch(n){if(n instanceof ql&&n.status===404)return!1;throw n}}async createTableIfNotExists(e,t){try{return await this.createTable(e,t)}catch(n){if(n instanceof ql&&n.status===409)return await this.loadTable({namespace:e.namespace,name:t.name});throw n}}},qO=class{constructor(e){var a;let t="v1";e.catalogName&&(t+=`/${e.catalogName}`);const n=e.baseUrl.endsWith("/")?e.baseUrl:`${e.baseUrl}/`;this.client=UO({baseUrl:n,auth:e.auth,fetchImpl:e.fetch}),this.accessDelegation=(a=e.accessDelegation)==null?void 0:a.join(","),this.namespaceOps=new BO(this.client,t),this.tableOps=new HO(this.client,t,this.accessDelegation)}async listNamespaces(e){return this.namespaceOps.listNamespaces(e)}async createNamespace(e,t){return this.namespaceOps.createNamespace(e,t)}async dropNamespace(e){await this.namespaceOps.dropNamespace(e)}async loadNamespaceMetadata(e){return this.namespaceOps.loadNamespaceMetadata(e)}async listTables(e){return this.tableOps.listTables(e)}async createTable(e,t){return this.tableOps.createTable(e,t)}async updateTable(e,t){return this.tableOps.updateTable(e,t)}async dropTable(e,t){await this.tableOps.dropTable(e,t)}async loadTable(e){return this.tableOps.loadTable(e)}async namespaceExists(e){return this.namespaceOps.namespaceExists(e)}async tableExists(e){return this.tableOps.tableExists(e)}async createNamespaceIfNotExists(e,t){return this.namespaceOps.createNamespaceIfNotExists(e,t)}async createTableIfNotExists(e,t){return this.tableOps.createTableIfNotExists(e,t)}};function Vl(e){"@babel/helpers - typeof";return Vl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Vl(e)}function VO(e,t){if(Vl(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var a=n.call(e,t);if(Vl(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function FO(e){var t=VO(e,"string");return Vl(t)=="symbol"?t:t+""}function GO(e,t,n){return(t=FO(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Rw(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,a)}return n}function Fe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Rw(Object(n),!0).forEach(function(a){GO(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Rw(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}var of=class extends Error{constructor(e,t="storage",n,a){super(e),this.__isStorageError=!0,this.namespace=t,this.name=t==="vectors"?"StorageVectorsError":"StorageError",this.status=n,this.statusCode=a}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}};function lf(e){return typeof e=="object"&&e!==null&&"__isStorageError"in e}var rg=class extends of{constructor(e,t,n,a="storage"){super(e,a,t,n),this.name=a==="vectors"?"StorageVectorsApiError":"StorageApiError",this.status=t,this.statusCode=n}toJSON(){return Fe({},super.toJSON())}},QS=class extends of{constructor(e,t,n="storage"){super(e,n),this.name=n==="vectors"?"StorageVectorsUnknownError":"StorageUnknownError",this.originalError=t}};function Td(e,t,n){const a=Fe({},e),i=t.toLowerCase();for(const l of Object.keys(a))l.toLowerCase()===i&&delete a[l];return a[i]=n,a}function KO(e){const t={};for(const[n,a]of Object.entries(e))t[n.toLowerCase()]=a;return t}const WO=e=>e?(...t)=>e(...t):(...t)=>fetch(...t),YO=e=>{if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},ag=e=>{if(Array.isArray(e))return e.map(n=>ag(n));if(typeof e=="function"||e!==Object(e))return e;const t={};return Object.entries(e).forEach(([n,a])=>{const i=n.replace(/([-_][a-z])/gi,l=>l.toUpperCase().replace(/[-_]/g,""));t[i]=ag(a)}),t},XO=e=>!e||typeof e!="string"||e.length===0||e.length>100||e.trim()!==e||e.includes("/")||e.includes("\\")?!1:/^[\w!.\*'() &$@=;:+,?-]+$/.test(e),Aw=e=>{if(typeof e=="object"&&e!==null){const t=e;if(typeof t.msg=="string")return t.msg;if(typeof t.message=="string")return t.message;if(typeof t.error_description=="string")return t.error_description;if(typeof t.error=="string")return t.error;if(typeof t.error=="object"&&t.error!==null){const n=t.error;if(typeof n.message=="string")return n.message}}return JSON.stringify(e)},JO=async(e,t,n,a)=>{if(e!==null&&typeof e=="object"&&"json"in e&&typeof e.json=="function"){const i=e;let l=parseInt(String(i.status),10);Number.isFinite(l)||(l=500),i.json().then(c=>{const f=(c==null?void 0:c.statusCode)||(c==null?void 0:c.code)||l+"";t(new rg(Aw(c),l,f,a))}).catch(()=>{const c=l+"";t(new rg(i.statusText||`HTTP ${l} error`,l,c,a))})}else t(new QS(Aw(e),e,a))},QO=(e,t,n,a)=>{const i={method:e,headers:(t==null?void 0:t.headers)||{}};if(e==="GET"||e==="HEAD"||!a)return Fe(Fe({},i),n);if(YO(a)){var l;const c=(t==null?void 0:t.headers)||{};let f;for(const[h,m]of Object.entries(c))h.toLowerCase()==="content-type"&&(f=m);i.headers=Td(c,"Content-Type",(l=f)!==null&&l!==void 0?l:"application/json"),i.body=JSON.stringify(a)}else i.body=a;return t!=null&&t.duplex&&(i.duplex=t.duplex),Fe(Fe({},i),n)};async function Sl(e,t,n,a,i,l,c){return new Promise((f,h)=>{e(n,QO(t,a,i,l)).then(m=>{if(!m.ok)throw m;if(a!=null&&a.noResolveJson)return m;if(c==="vectors"){const b=m.headers.get("content-type");if(m.headers.get("content-length")==="0"||m.status===204)return{};if(!b||!b.includes("application/json"))return{}}return m.json()}).then(m=>f(m)).catch(m=>JO(m,h,a,c))})}function ZS(e="storage"){return{get:async(t,n,a,i)=>Sl(t,"GET",n,a,i,void 0,e),post:async(t,n,a,i,l)=>Sl(t,"POST",n,i,l,a,e),put:async(t,n,a,i,l)=>Sl(t,"PUT",n,i,l,a,e),head:async(t,n,a,i)=>Sl(t,"HEAD",n,Fe(Fe({},a),{},{noResolveJson:!0}),i,void 0,e),remove:async(t,n,a,i,l)=>Sl(t,"DELETE",n,i,l,a,e)}}const ZO=ZS("storage"),{get:Fl,post:br,put:sg,head:eM,remove:ev}=ZO,Kn=ZS("vectors");var Co=class{constructor(e,t={},n,a="storage"){this.shouldThrowOnError=!1,this.url=e,this.headers=KO(t),this.fetch=WO(n),this.namespace=a}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=Td(this.headers,e,t),this}async handleOperation(e){var t=this;try{return{data:await e(),error:null}}catch(n){if(t.shouldThrowOnError)throw n;if(lf(n))return{data:null,error:n};throw n}}};let e1;e1=Symbol.toStringTag;var tM=class{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t,this[e1]="StreamDownloadBuilder",this.promise=null}then(e,t){return this.getPromise().then(e,t)}catch(e){return this.getPromise().catch(e)}finally(e){return this.getPromise().finally(e)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){var e=this;try{return{data:(await e.downloadFn()).body,error:null}}catch(t){if(e.shouldThrowOnError)throw t;if(lf(t))return{data:null,error:t};throw t}}};let t1;t1=Symbol.toStringTag;var nM=class{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t,this[t1]="BlobDownloadBuilder",this.promise=null}asStream(){return new tM(this.downloadFn,this.shouldThrowOnError)}then(e,t){return this.getPromise().then(e,t)}catch(e){return this.getPromise().catch(e)}finally(e){return this.getPromise().finally(e)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){var e=this;try{return{data:await(await e.downloadFn()).blob(),error:null}}catch(t){if(e.shouldThrowOnError)throw t;if(lf(t))return{data:null,error:t};throw t}}};const rM={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},kw={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var aM=class extends Co{constructor(e,t={},n,a){super(e,t,a,"storage"),this.bucketId=n}async uploadOrUpdate(e,t,n,a){var i=this;return i.handleOperation(async()=>{let l;const c=Fe(Fe({},kw),a);let f=Fe(Fe({},i.headers),e==="POST"&&{"x-upsert":String(c.upsert)});const h=c.metadata;if(typeof Blob<"u"&&n instanceof Blob?(l=new FormData,l.append("cacheControl",c.cacheControl),h&&l.append("metadata",i.encodeMetadata(h)),l.append("",n)):typeof FormData<"u"&&n instanceof FormData?(l=n,l.has("cacheControl")||l.append("cacheControl",c.cacheControl),h&&!l.has("metadata")&&l.append("metadata",i.encodeMetadata(h))):(l=n,f["cache-control"]=`max-age=${c.cacheControl}`,f["content-type"]=c.contentType,h&&(f["x-metadata"]=i.toBase64(i.encodeMetadata(h))),(typeof ReadableStream<"u"&&l instanceof ReadableStream||l&&typeof l=="object"&&"pipe"in l&&typeof l.pipe=="function")&&!c.duplex&&(c.duplex="half")),a!=null&&a.headers)for(const[x,w]of Object.entries(a.headers))f=Td(f,x,w);const m=i._removeEmptyFolders(t),b=i._getFinalPath(m),g=await(e=="PUT"?sg:br)(i.fetch,`${i.url}/object/${b}`,l,Fe({headers:f},c!=null&&c.duplex?{duplex:c.duplex}:{}));return{path:m,id:g.Id,fullPath:g.Key}})}async upload(e,t,n){return this.uploadOrUpdate("POST",e,t,n)}async uploadToSignedUrl(e,t,n,a){var i=this;const l=i._removeEmptyFolders(e),c=i._getFinalPath(l),f=new URL(i.url+`/object/upload/sign/${c}`);return f.searchParams.set("token",t),i.handleOperation(async()=>{let h;const m=Fe(Fe({},kw),a);let b=Fe(Fe({},i.headers),{"x-upsert":String(m.upsert)});const g=m.metadata;if(typeof Blob<"u"&&n instanceof Blob?(h=new FormData,h.append("cacheControl",m.cacheControl),g&&h.append("metadata",i.encodeMetadata(g)),h.append("",n)):typeof FormData<"u"&&n instanceof FormData?(h=n,h.has("cacheControl")||h.append("cacheControl",m.cacheControl),g&&!h.has("metadata")&&h.append("metadata",i.encodeMetadata(g))):(h=n,b["cache-control"]=`max-age=${m.cacheControl}`,b["content-type"]=m.contentType,g&&(b["x-metadata"]=i.toBase64(i.encodeMetadata(g))),(typeof ReadableStream<"u"&&h instanceof ReadableStream||h&&typeof h=="object"&&"pipe"in h&&typeof h.pipe=="function")&&!m.duplex&&(m.duplex="half")),a!=null&&a.headers)for(const[x,w]of Object.entries(a.headers))b=Td(b,x,w);return{path:l,fullPath:(await sg(i.fetch,f.toString(),h,Fe({headers:b},m!=null&&m.duplex?{duplex:m.duplex}:{}))).Key}})}async createSignedUploadUrl(e,t){var n=this;return n.handleOperation(async()=>{let a=n._getFinalPath(e);const i=Fe({},n.headers);t!=null&&t.upsert&&(i["x-upsert"]="true");const l=await br(n.fetch,`${n.url}/object/upload/sign/${a}`,{},{headers:i}),c=new URL(n.url+l.url),f=c.searchParams.get("token");if(!f)throw new of("No token returned by API");return{signedUrl:c.toString(),path:e,token:f}})}async update(e,t,n){return this.uploadOrUpdate("PUT",e,t,n)}async move(e,t,n){var a=this;return a.handleOperation(async()=>await br(a.fetch,`${a.url}/object/move`,{bucketId:a.bucketId,sourceKey:e,destinationKey:t,destinationBucket:n==null?void 0:n.destinationBucket},{headers:a.headers}))}async copy(e,t,n){var a=this;return a.handleOperation(async()=>({path:(await br(a.fetch,`${a.url}/object/copy`,{bucketId:a.bucketId,sourceKey:e,destinationKey:t,destinationBucket:n==null?void 0:n.destinationBucket},{headers:a.headers})).Key}))}async createSignedUrl(e,t,n){var a=this;return a.handleOperation(async()=>{let i=a._getFinalPath(e);const l=typeof(n==null?void 0:n.transform)=="object"&&n.transform!==null&&Object.keys(n.transform).length>0;let c=await br(a.fetch,`${a.url}/object/sign/${i}`,Fe({expiresIn:t},l?{transform:n.transform}:{}),{headers:a.headers});const f=new URLSearchParams;n!=null&&n.download&&f.set("download",n.download===!0?"":n.download),(n==null?void 0:n.cacheNonce)!=null&&f.set("cacheNonce",String(n.cacheNonce));const h=f.toString();return{signedUrl:encodeURI(`${a.url}${c.signedURL}${h?`&${h}`:""}`)}})}async createSignedUrls(e,t,n){var a=this;return a.handleOperation(async()=>{const i=await br(a.fetch,`${a.url}/object/sign/${a.bucketId}`,{expiresIn:t,paths:e},{headers:a.headers}),l=new URLSearchParams;n!=null&&n.download&&l.set("download",n.download===!0?"":n.download),(n==null?void 0:n.cacheNonce)!=null&&l.set("cacheNonce",String(n.cacheNonce));const c=l.toString();return i.map(f=>Fe(Fe({},f),{},{signedUrl:f.signedURL?encodeURI(`${a.url}${f.signedURL}${c?`&${c}`:""}`):null}))})}download(e,t,n){const a=typeof(t==null?void 0:t.transform)=="object"&&t.transform!==null&&Object.keys(t.transform).length>0?"render/image/authenticated":"object",i=new URLSearchParams;t!=null&&t.transform&&this.applyTransformOptsToQuery(i,t.transform),(t==null?void 0:t.cacheNonce)!=null&&i.set("cacheNonce",String(t.cacheNonce));const l=i.toString(),c=this._getFinalPath(e),f=()=>Fl(this.fetch,`${this.url}/${a}/${c}${l?`?${l}`:""}`,{headers:this.headers,noResolveJson:!0},n);return new nM(f,this.shouldThrowOnError)}async info(e){var t=this;const n=t._getFinalPath(e);return t.handleOperation(async()=>ag(await Fl(t.fetch,`${t.url}/object/info/${n}`,{headers:t.headers})))}async exists(e){var t=this;const n=t._getFinalPath(e);try{return await eM(t.fetch,`${t.url}/object/${n}`,{headers:t.headers}),{data:!0,error:null}}catch(i){if(t.shouldThrowOnError)throw i;if(lf(i)){var a;const l=i instanceof rg?i.status:i instanceof QS?(a=i.originalError)===null||a===void 0?void 0:a.status:void 0;if(l!==void 0&&[400,404].includes(l))return{data:!1,error:i}}throw i}}getPublicUrl(e,t){const n=this._getFinalPath(e),a=new URLSearchParams;t!=null&&t.download&&a.set("download",t.download===!0?"":t.download),t!=null&&t.transform&&this.applyTransformOptsToQuery(a,t.transform),(t==null?void 0:t.cacheNonce)!=null&&a.set("cacheNonce",String(t.cacheNonce));const i=a.toString(),l=typeof(t==null?void 0:t.transform)=="object"&&t.transform!==null&&Object.keys(t.transform).length>0?"render/image":"object";return{data:{publicUrl:encodeURI(`${this.url}/${l}/public/${n}`)+(i?`?${i}`:"")}}}async remove(e){var t=this;return t.handleOperation(async()=>await ev(t.fetch,`${t.url}/object/${t.bucketId}`,{prefixes:e},{headers:t.headers}))}async list(e,t,n){var a=this;return a.handleOperation(async()=>{const i=Fe(Fe(Fe({},rM),t),{},{prefix:e||""});return await br(a.fetch,`${a.url}/object/list/${a.bucketId}`,i,{headers:a.headers},n)})}async listV2(e,t){var n=this;return n.handleOperation(async()=>{const a=Fe({},e);return await br(n.fetch,`${n.url}/object/list-v2/${n.bucketId}`,a,{headers:n.headers},t)})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return typeof Buffer<"u"?Buffer.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e.replace(/^\/+/,"")}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}applyTransformOptsToQuery(e,t){return t.width&&e.set("width",t.width.toString()),t.height&&e.set("height",t.height.toString()),t.resize&&e.set("resize",t.resize),t.format&&e.set("format",t.format),t.quality&&e.set("quality",t.quality.toString()),e}};const sM="2.106.2",sc={"X-Client-Info":`storage-js/${sM}`};var iM=class extends Co{constructor(e,t={},n,a){const i=new URL(e);a!=null&&a.useNewHostname&&/supabase\.(co|in|red)$/.test(i.hostname)&&!i.hostname.includes("storage.supabase.")&&(i.hostname=i.hostname.replace("supabase.","storage.supabase."));const l=i.href.replace(/\/$/,""),c=Fe(Fe({},sc),t);super(l,c,n,"storage")}async listBuckets(e){var t=this;return t.handleOperation(async()=>{const n=t.listBucketOptionsToQueryString(e);return await Fl(t.fetch,`${t.url}/bucket${n}`,{headers:t.headers})})}async getBucket(e){var t=this;return t.handleOperation(async()=>await Fl(t.fetch,`${t.url}/bucket/${e}`,{headers:t.headers}))}async createBucket(e,t={public:!1}){var n=this;return n.handleOperation(async()=>await br(n.fetch,`${n.url}/bucket`,{id:e,name:e,type:t.type,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:n.headers}))}async updateBucket(e,t){var n=this;return n.handleOperation(async()=>await sg(n.fetch,`${n.url}/bucket/${e}`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:n.headers}))}async emptyBucket(e){var t=this;return t.handleOperation(async()=>await br(t.fetch,`${t.url}/bucket/${e}/empty`,{},{headers:t.headers}))}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await ev(t.fetch,`${t.url}/bucket/${e}`,{},{headers:t.headers}))}listBucketOptionsToQueryString(e){const t={};return e&&("limit"in e&&(t.limit=String(e.limit)),"offset"in e&&(t.offset=String(e.offset)),e.search&&(t.search=e.search),e.sortColumn&&(t.sortColumn=e.sortColumn),e.sortOrder&&(t.sortOrder=e.sortOrder)),Object.keys(t).length>0?"?"+new URLSearchParams(t).toString():""}},oM=class extends Co{constructor(e,t={},n){const a=e.replace(/\/$/,""),i=Fe(Fe({},sc),t);super(a,i,n,"storage")}async createBucket(e){var t=this;return t.handleOperation(async()=>await br(t.fetch,`${t.url}/bucket`,{name:e},{headers:t.headers}))}async listBuckets(e){var t=this;return t.handleOperation(async()=>{const n=new URLSearchParams;(e==null?void 0:e.limit)!==void 0&&n.set("limit",e.limit.toString()),(e==null?void 0:e.offset)!==void 0&&n.set("offset",e.offset.toString()),e!=null&&e.sortColumn&&n.set("sortColumn",e.sortColumn),e!=null&&e.sortOrder&&n.set("sortOrder",e.sortOrder),e!=null&&e.search&&n.set("search",e.search);const a=n.toString(),i=a?`${t.url}/bucket?${a}`:`${t.url}/bucket`;return await Fl(t.fetch,i,{headers:t.headers})})}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await ev(t.fetch,`${t.url}/bucket/${e}`,{},{headers:t.headers}))}from(e){var t=this;if(!XO(e))throw new of("Invalid bucket name: File, folder, and bucket names must follow AWS object key naming guidelines and should avoid the use of any other characters.");const n=new qO({baseUrl:this.url,catalogName:e,auth:{type:"custom",getHeaders:async()=>t.headers},fetch:this.fetch}),a=this.shouldThrowOnError;return new Proxy(n,{get(i,l){const c=i[l];return typeof c!="function"?c:async(...f)=>{try{return{data:await c.apply(i,f),error:null}}catch(h){if(a)throw h;return{data:null,error:h}}}}})}},lM=class extends Co{constructor(e,t={},n){const a=e.replace(/\/$/,""),i=Fe(Fe({},sc),{},{"Content-Type":"application/json"},t);super(a,i,n,"vectors")}async createIndex(e){var t=this;return t.handleOperation(async()=>await Kn.post(t.fetch,`${t.url}/CreateIndex`,e,{headers:t.headers})||{})}async getIndex(e,t){var n=this;return n.handleOperation(async()=>await Kn.post(n.fetch,`${n.url}/GetIndex`,{vectorBucketName:e,indexName:t},{headers:n.headers}))}async listIndexes(e){var t=this;return t.handleOperation(async()=>await Kn.post(t.fetch,`${t.url}/ListIndexes`,e,{headers:t.headers}))}async deleteIndex(e,t){var n=this;return n.handleOperation(async()=>await Kn.post(n.fetch,`${n.url}/DeleteIndex`,{vectorBucketName:e,indexName:t},{headers:n.headers})||{})}},cM=class extends Co{constructor(e,t={},n){const a=e.replace(/\/$/,""),i=Fe(Fe({},sc),{},{"Content-Type":"application/json"},t);super(a,i,n,"vectors")}async putVectors(e){var t=this;if(e.vectors.length<1||e.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return t.handleOperation(async()=>await Kn.post(t.fetch,`${t.url}/PutVectors`,e,{headers:t.headers})||{})}async getVectors(e){var t=this;return t.handleOperation(async()=>await Kn.post(t.fetch,`${t.url}/GetVectors`,e,{headers:t.headers}))}async listVectors(e){var t=this;if(e.segmentCount!==void 0){if(e.segmentCount<1||e.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");if(e.segmentIndex!==void 0&&(e.segmentIndex<0||e.segmentIndex>=e.segmentCount))throw new Error(`segmentIndex must be between 0 and ${e.segmentCount-1}`)}return t.handleOperation(async()=>await Kn.post(t.fetch,`${t.url}/ListVectors`,e,{headers:t.headers}))}async queryVectors(e){var t=this;return t.handleOperation(async()=>await Kn.post(t.fetch,`${t.url}/QueryVectors`,e,{headers:t.headers}))}async deleteVectors(e){var t=this;if(e.keys.length<1||e.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return t.handleOperation(async()=>await Kn.post(t.fetch,`${t.url}/DeleteVectors`,e,{headers:t.headers})||{})}},uM=class extends Co{constructor(e,t={},n){const a=e.replace(/\/$/,""),i=Fe(Fe({},sc),{},{"Content-Type":"application/json"},t);super(a,i,n,"vectors")}async createBucket(e){var t=this;return t.handleOperation(async()=>await Kn.post(t.fetch,`${t.url}/CreateVectorBucket`,{vectorBucketName:e},{headers:t.headers})||{})}async getBucket(e){var t=this;return t.handleOperation(async()=>await Kn.post(t.fetch,`${t.url}/GetVectorBucket`,{vectorBucketName:e},{headers:t.headers}))}async listBuckets(e={}){var t=this;return t.handleOperation(async()=>await Kn.post(t.fetch,`${t.url}/ListVectorBuckets`,e,{headers:t.headers}))}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await Kn.post(t.fetch,`${t.url}/DeleteVectorBucket`,{vectorBucketName:e},{headers:t.headers})||{})}},dM=class extends uM{constructor(e,t={}){super(e,t.headers||{},t.fetch)}from(e){return new fM(this.url,this.headers,e,this.fetch)}async createBucket(e){var t=()=>super.createBucket,n=this;return t().call(n,e)}async getBucket(e){var t=()=>super.getBucket,n=this;return t().call(n,e)}async listBuckets(e={}){var t=()=>super.listBuckets,n=this;return t().call(n,e)}async deleteBucket(e){var t=()=>super.deleteBucket,n=this;return t().call(n,e)}},fM=class extends lM{constructor(e,t,n,a){super(e,t,a),this.vectorBucketName=n}async createIndex(e){var t=()=>super.createIndex,n=this;return t().call(n,Fe(Fe({},e),{},{vectorBucketName:n.vectorBucketName}))}async listIndexes(e={}){var t=()=>super.listIndexes,n=this;return t().call(n,Fe(Fe({},e),{},{vectorBucketName:n.vectorBucketName}))}async getIndex(e){var t=()=>super.getIndex,n=this;return t().call(n,n.vectorBucketName,e)}async deleteIndex(e){var t=()=>super.deleteIndex,n=this;return t().call(n,n.vectorBucketName,e)}index(e){return new hM(this.url,this.headers,this.vectorBucketName,e,this.fetch)}},hM=class extends cM{constructor(e,t,n,a,i){super(e,t,i),this.vectorBucketName=n,this.indexName=a}async putVectors(e){var t=()=>super.putVectors,n=this;return t().call(n,Fe(Fe({},e),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async getVectors(e){var t=()=>super.getVectors,n=this;return t().call(n,Fe(Fe({},e),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async listVectors(e={}){var t=()=>super.listVectors,n=this;return t().call(n,Fe(Fe({},e),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async queryVectors(e){var t=()=>super.queryVectors,n=this;return t().call(n,Fe(Fe({},e),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async deleteVectors(e){var t=()=>super.deleteVectors,n=this;return t().call(n,Fe(Fe({},e),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}},mM=class extends iM{constructor(e,t={},n,a){super(e,t,n,a)}from(e){return new aM(this.url,this.headers,e,this.fetch)}get vectors(){return new dM(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new oM(this.url+"/iceberg",this.headers,this.fetch)}};const n1="2.106.2",no=30*1e3,ig=3,dp=ig*no,pM="http://localhost:9999",gM="supabase.auth.token",vM={"X-Client-Info":`gotrue-js/${n1}`},og="X-Supabase-Api-Version",r1={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},yM=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,bM=600*1e3;class po extends Error{constructor(t,n,a){super(t),this.__isAuthError=!0,this.name="AuthError",this.status=n,this.code=a}toJSON(){return{name:this.name,message:this.message,status:this.status,code:this.code}}}function ye(e){return typeof e=="object"&&e!==null&&"__isAuthError"in e}class xM extends po{constructor(t,n,a){super(t,n,a),this.name="AuthApiError",this.status=n,this.code=a}}function wM(e){return ye(e)&&e.name==="AuthApiError"}class xr extends po{constructor(t,n){super(t),this.name="AuthUnknownError",this.originalError=n}}class _a extends po{constructor(t,n,a,i){super(t,a,i),this.name=n,this.status=a}}class rn extends _a{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function zu(e){return ye(e)&&e.name==="AuthSessionMissingError"}class Fi extends _a{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class Iu extends _a{constructor(t){super(t,"AuthInvalidCredentialsError",400,void 0)}}class $u extends _a{constructor(t,n=null){super(t,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=n}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}function _M(e){return ye(e)&&e.name==="AuthImplicitGrantRedirectError"}class Ow extends _a{constructor(t,n=null){super(t,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=n}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}class SM extends _a{constructor(){super("PKCE code verifier not found in storage. This can happen if the auth flow was initiated in a different browser or device, or if the storage was cleared. For SSR frameworks (Next.js, SvelteKit, etc.), use @supabase/ssr on both the server and client to store the code verifier in cookies.","AuthPKCECodeVerifierMissingError",400,"pkce_code_verifier_not_found")}}class lg extends _a{constructor(t,n){super(t,"AuthRetryableFetchError",n,void 0)}}function fp(e){return ye(e)&&e.name==="AuthRetryableFetchError"}class Mw extends _a{constructor(t,n,a){super(t,"AuthWeakPasswordError",n,"weak_password"),this.reasons=a}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{reasons:this.reasons})}}class cg extends _a{constructor(t){super(t,"AuthInvalidJwtError",400,"invalid_jwt")}}const Rd="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),Dw=`
\r=`.split(""),EM=(()=>{const e=new Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<Dw.length;t+=1)e[Dw[t].charCodeAt(0)]=-2;for(let t=0;t<Rd.length;t+=1)e[Rd[t].charCodeAt(0)]=t;return e})();function Pw(e,t,n){if(e!==null)for(t.queue=t.queue<<8|e,t.queuedBits+=8;t.queuedBits>=6;){const a=t.queue>>t.queuedBits-6&63;n(Rd[a]),t.queuedBits-=6}else if(t.queuedBits>0)for(t.queue=t.queue<<6-t.queuedBits,t.queuedBits=6;t.queuedBits>=6;){const a=t.queue>>t.queuedBits-6&63;n(Rd[a]),t.queuedBits-=6}}function a1(e,t,n){const a=EM[e];if(a>-1)for(t.queue=t.queue<<6|a,t.queuedBits+=6;t.queuedBits>=8;)n(t.queue>>t.queuedBits-8&255),t.queuedBits-=8;else{if(a===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(e)}"`)}}function Lw(e){const t=[],n=c=>{t.push(String.fromCodePoint(c))},a={utf8seq:0,codepoint:0},i={queue:0,queuedBits:0},l=c=>{jM(c,a,n)};for(let c=0;c<e.length;c+=1)a1(e.charCodeAt(c),i,l);return t.join("")}function NM(e,t){if(e<=127){t(e);return}else if(e<=2047){t(192|e>>6),t(128|e&63);return}else if(e<=65535){t(224|e>>12),t(128|e>>6&63),t(128|e&63);return}else if(e<=1114111){t(240|e>>18),t(128|e>>12&63),t(128|e>>6&63),t(128|e&63);return}throw new Error(`Unrecognized Unicode codepoint: ${e.toString(16)}`)}function CM(e,t){for(let n=0;n<e.length;n+=1){let a=e.charCodeAt(n);if(a>55295&&a<=56319){const i=(a-55296)*1024&65535;a=(e.charCodeAt(n+1)-56320&65535|i)+65536,n+=1}NM(a,t)}}function jM(e,t,n){if(t.utf8seq===0){if(e<=127){n(e);return}for(let a=1;a<6;a+=1)if((e>>7-a&1)===0){t.utf8seq=a;break}if(t.utf8seq===2)t.codepoint=e&31;else if(t.utf8seq===3)t.codepoint=e&15;else if(t.utf8seq===4)t.codepoint=e&7;else throw new Error("Invalid UTF-8 sequence");t.utf8seq-=1}else if(t.utf8seq>0){if(e<=127)throw new Error("Invalid UTF-8 sequence");t.codepoint=t.codepoint<<6|e&63,t.utf8seq-=1,t.utf8seq===0&&n(t.codepoint)}}function co(e){const t=[],n={queue:0,queuedBits:0},a=i=>{t.push(i)};for(let i=0;i<e.length;i+=1)a1(e.charCodeAt(i),n,a);return new Uint8Array(t)}function TM(e){const t=[];return CM(e,n=>t.push(n)),new Uint8Array(t)}function Bs(e){const t=[],n={queue:0,queuedBits:0},a=i=>{t.push(i)};return e.forEach(i=>Pw(i,n,a)),Pw(null,n,a),t.join("")}function RM(e){return Math.round(Date.now()/1e3)+e}function AM(){return Symbol("auth-callback")}const mn=()=>typeof window<"u"&&typeof document<"u",Ms={tested:!1,writable:!1},s1=()=>{if(!mn())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Ms.tested)return Ms.writable;const e=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),Ms.tested=!0,Ms.writable=!0}catch{Ms.tested=!0,Ms.writable=!1}return Ms.writable};function kM(e){const t={},n=new URL(e);if(n.hash&&n.hash[0]==="#")try{new URLSearchParams(n.hash.substring(1)).forEach((i,l)=>{t[l]=i})}catch{}return n.searchParams.forEach((a,i)=>{t[i]=a}),t}const i1=e=>e?(...t)=>e(...t):(...t)=>fetch(...t),OM=e=>typeof e=="object"&&e!==null&&"status"in e&&"ok"in e&&"json"in e&&typeof e.json=="function",ro=async(e,t,n)=>{await e.setItem(t,JSON.stringify(n))},Ds=async(e,t)=>{const n=await e.getItem(t);if(!n)return null;try{return JSON.parse(n)}catch{return null}},hn=async(e,t)=>{await e.removeItem(t)};class cf{constructor(){this.promise=new cf.promiseConstructor((t,n)=>{this.resolve=t,this.reject=n})}}cf.promiseConstructor=Promise;function Uu(e){const t=e.split(".");if(t.length!==3)throw new cg("Invalid JWT structure");for(let a=0;a<t.length;a++)if(!yM.test(t[a]))throw new cg("JWT not in base64url format");return{header:JSON.parse(Lw(t[0])),payload:JSON.parse(Lw(t[1])),signature:co(t[2]),raw:{header:t[0],payload:t[1]}}}async function MM(e){return await new Promise(t=>{setTimeout(()=>t(null),e)})}function DM(e,t){return new Promise((a,i)=>{(async()=>{for(let l=0;l<1/0;l++)try{const c=await e(l);if(!t(l,null,c)){a(c);return}}catch(c){if(!t(l,c)){i(c);return}}})()})}function PM(e){return("0"+e.toString(16)).substr(-2)}function LM(){const t=new Uint32Array(56);if(typeof crypto>"u"){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",a=n.length;let i="";for(let l=0;l<56;l++)i+=n.charAt(Math.floor(Math.random()*a));return i}return crypto.getRandomValues(t),Array.from(t,PM).join("")}async function zM(e){const n=new TextEncoder().encode(e),a=await crypto.subtle.digest("SHA-256",n),i=new Uint8Array(a);return Array.from(i).map(l=>String.fromCharCode(l)).join("")}async function IM(e){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),e;const n=await zM(e);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Gi(e,t,n=!1){const a=LM();let i=a;n&&(i+="/recovery"),await ro(e,`${t}-code-verifier`,i);const l=await IM(a);return[l,a===l?"plain":"s256"]}const $M=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function UM(e){const t=e.headers.get(og);if(!t||!t.match($M))return null;try{return new Date(`${t}T00:00:00.0Z`)}catch{return null}}function BM(e){if(!e)throw new Error("Missing exp claim");const t=Math.floor(Date.now()/1e3);if(e<=t)throw new Error("JWT has expired")}function HM(e){switch(e){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const qM=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function ca(e){if(!qM.test(e))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function vr(e){if(!e.passkey)throw new Error("@supabase/auth-js: the passkey API is experimental and disabled by default. Enable it by passing `auth: { experimental: { passkey: true } }` to createClient (or to the GoTrueClient constructor).")}function hp(){const e={};return new Proxy(e,{get:(t,n)=>{if(n==="__isUserNotAvailableProxy")return!0;if(typeof n=="symbol"){const a=n.toString();if(a==="Symbol(Symbol.toPrimitive)"||a==="Symbol(Symbol.toStringTag)"||a==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${n}" property of the session object is not supported. Please use getUser() instead.`)},set:(t,n)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${n}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(t,n)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${n}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function VM(e,t){return new Proxy(e,{get:(n,a,i)=>{if(a==="__isInsecureUserWarningProxy")return!0;if(typeof a=="symbol"){const l=a.toString();if(l==="Symbol(Symbol.toPrimitive)"||l==="Symbol(Symbol.toStringTag)"||l==="Symbol(util.inspect.custom)"||l==="Symbol(nodejs.util.inspect.custom)")return Reflect.get(n,a,i)}return!t.value&&typeof a=="string"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),t.value=!0),Reflect.get(n,a,i)}})}function zw(e){return JSON.parse(JSON.stringify(e))}const $s=e=>{if(typeof e=="object"&&e!==null){const t=e;if(typeof t.msg=="string")return t.msg;if(typeof t.message=="string")return t.message;if(typeof t.error_description=="string")return t.error_description;if(typeof t.error=="string")return t.error}return JSON.stringify(e)},FM=[502,503,504,520,521,522,523,524,530];async function Iw(e){var t;if(!OM(e))throw new lg($s(e),0);if(FM.includes(e.status))throw new lg($s(e),e.status);let n;try{n=await e.json()}catch(l){throw new xr($s(l),l)}let a;const i=UM(e);if(i&&i.getTime()>=r1["2024-01-01"].timestamp&&typeof n=="object"&&n&&typeof n.code=="string"?a=n.code:typeof n=="object"&&n&&typeof n.error_code=="string"&&(a=n.error_code),a){if(a==="weak_password")throw new Mw($s(n),e.status,((t=n.weak_password)===null||t===void 0?void 0:t.reasons)||[]);if(a==="session_not_found")throw new rn}else if(typeof n=="object"&&n&&typeof n.weak_password=="object"&&n.weak_password&&Array.isArray(n.weak_password.reasons)&&n.weak_password.reasons.length&&n.weak_password.reasons.reduce((l,c)=>l&&typeof c=="string",!0))throw new Mw($s(n),e.status,n.weak_password.reasons);throw new xM($s(n),e.status||500,a)}const GM=(e,t,n,a)=>{const i={method:e,headers:(t==null?void 0:t.headers)||{}};return e==="GET"?i:(i.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},t==null?void 0:t.headers),i.body=JSON.stringify(a),Object.assign(Object.assign({},i),n))};async function ke(e,t,n,a){var i;const l=Object.assign({},a==null?void 0:a.headers);l[og]||(l[og]=r1["2024-01-01"].name),a!=null&&a.jwt&&(l.Authorization=`Bearer ${a.jwt}`);const c=(i=a==null?void 0:a.query)!==null&&i!==void 0?i:{};a!=null&&a.redirectTo&&(c.redirect_to=a.redirectTo);const f=Object.keys(c).length?"?"+new URLSearchParams(c).toString():"",h=await KM(e,t,n+f,{headers:l,noResolveJson:a==null?void 0:a.noResolveJson},{},a==null?void 0:a.body);return a!=null&&a.xform?a==null?void 0:a.xform(h):{data:Object.assign({},h),error:null}}async function KM(e,t,n,a,i,l){const c=GM(t,a,i,l);let f;try{f=await e(n,Object.assign({},c))}catch(h){throw console.error(h),new lg($s(h),0)}if(f.ok||await Iw(f),a!=null&&a.noResolveJson)return f;try{return await f.json()}catch(h){await Iw(h)}}function or(e){var t;let n=null;XM(e)&&(n=Object.assign({},e),e.expires_at||(n.expires_at=RM(e.expires_in)));const a=(t=e.user)!==null&&t!==void 0?t:typeof(e==null?void 0:e.id)=="string"?e:null;return{data:{session:n,user:a},error:null}}function $w(e){const t=or(e);return!t.error&&e.weak_password&&typeof e.weak_password=="object"&&Array.isArray(e.weak_password.reasons)&&e.weak_password.reasons.length&&e.weak_password.message&&typeof e.weak_password.message=="string"&&e.weak_password.reasons.reduce((n,a)=>n&&typeof a=="string",!0)&&(t.data.weak_password=e.weak_password),t}function ts(e){var t;return{data:{user:(t=e.user)!==null&&t!==void 0?t:e},error:null}}function WM(e){return{data:e,error:null}}function YM(e){const{action_link:t,email_otp:n,hashed_token:a,redirect_to:i,verification_type:l}=e,c=No(e,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),f={action_link:t,email_otp:n,hashed_token:a,redirect_to:i,verification_type:l},h=Object.assign({},c);return{data:{properties:f,user:h},error:null}}function Uw(e){return e}function XM(e){return!!e.access_token&&!!e.refresh_token&&!!e.expires_in}const mp=["global","local","others"];class JM{_encodePathSegment(t){if(t==="."||t==="..")throw new po("Invalid path segment");return encodeURIComponent(t)}constructor({url:t="",headers:n={},fetch:a,experimental:i}){this.url=t,this.headers=n,this.fetch=i1(a),this.experimental=i??{},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)},this.customProviders={listProviders:this._listCustomProviders.bind(this),createProvider:this._createCustomProvider.bind(this),getProvider:this._getCustomProvider.bind(this),updateProvider:this._updateCustomProvider.bind(this),deleteProvider:this._deleteCustomProvider.bind(this)},this.passkey={listPasskeys:this._adminListPasskeys.bind(this),deletePasskey:this._adminDeletePasskey.bind(this)}}async signOut(t,n=mp[0]){if(mp.indexOf(n)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${mp.join(", ")}`);try{return await ke(this.fetch,"POST",`${this.url}/logout?scope=${n}`,{headers:this.headers,jwt:t,noResolveJson:!0}),{data:null,error:null}}catch(a){if(ye(a))return{data:null,error:a};throw a}}async inviteUserByEmail(t,n={}){try{return await ke(this.fetch,"POST",`${this.url}/invite`,{body:{email:t,data:n.data},headers:this.headers,redirectTo:n.redirectTo,xform:ts})}catch(a){if(ye(a))return{data:{user:null},error:a};throw a}}async generateLink(t){try{const{options:n}=t,a=No(t,["options"]),i=Object.assign(Object.assign({},a),n);return"newEmail"in a&&(i.new_email=a==null?void 0:a.newEmail,delete i.newEmail),await ke(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:i,headers:this.headers,xform:YM,redirectTo:n==null?void 0:n.redirectTo})}catch(n){if(ye(n))return{data:{properties:null,user:null},error:n};throw n}}async createUser(t){try{return await ke(this.fetch,"POST",`${this.url}/admin/users`,{body:t,headers:this.headers,xform:ts})}catch(n){if(ye(n))return{data:{user:null},error:n};throw n}}async listUsers(t){var n,a,i,l,c,f,h;try{const m={nextPage:null,lastPage:0,total:0},b=await ke(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(a=(n=t==null?void 0:t.page)===null||n===void 0?void 0:n.toString())!==null&&a!==void 0?a:"",per_page:(l=(i=t==null?void 0:t.perPage)===null||i===void 0?void 0:i.toString())!==null&&l!==void 0?l:""},xform:Uw});if(b.error)throw b.error;const g=await b.json(),x=(c=b.headers.get("x-total-count"))!==null&&c!==void 0?c:0,w=(h=(f=b.headers.get("link"))===null||f===void 0?void 0:f.split(","))!==null&&h!==void 0?h:[];return w.length>0&&(w.forEach(E=>{const S=parseInt(E.split(";")[0].split("=")[1].substring(0,1)),C=JSON.parse(E.split(";")[1].split("=")[1]);m[`${C}Page`]=S}),m.total=parseInt(x)),{data:Object.assign(Object.assign({},g),m),error:null}}catch(m){if(ye(m))return{data:{users:[]},error:m};throw m}}async getUserById(t){ca(t);try{return await ke(this.fetch,"GET",`${this.url}/admin/users/${t}`,{headers:this.headers,xform:ts})}catch(n){if(ye(n))return{data:{user:null},error:n};throw n}}async updateUserById(t,n){ca(t);try{return await ke(this.fetch,"PUT",`${this.url}/admin/users/${t}`,{body:n,headers:this.headers,xform:ts})}catch(a){if(ye(a))return{data:{user:null},error:a};throw a}}async deleteUser(t,n=!1){ca(t);try{return await ke(this.fetch,"DELETE",`${this.url}/admin/users/${t}`,{headers:this.headers,body:{should_soft_delete:n},xform:ts})}catch(a){if(ye(a))return{data:{user:null},error:a};throw a}}async _listFactors(t){ca(t.userId);try{const{data:n,error:a}=await ke(this.fetch,"GET",`${this.url}/admin/users/${t.userId}/factors`,{headers:this.headers,xform:i=>({data:{factors:i},error:null})});return{data:n,error:a}}catch(n){if(ye(n))return{data:null,error:n};throw n}}async _deleteFactor(t){ca(t.userId),ca(t.id);try{return{data:await ke(this.fetch,"DELETE",`${this.url}/admin/users/${t.userId}/factors/${t.id}`,{headers:this.headers}),error:null}}catch(n){if(ye(n))return{data:null,error:n};throw n}}async _listOAuthClients(t){var n,a,i,l,c,f,h;try{const m={nextPage:null,lastPage:0,total:0},b=await ke(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(a=(n=t==null?void 0:t.page)===null||n===void 0?void 0:n.toString())!==null&&a!==void 0?a:"",per_page:(l=(i=t==null?void 0:t.perPage)===null||i===void 0?void 0:i.toString())!==null&&l!==void 0?l:""},xform:Uw});if(b.error)throw b.error;const g=await b.json(),x=(c=b.headers.get("x-total-count"))!==null&&c!==void 0?c:0,w=(h=(f=b.headers.get("link"))===null||f===void 0?void 0:f.split(","))!==null&&h!==void 0?h:[];return w.length>0&&(w.forEach(E=>{const S=parseInt(E.split(";")[0].split("=")[1].substring(0,1)),C=JSON.parse(E.split(";")[1].split("=")[1]);m[`${C}Page`]=S}),m.total=parseInt(x)),{data:Object.assign(Object.assign({},g),m),error:null}}catch(m){if(ye(m))return{data:{clients:[]},error:m};throw m}}async _createOAuthClient(t){try{return await ke(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:t,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(ye(n))return{data:null,error:n};throw n}}async _getOAuthClient(t){try{const n=this._encodePathSegment(t);return await ke(this.fetch,"GET",`${this.url}/admin/oauth/clients/${n}`,{headers:this.headers,xform:a=>({data:a,error:null})})}catch(n){if(ye(n))return{data:null,error:n};throw n}}async _updateOAuthClient(t,n){try{const a=this._encodePathSegment(t);return await ke(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${a}`,{body:n,headers:this.headers,xform:i=>({data:i,error:null})})}catch(a){if(ye(a))return{data:null,error:a};throw a}}async _deleteOAuthClient(t){try{const n=this._encodePathSegment(t);return await ke(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${n}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(n){if(ye(n))return{data:null,error:n};throw n}}async _regenerateOAuthClientSecret(t){try{const n=this._encodePathSegment(t);return await ke(this.fetch,"POST",`${this.url}/admin/oauth/clients/${n}/regenerate_secret`,{headers:this.headers,xform:a=>({data:a,error:null})})}catch(n){if(ye(n))return{data:null,error:n};throw n}}async _listCustomProviders(t){try{const n={};return t!=null&&t.type&&(n.type=t.type),await ke(this.fetch,"GET",`${this.url}/admin/custom-providers`,{headers:this.headers,query:n,xform:a=>{var i;return{data:{providers:(i=a==null?void 0:a.providers)!==null&&i!==void 0?i:[]},error:null}}})}catch(n){if(ye(n))return{data:{providers:[]},error:n};throw n}}async _createCustomProvider(t){try{return await ke(this.fetch,"POST",`${this.url}/admin/custom-providers`,{body:t,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(ye(n))return{data:null,error:n};throw n}}async _getCustomProvider(t){try{const n=this._encodePathSegment(t);return await ke(this.fetch,"GET",`${this.url}/admin/custom-providers/${n}`,{headers:this.headers,xform:a=>({data:a,error:null})})}catch(n){if(ye(n))return{data:null,error:n};throw n}}async _updateCustomProvider(t,n){try{const a=this._encodePathSegment(t);return await ke(this.fetch,"PUT",`${this.url}/admin/custom-providers/${a}`,{body:n,headers:this.headers,xform:i=>({data:i,error:null})})}catch(a){if(ye(a))return{data:null,error:a};throw a}}async _deleteCustomProvider(t){try{const n=this._encodePathSegment(t);return await ke(this.fetch,"DELETE",`${this.url}/admin/custom-providers/${n}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(n){if(ye(n))return{data:null,error:n};throw n}}async _adminListPasskeys(t){vr(this.experimental),ca(t.userId);try{return await ke(this.fetch,"GET",`${this.url}/admin/users/${t.userId}/passkeys`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(ye(n))return{data:null,error:n};throw n}}async _adminDeletePasskey(t){vr(this.experimental),ca(t.userId),ca(t.passkeyId);try{return await ke(this.fetch,"DELETE",`${this.url}/admin/users/${t.userId}/passkeys/${t.passkeyId}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(n){if(ye(n))return{data:null,error:n};throw n}}}function Bw(e={}){return{getItem:t=>e[t]||null,setItem:(t,n)=>{e[t]=n},removeItem:t=>{delete e[t]}}}const kr={debug:!!(globalThis&&s1()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class o1 extends Error{constructor(t){super(t),this.isAcquireTimeout=!0}}class Hw extends o1{}async function QM(e,t,n){kr.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",e,t);const a=new globalThis.AbortController;let i;t>0&&(i=setTimeout(()=>{a.abort(),kr.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",e)},t)),await Promise.resolve();try{return await globalThis.navigator.locks.request(e,t===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:a.signal},async l=>{if(l){clearTimeout(i),kr.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",e,l.name);try{return await n()}finally{kr.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",e,l.name)}}else{if(t===0)throw kr.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",e),new Hw(`Acquiring an exclusive Navigator LockManager lock "${e}" immediately failed`);if(kr.debug)try{const c=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(c,null," "))}catch(c){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",c)}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"),clearTimeout(i),await n()}})}catch(l){if(t>0&&clearTimeout(i),l!==null&&typeof l=="object"&&"name"in l&&l.name==="AbortError"&&t>0){if(a.signal.aborted)return kr.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire timeout, recovering by stealing lock",e),console.warn(`@supabase/gotrue-js: Lock "${e}" was not released within ${t}ms. This may indicate an orphaned lock from a component unmount (e.g., React Strict Mode). Forcefully acquiring the lock to recover.`),await Promise.resolve().then(()=>globalThis.navigator.locks.request(e,{mode:"exclusive",steal:!0},async c=>{if(c){kr.debug&&console.log("@supabase/gotrue-js: navigatorLock: recovered (stolen)",e,c.name);try{return await n()}finally{kr.debug&&console.log("@supabase/gotrue-js: navigatorLock: released (stolen)",e,c.name)}}else return console.warn("@supabase/gotrue-js: Navigator LockManager returned null lock even with steal: true"),await n()}));throw kr.debug&&console.log("@supabase/gotrue-js: navigatorLock: lock was stolen by another request",e),new Hw(`Lock "${e}" was released because another request stole it`)}throw l}}function ZM(){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 l1(e){if(!/^0x[a-fA-F0-9]{40}$/.test(e))throw new Error(`@supabase/auth-js: Address "${e}" is invalid.`);return e.toLowerCase()}function eD(e){return parseInt(e,16)}function tD(e){const t=new TextEncoder().encode(e);return"0x"+Array.from(t,a=>a.toString(16).padStart(2,"0")).join("")}function nD(e){var t;const{chainId:n,domain:a,expirationTime:i,issuedAt:l=new Date,nonce:c,notBefore:f,requestId:h,resources:m,scheme:b,uri:g,version:x}=e;{if(!Number.isInteger(n))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${n}`);if(!a)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(c&&c.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${c}`);if(!g)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(x!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${x}`);if(!((t=e.statement)===null||t===void 0)&&t.includes(`
`))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${e.statement}`)}const w=l1(e.address),E=b?`${b}://${a}`:a,S=e.statement?`${e.statement}
`:"",C=`${E} wants you to sign in with your Ethereum account:
${w}
${S}`;let N=`URI: ${g}
Version: ${x}
Chain ID: ${n}${c?`
Nonce: ${c}`:""}
Issued At: ${l.toISOString()}`;if(i&&(N+=`
Expiration Time: ${i.toISOString()}`),f&&(N+=`
Not Before: ${f.toISOString()}`),h&&(N+=`
Request ID: ${h}`),m){let A=`
Resources:`;for(const T of m){if(!T||typeof T!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${T}`);A+=`
- ${T}`}N+=A}return`${C}
${N}`}class Gt extends Error{constructor({message:t,code:n,cause:a,name:i}){var l;super(t,{cause:a}),this.__isWebAuthnError=!0,this.name=(l=i??(a instanceof Error?a.name:void 0))!==null&&l!==void 0?l:"Unknown Error",this.code=n}toJSON(){return{name:this.name,message:this.message,code:this.code}}}class Ad extends Gt{constructor(t,n){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:n,message:t}),this.name="WebAuthnUnknownError",this.originalError=n}}function rD({error:e,options:t}){var n,a,i;const{publicKey:l}=t;if(!l)throw Error("options was missing required publicKey property");if(e.name==="AbortError"){if(t.signal instanceof AbortSignal)return new Gt({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if(e.name==="ConstraintError"){if(((n=l.authenticatorSelection)===null||n===void 0?void 0:n.requireResidentKey)===!0)return new Gt({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:e});if(t.mediation==="conditional"&&((a=l.authenticatorSelection)===null||a===void 0?void 0:a.userVerification)==="required")return new Gt({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:e});if(((i=l.authenticatorSelection)===null||i===void 0?void 0:i.userVerification)==="required")return new Gt({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:e})}else{if(e.name==="InvalidStateError")return new Gt({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:e});if(e.name==="NotAllowedError")return new Gt({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if(e.name==="NotSupportedError")return l.pubKeyCredParams.filter(f=>f.type==="public-key").length===0?new Gt({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:e}):new Gt({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:e});if(e.name==="SecurityError"){const c=window.location.hostname;if(c1(c)){if(l.rp.id!==c)return new Gt({message:`The RP ID "${l.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else return new Gt({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e})}else if(e.name==="TypeError"){if(l.user.id.byteLength<1||l.user.id.byteLength>64)return new Gt({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:e})}else if(e.name==="UnknownError")return new Gt({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e})}return new Gt({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}function aD({error:e,options:t}){const{publicKey:n}=t;if(!n)throw Error("options was missing required publicKey property");if(e.name==="AbortError"){if(t.signal instanceof AbortSignal)return new Gt({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else{if(e.name==="NotAllowedError")return new Gt({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if(e.name==="SecurityError"){const a=window.location.hostname;if(c1(a)){if(n.rpId!==a)return new Gt({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else return new Gt({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e})}else if(e.name==="UnknownError")return new Gt({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e})}return new Gt({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}class sD{createNewAbortSignal(){if(this.controller){const n=new Error("Cancelling existing WebAuthn API call for new one");n.name="AbortError",this.controller.abort(n)}const t=new AbortController;return this.controller=t,t.signal}cancelCeremony(){if(this.controller){const t=new Error("Manually cancelling existing WebAuthn API call");t.name="AbortError",this.controller.abort(t),this.controller=void 0}}}const ug=new sD;function qw(e){if(!e)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(e);const{challenge:t,user:n,excludeCredentials:a}=e,i=No(e,["challenge","user","excludeCredentials"]),l=co(t).buffer,c=Object.assign(Object.assign({},n),{id:co(n.id).buffer}),f=Object.assign(Object.assign({},i),{challenge:l,user:c});if(a&&a.length>0){f.excludeCredentials=new Array(a.length);for(let h=0;h<a.length;h++){const m=a[h];f.excludeCredentials[h]=Object.assign(Object.assign({},m),{id:co(m.id).buffer,type:m.type||"public-key",transports:m.transports})}}return f}function Vw(e){if(!e)throw new Error("Credential request options are required");if(typeof PublicKeyCredential<"u"&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseRequestOptionsFromJSON=="function")return PublicKeyCredential.parseRequestOptionsFromJSON(e);const{challenge:t,allowCredentials:n}=e,a=No(e,["challenge","allowCredentials"]),i=co(t).buffer,l=Object.assign(Object.assign({},a),{challenge:i});if(n&&n.length>0){l.allowCredentials=new Array(n.length);for(let c=0;c<n.length;c++){const f=n[c];l.allowCredentials[c]=Object.assign(Object.assign({},f),{id:co(f.id).buffer,type:f.type||"public-key",transports:f.transports})}}return l}function Fw(e){var t;if("toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();const n=e;return{id:e.id,rawId:e.id,response:{attestationObject:Bs(new Uint8Array(e.response.attestationObject)),clientDataJSON:Bs(new Uint8Array(e.response.clientDataJSON))},type:"public-key",clientExtensionResults:e.getClientExtensionResults(),authenticatorAttachment:(t=n.authenticatorAttachment)!==null&&t!==void 0?t:void 0}}function Gw(e){var t;if("toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();const n=e,a=e.getClientExtensionResults(),i=e.response;return{id:e.id,rawId:e.id,response:{authenticatorData:Bs(new Uint8Array(i.authenticatorData)),clientDataJSON:Bs(new Uint8Array(i.clientDataJSON)),signature:Bs(new Uint8Array(i.signature)),userHandle:i.userHandle?Bs(new Uint8Array(i.userHandle)):void 0},type:"public-key",clientExtensionResults:a,authenticatorAttachment:(t=n.authenticatorAttachment)!==null&&t!==void 0?t:void 0}}function c1(e){return e==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}function kd(){var e,t;return!!(mn()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&typeof((e=navigator==null?void 0:navigator.credentials)===null||e===void 0?void 0:e.create)=="function"&&typeof((t=navigator==null?void 0:navigator.credentials)===null||t===void 0?void 0:t.get)=="function")}async function u1(e){try{const t=await navigator.credentials.create(e);return t?t instanceof PublicKeyCredential?{data:t,error:null}:{data:null,error:new Ad("Browser returned unexpected credential type",t)}:{data:null,error:new Ad("Empty credential response",t)}}catch(t){return{data:null,error:rD({error:t,options:e})}}}async function d1(e){try{const t=await navigator.credentials.get(e);return t?t instanceof PublicKeyCredential?{data:t,error:null}:{data:null,error:new Ad("Browser returned unexpected credential type",t)}:{data:null,error:new Ad("Empty credential response",t)}}catch(t){return{data:null,error:aD({error:t,options:e})}}}const iD={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},oD={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function Od(...e){const t=i=>i!==null&&typeof i=="object"&&!Array.isArray(i),n=i=>i instanceof ArrayBuffer||ArrayBuffer.isView(i),a={};for(const i of e)if(i)for(const l in i){const c=i[l];if(c!==void 0)if(Array.isArray(c))a[l]=c;else if(n(c))a[l]=c;else if(t(c)){const f=a[l];t(f)?a[l]=Od(f,c):a[l]=Od(c)}else a[l]=c}return a}function lD(e,t){return Od(iD,e,t||{})}function cD(e,t){return Od(oD,e,t||{})}class uD{constructor(t){this.client=t,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(t){return this.client.mfa.enroll(Object.assign(Object.assign({},t),{factorType:"webauthn"}))}async _challenge({factorId:t,webauthn:n,friendlyName:a,signal:i},l){var c;try{const{data:f,error:h}=await this.client.mfa.challenge({factorId:t,webauthn:n});if(!f)return{data:null,error:h};const m=i??ug.createNewAbortSignal();if(f.webauthn.type==="create"){const{user:b}=f.webauthn.credential_options.publicKey;if(!b.name){const g=a;if(g)b.name=`${b.id}:${g}`;else{const w=(await this.client.getUser()).data.user,E=((c=w==null?void 0:w.user_metadata)===null||c===void 0?void 0:c.name)||(w==null?void 0:w.email)||(w==null?void 0:w.id)||"User";b.name=`${b.id}:${E}`}}b.displayName||(b.displayName=b.name)}switch(f.webauthn.type){case"create":{const b=lD(f.webauthn.credential_options.publicKey,l==null?void 0:l.create),{data:g,error:x}=await u1({publicKey:b,signal:m});return g?{data:{factorId:t,challengeId:f.id,webauthn:{type:f.webauthn.type,credential_response:g}},error:null}:{data:null,error:x}}case"request":{const b=cD(f.webauthn.credential_options.publicKey,l==null?void 0:l.request),{data:g,error:x}=await d1(Object.assign(Object.assign({},f.webauthn.credential_options),{publicKey:b,signal:m}));return g?{data:{factorId:t,challengeId:f.id,webauthn:{type:f.webauthn.type,credential_response:g}},error:null}:{data:null,error:x}}}}catch(f){return ye(f)?{data:null,error:f}:{data:null,error:new xr("Unexpected error in challenge",f)}}}async _verify({challengeId:t,factorId:n,webauthn:a}){return this.client.mfa.verify({factorId:n,challengeId:t,webauthn:a})}async _authenticate({factorId:t,webauthn:{rpId:n=typeof window<"u"?window.location.hostname:void 0,rpOrigins:a=typeof window<"u"?[window.location.origin]:void 0,signal:i}={}},l){if(!n)return{data:null,error:new po("rpId is required for WebAuthn authentication")};try{if(!kd())return{data:null,error:new xr("Browser does not support WebAuthn",null)};const{data:c,error:f}=await this.challenge({factorId:t,webauthn:{rpId:n,rpOrigins:a},signal:i},{request:l});if(!c)return{data:null,error:f};const{webauthn:h}=c;return this._verify({factorId:t,challengeId:c.challengeId,webauthn:{type:h.type,rpId:n,rpOrigins:a,credential_response:h.credential_response}})}catch(c){return ye(c)?{data:null,error:c}:{data:null,error:new xr("Unexpected error in authenticate",c)}}}async _register({friendlyName:t,webauthn:{rpId:n=typeof window<"u"?window.location.hostname:void 0,rpOrigins:a=typeof window<"u"?[window.location.origin]:void 0,signal:i}={}},l){if(!n)return{data:null,error:new po("rpId is required for WebAuthn registration")};try{if(!kd())return{data:null,error:new xr("Browser does not support WebAuthn",null)};const{data:c,error:f}=await this._enroll({friendlyName:t});if(!c)return await this.client.mfa.listFactors().then(b=>{var g;return(g=b.data)===null||g===void 0?void 0:g.all.find(x=>x.factor_type==="webauthn"&&x.friendly_name===t&&x.status!=="unverified")}).then(b=>b?this.client.mfa.unenroll({factorId:b==null?void 0:b.id}):void 0),{data:null,error:f};const{data:h,error:m}=await this._challenge({factorId:c.id,friendlyName:c.friendly_name,webauthn:{rpId:n,rpOrigins:a},signal:i},{create:l});return h?this._verify({factorId:c.id,challengeId:h.challengeId,webauthn:{rpId:n,rpOrigins:a,type:h.webauthn.type,credential_response:h.webauthn.credential_response}}):{data:null,error:m}}catch(c){return ye(c)?{data:null,error:c}:{data:null,error:new xr("Unexpected error in register",c)}}}}ZM();const dD={url:pM,storageKey:gM,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:vM,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:5e3,skipAutoInitialize:!1,experimental:{}};async function Kw(e,t,n){return await n()}const Ki={};class Gl{get jwks(){var t,n;return(n=(t=Ki[this.storageKey])===null||t===void 0?void 0:t.jwks)!==null&&n!==void 0?n:{keys:[]}}set jwks(t){Ki[this.storageKey]=Object.assign(Object.assign({},Ki[this.storageKey]),{jwks:t})}get jwks_cached_at(){var t,n;return(n=(t=Ki[this.storageKey])===null||t===void 0?void 0:t.cachedAt)!==null&&n!==void 0?n:Number.MIN_SAFE_INTEGER}set jwks_cached_at(t){Ki[this.storageKey]=Object.assign(Object.assign({},Ki[this.storageKey]),{cachedAt:t})}constructor(t){var n,a,i,l;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.autoRefreshTickTimeout=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;const c=Object.assign(Object.assign({},dD),t);if(this.storageKey=c.storageKey,this.instanceID=(n=Gl.nextInstanceID[this.storageKey])!==null&&n!==void 0?n:0,Gl.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!c.debug,typeof c.debug=="function"&&(this.logger=c.debug),this.instanceID>0&&mn()){const f=`${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(f),this.logDebugMessages&&console.trace(f)}if(this.persistSession=c.persistSession,this.autoRefreshToken=c.autoRefreshToken,this.experimental=(a=c.experimental)!==null&&a!==void 0?a:{},this.admin=new JM({url:c.url,headers:c.headers,fetch:c.fetch,experimental:this.experimental}),this.url=c.url,this.headers=c.headers,this.fetch=i1(c.fetch),this.lock=c.lock||Kw,this.detectSessionInUrl=c.detectSessionInUrl,this.flowType=c.flowType,this.hasCustomAuthorizationHeader=c.hasCustomAuthorizationHeader,this.throwOnError=c.throwOnError,this.lockAcquireTimeout=c.lockAcquireTimeout,c.lock?this.lock=c.lock:this.persistSession&&mn()&&(!((i=globalThis==null?void 0:globalThis.navigator)===null||i===void 0)&&i.locks)?this.lock=QM:this.lock=Kw,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 uD(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.passkey={startRegistration:this._startPasskeyRegistration.bind(this),verifyRegistration:this._verifyPasskeyRegistration.bind(this),startAuthentication:this._startPasskeyAuthentication.bind(this),verifyAuthentication:this._verifyPasskeyAuthentication.bind(this),list:this._listPasskeys.bind(this),update:this._updatePasskey.bind(this),delete:this._deletePasskey.bind(this)},this.persistSession?(c.storage?this.storage=c.storage:s1()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=Bw(this.memoryStorage)),c.userStorage&&(this.userStorage=c.userStorage)):(this.memoryStorage={},this.storage=Bw(this.memoryStorage)),mn()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(f){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",f)}(l=this.broadcastChannel)===null||l===void 0||l.addEventListener("message",async f=>{this._debug("received broadcast notification from other tab or client",f);try{await this._notifyAllSubscribers(f.data.event,f.data.session,!1)}catch(h){this._debug("#broadcastChannel","error",h)}})}c.skipAutoInitialize||this.initialize().catch(f=>{this._debug("#initialize()","error",f)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(t){if(this.throwOnError&&t&&t.error)throw t.error;return t}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${n1}) ${new Date().toISOString()}`}_debug(...t){return this.logDebugMessages&&this.logger(this._logPrefix(),...t),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(this.lockAcquireTimeout,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var t;try{let n={},a="none";if(mn()&&(n=kM(window.location.href),this._isImplicitGrantCallback(n)?a="implicit":await this._isPKCECallback(n)&&(a="pkce")),mn()&&this.detectSessionInUrl&&a!=="none"){const{data:i,error:l}=await this._getSessionFromURL(n,a);if(l){if(this._debug("#_initialize()","error detecting session from URL",l),_M(l)){const h=(t=l.details)===null||t===void 0?void 0:t.code;if(h==="identity_already_exists"||h==="identity_not_found"||h==="single_identity_not_deletable")return{error:l}}return{error:l}}const{session:c,redirectType:f}=i;return this._debug("#_initialize()","detected session in URL",c,"redirect type",f),await this._saveSession(c),setTimeout(async()=>{f==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",c):await this._notifyAllSubscribers("SIGNED_IN",c)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(n){return ye(n)?this._returnResult({error:n}):this._returnResult({error:new xr("Unexpected error during initialization",n)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(t){var n,a,i;try{const l=await ke(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(a=(n=t==null?void 0:t.options)===null||n===void 0?void 0:n.data)!==null&&a!==void 0?a:{},gotrue_meta_security:{captcha_token:(i=t==null?void 0:t.options)===null||i===void 0?void 0:i.captchaToken}},xform:or}),{data:c,error:f}=l;if(f||!c)return this._returnResult({data:{user:null,session:null},error:f});const h=c.session,m=c.user;return c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",h)),this._returnResult({data:{user:m,session:h},error:null})}catch(l){if(ye(l))return this._returnResult({data:{user:null,session:null},error:l});throw l}}async signUp(t){var n,a,i;try{let l;if("email"in t){const{email:b,password:g,options:x}=t;let w=null,E=null;this.flowType==="pkce"&&([w,E]=await Gi(this.storage,this.storageKey)),l=await ke(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:x==null?void 0:x.emailRedirectTo,body:{email:b,password:g,data:(n=x==null?void 0:x.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:x==null?void 0:x.captchaToken},code_challenge:w,code_challenge_method:E},xform:or})}else if("phone"in t){const{phone:b,password:g,options:x}=t;l=await ke(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:b,password:g,data:(a=x==null?void 0:x.data)!==null&&a!==void 0?a:{},channel:(i=x==null?void 0:x.channel)!==null&&i!==void 0?i:"sms",gotrue_meta_security:{captcha_token:x==null?void 0:x.captchaToken}},xform:or})}else throw new Iu("You must provide either an email or phone number and a password");const{data:c,error:f}=l;if(f||!c)return await hn(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:f});const h=c.session,m=c.user;return c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",h)),this._returnResult({data:{user:m,session:h},error:null})}catch(l){if(await hn(this.storage,`${this.storageKey}-code-verifier`),ye(l))return this._returnResult({data:{user:null,session:null},error:l});throw l}}async signInWithPassword(t){try{let n;if("email"in t){const{email:l,password:c,options:f}=t;n=await ke(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:l,password:c,gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken}},xform:$w})}else if("phone"in t){const{phone:l,password:c,options:f}=t;n=await ke(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:l,password:c,gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken}},xform:$w})}else throw new Iu("You must provide either an email or phone number and a password");const{data:a,error:i}=n;if(i)return this._returnResult({data:{user:null,session:null},error:i});if(!a||!a.session||!a.user){const l=new Fi;return this._returnResult({data:{user:null,session:null},error:l})}return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",a.session)),this._returnResult({data:Object.assign({user:a.user,session:a.session},a.weak_password?{weakPassword:a.weak_password}:null),error:i})}catch(n){if(ye(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async signInWithOAuth(t){var n,a,i,l;return await this._handleProviderSignIn(t.provider,{redirectTo:(n=t.options)===null||n===void 0?void 0:n.redirectTo,scopes:(a=t.options)===null||a===void 0?void 0:a.scopes,queryParams:(i=t.options)===null||i===void 0?void 0:i.queryParams,skipBrowserRedirect:(l=t.options)===null||l===void 0?void 0:l.skipBrowserRedirect})}async exchangeCodeForSession(t){return await this.initializePromise,this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(t))}async signInWithWeb3(t){const{chain:n}=t;switch(n){case"ethereum":return await this.signInWithEthereum(t);case"solana":return await this.signInWithSolana(t);default:throw new Error(`@supabase/auth-js: Unsupported chain "${n}"`)}}async signInWithEthereum(t){var n,a,i,l,c,f,h,m,b,g,x;let w,E;if("message"in t)w=t.message,E=t.signature;else{const{chain:S,wallet:C,statement:N,options:A}=t;let T;if(mn())if(typeof C=="object")T=C;else{const J=window;if("ethereum"in J&&typeof J.ethereum=="object"&&"request"in J.ethereum&&typeof J.ethereum.request=="function")T=J.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 C!="object"||!(A!=null&&A.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");T=C}const M=new URL((n=A==null?void 0:A.url)!==null&&n!==void 0?n:window.location.href),$=await T.request({method:"eth_requestAccounts"}).then(J=>J).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!$||$.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const L=l1($[0]);let P=(a=A==null?void 0:A.signInWithEthereum)===null||a===void 0?void 0:a.chainId;if(!P){const J=await T.request({method:"eth_chainId"});P=eD(J)}const U={domain:M.host,address:L,statement:N,uri:M.href,version:"1",chainId:P,nonce:(i=A==null?void 0:A.signInWithEthereum)===null||i===void 0?void 0:i.nonce,issuedAt:(c=(l=A==null?void 0:A.signInWithEthereum)===null||l===void 0?void 0:l.issuedAt)!==null&&c!==void 0?c:new Date,expirationTime:(f=A==null?void 0:A.signInWithEthereum)===null||f===void 0?void 0:f.expirationTime,notBefore:(h=A==null?void 0:A.signInWithEthereum)===null||h===void 0?void 0:h.notBefore,requestId:(m=A==null?void 0:A.signInWithEthereum)===null||m===void 0?void 0:m.requestId,resources:(b=A==null?void 0:A.signInWithEthereum)===null||b===void 0?void 0:b.resources};w=nD(U),E=await T.request({method:"personal_sign",params:[tD(w),L]})}try{const{data:S,error:C}=await ke(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:w,signature:E},!((g=t.options)===null||g===void 0)&&g.captchaToken?{gotrue_meta_security:{captcha_token:(x=t.options)===null||x===void 0?void 0:x.captchaToken}}:null),xform:or});if(C)throw C;if(!S||!S.session||!S.user){const N=new Fi;return this._returnResult({data:{user:null,session:null},error:N})}return S.session&&(await this._saveSession(S.session),await this._notifyAllSubscribers("SIGNED_IN",S.session)),this._returnResult({data:Object.assign({},S),error:C})}catch(S){if(ye(S))return this._returnResult({data:{user:null,session:null},error:S});throw S}}async signInWithSolana(t){var n,a,i,l,c,f,h,m,b,g,x,w;let E,S;if("message"in t)E=t.message,S=t.signature;else{const{chain:C,wallet:N,statement:A,options:T}=t;let M;if(mn())if(typeof N=="object")M=N;else{const L=window;if("solana"in L&&typeof L.solana=="object"&&("signIn"in L.solana&&typeof L.solana.signIn=="function"||"signMessage"in L.solana&&typeof L.solana.signMessage=="function"))M=L.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 N!="object"||!(T!=null&&T.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");M=N}const $=new URL((n=T==null?void 0:T.url)!==null&&n!==void 0?n:window.location.href);if("signIn"in M&&M.signIn){const L=await M.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},T==null?void 0:T.signInWithSolana),{version:"1",domain:$.host,uri:$.href}),A?{statement:A}:null));let P;if(Array.isArray(L)&&L[0]&&typeof L[0]=="object")P=L[0];else if(L&&typeof L=="object"&&"signedMessage"in L&&"signature"in L)P=L;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in P&&"signature"in P&&(typeof P.signedMessage=="string"||P.signedMessage instanceof Uint8Array)&&P.signature instanceof Uint8Array)E=typeof P.signedMessage=="string"?P.signedMessage:new TextDecoder().decode(P.signedMessage),S=P.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in M)||typeof M.signMessage!="function"||!("publicKey"in M)||typeof M!="object"||!M.publicKey||!("toBase58"in M.publicKey)||typeof M.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");E=[`${$.host} wants you to sign in with your Solana account:`,M.publicKey.toBase58(),...A?["",A,""]:[""],"Version: 1",`URI: ${$.href}`,`Issued At: ${(i=(a=T==null?void 0:T.signInWithSolana)===null||a===void 0?void 0:a.issuedAt)!==null&&i!==void 0?i:new Date().toISOString()}`,...!((l=T==null?void 0:T.signInWithSolana)===null||l===void 0)&&l.notBefore?[`Not Before: ${T.signInWithSolana.notBefore}`]:[],...!((c=T==null?void 0:T.signInWithSolana)===null||c===void 0)&&c.expirationTime?[`Expiration Time: ${T.signInWithSolana.expirationTime}`]:[],...!((f=T==null?void 0:T.signInWithSolana)===null||f===void 0)&&f.chainId?[`Chain ID: ${T.signInWithSolana.chainId}`]:[],...!((h=T==null?void 0:T.signInWithSolana)===null||h===void 0)&&h.nonce?[`Nonce: ${T.signInWithSolana.nonce}`]:[],...!((m=T==null?void 0:T.signInWithSolana)===null||m===void 0)&&m.requestId?[`Request ID: ${T.signInWithSolana.requestId}`]:[],...!((g=(b=T==null?void 0:T.signInWithSolana)===null||b===void 0?void 0:b.resources)===null||g===void 0)&&g.length?["Resources",...T.signInWithSolana.resources.map(P=>`- ${P}`)]:[]].join(`
`);const L=await M.signMessage(new TextEncoder().encode(E),"utf8");if(!L||!(L instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");S=L}}try{const{data:C,error:N}=await ke(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:E,signature:Bs(S)},!((x=t.options)===null||x===void 0)&&x.captchaToken?{gotrue_meta_security:{captcha_token:(w=t.options)===null||w===void 0?void 0:w.captchaToken}}:null),xform:or});if(N)throw N;if(!C||!C.session||!C.user){const A=new Fi;return this._returnResult({data:{user:null,session:null},error:A})}return C.session&&(await this._saveSession(C.session),await this._notifyAllSubscribers("SIGNED_IN",C.session)),this._returnResult({data:Object.assign({},C),error:N})}catch(C){if(ye(C))return this._returnResult({data:{user:null,session:null},error:C});throw C}}async _exchangeCodeForSession(t){const n=await Ds(this.storage,`${this.storageKey}-code-verifier`),[a,i]=(n??"").split("/");try{if(!a&&this.flowType==="pkce")throw new SM;const{data:l,error:c}=await ke(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:t,code_verifier:a},xform:or});if(await hn(this.storage,`${this.storageKey}-code-verifier`),c)throw c;if(!l||!l.session||!l.user){const f=new Fi;return this._returnResult({data:{user:null,session:null,redirectType:null},error:f})}return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers(i==="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l.session)),this._returnResult({data:Object.assign(Object.assign({},l),{redirectType:i??null}),error:c})}catch(l){if(await hn(this.storage,`${this.storageKey}-code-verifier`),ye(l))return this._returnResult({data:{user:null,session:null,redirectType:null},error:l});throw l}}async signInWithIdToken(t){try{const{options:n,provider:a,token:i,access_token:l,nonce:c}=t,f=await ke(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:a,id_token:i,access_token:l,nonce:c,gotrue_meta_security:{captcha_token:n==null?void 0:n.captchaToken}},xform:or}),{data:h,error:m}=f;if(m)return this._returnResult({data:{user:null,session:null},error:m});if(!h||!h.session||!h.user){const b=new Fi;return this._returnResult({data:{user:null,session:null},error:b})}return h.session&&(await this._saveSession(h.session),await this._notifyAllSubscribers("SIGNED_IN",h.session)),this._returnResult({data:h,error:m})}catch(n){if(ye(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async signInWithOtp(t){var n,a,i,l,c;try{if("email"in t){const{email:f,options:h}=t;let m=null,b=null;this.flowType==="pkce"&&([m,b]=await Gi(this.storage,this.storageKey));const{error:g}=await ke(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:f,data:(n=h==null?void 0:h.data)!==null&&n!==void 0?n:{},create_user:(a=h==null?void 0:h.shouldCreateUser)!==null&&a!==void 0?a:!0,gotrue_meta_security:{captcha_token:h==null?void 0:h.captchaToken},code_challenge:m,code_challenge_method:b},redirectTo:h==null?void 0:h.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:g})}if("phone"in t){const{phone:f,options:h}=t,{data:m,error:b}=await ke(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:f,data:(i=h==null?void 0:h.data)!==null&&i!==void 0?i:{},create_user:(l=h==null?void 0:h.shouldCreateUser)!==null&&l!==void 0?l:!0,gotrue_meta_security:{captcha_token:h==null?void 0:h.captchaToken},channel:(c=h==null?void 0:h.channel)!==null&&c!==void 0?c:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:m==null?void 0:m.message_id},error:b})}throw new Iu("You must provide either an email or phone number.")}catch(f){if(await hn(this.storage,`${this.storageKey}-code-verifier`),ye(f))return this._returnResult({data:{user:null,session:null},error:f});throw f}}async verifyOtp(t){var n,a;try{let i,l;"options"in t&&(i=(n=t.options)===null||n===void 0?void 0:n.redirectTo,l=(a=t.options)===null||a===void 0?void 0:a.captchaToken);const{data:c,error:f}=await ke(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},t),{gotrue_meta_security:{captcha_token:l}}),redirectTo:i,xform:or});if(f)throw f;if(!c)throw new Error("An error occurred on token verification.");const h=c.session,m=c.user;return h!=null&&h.access_token&&(await this._saveSession(h),await this._notifyAllSubscribers(t.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",h)),this._returnResult({data:{user:m,session:h},error:null})}catch(i){if(ye(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signInWithSSO(t){var n,a,i,l,c;try{let f=null,h=null;this.flowType==="pkce"&&([f,h]=await Gi(this.storage,this.storageKey));const m=await ke(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in t?{provider_id:t.providerId}:null),"domain"in t?{domain:t.domain}:null),{redirect_to:(a=(n=t.options)===null||n===void 0?void 0:n.redirectTo)!==null&&a!==void 0?a:void 0}),!((i=t==null?void 0:t.options)===null||i===void 0)&&i.captchaToken?{gotrue_meta_security:{captcha_token:t.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:f,code_challenge_method:h}),headers:this.headers,xform:WM});return!((l=m.data)===null||l===void 0)&&l.url&&mn()&&!(!((c=t.options)===null||c===void 0)&&c.skipBrowserRedirect)&&window.location.assign(m.data.url),this._returnResult(m)}catch(f){if(await hn(this.storage,`${this.storageKey}-code-verifier`),ye(f))return this._returnResult({data:null,error:f});throw f}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async t=>{const{data:{session:n},error:a}=t;if(a)throw a;if(!n)throw new rn;const{error:i}=await ke(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:n.access_token});return this._returnResult({data:{user:null,session:null},error:i})})}catch(t){if(ye(t))return this._returnResult({data:{user:null,session:null},error:t});throw t}}async resend(t){try{const n=`${this.url}/resend`;if("email"in t){const{email:a,type:i,options:l}=t,{error:c}=await ke(this.fetch,"POST",n,{headers:this.headers,body:{email:a,type:i,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},redirectTo:l==null?void 0:l.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:c})}else if("phone"in t){const{phone:a,type:i,options:l}=t,{data:c,error:f}=await ke(this.fetch,"POST",n,{headers:this.headers,body:{phone:a,type:i,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:c==null?void 0:c.message_id},error:f})}throw new Iu("You must provide either an email or phone number and a type")}catch(n){if(ye(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async getSession(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async n=>n))}async _acquireLock(t,n){this._debug("#_acquireLock","begin",t);try{if(this.lockAcquired){const a=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),i=(async()=>(await a,await n()))();return this.pendingInLock.push((async()=>{try{await i}catch{}})()),i}return await this.lock(`lock:${this.storageKey}`,t,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const a=n();for(this.pendingInLock.push((async()=>{try{await a}catch{}})()),await a;this.pendingInLock.length;){const i=[...this.pendingInLock];await Promise.all(i),this.pendingInLock.splice(0,i.length)}return await a}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(t){this._debug("#_useSession","begin");try{const n=await this.__loadSession();return await t(n)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let t=null;const n=await Ds(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",n),n!==null&&(this._isValidSession(n)?t=n:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!t)return{data:{session:null},error:null};const a=t.expires_at?t.expires_at*1e3-Date.now()<dp:!1;if(this._debug("#__loadSession()",`session has${a?"":" not"} expired`,"expires_at",t.expires_at),!a){if(this.userStorage){const c=await Ds(this.userStorage,this.storageKey+"-user");c!=null&&c.user?t.user=c.user:t.user=hp()}if(this.storage.isServer&&t.user&&!t.user.__isUserNotAvailableProxy){const c={value:this.suppressGetSessionWarning};t.user=VM(t.user,c),c.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:t},error:null}}const{data:i,error:l}=await this._callRefreshToken(t.refresh_token);return l?this._returnResult({data:{session:null},error:l}):this._returnResult({data:{session:i},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(t){if(t)return await this._getUser(t);await this.initializePromise;const n=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser());return n.data.user&&(this.suppressGetSessionWarning=!0),n}async _getUser(t){try{return t?await ke(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:t,xform:ts}):await this._useSession(async n=>{var a,i,l;const{data:c,error:f}=n;if(f)throw f;return!(!((a=c.session)===null||a===void 0)&&a.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new rn}:await ke(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(l=(i=c.session)===null||i===void 0?void 0:i.access_token)!==null&&l!==void 0?l:void 0,xform:ts})})}catch(n){if(ye(n))return zu(n)&&(await this._removeSession(),await hn(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:n});throw n}}async updateUser(t,n={}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(t,n))}async _updateUser(t,n={}){try{return await this._useSession(async a=>{const{data:i,error:l}=a;if(l)throw l;if(!i.session)throw new rn;const c=i.session;let f=null,h=null;this.flowType==="pkce"&&t.email!=null&&([f,h]=await Gi(this.storage,this.storageKey));const{data:m,error:b}=await ke(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:n==null?void 0:n.emailRedirectTo,body:Object.assign(Object.assign({},t),{code_challenge:f,code_challenge_method:h}),jwt:c.access_token,xform:ts});if(b)throw b;return c.user=m.user,await this._saveSession(c),await this._notifyAllSubscribers("USER_UPDATED",c),this._returnResult({data:{user:c.user},error:null})})}catch(a){if(await hn(this.storage,`${this.storageKey}-code-verifier`),ye(a))return this._returnResult({data:{user:null},error:a});throw a}}async setSession(t){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(t))}async _setSession(t){try{if(!t.access_token||!t.refresh_token)throw new rn;const n=Date.now()/1e3;let a=n,i=!0,l=null;const{payload:c}=Uu(t.access_token);if(c.exp&&(a=c.exp,i=a<=n),i){const{data:f,error:h}=await this._callRefreshToken(t.refresh_token);if(h)return this._returnResult({data:{user:null,session:null},error:h});if(!f)return{data:{user:null,session:null},error:null};l=f}else{const{data:f,error:h}=await this._getUser(t.access_token);if(h)return this._returnResult({data:{user:null,session:null},error:h});l={access_token:t.access_token,refresh_token:t.refresh_token,user:f.user,token_type:"bearer",expires_in:a-n,expires_at:a},await this._saveSession(l),await this._notifyAllSubscribers("SIGNED_IN",l)}return this._returnResult({data:{user:l.user,session:l},error:null})}catch(n){if(ye(n))return this._returnResult({data:{session:null,user:null},error:n});throw n}}async refreshSession(t){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(t))}async _refreshSession(t){try{return await this._useSession(async n=>{var a;if(!t){const{data:c,error:f}=n;if(f)throw f;t=(a=c.session)!==null&&a!==void 0?a:void 0}if(!(t!=null&&t.refresh_token))throw new rn;const{data:i,error:l}=await this._callRefreshToken(t.refresh_token);return l?this._returnResult({data:{user:null,session:null},error:l}):i?this._returnResult({data:{user:i.user,session:i},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(n){if(ye(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async _getSessionFromURL(t,n){var a;try{if(!mn())throw new $u("No browser detected.");if(t.error||t.error_description||t.error_code)throw new $u(t.error_description||"Error in URL with unspecified error_description",{error:t.error||"unspecified_error",code:t.error_code||"unspecified_code"});switch(n){case"implicit":if(this.flowType==="pkce")throw new Ow("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new $u("Not a valid implicit grant flow url.");break;default:}if(n==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!t.code)throw new Ow("No code detected.");const{data:T,error:M}=await this._exchangeCodeForSession(t.code);if(M)throw M;const $=new URL(window.location.href);return $.searchParams.delete("code"),window.history.replaceState(window.history.state,"",$.toString()),{data:{session:T.session,redirectType:(a=T.redirectType)!==null&&a!==void 0?a:null},error:null}}const{provider_token:i,provider_refresh_token:l,access_token:c,refresh_token:f,expires_in:h,expires_at:m,token_type:b}=t;if(!c||!h||!f||!b)throw new $u("No session defined in URL");const g=Math.round(Date.now()/1e3),x=parseInt(h);let w=g+x;m&&(w=parseInt(m));const E=w-g;E*1e3<=no&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${E}s, should have been closer to ${x}s`);const S=w-x;g-S>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",S,w,g):g-S<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",S,w,g);const{data:C,error:N}=await this._getUser(c);if(N)throw N;const A={provider_token:i,provider_refresh_token:l,access_token:c,expires_in:x,expires_at:w,refresh_token:f,token_type:b,user:C.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:A,redirectType:t.type},error:null})}catch(i){if(ye(i))return this._returnResult({data:{session:null,redirectType:null},error:i});throw i}}_isImplicitGrantCallback(t){return typeof this.detectSessionInUrl=="function"?this.detectSessionInUrl(new URL(window.location.href),t):!!(t.access_token||t.error_description)}async _isPKCECallback(t){const n=await Ds(this.storage,`${this.storageKey}-code-verifier`);return!!(t.code&&n)}async signOut(t={scope:"global"}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(t))}async _signOut({scope:t}={scope:"global"}){return await this._useSession(async n=>{var a;const{data:i,error:l}=n;if(l&&!zu(l))return this._returnResult({error:l});const c=(a=i.session)===null||a===void 0?void 0:a.access_token;if(c){const{error:f}=await this.admin.signOut(c,t);if(f&&!(wM(f)&&(f.status===404||f.status===401||f.status===403)||zu(f)))return this._returnResult({error:f})}return t!=="others"&&(await this._removeSession(),await hn(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(t){const n=AM(),a={id:n,callback:t,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",n),this.stateChangeEmitters.delete(n)}};return this._debug("#onAuthStateChange()","registered callback with id",n),this.stateChangeEmitters.set(n,a),(async()=>(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(n)})))(),{data:{subscription:a}}}async _emitInitialSession(t){return await this._useSession(async n=>{var a,i;try{const{data:{session:l},error:c}=n;if(c)throw c;await((a=this.stateChangeEmitters.get(t))===null||a===void 0?void 0:a.callback("INITIAL_SESSION",l)),this._debug("INITIAL_SESSION","callback id",t,"session",l)}catch(l){await((i=this.stateChangeEmitters.get(t))===null||i===void 0?void 0:i.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",t,"error",l),zu(l)?console.warn(l):console.error(l)}})}async resetPasswordForEmail(t,n={}){let a=null,i=null;this.flowType==="pkce"&&([a,i]=await Gi(this.storage,this.storageKey,!0));try{return await ke(this.fetch,"POST",`${this.url}/recover`,{body:{email:t,code_challenge:a,code_challenge_method:i,gotrue_meta_security:{captcha_token:n.captchaToken}},headers:this.headers,redirectTo:n.redirectTo})}catch(l){if(await hn(this.storage,`${this.storageKey}-code-verifier`),ye(l))return this._returnResult({data:null,error:l});throw l}}async getUserIdentities(){var t;try{const{data:n,error:a}=await this.getUser();if(a)throw a;return this._returnResult({data:{identities:(t=n.user.identities)!==null&&t!==void 0?t:[]},error:null})}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}}async linkIdentity(t){return"token"in t?this.linkIdentityIdToken(t):this.linkIdentityOAuth(t)}async linkIdentityOAuth(t){var n;try{const{data:a,error:i}=await this._useSession(async l=>{var c,f,h,m,b;const{data:g,error:x}=l;if(x)throw x;const w=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,t.provider,{redirectTo:(c=t.options)===null||c===void 0?void 0:c.redirectTo,scopes:(f=t.options)===null||f===void 0?void 0:f.scopes,queryParams:(h=t.options)===null||h===void 0?void 0:h.queryParams,skipBrowserRedirect:!0});return await ke(this.fetch,"GET",w,{headers:this.headers,jwt:(b=(m=g.session)===null||m===void 0?void 0:m.access_token)!==null&&b!==void 0?b:void 0})});if(i)throw i;return mn()&&!(!((n=t.options)===null||n===void 0)&&n.skipBrowserRedirect)&&window.location.assign(a==null?void 0:a.url),this._returnResult({data:{provider:t.provider,url:a==null?void 0:a.url},error:null})}catch(a){if(ye(a))return this._returnResult({data:{provider:t.provider,url:null},error:a});throw a}}async linkIdentityIdToken(t){return await this._useSession(async n=>{var a;try{const{error:i,data:{session:l}}=n;if(i)throw i;const{options:c,provider:f,token:h,access_token:m,nonce:b}=t,g=await ke(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(a=l==null?void 0:l.access_token)!==null&&a!==void 0?a:void 0,body:{provider:f,id_token:h,access_token:m,nonce:b,link_identity:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken}},xform:or}),{data:x,error:w}=g;return w?this._returnResult({data:{user:null,session:null},error:w}):!x||!x.session||!x.user?this._returnResult({data:{user:null,session:null},error:new Fi}):(x.session&&(await this._saveSession(x.session),await this._notifyAllSubscribers("USER_UPDATED",x.session)),this._returnResult({data:x,error:w}))}catch(i){if(await hn(this.storage,`${this.storageKey}-code-verifier`),ye(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}})}async unlinkIdentity(t){try{return await this._useSession(async n=>{var a,i;const{data:l,error:c}=n;if(c)throw c;return await ke(this.fetch,"DELETE",`${this.url}/user/identities/${t.identity_id}`,{headers:this.headers,jwt:(i=(a=l.session)===null||a===void 0?void 0:a.access_token)!==null&&i!==void 0?i:void 0})})}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}}async _refreshAccessToken(t){const n=`#_refreshAccessToken(${t.substring(0,5)}...)`;this._debug(n,"begin");try{const a=Date.now();return await DM(async i=>(i>0&&await MM(200*Math.pow(2,i-1)),this._debug(n,"refreshing attempt",i),await ke(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:t},headers:this.headers,xform:or})),(i,l)=>{const c=200*Math.pow(2,i);return l&&fp(l)&&Date.now()+c-a<no})}catch(a){if(this._debug(n,"error",a),ye(a))return this._returnResult({data:{session:null,user:null},error:a});throw a}finally{this._debug(n,"end")}}_isValidSession(t){return typeof t=="object"&&t!==null&&"access_token"in t&&"refresh_token"in t&&"expires_at"in t}async _handleProviderSignIn(t,n){const a=await this._getUrlForProvider(`${this.url}/authorize`,t,{redirectTo:n.redirectTo,scopes:n.scopes,queryParams:n.queryParams});return this._debug("#_handleProviderSignIn()","provider",t,"options",n,"url",a),mn()&&!n.skipBrowserRedirect&&window.location.assign(a),{data:{provider:t,url:a},error:null}}async _recoverAndRefresh(){var t,n;const a="#_recoverAndRefresh()";this._debug(a,"begin");try{const i=await Ds(this.storage,this.storageKey);if(i&&this.userStorage){let c=await Ds(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!c&&(c={user:i.user},await ro(this.userStorage,this.storageKey+"-user",c)),i.user=(t=c==null?void 0:c.user)!==null&&t!==void 0?t:hp()}else if(i&&!i.user&&!i.user){const c=await Ds(this.storage,this.storageKey+"-user");c&&(c!=null&&c.user)?(i.user=c.user,await hn(this.storage,this.storageKey+"-user"),await ro(this.storage,this.storageKey,i)):i.user=hp()}if(this._debug(a,"session from storage",i),!this._isValidSession(i)){this._debug(a,"session is not valid"),i!==null&&await this._removeSession();return}const l=((n=i.expires_at)!==null&&n!==void 0?n:1/0)*1e3-Date.now()<dp;if(this._debug(a,`session has${l?"":" not"} expired with margin of ${dp}s`),l){if(this.autoRefreshToken&&i.refresh_token){const{error:c}=await this._callRefreshToken(i.refresh_token);c&&(console.error(c),fp(c)||(this._debug(a,"refresh failed with a non-retryable error, removing the session",c),await this._removeSession()))}}else if(i.user&&i.user.__isUserNotAvailableProxy===!0)try{const{data:c,error:f}=await this._getUser(i.access_token);!f&&(c!=null&&c.user)?(i.user=c.user,await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)):this._debug(a,"could not get user data, skipping SIGNED_IN notification")}catch(c){console.error("Error getting user data:",c),this._debug(a,"error getting user data, skipping SIGNED_IN notification",c)}else await this._notifyAllSubscribers("SIGNED_IN",i)}catch(i){this._debug(a,"error",i),console.error(i);return}finally{this._debug(a,"end")}}async _callRefreshToken(t){var n,a;if(!t)throw new rn;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const i=`#_callRefreshToken(${t.substring(0,5)}...)`;this._debug(i,"begin");try{this.refreshingDeferred=new cf;const{data:l,error:c}=await this._refreshAccessToken(t);if(c)throw c;if(!l.session)throw new rn;await this._saveSession(l.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",l.session);const f={data:l.session,error:null};return this.refreshingDeferred.resolve(f),f}catch(l){if(this._debug(i,"error",l),ye(l)){const c={data:null,error:l};return fp(l)||await this._removeSession(),(n=this.refreshingDeferred)===null||n===void 0||n.resolve(c),c}throw(a=this.refreshingDeferred)===null||a===void 0||a.reject(l),l}finally{this.refreshingDeferred=null,this._debug(i,"end")}}async _notifyAllSubscribers(t,n,a=!0){const i=`#_notifyAllSubscribers(${t})`;this._debug(i,"begin",n,`broadcast = ${a}`);try{this.broadcastChannel&&a&&this.broadcastChannel.postMessage({event:t,session:n});const l=[],c=Array.from(this.stateChangeEmitters.values()).map(async f=>{try{await f.callback(t,n)}catch(h){l.push(h)}});if(await Promise.all(c),l.length>0){for(let f=0;f<l.length;f+=1)console.error(l[f]);throw l[0]}}finally{this._debug(i,"end")}}async _saveSession(t){this._debug("#_saveSession()",t),this.suppressGetSessionWarning=!0,await hn(this.storage,`${this.storageKey}-code-verifier`);const n=Object.assign({},t),a=n.user&&n.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!a&&n.user&&await ro(this.userStorage,this.storageKey+"-user",{user:n.user});const i=Object.assign({},n);delete i.user;const l=zw(i);await ro(this.storage,this.storageKey,l)}else{const i=zw(n);await ro(this.storage,this.storageKey,i)}}async _removeSession(){this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await hn(this.storage,this.storageKey),await hn(this.storage,this.storageKey+"-code-verifier"),await hn(this.storage,this.storageKey+"-user"),this.userStorage&&await hn(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const t=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{t&&mn()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",t)}catch(n){console.error("removing visibilitychange callback failed",n)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const t=setInterval(()=>this._autoRefreshTokenTick(),no);this.autoRefreshTicker=t,t&&typeof t=="object"&&typeof t.unref=="function"?t.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(t);const n=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);this.autoRefreshTickTimeout=n,n&&typeof n=="object"&&typeof n.unref=="function"?n.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(n)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const t=this.autoRefreshTicker;this.autoRefreshTicker=null,t&&clearInterval(t);const n=this.autoRefreshTickTimeout;this.autoRefreshTickTimeout=null,n&&clearTimeout(n)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const t=Date.now();try{return await this._useSession(async n=>{const{data:{session:a}}=n;if(!a||!a.refresh_token||!a.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const i=Math.floor((a.expires_at*1e3-t)/no);this._debug("#_autoRefreshTokenTick()",`access token expires in ${i} ticks, a tick lasts ${no}ms, refresh threshold is ${ig} ticks`),i<=ig&&await this._callRefreshToken(a.refresh_token)})}catch(n){console.error("Auto refresh tick failed with error. This is likely a transient error.",n)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(t){if(t instanceof o1)this._debug("auto refresh token tick lock not available");else throw t}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!mn()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(t){this._debug("#visibilityChangedCallback","error",t)}},window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(t){console.error("_handleVisibilityChange",t)}}async _onVisibilityChanged(t){const n=`#_onVisibilityChanged(${t})`;this._debug(n,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),t||(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{if(document.visibilityState!=="visible"){this._debug(n,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(t,n,a){const i=[`provider=${encodeURIComponent(n)}`];if(a!=null&&a.redirectTo&&i.push(`redirect_to=${encodeURIComponent(a.redirectTo)}`),a!=null&&a.scopes&&i.push(`scopes=${encodeURIComponent(a.scopes)}`),this.flowType==="pkce"){const[l,c]=await Gi(this.storage,this.storageKey),f=new URLSearchParams({code_challenge:`${encodeURIComponent(l)}`,code_challenge_method:`${encodeURIComponent(c)}`});i.push(f.toString())}if(a!=null&&a.queryParams){const l=new URLSearchParams(a.queryParams);i.push(l.toString())}return a!=null&&a.skipBrowserRedirect&&i.push(`skip_http_redirect=${a.skipBrowserRedirect}`),`${t}?${i.join("&")}`}async _unenroll(t){try{return await this._useSession(async n=>{var a;const{data:i,error:l}=n;return l?this._returnResult({data:null,error:l}):await ke(this.fetch,"DELETE",`${this.url}/factors/${t.factorId}`,{headers:this.headers,jwt:(a=i==null?void 0:i.session)===null||a===void 0?void 0:a.access_token})})}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}}async _enroll(t){try{return await this._useSession(async n=>{var a,i;const{data:l,error:c}=n;if(c)return this._returnResult({data:null,error:c});const f=Object.assign({friendly_name:t.friendlyName,factor_type:t.factorType},t.factorType==="phone"?{phone:t.phone}:t.factorType==="totp"?{issuer:t.issuer}:{}),{data:h,error:m}=await ke(this.fetch,"POST",`${this.url}/factors`,{body:f,headers:this.headers,jwt:(a=l==null?void 0:l.session)===null||a===void 0?void 0:a.access_token});return m?this._returnResult({data:null,error:m}):(t.factorType==="totp"&&h.type==="totp"&&(!((i=h==null?void 0:h.totp)===null||i===void 0)&&i.qr_code)&&(h.totp.qr_code=`data:image/svg+xml;utf-8,${h.totp.qr_code}`),this._returnResult({data:h,error:null}))})}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}}async _verify(t){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async n=>{var a;const{data:i,error:l}=n;if(l)return this._returnResult({data:null,error:l});const c=Object.assign({challenge_id:t.challengeId},"webauthn"in t?{webauthn:Object.assign(Object.assign({},t.webauthn),{credential_response:t.webauthn.type==="create"?Fw(t.webauthn.credential_response):Gw(t.webauthn.credential_response)})}:{code:t.code}),{data:f,error:h}=await ke(this.fetch,"POST",`${this.url}/factors/${t.factorId}/verify`,{body:c,headers:this.headers,jwt:(a=i==null?void 0:i.session)===null||a===void 0?void 0:a.access_token});return h?this._returnResult({data:null,error:h}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+f.expires_in},f)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",f),this._returnResult({data:f,error:h}))})}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}})}async _challenge(t){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async n=>{var a;const{data:i,error:l}=n;if(l)return this._returnResult({data:null,error:l});const c=await ke(this.fetch,"POST",`${this.url}/factors/${t.factorId}/challenge`,{body:t,headers:this.headers,jwt:(a=i==null?void 0:i.session)===null||a===void 0?void 0:a.access_token});if(c.error)return c;const{data:f}=c;if(f.type!=="webauthn")return{data:f,error:null};switch(f.webauthn.type){case"create":return{data:Object.assign(Object.assign({},f),{webauthn:Object.assign(Object.assign({},f.webauthn),{credential_options:Object.assign(Object.assign({},f.webauthn.credential_options),{publicKey:qw(f.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},f),{webauthn:Object.assign(Object.assign({},f.webauthn),{credential_options:Object.assign(Object.assign({},f.webauthn.credential_options),{publicKey:Vw(f.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}})}async _challengeAndVerify(t){const{data:n,error:a}=await this._challenge({factorId:t.factorId});return a?this._returnResult({data:null,error:a}):await this._verify({factorId:t.factorId,challengeId:n.id,code:t.code})}async _listFactors(){var t;const{data:{user:n},error:a}=await this.getUser();if(a)return{data:null,error:a};const i={all:[],phone:[],totp:[],webauthn:[]};for(const l of(t=n==null?void 0:n.factors)!==null&&t!==void 0?t:[])i.all.push(l),l.status==="verified"&&i[l.factor_type].push(l);return{data:i,error:null}}async _getAuthenticatorAssuranceLevel(t){var n,a,i,l;if(t)try{const{payload:w}=Uu(t);let E=null;w.aal&&(E=w.aal);let S=E;const{data:{user:C},error:N}=await this.getUser(t);if(N)return this._returnResult({data:null,error:N});((a=(n=C==null?void 0:C.factors)===null||n===void 0?void 0:n.filter(M=>M.status==="verified"))!==null&&a!==void 0?a:[]).length>0&&(S="aal2");const T=w.amr||[];return{data:{currentLevel:E,nextLevel:S,currentAuthenticationMethods:T},error:null}}catch(w){if(ye(w))return this._returnResult({data:null,error:w});throw w}const{data:{session:c},error:f}=await this.getSession();if(f)return this._returnResult({data:null,error:f});if(!c)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:h}=Uu(c.access_token);let m=null;h.aal&&(m=h.aal);let b=m;((l=(i=c.user.factors)===null||i===void 0?void 0:i.filter(w=>w.status==="verified"))!==null&&l!==void 0?l:[]).length>0&&(b="aal2");const x=h.amr||[];return{data:{currentLevel:m,nextLevel:b,currentAuthenticationMethods:x},error:null}}async _getAuthorizationDetails(t){try{return await this._useSession(async n=>{const{data:{session:a},error:i}=n;return i?this._returnResult({data:null,error:i}):a?await ke(this.fetch,"GET",`${this.url}/oauth/authorizations/${t}`,{headers:this.headers,jwt:a.access_token,xform:l=>({data:l,error:null})}):this._returnResult({data:null,error:new rn})})}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}}async _approveAuthorization(t,n){try{return await this._useSession(async a=>{const{data:{session:i},error:l}=a;if(l)return this._returnResult({data:null,error:l});if(!i)return this._returnResult({data:null,error:new rn});const c=await ke(this.fetch,"POST",`${this.url}/oauth/authorizations/${t}/consent`,{headers:this.headers,jwt:i.access_token,body:{action:"approve"},xform:f=>({data:f,error:null})});return c.data&&c.data.redirect_url&&mn()&&!(n!=null&&n.skipBrowserRedirect)&&window.location.assign(c.data.redirect_url),c})}catch(a){if(ye(a))return this._returnResult({data:null,error:a});throw a}}async _denyAuthorization(t,n){try{return await this._useSession(async a=>{const{data:{session:i},error:l}=a;if(l)return this._returnResult({data:null,error:l});if(!i)return this._returnResult({data:null,error:new rn});const c=await ke(this.fetch,"POST",`${this.url}/oauth/authorizations/${t}/consent`,{headers:this.headers,jwt:i.access_token,body:{action:"deny"},xform:f=>({data:f,error:null})});return c.data&&c.data.redirect_url&&mn()&&!(n!=null&&n.skipBrowserRedirect)&&window.location.assign(c.data.redirect_url),c})}catch(a){if(ye(a))return this._returnResult({data:null,error:a});throw a}}async _listOAuthGrants(){try{return await this._useSession(async t=>{const{data:{session:n},error:a}=t;return a?this._returnResult({data:null,error:a}):n?await ke(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:n.access_token,xform:i=>({data:i,error:null})}):this._returnResult({data:null,error:new rn})})}catch(t){if(ye(t))return this._returnResult({data:null,error:t});throw t}}async _revokeOAuthGrant(t){try{return await this._useSession(async n=>{const{data:{session:a},error:i}=n;return i?this._returnResult({data:null,error:i}):a?(await ke(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:a.access_token,query:{client_id:t.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new rn})})}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}}async fetchJwk(t,n={keys:[]}){let a=n.keys.find(f=>f.kid===t);if(a)return a;const i=Date.now();if(a=this.jwks.keys.find(f=>f.kid===t),a&&this.jwks_cached_at+bM>i)return a;const{data:l,error:c}=await ke(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(c)throw c;return!l.keys||l.keys.length===0||(this.jwks=l,this.jwks_cached_at=i,a=l.keys.find(f=>f.kid===t),!a)?null:a}async getClaims(t,n={}){try{let a=t;if(!a){const{data:w,error:E}=await this.getSession();if(E||!w.session)return this._returnResult({data:null,error:E});a=w.session.access_token}const{header:i,payload:l,signature:c,raw:{header:f,payload:h}}=Uu(a);n!=null&&n.allowExpired||BM(l.exp);const m=!i.alg||i.alg.startsWith("HS")||!i.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(i.kid,n!=null&&n.keys?{keys:n.keys}:n==null?void 0:n.jwks);if(!m){const{error:w}=await this.getUser(a);if(w)throw w;return{data:{claims:l,header:i,signature:c},error:null}}const b=HM(i.alg),g=await crypto.subtle.importKey("jwk",m,b,!0,["verify"]);if(!await crypto.subtle.verify(b,g,c,TM(`${f}.${h}`)))throw new cg("Invalid JWT signature");return{data:{claims:l,header:i,signature:c},error:null}}catch(a){if(ye(a))return this._returnResult({data:null,error:a});throw a}}async signInWithPasskey(t){var n,a,i;vr(this.experimental);try{if(!kd())return this._returnResult({data:null,error:new xr("Browser does not support WebAuthn",null)});const{data:l,error:c}=await this._startPasskeyAuthentication({options:{captchaToken:(n=t==null?void 0:t.options)===null||n===void 0?void 0:n.captchaToken}});if(c||!l)return this._returnResult({data:null,error:c});const f=Vw(l.options),h=(i=(a=t==null?void 0:t.options)===null||a===void 0?void 0:a.signal)!==null&&i!==void 0?i:ug.createNewAbortSignal(),{data:m,error:b}=await d1({publicKey:f,signal:h});if(b||!m)return this._returnResult({data:null,error:b??new xr("WebAuthn ceremony failed",null)});const g=Gw(m);return this._verifyPasskeyAuthentication({challengeId:l.challenge_id,credential:g})}catch(l){if(ye(l))return this._returnResult({data:null,error:l});throw l}}async registerPasskey(t){var n,a;vr(this.experimental);try{if(!kd())return this._returnResult({data:null,error:new xr("Browser does not support WebAuthn",null)});const{data:i,error:l}=await this._startPasskeyRegistration();if(l||!i)return this._returnResult({data:null,error:l});const c=qw(i.options),f=(a=(n=t==null?void 0:t.options)===null||n===void 0?void 0:n.signal)!==null&&a!==void 0?a:ug.createNewAbortSignal(),{data:h,error:m}=await u1({publicKey:c,signal:f});if(m||!h)return this._returnResult({data:null,error:m??new xr("WebAuthn ceremony failed",null)});const b=Fw(h);return this._verifyPasskeyRegistration({challengeId:i.challenge_id,credential:b})}catch(i){if(ye(i))return this._returnResult({data:null,error:i});throw i}}async _startPasskeyRegistration(){vr(this.experimental);try{return await this._useSession(async t=>{const{data:{session:n},error:a}=t;if(a)return this._returnResult({data:null,error:a});if(!n)return this._returnResult({data:null,error:new rn});const{data:i,error:l}=await ke(this.fetch,"POST",`${this.url}/passkeys/registration/options`,{headers:this.headers,jwt:n.access_token,body:{}});return l?this._returnResult({data:null,error:l}):this._returnResult({data:i,error:null})})}catch(t){if(ye(t))return this._returnResult({data:null,error:t});throw t}}async _verifyPasskeyRegistration(t){vr(this.experimental);try{return await this._useSession(async n=>{const{data:{session:a},error:i}=n;if(i)return this._returnResult({data:null,error:i});if(!a)return this._returnResult({data:null,error:new rn});const{data:l,error:c}=await ke(this.fetch,"POST",`${this.url}/passkeys/registration/verify`,{headers:this.headers,jwt:a.access_token,body:{challenge_id:t.challengeId,credential:t.credential}});return c?this._returnResult({data:null,error:c}):this._returnResult({data:l,error:null})})}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}}async _startPasskeyAuthentication(t){var n;vr(this.experimental);try{const{data:a,error:i}=await ke(this.fetch,"POST",`${this.url}/passkeys/authentication/options`,{headers:this.headers,body:{gotrue_meta_security:{captcha_token:(n=t==null?void 0:t.options)===null||n===void 0?void 0:n.captchaToken}}});return i?this._returnResult({data:null,error:i}):this._returnResult({data:a,error:null})}catch(a){if(ye(a))return this._returnResult({data:null,error:a});throw a}}async _verifyPasskeyAuthentication(t){vr(this.experimental);try{const{data:n,error:a}=await ke(this.fetch,"POST",`${this.url}/passkeys/authentication/verify`,{headers:this.headers,body:{challenge_id:t.challengeId,credential:t.credential},xform:or});return a?this._returnResult({data:null,error:a}):(n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),this._returnResult({data:n,error:null}))}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}}async _listPasskeys(){vr(this.experimental);try{return await this._useSession(async t=>{const{data:{session:n},error:a}=t;if(a)return this._returnResult({data:null,error:a});if(!n)return this._returnResult({data:null,error:new rn});const{data:i,error:l}=await ke(this.fetch,"GET",`${this.url}/passkeys`,{headers:this.headers,jwt:n.access_token,xform:c=>({data:c,error:null})});return l?this._returnResult({data:null,error:l}):this._returnResult({data:i,error:null})})}catch(t){if(ye(t))return this._returnResult({data:null,error:t});throw t}}async _updatePasskey(t){vr(this.experimental);try{return await this._useSession(async n=>{const{data:{session:a},error:i}=n;if(i)return this._returnResult({data:null,error:i});if(!a)return this._returnResult({data:null,error:new rn});const{data:l,error:c}=await ke(this.fetch,"PATCH",`${this.url}/passkeys/${t.passkeyId}`,{headers:this.headers,jwt:a.access_token,body:{friendly_name:t.friendlyName}});return c?this._returnResult({data:null,error:c}):this._returnResult({data:l,error:null})})}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}}async _deletePasskey(t){vr(this.experimental);try{return await this._useSession(async n=>{const{data:{session:a},error:i}=n;if(i)return this._returnResult({data:null,error:i});if(!a)return this._returnResult({data:null,error:new rn});const{error:l}=await ke(this.fetch,"DELETE",`${this.url}/passkeys/${t.passkeyId}`,{headers:this.headers,jwt:a.access_token,noResolveJson:!0});return l?this._returnResult({data:null,error:l}):this._returnResult({data:null,error:null})})}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}}}Gl.nextInstanceID={};const fD=Gl,hD="2.106.2";let Al="";typeof Deno<"u"?Al="deno":typeof document<"u"?Al="web":typeof navigator<"u"&&navigator.product==="ReactNative"?Al="react-native":Al="node";const mD={"X-Client-Info":`supabase-js-${Al}/${hD}`},pD={headers:mD},gD={schema:"public"},vD={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},yD={},bD={enabled:!1,respectSamplingDecision:!0};function xD(e,t,n,a){function i(l){return l instanceof n?l:new n(function(c){c(l)})}return new(n||(n=Promise))(function(l,c){function f(b){try{m(a.next(b))}catch(g){c(g)}}function h(b){try{m(a.throw(b))}catch(g){c(g)}}function m(b){b.done?l(b.value):i(b.value).then(f,h)}m((a=a.apply(e,[])).next())})}let pp=null;const wD="@opentelemetry/api";function _D(){return pp===null&&(pp=import(wD).catch(()=>null)),pp}function SD(){return xD(this,void 0,void 0,function*(){try{const e=yield _D();if(!e||!e.propagation||!e.context)return null;const t={};e.propagation.inject(e.context.active(),t);const n=t.traceparent;return n?{traceparent:n,tracestate:t.tracestate,baggage:t.baggage}:null}catch{return null}})}function ED(e){if(!e||typeof e!="string")return null;const t=e.split("-");if(t.length!==4)return null;const[n,a,i,l]=t;if(n.length!==2||a.length!==32||i.length!==16||l.length!==2)return null;const c=/^[0-9a-f]+$/i;return!c.test(n)||!c.test(a)||!c.test(i)||!c.test(l)||a==="00000000000000000000000000000000"||i==="0000000000000000"?null:{version:n,traceId:a,parentId:i,traceFlags:l,isSampled:(parseInt(l,16)&1)===1}}function ND(e,t){if(!e||!t||t.length===0)return!1;let n;if(e instanceof URL)n=e;else try{n=new URL(e)}catch{return!1}for(const a of t)try{if(typeof a=="string"){if(CD(n.hostname,a))return!0}else if(a instanceof RegExp){if(a.test(n.hostname))return!0}else if(typeof a=="function"&&a(n))return!0}catch{continue}return!1}function CD(e,t){if(t===e)return!0;if(t.startsWith("*.")){const n=t.slice(2);if(e.endsWith(n)&&(e===n||e.endsWith("."+n)))return!0}return!1}function jD(e){const t=[];try{const n=new URL(e);t.push(n.hostname)}catch{}return t.push("*.supabase.co","*.supabase.in"),t.push("localhost","127.0.0.1","[::1]"),t}function Kl(e){"@babel/helpers - typeof";return Kl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kl(e)}function TD(e,t){if(Kl(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var a=n.call(e,t);if(Kl(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function RD(e){var t=TD(e,"string");return Kl(t)=="symbol"?t:t+""}function AD(e,t,n){return(t=RD(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ww(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,a)}return n}function It(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ww(Object(n),!0).forEach(function(a){AD(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ww(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}const kD=e=>e?(...t)=>e(...t):(...t)=>fetch(...t),OD=()=>Headers,MD=(e,t,n,a,i)=>{const l=kD(a),c=OD(),f=(i==null?void 0:i.enabled)===!0,h=(i==null?void 0:i.respectSamplingDecision)!==!1,m=f?jD(t):null;return async(b,g)=>{var x;const w=(x=await n())!==null&&x!==void 0?x:e;let E=new c(g==null?void 0:g.headers);if(E.has("apikey")||E.set("apikey",e),E.has("Authorization")||E.set("Authorization",`Bearer ${w}`),m){const S=await DD(b,m,h);S&&(S.traceparent&&!E.has("traceparent")&&E.set("traceparent",S.traceparent),S.tracestate&&!E.has("tracestate")&&E.set("tracestate",S.tracestate),S.baggage&&!E.has("baggage")&&E.set("baggage",S.baggage))}return l(b,It(It({},g),{},{headers:E}))}};async function DD(e,t,n){if(!ND(typeof e=="string"||e instanceof URL?e:e.url,t))return null;const a=await SD();if(!a||!a.traceparent)return null;if(n){const i=ED(a.traceparent);if(i&&!i.isSampled)return null}return a}function Yw(e){return typeof e=="boolean"?{enabled:e}:e}function PD(e){return e.endsWith("/")?e:e+"/"}function LD(e,t){var n,a,i,l,c,f;const{db:h,auth:m,realtime:b,global:g}=e,{db:x,auth:w,realtime:E,global:S}=t,C=Yw(e.tracePropagation),N=Yw(t.tracePropagation),A={db:It(It({},x),h),auth:It(It({},w),m),realtime:It(It({},E),b),storage:{},global:It(It(It({},S),g),{},{headers:It(It({},(n=S==null?void 0:S.headers)!==null&&n!==void 0?n:{}),(a=g==null?void 0:g.headers)!==null&&a!==void 0?a:{})}),tracePropagation:{enabled:(i=(l=C==null?void 0:C.enabled)!==null&&l!==void 0?l:N==null?void 0:N.enabled)!==null&&i!==void 0?i:!1,respectSamplingDecision:(c=(f=C==null?void 0:C.respectSamplingDecision)!==null&&f!==void 0?f:N==null?void 0:N.respectSamplingDecision)!==null&&c!==void 0?c:!0},accessToken:async()=>""};return e.accessToken?A.accessToken=e.accessToken:delete A.accessToken,A}function zD(e){const t=e==null?void 0:e.trim();if(!t)throw new Error("supabaseUrl is required.");if(!t.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(PD(t))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var ID=class extends fD{constructor(e){super(e)}},$D=class{constructor(e,t,n){var a,i;this.supabaseUrl=e,this.supabaseKey=t;const l=zD(e);if(!t)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",l),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",l),this.storageUrl=new URL("storage/v1",l),this.functionsUrl=new URL("functions/v1",l);const c=`sb-${l.hostname.split(".")[0]}-auth-token`,f={db:gD,realtime:yD,auth:It(It({},vD),{},{storageKey:c}),global:pD,tracePropagation:bD},h=LD(n??{},f);if(this.settings=h,this.storageKey=(a=h.auth.storageKey)!==null&&a!==void 0?a:"",this.headers=(i=h.global.headers)!==null&&i!==void 0?i:{},h.accessToken)this.accessToken=h.accessToken,this.auth=new Proxy({},{get:(b,g)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(g)} is not possible`)}});else{var m;this.auth=this._initSupabaseAuthClient((m=h.auth)!==null&&m!==void 0?m:{},this.headers,h.global.fetch)}this.fetch=MD(t,e,this._getAccessToken.bind(this),h.global.fetch,h.tracePropagation),this.realtime=this._initRealtimeClient(It({headers:this.headers,accessToken:this._getAccessToken.bind(this),fetch:this.fetch},h.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(b=>this.realtime.setAuth(b)).catch(b=>console.warn("Failed to set initial Realtime auth token:",b)),this.rest=new tO(new URL("rest/v1",l).href,{headers:this.headers,schema:h.db.schema,fetch:this.fetch,timeout:h.db.timeout,urlLengthLimit:h.db.urlLengthLimit}),this.storage=new mM(this.storageUrl.href,this.headers,this.fetch,n==null?void 0:n.storage),h.accessToken||this._listenForAuthEvents()}get functions(){return new F2(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,t={},n={head:!1,get:!1,count:void 0}){return this.rest.rpc(e,t,n)}channel(e,t={config:{}}){return this.realtime.channel(e,t)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var e=this,t,n;if(e.accessToken)return await e.accessToken();const{data:a}=await e.auth.getSession();return(t=(n=a.session)===null||n===void 0?void 0:n.access_token)!==null&&t!==void 0?t:e.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:n,storage:a,userStorage:i,storageKey:l,flowType:c,lock:f,debug:h,throwOnError:m,experimental:b,lockAcquireTimeout:g,skipAutoInitialize:x},w,E){const S={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new ID({url:this.authUrl.href,headers:It(It({},S),w),storageKey:l,autoRefreshToken:e,persistSession:t,detectSessionInUrl:n,storage:a,userStorage:i,flowType:c,lock:f,debug:h,throwOnError:m,experimental:b,fetch:E,lockAcquireTimeout:g,skipAutoInitialize:x,hasCustomAuthorizationHeader:Object.keys(this.headers).some(C=>C.toLowerCase()==="authorization")})}_initRealtimeClient(e){return new zO(this.realtimeUrl.href,It(It({},e),{},{params:It(It({},{apikey:this.supabaseKey}),e==null?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((e,t)=>{this._handleTokenChanged(e,"CLIENT",t==null?void 0:t.access_token)})}_handleTokenChanged(e,t,n){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==n?(this.changedAccessToken=n,this.realtime.setAuth(n)):e==="SIGNED_OUT"&&(this.realtime.setAuth(),t=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};const UD=(e,t,n)=>new $D(e,t,n);function BD(){if(typeof window<"u")return!1;const e=globalThis.process;if(!e)return!1;const t=e.version;if(t==null)return!1;const n=t.match(/^v(\d+)\./);return n?parseInt(n[1],10)<=18:!1}BD()&&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");const HD={BASE_URL:"/tablero-cdc/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_LISTS_WEBHOOK_URL:"https://agenteit.digitalcompass.agency/webhook/tablero-cdc-sync-listas-admin",VITE_SUPABASE_ANON_KEY:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE",VITE_SUPABASE_URL:"https://dbit.digitalcompass.agency",VITE_WEBHOOK_URL:"https://agenteit.digitalcompass.agency/webhook/tablero-cdc-sync-proyecto"},qD=["VITE_SUPABASE_URL","VITE_SUPABASE_ANON_KEY"],Xw=qD.filter(e=>!HD[e]);if(Xw.length>0)throw new Error(`Faltan variables de entorno de Supabase. Revisa tu archivo .env.
Variables faltantes: ${Xw.join(", ")}`);const Se=UD("https://dbit.digitalcompass.agency","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE",{auth:{persistSession:!0,autoRefreshToken:!0,detectSessionInUrl:!0}});function f1(e){return String(e??"").trim().toLowerCase()}function Bu(e){return!(e!=null&&e.email)||e.is_active!==!0?null:{email:f1(e.email),fullName:e.full_name??null,role:String(e.role||"user").trim()||"user",isActive:!0,canDeleteProjects:e.can_delete_projects===!0,canManageInternalPricing:e.can_manage_internal_pricing===!0,canControlPricingSummary:e.can_control_pricing_summary===!0,canManageTariffCatalog:e.can_manage_tariff_catalog===!0,canViewTeamHours:e.can_view_team_hours===!0,canCreateProjects:e.can_create_projects===!0}}async function h1(e){const t=f1(e);if(!t)return null;const n=await Se.from("tablero_cdc_allowed_users").select("email, full_name, role, is_active, can_delete_projects, can_manage_internal_pricing, can_control_pricing_summary, can_manage_tariff_catalog, can_view_team_hours, can_create_projects").eq("email",t).eq("is_active",!0).maybeSingle();if(!n.error)return Bu(n.data);const a=n.error.message||"";if(!(a.includes("can_create_projects")||a.includes("column")||a.includes("schema cache")))throw n.error;const l=await Se.from("tablero_cdc_allowed_users").select("email, full_name, role, is_active, can_delete_projects, can_manage_internal_pricing, can_control_pricing_summary, can_manage_tariff_catalog, can_view_team_hours").eq("email",t).eq("is_active",!0).maybeSingle();if(!l.error)return Bu(l.data);const c=l.error.message||"";if(!(c.includes("can_view_team_hours")||c.includes("column")||c.includes("schema cache")))throw l.error;const h=await Se.from("tablero_cdc_allowed_users").select("email, full_name, role, is_active, can_delete_projects, can_manage_internal_pricing, can_control_pricing_summary, can_manage_tariff_catalog").eq("email",t).eq("is_active",!0).maybeSingle();if(!h.error)return Bu(h.data);const m=h.error.message||"";if(!(m.includes("can_manage_tariff_catalog")||m.includes("column")||m.includes("schema cache")))throw h.error;const g=await Se.from("tablero_cdc_allowed_users").select("email, full_name, role, is_active, can_delete_projects, can_manage_internal_pricing, can_control_pricing_summary").eq("email",t).eq("is_active",!0).maybeSingle();if(g.error)throw g.error;return Bu(g.data)}async function uf(){const{data:e,error:t}=await Se.auth.getUser();if(t||!e.user)throw new Error("No hay una sesión activa de Supabase.");const n=await h1(e.user.email);if(!n)throw new Error("Tu correo no está autorizado para acceder al Tablero CDC.");return n}const Jw="tablero_cdc_metrics_session_id",Qw="tablero_cdc_metrics_open_recorded";function VD(){if(typeof window>"u")return crypto.randomUUID();const e=window.sessionStorage.getItem(Jw);if(e)return e;const t=crypto.randomUUID();return window.sessionStorage.setItem(Jw,t),t}async function FD(){if(typeof window<"u"&&window.sessionStorage.getItem(Qw)==="1")return;const e=VD(),{error:t}=await Se.rpc("tablero_cdc_track_app_open",{p_session_id:e});if(t){const n=String(t.message||"").toLowerCase();n.includes("tablero_cdc_track_app_open")||n.includes("could not find the function")||n.includes("schema cache")||console.warn("No se pudo registrar la métrica de apertura del Tablero CDC:",t);return}typeof window<"u"&&window.sessionStorage.setItem(Qw,"1")}function GD(){return typeof window>"u"?"/tablero-cdc/":new URL("/tablero-cdc/",window.location.origin).toString()}function KD(e){var i;const t=e.user_metadata||{},n=t.full_name||t.name||t.display_name||((i=e.email)==null?void 0:i.split("@")[0])||null,a=t.avatar_url||t.picture||null;return{id:e.id,uid:e.id,email:e.email??null,displayName:n,photoURL:a,raw:e}}const m1=v.createContext(null);function WD({children:e}){const[t,n]=v.useState(null),[a,i]=v.useState(null),[l,c]=v.useState(!0),[f,h]=v.useState(null),m=v.useCallback(async T=>{if(!T){n(null),i(null);return}let M=null;try{M=await h1(T.email)}catch($){console.error("Error al validar acceso al Tablero CDC:",$),await Se.auth.signOut(),n(null),i(null),h("No se pudo validar tu acceso al Tablero CDC. Verifica que el SQL de accesos esté ejecutado o contacta a IT.");return}if(!M){await Se.auth.signOut(),n(null),i(null),h("Tu correo no está autorizado para acceder al Tablero CDC. Solicita acceso a IT o al equipo CDC.");return}n(KD(T)),i(M),h(null),FD()},[]);v.useEffect(()=>{let T=!0;Se.auth.getSession().then(async({data:$,error:L})=>{var P;if(T){if(L){console.error("Error al recuperar sesión de Supabase:",L),n(null),h("No se pudo recuperar la sesión. Intenta iniciar sesión de nuevo.");return}await m(((P=$.session)==null?void 0:P.user)??null)}}).catch($=>{T&&(console.error("Error inesperado al recuperar sesión:",$),n(null),h("No se pudo recuperar la sesión. Intenta iniciar sesión de nuevo."))}).finally(()=>{T&&c(!1)});const{data:M}=Se.auth.onAuthStateChange(($,L)=>{c(!0),m((L==null?void 0:L.user)??null).finally(()=>{T&&c(!1)})});return()=>{T=!1,M.subscription.unsubscribe()}},[m]);const b=v.useCallback(async()=>{h(null);const{error:T}=await Se.auth.signInWithOAuth({provider:"google",options:{redirectTo:GD(),queryParams:{prompt:"select_account"}}});T&&(console.error("Error al iniciar sesión con Google:",T),h("No se pudo iniciar sesión. Intenta de nuevo."))},[]),g=v.useCallback(async()=>{const{error:T}=await Se.auth.signOut();if(T){console.error("Error al cerrar sesión:",T),h("No se pudo cerrar sesión. Intenta de nuevo.");return}n(null),i(null),h(null)},[]),x=v.useMemo(()=>(a==null?void 0:a.role)==="director_creativo",[a==null?void 0:a.role]),w=v.useMemo(()=>(a==null?void 0:a.canManageInternalPricing)===!0,[a==null?void 0:a.canManageInternalPricing]),E=v.useMemo(()=>(a==null?void 0:a.canDeleteProjects)===!0,[a==null?void 0:a.canDeleteProjects]),S=v.useMemo(()=>(a==null?void 0:a.canControlPricingSummary)===!0,[a==null?void 0:a.canControlPricingSummary]),C=v.useMemo(()=>(a==null?void 0:a.canManageTariffCatalog)===!0,[a==null?void 0:a.canManageTariffCatalog]),N=v.useMemo(()=>(a==null?void 0:a.canViewTeamHours)===!0,[a==null?void 0:a.canViewTeamHours]),A=v.useMemo(()=>(a==null?void 0:a.canCreateProjects)===!0,[a==null?void 0:a.canCreateProjects]);return d.jsx(m1.Provider,{value:{user:t,loading:l,error:f,isGerardo:x,canDeleteProjects:E,canManageInternalPricing:w,canControlPricingSummary:S,canManageTariffCatalog:C,canViewTeamHours:N,canCreateProjects:A,loginWithGoogle:b,logout:g},children:e})}function df(){const e=v.useContext(m1);if(!e)throw new Error("useAuth debe usarse dentro de <AuthProvider>");return e}function Zw(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function wn(...e){return t=>{let n=!1;const a=e.map(i=>{const l=Zw(i,t);return!n&&typeof l=="function"&&(n=!0),l});if(n)return()=>{for(let i=0;i<a.length;i++){const l=a[i];typeof l=="function"?l():Zw(e[i],null)}}}}function nt(...e){return v.useCallback(wn(...e),e)}var YD=Symbol.for("react.lazy"),Md=Vg[" use ".trim().toString()];function XD(e){return typeof e=="object"&&e!==null&&"then"in e}function p1(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===YD&&"_payload"in e&&XD(e._payload)}function ic(e){const t=QD(e),n=v.forwardRef((a,i)=>{let{children:l,...c}=a;p1(l)&&typeof Md=="function"&&(l=Md(l._payload));const f=v.Children.toArray(l),h=f.find(e5);if(h){const m=h.props.children,b=f.map(g=>g===h?v.Children.count(m)>1?v.Children.only(null):v.isValidElement(m)?m.props.children:null:g);return d.jsx(t,{...c,ref:i,children:v.isValidElement(m)?v.cloneElement(m,void 0,b):null})}return d.jsx(t,{...c,ref:i,children:l})});return n.displayName=`${e}.Slot`,n}var JD=ic("Slot");function QD(e){const t=v.forwardRef((n,a)=>{let{children:i,...l}=n;if(p1(i)&&typeof Md=="function"&&(i=Md(i._payload)),v.isValidElement(i)){const c=n5(i),f=t5(l,i.props);return i.type!==v.Fragment&&(f.ref=a?wn(a,c):c),v.cloneElement(i,f)}return v.Children.count(i)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ZD=Symbol("radix.slottable");function e5(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ZD}function t5(e,t){const n={...t};for(const a in t){const i=e[a],l=t[a];/^on[A-Z]/.test(a)?i&&l?n[a]=(...f)=>{const h=l(...f);return i(...f),h}:i&&(n[a]=i):a==="style"?n[a]={...i,...l}:a==="className"&&(n[a]=[i,l].filter(Boolean).join(" "))}return{...e,...n}}function n5(e){var a,i;let t=(a=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function g1(e){var t,n,a="";if(typeof e=="string"||typeof e=="number")a+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=g1(e[t]))&&(a&&(a+=" "),a+=n)}else for(n in e)e[n]&&(a&&(a+=" "),a+=n);return a}function v1(){for(var e,t,n=0,a="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=g1(e))&&(a&&(a+=" "),a+=t);return a}const e_=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,t_=v1,tv=(e,t)=>n=>{var a;if((t==null?void 0:t.variants)==null)return t_(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:l}=t,c=Object.keys(i).map(m=>{const b=n==null?void 0:n[m],g=l==null?void 0:l[m];if(b===null)return null;const x=e_(b)||e_(g);return i[m][x]}),f=n&&Object.entries(n).reduce((m,b)=>{let[g,x]=b;return x===void 0||(m[g]=x),m},{}),h=t==null||(a=t.compoundVariants)===null||a===void 0?void 0:a.reduce((m,b)=>{let{class:g,className:x,...w}=b;return Object.entries(w).every(E=>{let[S,C]=E;return Array.isArray(C)?C.includes({...l,...f}[S]):{...l,...f}[S]===C})?[...m,g,x]:m},[]);return t_(e,c,h,n==null?void 0:n.class,n==null?void 0:n.className)},r5=(e,t)=>{const n=new Array(e.length+t.length);for(let a=0;a<e.length;a++)n[a]=e[a];for(let a=0;a<t.length;a++)n[e.length+a]=t[a];return n},a5=(e,t)=>({classGroupId:e,validator:t}),y1=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Dd="-",n_=[],s5="arbitrary..",i5=e=>{const t=l5(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:c=>{if(c.startsWith("[")&&c.endsWith("]"))return o5(c);const f=c.split(Dd),h=f[0]===""&&f.length>1?1:0;return b1(f,h,t)},getConflictingClassGroupIds:(c,f)=>{if(f){const h=a[c],m=n[c];return h?m?r5(m,h):h:m||n_}return n[c]||n_}}},b1=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const i=e[t],l=n.nextPart.get(i);if(l){const m=b1(e,t+1,l);if(m)return m}const c=n.validators;if(c===null)return;const f=t===0?e.join(Dd):e.slice(t).join(Dd),h=c.length;for(let m=0;m<h;m++){const b=c[m];if(b.validator(f))return b.classGroupId}},o5=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),a=t.slice(0,n);return a?s5+a:void 0})(),l5=e=>{const{theme:t,classGroups:n}=e;return c5(n,t)},c5=(e,t)=>{const n=y1();for(const a in e){const i=e[a];nv(i,n,a,t)}return n},nv=(e,t,n,a)=>{const i=e.length;for(let l=0;l<i;l++){const c=e[l];u5(c,t,n,a)}},u5=(e,t,n,a)=>{if(typeof e=="string"){d5(e,t,n);return}if(typeof e=="function"){f5(e,t,n,a);return}h5(e,t,n,a)},d5=(e,t,n)=>{const a=e===""?t:x1(t,e);a.classGroupId=n},f5=(e,t,n,a)=>{if(m5(e)){nv(e(a),t,n,a);return}t.validators===null&&(t.validators=[]),t.validators.push(a5(n,e))},h5=(e,t,n,a)=>{const i=Object.entries(e),l=i.length;for(let c=0;c<l;c++){const[f,h]=i[c];nv(h,x1(t,f),n,a)}},x1=(e,t)=>{let n=e;const a=t.split(Dd),i=a.length;for(let l=0;l<i;l++){const c=a[l];let f=n.nextPart.get(c);f||(f=y1(),n.nextPart.set(c,f)),n=f}return n},m5=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,p5=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),a=Object.create(null);const i=(l,c)=>{n[l]=c,t++,t>e&&(t=0,a=n,n=Object.create(null))};return{get(l){let c=n[l];if(c!==void 0)return c;if((c=a[l])!==void 0)return i(l,c),c},set(l,c){l in n?n[l]=c:i(l,c)}}},dg="!",r_=":",g5=[],a_=(e,t,n,a,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:a,isExternal:i}),v5=e=>{const{prefix:t,experimentalParseClassName:n}=e;let a=i=>{const l=[];let c=0,f=0,h=0,m;const b=i.length;for(let S=0;S<b;S++){const C=i[S];if(c===0&&f===0){if(C===r_){l.push(i.slice(h,S)),h=S+1;continue}if(C==="/"){m=S;continue}}C==="["?c++:C==="]"?c--:C==="("?f++:C===")"&&f--}const g=l.length===0?i:i.slice(h);let x=g,w=!1;g.endsWith(dg)?(x=g.slice(0,-1),w=!0):g.startsWith(dg)&&(x=g.slice(1),w=!0);const E=m&&m>h?m-h:void 0;return a_(l,w,x,E)};if(t){const i=t+r_,l=a;a=c=>c.startsWith(i)?l(c.slice(i.length)):a_(g5,!1,c,void 0,!0)}if(n){const i=a;a=l=>n({className:l,parseClassName:i})}return a},y5=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,a)=>{t.set(n,1e6+a)}),n=>{const a=[];let i=[];for(let l=0;l<n.length;l++){const c=n[l],f=c[0]==="[",h=t.has(c);f||h?(i.length>0&&(i.sort(),a.push(...i),i=[]),a.push(c)):i.push(c)}return i.length>0&&(i.sort(),a.push(...i)),a}},b5=e=>({cache:p5(e.cacheSize),parseClassName:v5(e),sortModifiers:y5(e),postfixLookupClassGroupIds:x5(e),...i5(e)}),x5=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let a=0;a<n.length;a++)t[n[a]]=!0;return t},w5=/\s+/,_5=(e,t)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:i,sortModifiers:l,postfixLookupClassGroupIds:c}=t,f=[],h=e.trim().split(w5);let m="";for(let b=h.length-1;b>=0;b-=1){const g=h[b],{isExternal:x,modifiers:w,hasImportantModifier:E,baseClassName:S,maybePostfixModifierPosition:C}=n(g);if(x){m=g+(m.length>0?" "+m:m);continue}let N=!!C,A;if(N){const P=S.substring(0,C);A=a(P);const U=A&&c[A]?a(S):void 0;U&&U!==A&&(A=U,N=!1)}else A=a(S);if(!A){if(!N){m=g+(m.length>0?" "+m:m);continue}if(A=a(S),!A){m=g+(m.length>0?" "+m:m);continue}N=!1}const T=w.length===0?"":w.length===1?w[0]:l(w).join(":"),M=E?T+dg:T,$=M+A;if(f.indexOf($)>-1)continue;f.push($);const L=i(A,N);for(let P=0;P<L.length;++P){const U=L[P];f.push(M+U)}m=g+(m.length>0?" "+m:m)}return m},S5=(...e)=>{let t=0,n,a,i="";for(;t<e.length;)(n=e[t++])&&(a=w1(n))&&(i&&(i+=" "),i+=a);return i},w1=e=>{if(typeof e=="string")return e;let t,n="";for(let a=0;a<e.length;a++)e[a]&&(t=w1(e[a]))&&(n&&(n+=" "),n+=t);return n},E5=(e,...t)=>{let n,a,i,l;const c=h=>{const m=t.reduce((b,g)=>g(b),e());return n=b5(m),a=n.cache.get,i=n.cache.set,l=f,f(h)},f=h=>{const m=a(h);if(m)return m;const b=_5(h,n);return i(h,b),b};return l=c,(...h)=>l(S5(...h))},N5=[],Zt=e=>{const t=n=>n[e]||N5;return t.isThemeGetter=!0,t},_1=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,S1=/^\((?:(\w[\w-]*):)?(.+)\)$/i,C5=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,j5=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,T5=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,R5=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,A5=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,k5=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Wa=e=>C5.test(e),tt=e=>!!e&&!Number.isNaN(Number(e)),Or=e=>!!e&&Number.isInteger(Number(e)),gp=e=>e.endsWith("%")&&tt(e.slice(0,-1)),ua=e=>j5.test(e),E1=()=>!0,O5=e=>T5.test(e)&&!R5.test(e),rv=()=>!1,M5=e=>A5.test(e),D5=e=>k5.test(e),P5=e=>!Ce(e)&&!Te(e),L5=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),z5=e=>os(e,j1,rv),Ce=e=>_1.test(e),Ps=e=>os(e,T1,O5),s_=e=>os(e,F5,tt),I5=e=>os(e,A1,E1),$5=e=>os(e,R1,rv),i_=e=>os(e,N1,rv),U5=e=>os(e,C1,D5),Hu=e=>os(e,k1,M5),Te=e=>S1.test(e),El=e=>ei(e,T1),B5=e=>ei(e,R1),o_=e=>ei(e,N1),H5=e=>ei(e,j1),q5=e=>ei(e,C1),qu=e=>ei(e,k1,!0),V5=e=>ei(e,A1,!0),os=(e,t,n)=>{const a=_1.exec(e);return a?a[1]?t(a[1]):n(a[2]):!1},ei=(e,t,n=!1)=>{const a=S1.exec(e);return a?a[1]?t(a[1]):n:!1},N1=e=>e==="position"||e==="percentage",C1=e=>e==="image"||e==="url",j1=e=>e==="length"||e==="size"||e==="bg-size",T1=e=>e==="length",F5=e=>e==="number",R1=e=>e==="family-name",A1=e=>e==="number"||e==="weight",k1=e=>e==="shadow",G5=()=>{const e=Zt("color"),t=Zt("font"),n=Zt("text"),a=Zt("font-weight"),i=Zt("tracking"),l=Zt("leading"),c=Zt("breakpoint"),f=Zt("container"),h=Zt("spacing"),m=Zt("radius"),b=Zt("shadow"),g=Zt("inset-shadow"),x=Zt("text-shadow"),w=Zt("drop-shadow"),E=Zt("blur"),S=Zt("perspective"),C=Zt("aspect"),N=Zt("ease"),A=Zt("animate"),T=()=>["auto","avoid","all","avoid-page","page","left","right","column"],M=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],$=()=>[...M(),Te,Ce],L=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto","contain","none"],U=()=>[Te,Ce,h],J=()=>[Wa,"full","auto",...U()],ce=()=>[Or,"none","subgrid",Te,Ce],re=()=>["auto",{span:["full",Or,Te,Ce]},Or,Te,Ce],me=()=>[Or,"auto",Te,Ce],fe=()=>["auto","min","max","fr",Te,Ce],ge=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],de=()=>["start","end","center","stretch","center-safe","end-safe"],k=()=>["auto",...U()],K=()=>[Wa,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...U()],F=()=>[Wa,"screen","full","dvw","lvw","svw","min","max","fit",...U()],Y=()=>[Wa,"screen","full","lh","dvh","lvh","svh","min","max","fit",...U()],V=()=>[e,Te,Ce],R=()=>[...M(),o_,i_,{position:[Te,Ce]}],O=()=>["no-repeat",{repeat:["","x","y","space","round"]}],I=()=>["auto","cover","contain",H5,z5,{size:[Te,Ce]}],H=()=>[gp,El,Ps],q=()=>["","none","full",m,Te,Ce],ee=()=>["",tt,El,Ps],te=()=>["solid","dashed","dotted","double"],Q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],se=()=>[tt,gp,o_,i_],je=()=>["","none",E,Te,Ce],ze=()=>["none",tt,Te,Ce],Ne=()=>["none",tt,Te,Ce],ne=()=>[tt,Te,Ce],Me=()=>[Wa,"full",...U()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ua],breakpoint:[ua],color:[E1],container:[ua],"drop-shadow":[ua],ease:["in","out","in-out"],font:[P5],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ua],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ua],shadow:[ua],spacing:["px",tt],text:[ua],"text-shadow":[ua],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Wa,Ce,Te,C]}],container:["container"],"container-type":[{"@container":["","normal","size",Te,Ce]}],"container-named":[L5],columns:[{columns:[tt,Ce,Te,f]}],"break-after":[{"break-after":T()}],"break-before":[{"break-before":T()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:$()}],overflow:[{overflow:L()}],"overflow-x":[{"overflow-x":L()}],"overflow-y":[{"overflow-y":L()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:J()}],"inset-x":[{"inset-x":J()}],"inset-y":[{"inset-y":J()}],start:[{"inset-s":J(),start:J()}],end:[{"inset-e":J(),end:J()}],"inset-bs":[{"inset-bs":J()}],"inset-be":[{"inset-be":J()}],top:[{top:J()}],right:[{right:J()}],bottom:[{bottom:J()}],left:[{left:J()}],visibility:["visible","invisible","collapse"],z:[{z:[Or,"auto",Te,Ce]}],basis:[{basis:[Wa,"full","auto",f,...U()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[tt,Wa,"auto","initial","none",Ce]}],grow:[{grow:["",tt,Te,Ce]}],shrink:[{shrink:["",tt,Te,Ce]}],order:[{order:[Or,"first","last","none",Te,Ce]}],"grid-cols":[{"grid-cols":ce()}],"col-start-end":[{col:re()}],"col-start":[{"col-start":me()}],"col-end":[{"col-end":me()}],"grid-rows":[{"grid-rows":ce()}],"row-start-end":[{row:re()}],"row-start":[{"row-start":me()}],"row-end":[{"row-end":me()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":fe()}],"auto-rows":[{"auto-rows":fe()}],gap:[{gap:U()}],"gap-x":[{"gap-x":U()}],"gap-y":[{"gap-y":U()}],"justify-content":[{justify:[...ge(),"normal"]}],"justify-items":[{"justify-items":[...de(),"normal"]}],"justify-self":[{"justify-self":["auto",...de()]}],"align-content":[{content:["normal",...ge()]}],"align-items":[{items:[...de(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...de(),{baseline:["","last"]}]}],"place-content":[{"place-content":ge()}],"place-items":[{"place-items":[...de(),"baseline"]}],"place-self":[{"place-self":["auto",...de()]}],p:[{p:U()}],px:[{px:U()}],py:[{py:U()}],ps:[{ps:U()}],pe:[{pe:U()}],pbs:[{pbs:U()}],pbe:[{pbe:U()}],pt:[{pt:U()}],pr:[{pr:U()}],pb:[{pb:U()}],pl:[{pl:U()}],m:[{m:k()}],mx:[{mx:k()}],my:[{my:k()}],ms:[{ms:k()}],me:[{me:k()}],mbs:[{mbs:k()}],mbe:[{mbe:k()}],mt:[{mt:k()}],mr:[{mr:k()}],mb:[{mb:k()}],ml:[{ml:k()}],"space-x":[{"space-x":U()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":U()}],"space-y-reverse":["space-y-reverse"],size:[{size:K()}],"inline-size":[{inline:["auto",...F()]}],"min-inline-size":[{"min-inline":["auto",...F()]}],"max-inline-size":[{"max-inline":["none",...F()]}],"block-size":[{block:["auto",...Y()]}],"min-block-size":[{"min-block":["auto",...Y()]}],"max-block-size":[{"max-block":["none",...Y()]}],w:[{w:[f,"screen",...K()]}],"min-w":[{"min-w":[f,"screen","none",...K()]}],"max-w":[{"max-w":[f,"screen","none","prose",{screen:[c]},...K()]}],h:[{h:["screen","lh",...K()]}],"min-h":[{"min-h":["screen","lh","none",...K()]}],"max-h":[{"max-h":["screen","lh",...K()]}],"font-size":[{text:["base",n,El,Ps]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,V5,I5]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",gp,Ce]}],"font-family":[{font:[B5,$5,t]}],"font-features":[{"font-features":[Ce]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,Te,Ce]}],"line-clamp":[{"line-clamp":[tt,"none",Te,s_]}],leading:[{leading:[l,...U()]}],"list-image":[{"list-image":["none",Te,Ce]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Te,Ce]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:V()}],"text-color":[{text:V()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...te(),"wavy"]}],"text-decoration-thickness":[{decoration:[tt,"from-font","auto",Te,Ps]}],"text-decoration-color":[{decoration:V()}],"underline-offset":[{"underline-offset":[tt,"auto",Te,Ce]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:U()}],"tab-size":[{tab:[Or,Te,Ce]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Te,Ce]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Te,Ce]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:R()}],"bg-repeat":[{bg:O()}],"bg-size":[{bg:I()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Or,Te,Ce],radial:["",Te,Ce],conic:[Or,Te,Ce]},q5,U5]}],"bg-color":[{bg:V()}],"gradient-from-pos":[{from:H()}],"gradient-via-pos":[{via:H()}],"gradient-to-pos":[{to:H()}],"gradient-from":[{from:V()}],"gradient-via":[{via:V()}],"gradient-to":[{to:V()}],rounded:[{rounded:q()}],"rounded-s":[{"rounded-s":q()}],"rounded-e":[{"rounded-e":q()}],"rounded-t":[{"rounded-t":q()}],"rounded-r":[{"rounded-r":q()}],"rounded-b":[{"rounded-b":q()}],"rounded-l":[{"rounded-l":q()}],"rounded-ss":[{"rounded-ss":q()}],"rounded-se":[{"rounded-se":q()}],"rounded-ee":[{"rounded-ee":q()}],"rounded-es":[{"rounded-es":q()}],"rounded-tl":[{"rounded-tl":q()}],"rounded-tr":[{"rounded-tr":q()}],"rounded-br":[{"rounded-br":q()}],"rounded-bl":[{"rounded-bl":q()}],"border-w":[{border:ee()}],"border-w-x":[{"border-x":ee()}],"border-w-y":[{"border-y":ee()}],"border-w-s":[{"border-s":ee()}],"border-w-e":[{"border-e":ee()}],"border-w-bs":[{"border-bs":ee()}],"border-w-be":[{"border-be":ee()}],"border-w-t":[{"border-t":ee()}],"border-w-r":[{"border-r":ee()}],"border-w-b":[{"border-b":ee()}],"border-w-l":[{"border-l":ee()}],"divide-x":[{"divide-x":ee()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ee()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...te(),"hidden","none"]}],"divide-style":[{divide:[...te(),"hidden","none"]}],"border-color":[{border:V()}],"border-color-x":[{"border-x":V()}],"border-color-y":[{"border-y":V()}],"border-color-s":[{"border-s":V()}],"border-color-e":[{"border-e":V()}],"border-color-bs":[{"border-bs":V()}],"border-color-be":[{"border-be":V()}],"border-color-t":[{"border-t":V()}],"border-color-r":[{"border-r":V()}],"border-color-b":[{"border-b":V()}],"border-color-l":[{"border-l":V()}],"divide-color":[{divide:V()}],"outline-style":[{outline:[...te(),"none","hidden"]}],"outline-offset":[{"outline-offset":[tt,Te,Ce]}],"outline-w":[{outline:["",tt,El,Ps]}],"outline-color":[{outline:V()}],shadow:[{shadow:["","none",b,qu,Hu]}],"shadow-color":[{shadow:V()}],"inset-shadow":[{"inset-shadow":["none",g,qu,Hu]}],"inset-shadow-color":[{"inset-shadow":V()}],"ring-w":[{ring:ee()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:V()}],"ring-offset-w":[{"ring-offset":[tt,Ps]}],"ring-offset-color":[{"ring-offset":V()}],"inset-ring-w":[{"inset-ring":ee()}],"inset-ring-color":[{"inset-ring":V()}],"text-shadow":[{"text-shadow":["none",x,qu,Hu]}],"text-shadow-color":[{"text-shadow":V()}],opacity:[{opacity:[tt,Te,Ce]}],"mix-blend":[{"mix-blend":[...Q(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Q()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[tt]}],"mask-image-linear-from-pos":[{"mask-linear-from":se()}],"mask-image-linear-to-pos":[{"mask-linear-to":se()}],"mask-image-linear-from-color":[{"mask-linear-from":V()}],"mask-image-linear-to-color":[{"mask-linear-to":V()}],"mask-image-t-from-pos":[{"mask-t-from":se()}],"mask-image-t-to-pos":[{"mask-t-to":se()}],"mask-image-t-from-color":[{"mask-t-from":V()}],"mask-image-t-to-color":[{"mask-t-to":V()}],"mask-image-r-from-pos":[{"mask-r-from":se()}],"mask-image-r-to-pos":[{"mask-r-to":se()}],"mask-image-r-from-color":[{"mask-r-from":V()}],"mask-image-r-to-color":[{"mask-r-to":V()}],"mask-image-b-from-pos":[{"mask-b-from":se()}],"mask-image-b-to-pos":[{"mask-b-to":se()}],"mask-image-b-from-color":[{"mask-b-from":V()}],"mask-image-b-to-color":[{"mask-b-to":V()}],"mask-image-l-from-pos":[{"mask-l-from":se()}],"mask-image-l-to-pos":[{"mask-l-to":se()}],"mask-image-l-from-color":[{"mask-l-from":V()}],"mask-image-l-to-color":[{"mask-l-to":V()}],"mask-image-x-from-pos":[{"mask-x-from":se()}],"mask-image-x-to-pos":[{"mask-x-to":se()}],"mask-image-x-from-color":[{"mask-x-from":V()}],"mask-image-x-to-color":[{"mask-x-to":V()}],"mask-image-y-from-pos":[{"mask-y-from":se()}],"mask-image-y-to-pos":[{"mask-y-to":se()}],"mask-image-y-from-color":[{"mask-y-from":V()}],"mask-image-y-to-color":[{"mask-y-to":V()}],"mask-image-radial":[{"mask-radial":[Te,Ce]}],"mask-image-radial-from-pos":[{"mask-radial-from":se()}],"mask-image-radial-to-pos":[{"mask-radial-to":se()}],"mask-image-radial-from-color":[{"mask-radial-from":V()}],"mask-image-radial-to-color":[{"mask-radial-to":V()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":M()}],"mask-image-conic-pos":[{"mask-conic":[tt]}],"mask-image-conic-from-pos":[{"mask-conic-from":se()}],"mask-image-conic-to-pos":[{"mask-conic-to":se()}],"mask-image-conic-from-color":[{"mask-conic-from":V()}],"mask-image-conic-to-color":[{"mask-conic-to":V()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:R()}],"mask-repeat":[{mask:O()}],"mask-size":[{mask:I()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Te,Ce]}],filter:[{filter:["","none",Te,Ce]}],blur:[{blur:je()}],brightness:[{brightness:[tt,Te,Ce]}],contrast:[{contrast:[tt,Te,Ce]}],"drop-shadow":[{"drop-shadow":["","none",w,qu,Hu]}],"drop-shadow-color":[{"drop-shadow":V()}],grayscale:[{grayscale:["",tt,Te,Ce]}],"hue-rotate":[{"hue-rotate":[tt,Te,Ce]}],invert:[{invert:["",tt,Te,Ce]}],saturate:[{saturate:[tt,Te,Ce]}],sepia:[{sepia:["",tt,Te,Ce]}],"backdrop-filter":[{"backdrop-filter":["","none",Te,Ce]}],"backdrop-blur":[{"backdrop-blur":je()}],"backdrop-brightness":[{"backdrop-brightness":[tt,Te,Ce]}],"backdrop-contrast":[{"backdrop-contrast":[tt,Te,Ce]}],"backdrop-grayscale":[{"backdrop-grayscale":["",tt,Te,Ce]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[tt,Te,Ce]}],"backdrop-invert":[{"backdrop-invert":["",tt,Te,Ce]}],"backdrop-opacity":[{"backdrop-opacity":[tt,Te,Ce]}],"backdrop-saturate":[{"backdrop-saturate":[tt,Te,Ce]}],"backdrop-sepia":[{"backdrop-sepia":["",tt,Te,Ce]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":U()}],"border-spacing-x":[{"border-spacing-x":U()}],"border-spacing-y":[{"border-spacing-y":U()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Te,Ce]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[tt,"initial",Te,Ce]}],ease:[{ease:["linear","initial",N,Te,Ce]}],delay:[{delay:[tt,Te,Ce]}],animate:[{animate:["none",A,Te,Ce]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[S,Te,Ce]}],"perspective-origin":[{"perspective-origin":$()}],rotate:[{rotate:ze()}],"rotate-x":[{"rotate-x":ze()}],"rotate-y":[{"rotate-y":ze()}],"rotate-z":[{"rotate-z":ze()}],scale:[{scale:Ne()}],"scale-x":[{"scale-x":Ne()}],"scale-y":[{"scale-y":Ne()}],"scale-z":[{"scale-z":Ne()}],"scale-3d":["scale-3d"],skew:[{skew:ne()}],"skew-x":[{"skew-x":ne()}],"skew-y":[{"skew-y":ne()}],transform:[{transform:[Te,Ce,"","none","gpu","cpu"]}],"transform-origin":[{origin:$()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Me()}],"translate-x":[{"translate-x":Me()}],"translate-y":[{"translate-y":Me()}],"translate-z":[{"translate-z":Me()}],"translate-none":["translate-none"],zoom:[{zoom:[Or,Te,Ce]}],accent:[{accent:V()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:V()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Te,Ce]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":V()}],"scrollbar-track-color":[{"scrollbar-track":V()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":U()}],"scroll-mx":[{"scroll-mx":U()}],"scroll-my":[{"scroll-my":U()}],"scroll-ms":[{"scroll-ms":U()}],"scroll-me":[{"scroll-me":U()}],"scroll-mbs":[{"scroll-mbs":U()}],"scroll-mbe":[{"scroll-mbe":U()}],"scroll-mt":[{"scroll-mt":U()}],"scroll-mr":[{"scroll-mr":U()}],"scroll-mb":[{"scroll-mb":U()}],"scroll-ml":[{"scroll-ml":U()}],"scroll-p":[{"scroll-p":U()}],"scroll-px":[{"scroll-px":U()}],"scroll-py":[{"scroll-py":U()}],"scroll-ps":[{"scroll-ps":U()}],"scroll-pe":[{"scroll-pe":U()}],"scroll-pbs":[{"scroll-pbs":U()}],"scroll-pbe":[{"scroll-pbe":U()}],"scroll-pt":[{"scroll-pt":U()}],"scroll-pr":[{"scroll-pr":U()}],"scroll-pb":[{"scroll-pb":U()}],"scroll-pl":[{"scroll-pl":U()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Te,Ce]}],fill:[{fill:["none",...V()]}],"stroke-w":[{stroke:[tt,El,Ps,s_]}],stroke:[{stroke:["none",...V()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},K5=E5(G5);function xe(...e){return K5(v1(e))}const W5=tv("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),Ee=v.forwardRef(({className:e,variant:t,size:n,asChild:a=!1,...i},l)=>{const c=a?JD:"button";return d.jsx(c,{className:xe(W5({variant:t,size:n,className:e})),ref:l,...i})});Ee.displayName="Button";function av({size:e="sm",className:t}){const n=e==="lg"?"h-auto w-[168px]":"h-auto w-[104px]",a=e==="lg"?"-translate-x-1":"";return d.jsx("div",{className:xe("inline-flex items-center",t),"aria-label":"GLM",children:d.jsx("img",{src:"/tablero-cdc/glm-logo.png",alt:"GLM",className:xe(n,a),loading:"eager",decoding:"async"})})}function Y5(){const{loginWithGoogle:e,error:t,loading:n}=df();return d.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center px-4",children:d.jsxs("div",{className:"w-full max-w-sm",children:[d.jsxs("div",{className:"flex flex-col items-center mb-8 gap-3",children:[d.jsx(av,{size:"lg"}),d.jsx("h1",{className:"text-2xl font-bold tracking-tight text-[#4F758B] text-center",children:"CDC Project Management"})]}),d.jsxs("div",{className:"bg-card border border-border rounded-2xl p-8 shadow-sm",children:[d.jsxs(Ee,{onClick:e,disabled:n,className:"w-full gap-2.5 h-10 rounded-full font-medium",children:[d.jsxs("svg",{"aria-hidden":"true",className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[d.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),d.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),d.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),d.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),"Entrar con Google"]}),t&&d.jsx("div",{className:"mt-4 rounded-lg bg-destructive/10 border border-destructive/20 px-4 py-3",children:d.jsx("p",{className:"text-sm text-destructive text-center leading-snug",children:t})})]}),d.jsx("p",{className:"text-center text-xs text-muted-foreground mt-6",children:"Acceso restringido a usuarios autorizados"})]})})}/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const O1=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim();/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const X5=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const J5=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase());/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const l_=e=>{const t=J5(e);return t.charAt(0).toUpperCase()+t.slice(1)};/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/var Q5={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"};/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Z5=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const e3=v.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:a,className:i="",children:l,iconNode:c,...f},h)=>v.createElement("svg",{ref:h,...Q5,width:t,height:t,stroke:e,strokeWidth:a?Number(n)*24/Number(t):n,className:O1("lucide",i),...!l&&!Z5(f)&&{"aria-hidden":"true"},...f},[...c.map(([m,b])=>v.createElement(m,b)),...Array.isArray(l)?l:[l]]));/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ue=(e,t)=>{const n=v.forwardRef(({className:a,...i},l)=>v.createElement(e3,{ref:l,iconNode:t,className:O1(`lucide-${X5(l_(e))}`,`lucide-${e}`,a),...i}));return n.displayName=l_(e),n};/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const t3=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]],c_=Ue("archive-restore",t3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const n3=[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]],M1=Ue("badge-dollar-sign",n3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const r3=[["path",{d:"M10 12h4",key:"a56b0p"}],["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M14 21v-3a2 2 0 0 0-4 0v3",key:"1rgiei"}],["path",{d:"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2",key:"secmi2"}],["path",{d:"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16",key:"16ra0t"}]],u_=Ue("building-2",r3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const a3=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]],s3=Ue("calculator",a3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const i3=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],o3=Ue("calendar-clock",i3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const l3=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]],fg=Ue("calendar-days",l3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const c3=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],u3=Ue("calendar",c3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const d3=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Hr=Ue("check",d3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const f3=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],sv=Ue("chevron-down",f3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const h3=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ff=Ue("chevron-left",h3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const m3=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],oc=Ue("chevron-right",m3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const p3=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],g3=Ue("chevron-up",p3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const v3=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],D1=Ue("chevrons-up-down",v3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const y3=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Pd=Ue("circle-alert",y3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const b3=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],iv=Ue("circle-check",b3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const x3=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]],d_=Ue("circle-dollar-sign",x3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const w3=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],_3=Ue("circle-x",w3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const S3=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],E3=Ue("circle",S3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const N3=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6h4",key:"135r8i"}]],Fs=Ue("clock-3",N3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const C3=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],hg=Ue("dollar-sign",C3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const j3=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],ov=Ue("external-link",j3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const T3=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],R3=Ue("eye-off",T3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const A3=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],k3=Ue("eye",A3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const O3=[["path",{d:"M10.5 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v6",key:"g5mvt7"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m14 20 2 2 4-4",key:"15kota"}]],M3=Ue("file-check-corner",O3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const D3=[["path",{d:"M11 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5",key:"1jo35a"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m15 17 5 5",key:"36xl1x"}],["path",{d:"m20 17-5 5",key:"vdz27y"}]],P3=Ue("file-x-corner",D3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const L3=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],z3=Ue("folder-open",L3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const I3=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],P1=Ue("history",I3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const $3=[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]],U3=Ue("inbox",$3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const B3=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],H3=Ue("info",B3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const q3=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],V3=Ue("layers",q3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const F3=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],G3=Ue("layout-grid",F3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const K3=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],W3=Ue("link-2",K3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Y3=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],X3=Ue("link",Y3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const J3=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]],Ld=Ue("list-checks",J3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Q3=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Kt=Ue("loader-circle",Q3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Z3=[["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"}]],eP=Ue("lock",Z3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const tP=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],nP=Ue("log-out",tP);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const rP=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],zd=Ue("map-pin",rP);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const aP=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]],sP=Ue("message-square-plus",aP);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const iP=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],oP=Ue("pen-line",iP);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const lP=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],lv=Ue("pencil",lP);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const cP=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Ir=Ue("plus",cP);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const uP=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],go=Ue("refresh-cw",uP);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const dP=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Ws=Ue("search",dP);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const fP=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],hP=Ue("settings-2",fP);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const mP=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],pP=Ue("sliders-horizontal",mP);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const gP=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],vP=Ue("sparkles",gP);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const yP=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],Id=Ue("tag",yP);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const bP=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],hf=Ue("trash-2",bP);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const xP=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],wP=Ue("user-round",xP);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const _P=[["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"}]],L1=Ue("user",_P);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const SP=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],vp=Ue("users",SP);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const EP=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],vo=Ue("x",EP),ot=v.forwardRef(({className:e,type:t,...n},a)=>d.jsx("input",{type:t,className:xe("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:a,...n}));ot.displayName="Input";function be(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}function NP(e,t){const n=v.createContext(t),a=l=>{const{children:c,...f}=l,h=v.useMemo(()=>f,Object.values(f));return d.jsx(n.Provider,{value:h,children:c})};a.displayName=e+"Provider";function i(l){const c=v.useContext(n);if(c)return c;if(t!==void 0)return t;throw new Error(`\`${l}\` must be used within \`${e}\``)}return[a,i]}function ur(e,t=[]){let n=[];function a(l,c){const f=v.createContext(c),h=n.length;n=[...n,c];const m=g=>{var N;const{scope:x,children:w,...E}=g,S=((N=x==null?void 0:x[e])==null?void 0:N[h])||f,C=v.useMemo(()=>E,Object.values(E));return d.jsx(S.Provider,{value:C,children:w})};m.displayName=l+"Provider";function b(g,x){var S;const w=((S=x==null?void 0:x[e])==null?void 0:S[h])||f,E=v.useContext(w);if(E)return E;if(c!==void 0)return c;throw new Error(`\`${g}\` must be used within \`${l}\``)}return[m,b]}const i=()=>{const l=n.map(c=>v.createContext(c));return function(f){const h=(f==null?void 0:f[e])||l;return v.useMemo(()=>({[`__scope${e}`]:{...f,[e]:h}}),[f,h])}};return i.scopeName=e,[a,CP(i,...t)]}function CP(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const a=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(l){const c=a.reduce((f,{useScope:h,scopeName:m})=>{const g=h(l)[`__scope${m}`];return{...f,...g}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return n.scopeName=t.scopeName,n}var Yt=globalThis!=null&&globalThis.document?v.useLayoutEffect:()=>{},jP=Vg[" useInsertionEffect ".trim().toString()]||Yt;function ga({prop:e,defaultProp:t,onChange:n=()=>{},caller:a}){const[i,l,c]=TP({defaultProp:t,onChange:n}),f=e!==void 0,h=f?e:i;{const b=v.useRef(e!==void 0);v.useEffect(()=>{const g=b.current;g!==f&&console.warn(`${a} is changing from ${g?"controlled":"uncontrolled"} to ${f?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),b.current=f},[f,a])}const m=v.useCallback(b=>{var g;if(f){const x=RP(b)?b(e):b;x!==e&&((g=c.current)==null||g.call(c,x))}else l(b)},[f,e,l,c]);return[h,m]}function TP({defaultProp:e,onChange:t}){const[n,a]=v.useState(e),i=v.useRef(n),l=v.useRef(t);return jP(()=>{l.current=t},[t]),v.useEffect(()=>{var c;i.current!==n&&((c=l.current)==null||c.call(l,n),i.current=n)},[n,i]),[n,a,l]}function RP(e){return typeof e=="function"}function AP(e){const t=kP(e),n=v.forwardRef((a,i)=>{const{children:l,...c}=a,f=v.Children.toArray(l),h=f.find(MP);if(h){const m=h.props.children,b=f.map(g=>g===h?v.Children.count(m)>1?v.Children.only(null):v.isValidElement(m)?m.props.children:null:g);return d.jsx(t,{...c,ref:i,children:v.isValidElement(m)?v.cloneElement(m,void 0,b):null})}return d.jsx(t,{...c,ref:i,children:l})});return n.displayName=`${e}.Slot`,n}function kP(e){const t=v.forwardRef((n,a)=>{const{children:i,...l}=n;if(v.isValidElement(i)){const c=PP(i),f=DP(l,i.props);return i.type!==v.Fragment&&(f.ref=a?wn(a,c):c),v.cloneElement(i,f)}return v.Children.count(i)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var OP=Symbol("radix.slottable");function MP(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===OP}function DP(e,t){const n={...t};for(const a in t){const i=e[a],l=t[a];/^on[A-Z]/.test(a)?i&&l?n[a]=(...f)=>{const h=l(...f);return i(...f),h}:i&&(n[a]=i):a==="style"?n[a]={...i,...l}:a==="className"&&(n[a]=[i,l].filter(Boolean).join(" "))}return{...e,...n}}function PP(e){var a,i;let t=(a=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var LP=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Pe=LP.reduce((e,t)=>{const n=AP(`Primitive.${t}`),a=v.forwardRef((i,l)=>{const{asChild:c,...f}=i,h=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(h,{...f,ref:l})});return a.displayName=`Primitive.${t}`,{...e,[t]:a}},{});function z1(e,t){e&&ac.flushSync(()=>e.dispatchEvent(t))}function f_(e){const t=zP(e),n=v.forwardRef((a,i)=>{const{children:l,...c}=a,f=v.Children.toArray(l),h=f.find($P);if(h){const m=h.props.children,b=f.map(g=>g===h?v.Children.count(m)>1?v.Children.only(null):v.isValidElement(m)?m.props.children:null:g);return d.jsx(t,{...c,ref:i,children:v.isValidElement(m)?v.cloneElement(m,void 0,b):null})}return d.jsx(t,{...c,ref:i,children:l})});return n.displayName=`${e}.Slot`,n}function zP(e){const t=v.forwardRef((n,a)=>{const{children:i,...l}=n;if(v.isValidElement(i)){const c=BP(i),f=UP(l,i.props);return i.type!==v.Fragment&&(f.ref=a?wn(a,c):c),v.cloneElement(i,f)}return v.Children.count(i)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var IP=Symbol("radix.slottable");function $P(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===IP}function UP(e,t){const n={...t};for(const a in t){const i=e[a],l=t[a];/^on[A-Z]/.test(a)?i&&l?n[a]=(...f)=>{const h=l(...f);return i(...f),h}:i&&(n[a]=i):a==="style"?n[a]={...i,...l}:a==="className"&&(n[a]=[i,l].filter(Boolean).join(" "))}return{...e,...n}}function BP(e){var a,i;let t=(a=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function cv(e){const t=e+"CollectionProvider",[n,a]=ur(t),[i,l]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=S=>{const{scope:C,children:N}=S,A=ve.useRef(null),T=ve.useRef(new Map).current;return d.jsx(i,{scope:C,itemMap:T,collectionRef:A,children:N})};c.displayName=t;const f=e+"CollectionSlot",h=f_(f),m=ve.forwardRef((S,C)=>{const{scope:N,children:A}=S,T=l(f,N),M=nt(C,T.collectionRef);return d.jsx(h,{ref:M,children:A})});m.displayName=f;const b=e+"CollectionItemSlot",g="data-radix-collection-item",x=f_(b),w=ve.forwardRef((S,C)=>{const{scope:N,children:A,...T}=S,M=ve.useRef(null),$=nt(C,M),L=l(b,N);return ve.useEffect(()=>(L.itemMap.set(M,{ref:M,...T}),()=>void L.itemMap.delete(M))),d.jsx(x,{[g]:"",ref:$,children:A})});w.displayName=b;function E(S){const C=l(e+"CollectionConsumer",S);return ve.useCallback(()=>{const A=C.collectionRef.current;if(!A)return[];const T=Array.from(A.querySelectorAll(`[${g}]`));return Array.from(C.itemMap.values()).sort((L,P)=>T.indexOf(L.ref.current)-T.indexOf(P.ref.current))},[C.collectionRef,C.itemMap])}return[{Provider:c,Slot:m,ItemSlot:w},E,a]}var HP=v.createContext(void 0);function lc(e){const t=v.useContext(HP);return e||t||"ltr"}function an(e){const t=v.useRef(e);return v.useEffect(()=>{t.current=e}),v.useMemo(()=>(...n)=>{var a;return(a=t.current)==null?void 0:a.call(t,...n)},[])}function qP(e,t=globalThis==null?void 0:globalThis.document){const n=an(e);v.useEffect(()=>{const a=i=>{i.key==="Escape"&&n(i)};return t.addEventListener("keydown",a,{capture:!0}),()=>t.removeEventListener("keydown",a,{capture:!0})},[n,t])}var VP="DismissableLayer",mg="dismissableLayer.update",FP="dismissableLayer.pointerDownOutside",GP="dismissableLayer.focusOutside",h_,I1=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),cc=v.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:l,onInteractOutside:c,onDismiss:f,...h}=e,m=v.useContext(I1),[b,g]=v.useState(null),x=(b==null?void 0:b.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,w]=v.useState({}),E=nt(t,P=>g(P)),S=Array.from(m.layers),[C]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),N=S.indexOf(C),A=b?S.indexOf(b):-1,T=m.layersWithOutsidePointerEventsDisabled.size>0,M=A>=N,$=YP(P=>{const U=P.target,J=[...m.branches].some(ce=>ce.contains(U));!M||J||(i==null||i(P),c==null||c(P),P.defaultPrevented||f==null||f())},x),L=XP(P=>{const U=P.target;[...m.branches].some(ce=>ce.contains(U))||(l==null||l(P),c==null||c(P),P.defaultPrevented||f==null||f())},x);return qP(P=>{A===m.layers.size-1&&(a==null||a(P),!P.defaultPrevented&&f&&(P.preventDefault(),f()))},x),v.useEffect(()=>{if(b)return n&&(m.layersWithOutsidePointerEventsDisabled.size===0&&(h_=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),m.layersWithOutsidePointerEventsDisabled.add(b)),m.layers.add(b),m_(),()=>{n&&m.layersWithOutsidePointerEventsDisabled.size===1&&(x.body.style.pointerEvents=h_)}},[b,x,n,m]),v.useEffect(()=>()=>{b&&(m.layers.delete(b),m.layersWithOutsidePointerEventsDisabled.delete(b),m_())},[b,m]),v.useEffect(()=>{const P=()=>w({});return document.addEventListener(mg,P),()=>document.removeEventListener(mg,P)},[]),d.jsx(Pe.div,{...h,ref:E,style:{pointerEvents:T?M?"auto":"none":void 0,...e.style},onFocusCapture:be(e.onFocusCapture,L.onFocusCapture),onBlurCapture:be(e.onBlurCapture,L.onBlurCapture),onPointerDownCapture:be(e.onPointerDownCapture,$.onPointerDownCapture)})});cc.displayName=VP;var KP="DismissableLayerBranch",WP=v.forwardRef((e,t)=>{const n=v.useContext(I1),a=v.useRef(null),i=nt(t,a);return v.useEffect(()=>{const l=a.current;if(l)return n.branches.add(l),()=>{n.branches.delete(l)}},[n.branches]),d.jsx(Pe.div,{...e,ref:i})});WP.displayName=KP;function YP(e,t=globalThis==null?void 0:globalThis.document){const n=an(e),a=v.useRef(!1),i=v.useRef(()=>{});return v.useEffect(()=>{const l=f=>{if(f.target&&!a.current){let h=function(){$1(FP,n,m,{discrete:!0})};const m={originalEvent:f};f.pointerType==="touch"?(t.removeEventListener("click",i.current),i.current=h,t.addEventListener("click",i.current,{once:!0})):h()}else t.removeEventListener("click",i.current);a.current=!1},c=window.setTimeout(()=>{t.addEventListener("pointerdown",l)},0);return()=>{window.clearTimeout(c),t.removeEventListener("pointerdown",l),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>a.current=!0}}function XP(e,t=globalThis==null?void 0:globalThis.document){const n=an(e),a=v.useRef(!1);return v.useEffect(()=>{const i=l=>{l.target&&!a.current&&$1(GP,n,{originalEvent:l},{discrete:!1})};return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:()=>a.current=!0,onBlurCapture:()=>a.current=!1}}function m_(){const e=new CustomEvent(mg);document.dispatchEvent(e)}function $1(e,t,n,{discrete:a}){const i=n.originalEvent.target,l=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),a?z1(i,l):i.dispatchEvent(l)}var yp=0;function mf(){v.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??p_()),document.body.insertAdjacentElement("beforeend",e[1]??p_()),yp++,()=>{yp===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),yp--}},[])}function p_(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var bp="focusScope.autoFocusOnMount",xp="focusScope.autoFocusOnUnmount",g_={bubbles:!1,cancelable:!0},JP="FocusScope",uc=v.forwardRef((e,t)=>{const{loop:n=!1,trapped:a=!1,onMountAutoFocus:i,onUnmountAutoFocus:l,...c}=e,[f,h]=v.useState(null),m=an(i),b=an(l),g=v.useRef(null),x=nt(t,S=>h(S)),w=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(a){let S=function(T){if(w.paused||!f)return;const M=T.target;f.contains(M)?g.current=M:Xa(g.current,{select:!0})},C=function(T){if(w.paused||!f)return;const M=T.relatedTarget;M!==null&&(f.contains(M)||Xa(g.current,{select:!0}))},N=function(T){if(document.activeElement===document.body)for(const $ of T)$.removedNodes.length>0&&Xa(f)};document.addEventListener("focusin",S),document.addEventListener("focusout",C);const A=new MutationObserver(N);return f&&A.observe(f,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",S),document.removeEventListener("focusout",C),A.disconnect()}}},[a,f,w.paused]),v.useEffect(()=>{if(f){y_.add(w);const S=document.activeElement;if(!f.contains(S)){const N=new CustomEvent(bp,g_);f.addEventListener(bp,m),f.dispatchEvent(N),N.defaultPrevented||(QP(r4(U1(f)),{select:!0}),document.activeElement===S&&Xa(f))}return()=>{f.removeEventListener(bp,m),setTimeout(()=>{const N=new CustomEvent(xp,g_);f.addEventListener(xp,b),f.dispatchEvent(N),N.defaultPrevented||Xa(S??document.body,{select:!0}),f.removeEventListener(xp,b),y_.remove(w)},0)}}},[f,m,b,w]);const E=v.useCallback(S=>{if(!n&&!a||w.paused)return;const C=S.key==="Tab"&&!S.altKey&&!S.ctrlKey&&!S.metaKey,N=document.activeElement;if(C&&N){const A=S.currentTarget,[T,M]=ZP(A);T&&M?!S.shiftKey&&N===M?(S.preventDefault(),n&&Xa(T,{select:!0})):S.shiftKey&&N===T&&(S.preventDefault(),n&&Xa(M,{select:!0})):N===A&&S.preventDefault()}},[n,a,w.paused]);return d.jsx(Pe.div,{tabIndex:-1,...c,ref:x,onKeyDown:E})});uc.displayName=JP;function QP(e,{select:t=!1}={}){const n=document.activeElement;for(const a of e)if(Xa(a,{select:t}),document.activeElement!==n)return}function ZP(e){const t=U1(e),n=v_(t,e),a=v_(t.reverse(),e);return[n,a]}function U1(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:a=>{const i=a.tagName==="INPUT"&&a.type==="hidden";return a.disabled||a.hidden||i?NodeFilter.FILTER_SKIP:a.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function v_(e,t){for(const n of e)if(!e4(n,{upTo:t}))return n}function e4(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function t4(e){return e instanceof HTMLInputElement&&"select"in e}function Xa(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&t4(e)&&t&&e.select()}}var y_=n4();function n4(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=b_(e,t),e.unshift(t)},remove(t){var n;e=b_(e,t),(n=e[0])==null||n.resume()}}}function b_(e,t){const n=[...e],a=n.indexOf(t);return a!==-1&&n.splice(a,1),n}function r4(e){return e.filter(t=>t.tagName!=="A")}var a4=Vg[" useId ".trim().toString()]||(()=>{}),s4=0;function pn(e){const[t,n]=v.useState(a4());return Yt(()=>{n(a=>a??String(s4++))},[e]),t?`radix-${t}`:""}const i4=["top","right","bottom","left"],as=Math.min,Gn=Math.max,$d=Math.round,Vu=Math.floor,$r=e=>({x:e,y:e}),o4={left:"right",right:"left",bottom:"top",top:"bottom"};function pg(e,t,n){return Gn(e,as(t,n))}function va(e,t){return typeof e=="function"?e(t):e}function ya(e){return e.split("-")[0]}function jo(e){return e.split("-")[1]}function uv(e){return e==="x"?"y":"x"}function dv(e){return e==="y"?"height":"width"}function zr(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function fv(e){return uv(zr(e))}function l4(e,t,n){n===void 0&&(n=!1);const a=jo(e),i=fv(e),l=dv(i);let c=i==="x"?a===(n?"end":"start")?"right":"left":a==="start"?"bottom":"top";return t.reference[l]>t.floating[l]&&(c=Ud(c)),[c,Ud(c)]}function c4(e){const t=Ud(e);return[gg(e),t,gg(t)]}function gg(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const x_=["left","right"],w_=["right","left"],u4=["top","bottom"],d4=["bottom","top"];function f4(e,t,n){switch(e){case"top":case"bottom":return n?t?w_:x_:t?x_:w_;case"left":case"right":return t?u4:d4;default:return[]}}function h4(e,t,n,a){const i=jo(e);let l=f4(ya(e),n==="start",a);return i&&(l=l.map(c=>c+"-"+i),t&&(l=l.concat(l.map(gg)))),l}function Ud(e){const t=ya(e);return o4[t]+e.slice(t.length)}function m4(e){return{top:0,right:0,bottom:0,left:0,...e}}function B1(e){return typeof e!="number"?m4(e):{top:e,right:e,bottom:e,left:e}}function Bd(e){const{x:t,y:n,width:a,height:i}=e;return{width:a,height:i,top:n,left:t,right:t+a,bottom:n+i,x:t,y:n}}function __(e,t,n){let{reference:a,floating:i}=e;const l=zr(t),c=fv(t),f=dv(c),h=ya(t),m=l==="y",b=a.x+a.width/2-i.width/2,g=a.y+a.height/2-i.height/2,x=a[f]/2-i[f]/2;let w;switch(h){case"top":w={x:b,y:a.y-i.height};break;case"bottom":w={x:b,y:a.y+a.height};break;case"right":w={x:a.x+a.width,y:g};break;case"left":w={x:a.x-i.width,y:g};break;default:w={x:a.x,y:a.y}}switch(jo(t)){case"start":w[c]-=x*(n&&m?-1:1);break;case"end":w[c]+=x*(n&&m?-1:1);break}return w}async function p4(e,t){var n;t===void 0&&(t={});const{x:a,y:i,platform:l,rects:c,elements:f,strategy:h}=e,{boundary:m="clippingAncestors",rootBoundary:b="viewport",elementContext:g="floating",altBoundary:x=!1,padding:w=0}=va(t,e),E=B1(w),C=f[x?g==="floating"?"reference":"floating":g],N=Bd(await l.getClippingRect({element:(n=await(l.isElement==null?void 0:l.isElement(C)))==null||n?C:C.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(f.floating)),boundary:m,rootBoundary:b,strategy:h})),A=g==="floating"?{x:a,y:i,width:c.floating.width,height:c.floating.height}:c.reference,T=await(l.getOffsetParent==null?void 0:l.getOffsetParent(f.floating)),M=await(l.isElement==null?void 0:l.isElement(T))?await(l.getScale==null?void 0:l.getScale(T))||{x:1,y:1}:{x:1,y:1},$=Bd(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:f,rect:A,offsetParent:T,strategy:h}):A);return{top:(N.top-$.top+E.top)/M.y,bottom:($.bottom-N.bottom+E.bottom)/M.y,left:(N.left-$.left+E.left)/M.x,right:($.right-N.right+E.right)/M.x}}const g4=50,v4=async(e,t,n)=>{const{placement:a="bottom",strategy:i="absolute",middleware:l=[],platform:c}=n,f=c.detectOverflow?c:{...c,detectOverflow:p4},h=await(c.isRTL==null?void 0:c.isRTL(t));let m=await c.getElementRects({reference:e,floating:t,strategy:i}),{x:b,y:g}=__(m,a,h),x=a,w=0;const E={};for(let S=0;S<l.length;S++){const C=l[S];if(!C)continue;const{name:N,fn:A}=C,{x:T,y:M,data:$,reset:L}=await A({x:b,y:g,initialPlacement:a,placement:x,strategy:i,middlewareData:E,rects:m,platform:f,elements:{reference:e,floating:t}});b=T??b,g=M??g,E[N]={...E[N],...$},L&&w<g4&&(w++,typeof L=="object"&&(L.placement&&(x=L.placement),L.rects&&(m=L.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:i}):L.rects),{x:b,y:g}=__(m,x,h)),S=-1)}return{x:b,y:g,placement:x,strategy:i,middlewareData:E}},y4=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:a,placement:i,rects:l,platform:c,elements:f,middlewareData:h}=t,{element:m,padding:b=0}=va(e,t)||{};if(m==null)return{};const g=B1(b),x={x:n,y:a},w=fv(i),E=dv(w),S=await c.getDimensions(m),C=w==="y",N=C?"top":"left",A=C?"bottom":"right",T=C?"clientHeight":"clientWidth",M=l.reference[E]+l.reference[w]-x[w]-l.floating[E],$=x[w]-l.reference[w],L=await(c.getOffsetParent==null?void 0:c.getOffsetParent(m));let P=L?L[T]:0;(!P||!await(c.isElement==null?void 0:c.isElement(L)))&&(P=f.floating[T]||l.floating[E]);const U=M/2-$/2,J=P/2-S[E]/2-1,ce=as(g[N],J),re=as(g[A],J),me=ce,fe=P-S[E]-re,ge=P/2-S[E]/2+U,de=pg(me,ge,fe),k=!h.arrow&&jo(i)!=null&&ge!==de&&l.reference[E]/2-(ge<me?ce:re)-S[E]/2<0,K=k?ge<me?ge-me:ge-fe:0;return{[w]:x[w]+K,data:{[w]:de,centerOffset:ge-de-K,...k&&{alignmentOffset:K}},reset:k}}}),b4=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,a;const{placement:i,middlewareData:l,rects:c,initialPlacement:f,platform:h,elements:m}=t,{mainAxis:b=!0,crossAxis:g=!0,fallbackPlacements:x,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:E="none",flipAlignment:S=!0,...C}=va(e,t);if((n=l.arrow)!=null&&n.alignmentOffset)return{};const N=ya(i),A=zr(f),T=ya(f)===f,M=await(h.isRTL==null?void 0:h.isRTL(m.floating)),$=x||(T||!S?[Ud(f)]:c4(f)),L=E!=="none";!x&&L&&$.push(...h4(f,S,E,M));const P=[f,...$],U=await h.detectOverflow(t,C),J=[];let ce=((a=l.flip)==null?void 0:a.overflows)||[];if(b&&J.push(U[N]),g){const ge=l4(i,c,M);J.push(U[ge[0]],U[ge[1]])}if(ce=[...ce,{placement:i,overflows:J}],!J.every(ge=>ge<=0)){var re,me;const ge=(((re=l.flip)==null?void 0:re.index)||0)+1,de=P[ge];if(de&&(!(g==="alignment"?A!==zr(de):!1)||ce.every(F=>zr(F.placement)===A?F.overflows[0]>0:!0)))return{data:{index:ge,overflows:ce},reset:{placement:de}};let k=(me=ce.filter(K=>K.overflows[0]<=0).sort((K,F)=>K.overflows[1]-F.overflows[1])[0])==null?void 0:me.placement;if(!k)switch(w){case"bestFit":{var fe;const K=(fe=ce.filter(F=>{if(L){const Y=zr(F.placement);return Y===A||Y==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(Y=>Y>0).reduce((Y,V)=>Y+V,0)]).sort((F,Y)=>F[1]-Y[1])[0])==null?void 0:fe[0];K&&(k=K);break}case"initialPlacement":k=f;break}if(i!==k)return{reset:{placement:k}}}return{}}}};function S_(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function E_(e){return i4.some(t=>e[t]>=0)}const x4=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:a}=t,{strategy:i="referenceHidden",...l}=va(e,t);switch(i){case"referenceHidden":{const c=await a.detectOverflow(t,{...l,elementContext:"reference"}),f=S_(c,n.reference);return{data:{referenceHiddenOffsets:f,referenceHidden:E_(f)}}}case"escaped":{const c=await a.detectOverflow(t,{...l,altBoundary:!0}),f=S_(c,n.floating);return{data:{escapedOffsets:f,escaped:E_(f)}}}default:return{}}}}},H1=new Set(["left","top"]);async function w4(e,t){const{placement:n,platform:a,elements:i}=e,l=await(a.isRTL==null?void 0:a.isRTL(i.floating)),c=ya(n),f=jo(n),h=zr(n)==="y",m=H1.has(c)?-1:1,b=l&&h?-1:1,g=va(t,e);let{mainAxis:x,crossAxis:w,alignmentAxis:E}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return f&&typeof E=="number"&&(w=f==="end"?E*-1:E),h?{x:w*b,y:x*m}:{x:x*m,y:w*b}}const _4=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,a;const{x:i,y:l,placement:c,middlewareData:f}=t,h=await w4(t,e);return c===((n=f.offset)==null?void 0:n.placement)&&(a=f.arrow)!=null&&a.alignmentOffset?{}:{x:i+h.x,y:l+h.y,data:{...h,placement:c}}}}},S4=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:a,placement:i,platform:l}=t,{mainAxis:c=!0,crossAxis:f=!1,limiter:h={fn:N=>{let{x:A,y:T}=N;return{x:A,y:T}}},...m}=va(e,t),b={x:n,y:a},g=await l.detectOverflow(t,m),x=zr(ya(i)),w=uv(x);let E=b[w],S=b[x];if(c){const N=w==="y"?"top":"left",A=w==="y"?"bottom":"right",T=E+g[N],M=E-g[A];E=pg(T,E,M)}if(f){const N=x==="y"?"top":"left",A=x==="y"?"bottom":"right",T=S+g[N],M=S-g[A];S=pg(T,S,M)}const C=h.fn({...t,[w]:E,[x]:S});return{...C,data:{x:C.x-n,y:C.y-a,enabled:{[w]:c,[x]:f}}}}}},E4=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:a,placement:i,rects:l,middlewareData:c}=t,{offset:f=0,mainAxis:h=!0,crossAxis:m=!0}=va(e,t),b={x:n,y:a},g=zr(i),x=uv(g);let w=b[x],E=b[g];const S=va(f,t),C=typeof S=="number"?{mainAxis:S,crossAxis:0}:{mainAxis:0,crossAxis:0,...S};if(h){const T=x==="y"?"height":"width",M=l.reference[x]-l.floating[T]+C.mainAxis,$=l.reference[x]+l.reference[T]-C.mainAxis;w<M?w=M:w>$&&(w=$)}if(m){var N,A;const T=x==="y"?"width":"height",M=H1.has(ya(i)),$=l.reference[g]-l.floating[T]+(M&&((N=c.offset)==null?void 0:N[g])||0)+(M?0:C.crossAxis),L=l.reference[g]+l.reference[T]+(M?0:((A=c.offset)==null?void 0:A[g])||0)-(M?C.crossAxis:0);E<$?E=$:E>L&&(E=L)}return{[x]:w,[g]:E}}}},N4=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,a;const{placement:i,rects:l,platform:c,elements:f}=t,{apply:h=()=>{},...m}=va(e,t),b=await c.detectOverflow(t,m),g=ya(i),x=jo(i),w=zr(i)==="y",{width:E,height:S}=l.floating;let C,N;g==="top"||g==="bottom"?(C=g,N=x===(await(c.isRTL==null?void 0:c.isRTL(f.floating))?"start":"end")?"left":"right"):(N=g,C=x==="end"?"top":"bottom");const A=S-b.top-b.bottom,T=E-b.left-b.right,M=as(S-b[C],A),$=as(E-b[N],T),L=!t.middlewareData.shift;let P=M,U=$;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(U=T),(a=t.middlewareData.shift)!=null&&a.enabled.y&&(P=A),L&&!x){const ce=Gn(b.left,0),re=Gn(b.right,0),me=Gn(b.top,0),fe=Gn(b.bottom,0);w?U=E-2*(ce!==0||re!==0?ce+re:Gn(b.left,b.right)):P=S-2*(me!==0||fe!==0?me+fe:Gn(b.top,b.bottom))}await h({...t,availableWidth:U,availableHeight:P});const J=await c.getDimensions(f.floating);return E!==J.width||S!==J.height?{reset:{rects:!0}}:{}}}};function pf(){return typeof window<"u"}function To(e){return q1(e)?(e.nodeName||"").toLowerCase():"#document"}function Wn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function qr(e){var t;return(t=(q1(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function q1(e){return pf()?e instanceof Node||e instanceof Wn(e).Node:!1}function Er(e){return pf()?e instanceof Element||e instanceof Wn(e).Element:!1}function Sa(e){return pf()?e instanceof HTMLElement||e instanceof Wn(e).HTMLElement:!1}function N_(e){return!pf()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Wn(e).ShadowRoot}function dc(e){const{overflow:t,overflowX:n,overflowY:a,display:i}=Nr(e);return/auto|scroll|overlay|hidden|clip/.test(t+a+n)&&i!=="inline"&&i!=="contents"}function C4(e){return/^(table|td|th)$/.test(To(e))}function gf(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const j4=/transform|translate|scale|rotate|perspective|filter/,T4=/paint|layout|strict|content/,Ls=e=>!!e&&e!=="none";let wp;function hv(e){const t=Er(e)?Nr(e):e;return Ls(t.transform)||Ls(t.translate)||Ls(t.scale)||Ls(t.rotate)||Ls(t.perspective)||!mv()&&(Ls(t.backdropFilter)||Ls(t.filter))||j4.test(t.willChange||"")||T4.test(t.contain||"")}function R4(e){let t=ss(e);for(;Sa(t)&&!yo(t);){if(hv(t))return t;if(gf(t))return null;t=ss(t)}return null}function mv(){return wp==null&&(wp=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),wp}function yo(e){return/^(html|body|#document)$/.test(To(e))}function Nr(e){return Wn(e).getComputedStyle(e)}function vf(e){return Er(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ss(e){if(To(e)==="html")return e;const t=e.assignedSlot||e.parentNode||N_(e)&&e.host||qr(e);return N_(t)?t.host:t}function V1(e){const t=ss(e);return yo(t)?e.ownerDocument?e.ownerDocument.body:e.body:Sa(t)&&dc(t)?t:V1(t)}function Wl(e,t,n){var a;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=V1(e),l=i===((a=e.ownerDocument)==null?void 0:a.body),c=Wn(i);if(l){const f=vg(c);return t.concat(c,c.visualViewport||[],dc(i)?i:[],f&&n?Wl(f):[])}else return t.concat(i,Wl(i,[],n))}function vg(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function F1(e){const t=Nr(e);let n=parseFloat(t.width)||0,a=parseFloat(t.height)||0;const i=Sa(e),l=i?e.offsetWidth:n,c=i?e.offsetHeight:a,f=$d(n)!==l||$d(a)!==c;return f&&(n=l,a=c),{width:n,height:a,$:f}}function pv(e){return Er(e)?e:e.contextElement}function uo(e){const t=pv(e);if(!Sa(t))return $r(1);const n=t.getBoundingClientRect(),{width:a,height:i,$:l}=F1(t);let c=(l?$d(n.width):n.width)/a,f=(l?$d(n.height):n.height)/i;return(!c||!Number.isFinite(c))&&(c=1),(!f||!Number.isFinite(f))&&(f=1),{x:c,y:f}}const A4=$r(0);function G1(e){const t=Wn(e);return!mv()||!t.visualViewport?A4:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function k4(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Wn(e)?!1:t}function Ys(e,t,n,a){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),l=pv(e);let c=$r(1);t&&(a?Er(a)&&(c=uo(a)):c=uo(e));const f=k4(l,n,a)?G1(l):$r(0);let h=(i.left+f.x)/c.x,m=(i.top+f.y)/c.y,b=i.width/c.x,g=i.height/c.y;if(l){const x=Wn(l),w=a&&Er(a)?Wn(a):a;let E=x,S=vg(E);for(;S&&a&&w!==E;){const C=uo(S),N=S.getBoundingClientRect(),A=Nr(S),T=N.left+(S.clientLeft+parseFloat(A.paddingLeft))*C.x,M=N.top+(S.clientTop+parseFloat(A.paddingTop))*C.y;h*=C.x,m*=C.y,b*=C.x,g*=C.y,h+=T,m+=M,E=Wn(S),S=vg(E)}}return Bd({width:b,height:g,x:h,y:m})}function yf(e,t){const n=vf(e).scrollLeft;return t?t.left+n:Ys(qr(e)).left+n}function K1(e,t){const n=e.getBoundingClientRect(),a=n.left+t.scrollLeft-yf(e,n),i=n.top+t.scrollTop;return{x:a,y:i}}function O4(e){let{elements:t,rect:n,offsetParent:a,strategy:i}=e;const l=i==="fixed",c=qr(a),f=t?gf(t.floating):!1;if(a===c||f&&l)return n;let h={scrollLeft:0,scrollTop:0},m=$r(1);const b=$r(0),g=Sa(a);if((g||!g&&!l)&&((To(a)!=="body"||dc(c))&&(h=vf(a)),g)){const w=Ys(a);m=uo(a),b.x=w.x+a.clientLeft,b.y=w.y+a.clientTop}const x=c&&!g&&!l?K1(c,h):$r(0);return{width:n.width*m.x,height:n.height*m.y,x:n.x*m.x-h.scrollLeft*m.x+b.x+x.x,y:n.y*m.y-h.scrollTop*m.y+b.y+x.y}}function M4(e){return Array.from(e.getClientRects())}function D4(e){const t=qr(e),n=vf(e),a=e.ownerDocument.body,i=Gn(t.scrollWidth,t.clientWidth,a.scrollWidth,a.clientWidth),l=Gn(t.scrollHeight,t.clientHeight,a.scrollHeight,a.clientHeight);let c=-n.scrollLeft+yf(e);const f=-n.scrollTop;return Nr(a).direction==="rtl"&&(c+=Gn(t.clientWidth,a.clientWidth)-i),{width:i,height:l,x:c,y:f}}const C_=25;function P4(e,t){const n=Wn(e),a=qr(e),i=n.visualViewport;let l=a.clientWidth,c=a.clientHeight,f=0,h=0;if(i){l=i.width,c=i.height;const b=mv();(!b||b&&t==="fixed")&&(f=i.offsetLeft,h=i.offsetTop)}const m=yf(a);if(m<=0){const b=a.ownerDocument,g=b.body,x=getComputedStyle(g),w=b.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,E=Math.abs(a.clientWidth-g.clientWidth-w);E<=C_&&(l-=E)}else m<=C_&&(l+=m);return{width:l,height:c,x:f,y:h}}function L4(e,t){const n=Ys(e,!0,t==="fixed"),a=n.top+e.clientTop,i=n.left+e.clientLeft,l=Sa(e)?uo(e):$r(1),c=e.clientWidth*l.x,f=e.clientHeight*l.y,h=i*l.x,m=a*l.y;return{width:c,height:f,x:h,y:m}}function j_(e,t,n){let a;if(t==="viewport")a=P4(e,n);else if(t==="document")a=D4(qr(e));else if(Er(t))a=L4(t,n);else{const i=G1(e);a={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Bd(a)}function W1(e,t){const n=ss(e);return n===t||!Er(n)||yo(n)?!1:Nr(n).position==="fixed"||W1(n,t)}function z4(e,t){const n=t.get(e);if(n)return n;let a=Wl(e,[],!1).filter(f=>Er(f)&&To(f)!=="body"),i=null;const l=Nr(e).position==="fixed";let c=l?ss(e):e;for(;Er(c)&&!yo(c);){const f=Nr(c),h=hv(c);!h&&f.position==="fixed"&&(i=null),(l?!h&&!i:!h&&f.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||dc(c)&&!h&&W1(e,c))?a=a.filter(b=>b!==c):i=f,c=ss(c)}return t.set(e,a),a}function I4(e){let{element:t,boundary:n,rootBoundary:a,strategy:i}=e;const c=[...n==="clippingAncestors"?gf(t)?[]:z4(t,this._c):[].concat(n),a],f=j_(t,c[0],i);let h=f.top,m=f.right,b=f.bottom,g=f.left;for(let x=1;x<c.length;x++){const w=j_(t,c[x],i);h=Gn(w.top,h),m=as(w.right,m),b=as(w.bottom,b),g=Gn(w.left,g)}return{width:m-g,height:b-h,x:g,y:h}}function $4(e){const{width:t,height:n}=F1(e);return{width:t,height:n}}function U4(e,t,n){const a=Sa(t),i=qr(t),l=n==="fixed",c=Ys(e,!0,l,t);let f={scrollLeft:0,scrollTop:0};const h=$r(0);function m(){h.x=yf(i)}if(a||!a&&!l)if((To(t)!=="body"||dc(i))&&(f=vf(t)),a){const w=Ys(t,!0,l,t);h.x=w.x+t.clientLeft,h.y=w.y+t.clientTop}else i&&m();l&&!a&&i&&m();const b=i&&!a&&!l?K1(i,f):$r(0),g=c.left+f.scrollLeft-h.x-b.x,x=c.top+f.scrollTop-h.y-b.y;return{x:g,y:x,width:c.width,height:c.height}}function _p(e){return Nr(e).position==="static"}function T_(e,t){if(!Sa(e)||Nr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return qr(e)===n&&(n=n.ownerDocument.body),n}function Y1(e,t){const n=Wn(e);if(gf(e))return n;if(!Sa(e)){let i=ss(e);for(;i&&!yo(i);){if(Er(i)&&!_p(i))return i;i=ss(i)}return n}let a=T_(e,t);for(;a&&C4(a)&&_p(a);)a=T_(a,t);return a&&yo(a)&&_p(a)&&!hv(a)?n:a||R4(e)||n}const B4=async function(e){const t=this.getOffsetParent||Y1,n=this.getDimensions,a=await n(e.floating);return{reference:U4(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:a.width,height:a.height}}};function H4(e){return Nr(e).direction==="rtl"}const q4={convertOffsetParentRelativeRectToViewportRelativeRect:O4,getDocumentElement:qr,getClippingRect:I4,getOffsetParent:Y1,getElementRects:B4,getClientRects:M4,getDimensions:$4,getScale:uo,isElement:Er,isRTL:H4};function X1(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function V4(e,t){let n=null,a;const i=qr(e);function l(){var f;clearTimeout(a),(f=n)==null||f.disconnect(),n=null}function c(f,h){f===void 0&&(f=!1),h===void 0&&(h=1),l();const m=e.getBoundingClientRect(),{left:b,top:g,width:x,height:w}=m;if(f||t(),!x||!w)return;const E=Vu(g),S=Vu(i.clientWidth-(b+x)),C=Vu(i.clientHeight-(g+w)),N=Vu(b),T={rootMargin:-E+"px "+-S+"px "+-C+"px "+-N+"px",threshold:Gn(0,as(1,h))||1};let M=!0;function $(L){const P=L[0].intersectionRatio;if(P!==h){if(!M)return c();P?c(!1,P):a=setTimeout(()=>{c(!1,1e-7)},1e3)}P===1&&!X1(m,e.getBoundingClientRect())&&c(),M=!1}try{n=new IntersectionObserver($,{...T,root:i.ownerDocument})}catch{n=new IntersectionObserver($,T)}n.observe(e)}return c(!0),l}function F4(e,t,n,a){a===void 0&&(a={});const{ancestorScroll:i=!0,ancestorResize:l=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:f=typeof IntersectionObserver=="function",animationFrame:h=!1}=a,m=pv(e),b=i||l?[...m?Wl(m):[],...t?Wl(t):[]]:[];b.forEach(N=>{i&&N.addEventListener("scroll",n,{passive:!0}),l&&N.addEventListener("resize",n)});const g=m&&f?V4(m,n):null;let x=-1,w=null;c&&(w=new ResizeObserver(N=>{let[A]=N;A&&A.target===m&&w&&t&&(w.unobserve(t),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var T;(T=w)==null||T.observe(t)})),n()}),m&&!h&&w.observe(m),t&&w.observe(t));let E,S=h?Ys(e):null;h&&C();function C(){const N=Ys(e);S&&!X1(S,N)&&n(),S=N,E=requestAnimationFrame(C)}return n(),()=>{var N;b.forEach(A=>{i&&A.removeEventListener("scroll",n),l&&A.removeEventListener("resize",n)}),g==null||g(),(N=w)==null||N.disconnect(),w=null,h&&cancelAnimationFrame(E)}}const G4=_4,K4=S4,W4=b4,Y4=N4,X4=x4,R_=y4,J4=E4,Q4=(e,t,n)=>{const a=new Map,i={platform:q4,...n},l={...i.platform,_c:a};return v4(e,t,{...i,platform:l})};var Z4=typeof document<"u",eL=function(){},gd=Z4?v.useLayoutEffect:eL;function Hd(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,a,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(a=n;a--!==0;)if(!Hd(e[a],t[a]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(a=n;a--!==0;)if(!{}.hasOwnProperty.call(t,i[a]))return!1;for(a=n;a--!==0;){const l=i[a];if(!(l==="_owner"&&e.$$typeof)&&!Hd(e[l],t[l]))return!1}return!0}return e!==e&&t!==t}function J1(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function A_(e,t){const n=J1(e);return Math.round(t*n)/n}function Sp(e){const t=v.useRef(e);return gd(()=>{t.current=e}),t}function tL(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:a=[],platform:i,elements:{reference:l,floating:c}={},transform:f=!0,whileElementsMounted:h,open:m}=e,[b,g]=v.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[x,w]=v.useState(a);Hd(x,a)||w(a);const[E,S]=v.useState(null),[C,N]=v.useState(null),A=v.useCallback(F=>{F!==L.current&&(L.current=F,S(F))},[]),T=v.useCallback(F=>{F!==P.current&&(P.current=F,N(F))},[]),M=l||E,$=c||C,L=v.useRef(null),P=v.useRef(null),U=v.useRef(b),J=h!=null,ce=Sp(h),re=Sp(i),me=Sp(m),fe=v.useCallback(()=>{if(!L.current||!P.current)return;const F={placement:t,strategy:n,middleware:x};re.current&&(F.platform=re.current),Q4(L.current,P.current,F).then(Y=>{const V={...Y,isPositioned:me.current!==!1};ge.current&&!Hd(U.current,V)&&(U.current=V,ac.flushSync(()=>{g(V)}))})},[x,t,n,re,me]);gd(()=>{m===!1&&U.current.isPositioned&&(U.current.isPositioned=!1,g(F=>({...F,isPositioned:!1})))},[m]);const ge=v.useRef(!1);gd(()=>(ge.current=!0,()=>{ge.current=!1}),[]),gd(()=>{if(M&&(L.current=M),$&&(P.current=$),M&&$){if(ce.current)return ce.current(M,$,fe);fe()}},[M,$,fe,ce,J]);const de=v.useMemo(()=>({reference:L,floating:P,setReference:A,setFloating:T}),[A,T]),k=v.useMemo(()=>({reference:M,floating:$}),[M,$]),K=v.useMemo(()=>{const F={position:n,left:0,top:0};if(!k.floating)return F;const Y=A_(k.floating,b.x),V=A_(k.floating,b.y);return f?{...F,transform:"translate("+Y+"px, "+V+"px)",...J1(k.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Y,top:V}},[n,f,k.floating,b.x,b.y]);return v.useMemo(()=>({...b,update:fe,refs:de,elements:k,floatingStyles:K}),[b,fe,de,k,K])}const nL=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:a,padding:i}=typeof e=="function"?e(n):e;return a&&t(a)?a.current!=null?R_({element:a.current,padding:i}).fn(n):{}:a?R_({element:a,padding:i}).fn(n):{}}}},rL=(e,t)=>{const n=G4(e);return{name:n.name,fn:n.fn,options:[e,t]}},aL=(e,t)=>{const n=K4(e);return{name:n.name,fn:n.fn,options:[e,t]}},sL=(e,t)=>({fn:J4(e).fn,options:[e,t]}),iL=(e,t)=>{const n=W4(e);return{name:n.name,fn:n.fn,options:[e,t]}},oL=(e,t)=>{const n=Y4(e);return{name:n.name,fn:n.fn,options:[e,t]}},lL=(e,t)=>{const n=X4(e);return{name:n.name,fn:n.fn,options:[e,t]}},cL=(e,t)=>{const n=nL(e);return{name:n.name,fn:n.fn,options:[e,t]}};var uL="Arrow",Q1=v.forwardRef((e,t)=>{const{children:n,width:a=10,height:i=5,...l}=e;return d.jsx(Pe.svg,{...l,ref:t,width:a,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});Q1.displayName=uL;var dL=Q1;function gv(e){const[t,n]=v.useState(void 0);return Yt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const a=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const l=i[0];let c,f;if("borderBoxSize"in l){const h=l.borderBoxSize,m=Array.isArray(h)?h[0]:h;c=m.inlineSize,f=m.blockSize}else c=e.offsetWidth,f=e.offsetHeight;n({width:c,height:f})});return a.observe(e,{box:"border-box"}),()=>a.unobserve(e)}else n(void 0)},[e]),t}var vv="Popper",[Z1,Ro]=ur(vv),[fL,eE]=Z1(vv),tE=e=>{const{__scopePopper:t,children:n}=e,[a,i]=v.useState(null);return d.jsx(fL,{scope:t,anchor:a,onAnchorChange:i,children:n})};tE.displayName=vv;var nE="PopperAnchor",rE=v.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:a,...i}=e,l=eE(nE,n),c=v.useRef(null),f=nt(t,c),h=v.useRef(null);return v.useEffect(()=>{const m=h.current;h.current=(a==null?void 0:a.current)||c.current,m!==h.current&&l.onAnchorChange(h.current)}),a?null:d.jsx(Pe.div,{...i,ref:f})});rE.displayName=nE;var yv="PopperContent",[hL,mL]=Z1(yv),aE=v.forwardRef((e,t)=>{var te,Q,se,je,ze,Ne;const{__scopePopper:n,side:a="bottom",sideOffset:i=0,align:l="center",alignOffset:c=0,arrowPadding:f=0,avoidCollisions:h=!0,collisionBoundary:m=[],collisionPadding:b=0,sticky:g="partial",hideWhenDetached:x=!1,updatePositionStrategy:w="optimized",onPlaced:E,...S}=e,C=eE(yv,n),[N,A]=v.useState(null),T=nt(t,ne=>A(ne)),[M,$]=v.useState(null),L=gv(M),P=(L==null?void 0:L.width)??0,U=(L==null?void 0:L.height)??0,J=a+(l!=="center"?"-"+l:""),ce=typeof b=="number"?b:{top:0,right:0,bottom:0,left:0,...b},re=Array.isArray(m)?m:[m],me=re.length>0,fe={padding:ce,boundary:re.filter(gL),altBoundary:me},{refs:ge,floatingStyles:de,placement:k,isPositioned:K,middlewareData:F}=tL({strategy:"fixed",placement:J,whileElementsMounted:(...ne)=>F4(...ne,{animationFrame:w==="always"}),elements:{reference:C.anchor},middleware:[rL({mainAxis:i+U,alignmentAxis:c}),h&&aL({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?sL():void 0,...fe}),h&&iL({...fe}),oL({...fe,apply:({elements:ne,rects:Me,availableWidth:Je,availableHeight:ie})=>{const{width:De,height:Xe}=Me.reference,We=ne.floating.style;We.setProperty("--radix-popper-available-width",`${Je}px`),We.setProperty("--radix-popper-available-height",`${ie}px`),We.setProperty("--radix-popper-anchor-width",`${De}px`),We.setProperty("--radix-popper-anchor-height",`${Xe}px`)}}),M&&cL({element:M,padding:f}),vL({arrowWidth:P,arrowHeight:U}),x&&lL({strategy:"referenceHidden",...fe})]}),[Y,V]=oE(k),R=an(E);Yt(()=>{K&&(R==null||R())},[K,R]);const O=(te=F.arrow)==null?void 0:te.x,I=(Q=F.arrow)==null?void 0:Q.y,H=((se=F.arrow)==null?void 0:se.centerOffset)!==0,[q,ee]=v.useState();return Yt(()=>{N&&ee(window.getComputedStyle(N).zIndex)},[N]),d.jsx("div",{ref:ge.setFloating,"data-radix-popper-content-wrapper":"",style:{...de,transform:K?de.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:q,"--radix-popper-transform-origin":[(je=F.transformOrigin)==null?void 0:je.x,(ze=F.transformOrigin)==null?void 0:ze.y].join(" "),...((Ne=F.hide)==null?void 0:Ne.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:d.jsx(hL,{scope:n,placedSide:Y,onArrowChange:$,arrowX:O,arrowY:I,shouldHideArrow:H,children:d.jsx(Pe.div,{"data-side":Y,"data-align":V,...S,ref:T,style:{...S.style,animation:K?void 0:"none"}})})})});aE.displayName=yv;var sE="PopperArrow",pL={top:"bottom",right:"left",bottom:"top",left:"right"},iE=v.forwardRef(function(t,n){const{__scopePopper:a,...i}=t,l=mL(sE,a),c=pL[l.placedSide];return d.jsx("span",{ref:l.onArrowChange,style:{position:"absolute",left:l.arrowX,top:l.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[l.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[l.placedSide],visibility:l.shouldHideArrow?"hidden":void 0},children:d.jsx(dL,{...i,ref:n,style:{...i.style,display:"block"}})})});iE.displayName=sE;function gL(e){return e!==null}var vL=e=>({name:"transformOrigin",options:e,fn(t){var C,N,A;const{placement:n,rects:a,middlewareData:i}=t,c=((C=i.arrow)==null?void 0:C.centerOffset)!==0,f=c?0:e.arrowWidth,h=c?0:e.arrowHeight,[m,b]=oE(n),g={start:"0%",center:"50%",end:"100%"}[b],x=(((N=i.arrow)==null?void 0:N.x)??0)+f/2,w=(((A=i.arrow)==null?void 0:A.y)??0)+h/2;let E="",S="";return m==="bottom"?(E=c?g:`${x}px`,S=`${-h}px`):m==="top"?(E=c?g:`${x}px`,S=`${a.floating.height+h}px`):m==="right"?(E=`${-h}px`,S=c?g:`${w}px`):m==="left"&&(E=`${a.floating.width+h}px`,S=c?g:`${w}px`),{data:{x:E,y:S}}}});function oE(e){const[t,n="center"]=e.split("-");return[t,n]}var bv=tE,bf=rE,xv=aE,wv=iE,yL="Portal",fc=v.forwardRef((e,t)=>{var f;const{container:n,...a}=e,[i,l]=v.useState(!1);Yt(()=>l(!0),[]);const c=n||i&&((f=globalThis==null?void 0:globalThis.document)==null?void 0:f.body);return c?qS.createPortal(d.jsx(Pe.div,{...a,ref:t}),c):null});fc.displayName=yL;function bL(e,t){return v.useReducer((n,a)=>t[n][a]??n,e)}var bn=e=>{const{present:t,children:n}=e,a=xL(t),i=typeof n=="function"?n({present:a.isPresent}):v.Children.only(n),l=nt(a.ref,wL(i));return typeof n=="function"||a.isPresent?v.cloneElement(i,{ref:l}):null};bn.displayName="Presence";function xL(e){const[t,n]=v.useState(),a=v.useRef(null),i=v.useRef(e),l=v.useRef("none"),c=e?"mounted":"unmounted",[f,h]=bL(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const m=Fu(a.current);l.current=f==="mounted"?m:"none"},[f]),Yt(()=>{const m=a.current,b=i.current;if(b!==e){const x=l.current,w=Fu(m);e?h("MOUNT"):w==="none"||(m==null?void 0:m.display)==="none"?h("UNMOUNT"):h(b&&x!==w?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,h]),Yt(()=>{if(t){let m;const b=t.ownerDocument.defaultView??window,g=w=>{const S=Fu(a.current).includes(CSS.escape(w.animationName));if(w.target===t&&S&&(h("ANIMATION_END"),!i.current)){const C=t.style.animationFillMode;t.style.animationFillMode="forwards",m=b.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=C)})}},x=w=>{w.target===t&&(l.current=Fu(a.current))};return t.addEventListener("animationstart",x),t.addEventListener("animationcancel",g),t.addEventListener("animationend",g),()=>{b.clearTimeout(m),t.removeEventListener("animationstart",x),t.removeEventListener("animationcancel",g),t.removeEventListener("animationend",g)}}else h("ANIMATION_END")},[t,h]),{isPresent:["mounted","unmountSuspended"].includes(f),ref:v.useCallback(m=>{a.current=m?getComputedStyle(m):null,n(m)},[])}}function Fu(e){return(e==null?void 0:e.animationName)||"none"}function wL(e){var a,i;let t=(a=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Ep="rovingFocusGroup.onEntryFocus",_L={bubbles:!1,cancelable:!0},hc="RovingFocusGroup",[yg,lE,SL]=cv(hc),[EL,xf]=ur(hc,[SL]),[NL,CL]=EL(hc),cE=v.forwardRef((e,t)=>d.jsx(yg.Provider,{scope:e.__scopeRovingFocusGroup,children:d.jsx(yg.Slot,{scope:e.__scopeRovingFocusGroup,children:d.jsx(jL,{...e,ref:t})})}));cE.displayName=hc;var jL=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:a,loop:i=!1,dir:l,currentTabStopId:c,defaultCurrentTabStopId:f,onCurrentTabStopIdChange:h,onEntryFocus:m,preventScrollOnEntryFocus:b=!1,...g}=e,x=v.useRef(null),w=nt(t,x),E=lc(l),[S,C]=ga({prop:c,defaultProp:f??null,onChange:h,caller:hc}),[N,A]=v.useState(!1),T=an(m),M=lE(n),$=v.useRef(!1),[L,P]=v.useState(0);return v.useEffect(()=>{const U=x.current;if(U)return U.addEventListener(Ep,T),()=>U.removeEventListener(Ep,T)},[T]),d.jsx(NL,{scope:n,orientation:a,dir:E,loop:i,currentTabStopId:S,onItemFocus:v.useCallback(U=>C(U),[C]),onItemShiftTab:v.useCallback(()=>A(!0),[]),onFocusableItemAdd:v.useCallback(()=>P(U=>U+1),[]),onFocusableItemRemove:v.useCallback(()=>P(U=>U-1),[]),children:d.jsx(Pe.div,{tabIndex:N||L===0?-1:0,"data-orientation":a,...g,ref:w,style:{outline:"none",...e.style},onMouseDown:be(e.onMouseDown,()=>{$.current=!0}),onFocus:be(e.onFocus,U=>{const J=!$.current;if(U.target===U.currentTarget&&J&&!N){const ce=new CustomEvent(Ep,_L);if(U.currentTarget.dispatchEvent(ce),!ce.defaultPrevented){const re=M().filter(k=>k.focusable),me=re.find(k=>k.active),fe=re.find(k=>k.id===S),de=[me,fe,...re].filter(Boolean).map(k=>k.ref.current);fE(de,b)}}$.current=!1}),onBlur:be(e.onBlur,()=>A(!1))})})}),uE="RovingFocusGroupItem",dE=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:a=!0,active:i=!1,tabStopId:l,children:c,...f}=e,h=pn(),m=l||h,b=CL(uE,n),g=b.currentTabStopId===m,x=lE(n),{onFocusableItemAdd:w,onFocusableItemRemove:E,currentTabStopId:S}=b;return v.useEffect(()=>{if(a)return w(),()=>E()},[a,w,E]),d.jsx(yg.ItemSlot,{scope:n,id:m,focusable:a,active:i,children:d.jsx(Pe.span,{tabIndex:g?0:-1,"data-orientation":b.orientation,...f,ref:t,onMouseDown:be(e.onMouseDown,C=>{a?b.onItemFocus(m):C.preventDefault()}),onFocus:be(e.onFocus,()=>b.onItemFocus(m)),onKeyDown:be(e.onKeyDown,C=>{if(C.key==="Tab"&&C.shiftKey){b.onItemShiftTab();return}if(C.target!==C.currentTarget)return;const N=AL(C,b.orientation,b.dir);if(N!==void 0){if(C.metaKey||C.ctrlKey||C.altKey||C.shiftKey)return;C.preventDefault();let T=x().filter(M=>M.focusable).map(M=>M.ref.current);if(N==="last")T.reverse();else if(N==="prev"||N==="next"){N==="prev"&&T.reverse();const M=T.indexOf(C.currentTarget);T=b.loop?kL(T,M+1):T.slice(M+1)}setTimeout(()=>fE(T))}}),children:typeof c=="function"?c({isCurrentTabStop:g,hasTabStop:S!=null}):c})})});dE.displayName=uE;var TL={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function RL(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function AL(e,t,n){const a=RL(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(a))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(a)))return TL[a]}function fE(e,t=!1){const n=document.activeElement;for(const a of e)if(a===n||(a.focus({preventScroll:t}),document.activeElement!==n))return}function kL(e,t){return e.map((n,a)=>e[(t+a)%e.length])}var hE=cE,mE=dE;function OL(e){const t=ML(e),n=v.forwardRef((a,i)=>{const{children:l,...c}=a,f=v.Children.toArray(l),h=f.find(PL);if(h){const m=h.props.children,b=f.map(g=>g===h?v.Children.count(m)>1?v.Children.only(null):v.isValidElement(m)?m.props.children:null:g);return d.jsx(t,{...c,ref:i,children:v.isValidElement(m)?v.cloneElement(m,void 0,b):null})}return d.jsx(t,{...c,ref:i,children:l})});return n.displayName=`${e}.Slot`,n}function ML(e){const t=v.forwardRef((n,a)=>{const{children:i,...l}=n;if(v.isValidElement(i)){const c=zL(i),f=LL(l,i.props);return i.type!==v.Fragment&&(f.ref=a?wn(a,c):c),v.cloneElement(i,f)}return v.Children.count(i)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var DL=Symbol("radix.slottable");function PL(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===DL}function LL(e,t){const n={...t};for(const a in t){const i=e[a],l=t[a];/^on[A-Z]/.test(a)?i&&l?n[a]=(...f)=>{const h=l(...f);return i(...f),h}:i&&(n[a]=i):a==="style"?n[a]={...i,...l}:a==="className"&&(n[a]=[i,l].filter(Boolean).join(" "))}return{...e,...n}}function zL(e){var a,i;let t=(a=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var IL=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Wi=new WeakMap,Gu=new WeakMap,Ku={},Np=0,pE=function(e){return e&&(e.host||pE(e.parentNode))},$L=function(e,t){return t.map(function(n){if(e.contains(n))return n;var a=pE(n);return a&&e.contains(a)?a:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},UL=function(e,t,n,a){var i=$L(t,Array.isArray(e)?e:[e]);Ku[n]||(Ku[n]=new WeakMap);var l=Ku[n],c=[],f=new Set,h=new Set(i),m=function(g){!g||f.has(g)||(f.add(g),m(g.parentNode))};i.forEach(m);var b=function(g){!g||h.has(g)||Array.prototype.forEach.call(g.children,function(x){if(f.has(x))b(x);else try{var w=x.getAttribute(a),E=w!==null&&w!=="false",S=(Wi.get(x)||0)+1,C=(l.get(x)||0)+1;Wi.set(x,S),l.set(x,C),c.push(x),S===1&&E&&Gu.set(x,!0),C===1&&x.setAttribute(n,"true"),E||x.setAttribute(a,"true")}catch(N){console.error("aria-hidden: cannot operate on ",x,N)}})};return b(t),f.clear(),Np++,function(){c.forEach(function(g){var x=Wi.get(g)-1,w=l.get(g)-1;Wi.set(g,x),l.set(g,w),x||(Gu.has(g)||g.removeAttribute(a),Gu.delete(g)),w||g.removeAttribute(n)}),Np--,Np||(Wi=new WeakMap,Wi=new WeakMap,Gu=new WeakMap,Ku={})}},wf=function(e,t,n){n===void 0&&(n="data-aria-hidden");var a=Array.from(Array.isArray(e)?e:[e]),i=IL(e);return i?(a.push.apply(a,Array.from(i.querySelectorAll("[aria-live], script"))),UL(a,i,n,"aria-hidden")):function(){return null}},vd="right-scroll-bar-position",yd="width-before-scroll-bar",BL="with-scroll-bars-hidden",HL="--removed-body-scroll-bar-size";function Cp(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function qL(e,t){var n=v.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(a){var i=n.value;i!==a&&(n.value=a,n.callback(a,i))}}}})[0];return n.callback=t,n.facade}var VL=typeof window<"u"?v.useLayoutEffect:v.useEffect,k_=new WeakMap;function FL(e,t){var n=qL(null,function(a){return e.forEach(function(i){return Cp(i,a)})});return VL(function(){var a=k_.get(n);if(a){var i=new Set(a),l=new Set(e),c=n.current;i.forEach(function(f){l.has(f)||Cp(f,null)}),l.forEach(function(f){i.has(f)||Cp(f,c)})}k_.set(n,e)},[e]),n}function GL(e){return e}function KL(e,t){t===void 0&&(t=GL);var n=[],a=!1,i={read:function(){if(a)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(l){var c=t(l,a);return n.push(c),function(){n=n.filter(function(f){return f!==c})}},assignSyncMedium:function(l){for(a=!0;n.length;){var c=n;n=[],c.forEach(l)}n={push:function(f){return l(f)},filter:function(){return n}}},assignMedium:function(l){a=!0;var c=[];if(n.length){var f=n;n=[],f.forEach(l),c=n}var h=function(){var b=c;c=[],b.forEach(l)},m=function(){return Promise.resolve().then(h)};m(),n={push:function(b){c.push(b),m()},filter:function(b){return c=c.filter(b),n}}}};return i}function WL(e){e===void 0&&(e={});var t=KL(null);return t.options=Lr({async:!0,ssr:!1},e),t}var gE=function(e){var t=e.sideCar,n=No(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var a=t.read();if(!a)throw new Error("Sidecar medium not found");return v.createElement(a,Lr({},n))};gE.isSideCarExport=!0;function YL(e,t){return e.useMedium(t),gE}var vE=WL(),jp=function(){},_f=v.forwardRef(function(e,t){var n=v.useRef(null),a=v.useState({onScrollCapture:jp,onWheelCapture:jp,onTouchMoveCapture:jp}),i=a[0],l=a[1],c=e.forwardProps,f=e.children,h=e.className,m=e.removeScrollBar,b=e.enabled,g=e.shards,x=e.sideCar,w=e.noRelative,E=e.noIsolation,S=e.inert,C=e.allowPinchZoom,N=e.as,A=N===void 0?"div":N,T=e.gapMode,M=No(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),$=x,L=FL([n,t]),P=Lr(Lr({},M),i);return v.createElement(v.Fragment,null,b&&v.createElement($,{sideCar:vE,removeScrollBar:m,shards:g,noRelative:w,noIsolation:E,inert:S,setCallbacks:l,allowPinchZoom:!!C,lockRef:n,gapMode:T}),c?v.cloneElement(v.Children.only(f),Lr(Lr({},P),{ref:L})):v.createElement(A,Lr({},P,{className:h,ref:L}),f))});_f.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};_f.classNames={fullWidth:yd,zeroRight:vd};var XL=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function JL(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=XL();return t&&e.setAttribute("nonce",t),e}function QL(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function ZL(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var ez=function(){var e=0,t=null;return{add:function(n){e==0&&(t=JL())&&(QL(t,n),ZL(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},tz=function(){var e=ez();return function(t,n){v.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},yE=function(){var e=tz(),t=function(n){var a=n.styles,i=n.dynamic;return e(a,i),null};return t},nz={left:0,top:0,right:0,gap:0},Tp=function(e){return parseInt(e||"",10)||0},rz=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],a=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[Tp(n),Tp(a),Tp(i)]},az=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return nz;var t=rz(e),n=document.documentElement.clientWidth,a=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,a-n+t[2]-t[0])}},sz=yE(),fo="data-scroll-locked",iz=function(e,t,n,a){var i=e.left,l=e.top,c=e.right,f=e.gap;return n===void 0&&(n="margin"),`
.`.concat(BL,` {
overflow: hidden `).concat(a,`;
padding-right: `).concat(f,"px ").concat(a,`;
}
body[`).concat(fo,`] {
overflow: hidden `).concat(a,`;
overscroll-behavior: contain;
`).concat([t&&"position: relative ".concat(a,";"),n==="margin"&&`
padding-left: `.concat(i,`px;
padding-top: `).concat(l,`px;
padding-right: `).concat(c,`px;
margin-left:0;
margin-top:0;
margin-right: `).concat(f,"px ").concat(a,`;
`),n==="padding"&&"padding-right: ".concat(f,"px ").concat(a,";")].filter(Boolean).join(""),`
}
.`).concat(vd,` {
right: `).concat(f,"px ").concat(a,`;
}
.`).concat(yd,` {
margin-right: `).concat(f,"px ").concat(a,`;
}
.`).concat(vd," .").concat(vd,` {
right: 0 `).concat(a,`;
}
.`).concat(yd," .").concat(yd,` {
margin-right: 0 `).concat(a,`;
}
body[`).concat(fo,`] {
`).concat(HL,": ").concat(f,`px;
}
`)},O_=function(){var e=parseInt(document.body.getAttribute(fo)||"0",10);return isFinite(e)?e:0},oz=function(){v.useEffect(function(){return document.body.setAttribute(fo,(O_()+1).toString()),function(){var e=O_()-1;e<=0?document.body.removeAttribute(fo):document.body.setAttribute(fo,e.toString())}},[])},lz=function(e){var t=e.noRelative,n=e.noImportant,a=e.gapMode,i=a===void 0?"margin":a;oz();var l=v.useMemo(function(){return az(i)},[i]);return v.createElement(sz,{styles:iz(l,!t,i,n?"":"!important")})},bg=!1;if(typeof window<"u")try{var Wu=Object.defineProperty({},"passive",{get:function(){return bg=!0,!0}});window.addEventListener("test",Wu,Wu),window.removeEventListener("test",Wu,Wu)}catch{bg=!1}var Yi=bg?{passive:!1}:!1,cz=function(e){return e.tagName==="TEXTAREA"},bE=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!cz(e)&&n[t]==="visible")},uz=function(e){return bE(e,"overflowY")},dz=function(e){return bE(e,"overflowX")},M_=function(e,t){var n=t.ownerDocument,a=t;do{typeof ShadowRoot<"u"&&a instanceof ShadowRoot&&(a=a.host);var i=xE(e,a);if(i){var l=wE(e,a),c=l[1],f=l[2];if(c>f)return!0}a=a.parentNode}while(a&&a!==n.body);return!1},fz=function(e){var t=e.scrollTop,n=e.scrollHeight,a=e.clientHeight;return[t,n,a]},hz=function(e){var t=e.scrollLeft,n=e.scrollWidth,a=e.clientWidth;return[t,n,a]},xE=function(e,t){return e==="v"?uz(t):dz(t)},wE=function(e,t){return e==="v"?fz(t):hz(t)},mz=function(e,t){return e==="h"&&t==="rtl"?-1:1},pz=function(e,t,n,a,i){var l=mz(e,window.getComputedStyle(t).direction),c=l*a,f=n.target,h=t.contains(f),m=!1,b=c>0,g=0,x=0;do{if(!f)break;var w=wE(e,f),E=w[0],S=w[1],C=w[2],N=S-C-l*E;(E||N)&&xE(e,f)&&(g+=N,x+=E);var A=f.parentNode;f=A&&A.nodeType===Node.DOCUMENT_FRAGMENT_NODE?A.host:A}while(!h&&f!==document.body||h&&(t.contains(f)||t===f));return(b&&Math.abs(g)<1||!b&&Math.abs(x)<1)&&(m=!0),m},Yu=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},D_=function(e){return[e.deltaX,e.deltaY]},P_=function(e){return e&&"current"in e?e.current:e},gz=function(e,t){return e[0]===t[0]&&e[1]===t[1]},vz=function(e){return`
.block-interactivity-`.concat(e,` {pointer-events: none;}
.allow-interactivity-`).concat(e,` {pointer-events: all;}
`)},yz=0,Xi=[];function bz(e){var t=v.useRef([]),n=v.useRef([0,0]),a=v.useRef(),i=v.useState(yz++)[0],l=v.useState(yE)[0],c=v.useRef(e);v.useEffect(function(){c.current=e},[e]),v.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var S=H2([e.lockRef.current],(e.shards||[]).map(P_),!0).filter(Boolean);return S.forEach(function(C){return C.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),S.forEach(function(C){return C.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var f=v.useCallback(function(S,C){if("touches"in S&&S.touches.length===2||S.type==="wheel"&&S.ctrlKey)return!c.current.allowPinchZoom;var N=Yu(S),A=n.current,T="deltaX"in S?S.deltaX:A[0]-N[0],M="deltaY"in S?S.deltaY:A[1]-N[1],$,L=S.target,P=Math.abs(T)>Math.abs(M)?"h":"v";if("touches"in S&&P==="h"&&L.type==="range")return!1;var U=window.getSelection(),J=U&&U.anchorNode,ce=J?J===L||J.contains(L):!1;if(ce)return!1;var re=M_(P,L);if(!re)return!0;if(re?$=P:($=P==="v"?"h":"v",re=M_(P,L)),!re)return!1;if(!a.current&&"changedTouches"in S&&(T||M)&&(a.current=$),!$)return!0;var me=a.current||$;return pz(me,C,S,me==="h"?T:M)},[]),h=v.useCallback(function(S){var C=S;if(!(!Xi.length||Xi[Xi.length-1]!==l)){var N="deltaY"in C?D_(C):Yu(C),A=t.current.filter(function($){return $.name===C.type&&($.target===C.target||C.target===$.shadowParent)&&gz($.delta,N)})[0];if(A&&A.should){C.cancelable&&C.preventDefault();return}if(!A){var T=(c.current.shards||[]).map(P_).filter(Boolean).filter(function($){return $.contains(C.target)}),M=T.length>0?f(C,T[0]):!c.current.noIsolation;M&&C.cancelable&&C.preventDefault()}}},[]),m=v.useCallback(function(S,C,N,A){var T={name:S,delta:C,target:N,should:A,shadowParent:xz(N)};t.current.push(T),setTimeout(function(){t.current=t.current.filter(function(M){return M!==T})},1)},[]),b=v.useCallback(function(S){n.current=Yu(S),a.current=void 0},[]),g=v.useCallback(function(S){m(S.type,D_(S),S.target,f(S,e.lockRef.current))},[]),x=v.useCallback(function(S){m(S.type,Yu(S),S.target,f(S,e.lockRef.current))},[]);v.useEffect(function(){return Xi.push(l),e.setCallbacks({onScrollCapture:g,onWheelCapture:g,onTouchMoveCapture:x}),document.addEventListener("wheel",h,Yi),document.addEventListener("touchmove",h,Yi),document.addEventListener("touchstart",b,Yi),function(){Xi=Xi.filter(function(S){return S!==l}),document.removeEventListener("wheel",h,Yi),document.removeEventListener("touchmove",h,Yi),document.removeEventListener("touchstart",b,Yi)}},[]);var w=e.removeScrollBar,E=e.inert;return v.createElement(v.Fragment,null,E?v.createElement(l,{styles:vz(i)}):null,w?v.createElement(lz,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function xz(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const wz=YL(vE,bz);var mc=v.forwardRef(function(e,t){return v.createElement(_f,Lr({},e,{ref:t,sideCar:wz}))});mc.classNames=_f.classNames;var xg=["Enter"," "],_z=["ArrowDown","PageUp","Home"],_E=["ArrowUp","PageDown","End"],Sz=[..._z,..._E],Ez={ltr:[...xg,"ArrowRight"],rtl:[...xg,"ArrowLeft"]},Nz={ltr:["ArrowLeft"],rtl:["ArrowRight"]},pc="Menu",[Yl,Cz,jz]=cv(pc),[ti,SE]=ur(pc,[jz,Ro,xf]),Sf=Ro(),EE=xf(),[Tz,ni]=ti(pc),[Rz,gc]=ti(pc),NE=e=>{const{__scopeMenu:t,open:n=!1,children:a,dir:i,onOpenChange:l,modal:c=!0}=e,f=Sf(t),[h,m]=v.useState(null),b=v.useRef(!1),g=an(l),x=lc(i);return v.useEffect(()=>{const w=()=>{b.current=!0,document.addEventListener("pointerdown",E,{capture:!0,once:!0}),document.addEventListener("pointermove",E,{capture:!0,once:!0})},E=()=>b.current=!1;return document.addEventListener("keydown",w,{capture:!0}),()=>{document.removeEventListener("keydown",w,{capture:!0}),document.removeEventListener("pointerdown",E,{capture:!0}),document.removeEventListener("pointermove",E,{capture:!0})}},[]),d.jsx(bv,{...f,children:d.jsx(Tz,{scope:t,open:n,onOpenChange:g,content:h,onContentChange:m,children:d.jsx(Rz,{scope:t,onClose:v.useCallback(()=>g(!1),[g]),isUsingKeyboardRef:b,dir:x,modal:c,children:a})})})};NE.displayName=pc;var Az="MenuAnchor",_v=v.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,i=Sf(n);return d.jsx(bf,{...i,...a,ref:t})});_v.displayName=Az;var Sv="MenuPortal",[kz,CE]=ti(Sv,{forceMount:void 0}),jE=e=>{const{__scopeMenu:t,forceMount:n,children:a,container:i}=e,l=ni(Sv,t);return d.jsx(kz,{scope:t,forceMount:n,children:d.jsx(bn,{present:n||l.open,children:d.jsx(fc,{asChild:!0,container:i,children:a})})})};jE.displayName=Sv;var lr="MenuContent",[Oz,Ev]=ti(lr),TE=v.forwardRef((e,t)=>{const n=CE(lr,e.__scopeMenu),{forceMount:a=n.forceMount,...i}=e,l=ni(lr,e.__scopeMenu),c=gc(lr,e.__scopeMenu);return d.jsx(Yl.Provider,{scope:e.__scopeMenu,children:d.jsx(bn,{present:a||l.open,children:d.jsx(Yl.Slot,{scope:e.__scopeMenu,children:c.modal?d.jsx(Mz,{...i,ref:t}):d.jsx(Dz,{...i,ref:t})})})})}),Mz=v.forwardRef((e,t)=>{const n=ni(lr,e.__scopeMenu),a=v.useRef(null),i=nt(t,a);return v.useEffect(()=>{const l=a.current;if(l)return wf(l)},[]),d.jsx(Nv,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:be(e.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Dz=v.forwardRef((e,t)=>{const n=ni(lr,e.__scopeMenu);return d.jsx(Nv,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Pz=OL("MenuContent.ScrollLock"),Nv=v.forwardRef((e,t)=>{const{__scopeMenu:n,loop:a=!1,trapFocus:i,onOpenAutoFocus:l,onCloseAutoFocus:c,disableOutsidePointerEvents:f,onEntryFocus:h,onEscapeKeyDown:m,onPointerDownOutside:b,onFocusOutside:g,onInteractOutside:x,onDismiss:w,disableOutsideScroll:E,...S}=e,C=ni(lr,n),N=gc(lr,n),A=Sf(n),T=EE(n),M=Cz(n),[$,L]=v.useState(null),P=v.useRef(null),U=nt(t,P,C.onContentChange),J=v.useRef(0),ce=v.useRef(""),re=v.useRef(0),me=v.useRef(null),fe=v.useRef("right"),ge=v.useRef(0),de=E?mc:v.Fragment,k=E?{as:Pz,allowPinchZoom:!0}:void 0,K=Y=>{var te,Q;const V=ce.current+Y,R=M().filter(se=>!se.disabled),O=document.activeElement,I=(te=R.find(se=>se.ref.current===O))==null?void 0:te.textValue,H=R.map(se=>se.textValue),q=Kz(H,V,I),ee=(Q=R.find(se=>se.textValue===q))==null?void 0:Q.ref.current;(function se(je){ce.current=je,window.clearTimeout(J.current),je!==""&&(J.current=window.setTimeout(()=>se(""),1e3))})(V),ee&&setTimeout(()=>ee.focus())};v.useEffect(()=>()=>window.clearTimeout(J.current),[]),mf();const F=v.useCallback(Y=>{var R,O;return fe.current===((R=me.current)==null?void 0:R.side)&&Yz(Y,(O=me.current)==null?void 0:O.area)},[]);return d.jsx(Oz,{scope:n,searchRef:ce,onItemEnter:v.useCallback(Y=>{F(Y)&&Y.preventDefault()},[F]),onItemLeave:v.useCallback(Y=>{var V;F(Y)||((V=P.current)==null||V.focus(),L(null))},[F]),onTriggerLeave:v.useCallback(Y=>{F(Y)&&Y.preventDefault()},[F]),pointerGraceTimerRef:re,onPointerGraceIntentChange:v.useCallback(Y=>{me.current=Y},[]),children:d.jsx(de,{...k,children:d.jsx(uc,{asChild:!0,trapped:i,onMountAutoFocus:be(l,Y=>{var V;Y.preventDefault(),(V=P.current)==null||V.focus({preventScroll:!0})}),onUnmountAutoFocus:c,children:d.jsx(cc,{asChild:!0,disableOutsidePointerEvents:f,onEscapeKeyDown:m,onPointerDownOutside:b,onFocusOutside:g,onInteractOutside:x,onDismiss:w,children:d.jsx(hE,{asChild:!0,...T,dir:N.dir,orientation:"vertical",loop:a,currentTabStopId:$,onCurrentTabStopIdChange:L,onEntryFocus:be(h,Y=>{N.isUsingKeyboardRef.current||Y.preventDefault()}),preventScrollOnEntryFocus:!0,children:d.jsx(xv,{role:"menu","aria-orientation":"vertical","data-state":VE(C.open),"data-radix-menu-content":"",dir:N.dir,...A,...S,ref:U,style:{outline:"none",...S.style},onKeyDown:be(S.onKeyDown,Y=>{const R=Y.target.closest("[data-radix-menu-content]")===Y.currentTarget,O=Y.ctrlKey||Y.altKey||Y.metaKey,I=Y.key.length===1;R&&(Y.key==="Tab"&&Y.preventDefault(),!O&&I&&K(Y.key));const H=P.current;if(Y.target!==H||!Sz.includes(Y.key))return;Y.preventDefault();const ee=M().filter(te=>!te.disabled).map(te=>te.ref.current);_E.includes(Y.key)&&ee.reverse(),Fz(ee)}),onBlur:be(e.onBlur,Y=>{Y.currentTarget.contains(Y.target)||(window.clearTimeout(J.current),ce.current="")}),onPointerMove:be(e.onPointerMove,Xl(Y=>{const V=Y.target,R=ge.current!==Y.clientX;if(Y.currentTarget.contains(V)&&R){const O=Y.clientX>ge.current?"right":"left";fe.current=O,ge.current=Y.clientX}}))})})})})})})});TE.displayName=lr;var Lz="MenuGroup",Cv=v.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return d.jsx(Pe.div,{role:"group",...a,ref:t})});Cv.displayName=Lz;var zz="MenuLabel",RE=v.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return d.jsx(Pe.div,{...a,ref:t})});RE.displayName=zz;var qd="MenuItem",L_="menu.itemSelect",Ef=v.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:a,...i}=e,l=v.useRef(null),c=gc(qd,e.__scopeMenu),f=Ev(qd,e.__scopeMenu),h=nt(t,l),m=v.useRef(!1),b=()=>{const g=l.current;if(!n&&g){const x=new CustomEvent(L_,{bubbles:!0,cancelable:!0});g.addEventListener(L_,w=>a==null?void 0:a(w),{once:!0}),z1(g,x),x.defaultPrevented?m.current=!1:c.onClose()}};return d.jsx(AE,{...i,ref:h,disabled:n,onClick:be(e.onClick,b),onPointerDown:g=>{var x;(x=e.onPointerDown)==null||x.call(e,g),m.current=!0},onPointerUp:be(e.onPointerUp,g=>{var x;m.current||(x=g.currentTarget)==null||x.click()}),onKeyDown:be(e.onKeyDown,g=>{const x=f.searchRef.current!=="";n||x&&g.key===" "||xg.includes(g.key)&&(g.currentTarget.click(),g.preventDefault())})})});Ef.displayName=qd;var AE=v.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:a=!1,textValue:i,...l}=e,c=Ev(qd,n),f=EE(n),h=v.useRef(null),m=nt(t,h),[b,g]=v.useState(!1),[x,w]=v.useState("");return v.useEffect(()=>{const E=h.current;E&&w((E.textContent??"").trim())},[l.children]),d.jsx(Yl.ItemSlot,{scope:n,disabled:a,textValue:i??x,children:d.jsx(mE,{asChild:!0,...f,focusable:!a,children:d.jsx(Pe.div,{role:"menuitem","data-highlighted":b?"":void 0,"aria-disabled":a||void 0,"data-disabled":a?"":void 0,...l,ref:m,onPointerMove:be(e.onPointerMove,Xl(E=>{a?c.onItemLeave(E):(c.onItemEnter(E),E.defaultPrevented||E.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:be(e.onPointerLeave,Xl(E=>c.onItemLeave(E))),onFocus:be(e.onFocus,()=>g(!0)),onBlur:be(e.onBlur,()=>g(!1))})})})}),Iz="MenuCheckboxItem",kE=v.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:a,...i}=e;return d.jsx(LE,{scope:e.__scopeMenu,checked:n,children:d.jsx(Ef,{role:"menuitemcheckbox","aria-checked":Vd(n)?"mixed":n,...i,ref:t,"data-state":Tv(n),onSelect:be(i.onSelect,()=>a==null?void 0:a(Vd(n)?!0:!n),{checkForDefaultPrevented:!1})})})});kE.displayName=Iz;var OE="MenuRadioGroup",[$z,Uz]=ti(OE,{value:void 0,onValueChange:()=>{}}),ME=v.forwardRef((e,t)=>{const{value:n,onValueChange:a,...i}=e,l=an(a);return d.jsx($z,{scope:e.__scopeMenu,value:n,onValueChange:l,children:d.jsx(Cv,{...i,ref:t})})});ME.displayName=OE;var DE="MenuRadioItem",PE=v.forwardRef((e,t)=>{const{value:n,...a}=e,i=Uz(DE,e.__scopeMenu),l=n===i.value;return d.jsx(LE,{scope:e.__scopeMenu,checked:l,children:d.jsx(Ef,{role:"menuitemradio","aria-checked":l,...a,ref:t,"data-state":Tv(l),onSelect:be(a.onSelect,()=>{var c;return(c=i.onValueChange)==null?void 0:c.call(i,n)},{checkForDefaultPrevented:!1})})})});PE.displayName=DE;var jv="MenuItemIndicator",[LE,Bz]=ti(jv,{checked:!1}),zE=v.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:a,...i}=e,l=Bz(jv,n);return d.jsx(bn,{present:a||Vd(l.checked)||l.checked===!0,children:d.jsx(Pe.span,{...i,ref:t,"data-state":Tv(l.checked)})})});zE.displayName=jv;var Hz="MenuSeparator",IE=v.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return d.jsx(Pe.div,{role:"separator","aria-orientation":"horizontal",...a,ref:t})});IE.displayName=Hz;var qz="MenuArrow",$E=v.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,i=Sf(n);return d.jsx(wv,{...i,...a,ref:t})});$E.displayName=qz;var Vz="MenuSub",[UH,UE]=ti(Vz),kl="MenuSubTrigger",BE=v.forwardRef((e,t)=>{const n=ni(kl,e.__scopeMenu),a=gc(kl,e.__scopeMenu),i=UE(kl,e.__scopeMenu),l=Ev(kl,e.__scopeMenu),c=v.useRef(null),{pointerGraceTimerRef:f,onPointerGraceIntentChange:h}=l,m={__scopeMenu:e.__scopeMenu},b=v.useCallback(()=>{c.current&&window.clearTimeout(c.current),c.current=null},[]);return v.useEffect(()=>b,[b]),v.useEffect(()=>{const g=f.current;return()=>{window.clearTimeout(g),h(null)}},[f,h]),d.jsx(_v,{asChild:!0,...m,children:d.jsx(AE,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":VE(n.open),...e,ref:wn(t,i.onTriggerChange),onClick:g=>{var x;(x=e.onClick)==null||x.call(e,g),!(e.disabled||g.defaultPrevented)&&(g.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:be(e.onPointerMove,Xl(g=>{l.onItemEnter(g),!g.defaultPrevented&&!e.disabled&&!n.open&&!c.current&&(l.onPointerGraceIntentChange(null),c.current=window.setTimeout(()=>{n.onOpenChange(!0),b()},100))})),onPointerLeave:be(e.onPointerLeave,Xl(g=>{var w,E;b();const x=(w=n.content)==null?void 0:w.getBoundingClientRect();if(x){const S=(E=n.content)==null?void 0:E.dataset.side,C=S==="right",N=C?-5:5,A=x[C?"left":"right"],T=x[C?"right":"left"];l.onPointerGraceIntentChange({area:[{x:g.clientX+N,y:g.clientY},{x:A,y:x.top},{x:T,y:x.top},{x:T,y:x.bottom},{x:A,y:x.bottom}],side:S}),window.clearTimeout(f.current),f.current=window.setTimeout(()=>l.onPointerGraceIntentChange(null),300)}else{if(l.onTriggerLeave(g),g.defaultPrevented)return;l.onPointerGraceIntentChange(null)}})),onKeyDown:be(e.onKeyDown,g=>{var w;const x=l.searchRef.current!=="";e.disabled||x&&g.key===" "||Ez[a.dir].includes(g.key)&&(n.onOpenChange(!0),(w=n.content)==null||w.focus(),g.preventDefault())})})})});BE.displayName=kl;var HE="MenuSubContent",qE=v.forwardRef((e,t)=>{const n=CE(lr,e.__scopeMenu),{forceMount:a=n.forceMount,...i}=e,l=ni(lr,e.__scopeMenu),c=gc(lr,e.__scopeMenu),f=UE(HE,e.__scopeMenu),h=v.useRef(null),m=nt(t,h);return d.jsx(Yl.Provider,{scope:e.__scopeMenu,children:d.jsx(bn,{present:a||l.open,children:d.jsx(Yl.Slot,{scope:e.__scopeMenu,children:d.jsx(Nv,{id:f.contentId,"aria-labelledby":f.triggerId,...i,ref:m,align:"start",side:c.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:b=>{var g;c.isUsingKeyboardRef.current&&((g=h.current)==null||g.focus()),b.preventDefault()},onCloseAutoFocus:b=>b.preventDefault(),onFocusOutside:be(e.onFocusOutside,b=>{b.target!==f.trigger&&l.onOpenChange(!1)}),onEscapeKeyDown:be(e.onEscapeKeyDown,b=>{c.onClose(),b.preventDefault()}),onKeyDown:be(e.onKeyDown,b=>{var w;const g=b.currentTarget.contains(b.target),x=Nz[c.dir].includes(b.key);g&&x&&(l.onOpenChange(!1),(w=f.trigger)==null||w.focus(),b.preventDefault())})})})})})});qE.displayName=HE;function VE(e){return e?"open":"closed"}function Vd(e){return e==="indeterminate"}function Tv(e){return Vd(e)?"indeterminate":e?"checked":"unchecked"}function Fz(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Gz(e,t){return e.map((n,a)=>e[(t+a)%e.length])}function Kz(e,t,n){const i=t.length>1&&Array.from(t).every(m=>m===t[0])?t[0]:t,l=n?e.indexOf(n):-1;let c=Gz(e,Math.max(l,0));i.length===1&&(c=c.filter(m=>m!==n));const h=c.find(m=>m.toLowerCase().startsWith(i.toLowerCase()));return h!==n?h:void 0}function Wz(e,t){const{x:n,y:a}=e;let i=!1;for(let l=0,c=t.length-1;l<t.length;c=l++){const f=t[l],h=t[c],m=f.x,b=f.y,g=h.x,x=h.y;b>a!=x>a&&n<(g-m)*(a-b)/(x-b)+m&&(i=!i)}return i}function Yz(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Wz(n,t)}function Xl(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Xz=NE,Jz=_v,Qz=jE,Zz=TE,eI=Cv,tI=RE,nI=Ef,rI=kE,aI=ME,sI=PE,iI=zE,oI=IE,lI=$E,cI=BE,uI=qE,Nf="DropdownMenu",[dI]=ur(Nf,[SE]),_n=SE(),[fI,FE]=dI(Nf),GE=e=>{const{__scopeDropdownMenu:t,children:n,dir:a,open:i,defaultOpen:l,onOpenChange:c,modal:f=!0}=e,h=_n(t),m=v.useRef(null),[b,g]=ga({prop:i,defaultProp:l??!1,onChange:c,caller:Nf});return d.jsx(fI,{scope:t,triggerId:pn(),triggerRef:m,contentId:pn(),open:b,onOpenChange:g,onOpenToggle:v.useCallback(()=>g(x=>!x),[g]),modal:f,children:d.jsx(Xz,{...h,open:b,onOpenChange:g,dir:a,modal:f,children:n})})};GE.displayName=Nf;var KE="DropdownMenuTrigger",WE=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:a=!1,...i}=e,l=FE(KE,n),c=_n(n);return d.jsx(Jz,{asChild:!0,...c,children:d.jsx(Pe.button,{type:"button",id:l.triggerId,"aria-haspopup":"menu","aria-expanded":l.open,"aria-controls":l.open?l.contentId:void 0,"data-state":l.open?"open":"closed","data-disabled":a?"":void 0,disabled:a,...i,ref:wn(t,l.triggerRef),onPointerDown:be(e.onPointerDown,f=>{!a&&f.button===0&&f.ctrlKey===!1&&(l.onOpenToggle(),l.open||f.preventDefault())}),onKeyDown:be(e.onKeyDown,f=>{a||(["Enter"," "].includes(f.key)&&l.onOpenToggle(),f.key==="ArrowDown"&&l.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(f.key)&&f.preventDefault())})})})});WE.displayName=KE;var hI="DropdownMenuPortal",YE=e=>{const{__scopeDropdownMenu:t,...n}=e,a=_n(t);return d.jsx(Qz,{...a,...n})};YE.displayName=hI;var XE="DropdownMenuContent",JE=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,i=FE(XE,n),l=_n(n),c=v.useRef(!1);return d.jsx(Zz,{id:i.contentId,"aria-labelledby":i.triggerId,...l,...a,ref:t,onCloseAutoFocus:be(e.onCloseAutoFocus,f=>{var h;c.current||(h=i.triggerRef.current)==null||h.focus(),c.current=!1,f.preventDefault()}),onInteractOutside:be(e.onInteractOutside,f=>{const h=f.detail.originalEvent,m=h.button===0&&h.ctrlKey===!0,b=h.button===2||m;(!i.modal||b)&&(c.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});JE.displayName=XE;var mI="DropdownMenuGroup",pI=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,i=_n(n);return d.jsx(eI,{...i,...a,ref:t})});pI.displayName=mI;var gI="DropdownMenuLabel",QE=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,i=_n(n);return d.jsx(tI,{...i,...a,ref:t})});QE.displayName=gI;var vI="DropdownMenuItem",ZE=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,i=_n(n);return d.jsx(nI,{...i,...a,ref:t})});ZE.displayName=vI;var yI="DropdownMenuCheckboxItem",eN=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,i=_n(n);return d.jsx(rI,{...i,...a,ref:t})});eN.displayName=yI;var bI="DropdownMenuRadioGroup",xI=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,i=_n(n);return d.jsx(aI,{...i,...a,ref:t})});xI.displayName=bI;var wI="DropdownMenuRadioItem",tN=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,i=_n(n);return d.jsx(sI,{...i,...a,ref:t})});tN.displayName=wI;var _I="DropdownMenuItemIndicator",nN=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,i=_n(n);return d.jsx(iI,{...i,...a,ref:t})});nN.displayName=_I;var SI="DropdownMenuSeparator",rN=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,i=_n(n);return d.jsx(oI,{...i,...a,ref:t})});rN.displayName=SI;var EI="DropdownMenuArrow",NI=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,i=_n(n);return d.jsx(lI,{...i,...a,ref:t})});NI.displayName=EI;var CI="DropdownMenuSubTrigger",aN=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,i=_n(n);return d.jsx(cI,{...i,...a,ref:t})});aN.displayName=CI;var jI="DropdownMenuSubContent",sN=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,i=_n(n);return d.jsx(uI,{...i,...a,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});sN.displayName=jI;var TI=GE,RI=WE,AI=YE,iN=JE,oN=QE,lN=ZE,cN=eN,uN=tN,dN=nN,fN=rN,hN=aN,mN=sN;const kI=TI,OI=RI,MI=v.forwardRef(({className:e,inset:t,children:n,...a},i)=>d.jsxs(hN,{ref:i,className:xe("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...a,children:[n,d.jsx(oc,{className:"ml-auto"})]}));MI.displayName=hN.displayName;const DI=v.forwardRef(({className:e,...t},n)=>d.jsx(mN,{ref:n,className:xe("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-dropdown-menu-content-transform-origin)",e),...t}));DI.displayName=mN.displayName;const pN=v.forwardRef(({className:e,sideOffset:t=4,...n},a)=>d.jsx(AI,{children:d.jsx(iN,{ref:a,sideOffset:t,className:xe("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-dropdown-menu-content-transform-origin)",e),...n})}));pN.displayName=iN.displayName;const gN=v.forwardRef(({className:e,inset:t,...n},a)=>d.jsx(lN,{ref:a,className:xe("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",t&&"pl-8",e),...n}));gN.displayName=lN.displayName;const PI=v.forwardRef(({className:e,children:t,checked:n,...a},i)=>d.jsxs(cN,{ref:i,className:xe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...a,children:[d.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:d.jsx(dN,{children:d.jsx(Hr,{className:"h-4 w-4"})})}),t]}));PI.displayName=cN.displayName;const LI=v.forwardRef(({className:e,children:t,...n},a)=>d.jsxs(uN,{ref:a,className:xe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[d.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:d.jsx(dN,{children:d.jsx(E3,{className:"h-2 w-2 fill-current"})})}),t]}));LI.displayName=uN.displayName;const zI=v.forwardRef(({className:e,inset:t,...n},a)=>d.jsx(oN,{ref:a,className:xe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));zI.displayName=oN.displayName;const vN=v.forwardRef(({className:e,...t},n)=>d.jsx(fN,{ref:n,className:xe("-mx-1 my-1 h-px bg-muted",e),...t}));vN.displayName=fN.displayName;function II(e,t=[]){let n=[];function a(l,c){const f=v.createContext(c);f.displayName=l+"Context";const h=n.length;n=[...n,c];const m=g=>{var N;const{scope:x,children:w,...E}=g,S=((N=x==null?void 0:x[e])==null?void 0:N[h])||f,C=v.useMemo(()=>E,Object.values(E));return d.jsx(S.Provider,{value:C,children:w})};m.displayName=l+"Provider";function b(g,x){var S;const w=((S=x==null?void 0:x[e])==null?void 0:S[h])||f,E=v.useContext(w);if(E)return E;if(c!==void 0)return c;throw new Error(`\`${g}\` must be used within \`${l}\``)}return[m,b]}const i=()=>{const l=n.map(c=>v.createContext(c));return function(f){const h=(f==null?void 0:f[e])||l;return v.useMemo(()=>({[`__scope${e}`]:{...f,[e]:h}}),[f,h])}};return i.scopeName=e,[a,$I(i,...t)]}function $I(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const a=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(l){const c=a.reduce((f,{useScope:h,scopeName:m})=>{const g=h(l)[`__scope${m}`];return{...f,...g}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return n.scopeName=t.scopeName,n}var UI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Rv=UI.reduce((e,t)=>{const n=ic(`Primitive.${t}`),a=v.forwardRef((i,l)=>{const{asChild:c,...f}=i,h=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(h,{...f,ref:l})});return a.displayName=`Primitive.${t}`,{...e,[t]:a}},{}),Rp={exports:{}},Ap={};/**
* @license React
* use-sync-external-store-shim.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var z_;function BI(){if(z_)return Ap;z_=1;var e=rf();function t(g,x){return g===x&&(g!==0||1/g===1/x)||g!==g&&x!==x}var n=typeof Object.is=="function"?Object.is:t,a=e.useState,i=e.useEffect,l=e.useLayoutEffect,c=e.useDebugValue;function f(g,x){var w=x(),E=a({inst:{value:w,getSnapshot:x}}),S=E[0].inst,C=E[1];return l(function(){S.value=w,S.getSnapshot=x,h(S)&&C({inst:S})},[g,w,x]),i(function(){return h(S)&&C({inst:S}),g(function(){h(S)&&C({inst:S})})},[g]),c(w),w}function h(g){var x=g.getSnapshot;g=g.value;try{var w=x();return!n(g,w)}catch{return!0}}function m(g,x){return x()}var b=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?m:f;return Ap.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:b,Ap}var I_;function HI(){return I_||(I_=1,Rp.exports=BI()),Rp.exports}var qI=HI();function VI(){return qI.useSyncExternalStore(FI,()=>!0,()=>!1)}function FI(){return()=>{}}var Av="Avatar",[GI]=II(Av),[KI,yN]=GI(Av),bN=v.forwardRef((e,t)=>{const{__scopeAvatar:n,...a}=e,[i,l]=v.useState("idle");return d.jsx(KI,{scope:n,imageLoadingStatus:i,onImageLoadingStatusChange:l,children:d.jsx(Rv.span,{...a,ref:t})})});bN.displayName=Av;var xN="AvatarImage",wN=v.forwardRef((e,t)=>{const{__scopeAvatar:n,src:a,onLoadingStatusChange:i=()=>{},...l}=e,c=yN(xN,n),f=WI(a,l),h=an(m=>{i(m),c.onImageLoadingStatusChange(m)});return Yt(()=>{f!=="idle"&&h(f)},[f,h]),f==="loaded"?d.jsx(Rv.img,{...l,ref:t,src:a}):null});wN.displayName=xN;var _N="AvatarFallback",SN=v.forwardRef((e,t)=>{const{__scopeAvatar:n,delayMs:a,...i}=e,l=yN(_N,n),[c,f]=v.useState(a===void 0);return v.useEffect(()=>{if(a!==void 0){const h=window.setTimeout(()=>f(!0),a);return()=>window.clearTimeout(h)}},[a]),c&&l.imageLoadingStatus!=="loaded"?d.jsx(Rv.span,{...i,ref:t}):null});SN.displayName=_N;function $_(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function WI(e,{referrerPolicy:t,crossOrigin:n}){const a=VI(),i=v.useRef(null),l=a?(i.current||(i.current=new window.Image),i.current):null,[c,f]=v.useState(()=>$_(l,e));return Yt(()=>{f($_(l,e))},[l,e]),Yt(()=>{const h=g=>()=>{f(g)};if(!l)return;const m=h("loaded"),b=h("error");return l.addEventListener("load",m),l.addEventListener("error",b),t&&(l.referrerPolicy=t),typeof n=="string"&&(l.crossOrigin=n),()=>{l.removeEventListener("load",m),l.removeEventListener("error",b)}},[l,n,t]),c}var EN=bN,NN=wN,CN=SN;const Cf=v.forwardRef(({className:e,...t},n)=>d.jsx(EN,{ref:n,className:xe("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));Cf.displayName=EN.displayName;const jN=v.forwardRef(({className:e,...t},n)=>d.jsx(NN,{ref:n,className:xe("aspect-square h-full w-full",e),...t}));jN.displayName=NN.displayName;const jf=v.forwardRef(({className:e,...t},n)=>d.jsx(CN,{ref:n,className:xe("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));jf.displayName=CN.displayName;const YI=tv("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function sn({className:e,variant:t,...n}){return d.jsx("div",{className:xe(YI({variant:t}),e),...n})}const XI=["Ascenda","Bacardí","Bayer","Benedicto Wong","Big Cola","BMI","Casio","CDC","Colgate","Cordiflex","Diageo","Estelar","Estrella Azul","GLM","In Drive","Mars","Microsoft","Molino Criollo","Naicom","Nestlé","P&G","Pepsico","RRHH","Taco Bell","Us Meat","Vozez","Whirlpool","Little Caesars","Intcomex","Cemix","Súper Xtra","Grupo AJE","Varios","KitchenAid","Maytag","Across","Claro","Bruni","Volt","InDrive","TrueShore","Coca Cola","Más Móvil","US Rice","Café Indio","Café Maya","Jack Daniels","GLM Digital","Compass","Starbucks","Skechers","Ron Bermudez","Nature´s Heart","Larimart","Motorola","Bajaj - Pulsar","Xelet Media","Philip Morris","Malher","Carnation","La Lechera"].sort(),TN={CDC:"Marrero",Colombia:"J. Fernando","Costa Rica":"Poul","El Salvador":"Christian",Estelar:"Pablo",Guatemala:"Gerardo",Honduras:"Lucy",Jamaica:"Liz",Latam:"JL",Mexico:"Poul",Nicaragua:"Poul",OCI:"Liz",Panama:"Gabriel","Puerto Rico":"Liz","Republica Dominicana":"Liz",RRHH:"Maximo",Trinidad:"Liz",Venezuela:"Jose Fer",Vozez:"Nathalia","GLM Digital":"Lil",IQM:"Lil",WMC:"Willy"},RN=Object.keys(TN).sort(),JI=["Carnation","GLM RRHH","La Lechera","Malher","US Meat","Coffee Mate y Nescafé","Nestum y Nido","Whirlpool","Motorola","Philip Morris","US Meat Guatemala","KitKat, Crunch, Choco Trío","Colgate","Kit Kat","UMA","Purina","Maggi e Ideal","Nestlé","Jimador","Multimarcas","Maggi","Covo","El Machetazo","Grupo Bocel","Supply Chain","Carnation y La Lechera","GLM Administración","Nestlé Bice","GLM","Nescafé","Idea, Qué Rico y Maggi","EY","Nesquik","Maggi, Ketchup, Qué Rico","Ideal","Claro Empresas","Nido","Presto","Nestlé RD","GLM Colombia","Motorola RD","GLM Caribe","Mandino","Coffee Mate","GLM Latam","RRHH RD","Philip Morris TT","GLM RD","Smirnoff","Kaspersky","US Pork","Qué Rico y Maggi","Claro y Motorola","Sedal","Maytag","Qué Rico, Maggi y Ketchup","Multimarca","Aviva y Princesa","KitchenAid","Enredé","Ascenda","Lipton Té","Heiniken","Oral B","Aafresh","IQOS","Natures Heart"],QI=["Aprobado","No aprobado","Stand by","Aprobado /no ejecutado","Pre aprobado","On going","Sin respuesta"],wg=[{id:"blue",name:"Azul",hex:"#4285F4"},{id:"red",name:"Rojo",hex:"#EA4335"},{id:"yellow",name:"Amarillo",hex:"#FBBC04"},{id:"green",name:"Verde",hex:"#34A853"},{id:"purple",name:"Morado",hex:"#A142F4"},{id:"teal",name:"Turquesa",hex:"#00ACC1"},{id:"orange",name:"Naranja",hex:"#FB8C00"},{id:"pink",name:"Rosa",hex:"#E91E63"},{id:"indigo",name:"Índigo",hex:"#3F51B5"},{id:"gray",name:"Gris",hex:"#5F6368"}],ZI=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"];function AN(e){var t;return((t=wg.find(n=>n.id===e))==null?void 0:t.hex)??wg[0].hex}function e$({project:e,onClick:t,onTimeClick:n,showInternalAmount:a=!1}){const i=!!e.status,l=Number(e.monto),c=a&&e.monto!==null&&Number.isFinite(l)&&l>0,f=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),t())};return d.jsxs("div",{"data-cdc-project-id":e.id,"data-cdc-project-country":e.bu,"data-cdc-project-name":e.nombre||"Sin título",role:"button",tabIndex:0,onClick:t,onKeyDown:f,className:xe("group block text-left w-full rounded-2xl bg-card overflow-hidden p-0 ring-1 ring-border cursor-pointer","transition-all duration-200 hover:-translate-y-0.5","focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",i&&"opacity-65 hover:opacity-90"),style:{boxShadow:i?"0 1px 2px oklch(0.5 0.02 280 / 0.04)":"var(--shadow-soft)"},onMouseEnter:h=>{i||(h.currentTarget.style.boxShadow="var(--shadow-hover)")},onMouseLeave:h=>{h.currentTarget.style.boxShadow=i?"0 1px 2px oklch(0.5 0.02 280 / 0.04)":"var(--shadow-soft)"},children:[d.jsx("div",{className:"min-h-14 rounded-t-2xl px-4 py-3",style:{backgroundColor:i?"#9AA0A6":AN(e.color)},children:d.jsx("h3",{className:"text-white font-semibold text-sm leading-snug line-clamp-2 drop-shadow-sm",children:e.nombre||"Sin título"})}),d.jsxs("div",{className:"p-4 space-y-2.5",children:[d.jsx(Xu,{icon:d.jsx(Id,{className:"w-3.5 h-3.5"}),label:"Cliente",value:e.cliente}),d.jsx(Xu,{icon:d.jsx(Id,{className:"w-3.5 h-3.5"}),label:"Marca",value:e.marca}),d.jsx(Xu,{icon:d.jsx(zd,{className:"w-3.5 h-3.5"}),label:"País",value:e.bu}),d.jsx(Xu,{icon:d.jsx(L1,{className:"w-3.5 h-3.5"}),label:"Solicita",value:e.solicitante}),d.jsxs("div",{className:"flex items-center justify-between pt-2 mt-2 border-t border-border/70",children:[d.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[n&&d.jsxs("button",{type:"button",onClick:h=>{h.stopPropagation(),n()},onKeyDown:h=>h.stopPropagation(),className:"inline-flex h-7 items-center gap-1 rounded-full border border-border bg-card px-2.5 font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",title:"Agregar o ver tiempo dedicado",children:[d.jsx(Fs,{className:"h-3.5 w-3.5"}),"Tiempo"]}),e.propuestaLinks.length>0&&d.jsxs("span",{className:"flex items-center gap-1",title:"Propuestas",children:[d.jsx(W3,{className:"w-3 h-3"})," ",e.propuestaLinks.length]}),e.afLinks.length>0&&d.jsxs("span",{className:"flex items-center gap-1",title:"Artes finales",children:[d.jsx(M3,{className:"w-3 h-3"})," AF·",e.afLinks.length]})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[c&&d.jsx("span",{className:"text-sm font-semibold tabular-nums text-foreground",title:"Monto interno del proyecto",children:t$(l)}),e.status&&d.jsxs(sn,{variant:"secondary",className:xe("text-[10px] px-1.5 py-0 h-5 font-medium",e.status==="Aprobado"&&"bg-emerald-100 text-emerald-800 hover:bg-emerald-100",e.status==="No aprobado"&&"bg-red-100 text-red-800 hover:bg-red-100"),children:[e.status==="Aprobado"&&d.jsx(iv,{className:"w-2.5 h-2.5 mr-0.5"}),e.status]})]})]})]})]})}function t$(e){return`$${e.toLocaleString("en-US",{minimumFractionDigits:Number.isInteger(e)?0:2,maximumFractionDigits:2})}`}function Xu({icon:e,label:t,value:n}){return d.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[d.jsx("span",{className:"text-muted-foreground mt-0.5 flex-shrink-0",children:e}),d.jsx("span",{className:"text-muted-foreground w-14 flex-shrink-0",children:t}),d.jsx("span",{className:"text-foreground font-medium truncate",children:n||"—"})]})}function n$(e){const t=r$(e),n=v.forwardRef((a,i)=>{const{children:l,...c}=a,f=v.Children.toArray(l),h=f.find(s$);if(h){const m=h.props.children,b=f.map(g=>g===h?v.Children.count(m)>1?v.Children.only(null):v.isValidElement(m)?m.props.children:null:g);return d.jsx(t,{...c,ref:i,children:v.isValidElement(m)?v.cloneElement(m,void 0,b):null})}return d.jsx(t,{...c,ref:i,children:l})});return n.displayName=`${e}.Slot`,n}function r$(e){const t=v.forwardRef((n,a)=>{const{children:i,...l}=n;if(v.isValidElement(i)){const c=o$(i),f=i$(l,i.props);return i.type!==v.Fragment&&(f.ref=a?wn(a,c):c),v.cloneElement(i,f)}return v.Children.count(i)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var a$=Symbol("radix.slottable");function s$(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===a$}function i$(e,t){const n={...t};for(const a in t){const i=e[a],l=t[a];/^on[A-Z]/.test(a)?i&&l?n[a]=(...f)=>{const h=l(...f);return i(...f),h}:i&&(n[a]=i):a==="style"?n[a]={...i,...l}:a==="className"&&(n[a]=[i,l].filter(Boolean).join(" "))}return{...e,...n}}function o$(e){var a,i;let t=(a=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Tf="Dialog",[kN]=ur(Tf),[l$,Cr]=kN(Tf),ON=e=>{const{__scopeDialog:t,children:n,open:a,defaultOpen:i,onOpenChange:l,modal:c=!0}=e,f=v.useRef(null),h=v.useRef(null),[m,b]=ga({prop:a,defaultProp:i??!1,onChange:l,caller:Tf});return d.jsx(l$,{scope:t,triggerRef:f,contentRef:h,contentId:pn(),titleId:pn(),descriptionId:pn(),open:m,onOpenChange:b,onOpenToggle:v.useCallback(()=>b(g=>!g),[b]),modal:c,children:n})};ON.displayName=Tf;var MN="DialogTrigger",c$=v.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,i=Cr(MN,n),l=nt(t,i.triggerRef);return d.jsx(Pe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Mv(i.open),...a,ref:l,onClick:be(e.onClick,i.onOpenToggle)})});c$.displayName=MN;var kv="DialogPortal",[u$,DN]=kN(kv,{forceMount:void 0}),PN=e=>{const{__scopeDialog:t,forceMount:n,children:a,container:i}=e,l=Cr(kv,t);return d.jsx(u$,{scope:t,forceMount:n,children:v.Children.map(a,c=>d.jsx(bn,{present:n||l.open,children:d.jsx(fc,{asChild:!0,container:i,children:c})}))})};PN.displayName=kv;var Fd="DialogOverlay",LN=v.forwardRef((e,t)=>{const n=DN(Fd,e.__scopeDialog),{forceMount:a=n.forceMount,...i}=e,l=Cr(Fd,e.__scopeDialog);return l.modal?d.jsx(bn,{present:a||l.open,children:d.jsx(f$,{...i,ref:t})}):null});LN.displayName=Fd;var d$=n$("DialogOverlay.RemoveScroll"),f$=v.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,i=Cr(Fd,n);return d.jsx(mc,{as:d$,allowPinchZoom:!0,shards:[i.contentRef],children:d.jsx(Pe.div,{"data-state":Mv(i.open),...a,ref:t,style:{pointerEvents:"auto",...a.style}})})}),Xs="DialogContent",zN=v.forwardRef((e,t)=>{const n=DN(Xs,e.__scopeDialog),{forceMount:a=n.forceMount,...i}=e,l=Cr(Xs,e.__scopeDialog);return d.jsx(bn,{present:a||l.open,children:l.modal?d.jsx(h$,{...i,ref:t}):d.jsx(m$,{...i,ref:t})})});zN.displayName=Xs;var h$=v.forwardRef((e,t)=>{const n=Cr(Xs,e.__scopeDialog),a=v.useRef(null),i=nt(t,n.contentRef,a);return v.useEffect(()=>{const l=a.current;if(l)return wf(l)},[]),d.jsx(IN,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:be(e.onCloseAutoFocus,l=>{var c;l.preventDefault(),(c=n.triggerRef.current)==null||c.focus()}),onPointerDownOutside:be(e.onPointerDownOutside,l=>{const c=l.detail.originalEvent,f=c.button===0&&c.ctrlKey===!0;(c.button===2||f)&&l.preventDefault()}),onFocusOutside:be(e.onFocusOutside,l=>l.preventDefault())})}),m$=v.forwardRef((e,t)=>{const n=Cr(Xs,e.__scopeDialog),a=v.useRef(!1),i=v.useRef(!1);return d.jsx(IN,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:l=>{var c,f;(c=e.onCloseAutoFocus)==null||c.call(e,l),l.defaultPrevented||(a.current||(f=n.triggerRef.current)==null||f.focus(),l.preventDefault()),a.current=!1,i.current=!1},onInteractOutside:l=>{var h,m;(h=e.onInteractOutside)==null||h.call(e,l),l.defaultPrevented||(a.current=!0,l.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const c=l.target;((m=n.triggerRef.current)==null?void 0:m.contains(c))&&l.preventDefault(),l.detail.originalEvent.type==="focusin"&&i.current&&l.preventDefault()}})}),IN=v.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:a,onOpenAutoFocus:i,onCloseAutoFocus:l,...c}=e,f=Cr(Xs,n),h=v.useRef(null),m=nt(t,h);return mf(),d.jsxs(d.Fragment,{children:[d.jsx(uc,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:i,onUnmountAutoFocus:l,children:d.jsx(cc,{role:"dialog",id:f.contentId,"aria-describedby":f.descriptionId,"aria-labelledby":f.titleId,"data-state":Mv(f.open),...c,ref:m,onDismiss:()=>f.onOpenChange(!1)})}),d.jsxs(d.Fragment,{children:[d.jsx(p$,{titleId:f.titleId}),d.jsx(v$,{contentRef:h,descriptionId:f.descriptionId})]})]})}),Ov="DialogTitle",$N=v.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,i=Cr(Ov,n);return d.jsx(Pe.h2,{id:i.titleId,...a,ref:t})});$N.displayName=Ov;var UN="DialogDescription",BN=v.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,i=Cr(UN,n);return d.jsx(Pe.p,{id:i.descriptionId,...a,ref:t})});BN.displayName=UN;var HN="DialogClose",qN=v.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,i=Cr(HN,n);return d.jsx(Pe.button,{type:"button",...a,ref:t,onClick:be(e.onClick,()=>i.onOpenChange(!1))})});qN.displayName=HN;function Mv(e){return e?"open":"closed"}var VN="DialogTitleWarning",[BH,FN]=NP(VN,{contentName:Xs,titleName:Ov,docsSlug:"dialog"}),p$=({titleId:e})=>{const t=FN(VN),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return v.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},g$="DialogDescriptionWarning",v$=({contentRef:e,descriptionId:t})=>{const a=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${FN(g$).contentName}}.`;return v.useEffect(()=>{var l;const i=(l=e.current)==null?void 0:l.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(a))},[a,e,t]),null},GN=ON,KN=PN,Dv=LN,Pv=zN,WN=$N,YN=BN,y$=qN;const ri=GN,b$=KN,XN=v.forwardRef(({className:e,...t},n)=>d.jsx(Dv,{ref:n,className:xe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));XN.displayName=Dv.displayName;const ls=v.forwardRef(({className:e,children:t,...n},a)=>d.jsxs(b$,{children:[d.jsx(XN,{}),d.jsxs(Pv,{ref:a,className:xe("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:rounded-lg",e),...n,children:[t,d.jsxs(y$,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background cursor-pointer transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[d.jsx(vo,{className:"h-4 w-4"}),d.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ls.displayName=Pv.displayName;const cs=({className:e,...t})=>d.jsx("div",{className:xe("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});cs.displayName="DialogHeader";const Rf=({className:e,...t})=>d.jsx("div",{className:xe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Rf.displayName="DialogFooter";const us=v.forwardRef(({className:e,...t},n)=>d.jsx(WN,{ref:n,className:xe("text-lg font-semibold leading-none tracking-tight",e),...t}));us.displayName=WN.displayName;const ds=v.forwardRef(({className:e,...t},n)=>d.jsx(YN,{ref:n,className:xe("text-sm text-muted-foreground",e),...t}));ds.displayName=YN.displayName;var x$=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],w$=x$.reduce((e,t)=>{const n=ic(`Primitive.${t}`),a=v.forwardRef((i,l)=>{const{asChild:c,...f}=i,h=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(h,{...f,ref:l})});return a.displayName=`Primitive.${t}`,{...e,[t]:a}},{}),_$="Label",JN=v.forwardRef((e,t)=>d.jsx(w$.label,{...e,ref:t,onMouseDown:n=>{var i;n.target.closest("button, input, select, textarea")||((i=e.onMouseDown)==null||i.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));JN.displayName=_$;var QN=JN;const S$=tv("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ge=v.forwardRef(({className:e,...t},n)=>d.jsx(QN,{ref:n,className:xe(S$(),e),...t}));Ge.displayName=QN.displayName;const ma=v.forwardRef(({className:e,...t},n)=>d.jsx("textarea",{className:xe("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...t}));ma.displayName="Textarea";function Lv(e){const t=v.useRef({value:e,previous:e});return v.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Af="Checkbox",[E$]=ur(Af),[N$,zv]=E$(Af);function C$(e){const{__scopeCheckbox:t,checked:n,children:a,defaultChecked:i,disabled:l,form:c,name:f,onCheckedChange:h,required:m,value:b="on",internal_do_not_use_render:g}=e,[x,w]=ga({prop:n,defaultProp:i??!1,onChange:h,caller:Af}),[E,S]=v.useState(null),[C,N]=v.useState(null),A=v.useRef(!1),T=E?!!c||!!E.closest("form"):!0,M={checked:x,disabled:l,setChecked:w,control:E,setControl:S,name:f,form:c,value:b,hasConsumerStoppedPropagationRef:A,required:m,defaultChecked:rs(i)?!1:i,isFormControl:T,bubbleInput:C,setBubbleInput:N};return d.jsx(N$,{scope:t,...M,children:j$(g)?g(M):a})}var ZN="CheckboxTrigger",eC=v.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...a},i)=>{const{control:l,value:c,disabled:f,checked:h,required:m,setControl:b,setChecked:g,hasConsumerStoppedPropagationRef:x,isFormControl:w,bubbleInput:E}=zv(ZN,e),S=nt(i,b),C=v.useRef(h);return v.useEffect(()=>{const N=l==null?void 0:l.form;if(N){const A=()=>g(C.current);return N.addEventListener("reset",A),()=>N.removeEventListener("reset",A)}},[l,g]),d.jsx(Pe.button,{type:"button",role:"checkbox","aria-checked":rs(h)?"mixed":h,"aria-required":m,"data-state":sC(h),"data-disabled":f?"":void 0,disabled:f,value:c,...a,ref:S,onKeyDown:be(t,N=>{N.key==="Enter"&&N.preventDefault()}),onClick:be(n,N=>{g(A=>rs(A)?!0:!A),E&&w&&(x.current=N.isPropagationStopped(),x.current||N.stopPropagation())})})});eC.displayName=ZN;var Iv=v.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:a,checked:i,defaultChecked:l,required:c,disabled:f,value:h,onCheckedChange:m,form:b,...g}=e;return d.jsx(C$,{__scopeCheckbox:n,checked:i,defaultChecked:l,disabled:f,required:c,onCheckedChange:m,name:a,form:b,value:h,internal_do_not_use_render:({isFormControl:x})=>d.jsxs(d.Fragment,{children:[d.jsx(eC,{...g,ref:t,__scopeCheckbox:n}),x&&d.jsx(aC,{__scopeCheckbox:n})]})})});Iv.displayName=Af;var tC="CheckboxIndicator",nC=v.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:a,...i}=e,l=zv(tC,n);return d.jsx(bn,{present:a||rs(l.checked)||l.checked===!0,children:d.jsx(Pe.span,{"data-state":sC(l.checked),"data-disabled":l.disabled?"":void 0,...i,ref:t,style:{pointerEvents:"none",...e.style}})})});nC.displayName=tC;var rC="CheckboxBubbleInput",aC=v.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:a,hasConsumerStoppedPropagationRef:i,checked:l,defaultChecked:c,required:f,disabled:h,name:m,value:b,form:g,bubbleInput:x,setBubbleInput:w}=zv(rC,e),E=nt(n,w),S=Lv(l),C=gv(a);v.useEffect(()=>{const A=x;if(!A)return;const T=window.HTMLInputElement.prototype,$=Object.getOwnPropertyDescriptor(T,"checked").set,L=!i.current;if(S!==l&&$){const P=new Event("click",{bubbles:L});A.indeterminate=rs(l),$.call(A,rs(l)?!1:l),A.dispatchEvent(P)}},[x,S,l,i]);const N=v.useRef(rs(l)?!1:l);return d.jsx(Pe.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??N.current,required:f,disabled:h,name:m,value:b,form:g,...t,tabIndex:-1,ref:E,style:{...t.style,...C,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});aC.displayName=rC;function j$(e){return typeof e=="function"}function rs(e){return e==="indeterminate"}function sC(e){return rs(e)?"indeterminate":e?"checked":"unchecked"}const iC=v.forwardRef(({className:e,...t},n)=>d.jsx(Iv,{ref:n,className:xe("grid place-content-center peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow cursor-pointer focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:d.jsx(nC,{className:xe("grid place-content-center text-current"),children:d.jsx(Hr,{className:"h-4 w-4"})})}));iC.displayName=Iv.displayName;function _g(e,[t,n]){return Math.min(n,Math.max(t,e))}function T$(e){const t=R$(e),n=v.forwardRef((a,i)=>{const{children:l,...c}=a,f=v.Children.toArray(l),h=f.find(k$);if(h){const m=h.props.children,b=f.map(g=>g===h?v.Children.count(m)>1?v.Children.only(null):v.isValidElement(m)?m.props.children:null:g);return d.jsx(t,{...c,ref:i,children:v.isValidElement(m)?v.cloneElement(m,void 0,b):null})}return d.jsx(t,{...c,ref:i,children:l})});return n.displayName=`${e}.Slot`,n}function R$(e){const t=v.forwardRef((n,a)=>{const{children:i,...l}=n;if(v.isValidElement(i)){const c=M$(i),f=O$(l,i.props);return i.type!==v.Fragment&&(f.ref=a?wn(a,c):c),v.cloneElement(i,f)}return v.Children.count(i)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var A$=Symbol("radix.slottable");function k$(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===A$}function O$(e,t){const n={...t};for(const a in t){const i=e[a],l=t[a];/^on[A-Z]/.test(a)?i&&l?n[a]=(...f)=>{const h=l(...f);return i(...f),h}:i&&(n[a]=i):a==="style"?n[a]={...i,...l}:a==="className"&&(n[a]=[i,l].filter(Boolean).join(" "))}return{...e,...n}}function M$(e){var a,i;let t=(a=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var oC=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),D$="VisuallyHidden",P$=v.forwardRef((e,t)=>d.jsx(Pe.span,{...e,ref:t,style:{...oC,...e.style}}));P$.displayName=D$;var L$=[" ","Enter","ArrowUp","ArrowDown"],z$=[" ","Enter"],Js="Select",[kf,Of,I$]=cv(Js),[Ao]=ur(Js,[I$,Ro]),Mf=Ro(),[$$,fs]=Ao(Js),[U$,B$]=Ao(Js),lC=e=>{const{__scopeSelect:t,children:n,open:a,defaultOpen:i,onOpenChange:l,value:c,defaultValue:f,onValueChange:h,dir:m,name:b,autoComplete:g,disabled:x,required:w,form:E}=e,S=Mf(t),[C,N]=v.useState(null),[A,T]=v.useState(null),[M,$]=v.useState(!1),L=lc(m),[P,U]=ga({prop:a,defaultProp:i??!1,onChange:l,caller:Js}),[J,ce]=ga({prop:c,defaultProp:f,onChange:h,caller:Js}),re=v.useRef(null),me=C?E||!!C.closest("form"):!0,[fe,ge]=v.useState(new Set),de=Array.from(fe).map(k=>k.props.value).join(";");return d.jsx(bv,{...S,children:d.jsxs($$,{required:w,scope:t,trigger:C,onTriggerChange:N,valueNode:A,onValueNodeChange:T,valueNodeHasChildren:M,onValueNodeHasChildrenChange:$,contentId:pn(),value:J,onValueChange:ce,open:P,onOpenChange:U,dir:L,triggerPointerDownPosRef:re,disabled:x,children:[d.jsx(kf.Provider,{scope:t,children:d.jsx(U$,{scope:e.__scopeSelect,onNativeOptionAdd:v.useCallback(k=>{ge(K=>new Set(K).add(k))},[]),onNativeOptionRemove:v.useCallback(k=>{ge(K=>{const F=new Set(K);return F.delete(k),F})},[]),children:n})}),me?d.jsxs(OC,{"aria-hidden":!0,required:w,tabIndex:-1,name:b,autoComplete:g,value:J,onChange:k=>ce(k.target.value),disabled:x,form:E,children:[J===void 0?d.jsx("option",{value:""}):null,Array.from(fe)]},de):null]})})};lC.displayName=Js;var cC="SelectTrigger",uC=v.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:a=!1,...i}=e,l=Mf(n),c=fs(cC,n),f=c.disabled||a,h=nt(t,c.onTriggerChange),m=Of(n),b=v.useRef("touch"),[g,x,w]=DC(S=>{const C=m().filter(T=>!T.disabled),N=C.find(T=>T.value===c.value),A=PC(C,S,N);A!==void 0&&c.onValueChange(A.value)}),E=S=>{f||(c.onOpenChange(!0),w()),S&&(c.triggerPointerDownPosRef.current={x:Math.round(S.pageX),y:Math.round(S.pageY)})};return d.jsx(bf,{asChild:!0,...l,children:d.jsx(Pe.button,{type:"button",role:"combobox","aria-controls":c.contentId,"aria-expanded":c.open,"aria-required":c.required,"aria-autocomplete":"none",dir:c.dir,"data-state":c.open?"open":"closed",disabled:f,"data-disabled":f?"":void 0,"data-placeholder":MC(c.value)?"":void 0,...i,ref:h,onClick:be(i.onClick,S=>{S.currentTarget.focus(),b.current!=="mouse"&&E(S)}),onPointerDown:be(i.onPointerDown,S=>{b.current=S.pointerType;const C=S.target;C.hasPointerCapture(S.pointerId)&&C.releasePointerCapture(S.pointerId),S.button===0&&S.ctrlKey===!1&&S.pointerType==="mouse"&&(E(S),S.preventDefault())}),onKeyDown:be(i.onKeyDown,S=>{const C=g.current!=="";!(S.ctrlKey||S.altKey||S.metaKey)&&S.key.length===1&&x(S.key),!(C&&S.key===" ")&&L$.includes(S.key)&&(E(),S.preventDefault())})})})});uC.displayName=cC;var dC="SelectValue",fC=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:a,style:i,children:l,placeholder:c="",...f}=e,h=fs(dC,n),{onValueNodeHasChildrenChange:m}=h,b=l!==void 0,g=nt(t,h.onValueNodeChange);return Yt(()=>{m(b)},[m,b]),d.jsx(Pe.span,{...f,ref:g,style:{pointerEvents:"none"},children:MC(h.value)?d.jsx(d.Fragment,{children:c}):l})});fC.displayName=dC;var H$="SelectIcon",hC=v.forwardRef((e,t)=>{const{__scopeSelect:n,children:a,...i}=e;return d.jsx(Pe.span,{"aria-hidden":!0,...i,ref:t,children:a||"▼"})});hC.displayName=H$;var q$="SelectPortal",mC=e=>d.jsx(fc,{asChild:!0,...e});mC.displayName=q$;var Qs="SelectContent",pC=v.forwardRef((e,t)=>{const n=fs(Qs,e.__scopeSelect),[a,i]=v.useState();if(Yt(()=>{i(new DocumentFragment)},[]),!n.open){const l=a;return l?ac.createPortal(d.jsx(gC,{scope:e.__scopeSelect,children:d.jsx(kf.Slot,{scope:e.__scopeSelect,children:d.jsx("div",{children:e.children})})}),l):null}return d.jsx(vC,{...e,ref:t})});pC.displayName=Qs;var yr=10,[gC,hs]=Ao(Qs),V$="SelectContentImpl",F$=T$("SelectContent.RemoveScroll"),vC=v.forwardRef((e,t)=>{const{__scopeSelect:n,position:a="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:l,onPointerDownOutside:c,side:f,sideOffset:h,align:m,alignOffset:b,arrowPadding:g,collisionBoundary:x,collisionPadding:w,sticky:E,hideWhenDetached:S,avoidCollisions:C,...N}=e,A=fs(Qs,n),[T,M]=v.useState(null),[$,L]=v.useState(null),P=nt(t,te=>M(te)),[U,J]=v.useState(null),[ce,re]=v.useState(null),me=Of(n),[fe,ge]=v.useState(!1),de=v.useRef(!1);v.useEffect(()=>{if(T)return wf(T)},[T]),mf();const k=v.useCallback(te=>{const[Q,...se]=me().map(Ne=>Ne.ref.current),[je]=se.slice(-1),ze=document.activeElement;for(const Ne of te)if(Ne===ze||(Ne==null||Ne.scrollIntoView({block:"nearest"}),Ne===Q&&$&&($.scrollTop=0),Ne===je&&$&&($.scrollTop=$.scrollHeight),Ne==null||Ne.focus(),document.activeElement!==ze))return},[me,$]),K=v.useCallback(()=>k([U,T]),[k,U,T]);v.useEffect(()=>{fe&&K()},[fe,K]);const{onOpenChange:F,triggerPointerDownPosRef:Y}=A;v.useEffect(()=>{if(T){let te={x:0,y:0};const Q=je=>{var ze,Ne;te={x:Math.abs(Math.round(je.pageX)-(((ze=Y.current)==null?void 0:ze.x)??0)),y:Math.abs(Math.round(je.pageY)-(((Ne=Y.current)==null?void 0:Ne.y)??0))}},se=je=>{te.x<=10&&te.y<=10?je.preventDefault():T.contains(je.target)||F(!1),document.removeEventListener("pointermove",Q),Y.current=null};return Y.current!==null&&(document.addEventListener("pointermove",Q),document.addEventListener("pointerup",se,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Q),document.removeEventListener("pointerup",se,{capture:!0})}}},[T,F,Y]),v.useEffect(()=>{const te=()=>F(!1);return window.addEventListener("blur",te),window.addEventListener("resize",te),()=>{window.removeEventListener("blur",te),window.removeEventListener("resize",te)}},[F]);const[V,R]=DC(te=>{const Q=me().filter(ze=>!ze.disabled),se=Q.find(ze=>ze.ref.current===document.activeElement),je=PC(Q,te,se);je&&setTimeout(()=>je.ref.current.focus())}),O=v.useCallback((te,Q,se)=>{const je=!de.current&&!se;(A.value!==void 0&&A.value===Q||je)&&(J(te),je&&(de.current=!0))},[A.value]),I=v.useCallback(()=>T==null?void 0:T.focus(),[T]),H=v.useCallback((te,Q,se)=>{const je=!de.current&&!se;(A.value!==void 0&&A.value===Q||je)&&re(te)},[A.value]),q=a==="popper"?Sg:yC,ee=q===Sg?{side:f,sideOffset:h,align:m,alignOffset:b,arrowPadding:g,collisionBoundary:x,collisionPadding:w,sticky:E,hideWhenDetached:S,avoidCollisions:C}:{};return d.jsx(gC,{scope:n,content:T,viewport:$,onViewportChange:L,itemRefCallback:O,selectedItem:U,onItemLeave:I,itemTextRefCallback:H,focusSelectedItem:K,selectedItemText:ce,position:a,isPositioned:fe,searchRef:V,children:d.jsx(mc,{as:F$,allowPinchZoom:!0,children:d.jsx(uc,{asChild:!0,trapped:A.open,onMountAutoFocus:te=>{te.preventDefault()},onUnmountAutoFocus:be(i,te=>{var Q;(Q=A.trigger)==null||Q.focus({preventScroll:!0}),te.preventDefault()}),children:d.jsx(cc,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:te=>te.preventDefault(),onDismiss:()=>A.onOpenChange(!1),children:d.jsx(q,{role:"listbox",id:A.contentId,"data-state":A.open?"open":"closed",dir:A.dir,onContextMenu:te=>te.preventDefault(),...N,...ee,onPlaced:()=>ge(!0),ref:P,style:{display:"flex",flexDirection:"column",outline:"none",...N.style},onKeyDown:be(N.onKeyDown,te=>{const Q=te.ctrlKey||te.altKey||te.metaKey;if(te.key==="Tab"&&te.preventDefault(),!Q&&te.key.length===1&&R(te.key),["ArrowUp","ArrowDown","Home","End"].includes(te.key)){let je=me().filter(ze=>!ze.disabled).map(ze=>ze.ref.current);if(["ArrowUp","End"].includes(te.key)&&(je=je.slice().reverse()),["ArrowUp","ArrowDown"].includes(te.key)){const ze=te.target,Ne=je.indexOf(ze);je=je.slice(Ne+1)}setTimeout(()=>k(je)),te.preventDefault()}})})})})})})});vC.displayName=V$;var G$="SelectItemAlignedPosition",yC=v.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:a,...i}=e,l=fs(Qs,n),c=hs(Qs,n),[f,h]=v.useState(null),[m,b]=v.useState(null),g=nt(t,P=>b(P)),x=Of(n),w=v.useRef(!1),E=v.useRef(!0),{viewport:S,selectedItem:C,selectedItemText:N,focusSelectedItem:A}=c,T=v.useCallback(()=>{if(l.trigger&&l.valueNode&&f&&m&&S&&C&&N){const P=l.trigger.getBoundingClientRect(),U=m.getBoundingClientRect(),J=l.valueNode.getBoundingClientRect(),ce=N.getBoundingClientRect();if(l.dir!=="rtl"){const ze=ce.left-U.left,Ne=J.left-ze,ne=P.left-Ne,Me=P.width+ne,Je=Math.max(Me,U.width),ie=window.innerWidth-yr,De=_g(Ne,[yr,Math.max(yr,ie-Je)]);f.style.minWidth=Me+"px",f.style.left=De+"px"}else{const ze=U.right-ce.right,Ne=window.innerWidth-J.right-ze,ne=window.innerWidth-P.right-Ne,Me=P.width+ne,Je=Math.max(Me,U.width),ie=window.innerWidth-yr,De=_g(Ne,[yr,Math.max(yr,ie-Je)]);f.style.minWidth=Me+"px",f.style.right=De+"px"}const re=x(),me=window.innerHeight-yr*2,fe=S.scrollHeight,ge=window.getComputedStyle(m),de=parseInt(ge.borderTopWidth,10),k=parseInt(ge.paddingTop,10),K=parseInt(ge.borderBottomWidth,10),F=parseInt(ge.paddingBottom,10),Y=de+k+fe+F+K,V=Math.min(C.offsetHeight*5,Y),R=window.getComputedStyle(S),O=parseInt(R.paddingTop,10),I=parseInt(R.paddingBottom,10),H=P.top+P.height/2-yr,q=me-H,ee=C.offsetHeight/2,te=C.offsetTop+ee,Q=de+k+te,se=Y-Q;if(Q<=H){const ze=re.length>0&&C===re[re.length-1].ref.current;f.style.bottom="0px";const Ne=m.clientHeight-S.offsetTop-S.offsetHeight,ne=Math.max(q,ee+(ze?I:0)+Ne+K),Me=Q+ne;f.style.height=Me+"px"}else{const ze=re.length>0&&C===re[0].ref.current;f.style.top="0px";const ne=Math.max(H,de+S.offsetTop+(ze?O:0)+ee)+se;f.style.height=ne+"px",S.scrollTop=Q-H+S.offsetTop}f.style.margin=`${yr}px 0`,f.style.minHeight=V+"px",f.style.maxHeight=me+"px",a==null||a(),requestAnimationFrame(()=>w.current=!0)}},[x,l.trigger,l.valueNode,f,m,S,C,N,l.dir,a]);Yt(()=>T(),[T]);const[M,$]=v.useState();Yt(()=>{m&&$(window.getComputedStyle(m).zIndex)},[m]);const L=v.useCallback(P=>{P&&E.current===!0&&(T(),A==null||A(),E.current=!1)},[T,A]);return d.jsx(W$,{scope:n,contentWrapper:f,shouldExpandOnScrollRef:w,onScrollButtonChange:L,children:d.jsx("div",{ref:h,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:M},children:d.jsx(Pe.div,{...i,ref:g,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});yC.displayName=G$;var K$="SelectPopperPosition",Sg=v.forwardRef((e,t)=>{const{__scopeSelect:n,align:a="start",collisionPadding:i=yr,...l}=e,c=Mf(n);return d.jsx(xv,{...c,...l,ref:t,align:a,collisionPadding:i,style:{boxSizing:"border-box",...l.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Sg.displayName=K$;var[W$,$v]=Ao(Qs,{}),Eg="SelectViewport",bC=v.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:a,...i}=e,l=hs(Eg,n),c=$v(Eg,n),f=nt(t,l.onViewportChange),h=v.useRef(0);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),d.jsx(kf.Slot,{scope:n,children:d.jsx(Pe.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:f,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:be(i.onScroll,m=>{const b=m.currentTarget,{contentWrapper:g,shouldExpandOnScrollRef:x}=c;if(x!=null&&x.current&&g){const w=Math.abs(h.current-b.scrollTop);if(w>0){const E=window.innerHeight-yr*2,S=parseFloat(g.style.minHeight),C=parseFloat(g.style.height),N=Math.max(S,C);if(N<E){const A=N+w,T=Math.min(E,A),M=A-T;g.style.height=T+"px",g.style.bottom==="0px"&&(b.scrollTop=M>0?M:0,g.style.justifyContent="flex-end")}}}h.current=b.scrollTop})})})]})});bC.displayName=Eg;var xC="SelectGroup",[Y$,X$]=Ao(xC),J$=v.forwardRef((e,t)=>{const{__scopeSelect:n,...a}=e,i=pn();return d.jsx(Y$,{scope:n,id:i,children:d.jsx(Pe.div,{role:"group","aria-labelledby":i,...a,ref:t})})});J$.displayName=xC;var wC="SelectLabel",_C=v.forwardRef((e,t)=>{const{__scopeSelect:n,...a}=e,i=X$(wC,n);return d.jsx(Pe.div,{id:i.id,...a,ref:t})});_C.displayName=wC;var Gd="SelectItem",[Q$,SC]=Ao(Gd),EC=v.forwardRef((e,t)=>{const{__scopeSelect:n,value:a,disabled:i=!1,textValue:l,...c}=e,f=fs(Gd,n),h=hs(Gd,n),m=f.value===a,[b,g]=v.useState(l??""),[x,w]=v.useState(!1),E=nt(t,A=>{var T;return(T=h.itemRefCallback)==null?void 0:T.call(h,A,a,i)}),S=pn(),C=v.useRef("touch"),N=()=>{i||(f.onValueChange(a),f.onOpenChange(!1))};if(a==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return d.jsx(Q$,{scope:n,value:a,disabled:i,textId:S,isSelected:m,onItemTextChange:v.useCallback(A=>{g(T=>T||((A==null?void 0:A.textContent)??"").trim())},[]),children:d.jsx(kf.ItemSlot,{scope:n,value:a,disabled:i,textValue:b,children:d.jsx(Pe.div,{role:"option","aria-labelledby":S,"data-highlighted":x?"":void 0,"aria-selected":m&&x,"data-state":m?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...c,ref:E,onFocus:be(c.onFocus,()=>w(!0)),onBlur:be(c.onBlur,()=>w(!1)),onClick:be(c.onClick,()=>{C.current!=="mouse"&&N()}),onPointerUp:be(c.onPointerUp,()=>{C.current==="mouse"&&N()}),onPointerDown:be(c.onPointerDown,A=>{C.current=A.pointerType}),onPointerMove:be(c.onPointerMove,A=>{var T;C.current=A.pointerType,i?(T=h.onItemLeave)==null||T.call(h):C.current==="mouse"&&A.currentTarget.focus({preventScroll:!0})}),onPointerLeave:be(c.onPointerLeave,A=>{var T;A.currentTarget===document.activeElement&&((T=h.onItemLeave)==null||T.call(h))}),onKeyDown:be(c.onKeyDown,A=>{var M;((M=h.searchRef)==null?void 0:M.current)!==""&&A.key===" "||(z$.includes(A.key)&&N(),A.key===" "&&A.preventDefault())})})})})});EC.displayName=Gd;var Ol="SelectItemText",NC=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:a,style:i,...l}=e,c=fs(Ol,n),f=hs(Ol,n),h=SC(Ol,n),m=B$(Ol,n),[b,g]=v.useState(null),x=nt(t,N=>g(N),h.onItemTextChange,N=>{var A;return(A=f.itemTextRefCallback)==null?void 0:A.call(f,N,h.value,h.disabled)}),w=b==null?void 0:b.textContent,E=v.useMemo(()=>d.jsx("option",{value:h.value,disabled:h.disabled,children:w},h.value),[h.disabled,h.value,w]),{onNativeOptionAdd:S,onNativeOptionRemove:C}=m;return Yt(()=>(S(E),()=>C(E)),[S,C,E]),d.jsxs(d.Fragment,{children:[d.jsx(Pe.span,{id:h.textId,...l,ref:x}),h.isSelected&&c.valueNode&&!c.valueNodeHasChildren?ac.createPortal(l.children,c.valueNode):null]})});NC.displayName=Ol;var CC="SelectItemIndicator",jC=v.forwardRef((e,t)=>{const{__scopeSelect:n,...a}=e;return SC(CC,n).isSelected?d.jsx(Pe.span,{"aria-hidden":!0,...a,ref:t}):null});jC.displayName=CC;var Ng="SelectScrollUpButton",TC=v.forwardRef((e,t)=>{const n=hs(Ng,e.__scopeSelect),a=$v(Ng,e.__scopeSelect),[i,l]=v.useState(!1),c=nt(t,a.onScrollButtonChange);return Yt(()=>{if(n.viewport&&n.isPositioned){let f=function(){const m=h.scrollTop>0;l(m)};const h=n.viewport;return f(),h.addEventListener("scroll",f),()=>h.removeEventListener("scroll",f)}},[n.viewport,n.isPositioned]),i?d.jsx(AC,{...e,ref:c,onAutoScroll:()=>{const{viewport:f,selectedItem:h}=n;f&&h&&(f.scrollTop=f.scrollTop-h.offsetHeight)}}):null});TC.displayName=Ng;var Cg="SelectScrollDownButton",RC=v.forwardRef((e,t)=>{const n=hs(Cg,e.__scopeSelect),a=$v(Cg,e.__scopeSelect),[i,l]=v.useState(!1),c=nt(t,a.onScrollButtonChange);return Yt(()=>{if(n.viewport&&n.isPositioned){let f=function(){const m=h.scrollHeight-h.clientHeight,b=Math.ceil(h.scrollTop)<m;l(b)};const h=n.viewport;return f(),h.addEventListener("scroll",f),()=>h.removeEventListener("scroll",f)}},[n.viewport,n.isPositioned]),i?d.jsx(AC,{...e,ref:c,onAutoScroll:()=>{const{viewport:f,selectedItem:h}=n;f&&h&&(f.scrollTop=f.scrollTop+h.offsetHeight)}}):null});RC.displayName=Cg;var AC=v.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:a,...i}=e,l=hs("SelectScrollButton",n),c=v.useRef(null),f=Of(n),h=v.useCallback(()=>{c.current!==null&&(window.clearInterval(c.current),c.current=null)},[]);return v.useEffect(()=>()=>h(),[h]),Yt(()=>{var b;const m=f().find(g=>g.ref.current===document.activeElement);(b=m==null?void 0:m.ref.current)==null||b.scrollIntoView({block:"nearest"})},[f]),d.jsx(Pe.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:be(i.onPointerDown,()=>{c.current===null&&(c.current=window.setInterval(a,50))}),onPointerMove:be(i.onPointerMove,()=>{var m;(m=l.onItemLeave)==null||m.call(l),c.current===null&&(c.current=window.setInterval(a,50))}),onPointerLeave:be(i.onPointerLeave,()=>{h()})})}),Z$="SelectSeparator",kC=v.forwardRef((e,t)=>{const{__scopeSelect:n,...a}=e;return d.jsx(Pe.div,{"aria-hidden":!0,...a,ref:t})});kC.displayName=Z$;var jg="SelectArrow",eU=v.forwardRef((e,t)=>{const{__scopeSelect:n,...a}=e,i=Mf(n),l=fs(jg,n),c=hs(jg,n);return l.open&&c.position==="popper"?d.jsx(wv,{...i,...a,ref:t}):null});eU.displayName=jg;var tU="SelectBubbleInput",OC=v.forwardRef(({__scopeSelect:e,value:t,...n},a)=>{const i=v.useRef(null),l=nt(a,i),c=Lv(t);return v.useEffect(()=>{const f=i.current;if(!f)return;const h=window.HTMLSelectElement.prototype,b=Object.getOwnPropertyDescriptor(h,"value").set;if(c!==t&&b){const g=new Event("change",{bubbles:!0});b.call(f,t),f.dispatchEvent(g)}},[c,t]),d.jsx(Pe.select,{...n,style:{...oC,...n.style},ref:l,defaultValue:t})});OC.displayName=tU;function MC(e){return e===""||e===void 0}function DC(e){const t=an(e),n=v.useRef(""),a=v.useRef(0),i=v.useCallback(c=>{const f=n.current+c;t(f),(function h(m){n.current=m,window.clearTimeout(a.current),m!==""&&(a.current=window.setTimeout(()=>h(""),1e3))})(f)},[t]),l=v.useCallback(()=>{n.current="",window.clearTimeout(a.current)},[]);return v.useEffect(()=>()=>window.clearTimeout(a.current),[]),[n,i,l]}function PC(e,t,n){const i=t.length>1&&Array.from(t).every(m=>m===t[0])?t[0]:t,l=n?e.indexOf(n):-1;let c=nU(e,Math.max(l,0));i.length===1&&(c=c.filter(m=>m!==n));const h=c.find(m=>m.textValue.toLowerCase().startsWith(i.toLowerCase()));return h!==n?h:void 0}function nU(e,t){return e.map((n,a)=>e[(t+a)%e.length])}var rU=lC,LC=uC,aU=fC,sU=hC,iU=mC,zC=pC,oU=bC,IC=_C,$C=EC,lU=NC,cU=jC,UC=TC,BC=RC,HC=kC;const uU=rU,dU=aU,qC=v.forwardRef(({className:e,children:t,...n},a)=>d.jsxs(LC,{ref:a,className:xe("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background cursor-pointer data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,d.jsx(sU,{asChild:!0,children:d.jsx(sv,{className:"h-4 w-4 opacity-50"})})]}));qC.displayName=LC.displayName;const VC=v.forwardRef(({className:e,...t},n)=>d.jsx(UC,{ref:n,className:xe("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(g3,{className:"h-4 w-4"})}));VC.displayName=UC.displayName;const FC=v.forwardRef(({className:e,...t},n)=>d.jsx(BC,{ref:n,className:xe("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(sv,{className:"h-4 w-4"})}));FC.displayName=BC.displayName;const GC=v.forwardRef(({className:e,children:t,position:n="popper",...a},i)=>d.jsx(iU,{children:d.jsxs(zC,{ref:i,className:xe("relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-select-content-transform-origin)",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...a,children:[d.jsx(VC,{}),d.jsx(oU,{className:xe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),d.jsx(FC,{})]})}));GC.displayName=zC.displayName;const fU=v.forwardRef(({className:e,...t},n)=>d.jsx(IC,{ref:n,className:xe("px-2 py-1.5 text-sm font-semibold",e),...t}));fU.displayName=IC.displayName;const Tg=v.forwardRef(({className:e,children:t,...n},a)=>d.jsxs($C,{ref:a,className:xe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[d.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:d.jsx(cU,{children:d.jsx(Hr,{className:"h-4 w-4"})})}),d.jsx(lU,{children:t})]}));Tg.displayName=$C.displayName;const hU=v.forwardRef(({className:e,...t},n)=>d.jsx(HC,{ref:n,className:xe("-mx-1 my-1 h-px bg-muted",e),...t}));hU.displayName=HC.displayName;var mU=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],pU=mU.reduce((e,t)=>{const n=ic(`Primitive.${t}`),a=v.forwardRef((i,l)=>{const{asChild:c,...f}=i,h=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(h,{...f,ref:l})});return a.displayName=`Primitive.${t}`,{...e,[t]:a}},{}),gU="Separator",U_="horizontal",vU=["horizontal","vertical"],KC=v.forwardRef((e,t)=>{const{decorative:n,orientation:a=U_,...i}=e,l=yU(a)?a:U_,f=n?{role:"none"}:{"aria-orientation":l==="vertical"?l:void 0,role:"separator"};return d.jsx(pU.div,{"data-orientation":l,...f,...i,ref:t})});KC.displayName=gU;function yU(e){return vU.includes(e)}var WC=KC;const Hs=v.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...a},i)=>d.jsx(WC,{ref:i,decorative:n,orientation:t,className:xe("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...a}));Hs.displayName=WC.displayName;function bU({value:e,onChange:t}){return d.jsx("div",{className:"flex flex-wrap gap-2",children:wg.map(n=>d.jsx("button",{type:"button",onClick:()=>t(n.id),title:n.name,className:xe("w-9 h-9 rounded-full flex items-center justify-center transition-all ring-offset-2 ring-offset-background hover:scale-110",e===n.id&&"ring-2 ring-foreground/40 scale-110"),style:{backgroundColor:n.hex},children:e===n.id&&d.jsx(Hr,{className:"w-4 h-4 text-white drop-shadow"})},n.id))})}function B_({label:e,prefix:t,links:n,onChange:a,readOnly:i,emptyText:l}){const[c,f]=v.useState(""),h=()=>{const g=c.trim();g&&(a([...n,g]),f(""))},m=(g,x)=>a(n.map((w,E)=>E===g?x:w)),b=g=>a(n.filter((x,w)=>w!==g));return d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("span",{className:"text-sm font-medium text-foreground",children:[e," ",t&&d.jsxs("span",{className:"text-xs text-muted-foreground font-normal",children:["(",t,")"]})]}),d.jsx("span",{className:"text-xs text-muted-foreground",children:n.length})]}),n.length===0&&d.jsx("p",{className:"text-xs text-muted-foreground italic px-1",children:l??"Sin links aún"}),d.jsx("div",{className:"space-y-1.5",children:n.map((g,x)=>d.jsxs("div",{className:"group flex items-center gap-1.5",children:[d.jsxs("div",{className:"flex-shrink-0 w-7 h-7 rounded-md bg-accent flex items-center justify-center text-[10px] font-semibold text-accent-foreground",children:[t??"·",x+1]}),i?d.jsxs("a",{href:g,target:"_blank",rel:"noreferrer",className:"flex-1 text-sm text-primary hover:underline truncate flex items-center gap-1.5 py-1.5 px-2 rounded-md hover:bg-accent/60 transition-colors",children:[d.jsx(X3,{className:"w-3.5 h-3.5 flex-shrink-0"}),d.jsx("span",{className:"truncate",children:g}),d.jsx(ov,{className:"w-3 h-3 flex-shrink-0 opacity-60"})]}):d.jsxs(d.Fragment,{children:[d.jsx(ot,{value:g,onChange:w=>m(x,w.target.value),placeholder:"https://…",className:"h-9 text-sm"}),d.jsx(Ee,{type:"button",variant:"ghost",size:"icon",className:"h-9 w-9 flex-shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>b(x),children:d.jsx(vo,{className:"w-4 h-4"})})]})]},x))}),!i&&d.jsxs("div",{className:"flex gap-1.5 pt-1",children:[d.jsx(ot,{value:c,onChange:g=>f(g.target.value),onKeyDown:g=>g.key==="Enter"&&(g.preventDefault(),h()),placeholder:"Pegar link y Enter",className:"h-9 text-sm"}),d.jsxs(Ee,{type:"button",variant:"outline",size:"sm",onClick:h,className:"h-9",children:[d.jsx(Ir,{className:"w-4 h-4 mr-1"})," Añadir"]})]})]})}var H_=1,xU=.9,wU=.8,_U=.17,kp=.1,Op=.999,SU=.9999,EU=.99,NU=/[\\\/_+.#"@\[\(\{&]/,CU=/[\\\/_+.#"@\[\(\{&]/g,jU=/[\s-]/,YC=/[\s-]/g;function Rg(e,t,n,a,i,l,c){if(l===t.length)return i===e.length?H_:EU;var f=`${i},${l}`;if(c[f]!==void 0)return c[f];for(var h=a.charAt(l),m=n.indexOf(h,i),b=0,g,x,w,E;m>=0;)g=Rg(e,t,n,a,m+1,l+1,c),g>b&&(m===i?g*=H_:NU.test(e.charAt(m-1))?(g*=wU,w=e.slice(i,m-1).match(CU),w&&i>0&&(g*=Math.pow(Op,w.length))):jU.test(e.charAt(m-1))?(g*=xU,E=e.slice(i,m-1).match(YC),E&&i>0&&(g*=Math.pow(Op,E.length))):(g*=_U,i>0&&(g*=Math.pow(Op,m-i))),e.charAt(m)!==t.charAt(l)&&(g*=SU)),(g<kp&&n.charAt(m-1)===a.charAt(l+1)||a.charAt(l+1)===a.charAt(l)&&n.charAt(m-1)!==a.charAt(l))&&(x=Rg(e,t,n,a,m+1,l+2,c),x*kp>g&&(g=x*kp)),g>b&&(b=g),m=n.indexOf(h,m+1);return c[f]=b,b}function q_(e){return e.toLowerCase().replace(YC," ")}function TU(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Rg(e,t,q_(e),q_(t),0,0,{})}var Nl='[cmdk-group=""]',Mp='[cmdk-group-items=""]',RU='[cmdk-group-heading=""]',XC='[cmdk-item=""]',V_=`${XC}:not([aria-disabled="true"])`,Ag="cmdk-item-select",ao="data-value",AU=(e,t,n)=>TU(e,t,n),JC=v.createContext(void 0),vc=()=>v.useContext(JC),QC=v.createContext(void 0),Uv=()=>v.useContext(QC),ZC=v.createContext(void 0),ej=v.forwardRef((e,t)=>{let n=so(()=>{var O,I;return{search:"",value:(I=(O=e.value)!=null?O:e.defaultValue)!=null?I:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),a=so(()=>new Set),i=so(()=>new Map),l=so(()=>new Map),c=so(()=>new Set),f=tj(e),{label:h,children:m,value:b,onValueChange:g,filter:x,shouldFilter:w,loop:E,disablePointerSelection:S=!1,vimBindings:C=!0,...N}=e,A=pn(),T=pn(),M=pn(),$=v.useRef(null),L=BU();Zs(()=>{if(b!==void 0){let O=b.trim();n.current.value=O,P.emit()}},[b]),Zs(()=>{L(6,fe)},[]);let P=v.useMemo(()=>({subscribe:O=>(c.current.add(O),()=>c.current.delete(O)),snapshot:()=>n.current,setState:(O,I,H)=>{var q,ee,te,Q;if(!Object.is(n.current[O],I)){if(n.current[O]=I,O==="search")me(),ce(),L(1,re);else if(O==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let se=document.getElementById(M);se?se.focus():(q=document.getElementById(A))==null||q.focus()}if(L(7,()=>{var se;n.current.selectedItemId=(se=ge())==null?void 0:se.id,P.emit()}),H||L(5,fe),((ee=f.current)==null?void 0:ee.value)!==void 0){let se=I??"";(Q=(te=f.current).onValueChange)==null||Q.call(te,se);return}}P.emit()}},emit:()=>{c.current.forEach(O=>O())}}),[]),U=v.useMemo(()=>({value:(O,I,H)=>{var q;I!==((q=l.current.get(O))==null?void 0:q.value)&&(l.current.set(O,{value:I,keywords:H}),n.current.filtered.items.set(O,J(I,H)),L(2,()=>{ce(),P.emit()}))},item:(O,I)=>(a.current.add(O),I&&(i.current.has(I)?i.current.get(I).add(O):i.current.set(I,new Set([O]))),L(3,()=>{me(),ce(),n.current.value||re(),P.emit()}),()=>{l.current.delete(O),a.current.delete(O),n.current.filtered.items.delete(O);let H=ge();L(4,()=>{me(),(H==null?void 0:H.getAttribute("id"))===O&&re(),P.emit()})}),group:O=>(i.current.has(O)||i.current.set(O,new Set),()=>{l.current.delete(O),i.current.delete(O)}),filter:()=>f.current.shouldFilter,label:h||e["aria-label"],getDisablePointerSelection:()=>f.current.disablePointerSelection,listId:A,inputId:M,labelId:T,listInnerRef:$}),[]);function J(O,I){var H,q;let ee=(q=(H=f.current)==null?void 0:H.filter)!=null?q:AU;return O?ee(O,n.current.search,I):0}function ce(){if(!n.current.search||f.current.shouldFilter===!1)return;let O=n.current.filtered.items,I=[];n.current.filtered.groups.forEach(q=>{let ee=i.current.get(q),te=0;ee.forEach(Q=>{let se=O.get(Q);te=Math.max(se,te)}),I.push([q,te])});let H=$.current;de().sort((q,ee)=>{var te,Q;let se=q.getAttribute("id"),je=ee.getAttribute("id");return((te=O.get(je))!=null?te:0)-((Q=O.get(se))!=null?Q:0)}).forEach(q=>{let ee=q.closest(Mp);ee?ee.appendChild(q.parentElement===ee?q:q.closest(`${Mp} > *`)):H.appendChild(q.parentElement===H?q:q.closest(`${Mp} > *`))}),I.sort((q,ee)=>ee[1]-q[1]).forEach(q=>{var ee;let te=(ee=$.current)==null?void 0:ee.querySelector(`${Nl}[${ao}="${encodeURIComponent(q[0])}"]`);te==null||te.parentElement.appendChild(te)})}function re(){let O=de().find(H=>H.getAttribute("aria-disabled")!=="true"),I=O==null?void 0:O.getAttribute(ao);P.setState("value",I||void 0)}function me(){var O,I,H,q;if(!n.current.search||f.current.shouldFilter===!1){n.current.filtered.count=a.current.size;return}n.current.filtered.groups=new Set;let ee=0;for(let te of a.current){let Q=(I=(O=l.current.get(te))==null?void 0:O.value)!=null?I:"",se=(q=(H=l.current.get(te))==null?void 0:H.keywords)!=null?q:[],je=J(Q,se);n.current.filtered.items.set(te,je),je>0&&ee++}for(let[te,Q]of i.current)for(let se of Q)if(n.current.filtered.items.get(se)>0){n.current.filtered.groups.add(te);break}n.current.filtered.count=ee}function fe(){var O,I,H;let q=ge();q&&(((O=q.parentElement)==null?void 0:O.firstChild)===q&&((H=(I=q.closest(Nl))==null?void 0:I.querySelector(RU))==null||H.scrollIntoView({block:"nearest"})),q.scrollIntoView({block:"nearest"}))}function ge(){var O;return(O=$.current)==null?void 0:O.querySelector(`${XC}[aria-selected="true"]`)}function de(){var O;return Array.from(((O=$.current)==null?void 0:O.querySelectorAll(V_))||[])}function k(O){let I=de()[O];I&&P.setState("value",I.getAttribute(ao))}function K(O){var I;let H=ge(),q=de(),ee=q.findIndex(Q=>Q===H),te=q[ee+O];(I=f.current)!=null&&I.loop&&(te=ee+O<0?q[q.length-1]:ee+O===q.length?q[0]:q[ee+O]),te&&P.setState("value",te.getAttribute(ao))}function F(O){let I=ge(),H=I==null?void 0:I.closest(Nl),q;for(;H&&!q;)H=O>0?$U(H,Nl):UU(H,Nl),q=H==null?void 0:H.querySelector(V_);q?P.setState("value",q.getAttribute(ao)):K(O)}let Y=()=>k(de().length-1),V=O=>{O.preventDefault(),O.metaKey?Y():O.altKey?F(1):K(1)},R=O=>{O.preventDefault(),O.metaKey?k(0):O.altKey?F(-1):K(-1)};return v.createElement(Pe.div,{ref:t,tabIndex:-1,...N,"cmdk-root":"",onKeyDown:O=>{var I;(I=N.onKeyDown)==null||I.call(N,O);let H=O.nativeEvent.isComposing||O.keyCode===229;if(!(O.defaultPrevented||H))switch(O.key){case"n":case"j":{C&&O.ctrlKey&&V(O);break}case"ArrowDown":{V(O);break}case"p":case"k":{C&&O.ctrlKey&&R(O);break}case"ArrowUp":{R(O);break}case"Home":{O.preventDefault(),k(0);break}case"End":{O.preventDefault(),Y();break}case"Enter":{O.preventDefault();let q=ge();if(q){let ee=new Event(Ag);q.dispatchEvent(ee)}}}}},v.createElement("label",{"cmdk-label":"",htmlFor:U.inputId,id:U.labelId,style:qU},h),Df(e,O=>v.createElement(QC.Provider,{value:P},v.createElement(JC.Provider,{value:U},O))))}),kU=v.forwardRef((e,t)=>{var n,a;let i=pn(),l=v.useRef(null),c=v.useContext(ZC),f=vc(),h=tj(e),m=(a=(n=h.current)==null?void 0:n.forceMount)!=null?a:c==null?void 0:c.forceMount;Zs(()=>{if(!m)return f.item(i,c==null?void 0:c.id)},[m]);let b=nj(i,l,[e.value,e.children,l],e.keywords),g=Uv(),x=is(L=>L.value&&L.value===b.current),w=is(L=>m||f.filter()===!1?!0:L.search?L.filtered.items.get(i)>0:!0);v.useEffect(()=>{let L=l.current;if(!(!L||e.disabled))return L.addEventListener(Ag,E),()=>L.removeEventListener(Ag,E)},[w,e.onSelect,e.disabled]);function E(){var L,P;S(),(P=(L=h.current).onSelect)==null||P.call(L,b.current)}function S(){g.setState("value",b.current,!0)}if(!w)return null;let{disabled:C,value:N,onSelect:A,forceMount:T,keywords:M,...$}=e;return v.createElement(Pe.div,{ref:wn(l,t),...$,id:i,"cmdk-item":"",role:"option","aria-disabled":!!C,"aria-selected":!!x,"data-disabled":!!C,"data-selected":!!x,onPointerMove:C||f.getDisablePointerSelection()?void 0:S,onClick:C?void 0:E},e.children)}),OU=v.forwardRef((e,t)=>{let{heading:n,children:a,forceMount:i,...l}=e,c=pn(),f=v.useRef(null),h=v.useRef(null),m=pn(),b=vc(),g=is(w=>i||b.filter()===!1?!0:w.search?w.filtered.groups.has(c):!0);Zs(()=>b.group(c),[]),nj(c,f,[e.value,e.heading,h]);let x=v.useMemo(()=>({id:c,forceMount:i}),[i]);return v.createElement(Pe.div,{ref:wn(f,t),...l,"cmdk-group":"",role:"presentation",hidden:g?void 0:!0},n&&v.createElement("div",{ref:h,"cmdk-group-heading":"","aria-hidden":!0,id:m},n),Df(e,w=>v.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?m:void 0},v.createElement(ZC.Provider,{value:x},w))))}),MU=v.forwardRef((e,t)=>{let{alwaysRender:n,...a}=e,i=v.useRef(null),l=is(c=>!c.search);return!n&&!l?null:v.createElement(Pe.div,{ref:wn(i,t),...a,"cmdk-separator":"",role:"separator"})}),DU=v.forwardRef((e,t)=>{let{onValueChange:n,...a}=e,i=e.value!=null,l=Uv(),c=is(m=>m.search),f=is(m=>m.selectedItemId),h=vc();return v.useEffect(()=>{e.value!=null&&l.setState("search",e.value)},[e.value]),v.createElement(Pe.input,{ref:t,...a,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":h.listId,"aria-labelledby":h.labelId,"aria-activedescendant":f,id:h.inputId,type:"text",value:i?e.value:c,onChange:m=>{i||l.setState("search",m.target.value),n==null||n(m.target.value)}})}),PU=v.forwardRef((e,t)=>{let{children:n,label:a="Suggestions",...i}=e,l=v.useRef(null),c=v.useRef(null),f=is(m=>m.selectedItemId),h=vc();return v.useEffect(()=>{if(c.current&&l.current){let m=c.current,b=l.current,g,x=new ResizeObserver(()=>{g=requestAnimationFrame(()=>{let w=m.offsetHeight;b.style.setProperty("--cmdk-list-height",w.toFixed(1)+"px")})});return x.observe(m),()=>{cancelAnimationFrame(g),x.unobserve(m)}}},[]),v.createElement(Pe.div,{ref:wn(l,t),...i,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":f,"aria-label":a,id:h.listId},Df(e,m=>v.createElement("div",{ref:wn(c,h.listInnerRef),"cmdk-list-sizer":""},m)))}),LU=v.forwardRef((e,t)=>{let{open:n,onOpenChange:a,overlayClassName:i,contentClassName:l,container:c,...f}=e;return v.createElement(GN,{open:n,onOpenChange:a},v.createElement(KN,{container:c},v.createElement(Dv,{"cmdk-overlay":"",className:i}),v.createElement(Pv,{"aria-label":e.label,"cmdk-dialog":"",className:l},v.createElement(ej,{ref:t,...f}))))}),zU=v.forwardRef((e,t)=>is(n=>n.filtered.count===0)?v.createElement(Pe.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),IU=v.forwardRef((e,t)=>{let{progress:n,children:a,label:i="Loading...",...l}=e;return v.createElement(Pe.div,{ref:t,...l,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Df(e,c=>v.createElement("div",{"aria-hidden":!0},c)))}),zn=Object.assign(ej,{List:PU,Item:kU,Input:DU,Group:OU,Separator:MU,Dialog:LU,Empty:zU,Loading:IU});function $U(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function UU(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function tj(e){let t=v.useRef(e);return Zs(()=>{t.current=e}),t}var Zs=typeof window>"u"?v.useEffect:v.useLayoutEffect;function so(e){let t=v.useRef();return t.current===void 0&&(t.current=e()),t}function is(e){let t=Uv(),n=()=>e(t.snapshot());return v.useSyncExternalStore(t.subscribe,n,n)}function nj(e,t,n,a=[]){let i=v.useRef(),l=vc();return Zs(()=>{var c;let f=(()=>{var m;for(let b of n){if(typeof b=="string")return b.trim();if(typeof b=="object"&&"current"in b)return b.current?(m=b.current.textContent)==null?void 0:m.trim():i.current}})(),h=a.map(m=>m.trim());l.value(e,f,h),(c=t.current)==null||c.setAttribute(ao,f),i.current=f}),i}var BU=()=>{let[e,t]=v.useState(),n=so(()=>new Map);return Zs(()=>{n.current.forEach(a=>a()),n.current=new Map},[e]),(a,i)=>{n.current.set(a,i),t({})}};function HU(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Df({asChild:e,children:t},n){return e&&v.isValidElement(t)?v.cloneElement(HU(t),{ref:t.ref},n(t.props.children)):n(t)}var qU={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Bv=v.forwardRef(({className:e,...t},n)=>d.jsx(zn,{ref:n,className:xe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Bv.displayName=zn.displayName;const Hv=v.forwardRef(({className:e,...t},n)=>d.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[d.jsx(Ws,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),d.jsx(zn.Input,{ref:n,className:xe("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));Hv.displayName=zn.Input.displayName;const qv=v.forwardRef(({className:e,...t},n)=>d.jsx(zn.List,{ref:n,className:xe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));qv.displayName=zn.List.displayName;const Vv=v.forwardRef((e,t)=>d.jsx(zn.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Vv.displayName=zn.Empty.displayName;const Fv=v.forwardRef(({className:e,...t},n)=>d.jsx(zn.Group,{ref:n,className:xe("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Fv.displayName=zn.Group.displayName;const rj=v.forwardRef(({className:e,...t},n)=>d.jsx(zn.Separator,{ref:n,className:xe("-mx-1 h-px bg-border",e),...t}));rj.displayName=zn.Separator.displayName;const Kd=v.forwardRef(({className:e,...t},n)=>d.jsx(zn.Item,{ref:n,className:xe("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",e),...t}));Kd.displayName=zn.Item.displayName;function VU(e){const t=FU(e),n=v.forwardRef((a,i)=>{const{children:l,...c}=a,f=v.Children.toArray(l),h=f.find(KU);if(h){const m=h.props.children,b=f.map(g=>g===h?v.Children.count(m)>1?v.Children.only(null):v.isValidElement(m)?m.props.children:null:g);return d.jsx(t,{...c,ref:i,children:v.isValidElement(m)?v.cloneElement(m,void 0,b):null})}return d.jsx(t,{...c,ref:i,children:l})});return n.displayName=`${e}.Slot`,n}function FU(e){const t=v.forwardRef((n,a)=>{const{children:i,...l}=n;if(v.isValidElement(i)){const c=YU(i),f=WU(l,i.props);return i.type!==v.Fragment&&(f.ref=a?wn(a,c):c),v.cloneElement(i,f)}return v.Children.count(i)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var GU=Symbol("radix.slottable");function KU(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===GU}function WU(e,t){const n={...t};for(const a in t){const i=e[a],l=t[a];/^on[A-Z]/.test(a)?i&&l?n[a]=(...f)=>{const h=l(...f);return i(...f),h}:i&&(n[a]=i):a==="style"?n[a]={...i,...l}:a==="className"&&(n[a]=[i,l].filter(Boolean).join(" "))}return{...e,...n}}function YU(e){var a,i;let t=(a=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Pf="Popover",[aj]=ur(Pf,[Ro]),yc=Ro(),[XU,ms]=aj(Pf),sj=e=>{const{__scopePopover:t,children:n,open:a,defaultOpen:i,onOpenChange:l,modal:c=!1}=e,f=yc(t),h=v.useRef(null),[m,b]=v.useState(!1),[g,x]=ga({prop:a,defaultProp:i??!1,onChange:l,caller:Pf});return d.jsx(bv,{...f,children:d.jsx(XU,{scope:t,contentId:pn(),triggerRef:h,open:g,onOpenChange:x,onOpenToggle:v.useCallback(()=>x(w=>!w),[x]),hasCustomAnchor:m,onCustomAnchorAdd:v.useCallback(()=>b(!0),[]),onCustomAnchorRemove:v.useCallback(()=>b(!1),[]),modal:c,children:n})})};sj.displayName=Pf;var ij="PopoverAnchor",JU=v.forwardRef((e,t)=>{const{__scopePopover:n,...a}=e,i=ms(ij,n),l=yc(n),{onCustomAnchorAdd:c,onCustomAnchorRemove:f}=i;return v.useEffect(()=>(c(),()=>f()),[c,f]),d.jsx(bf,{...l,...a,ref:t})});JU.displayName=ij;var oj="PopoverTrigger",lj=v.forwardRef((e,t)=>{const{__scopePopover:n,...a}=e,i=ms(oj,n),l=yc(n),c=nt(t,i.triggerRef),f=d.jsx(Pe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":hj(i.open),...a,ref:c,onClick:be(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?f:d.jsx(bf,{asChild:!0,...l,children:f})});lj.displayName=oj;var Gv="PopoverPortal",[QU,ZU]=aj(Gv,{forceMount:void 0}),cj=e=>{const{__scopePopover:t,forceMount:n,children:a,container:i}=e,l=ms(Gv,t);return d.jsx(QU,{scope:t,forceMount:n,children:d.jsx(bn,{present:n||l.open,children:d.jsx(fc,{asChild:!0,container:i,children:a})})})};cj.displayName=Gv;var bo="PopoverContent",uj=v.forwardRef((e,t)=>{const n=ZU(bo,e.__scopePopover),{forceMount:a=n.forceMount,...i}=e,l=ms(bo,e.__scopePopover);return d.jsx(bn,{present:a||l.open,children:l.modal?d.jsx(tB,{...i,ref:t}):d.jsx(nB,{...i,ref:t})})});uj.displayName=bo;var eB=VU("PopoverContent.RemoveScroll"),tB=v.forwardRef((e,t)=>{const n=ms(bo,e.__scopePopover),a=v.useRef(null),i=nt(t,a),l=v.useRef(!1);return v.useEffect(()=>{const c=a.current;if(c)return wf(c)},[]),d.jsx(mc,{as:eB,allowPinchZoom:!0,children:d.jsx(dj,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:be(e.onCloseAutoFocus,c=>{var f;c.preventDefault(),l.current||(f=n.triggerRef.current)==null||f.focus()}),onPointerDownOutside:be(e.onPointerDownOutside,c=>{const f=c.detail.originalEvent,h=f.button===0&&f.ctrlKey===!0,m=f.button===2||h;l.current=m},{checkForDefaultPrevented:!1}),onFocusOutside:be(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1})})})}),nB=v.forwardRef((e,t)=>{const n=ms(bo,e.__scopePopover),a=v.useRef(!1),i=v.useRef(!1);return d.jsx(dj,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:l=>{var c,f;(c=e.onCloseAutoFocus)==null||c.call(e,l),l.defaultPrevented||(a.current||(f=n.triggerRef.current)==null||f.focus(),l.preventDefault()),a.current=!1,i.current=!1},onInteractOutside:l=>{var h,m;(h=e.onInteractOutside)==null||h.call(e,l),l.defaultPrevented||(a.current=!0,l.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const c=l.target;((m=n.triggerRef.current)==null?void 0:m.contains(c))&&l.preventDefault(),l.detail.originalEvent.type==="focusin"&&i.current&&l.preventDefault()}})}),dj=v.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:a,onOpenAutoFocus:i,onCloseAutoFocus:l,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:h,onFocusOutside:m,onInteractOutside:b,...g}=e,x=ms(bo,n),w=yc(n);return mf(),d.jsx(uc,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:i,onUnmountAutoFocus:l,children:d.jsx(cc,{asChild:!0,disableOutsidePointerEvents:c,onInteractOutside:b,onEscapeKeyDown:f,onPointerDownOutside:h,onFocusOutside:m,onDismiss:()=>x.onOpenChange(!1),children:d.jsx(xv,{"data-state":hj(x.open),role:"dialog",id:x.contentId,...w,...g,ref:t,style:{...g.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),fj="PopoverClose",rB=v.forwardRef((e,t)=>{const{__scopePopover:n,...a}=e,i=ms(fj,n);return d.jsx(Pe.button,{type:"button",...a,ref:t,onClick:be(e.onClick,()=>i.onOpenChange(!1))})});rB.displayName=fj;var aB="PopoverArrow",sB=v.forwardRef((e,t)=>{const{__scopePopover:n,...a}=e,i=yc(n);return d.jsx(wv,{...i,...a,ref:t})});sB.displayName=aB;function hj(e){return e?"open":"closed"}var iB=sj,oB=lj,lB=cj,mj=uj;const pj=iB,gj=oB,Kv=v.forwardRef(({className:e,align:t="center",sideOffset:n=4,...a},i)=>d.jsx(lB,{children:d.jsx(mj,{ref:i,align:t,sideOffset:n,className:xe("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-popover-content-transform-origin)",e),...a})}));Kv.displayName=mj.displayName;const cB=new RegExp("[\\u0000-\\u001F\\u007F-\\u009F\\u00AD\\u061C\\u180E\\u200B-\\u200F\\u202A-\\u202E\\u2060-\\u206F\\uFEFF]","g");function vj(e){return String(e||"").replace(cB,"").replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function Ae(e){return vj(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").trim()}function Wt(e){const t=vj(e),n=Ae(t);return["republica dominicana","rep dominicana","rep dom","rep dom lizbeth","dominicana"].includes(n)?"Republica Dominicana":t}function at(e){const t=new Map;for(const n of e){const a=Wt(n);if(!a)continue;const i=Ae(a);i&&(t.has(i)||t.set(i,a))}return Array.from(t.values())}function F_(e,t){const n=at(e),a=Wt(t);if(!a)return n;const i=Ae(a);return n.some(c=>Ae(c)===i)?n:[a,...n]}function uB(e){e.preventDefault(),e.stopPropagation(),e.currentTarget.scrollTop+=e.deltaY}function _r({value:e,options:t,onValueChange:n,placeholder:a="Seleccionar…",searchPlaceholder:i="Buscar…",emptyText:l="No hay resultados.",disabled:c=!1,clearLabel:f}){const[h,m]=v.useState(!1),b=v.useMemo(()=>{const x=new Map;for(const w of at(t)){const E=Wt(w),S=Ae(E);!S||x.has(S)||x.set(S,E)}return Array.from(x.values())},[t]),g=v.useMemo(()=>{const x=Ae(e);return b.find(w=>Ae(w)===x)??e},[b,e]);return d.jsxs(pj,{open:h,onOpenChange:m,children:[d.jsx(gj,{asChild:!0,children:d.jsxs(Ee,{type:"button",variant:"outline",role:"combobox","aria-expanded":h,disabled:c,className:xe("h-10 w-full justify-between rounded-md border-border bg-background px-3 font-normal hover:bg-background",!g&&"text-muted-foreground"),children:[d.jsx("span",{className:"truncate",children:g||a}),d.jsx(D1,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),d.jsx(Kv,{align:"start",className:"w-[min(92vw,560px)] min-w-[var(--radix-popover-trigger-width)] p-0",children:d.jsxs(Bv,{children:[d.jsx(Hv,{placeholder:i}),d.jsxs(qv,{className:"overscroll-contain",onWheel:uB,children:[d.jsx(Vv,{children:l}),d.jsxs(Fv,{children:[f&&d.jsxs(d.Fragment,{children:[d.jsxs(Kd,{value:`__clear_${f}`,onSelect:()=>{n(""),m(!1)},children:[d.jsx(Hr,{className:xe("mr-2 h-4 w-4",e?"opacity-0":"opacity-100")}),d.jsx("span",{className:"whitespace-normal break-words font-medium",children:f})]},"__clear__"),b.length>0&&d.jsx(rj,{className:"my-1"})]}),b.map(x=>d.jsxs(Kd,{value:`${Ae(x)} ${x}`,onSelect:()=>{n(x),m(!1)},children:[d.jsx(Hr,{className:xe("mr-2 h-4 w-4",Ae(e)===Ae(x)?"opacity-100":"opacity-0")}),d.jsx("span",{className:"whitespace-normal break-words leading-snug",children:x})]},Ae(x)))]})]})]})})]})}function dB(e){e.preventDefault(),e.stopPropagation(),e.currentTarget.scrollTop+=e.deltaY}function G_(e){return at(e.map(t=>Wt(t)).filter(Boolean))}function kg({values:e,options:t,onValuesChange:n,placeholder:a="Seleccionar…",searchPlaceholder:i="Buscar…",emptyText:l="No hay resultados.",disabled:c=!1,summaryLabel:f="opciones seleccionadas"}){const[h,m]=v.useState(!1),b=v.useMemo(()=>G_(e),[e]),g=v.useMemo(()=>new Set(b.map(N=>Ae(N))),[b]),x=v.useMemo(()=>at([...t,...b].map(N=>Wt(N))),[t,b]),w=v.useMemo(()=>b.length===0?"":b.length<=2?b.join(", "):`${b.length} ${f}`,[b,f]),E=N=>{n(G_(N))},S=N=>{const A=Wt(N),T=Ae(A);if(g.has(T)){E(b.filter(M=>Ae(M)!==T));return}E([...b,A])},C=N=>{const A=Ae(N);E(b.filter(T=>Ae(T)!==A))};return d.jsxs("div",{className:"space-y-2",children:[d.jsxs(pj,{open:h,onOpenChange:m,children:[d.jsx(gj,{asChild:!0,children:d.jsxs(Ee,{type:"button",variant:"outline",role:"combobox","aria-expanded":h,disabled:c,className:xe("min-h-10 w-full justify-between rounded-md border-border bg-background px-3 font-normal hover:bg-background",!w&&"text-muted-foreground"),children:[d.jsx("span",{className:"truncate text-left",children:w||a}),d.jsx(D1,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),d.jsx(Kv,{align:"start",className:"w-[var(--radix-popover-trigger-width)] p-0",children:d.jsxs(Bv,{children:[d.jsx(Hv,{placeholder:i}),d.jsxs(qv,{className:"overscroll-contain",onWheel:dB,children:[d.jsx(Vv,{children:l}),d.jsx(Fv,{children:x.map(N=>{const A=g.has(Ae(N));return d.jsxs(Kd,{value:N,onSelect:()=>S(N),children:[d.jsx(Hr,{className:xe("mr-2 h-4 w-4",A?"opacity-100":"opacity-0")}),d.jsx("span",{className:"truncate",children:N})]},N)})})]})]})})]}),b.length>0&&d.jsx("div",{className:"flex flex-wrap gap-1.5",children:b.map(N=>d.jsxs(sn,{variant:"secondary",className:"gap-1 rounded-full px-2 py-0.5",children:[d.jsx("span",{className:"max-w-[190px] truncate",children:N}),d.jsx("button",{type:"button",onClick:()=>C(N),className:"rounded-full text-muted-foreground transition-colors hover:text-foreground","aria-label":`Quitar ${N}`,children:d.jsx(vo,{className:"h-3 w-3"})})]},N))})]})}const fB="design_final_art",hB="adaptation_final_art",Dn="reference",mB="wmc",pB="wmc_fixed",gB="fixed";function _e(e,t,n,a,i,l){return{id:e,label:t,reference:n,min:a,max:i,hint:l}}function Mn({designHour:e="35 - 50",adaptationHour:t="30",design:n,adaptation:a}){const i=[{id:fB,label:"Diseño + Entregable Arte Final",shortLabel:"Diseño + AF",hourReference:e,levels:n}];return a!=null&&a.length&&i.push({id:hB,label:"Adaptación Arte Final",shortLabel:"Adaptación AF",hourReference:t,levels:a}),i}function ir({id:e,service:t,amount:n,description:a,equivalent:i,observations:l}){const c=[a,i?`Equivalencia CDC: ${i}.`:"",l].filter(Boolean).join(" ");return{id:e,section:mB,category:"Walmart Connect",service:t,notes:c,workTypes:[{id:pB,label:"Tarifa fija WMC",shortLabel:"WMC",hourReference:"35 - 80",levels:[_e(gB,"Precio fijo",`${n} USD`,n,n,l)]}]}}const zl=[{id:"pdv-materiales-basicos",section:"grafico",category:"Materiales de PDV estándar",service:"Cenefas, habladores, danglers, rompetráficos, afiches, backings, rollups, uniformes, piezas WhatsApp/web",notes:"Incluye diseño en alta resolución, troqueles y 3 rondas de cambios. Cambios adicionales pueden agregarse como Otros.",workTypes:Mn({design:[_e("basic","Básico","50 - 80",50,80),_e("intermediate","Intermedio","100 - 150",100,150),_e("advanced","Avanzado","150 - 300",150,300)],adaptation:[_e("basic","Básico","30 - 50",30,50),_e("intermediate","Intermedio","60 - 80",60,80),_e("advanced","Avanzado","100 - 150",100,150)]})},{id:"pdv-promocion-pack",section:"grafico",category:"Promoción en PDV",service:"Quick counter + roll up + mecánica de canje + uniforme (pack 3 a 5 piezas o más)",notes:"Montos por paquete de 3 a 5 piezas. Piezas o solicitudes extra deben agregarse como Otros.",workTypes:Mn({design:[_e("basic","Básico","320 - 500",320,500),_e("intermediate","Intermedio","500 - 700",500,700),_e("advanced","Avanzado","800 - 1000",800,1e3)],adaptation:[_e("basic","Básico","200 - 350",200,350),_e("intermediate","Intermedio","350 - 550",350,550),_e("advanced","Avanzado","600 - 800+",600,800,"Puede superar el rango si el caso lo requiere.")]})},{id:"ooh-gigantografias",section:"grafico",category:"OOH y gigantografías",service:"Vallas, mupies y gigantografías",notes:"Los niveles están asociados a tamaño aproximado: 6m², más de 10m² y más de 20m².",workTypes:Mn({design:[_e("basic","6m² aprox","250 - 350",250,350),_e("intermediate","Más 10m²","400 - 650",400,650),_e("advanced","Más de 20m²","700 - 1100",700,1100)],adaptation:[_e("basic","6m² aprox","100 - 150",100,150),_e("intermediate","Más 10m²","200 - 300",200,300),_e("advanced","Más de 20m²","400 - 600",400,600)]})},{id:"stands-muebles-exhibidores",section:"grafico",category:"Stands, muebles y exhibidores",service:"One Way, cabeceras de góndola, revestimiento de islas y displays básicos",notes:"Incluye diseño en alta resolución, troqueles y 3 rondas de cambios.",workTypes:Mn({design:[_e("basic","Básico","300 - 400",300,400),_e("intermediate","Intermedio","450 - 650",450,650),_e("advanced","Avanzado","700 - 1000",700,1e3)],adaptation:[_e("basic","Básico","200 - 300",200,300),_e("intermediate","Intermedio","300 - 400",300,400),_e("advanced","Avanzado","450 - 600",450,600)]})},{id:"proyectos-especiales-muebles",section:"grafico",category:"Proyectos especiales",service:"Diseño de muebles u otros proyectos especiales con planos estructurales y troqueles desde cero",notes:"Precio por proyecto. Incluye diseño gráfico/estructural, planos, troqueles, conceptualización y 4 rondas de cambios.",workTypes:Mn({design:[_e("project","Precio único","1000 - 1500",1e3,1500)],adaptation:[_e("project","Precio único","600 - 850",600,850)]})},{id:"stands-creativos-eventos",section:"grafico",category:"Proyectos especiales",service:"Stands creativos para ferias/eventos, montaje de eventos especiales y diseños de espacios especiales",notes:"Precio por proyecto. Incluye stand creativo, planos estructurales, visualizaciones 3D y 4 rondas de cambios.",workTypes:Mn({design:[_e("project","Precio único","1500 - 3000",1500,3e3)],adaptation:[_e("project","Precio único","800 - 1200",800,1200)]})},{id:"empaque-simple",section:"grafico",category:"Diseño de empaques",service:"Empaque simple",notes:"Diseño gráfico original para empaques simples sin troqueles complejos.",workTypes:Mn({design:[_e("project","Precio único","700 - 1000",700,1e3)],adaptation:[_e("project","Adaptación / SKU","100 - 300",100,300)]})},{id:"empaque-complejo",section:"grafico",category:"Diseño de empaques",service:"Empaque complejo",notes:"Diseño gráfico y estructural para empaques con troqueles personalizados o formas no convencionales.",workTypes:Mn({design:[_e("project","Precio único","1000 - 1500",1e3,1500)],adaptation:[_e("project","Adaptación / SKU","100 - 300",100,300)]})},{id:"brochures",section:"grafico",category:"Catálogos, brochures y folletos",service:"Brochures",notes:"Incluye diseño y 3 rondas de cambios.",workTypes:Mn({design:[_e("basic","Básico","200 - 400",200,400),_e("intermediate","Intermedio","400 - 600",400,600),_e("advanced","Avanzado","600 - 800",600,800)],adaptation:[_e("basic","Básico","50 - 100",50,100),_e("intermediate","Intermedio","100 - 150",100,150),_e("advanced","Avanzado","150 - 350",150,350)]})},{id:"catalogos-folletos-pagina",section:"grafico",category:"Catálogos, brochures y folletos",service:"Catálogos y folletos (costo por página)",notes:"Costo por página. Incluye diseño y 3 rondas de cambios.",workTypes:Mn({design:[_e("basic","Básico","30 - 60",30,60),_e("intermediate","Intermedio","60 - 90",60,90),_e("advanced","Avanzado","90 - 120",90,120)],adaptation:[_e("basic","Básico","15 - 30",15,30),_e("intermediate","Intermedio","30 - 60",30,60),_e("advanced","Avanzado","60 - 100",60,100)]})},{id:"web-landing",section:"grafico",category:"Páginas web",service:"Landing page o sitio simple hasta 5 páginas",notes:"Sitio web básico con diseño estático, contenido del cliente y hasta 2 rondas de cambios.",workTypes:[{id:Dn,label:"Diseño web",shortLabel:"Web",hourReference:"35 - 50",levels:[_e("project","Precio único","800 - 1500",800,1500)]}]},{id:"web-intermedio",section:"grafico",category:"Páginas web",service:"Sitio corporativo intermedio de 6 a 15 páginas",notes:"Sitio mediano con páginas adicionales y diseño más personalizado. Hasta 3 rondas de cambios.",workTypes:[{id:Dn,label:"Diseño web",shortLabel:"Web",hourReference:"35 - 50",levels:[_e("project","Precio único","2000 - 5000",2e3,5e3)]}]},{id:"web-avanzado",section:"grafico",category:"Páginas web",service:"Sitio avanzado: más de 15 páginas, interactividad o integraciones complejas",notes:"Incluye desarrollo a medida y hasta 5 rondas de cambios.",workTypes:[{id:Dn,label:"Diseño web",shortLabel:"Web",hourReference:"36 - 50",levels:[_e("project","Precio único","4000 - 8000",4e3,8e3)]}]},{id:"retoques-fotograficos",section:"grafico",category:"Otros servicios",service:"Retoques fotográficos",notes:"Incluye 2 rondas de ajustes.",workTypes:Mn({design:[_e("basic","Básico","20 - 40",20,40),_e("intermediate","Intermedio","50 - 100",50,100),_e("advanced","Avanzado","150 - 300",150,300)],adaptation:void 0})},{id:"videos",section:"grafico",category:"Otros servicios",service:"Videos",notes:"Referencia por complejidad del video.",workTypes:Mn({designHour:"35 - 50",design:[_e("basic","Básico","100 - 250",100,250),_e("intermediate","Intermedio","250 - 500",250,500),_e("advanced","Avanzado","500 - 1200",500,1200)]})},{id:"copy-puntual",section:"grafico",category:"Otros servicios",service:"Copy puntual para ADS, tarjetas o comunicaciones sueltas",notes:"Solo copy puntual. Si requiere concepto, presupuestar según proyecto/hora hombre.",workTypes:Mn({designHour:"1 - 25",design:[_e("basic","Básico","100",100,100),_e("intermediate","Intermedio","100 - 200",100,200),_e("advanced","Avanzado","200 - 500",200,500)]})},{id:"render-sencillo",section:"grafico",category:"Otros servicios",service:"Render sencillo de 1 solo plano por unidad",notes:"No aplica para eventos donde hay que conceptualizar el ambiente total.",workTypes:Mn({designHour:"1 - 50",design:[_e("basic","Básico","100",100,100),_e("intermediate","Intermedio","100 - 150",100,150),_e("advanced","Avanzado","150 - 300",150,300)]})},{id:"carnets",section:"grafico",category:"Otros servicios",service:"Carnets",notes:"Referencia especial: diseño base + réplicas. El Director Creativo calcula y escribe el monto final manualmente.",workTypes:[{id:Dn,label:"Referencia manual",shortLabel:"Manual",levels:[_e("base","Diseño base","20 base",20,20),_e("replica","Réplicas","5 por réplica",5,5)]}]},{id:"identidad-basica",section:"estrategia",category:"Desarrollo de Identidad Gráfica para Marca",service:"Desarrollo básico para pequeñas marcas o emprendimientos",notes:"Incluye logo, paleta, tipografía, identidad visual básica, hasta 2 conceptos y 3 rondas de cambios.",workTypes:[{id:Dn,label:"Tarifa fija",shortLabel:"Fija",levels:[_e("project","Básico","2000 - 4000",2e3,4e3)]}]},{id:"identidad-intermedia",section:"estrategia",category:"Desarrollo de Identidad Gráfica para Marca",service:"Desarrollo intermedio para marcas medianas",notes:"Incluye nombre si aplica, logotipo, paleta, tipografía, key visuals y manual de marca detallado.",workTypes:[{id:Dn,label:"Tarifa fija",shortLabel:"Fija",levels:[_e("project","Intermedio","4000 - 8000",4e3,8e3)]}]},{id:"identidad-avanzada",section:"estrategia",category:"Desarrollo de Identidad Gráfica para Marca",service:"Desarrollo avanzado para grandes marcas o redes",notes:"Identidad visual robusta con aplicaciones de marca, investigación, key visuals y manual exhaustivo.",workTypes:[{id:Dn,label:"Tarifa fija",shortLabel:"Fija",levels:[_e("project","Avanzado","8000 - 15000 o más",8e3,15e3)]}]},{id:"campana-key-visual-basica",section:"estrategia",category:"Desarrollo de Campaña Creativa",service:"Concepto y Key Visual básico para campañas pequeñas",notes:"Concepto creativo básico, key visual, línea gráfica y eslogan con aplicaciones limitadas.",workTypes:[{id:Dn,label:"Tarifa fija",shortLabel:"Fija",levels:[_e("project","Básico","2000 - 3000",2e3,3e3)]}]},{id:"campana-creativa-intermedia",section:"estrategia",category:"Desarrollo de Campaña Creativa",service:"Campaña creativa intermedia para lanzamientos medianos",notes:"Concepto creativo completo, key visuals, eslogan y piezas para distintos medios.",workTypes:[{id:Dn,label:"Tarifa fija",shortLabel:"Fija",levels:[_e("project","Intermedio","3000 - 5000",3e3,5e3)]}]},{id:"campana-creativa-avanzada",section:"estrategia",category:"Desarrollo de Campaña Creativa",service:"Campaña creativa avanzada para lanzamientos grandes",notes:"Desarrollo estratégico y creativo de campaña grande con insights, key visuals y múltiples piezas.",workTypes:[{id:Dn,label:"Tarifa fija",shortLabel:"Fija",levels:[_e("project","Avanzado","5000 - 8000 o más",5e3,8e3)]}]},{id:"consultoria-estrategica",section:"estrategia",category:"Desarrollo Estratégico y Conceptual",service:"Consultoría estratégica y desarrollo de concepto",notes:"Investigación de mercado, análisis de competencia, concepto estratégico y alineación con objetivos del cliente.",workTypes:[{id:Dn,label:"Tarifa fija o por hora",shortLabel:"Referencia",levels:[_e("project","Por proyecto","1500 - 3000",1500,3e3),_e("hour","Por hora","100 - 200 por hora",100,200)]}]},{id:"rondas-adicionales-estrategia",section:"estrategia",category:"Adicionales estratégicos",service:"Rondas adicionales de cambios",notes:"Referencia para trabajo adicional en estrategia o creatividad.",workTypes:[{id:Dn,label:"Por hora",shortLabel:"Hora",levels:[_e("hour","Por hora","50 - 150 por hora",50,150)]}]},ir({id:"wmc-uniformes",service:"Uniformes",amount:80,description:"Uniforme completo para personal de impulso en piso (playera/top, jogger, falda, chaleco), con 4 variantes de diseño exploradas.",equivalent:"Materiales de PDV estándar y otros materiales básicos > Uniformes",observations:"Incluye diseño en alta resolución y 3 rondas de cambios."}),ir({id:"wmc-uniformes-supervisor",service:"Uniformes Supervisor",amount:100,description:"Uniforme para supervisor de piso (polo, chumpa/track jacket, camisa formal), con 3 variantes de diseño exploradas.",equivalent:"Materiales de PDV estándar y otros materiales básicos > Uniformes",observations:"Incluye diseño en alta resolución y 3 rondas de cambios."}),ir({id:"wmc-glorificador-mano",service:"Glorificador de mano",amount:150,description:"Exhibidor portátil pequeño para presentar el producto: bandeja iluminada, aro LED, estuche o base acrílica.",equivalent:"Stands, Muebles y Exhibidores > Estándar (Displays básicos)",observations:"Incluye diseño 3D, troqueles y 3 rondas de cambios."}),ir({id:"wmc-carritos-intervenidos",service:"Carritos intervenidos",amount:200,description:"Vinil o calcomanía de marca aplicada a la canasta y al mango del carrito de compras.",equivalent:"Materiales de PDV estándar y otros materiales básicos (análogo a Backings/Rompetráficos)",observations:"Pieza análoga a material gráfico estándar aplicado sobre una superficie existente."}),ir({id:"wmc-dummies-exhibicion",service:"Dummies de exhibición",amount:200,description:"Réplica escultórica a gran escala de pasta y cepillo dental como punto focal decorativo o táctil.",equivalent:"Proyectos especiales > Diseño de muebles / proyectos con planos y troqueles desde cero",observations:"Requiere diseño estructural y visualización 3D; no es solo arte de impresión."}),ir({id:"wmc-photobooth",service:"Photobooth",amount:200,description:"Estructura tipo arco con iluminación LED y espacio fotográfico de marca para activaciones.",equivalent:"Proyectos especiales > Diseño de Stands Creativos para ferias o eventos",observations:"Estructura autoportante con iluminación, ambientación y 4 rondas de cambios."}),ir({id:"wmc-play-station",service:"Play Station",amount:200,description:"Kiosco interactivo con pantalla táctil y mecánica de juego.",equivalent:"Proyectos especiales > Diseño de muebles / proyectos especiales",observations:"Incluye diseño de mueble e interfaz gráfica; el desarrollo funcional del juego se cotiza aparte."}),ir({id:"wmc-isla-wm",service:"Isla WM",amount:150,description:"Mueble isla completo multinivel con iluminación, gráficos y espacio de exhibición de la línea completa de producto.",equivalent:"Proyectos especiales > Diseño de Stands Creativos para ferias o eventos",observations:"Mayor escala y complejidad estructural dentro del set de piezas."}),ir({id:"wmc-exhibicion-especial",service:"Exhibición Especial",amount:250,description:"Propuesta de muebles de exhibición.",equivalent:"Proyectos especiales > Diseño de muebles con planos y troqueles desde cero",observations:"Costo de referencia por concepto; las variantes adicionales se cobran como adicionales."}),ir({id:"wmc-punta-gondola",service:"Punta de góndola",amount:250,description:"Cabecera de góndola personalizada con iluminación, gráficos y espacio para producto.",equivalent:"Proyectos especiales > Diseño de muebles con planos y troqueles desde cero",observations:"Costo de referencia por concepto; las variantes adicionales se cobran como adicionales."}),ir({id:"wmc-estacion-prueba-producto",service:"Estación para prueba de producto",amount:200,description:"Carrito móvil con lavamanos funcional, grifo y desagüe para pruebas de producto en piso.",equivalent:"Proyectos especiales > Diseño de Stands Creativos para ferias o eventos",observations:"La complejidad funcional puede requerir una cotización especial fuera del tarifario estándar."}),ir({id:"wmc-arco-entrada",service:"Arco de entrada",amount:200,description:"Estructura de entrada de tienda a gran formato con iluminación, efecto de niebla y gráficos de marca.",equivalent:"Proyectos especiales > Diseño de Stands Creativos para ferias o eventos",observations:"La instalación en sitio se cotiza aparte."})];function Og(e){return e?e.reference:""}function Ju(e){return e&&typeof e.min=="number"&&typeof e.max=="number"?String((e.min===e.max,e.min)):""}const xo="tablero_cdc_tariff_catalog",Mg="Referencia",yj="Precio único";let Qa={rows:Dg(zl),catalog:zl,source:"fallback",loading:!1,error:null},ho=!1,bd=[],Dp=0;function Pp(){bd.forEach(e=>e())}function K_(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){const t=Number(e.trim());if(Number.isFinite(t))return t}return null}function Il(e){return String(e||"").trim().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function Wv(e,t,n){return[e,t,n].map(Il).filter(Boolean).join("__")}function bj(e){const t=String(e.section||"grafico").trim().toLowerCase()||"grafico",n=String(e.category||"").trim(),a=String(e.service||"").trim(),i=String(e.catalog_item_id||Il(`${t}-${n}-${a}`)).trim(),l=String(e.work_type_label||Mg).trim(),c=String(e.level_label||yj).trim(),f=String(e.work_type_id||Il(l)||Dn).trim(),h=String(e.level_id||Il(c)||"project").trim();return{id:String(e.id||Wv(i,f,h)).trim(),catalog_item_id:i,section:t,category:n,service:a,notes:String(e.notes||"").trim(),work_type_id:f,work_type_label:l,work_type_short_label:String(e.work_type_short_label||l).trim(),hour_reference:String(e.hour_reference||"").trim(),level_id:h,level_label:c,reference:String(e.reference||"").trim(),reference_min:K_(e.reference_min),reference_max:K_(e.reference_max),level_hint:String(e.level_hint||"").trim(),sort_order:Number(e.sort_order||0),is_active:e.is_active!==!1,managed_by:String(e.managed_by||"sheet").trim()||"sheet",created_at:typeof e.created_at=="string"?e.created_at:null,updated_at:typeof e.updated_at=="string"?e.updated_at:null}}function vB(e){const t=new Map,n=new Map,a=e.filter(i=>i.is_active).sort((i,l)=>i.sort_order-l.sort_order||i.category.localeCompare(l.category));for(const i of a){const l=i.catalog_item_id||Il(`${i.section}-${i.category}-${i.service}`);let c=t.get(l);c||(c={id:l,section:i.section,category:i.category,service:i.service,notes:i.notes,workTypes:[]},t.set(l,c),n.set(l,new Map));const f=i.work_type_id||Dn,h=n.get(l);let m=h.get(f);m||(m={id:f,label:i.work_type_label||Mg,shortLabel:i.work_type_short_label||i.work_type_label||Mg,hourReference:i.hour_reference||void 0,levels:[]},h.set(f,m),c.workTypes.push(m));const b={id:i.level_id||"project",label:i.level_label||yj,reference:i.reference||"",min:i.reference_min??void 0,max:i.reference_max??void 0,hint:i.level_hint||void 0};m.levels.some(g=>g.id===b.id)||m.levels.push(b)}return Array.from(t.values())}function Dg(e){const t=[];return e.forEach((n,a)=>{n.workTypes.forEach((i,l)=>{i.levels.forEach((c,f)=>{t.push({id:Wv(n.id,i.id,c.id),catalog_item_id:n.id,section:n.section,category:n.category,service:n.service,notes:n.notes||"",work_type_id:i.id,work_type_label:i.label,work_type_short_label:i.shortLabel,hour_reference:i.hourReference||"",level_id:c.id,level_label:c.label,reference:c.reference,reference_min:c.min??null,reference_max:c.max??null,level_hint:c.hint||"",sort_order:a*1e3+l*100+f,is_active:!0,managed_by:"system"})})})}),t}function xj(e){return Wv(e.catalog_item_id,e.work_type_id,e.level_id)}function yB(e){const t=e instanceof Error?e.message:String(e||"");return t.includes(xo)||t.includes("Could not find the table")||t.includes("relation")||t.includes("does not exist")}async function Wd(e=!1){if(ho&&!e)return Qa;const t=Dp+=1;Qa={...Qa,loading:!0,error:null},Pp();try{const n=await Se.from(xo).select("id, catalog_item_id, section, category, service, notes, work_type_id, work_type_label, work_type_short_label, hour_reference, level_id, level_label, reference, reference_min, reference_max, level_hint, sort_order, is_active, managed_by, created_at, updated_at").order("sort_order",{ascending:!0}).order("category",{ascending:!0});let a=n.data,i=n.error;if(i&&String(i.message||"").includes("managed_by")){const b=await Se.from(xo).select("id, catalog_item_id, section, category, service, notes, work_type_id, work_type_label, work_type_short_label, hour_reference, level_id, level_label, reference, reference_min, reference_max, level_hint, sort_order, is_active, created_at, updated_at").order("sort_order",{ascending:!0}).order("category",{ascending:!0});a=b.data,i=b.error}if(i)throw i;const l=(a||[]).map(b=>bj(b)),c=Dg(zl),f=new Map;c.forEach(b=>f.set(b.id,b)),l.forEach(b=>f.set(b.id,b));const h=Array.from(f.values()).sort((b,g)=>b.sort_order-g.sort_order||b.category.localeCompare(g.category)),m=vB(h);t===Dp&&(Qa={rows:h,catalog:m,source:l.length?"supabase":"fallback",loading:!1,error:l.length?null:"La tabla del tarifario está vacía. Se está usando el tarifario base de la app como respaldo."},ho=!0,Pp())}catch(n){const a=n instanceof Error?n.message:String(n||""),i=yB(n)?"Falta crear la tabla tablero_cdc_tariff_catalog en Supabase. Se está usando el tarifario base de la app como respaldo.":a||"No se pudo cargar el tarifario dinámico.";t===Dp&&(Qa={rows:Dg(zl),catalog:zl,source:"fallback",loading:!1,error:i},ho=!0,Pp())}return Qa}async function bB(e,t){const n=bj(e),a=n.id||xj(n);if(t!=null&&t.catalog_item_id&&(t.category!==n.category||t.service!==n.service||t.notes!==n.notes)){const{error:c}=await Se.from(xo).update({category:n.category,service:n.service,notes:n.notes,managed_by:"app"}).eq("catalog_item_id",t.catalog_item_id);if(c)throw c}const{error:i}=await Se.from(xo).upsert({id:a,catalog_item_id:n.catalog_item_id,section:n.section,category:n.category,service:n.service,notes:n.notes,work_type_id:n.work_type_id,work_type_label:n.work_type_label,work_type_short_label:n.work_type_short_label,hour_reference:n.hour_reference,level_id:n.level_id,level_label:n.level_label,reference:n.reference,reference_min:n.reference_min,reference_max:n.reference_max,level_hint:n.level_hint,sort_order:n.sort_order,is_active:n.is_active,managed_by:"app"},{onConflict:"id"});if(i)throw i;return ho=!1,Wd(!0)}async function xB(e,t){const{error:n}=await Se.from(xo).update({is_active:t,managed_by:"app"}).eq("id",e.id);if(n)throw n;ho=!1,await Wd(!0)}function wj(){const[,e]=v.useState(0);return v.useEffect(()=>{const t=()=>e(n=>n+1);return bd.push(t),!ho&&!Qa.loading&&Wd(),()=>{bd=bd.filter(n=>n!==t)}},[]),{...Qa,refresh:Wd}}const Lf="tablero_cdc_tariff_sections",Pg=[{id:"grafico",name:"Tarifario Gráfico CDC",scope:"general",clientName:"",pricingMode:"guided",allowManual:!0,description:"Diseño gráfico, artes finales, adaptaciones y materiales de punto de venta.",sortOrder:10,isActive:!0},{id:"estrategia",name:"Estrategia y Creatividad",scope:"general",clientName:"",pricingMode:"guided",allowManual:!0,description:"Servicios de estrategia, conceptualización y creatividad.",sortOrder:20,isActive:!0},{id:"wmc",name:"Tarifario Walmart Connect",scope:"client",clientName:"Walmart Connect WMC",pricingMode:"fixed_multi",allowManual:!0,description:"Piezas de precio fijo que aparecen únicamente para Walmart Connect WMC.",sortOrder:100,isActive:!0}];let Za={sections:Pg,loading:!1,error:null,source:"fallback"},mo=!1,xd=[],Lp=0;function zp(){xd.forEach(e=>e())}function Ja(e){return String(e||"").trim().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,70)}function _j(e,t,n=""){const a=Ja(e==="client"&&n||t)||"seccion",i=Date.now().toString(36).slice(-5);return`${e==="client"?"cliente":"general"}-${a}-${i}`}function wB(e){const t=e.scope==="client"?"client":"general",n=e.pricing_mode==="fixed_multi"?"fixed_multi":"guided";return{id:String(e.id||"").trim(),name:String(e.name||"Sección sin nombre").trim(),scope:t,clientName:String(e.client_name||"").trim(),pricingMode:n,allowManual:e.allow_manual!==!1,description:String(e.description||"").trim(),sortOrder:Number(e.sort_order||0),isActive:e.is_active!==!1,createdAt:e.created_at||null,updatedAt:e.updated_at||null}}function _B(e){const t=e instanceof Error?e.message:String(e||"");return t.includes(Lf)||t.includes("Could not find the table")||t.includes("does not exist")||t.includes("relation")}async function Yd(e=!1){if(mo&&!e)return Za;const t=Lp+=1;Za={...Za,loading:!0,error:null},zp();try{const{data:n,error:a}=await Se.from(Lf).select("id, name, scope, client_name, pricing_mode, allow_manual, description, sort_order, is_active, created_at, updated_at").order("sort_order",{ascending:!0}).order("name",{ascending:!0});if(a)throw a;const i=(n||[]).map(wB),l=new Map(Pg.map(f=>[f.id,f]));i.forEach(f=>l.set(f.id,f));const c=Array.from(l.values()).sort((f,h)=>f.sortOrder-h.sortOrder||f.name.localeCompare(h.name));t===Lp&&(Za={sections:c,loading:!1,error:i.length?null:"La tabla de secciones está vacía. Se muestran las secciones base como respaldo.",source:i.length?"supabase":"fallback"},mo=!0,zp())}catch(n){const a=n instanceof Error?n.message:String(n||"");t===Lp&&(Za={sections:Pg,loading:!1,error:_B(n)?"Falta ejecutar el SQL del módulo de tarifario. Se muestran las secciones base como respaldo.":a||"No se pudieron cargar las secciones del tarifario.",source:"fallback"},mo=!0,zp())}return Za}async function SB(e){const t=e.name.trim(),n=e.scope==="client"?e.clientName.trim():"";if(!t)throw new Error("Escribe el nombre de la sección.");if(e.scope==="client"&&!n)throw new Error("Selecciona el cliente del tarifario especial.");const{error:a}=await Se.from(Lf).upsert({id:e.id,name:t,scope:e.scope,client_name:n,pricing_mode:e.scope==="client"?"fixed_multi":"guided",allow_manual:e.allowManual,description:e.description.trim(),sort_order:Number(e.sortOrder||0),is_active:e.isActive},{onConflict:"id"});if(a)throw a;return mo=!1,Yd(!0)}async function EB(e,t){const{error:n}=await Se.from(Lf).update({is_active:t}).eq("id",e.id);if(n)throw n;return mo=!1,Yd(!0)}function Sj(){const[,e]=v.useState(0);return v.useEffect(()=>{const t=()=>e(n=>n+1);return xd.push(t),!mo&&!Za.loading&&Yd(),()=>{xd=xd.filter(n=>n!==t)}},[]),{...Za,refresh:Yd}}function Qu(e){const t=Number(e.replace(/,/g,"").trim());return Number.isFinite(t)?t:0}function Cl(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e||0)}function NB(e){return(e==null?void 0:e.workTypes[0])||null}function W_(e){return(e==null?void 0:e.levels[0])||null}function Ip(e){return e.trim()}function Ej(e){const t=e.workTypes[0]||null,n=(t==null?void 0:t.levels[0])||null;return{workType:t,level:n}}function wd(e){const{level:t}=Ej(e),n=Number((t==null?void 0:t.min)??(t==null?void 0:t.max)??0);return Number.isFinite(n)?n:0}function Nj(e,t){return t.id==="wmc"&&e.source==="tariff"&&(Ae(e.workType)===Ae("Tarifa fija WMC")||Ae(e.category)===Ae("Walmart Connect"))}function $p(e,t){return e.source!=="tariff"?!1:e.tariffSectionId?e.tariffSectionId===t.id:Nj(e,t)}function CB(e,t){const{workType:n,level:a}=Ej(e),i=wd(e);return!n||!a||i<=0?null:{source:"tariff",category:t.name,serviceName:e.service,workType:`Tarifa fija · ${t.name}`,complexityLevel:"Precio fijo",referenceLabel:Og(a),referenceMin:i,referenceMax:i,amount:i,description:e.notes||"",tariffSectionId:t.id,tariffCatalogId:e.id}}function jB({client:e,items:t,onChange:n,loading:a,error:i}){const[l,c]=v.useState("grafico"),[f,h]=v.useState(""),[m,b]=v.useState(""),[g,x]=v.useState(""),[w,E]=v.useState(""),[S,C]=v.useState(""),[N,A]=v.useState(""),[T,M]=v.useState(""),[$,L]=v.useState(""),{catalog:P,loading:U,error:J}=wj(),{sections:ce,loading:re,error:me}=Sj(),fe=v.useMemo(()=>ce.filter(ie=>ie.isActive&&ie.scope==="general"&&ie.pricingMode==="guided"),[ce]),ge=v.useMemo(()=>{const ie=Ae(e);return ie?ce.filter(De=>De.isActive&&De.scope==="client"&&De.pricingMode==="fixed_multi"&&Ae(De.clientName)===ie):[]},[e,ce]),de=ge.length>0,k=fe.find(ie=>ie.id===l)||fe[0]||null;v.useEffect(()=>{!k&&fe.length?c(fe[0].id):k&&k.id!==l&&c(k.id)},[k,fe,l]);const K=v.useMemo(()=>P.filter(ie=>ie.section===(k==null?void 0:k.id)).map(ie=>`${ie.category} · ${ie.service}`),[k==null?void 0:k.id,P]),F=v.useMemo(()=>P.find(ie=>ie.section===(k==null?void 0:k.id)&&`${ie.category} · ${ie.service}`===f)||null,[k==null?void 0:k.id,f,P]),Y=v.useMemo(()=>F&&F.workTypes.find(ie=>ie.id===m)||null,[F,m]),V=v.useMemo(()=>Y&&Y.levels.find(ie=>ie.id===g)||null,[Y,g]),R=t.reduce((ie,De)=>ie+Number(De.amount||0),0),O=()=>{h(""),b(""),x(""),E(""),C("")},I=ie=>{var Xe;const De=fe.find(We=>We.name===ie);c((De==null?void 0:De.id)||((Xe=fe[0])==null?void 0:Xe.id)||""),O()},H=ie=>{h(ie);const De=P.find(Ct=>Ct.section===(k==null?void 0:k.id)&&`${Ct.category} · ${Ct.service}`===ie),Xe=NB(De),We=W_(Xe);b((Xe==null?void 0:Xe.id)||""),x((We==null?void 0:We.id)||""),E(Ju(We)),C("")},q=ie=>{if(!F)return;const De=F.workTypes.find(We=>We.label===ie),Xe=W_(De);b((De==null?void 0:De.id)||""),x((Xe==null?void 0:Xe.id)||""),E(Ju(Xe))},ee=ie=>{if(!Y)return;const De=Y.levels.find(Xe=>Xe.label===ie);x((De==null?void 0:De.id)||""),E(Ju(De))},te=()=>{if(!F||!Y||!V||!k)return;const ie=Qu(w);ie<=0||(n([...t,{source:"tariff",category:F.category,serviceName:F.service,workType:Y.label,complexityLevel:V.label,referenceLabel:Og(V),referenceMin:V.min??null,referenceMax:V.max??null,amount:ie,description:Ip(S),tariffSectionId:k.id,tariffCatalogId:F.id}]),C(""),E(Ju(V)))},Q=(ie,De)=>{const Xe=P.filter(Le=>Le.section===ie.id&&wd(Le)>0),We=t.filter(Le=>$p(Le,ie)),Ct=new Map(We.map(Le=>[Ae(Le.serviceName),Le])),pe=new Map(Xe.map(Le=>[Ae(Le.service),Le])),$e=De.map(Le=>{const ue=Ae(Le);return Ct.get(ue)||(pe.get(ue)?CB(pe.get(ue),ie):null)}).filter(Le=>!!Le),Ke=t.filter(Le=>!$p(Le,ie));n([...Ke,...$e])},se=ge[0]||null,je=!de||ge.some(ie=>ie.allowManual),ze=()=>{const ie=Qu($),De=(se==null?void 0:se.name)||"Otros",Xe=Ip(N)||(se?`Propuesta general ${se.clientName}`:"Otros / costo manual");ie<=0||(n([...t,{source:"manual",category:De,serviceName:Xe,workType:"Manual",complexityLevel:"",referenceLabel:"Monto manual",referenceMin:null,referenceMax:null,amount:ie,description:Ip(T),tariffSectionId:se==null?void 0:se.id}]),A(""),M(""),L(""))},Ne=ie=>{n(t.filter((De,Xe)=>Xe!==ie))},ne=(Y==null?void 0:Y.label)||"",Me=(V==null?void 0:V.label)||"",Je=i||J||me;return d.jsxs("div",{className:"md:col-span-2 rounded-2xl border border-border bg-muted/20 p-4",children:[d.jsxs("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[d.jsxs("div",{className:"flex items-start gap-2.5",children:[d.jsx("span",{className:"mt-0.5 flex h-8 w-8 items-center justify-center rounded-full bg-primary/10 text-primary",children:d.jsx(s3,{className:"h-4 w-4"})}),d.jsxs("div",{children:[d.jsx("h3",{className:"text-sm font-semibold",children:"Tarifario / Estimación interna"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:de?`Este cliente tiene ${ge.length===1?"un tarifario especial":"tarifarios especiales"}. Selecciona piezas o agrega un costo manual.`:"Agrega costos del tarifario general o montos manuales. El total se guarda automáticamente como monto interno del proyecto."})]})]}),d.jsxs("div",{className:"flex w-full flex-shrink-0 items-center justify-between gap-3 rounded-xl border border-primary/20 bg-card px-3 py-2 shadow-sm sm:w-auto",children:[d.jsx("span",{className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary",children:d.jsx(hg,{className:"h-4 w-4"})}),d.jsxs("div",{className:"min-w-0",children:[d.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Total estimado"}),d.jsx("p",{className:"mt-1 whitespace-nowrap text-lg font-semibold leading-none tabular-nums text-primary",children:Cl(R)})]})]})]}),Je&&d.jsxs("div",{className:"mb-3 flex items-start gap-2 rounded-xl border border-amber-300/50 bg-amber-50 px-3 py-2 text-xs text-amber-900",children:[d.jsx(H3,{className:"mt-0.5 h-3.5 w-3.5 flex-shrink-0"}),d.jsx("span",{children:Je})]}),(a||U||re)&&d.jsx("div",{className:"mb-3 rounded-xl border border-border bg-card px-3 py-2 text-xs text-muted-foreground",children:a?"Cargando costos guardados…":"Cargando tarifario…"}),d.jsxs("div",{className:"space-y-4",children:[de?ge.map(ie=>{const De=P.filter(pe=>pe.section===ie.id&&wd(pe)>0),Xe=t.filter(pe=>$p(pe,ie)),We=Xe.map(pe=>pe.serviceName),Ct=Xe.reduce((pe,$e)=>pe+Number($e.amount||0),0);return d.jsxs("div",{className:"space-y-4 rounded-xl border border-primary/20 bg-card p-4",children:[d.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[d.jsxs("div",{children:[d.jsx("p",{className:"text-sm font-medium",children:ie.name}),d.jsx("p",{className:"text-xs text-muted-foreground",children:ie.description||"Selecciona una o varias piezas. Cada pieza se carga una sola vez con su monto fijo."})]}),d.jsx(sn,{className:"w-fit",children:ie.clientName})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Piezas a cotizar"}),d.jsx(kg,{values:We,options:De.map(pe=>pe.service),onValuesChange:pe=>Q(ie,pe),placeholder:"Seleccionar una o varias piezas…",searchPlaceholder:"Buscar pieza…",emptyText:"No se encontró esa pieza en este tarifario.",disabled:U||De.length===0,summaryLabel:"piezas seleccionadas"})]}),d.jsxs("div",{className:"rounded-xl border border-dashed border-border bg-muted/30 p-3",children:[d.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[d.jsx("p",{className:"text-xs font-medium text-foreground",children:"Piezas y montos fijos"}),d.jsxs("p",{className:"text-xs font-semibold text-primary",children:["Subtotal: ",Cl(Ct)]})]}),De.length===0?d.jsx("p",{className:"text-xs text-muted-foreground",children:"Este tarifario todavía no tiene piezas activas. Agrégalas desde el módulo Tarifario."}):d.jsx("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:De.map(pe=>{const $e=We.some(Ke=>Ae(Ke)===Ae(pe.service));return d.jsxs("div",{className:xe("flex items-center justify-between gap-3 rounded-lg border px-2.5 py-2 text-xs",$e?"border-primary/30 bg-primary/10 text-foreground":"border-border bg-card text-muted-foreground"),children:[d.jsx("span",{className:"min-w-0 truncate",children:pe.service}),d.jsx("span",{className:"flex-shrink-0 font-semibold text-foreground",children:Cl(wd(pe))})]},pe.id)})})]})]},ie.id)}):d.jsxs("div",{className:"space-y-4 rounded-xl border border-border bg-card p-4",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsxs("div",{children:[d.jsx("p",{className:"text-sm font-medium",children:"Agregar desde tarifario general"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Referencia flexible. El usuario autorizado decide el monto final."})]}),d.jsx(sn,{variant:"secondary",children:"Tarifario"})]}),d.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Sección"}),d.jsx(_r,{value:(k==null?void 0:k.name)||"",options:fe.map(ie=>ie.name),onValueChange:I,placeholder:"Seleccionar sección…",searchPlaceholder:"Buscar sección…",emptyText:"No hay secciones generales activas."})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Ítem a cobrar"}),d.jsx(_r,{value:f,options:K,onValueChange:H,placeholder:"Seleccionar ítem…",searchPlaceholder:"Buscar ítem…",emptyText:"No se encontró ese ítem.",disabled:!k})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Tipo de trabajo"}),d.jsx(_r,{value:ne,options:(F==null?void 0:F.workTypes.map(ie=>ie.label))||[],onValueChange:q,placeholder:"Seleccionar tipo…",searchPlaceholder:"Buscar tipo…",disabled:!F})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Nivel / referencia"}),d.jsx(_r,{value:Me,options:(Y==null?void 0:Y.levels.map(ie=>ie.label))||[],onValueChange:ee,placeholder:"Seleccionar nivel…",searchPlaceholder:"Buscar nivel…",disabled:!Y})]})]}),F&&Y&&V&&d.jsxs("div",{className:"rounded-xl border border-dashed border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground",children:[d.jsxs("p",{children:[d.jsx("span",{className:"font-medium text-foreground",children:"Referencia:"})," ",Og(V)," USD",Y.hourReference?` · Hora hombre ref.: ${Y.hourReference}`:""]}),F.notes&&d.jsx("p",{className:"mt-1",children:F.notes}),V.hint&&d.jsx("p",{className:"mt-1",children:V.hint})]}),d.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-[220px_minmax(0,1fr)]",children:[d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Monto final"}),d.jsx(ot,{type:"number",min:"0",step:"0.01",value:w,onChange:ie=>E(ie.target.value),placeholder:"0.00",disabled:!V})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Observación"}),d.jsx(ma,{value:S,onChange:ie=>C(ie.target.value),placeholder:"Ej: más rondas de cambios, piezas adicionales, complejidad especial…",disabled:!V,rows:5,className:"min-h-[132px] resize-y"})]})]}),d.jsx("div",{className:"flex justify-end",children:d.jsxs(Ee,{type:"button",onClick:te,disabled:!F||!Y||!V||Qu(w)<=0,className:"gap-1.5 rounded-full",children:[d.jsx(Ir,{className:"h-4 w-4"}),"Agregar tarifa"]})})]}),je&&d.jsxs("div",{className:"space-y-4 rounded-xl border border-border bg-card p-4",children:[d.jsxs("div",{children:[d.jsx("p",{className:"text-sm font-medium",children:se?`Agregar propuesta o costo manual para ${se.clientName}`:"Agregar costo manual"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:se?"Para propuestas generales, proyectos por concepto o casos no contemplados por pieza.":"Para otros, adicionales o casos fuera del tarifario."})]}),d.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-[minmax(0,1fr)_220px]",children:[d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Nombre"}),d.jsx(ot,{value:N,onChange:ie=>A(ie.target.value),placeholder:se?`Ej: Propuesta general ${se.clientName}`:"Ej: Piezas adicionales"})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Monto"}),d.jsx(ot,{type:"number",min:"0",step:"0.01",value:$,onChange:ie=>L(ie.target.value),placeholder:"0.00"})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Descripción"}),d.jsx(ma,{value:T,onChange:ie=>M(ie.target.value),placeholder:se?"Ej: Compendio cotizado por proyecto, no por piezas.":"Ej: Cliente pidió piezas adicionales fuera del paquete.",rows:4,className:"min-h-[110px] resize-y"})]}),d.jsx("div",{className:"flex justify-end",children:d.jsxs(Ee,{type:"button",variant:"outline",onClick:ze,disabled:Qu($)<=0,className:"w-full gap-1.5 rounded-full sm:w-auto sm:min-w-[240px]",children:[d.jsx(Ir,{className:"h-4 w-4"}),"Agregar costo manual"]})})]})]}),d.jsx(Hs,{className:"my-4"}),d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx("p",{className:"text-sm font-medium",children:"Costos agregados"}),d.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.length," línea(s)"]})]}),t.length===0?d.jsx("div",{className:"rounded-xl border border-dashed border-border bg-card/70 px-3 py-3 text-sm text-muted-foreground",children:"Aún no hay costos agregados. Usa el tarifario disponible o agrega un monto manual."}):d.jsxs("div",{className:"space-y-2",children:[t.map((ie,De)=>{const Xe=ce.find(pe=>pe.id===ie.tariffSectionId&&pe.scope==="client"),We=!Xe&&ge.find(pe=>Nj(ie,pe)),Ct=Xe||We;return d.jsxs("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card px-3 py-3 sm:flex-row sm:items-start sm:justify-between",children:[d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsx(sn,{variant:ie.source==="manual"?"outline":"secondary",children:ie.source==="manual"?"Manual":Ct?Ct.clientName:"Tarifario"}),d.jsx("p",{className:"text-sm font-medium",children:ie.serviceName})]}),d.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[ie.category&&d.jsx("span",{children:ie.category}),ie.workType&&d.jsx("span",{children:ie.workType}),ie.complexityLevel&&d.jsx("span",{children:ie.complexityLevel}),ie.referenceLabel&&d.jsxs("span",{children:["Ref.: ",ie.referenceLabel]})]}),ie.description&&d.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:ie.description})]}),d.jsxs("div",{className:"flex items-center justify-between gap-3 sm:flex-col sm:items-end",children:[d.jsx("p",{className:"text-sm font-semibold text-foreground",children:Cl(Number(ie.amount||0))}),d.jsxs(Ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>Ne(De),className:xe("h-8 rounded-full px-2 text-muted-foreground hover:text-destructive"),children:[d.jsx(hf,{className:"mr-1 h-3.5 w-3.5"}),"Quitar"]})]})]},`${ie.source}-${ie.serviceName}-${De}`)}),d.jsxs("div",{className:"flex items-center justify-end gap-2 rounded-xl bg-primary/10 px-3 py-2 text-primary",children:[d.jsx(hg,{className:"h-4 w-4"}),d.jsxs("span",{className:"text-sm font-semibold",children:["Total interno estimado: ",Cl(R)]})]})]})]})]})}const Us={clientes:XI,marcas:JI,bus:RN,buCm:TN,status:[...QI]};let _d=[],Lg=Us,Jl=!1,Cj=!1,Yv=null,$l=null,qs=null,Zu=0;function zg(){_d.forEach(e=>e())}function zs(e){return at(e)}function TB(e){const t=new Map(RN.map(n=>[Ae(n),n]));return at(e).map(n=>t.get(Ae(n))||Wt(n)).filter(n=>!!n)}function RB(e){return String(e||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function AB(e){const t=RB(e);return["client","clients","cliente","clientes"].includes(t)?"client":["brand","brands","marca","marcas"].includes(t)?"brand":["country","countries","pais","paises","bu","business_unit","business unit"].includes(t)?"country":["status","estatus","estado","estados"].includes(t)?"status":["country_manager","country manager","cm","bu_cm","bu cm","manager","managers"].includes(t)?"country_manager":t}function kB(e){return Wt(String(e.label||e.value||""))}function OB(e){const t=[],n=[],a=[],i=[],l={};for(const c of e){if(c.is_active===!1)continue;const f=AB(c.category),h=kB(c),m=Wt(String(c.value||""));if(!(!h&&!m)&&(f==="client"&&t.push(h||m),f==="brand"&&n.push(h||m),f==="country"&&a.push(h||m),f==="status"&&i.push(h||m),f==="country_manager"&&m)){const b=h||m;b&&b!==m&&(l[m]=b)}}return{clientes:t.length?zs(t):zs(Us.clientes),marcas:n.length?zs(n):zs(Us.marcas),bus:a.length?TB(a):zs(Us.bus),buCm:a.length?l:{...Us.buCm},status:i.length?zs(i):zs(Us.status)}}function MB(e){Yv=e,zg()}async function Ig(){Jl=!0,MB(null),zg();try{const{data:e,error:t}=await Se.from("tablero_cdc_app_lists").select("category, value, label, sort_order, is_active").eq("is_active",!0).order("category",{ascending:!0}).order("sort_order",{ascending:!0}).order("label",{ascending:!0});if(t)throw t;Lg=OB(e||[]),Cj=!0}catch(e){console.error("Error cargando listas desde Supabase:",e),Yv=e instanceof Error?e.message:"No se pudieron cargar los desplegables desde Supabase.",Lg=Us}finally{Jl=!1,zg()}}function DB(){qs&&clearTimeout(qs),qs=setTimeout(()=>{qs=null,Jl||Ig()},350)}function PB(){$l||($l=Se.channel("tablero-cdc-app-lists").on("postgres_changes",{event:"*",schema:"public",table:"tablero_cdc_app_lists"},()=>DB()).subscribe(e=>{(e==="CHANNEL_ERROR"||e==="TIMED_OUT")&&console.warn("Supabase Realtime no pudo suscribirse a tablero_cdc_app_lists:",e)}))}function LB(){qs&&(clearTimeout(qs),qs=null),$l&&(Se.removeChannel($l),$l=null)}function bc(){const[,e]=v.useState(0);return v.useEffect(()=>{const t=()=>e(n=>n+1);return _d.push(t),Zu+=1,PB(),!Cj&&!Jl&&Ig(),()=>{_d=_d.filter(n=>n!==t),Zu=Math.max(0,Zu-1),Zu===0&&LB()}},[]),{lists:Lg,loading:Jl,error:Yv,refresh:Ig}}const zB={cr:"Costa Rica","costa rica":"Costa Rica",costarica:"Costa Rica",gt:"Guatemala",gua:"Guatemala",guate:"Guatemala",guatemala:"Guatemala",hn:"Honduras",honduras:"Honduras",ni:"Nicaragua",nicaragua:"Nicaragua",sv:"El Salvador",es:"El Salvador","el salvador":"El Salvador",elsalvador:"El Salvador",pa:"Panama",pty:"Panama",panama:"Panama",rd:"Republica Dominicana",repdom:"Republica Dominicana","republica dominicana":"Republica Dominicana",republicadominicana:"Republica Dominicana",do:"Republica Dominicana",mx:"Mexico",mexico:"Mexico",pr:"Puerto Rico","puerto rico":"Puerto Rico",puertorico:"Puerto Rico",co:"Colombia",colombia:"Colombia",jm:"Jamaica",jamaica:"Jamaica",tt:"Trinidad",trinidad:"Trinidad",ve:"Venezuela",venezuela:"Venezuela",latam:"Latam",wmc:"WMC"},IB=[[/(^|[_\-\s])cr([_\-\s]|$)/i,"Costa Rica"],[/(^|[_\-\s])(gt|gua|guate)([_\-\s]|$)/i,"Guatemala"],[/(^|[_\-\s])hn([_\-\s]|$)/i,"Honduras"],[/(^|[_\-\s])ni([_\-\s]|$)/i,"Nicaragua"],[/(^|[_\-\s])(sv|es)([_\-\s]|$)/i,"El Salvador"],[/(^|[_\-\s])(pa|pty|panama)([_\-\s]|$)/i,"Panama"],[/(^|[_\-\s])(rd|repdom|do)([_\-\s]|$)/i,"Republica Dominicana"],[/(^|[_\-\s])mx([_\-\s]|$)/i,"Mexico"],[/(^|[_\-\s])pr([_\-\s]|$)/i,"Puerto Rico"],[/(^|[_\-\s])co([_\-\s]|$)/i,"Colombia"],[/(^|[_\-\s])jm([_\-\s]|$)/i,"Jamaica"],[/(^|[_\-\s])tt([_\-\s]|$)/i,"Trinidad"],[/(^|[_\-\s])ve([_\-\s]|$)/i,"Venezuela"],[/(^|[_\-\s])latam([_\-\s]|$)/i,"Latam"],[/(^|[_\-\s])wmc([_\-\s]|$)/i,"WMC"]];function wo(e){return Wt(String(e??""))}function Y_(e,t,n=[]){const a=wo(t);if(!a)return;const i=n.find(l=>Ae(l)===Ae(a));e.push(i||a)}function jj(e,t,n){const a=wo(t),i=Ae(a);i&&n.forEach(l=>{const c=Ae(l);c&&(i===c||i.includes(c))&&e.push(l)})}function zf(e,t=[]){const n=wo(e);if(!n)return[];const a=[];return jj(a,n,t),n.split(/[,;|/]+/).map(i=>wo(i)).filter(Boolean).forEach(i=>Y_(a,i,t)),a.length===0&&Y_(a,n,t),at(a)}function $g(e,t=[]){const n=wo(e);if(!n)return[];const a=[];return jj(a,n,t),n.split(/[,;|/]+/).map(i=>wo(i)).filter(Boolean).forEach(i=>{const l=zB[Ae(i)],c=t.find(f=>Ae(f)===Ae(i));l?a.push(l):c&&a.push(c)}),IB.forEach(([i,l])=>{i.test(n)&&a.push(l)}),at(a)}function Tj(e,t=[]){const n=[...$g(e.bu,t),...$g(e.nombre,t)],a=Ae(e.cliente),i=Ae(e.nombre);return(a.includes("walmartconnect")||a.includes("wmc")||i.includes("wmc"))&&n.push("WMC"),at(n)}function Rj(e,t=[]){return zf(e.marca,t)}function Aj(e,t=[]){return zf(e.cliente,t)}function kj(e,t=[]){return zf(e.cm,t)}function ed(e,t){const n=Ae(t);return n?e.some(a=>{const i=Ae(a);return i===n||i.includes(n)||n.includes(i)}):!0}function Oj(e,t,n={}){if(t.country){const a=Tj(e,n.countries||[]);if(!ed(a,t.country))return!1}if(t.brand){const a=Rj(e,n.brands||[]);if(!ed(a,t.brand))return!1}if(t.client){const a=Aj(e,n.clients||[]);if(!ed(a,t.client))return!1}if(t.cm){const a=kj(e,n.cms||[]);if(!ed(a,t.cm))return!1}return!0}function $B(e,t=[]){return at(e.flatMap(n=>$g(n,t)))}function Up(e,t=[]){return at(e.flatMap(n=>zf(n,t)))}function Mj(e,t={}){return{countries:at(e.flatMap(n=>Tj(n,t.countries||[]))),brands:at(e.flatMap(n=>Rj(n,t.brands||[]))),clients:at(e.flatMap(n=>Aj(n,t.clients||[]))),cms:at(e.flatMap(n=>kj(n,t.cms||[])))}}function Dj(e){return!!(e.country||e.brand||e.client||e.cm)}const Pj="blue",If="Activo",da={tab:"todos",search:"",page:1,pageSize:24,country:"",brand:"",client:"",cm:""};let Sd=[],ba=[],Xd=0,Lj={countries:[],brands:[],clients:[],cms:[]},Ql=!1,zj=!1,Xv=null,Ul=null,Vs=null,td=0,Ln={...da},Ur=0,nd=0;function Zl(){Sd.forEach(e=>e())}function Jd(e,t=""){return typeof e=="string"?e:t}function UB(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function BB(e,t){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){const n=Number(e.trim());if(Number.isFinite(n))return n}return t}function HB(e,t){return Jd(e.legacy_month,"")||Jd(e.mes,"")||t.toLocaleString("es-DO",{month:"long"})}function qB(e,t){return BB(e.legacy_year,UB(e.anio,t.getFullYear()))}function VB(e){return!e||e===If?"":e}function FB(e){return e&&e.trim()?e:If}function Ij(e){return{tab:(e==null?void 0:e.tab)??Ln.tab??da.tab,search:String((e==null?void 0:e.search)??Ln.search??da.search).trim(),page:Math.max(1,Math.floor(Number((e==null?void 0:e.page)??Ln.page??da.page))),pageSize:Math.max(1,Math.min(100,Math.floor(Number((e==null?void 0:e.pageSize)??Ln.pageSize??da.pageSize)))),country:String((e==null?void 0:e.country)??Ln.country??da.country).trim(),brand:String((e==null?void 0:e.brand)??Ln.brand??da.brand).trim(),client:String((e==null?void 0:e.client)??Ln.client??da.client).trim(),cm:String((e==null?void 0:e.cm)??Ln.cm??da.cm).trim()}}function $f(e){const t=e.extra_data||{},n=e.project_links||[],a=n.filter(f=>f.link_type==="proposal").map(f=>f.url||"").filter(Boolean),i=n.filter(f=>f.link_type==="final_art").map(f=>f.url||"").filter(Boolean),l=e.created_at?new Date(e.created_at).getTime():Date.now(),c=Number.isFinite(l)?new Date(l):new Date;return{id:e.id,nombre:e.title||"",color:Jd(t.color,Pj),cliente:e.client||"",bu:e.country||"",cm:e.country_manager||"",marca:e.brand||"",solicitante:e.requested_by||"",comentarios:e.description||"",briefLink:e.brief_link||"",propuestaLinks:a,afLinks:i,status:VB(e.status),monto:e.internal_amount==null?null:Number(e.internal_amount),mes:HB(t,c),anio:qB(t,c),createdAt:Number.isFinite(l)?l:Date.now(),extraData:t}}function GB(e){const t=e.created_at?new Date(e.created_at).getTime():Date.now();return{id:e.id,projectId:e.project_id,type:e.activity_type||"note",title:e.title||"Actividad registrada",description:e.description||"",actorName:e.actor_name||e.actor_email||"Usuario CDC",actorEmail:e.actor_email||"",createdAt:Number.isFinite(t)?t:Date.now()}}function Jv(e){const t=e.created_at?new Date(e.created_at).getTime():Date.now(),n=e.updated_at?new Date(e.updated_at).getTime():t,a=Number(e.duration_minutes??0);return{id:e.id,projectId:e.project_id,country:e.country||"",taskName:e.task_name||"",durationMinutes:Number.isFinite(a)?Math.max(0,a):0,workDate:e.work_date||new Date().toISOString().slice(0,10),notes:e.notes||"",actorName:e.created_by_name||e.created_by_email||"Usuario CDC",actorEmail:e.created_by_email||"",createdAt:Number.isFinite(t)?t:Date.now(),updatedAt:Number.isFinite(n)?n:Date.now()}}function X_(e){const t=e.created_at?new Date(e.created_at).getTime():Date.now(),n=Number(e.amount??0),a=e.reference_min==null?null:Number(e.reference_min),i=e.reference_max==null?null:Number(e.reference_max);return{id:e.id,projectId:e.project_id,source:e.source==="manual"?"manual":"tariff",category:e.category||"",serviceName:e.service_name||"",workType:e.work_type||"",complexityLevel:e.complexity_level||"",referenceLabel:e.reference_label||"",referenceMin:Number.isFinite(a)?a:null,referenceMax:Number.isFinite(i)?i:null,amount:Number.isFinite(n)?n:0,description:e.description||"",tariffSectionId:e.tariff_section_id||"",tariffCatalogId:e.tariff_catalog_id||"",createdAt:Number.isFinite(t)?t:Date.now()}}function Qv(e){var n;const t=e.user_metadata||{};return t.full_name||t.name||t.display_name||((n=e.email)==null?void 0:n.split("@")[0])||"Usuario CDC"}function J_(e){return e&&e.trim()?e:If}function rd(e,t,n){return`${e} ${e===1?t:n}`}function Q_(e){return Array.isArray(e)?e.map(t=>String(t||"").trim()).filter(Boolean).join(" | "):String(e??"").trim()}function Ya(e,t,n,a,i){const l=Q_(n),c=Q_(a);if(l!==c){if(i!=null&&i.privateValue){e.push(`${t} actualizado.`);return}e.push(`${t}: ${l||"—"}${c||"—"}`)}}function KB(e,t,n){const a=[];return Ya(a,"Nombre",e.nombre,t.nombre),Ya(a,"Cliente",e.cliente,t.cliente),Ya(a,"Marca",e.marca,t.marca),Ya(a,"País/BU",e.bu,t.bu),Ya(a,"CM",e.cm,t.cm),Ya(a,"Solicitado por",e.solicitante,t.solicitante),Ya(a,"Estatus",J_(e.status),J_(t.status)),e.color!==t.color&&a.push("Etiqueta de color actualizada."),(e.comentarios||"").trim()!==(t.comentarios||"").trim()&&a.push("Comentarios actualizados."),(e.briefLink||"").trim()!==(t.briefLink||"").trim()&&a.push("Link del brief actualizado."),e.propuestaLinks.join("|")!==t.propuestaLinks.join("|")&&a.push(`Links de propuestas: ${rd(e.propuestaLinks.length,"link","links")}${rd(t.propuestaLinks.length,"link","links")}.`),e.afLinks.join("|")!==t.afLinks.join("|")&&a.push(`Links de artes finales: ${rd(e.afLinks.length,"link","links")}${rd(t.afLinks.length,"link","links")}.`),n&&Number(e.monto??0)!==Number(t.monto??0)&&Ya(a,"Monto interno",e.monto,t.monto,{privateValue:!0}),a}async function Uf(){const{data:e,error:t}=await Se.auth.getUser();if(t||!e.user)throw new Error("No hay una sesión activa de Supabase.");return e.user}async function $j(){return(await Uf()).id}async function WB(){return(await uf()).role==="director_creativo"}async function Uj(){return(await uf()).canManageInternalPricing}async function YB(){return(await uf()).canDeleteProjects}function Bj(e){const t=e.extraData&&typeof e.extraData=="object"&&!Array.isArray(e.extraData)?e.extraData:{};return{title:e.nombre,client:e.cliente,brand:e.marca,country:e.bu,requested_by:e.solicitante,country_manager:e.cm,description:e.comentarios,status:FB(e.status),internal_amount:e.monto??null,brief_link:e.briefLink,extra_data:{...t,color:e.color??Jd(t.color,Pj),mes:e.mes,anio:e.anio}}}function XB(e,t){const n=t.propuestaLinks.map(i=>i.trim()).filter(Boolean).map((i,l)=>({project_id:e,link_type:"proposal",url:i,label:`Propuesta ${l+1}`})),a=t.afLinks.map(i=>i.trim()).filter(Boolean).map((i,l)=>({project_id:e,link_type:"final_art",url:i,label:`AF ${l+1}`}));return[...n,...a]}function Hj(e){ba=e,Zl()}function ns(e){return Array.isArray(e)?Array.from(new Set(e.map(t=>String(t??"").trim()).filter(Boolean))).sort((t,n)=>t.localeCompare(n,"es",{sensitivity:"base"})):[]}function JB(e){return{countries:ns(e.map(t=>t.bu)),brands:ns(e.map(t=>t.marca)),clients:ns(e.map(t=>t.cliente)),cms:ns(e.map(t=>t.cm))}}function wr(e){Xv=e,Zl()}function qj(e){ba.some(n=>n.id===e.id)&&Hj(ba.map(n=>n.id===e.id?e:n))}function QB(e){ba.some(t=>t.id===e)&&(Hj(ba.filter(t=>t.id!==e)),Xd=Math.max(0,Xd-1),Zl())}function ZB(){return"https://agenteit.digitalcompass.agency/webhook/tablero-cdc-sync-proyecto".trim()||""}async function Bf(e,t){const n=ZB();if(!n)return console.info("No se configuró VITE_WEBHOOK_URL; se omite sincronización con Google Sheet."),{sheetSyncStatus:"skipped",sheetSyncMessage:t==="delete"?"No hay webhook configurado para eliminar el proyecto del Google Sheet.":"Proyecto guardado. No hay webhook configurado para sincronizar el Sheet."};const a=new AbortController,i=window.setTimeout(()=>a.abort(),15e3);try{const l=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project_id:e,action:t,source:"tablero-cdc",sent_at:new Date().toISOString()}),signal:a.signal});if(!l.ok){const c=await l.text().catch(()=>""),f=c||`${l.status} ${l.statusText}`.trim();return console.warn("El proyecto se guardó en Supabase, pero n8n no respondió correctamente.",{status:l.status,statusText:l.statusText,errorText:c}),{sheetSyncStatus:"failed",sheetSyncMessage:t==="delete"?`No se pudo eliminar el proyecto del Google Sheet: ${f}`:`Proyecto guardado, pero el Sheet no se pudo sincronizar: ${f}`}}return{sheetSyncStatus:"synced",sheetSyncMessage:t==="delete"?"Proyecto eliminado del Google Sheet.":"Proyecto guardado y sincronizado con el Google Sheet."}}catch(l){const c=l instanceof DOMException&&l.name==="AbortError";return console.warn("El proyecto se guardó en Supabase, pero no se pudo sincronizar con Google Sheet.",l),{sheetSyncStatus:c?"timeout":"failed",sheetSyncMessage:c?t==="delete"?"n8n tardó demasiado en responder. No se eliminó el proyecto para evitar inconsistencias.":"Proyecto guardado, pero n8n tardó demasiado en responder. Revisa el workflow si el Sheet no se actualizó.":t==="delete"?"No se pudo eliminar el proyecto del Google Sheet. No se eliminó el proyecto para evitar inconsistencias.":"Proyecto guardado, pero no se pudo sincronizar con Google Sheet."}}finally{window.clearTimeout(i)}}function Z_(){Vs&&clearTimeout(Vs),Vs=setTimeout(()=>{Vs=null,!Ql&&Ur===0&&Gs(Ln)},350)}function e6(){Ul||(Ul=Se.channel("tablero-cdc-projects").on("postgres_changes",{event:"*",schema:"public",table:"tablero_cdc_projects"},()=>Z_()).on("postgres_changes",{event:"*",schema:"public",table:"tablero_cdc_project_links"},()=>Z_()).subscribe(e=>{(e==="CHANNEL_ERROR"||e==="TIMED_OUT")&&console.warn("Supabase Realtime no pudo suscribirse a proyectos:",e)}))}function t6(){Vs&&(clearTimeout(Vs),Vs=null),Ul&&(Se.removeChannel(Ul),Ul=null)}async function Vj(e,t){const n=XB(e,t);try{const{error:l}=await Se.rpc("tablero_cdc_replace_project_links",{p_project_id:e,p_links:n.map(({link_type:c,url:f,label:h})=>({link_type:c,url:f,label:h}))});if(l)throw l;return}catch(l){if(!d6(l))throw l;console.warn("RPC tablero_cdc_replace_project_links no existe todavía. Usando reemplazo de links por delete+insert.",l)}const{error:a}=await Se.from("tablero_cdc_project_links").delete().eq("project_id",e);if(a)throw a;if(n.length===0)return;const{error:i}=await Se.from("tablero_cdc_project_links").insert(n);if(i)throw i}function Fj(e){const t=String((e==null?void 0:e.message)||"");return t.includes("tariff_section_id")||t.includes("tariff_catalog_id")||t.includes("schema cache")}async function Gj(e,t){if(!Array.isArray(t))return;const{error:n}=await Se.from("tablero_cdc_project_pricing_items").delete().eq("project_id",e);if(n)throw n;const a=t.map((f,h)=>({item:f,index:h})).filter(({item:f})=>Number.isFinite(Number(f.amount))&&Number(f.amount)>0).map(({item:f,index:h})=>({project_id:e,source:f.source,category:f.category||"",service_name:f.serviceName||"Costo manual",work_type:f.workType||"",complexity_level:f.complexityLevel||"",reference_label:f.referenceLabel||"",reference_min:f.referenceMin??null,reference_max:f.referenceMax??null,amount:Number(f.amount),description:f.description||"",tariff_section_id:f.tariffSectionId||null,tariff_catalog_id:f.tariffCatalogId||null,sort_order:h}));if(a.length===0)return;const i=await Se.from("tablero_cdc_project_pricing_items").insert(a);if(!i.error)return;if(!Fj(i.error))throw i.error;const l=a.map(({tariff_section_id:f,tariff_catalog_id:h,...m})=>m),c=await Se.from("tablero_cdc_project_pricing_items").insert(l);if(c.error)throw c.error}async function n6(e){const n=await Se.from("tablero_cdc_project_pricing_items").select("id, project_id, source, category, service_name, work_type, complexity_level, reference_label, reference_min, reference_max, amount, description, tariff_section_id, tariff_catalog_id, created_at").eq("project_id",e).order("sort_order",{ascending:!0}).order("created_at",{ascending:!0});if(!n.error)return(n.data||[]).map(X_);if(!Fj(n.error))throw n.error;const a=await Se.from("tablero_cdc_project_pricing_items").select("id, project_id, source, category, service_name, work_type, complexity_level, reference_label, reference_min, reference_max, amount, description, created_at").eq("project_id",e).order("sort_order",{ascending:!0}).order("created_at",{ascending:!0});if(a.error)throw a.error;return(a.data||[]).map(X_)}async function eS(e,t=20,n=0){const a=Math.max(1,Math.min(50,Math.floor(t))),i=Math.max(0,Math.floor(n)),{data:l,error:c}=await Se.from("tablero_cdc_project_activity").select("id, project_id, activity_type, title, description, actor_name, actor_email, created_at").eq("project_id",e).order("created_at",{ascending:!1}).range(i,i+a-1);if(c)throw c;return(l||[]).map(GB)}const Bp=500;async function r6(e){const t=String(e||"").trim();if(!t)return[];const n=[];let a=0;for(;;){const{data:i,error:l}=await Se.from("tablero_cdc_project_time_entries").select("id, project_id, country, task_name, duration_minutes, work_date, notes, created_by_name, created_by_email, created_at, updated_at").eq("project_id",t).order("work_date",{ascending:!1}).order("created_at",{ascending:!1}).range(a,a+Bp-1);if(l)throw l;const c=i||[];if(n.push(...c),c.length<Bp)break;a+=Bp}return n.map(Jv)}async function a6(e,t){const n=String(e||"").trim(),a=String(t.country||"").trim(),i=String(t.taskName||"").trim(),l=Math.round(Number(t.durationMinutes||0)),c=String(t.workDate||"").trim(),f=String(t.notes||"").trim();if(!n)throw new Error("No se encontró el proyecto.");if(!a)throw new Error("Selecciona el país.");if(!i)throw new Error("Escribe la tarea realizada.");if(!Number.isFinite(l)||l<=0)throw new Error("La duración debe ser mayor que 0 minutos.");if(!/^\d{4}-\d{2}-\d{2}$/.test(c))throw new Error("Selecciona una fecha válida.");const h=await Uf(),m=Qv(h),b=h.email||"",{data:g,error:x}=await Se.from("tablero_cdc_project_time_entries").insert({project_id:n,country:a,task_name:i,duration_minutes:l,work_date:c,notes:f,created_by:h.id,created_by_email:b||null,created_by_name:m}).select("id, project_id, country, task_name, duration_minutes, work_date, notes, created_by_name, created_by_email, created_at, updated_at").single();if(x)throw x;return Jv(g)}async function s6(e,t){const n=String(e||"").trim(),a=String(t.country||"").trim(),i=String(t.taskName||"").trim(),l=Math.round(Number(t.durationMinutes||0)),c=String(t.workDate||"").trim(),f=String(t.notes||"").trim();if(!n)throw new Error("No se encontró el registro de tiempo.");if(!a)throw new Error("Selecciona el país.");if(!i)throw new Error("Escribe la tarea realizada.");if(!Number.isFinite(l)||l<=0)throw new Error("La duración debe ser mayor que 0 minutos.");if(!/^\d{4}-\d{2}-\d{2}$/.test(c))throw new Error("Selecciona una fecha válida.");const{data:h,error:m}=await Se.from("tablero_cdc_project_time_entries").update({country:a,task_name:i,duration_minutes:l,work_date:c,notes:f}).eq("id",n).select("id, project_id, country, task_name, duration_minutes, work_date, notes, created_by_name, created_by_email, created_at, updated_at").single();if(m)throw m;return Jv(h)}async function i6(e){const t=String(e||"").trim();if(!t)throw new Error("No se encontró el registro de tiempo.");const{error:n}=await Se.from("tablero_cdc_project_time_entries").delete().eq("id",t);if(n)throw n}function o6(e,t,n,a){const i=new Intl.DateTimeFormat("es-DO",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(a),l=n?`${t} (${n})`:t;return`[${i}] ${l}:
${e}`}async function l6(e,t,n,a,i,l){const{data:c,error:f}=await Se.from("tablero_cdc_projects").select("description").eq("id",e).single();if(f)throw f;const h=String((c==null?void 0:c.description)||"").trim(),m=o6(t,n,a,l),b=h?`${h}
${m}`:m,{error:g}=await Se.from("tablero_cdc_projects").update({description:b,updated_by:i}).eq("id",e);if(g)throw g;const x=ba.find(w=>w.id===e);return x&&qj({...x,comentarios:b}),b}async function c6(e,t){const n=t.trim();if(!n)throw new Error("Escribe una nota antes de agregarla al historial.");const a=await Uf(),i=Qv(a),l=a.email||"",c=new Date,{error:f}=await Se.from("tablero_cdc_project_activity").insert({project_id:e,activity_type:"note",title:"Comentario agregado",description:n,actor_id:a.id,actor_email:l||null,actor_name:i});if(f)throw f;const h=await l6(e,n,i,l,a.id,c),m=await Bf(e,"update");return{comments:h,...m}}async function Kj(e,t,n,a="",i=!1){try{const l=await Uf(),c=Qv(l),{error:f}=await Se.from("tablero_cdc_project_activity").insert({project_id:e,activity_type:t,title:n,description:a,actor_id:l.id,actor_email:l.email||null,actor_name:c});if(f)throw f}catch(l){if(console.warn("No se pudo registrar la actividad del proyecto:",l),i)throw l instanceof Error?l:new Error("No se pudo registrar la actividad del proyecto.")}}function Wj(e){return`
id,
title,
client,
brand,
country,
requested_by,
country_manager,
description,
status,
${e?"internal_amount,":""}
brief_link,
created_at,
extra_data,
project_links:tablero_cdc_project_links (
id,
link_type,
url,
label
)
`}function Zv(e){return e instanceof Error?e.message:e&&typeof e=="object"&&"message"in e?String(e.message||""):String(e||"")}function u6(e){const t=Zv(e);return t.includes("tablero_cdc_get_projects_paginated")||t.includes("Could not find the function")}function d6(e){const t=Zv(e);return t.includes("tablero_cdc_replace_project_links")||t.includes("Could not find the function")}function f6(e){const t=Zv(e);return t.includes("tablero_cdc_get_pricing_summary")||t.includes("Could not find the function")}function Ml(e){return e.replace(/[%_]/g,"\\$&").replace(/,/g," ")}function ey(e,t){let n=e;t.tab==="abiertos"&&(n=n.or("status.is.null,status.eq.,status.eq.Activo")),t.tab==="cerrados"&&(n=n.not("status","is",null).neq("status","").neq("status",If));const a=t.search.trim();if(a){const l=`%${Ml(a)}%`;n=n.or(`title.ilike.${l},client.ilike.${l},brand.ilike.${l},country.ilike.${l},requested_by.ilike.${l},country_manager.ilike.${l},description.ilike.${l}`)}return n}function Yj(e,t){let n=ey(e,t);if(t.country){const a=`%${Ml(t.country)}%`;n=n.or(`country.ilike.${a}`)}if(t.brand){const a=`%${Ml(t.brand)}%`;n=n.or(`brand.ilike.${a}`)}if(t.client){const a=`%${Ml(t.client)}%`;n=n.or(`client.ilike.${a}`)}if(t.cm){const a=`%${Ml(t.cm)}%`;n=n.or(`country_manager.ilike.${a}`)}return n}async function h6(e,t){const n=(e.page-1)*e.pageSize,a=n+e.pageSize-1;let i=Se.from("tablero_cdc_projects").select(Wj(t),{count:"exact"}).order("created_at",{ascending:!1});i=Yj(i,e);const{data:l,error:c,count:f}=await i.range(n,a);if(c)throw c;const h=(l||[]).map(m=>$f(m));return{projects:h,totalProjects:f??0,filterOptions:JB(h)}}async function m6(e,t){let a=0,i=null;const l=[];for(;i===null||a<i;){let b=Se.from("tablero_cdc_projects").select(Wj(t),{count:"exact"}).order("created_at",{ascending:!1});b=ey(b,e);const{data:g,error:x,count:w}=await b.range(a,a+1e3-1);if(x)throw x;i===null&&(i=w??(g||[]).length);const E=(g||[]).map(S=>$f(S));if(l.push(...E),E.length<1e3)break;a+=1e3}const c=Mj(l),f=l.filter(b=>Oj(b,e,c)),h=(e.page-1)*e.pageSize,m=h+e.pageSize;return{projects:f.slice(h,m),totalProjects:f.length,filterOptions:c}}async function p6(e){var l,c,f,h;const{data:t,error:n}=await Se.rpc("tablero_cdc_get_projects_paginated",{p_tab:e.tab,p_search:e.search,p_page:e.page,p_page_size:e.pageSize,p_country:e.country||"",p_brand:e.brand||"",p_client:e.client||"",p_cm:e.cm||""});if(n)throw n;const a=t||{},i=Array.isArray(a.projects)?a.projects:[];return{totalProjects:Number(a.total_count||0),projects:i.map(m=>$f(m)),filterOptions:{countries:ns((l=a.filter_options)==null?void 0:l.countries),brands:ns((c=a.filter_options)==null?void 0:c.brands),clients:ns((f=a.filter_options)==null?void 0:f.clients),cms:ns((h=a.filter_options)==null?void 0:h.cms)}}}async function Gs(e){const t=Ij(e),n=nd+=1;Ln=t,Ql=!0,wr(null),Zl();try{const a=await Uj();let i;if(Dj(t)||a)i=await m6(t,a);else try{i=await p6(t)}catch(l){if(!u6(l))throw l;console.warn("RPC tablero_cdc_get_projects_paginated no existe todavía. Usando consulta directa como respaldo temporal.",l),i=await h6(t,a)}if(n!==nd)return;Xd=i.totalProjects,ba=i.projects,Lj=i.filterOptions,zj=!0}catch(a){if(n!==nd)return;console.error("Error cargando proyectos desde Supabase:",a),Xv=a instanceof Error?a.message:"No se pudieron cargar los proyectos desde Supabase."}finally{n===nd&&(Ql=!1,Zl())}}async function g6(e){wr(null),Ur+=1;try{if(!(await uf()).canCreateProjects)throw new Error("No tienes permiso para crear proyectos.");const n=await $j(),a={...Bj(e),created_by:n,updated_by:n},{data:i,error:l}=await Se.from("tablero_cdc_projects").insert(a).select("id").single();if(l)throw wr(l.message),l;await Vj(i.id,e),await Gj(i.id,e.pricingItems),await Kj(i.id,"created","Proyecto creado",`${e.nombre||"Proyecto sin título"} quedó registrado en el tablero.`);const c=await Bf(i.id,"create");return await Gs(Ln),{projectId:i.id,...c}}finally{Ur=Math.max(0,Ur-1)}}async function v6(e,t){wr(null),Ur+=1;try{const n=await $j(),a=await WB(),i=await Uj(),l=ba.find(x=>x.id===e);if(!l){const x="No se encontró el proyecto en la página actual. Recarga el tablero antes de guardar para evitar sobrescribir datos.";throw wr(x),new Error(x)}const c={...l,...t},f=Bj(c),h=a?{...f,updated_by:n}:i?{title:f.title,client:f.client,brand:f.brand,country:f.country,requested_by:f.requested_by,country_manager:f.country_manager,description:f.description,status:l.status,internal_amount:f.internal_amount,brief_link:f.brief_link,extra_data:f.extra_data,updated_by:n}:{title:f.title,client:f.client,brand:f.brand,country:f.country,requested_by:f.requested_by,country_manager:f.country_manager,description:f.description,status:f.status,brief_link:f.brief_link,extra_data:f.extra_data,updated_by:n},{error:m}=await Se.from("tablero_cdc_projects").update(h).eq("id",e);if(m)throw wr(m.message),m;qj(c),await Vj(e,c),i&&await Gj(e,t.pricingItems);const b=KB(l,c,i);b.length>0&&await Kj(e,"updated","Proyecto actualizado",b.slice(0,8).join(`
`));const g=await Bf(e,"update");return await Gs(Ln),{projectId:e,...g}}finally{Ur=Math.max(0,Ur-1)}}async function y6(e){wr(null),Ur+=1;try{if(!await YB()){const l="No tienes permiso para eliminar proyectos.";throw wr(l),new Error(l)}const n=await Bf(e,"delete");if(n.sheetSyncStatus!=="synced"){const l=n.sheetSyncMessage||"No se pudo eliminar el proyecto del Google Sheet.";throw wr(l),new Error(l)}const{error:a}=await Se.from("tablero_cdc_project_links").delete().eq("project_id",e);if(a)throw wr(a.message),a;const{error:i}=await Se.from("tablero_cdc_projects").delete().eq("id",e);if(i)throw wr(i.message),i;QB(e),await Gs(Ln)}finally{Ur=Math.max(0,Ur-1)}}async function b6(e){const{data:t,error:n}=await Se.rpc("tablero_cdc_get_pricing_summary",{p_tab:e.tab,p_search:e.search,p_country:e.country||"",p_brand:e.brand||"",p_client:e.client||"",p_cm:e.cm||""});if(n)throw n;const a=t||{},i=Number(a.total_amount||0),l=Number(a.project_count||0);return{totalAmount:Number.isFinite(i)?i:0,projectCount:Number.isFinite(l)?l:0,loadedAt:Date.now()}}async function x6(e){let n=0,a=null,i=0;for(;a===null||n<a;){let l=Se.from("tablero_cdc_projects").select("id, internal_amount",{count:"exact"}).order("created_at",{ascending:!1});l=Yj(l,e);const{data:c,error:f,count:h}=await l.range(n,n+1e3-1);if(f)throw f;a===null&&(a=h??(c||[]).length);const m=c||[];if(m.forEach(b=>{const g=Number(b.internal_amount??0);Number.isFinite(g)&&g>0&&(i+=g)}),m.length<1e3)break;n+=1e3}return{totalAmount:i,projectCount:a??0,loadedAt:Date.now()}}async function w6(e){let n=0,a=null;const i=[];for(;a===null||n<a;){let h=Se.from("tablero_cdc_projects").select("id, title, client, brand, country, requested_by, country_manager, description, status, internal_amount, brief_link, created_at, extra_data",{count:"exact"}).order("created_at",{ascending:!1});h=ey(h,e);const{data:m,error:b,count:g}=await h.range(n,n+1e3-1);if(b)throw b;a===null&&(a=g??(m||[]).length);const x=(m||[]).map(w=>$f(w));if(i.push(...x),x.length<1e3)break;n+=1e3}const l=Mj(i),c=i.filter(h=>Oj(h,e,l));return{totalAmount:c.reduce((h,m)=>{const b=Number(m.monto??0);return Number.isFinite(b)&&b>0?h+b:h},0),projectCount:c.length,loadedAt:Date.now()}}async function tS(e){const t=Ij({...e,page:1,pageSize:1e3});if(Dj(t))return w6(t);try{return await b6(t)}catch(n){if(!f6(n))throw n;return console.warn("RPC tablero_cdc_get_pricing_summary no existe todavía. Usando suma directa como respaldo temporal.",n),x6(t)}}function _6(e,t){const[n,a]=v.useState({totalAmount:0,projectCount:0,loadedAt:null}),[i,l]=v.useState(!1),[c,f]=v.useState(null),h=e.tab,m=e.search,b=e.country,g=e.brand,x=e.client,w=e.cm;return v.useEffect(()=>{if(!t){a({totalAmount:0,projectCount:0,loadedAt:null}),f(null),l(!1);return}let E=!1;return l(!0),f(null),tS({tab:h,search:m,country:b,brand:g,client:x,cm:w,page:1,pageSize:1e3}).then(S=>{E||a(S)}).catch(S=>{E||(console.error("No se pudo calcular el total tarifado filtrado:",S),f(S instanceof Error?S.message:"No se pudo calcular el total tarifado filtrado."))}).finally(()=>{E||l(!1)}),()=>{E=!0}},[t,h,m,b,g,x,w]),{summary:n,loading:i,error:c,refresh:()=>tS(e).then(E=>(a(E),E))}}function Xj(e){const[,t]=v.useState(0),n=e==null?void 0:e.tab,a=e==null?void 0:e.search,i=e==null?void 0:e.page,l=e==null?void 0:e.pageSize,c=e==null?void 0:e.country,f=e==null?void 0:e.brand,h=e==null?void 0:e.client,m=e==null?void 0:e.cm;return v.useEffect(()=>{const b=()=>t(g=>g+1);return Sd.push(b),td+=1,e6(),()=>{Sd=Sd.filter(g=>g!==b),td=Math.max(0,td-1),td===0&&t6()}},[]),v.useEffect(()=>{if(n&&i&&l){Gs({tab:n,search:a??"",page:i,pageSize:l,country:c??"",brand:f??"",client:h??"",cm:m??""});return}!zj&&!Ql&&Gs()},[n,a,i,l,c,f,h,m]),{projects:ba,totalProjects:Xd,filterOptions:Lj,loading:Ql,error:Xv,refresh:()=>Gs(e??Ln),add:g6,update:v6,remove:y6}}function S6(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const E6=e=>{switch(e){case"success":return j6;case"info":return R6;case"warning":return T6;case"error":return A6;default:return null}},N6=Array(12).fill(0),C6=({visible:e,className:t})=>ve.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},ve.createElement("div",{className:"sonner-spinner"},N6.map((n,a)=>ve.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${a}`})))),j6=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ve.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),T6=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ve.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),R6=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ve.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),A6=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ve.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),k6=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},ve.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ve.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),O6=()=>{const[e,t]=ve.useState(document.hidden);return ve.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let Ug=1;class M6{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;const{message:a,...i}=t,l=typeof(t==null?void 0:t.id)=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:Ug++,c=this.toasts.find(h=>h.id===l),f=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(l)&&this.dismissedToasts.delete(l),c?this.toasts=this.toasts.map(h=>h.id===l?(this.publish({...h,...t,id:l,title:a}),{...h,...t,id:l,dismissible:f,title:a}):h):this.addToast({title:a,...i,dismissible:f,id:l}),l},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:t,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(a=>a({id:n.id,dismiss:!0}))}),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let a;n.loading!==void 0&&(a=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const i=Promise.resolve(t instanceof Function?t():t);let l=a!==void 0,c;const f=i.then(async m=>{if(c=["resolve",m],ve.isValidElement(m))l=!1,this.create({id:a,type:"default",message:m});else if(P6(m)&&!m.ok){l=!1;const g=typeof n.error=="function"?await n.error(`HTTP error! status: ${m.status}`):n.error,x=typeof n.description=="function"?await n.description(`HTTP error! status: ${m.status}`):n.description,E=typeof g=="object"&&!ve.isValidElement(g)?g:{message:g};this.create({id:a,type:"error",description:x,...E})}else if(m instanceof Error){l=!1;const g=typeof n.error=="function"?await n.error(m):n.error,x=typeof n.description=="function"?await n.description(m):n.description,E=typeof g=="object"&&!ve.isValidElement(g)?g:{message:g};this.create({id:a,type:"error",description:x,...E})}else if(n.success!==void 0){l=!1;const g=typeof n.success=="function"?await n.success(m):n.success,x=typeof n.description=="function"?await n.description(m):n.description,E=typeof g=="object"&&!ve.isValidElement(g)?g:{message:g};this.create({id:a,type:"success",description:x,...E})}}).catch(async m=>{if(c=["reject",m],n.error!==void 0){l=!1;const b=typeof n.error=="function"?await n.error(m):n.error,g=typeof n.description=="function"?await n.description(m):n.description,w=typeof b=="object"&&!ve.isValidElement(b)?b:{message:b};this.create({id:a,type:"error",description:g,...w})}}).finally(()=>{l&&(this.dismiss(a),a=void 0),n.finally==null||n.finally.call(n)}),h=()=>new Promise((m,b)=>f.then(()=>c[0]==="reject"?b(c[1]):m(c[1])).catch(b));return typeof a!="string"&&typeof a!="number"?{unwrap:h}:Object.assign(a,{unwrap:h})},this.custom=(t,n)=>{const a=(n==null?void 0:n.id)||Ug++;return this.create({jsx:t(a),id:a,...n}),a},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const Pn=new M6,D6=(e,t)=>{const n=(t==null?void 0:t.id)||Ug++;return Pn.addToast({title:e,...t,id:n}),n},P6=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",L6=D6,z6=()=>Pn.toasts,I6=()=>Pn.getActiveToasts(),dt=Object.assign(L6,{success:Pn.success,info:Pn.info,warning:Pn.warning,error:Pn.error,custom:Pn.custom,message:Pn.message,promise:Pn.promise,dismiss:Pn.dismiss,loading:Pn.loading},{getHistory:z6,getToasts:I6});S6("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function ad(e){return e.label!==void 0}const $6=3,U6="24px",B6="16px",nS=4e3,H6=356,q6=14,V6=45,F6=200;function Mr(...e){return e.filter(Boolean).join(" ")}function G6(e){const[t,n]=e.split("-"),a=[];return t&&a.push(t),n&&a.push(n),a}const K6=e=>{var t,n,a,i,l,c,f,h,m;const{invert:b,toast:g,unstyled:x,interacting:w,setHeights:E,visibleToasts:S,heights:C,index:N,toasts:A,expanded:T,removeToast:M,defaultRichColors:$,closeButton:L,style:P,cancelButtonStyle:U,actionButtonStyle:J,className:ce="",descriptionClassName:re="",duration:me,position:fe,gap:ge,expandByDefault:de,classNames:k,icons:K,closeButtonAriaLabel:F="Close toast"}=e,[Y,V]=ve.useState(null),[R,O]=ve.useState(null),[I,H]=ve.useState(!1),[q,ee]=ve.useState(!1),[te,Q]=ve.useState(!1),[se,je]=ve.useState(!1),[ze,Ne]=ve.useState(!1),[ne,Me]=ve.useState(0),[Je,ie]=ve.useState(0),De=ve.useRef(g.duration||me||nS),Xe=ve.useRef(null),We=ve.useRef(null),Ct=N===0,pe=N+1<=S,$e=g.type,Ke=g.dismissible!==!1,Le=g.className||"",ue=g.descriptionClassName||"",qe=ve.useMemo(()=>C.findIndex(He=>He.toastId===g.id)||0,[C,g.id]),gt=ve.useMemo(()=>{var He;return(He=g.closeButton)!=null?He:L},[g.closeButton,L]),Xt=ve.useMemo(()=>g.duration||me||nS,[g.duration,me]),jt=ve.useRef(0),At=ve.useRef(0),on=ve.useRef(0),gn=ve.useRef(null),[vn,Mt]=fe.split("-"),Jt=ve.useMemo(()=>C.reduce((He,Et,we)=>we>=qe?He:He+Et.height,0),[C,qe]),Dt=O6(),fr=g.invert||b,Yn=$e==="loading";At.current=ve.useMemo(()=>qe*ge+Jt,[qe,Jt]),ve.useEffect(()=>{De.current=Xt},[Xt]),ve.useEffect(()=>{H(!0)},[]),ve.useEffect(()=>{const He=We.current;if(He){const Et=He.getBoundingClientRect().height;return ie(Et),E(we=>[{toastId:g.id,height:Et,position:g.position},...we]),()=>E(we=>we.filter(ft=>ft.toastId!==g.id))}},[E,g.id]),ve.useLayoutEffect(()=>{if(!I)return;const He=We.current,Et=He.style.height;He.style.height="auto";const we=He.getBoundingClientRect().height;He.style.height=Et,ie(we),E(ft=>ft.find(ht=>ht.toastId===g.id)?ft.map(ht=>ht.toastId===g.id?{...ht,height:we}:ht):[{toastId:g.id,height:we,position:g.position},...ft])},[I,g.title,g.description,E,g.id,g.jsx,g.action,g.cancel]);const en=ve.useCallback(()=>{ee(!0),Me(At.current),E(He=>He.filter(Et=>Et.toastId!==g.id)),setTimeout(()=>{M(g)},F6)},[g,M,E,At]);ve.useEffect(()=>{if(g.promise&&$e==="loading"||g.duration===1/0||g.type==="loading")return;let He;return T||w||Dt?(()=>{if(on.current<jt.current){const ft=new Date().getTime()-jt.current;De.current=De.current-ft}on.current=new Date().getTime()})():(()=>{De.current!==1/0&&(jt.current=new Date().getTime(),He=setTimeout(()=>{g.onAutoClose==null||g.onAutoClose.call(g,g),en()},De.current))})(),()=>clearTimeout(He)},[T,w,g,$e,Dt,en]),ve.useEffect(()=>{g.delete&&(en(),g.onDismiss==null||g.onDismiss.call(g,g))},[en,g.delete]);function he(){var He;if(K!=null&&K.loading){var Et;return ve.createElement("div",{className:Mr(k==null?void 0:k.loader,g==null||(Et=g.classNames)==null?void 0:Et.loader,"sonner-loader"),"data-visible":$e==="loading"},K.loading)}return ve.createElement(C6,{className:Mr(k==null?void 0:k.loader,g==null||(He=g.classNames)==null?void 0:He.loader),visible:$e==="loading"})}const Be=g.icon||(K==null?void 0:K[$e])||E6($e);var et,rt;return ve.createElement("li",{tabIndex:0,ref:We,className:Mr(ce,Le,k==null?void 0:k.toast,g==null||(t=g.classNames)==null?void 0:t.toast,k==null?void 0:k.default,k==null?void 0:k[$e],g==null||(n=g.classNames)==null?void 0:n[$e]),"data-sonner-toast":"","data-rich-colors":(et=g.richColors)!=null?et:$,"data-styled":!(g.jsx||g.unstyled||x),"data-mounted":I,"data-promise":!!g.promise,"data-swiped":ze,"data-removed":q,"data-visible":pe,"data-y-position":vn,"data-x-position":Mt,"data-index":N,"data-front":Ct,"data-swiping":te,"data-dismissible":Ke,"data-type":$e,"data-invert":fr,"data-swipe-out":se,"data-swipe-direction":R,"data-expanded":!!(T||de&&I),"data-testid":g.testId,style:{"--index":N,"--toasts-before":N,"--z-index":A.length-N,"--offset":`${q?ne:At.current}px`,"--initial-height":de?"auto":`${Je}px`,...P,...g.style},onDragEnd:()=>{Q(!1),V(null),gn.current=null},onPointerDown:He=>{He.button!==2&&(Yn||!Ke||(Xe.current=new Date,Me(At.current),He.target.setPointerCapture(He.pointerId),He.target.tagName!=="BUTTON"&&(Q(!0),gn.current={x:He.clientX,y:He.clientY})))},onPointerUp:()=>{var He,Et,we;if(se||!Ke)return;gn.current=null;const ft=Number(((He=We.current)==null?void 0:He.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),kt=Number(((Et=We.current)==null?void 0:Et.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ht=new Date().getTime()-((we=Xe.current)==null?void 0:we.getTime()),$t=Y==="x"?ft:kt,ps=Math.abs($t)/ht;if(Math.abs($t)>=V6||ps>.11){Me(At.current),g.onDismiss==null||g.onDismiss.call(g,g),O(Y==="x"?ft>0?"right":"left":kt>0?"down":"up"),en(),je(!0);return}else{var Sn,En;(Sn=We.current)==null||Sn.style.setProperty("--swipe-amount-x","0px"),(En=We.current)==null||En.style.setProperty("--swipe-amount-y","0px")}Ne(!1),Q(!1),V(null)},onPointerMove:He=>{var Et,we,ft;if(!gn.current||!Ke||((Et=window.getSelection())==null?void 0:Et.toString().length)>0)return;const ht=He.clientY-gn.current.y,$t=He.clientX-gn.current.x;var ps;const Sn=(ps=e.swipeDirections)!=null?ps:G6(fe);!Y&&(Math.abs($t)>1||Math.abs(ht)>1)&&V(Math.abs($t)>Math.abs(ht)?"x":"y");let En={x:0,y:0};const ai=hr=>1/(1.5+Math.abs(hr)/20);if(Y==="y"){if(Sn.includes("top")||Sn.includes("bottom"))if(Sn.includes("top")&&ht<0||Sn.includes("bottom")&&ht>0)En.y=ht;else{const hr=ht*ai(ht);En.y=Math.abs(hr)<Math.abs(ht)?hr:ht}}else if(Y==="x"&&(Sn.includes("left")||Sn.includes("right")))if(Sn.includes("left")&&$t<0||Sn.includes("right")&&$t>0)En.x=$t;else{const hr=$t*ai($t);En.x=Math.abs(hr)<Math.abs($t)?hr:$t}(Math.abs(En.x)>0||Math.abs(En.y)>0)&&Ne(!0),(we=We.current)==null||we.style.setProperty("--swipe-amount-x",`${En.x}px`),(ft=We.current)==null||ft.style.setProperty("--swipe-amount-y",`${En.y}px`)}},gt&&!g.jsx&&$e!=="loading"?ve.createElement("button",{"aria-label":F,"data-disabled":Yn,"data-close-button":!0,onClick:Yn||!Ke?()=>{}:()=>{en(),g.onDismiss==null||g.onDismiss.call(g,g)},className:Mr(k==null?void 0:k.closeButton,g==null||(a=g.classNames)==null?void 0:a.closeButton)},(rt=K==null?void 0:K.close)!=null?rt:k6):null,($e||g.icon||g.promise)&&g.icon!==null&&((K==null?void 0:K[$e])!==null||g.icon)?ve.createElement("div",{"data-icon":"",className:Mr(k==null?void 0:k.icon,g==null||(i=g.classNames)==null?void 0:i.icon)},g.promise||g.type==="loading"&&!g.icon?g.icon||he():null,g.type!=="loading"?Be:null):null,ve.createElement("div",{"data-content":"",className:Mr(k==null?void 0:k.content,g==null||(l=g.classNames)==null?void 0:l.content)},ve.createElement("div",{"data-title":"",className:Mr(k==null?void 0:k.title,g==null||(c=g.classNames)==null?void 0:c.title)},g.jsx?g.jsx:typeof g.title=="function"?g.title():g.title),g.description?ve.createElement("div",{"data-description":"",className:Mr(re,ue,k==null?void 0:k.description,g==null||(f=g.classNames)==null?void 0:f.description)},typeof g.description=="function"?g.description():g.description):null),ve.isValidElement(g.cancel)?g.cancel:g.cancel&&ad(g.cancel)?ve.createElement("button",{"data-button":!0,"data-cancel":!0,style:g.cancelButtonStyle||U,onClick:He=>{ad(g.cancel)&&Ke&&(g.cancel.onClick==null||g.cancel.onClick.call(g.cancel,He),en())},className:Mr(k==null?void 0:k.cancelButton,g==null||(h=g.classNames)==null?void 0:h.cancelButton)},g.cancel.label):null,ve.isValidElement(g.action)?g.action:g.action&&ad(g.action)?ve.createElement("button",{"data-button":!0,"data-action":!0,style:g.actionButtonStyle||J,onClick:He=>{ad(g.action)&&(g.action.onClick==null||g.action.onClick.call(g.action,He),!He.defaultPrevented&&en())},className:Mr(k==null?void 0:k.actionButton,g==null||(m=g.classNames)==null?void 0:m.actionButton)},g.action.label):null)};function rS(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function W6(e,t){const n={};return[e,t].forEach((a,i)=>{const l=i===1,c=l?"--mobile-offset":"--offset",f=l?B6:U6;function h(m){["top","right","bottom","left"].forEach(b=>{n[`${c}-${b}`]=typeof m=="number"?`${m}px`:m})}typeof a=="number"||typeof a=="string"?h(a):typeof a=="object"?["top","right","bottom","left"].forEach(m=>{a[m]===void 0?n[`${c}-${m}`]=f:n[`${c}-${m}`]=typeof a[m]=="number"?`${a[m]}px`:a[m]}):h(f)}),n}const Y6=ve.forwardRef(function(t,n){const{id:a,invert:i,position:l="bottom-right",hotkey:c=["altKey","KeyT"],expand:f,closeButton:h,className:m,offset:b,mobileOffset:g,theme:x="light",richColors:w,duration:E,style:S,visibleToasts:C=$6,toastOptions:N,dir:A=rS(),gap:T=q6,icons:M,containerAriaLabel:$="Notifications"}=t,[L,P]=ve.useState([]),U=ve.useMemo(()=>a?L.filter(I=>I.toasterId===a):L.filter(I=>!I.toasterId),[L,a]),J=ve.useMemo(()=>Array.from(new Set([l].concat(U.filter(I=>I.position).map(I=>I.position)))),[U,l]),[ce,re]=ve.useState([]),[me,fe]=ve.useState(!1),[ge,de]=ve.useState(!1),[k,K]=ve.useState(x!=="system"?x:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),F=ve.useRef(null),Y=c.join("+").replace(/Key/g,"").replace(/Digit/g,""),V=ve.useRef(null),R=ve.useRef(!1),O=ve.useCallback(I=>{P(H=>{var q;return(q=H.find(ee=>ee.id===I.id))!=null&&q.delete||Pn.dismiss(I.id),H.filter(({id:ee})=>ee!==I.id)})},[]);return ve.useEffect(()=>Pn.subscribe(I=>{if(I.dismiss){requestAnimationFrame(()=>{P(H=>H.map(q=>q.id===I.id?{...q,delete:!0}:q))});return}setTimeout(()=>{qS.flushSync(()=>{P(H=>{const q=H.findIndex(ee=>ee.id===I.id);return q!==-1?[...H.slice(0,q),{...H[q],...I},...H.slice(q+1)]:[I,...H]})})})}),[L]),ve.useEffect(()=>{if(x!=="system"){K(x);return}if(x==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?K("dark"):K("light")),typeof window>"u")return;const I=window.matchMedia("(prefers-color-scheme: dark)");try{I.addEventListener("change",({matches:H})=>{K(H?"dark":"light")})}catch{I.addListener(({matches:q})=>{try{K(q?"dark":"light")}catch(ee){console.error(ee)}})}},[x]),ve.useEffect(()=>{L.length<=1&&fe(!1)},[L]),ve.useEffect(()=>{const I=H=>{var q;if(c.every(Q=>H[Q]||H.code===Q)){var te;fe(!0),(te=F.current)==null||te.focus()}H.code==="Escape"&&(document.activeElement===F.current||(q=F.current)!=null&&q.contains(document.activeElement))&&fe(!1)};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[c]),ve.useEffect(()=>{if(F.current)return()=>{V.current&&(V.current.focus({preventScroll:!0}),V.current=null,R.current=!1)}},[F.current]),ve.createElement("section",{ref:n,"aria-label":`${$} ${Y}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},J.map((I,H)=>{var q;const[ee,te]=I.split("-");return U.length?ve.createElement("ol",{key:I,dir:A==="auto"?rS():A,tabIndex:-1,ref:F,className:m,"data-sonner-toaster":!0,"data-sonner-theme":k,"data-y-position":ee,"data-x-position":te,style:{"--front-toast-height":`${((q=ce[0])==null?void 0:q.height)||0}px`,"--width":`${H6}px`,"--gap":`${T}px`,...S,...W6(b,g)},onBlur:Q=>{R.current&&!Q.currentTarget.contains(Q.relatedTarget)&&(R.current=!1,V.current&&(V.current.focus({preventScroll:!0}),V.current=null))},onFocus:Q=>{Q.target instanceof HTMLElement&&Q.target.dataset.dismissible==="false"||R.current||(R.current=!0,V.current=Q.relatedTarget)},onMouseEnter:()=>fe(!0),onMouseMove:()=>fe(!0),onMouseLeave:()=>{ge||fe(!1)},onDragEnd:()=>fe(!1),onPointerDown:Q=>{Q.target instanceof HTMLElement&&Q.target.dataset.dismissible==="false"||de(!0)},onPointerUp:()=>de(!1)},U.filter(Q=>!Q.position&&H===0||Q.position===I).map((Q,se)=>{var je,ze;return ve.createElement(K6,{key:Q.id,icons:M,index:se,toast:Q,defaultRichColors:w,duration:(je=N==null?void 0:N.duration)!=null?je:E,className:N==null?void 0:N.className,descriptionClassName:N==null?void 0:N.descriptionClassName,invert:i,visibleToasts:C,closeButton:(ze=N==null?void 0:N.closeButton)!=null?ze:h,interacting:ge,position:I,style:N==null?void 0:N.style,unstyled:N==null?void 0:N.unstyled,classNames:N==null?void 0:N.classNames,cancelButtonStyle:N==null?void 0:N.cancelButtonStyle,actionButtonStyle:N==null?void 0:N.actionButtonStyle,closeButtonAriaLabel:N==null?void 0:N.closeButtonAriaLabel,removeToast:O,toasts:U.filter(Ne=>Ne.position==Q.position),heights:ce.filter(Ne=>Ne.position==Q.position),setHeights:re,expandByDefault:f,gap:T,expanded:me,swipeDirections:t.swipeDirections})})):null}))}),X6="Walmart Connect WMC",J6=new Set(["wmc"]),Ji=15;function Q6(e){return new Intl.DateTimeFormat("es-DO",{day:"2-digit",month:"short",year:"numeric",hour:"numeric",minute:"2-digit"}).format(new Date(e))}function Z6(e){return e.split(`
`).map(t=>t.trim()).filter(Boolean)}function Bg(e){return e.reduce((t,n)=>t+Number(n.amount||0),0)}function e8(e){return e.map(t=>({id:t.id,source:t.source,category:t.category,serviceName:t.serviceName,workType:t.workType,complexityLevel:t.complexityLevel,referenceLabel:t.referenceLabel,referenceMin:t.referenceMin,referenceMax:t.referenceMax,amount:t.amount,description:t.description,tariffSectionId:t.tariffSectionId,tariffCatalogId:t.tariffCatalogId}))}function t8(e,t){if(!t.length||e==null)return!1;const n=Number(e);if(!Number.isFinite(n)||n<=0)return!1;const a=Bg(t);return Math.abs(n-a)>.01}function n8(e,t=[]){const n=Wt(e);if(!n)return[];const a=new Map(at(t).map(h=>[Ae(h),h])),i=a.get(Ae(n));if(i)return[i];const l=n.split(/[,;]/).map(h=>Wt(h)).filter(Boolean);if(l.length<=1)return at([i||n]);const c=[];let f=0;for(;f<l.length;){let h="",m=f+1;for(let b=l.length;b>f;b-=1){const g=l.slice(f,b).join(", "),x=a.get(Ae(g));if(x){h=x,m=b;break}}c.push(h||l[f]),f=m}return at(c)}function r8(e){return at(e.map(t=>Wt(t)).filter(Boolean)).join(", ")}function a8(e,t=[]){const n=Wt(e);if(!n)return[];const a=new Map(at(t).map(c=>[Ae(c),c])),i=a.get(Ae(n));if(i)return[i];const l=n.split(/[,;]/).map(c=>Wt(c)).filter(Boolean);return l.length<=1?at([i||n]):at(l.map(c=>a.get(Ae(c))||c))}function aS(e){return at(e.map(t=>Wt(t)).filter(Boolean)).join(", ")}function sd(e){return Ae(e)===Ae(X6)}const sS=()=>{const e=new Date;return{nombre:"",color:"blue",cliente:"",bu:"",cm:"",marca:"",solicitante:"",comentarios:"",briefLink:"",propuestaLinks:[],afLinks:[],status:"",monto:null,mes:ZI[e.getMonth()],anio:e.getFullYear()}};function s8({open:e,onOpenChange:t,project:n,onDelete:a,deleting:i=!1}){const{add:l,update:c}=Xj(),{lists:f,loading:h,error:m,refresh:b}=bc(),{isGerardo:g,canDeleteProjects:x,canManageInternalPricing:w}=df(),E=!!n,[S,C]=v.useState(sS()),[N,A]=v.useState([]),[T,M]=v.useState(!1),[$,L]=v.useState(""),[P,U]=v.useState(null),[J,ce]=v.useState(null),[re,me]=v.useState([]),[fe,ge]=v.useState(!1),[de,k]=v.useState(null),[K,F]=v.useState(""),[Y,V]=v.useState(!1),[R,O]=v.useState(!1),[I,H]=v.useState(!1),[q,ee]=v.useState([]),[te,Q]=v.useState(!1),[se,je]=v.useState(null),[ze,Ne]=v.useState(!1),ne=v.useRef(!1),Me=n8(S.marca,f.marcas),Je=a8(S.bu,f.bus),ie=at(F_(f.clientes,S.cliente)),De=at([...f.marcas,...Me]),Xe=at([...f.bus,...Je]),We=at(F_(f.status,S.status)),Ct=Xe.filter(he=>{const Be=Ae(he);return!J6.has(Be)&&Be.includes(Ae($))}),pe=Bg(q);v.useEffect(()=>{if(ce(null),U(null),n){const{id:he,createdAt:Be,...et}=n,rt=Wt(et.bu);C({...et,bu:rt}),A(rt?[rt]:[]),L(""),me([]),V(!1),k(null),F(""),ee([]),je(null),Ne(!1)}else e&&(C(sS()),A([]),L(""),me([]),V(!1),k(null),F(""),ee([]),je(null),Ne(!1))},[n,e]);const $e=v.useCallback(async()=>{if(n!=null&&n.id)try{ge(!0),k(null);const he=await eS(n.id,Ji+1);me(he.slice(0,Ji)),V(he.length>Ji)}catch(he){console.warn("No se pudo cargar el historial del proyecto:",he),k("No se pudo cargar el historial. Revisa que el SQL de actividad esté ejecutado en Supabase."),me([]),V(!1)}finally{ge(!1)}},[n==null?void 0:n.id]),Ke=v.useCallback(async()=>{if(!(!(n!=null&&n.id)||R||!Y))try{O(!0),k(null);const he=await eS(n.id,Ji+1,re.length);me(Be=>[...Be,...he.slice(0,Ji)]),V(he.length>Ji)}catch(he){console.warn("No se pudo cargar más historial del proyecto:",he),k("No se pudo cargar más actividad. Inténtalo nuevamente.")}finally{O(!1)}},[Y,re.length,R,n==null?void 0:n.id]);v.useEffect(()=>{!e||!(n!=null&&n.id)||$e()},[e,n==null?void 0:n.id,$e]),v.useEffect(()=>{if(!e||!(n!=null&&n.id)||!w)return;let he=!1;return(async()=>{try{Q(!0),je(null);const et=await n6(n.id),rt=e8(et);he||(Ne(t8(n.monto,rt)),ee(rt))}catch(et){console.warn("No se pudo cargar el tarifario del proyecto:",et),he||(ee([]),je("No se pudieron cargar los costos guardados. Revisa que el SQL del tarifario esté ejecutado en Supabase."))}finally{he||Q(!1)}})(),()=>{he=!0}},[w,e,n==null?void 0:n.id,n==null?void 0:n.monto]);const Le=(he,Be)=>C(et=>({...et,[he]:Be})),ue=he=>{Ne(!1),ee(he);const Be=Number(Bg(he).toFixed(2));C(et=>et.monto===Be?et:{...et,monto:Be})};v.useEffect(()=>{if(!w||!q.length||ze)return;const he=Number(pe.toFixed(2));C(Be=>Be.monto===he?Be:{...Be,monto:he})},[w,ze,q.length,pe]);const qe=he=>{const Be=f.buCm[he];if(Be)return Be;const et=Ae(he),rt=Object.entries(f.buCm).find(([He])=>Ae(He)===et);return(rt==null?void 0:rt[1])??""},gt=he=>{const Be=at(he.map(rt=>Wt(rt)).filter(Boolean)),et=at(Be.map(qe).filter(Boolean));C(rt=>({...rt,bu:aS(Be),cm:et.join(", ")}))},Xt=he=>{const Be=Wt(he);C(et=>({...et,cliente:Be,...sd(Be)&&!E?{bu:"",cm:""}:et.cliente&&sd(et.cliente)?{bu:"",cm:""}:{}})),sd(Be)||(A([]),L(""))},jt=!E&&sd(S.cliente),At=jt?N:Je,on=!E&&At.length>1,gn=(he,Be)=>{const et=Wt(he);A(rt=>Be?at([...rt,et]):rt.filter(He=>Ae(He)!==Ae(et)))},vn=N.map(he=>({country:he,manager:qe(he)})),Mt=Je.map(he=>({country:he,manager:qe(he)})),Jt=S.nombre.trim()&&S.cliente&&S.marca&&S.solicitante.trim()&&(jt?N.length>0:Je.length>0),Dt=he=>{if(he.sheetSyncStatus==="synced"){dt.success(E?"Proyecto actualizado":"Proyecto creado",{description:"Se guardó y se sincronizó con el Google Sheet."});return}if(he.sheetSyncStatus==="skipped"){dt.success(E?"Proyecto actualizado":"Proyecto creado",{description:"Se guardó. La sincronización con Google Sheet no está configurada."});return}dt.warning("Proyecto guardado con aviso",{description:he.sheetSyncMessage})},fr=async()=>{if(!(!(n!=null&&n.id)||!K.trim()||I))try{H(!0);const he=await c6(n.id,K);Le("comentarios",he.comments),F(""),await $e(),he.sheetSyncStatus==="synced"?dt.success("Comentario agregado al historial",{description:"También se actualizó la columna Comentarios del Google Sheet."}):he.sheetSyncStatus==="skipped"?dt.success("Comentario agregado al historial",{description:"Se guardó como comentario interno. La sincronización con Sheet no está configurada."}):dt.warning("Comentario agregado con aviso",{description:he.sheetSyncMessage})}catch(he){console.error("Error agregando comentario al historial:",he);const Be=he instanceof Error?he.message:"No se pudo agregar el comentario al historial.";dt.error("No se pudo agregar el comentario",{description:Be})}finally{H(!1)}},Yn=async()=>{if(!Jt||T||ne.current)return;ne.current=!0;const he=g?S:w?{...S,status:(n==null?void 0:n.status)??""}:{...S,status:(n==null?void 0:n.status)??"",monto:(n==null?void 0:n.monto)??null};try{M(!0),ce(null),U("Guardando y sincronizando con Google Sheet…");const Be=At,et=at(Be.map(qe).filter(Boolean)),rt=E&&n?await c(n.id,{...he,pricingItems:w?q:void 0}):await l({...he,bu:aS(Be),cm:et.join(", "),id:crypto.randomUUID(),createdAt:Date.now(),pricingItems:w?q:void 0});Dt(rt),t(!1)}catch(Be){console.error("Error guardando proyecto:",Be);const et=Be instanceof Error?Be.message:"No se pudo guardar el proyecto. Revisa los permisos o intenta de nuevo.";ce(et),dt.error("No se pudo guardar el proyecto",{description:et})}finally{ne.current=!1,M(!1),U(null)}},en=!!S.status;return d.jsx(ri,{open:e,onOpenChange:he=>{T||ne.current||t(he)},children:d.jsxs(ls,{className:"max-w-3xl max-h-[92vh] overflow-y-auto p-0 gap-0",children:[d.jsx("div",{className:"h-2.5 w-full rounded-t-lg",style:{backgroundColor:AN(S.color)}}),d.jsxs("div",{className:"px-7 pt-6 pb-7",children:[d.jsx(cs,{className:"space-y-3",children:d.jsx("div",{className:"flex items-start justify-between gap-4",children:d.jsxs("div",{className:"flex-1",children:[d.jsx(us,{className:"text-2xl tracking-tight",children:E?S.nombre||"Sin título":"Nuevo proyecto"}),d.jsxs(ds,{className:"mt-1 flex items-center gap-2 text-xs",children:[d.jsx(u3,{className:"w-3.5 h-3.5"}),S.mes," · ",S.anio,en&&d.jsx(sn,{variant:"secondary",className:"ml-2",children:"Cerrado"})]})]})})}),d.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-5 mt-6",children:[d.jsxs("div",{className:"md:col-span-2 space-y-1.5",children:[d.jsxs(Ge,{children:["Nombre del proyecto ",d.jsx("span",{className:"text-destructive",children:"*"})]}),d.jsx(ot,{value:S.nombre,onChange:he=>Le("nombre",he.target.value),placeholder:"Ej: Promoción Día de las Madres",className:"h-10"})]}),d.jsxs("div",{className:"md:col-span-2 space-y-2",children:[d.jsx(Ge,{children:"Etiqueta de color"}),d.jsx(bU,{value:S.color,onChange:he=>Le("color",he)})]}),d.jsx(Hs,{className:"md:col-span-2 my-1"}),(h||m)&&d.jsxs("div",{className:xe("md:col-span-2 flex items-center justify-between gap-3 rounded-xl border px-3 py-2 text-xs",m?"border-amber-300/50 bg-amber-50 text-amber-900":"border-border bg-muted/30 text-muted-foreground"),children:[d.jsx("span",{className:"flex items-center gap-2",children:h?d.jsxs(d.Fragment,{children:[d.jsx(Kt,{className:"h-3.5 w-3.5 animate-spin"}),"Cargando listas…"]}):d.jsxs(d.Fragment,{children:[d.jsx(Pd,{className:"h-3.5 w-3.5"}),"No se pudieron cargar las listas. Se usaron opciones locales."]})}),m&&d.jsx("button",{type:"button",onClick:()=>void b(),className:"font-medium text-amber-950 underline-offset-4 hover:underline",children:"Reintentar"})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsxs(Ge,{children:["Cliente ",d.jsx("span",{className:"text-destructive",children:"*"})]}),d.jsx(_r,{value:S.cliente,options:ie,onValueChange:Xt,placeholder:"Seleccionar…",searchPlaceholder:"Buscar cliente…",emptyText:"No se encontró ese cliente."})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsxs(Ge,{children:["Marca ",d.jsx("span",{className:"text-destructive",children:"*"})]}),d.jsx(kg,{values:Me,options:De,onValuesChange:he=>Le("marca",r8(he)),placeholder:"Seleccionar una o varias marcas…",searchPlaceholder:"Buscar marca…",emptyText:"No se encontró esa marca.",summaryLabel:"marcas seleccionadas"})]}),jt?d.jsxs("div",{className:"md:col-span-2 space-y-2 rounded-xl border border-primary/20 bg-primary/5 p-3",children:[d.jsxs("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between",children:[d.jsxs(Ge,{children:["BU Solicita (Países) ",d.jsx("span",{className:"text-destructive",children:"*"})]}),d.jsxs("span",{className:"text-xs font-medium text-primary",children:[N.length," seleccionado(s)"]})]}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Para Walmart Connect WMC puedes seleccionar varios países. Todos quedarán asociados a un solo proyecto y una sola fila del Sheet."}),d.jsxs("div",{className:"relative",children:[d.jsx(Ws,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),d.jsx(ot,{value:$,onChange:he=>L(he.target.value),placeholder:"Buscar país…",className:"h-9 pl-9 bg-card"})]}),d.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:Ct.map(he=>{const Be=N.some(rt=>Ae(rt)===Ae(he)),et=qe(he);return d.jsxs("label",{className:xe("flex cursor-pointer items-start gap-2 rounded-lg border bg-card px-3 py-2 text-sm transition-colors",Be?"border-primary/50 bg-primary/10":"border-border hover:bg-muted/40"),children:[d.jsx(iC,{checked:Be,onCheckedChange:rt=>gn(he,rt===!0),className:"mt-0.5"}),d.jsxs("span",{className:"leading-tight",children:[d.jsx("span",{className:"block font-medium",children:he}),d.jsxs("span",{className:"text-xs text-muted-foreground",children:["CM: ",et||"—"]})]})]},he)})})]}):d.jsxs("div",{className:"md:col-span-2 space-y-1.5",children:[d.jsxs(Ge,{children:["BU Solicita (Países) ",d.jsx("span",{className:"text-destructive",children:"*"})]}),d.jsx(kg,{values:Je,options:Xe,onValuesChange:gt,placeholder:"Seleccionar uno o varios países…",searchPlaceholder:"Buscar país…",emptyText:"No se encontró ese país.",summaryLabel:"países seleccionados"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Si seleccionas varios países, todos quedarán asociados a un solo proyecto y una sola fila del Sheet."})]}),d.jsxs("div",{className:xe("space-y-1.5",jt&&"md:col-span-2"),children:[d.jsxs(Ge,{className:"flex items-center gap-1.5",children:["Country Manager ",d.jsx("span",{className:"text-xs text-muted-foreground",children:"(automático)"})]}),jt?d.jsx("div",{className:"min-h-10 rounded-md border border-border bg-muted/30 px-3 py-2 text-sm",children:vn.length===0?d.jsx("span",{className:"text-muted-foreground",children:"Selecciona uno o más países."}):d.jsx("div",{className:"flex flex-wrap gap-1.5",children:vn.map(({country:he,manager:Be})=>d.jsxs(sn,{variant:"secondary",className:"font-normal",children:[he,": ",Be||"—"]},he))})}):d.jsx("div",{className:"min-h-10 rounded-md border border-border bg-muted/30 px-3 py-2 text-sm",children:Mt.length===0?d.jsx("span",{className:"text-muted-foreground",children:"Selecciona uno o más países."}):d.jsx("div",{className:"flex flex-wrap gap-1.5",children:Mt.map(({country:he,manager:Be})=>d.jsxs(sn,{variant:"secondary",className:"font-normal",children:[he,": ",Be||"—"]},he))})})]}),on&&w&&d.jsx("div",{className:"md:col-span-2 rounded-xl border border-amber-300/50 bg-amber-50 px-3 py-2 text-xs text-amber-900",children:"Si seleccionas varios países, el total de la estimación interna corresponde al proyecto completo y no se multiplica por país."}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsxs(Ge,{children:["Solicitado por ",d.jsx("span",{className:"text-destructive",children:"*"})]}),d.jsx(ot,{value:S.solicitante,onChange:he=>Le("solicitante",he.target.value),placeholder:"Nombre de quien solicita",className:"h-10"})]}),d.jsx(i8,{isEdit:E,items:re,loading:fe,error:de,note:K,hasMore:Y,loadingMore:R,addingNote:I,onNoteChange:F,onAddNote:fr,onRefresh:$e,onLoadMore:Ke}),d.jsx(Hs,{className:"md:col-span-2 my-1"}),d.jsxs("div",{className:"md:col-span-2 space-y-1.5",children:[d.jsxs(Ge,{children:["Link del Brief"," ",d.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(carpeta de Fulgencio)"})]}),d.jsx(ot,{value:S.briefLink,onChange:he=>Le("briefLink",he.target.value),placeholder:"https://drive.google.com/…",className:"h-10"})]}),d.jsx("div",{className:"md:col-span-2",children:d.jsx(B_,{label:"Links de Propuestas",links:S.propuestaLinks,onChange:he=>Le("propuestaLinks",he),emptyText:"Aún no hay propuestas. Pega tantos links como necesites."})}),d.jsx("div",{className:"md:col-span-2",children:d.jsx(B_,{label:"Links de Artes Finales",prefix:"AF",links:S.afLinks,onChange:he=>Le("afLinks",he),emptyText:"Aún no hay artes finales."})}),d.jsx(Hs,{className:"md:col-span-2 my-1"}),w&&d.jsx(jB,{client:S.cliente,items:q,onChange:ue,loading:te,error:se}),d.jsx(Hs,{className:"md:col-span-2 my-1"}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsxs(Ge,{className:"flex items-center gap-1.5 pl-1",children:["Estatus",!g&&d.jsx(eP,{className:"w-3 h-3 text-muted-foreground"})]}),g?d.jsxs(uU,{value:S.status||"_none",onValueChange:he=>Le("status",he==="_none"?"":he),children:[d.jsx(qC,{className:"h-10",children:d.jsx(dU,{placeholder:"Sin estatus"})}),d.jsxs(GC,{children:[d.jsx(Tg,{value:"_none",children:"Sin estatus"}),We.map(he=>d.jsx(Tg,{value:he,children:he},he))]})]}):d.jsx("div",{className:"h-10 px-3 flex items-center rounded-md border border-border bg-muted/30 text-sm text-foreground",children:S.status||"Sin estatus"}),!g&&d.jsx("p",{className:"pl-1 text-[11px] text-muted-foreground",children:"Solo el Director Creativo puede cambiar el estatus."})]})]}),(J||P)&&d.jsxs("div",{className:xe("mt-5 flex items-start gap-2 rounded-xl border px-3 py-2 text-sm",J?"border-destructive/30 bg-destructive/5 text-destructive":"border-primary/20 bg-primary/5 text-primary"),children:[J?d.jsx(Pd,{className:"mt-0.5 h-4 w-4 flex-shrink-0"}):d.jsx(Kt,{className:"mt-0.5 h-4 w-4 flex-shrink-0 animate-spin"}),d.jsx("span",{children:J||P})]})]}),d.jsx(Rf,{className:"px-7 py-4 border-t bg-muted/30 rounded-b-lg sm:justify-between",children:d.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[d.jsx("div",{children:E&&n&&x&&a&&d.jsxs(Ee,{type:"button",variant:"destructive",onClick:()=>a(n),disabled:T||i,className:"gap-1.5 rounded-full",children:[i?d.jsx(Kt,{className:"h-4 w-4 animate-spin"}):d.jsx(hf,{className:"h-4 w-4"}),i?"Eliminando…":"Eliminar proyecto"]})}),d.jsxs("div",{className:"flex justify-end gap-2",children:[d.jsx(Ee,{variant:"ghost",onClick:()=>{T||ne.current||t(!1)},disabled:T||i,children:"Cancelar"}),d.jsxs(Ee,{onClick:Yn,disabled:!Jt||T||i,children:[T&&d.jsx(Kt,{className:"mr-1.5 h-4 w-4 animate-spin"}),T?"Guardando…":E?"Guardar cambios":"Crear proyecto"]})]})]})})]})})}function i8({isEdit:e,items:t,loading:n,error:a,note:i,hasMore:l,loadingMore:c,addingNote:f,onNoteChange:h,onAddNote:m,onRefresh:b,onLoadMore:g}){return d.jsxs("div",{className:"md:col-span-2 rounded-2xl border border-border bg-muted/20 p-4",children:[d.jsxs("div",{className:"mb-3 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[d.jsxs("div",{className:"flex items-start gap-2.5",children:[d.jsx("span",{className:"mt-0.5 flex h-8 w-8 items-center justify-center rounded-full bg-primary/10 text-primary",children:d.jsx(P1,{className:"h-4 w-4"})}),d.jsxs("div",{children:[d.jsx("h3",{className:"text-sm font-semibold",children:"Actividad del proyecto"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Comentarios y movimientos recientes con fecha."})]})]}),e&&d.jsxs(Ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>void b(),disabled:n,className:"h-8 rounded-full px-2.5 text-xs text-muted-foreground hover:text-foreground",children:[n?d.jsx(Kt,{className:"mr-1 h-3.5 w-3.5 animate-spin"}):null,"Actualizar"]})]}),e?d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"rounded-xl border border-border bg-card p-3",children:[d.jsx(Ge,{className:"text-xs font-medium",children:"Agregar comentario o solicitud adicional"}),d.jsxs("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row",children:[d.jsx(ma,{value:i,onChange:x=>h(x.target.value),placeholder:"Ej: CM pidió ajustar artes, agregar una marca o cambiar una fecha…",rows:2,className:"min-h-[64px] flex-1 resize-none"}),d.jsxs(Ee,{type:"button",onClick:()=>void m(),disabled:!i.trim()||f,className:"gap-1.5 rounded-full sm:self-end",children:[f?d.jsx(Kt,{className:"h-4 w-4 animate-spin"}):d.jsx(sP,{className:"h-4 w-4"}),"Agregar"]})]})]}),a&&d.jsxs("div",{className:"flex items-start gap-2 rounded-xl border border-amber-300/50 bg-amber-50 px-3 py-2 text-xs text-amber-900",children:[d.jsx(Pd,{className:"mt-0.5 h-3.5 w-3.5 flex-shrink-0"}),d.jsx("span",{children:a})]}),n&&t.length===0?d.jsxs("div",{className:"flex items-center gap-2 rounded-xl border border-border bg-card px-3 py-3 text-sm text-muted-foreground",children:[d.jsx(Kt,{className:"h-4 w-4 animate-spin"}),"Cargando actividad…"]}):t.length===0?d.jsx("div",{className:"rounded-xl border border-border bg-card px-3 py-3 text-sm text-muted-foreground",children:"Aún no hay actividad registrada. Los próximos comentarios o cambios quedarán aquí."}):d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between gap-3 px-0.5 text-[11px] text-muted-foreground",children:[d.jsx("span",{children:"Mostrando los movimientos más recientes."}),d.jsxs("span",{children:[t.length," visibles"]})]}),d.jsx("div",{className:"max-h-[440px] space-y-2 overflow-y-auto pr-1",children:t.map(x=>{const w=Z6(x.description);return d.jsxs("div",{className:"rounded-xl border border-border bg-card px-3 py-3 shadow-sm",children:[d.jsxs("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-start sm:justify-between",children:[d.jsxs("div",{children:[d.jsx("p",{className:"text-sm font-medium",children:x.title}),d.jsxs("p",{className:"text-xs text-muted-foreground",children:[x.actorName,x.actorEmail?` · ${x.actorEmail}`:""]})]}),d.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:[d.jsx(Fs,{className:"h-3.5 w-3.5"}),Q6(x.createdAt)]})]}),w.length>0&&d.jsx("div",{className:"mt-2 space-y-1 text-sm text-muted-foreground",children:w.map(E=>d.jsx("p",{children:E},E))})]},x.id)})}),l&&d.jsx("div",{className:"flex justify-center pt-1",children:d.jsxs(Ee,{type:"button",variant:"outline",size:"sm",onClick:()=>void g(),disabled:c,className:"rounded-full",children:[c?d.jsx(Kt,{className:"mr-1.5 h-4 w-4 animate-spin"}):null,c?"Cargando…":"Cargar más"]})})]})]}):d.jsx("div",{className:"rounded-xl border border-dashed border-border bg-card/70 px-3 py-3 text-sm text-muted-foreground",children:"El historial se activará cuando el proyecto sea creado."})]})}const o8="https://agenteit.digitalcompass.agency/webhook/tablero-cdc-sync-registro-horas";function l8(){return"".trim()||o8}async function c8(e,t,n=2e4){const a=new AbortController,i=window.setTimeout(()=>a.abort(),n);try{return await fetch(e,{...t,signal:a.signal})}finally{window.clearTimeout(i)}}function u8(e){return new Promise(t=>window.setTimeout(t,e))}async function Hp(e){const t=String(e||"").trim();if(!t)throw new Error("No se encontró el proyecto para sincronizar las horas.");const{data:{session:n},error:a}=await Se.auth.getSession();if(a)throw a;if(!(n!=null&&n.access_token))throw new Error("No se encontró una sesión activa para sincronizar el registro de horas.");let i=null;for(let l=1;l<=3;l+=1)try{const c=await c8(l8(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"sync_project",project_id:t,access_token:n.access_token,source:"tablero-cdc-time"})}),f=await c.text();let h=null;if(f)try{h=JSON.parse(f)}catch{h=null}if(!c.ok||(h==null?void 0:h.ok)===!1)throw new Error((h==null?void 0:h.message)||f||`Error ${c.status} al sincronizar Excel.`);return h||{ok:!0,projectId:t}}catch(c){i=c instanceof Error?c:new Error(String(c||"Error de sincronización")),l<3&&await u8(l*1200)}throw i||new Error("No se pudo sincronizar el registro de horas con Excel.")}const Qi=10;function qp(){const e=new Date,t=e.getTimezoneOffset()*6e4;return new Date(e.getTime()-t).toISOString().slice(0,10)}function d8(e){return at(String(e||"").split(",").map(t=>t.trim()).filter(Boolean))}function oo(e,t=!1){const n=Math.max(0,Math.round(Number(e||0))),a=Math.floor(n/60),i=n%60;return t?a&&i?`${a} h ${i} min`:a?`${a} h`:`${i} min`:a&&i?`${a} ${a===1?"hora":"horas"} ${i} min`:a?`${a} ${a===1?"hora":"horas"}`:`${i} min`}function f8(e){if(!e)return"—";const t=new Date(`${e}T12:00:00`);return Number.isFinite(t.getTime())?new Intl.DateTimeFormat("es-DO",{day:"2-digit",month:"short",year:"numeric"}).format(t):e}function h8(e){return new Intl.DateTimeFormat("es-DO",{day:"2-digit",month:"short",hour:"numeric",minute:"2-digit"}).format(new Date(e))}function iS(e,t){const n=new Map;for(const a of e){const i=t(a).trim()||"Sin especificar",l=Ae(i)||i.toLowerCase(),c=n.get(l);c?c.minutes+=a.durationMinutes:n.set(l,{key:l,label:i,minutes:a.durationMinutes})}return[...n.values()].sort((a,i)=>i.minutes-a.minutes||a.label.localeCompare(i.label,"es"))}function oS(e){const n=(e instanceof Error?e.message:String(e||"")).toLowerCase();return n.includes("tablero_cdc_project_time_entries")||n.includes("relation")||n.includes("schema cache")}function m8({open:e,onOpenChange:t,project:n}){const{lists:a}=bc(),[i,l]=v.useState([]),[c,f]=v.useState(null),h=v.useRef(0),[m,b]=v.useState(!1),[g,x]=v.useState(!1),[w,E]=v.useState(null),[S,C]=v.useState(null),[N,A]=v.useState(null),[T,M]=v.useState(null),[$,L]=v.useState(""),[P,U]=v.useState(""),[J,ce]=v.useState(""),[re,me]=v.useState(""),[fe,ge]=v.useState(qp()),[de,k]=v.useState(""),[K,F]=v.useState(1),Y=v.useMemo(()=>d8((n==null?void 0:n.bu)||""),[n==null?void 0:n.bu]),V=v.useMemo(()=>at([...Y,...a.bus,$]),[$,a.bus,Y]),R=c===(n==null?void 0:n.id)?i:[],O=v.useMemo(()=>R.reduce((pe,$e)=>pe+$e.durationMinutes,0),[R]),I=v.useMemo(()=>iS(R,pe=>pe.country),[R]),H=v.useMemo(()=>iS(R,pe=>pe.taskName),[R]),q=v.useMemo(()=>at(R.map(pe=>pe.taskName)).slice(0,8),[R]),ee=Math.max(1,Math.ceil(R.length/Qi)),te=Math.min(K,ee),Q=(te-1)*Qi,se=R.slice(Q,Q+Qi),je=R.length===0?0:Q+1,ze=Math.min(Q+Qi,R.length),Ne=v.useCallback(async()=>{const pe=n==null?void 0:n.id;if(!pe)return;const $e=++h.current;try{b(!0),A(null);const Ke=await r6(pe);if($e!==h.current)return;l(Ke),f(pe),Hp(pe).then(()=>{$e===h.current&&M(null)}).catch(Le=>{console.warn("No se pudo reconciliar el registro de horas con Excel:",Le)})}catch(Ke){if($e!==h.current)return;console.error("No se pudo cargar el tiempo del proyecto:",Ke),l([]),f(pe),A(oS(Ke)?"El módulo de tiempo todavía no está instalado en Supabase. Ejecuta supabase_project_time_entries.sql.":Ke instanceof Error?Ke.message:"No se pudo cargar el desglose de tiempo.")}finally{$e===h.current&&b(!1)}},[n==null?void 0:n.id]);v.useEffect(()=>{!e||!(n!=null&&n.id)||(h.current+=1,f(null),l([]),b(!0),L(Y[0]||""),U(""),ce(""),me(""),ge(qp()),k(""),M(null),C(null),F(1),Ne())},[Ne,e,n==null?void 0:n.id,Y]),v.useEffect(()=>{K>ee&&F(ee)},[K,ee]);const ne=Math.max(0,Math.floor(Number(J||0)))*60+Math.max(0,Math.floor(Number(re||0))),Me=Number.isFinite(ne)&&ne>0,Je=!!($.trim()&&P.trim()&&fe&&Me),ie=!!S,De=()=>{L(Y[0]||""),U(""),ce(""),me(""),ge(qp()),k(""),C(null)},Xe=pe=>{const $e=Math.max(0,Math.round(pe.durationMinutes));C(pe.id),L(pe.country),U(pe.taskName),ce(String(Math.floor($e/60))),me(String($e%60)),ge(pe.workDate),k(pe.notes||""),A(null),requestAnimationFrame(()=>{var Ke;(Ke=document.querySelector('[data-project-time-form="true"]'))==null||Ke.scrollIntoView({behavior:"smooth",block:"start"})})},We=async()=>{if(!(!(n!=null&&n.id)||!Je||g))try{x(!0),A(null);const pe={country:$,taskName:P,durationMinutes:ne,workDate:fe,notes:de},$e=S?await s6(S,pe):await a6(n.id,pe);S?l(Ke=>Ke.map(Le=>Le.id===$e.id?$e:Le).sort((Le,ue)=>ue.workDate.localeCompare(Le.workDate)||ue.createdAt-Le.createdAt)):(l(Ke=>[$e,...Ke]),F(1)),De(),dt.success(S?"Registro de tiempo actualizado":"Tiempo registrado",{description:`${oo($e.durationMinutes,!0)} · ${$e.country} · ${$e.taskName}`});try{await Hp(n.id),M(null)}catch(Ke){console.warn("El tiempo se guardó, pero Excel no pudo sincronizarse todavía:",Ke),M("El tiempo quedó guardado en el Tablero, pero el Excel no pudo actualizarse ahora. Se reintentará automáticamente al volver a abrir Tiempo."),dt.warning("Tiempo guardado; Excel pendiente",{description:"La app volverá a intentar la sincronización automáticamente."})}}catch(pe){console.error("No se pudo registrar el tiempo:",pe);const $e=oS(pe)?"Ejecuta supabase_project_time_entries.sql en Supabase antes de usar este módulo.":pe instanceof Error?pe.message:"No se pudo registrar el tiempo.";A($e),dt.error("No se pudo registrar el tiempo",{description:$e})}finally{x(!1)}},Ct=async pe=>{if(window.confirm(`¿Eliminar este registro de ${oo(pe.durationMinutes,!0)} para “${pe.taskName}”?`))try{if(E(pe.id),await i6(pe.id),l(Ke=>Ke.filter(Le=>Le.id!==pe.id)),S===pe.id&&De(),dt.success("Registro de tiempo eliminado"),n!=null&&n.id)try{await Hp(n.id),M(null)}catch(Ke){console.warn("El registro se eliminó, pero Excel no pudo sincronizarse todavía:",Ke),M("El registro se eliminó del Tablero, pero el Excel no pudo actualizarse ahora. Se reintentará automáticamente al volver a abrir Tiempo."),dt.warning("Registro eliminado; Excel pendiente",{description:"La app volverá a intentar la sincronización automáticamente."})}}catch(Ke){console.error("No se pudo eliminar el registro de tiempo:",Ke),dt.error("No se pudo eliminar",{description:Ke instanceof Error?Ke.message:"Intenta nuevamente."})}finally{E(null)}};return d.jsx(ri,{open:e,onOpenChange:t,children:d.jsxs(ls,{className:"max-h-[92vh] max-w-5xl overflow-y-auto p-0 gap-0",children:[d.jsx("div",{className:"border-b border-border bg-muted/20 px-6 py-5 sm:px-7",children:d.jsx(cs,{children:d.jsxs("div",{className:"flex items-start gap-3",children:[d.jsx("span",{className:"mt-0.5 flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-2xl bg-primary/10 text-primary",children:d.jsx(Fs,{className:"h-5 w-5"})}),d.jsxs("div",{className:"min-w-0",children:[d.jsx(us,{className:"text-xl tracking-tight",children:"Tiempo dedicado"}),d.jsxs(ds,{className:"mt-1",children:["Desglose por país y tarea para ",d.jsx("span",{className:"font-medium text-foreground",children:(n==null?void 0:n.nombre)||"este proyecto"}),"."]})]})]})})}),d.jsxs("div",{className:"space-y-6 px-6 py-6 sm:px-7",children:[d.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[d.jsx(Vp,{icon:d.jsx(Fs,{className:"h-4 w-4"}),label:"Total dedicado",value:oo(O,!0)}),d.jsx(Vp,{icon:d.jsx(zd,{className:"h-4 w-4"}),label:"Países con tiempo",value:String(I.length)}),d.jsx(Vp,{icon:d.jsx(Ld,{className:"h-4 w-4"}),label:"Tareas registradas",value:String(H.length)})]}),d.jsxs("section",{"data-project-time-form":"true",className:"rounded-2xl border border-border bg-card p-4 sm:p-5",children:[d.jsxs("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[d.jsxs("div",{children:[d.jsx("h3",{className:"text-sm font-semibold",children:ie?"Editar tiempo":"Agregar tiempo"}),d.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:ie?"Modifica los datos del registro seleccionado y guarda los cambios.":"Cada registro queda asociado a este proyecto y al usuario que lo agrega."})]}),d.jsxs(Ee,{type:"button",variant:"ghost",size:"sm",className:"h-8 self-start rounded-full px-2.5 text-xs text-muted-foreground",onClick:()=>void Ne(),disabled:m,children:[m?d.jsx(Kt,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):d.jsx(go,{className:"mr-1.5 h-3.5 w-3.5"}),"Actualizar"]})]}),d.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-12",children:[d.jsxs("div",{className:"space-y-1.5 md:col-span-4",children:[d.jsx(Ge,{children:"País"}),d.jsx(_r,{value:$,options:V,onValueChange:L,placeholder:"Seleccionar país…",searchPlaceholder:"Buscar país…",emptyText:"No se encontró ese país."})]}),d.jsxs("div",{className:"space-y-1.5 md:col-span-4",children:[d.jsx(Ge,{children:"Tarea"}),d.jsx(ot,{value:P,onChange:pe=>U(pe.target.value),placeholder:"Ej: Diseño, adaptación, reunión…",className:"h-10",maxLength:160})]}),d.jsxs("div",{className:"space-y-1.5 md:col-span-2",children:[d.jsx(Ge,{children:"Horas"}),d.jsx(ot,{type:"number",min:0,step:1,inputMode:"numeric",value:J,onChange:pe=>ce(pe.target.value),placeholder:"0",className:"h-10"})]}),d.jsxs("div",{className:"space-y-1.5 md:col-span-2",children:[d.jsx(Ge,{children:"Minutos"}),d.jsx(ot,{type:"number",min:0,max:59,step:1,inputMode:"numeric",value:re,onChange:pe=>{const $e=pe.target.value;if($e===""){me("");return}me(String(Math.min(59,Math.max(0,Math.floor(Number($e)||0)))))},placeholder:"0",className:"h-10"})]}),d.jsxs("div",{className:"space-y-1.5 md:col-span-4",children:[d.jsx(Ge,{children:"Fecha"}),d.jsx(ot,{type:"date",value:fe,onChange:pe=>ge(pe.target.value),className:"h-10"})]}),d.jsxs("div",{className:"space-y-1.5 md:col-span-8",children:[d.jsxs(Ge,{children:["Nota ",d.jsx("span",{className:"font-normal text-muted-foreground",children:"(opcional)"})]}),d.jsx(ma,{value:de,onChange:pe=>k(pe.target.value),placeholder:"Detalle breve de lo realizado…",rows:2,maxLength:600,className:"min-h-[64px] resize-none"})]})]}),q.length>0&&d.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-1.5",children:[d.jsx("span",{className:"mr-1 text-[11px] text-muted-foreground",children:"Tareas recientes:"}),q.map(pe=>d.jsx("button",{type:"button",onClick:()=>U(pe),className:"rounded-full border border-border bg-muted/30 px-2.5 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:pe},pe))]}),d.jsxs("div",{className:"mt-4 flex flex-col gap-2 border-t border-border/70 pt-4 sm:flex-row sm:items-center sm:justify-between",children:[d.jsxs("p",{className:"text-xs text-muted-foreground",children:["Duración a registrar: ",d.jsx("span",{className:"font-semibold text-foreground",children:oo(ne,!0)})]}),d.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[ie&&d.jsx(Ee,{type:"button",variant:"outline",onClick:De,disabled:g,className:"rounded-full",children:"Cancelar"}),d.jsxs(Ee,{type:"button",onClick:()=>void We(),disabled:!Je||g||m,className:"gap-1.5 rounded-full",children:[g?d.jsx(Kt,{className:"h-4 w-4 animate-spin"}):ie?d.jsx(lv,{className:"h-4 w-4"}):d.jsx(Ir,{className:"h-4 w-4"}),g?"Guardando…":ie?"Guardar cambios":"Agregar registro"]})]})]}),T&&d.jsx("div",{className:"mt-4 rounded-xl border border-amber-300/60 bg-amber-50 px-3 py-2 text-xs text-amber-800",children:T}),N&&d.jsx("div",{className:"mt-4 rounded-xl border border-destructive/20 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:N})]}),d.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[d.jsx(lS,{icon:d.jsx(zd,{className:"h-4 w-4"}),title:"Desglose por país",rows:I,totalMinutes:O,emptyText:"Aún no hay países con tiempo registrado."}),d.jsx(lS,{icon:d.jsx(Ld,{className:"h-4 w-4"}),title:"Desglose por tarea",rows:H,totalMinutes:O,emptyText:"Aún no hay tareas con tiempo registrado."})]}),d.jsxs("section",{className:"overflow-hidden rounded-2xl border border-border bg-card",children:[d.jsxs("div",{className:"flex flex-col gap-2 border-b border-border bg-muted/20 px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[d.jsxs("div",{children:[d.jsx("h3",{className:"text-sm font-semibold",children:"Registros detallados"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:R.length===0?"Sin registros todavía.":`Mostrando ${je}-${ze} de ${R.length}.`})]}),R.length>Qi&&d.jsxs("span",{className:"text-xs text-muted-foreground",children:["Página ",te," de ",ee]})]}),m&&R.length===0?d.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-12 text-sm text-muted-foreground",children:[d.jsx(Kt,{className:"h-4 w-4 animate-spin"}),"Cargando tiempo…"]}):R.length===0?d.jsxs("div",{className:"px-4 py-10 text-center",children:[d.jsx(Fs,{className:"mx-auto h-8 w-8 text-muted-foreground/40"}),d.jsx("p",{className:"mt-2 text-sm font-medium",children:"Aún no hay tiempo registrado"}),d.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Agrega el primer registro usando el formulario de arriba."})]}):d.jsx("div",{className:"divide-y divide-border/70",children:se.map(pe=>d.jsx(p8,{entry:pe,deleting:w===pe.id,editing:S===pe.id,onEdit:()=>Xe(pe),onDelete:()=>void Ct(pe)},pe.id))}),R.length>Qi&&d.jsxs("div",{className:"flex items-center justify-between border-t border-border bg-muted/10 px-4 py-3",children:[d.jsxs(Ee,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1 rounded-full",disabled:te<=1,onClick:()=>F(pe=>Math.max(1,pe-1)),children:[d.jsx(ff,{className:"h-3.5 w-3.5"}),"Anterior"]}),d.jsxs("span",{className:"text-xs text-muted-foreground",children:[te," / ",ee]}),d.jsxs(Ee,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1 rounded-full",disabled:te>=ee,onClick:()=>F(pe=>Math.min(ee,pe+1)),children:["Siguiente",d.jsx(oc,{className:"h-3.5 w-3.5"})]})]})]})]})]})})}function Vp({icon:e,label:t,value:n}){return d.jsxs("div",{className:"flex items-center gap-3 rounded-2xl border border-border bg-card px-4 py-3.5 shadow-sm",children:[d.jsx("span",{className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary",children:e}),d.jsxs("div",{className:"min-w-0",children:[d.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:t}),d.jsx("p",{className:"mt-0.5 truncate text-lg font-semibold tabular-nums text-foreground",children:n})]})]})}function lS({icon:e,title:t,rows:n,totalMinutes:a,emptyText:i}){return d.jsxs("section",{className:"rounded-2xl border border-border bg-card p-4",children:[d.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[d.jsx("span",{className:"text-primary",children:e}),d.jsx("h3",{className:"text-sm font-semibold",children:t})]}),n.length===0?d.jsx("p",{className:"rounded-xl border border-dashed border-border bg-muted/20 px-3 py-5 text-center text-xs text-muted-foreground",children:i}):d.jsx("div",{className:"space-y-3",children:n.map(l=>{const c=a>0?l.minutes/a*100:0;return d.jsxs("div",{children:[d.jsxs("div",{className:"mb-1 flex items-center justify-between gap-3 text-xs",children:[d.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",title:l.label,children:l.label}),d.jsx("span",{className:"flex-shrink-0 font-semibold tabular-nums text-foreground",children:oo(l.minutes,!0)})]}),d.jsx("div",{className:"h-1.5 overflow-hidden rounded-full bg-muted",children:d.jsx("div",{className:"h-full rounded-full bg-primary/70 transition-[width]",style:{width:`${Math.max(2,Math.min(100,c))}%`}})})]},l.key)})})]})}function p8({entry:e,deleting:t,editing:n,onEdit:a,onDelete:i}){return d.jsxs("div",{className:"grid grid-cols-1 gap-3 px-4 py-4 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-start",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsx("span",{className:"font-medium text-sm text-foreground",children:e.taskName}),d.jsx(sn,{variant:"secondary",className:"h-5 px-1.5 text-[10px] font-normal",children:e.country}),d.jsx("span",{className:"rounded-full bg-primary/10 px-2 py-0.5 text-xs font-semibold tabular-nums text-primary",children:oo(e.durationMinutes,!0)})]}),e.notes&&d.jsx("p",{className:"mt-1.5 whitespace-pre-wrap text-xs leading-relaxed text-muted-foreground",children:e.notes}),d.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[d.jsxs("span",{className:"inline-flex items-center gap-1",children:[d.jsx(fg,{className:"h-3 w-3"}),f8(e.workDate)]}),d.jsxs("span",{className:"inline-flex items-center gap-1",title:e.actorEmail||e.actorName,children:[d.jsx(wP,{className:"h-3 w-3"}),e.actorName]}),d.jsxs("span",{children:["Registrado ",h8(e.createdAt)]})]})]}),d.jsxs("div",{className:"flex items-center justify-self-end gap-1",children:[d.jsx(Ee,{type:"button",variant:"ghost",size:"icon",onClick:a,disabled:t,className:xe("h-8 w-8 rounded-full text-muted-foreground hover:bg-primary/10 hover:text-primary",n&&"bg-primary/10 text-primary"),title:"Editar registro",children:d.jsx(lv,{className:"h-4 w-4"})}),d.jsx(Ee,{type:"button",variant:"ghost",size:"icon",onClick:i,disabled:t,className:xe("h-8 w-8 rounded-full text-muted-foreground hover:bg-destructive/10 hover:text-destructive",t&&"text-destructive"),title:"Eliminar registro",children:t?d.jsx(Kt,{className:"h-4 w-4 animate-spin"}):d.jsx(hf,{className:"h-4 w-4"})})]})]})}function g8(e,t=[]){let n=[];function a(l,c){const f=v.createContext(c);f.displayName=l+"Context";const h=n.length;n=[...n,c];const m=g=>{var N;const{scope:x,children:w,...E}=g,S=((N=x==null?void 0:x[e])==null?void 0:N[h])||f,C=v.useMemo(()=>E,Object.values(E));return d.jsx(S.Provider,{value:C,children:w})};m.displayName=l+"Provider";function b(g,x){var S;const w=((S=x==null?void 0:x[e])==null?void 0:S[h])||f,E=v.useContext(w);if(E)return E;if(c!==void 0)return c;throw new Error(`\`${g}\` must be used within \`${l}\``)}return[m,b]}const i=()=>{const l=n.map(c=>v.createContext(c));return function(f){const h=(f==null?void 0:f[e])||l;return v.useMemo(()=>({[`__scope${e}`]:{...f,[e]:h}}),[f,h])}};return i.scopeName=e,[a,v8(i,...t)]}function v8(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const a=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(l){const c=a.reduce((f,{useScope:h,scopeName:m})=>{const g=h(l)[`__scope${m}`];return{...f,...g}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return n.scopeName=t.scopeName,n}var y8=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Jj=y8.reduce((e,t)=>{const n=ic(`Primitive.${t}`),a=v.forwardRef((i,l)=>{const{asChild:c,...f}=i,h=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(h,{...f,ref:l})});return a.displayName=`Primitive.${t}`,{...e,[t]:a}},{}),ty="Progress",ny=100,[b8]=g8(ty),[x8,w8]=b8(ty),Qj=v.forwardRef((e,t)=>{const{__scopeProgress:n,value:a=null,max:i,getValueLabel:l=_8,...c}=e;(i||i===0)&&!cS(i)&&console.error(S8(`${i}`,"Progress"));const f=cS(i)?i:ny;a!==null&&!uS(a,f)&&console.error(E8(`${a}`,"Progress"));const h=uS(a,f)?a:null,m=Qd(h)?l(h,f):void 0;return d.jsx(x8,{scope:n,value:h,max:f,children:d.jsx(Jj.div,{"aria-valuemax":f,"aria-valuemin":0,"aria-valuenow":Qd(h)?h:void 0,"aria-valuetext":m,role:"progressbar","data-state":tT(h,f),"data-value":h??void 0,"data-max":f,...c,ref:t})})});Qj.displayName=ty;var Zj="ProgressIndicator",eT=v.forwardRef((e,t)=>{const{__scopeProgress:n,...a}=e,i=w8(Zj,n);return d.jsx(Jj.div,{"data-state":tT(i.value,i.max),"data-value":i.value??void 0,"data-max":i.max,...a,ref:t})});eT.displayName=Zj;function _8(e,t){return`${Math.round(e/t*100)}%`}function tT(e,t){return e==null?"indeterminate":e===t?"complete":"loading"}function Qd(e){return typeof e=="number"}function cS(e){return Qd(e)&&!isNaN(e)&&e>0}function uS(e,t){return Qd(e)&&!isNaN(e)&&e<=t&&e>=0}function S8(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${ny}\`.`}function E8(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
- a positive number
- less than the value passed to \`max\` (or ${ny} if no \`max\` prop is set)
- \`null\` or \`undefined\` if the progress is indeterminate.
Defaulting to \`null\`.`}var nT=Qj,N8=eT;const rT=v.forwardRef(({className:e,value:t,...n},a)=>d.jsx(nT,{ref:a,className:xe("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...n,children:d.jsx(N8,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));rT.displayName=nT.displayName;function Fn(e){return String(e??"").trim().replace(/\s+/g," ")}function C8(e){return{id:Fn(e.id),recordSource:e.record_source==="app"?"app":"excel_history",sourceKey:Fn(e.source_key),workDate:Fn(e.work_date),projectName:Fn(e.project_name)||"Sin nombre",client:Fn(e.client),country:Fn(e.country),workedByName:Fn(e.worked_by_name)||"Sin nombre",workedByEmail:Fn(e.worked_by_email).toLowerCase(),taskName:Fn(e.task_name)||"Sin tarea",durationMinutes:Math.max(0,Math.round(Number(e.duration_minutes)||0)),notes:Fn(e.notes)}}async function j8({from:e,to:t}={}){const a=[];for(let i=0;;i+=1e3){const{data:l,error:c}=await Se.rpc("tablero_cdc_get_team_hours_records",{p_from:e||null,p_to:t||null,p_limit:1e3,p_offset:i});if(c)throw console.error("No se pudieron cargar las horas del equipo:",c),new Error("No pudimos cargar las horas ahora. Intenta nuevamente.");const f=l||[];if(a.push(...f),f.length<1e3)break}return a.map(C8).filter(i=>i.durationMinutes>0&&i.workDate)}async function T8(){const{data:e,error:t}=await Se.rpc("tablero_cdc_get_team_hours_roster");return t?(console.warn("No se pudo cargar el roster completo del equipo:",t),[]):(e||[]).map(n=>({email:Fn(n.email).toLowerCase(),fullName:Fn(n.full_name)||Fn(n.email)})).filter(n=>n.email&&n.fullName)}const id=8;function ry(e){return String(e??"").trim().replace(/\s+/g," ")}function Ks(e){return ry(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g," ").replace(/\s+/g," ").trim()}function dS(e){return Ks(e).split(" ").filter(t=>t.length>=3)}function R8(e,t,n){var h,m,b,g,x;const a=ry(t).toLowerCase();if(a){const w=n.find(E=>E.email===a);if(w)return w}const i=Ks(e);if(!i)return null;const l=n.find(w=>Ks(w.fullName)===i);if(l)return l;const c=new Set(dS(e));if(c.size<2)return null;const f=n.map(w=>{const E=new Set(dS(w.fullName)),S=[...c].filter(N=>E.has(N)),C=S.length===c.size||S.length===E.size;return{member:w,shared:S.length,subset:C}}).filter(w=>w.shared>=2).sort((w,E)=>Number(E.subset)-Number(w.subset)||E.shared-w.shared);return f.length!==1&&((h=f[0])==null?void 0:h.shared)===((m=f[1])==null?void 0:m.shared)&&((b=f[0])==null?void 0:b.subset)===((g=f[1])==null?void 0:g.subset)?null:((x=f[0])==null?void 0:x.member)||null}function lo(e,t=!1){const n=Math.max(0,Math.round(e||0)),a=Math.floor(n/60),i=n%60;return t?i?a?`${a} h ${i} min`:`${i} min`:`${a} h`:i?`${a} h ${i.toString().padStart(2,"0")} min`:`${a} h`}function Hg(e){return e?lo(e,!0):"0 h"}function od(e){const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${a}`}function fS(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n}function hS(e){const t=new Date,n=od(t);return e==="today"?{from:n,to:n}:e==="7d"?{from:od(fS(t,-6)),to:n}:e==="30d"?{from:od(fS(t,-29)),to:n}:e==="month"?{from:od(new Date(t.getFullYear(),t.getMonth(),1)),to:n}:{}}function ld(e){if(!e)return"—";const[t,n,a]=e.split("-").map(Number);return!t||!n||!a?e:new Intl.DateTimeFormat("es",{day:"numeric",month:"short",year:"numeric"}).format(new Date(t,n-1,a))}function aT(e){const t=ry(e).split(" ").filter(Boolean);return t.length>=2?`${t[0][0]}${t[1][0]}`.toUpperCase():(t[0]||"?").slice(0,2).toUpperCase()}function A8(e,t){const n=new Map;for(const a of t)n.set(`email:${a.email}`,{key:`email:${a.email}`,name:a.fullName,email:a.email,current:!0,records:[],totalMinutes:0,daysWithEntries:0,averageMinutesPerLoggedDay:0,lastDate:""});for(const a of e){const i=R8(a.workedByName,a.workedByEmail,t),l=(i==null?void 0:i.fullName)||a.workedByName||"Sin nombre",c=(i==null?void 0:i.email)||a.workedByEmail,f=Ks(l)||"sin-nombre",h=i?`email:${i.email}`:`name:${f}`,m=n.get(h)||{key:h,name:l,email:c,current:!!i,records:[],totalMinutes:0,daysWithEntries:0,averageMinutesPerLoggedDay:0,lastDate:""};m.records.push(a),m.totalMinutes+=a.durationMinutes,(!m.lastDate||a.workDate>m.lastDate)&&(m.lastDate=a.workDate),n.set(h,m)}for(const a of n.values()){const i=new Set(a.records.map(l=>l.workDate));a.daysWithEntries=i.size,a.averageMinutesPerLoggedDay=i.size?Math.round(a.totalMinutes/i.size):0,a.records.sort((l,c)=>c.workDate.localeCompare(l.workDate)||c.sourceKey.localeCompare(l.sourceKey))}return Array.from(n.values())}function k8(e){const t=new Map;for(const n of e){const a=t.get(n.workDate)||{minutes:0,records:0,projects:new Set};a.minutes+=n.durationMinutes,a.records+=1,a.projects.add(n.projectName),t.set(n.workDate,a)}return Array.from(t.entries()).map(([n,a])=>({date:n,minutes:a.minutes,records:a.records,projects:a.projects.size})).sort((n,a)=>a.date.localeCompare(n.date))}function cd({icon:e,label:t,value:n,hint:a}){return d.jsxs("div",{className:"rounded-2xl border border-border bg-card px-4 py-4 shadow-sm",children:[d.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[d.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-primary/8 text-primary",children:e}),t]}),d.jsx("div",{className:"mt-3 text-2xl font-semibold tracking-tight text-foreground",children:n}),d.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:a})]})}function O8({person:e,selected:t,maxMinutes:n,onSelect:a}){const i=n>0?Math.max(0,Math.min(100,e.totalMinutes/n*100)):0;return d.jsx("button",{type:"button",onClick:a,className:`w-full rounded-2xl border p-3.5 text-left transition-all ${t?"border-primary/35 bg-primary/[0.055] shadow-sm":"border-border bg-card hover:border-primary/20 hover:bg-muted/20"}`,children:d.jsxs("div",{className:"flex items-start gap-3",children:[d.jsx(Cf,{className:"h-10 w-10 flex-shrink-0",children:d.jsx(jf,{className:"bg-primary/10 text-xs font-semibold text-primary",children:aT(e.name)})}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("div",{className:"flex items-start justify-between gap-3",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:e.name}),d.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[d.jsx(sn,{variant:"secondary",className:"h-5 rounded-full px-2 text-[10px] font-medium",children:e.current?"Equipo actual":"Histórico"}),e.daysWithEntries>0&&d.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[e.daysWithEntries," ",e.daysWithEntries===1?"día":"días"]})]})]}),d.jsxs("div",{className:"text-right",children:[d.jsx("div",{className:"text-sm font-semibold text-foreground",children:lo(e.totalMinutes,!0)}),d.jsxs("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:[Hg(e.averageMinutesPerLoggedDay)," / día"]})]})]}),d.jsx(rT,{value:i,className:"mt-3 h-1.5"})]})]})})}function M8({open:e,onOpenChange:t}){const n=v.useMemo(()=>hS("7d"),[]),[a,i]=v.useState("7d"),[l,c]=v.useState(n.from||""),[f,h]=v.useState(n.to||""),[m,b]=v.useState(""),[g,x]=v.useState("current"),[w,E]=v.useState("hours"),[S,C]=v.useState([]),[N,A]=v.useState([]),[T,M]=v.useState(!1),[$,L]=v.useState(null),[P,U]=v.useState(""),[J,ce]=v.useState(""),[re,me]=v.useState(1),fe=async()=>{if(e)try{M(!0),L(null);const[ne,Me]=await Promise.all([j8({from:l||void 0,to:f||void 0}),T8()]);C(ne),A(Me)}catch(ne){console.error("No se pudieron cargar las horas del equipo:",ne),L(ne instanceof Error?ne.message:"No pudimos cargar las horas ahora. Intenta nuevamente.")}finally{M(!1)}};v.useEffect(()=>{e&&fe()},[e,l,f]);const ge=v.useMemo(()=>A8(S,N),[S,N]),de=v.useMemo(()=>{const ne=Ks(m);return ge.filter(Je=>g==="current"&&!Je.current||g==="historical"&&Je.current?!1:ne?Ks(Je.name).includes(ne)||Ks(Je.email).includes(ne):!0).sort((Je,ie)=>w==="name"?Je.name.localeCompare(ie.name,"es",{sensitivity:"base"}):w==="recent"?(ie.lastDate||"").localeCompare(Je.lastDate||"")||ie.totalMinutes-Je.totalMinutes:ie.totalMinutes-Je.totalMinutes||Je.name.localeCompare(ie.name,"es",{sensitivity:"base"}))},[ge,g,m,w]);v.useEffect(()=>{if(!de.length){U("");return}de.some(ne=>ne.key===P)||U(de[0].key)},[de,P]);const k=de.find(ne=>ne.key===P)||null,K=v.useMemo(()=>k8((k==null?void 0:k.records)||[]),[k]);v.useEffect(()=>{ce(""),me(1)},[P,l,f]);const F=v.useMemo(()=>{const ne=(k==null?void 0:k.records)||[];return J?ne.filter(Me=>Me.workDate===J):ne},[J,k]),Y=Math.max(1,Math.ceil(F.length/id)),V=Math.min(re,Y),R=F.slice((V-1)*id,V*id),O=de.flatMap(ne=>ne.records),I=de.reduce((ne,Me)=>ne+Me.totalMinutes,0),H=de.filter(ne=>ne.totalMinutes>0).length,q=new Set(O.map(ne=>ne.workDate)).size,ee=de.reduce((ne,Me)=>ne+Me.daysWithEntries,0),te=ee?Math.round(I/ee):0,Q=Math.max(0,...de.map(ne=>ne.totalMinutes)),se=Math.max(0,...K.map(ne=>ne.minutes)),je=ne=>{i(ne);const Me=hS(ne);c(Me.from||""),h(Me.to||"")},ze=ne=>{i("custom"),c(ne),ne&&f&&ne>f&&h(ne)},Ne=ne=>{i("custom"),h(ne),ne&&l&&ne<l&&c(ne)};return d.jsx(ri,{open:e,onOpenChange:t,children:d.jsxs(ls,{className:"max-h-[94vh] max-w-[1380px] overflow-hidden p-0 gap-0",children:[d.jsx("div",{className:"border-b border-border bg-gradient-to-r from-primary/[0.06] via-background to-background px-6 py-5 sm:px-7",children:d.jsx(cs,{children:d.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between",children:[d.jsxs("div",{className:"flex items-start gap-3",children:[d.jsx("span",{className:"mt-0.5 flex h-11 w-11 flex-shrink-0 items-center justify-center rounded-2xl bg-primary/10 text-primary shadow-sm",children:d.jsx(vp,{className:"h-5 w-5"})}),d.jsxs("div",{className:"min-w-0",children:[d.jsx(us,{className:"text-xl tracking-tight",children:"Horas del equipo"}),d.jsx(ds,{className:"mt-1 max-w-2xl",children:"Consulta el tiempo registrado por persona, cuánto lleva por día y el detalle de sus actividades."})]})]}),d.jsxs(Ee,{type:"button",variant:"outline",size:"sm",className:"h-9 self-start rounded-full px-3.5 shadow-sm lg:mr-6",onClick:()=>void fe(),disabled:T,children:[T?d.jsx(Kt,{className:"mr-1.5 h-4 w-4 animate-spin"}):d.jsx(go,{className:"mr-1.5 h-4 w-4"}),"Actualizar"]})]})})}),d.jsx("div",{className:"max-h-[calc(94vh-92px)] overflow-y-auto bg-muted/[0.12] px-5 py-5 sm:px-7 sm:py-6",children:d.jsxs("div",{className:"space-y-5",children:[d.jsx("section",{className:"rounded-2xl border border-border bg-card p-4 shadow-sm",children:d.jsxs("div",{className:"flex flex-col gap-4 xl:flex-row xl:items-end xl:justify-between",children:[d.jsx("div",{className:"flex flex-wrap gap-2",children:[["today","Hoy"],["7d","7 días"],["30d","30 días"],["month","Este mes"],["all","Todo"]].map(([ne,Me])=>d.jsx(Ee,{type:"button",size:"sm",variant:a===ne?"default":"outline",className:"h-8 rounded-full px-3 text-xs",onClick:()=>je(ne),children:Me},ne))}),d.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 xl:w-[430px]",children:[d.jsxs("label",{className:"space-y-1",children:[d.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Desde"}),d.jsx(ot,{type:"date",value:l,onChange:ne=>ze(ne.target.value),className:"h-9"})]}),d.jsxs("label",{className:"space-y-1",children:[d.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Hasta"}),d.jsx(ot,{type:"date",value:f,onChange:ne=>Ne(ne.target.value),className:"h-9"})]})]})]})}),$?d.jsxs("div",{className:"rounded-2xl border border-destructive/25 bg-destructive/5 px-5 py-7 text-center",children:[d.jsx("div",{className:"text-sm font-semibold text-foreground",children:"No pudimos cargar las horas"}),d.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Intenta nuevamente en unos segundos."}),d.jsxs(Ee,{type:"button",variant:"outline",size:"sm",className:"mt-4 rounded-full",onClick:()=>void fe(),children:[d.jsx(go,{className:"mr-1.5 h-4 w-4"})," Reintentar"]})]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:[d.jsx(cd,{icon:d.jsx(Fs,{className:"h-4 w-4"}),label:"Horas registradas",value:lo(I,!0),hint:`${O.length.toLocaleString("es")} registros en el periodo`}),d.jsx(cd,{icon:d.jsx(vp,{className:"h-4 w-4"}),label:"Personas con horas",value:String(H),hint:`${de.length} personas visibles`}),d.jsx(cd,{icon:d.jsx(fg,{className:"h-4 w-4"}),label:"Días con actividad",value:String(q),hint:"Días con al menos un registro"}),d.jsx(cd,{icon:d.jsx(vP,{className:"h-4 w-4"}),label:"Promedio por persona/día",value:Hg(te),hint:"Sobre días que tienen registros"})]}),d.jsxs("div",{className:"grid grid-cols-1 gap-4 xl:grid-cols-[360px_minmax(0,1fr)]",children:[d.jsxs("section",{className:"rounded-2xl border border-border bg-card shadow-sm",children:[d.jsxs("div",{className:"border-b border-border p-4",children:[d.jsxs("div",{className:"relative",children:[d.jsx(Ws,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),d.jsx(ot,{value:m,onChange:ne=>b(ne.target.value),placeholder:"Buscar persona…",className:"h-9 pl-9"})]}),d.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[["all","Todos"],["current","Equipo actual"],["historical","Histórico"]].map(([ne,Me])=>d.jsx("button",{type:"button",onClick:()=>x(ne),className:`rounded-full px-2.5 py-1 text-[11px] font-medium transition-colors ${g===ne?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:text-foreground"}`,children:Me},ne))}),d.jsxs("div",{className:"mt-3 flex items-center justify-between gap-2",children:[d.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[de.length," personas"]}),d.jsxs("select",{value:w,onChange:ne=>E(ne.target.value),className:"h-8 rounded-lg border border-border bg-background px-2 text-[11px] text-foreground outline-none focus:border-primary/40",children:[d.jsx("option",{value:"hours",children:"Más horas"}),d.jsx("option",{value:"recent",children:"Más recientes"}),d.jsx("option",{value:"name",children:"Nombre"})]})]})]}),d.jsx("div",{className:"max-h-[620px] space-y-2 overflow-y-auto p-3",children:T&&!S.length?Array.from({length:6}).map((ne,Me)=>d.jsx("div",{className:"h-[92px] animate-pulse rounded-2xl bg-muted"},Me)):de.length?de.map(ne=>d.jsx(O8,{person:ne,selected:ne.key===P,maxMinutes:Q,onSelect:()=>U(ne.key)},ne.key)):d.jsxs("div",{className:"px-4 py-12 text-center",children:[d.jsx(vp,{className:"mx-auto h-7 w-7 text-muted-foreground/50"}),d.jsx("p",{className:"mt-2 text-sm font-medium",children:"No hay personas para mostrar"}),d.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Prueba cambiando la búsqueda o el filtro."})]})})]}),d.jsx("section",{className:"min-w-0 rounded-2xl border border-border bg-card shadow-sm",children:k?d.jsxs("div",{children:[d.jsx("div",{className:"border-b border-border p-5 sm:p-6",children:d.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between",children:[d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx(Cf,{className:"h-12 w-12",children:d.jsx(jf,{className:"bg-primary/10 text-sm font-semibold text-primary",children:aT(k.name)})}),d.jsxs("div",{children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsx("h3",{className:"text-lg font-semibold tracking-tight",children:k.name}),d.jsx(sn,{variant:"secondary",className:"rounded-full text-[10px]",children:k.current?"Equipo actual":"Histórico"})]}),d.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:k.lastDate?`Último registro: ${ld(k.lastDate)}`:"Sin registros en este periodo"})]})]}),d.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center lg:min-w-[390px]",children:[d.jsxs("div",{className:"rounded-xl bg-muted/50 px-3 py-2.5",children:[d.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Total"}),d.jsx("div",{className:"mt-1 text-sm font-semibold",children:lo(k.totalMinutes,!0)})]}),d.jsxs("div",{className:"rounded-xl bg-muted/50 px-3 py-2.5",children:[d.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Promedio / día"}),d.jsx("div",{className:"mt-1 text-sm font-semibold",children:Hg(k.averageMinutesPerLoggedDay)})]}),d.jsxs("div",{className:"rounded-xl bg-muted/50 px-3 py-2.5",children:[d.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Días"}),d.jsx("div",{className:"mt-1 text-sm font-semibold",children:k.daysWithEntries})]})]})]})}),d.jsxs("div",{className:"grid grid-cols-1 gap-5 p-5 sm:p-6 lg:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[d.jsxs("div",{children:[d.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[d.jsxs("div",{children:[d.jsx("h4",{className:"text-sm font-semibold",children:"Horas por día"}),d.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Selecciona un día para ver únicamente sus actividades."})]}),J&&d.jsx(Ee,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-full px-2 text-[11px]",onClick:()=>ce(""),children:"Ver todos"})]}),d.jsx("div",{className:"max-h-[430px] space-y-2 overflow-y-auto pr-1",children:K.length?K.map(ne=>{const Me=se?Math.max(5,ne.minutes/se*100):0,Je=J===ne.date;return d.jsxs("button",{type:"button",onClick:()=>ce(Je?"":ne.date),className:`w-full rounded-xl border px-3.5 py-3 text-left transition-colors ${Je?"border-primary/35 bg-primary/[0.055]":"border-border bg-background hover:bg-muted/30"}`,children:[d.jsxs("div",{className:"flex items-center justify-between gap-3",children:[d.jsxs("div",{children:[d.jsx("div",{className:"text-xs font-semibold",children:ld(ne.date)}),d.jsxs("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:[ne.projects," ",ne.projects===1?"proyecto":"proyectos"," · ",ne.records," ",ne.records===1?"registro":"registros"]})]}),d.jsx("div",{className:"text-sm font-semibold text-primary",children:lo(ne.minutes,!0)})]}),d.jsx("div",{className:"mt-2 h-1.5 overflow-hidden rounded-full bg-muted",children:d.jsx("div",{className:"h-full rounded-full bg-primary/75 transition-all",style:{width:`${Me}%`}})})]},ne.date)}):d.jsxs("div",{className:"rounded-xl border border-dashed border-border px-4 py-12 text-center",children:[d.jsx(fg,{className:"mx-auto h-7 w-7 text-muted-foreground/50"}),d.jsx("p",{className:"mt-2 text-sm font-medium",children:"Sin horas en este periodo"}),d.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Cuando registre tiempo, aparecerá aquí."})]})})]}),d.jsxs("div",{className:"min-w-0",children:[d.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[d.jsxs("div",{children:[d.jsx("h4",{className:"text-sm font-semibold",children:J?`Actividades · ${ld(J)}`:"Actividades registradas"}),d.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Proyecto, tarea, país y duración."})]}),d.jsxs(sn,{variant:"outline",className:"rounded-full text-[10px]",children:[F.length," registros"]})]}),d.jsx("div",{className:"space-y-2",children:R.length?R.map(ne=>d.jsxs("div",{className:"rounded-xl border border-border bg-background px-3.5 py-3",children:[d.jsxs("div",{className:"flex items-start justify-between gap-3",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("div",{className:"truncate text-xs font-semibold text-foreground",children:ne.projectName}),d.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-[10px] text-muted-foreground",children:[d.jsx("span",{children:ne.taskName}),ne.country&&d.jsxs("span",{children:["· ",ne.country]}),!J&&d.jsxs("span",{children:["· ",ld(ne.workDate)]})]})]}),d.jsx("span",{className:"flex-shrink-0 rounded-full bg-primary/10 px-2.5 py-1 text-[11px] font-semibold text-primary",children:lo(ne.durationMinutes,!0)})]}),ne.notes&&ne.notes.toLowerCase()!=="sin comentarios"&&d.jsx("p",{className:"mt-2 line-clamp-2 text-[10px] leading-relaxed text-muted-foreground",children:ne.notes})]},`${ne.recordSource}:${ne.id}:${ne.sourceKey}`)):d.jsxs("div",{className:"rounded-xl border border-dashed border-border px-4 py-12 text-center",children:[d.jsx(iv,{className:"mx-auto h-7 w-7 text-muted-foreground/50"}),d.jsx("p",{className:"mt-2 text-sm font-medium",children:"No hay actividades para mostrar"})]})}),F.length>id&&d.jsxs("div",{className:"mt-4 flex items-center justify-between rounded-xl bg-muted/35 px-3 py-2",children:[d.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["Página ",V," de ",Y]}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(Ee,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 rounded-full",disabled:V<=1,onClick:()=>me(ne=>Math.max(1,ne-1)),children:d.jsx(ff,{className:"h-3.5 w-3.5"})}),d.jsx(Ee,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 rounded-full",disabled:V>=Y,onClick:()=>me(ne=>Math.min(Y,ne+1)),children:d.jsx(oc,{className:"h-3.5 w-3.5"})})]})]})]})]})]}):d.jsx("div",{className:"flex min-h-[440px] items-center justify-center px-6 text-center",children:d.jsxs("div",{children:[d.jsx(P1,{className:"mx-auto h-9 w-9 text-muted-foreground/40"}),d.jsx("h3",{className:"mt-3 text-sm font-semibold",children:"Selecciona una persona"}),d.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Aquí verás su resumen diario y las actividades registradas."})]})})})]})]})]})})]})})}function Ed(e){const t=e.trim();return/^https?:\/\//i.test(t)?t:""}function mS(e){const t=Ed(e);t&&window.open(t,"_blank","noopener,noreferrer")}function pS(e){return!e||!Number.isFinite(e)?"—":new Intl.DateTimeFormat("es-DO",{day:"2-digit",month:"short",year:"numeric"}).format(new Date(e))}function D8({item:e,mode:t,busy:n=!1,onApprove:a,onReject:i}){const l=t==="rejected",c=Ed(e.documentLink)||Ed(e.briefLink),f=Ed(e.briefLink);return d.jsxs("article",{className:xe("overflow-hidden rounded-2xl border bg-card shadow-sm transition-shadow hover:shadow-md",l?"border-red-200/70":"border-amber-200/80"),children:[d.jsx("div",{className:xe("flex min-h-14 items-start justify-between gap-3 px-4 py-3",l?"bg-red-50":"bg-amber-50"),children:d.jsxs("div",{className:"min-w-0",children:[d.jsx("div",{className:"mb-1.5 flex flex-wrap items-center gap-1.5",children:d.jsx(sn,{variant:"secondary",className:xe("h-5 px-2 text-[10px] font-semibold",l?"bg-red-100 text-red-800 hover:bg-red-100":"bg-amber-100 text-amber-900 hover:bg-amber-100"),children:l?"Rechazado":"Nuevo · CDC Brief"})}),d.jsx("h3",{className:"line-clamp-2 text-sm font-semibold leading-snug text-foreground",children:e.title||"Brief sin título"})]})}),d.jsxs("div",{className:"space-y-3 p-4",children:[d.jsxs("div",{className:"space-y-2.5",children:[d.jsx(jl,{icon:d.jsx(Id,{className:"h-3.5 w-3.5"}),label:"Cliente",value:e.client}),d.jsx(jl,{icon:d.jsx(Id,{className:"h-3.5 w-3.5"}),label:"Marca",value:e.brand}),d.jsx(jl,{icon:d.jsx(zd,{className:"h-3.5 w-3.5"}),label:"País",value:e.country}),d.jsx(jl,{icon:d.jsx(L1,{className:"h-3.5 w-3.5"}),label:"Solicita",value:e.requestedBy}),d.jsx(jl,{icon:d.jsx(o3,{className:"h-3.5 w-3.5"}),label:"Creado",value:pS(e.sourceCreatedAt)})]}),(e.requestType||e.deliverableType||e.deliveryDate)&&d.jsxs("div",{className:"rounded-xl border border-border/70 bg-muted/20 px-3 py-2.5 text-xs",children:[e.requestType&&d.jsxs("p",{children:[d.jsx("span",{className:"text-muted-foreground",children:"Requerimiento:"})," ",d.jsx("span",{className:"font-medium text-foreground",children:e.requestType})]}),e.deliverableType&&d.jsxs("p",{className:e.requestType?"mt-1":"",children:[d.jsx("span",{className:"text-muted-foreground",children:"Entregable:"})," ",d.jsx("span",{className:"font-medium text-foreground",children:e.deliverableType})]}),e.deliveryDate&&d.jsxs("p",{className:e.requestType||e.deliverableType?"mt-1":"",children:[d.jsx("span",{className:"text-muted-foreground",children:"Entrega:"})," ",d.jsx("span",{className:"font-medium text-foreground",children:e.deliveryDate})]})]}),e.summary&&d.jsx("p",{className:"line-clamp-4 text-xs leading-relaxed text-muted-foreground",children:e.summary}),l&&(e.reviewedByName||e.reviewedAt)&&d.jsxs("div",{className:"rounded-xl border border-red-100 bg-red-50/60 px-3 py-2 text-[11px] text-red-800",children:["Revisado",e.reviewedByName?` por ${e.reviewedByName}`:"",e.reviewedAt?` · ${pS(e.reviewedAt)}`:"",e.rejectionReason?` · ${e.rejectionReason}`:""]}),d.jsxs("div",{className:"flex flex-wrap gap-2 border-t border-border/70 pt-3",children:[d.jsxs(Ee,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1.5 rounded-full px-3 text-xs",disabled:!c||n,onClick:()=>mS(c),children:[d.jsx(ov,{className:"h-3.5 w-3.5"}),"Ver brief"]}),f&&f!==c&&d.jsxs(Ee,{type:"button",variant:"ghost",size:"sm",className:"h-8 gap-1.5 rounded-full px-3 text-xs",disabled:n,onClick:()=>mS(f),children:[d.jsx(z3,{className:"h-3.5 w-3.5"}),"Carpeta"]}),d.jsxs("div",{className:"ml-auto flex gap-2",children:[!l&&d.jsxs(Ee,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1.5 rounded-full border-red-200 px-3 text-xs text-red-700 hover:bg-red-50 hover:text-red-800",disabled:n||!i,onClick:i,children:[d.jsx(_3,{className:"h-3.5 w-3.5"}),"No aprobar"]}),d.jsxs(Ee,{type:"button",size:"sm",className:"h-8 gap-1.5 rounded-full px-3 text-xs",disabled:n||!a,onClick:a,children:[d.jsx(iv,{className:"h-3.5 w-3.5"}),n?"Procesando…":"Aprobar"]})]})]})]})]})}function jl({icon:e,label:t,value:n}){return d.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[d.jsx("span",{className:"mt-0.5 flex-shrink-0 text-muted-foreground",children:e}),d.jsx("span",{className:"w-14 flex-shrink-0 text-muted-foreground",children:t}),d.jsx("span",{className:"truncate font-medium text-foreground",children:n||"—"})]})}function Fp(e,t=Date.now()){if(!e)return t;const n=new Date(e).getTime();return Number.isFinite(n)?n:t}function P8(e){const t=Fp(e.created_at);return{id:e.id,briefId:e.brief_id||"",sourceCreatedAt:Fp(e.source_created_at,t),title:e.title||"",client:e.client||"",brand:e.brand||"",country:e.country||"",requestedBy:e.requested_by||"",requestedByEmail:e.requested_by_email||"",deliveryDate:e.delivery_date||"",briefLink:e.brief_link||"",documentLink:e.document_link||"",summary:e.summary||"",requestType:e.request_type||"",deliverableType:e.deliverable_type||"",reviewStatus:e.review_status==="approved"?"approved":e.review_status==="rejected"?"rejected":"new",rejectionReason:e.rejection_reason||"",approvedProjectId:e.approved_project_id||"",reviewedByName:e.reviewed_by_name||"",reviewedByEmail:e.reviewed_by_email||"",reviewedAt:e.reviewed_at?Fp(e.reviewed_at):null,createdAt:t}}function L8(e){return e.trim().replace(/[%_,]/g," ").replace(/\s+/g," ")}function z8(){return"https://agenteit.digitalcompass.agency/webhook/tablero-cdc-sync-proyecto".trim()||""}async function I8(e){const t=z8();if(!t)return{sheetSyncStatus:"skipped",sheetSyncMessage:"Proyecto aprobado y creado en Supabase. No hay webhook configurado para sincronizar Google Sheet."};const n=new AbortController,a=window.setTimeout(()=>n.abort(),15e3);try{const i=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project_id:e,action:"create",source:"tablero-cdc-brief-review",sent_at:new Date().toISOString()}),signal:n.signal});return i.ok?{sheetSyncStatus:"synced",sheetSyncMessage:"Brief aprobado, proyecto Activo creado y Google Sheet sincronizado."}:{sheetSyncStatus:"failed",sheetSyncMessage:`El proyecto quedó Activo en el Tablero, pero el Sheet no se pudo sincronizar: ${await i.text().catch(()=>"")||`${i.status} ${i.statusText}`.trim()}`}}catch(i){const l=i instanceof DOMException&&i.name==="AbortError";return{sheetSyncStatus:l?"timeout":"failed",sheetSyncMessage:l?"El proyecto quedó Activo en el Tablero, pero n8n tardó demasiado en responder. Revisa el Sheet si fuera necesario.":"El proyecto quedó Activo en el Tablero, pero no se pudo sincronizar con Google Sheet."}}finally{window.clearTimeout(a)}}function $8({status:e,search:t,page:n,pageSize:a,enabled:i=!0}){const[l,c]=v.useState([]),[f,h]=v.useState(0),[m,b]=v.useState(!1),[g,x]=v.useState(null),w=v.useRef(0),E=v.useMemo(()=>L8(t),[t]),S=v.useCallback(async()=>{if(!i)return;const A=w.current+=1;b(!0),x(null);try{const T=Math.max(0,(n-1)*a),M=T+a-1;let $=Se.from("tablero_cdc_brief_inbox").select("id, brief_id, source_created_at, title, client, brand, country, requested_by, requested_by_email, delivery_date, brief_link, document_link, summary, request_type, deliverable_type, review_status, rejection_reason, approved_project_id, reviewed_by_name, reviewed_by_email, reviewed_at, created_at",{count:"exact"}).eq("review_status",e).order("created_at",{ascending:!1});if(E){const J=`%${E}%`;$=$.or(`title.ilike.${J},client.ilike.${J},brand.ilike.${J},country.ilike.${J},requested_by.ilike.${J},requested_by_email.ilike.${J},request_type.ilike.${J},deliverable_type.ilike.${J},summary.ilike.${J}`)}const{data:L,error:P,count:U}=await $.range(T,M);if(P)throw P;if(A!==w.current)return;c((L||[]).map(P8)),h(U??0)}catch(T){if(A!==w.current)return;console.error("Error cargando bandeja de CDC Brief:",T),x(T instanceof Error?T.message:"No se pudieron cargar los briefs pendientes de revisión."),c([]),h(0)}finally{A===w.current&&b(!1)}},[i,E,n,a,e]);v.useEffect(()=>{i&&S()},[i,S]),v.useEffect(()=>{if(!i)return;let A=null;const T=Se.channel(`tablero-cdc-brief-inbox-${e}`).on("postgres_changes",{event:"*",schema:"public",table:"tablero_cdc_brief_inbox"},()=>{A&&clearTimeout(A),A=setTimeout(()=>void S(),300)}).subscribe(M=>{(M==="CHANNEL_ERROR"||M==="TIMED_OUT")&&console.warn("Supabase Realtime no pudo suscribirse a tablero_cdc_brief_inbox:",M)});return()=>{A&&clearTimeout(A),Se.removeChannel(T)}},[i,S,e]);const C=v.useCallback(async A=>{const{data:T,error:M}=await Se.rpc("tablero_cdc_approve_brief",{p_inbox_id:A});if(M)throw M;const L=String((T||{}).project_id||"").trim();if(!L)throw new Error("Supabase aprobó el brief, pero no devolvió el Project ID.");const P=await I8(L);return await S(),{projectId:L,...P}},[S]),N=v.useCallback(async(A,T="")=>{const{data:M,error:$}=await Se.rpc("tablero_cdc_reject_brief",{p_inbox_id:A,p_reason:T.trim()||null});if($)throw $;if((M||{}).ok===!1)throw new Error("Supabase no pudo mover el brief a Rechazados.");await S()},[S]);return{items:l,totalItems:f,loading:m,error:g,refresh:S,approve:C,reject:N}}function U8(e=!0){const[t,n]=v.useState(0),[a,i]=v.useState(!1),[l,c]=v.useState(null),f=v.useRef(0),h=v.useCallback(async()=>{if(!e){n(0);return}const b=f.current+=1;i(!0);try{const{data:g,error:x}=await Se.rpc("tablero_cdc_get_unseen_brief_count");if(x)throw x;if(b!==f.current)return;const w=Number(g??0);n(Number.isFinite(w)&&w>0?w:0),c(null)}catch(g){if(b!==f.current)return;console.error("Error cargando notificaciones de briefs nuevos:",g),c(g instanceof Error?g.message:"No se pudo actualizar el contador de briefs nuevos.")}finally{b===f.current&&i(!1)}},[e]),m=v.useCallback(async()=>{if(!e)return 0;n(0);try{const{data:b,error:g}=await Se.rpc("tablero_cdc_mark_briefs_seen");if(g)throw g;const w=Number((b||{}).unseen_count??0),E=Number.isFinite(w)&&w>0?w:0;return n(E),c(null),E}catch(b){throw await h(),b}},[e,h]);return v.useEffect(()=>{if(!e){n(0);return}h()},[e,h]),v.useEffect(()=>{if(!e)return;let b=null;const g=()=>{b&&clearTimeout(b),b=setTimeout(()=>void h(),250)},x=Se.channel("tablero-cdc-brief-unread-counter").on("postgres_changes",{event:"*",schema:"public",table:"tablero_cdc_brief_inbox"},g).subscribe(C=>{(C==="CHANNEL_ERROR"||C==="TIMED_OUT")&&console.warn("Supabase Realtime no pudo actualizar el contador de briefs:",C)}),w=window.setInterval(()=>{document.visibilityState==="visible"&&h()},3e4),E=()=>void h(),S=()=>{document.visibilityState==="visible"&&h()};return window.addEventListener("focus",E),document.addEventListener("visibilitychange",S),()=>{b&&clearTimeout(b),window.clearInterval(w),window.removeEventListener("focus",E),document.removeEventListener("visibilitychange",S),Se.removeChannel(x)}},[e,h]),{unreadCount:t,loading:a,error:l,refresh:h,markAllSeen:m}}const sT="pricing_summary_public";function iT(e){var t;return!!((t=e==null?void 0:e.value)!=null&&t.enabled)}async function B8(){const{data:e,error:t}=await Se.from("tablero_cdc_app_settings").select("key, value").eq("key",sT).maybeSingle();if(t)throw t;return iT(e)}async function H8(e){const{error:t}=await Se.rpc("tablero_cdc_set_pricing_summary_public",{p_enabled:e});if(t)throw t}function q8(e=!0){const[t,n]=v.useState(!1),[a,i]=v.useState(e),[l,c]=v.useState(!1),[f,h]=v.useState(null),m=v.useCallback(async()=>{if(!e)return!1;i(!0),h(null);try{const g=await B8();return n(g),g}catch(g){return console.error("No se pudo leer la visibilidad del total tarifado:",g),h(g instanceof Error?g.message:"No se pudo leer la visibilidad del total tarifado."),!1}finally{i(!1)}},[e]),b=v.useCallback(async g=>{c(!0),h(null);try{return await H8(g),n(g),g}catch(x){throw console.error("No se pudo actualizar la visibilidad del total tarifado:",x),h(x instanceof Error?x.message:"No se pudo actualizar la visibilidad del total tarifado."),x}finally{c(!1)}},[]);return v.useEffect(()=>{m()},[m]),v.useEffect(()=>{if(!e)return;const g=Se.channel("tablero-cdc-pricing-summary-visibility").on("postgres_changes",{event:"*",schema:"public",table:"tablero_cdc_app_settings",filter:`key=eq.${sT}`},x=>{const w=x.new||x.old;n(iT(w))}).subscribe();return()=>{Se.removeChannel(g)}},[e]),{isPublic:t,loading:a,saving:l,error:f,refresh:m,setPublicVisibility:b}}function V8(e,t){return v.useReducer((n,a)=>t[n][a]??n,e)}var ay="ScrollArea",[oT]=ur(ay),[F8,dr]=oT(ay),lT=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:a="hover",dir:i,scrollHideDelay:l=600,...c}=e,[f,h]=v.useState(null),[m,b]=v.useState(null),[g,x]=v.useState(null),[w,E]=v.useState(null),[S,C]=v.useState(null),[N,A]=v.useState(0),[T,M]=v.useState(0),[$,L]=v.useState(!1),[P,U]=v.useState(!1),J=nt(t,re=>h(re)),ce=lc(i);return d.jsx(F8,{scope:n,type:a,dir:ce,scrollHideDelay:l,scrollArea:f,viewport:m,onViewportChange:b,content:g,onContentChange:x,scrollbarX:w,onScrollbarXChange:E,scrollbarXEnabled:$,onScrollbarXEnabledChange:L,scrollbarY:S,onScrollbarYChange:C,scrollbarYEnabled:P,onScrollbarYEnabledChange:U,onCornerWidthChange:A,onCornerHeightChange:M,children:d.jsx(Pe.div,{dir:ce,...c,ref:J,style:{position:"relative","--radix-scroll-area-corner-width":N+"px","--radix-scroll-area-corner-height":T+"px",...e.style}})})});lT.displayName=ay;var cT="ScrollAreaViewport",uT=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:a,nonce:i,...l}=e,c=dr(cT,n),f=v.useRef(null),h=nt(t,f,c.onViewportChange);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),d.jsx(Pe.div,{"data-radix-scroll-area-viewport":"",...l,ref:h,style:{overflowX:c.scrollbarXEnabled?"scroll":"hidden",overflowY:c.scrollbarYEnabled?"scroll":"hidden",...e.style},children:d.jsx("div",{ref:c.onContentChange,style:{minWidth:"100%",display:"table"},children:a})})]})});uT.displayName=cT;var Vr="ScrollAreaScrollbar",sy=v.forwardRef((e,t)=>{const{forceMount:n,...a}=e,i=dr(Vr,e.__scopeScrollArea),{onScrollbarXEnabledChange:l,onScrollbarYEnabledChange:c}=i,f=e.orientation==="horizontal";return v.useEffect(()=>(f?l(!0):c(!0),()=>{f?l(!1):c(!1)}),[f,l,c]),i.type==="hover"?d.jsx(G8,{...a,ref:t,forceMount:n}):i.type==="scroll"?d.jsx(K8,{...a,ref:t,forceMount:n}):i.type==="auto"?d.jsx(dT,{...a,ref:t,forceMount:n}):i.type==="always"?d.jsx(iy,{...a,ref:t}):null});sy.displayName=Vr;var G8=v.forwardRef((e,t)=>{const{forceMount:n,...a}=e,i=dr(Vr,e.__scopeScrollArea),[l,c]=v.useState(!1);return v.useEffect(()=>{const f=i.scrollArea;let h=0;if(f){const m=()=>{window.clearTimeout(h),c(!0)},b=()=>{h=window.setTimeout(()=>c(!1),i.scrollHideDelay)};return f.addEventListener("pointerenter",m),f.addEventListener("pointerleave",b),()=>{window.clearTimeout(h),f.removeEventListener("pointerenter",m),f.removeEventListener("pointerleave",b)}}},[i.scrollArea,i.scrollHideDelay]),d.jsx(bn,{present:n||l,children:d.jsx(dT,{"data-state":l?"visible":"hidden",...a,ref:t})})}),K8=v.forwardRef((e,t)=>{const{forceMount:n,...a}=e,i=dr(Vr,e.__scopeScrollArea),l=e.orientation==="horizontal",c=qf(()=>h("SCROLL_END"),100),[f,h]=V8("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return v.useEffect(()=>{if(f==="idle"){const m=window.setTimeout(()=>h("HIDE"),i.scrollHideDelay);return()=>window.clearTimeout(m)}},[f,i.scrollHideDelay,h]),v.useEffect(()=>{const m=i.viewport,b=l?"scrollLeft":"scrollTop";if(m){let g=m[b];const x=()=>{const w=m[b];g!==w&&(h("SCROLL"),c()),g=w};return m.addEventListener("scroll",x),()=>m.removeEventListener("scroll",x)}},[i.viewport,l,h,c]),d.jsx(bn,{present:n||f!=="hidden",children:d.jsx(iy,{"data-state":f==="hidden"?"hidden":"visible",...a,ref:t,onPointerEnter:be(e.onPointerEnter,()=>h("POINTER_ENTER")),onPointerLeave:be(e.onPointerLeave,()=>h("POINTER_LEAVE"))})})}),dT=v.forwardRef((e,t)=>{const n=dr(Vr,e.__scopeScrollArea),{forceMount:a,...i}=e,[l,c]=v.useState(!1),f=e.orientation==="horizontal",h=qf(()=>{if(n.viewport){const m=n.viewport.offsetWidth<n.viewport.scrollWidth,b=n.viewport.offsetHeight<n.viewport.scrollHeight;c(f?m:b)}},10);return _o(n.viewport,h),_o(n.content,h),d.jsx(bn,{present:a||l,children:d.jsx(iy,{"data-state":l?"visible":"hidden",...i,ref:t})})}),iy=v.forwardRef((e,t)=>{const{orientation:n="vertical",...a}=e,i=dr(Vr,e.__scopeScrollArea),l=v.useRef(null),c=v.useRef(0),[f,h]=v.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),m=gT(f.viewport,f.content),b={...a,sizes:f,onSizesChange:h,hasThumb:m>0&&m<1,onThumbChange:x=>l.current=x,onThumbPointerUp:()=>c.current=0,onThumbPointerDown:x=>c.current=x};function g(x,w){return Z8(x,c.current,f,w)}return n==="horizontal"?d.jsx(W8,{...b,ref:t,onThumbPositionChange:()=>{if(i.viewport&&l.current){const x=i.viewport.scrollLeft,w=gS(x,f,i.dir);l.current.style.transform=`translate3d(${w}px, 0, 0)`}},onWheelScroll:x=>{i.viewport&&(i.viewport.scrollLeft=x)},onDragScroll:x=>{i.viewport&&(i.viewport.scrollLeft=g(x,i.dir))}}):n==="vertical"?d.jsx(Y8,{...b,ref:t,onThumbPositionChange:()=>{if(i.viewport&&l.current){const x=i.viewport.scrollTop,w=gS(x,f);l.current.style.transform=`translate3d(0, ${w}px, 0)`}},onWheelScroll:x=>{i.viewport&&(i.viewport.scrollTop=x)},onDragScroll:x=>{i.viewport&&(i.viewport.scrollTop=g(x))}}):null}),W8=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:a,...i}=e,l=dr(Vr,e.__scopeScrollArea),[c,f]=v.useState(),h=v.useRef(null),m=nt(t,h,l.onScrollbarXChange);return v.useEffect(()=>{h.current&&f(getComputedStyle(h.current))},[h]),d.jsx(hT,{"data-orientation":"horizontal",...i,ref:m,sizes:n,style:{bottom:0,left:l.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:l.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Hf(n)+"px",...e.style},onThumbPointerDown:b=>e.onThumbPointerDown(b.x),onDragScroll:b=>e.onDragScroll(b.x),onWheelScroll:(b,g)=>{if(l.viewport){const x=l.viewport.scrollLeft+b.deltaX;e.onWheelScroll(x),yT(x,g)&&b.preventDefault()}},onResize:()=>{h.current&&l.viewport&&c&&a({content:l.viewport.scrollWidth,viewport:l.viewport.offsetWidth,scrollbar:{size:h.current.clientWidth,paddingStart:ef(c.paddingLeft),paddingEnd:ef(c.paddingRight)}})}})}),Y8=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:a,...i}=e,l=dr(Vr,e.__scopeScrollArea),[c,f]=v.useState(),h=v.useRef(null),m=nt(t,h,l.onScrollbarYChange);return v.useEffect(()=>{h.current&&f(getComputedStyle(h.current))},[h]),d.jsx(hT,{"data-orientation":"vertical",...i,ref:m,sizes:n,style:{top:0,right:l.dir==="ltr"?0:void 0,left:l.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Hf(n)+"px",...e.style},onThumbPointerDown:b=>e.onThumbPointerDown(b.y),onDragScroll:b=>e.onDragScroll(b.y),onWheelScroll:(b,g)=>{if(l.viewport){const x=l.viewport.scrollTop+b.deltaY;e.onWheelScroll(x),yT(x,g)&&b.preventDefault()}},onResize:()=>{h.current&&l.viewport&&c&&a({content:l.viewport.scrollHeight,viewport:l.viewport.offsetHeight,scrollbar:{size:h.current.clientHeight,paddingStart:ef(c.paddingTop),paddingEnd:ef(c.paddingBottom)}})}})}),[X8,fT]=oT(Vr),hT=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:a,hasThumb:i,onThumbChange:l,onThumbPointerUp:c,onThumbPointerDown:f,onThumbPositionChange:h,onDragScroll:m,onWheelScroll:b,onResize:g,...x}=e,w=dr(Vr,n),[E,S]=v.useState(null),C=nt(t,J=>S(J)),N=v.useRef(null),A=v.useRef(""),T=w.viewport,M=a.content-a.viewport,$=an(b),L=an(h),P=qf(g,10);function U(J){if(N.current){const ce=J.clientX-N.current.left,re=J.clientY-N.current.top;m({x:ce,y:re})}}return v.useEffect(()=>{const J=ce=>{const re=ce.target;(E==null?void 0:E.contains(re))&&$(ce,M)};return document.addEventListener("wheel",J,{passive:!1}),()=>document.removeEventListener("wheel",J,{passive:!1})},[T,E,M,$]),v.useEffect(L,[a,L]),_o(E,P),_o(w.content,P),d.jsx(X8,{scope:n,scrollbar:E,hasThumb:i,onThumbChange:an(l),onThumbPointerUp:an(c),onThumbPositionChange:L,onThumbPointerDown:an(f),children:d.jsx(Pe.div,{...x,ref:C,style:{position:"absolute",...x.style},onPointerDown:be(e.onPointerDown,J=>{J.button===0&&(J.target.setPointerCapture(J.pointerId),N.current=E.getBoundingClientRect(),A.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",w.viewport&&(w.viewport.style.scrollBehavior="auto"),U(J))}),onPointerMove:be(e.onPointerMove,U),onPointerUp:be(e.onPointerUp,J=>{const ce=J.target;ce.hasPointerCapture(J.pointerId)&&ce.releasePointerCapture(J.pointerId),document.body.style.webkitUserSelect=A.current,w.viewport&&(w.viewport.style.scrollBehavior=""),N.current=null})})})}),Zd="ScrollAreaThumb",mT=v.forwardRef((e,t)=>{const{forceMount:n,...a}=e,i=fT(Zd,e.__scopeScrollArea);return d.jsx(bn,{present:n||i.hasThumb,children:d.jsx(J8,{ref:t,...a})})}),J8=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:a,...i}=e,l=dr(Zd,n),c=fT(Zd,n),{onThumbPositionChange:f}=c,h=nt(t,g=>c.onThumbChange(g)),m=v.useRef(void 0),b=qf(()=>{m.current&&(m.current(),m.current=void 0)},100);return v.useEffect(()=>{const g=l.viewport;if(g){const x=()=>{if(b(),!m.current){const w=eH(g,f);m.current=w,f()}};return f(),g.addEventListener("scroll",x),()=>g.removeEventListener("scroll",x)}},[l.viewport,b,f]),d.jsx(Pe.div,{"data-state":c.hasThumb?"visible":"hidden",...i,ref:h,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...a},onPointerDownCapture:be(e.onPointerDownCapture,g=>{const w=g.target.getBoundingClientRect(),E=g.clientX-w.left,S=g.clientY-w.top;c.onThumbPointerDown({x:E,y:S})}),onPointerUp:be(e.onPointerUp,c.onThumbPointerUp)})});mT.displayName=Zd;var oy="ScrollAreaCorner",pT=v.forwardRef((e,t)=>{const n=dr(oy,e.__scopeScrollArea),a=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&a?d.jsx(Q8,{...e,ref:t}):null});pT.displayName=oy;var Q8=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,...a}=e,i=dr(oy,n),[l,c]=v.useState(0),[f,h]=v.useState(0),m=!!(l&&f);return _o(i.scrollbarX,()=>{var g;const b=((g=i.scrollbarX)==null?void 0:g.offsetHeight)||0;i.onCornerHeightChange(b),h(b)}),_o(i.scrollbarY,()=>{var g;const b=((g=i.scrollbarY)==null?void 0:g.offsetWidth)||0;i.onCornerWidthChange(b),c(b)}),m?d.jsx(Pe.div,{...a,ref:t,style:{width:l,height:f,position:"absolute",right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function ef(e){return e?parseInt(e,10):0}function gT(e,t){const n=e/t;return isNaN(n)?0:n}function Hf(e){const t=gT(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,a=(e.scrollbar.size-n)*t;return Math.max(a,18)}function Z8(e,t,n,a="ltr"){const i=Hf(n),l=i/2,c=t||l,f=i-c,h=n.scrollbar.paddingStart+c,m=n.scrollbar.size-n.scrollbar.paddingEnd-f,b=n.content-n.viewport,g=a==="ltr"?[0,b]:[b*-1,0];return vT([h,m],g)(e)}function gS(e,t,n="ltr"){const a=Hf(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,l=t.scrollbar.size-i,c=t.content-t.viewport,f=l-a,h=n==="ltr"?[0,c]:[c*-1,0],m=_g(e,h);return vT([0,c],[0,f])(m)}function vT(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const a=(t[1]-t[0])/(e[1]-e[0]);return t[0]+a*(n-e[0])}}function yT(e,t){return e>0&&e<t}var eH=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},a=0;return(function i(){const l={left:e.scrollLeft,top:e.scrollTop},c=n.left!==l.left,f=n.top!==l.top;(c||f)&&t(),n=l,a=window.requestAnimationFrame(i)})(),()=>window.cancelAnimationFrame(a)};function qf(e,t){const n=an(e),a=v.useRef(0);return v.useEffect(()=>()=>window.clearTimeout(a.current),[]),v.useCallback(()=>{window.clearTimeout(a.current),a.current=window.setTimeout(n,t)},[n,t])}function _o(e,t){const n=an(t);Yt(()=>{let a=0;if(e){const i=new ResizeObserver(()=>{cancelAnimationFrame(a),a=window.requestAnimationFrame(n)});return i.observe(e),()=>{window.cancelAnimationFrame(a),i.unobserve(e)}}},[e,n])}var bT=lT,tH=uT,nH=pT;const qg=v.forwardRef(({className:e,children:t,...n},a)=>d.jsxs(bT,{ref:a,className:xe("relative overflow-hidden",e),...n,children:[d.jsx(tH,{className:"h-full w-full rounded-[inherit]",children:t}),d.jsx(xT,{}),d.jsx(nH,{})]}));qg.displayName=bT.displayName;const xT=v.forwardRef(({className:e,orientation:t="vertical",...n},a)=>d.jsx(sy,{ref:a,orientation:t,className:xe("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:d.jsx(mT,{className:"relative flex-1 rounded-full bg-border"})}));xT.displayName=sy.displayName;var Vf="Switch",[rH]=ur(Vf),[aH,sH]=rH(Vf),wT=v.forwardRef((e,t)=>{const{__scopeSwitch:n,name:a,checked:i,defaultChecked:l,required:c,disabled:f,value:h="on",onCheckedChange:m,form:b,...g}=e,[x,w]=v.useState(null),E=nt(t,T=>w(T)),S=v.useRef(!1),C=x?b||!!x.closest("form"):!0,[N,A]=ga({prop:i,defaultProp:l??!1,onChange:m,caller:Vf});return d.jsxs(aH,{scope:n,checked:N,disabled:f,children:[d.jsx(Pe.button,{type:"button",role:"switch","aria-checked":N,"aria-required":c,"data-state":NT(N),"data-disabled":f?"":void 0,disabled:f,value:h,...g,ref:E,onClick:be(e.onClick,T=>{A(M=>!M),C&&(S.current=T.isPropagationStopped(),S.current||T.stopPropagation())})}),C&&d.jsx(ET,{control:x,bubbles:!S.current,name:a,value:h,checked:N,required:c,disabled:f,form:b,style:{transform:"translateX(-100%)"}})]})});wT.displayName=Vf;var _T="SwitchThumb",ST=v.forwardRef((e,t)=>{const{__scopeSwitch:n,...a}=e,i=sH(_T,n);return d.jsx(Pe.span,{"data-state":NT(i.checked),"data-disabled":i.disabled?"":void 0,...a,ref:t})});ST.displayName=_T;var iH="SwitchBubbleInput",ET=v.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:a=!0,...i},l)=>{const c=v.useRef(null),f=nt(c,l),h=Lv(n),m=gv(t);return v.useEffect(()=>{const b=c.current;if(!b)return;const g=window.HTMLInputElement.prototype,w=Object.getOwnPropertyDescriptor(g,"checked").set;if(h!==n&&w){const E=new Event("click",{bubbles:a});w.call(b,n),b.dispatchEvent(E)}},[h,n,a]),d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:f,style:{...i.style,...m,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});ET.displayName=iH;function NT(e){return e?"checked":"unchecked"}var CT=wT,oH=ST;const ec=v.forwardRef(({className:e,...t},n)=>d.jsx(CT,{className:xe("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:d.jsx(oH,{className:xe("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));ec.displayName=CT.displayName;var Ff="Tabs",[lH]=ur(Ff,[xf]),jT=xf(),[cH,ly]=lH(Ff),TT=v.forwardRef((e,t)=>{const{__scopeTabs:n,value:a,onValueChange:i,defaultValue:l,orientation:c="horizontal",dir:f,activationMode:h="automatic",...m}=e,b=lc(f),[g,x]=ga({prop:a,onChange:i,defaultProp:l??"",caller:Ff});return d.jsx(cH,{scope:n,baseId:pn(),value:g,onValueChange:x,orientation:c,dir:b,activationMode:h,children:d.jsx(Pe.div,{dir:b,"data-orientation":c,...m,ref:t})})});TT.displayName=Ff;var RT="TabsList",AT=v.forwardRef((e,t)=>{const{__scopeTabs:n,loop:a=!0,...i}=e,l=ly(RT,n),c=jT(n);return d.jsx(hE,{asChild:!0,...c,orientation:l.orientation,dir:l.dir,loop:a,children:d.jsx(Pe.div,{role:"tablist","aria-orientation":l.orientation,...i,ref:t})})});AT.displayName=RT;var kT="TabsTrigger",OT=v.forwardRef((e,t)=>{const{__scopeTabs:n,value:a,disabled:i=!1,...l}=e,c=ly(kT,n),f=jT(n),h=PT(c.baseId,a),m=LT(c.baseId,a),b=a===c.value;return d.jsx(mE,{asChild:!0,...f,focusable:!i,active:b,children:d.jsx(Pe.button,{type:"button",role:"tab","aria-selected":b,"aria-controls":m,"data-state":b?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:h,...l,ref:t,onMouseDown:be(e.onMouseDown,g=>{!i&&g.button===0&&g.ctrlKey===!1?c.onValueChange(a):g.preventDefault()}),onKeyDown:be(e.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&c.onValueChange(a)}),onFocus:be(e.onFocus,()=>{const g=c.activationMode!=="manual";!b&&!i&&g&&c.onValueChange(a)})})})});OT.displayName=kT;var MT="TabsContent",DT=v.forwardRef((e,t)=>{const{__scopeTabs:n,value:a,forceMount:i,children:l,...c}=e,f=ly(MT,n),h=PT(f.baseId,a),m=LT(f.baseId,a),b=a===f.value,g=v.useRef(b);return v.useEffect(()=>{const x=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(x)},[]),d.jsx(bn,{present:i||b,children:({present:x})=>d.jsx(Pe.div,{"data-state":b?"active":"inactive","data-orientation":f.orientation,role:"tabpanel","aria-labelledby":h,hidden:!x,id:m,tabIndex:0,...c,ref:t,style:{...e.style,animationDuration:g.current?"0s":void 0},children:x&&l})})});DT.displayName=MT;function PT(e,t){return`${e}-trigger-${t}`}function LT(e,t){return`${e}-content-${t}`}var uH=TT,zT=AT,IT=OT,$T=DT;const UT=uH,cy=v.forwardRef(({className:e,...t},n)=>d.jsx(zT,{ref:n,className:xe("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));cy.displayName=zT.displayName;const tf=v.forwardRef(({className:e,...t},n)=>d.jsx(IT,{ref:n,className:xe("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background cursor-pointer transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 disabled:cursor-not-allowed data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...t}));tf.displayName=IT.displayName;const dH=v.forwardRef(({className:e,...t},n)=>d.jsx($T,{ref:n,className:xe("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));dH.displayName=$T.displayName;const Zi=6,ud=10;function Gp(e){return e==null||!Number.isFinite(Number(e))?"—":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(Number(e))}function Kp(e){const t=Number(String(e||"").replace(/,/g,"").trim());return Number.isFinite(t)?t:null}function fH(e,t){return e==null&&t==null?"":e!=null&&t!=null&&e!==t?`${e} - ${t}`:String(e??t??"")}function hH(e,t){const n=t.reduce((i,l)=>Math.max(i,l.sortOrder),0),a=e==="client"?"Tarifario especial":"Nueva sección";return{id:_j(e,a),name:a,scope:e,clientName:"",pricingMode:e==="client"?"fixed_multi":"guided",allowManual:!0,description:"",sortOrder:n+10,isActive:!0}}function mH(e){return{id:e.id,name:e.name,scope:e.scope,clientName:e.clientName,pricingMode:e.pricingMode,allowManual:e.allowManual,description:e.description,sortOrder:e.sortOrder,isActive:e.isActive}}function pH(e,t){const a=t.filter(l=>l.section===e.id).reduce((l,c)=>Math.max(l,c.sort_order),0),i=e.scope==="client";return{id:"",catalog_item_id:"",section:e.id,category:i?e.name:"",service:"",notes:"",work_type_id:i?"special_fixed":"",work_type_label:i?"Tarifa fija":"",work_type_short_label:i?"Fijo":"",hour_reference:"",level_id:i?"fixed":"",level_label:i?"Precio fijo":"",reference:"",reference_min:null,reference_max:null,level_hint:"",sort_order:a+1,is_active:!0,managed_by:"app"}}function gH(e){return{id:e.id,catalog_item_id:e.catalog_item_id,section:e.section,category:e.category,service:e.service,notes:e.notes,work_type_id:e.work_type_id,work_type_label:e.work_type_label,work_type_short_label:e.work_type_short_label,hour_reference:e.hour_reference,level_id:e.level_id,level_label:e.level_label,reference:e.reference,reference_min:e.reference_min,reference_max:e.reference_max,level_hint:e.level_hint,sort_order:e.sort_order,is_active:e.is_active,managed_by:"app"}}function vH({open:e,onOpenChange:t}){const{lists:n}=bc(),{sections:a,loading:i,error:l,refresh:c}=Sj(),{rows:f,loading:h,error:m,refresh:b}=wj(),[g,x]=v.useState("general"),[w,E]=v.useState(""),[S,C]=v.useState(""),[N,A]=v.useState(!1),[T,M]=v.useState(!1),[$,L]=v.useState(null),[P,U]=v.useState(null),[J,ce]=v.useState(!1),[re,me]=v.useState(null),[fe,ge]=v.useState(null),[de,k]=v.useState(!1),[K,F]=v.useState(!1),[Y,V]=v.useState(null),[R,O]=v.useState(1),[I,H]=v.useState(1),q=v.useMemo(()=>a.filter(ue=>ue.scope===g).sort((ue,qe)=>ue.isActive!==qe.isActive?ue.isActive?-1:1:ue.sortOrder-qe.sortOrder||ue.name.localeCompare(qe.name)),[g,a]),ee=Math.max(1,Math.ceil(q.length/Zi)),te=v.useMemo(()=>{const ue=(R-1)*Zi;return q.slice(ue,ue+Zi)},[q,R]),Q=a.find(ue=>ue.id===w)||q[0]||null;v.useEffect(()=>{var ue;if(!Q&&q.length){E(q[0].id);return}Q&&Q.scope!==g&&E(((ue=q[0])==null?void 0:ue.id)||"")},[g,q,Q]),v.useEffect(()=>{e&&Promise.all([c(),b()])},[e,b,c]),v.useEffect(()=>{O(1)},[g]),v.useEffect(()=>{O(ue=>Math.min(ue,ee))},[ee]),v.useEffect(()=>{if(!w)return;const ue=q.findIndex(gt=>gt.id===w);if(ue<0)return;const qe=Math.floor(ue/Zi)+1;O(qe)},[q,w]);const se=v.useMemo(()=>{if(!Q)return[];const ue=S.trim().toLowerCase();return f.filter(qe=>qe.section===Q.id).filter(qe=>N||qe.is_active).filter(qe=>ue?[qe.category,qe.service,qe.work_type_label,qe.level_label,qe.notes].join(" ").toLowerCase().includes(ue):!0).sort((qe,gt)=>qe.sort_order-gt.sort_order||qe.service.localeCompare(gt.service))},[f,S,Q,N]),je=Math.max(1,Math.ceil(se.length/ud)),ze=v.useMemo(()=>{const ue=(I-1)*ud;return se.slice(ue,ue+ud)},[se,I]);v.useEffect(()=>{H(1)},[S,Q==null?void 0:Q.id,N]),v.useEffect(()=>{H(ue=>Math.min(ue,je))},[je]);const Ne=f.filter(ue=>ue.is_active).length,ne=a.filter(ue=>ue.scope==="client"&&ue.isActive).length,Me=ue=>{const qe=Math.min(Math.max(ue,1),ee);O(qe);const gt=q[(qe-1)*Zi];gt&&E(gt.id)},Je=ue=>{U(null),L(hH(ue,a)),M(!0)},ie=ue=>{U(ue),L(mH(ue)),M(!0)},De=async()=>{if(!$)return;const ue=$.name.trim(),qe=$.scope==="client"?$.clientName.trim():"";if(!ue){dt.error("Escribe el nombre de la sección.");return}if($.scope==="client"&&!qe){dt.error("Selecciona el cliente del tarifario especial.");return}k(!0);try{const gt={...$,id:(P==null?void 0:P.id)||_j($.scope,ue,$.clientName),name:ue,clientName:qe,pricingMode:$.scope==="client"?"fixed_multi":"guided"};await SB(gt),x(gt.scope),E(gt.id),M(!1),dt.success(P?"Sección actualizada.":"Sección creada.")}catch(gt){console.error("Error guardando sección del tarifario:",gt),dt.error(gt instanceof Error?gt.message:"No se pudo guardar la sección.")}finally{k(!1)}},Xe=async ue=>{V(ue.id);try{await EB(ue,!ue.isActive),dt.success(ue.isActive?"Sección desactivada.":"Sección reactivada.")}catch(qe){console.error("Error cambiando estado de sección:",qe),dt.error("No se pudo cambiar el estado de la sección.")}finally{V(null)}},We=()=>{Q&&(ge(null),me(pH(Q,f)),ce(!0))},Ct=ue=>{ge(ue),me(gH(ue)),ce(!0)},pe=async()=>{if(!re||!Q)return;const ue=Q.scope==="client",qe=re.service.trim(),gt=ue?Q.name:re.category.trim(),Xt=re.notes.trim();if(!qe){dt.error(ue?"Escribe el nombre de la pieza.":"Escribe el servicio o ítem.");return}if(!ue&&!gt){dt.error("Escribe la categoría.");return}const jt=re.reference_min==null?null:Number(re.reference_min),At=re.reference_max==null?null:Number(re.reference_max);if(ue&&(!Number.isFinite(jt)||Number(jt)<=0)){dt.error("El monto fijo debe ser mayor que cero.");return}if(jt!=null&&At!=null&&jt>At){dt.error("El monto mínimo no puede ser mayor que el máximo.");return}F(!0);try{const on=ue?null:f.find(en=>en.section===Q.id&&Ja(en.category)===Ja(gt)&&Ja(en.service)===Ja(qe)),gn=(fe==null?void 0:fe.catalog_item_id)||(on==null?void 0:on.catalog_item_id)||Ja(`${Q.id}-${gt}-${qe}`),vn=ue?"Tarifa fija":re.work_type_label.trim()||"Referencia",Mt=ue?"Precio fijo":re.level_label.trim()||"Precio único",Jt=(fe==null?void 0:fe.work_type_id)||Ja(vn)||"reference",Dt=(fe==null?void 0:fe.level_id)||Ja(Mt)||"project",fr=ue?Number(jt):null,Yn={...re,id:(fe==null?void 0:fe.id)||xj({catalog_item_id:gn,work_type_id:Jt,level_id:Dt}),catalog_item_id:gn,section:Q.id,category:gt,service:qe,notes:Xt,work_type_id:Jt,work_type_label:vn,work_type_short_label:ue?"Fijo":re.work_type_short_label.trim()||vn,hour_reference:ue?"":re.hour_reference.trim(),level_id:Dt,level_label:Mt,reference:ue?`${fr} USD`:re.reference.trim()||fH(jt,At),reference_min:ue?fr:jt,reference_max:ue?fr:At,level_hint:ue?"Monto fijo por pieza.":re.level_hint.trim(),sort_order:Number(re.sort_order||0),is_active:re.is_active,managed_by:"app"};await bB(Yn,fe),ce(!1),dt.success(fe?"Tarifa actualizada.":"Tarifa agregada.")}catch(on){console.error("Error guardando tarifa:",on),dt.error(on instanceof Error?on.message:"No se pudo guardar la tarifa.")}finally{F(!1)}},$e=async ue=>{V(ue.id);try{await xB(ue,!ue.is_active),dt.success(ue.is_active?"Tarifa desactivada.":"Tarifa reactivada.")}catch(qe){console.error("Error cambiando estado de tarifa:",qe),dt.error("No se pudo cambiar el estado de la tarifa.")}finally{V(null)}},Ke=i||h,Le=l||m;return d.jsxs(d.Fragment,{children:[d.jsx(ri,{open:e,onOpenChange:t,children:d.jsx(ls,{className:"h-[90vh] max-h-[900px] w-[96vw] max-w-[1280px] overflow-hidden p-0",children:d.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[d.jsxs("div",{className:"border-b border-border px-6 py-5 pr-14",children:[d.jsx(cs,{children:d.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[d.jsxs("div",{children:[d.jsxs(us,{className:"flex items-center gap-2 text-xl",children:[d.jsx(M1,{className:"h-5 w-5 text-primary"}),"Administración del tarifario"]}),d.jsx(ds,{className:"mt-1 max-w-3xl",children:"Crea secciones generales, administra tarifas por cliente y edita los ítems que ya utiliza el equipo al cotizar proyectos."})]}),d.jsxs("div",{className:"flex flex-wrap gap-2",children:[d.jsxs(Ee,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>void Promise.all([c(),b()]),disabled:Ke,children:[d.jsx(go,{className:xe("h-3.5 w-3.5",Ke&&"animate-spin")}),"Actualizar"]}),d.jsxs(Ee,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>Je("client"),children:[d.jsx(u_,{className:"h-3.5 w-3.5"}),"Tarifario por cliente"]}),d.jsxs(Ee,{type:"button",size:"sm",className:"gap-1.5",onClick:()=>Je("general"),children:[d.jsx(Ir,{className:"h-3.5 w-3.5"}),"Sección general"]})]})]})}),d.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:grid-cols-3",children:[d.jsx(Wp,{icon:d.jsx(V3,{className:"h-4 w-4"}),label:"Secciones activas",value:a.filter(ue=>ue.isActive).length}),d.jsx(Wp,{icon:d.jsx(u_,{className:"h-4 w-4"}),label:"Tarifarios por cliente",value:ne}),d.jsx(Wp,{icon:d.jsx(d_,{className:"h-4 w-4"}),label:"Tarifas activas",value:Ne})]})]}),Le&&d.jsx("div",{className:"border-b border-amber-200 bg-amber-50 px-6 py-2 text-xs text-amber-900",children:Le}),d.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-[310px_minmax(0,1fr)]",children:[d.jsxs("aside",{className:"flex min-h-0 flex-col border-b border-border bg-muted/20 lg:border-b-0 lg:border-r",children:[d.jsxs("div",{className:"space-y-3 p-4",children:[d.jsx(UT,{value:g,onValueChange:ue=>x(ue),children:d.jsxs(cy,{className:"grid w-full grid-cols-2",children:[d.jsx(tf,{value:"general",children:"Generales"}),d.jsx(tf,{value:"client",children:"Por cliente"})]})}),d.jsx("p",{className:"text-xs text-muted-foreground",children:g==="general"?"Estas secciones aparecen para los clientes que no tienen un tarifario especial.":"Cada tarifario aparece únicamente al seleccionar el cliente asociado."})]}),d.jsx(qg,{className:"min-h-[220px] flex-1 px-3 pb-3",children:d.jsxs("div",{className:"space-y-2 pr-2",children:[te.map(ue=>{const qe=ue.id===(Q==null?void 0:Q.id),gt=f.filter(Xt=>Xt.section===ue.id&&Xt.is_active).length;return d.jsxs("button",{type:"button",onClick:()=>E(ue.id),className:xe("w-full rounded-xl border px-3 py-3 text-left transition-colors",qe?"border-primary/40 bg-primary/10":"border-border bg-card hover:bg-muted/50",!ue.isActive&&"opacity-60"),children:[d.jsxs("div",{className:"flex items-start justify-between gap-2",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("p",{className:"truncate text-sm font-semibold",children:ue.name}),ue.scope==="client"&&d.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:ue.clientName})]}),d.jsx(sn,{variant:ue.isActive?"secondary":"outline",children:ue.isActive?"Activa":"Inactiva"})]}),d.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:[gt," tarifa(s) activa(s)"]})]},ue.id)}),q.length===0&&d.jsx("div",{className:"rounded-xl border border-dashed border-border bg-card px-3 py-5 text-center text-sm text-muted-foreground",children:"No hay secciones de este tipo."})]})}),d.jsx(vS,{currentPage:R,totalPages:ee,totalItems:q.length,pageSize:Zi,itemLabel:"secciones",onPageChange:Me,compact:!0})]}),d.jsx("section",{className:"min-h-0",children:Q?d.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[d.jsx("div",{className:"border-b border-border px-5 py-4",children:d.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-start md:justify-between",children:[d.jsxs("div",{children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsx("h3",{className:"text-lg font-semibold",children:Q.name}),d.jsx(sn,{variant:Q.scope==="client"?"default":"secondary",children:Q.scope==="client"?"Por cliente":"General"}),!Q.isActive&&d.jsx(sn,{variant:"outline",children:"Inactiva"})]}),Q.scope==="client"&&d.jsxs("p",{className:"mt-1 text-sm text-primary",children:["Se muestra al seleccionar: ",Q.clientName]}),d.jsx("p",{className:"mt-1 max-w-3xl text-sm text-muted-foreground",children:Q.description||"Sin descripción."})]}),d.jsxs("div",{className:"flex flex-wrap gap-2",children:[d.jsxs(Ee,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>ie(Q),children:[d.jsx(hP,{className:"h-3.5 w-3.5"}),"Editar sección"]}),d.jsxs(Ee,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>void Xe(Q),disabled:Y===Q.id,children:[Q.isActive?d.jsx(c_,{className:"h-3.5 w-3.5 rotate-180"}):d.jsx(c_,{className:"h-3.5 w-3.5"}),Q.isActive?"Desactivar":"Reactivar"]}),d.jsxs(Ee,{type:"button",size:"sm",className:"gap-1.5",onClick:We,children:[d.jsx(Ir,{className:"h-3.5 w-3.5"}),Q.scope==="client"?"Nueva pieza":"Nueva tarifa"]})]})]})}),d.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b border-border px-5 py-3",children:[d.jsxs("div",{className:"relative min-w-[220px] flex-1",children:[d.jsx(Ws,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),d.jsx(ot,{value:S,onChange:ue=>C(ue.target.value),className:"pl-9",placeholder:"Buscar servicio, categoría o nivel…"})]}),d.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[d.jsx(ec,{checked:N,onCheckedChange:A}),"Mostrar inactivas"]})]}),d.jsx(qg,{className:"min-h-0 flex-1",children:d.jsx("div",{className:"space-y-3 p-5",children:Ke&&se.length===0?d.jsxs("div",{className:"flex items-center justify-center gap-2 py-12 text-sm text-muted-foreground",children:[d.jsx(Kt,{className:"h-4 w-4 animate-spin"})," Cargando tarifario…"]}):se.length===0?d.jsxs("div",{className:"rounded-2xl border border-dashed border-border bg-muted/20 px-5 py-10 text-center",children:[d.jsx(d_,{className:"mx-auto h-8 w-8 text-muted-foreground"}),d.jsx("p",{className:"mt-3 text-sm font-medium",children:"No hay tarifas para mostrar"}),d.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Agrega la primera tarifa de esta sección o activa “Mostrar inactivas”."}),d.jsxs(Ee,{className:"mt-4 gap-1.5",size:"sm",onClick:We,children:[d.jsx(Ir,{className:"h-3.5 w-3.5"})," Agregar tarifa"]})]}):ze.map(ue=>d.jsx(yH,{row:ue,section:Q,busy:Y===ue.id,onEdit:()=>Ct(ue),onToggle:()=>void $e(ue)},ue.id))})}),d.jsx(vS,{currentPage:I,totalPages:je,totalItems:se.length,pageSize:ud,itemLabel:"tarifas",onPageChange:H})]}):d.jsx("div",{className:"flex h-full items-center justify-center p-8 text-center text-sm text-muted-foreground",children:"Selecciona o crea una sección para comenzar."})})]})]})})}),d.jsx(bH,{open:T,onOpenChange:M,draft:$,onDraftChange:L,clients:n.clientes,editing:!!P,saving:de,onSave:()=>void De()}),d.jsx(xH,{open:J,onOpenChange:ce,section:Q,draft:re,onDraftChange:me,editing:!!fe,saving:K,onSave:()=>void pe()})]})}function vS({currentPage:e,totalPages:t,totalItems:n,pageSize:a,itemLabel:i,onPageChange:l,compact:c=!1}){const f=n===0?0:(e-1)*a+1,h=Math.min(e*a,n);return d.jsxs("div",{className:xe("flex items-center justify-between gap-3 border-t border-border bg-background/95 px-4 py-2.5",c&&"px-3"),children:[d.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[f,"",h," de ",n," ",i]}),d.jsxs("div",{className:"flex items-center gap-1.5",children:[!c&&d.jsxs("span",{className:"mr-1 text-[11px] text-muted-foreground",children:["Página ",e," de ",t]}),d.jsx(Ee,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Página anterior",onClick:()=>l(e-1),disabled:e<=1,children:d.jsx(ff,{className:"h-3.5 w-3.5"})}),c&&d.jsxs("span",{className:"min-w-[42px] text-center text-[11px] text-muted-foreground",children:[e,"/",t]}),d.jsx(Ee,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Página siguiente",onClick:()=>l(e+1),disabled:e>=t,children:d.jsx(oc,{className:"h-3.5 w-3.5"})})]})]})}function Wp({icon:e,label:t,value:n}){return d.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-border bg-muted/20 px-3 py-2.5",children:[d.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10 text-primary",children:e}),d.jsxs("div",{children:[d.jsx("p",{className:"text-lg font-semibold leading-none",children:n}),d.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:t})]})]})}function yH({row:e,section:t,busy:n,onEdit:a,onToggle:i}){const l=t.scope==="client",c=l?Gp(e.reference_min??e.reference_max):e.reference||(e.reference_min!=null||e.reference_max!=null?`${Gp(e.reference_min)} ${Gp(e.reference_max)}`:"Sin monto de referencia");return d.jsx("div",{className:xe("rounded-2xl border border-border bg-card px-4 py-3 shadow-sm",!e.is_active&&"opacity-60"),children:d.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsx("p",{className:"font-medium",children:e.service}),d.jsx(sn,{variant:e.is_active?"secondary":"outline",children:e.is_active?"Activa":"Inactiva"}),e.managed_by==="app"&&d.jsx(sn,{variant:"outline",children:"Gestionada en app"})]}),!l&&d.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:e.category}),d.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[!l&&d.jsx("span",{children:e.work_type_label}),!l&&d.jsx("span",{children:e.level_label}),d.jsx("span",{className:"font-semibold text-foreground",children:c}),d.jsxs("span",{children:["Orden: ",e.sort_order]})]}),e.notes&&d.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-muted-foreground",children:e.notes})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsxs(Ee,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",onClick:a,children:[d.jsx(oP,{className:"h-3.5 w-3.5"})," Editar"]}),d.jsx(Ee,{type:"button",variant:"ghost",size:"sm",onClick:i,disabled:n,children:n?d.jsx(Kt,{className:"h-3.5 w-3.5 animate-spin"}):e.is_active?"Desactivar":"Reactivar"})]})]})})}function bH({open:e,onOpenChange:t,draft:n,onDraftChange:a,clients:i,editing:l,saving:c,onSave:f}){if(!n)return null;const h=n.scope==="client";return d.jsx(ri,{open:e,onOpenChange:t,children:d.jsxs(ls,{className:"max-w-2xl",children:[d.jsxs(cs,{children:[d.jsx(us,{children:l?"Editar sección":h?"Nuevo tarifario por cliente":"Nueva sección general"}),d.jsx(ds,{children:h?"El tarifario aparecerá automáticamente cuando se seleccione el cliente indicado.":"La sección aparecerá junto a las demás secciones del tarifario general."})]}),d.jsxs("div",{className:"grid grid-cols-1 gap-4 py-2 sm:grid-cols-2",children:[d.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[d.jsx(Ge,{children:"Nombre de la sección"}),d.jsx(ot,{value:n.name,onChange:m=>a({...n,name:m.target.value}),placeholder:h?"Ej: Tarifario PepsiCo":"Ej: Producción audiovisual"})]}),h&&d.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[d.jsx(Ge,{children:"Cliente asociado"}),d.jsx(_r,{value:n.clientName,options:i,onValueChange:m=>a({...n,clientName:m}),placeholder:"Seleccionar cliente…",searchPlaceholder:"Buscar cliente…",emptyText:"No se encontró ese cliente en las listas de la app."}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"El nombre debe coincidir con el cliente disponible en el formulario de proyectos."})]}),d.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[d.jsx(Ge,{children:"Descripción para el usuario"}),d.jsx(ma,{value:n.description,onChange:m=>a({...n,description:m.target.value}),placeholder:"Explica brevemente qué incluye esta sección.",rows:3})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Orden"}),d.jsx(ot,{type:"number",min:"0",value:n.sortOrder,onChange:m=>a({...n,sortOrder:Number(m.target.value||0)})})]}),d.jsxs("div",{className:"flex flex-col justify-end gap-3 rounded-xl border border-border bg-muted/20 px-3 py-2.5",children:[d.jsxs("label",{className:"flex items-center justify-between gap-3 text-sm",children:[d.jsx("span",{children:"Sección activa"}),d.jsx(ec,{checked:n.isActive,onCheckedChange:m=>a({...n,isActive:m})})]}),h&&d.jsxs("label",{className:"flex items-center justify-between gap-3 text-sm",children:[d.jsx("span",{children:"Permitir costo manual"}),d.jsx(ec,{checked:n.allowManual,onCheckedChange:m=>a({...n,allowManual:m})})]})]})]}),d.jsxs(Rf,{children:[d.jsx(Ee,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancelar"}),d.jsxs(Ee,{type:"button",className:"gap-1.5",onClick:f,disabled:c,children:[c?d.jsx(Kt,{className:"h-4 w-4 animate-spin"}):d.jsx(Hr,{className:"h-4 w-4"}),"Guardar sección"]})]})]})})}function xH({open:e,onOpenChange:t,section:n,draft:a,onDraftChange:i,editing:l,saving:c,onSave:f}){if(!a||!n)return null;const h=n.scope==="client";return d.jsx(ri,{open:e,onOpenChange:t,children:d.jsxs(ls,{className:"max-h-[88vh] max-w-3xl overflow-y-auto",children:[d.jsxs(cs,{children:[d.jsx(us,{children:l?h?"Editar pieza":"Editar tarifa":h?"Nueva pieza de precio fijo":"Nueva tarifa"}),d.jsxs(ds,{children:["Sección: ",n.name]})]}),h?d.jsxs("div",{className:"grid grid-cols-1 gap-4 py-2 sm:grid-cols-[minmax(0,1fr)_200px]",children:[d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Nombre de la pieza"}),d.jsx(ot,{value:a.service,onChange:m=>i({...a,service:m.target.value}),placeholder:"Ej: Photobooth"})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Monto fijo (USD)"}),d.jsx(ot,{type:"number",min:"0",step:"0.01",value:a.reference_min??"",onChange:m=>i({...a,reference_min:Kp(m.target.value)}),placeholder:"0.00"})]}),d.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[d.jsx(Ge,{children:"Descripción / incluye"}),d.jsx(ma,{value:a.notes,onChange:m=>i({...a,notes:m.target.value}),placeholder:"Describe qué incluye esta pieza y cualquier observación importante.",rows:4})]})]}):d.jsxs("div",{className:"grid grid-cols-1 gap-4 py-2 sm:grid-cols-2",children:[d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Categoría"}),d.jsx(ot,{value:a.category,onChange:m=>i({...a,category:m.target.value}),placeholder:"Ej: Materiales de PDV"})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Servicio / ítem"}),d.jsx(ot,{value:a.service,onChange:m=>i({...a,service:m.target.value}),placeholder:"Ej: Diseño de roll up"})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Tipo de trabajo"}),d.jsx(ot,{value:a.work_type_label,onChange:m=>i({...a,work_type_label:m.target.value}),placeholder:"Ej: Diseño + Arte Final"})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Etiqueta corta"}),d.jsx(ot,{value:a.work_type_short_label,onChange:m=>i({...a,work_type_short_label:m.target.value}),placeholder:"Ej: Diseño"})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Nivel / referencia"}),d.jsx(ot,{value:a.level_label,onChange:m=>i({...a,level_label:m.target.value}),placeholder:"Ej: Básico"})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Hora hombre ref."}),d.jsx(ot,{value:a.hour_reference,onChange:m=>i({...a,hour_reference:m.target.value}),placeholder:"Ej: 35 - 50"})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Monto mínimo"}),d.jsx(ot,{type:"number",min:"0",step:"0.01",value:a.reference_min??"",onChange:m=>i({...a,reference_min:Kp(m.target.value)}),placeholder:"0.00"})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Monto máximo"}),d.jsx(ot,{type:"number",min:"0",step:"0.01",value:a.reference_max??"",onChange:m=>i({...a,reference_max:Kp(m.target.value)}),placeholder:"0.00"})]}),d.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[d.jsx(Ge,{children:"Referencia visible"}),d.jsx(ot,{value:a.reference,onChange:m=>i({...a,reference:m.target.value}),placeholder:"Ej: 100 - 150 USD (se genera automáticamente si se deja vacío)"})]}),d.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[d.jsx(Ge,{children:"Observaciones / incluye"}),d.jsx(ma,{value:a.notes,onChange:m=>i({...a,notes:m.target.value}),placeholder:"Describe qué incluye el servicio.",rows:3})]}),d.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[d.jsx(Ge,{children:"Nota del nivel"}),d.jsx(ma,{value:a.level_hint,onChange:m=>i({...a,level_hint:m.target.value}),placeholder:"Ej: Puede superar el rango si la complejidad lo requiere.",rows:2})]})]}),d.jsx(Hs,{}),d.jsxs("div",{className:"grid grid-cols-1 gap-4 py-2 sm:grid-cols-2",children:[d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Orden"}),d.jsx(ot,{type:"number",min:"0",value:a.sort_order,onChange:m=>i({...a,sort_order:Number(m.target.value||0)})})]}),d.jsxs("label",{className:"flex items-center justify-between gap-3 rounded-xl border border-border bg-muted/20 px-3 py-2.5 text-sm",children:[d.jsx("span",{children:"Tarifa activa"}),d.jsx(ec,{checked:a.is_active,onCheckedChange:m=>i({...a,is_active:m})})]})]}),d.jsxs(Rf,{children:[d.jsx(Ee,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancelar"}),d.jsxs(Ee,{type:"button",className:"gap-1.5",onClick:f,disabled:c,children:[c?d.jsx(Kt,{className:"h-4 w-4 animate-spin"}):d.jsx(Hr,{className:"h-4 w-4"}),"Guardar tarifa"]})]})]})})}const wH="https://agenteit.digitalcompass.agency/webhook/tablero-cdc-sync-listas-admin";function _H(){return"https://agenteit.digitalcompass.agency/webhook/tablero-cdc-sync-listas-admin".trim()||wH}async function Yp(e){var l;const{data:t,error:n}=await Se.auth.getSession();if(n||!((l=t.session)!=null&&l.access_token))throw new Error("No hay una sesión activa. Recarga la página e inicia sesión nuevamente.");const a=new AbortController,i=window.setTimeout(()=>a.abort(),2e4);try{const c=await fetch(_H(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e.action,category:e.category||"",value:e.value||"",previous_value:e.previousValue||"",manager:e.manager||"",source:"tablero-cdc",access_token:t.session.access_token,sent_at:new Date().toISOString()}),signal:a.signal}),f=await c.text();let h=null;if(f)try{h=JSON.parse(f)}catch{h={message:f}}if(!c.ok)throw new Error((h==null?void 0:h.message)||`${c.status} ${c.statusText}`.trim());return h||{ok:!0}}catch(c){throw c instanceof DOMException&&c.name==="AbortError"?new Error("n8n tardó demasiado en responder. Revisa el workflow de sincronización de listas."):c}finally{window.clearTimeout(i)}}const SH="https://docs.google.com/spreadsheets/d/19oBoslErcTSk8ibA6Nr38lcOV8Q09JwGahS7JD1o4Ts/edit?gid=1709890592#gid=1709890592",Tl={client:{label:"Clientes",singular:"cliente",placeholder:"Ej: PepsiCo",description:"Opciones disponibles en el campo Cliente de los proyectos."},brand:{label:"Marcas",singular:"marca",placeholder:"Ej: Nescafé",description:"Opciones disponibles en la selección de una o varias marcas."},country:{label:"País / BU",singular:"País / BU",placeholder:"Ej: Guatemala",description:"Cada País / BU puede tener un Country Manager asociado."},status:{label:"Estatus",singular:"estatus",placeholder:"Ej: Stand by",description:"Estatus disponibles para cerrar o clasificar proyectos."}};function dd(e){return[...e].sort((t,n)=>t.value.localeCompare(n.value,"es",{sensitivity:"base"}))}const fd=25;function EH(e,t){return t<=7?Array.from({length:t},(n,a)=>a+1):e<=4?[1,2,3,4,5,"ellipsis-end",t]:e>=t-3?[1,"ellipsis-start",t-4,t-3,t-2,t-1,t]:[1,"ellipsis-start",e-1,e,e+1,"ellipsis-end",t]}function NH({open:e,onOpenChange:t}){const[n,a]=v.useState("client"),[i,l]=v.useState(""),[c,f]=v.useState(1),[h,m]=v.useState(""),[b,g]=v.useState(""),[x,w]=v.useState(null),[E,S]=v.useState(!1),[C,N]=v.useState(null),[A,T]=v.useState(!1),{lists:M,loading:$,error:L,refresh:P}=bc(),U=v.useMemo(()=>dd(n==="client"?M.clientes.map(R=>({value:R})):n==="brand"?M.marcas.map(R=>({value:R})):n==="status"?M.status.map(R=>({value:R})):M.bus.map(R=>{var O;return{value:R,manager:M.buCm[R]||((O=Object.entries(M.buCm).find(([I])=>Ae(I)===Ae(R)))==null?void 0:O[1])||""}})),[n,M]),J=v.useMemo(()=>{const R=Ae(i);return R?U.filter(O=>Ae(`${O.value} ${O.manager||""}`).includes(R)):U},[i,U]),ce=Math.max(1,Math.ceil(J.length/fd)),re=Math.min(c,ce),me=(re-1)*fd,fe=J.slice(me,me+fd),ge=EH(re,ce),de=()=>{m(""),g(""),w(null)};v.useEffect(()=>{e&&P()},[e,P]),v.useEffect(()=>{de(),l(""),f(1)},[n]),v.useEffect(()=>{f(1)},[i]),v.useEffect(()=>{c>ce&&f(ce)},[c,ce]);const k=R=>{w(R.value),m(R.value),g(R.manager||"")},K=async()=>{const R=h.trim(),O=b.trim();if(!R){dt.error(`Escribe el ${Tl[n].singular}.`);return}S(!0);try{await Yp({action:x?"update":"create",category:n,value:R,previousValue:x||void 0,manager:n==="country"?O:void 0}),await P(),dt.success(x?"Lista actualizada.":"Opción agregada.",{description:"Google Sheet y Supabase quedaron sincronizados."}),de()}catch(I){console.error("Error guardando lista:",I),dt.error("No se pudo guardar la lista.",{description:I instanceof Error?I.message:"Revisa n8n e intenta nuevamente."})}finally{S(!1)}},F=async R=>{if(window.confirm(`¿Eliminar "${R.value}" de ${Tl[n].label}?
El cambio también se hará en el Google Sheet. Los proyectos históricos no se borrarán.`)){N(R.value);try{await Yp({action:"delete",category:n,value:R.value,previousValue:R.value}),await P(),x&&Ae(x)===Ae(R.value)&&de(),dt.success("Opción eliminada.",{description:"Google Sheet y Supabase quedaron sincronizados."})}catch(O){console.error("Error eliminando lista:",O),dt.error("No se pudo eliminar la opción.",{description:O instanceof Error?O.message:"Revisa n8n e intenta nuevamente."})}finally{N(null)}}},Y=async()=>{T(!0);try{await Yp({action:"refresh"}),await P(),dt.success("Listas actualizadas desde el Sheet.")}catch(R){console.error("Error sincronizando listas:",R),dt.error("No se pudieron sincronizar las listas.",{description:R instanceof Error?R.message:"Revisa n8n e intenta nuevamente."})}finally{T(!1)}},V=Tl[n];return d.jsx(ri,{open:e,onOpenChange:t,children:d.jsx(ls,{className:"h-[88vh] max-h-[860px] w-[96vw] max-w-[1050px] overflow-hidden p-0",children:d.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[d.jsx("div",{className:"border-b border-border px-6 py-5 pr-14",children:d.jsx(cs,{children:d.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[d.jsxs("div",{children:[d.jsxs(us,{className:"flex items-center gap-2 text-xl",children:[d.jsx(Ld,{className:"h-5 w-5 text-primary"}),"Administración de listas"]}),d.jsxs(ds,{className:"mt-1 max-w-2xl",children:["Los cambios que realices aquí se guardarán automáticamente en la hoja"," ",d.jsx("strong",{children:"Listas"})," y se reflejarán de inmediato en las opciones disponibles de la aplicación."]})]}),d.jsxs("div",{className:"flex flex-wrap gap-2",children:[d.jsxs(Ee,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>window.open(SH,"_blank","noopener,noreferrer"),children:[d.jsx(ov,{className:"h-3.5 w-3.5"})," Abrir Sheet"]}),d.jsxs(Ee,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>void Y(),disabled:A,children:[d.jsx(go,{className:xe("h-3.5 w-3.5",A&&"animate-spin")}),"Sincronizar desde Sheet"]})]})]})})}),d.jsx("div",{className:"border-b border-border px-6 py-4",children:d.jsx(UT,{value:n,onValueChange:R=>a(R),children:d.jsx(cy,{className:"grid w-full grid-cols-2 sm:grid-cols-4",children:Object.keys(Tl).map(R=>d.jsx(tf,{value:R,children:Tl[R].label},R))})})}),d.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-[360px_minmax(0,1fr)]",children:[d.jsx("section",{className:"border-b border-border bg-muted/15 p-5 lg:border-b-0 lg:border-r",children:d.jsxs("div",{className:"rounded-2xl border border-border bg-card p-4 shadow-sm",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsxs("div",{children:[d.jsx("h3",{className:"text-sm font-semibold",children:x?`Editar ${V.singular}`:`Agregar ${V.singular}`}),d.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:V.description})]}),x&&d.jsx(Ee,{type:"button",variant:"ghost",size:"icon",onClick:de,children:d.jsx(vo,{className:"h-4 w-4"})})]}),d.jsxs("div",{className:"mt-4 space-y-3",children:[d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:V.singular.charAt(0).toUpperCase()+V.singular.slice(1)}),d.jsx(ot,{value:h,onChange:R=>m(R.target.value),placeholder:V.placeholder,disabled:E})]}),n==="country"&&d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(Ge,{children:"Country Manager"}),d.jsx(ot,{value:b,onChange:R=>g(R.target.value),placeholder:"Ej: Poul",disabled:E})]}),d.jsxs(Ee,{type:"button",className:"w-full gap-1.5",onClick:()=>void K(),disabled:E||!h.trim(),children:[E?d.jsx(Kt,{className:"h-4 w-4 animate-spin"}):x?d.jsx(Hr,{className:"h-4 w-4"}):d.jsx(Ir,{className:"h-4 w-4"}),x?"Guardar cambios":"Agregar"]})]})]})}),d.jsxs("section",{className:"flex min-h-0 flex-col p-5",children:[d.jsxs("div",{className:"relative mb-3",children:[d.jsx(Ws,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),d.jsx(ot,{value:i,onChange:R=>l(R.target.value),placeholder:`Buscar en ${V.label}`,className:"pl-9"})]}),L&&d.jsxs("div",{className:"mb-3 rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-900",children:["No se pudieron cargar las listas desde Supabase: ",L]}),d.jsxs("div",{className:"mb-2 flex items-center justify-between text-xs text-muted-foreground",children:[d.jsxs("span",{children:[J.length," opción(es)"]}),$&&d.jsx("span",{children:"Cargando…"})]}),d.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto rounded-2xl border border-border bg-card",children:$&&U.length===0?d.jsxs("div",{className:"flex h-40 items-center justify-center gap-2 text-sm text-muted-foreground",children:[d.jsx(Kt,{className:"h-4 w-4 animate-spin"})," Cargando listas…"]}):J.length===0?d.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"No hay opciones que coincidan."}):d.jsx("div",{className:"divide-y divide-border",children:fe.map(R=>d.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-3",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("p",{className:"truncate text-sm font-medium",children:R.value}),n==="country"&&d.jsxs("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:["CM: ",R.manager||"Sin asignar"]})]}),d.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[d.jsxs(Ee,{type:"button",variant:"ghost",size:"sm",className:"h-8 gap-1 px-2",onClick:()=>k(R),disabled:!!C||E,children:[d.jsx(lv,{className:"h-3.5 w-3.5"})," Editar"]}),d.jsxs(Ee,{type:"button",variant:"ghost",size:"sm",className:"h-8 gap-1 px-2 text-muted-foreground hover:text-destructive",onClick:()=>void F(R),disabled:!!C||E,children:[C===R.value?d.jsx(Kt,{className:"h-3.5 w-3.5 animate-spin"}):d.jsx(hf,{className:"h-3.5 w-3.5"}),"Eliminar"]})]})]},Ae(`${n}:${R.value}`)))})}),J.length>0&&d.jsxs("div",{className:"mt-3 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[d.jsxs("span",{className:"text-xs text-muted-foreground",children:["Mostrando ",me+1,"",Math.min(me+fd,J.length)," de"," ",J.length]}),ce>1&&d.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[d.jsx(Ee,{type:"button",variant:"outline",size:"sm",className:"h-8 px-2.5",onClick:()=>f(R=>Math.max(1,R-1)),disabled:re===1,children:"Anterior"}),ge.map(R=>typeof R=="number"?d.jsx(Ee,{type:"button",variant:R===re?"default":"outline",size:"sm",className:"h-8 min-w-8 px-2",onClick:()=>f(R),"aria-current":R===re?"page":void 0,children:R},R):d.jsx("span",{className:"flex h-8 min-w-6 items-center justify-center text-xs text-muted-foreground","aria-hidden":"true",children:"…"},R)),d.jsx(Ee,{type:"button",variant:"outline",size:"sm",className:"h-8 px-2.5",onClick:()=>f(R=>Math.min(ce,R+1)),disabled:re===ce,children:"Siguiente"})]})]})]})]})]})})})}const Is=24,nf={country:"",brand:"",client:"",cm:""},yS={nuevos:1,todos:1,abiertos:1,cerrados:1,no_aprobados:1},BT="tablero-cdc:ui-state:v1";function CH(){const e={query:"",filter:"todos",advancedFilters:nf,pageByFilter:yS,tariffManagerOpen:!1,listManagerOpen:!1,teamHoursOpen:!1,scrollY:0};if(typeof window>"u")return e;try{const t=window.localStorage.getItem(BT);if(!t)return e;const n=JSON.parse(t);return{query:"",filter:["nuevos","todos","abiertos","cerrados","no_aprobados"].includes(n.filter)?n.filter:e.filter,advancedFilters:nf,pageByFilter:Object.fromEntries(Object.entries({...yS,...n.pageByFilter||{}}).map(([l,c])=>[l,Math.max(1,Math.floor(Number(c)||1))])),tariffManagerOpen:n.tariffManagerOpen===!0,listManagerOpen:n.listManagerOpen===!0,teamHoursOpen:n.teamHoursOpen===!0,scrollY:Number.isFinite(Number(n.scrollY))?Math.max(0,Number(n.scrollY)):0}}catch(t){return console.warn("No se pudo restaurar la vista anterior del Tablero CDC:",t),e}}function jH(e,t){if(e){const n=e.trim().split(/\s+/);return n.length>=2?(n[0][0]+n[1][0]).toUpperCase():e.slice(0,2).toUpperCase()}return t?t.slice(0,2).toUpperCase():"?"}function TH(){const[e]=v.useState(CH),t=v.useRef(!1),n=v.useRef(e.scrollY<=0),[a,i]=v.useState(!1),[l,c]=v.useState(null),[f,h]=v.useState(e.query),[m,b]=v.useState(e.filter),[g,x]=v.useState(e.advancedFilters),[w,E]=v.useState(e.pageByFilter),[S,C]=v.useState(null),[N,A]=v.useState(e.tariffManagerOpen),[T,M]=v.useState(e.listManagerOpen),[$,L]=v.useState(e.teamHoursOpen),[P,U]=v.useState(null),[J,ce]=v.useState(null),re=m==="nuevos"||m==="no_aprobados",me=m==="no_aprobados"?"rejected":"new",fe=re?"todos":m,ge=w[m],{lists:de}=bc(),{projects:k,totalProjects:K,filterOptions:F,loading:Y,error:V,refresh:R,remove:O}=Xj({tab:fe,search:re?"":f,page:re?w[fe]:ge,pageSize:Is,country:re?"":g.country,brand:re?"":g.brand,client:re?"":g.client,cm:re?"":g.cm}),I=$8({status:me,search:f,page:ge,pageSize:Is,enabled:re}),{user:H,isGerardo:q,canManageInternalPricing:ee,canControlPricingSummary:te,canManageTariffCatalog:Q,canViewTeamHours:se,canCreateProjects:je,logout:ze}=df(),Ne=U8(!!H);v.useEffect(()=>{!se&&$&&L(!1)},[se,$]);const ne={tab:fe,search:re?"":f,page:1,pageSize:Is,country:re?"":g.country,brand:re?"":g.brand,client:re?"":g.client,cm:re?"":g.cm},{isPublic:Me,loading:Je,saving:ie,error:De,setPublicVisibility:Xe}=q8(!!H),We=!re&&(te||Me),{summary:Ct,loading:pe,error:$e}=_6(ne,We),Ke=Object.values(de.buCm),Le=at([...de.bus,...$B(F.countries,de.bus),g.country]),ue=at([...de.marcas,...Up(F.brands,de.marcas),g.brand]),qe=at([...de.clientes,...Up(F.clients,de.clientes),g.client]),gt=at([...Ke,...Up(F.cms,Ke),g.cm]),Xt=Object.values(g).filter(Boolean).length,jt=re?I.totalItems:K,At=Math.max(1,Math.ceil(jt/Is)),on=Math.min(ge,At),gn=(on-1)*Is,vn=jt===0?0:gn+1,Mt=Math.min(gn+Is,jt);v.useEffect(()=>{if(!t.current){t.current=!0;return}E(we=>({...we,[m]:1}))},[f,g.country,g.brand,g.client,g.cm]),v.useEffect(()=>{const we=()=>{try{const ht={query:"",filter:m,advancedFilters:nf,pageByFilter:w,tariffManagerOpen:N,listManagerOpen:T,teamHoursOpen:$,scrollY:n.current?window.scrollY:e.scrollY};window.localStorage.setItem(BT,JSON.stringify(ht))}catch(ht){console.warn("No se pudo guardar la vista del Tablero CDC:",ht)}};we();const ft=()=>we(),kt=()=>{document.visibilityState==="hidden"&&we()};return window.addEventListener("pagehide",ft),document.addEventListener("visibilitychange",kt),()=>{window.removeEventListener("pagehide",ft),document.removeEventListener("visibilitychange",kt)}},[f,m,g,w,N,T,$,e.scrollY]),v.useEffect(()=>{const we=e.scrollY,ft=re?I.loading:Y;if(we<=0||ft||n.current)return;const kt=window.setTimeout(()=>{window.scrollTo({top:we,behavior:"auto"}),n.current=!0},120);return()=>window.clearTimeout(kt)},[e.scrollY,re,I.loading,Y]),v.useEffect(()=>{ge>At&&E(we=>({...we,[m]:At}))},[ge,m,At]),v.useEffect(()=>{m!=="nuevos"||!H||Ne.unreadCount<=0||Ne.markAllSeen().catch(we=>{console.error("Error marcando briefs como vistos:",we)})},[m,H==null?void 0:H.id,Ne.unreadCount,Ne.markAllSeen]);const Jt=we=>{const ft=Math.min(Math.max(we,1),At);ft!==ge&&(E(kt=>({...kt,[m]:ft})),window.scrollTo({top:0,behavior:"smooth"}))},Dt=(we,ft)=>{x(kt=>({...kt,[we]:ft}))},fr=()=>{x(nf)},Yn=()=>{je&&(c(null),i(!0))},en=we=>{c(we),i(!0)},he=async we=>{if(window.confirm(`¿Seguro que deseas eliminar el proyecto "${we.nombre||"Sin título"}"?
Esta acción eliminará el proyecto del tablero y del Google Sheet.`)){C(we.id);try{await O(we.id),(l==null?void 0:l.id)===we.id&&(i(!1),c(null))}catch(kt){console.error("Error eliminando proyecto:",kt);const ht=kt instanceof Error?kt.message:"No se pudo eliminar el proyecto. Revisa n8n, Supabase o permisos.";window.alert(ht)}finally{C(null)}}},Be=async(we,ft,kt=!1)=>{if(!(!window.confirm(kt?`¿Aprobar el brief rechazado "${ft||"Sin título"}"?
Se recuperará de Rechazados, se creará como proyecto Activo y aparecerá en Todos y Activos.`:`¿Aprobar el brief "${ft||"Sin título"}"?
Se creará como proyecto Activo y aparecerá en Todos y Activos.`)||J)){ce(we);try{const $t=await I.approve(we);await R(),$t.sheetSyncStatus==="synced"?window.alert("Brief aprobado. El proyecto quedó Activo y sincronizado con Google Sheet."):window.alert($t.sheetSyncMessage)}catch($t){console.error("Error aprobando brief:",$t),window.alert($t instanceof Error?$t.message:"No se pudo aprobar el brief. Revisa Supabase e intenta de nuevo.")}finally{ce(null)}}},et=async(we,ft)=>{if(!(!window.confirm(`¿Mover el brief "${ft||"Sin título"}" a Rechazados?
No se creará ningún proyecto en el tablero general.`)||J)){ce(we);try{await I.reject(we)}catch(ht){console.error("Error marcando brief como rechazado:",ht),window.alert(ht instanceof Error?ht.message:"No se pudo mover el brief a Rechazados. Revisa Supabase e intenta de nuevo.")}finally{ce(null)}}},rt=(H==null?void 0:H.displayName)??(H==null?void 0:H.email)??"Usuario",He=q?"Jefe CDC":"Usuario CDC",Et=jH(H==null?void 0:H.displayName,H==null?void 0:H.email);return d.jsxs("div",{className:"min-h-screen bg-background",children:[d.jsx("header",{className:"sticky top-0 z-30 bg-background/85 backdrop-blur-md border-b border-border",children:d.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-3.5 flex items-center gap-4",children:[d.jsxs("div",{className:"flex items-center gap-4",children:[d.jsx(av,{size:"sm"}),d.jsx("div",{className:"h-7 w-px bg-border"}),d.jsx("h1",{className:"text-[15px] font-semibold tracking-tight text-[#4F758B]",children:"CDC Project Management"})]}),d.jsxs("div",{className:"flex-1 max-w-md ml-4 relative hidden md:block",children:[d.jsx(Ws,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),d.jsx(ot,{value:f,onChange:we=>h(we.target.value),placeholder:re?"Buscar brief, cliente, marca…":"Buscar proyecto, cliente, marca…",className:"pl-9 h-9 bg-muted/40 border-transparent focus-visible:bg-card focus-visible:border-border"})]}),d.jsx("div",{className:"flex-1 md:flex-none"}),d.jsxs(kI,{children:[d.jsx(OI,{asChild:!0,children:d.jsxs(Ee,{variant:"ghost",size:"sm",className:"gap-2 h-9 px-2.5",children:[d.jsxs(Cf,{className:"w-7 h-7",children:[(H==null?void 0:H.photoURL)&&d.jsx(jN,{src:H.photoURL,alt:rt,referrerPolicy:"no-referrer"}),d.jsx(jf,{className:q?"bg-primary text-primary-foreground text-xs":"bg-accent text-accent-foreground text-xs",children:Et})]}),d.jsxs("div",{className:"text-left leading-tight hidden sm:block",children:[d.jsx("div",{className:"text-xs font-medium",children:rt}),d.jsx("div",{className:"text-[10px] text-muted-foreground",children:He})]}),d.jsx(sv,{className:"w-3.5 h-3.5 text-muted-foreground"})]})}),d.jsxs(pN,{align:"end",className:"w-52",children:[d.jsxs("div",{className:"px-3 py-2",children:[d.jsx("p",{className:"text-xs font-medium truncate",children:rt}),d.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:H==null?void 0:H.email})]}),d.jsx(vN,{}),d.jsxs(gN,{onClick:ze,className:"gap-2 text-destructive focus:text-destructive focus:bg-destructive/10 cursor-pointer",children:[d.jsx(nP,{className:"w-3.5 h-3.5"}),"Cerrar sesión"]})]})]}),se&&d.jsxs(Ee,{type:"button",variant:"outline",onClick:()=>L(!0),className:"gap-1.5 h-9 rounded-full px-4 shadow-sm",children:[d.jsx(Fs,{className:"w-4 h-4"})," Horas del equipo"]}),Q&&d.jsxs(Ee,{type:"button",variant:"outline",onClick:()=>A(!0),className:"gap-1.5 h-9 rounded-full px-4 shadow-sm",children:[d.jsx(M1,{className:"w-4 h-4"})," Tarifario"]}),Q&&d.jsxs(Ee,{type:"button",variant:"outline",onClick:()=>M(!0),className:"gap-1.5 h-9 rounded-full px-4 shadow-sm",children:[d.jsx(Ld,{className:"w-4 h-4"})," Listas"]}),je&&d.jsxs(Ee,{onClick:Yn,className:"gap-1.5 h-9 rounded-full px-4 shadow-sm",children:[d.jsx(Ir,{className:"w-4 h-4"})," Nuevo"]})]})}),d.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 pt-6 pb-3 space-y-3",children:[d.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[d.jsxs("div",{children:[d.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:m==="nuevos"?"Briefs por revisar":m==="no_aprobados"?"Briefs rechazados":"Proyectos"}),m==="nuevos"&&d.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Los briefs de CDC Brief llegan aquí antes de convertirse en proyectos Activos."}),m==="no_aprobados"&&d.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Briefs revisados que no se incorporaron al tablero general."})]}),d.jsx("div",{className:"flex items-center gap-2",children:d.jsx("div",{className:"inline-flex flex-wrap bg-muted/60 rounded-full p-1 text-xs",children:[["todos","Todos"],["abiertos","Activos"],["cerrados","Cerrados"],["nuevos","Nuevos"],["no_aprobados","Rechazados"]].map(([we,ft])=>d.jsxs("button",{onClick:()=>b(we),className:`inline-flex items-center gap-1.5 px-3.5 py-1.5 rounded-full transition-colors font-medium ${m===we?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[d.jsx("span",{children:ft}),we==="nuevos"&&Ne.unreadCount>0&&d.jsx("span",{className:"inline-flex min-w-[18px] h-[18px] items-center justify-center rounded-full bg-red-500 px-1 text-[10px] font-bold leading-none text-white shadow-sm","aria-label":`${Ne.unreadCount} briefs nuevos sin revisar`,children:Ne.unreadCount>99?"99+":Ne.unreadCount})]},we))})})]}),d.jsxs("div",{className:"relative md:hidden",children:[d.jsx(Ws,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),d.jsx(ot,{value:f,onChange:we=>h(we.target.value),placeholder:re?"Buscar brief, cliente, marca…":"Buscar proyecto, cliente, marca…",className:"pl-9 h-9 bg-muted/40 border-transparent focus-visible:bg-card focus-visible:border-border"})]}),!re&&d.jsx(kH,{filters:g,activeCount:Xt,countryOptions:Le,brandOptions:ue,clientOptions:qe,cmOptions:gt,onFilterChange:Dt,onClear:fr}),We&&d.jsx(AH,{totalAmount:Ct.totalAmount,projectCount:Ct.projectCount,loading:pe||Je,error:$e||De,hasFilters:m!=="todos"||f.trim().length>0||Xt>0,canControlVisibility:te,isPublic:Me,visibilitySaving:ie,onToggleVisibility:()=>Xe(!Me).catch(()=>{})})]}),d.jsxs("main",{className:"max-w-[1400px] mx-auto px-6 pb-16",children:[(re?I.error:V)&&d.jsxs("div",{className:"mb-4 flex flex-col gap-3 rounded-2xl border border-destructive/30 bg-destructive/5 px-4 py-3 text-sm text-destructive sm:flex-row sm:items-center sm:justify-between",children:[d.jsxs("span",{className:"flex items-start gap-2",children:[d.jsx(Pd,{className:"mt-0.5 h-4 w-4 flex-shrink-0"}),d.jsxs("span",{children:[d.jsx("span",{className:"font-medium",children:re?"No se pudieron cargar los briefs.":"No se pudieron cargar los proyectos."})," ",re?I.error:V]})]}),d.jsxs(Ee,{variant:"outline",size:"sm",onClick:()=>void(re?I.refresh():R()),className:"gap-1.5",children:[d.jsx(go,{className:"h-3.5 w-3.5"})," Reintentar"]})]}),re?I.loading&&I.items.length===0?d.jsx(bS,{}):I.items.length===0?d.jsx(DH,{mode:me,query:f}):d.jsx("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2 xl:grid-cols-3",children:I.items.map(we=>d.jsx(D8,{item:we,mode:me,busy:J===we.id,onApprove:()=>void Be(we.id,we.title,me==="rejected"),onReject:()=>void et(we.id,we.title)},we.id))}):Y&&k.length===0?d.jsx(bS,{}):k.length===0?d.jsx(PH,{onNew:Yn,hasProjects:K>0||fe!=="todos"||f.trim().length>0||Xt>0,filter:fe,query:f,activeAdvancedFilterCount:Xt}):d.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:k.map(we=>d.jsx(e$,{project:we,onClick:()=>en(we),onTimeClick:()=>U(we),showInternalAmount:ee},we.id))}),jt>Is&&d.jsx(OH,{currentPage:on,totalPages:At,visibleStart:vn,visibleEnd:Mt,totalItems:jt,itemLabel:re?"briefs":"proyectos",onPageChange:Jt})]}),d.jsx(s8,{open:a,onOpenChange:i,project:l,onDelete:he,deleting:!!l&&S===l.id}),d.jsx(m8,{open:!!P,onOpenChange:we=>{we||U(null)},project:P}),se&&d.jsx(M8,{open:$,onOpenChange:L}),Q&&d.jsxs(d.Fragment,{children:[d.jsx(vH,{open:N,onOpenChange:A}),d.jsx(NH,{open:T,onOpenChange:M})]})]})}function RH(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e||0)}function AH({totalAmount:e,projectCount:t,loading:n,error:a,hasFilters:i,canControlVisibility:l,isPublic:c,visibilitySaving:f,onToggleVisibility:h}){return d.jsx("div",{className:"rounded-2xl border border-primary/15 bg-primary/5 px-4 py-3 shadow-sm",children:d.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[d.jsxs("div",{className:"flex items-start gap-3",children:[d.jsx("span",{className:"mt-0.5 flex h-9 w-9 items-center justify-center rounded-xl bg-primary/10 text-primary",children:d.jsx(hg,{className:"h-4 w-4"})}),d.jsxs("div",{children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:i?"Total tarifado filtrado":"Total tarifado global"}),d.jsx("span",{className:`rounded-full border px-2 py-0.5 text-[10px] font-medium ${c?"border-emerald-200 bg-emerald-50 text-emerald-700":"border-primary/20 bg-card text-primary"}`,children:c?"Visible para todos":"Privado"})]}),d.jsx("p",{className:"mt-0.5 text-2xl font-semibold tracking-tight text-foreground",children:n?"Calculando…":RH(e)}),d.jsx("p",{className:"text-xs text-muted-foreground",children:a?`No se pudo calcular el total: ${a}`:`${t} proyecto(s) incluidos según los filtros actuales.`})]})]}),d.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center lg:justify-end",children:[d.jsx("div",{className:"rounded-full border border-primary/20 bg-card px-3 py-1 text-xs font-medium text-primary",children:i?"Según filtros activos":"Sin filtros aplicados"}),l&&d.jsxs(Ee,{type:"button",variant:c?"secondary":"outline",size:"sm",className:"gap-1.5 rounded-full",disabled:f,onClick:h,title:c?"Ocultar este total para los demás usuarios":"Mostrar este total temporalmente a todos los usuarios",children:[c?d.jsx(R3,{className:"h-3.5 w-3.5"}):d.jsx(k3,{className:"h-3.5 w-3.5"}),f?"Actualizando…":c?"Ocultar a todos":"Mostrar a todos"]})]})]})})}function kH({filters:e,activeCount:t,countryOptions:n,brandOptions:a,clientOptions:i,cmOptions:l,onFilterChange:c,onClear:f}){return d.jsx("div",{className:"rounded-2xl border border-border bg-card/70 px-3.5 py-3 shadow-sm",children:d.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center",children:[d.jsxs("div",{className:"flex items-center justify-between gap-3 lg:w-auto lg:min-w-[120px] lg:justify-start",children:[d.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[d.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-primary/10 text-primary",children:d.jsx(pP,{className:"h-4 w-4"})}),d.jsx("span",{children:"Filtros"}),t>0&&d.jsx("span",{className:"rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-semibold text-primary",children:t})]}),t>0&&d.jsxs(Ee,{type:"button",variant:"ghost",size:"sm",onClick:f,className:"h-8 rounded-full px-2.5 text-xs text-muted-foreground hover:text-foreground lg:hidden",children:[d.jsx(vo,{className:"mr-1 h-3.5 w-3.5"}),"Limpiar"]})]}),d.jsxs("div",{className:"grid flex-1 grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-4",children:[d.jsx(_r,{value:e.country,options:n,onValueChange:h=>c("country",h),placeholder:"País: Todos",searchPlaceholder:"Buscar país…",emptyText:"No se encontró ese país.",clearLabel:"Todos"}),d.jsx(_r,{value:e.brand,options:a,onValueChange:h=>c("brand",h),placeholder:"Marca: Todas",searchPlaceholder:"Buscar marca…",emptyText:"No se encontró esa marca.",clearLabel:"Todas"}),d.jsx(_r,{value:e.client,options:i,onValueChange:h=>c("client",h),placeholder:"Cliente: Todos",searchPlaceholder:"Buscar cliente…",emptyText:"No se encontró ese cliente.",clearLabel:"Todos"}),d.jsx(_r,{value:e.cm,options:l,onValueChange:h=>c("cm",h),placeholder:"CM: Todos",searchPlaceholder:"Buscar CM…",emptyText:"No se encontró ese CM.",clearLabel:"Todos"})]}),d.jsxs(Ee,{type:"button",variant:"ghost",size:"sm",onClick:f,disabled:t===0,className:"hidden h-9 rounded-full px-3 text-xs text-muted-foreground hover:text-foreground lg:inline-flex",children:[d.jsx(vo,{className:"mr-1 h-3.5 w-3.5"}),"Limpiar"]})]})})}function OH({currentPage:e,totalPages:t,visibleStart:n,visibleEnd:a,totalItems:i,itemLabel:l="proyectos",onPageChange:c}){const f=MH(e,t);return d.jsxs("div",{className:"mt-6 flex flex-col sm:flex-row items-center justify-between gap-3 rounded-2xl border border-border bg-card/70 px-4 py-3",children:[d.jsxs("p",{className:"text-xs text-muted-foreground",children:[d.jsxs("span",{className:"font-medium text-foreground",children:[n,"-",a]})," ","de ",d.jsx("span",{className:"font-medium text-foreground",children:i})," ",l]}),d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsxs(Ee,{type:"button",variant:"ghost",size:"sm",className:"h-8 gap-1 rounded-full px-2.5",onClick:()=>c(e-1),disabled:e===1,children:[d.jsx(ff,{className:"h-4 w-4"}),d.jsx("span",{className:"hidden sm:inline",children:"Anterior"})]}),d.jsx("div",{className:"flex items-center gap-1",children:f.map((h,m)=>h==="ellipsis"?d.jsx("span",{className:"flex h-8 w-8 items-center justify-center text-xs text-muted-foreground",children:"…"},`ellipsis-${m}`):d.jsx(Ee,{type:"button",variant:h===e?"default":"ghost",size:"sm",className:"h-8 w-8 rounded-full p-0 text-xs",onClick:()=>c(h),"aria-current":h===e?"page":void 0,children:h},h))}),d.jsxs(Ee,{type:"button",variant:"ghost",size:"sm",className:"h-8 gap-1 rounded-full px-2.5",onClick:()=>c(e+1),disabled:e===t,children:[d.jsx("span",{className:"hidden sm:inline",children:"Siguiente"}),d.jsx(oc,{className:"h-4 w-4"})]})]})]})}function MH(e,t){if(t<=7)return Array.from({length:t},(i,l)=>l+1);const n=new Set([1,t,e]);return e>1&&n.add(e-1),e<t&&n.add(e+1),e<=3&&(n.add(2),n.add(3),n.add(4)),e>=t-2&&(n.add(t-3),n.add(t-2),n.add(t-1)),Array.from(n).filter(i=>i>=1&&i<=t).sort((i,l)=>i-l).reduce((i,l)=>{const c=i[i.length-1];return typeof c=="number"&&l-c>1&&i.push("ellipsis"),i.push(l),i},[])}function bS(){return d.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:Array.from({length:8}).map((e,t)=>d.jsxs("div",{className:"min-h-[230px] overflow-hidden rounded-2xl border border-border bg-card",children:[d.jsx("div",{className:"h-14 bg-muted animate-pulse"}),d.jsxs("div",{className:"space-y-3 p-4",children:[d.jsx("div",{className:"h-3 w-3/4 rounded-full bg-muted animate-pulse"}),d.jsx("div",{className:"h-3 w-2/3 rounded-full bg-muted animate-pulse"}),d.jsx("div",{className:"h-3 w-1/2 rounded-full bg-muted animate-pulse"}),d.jsx("div",{className:"mt-6 h-8 rounded-full bg-muted animate-pulse"})]})]},t))})}function DH({mode:e,query:t}){const n=t.trim().length>0,a=e==="rejected";return d.jsxs("div",{className:"rounded-2xl border border-dashed border-border bg-card/40 py-24 text-center",children:[d.jsx("div",{className:`mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-2xl ${a?"bg-red-50 text-red-600":"bg-amber-50 text-amber-700"}`,children:a?d.jsx(P3,{className:"h-6 w-6"}):d.jsx(U3,{className:"h-6 w-6"})}),d.jsx("h3",{className:"text-lg font-semibold",children:n?"No hay briefs que coincidan con la búsqueda":a?"No hay briefs rechazados":"No hay briefs pendientes"}),d.jsx("p",{className:"mx-auto mt-1 max-w-md text-sm text-muted-foreground",children:n?"Prueba con otro nombre, cliente, marca, país o solicitante.":a?"Los briefs que el equipo decida no convertir en proyecto aparecerán aquí.":"Cuando CDC Brief genere un nuevo brief, aparecerá aquí automáticamente para revisión."})]})}function PH({onNew:e,hasProjects:t,filter:n,query:a,activeAdvancedFilterCount:i}){const l=a.trim().length>0,c=i>0;let f="Tu tablero está vacío",h="Crea tu primer proyecto para que el equipo pueda darle seguimiento.";return t&&l&&c?(f="Nada coincide con la búsqueda y filtros",h="Intenta cambiar la búsqueda, limpiar filtros o seleccionar otras opciones."):t&&l?(f="Nada coincide con la búsqueda",h="Intenta cambiar la búsqueda o borrar el texto escrito."):t&&c?(f="Nada coincide con los filtros",h="Intenta limpiar filtros o seleccionar otras opciones."):t&&n==="abiertos"?(f="No hay proyectos activos",h="Cuando se cree un proyecto nuevo, aparecerá en esta pestaña."):t&&n==="cerrados"?(f="No hay proyectos cerrados",h="Cuando el Director Creativo asigne un estatus a un proyecto, aparecerá aquí."):t&&(f="Nada coincide con el filtro",h="Intenta quitar el filtro o cambiar la búsqueda."),d.jsxs("div",{className:"text-center py-24 rounded-2xl border border-dashed border-border bg-card/40",children:[d.jsx("div",{className:"w-14 h-14 rounded-2xl bg-primary/10 mx-auto flex items-center justify-center mb-4",children:d.jsx(G3,{className:"w-6 h-6 text-primary"})}),d.jsx("h3",{className:"text-lg font-semibold",children:f}),d.jsx("p",{className:"text-sm text-muted-foreground mt-1 max-w-sm mx-auto",children:h}),!t&&d.jsxs(Ee,{onClick:e,className:"mt-5 gap-1.5 rounded-full",children:[d.jsx(Ir,{className:"w-4 h-4"})," Crear proyecto"]})]})}const LH=({...e})=>d.jsx(Y6,{className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e});class zH extends v.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,n){console.error("Uncaught error:",t,n)}render(){return this.state.hasError?d.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-4",children:d.jsxs("div",{className:"max-w-md text-center",children:[d.jsx("h1",{className:"text-xl font-semibold tracking-tight text-foreground",children:"Ocurrió un error al cargar el tablero."}),d.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Intenta recargar la página."}),d.jsx("div",{className:"mt-6",children:d.jsx("button",{onClick:()=>window.location.reload(),className:"inline-flex items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90",children:"Recargar"})})]})}):this.props.children}}function IH(){const{user:e,loading:t}=df();return t&&!e?d.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:d.jsxs("div",{className:"flex flex-col items-center gap-3",children:[d.jsx("div",{className:"animate-pulse",children:d.jsx(av,{showWordmark:!1})}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Cargando tablero…"})]})}):e?d.jsx(o2,{children:d.jsx(IS,{path:"/*",element:d.jsx(TH,{})})}):d.jsx(Y5,{})}function $H(){return d.jsx(zH,{children:d.jsx(WD,{children:d.jsxs(k2,{basename:"/tablero-cdc/",children:[d.jsx(IH,{}),d.jsx(LH,{richColors:!0,position:"top-right"})]})})})}lk.createRoot(document.getElementById("root")).render(d.jsx(v.StrictMode,{children:d.jsx($H,{})}));