@realtimex/folio 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
function YN(t,e){for(var s=0;s<e.length;s++){const r=e[s];if(typeof r!="string"&&!Array.isArray(r)){for(const l in r)if(l!=="default"&&!(l in t)){const u=Object.getOwnPropertyDescriptor(r,l);u&&Object.defineProperty(t,l,u.get?u:{enumerable:!0,get:()=>r[l]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&r(d)}).observe(document,{childList:!0,subtree:!0});function s(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function r(l){if(l.ep)return;l.ep=!0;const u=s(l);fetch(l.href,u)}})();function Zb(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Jh={exports:{}},po={};var Nx;function XN(){if(Nx)return po;Nx=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function s(r,l,u){var d=null;if(u!==void 0&&(d=""+u),l.key!==void 0&&(d=""+l.key),"key"in l){u={};for(var h in l)h!=="key"&&(u[h]=l[h])}else u=l;return l=u.ref,{$$typeof:t,type:r,key:d,ref:l!==void 0?l:null,props:u}}return po.Fragment=e,po.jsx=s,po.jsxs=s,po}var Tx;function WN(){return Tx||(Tx=1,Jh.exports=XN()),Jh.exports}var o=WN(),Qh={exports:{}},Oe={};var Ex;function JN(){if(Ex)return Oe;Ex=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),d=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),x=Symbol.for("react.activity"),w=Symbol.iterator;function S(M){return M===null||typeof M!="object"?null:(M=w&&M[w]||M["@@iterator"],typeof M=="function"?M:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},j=Object.assign,_={};function N(M,L,W){this.props=M,this.context=L,this.refs=_,this.updater=W||E}N.prototype.isReactComponent={},N.prototype.setState=function(M,L){if(typeof M!="object"&&typeof M!="function"&&M!=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,M,L,"setState")},N.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function k(){}k.prototype=N.prototype;function C(M,L,W){this.props=M,this.context=L,this.refs=_,this.updater=W||E}var A=C.prototype=new k;A.constructor=C,j(A,N.prototype),A.isPureReactComponent=!0;var D=Array.isArray;function U(){}var V={H:null,A:null,T:null,S:null},R=Object.prototype.hasOwnProperty;function P(M,L,W){var ne=W.ref;return{$$typeof:t,type:M,key:L,ref:ne!==void 0?ne:null,props:W}}function Z(M,L){return P(M.type,L,M.props)}function te(M){return typeof M=="object"&&M!==null&&M.$$typeof===t}function me(M){var L={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(W){return L[W]})}var Ee=/\/+/g;function ye(M,L){return typeof M=="object"&&M!==null&&M.key!=null?me(""+M.key):L.toString(36)}function _e(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(U,U):(M.status="pending",M.then(function(L){M.status==="pending"&&(M.status="fulfilled",M.value=L)},function(L){M.status==="pending"&&(M.status="rejected",M.reason=L)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function $(M,L,W,ne,oe){var ue=typeof M;(ue==="undefined"||ue==="boolean")&&(M=null);var q=!1;if(M===null)q=!0;else switch(ue){case"bigint":case"string":case"number":q=!0;break;case"object":switch(M.$$typeof){case t:case e:q=!0;break;case y:return q=M._init,$(q(M._payload),L,W,ne,oe)}}if(q)return oe=oe(M),q=ne===""?"."+ye(M,0):ne,D(oe)?(W="",q!=null&&(W=q.replace(Ee,"$&/")+"/"),$(oe,L,W,"",function(ze){return ze})):oe!=null&&(te(oe)&&(oe=Z(oe,W+(oe.key==null||M&&M.key===oe.key?"":(""+oe.key).replace(Ee,"$&/")+"/")+q)),L.push(oe)),1;q=0;var fe=ne===""?".":ne+":";if(D(M))for(var ie=0;ie<M.length;ie++)ne=M[ie],ue=fe+ye(ne,ie),q+=$(ne,L,W,ue,oe);else if(ie=S(M),typeof ie=="function")for(M=ie.call(M),ie=0;!(ne=M.next()).done;)ne=ne.value,ue=fe+ye(ne,ie++),q+=$(ne,L,W,ue,oe);else if(ue==="object"){if(typeof M.then=="function")return $(_e(M),L,W,ne,oe);throw L=String(M),Error("Objects are not valid as a React child (found: "+(L==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":L)+"). If you meant to render a collection of children, use an array instead.")}return q}function Y(M,L,W){if(M==null)return M;var ne=[],oe=0;return $(M,ne,"","",function(ue){return L.call(W,ue,oe++)}),ne}function J(M){if(M._status===-1){var L=M._result;L=L(),L.then(function(W){(M._status===0||M._status===-1)&&(M._status=1,M._result=W)},function(W){(M._status===0||M._status===-1)&&(M._status=2,M._result=W)}),M._status===-1&&(M._status=0,M._result=L)}if(M._status===1)return M._result.default;throw M._result}var pe=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var L=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(L))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},se={map:Y,forEach:function(M,L,W){Y(M,function(){L.apply(this,arguments)},W)},count:function(M){var L=0;return Y(M,function(){L++}),L},toArray:function(M){return Y(M,function(L){return L})||[]},only:function(M){if(!te(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return Oe.Activity=x,Oe.Children=se,Oe.Component=N,Oe.Fragment=s,Oe.Profiler=l,Oe.PureComponent=C,Oe.StrictMode=r,Oe.Suspense=m,Oe.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=V,Oe.__COMPILER_RUNTIME={__proto__:null,c:function(M){return V.H.useMemoCache(M)}},Oe.cache=function(M){return function(){return M.apply(null,arguments)}},Oe.cacheSignal=function(){return null},Oe.cloneElement=function(M,L,W){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var ne=j({},M.props),oe=M.key;if(L!=null)for(ue in L.key!==void 0&&(oe=""+L.key),L)!R.call(L,ue)||ue==="key"||ue==="__self"||ue==="__source"||ue==="ref"&&L.ref===void 0||(ne[ue]=L[ue]);var ue=arguments.length-2;if(ue===1)ne.children=W;else if(1<ue){for(var q=Array(ue),fe=0;fe<ue;fe++)q[fe]=arguments[fe+2];ne.children=q}return P(M.type,oe,ne)},Oe.createContext=function(M){return M={$$typeof:d,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:u,_context:M},M},Oe.createElement=function(M,L,W){var ne,oe={},ue=null;if(L!=null)for(ne in L.key!==void 0&&(ue=""+L.key),L)R.call(L,ne)&&ne!=="key"&&ne!=="__self"&&ne!=="__source"&&(oe[ne]=L[ne]);var q=arguments.length-2;if(q===1)oe.children=W;else if(1<q){for(var fe=Array(q),ie=0;ie<q;ie++)fe[ie]=arguments[ie+2];oe.children=fe}if(M&&M.defaultProps)for(ne in q=M.defaultProps,q)oe[ne]===void 0&&(oe[ne]=q[ne]);return P(M,ue,oe)},Oe.createRef=function(){return{current:null}},Oe.forwardRef=function(M){return{$$typeof:h,render:M}},Oe.isValidElement=te,Oe.lazy=function(M){return{$$typeof:y,_payload:{_status:-1,_result:M},_init:J}},Oe.memo=function(M,L){return{$$typeof:g,type:M,compare:L===void 0?null:L}},Oe.startTransition=function(M){var L=V.T,W={};V.T=W;try{var ne=M(),oe=V.S;oe!==null&&oe(W,ne),typeof ne=="object"&&ne!==null&&typeof ne.then=="function"&&ne.then(U,pe)}catch(ue){pe(ue)}finally{L!==null&&W.types!==null&&(L.types=W.types),V.T=L}},Oe.unstable_useCacheRefresh=function(){return V.H.useCacheRefresh()},Oe.use=function(M){return V.H.use(M)},Oe.useActionState=function(M,L,W){return V.H.useActionState(M,L,W)},Oe.useCallback=function(M,L){return V.H.useCallback(M,L)},Oe.useContext=function(M){return V.H.useContext(M)},Oe.useDebugValue=function(){},Oe.useDeferredValue=function(M,L){return V.H.useDeferredValue(M,L)},Oe.useEffect=function(M,L){return V.H.useEffect(M,L)},Oe.useEffectEvent=function(M){return V.H.useEffectEvent(M)},Oe.useId=function(){return V.H.useId()},Oe.useImperativeHandle=function(M,L,W){return V.H.useImperativeHandle(M,L,W)},Oe.useInsertionEffect=function(M,L){return V.H.useInsertionEffect(M,L)},Oe.useLayoutEffect=function(M,L){return V.H.useLayoutEffect(M,L)},Oe.useMemo=function(M,L){return V.H.useMemo(M,L)},Oe.useOptimistic=function(M,L){return V.H.useOptimistic(M,L)},Oe.useReducer=function(M,L,W){return V.H.useReducer(M,L,W)},Oe.useRef=function(M){return V.H.useRef(M)},Oe.useState=function(M){return V.H.useState(M)},Oe.useSyncExternalStore=function(M,L,W){return V.H.useSyncExternalStore(M,L,W)},Oe.useTransition=function(){return V.H.useTransition()},Oe.version="19.2.4",Oe}var kx;function Om(){return kx||(kx=1,Qh.exports=JN()),Qh.exports}var v=Om();const ew=Zb(v),Mm=YN({__proto__:null,default:ew},[v]);var Zh={exports:{}},go={},ef={exports:{}},tf={};var Cx;function QN(){return Cx||(Cx=1,(function(t){function e($,Y){var J=$.length;$.push(Y);e:for(;0<J;){var pe=J-1>>>1,se=$[pe];if(0<l(se,Y))$[pe]=Y,$[J]=se,J=pe;else break e}}function s($){return $.length===0?null:$[0]}function r($){if($.length===0)return null;var Y=$[0],J=$.pop();if(J!==Y){$[0]=J;e:for(var pe=0,se=$.length,M=se>>>1;pe<M;){var L=2*(pe+1)-1,W=$[L],ne=L+1,oe=$[ne];if(0>l(W,J))ne<se&&0>l(oe,W)?($[pe]=oe,$[ne]=J,pe=ne):($[pe]=W,$[L]=J,pe=L);else if(ne<se&&0>l(oe,J))$[pe]=oe,$[ne]=J,pe=ne;else break e}}return Y}function l($,Y){var J=$.sortIndex-Y.sortIndex;return J!==0?J:$.id-Y.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var d=Date,h=d.now();t.unstable_now=function(){return d.now()-h}}var m=[],g=[],y=1,x=null,w=3,S=!1,E=!1,j=!1,_=!1,N=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;function A($){for(var Y=s(g);Y!==null;){if(Y.callback===null)r(g);else if(Y.startTime<=$)r(g),Y.sortIndex=Y.expirationTime,e(m,Y);else break;Y=s(g)}}function D($){if(j=!1,A($),!E)if(s(m)!==null)E=!0,U||(U=!0,me());else{var Y=s(g);Y!==null&&_e(D,Y.startTime-$)}}var U=!1,V=-1,R=5,P=-1;function Z(){return _?!0:!(t.unstable_now()-P<R)}function te(){if(_=!1,U){var $=t.unstable_now();P=$;var Y=!0;try{e:{E=!1,j&&(j=!1,k(V),V=-1),S=!0;var J=w;try{t:{for(A($),x=s(m);x!==null&&!(x.expirationTime>$&&Z());){var pe=x.callback;if(typeof pe=="function"){x.callback=null,w=x.priorityLevel;var se=pe(x.expirationTime<=$);if($=t.unstable_now(),typeof se=="function"){x.callback=se,A($),Y=!0;break t}x===s(m)&&r(m),A($)}else r(m);x=s(m)}if(x!==null)Y=!0;else{var M=s(g);M!==null&&_e(D,M.startTime-$),Y=!1}}break e}finally{x=null,w=J,S=!1}Y=void 0}}finally{Y?me():U=!1}}}var me;if(typeof C=="function")me=function(){C(te)};else if(typeof MessageChannel<"u"){var Ee=new MessageChannel,ye=Ee.port2;Ee.port1.onmessage=te,me=function(){ye.postMessage(null)}}else me=function(){N(te,0)};function _e($,Y){V=N(function(){$(t.unstable_now())},Y)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function($){$.callback=null},t.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<$?Math.floor(1e3/$):5},t.unstable_getCurrentPriorityLevel=function(){return w},t.unstable_next=function($){switch(w){case 1:case 2:case 3:var Y=3;break;default:Y=w}var J=w;w=Y;try{return $()}finally{w=J}},t.unstable_requestPaint=function(){_=!0},t.unstable_runWithPriority=function($,Y){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var J=w;w=$;try{return Y()}finally{w=J}},t.unstable_scheduleCallback=function($,Y,J){var pe=t.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?pe+J:pe):J=pe,$){case 1:var se=-1;break;case 2:se=250;break;case 5:se=1073741823;break;case 4:se=1e4;break;default:se=5e3}return se=J+se,$={id:y++,callback:Y,priorityLevel:$,startTime:J,expirationTime:se,sortIndex:-1},J>pe?($.sortIndex=J,e(g,$),s(m)===null&&$===s(g)&&(j?(k(V),V=-1):j=!0,_e(D,J-pe))):($.sortIndex=se,e(m,$),E||S||(E=!0,U||(U=!0,me()))),$},t.unstable_shouldYield=Z,t.unstable_wrapCallback=function($){var Y=w;return function(){var J=w;w=Y;try{return $.apply(this,arguments)}finally{w=J}}}})(tf)),tf}var Ax;function ZN(){return Ax||(Ax=1,ef.exports=QN()),ef.exports}var nf={exports:{}},Yt={};var Rx;function e2(){if(Rx)return Yt;Rx=1;var t=Om();function e(m){var g="https://react.dev/errors/"+m;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)g+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+m+"; visit "+g+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(){}var r={d:{f:s,r:function(){throw Error(e(522))},D:s,C:s,L:s,m:s,X:s,S:s,M:s},p:0,findDOMNode:null},l=Symbol.for("react.portal");function u(m,g,y){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:l,key:x==null?null:""+x,children:m,containerInfo:g,implementation:y}}var d=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(m,g){if(m==="font")return"";if(typeof g=="string")return g==="use-credentials"?g:""}return Yt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Yt.createPortal=function(m,g){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!g||g.nodeType!==1&&g.nodeType!==9&&g.nodeType!==11)throw Error(e(299));return u(m,g,null,y)},Yt.flushSync=function(m){var g=d.T,y=r.p;try{if(d.T=null,r.p=2,m)return m()}finally{d.T=g,r.p=y,r.d.f()}},Yt.preconnect=function(m,g){typeof m=="string"&&(g?(g=g.crossOrigin,g=typeof g=="string"?g==="use-credentials"?g:"":void 0):g=null,r.d.C(m,g))},Yt.prefetchDNS=function(m){typeof m=="string"&&r.d.D(m)},Yt.preinit=function(m,g){if(typeof m=="string"&&g&&typeof g.as=="string"){var y=g.as,x=h(y,g.crossOrigin),w=typeof g.integrity=="string"?g.integrity:void 0,S=typeof g.fetchPriority=="string"?g.fetchPriority:void 0;y==="style"?r.d.S(m,typeof g.precedence=="string"?g.precedence:void 0,{crossOrigin:x,integrity:w,fetchPriority:S}):y==="script"&&r.d.X(m,{crossOrigin:x,integrity:w,fetchPriority:S,nonce:typeof g.nonce=="string"?g.nonce:void 0})}},Yt.preinitModule=function(m,g){if(typeof m=="string")if(typeof g=="object"&&g!==null){if(g.as==null||g.as==="script"){var y=h(g.as,g.crossOrigin);r.d.M(m,{crossOrigin:y,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0})}}else g==null&&r.d.M(m)},Yt.preload=function(m,g){if(typeof m=="string"&&typeof g=="object"&&g!==null&&typeof g.as=="string"){var y=g.as,x=h(y,g.crossOrigin);r.d.L(m,y,{crossOrigin:x,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0,type:typeof g.type=="string"?g.type:void 0,fetchPriority:typeof g.fetchPriority=="string"?g.fetchPriority:void 0,referrerPolicy:typeof g.referrerPolicy=="string"?g.referrerPolicy:void 0,imageSrcSet:typeof g.imageSrcSet=="string"?g.imageSrcSet:void 0,imageSizes:typeof g.imageSizes=="string"?g.imageSizes:void 0,media:typeof g.media=="string"?g.media:void 0})}},Yt.preloadModule=function(m,g){if(typeof m=="string")if(g){var y=h(g.as,g.crossOrigin);r.d.m(m,{as:typeof g.as=="string"&&g.as!=="script"?g.as:void 0,crossOrigin:y,integrity:typeof g.integrity=="string"?g.integrity:void 0})}else r.d.m(m)},Yt.requestFormReset=function(m){r.d.r(m)},Yt.unstable_batchedUpdates=function(m,g){return m(g)},Yt.useFormState=function(m,g,y){return d.H.useFormState(m,g,y)},Yt.useFormStatus=function(){return d.H.useHostTransitionStatus()},Yt.version="19.2.4",Yt}var Ox;function tw(){if(Ox)return nf.exports;Ox=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),nf.exports=e2(),nf.exports}var Mx;function t2(){if(Mx)return go;Mx=1;var t=ZN(),e=Om(),s=tw();function r(n){var a="https://react.dev/errors/"+n;if(1<arguments.length){a+="?args[]="+encodeURIComponent(arguments[1]);for(var i=2;i<arguments.length;i++)a+="&args[]="+encodeURIComponent(arguments[i])}return"Minified React error #"+n+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function l(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function u(n){var a=n,i=n;if(n.alternate)for(;a.return;)a=a.return;else{n=a;do a=n,(a.flags&4098)!==0&&(i=a.return),n=a.return;while(n)}return a.tag===3?i:null}function d(n){if(n.tag===13){var a=n.memoizedState;if(a===null&&(n=n.alternate,n!==null&&(a=n.memoizedState)),a!==null)return a.dehydrated}return null}function h(n){if(n.tag===31){var a=n.memoizedState;if(a===null&&(n=n.alternate,n!==null&&(a=n.memoizedState)),a!==null)return a.dehydrated}return null}function m(n){if(u(n)!==n)throw Error(r(188))}function g(n){var a=n.alternate;if(!a){if(a=u(n),a===null)throw Error(r(188));return a!==n?null:n}for(var i=n,c=a;;){var f=i.return;if(f===null)break;var p=f.alternate;if(p===null){if(c=f.return,c!==null){i=c;continue}break}if(f.child===p.child){for(p=f.child;p;){if(p===i)return m(f),n;if(p===c)return m(f),a;p=p.sibling}throw Error(r(188))}if(i.return!==c.return)i=f,c=p;else{for(var b=!1,T=f.child;T;){if(T===i){b=!0,i=f,c=p;break}if(T===c){b=!0,c=f,i=p;break}T=T.sibling}if(!b){for(T=p.child;T;){if(T===i){b=!0,i=p,c=f;break}if(T===c){b=!0,c=p,i=f;break}T=T.sibling}if(!b)throw Error(r(189))}}if(i.alternate!==c)throw Error(r(190))}if(i.tag!==3)throw Error(r(188));return i.stateNode.current===i?n:a}function y(n){var a=n.tag;if(a===5||a===26||a===27||a===6)return n;for(n=n.child;n!==null;){if(a=y(n),a!==null)return a;n=n.sibling}return null}var x=Object.assign,w=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),j=Symbol.for("react.fragment"),_=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),k=Symbol.for("react.consumer"),C=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),U=Symbol.for("react.suspense_list"),V=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),P=Symbol.for("react.activity"),Z=Symbol.for("react.memo_cache_sentinel"),te=Symbol.iterator;function me(n){return n===null||typeof n!="object"?null:(n=te&&n[te]||n["@@iterator"],typeof n=="function"?n:null)}var Ee=Symbol.for("react.client.reference");function ye(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===Ee?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case j:return"Fragment";case N:return"Profiler";case _:return"StrictMode";case D:return"Suspense";case U:return"SuspenseList";case P:return"Activity"}if(typeof n=="object")switch(n.$$typeof){case E:return"Portal";case C:return n.displayName||"Context";case k:return(n._context.displayName||"Context")+".Consumer";case A:var a=n.render;return n=n.displayName,n||(n=a.displayName||a.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case V:return a=n.displayName||null,a!==null?a:ye(n.type)||"Memo";case R:a=n._payload,n=n._init;try{return ye(n(a))}catch{}}return null}var _e=Array.isArray,$=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J={pending:!1,data:null,method:null,action:null},pe=[],se=-1;function M(n){return{current:n}}function L(n){0>se||(n.current=pe[se],pe[se]=null,se--)}function W(n,a){se++,pe[se]=n.current,n.current=a}var ne=M(null),oe=M(null),ue=M(null),q=M(null);function fe(n,a){switch(W(ue,a),W(oe,n),W(ne,null),a.nodeType){case 9:case 11:n=(n=a.documentElement)&&(n=n.namespaceURI)?Yv(n):0;break;default:if(n=a.tagName,a=a.namespaceURI)a=Yv(a),n=Xv(a,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}L(ne),W(ne,n)}function ie(){L(ne),L(oe),L(ue)}function ze(n){n.memoizedState!==null&&W(q,n);var a=ne.current,i=Xv(a,n.type);a!==i&&(W(oe,n),W(ne,i))}function Be(n){oe.current===n&&(L(ne),L(oe)),q.current===n&&(L(q),uo._currentValue=J)}var kt,et;function le(n){if(kt===void 0)try{throw Error()}catch(i){var a=i.stack.trim().match(/\n( *(at )?)/);kt=a&&a[1]||"",et=-1<i.stack.indexOf(`
|
|
2
|
-
at`)?" (<anonymous>)":-1<
|
|
3
|
-
`+kt+n+et}var Fe=!1;function de(n,a){if(!n||Fe)return"";Fe=!0;var
|
|
1
|
+
function YN(t,e){for(var s=0;s<e.length;s++){const i=e[s];if(typeof i!="string"&&!Array.isArray(i)){for(const l in i)if(l!=="default"&&!(l in t)){const u=Object.getOwnPropertyDescriptor(i,l);u&&Object.defineProperty(t,l,u.get?u:{enumerable:!0,get:()=>i[l]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))i(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&i(d)}).observe(document,{childList:!0,subtree:!0});function s(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function i(l){if(l.ep)return;l.ep=!0;const u=s(l);fetch(l.href,u)}})();function Zb(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Jh={exports:{}},po={};var Nx;function XN(){if(Nx)return po;Nx=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function s(i,l,u){var d=null;if(u!==void 0&&(d=""+u),l.key!==void 0&&(d=""+l.key),"key"in l){u={};for(var h in l)h!=="key"&&(u[h]=l[h])}else u=l;return l=u.ref,{$$typeof:t,type:i,key:d,ref:l!==void 0?l:null,props:u}}return po.Fragment=e,po.jsx=s,po.jsxs=s,po}var Tx;function WN(){return Tx||(Tx=1,Jh.exports=XN()),Jh.exports}var o=WN(),Qh={exports:{}},Oe={};var Ex;function JN(){if(Ex)return Oe;Ex=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),d=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),x=Symbol.for("react.activity"),w=Symbol.iterator;function S(M){return M===null||typeof M!="object"?null:(M=w&&M[w]||M["@@iterator"],typeof M=="function"?M:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},j=Object.assign,_={};function N(M,U,W){this.props=M,this.context=U,this.refs=_,this.updater=W||E}N.prototype.isReactComponent={},N.prototype.setState=function(M,U){if(typeof M!="object"&&typeof M!="function"&&M!=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,M,U,"setState")},N.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function k(){}k.prototype=N.prototype;function C(M,U,W){this.props=M,this.context=U,this.refs=_,this.updater=W||E}var A=C.prototype=new k;A.constructor=C,j(A,N.prototype),A.isPureReactComponent=!0;var D=Array.isArray;function z(){}var V={H:null,A:null,T:null,S:null},R=Object.prototype.hasOwnProperty;function P(M,U,W){var ne=W.ref;return{$$typeof:t,type:M,key:U,ref:ne!==void 0?ne:null,props:W}}function Z(M,U){return P(M.type,U,M.props)}function te(M){return typeof M=="object"&&M!==null&&M.$$typeof===t}function me(M){var U={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(W){return U[W]})}var Ee=/\/+/g;function ye(M,U){return typeof M=="object"&&M!==null&&M.key!=null?me(""+M.key):U.toString(36)}function _e(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(z,z):(M.status="pending",M.then(function(U){M.status==="pending"&&(M.status="fulfilled",M.value=U)},function(U){M.status==="pending"&&(M.status="rejected",M.reason=U)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function $(M,U,W,ne,oe){var ue=typeof M;(ue==="undefined"||ue==="boolean")&&(M=null);var q=!1;if(M===null)q=!0;else switch(ue){case"bigint":case"string":case"number":q=!0;break;case"object":switch(M.$$typeof){case t:case e:q=!0;break;case y:return q=M._init,$(q(M._payload),U,W,ne,oe)}}if(q)return oe=oe(M),q=ne===""?"."+ye(M,0):ne,D(oe)?(W="",q!=null&&(W=q.replace(Ee,"$&/")+"/"),$(oe,U,W,"",function(ze){return ze})):oe!=null&&(te(oe)&&(oe=Z(oe,W+(oe.key==null||M&&M.key===oe.key?"":(""+oe.key).replace(Ee,"$&/")+"/")+q)),U.push(oe)),1;q=0;var fe=ne===""?".":ne+":";if(D(M))for(var re=0;re<M.length;re++)ne=M[re],ue=fe+ye(ne,re),q+=$(ne,U,W,ue,oe);else if(re=S(M),typeof re=="function")for(M=re.call(M),re=0;!(ne=M.next()).done;)ne=ne.value,ue=fe+ye(ne,re++),q+=$(ne,U,W,ue,oe);else if(ue==="object"){if(typeof M.then=="function")return $(_e(M),U,W,ne,oe);throw U=String(M),Error("Objects are not valid as a React child (found: "+(U==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":U)+"). If you meant to render a collection of children, use an array instead.")}return q}function Y(M,U,W){if(M==null)return M;var ne=[],oe=0;return $(M,ne,"","",function(ue){return U.call(W,ue,oe++)}),ne}function J(M){if(M._status===-1){var U=M._result;U=U(),U.then(function(W){(M._status===0||M._status===-1)&&(M._status=1,M._result=W)},function(W){(M._status===0||M._status===-1)&&(M._status=2,M._result=W)}),M._status===-1&&(M._status=0,M._result=U)}if(M._status===1)return M._result.default;throw M._result}var pe=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var U=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(U))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},se={map:Y,forEach:function(M,U,W){Y(M,function(){U.apply(this,arguments)},W)},count:function(M){var U=0;return Y(M,function(){U++}),U},toArray:function(M){return Y(M,function(U){return U})||[]},only:function(M){if(!te(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return Oe.Activity=x,Oe.Children=se,Oe.Component=N,Oe.Fragment=s,Oe.Profiler=l,Oe.PureComponent=C,Oe.StrictMode=i,Oe.Suspense=m,Oe.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=V,Oe.__COMPILER_RUNTIME={__proto__:null,c:function(M){return V.H.useMemoCache(M)}},Oe.cache=function(M){return function(){return M.apply(null,arguments)}},Oe.cacheSignal=function(){return null},Oe.cloneElement=function(M,U,W){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var ne=j({},M.props),oe=M.key;if(U!=null)for(ue in U.key!==void 0&&(oe=""+U.key),U)!R.call(U,ue)||ue==="key"||ue==="__self"||ue==="__source"||ue==="ref"&&U.ref===void 0||(ne[ue]=U[ue]);var ue=arguments.length-2;if(ue===1)ne.children=W;else if(1<ue){for(var q=Array(ue),fe=0;fe<ue;fe++)q[fe]=arguments[fe+2];ne.children=q}return P(M.type,oe,ne)},Oe.createContext=function(M){return M={$$typeof:d,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:u,_context:M},M},Oe.createElement=function(M,U,W){var ne,oe={},ue=null;if(U!=null)for(ne in U.key!==void 0&&(ue=""+U.key),U)R.call(U,ne)&&ne!=="key"&&ne!=="__self"&&ne!=="__source"&&(oe[ne]=U[ne]);var q=arguments.length-2;if(q===1)oe.children=W;else if(1<q){for(var fe=Array(q),re=0;re<q;re++)fe[re]=arguments[re+2];oe.children=fe}if(M&&M.defaultProps)for(ne in q=M.defaultProps,q)oe[ne]===void 0&&(oe[ne]=q[ne]);return P(M,ue,oe)},Oe.createRef=function(){return{current:null}},Oe.forwardRef=function(M){return{$$typeof:h,render:M}},Oe.isValidElement=te,Oe.lazy=function(M){return{$$typeof:y,_payload:{_status:-1,_result:M},_init:J}},Oe.memo=function(M,U){return{$$typeof:g,type:M,compare:U===void 0?null:U}},Oe.startTransition=function(M){var U=V.T,W={};V.T=W;try{var ne=M(),oe=V.S;oe!==null&&oe(W,ne),typeof ne=="object"&&ne!==null&&typeof ne.then=="function"&&ne.then(z,pe)}catch(ue){pe(ue)}finally{U!==null&&W.types!==null&&(U.types=W.types),V.T=U}},Oe.unstable_useCacheRefresh=function(){return V.H.useCacheRefresh()},Oe.use=function(M){return V.H.use(M)},Oe.useActionState=function(M,U,W){return V.H.useActionState(M,U,W)},Oe.useCallback=function(M,U){return V.H.useCallback(M,U)},Oe.useContext=function(M){return V.H.useContext(M)},Oe.useDebugValue=function(){},Oe.useDeferredValue=function(M,U){return V.H.useDeferredValue(M,U)},Oe.useEffect=function(M,U){return V.H.useEffect(M,U)},Oe.useEffectEvent=function(M){return V.H.useEffectEvent(M)},Oe.useId=function(){return V.H.useId()},Oe.useImperativeHandle=function(M,U,W){return V.H.useImperativeHandle(M,U,W)},Oe.useInsertionEffect=function(M,U){return V.H.useInsertionEffect(M,U)},Oe.useLayoutEffect=function(M,U){return V.H.useLayoutEffect(M,U)},Oe.useMemo=function(M,U){return V.H.useMemo(M,U)},Oe.useOptimistic=function(M,U){return V.H.useOptimistic(M,U)},Oe.useReducer=function(M,U,W){return V.H.useReducer(M,U,W)},Oe.useRef=function(M){return V.H.useRef(M)},Oe.useState=function(M){return V.H.useState(M)},Oe.useSyncExternalStore=function(M,U,W){return V.H.useSyncExternalStore(M,U,W)},Oe.useTransition=function(){return V.H.useTransition()},Oe.version="19.2.4",Oe}var kx;function Om(){return kx||(kx=1,Qh.exports=JN()),Qh.exports}var v=Om();const ew=Zb(v),Mm=YN({__proto__:null,default:ew},[v]);var Zh={exports:{}},go={},ef={exports:{}},tf={};var Cx;function QN(){return Cx||(Cx=1,(function(t){function e($,Y){var J=$.length;$.push(Y);e:for(;0<J;){var pe=J-1>>>1,se=$[pe];if(0<l(se,Y))$[pe]=Y,$[J]=se,J=pe;else break e}}function s($){return $.length===0?null:$[0]}function i($){if($.length===0)return null;var Y=$[0],J=$.pop();if(J!==Y){$[0]=J;e:for(var pe=0,se=$.length,M=se>>>1;pe<M;){var U=2*(pe+1)-1,W=$[U],ne=U+1,oe=$[ne];if(0>l(W,J))ne<se&&0>l(oe,W)?($[pe]=oe,$[ne]=J,pe=ne):($[pe]=W,$[U]=J,pe=U);else if(ne<se&&0>l(oe,J))$[pe]=oe,$[ne]=J,pe=ne;else break e}}return Y}function l($,Y){var J=$.sortIndex-Y.sortIndex;return J!==0?J:$.id-Y.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var d=Date,h=d.now();t.unstable_now=function(){return d.now()-h}}var m=[],g=[],y=1,x=null,w=3,S=!1,E=!1,j=!1,_=!1,N=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;function A($){for(var Y=s(g);Y!==null;){if(Y.callback===null)i(g);else if(Y.startTime<=$)i(g),Y.sortIndex=Y.expirationTime,e(m,Y);else break;Y=s(g)}}function D($){if(j=!1,A($),!E)if(s(m)!==null)E=!0,z||(z=!0,me());else{var Y=s(g);Y!==null&&_e(D,Y.startTime-$)}}var z=!1,V=-1,R=5,P=-1;function Z(){return _?!0:!(t.unstable_now()-P<R)}function te(){if(_=!1,z){var $=t.unstable_now();P=$;var Y=!0;try{e:{E=!1,j&&(j=!1,k(V),V=-1),S=!0;var J=w;try{t:{for(A($),x=s(m);x!==null&&!(x.expirationTime>$&&Z());){var pe=x.callback;if(typeof pe=="function"){x.callback=null,w=x.priorityLevel;var se=pe(x.expirationTime<=$);if($=t.unstable_now(),typeof se=="function"){x.callback=se,A($),Y=!0;break t}x===s(m)&&i(m),A($)}else i(m);x=s(m)}if(x!==null)Y=!0;else{var M=s(g);M!==null&&_e(D,M.startTime-$),Y=!1}}break e}finally{x=null,w=J,S=!1}Y=void 0}}finally{Y?me():z=!1}}}var me;if(typeof C=="function")me=function(){C(te)};else if(typeof MessageChannel<"u"){var Ee=new MessageChannel,ye=Ee.port2;Ee.port1.onmessage=te,me=function(){ye.postMessage(null)}}else me=function(){N(te,0)};function _e($,Y){V=N(function(){$(t.unstable_now())},Y)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function($){$.callback=null},t.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<$?Math.floor(1e3/$):5},t.unstable_getCurrentPriorityLevel=function(){return w},t.unstable_next=function($){switch(w){case 1:case 2:case 3:var Y=3;break;default:Y=w}var J=w;w=Y;try{return $()}finally{w=J}},t.unstable_requestPaint=function(){_=!0},t.unstable_runWithPriority=function($,Y){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var J=w;w=$;try{return Y()}finally{w=J}},t.unstable_scheduleCallback=function($,Y,J){var pe=t.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?pe+J:pe):J=pe,$){case 1:var se=-1;break;case 2:se=250;break;case 5:se=1073741823;break;case 4:se=1e4;break;default:se=5e3}return se=J+se,$={id:y++,callback:Y,priorityLevel:$,startTime:J,expirationTime:se,sortIndex:-1},J>pe?($.sortIndex=J,e(g,$),s(m)===null&&$===s(g)&&(j?(k(V),V=-1):j=!0,_e(D,J-pe))):($.sortIndex=se,e(m,$),E||S||(E=!0,z||(z=!0,me()))),$},t.unstable_shouldYield=Z,t.unstable_wrapCallback=function($){var Y=w;return function(){var J=w;w=Y;try{return $.apply(this,arguments)}finally{w=J}}}})(tf)),tf}var Ax;function ZN(){return Ax||(Ax=1,ef.exports=QN()),ef.exports}var nf={exports:{}},Yt={};var Rx;function e2(){if(Rx)return Yt;Rx=1;var t=Om();function e(m){var g="https://react.dev/errors/"+m;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)g+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+m+"; visit "+g+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(){}var i={d:{f:s,r:function(){throw Error(e(522))},D:s,C:s,L:s,m:s,X:s,S:s,M:s},p:0,findDOMNode:null},l=Symbol.for("react.portal");function u(m,g,y){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:l,key:x==null?null:""+x,children:m,containerInfo:g,implementation:y}}var d=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(m,g){if(m==="font")return"";if(typeof g=="string")return g==="use-credentials"?g:""}return Yt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,Yt.createPortal=function(m,g){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!g||g.nodeType!==1&&g.nodeType!==9&&g.nodeType!==11)throw Error(e(299));return u(m,g,null,y)},Yt.flushSync=function(m){var g=d.T,y=i.p;try{if(d.T=null,i.p=2,m)return m()}finally{d.T=g,i.p=y,i.d.f()}},Yt.preconnect=function(m,g){typeof m=="string"&&(g?(g=g.crossOrigin,g=typeof g=="string"?g==="use-credentials"?g:"":void 0):g=null,i.d.C(m,g))},Yt.prefetchDNS=function(m){typeof m=="string"&&i.d.D(m)},Yt.preinit=function(m,g){if(typeof m=="string"&&g&&typeof g.as=="string"){var y=g.as,x=h(y,g.crossOrigin),w=typeof g.integrity=="string"?g.integrity:void 0,S=typeof g.fetchPriority=="string"?g.fetchPriority:void 0;y==="style"?i.d.S(m,typeof g.precedence=="string"?g.precedence:void 0,{crossOrigin:x,integrity:w,fetchPriority:S}):y==="script"&&i.d.X(m,{crossOrigin:x,integrity:w,fetchPriority:S,nonce:typeof g.nonce=="string"?g.nonce:void 0})}},Yt.preinitModule=function(m,g){if(typeof m=="string")if(typeof g=="object"&&g!==null){if(g.as==null||g.as==="script"){var y=h(g.as,g.crossOrigin);i.d.M(m,{crossOrigin:y,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0})}}else g==null&&i.d.M(m)},Yt.preload=function(m,g){if(typeof m=="string"&&typeof g=="object"&&g!==null&&typeof g.as=="string"){var y=g.as,x=h(y,g.crossOrigin);i.d.L(m,y,{crossOrigin:x,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0,type:typeof g.type=="string"?g.type:void 0,fetchPriority:typeof g.fetchPriority=="string"?g.fetchPriority:void 0,referrerPolicy:typeof g.referrerPolicy=="string"?g.referrerPolicy:void 0,imageSrcSet:typeof g.imageSrcSet=="string"?g.imageSrcSet:void 0,imageSizes:typeof g.imageSizes=="string"?g.imageSizes:void 0,media:typeof g.media=="string"?g.media:void 0})}},Yt.preloadModule=function(m,g){if(typeof m=="string")if(g){var y=h(g.as,g.crossOrigin);i.d.m(m,{as:typeof g.as=="string"&&g.as!=="script"?g.as:void 0,crossOrigin:y,integrity:typeof g.integrity=="string"?g.integrity:void 0})}else i.d.m(m)},Yt.requestFormReset=function(m){i.d.r(m)},Yt.unstable_batchedUpdates=function(m,g){return m(g)},Yt.useFormState=function(m,g,y){return d.H.useFormState(m,g,y)},Yt.useFormStatus=function(){return d.H.useHostTransitionStatus()},Yt.version="19.2.4",Yt}var Ox;function tw(){if(Ox)return nf.exports;Ox=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),nf.exports=e2(),nf.exports}var Mx;function t2(){if(Mx)return go;Mx=1;var t=ZN(),e=Om(),s=tw();function i(n){var a="https://react.dev/errors/"+n;if(1<arguments.length){a+="?args[]="+encodeURIComponent(arguments[1]);for(var r=2;r<arguments.length;r++)a+="&args[]="+encodeURIComponent(arguments[r])}return"Minified React error #"+n+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function l(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function u(n){var a=n,r=n;if(n.alternate)for(;a.return;)a=a.return;else{n=a;do a=n,(a.flags&4098)!==0&&(r=a.return),n=a.return;while(n)}return a.tag===3?r:null}function d(n){if(n.tag===13){var a=n.memoizedState;if(a===null&&(n=n.alternate,n!==null&&(a=n.memoizedState)),a!==null)return a.dehydrated}return null}function h(n){if(n.tag===31){var a=n.memoizedState;if(a===null&&(n=n.alternate,n!==null&&(a=n.memoizedState)),a!==null)return a.dehydrated}return null}function m(n){if(u(n)!==n)throw Error(i(188))}function g(n){var a=n.alternate;if(!a){if(a=u(n),a===null)throw Error(i(188));return a!==n?null:n}for(var r=n,c=a;;){var f=r.return;if(f===null)break;var p=f.alternate;if(p===null){if(c=f.return,c!==null){r=c;continue}break}if(f.child===p.child){for(p=f.child;p;){if(p===r)return m(f),n;if(p===c)return m(f),a;p=p.sibling}throw Error(i(188))}if(r.return!==c.return)r=f,c=p;else{for(var b=!1,T=f.child;T;){if(T===r){b=!0,r=f,c=p;break}if(T===c){b=!0,c=f,r=p;break}T=T.sibling}if(!b){for(T=p.child;T;){if(T===r){b=!0,r=p,c=f;break}if(T===c){b=!0,c=p,r=f;break}T=T.sibling}if(!b)throw Error(i(189))}}if(r.alternate!==c)throw Error(i(190))}if(r.tag!==3)throw Error(i(188));return r.stateNode.current===r?n:a}function y(n){var a=n.tag;if(a===5||a===26||a===27||a===6)return n;for(n=n.child;n!==null;){if(a=y(n),a!==null)return a;n=n.sibling}return null}var x=Object.assign,w=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),j=Symbol.for("react.fragment"),_=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),k=Symbol.for("react.consumer"),C=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),z=Symbol.for("react.suspense_list"),V=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),P=Symbol.for("react.activity"),Z=Symbol.for("react.memo_cache_sentinel"),te=Symbol.iterator;function me(n){return n===null||typeof n!="object"?null:(n=te&&n[te]||n["@@iterator"],typeof n=="function"?n:null)}var Ee=Symbol.for("react.client.reference");function ye(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===Ee?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case j:return"Fragment";case N:return"Profiler";case _:return"StrictMode";case D:return"Suspense";case z:return"SuspenseList";case P:return"Activity"}if(typeof n=="object")switch(n.$$typeof){case E:return"Portal";case C:return n.displayName||"Context";case k:return(n._context.displayName||"Context")+".Consumer";case A:var a=n.render;return n=n.displayName,n||(n=a.displayName||a.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case V:return a=n.displayName||null,a!==null?a:ye(n.type)||"Memo";case R:a=n._payload,n=n._init;try{return ye(n(a))}catch{}}return null}var _e=Array.isArray,$=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J={pending:!1,data:null,method:null,action:null},pe=[],se=-1;function M(n){return{current:n}}function U(n){0>se||(n.current=pe[se],pe[se]=null,se--)}function W(n,a){se++,pe[se]=n.current,n.current=a}var ne=M(null),oe=M(null),ue=M(null),q=M(null);function fe(n,a){switch(W(ue,a),W(oe,n),W(ne,null),a.nodeType){case 9:case 11:n=(n=a.documentElement)&&(n=n.namespaceURI)?Yv(n):0;break;default:if(n=a.tagName,a=a.namespaceURI)a=Yv(a),n=Xv(a,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}U(ne),W(ne,n)}function re(){U(ne),U(oe),U(ue)}function ze(n){n.memoizedState!==null&&W(q,n);var a=ne.current,r=Xv(a,n.type);a!==r&&(W(oe,n),W(ne,r))}function Be(n){oe.current===n&&(U(ne),U(oe)),q.current===n&&(U(q),uo._currentValue=J)}var kt,et;function le(n){if(kt===void 0)try{throw Error()}catch(r){var a=r.stack.trim().match(/\n( *(at )?)/);kt=a&&a[1]||"",et=-1<r.stack.indexOf(`
|
|
2
|
+
at`)?" (<anonymous>)":-1<r.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
+
`+kt+n+et}var Fe=!1;function de(n,a){if(!n||Fe)return"";Fe=!0;var r=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var c={DetermineComponentFrameRoot:function(){try{if(a){var ee=function(){throw Error()};if(Object.defineProperty(ee.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ee,[])}catch(K){var F=K}Reflect.construct(n,[],ee)}else{try{ee.call()}catch(K){F=K}n.call(ee.prototype)}}else{try{throw Error()}catch(K){F=K}(ee=n())&&typeof ee.catch=="function"&&ee.catch(function(){})}}catch(K){if(K&&F&&typeof K.stack=="string")return[K.stack,F.stack]}return[null,null]}};c.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var f=Object.getOwnPropertyDescriptor(c.DetermineComponentFrameRoot,"name");f&&f.configurable&&Object.defineProperty(c.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var p=c.DetermineComponentFrameRoot(),b=p[0],T=p[1];if(b&&T){var O=b.split(`
|
|
4
4
|
`),G=T.split(`
|
|
5
5
|
`);for(f=c=0;c<O.length&&!O[c].includes("DetermineComponentFrameRoot");)c++;for(;f<G.length&&!G[f].includes("DetermineComponentFrameRoot");)f++;if(c===O.length||f===G.length)for(c=O.length-1,f=G.length-1;1<=c&&0<=f&&O[c]!==G[f];)f--;for(;1<=c&&0<=f;c--,f--)if(O[c]!==G[f]){if(c!==1||f!==1)do if(c--,f--,0>f||O[c]!==G[f]){var X=`
|
|
6
|
-
`+O[c].replace(" at new "," at ");return n.displayName&&X.includes("<anonymous>")&&(X=X.replace("<anonymous>",n.displayName)),X}while(1<=c&&0<=f);break}}}finally{Fe=!1,Error.prepareStackTrace=
|
|
6
|
+
`+O[c].replace(" at new "," at ");return n.displayName&&X.includes("<anonymous>")&&(X=X.replace("<anonymous>",n.displayName)),X}while(1<=c&&0<=f);break}}}finally{Fe=!1,Error.prepareStackTrace=r}return(r=n?n.displayName||n.name:"")?le(r):""}function Me(n,a){switch(n.tag){case 26:case 27:case 5:return le(n.type);case 16:return le("Lazy");case 13:return n.child!==a&&a!==null?le("Suspense Fallback"):le("Suspense");case 19:return le("SuspenseList");case 0:case 15:return de(n.type,!1);case 11:return de(n.type.render,!1);case 1:return de(n.type,!0);case 31:return le("Activity");default:return""}}function at(n){try{var a="",r=null;do a+=Me(n,r),r=n,n=n.return;while(n);return a}catch(c){return`
|
|
7
7
|
Error generating stack: `+c.message+`
|
|
8
|
-
`+c.stack}}var Ut=Object.prototype.hasOwnProperty,Xn=t.unstable_scheduleCallback,wi=t.unstable_cancelCallback,Si=t.unstable_shouldYield,Uu=t.unstable_requestPaint,B=t.unstable_now,re=t.unstable_getCurrentPriorityLevel,De=t.unstable_ImmediatePriority,qe=t.unstable_UserBlockingPriority,ft=t.unstable_NormalPriority,Zt=t.unstable_LowPriority,Ve=t.unstable_IdlePriority,en=t.log,ll=t.unstable_setDisableYieldValue,Ms=null,Kt=null;function Wn(n){if(typeof en=="function"&&ll(n),Kt&&typeof Kt.setStrictMode=="function")try{Kt.setStrictMode(Ms,n)}catch{}}var dn=Math.clz32?Math.clz32:Dj,Oj=Math.log,Mj=Math.LN2;function Dj(n){return n>>>=0,n===0?32:31-(Oj(n)/Mj|0)|0}var cl=256,ul=262144,dl=4194304;function xa(n){var a=n&42;if(a!==0)return a;switch(n&-n){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 n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function hl(n,a,i){var c=n.pendingLanes;if(c===0)return 0;var f=0,p=n.suspendedLanes,b=n.pingedLanes;n=n.warmLanes;var T=c&134217727;return T!==0?(c=T&~p,c!==0?f=xa(c):(b&=T,b!==0?f=xa(b):i||(i=T&~n,i!==0&&(f=xa(i))))):(T=c&~p,T!==0?f=xa(T):b!==0?f=xa(b):i||(i=c&~n,i!==0&&(f=xa(i)))),f===0?0:a!==0&&a!==f&&(a&p)===0&&(p=f&-f,i=a&-a,p>=i||p===32&&(i&4194048)!==0)?a:f}function ji(n,a){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&a)===0}function Pj(n,a){switch(n){case 1:case 2:case 4:case 8:case 64:return a+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 a+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 Cp(){var n=dl;return dl<<=1,(dl&62914560)===0&&(dl=4194304),n}function Bu(n){for(var a=[],i=0;31>i;i++)a.push(n);return a}function _i(n,a){n.pendingLanes|=a,a!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function zj(n,a,i,c,f,p){var b=n.pendingLanes;n.pendingLanes=i,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=i,n.entangledLanes&=i,n.errorRecoveryDisabledLanes&=i,n.shellSuspendCounter=0;var T=n.entanglements,O=n.expirationTimes,G=n.hiddenUpdates;for(i=b&~i;0<i;){var X=31-dn(i),ee=1<<X;T[X]=0,O[X]=-1;var F=G[X];if(F!==null)for(G[X]=null,X=0;X<F.length;X++){var K=F[X];K!==null&&(K.lane&=-536870913)}i&=~ee}c!==0&&Ap(n,c,0),p!==0&&f===0&&n.tag!==0&&(n.suspendedLanes|=p&~(b&~a))}function Ap(n,a,i){n.pendingLanes|=a,n.suspendedLanes&=~a;var c=31-dn(a);n.entangledLanes|=a,n.entanglements[c]=n.entanglements[c]|1073741824|i&261930}function Rp(n,a){var i=n.entangledLanes|=a;for(n=n.entanglements;i;){var c=31-dn(i),f=1<<c;f&a|n[c]&a&&(n[c]|=a),i&=~f}}function Op(n,a){var i=a&-a;return i=(i&42)!==0?1:Vu(i),(i&(n.suspendedLanes|a))!==0?0:i}function Vu(n){switch(n){case 2:n=1;break;case 8:n=4;break;case 32:n=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:n=128;break;case 268435456:n=134217728;break;default:n=0}return n}function Iu(n){return n&=-n,2<n?8<n?(n&134217727)!==0?32:268435456:8:2}function Mp(){var n=Y.p;return n!==0?n:(n=window.event,n===void 0?32:vx(n.type))}function Dp(n,a){var i=Y.p;try{return Y.p=n,a()}finally{Y.p=i}}var Ds=Math.random().toString(36).slice(2),Bt="__reactFiber$"+Ds,tn="__reactProps$"+Ds,sr="__reactContainer$"+Ds,$u="__reactEvents$"+Ds,Lj="__reactListeners$"+Ds,Uj="__reactHandles$"+Ds,Pp="__reactResources$"+Ds,Ni="__reactMarker$"+Ds;function qu(n){delete n[Bt],delete n[tn],delete n[$u],delete n[Lj],delete n[Uj]}function ar(n){var a=n[Bt];if(a)return a;for(var i=n.parentNode;i;){if(a=i[sr]||i[Bt]){if(i=a.alternate,a.child!==null||i!==null&&i.child!==null)for(n=nx(n);n!==null;){if(i=n[Bt])return i;n=nx(n)}return a}n=i,i=n.parentNode}return null}function rr(n){if(n=n[Bt]||n[sr]){var a=n.tag;if(a===5||a===6||a===13||a===31||a===26||a===27||a===3)return n}return null}function Ti(n){var a=n.tag;if(a===5||a===26||a===27||a===6)return n.stateNode;throw Error(r(33))}function ir(n){var a=n[Pp];return a||(a=n[Pp]={hoistableStyles:new Map,hoistableScripts:new Map}),a}function Mt(n){n[Ni]=!0}var zp=new Set,Lp={};function ba(n,a){or(n,a),or(n+"Capture",a)}function or(n,a){for(Lp[n]=a,n=0;n<a.length;n++)zp.add(a[n])}var Bj=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]*$"),Up={},Bp={};function Vj(n){return Ut.call(Bp,n)?!0:Ut.call(Up,n)?!1:Bj.test(n)?Bp[n]=!0:(Up[n]=!0,!1)}function fl(n,a,i){if(Vj(a))if(i===null)n.removeAttribute(a);else{switch(typeof i){case"undefined":case"function":case"symbol":n.removeAttribute(a);return;case"boolean":var c=a.toLowerCase().slice(0,5);if(c!=="data-"&&c!=="aria-"){n.removeAttribute(a);return}}n.setAttribute(a,""+i)}}function ml(n,a,i){if(i===null)n.removeAttribute(a);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(a);return}n.setAttribute(a,""+i)}}function cs(n,a,i,c){if(c===null)n.removeAttribute(i);else{switch(typeof c){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(i);return}n.setAttributeNS(a,i,""+c)}}function Nn(n){switch(typeof n){case"bigint":case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function Vp(n){var a=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function Ij(n,a,i){var c=Object.getOwnPropertyDescriptor(n.constructor.prototype,a);if(!n.hasOwnProperty(a)&&typeof c<"u"&&typeof c.get=="function"&&typeof c.set=="function"){var f=c.get,p=c.set;return Object.defineProperty(n,a,{configurable:!0,get:function(){return f.call(this)},set:function(b){i=""+b,p.call(this,b)}}),Object.defineProperty(n,a,{enumerable:c.enumerable}),{getValue:function(){return i},setValue:function(b){i=""+b},stopTracking:function(){n._valueTracker=null,delete n[a]}}}}function Hu(n){if(!n._valueTracker){var a=Vp(n)?"checked":"value";n._valueTracker=Ij(n,a,""+n[a])}}function Ip(n){if(!n)return!1;var a=n._valueTracker;if(!a)return!0;var i=a.getValue(),c="";return n&&(c=Vp(n)?n.checked?"true":"false":n.value),n=c,n!==i?(a.setValue(n),!0):!1}function pl(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}var $j=/[\n"\\]/g;function Tn(n){return n.replace($j,function(a){return"\\"+a.charCodeAt(0).toString(16)+" "})}function Gu(n,a,i,c,f,p,b,T){n.name="",b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"?n.type=b:n.removeAttribute("type"),a!=null?b==="number"?(a===0&&n.value===""||n.value!=a)&&(n.value=""+Nn(a)):n.value!==""+Nn(a)&&(n.value=""+Nn(a)):b!=="submit"&&b!=="reset"||n.removeAttribute("value"),a!=null?Fu(n,b,Nn(a)):i!=null?Fu(n,b,Nn(i)):c!=null&&n.removeAttribute("value"),f==null&&p!=null&&(n.defaultChecked=!!p),f!=null&&(n.checked=f&&typeof f!="function"&&typeof f!="symbol"),T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?n.name=""+Nn(T):n.removeAttribute("name")}function $p(n,a,i,c,f,p,b,T){if(p!=null&&typeof p!="function"&&typeof p!="symbol"&&typeof p!="boolean"&&(n.type=p),a!=null||i!=null){if(!(p!=="submit"&&p!=="reset"||a!=null)){Hu(n);return}i=i!=null?""+Nn(i):"",a=a!=null?""+Nn(a):i,T||a===n.value||(n.value=a),n.defaultValue=a}c=c??f,c=typeof c!="function"&&typeof c!="symbol"&&!!c,n.checked=T?n.checked:!!c,n.defaultChecked=!!c,b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(n.name=b),Hu(n)}function Fu(n,a,i){a==="number"&&pl(n.ownerDocument)===n||n.defaultValue===""+i||(n.defaultValue=""+i)}function lr(n,a,i,c){if(n=n.options,a){a={};for(var f=0;f<i.length;f++)a["$"+i[f]]=!0;for(i=0;i<n.length;i++)f=a.hasOwnProperty("$"+n[i].value),n[i].selected!==f&&(n[i].selected=f),f&&c&&(n[i].defaultSelected=!0)}else{for(i=""+Nn(i),a=null,f=0;f<n.length;f++){if(n[f].value===i){n[f].selected=!0,c&&(n[f].defaultSelected=!0);return}a!==null||n[f].disabled||(a=n[f])}a!==null&&(a.selected=!0)}}function qp(n,a,i){if(a!=null&&(a=""+Nn(a),a!==n.value&&(n.value=a),i==null)){n.defaultValue!==a&&(n.defaultValue=a);return}n.defaultValue=i!=null?""+Nn(i):""}function Hp(n,a,i,c){if(a==null){if(c!=null){if(i!=null)throw Error(r(92));if(_e(c)){if(1<c.length)throw Error(r(93));c=c[0]}i=c}i==null&&(i=""),a=i}i=Nn(a),n.defaultValue=i,c=n.textContent,c===i&&c!==""&&c!==null&&(n.value=c),Hu(n)}function cr(n,a){if(a){var i=n.firstChild;if(i&&i===n.lastChild&&i.nodeType===3){i.nodeValue=a;return}}n.textContent=a}var qj=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 Gp(n,a,i){var c=a.indexOf("--")===0;i==null||typeof i=="boolean"||i===""?c?n.setProperty(a,""):a==="float"?n.cssFloat="":n[a]="":c?n.setProperty(a,i):typeof i!="number"||i===0||qj.has(a)?a==="float"?n.cssFloat=i:n[a]=(""+i).trim():n[a]=i+"px"}function Fp(n,a,i){if(a!=null&&typeof a!="object")throw Error(r(62));if(n=n.style,i!=null){for(var c in i)!i.hasOwnProperty(c)||a!=null&&a.hasOwnProperty(c)||(c.indexOf("--")===0?n.setProperty(c,""):c==="float"?n.cssFloat="":n[c]="");for(var f in a)c=a[f],a.hasOwnProperty(f)&&i[f]!==c&&Gp(n,f,c)}else for(var p in a)a.hasOwnProperty(p)&&Gp(n,p,a[p])}function Ku(n){if(n.indexOf("-")===-1)return!1;switch(n){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 Hj=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"]]),Gj=/^[\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 gl(n){return Gj.test(""+n)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":n}function us(){}var Yu=null;function Xu(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var ur=null,dr=null;function Kp(n){var a=rr(n);if(a&&(n=a.stateNode)){var i=n[tn]||null;e:switch(n=a.stateNode,a.type){case"input":if(Gu(n,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name),a=i.name,i.type==="radio"&&a!=null){for(i=n;i.parentNode;)i=i.parentNode;for(i=i.querySelectorAll('input[name="'+Tn(""+a)+'"][type="radio"]'),a=0;a<i.length;a++){var c=i[a];if(c!==n&&c.form===n.form){var f=c[tn]||null;if(!f)throw Error(r(90));Gu(c,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name)}}for(a=0;a<i.length;a++)c=i[a],c.form===n.form&&Ip(c)}break e;case"textarea":qp(n,i.value,i.defaultValue);break e;case"select":a=i.value,a!=null&&lr(n,!!i.multiple,a,!1)}}}var Wu=!1;function Yp(n,a,i){if(Wu)return n(a,i);Wu=!0;try{var c=n(a);return c}finally{if(Wu=!1,(ur!==null||dr!==null)&&(sc(),ur&&(a=ur,n=dr,dr=ur=null,Kp(a),n)))for(a=0;a<n.length;a++)Kp(n[a])}}function Ei(n,a){var i=n.stateNode;if(i===null)return null;var c=i[tn]||null;if(c===null)return null;i=c[a];e:switch(a){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(n=n.type,c=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!c;break e;default:n=!1}if(n)return null;if(i&&typeof i!="function")throw Error(r(231,a,typeof i));return i}var ds=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ju=!1;if(ds)try{var ki={};Object.defineProperty(ki,"passive",{get:function(){Ju=!0}}),window.addEventListener("test",ki,ki),window.removeEventListener("test",ki,ki)}catch{Ju=!1}var Ps=null,Qu=null,yl=null;function Xp(){if(yl)return yl;var n,a=Qu,i=a.length,c,f="value"in Ps?Ps.value:Ps.textContent,p=f.length;for(n=0;n<i&&a[n]===f[n];n++);var b=i-n;for(c=1;c<=b&&a[i-c]===f[p-c];c++);return yl=f.slice(n,1<c?1-c:void 0)}function vl(n){var a=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&a===13&&(n=13)):n=a,n===10&&(n=13),32<=n||n===13?n:0}function xl(){return!0}function Wp(){return!1}function nn(n){function a(i,c,f,p,b){this._reactName=i,this._targetInst=f,this.type=c,this.nativeEvent=p,this.target=b,this.currentTarget=null;for(var T in n)n.hasOwnProperty(T)&&(i=n[T],this[T]=i?i(p):p[T]);return this.isDefaultPrevented=(p.defaultPrevented!=null?p.defaultPrevented:p.returnValue===!1)?xl:Wp,this.isPropagationStopped=Wp,this}return x(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var i=this.nativeEvent;i&&(i.preventDefault?i.preventDefault():typeof i.returnValue!="unknown"&&(i.returnValue=!1),this.isDefaultPrevented=xl)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=xl)},persist:function(){},isPersistent:xl}),a}var wa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},bl=nn(wa),Ci=x({},wa,{view:0,detail:0}),Fj=nn(Ci),Zu,ed,Ai,wl=x({},Ci,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:nd,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==Ai&&(Ai&&n.type==="mousemove"?(Zu=n.screenX-Ai.screenX,ed=n.screenY-Ai.screenY):ed=Zu=0,Ai=n),Zu)},movementY:function(n){return"movementY"in n?n.movementY:ed}}),Jp=nn(wl),Kj=x({},wl,{dataTransfer:0}),Yj=nn(Kj),Xj=x({},Ci,{relatedTarget:0}),td=nn(Xj),Wj=x({},wa,{animationName:0,elapsedTime:0,pseudoElement:0}),Jj=nn(Wj),Qj=x({},wa,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),Zj=nn(Qj),e_=x({},wa,{data:0}),Qp=nn(e_),t_={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},n_={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"},s_={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function a_(n){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(n):(n=s_[n])?!!a[n]:!1}function nd(){return a_}var r_=x({},Ci,{key:function(n){if(n.key){var a=t_[n.key]||n.key;if(a!=="Unidentified")return a}return n.type==="keypress"?(n=vl(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?n_[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:nd,charCode:function(n){return n.type==="keypress"?vl(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?vl(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),i_=nn(r_),o_=x({},wl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Zp=nn(o_),l_=x({},Ci,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:nd}),c_=nn(l_),u_=x({},wa,{propertyName:0,elapsedTime:0,pseudoElement:0}),d_=nn(u_),h_=x({},wl,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),f_=nn(h_),m_=x({},wa,{newState:0,oldState:0}),p_=nn(m_),g_=[9,13,27,32],sd=ds&&"CompositionEvent"in window,Ri=null;ds&&"documentMode"in document&&(Ri=document.documentMode);var y_=ds&&"TextEvent"in window&&!Ri,eg=ds&&(!sd||Ri&&8<Ri&&11>=Ri),tg=" ",ng=!1;function sg(n,a){switch(n){case"keyup":return g_.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ag(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var hr=!1;function v_(n,a){switch(n){case"compositionend":return ag(a);case"keypress":return a.which!==32?null:(ng=!0,tg);case"textInput":return n=a.data,n===tg&&ng?null:n;default:return null}}function x_(n,a){if(hr)return n==="compositionend"||!sd&&sg(n,a)?(n=Xp(),yl=Qu=Ps=null,hr=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1<a.char.length)return a.char;if(a.which)return String.fromCharCode(a.which)}return null;case"compositionend":return eg&&a.locale!=="ko"?null:a.data;default:return null}}var b_={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 rg(n){var a=n&&n.nodeName&&n.nodeName.toLowerCase();return a==="input"?!!b_[n.type]:a==="textarea"}function ig(n,a,i,c){ur?dr?dr.push(c):dr=[c]:ur=c,a=uc(a,"onChange"),0<a.length&&(i=new bl("onChange","change",null,i,c),n.push({event:i,listeners:a}))}var Oi=null,Mi=null;function w_(n){$v(n,0)}function Sl(n){var a=Ti(n);if(Ip(a))return n}function og(n,a){if(n==="change")return a}var lg=!1;if(ds){var ad;if(ds){var rd="oninput"in document;if(!rd){var cg=document.createElement("div");cg.setAttribute("oninput","return;"),rd=typeof cg.oninput=="function"}ad=rd}else ad=!1;lg=ad&&(!document.documentMode||9<document.documentMode)}function ug(){Oi&&(Oi.detachEvent("onpropertychange",dg),Mi=Oi=null)}function dg(n){if(n.propertyName==="value"&&Sl(Mi)){var a=[];ig(a,Mi,n,Xu(n)),Yp(w_,a)}}function S_(n,a,i){n==="focusin"?(ug(),Oi=a,Mi=i,Oi.attachEvent("onpropertychange",dg)):n==="focusout"&&ug()}function j_(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return Sl(Mi)}function __(n,a){if(n==="click")return Sl(a)}function N_(n,a){if(n==="input"||n==="change")return Sl(a)}function T_(n,a){return n===a&&(n!==0||1/n===1/a)||n!==n&&a!==a}var hn=typeof Object.is=="function"?Object.is:T_;function Di(n,a){if(hn(n,a))return!0;if(typeof n!="object"||n===null||typeof a!="object"||a===null)return!1;var i=Object.keys(n),c=Object.keys(a);if(i.length!==c.length)return!1;for(c=0;c<i.length;c++){var f=i[c];if(!Ut.call(a,f)||!hn(n[f],a[f]))return!1}return!0}function hg(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function fg(n,a){var i=hg(n);n=0;for(var c;i;){if(i.nodeType===3){if(c=n+i.textContent.length,n<=a&&c>=a)return{node:i,offset:a-n};n=c}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=hg(i)}}function mg(n,a){return n&&a?n===a?!0:n&&n.nodeType===3?!1:a&&a.nodeType===3?mg(n,a.parentNode):"contains"in n?n.contains(a):n.compareDocumentPosition?!!(n.compareDocumentPosition(a)&16):!1:!1}function pg(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var a=pl(n.document);a instanceof n.HTMLIFrameElement;){try{var i=typeof a.contentWindow.location.href=="string"}catch{i=!1}if(i)n=a.contentWindow;else break;a=pl(n.document)}return a}function id(n){var a=n&&n.nodeName&&n.nodeName.toLowerCase();return a&&(a==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||a==="textarea"||n.contentEditable==="true")}var E_=ds&&"documentMode"in document&&11>=document.documentMode,fr=null,od=null,Pi=null,ld=!1;function gg(n,a,i){var c=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;ld||fr==null||fr!==pl(c)||(c=fr,"selectionStart"in c&&id(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),Pi&&Di(Pi,c)||(Pi=c,c=uc(od,"onSelect"),0<c.length&&(a=new bl("onSelect","select",null,a,i),n.push({event:a,listeners:c}),a.target=fr)))}function Sa(n,a){var i={};return i[n.toLowerCase()]=a.toLowerCase(),i["Webkit"+n]="webkit"+a,i["Moz"+n]="moz"+a,i}var mr={animationend:Sa("Animation","AnimationEnd"),animationiteration:Sa("Animation","AnimationIteration"),animationstart:Sa("Animation","AnimationStart"),transitionrun:Sa("Transition","TransitionRun"),transitionstart:Sa("Transition","TransitionStart"),transitioncancel:Sa("Transition","TransitionCancel"),transitionend:Sa("Transition","TransitionEnd")},cd={},yg={};ds&&(yg=document.createElement("div").style,"AnimationEvent"in window||(delete mr.animationend.animation,delete mr.animationiteration.animation,delete mr.animationstart.animation),"TransitionEvent"in window||delete mr.transitionend.transition);function ja(n){if(cd[n])return cd[n];if(!mr[n])return n;var a=mr[n],i;for(i in a)if(a.hasOwnProperty(i)&&i in yg)return cd[n]=a[i];return n}var vg=ja("animationend"),xg=ja("animationiteration"),bg=ja("animationstart"),k_=ja("transitionrun"),C_=ja("transitionstart"),A_=ja("transitioncancel"),wg=ja("transitionend"),Sg=new Map,ud="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(" ");ud.push("scrollEnd");function Un(n,a){Sg.set(n,a),ba(a,[n])}var jl=typeof reportError=="function"?reportError:function(n){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var a=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof n=="object"&&n!==null&&typeof n.message=="string"?String(n.message):String(n),error:n});if(!window.dispatchEvent(a))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",n);return}console.error(n)},En=[],pr=0,dd=0;function _l(){for(var n=pr,a=dd=pr=0;a<n;){var i=En[a];En[a++]=null;var c=En[a];En[a++]=null;var f=En[a];En[a++]=null;var p=En[a];if(En[a++]=null,c!==null&&f!==null){var b=c.pending;b===null?f.next=f:(f.next=b.next,b.next=f),c.pending=f}p!==0&&jg(i,f,p)}}function Nl(n,a,i,c){En[pr++]=n,En[pr++]=a,En[pr++]=i,En[pr++]=c,dd|=c,n.lanes|=c,n=n.alternate,n!==null&&(n.lanes|=c)}function hd(n,a,i,c){return Nl(n,a,i,c),Tl(n)}function _a(n,a){return Nl(n,null,null,a),Tl(n)}function jg(n,a,i){n.lanes|=i;var c=n.alternate;c!==null&&(c.lanes|=i);for(var f=!1,p=n.return;p!==null;)p.childLanes|=i,c=p.alternate,c!==null&&(c.childLanes|=i),p.tag===22&&(n=p.stateNode,n===null||n._visibility&1||(f=!0)),n=p,p=p.return;return n.tag===3?(p=n.stateNode,f&&a!==null&&(f=31-dn(i),n=p.hiddenUpdates,c=n[f],c===null?n[f]=[a]:c.push(a),a.lane=i|536870912),p):null}function Tl(n){if(50<so)throw so=0,wh=null,Error(r(185));for(var a=n.return;a!==null;)n=a,a=n.return;return n.tag===3?n.stateNode:null}var gr={};function R_(n,a,i,c){this.tag=n,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=a,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function fn(n,a,i,c){return new R_(n,a,i,c)}function fd(n){return n=n.prototype,!(!n||!n.isReactComponent)}function hs(n,a){var i=n.alternate;return i===null?(i=fn(n.tag,a,n.key,n.mode),i.elementType=n.elementType,i.type=n.type,i.stateNode=n.stateNode,i.alternate=n,n.alternate=i):(i.pendingProps=a,i.type=n.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=n.flags&65011712,i.childLanes=n.childLanes,i.lanes=n.lanes,i.child=n.child,i.memoizedProps=n.memoizedProps,i.memoizedState=n.memoizedState,i.updateQueue=n.updateQueue,a=n.dependencies,i.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},i.sibling=n.sibling,i.index=n.index,i.ref=n.ref,i.refCleanup=n.refCleanup,i}function _g(n,a){n.flags&=65011714;var i=n.alternate;return i===null?(n.childLanes=0,n.lanes=a,n.child=null,n.subtreeFlags=0,n.memoizedProps=null,n.memoizedState=null,n.updateQueue=null,n.dependencies=null,n.stateNode=null):(n.childLanes=i.childLanes,n.lanes=i.lanes,n.child=i.child,n.subtreeFlags=0,n.deletions=null,n.memoizedProps=i.memoizedProps,n.memoizedState=i.memoizedState,n.updateQueue=i.updateQueue,n.type=i.type,a=i.dependencies,n.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),n}function El(n,a,i,c,f,p){var b=0;if(c=n,typeof n=="function")fd(n)&&(b=1);else if(typeof n=="string")b=zN(n,i,ne.current)?26:n==="html"||n==="head"||n==="body"?27:5;else e:switch(n){case P:return n=fn(31,i,a,f),n.elementType=P,n.lanes=p,n;case j:return Na(i.children,f,p,a);case _:b=8,f|=24;break;case N:return n=fn(12,i,a,f|2),n.elementType=N,n.lanes=p,n;case D:return n=fn(13,i,a,f),n.elementType=D,n.lanes=p,n;case U:return n=fn(19,i,a,f),n.elementType=U,n.lanes=p,n;default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case C:b=10;break e;case k:b=9;break e;case A:b=11;break e;case V:b=14;break e;case R:b=16,c=null;break e}b=29,i=Error(r(130,n===null?"null":typeof n,"")),c=null}return a=fn(b,i,a,f),a.elementType=n,a.type=c,a.lanes=p,a}function Na(n,a,i,c){return n=fn(7,n,c,a),n.lanes=i,n}function md(n,a,i){return n=fn(6,n,null,a),n.lanes=i,n}function Ng(n){var a=fn(18,null,null,0);return a.stateNode=n,a}function pd(n,a,i){return a=fn(4,n.children!==null?n.children:[],n.key,a),a.lanes=i,a.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},a}var Tg=new WeakMap;function kn(n,a){if(typeof n=="object"&&n!==null){var i=Tg.get(n);return i!==void 0?i:(a={value:n,source:a,stack:at(a)},Tg.set(n,a),a)}return{value:n,source:a,stack:at(a)}}var yr=[],vr=0,kl=null,zi=0,Cn=[],An=0,zs=null,Jn=1,Qn="";function fs(n,a){yr[vr++]=zi,yr[vr++]=kl,kl=n,zi=a}function Eg(n,a,i){Cn[An++]=Jn,Cn[An++]=Qn,Cn[An++]=zs,zs=n;var c=Jn;n=Qn;var f=32-dn(c)-1;c&=~(1<<f),i+=1;var p=32-dn(a)+f;if(30<p){var b=f-f%5;p=(c&(1<<b)-1).toString(32),c>>=b,f-=b,Jn=1<<32-dn(a)+f|i<<f|c,Qn=p+n}else Jn=1<<p|i<<f|c,Qn=n}function gd(n){n.return!==null&&(fs(n,1),Eg(n,1,0))}function yd(n){for(;n===kl;)kl=yr[--vr],yr[vr]=null,zi=yr[--vr],yr[vr]=null;for(;n===zs;)zs=Cn[--An],Cn[An]=null,Qn=Cn[--An],Cn[An]=null,Jn=Cn[--An],Cn[An]=null}function kg(n,a){Cn[An++]=Jn,Cn[An++]=Qn,Cn[An++]=zs,Jn=a.id,Qn=a.overflow,zs=n}var Vt=null,ct=null,Ke=!1,Ls=null,Rn=!1,vd=Error(r(519));function Us(n){var a=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Li(kn(a,n)),vd}function Cg(n){var a=n.stateNode,i=n.type,c=n.memoizedProps;switch(a[Bt]=n,a[tn]=c,i){case"dialog":$e("cancel",a),$e("close",a);break;case"iframe":case"object":case"embed":$e("load",a);break;case"video":case"audio":for(i=0;i<ro.length;i++)$e(ro[i],a);break;case"source":$e("error",a);break;case"img":case"image":case"link":$e("error",a),$e("load",a);break;case"details":$e("toggle",a);break;case"input":$e("invalid",a),$p(a,c.value,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name,!0);break;case"select":$e("invalid",a);break;case"textarea":$e("invalid",a),Hp(a,c.value,c.defaultValue,c.children)}i=c.children,typeof i!="string"&&typeof i!="number"&&typeof i!="bigint"||a.textContent===""+i||c.suppressHydrationWarning===!0||Fv(a.textContent,i)?(c.popover!=null&&($e("beforetoggle",a),$e("toggle",a)),c.onScroll!=null&&$e("scroll",a),c.onScrollEnd!=null&&$e("scrollend",a),c.onClick!=null&&(a.onclick=us),a=!0):a=!1,a||Us(n,!0)}function Ag(n){for(Vt=n.return;Vt;)switch(Vt.tag){case 5:case 31:case 13:Rn=!1;return;case 27:case 3:Rn=!0;return;default:Vt=Vt.return}}function xr(n){if(n!==Vt)return!1;if(!Ke)return Ag(n),Ke=!0,!1;var a=n.tag,i;if((i=a!==3&&a!==27)&&((i=a===5)&&(i=n.type,i=!(i!=="form"&&i!=="button")||zh(n.type,n.memoizedProps)),i=!i),i&&ct&&Us(n),Ag(n),a===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(r(317));ct=tx(n)}else if(a===31){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(r(317));ct=tx(n)}else a===27?(a=ct,Qs(n.type)?(n=Ih,Ih=null,ct=n):ct=a):ct=Vt?Mn(n.stateNode.nextSibling):null;return!0}function Ta(){ct=Vt=null,Ke=!1}function xd(){var n=Ls;return n!==null&&(on===null?on=n:on.push.apply(on,n),Ls=null),n}function Li(n){Ls===null?Ls=[n]:Ls.push(n)}var bd=M(null),Ea=null,ms=null;function Bs(n,a,i){W(bd,a._currentValue),a._currentValue=i}function ps(n){n._currentValue=bd.current,L(bd)}function wd(n,a,i){for(;n!==null;){var c=n.alternate;if((n.childLanes&a)!==a?(n.childLanes|=a,c!==null&&(c.childLanes|=a)):c!==null&&(c.childLanes&a)!==a&&(c.childLanes|=a),n===i)break;n=n.return}}function Sd(n,a,i,c){var f=n.child;for(f!==null&&(f.return=n);f!==null;){var p=f.dependencies;if(p!==null){var b=f.child;p=p.firstContext;e:for(;p!==null;){var T=p;p=f;for(var O=0;O<a.length;O++)if(T.context===a[O]){p.lanes|=i,T=p.alternate,T!==null&&(T.lanes|=i),wd(p.return,i,n),c||(b=null);break e}p=T.next}}else if(f.tag===18){if(b=f.return,b===null)throw Error(r(341));b.lanes|=i,p=b.alternate,p!==null&&(p.lanes|=i),wd(b,i,n),b=null}else b=f.child;if(b!==null)b.return=f;else for(b=f;b!==null;){if(b===n){b=null;break}if(f=b.sibling,f!==null){f.return=b.return,b=f;break}b=b.return}f=b}}function br(n,a,i,c){n=null;for(var f=a,p=!1;f!==null;){if(!p){if((f.flags&524288)!==0)p=!0;else if((f.flags&262144)!==0)break}if(f.tag===10){var b=f.alternate;if(b===null)throw Error(r(387));if(b=b.memoizedProps,b!==null){var T=f.type;hn(f.pendingProps.value,b.value)||(n!==null?n.push(T):n=[T])}}else if(f===q.current){if(b=f.alternate,b===null)throw Error(r(387));b.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(n!==null?n.push(uo):n=[uo])}f=f.return}n!==null&&Sd(a,n,i,c),a.flags|=262144}function Cl(n){for(n=n.firstContext;n!==null;){if(!hn(n.context._currentValue,n.memoizedValue))return!0;n=n.next}return!1}function ka(n){Ea=n,ms=null,n=n.dependencies,n!==null&&(n.firstContext=null)}function It(n){return Rg(Ea,n)}function Al(n,a){return Ea===null&&ka(n),Rg(n,a)}function Rg(n,a){var i=a._currentValue;if(a={context:a,memoizedValue:i,next:null},ms===null){if(n===null)throw Error(r(308));ms=a,n.dependencies={lanes:0,firstContext:a},n.flags|=524288}else ms=ms.next=a;return i}var O_=typeof AbortController<"u"?AbortController:function(){var n=[],a=this.signal={aborted:!1,addEventListener:function(i,c){n.push(c)}};this.abort=function(){a.aborted=!0,n.forEach(function(i){return i()})}},M_=t.unstable_scheduleCallback,D_=t.unstable_NormalPriority,St={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function jd(){return{controller:new O_,data:new Map,refCount:0}}function Ui(n){n.refCount--,n.refCount===0&&M_(D_,function(){n.controller.abort()})}var Bi=null,_d=0,wr=0,Sr=null;function P_(n,a){if(Bi===null){var i=Bi=[];_d=0,wr=Eh(),Sr={status:"pending",value:void 0,then:function(c){i.push(c)}}}return _d++,a.then(Og,Og),a}function Og(){if(--_d===0&&Bi!==null){Sr!==null&&(Sr.status="fulfilled");var n=Bi;Bi=null,wr=0,Sr=null;for(var a=0;a<n.length;a++)(0,n[a])()}}function z_(n,a){var i=[],c={status:"pending",value:null,reason:null,then:function(f){i.push(f)}};return n.then(function(){c.status="fulfilled",c.value=a;for(var f=0;f<i.length;f++)(0,i[f])(a)},function(f){for(c.status="rejected",c.reason=f,f=0;f<i.length;f++)(0,i[f])(void 0)}),c}var Mg=$.S;$.S=function(n,a){gv=B(),typeof a=="object"&&a!==null&&typeof a.then=="function"&&P_(n,a),Mg!==null&&Mg(n,a)};var Ca=M(null);function Nd(){var n=Ca.current;return n!==null?n:rt.pooledCache}function Rl(n,a){a===null?W(Ca,Ca.current):W(Ca,a.pool)}function Dg(){var n=Nd();return n===null?null:{parent:St._currentValue,pool:n}}var jr=Error(r(460)),Td=Error(r(474)),Ol=Error(r(542)),Ml={then:function(){}};function Pg(n){return n=n.status,n==="fulfilled"||n==="rejected"}function zg(n,a,i){switch(i=n[i],i===void 0?n.push(a):i!==a&&(a.then(us,us),a=i),a.status){case"fulfilled":return a.value;case"rejected":throw n=a.reason,Ug(n),n;default:if(typeof a.status=="string")a.then(us,us);else{if(n=rt,n!==null&&100<n.shellSuspendCounter)throw Error(r(482));n=a,n.status="pending",n.then(function(c){if(a.status==="pending"){var f=a;f.status="fulfilled",f.value=c}},function(c){if(a.status==="pending"){var f=a;f.status="rejected",f.reason=c}})}switch(a.status){case"fulfilled":return a.value;case"rejected":throw n=a.reason,Ug(n),n}throw Ra=a,jr}}function Aa(n){try{var a=n._init;return a(n._payload)}catch(i){throw i!==null&&typeof i=="object"&&typeof i.then=="function"?(Ra=i,jr):i}}var Ra=null;function Lg(){if(Ra===null)throw Error(r(459));var n=Ra;return Ra=null,n}function Ug(n){if(n===jr||n===Ol)throw Error(r(483))}var _r=null,Vi=0;function Dl(n){var a=Vi;return Vi+=1,_r===null&&(_r=[]),zg(_r,n,a)}function Ii(n,a){a=a.props.ref,n.ref=a!==void 0?a:null}function Pl(n,a){throw a.$$typeof===w?Error(r(525)):(n=Object.prototype.toString.call(a),Error(r(31,n==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":n)))}function Bg(n){function a(I,z){if(n){var H=I.deletions;H===null?(I.deletions=[z],I.flags|=16):H.push(z)}}function i(I,z){if(!n)return null;for(;z!==null;)a(I,z),z=z.sibling;return null}function c(I){for(var z=new Map;I!==null;)I.key!==null?z.set(I.key,I):z.set(I.index,I),I=I.sibling;return z}function f(I,z){return I=hs(I,z),I.index=0,I.sibling=null,I}function p(I,z,H){return I.index=H,n?(H=I.alternate,H!==null?(H=H.index,H<z?(I.flags|=67108866,z):H):(I.flags|=67108866,z)):(I.flags|=1048576,z)}function b(I){return n&&I.alternate===null&&(I.flags|=67108866),I}function T(I,z,H,Q){return z===null||z.tag!==6?(z=md(H,I.mode,Q),z.return=I,z):(z=f(z,H),z.return=I,z)}function O(I,z,H,Q){var ke=H.type;return ke===j?X(I,z,H.props.children,Q,H.key):z!==null&&(z.elementType===ke||typeof ke=="object"&&ke!==null&&ke.$$typeof===R&&Aa(ke)===z.type)?(z=f(z,H.props),Ii(z,H),z.return=I,z):(z=El(H.type,H.key,H.props,null,I.mode,Q),Ii(z,H),z.return=I,z)}function G(I,z,H,Q){return z===null||z.tag!==4||z.stateNode.containerInfo!==H.containerInfo||z.stateNode.implementation!==H.implementation?(z=pd(H,I.mode,Q),z.return=I,z):(z=f(z,H.children||[]),z.return=I,z)}function X(I,z,H,Q,ke){return z===null||z.tag!==7?(z=Na(H,I.mode,Q,ke),z.return=I,z):(z=f(z,H),z.return=I,z)}function ee(I,z,H){if(typeof z=="string"&&z!==""||typeof z=="number"||typeof z=="bigint")return z=md(""+z,I.mode,H),z.return=I,z;if(typeof z=="object"&&z!==null){switch(z.$$typeof){case S:return H=El(z.type,z.key,z.props,null,I.mode,H),Ii(H,z),H.return=I,H;case E:return z=pd(z,I.mode,H),z.return=I,z;case R:return z=Aa(z),ee(I,z,H)}if(_e(z)||me(z))return z=Na(z,I.mode,H,null),z.return=I,z;if(typeof z.then=="function")return ee(I,Dl(z),H);if(z.$$typeof===C)return ee(I,Al(I,z),H);Pl(I,z)}return null}function F(I,z,H,Q){var ke=z!==null?z.key:null;if(typeof H=="string"&&H!==""||typeof H=="number"||typeof H=="bigint")return ke!==null?null:T(I,z,""+H,Q);if(typeof H=="object"&&H!==null){switch(H.$$typeof){case S:return H.key===ke?O(I,z,H,Q):null;case E:return H.key===ke?G(I,z,H,Q):null;case R:return H=Aa(H),F(I,z,H,Q)}if(_e(H)||me(H))return ke!==null?null:X(I,z,H,Q,null);if(typeof H.then=="function")return F(I,z,Dl(H),Q);if(H.$$typeof===C)return F(I,z,Al(I,H),Q);Pl(I,H)}return null}function K(I,z,H,Q,ke){if(typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint")return I=I.get(H)||null,T(z,I,""+Q,ke);if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case S:return I=I.get(Q.key===null?H:Q.key)||null,O(z,I,Q,ke);case E:return I=I.get(Q.key===null?H:Q.key)||null,G(z,I,Q,ke);case R:return Q=Aa(Q),K(I,z,H,Q,ke)}if(_e(Q)||me(Q))return I=I.get(H)||null,X(z,I,Q,ke,null);if(typeof Q.then=="function")return K(I,z,H,Dl(Q),ke);if(Q.$$typeof===C)return K(I,z,H,Al(z,Q),ke);Pl(z,Q)}return null}function ve(I,z,H,Q){for(var ke=null,Ye=null,Se=z,Le=z=0,Ge=null;Se!==null&&Le<H.length;Le++){Se.index>Le?(Ge=Se,Se=null):Ge=Se.sibling;var Xe=F(I,Se,H[Le],Q);if(Xe===null){Se===null&&(Se=Ge);break}n&&Se&&Xe.alternate===null&&a(I,Se),z=p(Xe,z,Le),Ye===null?ke=Xe:Ye.sibling=Xe,Ye=Xe,Se=Ge}if(Le===H.length)return i(I,Se),Ke&&fs(I,Le),ke;if(Se===null){for(;Le<H.length;Le++)Se=ee(I,H[Le],Q),Se!==null&&(z=p(Se,z,Le),Ye===null?ke=Se:Ye.sibling=Se,Ye=Se);return Ke&&fs(I,Le),ke}for(Se=c(Se);Le<H.length;Le++)Ge=K(Se,I,Le,H[Le],Q),Ge!==null&&(n&&Ge.alternate!==null&&Se.delete(Ge.key===null?Le:Ge.key),z=p(Ge,z,Le),Ye===null?ke=Ge:Ye.sibling=Ge,Ye=Ge);return n&&Se.forEach(function(sa){return a(I,sa)}),Ke&&fs(I,Le),ke}function Ce(I,z,H,Q){if(H==null)throw Error(r(151));for(var ke=null,Ye=null,Se=z,Le=z=0,Ge=null,Xe=H.next();Se!==null&&!Xe.done;Le++,Xe=H.next()){Se.index>Le?(Ge=Se,Se=null):Ge=Se.sibling;var sa=F(I,Se,Xe.value,Q);if(sa===null){Se===null&&(Se=Ge);break}n&&Se&&sa.alternate===null&&a(I,Se),z=p(sa,z,Le),Ye===null?ke=sa:Ye.sibling=sa,Ye=sa,Se=Ge}if(Xe.done)return i(I,Se),Ke&&fs(I,Le),ke;if(Se===null){for(;!Xe.done;Le++,Xe=H.next())Xe=ee(I,Xe.value,Q),Xe!==null&&(z=p(Xe,z,Le),Ye===null?ke=Xe:Ye.sibling=Xe,Ye=Xe);return Ke&&fs(I,Le),ke}for(Se=c(Se);!Xe.done;Le++,Xe=H.next())Xe=K(Se,I,Le,Xe.value,Q),Xe!==null&&(n&&Xe.alternate!==null&&Se.delete(Xe.key===null?Le:Xe.key),z=p(Xe,z,Le),Ye===null?ke=Xe:Ye.sibling=Xe,Ye=Xe);return n&&Se.forEach(function(KN){return a(I,KN)}),Ke&&fs(I,Le),ke}function st(I,z,H,Q){if(typeof H=="object"&&H!==null&&H.type===j&&H.key===null&&(H=H.props.children),typeof H=="object"&&H!==null){switch(H.$$typeof){case S:e:{for(var ke=H.key;z!==null;){if(z.key===ke){if(ke=H.type,ke===j){if(z.tag===7){i(I,z.sibling),Q=f(z,H.props.children),Q.return=I,I=Q;break e}}else if(z.elementType===ke||typeof ke=="object"&&ke!==null&&ke.$$typeof===R&&Aa(ke)===z.type){i(I,z.sibling),Q=f(z,H.props),Ii(Q,H),Q.return=I,I=Q;break e}i(I,z);break}else a(I,z);z=z.sibling}H.type===j?(Q=Na(H.props.children,I.mode,Q,H.key),Q.return=I,I=Q):(Q=El(H.type,H.key,H.props,null,I.mode,Q),Ii(Q,H),Q.return=I,I=Q)}return b(I);case E:e:{for(ke=H.key;z!==null;){if(z.key===ke)if(z.tag===4&&z.stateNode.containerInfo===H.containerInfo&&z.stateNode.implementation===H.implementation){i(I,z.sibling),Q=f(z,H.children||[]),Q.return=I,I=Q;break e}else{i(I,z);break}else a(I,z);z=z.sibling}Q=pd(H,I.mode,Q),Q.return=I,I=Q}return b(I);case R:return H=Aa(H),st(I,z,H,Q)}if(_e(H))return ve(I,z,H,Q);if(me(H)){if(ke=me(H),typeof ke!="function")throw Error(r(150));return H=ke.call(H),Ce(I,z,H,Q)}if(typeof H.then=="function")return st(I,z,Dl(H),Q);if(H.$$typeof===C)return st(I,z,Al(I,H),Q);Pl(I,H)}return typeof H=="string"&&H!==""||typeof H=="number"||typeof H=="bigint"?(H=""+H,z!==null&&z.tag===6?(i(I,z.sibling),Q=f(z,H),Q.return=I,I=Q):(i(I,z),Q=md(H,I.mode,Q),Q.return=I,I=Q),b(I)):i(I,z)}return function(I,z,H,Q){try{Vi=0;var ke=st(I,z,H,Q);return _r=null,ke}catch(Se){if(Se===jr||Se===Ol)throw Se;var Ye=fn(29,Se,null,I.mode);return Ye.lanes=Q,Ye.return=I,Ye}}}var Oa=Bg(!0),Vg=Bg(!1),Vs=!1;function Ed(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function kd(n,a){n=n.updateQueue,a.updateQueue===n&&(a.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,callbacks:null})}function Is(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function $s(n,a,i){var c=n.updateQueue;if(c===null)return null;if(c=c.shared,(We&2)!==0){var f=c.pending;return f===null?a.next=a:(a.next=f.next,f.next=a),c.pending=a,a=Tl(n),jg(n,null,i),a}return Nl(n,c,a,i),Tl(n)}function $i(n,a,i){if(a=a.updateQueue,a!==null&&(a=a.shared,(i&4194048)!==0)){var c=a.lanes;c&=n.pendingLanes,i|=c,a.lanes=i,Rp(n,i)}}function Cd(n,a){var i=n.updateQueue,c=n.alternate;if(c!==null&&(c=c.updateQueue,i===c)){var f=null,p=null;if(i=i.firstBaseUpdate,i!==null){do{var b={lane:i.lane,tag:i.tag,payload:i.payload,callback:null,next:null};p===null?f=p=b:p=p.next=b,i=i.next}while(i!==null);p===null?f=p=a:p=p.next=a}else f=p=a;i={baseState:c.baseState,firstBaseUpdate:f,lastBaseUpdate:p,shared:c.shared,callbacks:c.callbacks},n.updateQueue=i;return}n=i.lastBaseUpdate,n===null?i.firstBaseUpdate=a:n.next=a,i.lastBaseUpdate=a}var Ad=!1;function qi(){if(Ad){var n=Sr;if(n!==null)throw n}}function Hi(n,a,i,c){Ad=!1;var f=n.updateQueue;Vs=!1;var p=f.firstBaseUpdate,b=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,G=O.next;O.next=null,b===null?p=G:b.next=G,b=O;var X=n.alternate;X!==null&&(X=X.updateQueue,T=X.lastBaseUpdate,T!==b&&(T===null?X.firstBaseUpdate=G:T.next=G,X.lastBaseUpdate=O))}if(p!==null){var ee=f.baseState;b=0,X=G=O=null,T=p;do{var F=T.lane&-536870913,K=F!==T.lane;if(K?(He&F)===F:(c&F)===F){F!==0&&F===wr&&(Ad=!0),X!==null&&(X=X.next={lane:0,tag:T.tag,payload:T.payload,callback:null,next:null});e:{var ve=n,Ce=T;F=a;var st=i;switch(Ce.tag){case 1:if(ve=Ce.payload,typeof ve=="function"){ee=ve.call(st,ee,F);break e}ee=ve;break e;case 3:ve.flags=ve.flags&-65537|128;case 0:if(ve=Ce.payload,F=typeof ve=="function"?ve.call(st,ee,F):ve,F==null)break e;ee=x({},ee,F);break e;case 2:Vs=!0}}F=T.callback,F!==null&&(n.flags|=64,K&&(n.flags|=8192),K=f.callbacks,K===null?f.callbacks=[F]:K.push(F))}else K={lane:F,tag:T.tag,payload:T.payload,callback:T.callback,next:null},X===null?(G=X=K,O=ee):X=X.next=K,b|=F;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;K=T,T=K.next,K.next=null,f.lastBaseUpdate=K,f.shared.pending=null}}while(!0);X===null&&(O=ee),f.baseState=O,f.firstBaseUpdate=G,f.lastBaseUpdate=X,p===null&&(f.shared.lanes=0),Ks|=b,n.lanes=b,n.memoizedState=ee}}function Ig(n,a){if(typeof n!="function")throw Error(r(191,n));n.call(a)}function $g(n,a){var i=n.callbacks;if(i!==null)for(n.callbacks=null,n=0;n<i.length;n++)Ig(i[n],a)}var Nr=M(null),zl=M(0);function qg(n,a){n=_s,W(zl,n),W(Nr,a),_s=n|a.baseLanes}function Rd(){W(zl,_s),W(Nr,Nr.current)}function Od(){_s=zl.current,L(Nr),L(zl)}var mn=M(null),On=null;function qs(n){var a=n.alternate;W(bt,bt.current&1),W(mn,n),On===null&&(a===null||Nr.current!==null||a.memoizedState!==null)&&(On=n)}function Md(n){W(bt,bt.current),W(mn,n),On===null&&(On=n)}function Hg(n){n.tag===22?(W(bt,bt.current),W(mn,n),On===null&&(On=n)):Hs()}function Hs(){W(bt,bt.current),W(mn,mn.current)}function pn(n){L(mn),On===n&&(On=null),L(bt)}var bt=M(0);function Ll(n){for(var a=n;a!==null;){if(a.tag===13){var i=a.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||Bh(i)||Vh(i)))return a}else if(a.tag===19&&(a.memoizedProps.revealOrder==="forwards"||a.memoizedProps.revealOrder==="backwards"||a.memoizedProps.revealOrder==="unstable_legacy-backwards"||a.memoizedProps.revealOrder==="together")){if((a.flags&128)!==0)return a}else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===n)break;for(;a.sibling===null;){if(a.return===null||a.return===n)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var gs=0,Pe=null,tt=null,jt=null,Ul=!1,Tr=!1,Ma=!1,Bl=0,Gi=0,Er=null,L_=0;function pt(){throw Error(r(321))}function Dd(n,a){if(a===null)return!1;for(var i=0;i<a.length&&i<n.length;i++)if(!hn(n[i],a[i]))return!1;return!0}function Pd(n,a,i,c,f,p){return gs=p,Pe=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,$.H=n===null||n.memoizedState===null?Ey:Wd,Ma=!1,p=i(c,f),Ma=!1,Tr&&(p=Fg(a,i,c,f)),Gg(n),p}function Gg(n){$.H=Yi;var a=tt!==null&&tt.next!==null;if(gs=0,jt=tt=Pe=null,Ul=!1,Gi=0,Er=null,a)throw Error(r(300));n===null||_t||(n=n.dependencies,n!==null&&Cl(n)&&(_t=!0))}function Fg(n,a,i,c){Pe=n;var f=0;do{if(Tr&&(Er=null),Gi=0,Tr=!1,25<=f)throw Error(r(301));if(f+=1,jt=tt=null,n.updateQueue!=null){var p=n.updateQueue;p.lastEffect=null,p.events=null,p.stores=null,p.memoCache!=null&&(p.memoCache.index=0)}$.H=ky,p=a(i,c)}while(Tr);return p}function U_(){var n=$.H,a=n.useState()[0];return a=typeof a.then=="function"?Fi(a):a,n=n.useState()[0],(tt!==null?tt.memoizedState:null)!==n&&(Pe.flags|=1024),a}function zd(){var n=Bl!==0;return Bl=0,n}function Ld(n,a,i){a.updateQueue=n.updateQueue,a.flags&=-2053,n.lanes&=~i}function Ud(n){if(Ul){for(n=n.memoizedState;n!==null;){var a=n.queue;a!==null&&(a.pending=null),n=n.next}Ul=!1}gs=0,jt=tt=Pe=null,Tr=!1,Gi=Bl=0,Er=null}function Wt(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return jt===null?Pe.memoizedState=jt=n:jt=jt.next=n,jt}function wt(){if(tt===null){var n=Pe.alternate;n=n!==null?n.memoizedState:null}else n=tt.next;var a=jt===null?Pe.memoizedState:jt.next;if(a!==null)jt=a,tt=n;else{if(n===null)throw Pe.alternate===null?Error(r(467)):Error(r(310));tt=n,n={memoizedState:tt.memoizedState,baseState:tt.baseState,baseQueue:tt.baseQueue,queue:tt.queue,next:null},jt===null?Pe.memoizedState=jt=n:jt=jt.next=n}return jt}function Vl(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Fi(n){var a=Gi;return Gi+=1,Er===null&&(Er=[]),n=zg(Er,n,a),a=Pe,(jt===null?a.memoizedState:jt.next)===null&&(a=a.alternate,$.H=a===null||a.memoizedState===null?Ey:Wd),n}function Il(n){if(n!==null&&typeof n=="object"){if(typeof n.then=="function")return Fi(n);if(n.$$typeof===C)return It(n)}throw Error(r(438,String(n)))}function Bd(n){var a=null,i=Pe.updateQueue;if(i!==null&&(a=i.memoCache),a==null){var c=Pe.alternate;c!==null&&(c=c.updateQueue,c!==null&&(c=c.memoCache,c!=null&&(a={data:c.data.map(function(f){return f.slice()}),index:0})))}if(a==null&&(a={data:[],index:0}),i===null&&(i=Vl(),Pe.updateQueue=i),i.memoCache=a,i=a.data[a.index],i===void 0)for(i=a.data[a.index]=Array(n),c=0;c<n;c++)i[c]=Z;return a.index++,i}function ys(n,a){return typeof a=="function"?a(n):a}function $l(n){var a=wt();return Vd(a,tt,n)}function Vd(n,a,i){var c=n.queue;if(c===null)throw Error(r(311));c.lastRenderedReducer=i;var f=n.baseQueue,p=c.pending;if(p!==null){if(f!==null){var b=f.next;f.next=p.next,p.next=b}a.baseQueue=f=p,c.pending=null}if(p=n.baseState,f===null)n.memoizedState=p;else{a=f.next;var T=b=null,O=null,G=a,X=!1;do{var ee=G.lane&-536870913;if(ee!==G.lane?(He&ee)===ee:(gs&ee)===ee){var F=G.revertLane;if(F===0)O!==null&&(O=O.next={lane:0,revertLane:0,gesture:null,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null}),ee===wr&&(X=!0);else if((gs&F)===F){G=G.next,F===wr&&(X=!0);continue}else ee={lane:0,revertLane:G.revertLane,gesture:null,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null},O===null?(T=O=ee,b=p):O=O.next=ee,Pe.lanes|=F,Ks|=F;ee=G.action,Ma&&i(p,ee),p=G.hasEagerState?G.eagerState:i(p,ee)}else F={lane:ee,revertLane:G.revertLane,gesture:G.gesture,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null},O===null?(T=O=F,b=p):O=O.next=F,Pe.lanes|=ee,Ks|=ee;G=G.next}while(G!==null&&G!==a);if(O===null?b=p:O.next=T,!hn(p,n.memoizedState)&&(_t=!0,X&&(i=Sr,i!==null)))throw i;n.memoizedState=p,n.baseState=b,n.baseQueue=O,c.lastRenderedState=p}return f===null&&(c.lanes=0),[n.memoizedState,c.dispatch]}function Id(n){var a=wt(),i=a.queue;if(i===null)throw Error(r(311));i.lastRenderedReducer=n;var c=i.dispatch,f=i.pending,p=a.memoizedState;if(f!==null){i.pending=null;var b=f=f.next;do p=n(p,b.action),b=b.next;while(b!==f);hn(p,a.memoizedState)||(_t=!0),a.memoizedState=p,a.baseQueue===null&&(a.baseState=p),i.lastRenderedState=p}return[p,c]}function Kg(n,a,i){var c=Pe,f=wt(),p=Ke;if(p){if(i===void 0)throw Error(r(407));i=i()}else i=a();var b=!hn((tt||f).memoizedState,i);if(b&&(f.memoizedState=i,_t=!0),f=f.queue,Hd(Wg.bind(null,c,f,n),[n]),f.getSnapshot!==a||b||jt!==null&&jt.memoizedState.tag&1){if(c.flags|=2048,kr(9,{destroy:void 0},Xg.bind(null,c,f,i,a),null),rt===null)throw Error(r(349));p||(gs&127)!==0||Yg(c,a,i)}return i}function Yg(n,a,i){n.flags|=16384,n={getSnapshot:a,value:i},a=Pe.updateQueue,a===null?(a=Vl(),Pe.updateQueue=a,a.stores=[n]):(i=a.stores,i===null?a.stores=[n]:i.push(n))}function Xg(n,a,i,c){a.value=i,a.getSnapshot=c,Jg(a)&&Qg(n)}function Wg(n,a,i){return i(function(){Jg(a)&&Qg(n)})}function Jg(n){var a=n.getSnapshot;n=n.value;try{var i=a();return!hn(n,i)}catch{return!0}}function Qg(n){var a=_a(n,2);a!==null&&ln(a,n,2)}function $d(n){var a=Wt();if(typeof n=="function"){var i=n;if(n=i(),Ma){Wn(!0);try{i()}finally{Wn(!1)}}}return a.memoizedState=a.baseState=n,a.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ys,lastRenderedState:n},a}function Zg(n,a,i,c){return n.baseState=i,Vd(n,tt,typeof c=="function"?c:ys)}function B_(n,a,i,c,f){if(Gl(n))throw Error(r(485));if(n=a.action,n!==null){var p={payload:f,action:n,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(b){p.listeners.push(b)}};$.T!==null?i(!0):p.isTransition=!1,c(p),i=a.pending,i===null?(p.next=a.pending=p,ey(a,p)):(p.next=i.next,a.pending=i.next=p)}}function ey(n,a){var i=a.action,c=a.payload,f=n.state;if(a.isTransition){var p=$.T,b={};$.T=b;try{var T=i(f,c),O=$.S;O!==null&&O(b,T),ty(n,a,T)}catch(G){qd(n,a,G)}finally{p!==null&&b.types!==null&&(p.types=b.types),$.T=p}}else try{p=i(f,c),ty(n,a,p)}catch(G){qd(n,a,G)}}function ty(n,a,i){i!==null&&typeof i=="object"&&typeof i.then=="function"?i.then(function(c){ny(n,a,c)},function(c){return qd(n,a,c)}):ny(n,a,i)}function ny(n,a,i){a.status="fulfilled",a.value=i,sy(a),n.state=i,a=n.pending,a!==null&&(i=a.next,i===a?n.pending=null:(i=i.next,a.next=i,ey(n,i)))}function qd(n,a,i){var c=n.pending;if(n.pending=null,c!==null){c=c.next;do a.status="rejected",a.reason=i,sy(a),a=a.next;while(a!==c)}n.action=null}function sy(n){n=n.listeners;for(var a=0;a<n.length;a++)(0,n[a])()}function ay(n,a){return a}function ry(n,a){if(Ke){var i=rt.formState;if(i!==null){e:{var c=Pe;if(Ke){if(ct){t:{for(var f=ct,p=Rn;f.nodeType!==8;){if(!p){f=null;break t}if(f=Mn(f.nextSibling),f===null){f=null;break t}}p=f.data,f=p==="F!"||p==="F"?f:null}if(f){ct=Mn(f.nextSibling),c=f.data==="F!";break e}}Us(c)}c=!1}c&&(a=i[0])}}return i=Wt(),i.memoizedState=i.baseState=a,c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ay,lastRenderedState:a},i.queue=c,i=_y.bind(null,Pe,c),c.dispatch=i,c=$d(!1),p=Xd.bind(null,Pe,!1,c.queue),c=Wt(),f={state:a,dispatch:null,action:n,pending:null},c.queue=f,i=B_.bind(null,Pe,f,p,i),f.dispatch=i,c.memoizedState=n,[a,i,!1]}function iy(n){var a=wt();return oy(a,tt,n)}function oy(n,a,i){if(a=Vd(n,a,ay)[0],n=$l(ys)[0],typeof a=="object"&&a!==null&&typeof a.then=="function")try{var c=Fi(a)}catch(b){throw b===jr?Ol:b}else c=a;a=wt();var f=a.queue,p=f.dispatch;return i!==a.memoizedState&&(Pe.flags|=2048,kr(9,{destroy:void 0},V_.bind(null,f,i),null)),[c,p,n]}function V_(n,a){n.action=a}function ly(n){var a=wt(),i=tt;if(i!==null)return oy(a,i,n);wt(),a=a.memoizedState,i=wt();var c=i.queue.dispatch;return i.memoizedState=n,[a,c,!1]}function kr(n,a,i,c){return n={tag:n,create:i,deps:c,inst:a,next:null},a=Pe.updateQueue,a===null&&(a=Vl(),Pe.updateQueue=a),i=a.lastEffect,i===null?a.lastEffect=n.next=n:(c=i.next,i.next=n,n.next=c,a.lastEffect=n),n}function cy(){return wt().memoizedState}function ql(n,a,i,c){var f=Wt();Pe.flags|=n,f.memoizedState=kr(1|a,{destroy:void 0},i,c===void 0?null:c)}function Hl(n,a,i,c){var f=wt();c=c===void 0?null:c;var p=f.memoizedState.inst;tt!==null&&c!==null&&Dd(c,tt.memoizedState.deps)?f.memoizedState=kr(a,p,i,c):(Pe.flags|=n,f.memoizedState=kr(1|a,p,i,c))}function uy(n,a){ql(8390656,8,n,a)}function Hd(n,a){Hl(2048,8,n,a)}function I_(n){Pe.flags|=4;var a=Pe.updateQueue;if(a===null)a=Vl(),Pe.updateQueue=a,a.events=[n];else{var i=a.events;i===null?a.events=[n]:i.push(n)}}function dy(n){var a=wt().memoizedState;return I_({ref:a,nextImpl:n}),function(){if((We&2)!==0)throw Error(r(440));return a.impl.apply(void 0,arguments)}}function hy(n,a){return Hl(4,2,n,a)}function fy(n,a){return Hl(4,4,n,a)}function my(n,a){if(typeof a=="function"){n=n();var i=a(n);return function(){typeof i=="function"?i():a(null)}}if(a!=null)return n=n(),a.current=n,function(){a.current=null}}function py(n,a,i){i=i!=null?i.concat([n]):null,Hl(4,4,my.bind(null,a,n),i)}function Gd(){}function gy(n,a){var i=wt();a=a===void 0?null:a;var c=i.memoizedState;return a!==null&&Dd(a,c[1])?c[0]:(i.memoizedState=[n,a],n)}function yy(n,a){var i=wt();a=a===void 0?null:a;var c=i.memoizedState;if(a!==null&&Dd(a,c[1]))return c[0];if(c=n(),Ma){Wn(!0);try{n()}finally{Wn(!1)}}return i.memoizedState=[c,a],c}function Fd(n,a,i){return i===void 0||(gs&1073741824)!==0&&(He&261930)===0?n.memoizedState=a:(n.memoizedState=i,n=vv(),Pe.lanes|=n,Ks|=n,i)}function vy(n,a,i,c){return hn(i,a)?i:Nr.current!==null?(n=Fd(n,i,c),hn(n,a)||(_t=!0),n):(gs&42)===0||(gs&1073741824)!==0&&(He&261930)===0?(_t=!0,n.memoizedState=i):(n=vv(),Pe.lanes|=n,Ks|=n,a)}function xy(n,a,i,c,f){var p=Y.p;Y.p=p!==0&&8>p?p:8;var b=$.T,T={};$.T=T,Xd(n,!1,a,i);try{var O=f(),G=$.S;if(G!==null&&G(T,O),O!==null&&typeof O=="object"&&typeof O.then=="function"){var X=z_(O,c);Ki(n,a,X,vn(n))}else Ki(n,a,c,vn(n))}catch(ee){Ki(n,a,{then:function(){},status:"rejected",reason:ee},vn())}finally{Y.p=p,b!==null&&T.types!==null&&(b.types=T.types),$.T=b}}function $_(){}function Kd(n,a,i,c){if(n.tag!==5)throw Error(r(476));var f=by(n).queue;xy(n,f,a,J,i===null?$_:function(){return wy(n),i(c)})}function by(n){var a=n.memoizedState;if(a!==null)return a;a={memoizedState:J,baseState:J,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ys,lastRenderedState:J},next:null};var i={};return a.next={memoizedState:i,baseState:i,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ys,lastRenderedState:i},next:null},n.memoizedState=a,n=n.alternate,n!==null&&(n.memoizedState=a),a}function wy(n){var a=by(n);a.next===null&&(a=n.alternate.memoizedState),Ki(n,a.next.queue,{},vn())}function Yd(){return It(uo)}function Sy(){return wt().memoizedState}function jy(){return wt().memoizedState}function q_(n){for(var a=n.return;a!==null;){switch(a.tag){case 24:case 3:var i=vn();n=Is(i);var c=$s(a,n,i);c!==null&&(ln(c,a,i),$i(c,a,i)),a={cache:jd()},n.payload=a;return}a=a.return}}function H_(n,a,i){var c=vn();i={lane:c,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Gl(n)?Ny(a,i):(i=hd(n,a,i,c),i!==null&&(ln(i,n,c),Ty(i,a,c)))}function _y(n,a,i){var c=vn();Ki(n,a,i,c)}function Ki(n,a,i,c){var f={lane:c,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null};if(Gl(n))Ny(a,f);else{var p=n.alternate;if(n.lanes===0&&(p===null||p.lanes===0)&&(p=a.lastRenderedReducer,p!==null))try{var b=a.lastRenderedState,T=p(b,i);if(f.hasEagerState=!0,f.eagerState=T,hn(T,b))return Nl(n,a,f,0),rt===null&&_l(),!1}catch{}if(i=hd(n,a,f,c),i!==null)return ln(i,n,c),Ty(i,a,c),!0}return!1}function Xd(n,a,i,c){if(c={lane:2,revertLane:Eh(),gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},Gl(n)){if(a)throw Error(r(479))}else a=hd(n,i,c,2),a!==null&&ln(a,n,2)}function Gl(n){var a=n.alternate;return n===Pe||a!==null&&a===Pe}function Ny(n,a){Tr=Ul=!0;var i=n.pending;i===null?a.next=a:(a.next=i.next,i.next=a),n.pending=a}function Ty(n,a,i){if((i&4194048)!==0){var c=a.lanes;c&=n.pendingLanes,i|=c,a.lanes=i,Rp(n,i)}}var Yi={readContext:It,use:Il,useCallback:pt,useContext:pt,useEffect:pt,useImperativeHandle:pt,useLayoutEffect:pt,useInsertionEffect:pt,useMemo:pt,useReducer:pt,useRef:pt,useState:pt,useDebugValue:pt,useDeferredValue:pt,useTransition:pt,useSyncExternalStore:pt,useId:pt,useHostTransitionStatus:pt,useFormState:pt,useActionState:pt,useOptimistic:pt,useMemoCache:pt,useCacheRefresh:pt};Yi.useEffectEvent=pt;var Ey={readContext:It,use:Il,useCallback:function(n,a){return Wt().memoizedState=[n,a===void 0?null:a],n},useContext:It,useEffect:uy,useImperativeHandle:function(n,a,i){i=i!=null?i.concat([n]):null,ql(4194308,4,my.bind(null,a,n),i)},useLayoutEffect:function(n,a){return ql(4194308,4,n,a)},useInsertionEffect:function(n,a){ql(4,2,n,a)},useMemo:function(n,a){var i=Wt();a=a===void 0?null:a;var c=n();if(Ma){Wn(!0);try{n()}finally{Wn(!1)}}return i.memoizedState=[c,a],c},useReducer:function(n,a,i){var c=Wt();if(i!==void 0){var f=i(a);if(Ma){Wn(!0);try{i(a)}finally{Wn(!1)}}}else f=a;return c.memoizedState=c.baseState=f,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:f},c.queue=n,n=n.dispatch=H_.bind(null,Pe,n),[c.memoizedState,n]},useRef:function(n){var a=Wt();return n={current:n},a.memoizedState=n},useState:function(n){n=$d(n);var a=n.queue,i=_y.bind(null,Pe,a);return a.dispatch=i,[n.memoizedState,i]},useDebugValue:Gd,useDeferredValue:function(n,a){var i=Wt();return Fd(i,n,a)},useTransition:function(){var n=$d(!1);return n=xy.bind(null,Pe,n.queue,!0,!1),Wt().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,a,i){var c=Pe,f=Wt();if(Ke){if(i===void 0)throw Error(r(407));i=i()}else{if(i=a(),rt===null)throw Error(r(349));(He&127)!==0||Yg(c,a,i)}f.memoizedState=i;var p={value:i,getSnapshot:a};return f.queue=p,uy(Wg.bind(null,c,p,n),[n]),c.flags|=2048,kr(9,{destroy:void 0},Xg.bind(null,c,p,i,a),null),i},useId:function(){var n=Wt(),a=rt.identifierPrefix;if(Ke){var i=Qn,c=Jn;i=(c&~(1<<32-dn(c)-1)).toString(32)+i,a="_"+a+"R_"+i,i=Bl++,0<i&&(a+="H"+i.toString(32)),a+="_"}else i=L_++,a="_"+a+"r_"+i.toString(32)+"_";return n.memoizedState=a},useHostTransitionStatus:Yd,useFormState:ry,useActionState:ry,useOptimistic:function(n){var a=Wt();a.memoizedState=a.baseState=n;var i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return a.queue=i,a=Xd.bind(null,Pe,!0,i),i.dispatch=a,[n,a]},useMemoCache:Bd,useCacheRefresh:function(){return Wt().memoizedState=q_.bind(null,Pe)},useEffectEvent:function(n){var a=Wt(),i={impl:n};return a.memoizedState=i,function(){if((We&2)!==0)throw Error(r(440));return i.impl.apply(void 0,arguments)}}},Wd={readContext:It,use:Il,useCallback:gy,useContext:It,useEffect:Hd,useImperativeHandle:py,useInsertionEffect:hy,useLayoutEffect:fy,useMemo:yy,useReducer:$l,useRef:cy,useState:function(){return $l(ys)},useDebugValue:Gd,useDeferredValue:function(n,a){var i=wt();return vy(i,tt.memoizedState,n,a)},useTransition:function(){var n=$l(ys)[0],a=wt().memoizedState;return[typeof n=="boolean"?n:Fi(n),a]},useSyncExternalStore:Kg,useId:Sy,useHostTransitionStatus:Yd,useFormState:iy,useActionState:iy,useOptimistic:function(n,a){var i=wt();return Zg(i,tt,n,a)},useMemoCache:Bd,useCacheRefresh:jy};Wd.useEffectEvent=dy;var ky={readContext:It,use:Il,useCallback:gy,useContext:It,useEffect:Hd,useImperativeHandle:py,useInsertionEffect:hy,useLayoutEffect:fy,useMemo:yy,useReducer:Id,useRef:cy,useState:function(){return Id(ys)},useDebugValue:Gd,useDeferredValue:function(n,a){var i=wt();return tt===null?Fd(i,n,a):vy(i,tt.memoizedState,n,a)},useTransition:function(){var n=Id(ys)[0],a=wt().memoizedState;return[typeof n=="boolean"?n:Fi(n),a]},useSyncExternalStore:Kg,useId:Sy,useHostTransitionStatus:Yd,useFormState:ly,useActionState:ly,useOptimistic:function(n,a){var i=wt();return tt!==null?Zg(i,tt,n,a):(i.baseState=n,[n,i.queue.dispatch])},useMemoCache:Bd,useCacheRefresh:jy};ky.useEffectEvent=dy;function Jd(n,a,i,c){a=n.memoizedState,i=i(c,a),i=i==null?a:x({},a,i),n.memoizedState=i,n.lanes===0&&(n.updateQueue.baseState=i)}var Qd={enqueueSetState:function(n,a,i){n=n._reactInternals;var c=vn(),f=Is(c);f.payload=a,i!=null&&(f.callback=i),a=$s(n,f,c),a!==null&&(ln(a,n,c),$i(a,n,c))},enqueueReplaceState:function(n,a,i){n=n._reactInternals;var c=vn(),f=Is(c);f.tag=1,f.payload=a,i!=null&&(f.callback=i),a=$s(n,f,c),a!==null&&(ln(a,n,c),$i(a,n,c))},enqueueForceUpdate:function(n,a){n=n._reactInternals;var i=vn(),c=Is(i);c.tag=2,a!=null&&(c.callback=a),a=$s(n,c,i),a!==null&&(ln(a,n,i),$i(a,n,i))}};function Cy(n,a,i,c,f,p,b){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(c,p,b):a.prototype&&a.prototype.isPureReactComponent?!Di(i,c)||!Di(f,p):!0}function Ay(n,a,i,c){n=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(i,c),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(i,c),a.state!==n&&Qd.enqueueReplaceState(a,a.state,null)}function Da(n,a){var i=a;if("ref"in a){i={};for(var c in a)c!=="ref"&&(i[c]=a[c])}if(n=n.defaultProps){i===a&&(i=x({},i));for(var f in n)i[f]===void 0&&(i[f]=n[f])}return i}function Ry(n){jl(n)}function Oy(n){console.error(n)}function My(n){jl(n)}function Fl(n,a){try{var i=n.onUncaughtError;i(a.value,{componentStack:a.stack})}catch(c){setTimeout(function(){throw c})}}function Dy(n,a,i){try{var c=n.onCaughtError;c(i.value,{componentStack:i.stack,errorBoundary:a.tag===1?a.stateNode:null})}catch(f){setTimeout(function(){throw f})}}function Zd(n,a,i){return i=Is(i),i.tag=3,i.payload={element:null},i.callback=function(){Fl(n,a)},i}function Py(n){return n=Is(n),n.tag=3,n}function zy(n,a,i,c){var f=i.type.getDerivedStateFromError;if(typeof f=="function"){var p=c.value;n.payload=function(){return f(p)},n.callback=function(){Dy(a,i,c)}}var b=i.stateNode;b!==null&&typeof b.componentDidCatch=="function"&&(n.callback=function(){Dy(a,i,c),typeof f!="function"&&(Ys===null?Ys=new Set([this]):Ys.add(this));var T=c.stack;this.componentDidCatch(c.value,{componentStack:T!==null?T:""})})}function G_(n,a,i,c,f){if(i.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){if(a=i.alternate,a!==null&&br(a,i,f,!0),i=mn.current,i!==null){switch(i.tag){case 31:case 13:return On===null?ac():i.alternate===null&>===0&&(gt=3),i.flags&=-257,i.flags|=65536,i.lanes=f,c===Ml?i.flags|=16384:(a=i.updateQueue,a===null?i.updateQueue=new Set([c]):a.add(c),_h(n,c,f)),!1;case 22:return i.flags|=65536,c===Ml?i.flags|=16384:(a=i.updateQueue,a===null?(a={transitions:null,markerInstances:null,retryQueue:new Set([c])},i.updateQueue=a):(i=a.retryQueue,i===null?a.retryQueue=new Set([c]):i.add(c)),_h(n,c,f)),!1}throw Error(r(435,i.tag))}return _h(n,c,f),ac(),!1}if(Ke)return a=mn.current,a!==null?((a.flags&65536)===0&&(a.flags|=256),a.flags|=65536,a.lanes=f,c!==vd&&(n=Error(r(422),{cause:c}),Li(kn(n,i)))):(c!==vd&&(a=Error(r(423),{cause:c}),Li(kn(a,i))),n=n.current.alternate,n.flags|=65536,f&=-f,n.lanes|=f,c=kn(c,i),f=Zd(n.stateNode,c,f),Cd(n,f),gt!==4&&(gt=2)),!1;var p=Error(r(520),{cause:c});if(p=kn(p,i),no===null?no=[p]:no.push(p),gt!==4&&(gt=2),a===null)return!0;c=kn(c,i),i=a;do{switch(i.tag){case 3:return i.flags|=65536,n=f&-f,i.lanes|=n,n=Zd(i.stateNode,c,n),Cd(i,n),!1;case 1:if(a=i.type,p=i.stateNode,(i.flags&128)===0&&(typeof a.getDerivedStateFromError=="function"||p!==null&&typeof p.componentDidCatch=="function"&&(Ys===null||!Ys.has(p))))return i.flags|=65536,f&=-f,i.lanes|=f,f=Py(f),zy(f,n,i,c),Cd(i,f),!1}i=i.return}while(i!==null);return!1}var eh=Error(r(461)),_t=!1;function $t(n,a,i,c){a.child=n===null?Vg(a,null,i,c):Oa(a,n.child,i,c)}function Ly(n,a,i,c,f){i=i.render;var p=a.ref;if("ref"in c){var b={};for(var T in c)T!=="ref"&&(b[T]=c[T])}else b=c;return ka(a),c=Pd(n,a,i,b,p,f),T=zd(),n!==null&&!_t?(Ld(n,a,f),vs(n,a,f)):(Ke&&T&&gd(a),a.flags|=1,$t(n,a,c,f),a.child)}function Uy(n,a,i,c,f){if(n===null){var p=i.type;return typeof p=="function"&&!fd(p)&&p.defaultProps===void 0&&i.compare===null?(a.tag=15,a.type=p,By(n,a,p,c,f)):(n=El(i.type,null,c,a,a.mode,f),n.ref=a.ref,n.return=a,a.child=n)}if(p=n.child,!lh(n,f)){var b=p.memoizedProps;if(i=i.compare,i=i!==null?i:Di,i(b,c)&&n.ref===a.ref)return vs(n,a,f)}return a.flags|=1,n=hs(p,c),n.ref=a.ref,n.return=a,a.child=n}function By(n,a,i,c,f){if(n!==null){var p=n.memoizedProps;if(Di(p,c)&&n.ref===a.ref)if(_t=!1,a.pendingProps=c=p,lh(n,f))(n.flags&131072)!==0&&(_t=!0);else return a.lanes=n.lanes,vs(n,a,f)}return th(n,a,i,c,f)}function Vy(n,a,i,c){var f=c.children,p=n!==null?n.memoizedState:null;if(n===null&&a.stateNode===null&&(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),c.mode==="hidden"){if((a.flags&128)!==0){if(p=p!==null?p.baseLanes|i:i,n!==null){for(c=a.child=n.child,f=0;c!==null;)f=f|c.lanes|c.childLanes,c=c.sibling;c=f&~p}else c=0,a.child=null;return Iy(n,a,p,i,c)}if((i&536870912)!==0)a.memoizedState={baseLanes:0,cachePool:null},n!==null&&Rl(a,p!==null?p.cachePool:null),p!==null?qg(a,p):Rd(),Hg(a);else return c=a.lanes=536870912,Iy(n,a,p!==null?p.baseLanes|i:i,i,c)}else p!==null?(Rl(a,p.cachePool),qg(a,p),Hs(),a.memoizedState=null):(n!==null&&Rl(a,null),Rd(),Hs());return $t(n,a,f,i),a.child}function Xi(n,a){return n!==null&&n.tag===22||a.stateNode!==null||(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),a.sibling}function Iy(n,a,i,c,f){var p=Nd();return p=p===null?null:{parent:St._currentValue,pool:p},a.memoizedState={baseLanes:i,cachePool:p},n!==null&&Rl(a,null),Rd(),Hg(a),n!==null&&br(n,a,c,!0),a.childLanes=f,null}function Kl(n,a){return a=Xl({mode:a.mode,children:a.children},n.mode),a.ref=n.ref,n.child=a,a.return=n,a}function $y(n,a,i){return Oa(a,n.child,null,i),n=Kl(a,a.pendingProps),n.flags|=2,pn(a),a.memoizedState=null,n}function F_(n,a,i){var c=a.pendingProps,f=(a.flags&128)!==0;if(a.flags&=-129,n===null){if(Ke){if(c.mode==="hidden")return n=Kl(a,c),a.lanes=536870912,Xi(null,n);if(Md(a),(n=ct)?(n=ex(n,Rn),n=n!==null&&n.data==="&"?n:null,n!==null&&(a.memoizedState={dehydrated:n,treeContext:zs!==null?{id:Jn,overflow:Qn}:null,retryLane:536870912,hydrationErrors:null},i=Ng(n),i.return=a,a.child=i,Vt=a,ct=null)):n=null,n===null)throw Us(a);return a.lanes=536870912,null}return Kl(a,c)}var p=n.memoizedState;if(p!==null){var b=p.dehydrated;if(Md(a),f)if(a.flags&256)a.flags&=-257,a=$y(n,a,i);else if(a.memoizedState!==null)a.child=n.child,a.flags|=128,a=null;else throw Error(r(558));else if(_t||br(n,a,i,!1),f=(i&n.childLanes)!==0,_t||f){if(c=rt,c!==null&&(b=Op(c,i),b!==0&&b!==p.retryLane))throw p.retryLane=b,_a(n,b),ln(c,n,b),eh;ac(),a=$y(n,a,i)}else n=p.treeContext,ct=Mn(b.nextSibling),Vt=a,Ke=!0,Ls=null,Rn=!1,n!==null&&kg(a,n),a=Kl(a,c),a.flags|=4096;return a}return n=hs(n.child,{mode:c.mode,children:c.children}),n.ref=a.ref,a.child=n,n.return=a,n}function Yl(n,a){var i=a.ref;if(i===null)n!==null&&n.ref!==null&&(a.flags|=4194816);else{if(typeof i!="function"&&typeof i!="object")throw Error(r(284));(n===null||n.ref!==i)&&(a.flags|=4194816)}}function th(n,a,i,c,f){return ka(a),i=Pd(n,a,i,c,void 0,f),c=zd(),n!==null&&!_t?(Ld(n,a,f),vs(n,a,f)):(Ke&&c&&gd(a),a.flags|=1,$t(n,a,i,f),a.child)}function qy(n,a,i,c,f,p){return ka(a),a.updateQueue=null,i=Fg(a,c,i,f),Gg(n),c=zd(),n!==null&&!_t?(Ld(n,a,p),vs(n,a,p)):(Ke&&c&&gd(a),a.flags|=1,$t(n,a,i,p),a.child)}function Hy(n,a,i,c,f){if(ka(a),a.stateNode===null){var p=gr,b=i.contextType;typeof b=="object"&&b!==null&&(p=It(b)),p=new i(c,p),a.memoizedState=p.state!==null&&p.state!==void 0?p.state:null,p.updater=Qd,a.stateNode=p,p._reactInternals=a,p=a.stateNode,p.props=c,p.state=a.memoizedState,p.refs={},Ed(a),b=i.contextType,p.context=typeof b=="object"&&b!==null?It(b):gr,p.state=a.memoizedState,b=i.getDerivedStateFromProps,typeof b=="function"&&(Jd(a,i,b,c),p.state=a.memoizedState),typeof i.getDerivedStateFromProps=="function"||typeof p.getSnapshotBeforeUpdate=="function"||typeof p.UNSAFE_componentWillMount!="function"&&typeof p.componentWillMount!="function"||(b=p.state,typeof p.componentWillMount=="function"&&p.componentWillMount(),typeof p.UNSAFE_componentWillMount=="function"&&p.UNSAFE_componentWillMount(),b!==p.state&&Qd.enqueueReplaceState(p,p.state,null),Hi(a,c,p,f),qi(),p.state=a.memoizedState),typeof p.componentDidMount=="function"&&(a.flags|=4194308),c=!0}else if(n===null){p=a.stateNode;var T=a.memoizedProps,O=Da(i,T);p.props=O;var G=p.context,X=i.contextType;b=gr,typeof X=="object"&&X!==null&&(b=It(X));var ee=i.getDerivedStateFromProps;X=typeof ee=="function"||typeof p.getSnapshotBeforeUpdate=="function",T=a.pendingProps!==T,X||typeof p.UNSAFE_componentWillReceiveProps!="function"&&typeof p.componentWillReceiveProps!="function"||(T||G!==b)&&Ay(a,p,c,b),Vs=!1;var F=a.memoizedState;p.state=F,Hi(a,c,p,f),qi(),G=a.memoizedState,T||F!==G||Vs?(typeof ee=="function"&&(Jd(a,i,ee,c),G=a.memoizedState),(O=Vs||Cy(a,i,O,c,F,G,b))?(X||typeof p.UNSAFE_componentWillMount!="function"&&typeof p.componentWillMount!="function"||(typeof p.componentWillMount=="function"&&p.componentWillMount(),typeof p.UNSAFE_componentWillMount=="function"&&p.UNSAFE_componentWillMount()),typeof p.componentDidMount=="function"&&(a.flags|=4194308)):(typeof p.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=c,a.memoizedState=G),p.props=c,p.state=G,p.context=b,c=O):(typeof p.componentDidMount=="function"&&(a.flags|=4194308),c=!1)}else{p=a.stateNode,kd(n,a),b=a.memoizedProps,X=Da(i,b),p.props=X,ee=a.pendingProps,F=p.context,G=i.contextType,O=gr,typeof G=="object"&&G!==null&&(O=It(G)),T=i.getDerivedStateFromProps,(G=typeof T=="function"||typeof p.getSnapshotBeforeUpdate=="function")||typeof p.UNSAFE_componentWillReceiveProps!="function"&&typeof p.componentWillReceiveProps!="function"||(b!==ee||F!==O)&&Ay(a,p,c,O),Vs=!1,F=a.memoizedState,p.state=F,Hi(a,c,p,f),qi();var K=a.memoizedState;b!==ee||F!==K||Vs||n!==null&&n.dependencies!==null&&Cl(n.dependencies)?(typeof T=="function"&&(Jd(a,i,T,c),K=a.memoizedState),(X=Vs||Cy(a,i,X,c,F,K,O)||n!==null&&n.dependencies!==null&&Cl(n.dependencies))?(G||typeof p.UNSAFE_componentWillUpdate!="function"&&typeof p.componentWillUpdate!="function"||(typeof p.componentWillUpdate=="function"&&p.componentWillUpdate(c,K,O),typeof p.UNSAFE_componentWillUpdate=="function"&&p.UNSAFE_componentWillUpdate(c,K,O)),typeof p.componentDidUpdate=="function"&&(a.flags|=4),typeof p.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof p.componentDidUpdate!="function"||b===n.memoizedProps&&F===n.memoizedState||(a.flags|=4),typeof p.getSnapshotBeforeUpdate!="function"||b===n.memoizedProps&&F===n.memoizedState||(a.flags|=1024),a.memoizedProps=c,a.memoizedState=K),p.props=c,p.state=K,p.context=O,c=X):(typeof p.componentDidUpdate!="function"||b===n.memoizedProps&&F===n.memoizedState||(a.flags|=4),typeof p.getSnapshotBeforeUpdate!="function"||b===n.memoizedProps&&F===n.memoizedState||(a.flags|=1024),c=!1)}return p=c,Yl(n,a),c=(a.flags&128)!==0,p||c?(p=a.stateNode,i=c&&typeof i.getDerivedStateFromError!="function"?null:p.render(),a.flags|=1,n!==null&&c?(a.child=Oa(a,n.child,null,f),a.child=Oa(a,null,i,f)):$t(n,a,i,f),a.memoizedState=p.state,n=a.child):n=vs(n,a,f),n}function Gy(n,a,i,c){return Ta(),a.flags|=256,$t(n,a,i,c),a.child}var nh={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function sh(n){return{baseLanes:n,cachePool:Dg()}}function ah(n,a,i){return n=n!==null?n.childLanes&~i:0,a&&(n|=yn),n}function Fy(n,a,i){var c=a.pendingProps,f=!1,p=(a.flags&128)!==0,b;if((b=p)||(b=n!==null&&n.memoizedState===null?!1:(bt.current&2)!==0),b&&(f=!0,a.flags&=-129),b=(a.flags&32)!==0,a.flags&=-33,n===null){if(Ke){if(f?qs(a):Hs(),(n=ct)?(n=ex(n,Rn),n=n!==null&&n.data!=="&"?n:null,n!==null&&(a.memoizedState={dehydrated:n,treeContext:zs!==null?{id:Jn,overflow:Qn}:null,retryLane:536870912,hydrationErrors:null},i=Ng(n),i.return=a,a.child=i,Vt=a,ct=null)):n=null,n===null)throw Us(a);return Vh(n)?a.lanes=32:a.lanes=536870912,null}var T=c.children;return c=c.fallback,f?(Hs(),f=a.mode,T=Xl({mode:"hidden",children:T},f),c=Na(c,f,i,null),T.return=a,c.return=a,T.sibling=c,a.child=T,c=a.child,c.memoizedState=sh(i),c.childLanes=ah(n,b,i),a.memoizedState=nh,Xi(null,c)):(qs(a),rh(a,T))}var O=n.memoizedState;if(O!==null&&(T=O.dehydrated,T!==null)){if(p)a.flags&256?(qs(a),a.flags&=-257,a=ih(n,a,i)):a.memoizedState!==null?(Hs(),a.child=n.child,a.flags|=128,a=null):(Hs(),T=c.fallback,f=a.mode,c=Xl({mode:"visible",children:c.children},f),T=Na(T,f,i,null),T.flags|=2,c.return=a,T.return=a,c.sibling=T,a.child=c,Oa(a,n.child,null,i),c=a.child,c.memoizedState=sh(i),c.childLanes=ah(n,b,i),a.memoizedState=nh,a=Xi(null,c));else if(qs(a),Vh(T)){if(b=T.nextSibling&&T.nextSibling.dataset,b)var G=b.dgst;b=G,c=Error(r(419)),c.stack="",c.digest=b,Li({value:c,source:null,stack:null}),a=ih(n,a,i)}else if(_t||br(n,a,i,!1),b=(i&n.childLanes)!==0,_t||b){if(b=rt,b!==null&&(c=Op(b,i),c!==0&&c!==O.retryLane))throw O.retryLane=c,_a(n,c),ln(b,n,c),eh;Bh(T)||ac(),a=ih(n,a,i)}else Bh(T)?(a.flags|=192,a.child=n.child,a=null):(n=O.treeContext,ct=Mn(T.nextSibling),Vt=a,Ke=!0,Ls=null,Rn=!1,n!==null&&kg(a,n),a=rh(a,c.children),a.flags|=4096);return a}return f?(Hs(),T=c.fallback,f=a.mode,O=n.child,G=O.sibling,c=hs(O,{mode:"hidden",children:c.children}),c.subtreeFlags=O.subtreeFlags&65011712,G!==null?T=hs(G,T):(T=Na(T,f,i,null),T.flags|=2),T.return=a,c.return=a,c.sibling=T,a.child=c,Xi(null,c),c=a.child,T=n.child.memoizedState,T===null?T=sh(i):(f=T.cachePool,f!==null?(O=St._currentValue,f=f.parent!==O?{parent:O,pool:O}:f):f=Dg(),T={baseLanes:T.baseLanes|i,cachePool:f}),c.memoizedState=T,c.childLanes=ah(n,b,i),a.memoizedState=nh,Xi(n.child,c)):(qs(a),i=n.child,n=i.sibling,i=hs(i,{mode:"visible",children:c.children}),i.return=a,i.sibling=null,n!==null&&(b=a.deletions,b===null?(a.deletions=[n],a.flags|=16):b.push(n)),a.child=i,a.memoizedState=null,i)}function rh(n,a){return a=Xl({mode:"visible",children:a},n.mode),a.return=n,n.child=a}function Xl(n,a){return n=fn(22,n,null,a),n.lanes=0,n}function ih(n,a,i){return Oa(a,n.child,null,i),n=rh(a,a.pendingProps.children),n.flags|=2,a.memoizedState=null,n}function Ky(n,a,i){n.lanes|=a;var c=n.alternate;c!==null&&(c.lanes|=a),wd(n.return,a,i)}function oh(n,a,i,c,f,p){var b=n.memoizedState;b===null?n.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:c,tail:i,tailMode:f,treeForkCount:p}:(b.isBackwards=a,b.rendering=null,b.renderingStartTime=0,b.last=c,b.tail=i,b.tailMode=f,b.treeForkCount=p)}function Yy(n,a,i){var c=a.pendingProps,f=c.revealOrder,p=c.tail;c=c.children;var b=bt.current,T=(b&2)!==0;if(T?(b=b&1|2,a.flags|=128):b&=1,W(bt,b),$t(n,a,c,i),c=Ke?zi:0,!T&&n!==null&&(n.flags&128)!==0)e:for(n=a.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&Ky(n,i,a);else if(n.tag===19)Ky(n,i,a);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===a)break e;for(;n.sibling===null;){if(n.return===null||n.return===a)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}switch(f){case"forwards":for(i=a.child,f=null;i!==null;)n=i.alternate,n!==null&&Ll(n)===null&&(f=i),i=i.sibling;i=f,i===null?(f=a.child,a.child=null):(f=i.sibling,i.sibling=null),oh(a,!1,f,i,p,c);break;case"backwards":case"unstable_legacy-backwards":for(i=null,f=a.child,a.child=null;f!==null;){if(n=f.alternate,n!==null&&Ll(n)===null){a.child=f;break}n=f.sibling,f.sibling=i,i=f,f=n}oh(a,!0,i,null,p,c);break;case"together":oh(a,!1,null,null,void 0,c);break;default:a.memoizedState=null}return a.child}function vs(n,a,i){if(n!==null&&(a.dependencies=n.dependencies),Ks|=a.lanes,(i&a.childLanes)===0)if(n!==null){if(br(n,a,i,!1),(i&a.childLanes)===0)return null}else return null;if(n!==null&&a.child!==n.child)throw Error(r(153));if(a.child!==null){for(n=a.child,i=hs(n,n.pendingProps),a.child=i,i.return=a;n.sibling!==null;)n=n.sibling,i=i.sibling=hs(n,n.pendingProps),i.return=a;i.sibling=null}return a.child}function lh(n,a){return(n.lanes&a)!==0?!0:(n=n.dependencies,!!(n!==null&&Cl(n)))}function K_(n,a,i){switch(a.tag){case 3:fe(a,a.stateNode.containerInfo),Bs(a,St,n.memoizedState.cache),Ta();break;case 27:case 5:ze(a);break;case 4:fe(a,a.stateNode.containerInfo);break;case 10:Bs(a,a.type,a.memoizedProps.value);break;case 31:if(a.memoizedState!==null)return a.flags|=128,Md(a),null;break;case 13:var c=a.memoizedState;if(c!==null)return c.dehydrated!==null?(qs(a),a.flags|=128,null):(i&a.child.childLanes)!==0?Fy(n,a,i):(qs(a),n=vs(n,a,i),n!==null?n.sibling:null);qs(a);break;case 19:var f=(n.flags&128)!==0;if(c=(i&a.childLanes)!==0,c||(br(n,a,i,!1),c=(i&a.childLanes)!==0),f){if(c)return Yy(n,a,i);a.flags|=128}if(f=a.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),W(bt,bt.current),c)break;return null;case 22:return a.lanes=0,Vy(n,a,i,a.pendingProps);case 24:Bs(a,St,n.memoizedState.cache)}return vs(n,a,i)}function Xy(n,a,i){if(n!==null)if(n.memoizedProps!==a.pendingProps)_t=!0;else{if(!lh(n,i)&&(a.flags&128)===0)return _t=!1,K_(n,a,i);_t=(n.flags&131072)!==0}else _t=!1,Ke&&(a.flags&1048576)!==0&&Eg(a,zi,a.index);switch(a.lanes=0,a.tag){case 16:e:{var c=a.pendingProps;if(n=Aa(a.elementType),a.type=n,typeof n=="function")fd(n)?(c=Da(n,c),a.tag=1,a=Hy(null,a,n,c,i)):(a.tag=0,a=th(null,a,n,c,i));else{if(n!=null){var f=n.$$typeof;if(f===A){a.tag=11,a=Ly(null,a,n,c,i);break e}else if(f===V){a.tag=14,a=Uy(null,a,n,c,i);break e}}throw a=ye(n)||n,Error(r(306,a,""))}}return a;case 0:return th(n,a,a.type,a.pendingProps,i);case 1:return c=a.type,f=Da(c,a.pendingProps),Hy(n,a,c,f,i);case 3:e:{if(fe(a,a.stateNode.containerInfo),n===null)throw Error(r(387));c=a.pendingProps;var p=a.memoizedState;f=p.element,kd(n,a),Hi(a,c,null,i);var b=a.memoizedState;if(c=b.cache,Bs(a,St,c),c!==p.cache&&Sd(a,[St],i,!0),qi(),c=b.element,p.isDehydrated)if(p={element:c,isDehydrated:!1,cache:b.cache},a.updateQueue.baseState=p,a.memoizedState=p,a.flags&256){a=Gy(n,a,c,i);break e}else if(c!==f){f=kn(Error(r(424)),a),Li(f),a=Gy(n,a,c,i);break e}else for(n=a.stateNode.containerInfo,n.nodeType===9?n=n.body:n=n.nodeName==="HTML"?n.ownerDocument.body:n,ct=Mn(n.firstChild),Vt=a,Ke=!0,Ls=null,Rn=!0,i=Vg(a,null,c,i),a.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Ta(),c===f){a=vs(n,a,i);break e}$t(n,a,c,i)}a=a.child}return a;case 26:return Yl(n,a),n===null?(i=ix(a.type,null,a.pendingProps,null))?a.memoizedState=i:Ke||(i=a.type,n=a.pendingProps,c=dc(ue.current).createElement(i),c[Bt]=a,c[tn]=n,qt(c,i,n),Mt(c),a.stateNode=c):a.memoizedState=ix(a.type,n.memoizedProps,a.pendingProps,n.memoizedState),null;case 27:return ze(a),n===null&&Ke&&(c=a.stateNode=sx(a.type,a.pendingProps,ue.current),Vt=a,Rn=!0,f=ct,Qs(a.type)?(Ih=f,ct=Mn(c.firstChild)):ct=f),$t(n,a,a.pendingProps.children,i),Yl(n,a),n===null&&(a.flags|=4194304),a.child;case 5:return n===null&&Ke&&((f=c=ct)&&(c=jN(c,a.type,a.pendingProps,Rn),c!==null?(a.stateNode=c,Vt=a,ct=Mn(c.firstChild),Rn=!1,f=!0):f=!1),f||Us(a)),ze(a),f=a.type,p=a.pendingProps,b=n!==null?n.memoizedProps:null,c=p.children,zh(f,p)?c=null:b!==null&&zh(f,b)&&(a.flags|=32),a.memoizedState!==null&&(f=Pd(n,a,U_,null,null,i),uo._currentValue=f),Yl(n,a),$t(n,a,c,i),a.child;case 6:return n===null&&Ke&&((n=i=ct)&&(i=_N(i,a.pendingProps,Rn),i!==null?(a.stateNode=i,Vt=a,ct=null,n=!0):n=!1),n||Us(a)),null;case 13:return Fy(n,a,i);case 4:return fe(a,a.stateNode.containerInfo),c=a.pendingProps,n===null?a.child=Oa(a,null,c,i):$t(n,a,c,i),a.child;case 11:return Ly(n,a,a.type,a.pendingProps,i);case 7:return $t(n,a,a.pendingProps,i),a.child;case 8:return $t(n,a,a.pendingProps.children,i),a.child;case 12:return $t(n,a,a.pendingProps.children,i),a.child;case 10:return c=a.pendingProps,Bs(a,a.type,c.value),$t(n,a,c.children,i),a.child;case 9:return f=a.type._context,c=a.pendingProps.children,ka(a),f=It(f),c=c(f),a.flags|=1,$t(n,a,c,i),a.child;case 14:return Uy(n,a,a.type,a.pendingProps,i);case 15:return By(n,a,a.type,a.pendingProps,i);case 19:return Yy(n,a,i);case 31:return F_(n,a,i);case 22:return Vy(n,a,i,a.pendingProps);case 24:return ka(a),c=It(St),n===null?(f=Nd(),f===null&&(f=rt,p=jd(),f.pooledCache=p,p.refCount++,p!==null&&(f.pooledCacheLanes|=i),f=p),a.memoizedState={parent:c,cache:f},Ed(a),Bs(a,St,f)):((n.lanes&i)!==0&&(kd(n,a),Hi(a,null,null,i),qi()),f=n.memoizedState,p=a.memoizedState,f.parent!==c?(f={parent:c,cache:c},a.memoizedState=f,a.lanes===0&&(a.memoizedState=a.updateQueue.baseState=f),Bs(a,St,c)):(c=p.cache,Bs(a,St,c),c!==f.cache&&Sd(a,[St],i,!0))),$t(n,a,a.pendingProps.children,i),a.child;case 29:throw a.pendingProps}throw Error(r(156,a.tag))}function xs(n){n.flags|=4}function ch(n,a,i,c,f){if((a=(n.mode&32)!==0)&&(a=!1),a){if(n.flags|=16777216,(f&335544128)===f)if(n.stateNode.complete)n.flags|=8192;else if(Sv())n.flags|=8192;else throw Ra=Ml,Td}else n.flags&=-16777217}function Wy(n,a){if(a.type!=="stylesheet"||(a.state.loading&4)!==0)n.flags&=-16777217;else if(n.flags|=16777216,!dx(a))if(Sv())n.flags|=8192;else throw Ra=Ml,Td}function Wl(n,a){a!==null&&(n.flags|=4),n.flags&16384&&(a=n.tag!==22?Cp():536870912,n.lanes|=a,Or|=a)}function Wi(n,a){if(!Ke)switch(n.tailMode){case"hidden":a=n.tail;for(var i=null;a!==null;)a.alternate!==null&&(i=a),a=a.sibling;i===null?n.tail=null:i.sibling=null;break;case"collapsed":i=n.tail;for(var c=null;i!==null;)i.alternate!==null&&(c=i),i=i.sibling;c===null?a||n.tail===null?n.tail=null:n.tail.sibling=null:c.sibling=null}}function ut(n){var a=n.alternate!==null&&n.alternate.child===n.child,i=0,c=0;if(a)for(var f=n.child;f!==null;)i|=f.lanes|f.childLanes,c|=f.subtreeFlags&65011712,c|=f.flags&65011712,f.return=n,f=f.sibling;else for(f=n.child;f!==null;)i|=f.lanes|f.childLanes,c|=f.subtreeFlags,c|=f.flags,f.return=n,f=f.sibling;return n.subtreeFlags|=c,n.childLanes=i,a}function Y_(n,a,i){var c=a.pendingProps;switch(yd(a),a.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ut(a),null;case 1:return ut(a),null;case 3:return i=a.stateNode,c=null,n!==null&&(c=n.memoizedState.cache),a.memoizedState.cache!==c&&(a.flags|=2048),ps(St),ie(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(n===null||n.child===null)&&(xr(a)?xs(a):n===null||n.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,xd())),ut(a),null;case 26:var f=a.type,p=a.memoizedState;return n===null?(xs(a),p!==null?(ut(a),Wy(a,p)):(ut(a),ch(a,f,null,c,i))):p?p!==n.memoizedState?(xs(a),ut(a),Wy(a,p)):(ut(a),a.flags&=-16777217):(n=n.memoizedProps,n!==c&&xs(a),ut(a),ch(a,f,n,c,i)),null;case 27:if(Be(a),i=ue.current,f=a.type,n!==null&&a.stateNode!=null)n.memoizedProps!==c&&xs(a);else{if(!c){if(a.stateNode===null)throw Error(r(166));return ut(a),null}n=ne.current,xr(a)?Cg(a):(n=sx(f,c,i),a.stateNode=n,xs(a))}return ut(a),null;case 5:if(Be(a),f=a.type,n!==null&&a.stateNode!=null)n.memoizedProps!==c&&xs(a);else{if(!c){if(a.stateNode===null)throw Error(r(166));return ut(a),null}if(p=ne.current,xr(a))Cg(a);else{var b=dc(ue.current);switch(p){case 1:p=b.createElementNS("http://www.w3.org/2000/svg",f);break;case 2:p=b.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;default:switch(f){case"svg":p=b.createElementNS("http://www.w3.org/2000/svg",f);break;case"math":p=b.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;case"script":p=b.createElement("div"),p.innerHTML="<script><\/script>",p=p.removeChild(p.firstChild);break;case"select":p=typeof c.is=="string"?b.createElement("select",{is:c.is}):b.createElement("select"),c.multiple?p.multiple=!0:c.size&&(p.size=c.size);break;default:p=typeof c.is=="string"?b.createElement(f,{is:c.is}):b.createElement(f)}}p[Bt]=a,p[tn]=c;e:for(b=a.child;b!==null;){if(b.tag===5||b.tag===6)p.appendChild(b.stateNode);else if(b.tag!==4&&b.tag!==27&&b.child!==null){b.child.return=b,b=b.child;continue}if(b===a)break e;for(;b.sibling===null;){if(b.return===null||b.return===a)break e;b=b.return}b.sibling.return=b.return,b=b.sibling}a.stateNode=p;e:switch(qt(p,f,c),f){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}c&&xs(a)}}return ut(a),ch(a,a.type,n===null?null:n.memoizedProps,a.pendingProps,i),null;case 6:if(n&&a.stateNode!=null)n.memoizedProps!==c&&xs(a);else{if(typeof c!="string"&&a.stateNode===null)throw Error(r(166));if(n=ue.current,xr(a)){if(n=a.stateNode,i=a.memoizedProps,c=null,f=Vt,f!==null)switch(f.tag){case 27:case 5:c=f.memoizedProps}n[Bt]=a,n=!!(n.nodeValue===i||c!==null&&c.suppressHydrationWarning===!0||Fv(n.nodeValue,i)),n||Us(a,!0)}else n=dc(n).createTextNode(c),n[Bt]=a,a.stateNode=n}return ut(a),null;case 31:if(i=a.memoizedState,n===null||n.memoizedState!==null){if(c=xr(a),i!==null){if(n===null){if(!c)throw Error(r(318));if(n=a.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(r(557));n[Bt]=a}else Ta(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;ut(a),n=!1}else i=xd(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=i),n=!0;if(!n)return a.flags&256?(pn(a),a):(pn(a),null);if((a.flags&128)!==0)throw Error(r(558))}return ut(a),null;case 13:if(c=a.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(f=xr(a),c!==null&&c.dehydrated!==null){if(n===null){if(!f)throw Error(r(318));if(f=a.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(r(317));f[Bt]=a}else Ta(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;ut(a),f=!1}else f=xd(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=f),f=!0;if(!f)return a.flags&256?(pn(a),a):(pn(a),null)}return pn(a),(a.flags&128)!==0?(a.lanes=i,a):(i=c!==null,n=n!==null&&n.memoizedState!==null,i&&(c=a.child,f=null,c.alternate!==null&&c.alternate.memoizedState!==null&&c.alternate.memoizedState.cachePool!==null&&(f=c.alternate.memoizedState.cachePool.pool),p=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(p=c.memoizedState.cachePool.pool),p!==f&&(c.flags|=2048)),i!==n&&i&&(a.child.flags|=8192),Wl(a,a.updateQueue),ut(a),null);case 4:return ie(),n===null&&Rh(a.stateNode.containerInfo),ut(a),null;case 10:return ps(a.type),ut(a),null;case 19:if(L(bt),c=a.memoizedState,c===null)return ut(a),null;if(f=(a.flags&128)!==0,p=c.rendering,p===null)if(f)Wi(c,!1);else{if(gt!==0||n!==null&&(n.flags&128)!==0)for(n=a.child;n!==null;){if(p=Ll(n),p!==null){for(a.flags|=128,Wi(c,!1),n=p.updateQueue,a.updateQueue=n,Wl(a,n),a.subtreeFlags=0,n=i,i=a.child;i!==null;)_g(i,n),i=i.sibling;return W(bt,bt.current&1|2),Ke&&fs(a,c.treeForkCount),a.child}n=n.sibling}c.tail!==null&&B()>tc&&(a.flags|=128,f=!0,Wi(c,!1),a.lanes=4194304)}else{if(!f)if(n=Ll(p),n!==null){if(a.flags|=128,f=!0,n=n.updateQueue,a.updateQueue=n,Wl(a,n),Wi(c,!0),c.tail===null&&c.tailMode==="hidden"&&!p.alternate&&!Ke)return ut(a),null}else 2*B()-c.renderingStartTime>tc&&i!==536870912&&(a.flags|=128,f=!0,Wi(c,!1),a.lanes=4194304);c.isBackwards?(p.sibling=a.child,a.child=p):(n=c.last,n!==null?n.sibling=p:a.child=p,c.last=p)}return c.tail!==null?(n=c.tail,c.rendering=n,c.tail=n.sibling,c.renderingStartTime=B(),n.sibling=null,i=bt.current,W(bt,f?i&1|2:i&1),Ke&&fs(a,c.treeForkCount),n):(ut(a),null);case 22:case 23:return pn(a),Od(),c=a.memoizedState!==null,n!==null?n.memoizedState!==null!==c&&(a.flags|=8192):c&&(a.flags|=8192),c?(i&536870912)!==0&&(a.flags&128)===0&&(ut(a),a.subtreeFlags&6&&(a.flags|=8192)):ut(a),i=a.updateQueue,i!==null&&Wl(a,i.retryQueue),i=null,n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(i=n.memoizedState.cachePool.pool),c=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(c=a.memoizedState.cachePool.pool),c!==i&&(a.flags|=2048),n!==null&&L(Ca),null;case 24:return i=null,n!==null&&(i=n.memoizedState.cache),a.memoizedState.cache!==i&&(a.flags|=2048),ps(St),ut(a),null;case 25:return null;case 30:return null}throw Error(r(156,a.tag))}function X_(n,a){switch(yd(a),a.tag){case 1:return n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 3:return ps(St),ie(),n=a.flags,(n&65536)!==0&&(n&128)===0?(a.flags=n&-65537|128,a):null;case 26:case 27:case 5:return Be(a),null;case 31:if(a.memoizedState!==null){if(pn(a),a.alternate===null)throw Error(r(340));Ta()}return n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 13:if(pn(a),n=a.memoizedState,n!==null&&n.dehydrated!==null){if(a.alternate===null)throw Error(r(340));Ta()}return n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 19:return L(bt),null;case 4:return ie(),null;case 10:return ps(a.type),null;case 22:case 23:return pn(a),Od(),n!==null&&L(Ca),n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 24:return ps(St),null;case 25:return null;default:return null}}function Jy(n,a){switch(yd(a),a.tag){case 3:ps(St),ie();break;case 26:case 27:case 5:Be(a);break;case 4:ie();break;case 31:a.memoizedState!==null&&pn(a);break;case 13:pn(a);break;case 19:L(bt);break;case 10:ps(a.type);break;case 22:case 23:pn(a),Od(),n!==null&&L(Ca);break;case 24:ps(St)}}function Ji(n,a){try{var i=a.updateQueue,c=i!==null?i.lastEffect:null;if(c!==null){var f=c.next;i=f;do{if((i.tag&n)===n){c=void 0;var p=i.create,b=i.inst;c=p(),b.destroy=c}i=i.next}while(i!==f)}}catch(T){Ze(a,a.return,T)}}function Gs(n,a,i){try{var c=a.updateQueue,f=c!==null?c.lastEffect:null;if(f!==null){var p=f.next;c=p;do{if((c.tag&n)===n){var b=c.inst,T=b.destroy;if(T!==void 0){b.destroy=void 0,f=a;var O=i,G=T;try{G()}catch(X){Ze(f,O,X)}}}c=c.next}while(c!==p)}}catch(X){Ze(a,a.return,X)}}function Qy(n){var a=n.updateQueue;if(a!==null){var i=n.stateNode;try{$g(a,i)}catch(c){Ze(n,n.return,c)}}}function Zy(n,a,i){i.props=Da(n.type,n.memoizedProps),i.state=n.memoizedState;try{i.componentWillUnmount()}catch(c){Ze(n,a,c)}}function Qi(n,a){try{var i=n.ref;if(i!==null){switch(n.tag){case 26:case 27:case 5:var c=n.stateNode;break;case 30:c=n.stateNode;break;default:c=n.stateNode}typeof i=="function"?n.refCleanup=i(c):i.current=c}}catch(f){Ze(n,a,f)}}function Zn(n,a){var i=n.ref,c=n.refCleanup;if(i!==null)if(typeof c=="function")try{c()}catch(f){Ze(n,a,f)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof i=="function")try{i(null)}catch(f){Ze(n,a,f)}else i.current=null}function ev(n){var a=n.type,i=n.memoizedProps,c=n.stateNode;try{e:switch(a){case"button":case"input":case"select":case"textarea":i.autoFocus&&c.focus();break e;case"img":i.src?c.src=i.src:i.srcSet&&(c.srcset=i.srcSet)}}catch(f){Ze(n,n.return,f)}}function uh(n,a,i){try{var c=n.stateNode;yN(c,n.type,i,a),c[tn]=a}catch(f){Ze(n,n.return,f)}}function tv(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&Qs(n.type)||n.tag===4}function dh(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||tv(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.tag===27&&Qs(n.type)||n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function hh(n,a,i){var c=n.tag;if(c===5||c===6)n=n.stateNode,a?(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i).insertBefore(n,a):(a=i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.appendChild(n),i=i._reactRootContainer,i!=null||a.onclick!==null||(a.onclick=us));else if(c!==4&&(c===27&&Qs(n.type)&&(i=n.stateNode,a=null),n=n.child,n!==null))for(hh(n,a,i),n=n.sibling;n!==null;)hh(n,a,i),n=n.sibling}function Jl(n,a,i){var c=n.tag;if(c===5||c===6)n=n.stateNode,a?i.insertBefore(n,a):i.appendChild(n);else if(c!==4&&(c===27&&Qs(n.type)&&(i=n.stateNode),n=n.child,n!==null))for(Jl(n,a,i),n=n.sibling;n!==null;)Jl(n,a,i),n=n.sibling}function nv(n){var a=n.stateNode,i=n.memoizedProps;try{for(var c=n.type,f=a.attributes;f.length;)a.removeAttributeNode(f[0]);qt(a,c,i),a[Bt]=n,a[tn]=i}catch(p){Ze(n,n.return,p)}}var bs=!1,Nt=!1,fh=!1,sv=typeof WeakSet=="function"?WeakSet:Set,Dt=null;function W_(n,a){if(n=n.containerInfo,Dh=vc,n=pg(n),id(n)){if("selectionStart"in n)var i={start:n.selectionStart,end:n.selectionEnd};else e:{i=(i=n.ownerDocument)&&i.defaultView||window;var c=i.getSelection&&i.getSelection();if(c&&c.rangeCount!==0){i=c.anchorNode;var f=c.anchorOffset,p=c.focusNode;c=c.focusOffset;try{i.nodeType,p.nodeType}catch{i=null;break e}var b=0,T=-1,O=-1,G=0,X=0,ee=n,F=null;t:for(;;){for(var K;ee!==i||f!==0&&ee.nodeType!==3||(T=b+f),ee!==p||c!==0&&ee.nodeType!==3||(O=b+c),ee.nodeType===3&&(b+=ee.nodeValue.length),(K=ee.firstChild)!==null;)F=ee,ee=K;for(;;){if(ee===n)break t;if(F===i&&++G===f&&(T=b),F===p&&++X===c&&(O=b),(K=ee.nextSibling)!==null)break;ee=F,F=ee.parentNode}ee=K}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(Ph={focusedElem:n,selectionRange:i},vc=!1,Dt=a;Dt!==null;)if(a=Dt,n=a.child,(a.subtreeFlags&1028)!==0&&n!==null)n.return=a,Dt=n;else for(;Dt!==null;){switch(a=Dt,p=a.alternate,n=a.flags,a.tag){case 0:if((n&4)!==0&&(n=a.updateQueue,n=n!==null?n.events:null,n!==null))for(i=0;i<n.length;i++)f=n[i],f.ref.impl=f.nextImpl;break;case 11:case 15:break;case 1:if((n&1024)!==0&&p!==null){n=void 0,i=a,f=p.memoizedProps,p=p.memoizedState,c=i.stateNode;try{var ve=Da(i.type,f);n=c.getSnapshotBeforeUpdate(ve,p),c.__reactInternalSnapshotBeforeUpdate=n}catch(Ce){Ze(i,i.return,Ce)}}break;case 3:if((n&1024)!==0){if(n=a.stateNode.containerInfo,i=n.nodeType,i===9)Uh(n);else if(i===1)switch(n.nodeName){case"HEAD":case"HTML":case"BODY":Uh(n);break;default:n.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((n&1024)!==0)throw Error(r(163))}if(n=a.sibling,n!==null){n.return=a.return,Dt=n;break}Dt=a.return}}function av(n,a,i){var c=i.flags;switch(i.tag){case 0:case 11:case 15:Ss(n,i),c&4&&Ji(5,i);break;case 1:if(Ss(n,i),c&4)if(n=i.stateNode,a===null)try{n.componentDidMount()}catch(b){Ze(i,i.return,b)}else{var f=Da(i.type,a.memoizedProps);a=a.memoizedState;try{n.componentDidUpdate(f,a,n.__reactInternalSnapshotBeforeUpdate)}catch(b){Ze(i,i.return,b)}}c&64&&Qy(i),c&512&&Qi(i,i.return);break;case 3:if(Ss(n,i),c&64&&(n=i.updateQueue,n!==null)){if(a=null,i.child!==null)switch(i.child.tag){case 27:case 5:a=i.child.stateNode;break;case 1:a=i.child.stateNode}try{$g(n,a)}catch(b){Ze(i,i.return,b)}}break;case 27:a===null&&c&4&&nv(i);case 26:case 5:Ss(n,i),a===null&&c&4&&ev(i),c&512&&Qi(i,i.return);break;case 12:Ss(n,i);break;case 31:Ss(n,i),c&4&&ov(n,i);break;case 13:Ss(n,i),c&4&&lv(n,i),c&64&&(n=i.memoizedState,n!==null&&(n=n.dehydrated,n!==null&&(i=rN.bind(null,i),NN(n,i))));break;case 22:if(c=i.memoizedState!==null||bs,!c){a=a!==null&&a.memoizedState!==null||Nt,f=bs;var p=Nt;bs=c,(Nt=a)&&!p?js(n,i,(i.subtreeFlags&8772)!==0):Ss(n,i),bs=f,Nt=p}break;case 30:break;default:Ss(n,i)}}function rv(n){var a=n.alternate;a!==null&&(n.alternate=null,rv(a)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(a=n.stateNode,a!==null&&qu(a)),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}var dt=null,sn=!1;function ws(n,a,i){for(i=i.child;i!==null;)iv(n,a,i),i=i.sibling}function iv(n,a,i){if(Kt&&typeof Kt.onCommitFiberUnmount=="function")try{Kt.onCommitFiberUnmount(Ms,i)}catch{}switch(i.tag){case 26:Nt||Zn(i,a),ws(n,a,i),i.memoizedState?i.memoizedState.count--:i.stateNode&&(i=i.stateNode,i.parentNode.removeChild(i));break;case 27:Nt||Zn(i,a);var c=dt,f=sn;Qs(i.type)&&(dt=i.stateNode,sn=!1),ws(n,a,i),oo(i.stateNode),dt=c,sn=f;break;case 5:Nt||Zn(i,a);case 6:if(c=dt,f=sn,dt=null,ws(n,a,i),dt=c,sn=f,dt!==null)if(sn)try{(dt.nodeType===9?dt.body:dt.nodeName==="HTML"?dt.ownerDocument.body:dt).removeChild(i.stateNode)}catch(p){Ze(i,a,p)}else try{dt.removeChild(i.stateNode)}catch(p){Ze(i,a,p)}break;case 18:dt!==null&&(sn?(n=dt,Qv(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,i.stateNode),Vr(n)):Qv(dt,i.stateNode));break;case 4:c=dt,f=sn,dt=i.stateNode.containerInfo,sn=!0,ws(n,a,i),dt=c,sn=f;break;case 0:case 11:case 14:case 15:Gs(2,i,a),Nt||Gs(4,i,a),ws(n,a,i);break;case 1:Nt||(Zn(i,a),c=i.stateNode,typeof c.componentWillUnmount=="function"&&Zy(i,a,c)),ws(n,a,i);break;case 21:ws(n,a,i);break;case 22:Nt=(c=Nt)||i.memoizedState!==null,ws(n,a,i),Nt=c;break;default:ws(n,a,i)}}function ov(n,a){if(a.memoizedState===null&&(n=a.alternate,n!==null&&(n=n.memoizedState,n!==null))){n=n.dehydrated;try{Vr(n)}catch(i){Ze(a,a.return,i)}}}function lv(n,a){if(a.memoizedState===null&&(n=a.alternate,n!==null&&(n=n.memoizedState,n!==null&&(n=n.dehydrated,n!==null))))try{Vr(n)}catch(i){Ze(a,a.return,i)}}function J_(n){switch(n.tag){case 31:case 13:case 19:var a=n.stateNode;return a===null&&(a=n.stateNode=new sv),a;case 22:return n=n.stateNode,a=n._retryCache,a===null&&(a=n._retryCache=new sv),a;default:throw Error(r(435,n.tag))}}function Ql(n,a){var i=J_(n);a.forEach(function(c){if(!i.has(c)){i.add(c);var f=iN.bind(null,n,c);c.then(f,f)}})}function an(n,a){var i=a.deletions;if(i!==null)for(var c=0;c<i.length;c++){var f=i[c],p=n,b=a,T=b;e:for(;T!==null;){switch(T.tag){case 27:if(Qs(T.type)){dt=T.stateNode,sn=!1;break e}break;case 5:dt=T.stateNode,sn=!1;break e;case 3:case 4:dt=T.stateNode.containerInfo,sn=!0;break e}T=T.return}if(dt===null)throw Error(r(160));iv(p,b,f),dt=null,sn=!1,p=f.alternate,p!==null&&(p.return=null),f.return=null}if(a.subtreeFlags&13886)for(a=a.child;a!==null;)cv(a,n),a=a.sibling}var Bn=null;function cv(n,a){var i=n.alternate,c=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:an(a,n),rn(n),c&4&&(Gs(3,n,n.return),Ji(3,n),Gs(5,n,n.return));break;case 1:an(a,n),rn(n),c&512&&(Nt||i===null||Zn(i,i.return)),c&64&&bs&&(n=n.updateQueue,n!==null&&(c=n.callbacks,c!==null&&(i=n.shared.hiddenCallbacks,n.shared.hiddenCallbacks=i===null?c:i.concat(c))));break;case 26:var f=Bn;if(an(a,n),rn(n),c&512&&(Nt||i===null||Zn(i,i.return)),c&4){var p=i!==null?i.memoizedState:null;if(c=n.memoizedState,i===null)if(c===null)if(n.stateNode===null){e:{c=n.type,i=n.memoizedProps,f=f.ownerDocument||f;t:switch(c){case"title":p=f.getElementsByTagName("title")[0],(!p||p[Ni]||p[Bt]||p.namespaceURI==="http://www.w3.org/2000/svg"||p.hasAttribute("itemprop"))&&(p=f.createElement(c),f.head.insertBefore(p,f.querySelector("head > title"))),qt(p,c,i),p[Bt]=n,Mt(p),c=p;break e;case"link":var b=cx("link","href",f).get(c+(i.href||""));if(b){for(var T=0;T<b.length;T++)if(p=b[T],p.getAttribute("href")===(i.href==null||i.href===""?null:i.href)&&p.getAttribute("rel")===(i.rel==null?null:i.rel)&&p.getAttribute("title")===(i.title==null?null:i.title)&&p.getAttribute("crossorigin")===(i.crossOrigin==null?null:i.crossOrigin)){b.splice(T,1);break t}}p=f.createElement(c),qt(p,c,i),f.head.appendChild(p);break;case"meta":if(b=cx("meta","content",f).get(c+(i.content||""))){for(T=0;T<b.length;T++)if(p=b[T],p.getAttribute("content")===(i.content==null?null:""+i.content)&&p.getAttribute("name")===(i.name==null?null:i.name)&&p.getAttribute("property")===(i.property==null?null:i.property)&&p.getAttribute("http-equiv")===(i.httpEquiv==null?null:i.httpEquiv)&&p.getAttribute("charset")===(i.charSet==null?null:i.charSet)){b.splice(T,1);break t}}p=f.createElement(c),qt(p,c,i),f.head.appendChild(p);break;default:throw Error(r(468,c))}p[Bt]=n,Mt(p),c=p}n.stateNode=c}else ux(f,n.type,n.stateNode);else n.stateNode=lx(f,c,n.memoizedProps);else p!==c?(p===null?i.stateNode!==null&&(i=i.stateNode,i.parentNode.removeChild(i)):p.count--,c===null?ux(f,n.type,n.stateNode):lx(f,c,n.memoizedProps)):c===null&&n.stateNode!==null&&uh(n,n.memoizedProps,i.memoizedProps)}break;case 27:an(a,n),rn(n),c&512&&(Nt||i===null||Zn(i,i.return)),i!==null&&c&4&&uh(n,n.memoizedProps,i.memoizedProps);break;case 5:if(an(a,n),rn(n),c&512&&(Nt||i===null||Zn(i,i.return)),n.flags&32){f=n.stateNode;try{cr(f,"")}catch(ve){Ze(n,n.return,ve)}}c&4&&n.stateNode!=null&&(f=n.memoizedProps,uh(n,f,i!==null?i.memoizedProps:f)),c&1024&&(fh=!0);break;case 6:if(an(a,n),rn(n),c&4){if(n.stateNode===null)throw Error(r(162));c=n.memoizedProps,i=n.stateNode;try{i.nodeValue=c}catch(ve){Ze(n,n.return,ve)}}break;case 3:if(mc=null,f=Bn,Bn=hc(a.containerInfo),an(a,n),Bn=f,rn(n),c&4&&i!==null&&i.memoizedState.isDehydrated)try{Vr(a.containerInfo)}catch(ve){Ze(n,n.return,ve)}fh&&(fh=!1,uv(n));break;case 4:c=Bn,Bn=hc(n.stateNode.containerInfo),an(a,n),rn(n),Bn=c;break;case 12:an(a,n),rn(n);break;case 31:an(a,n),rn(n),c&4&&(c=n.updateQueue,c!==null&&(n.updateQueue=null,Ql(n,c)));break;case 13:an(a,n),rn(n),n.child.flags&8192&&n.memoizedState!==null!=(i!==null&&i.memoizedState!==null)&&(ec=B()),c&4&&(c=n.updateQueue,c!==null&&(n.updateQueue=null,Ql(n,c)));break;case 22:f=n.memoizedState!==null;var O=i!==null&&i.memoizedState!==null,G=bs,X=Nt;if(bs=G||f,Nt=X||O,an(a,n),Nt=X,bs=G,rn(n),c&8192)e:for(a=n.stateNode,a._visibility=f?a._visibility&-2:a._visibility|1,f&&(i===null||O||bs||Nt||Pa(n)),i=null,a=n;;){if(a.tag===5||a.tag===26){if(i===null){O=i=a;try{if(p=O.stateNode,f)b=p.style,typeof b.setProperty=="function"?b.setProperty("display","none","important"):b.display="none";else{T=O.stateNode;var ee=O.memoizedProps.style,F=ee!=null&&ee.hasOwnProperty("display")?ee.display:null;T.style.display=F==null||typeof F=="boolean"?"":(""+F).trim()}}catch(ve){Ze(O,O.return,ve)}}}else if(a.tag===6){if(i===null){O=a;try{O.stateNode.nodeValue=f?"":O.memoizedProps}catch(ve){Ze(O,O.return,ve)}}}else if(a.tag===18){if(i===null){O=a;try{var K=O.stateNode;f?Zv(K,!0):Zv(O.stateNode,!1)}catch(ve){Ze(O,O.return,ve)}}}else if((a.tag!==22&&a.tag!==23||a.memoizedState===null||a===n)&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===n)break e;for(;a.sibling===null;){if(a.return===null||a.return===n)break e;i===a&&(i=null),a=a.return}i===a&&(i=null),a.sibling.return=a.return,a=a.sibling}c&4&&(c=n.updateQueue,c!==null&&(i=c.retryQueue,i!==null&&(c.retryQueue=null,Ql(n,i))));break;case 19:an(a,n),rn(n),c&4&&(c=n.updateQueue,c!==null&&(n.updateQueue=null,Ql(n,c)));break;case 30:break;case 21:break;default:an(a,n),rn(n)}}function rn(n){var a=n.flags;if(a&2){try{for(var i,c=n.return;c!==null;){if(tv(c)){i=c;break}c=c.return}if(i==null)throw Error(r(160));switch(i.tag){case 27:var f=i.stateNode,p=dh(n);Jl(n,p,f);break;case 5:var b=i.stateNode;i.flags&32&&(cr(b,""),i.flags&=-33);var T=dh(n);Jl(n,T,b);break;case 3:case 4:var O=i.stateNode.containerInfo,G=dh(n);hh(n,G,O);break;default:throw Error(r(161))}}catch(X){Ze(n,n.return,X)}n.flags&=-3}a&4096&&(n.flags&=-4097)}function uv(n){if(n.subtreeFlags&1024)for(n=n.child;n!==null;){var a=n;uv(a),a.tag===5&&a.flags&1024&&a.stateNode.reset(),n=n.sibling}}function Ss(n,a){if(a.subtreeFlags&8772)for(a=a.child;a!==null;)av(n,a.alternate,a),a=a.sibling}function Pa(n){for(n=n.child;n!==null;){var a=n;switch(a.tag){case 0:case 11:case 14:case 15:Gs(4,a,a.return),Pa(a);break;case 1:Zn(a,a.return);var i=a.stateNode;typeof i.componentWillUnmount=="function"&&Zy(a,a.return,i),Pa(a);break;case 27:oo(a.stateNode);case 26:case 5:Zn(a,a.return),Pa(a);break;case 22:a.memoizedState===null&&Pa(a);break;case 30:Pa(a);break;default:Pa(a)}n=n.sibling}}function js(n,a,i){for(i=i&&(a.subtreeFlags&8772)!==0,a=a.child;a!==null;){var c=a.alternate,f=n,p=a,b=p.flags;switch(p.tag){case 0:case 11:case 15:js(f,p,i),Ji(4,p);break;case 1:if(js(f,p,i),c=p,f=c.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(G){Ze(c,c.return,G)}if(c=p,f=c.updateQueue,f!==null){var T=c.stateNode;try{var O=f.shared.hiddenCallbacks;if(O!==null)for(f.shared.hiddenCallbacks=null,f=0;f<O.length;f++)Ig(O[f],T)}catch(G){Ze(c,c.return,G)}}i&&b&64&&Qy(p),Qi(p,p.return);break;case 27:nv(p);case 26:case 5:js(f,p,i),i&&c===null&&b&4&&ev(p),Qi(p,p.return);break;case 12:js(f,p,i);break;case 31:js(f,p,i),i&&b&4&&ov(f,p);break;case 13:js(f,p,i),i&&b&4&&lv(f,p);break;case 22:p.memoizedState===null&&js(f,p,i),Qi(p,p.return);break;case 30:break;default:js(f,p,i)}a=a.sibling}}function mh(n,a){var i=null;n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(i=n.memoizedState.cachePool.pool),n=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(n=a.memoizedState.cachePool.pool),n!==i&&(n!=null&&n.refCount++,i!=null&&Ui(i))}function ph(n,a){n=null,a.alternate!==null&&(n=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==n&&(a.refCount++,n!=null&&Ui(n))}function Vn(n,a,i,c){if(a.subtreeFlags&10256)for(a=a.child;a!==null;)dv(n,a,i,c),a=a.sibling}function dv(n,a,i,c){var f=a.flags;switch(a.tag){case 0:case 11:case 15:Vn(n,a,i,c),f&2048&&Ji(9,a);break;case 1:Vn(n,a,i,c);break;case 3:Vn(n,a,i,c),f&2048&&(n=null,a.alternate!==null&&(n=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==n&&(a.refCount++,n!=null&&Ui(n)));break;case 12:if(f&2048){Vn(n,a,i,c),n=a.stateNode;try{var p=a.memoizedProps,b=p.id,T=p.onPostCommit;typeof T=="function"&&T(b,a.alternate===null?"mount":"update",n.passiveEffectDuration,-0)}catch(O){Ze(a,a.return,O)}}else Vn(n,a,i,c);break;case 31:Vn(n,a,i,c);break;case 13:Vn(n,a,i,c);break;case 23:break;case 22:p=a.stateNode,b=a.alternate,a.memoizedState!==null?p._visibility&2?Vn(n,a,i,c):Zi(n,a):p._visibility&2?Vn(n,a,i,c):(p._visibility|=2,Cr(n,a,i,c,(a.subtreeFlags&10256)!==0||!1)),f&2048&&mh(b,a);break;case 24:Vn(n,a,i,c),f&2048&&ph(a.alternate,a);break;default:Vn(n,a,i,c)}}function Cr(n,a,i,c,f){for(f=f&&((a.subtreeFlags&10256)!==0||!1),a=a.child;a!==null;){var p=n,b=a,T=i,O=c,G=b.flags;switch(b.tag){case 0:case 11:case 15:Cr(p,b,T,O,f),Ji(8,b);break;case 23:break;case 22:var X=b.stateNode;b.memoizedState!==null?X._visibility&2?Cr(p,b,T,O,f):Zi(p,b):(X._visibility|=2,Cr(p,b,T,O,f)),f&&G&2048&&mh(b.alternate,b);break;case 24:Cr(p,b,T,O,f),f&&G&2048&&ph(b.alternate,b);break;default:Cr(p,b,T,O,f)}a=a.sibling}}function Zi(n,a){if(a.subtreeFlags&10256)for(a=a.child;a!==null;){var i=n,c=a,f=c.flags;switch(c.tag){case 22:Zi(i,c),f&2048&&mh(c.alternate,c);break;case 24:Zi(i,c),f&2048&&ph(c.alternate,c);break;default:Zi(i,c)}a=a.sibling}}var eo=8192;function Ar(n,a,i){if(n.subtreeFlags&eo)for(n=n.child;n!==null;)hv(n,a,i),n=n.sibling}function hv(n,a,i){switch(n.tag){case 26:Ar(n,a,i),n.flags&eo&&n.memoizedState!==null&&LN(i,Bn,n.memoizedState,n.memoizedProps);break;case 5:Ar(n,a,i);break;case 3:case 4:var c=Bn;Bn=hc(n.stateNode.containerInfo),Ar(n,a,i),Bn=c;break;case 22:n.memoizedState===null&&(c=n.alternate,c!==null&&c.memoizedState!==null?(c=eo,eo=16777216,Ar(n,a,i),eo=c):Ar(n,a,i));break;default:Ar(n,a,i)}}function fv(n){var a=n.alternate;if(a!==null&&(n=a.child,n!==null)){a.child=null;do a=n.sibling,n.sibling=null,n=a;while(n!==null)}}function to(n){var a=n.deletions;if((n.flags&16)!==0){if(a!==null)for(var i=0;i<a.length;i++){var c=a[i];Dt=c,pv(c,n)}fv(n)}if(n.subtreeFlags&10256)for(n=n.child;n!==null;)mv(n),n=n.sibling}function mv(n){switch(n.tag){case 0:case 11:case 15:to(n),n.flags&2048&&Gs(9,n,n.return);break;case 3:to(n);break;case 12:to(n);break;case 22:var a=n.stateNode;n.memoizedState!==null&&a._visibility&2&&(n.return===null||n.return.tag!==13)?(a._visibility&=-3,Zl(n)):to(n);break;default:to(n)}}function Zl(n){var a=n.deletions;if((n.flags&16)!==0){if(a!==null)for(var i=0;i<a.length;i++){var c=a[i];Dt=c,pv(c,n)}fv(n)}for(n=n.child;n!==null;){switch(a=n,a.tag){case 0:case 11:case 15:Gs(8,a,a.return),Zl(a);break;case 22:i=a.stateNode,i._visibility&2&&(i._visibility&=-3,Zl(a));break;default:Zl(a)}n=n.sibling}}function pv(n,a){for(;Dt!==null;){var i=Dt;switch(i.tag){case 0:case 11:case 15:Gs(8,i,a);break;case 23:case 22:if(i.memoizedState!==null&&i.memoizedState.cachePool!==null){var c=i.memoizedState.cachePool.pool;c!=null&&c.refCount++}break;case 24:Ui(i.memoizedState.cache)}if(c=i.child,c!==null)c.return=i,Dt=c;else e:for(i=n;Dt!==null;){c=Dt;var f=c.sibling,p=c.return;if(rv(c),c===i){Dt=null;break e}if(f!==null){f.return=p,Dt=f;break e}Dt=p}}}var Q_={getCacheForType:function(n){var a=It(St),i=a.data.get(n);return i===void 0&&(i=n(),a.data.set(n,i)),i},cacheSignal:function(){return It(St).controller.signal}},Z_=typeof WeakMap=="function"?WeakMap:Map,We=0,rt=null,Ie=null,He=0,Qe=0,gn=null,Fs=!1,Rr=!1,gh=!1,_s=0,gt=0,Ks=0,za=0,yh=0,yn=0,Or=0,no=null,on=null,vh=!1,ec=0,gv=0,tc=1/0,nc=null,Ys=null,Ct=0,Xs=null,Mr=null,Ns=0,xh=0,bh=null,yv=null,so=0,wh=null;function vn(){return(We&2)!==0&&He!==0?He&-He:$.T!==null?Eh():Mp()}function vv(){if(yn===0)if((He&536870912)===0||Ke){var n=ul;ul<<=1,(ul&3932160)===0&&(ul=262144),yn=n}else yn=536870912;return n=mn.current,n!==null&&(n.flags|=32),yn}function ln(n,a,i){(n===rt&&(Qe===2||Qe===9)||n.cancelPendingCommit!==null)&&(Dr(n,0),Ws(n,He,yn,!1)),_i(n,i),((We&2)===0||n!==rt)&&(n===rt&&((We&2)===0&&(za|=i),gt===4&&Ws(n,He,yn,!1)),es(n))}function xv(n,a,i){if((We&6)!==0)throw Error(r(327));var c=!i&&(a&127)===0&&(a&n.expiredLanes)===0||ji(n,a),f=c?nN(n,a):jh(n,a,!0),p=c;do{if(f===0){Rr&&!c&&Ws(n,a,0,!1);break}else{if(i=n.current.alternate,p&&!eN(i)){f=jh(n,a,!1),p=!1;continue}if(f===2){if(p=a,n.errorRecoveryDisabledLanes&p)var b=0;else b=n.pendingLanes&-536870913,b=b!==0?b:b&536870912?536870912:0;if(b!==0){a=b;e:{var T=n;f=no;var O=T.current.memoizedState.isDehydrated;if(O&&(Dr(T,b).flags|=256),b=jh(T,b,!1),b!==2){if(gh&&!O){T.errorRecoveryDisabledLanes|=p,za|=p,f=4;break e}p=on,on=f,p!==null&&(on===null?on=p:on.push.apply(on,p))}f=b}if(p=!1,f!==2)continue}}if(f===1){Dr(n,0),Ws(n,a,0,!0);break}e:{switch(c=n,p=f,p){case 0:case 1:throw Error(r(345));case 4:if((a&4194048)!==a)break;case 6:Ws(c,a,yn,!Fs);break e;case 2:on=null;break;case 3:case 5:break;default:throw Error(r(329))}if((a&62914560)===a&&(f=ec+300-B(),10<f)){if(Ws(c,a,yn,!Fs),hl(c,0,!0)!==0)break e;Ns=a,c.timeoutHandle=Wv(bv.bind(null,c,i,on,nc,vh,a,yn,za,Or,Fs,p,"Throttled",-0,0),f);break e}bv(c,i,on,nc,vh,a,yn,za,Or,Fs,p,null,-0,0)}}break}while(!0);es(n)}function bv(n,a,i,c,f,p,b,T,O,G,X,ee,F,K){if(n.timeoutHandle=-1,ee=a.subtreeFlags,ee&8192||(ee&16785408)===16785408){ee={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:us},hv(a,p,ee);var ve=(p&62914560)===p?ec-B():(p&4194048)===p?gv-B():0;if(ve=UN(ee,ve),ve!==null){Ns=p,n.cancelPendingCommit=ve(kv.bind(null,n,a,p,i,c,f,b,T,O,X,ee,null,F,K)),Ws(n,p,b,!G);return}}kv(n,a,p,i,c,f,b,T,O)}function eN(n){for(var a=n;;){var i=a.tag;if((i===0||i===11||i===15)&&a.flags&16384&&(i=a.updateQueue,i!==null&&(i=i.stores,i!==null)))for(var c=0;c<i.length;c++){var f=i[c],p=f.getSnapshot;f=f.value;try{if(!hn(p(),f))return!1}catch{return!1}}if(i=a.child,a.subtreeFlags&16384&&i!==null)i.return=a,a=i;else{if(a===n)break;for(;a.sibling===null;){if(a.return===null||a.return===n)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function Ws(n,a,i,c){a&=~yh,a&=~za,n.suspendedLanes|=a,n.pingedLanes&=~a,c&&(n.warmLanes|=a),c=n.expirationTimes;for(var f=a;0<f;){var p=31-dn(f),b=1<<p;c[p]=-1,f&=~b}i!==0&&Ap(n,i,a)}function sc(){return(We&6)===0?(ao(0),!1):!0}function Sh(){if(Ie!==null){if(Qe===0)var n=Ie.return;else n=Ie,ms=Ea=null,Ud(n),_r=null,Vi=0,n=Ie;for(;n!==null;)Jy(n.alternate,n),n=n.return;Ie=null}}function Dr(n,a){var i=n.timeoutHandle;i!==-1&&(n.timeoutHandle=-1,bN(i)),i=n.cancelPendingCommit,i!==null&&(n.cancelPendingCommit=null,i()),Ns=0,Sh(),rt=n,Ie=i=hs(n.current,null),He=a,Qe=0,gn=null,Fs=!1,Rr=ji(n,a),gh=!1,Or=yn=yh=za=Ks=gt=0,on=no=null,vh=!1,(a&8)!==0&&(a|=a&32);var c=n.entangledLanes;if(c!==0)for(n=n.entanglements,c&=a;0<c;){var f=31-dn(c),p=1<<f;a|=n[f],c&=~p}return _s=a,_l(),i}function wv(n,a){Pe=null,$.H=Yi,a===jr||a===Ol?(a=Lg(),Qe=3):a===Td?(a=Lg(),Qe=4):Qe=a===eh?8:a!==null&&typeof a=="object"&&typeof a.then=="function"?6:1,gn=a,Ie===null&&(gt=1,Fl(n,kn(a,n.current)))}function Sv(){var n=mn.current;return n===null?!0:(He&4194048)===He?On===null:(He&62914560)===He||(He&536870912)!==0?n===On:!1}function jv(){var n=$.H;return $.H=Yi,n===null?Yi:n}function _v(){var n=$.A;return $.A=Q_,n}function ac(){gt=4,Fs||(He&4194048)!==He&&mn.current!==null||(Rr=!0),(Ks&134217727)===0&&(za&134217727)===0||rt===null||Ws(rt,He,yn,!1)}function jh(n,a,i){var c=We;We|=2;var f=jv(),p=_v();(rt!==n||He!==a)&&(nc=null,Dr(n,a)),a=!1;var b=gt;e:do try{if(Qe!==0&&Ie!==null){var T=Ie,O=gn;switch(Qe){case 8:Sh(),b=6;break e;case 3:case 2:case 9:case 6:mn.current===null&&(a=!0);var G=Qe;if(Qe=0,gn=null,Pr(n,T,O,G),i&&Rr){b=0;break e}break;default:G=Qe,Qe=0,gn=null,Pr(n,T,O,G)}}tN(),b=gt;break}catch(X){wv(n,X)}while(!0);return a&&n.shellSuspendCounter++,ms=Ea=null,We=c,$.H=f,$.A=p,Ie===null&&(rt=null,He=0,_l()),b}function tN(){for(;Ie!==null;)Nv(Ie)}function nN(n,a){var i=We;We|=2;var c=jv(),f=_v();rt!==n||He!==a?(nc=null,tc=B()+500,Dr(n,a)):Rr=ji(n,a);e:do try{if(Qe!==0&&Ie!==null){a=Ie;var p=gn;t:switch(Qe){case 1:Qe=0,gn=null,Pr(n,a,p,1);break;case 2:case 9:if(Pg(p)){Qe=0,gn=null,Tv(a);break}a=function(){Qe!==2&&Qe!==9||rt!==n||(Qe=7),es(n)},p.then(a,a);break e;case 3:Qe=7;break e;case 4:Qe=5;break e;case 7:Pg(p)?(Qe=0,gn=null,Tv(a)):(Qe=0,gn=null,Pr(n,a,p,7));break;case 5:var b=null;switch(Ie.tag){case 26:b=Ie.memoizedState;case 5:case 27:var T=Ie;if(b?dx(b):T.stateNode.complete){Qe=0,gn=null;var O=T.sibling;if(O!==null)Ie=O;else{var G=T.return;G!==null?(Ie=G,rc(G)):Ie=null}break t}}Qe=0,gn=null,Pr(n,a,p,5);break;case 6:Qe=0,gn=null,Pr(n,a,p,6);break;case 8:Sh(),gt=6;break e;default:throw Error(r(462))}}sN();break}catch(X){wv(n,X)}while(!0);return ms=Ea=null,$.H=c,$.A=f,We=i,Ie!==null?0:(rt=null,He=0,_l(),gt)}function sN(){for(;Ie!==null&&!Si();)Nv(Ie)}function Nv(n){var a=Xy(n.alternate,n,_s);n.memoizedProps=n.pendingProps,a===null?rc(n):Ie=a}function Tv(n){var a=n,i=a.alternate;switch(a.tag){case 15:case 0:a=qy(i,a,a.pendingProps,a.type,void 0,He);break;case 11:a=qy(i,a,a.pendingProps,a.type.render,a.ref,He);break;case 5:Ud(a);default:Jy(i,a),a=Ie=_g(a,_s),a=Xy(i,a,_s)}n.memoizedProps=n.pendingProps,a===null?rc(n):Ie=a}function Pr(n,a,i,c){ms=Ea=null,Ud(a),_r=null,Vi=0;var f=a.return;try{if(G_(n,f,a,i,He)){gt=1,Fl(n,kn(i,n.current)),Ie=null;return}}catch(p){if(f!==null)throw Ie=f,p;gt=1,Fl(n,kn(i,n.current)),Ie=null;return}a.flags&32768?(Ke||c===1?n=!0:Rr||(He&536870912)!==0?n=!1:(Fs=n=!0,(c===2||c===9||c===3||c===6)&&(c=mn.current,c!==null&&c.tag===13&&(c.flags|=16384))),Ev(a,n)):rc(a)}function rc(n){var a=n;do{if((a.flags&32768)!==0){Ev(a,Fs);return}n=a.return;var i=Y_(a.alternate,a,_s);if(i!==null){Ie=i;return}if(a=a.sibling,a!==null){Ie=a;return}Ie=a=n}while(a!==null);gt===0&&(gt=5)}function Ev(n,a){do{var i=X_(n.alternate,n);if(i!==null){i.flags&=32767,Ie=i;return}if(i=n.return,i!==null&&(i.flags|=32768,i.subtreeFlags=0,i.deletions=null),!a&&(n=n.sibling,n!==null)){Ie=n;return}Ie=n=i}while(n!==null);gt=6,Ie=null}function kv(n,a,i,c,f,p,b,T,O){n.cancelPendingCommit=null;do ic();while(Ct!==0);if((We&6)!==0)throw Error(r(327));if(a!==null){if(a===n.current)throw Error(r(177));if(p=a.lanes|a.childLanes,p|=dd,zj(n,i,p,b,T,O),n===rt&&(Ie=rt=null,He=0),Mr=a,Xs=n,Ns=i,xh=p,bh=f,yv=c,(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?(n.callbackNode=null,n.callbackPriority=0,oN(ft,function(){return Mv(),null})):(n.callbackNode=null,n.callbackPriority=0),c=(a.flags&13878)!==0,(a.subtreeFlags&13878)!==0||c){c=$.T,$.T=null,f=Y.p,Y.p=2,b=We,We|=4;try{W_(n,a,i)}finally{We=b,Y.p=f,$.T=c}}Ct=1,Cv(),Av(),Rv()}}function Cv(){if(Ct===1){Ct=0;var n=Xs,a=Mr,i=(a.flags&13878)!==0;if((a.subtreeFlags&13878)!==0||i){i=$.T,$.T=null;var c=Y.p;Y.p=2;var f=We;We|=4;try{cv(a,n);var p=Ph,b=pg(n.containerInfo),T=p.focusedElem,O=p.selectionRange;if(b!==T&&T&&T.ownerDocument&&mg(T.ownerDocument.documentElement,T)){if(O!==null&&id(T)){var G=O.start,X=O.end;if(X===void 0&&(X=G),"selectionStart"in T)T.selectionStart=G,T.selectionEnd=Math.min(X,T.value.length);else{var ee=T.ownerDocument||document,F=ee&&ee.defaultView||window;if(F.getSelection){var K=F.getSelection(),ve=T.textContent.length,Ce=Math.min(O.start,ve),st=O.end===void 0?Ce:Math.min(O.end,ve);!K.extend&&Ce>st&&(b=st,st=Ce,Ce=b);var I=fg(T,Ce),z=fg(T,st);if(I&&z&&(K.rangeCount!==1||K.anchorNode!==I.node||K.anchorOffset!==I.offset||K.focusNode!==z.node||K.focusOffset!==z.offset)){var H=ee.createRange();H.setStart(I.node,I.offset),K.removeAllRanges(),Ce>st?(K.addRange(H),K.extend(z.node,z.offset)):(H.setEnd(z.node,z.offset),K.addRange(H))}}}}for(ee=[],K=T;K=K.parentNode;)K.nodeType===1&&ee.push({element:K,left:K.scrollLeft,top:K.scrollTop});for(typeof T.focus=="function"&&T.focus(),T=0;T<ee.length;T++){var Q=ee[T];Q.element.scrollLeft=Q.left,Q.element.scrollTop=Q.top}}vc=!!Dh,Ph=Dh=null}finally{We=f,Y.p=c,$.T=i}}n.current=a,Ct=2}}function Av(){if(Ct===2){Ct=0;var n=Xs,a=Mr,i=(a.flags&8772)!==0;if((a.subtreeFlags&8772)!==0||i){i=$.T,$.T=null;var c=Y.p;Y.p=2;var f=We;We|=4;try{av(n,a.alternate,a)}finally{We=f,Y.p=c,$.T=i}}Ct=3}}function Rv(){if(Ct===4||Ct===3){Ct=0,Uu();var n=Xs,a=Mr,i=Ns,c=yv;(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?Ct=5:(Ct=0,Mr=Xs=null,Ov(n,n.pendingLanes));var f=n.pendingLanes;if(f===0&&(Ys=null),Iu(i),a=a.stateNode,Kt&&typeof Kt.onCommitFiberRoot=="function")try{Kt.onCommitFiberRoot(Ms,a,void 0,(a.current.flags&128)===128)}catch{}if(c!==null){a=$.T,f=Y.p,Y.p=2,$.T=null;try{for(var p=n.onRecoverableError,b=0;b<c.length;b++){var T=c[b];p(T.value,{componentStack:T.stack})}}finally{$.T=a,Y.p=f}}(Ns&3)!==0&&ic(),es(n),f=n.pendingLanes,(i&261930)!==0&&(f&42)!==0?n===wh?so++:(so=0,wh=n):so=0,ao(0)}}function Ov(n,a){(n.pooledCacheLanes&=a)===0&&(a=n.pooledCache,a!=null&&(n.pooledCache=null,Ui(a)))}function ic(){return Cv(),Av(),Rv(),Mv()}function Mv(){if(Ct!==5)return!1;var n=Xs,a=xh;xh=0;var i=Iu(Ns),c=$.T,f=Y.p;try{Y.p=32>i?32:i,$.T=null,i=bh,bh=null;var p=Xs,b=Ns;if(Ct=0,Mr=Xs=null,Ns=0,(We&6)!==0)throw Error(r(331));var T=We;if(We|=4,mv(p.current),dv(p,p.current,b,i),We=T,ao(0,!1),Kt&&typeof Kt.onPostCommitFiberRoot=="function")try{Kt.onPostCommitFiberRoot(Ms,p)}catch{}return!0}finally{Y.p=f,$.T=c,Ov(n,a)}}function Dv(n,a,i){a=kn(i,a),a=Zd(n.stateNode,a,2),n=$s(n,a,2),n!==null&&(_i(n,2),es(n))}function Ze(n,a,i){if(n.tag===3)Dv(n,n,i);else for(;a!==null;){if(a.tag===3){Dv(a,n,i);break}else if(a.tag===1){var c=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Ys===null||!Ys.has(c))){n=kn(i,n),i=Py(2),c=$s(a,i,2),c!==null&&(zy(i,c,a,n),_i(c,2),es(c));break}}a=a.return}}function _h(n,a,i){var c=n.pingCache;if(c===null){c=n.pingCache=new Z_;var f=new Set;c.set(a,f)}else f=c.get(a),f===void 0&&(f=new Set,c.set(a,f));f.has(i)||(gh=!0,f.add(i),n=aN.bind(null,n,a,i),a.then(n,n))}function aN(n,a,i){var c=n.pingCache;c!==null&&c.delete(a),n.pingedLanes|=n.suspendedLanes&i,n.warmLanes&=~i,rt===n&&(He&i)===i&&(gt===4||gt===3&&(He&62914560)===He&&300>B()-ec?(We&2)===0&&Dr(n,0):yh|=i,Or===He&&(Or=0)),es(n)}function Pv(n,a){a===0&&(a=Cp()),n=_a(n,a),n!==null&&(_i(n,a),es(n))}function rN(n){var a=n.memoizedState,i=0;a!==null&&(i=a.retryLane),Pv(n,i)}function iN(n,a){var i=0;switch(n.tag){case 31:case 13:var c=n.stateNode,f=n.memoizedState;f!==null&&(i=f.retryLane);break;case 19:c=n.stateNode;break;case 22:c=n.stateNode._retryCache;break;default:throw Error(r(314))}c!==null&&c.delete(a),Pv(n,i)}function oN(n,a){return Xn(n,a)}var oc=null,zr=null,Nh=!1,lc=!1,Th=!1,Js=0;function es(n){n!==zr&&n.next===null&&(zr===null?oc=zr=n:zr=zr.next=n),lc=!0,Nh||(Nh=!0,cN())}function ao(n,a){if(!Th&&lc){Th=!0;do for(var i=!1,c=oc;c!==null;){if(n!==0){var f=c.pendingLanes;if(f===0)var p=0;else{var b=c.suspendedLanes,T=c.pingedLanes;p=(1<<31-dn(42|n)+1)-1,p&=f&~(b&~T),p=p&201326741?p&201326741|1:p?p|2:0}p!==0&&(i=!0,Bv(c,p))}else p=He,p=hl(c,c===rt?p:0,c.cancelPendingCommit!==null||c.timeoutHandle!==-1),(p&3)===0||ji(c,p)||(i=!0,Bv(c,p));c=c.next}while(i);Th=!1}}function lN(){zv()}function zv(){lc=Nh=!1;var n=0;Js!==0&&xN()&&(n=Js);for(var a=B(),i=null,c=oc;c!==null;){var f=c.next,p=Lv(c,a);p===0?(c.next=null,i===null?oc=f:i.next=f,f===null&&(zr=i)):(i=c,(n!==0||(p&3)!==0)&&(lc=!0)),c=f}Ct!==0&&Ct!==5||ao(n),Js!==0&&(Js=0)}function Lv(n,a){for(var i=n.suspendedLanes,c=n.pingedLanes,f=n.expirationTimes,p=n.pendingLanes&-62914561;0<p;){var b=31-dn(p),T=1<<b,O=f[b];O===-1?((T&i)===0||(T&c)!==0)&&(f[b]=Pj(T,a)):O<=a&&(n.expiredLanes|=T),p&=~T}if(a=rt,i=He,i=hl(n,n===a?i:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),c=n.callbackNode,i===0||n===a&&(Qe===2||Qe===9)||n.cancelPendingCommit!==null)return c!==null&&c!==null&&wi(c),n.callbackNode=null,n.callbackPriority=0;if((i&3)===0||ji(n,i)){if(a=i&-i,a===n.callbackPriority)return a;switch(c!==null&&wi(c),Iu(i)){case 2:case 8:i=qe;break;case 32:i=ft;break;case 268435456:i=Ve;break;default:i=ft}return c=Uv.bind(null,n),i=Xn(i,c),n.callbackPriority=a,n.callbackNode=i,a}return c!==null&&c!==null&&wi(c),n.callbackPriority=2,n.callbackNode=null,2}function Uv(n,a){if(Ct!==0&&Ct!==5)return n.callbackNode=null,n.callbackPriority=0,null;var i=n.callbackNode;if(ic()&&n.callbackNode!==i)return null;var c=He;return c=hl(n,n===rt?c:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),c===0?null:(xv(n,c,a),Lv(n,B()),n.callbackNode!=null&&n.callbackNode===i?Uv.bind(null,n):null)}function Bv(n,a){if(ic())return null;xv(n,a,!0)}function cN(){wN(function(){(We&6)!==0?Xn(De,lN):zv()})}function Eh(){if(Js===0){var n=wr;n===0&&(n=cl,cl<<=1,(cl&261888)===0&&(cl=256)),Js=n}return Js}function Vv(n){return n==null||typeof n=="symbol"||typeof n=="boolean"?null:typeof n=="function"?n:gl(""+n)}function Iv(n,a){var i=a.ownerDocument.createElement("input");return i.name=a.name,i.value=a.value,n.id&&i.setAttribute("form",n.id),a.parentNode.insertBefore(i,a),n=new FormData(n),i.parentNode.removeChild(i),n}function uN(n,a,i,c,f){if(a==="submit"&&i&&i.stateNode===f){var p=Vv((f[tn]||null).action),b=c.submitter;b&&(a=(a=b[tn]||null)?Vv(a.formAction):b.getAttribute("formAction"),a!==null&&(p=a,b=null));var T=new bl("action","action",null,c,f);n.push({event:T,listeners:[{instance:null,listener:function(){if(c.defaultPrevented){if(Js!==0){var O=b?Iv(f,b):new FormData(f);Kd(i,{pending:!0,data:O,method:f.method,action:p},null,O)}}else typeof p=="function"&&(T.preventDefault(),O=b?Iv(f,b):new FormData(f),Kd(i,{pending:!0,data:O,method:f.method,action:p},p,O))},currentTarget:f}]})}}for(var kh=0;kh<ud.length;kh++){var Ch=ud[kh],dN=Ch.toLowerCase(),hN=Ch[0].toUpperCase()+Ch.slice(1);Un(dN,"on"+hN)}Un(vg,"onAnimationEnd"),Un(xg,"onAnimationIteration"),Un(bg,"onAnimationStart"),Un("dblclick","onDoubleClick"),Un("focusin","onFocus"),Un("focusout","onBlur"),Un(k_,"onTransitionRun"),Un(C_,"onTransitionStart"),Un(A_,"onTransitionCancel"),Un(wg,"onTransitionEnd"),or("onMouseEnter",["mouseout","mouseover"]),or("onMouseLeave",["mouseout","mouseover"]),or("onPointerEnter",["pointerout","pointerover"]),or("onPointerLeave",["pointerout","pointerover"]),ba("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ba("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ba("onBeforeInput",["compositionend","keypress","textInput","paste"]),ba("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ba("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ba("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ro="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(" "),fN=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(ro));function $v(n,a){a=(a&4)!==0;for(var i=0;i<n.length;i++){var c=n[i],f=c.event;c=c.listeners;e:{var p=void 0;if(a)for(var b=c.length-1;0<=b;b--){var T=c[b],O=T.instance,G=T.currentTarget;if(T=T.listener,O!==p&&f.isPropagationStopped())break e;p=T,f.currentTarget=G;try{p(f)}catch(X){jl(X)}f.currentTarget=null,p=O}else for(b=0;b<c.length;b++){if(T=c[b],O=T.instance,G=T.currentTarget,T=T.listener,O!==p&&f.isPropagationStopped())break e;p=T,f.currentTarget=G;try{p(f)}catch(X){jl(X)}f.currentTarget=null,p=O}}}}function $e(n,a){var i=a[$u];i===void 0&&(i=a[$u]=new Set);var c=n+"__bubble";i.has(c)||(qv(a,n,2,!1),i.add(c))}function Ah(n,a,i){var c=0;a&&(c|=4),qv(i,n,c,a)}var cc="_reactListening"+Math.random().toString(36).slice(2);function Rh(n){if(!n[cc]){n[cc]=!0,zp.forEach(function(i){i!=="selectionchange"&&(fN.has(i)||Ah(i,!1,n),Ah(i,!0,n))});var a=n.nodeType===9?n:n.ownerDocument;a===null||a[cc]||(a[cc]=!0,Ah("selectionchange",!1,a))}}function qv(n,a,i,c){switch(vx(a)){case 2:var f=IN;break;case 8:f=$N;break;default:f=Fh}i=f.bind(null,a,i,n),f=void 0,!Ju||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(f=!0),c?f!==void 0?n.addEventListener(a,i,{capture:!0,passive:f}):n.addEventListener(a,i,!0):f!==void 0?n.addEventListener(a,i,{passive:f}):n.addEventListener(a,i,!1)}function Oh(n,a,i,c,f){var p=c;if((a&1)===0&&(a&2)===0&&c!==null)e:for(;;){if(c===null)return;var b=c.tag;if(b===3||b===4){var T=c.stateNode.containerInfo;if(T===f)break;if(b===4)for(b=c.return;b!==null;){var O=b.tag;if((O===3||O===4)&&b.stateNode.containerInfo===f)return;b=b.return}for(;T!==null;){if(b=ar(T),b===null)return;if(O=b.tag,O===5||O===6||O===26||O===27){c=p=b;continue e}T=T.parentNode}}c=c.return}Yp(function(){var G=p,X=Xu(i),ee=[];e:{var F=Sg.get(n);if(F!==void 0){var K=bl,ve=n;switch(n){case"keypress":if(vl(i)===0)break e;case"keydown":case"keyup":K=i_;break;case"focusin":ve="focus",K=td;break;case"focusout":ve="blur",K=td;break;case"beforeblur":case"afterblur":K=td;break;case"click":if(i.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":K=Jp;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":K=Yj;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":K=c_;break;case vg:case xg:case bg:K=Jj;break;case wg:K=d_;break;case"scroll":case"scrollend":K=Fj;break;case"wheel":K=f_;break;case"copy":case"cut":case"paste":K=Zj;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":K=Zp;break;case"toggle":case"beforetoggle":K=p_}var Ce=(a&4)!==0,st=!Ce&&(n==="scroll"||n==="scrollend"),I=Ce?F!==null?F+"Capture":null:F;Ce=[];for(var z=G,H;z!==null;){var Q=z;if(H=Q.stateNode,Q=Q.tag,Q!==5&&Q!==26&&Q!==27||H===null||I===null||(Q=Ei(z,I),Q!=null&&Ce.push(io(z,Q,H))),st)break;z=z.return}0<Ce.length&&(F=new K(F,ve,null,i,X),ee.push({event:F,listeners:Ce}))}}if((a&7)===0){e:{if(F=n==="mouseover"||n==="pointerover",K=n==="mouseout"||n==="pointerout",F&&i!==Yu&&(ve=i.relatedTarget||i.fromElement)&&(ar(ve)||ve[sr]))break e;if((K||F)&&(F=X.window===X?X:(F=X.ownerDocument)?F.defaultView||F.parentWindow:window,K?(ve=i.relatedTarget||i.toElement,K=G,ve=ve?ar(ve):null,ve!==null&&(st=u(ve),Ce=ve.tag,ve!==st||Ce!==5&&Ce!==27&&Ce!==6)&&(ve=null)):(K=null,ve=G),K!==ve)){if(Ce=Jp,Q="onMouseLeave",I="onMouseEnter",z="mouse",(n==="pointerout"||n==="pointerover")&&(Ce=Zp,Q="onPointerLeave",I="onPointerEnter",z="pointer"),st=K==null?F:Ti(K),H=ve==null?F:Ti(ve),F=new Ce(Q,z+"leave",K,i,X),F.target=st,F.relatedTarget=H,Q=null,ar(X)===G&&(Ce=new Ce(I,z+"enter",ve,i,X),Ce.target=H,Ce.relatedTarget=st,Q=Ce),st=Q,K&&ve)t:{for(Ce=mN,I=K,z=ve,H=0,Q=I;Q;Q=Ce(Q))H++;Q=0;for(var ke=z;ke;ke=Ce(ke))Q++;for(;0<H-Q;)I=Ce(I),H--;for(;0<Q-H;)z=Ce(z),Q--;for(;H--;){if(I===z||z!==null&&I===z.alternate){Ce=I;break t}I=Ce(I),z=Ce(z)}Ce=null}else Ce=null;K!==null&&Hv(ee,F,K,Ce,!1),ve!==null&&st!==null&&Hv(ee,st,ve,Ce,!0)}}e:{if(F=G?Ti(G):window,K=F.nodeName&&F.nodeName.toLowerCase(),K==="select"||K==="input"&&F.type==="file")var Ye=og;else if(rg(F))if(lg)Ye=N_;else{Ye=j_;var Se=S_}else K=F.nodeName,!K||K.toLowerCase()!=="input"||F.type!=="checkbox"&&F.type!=="radio"?G&&Ku(G.elementType)&&(Ye=og):Ye=__;if(Ye&&(Ye=Ye(n,G))){ig(ee,Ye,i,X);break e}Se&&Se(n,F,G),n==="focusout"&&G&&F.type==="number"&&G.memoizedProps.value!=null&&Fu(F,"number",F.value)}switch(Se=G?Ti(G):window,n){case"focusin":(rg(Se)||Se.contentEditable==="true")&&(fr=Se,od=G,Pi=null);break;case"focusout":Pi=od=fr=null;break;case"mousedown":ld=!0;break;case"contextmenu":case"mouseup":case"dragend":ld=!1,gg(ee,i,X);break;case"selectionchange":if(E_)break;case"keydown":case"keyup":gg(ee,i,X)}var Le;if(sd)e:{switch(n){case"compositionstart":var Ge="onCompositionStart";break e;case"compositionend":Ge="onCompositionEnd";break e;case"compositionupdate":Ge="onCompositionUpdate";break e}Ge=void 0}else hr?sg(n,i)&&(Ge="onCompositionEnd"):n==="keydown"&&i.keyCode===229&&(Ge="onCompositionStart");Ge&&(eg&&i.locale!=="ko"&&(hr||Ge!=="onCompositionStart"?Ge==="onCompositionEnd"&&hr&&(Le=Xp()):(Ps=X,Qu="value"in Ps?Ps.value:Ps.textContent,hr=!0)),Se=uc(G,Ge),0<Se.length&&(Ge=new Qp(Ge,n,null,i,X),ee.push({event:Ge,listeners:Se}),Le?Ge.data=Le:(Le=ag(i),Le!==null&&(Ge.data=Le)))),(Le=y_?v_(n,i):x_(n,i))&&(Ge=uc(G,"onBeforeInput"),0<Ge.length&&(Se=new Qp("onBeforeInput","beforeinput",null,i,X),ee.push({event:Se,listeners:Ge}),Se.data=Le)),uN(ee,n,G,i,X)}$v(ee,a)})}function io(n,a,i){return{instance:n,listener:a,currentTarget:i}}function uc(n,a){for(var i=a+"Capture",c=[];n!==null;){var f=n,p=f.stateNode;if(f=f.tag,f!==5&&f!==26&&f!==27||p===null||(f=Ei(n,i),f!=null&&c.unshift(io(n,f,p)),f=Ei(n,a),f!=null&&c.push(io(n,f,p))),n.tag===3)return c;n=n.return}return[]}function mN(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5&&n.tag!==27);return n||null}function Hv(n,a,i,c,f){for(var p=a._reactName,b=[];i!==null&&i!==c;){var T=i,O=T.alternate,G=T.stateNode;if(T=T.tag,O!==null&&O===c)break;T!==5&&T!==26&&T!==27||G===null||(O=G,f?(G=Ei(i,p),G!=null&&b.unshift(io(i,G,O))):f||(G=Ei(i,p),G!=null&&b.push(io(i,G,O)))),i=i.return}b.length!==0&&n.push({event:a,listeners:b})}var pN=/\r\n?/g,gN=/\u0000|\uFFFD/g;function Gv(n){return(typeof n=="string"?n:""+n).replace(pN,`
|
|
9
|
-
`).replace(gN,"")}function Fv(n,a){return a=Gv(a),Gv(n)===a}function nt(n,a,i,c,f,p){switch(i){case"children":typeof c=="string"?a==="body"||a==="textarea"&&c===""||cr(n,c):(typeof c=="number"||typeof c=="bigint")&&a!=="body"&&cr(n,""+c);break;case"className":ml(n,"class",c);break;case"tabIndex":ml(n,"tabindex",c);break;case"dir":case"role":case"viewBox":case"width":case"height":ml(n,i,c);break;case"style":Fp(n,c,p);break;case"data":if(a!=="object"){ml(n,"data",c);break}case"src":case"href":if(c===""&&(a!=="a"||i!=="href")){n.removeAttribute(i);break}if(c==null||typeof c=="function"||typeof c=="symbol"||typeof c=="boolean"){n.removeAttribute(i);break}c=gl(""+c),n.setAttribute(i,c);break;case"action":case"formAction":if(typeof c=="function"){n.setAttribute(i,"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 p=="function"&&(i==="formAction"?(a!=="input"&&nt(n,a,"name",f.name,f,null),nt(n,a,"formEncType",f.formEncType,f,null),nt(n,a,"formMethod",f.formMethod,f,null),nt(n,a,"formTarget",f.formTarget,f,null)):(nt(n,a,"encType",f.encType,f,null),nt(n,a,"method",f.method,f,null),nt(n,a,"target",f.target,f,null)));if(c==null||typeof c=="symbol"||typeof c=="boolean"){n.removeAttribute(i);break}c=gl(""+c),n.setAttribute(i,c);break;case"onClick":c!=null&&(n.onclick=us);break;case"onScroll":c!=null&&$e("scroll",n);break;case"onScrollEnd":c!=null&&$e("scrollend",n);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(r(61));if(i=c.__html,i!=null){if(f.children!=null)throw Error(r(60));n.innerHTML=i}}break;case"multiple":n.multiple=c&&typeof c!="function"&&typeof c!="symbol";break;case"muted":n.muted=c&&typeof c!="function"&&typeof c!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(c==null||typeof c=="function"||typeof c=="boolean"||typeof c=="symbol"){n.removeAttribute("xlink:href");break}i=gl(""+c),n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",i);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":c!=null&&typeof c!="function"&&typeof c!="symbol"?n.setAttribute(i,""+c):n.removeAttribute(i);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":c&&typeof c!="function"&&typeof c!="symbol"?n.setAttribute(i,""):n.removeAttribute(i);break;case"capture":case"download":c===!0?n.setAttribute(i,""):c!==!1&&c!=null&&typeof c!="function"&&typeof c!="symbol"?n.setAttribute(i,c):n.removeAttribute(i);break;case"cols":case"rows":case"size":case"span":c!=null&&typeof c!="function"&&typeof c!="symbol"&&!isNaN(c)&&1<=c?n.setAttribute(i,c):n.removeAttribute(i);break;case"rowSpan":case"start":c==null||typeof c=="function"||typeof c=="symbol"||isNaN(c)?n.removeAttribute(i):n.setAttribute(i,c);break;case"popover":$e("beforetoggle",n),$e("toggle",n),fl(n,"popover",c);break;case"xlinkActuate":cs(n,"http://www.w3.org/1999/xlink","xlink:actuate",c);break;case"xlinkArcrole":cs(n,"http://www.w3.org/1999/xlink","xlink:arcrole",c);break;case"xlinkRole":cs(n,"http://www.w3.org/1999/xlink","xlink:role",c);break;case"xlinkShow":cs(n,"http://www.w3.org/1999/xlink","xlink:show",c);break;case"xlinkTitle":cs(n,"http://www.w3.org/1999/xlink","xlink:title",c);break;case"xlinkType":cs(n,"http://www.w3.org/1999/xlink","xlink:type",c);break;case"xmlBase":cs(n,"http://www.w3.org/XML/1998/namespace","xml:base",c);break;case"xmlLang":cs(n,"http://www.w3.org/XML/1998/namespace","xml:lang",c);break;case"xmlSpace":cs(n,"http://www.w3.org/XML/1998/namespace","xml:space",c);break;case"is":fl(n,"is",c);break;case"innerText":case"textContent":break;default:(!(2<i.length)||i[0]!=="o"&&i[0]!=="O"||i[1]!=="n"&&i[1]!=="N")&&(i=Hj.get(i)||i,fl(n,i,c))}}function Mh(n,a,i,c,f,p){switch(i){case"style":Fp(n,c,p);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(r(61));if(i=c.__html,i!=null){if(f.children!=null)throw Error(r(60));n.innerHTML=i}}break;case"children":typeof c=="string"?cr(n,c):(typeof c=="number"||typeof c=="bigint")&&cr(n,""+c);break;case"onScroll":c!=null&&$e("scroll",n);break;case"onScrollEnd":c!=null&&$e("scrollend",n);break;case"onClick":c!=null&&(n.onclick=us);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Lp.hasOwnProperty(i))e:{if(i[0]==="o"&&i[1]==="n"&&(f=i.endsWith("Capture"),a=i.slice(2,f?i.length-7:void 0),p=n[tn]||null,p=p!=null?p[i]:null,typeof p=="function"&&n.removeEventListener(a,p,f),typeof c=="function")){typeof p!="function"&&p!==null&&(i in n?n[i]=null:n.hasAttribute(i)&&n.removeAttribute(i)),n.addEventListener(a,c,f);break e}i in n?n[i]=c:c===!0?n.setAttribute(i,""):fl(n,i,c)}}}function qt(n,a,i){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":$e("error",n),$e("load",n);var c=!1,f=!1,p;for(p in i)if(i.hasOwnProperty(p)){var b=i[p];if(b!=null)switch(p){case"src":c=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,a));default:nt(n,a,p,b,i,null)}}f&&nt(n,a,"srcSet",i.srcSet,i,null),c&&nt(n,a,"src",i.src,i,null);return;case"input":$e("invalid",n);var T=p=b=f=null,O=null,G=null;for(c in i)if(i.hasOwnProperty(c)){var X=i[c];if(X!=null)switch(c){case"name":f=X;break;case"type":b=X;break;case"checked":O=X;break;case"defaultChecked":G=X;break;case"value":p=X;break;case"defaultValue":T=X;break;case"children":case"dangerouslySetInnerHTML":if(X!=null)throw Error(r(137,a));break;default:nt(n,a,c,X,i,null)}}$p(n,p,T,O,G,b,f,!1);return;case"select":$e("invalid",n),c=b=p=null;for(f in i)if(i.hasOwnProperty(f)&&(T=i[f],T!=null))switch(f){case"value":p=T;break;case"defaultValue":b=T;break;case"multiple":c=T;default:nt(n,a,f,T,i,null)}a=p,i=b,n.multiple=!!c,a!=null?lr(n,!!c,a,!1):i!=null&&lr(n,!!c,i,!0);return;case"textarea":$e("invalid",n),p=f=c=null;for(b in i)if(i.hasOwnProperty(b)&&(T=i[b],T!=null))switch(b){case"value":c=T;break;case"defaultValue":f=T;break;case"children":p=T;break;case"dangerouslySetInnerHTML":if(T!=null)throw Error(r(91));break;default:nt(n,a,b,T,i,null)}Hp(n,c,f,p);return;case"option":for(O in i)i.hasOwnProperty(O)&&(c=i[O],c!=null)&&(O==="selected"?n.selected=c&&typeof c!="function"&&typeof c!="symbol":nt(n,a,O,c,i,null));return;case"dialog":$e("beforetoggle",n),$e("toggle",n),$e("cancel",n),$e("close",n);break;case"iframe":case"object":$e("load",n);break;case"video":case"audio":for(c=0;c<ro.length;c++)$e(ro[c],n);break;case"image":$e("error",n),$e("load",n);break;case"details":$e("toggle",n);break;case"embed":case"source":case"link":$e("error",n),$e("load",n);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(G in i)if(i.hasOwnProperty(G)&&(c=i[G],c!=null))switch(G){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,a));default:nt(n,a,G,c,i,null)}return;default:if(Ku(a)){for(X in i)i.hasOwnProperty(X)&&(c=i[X],c!==void 0&&Mh(n,a,X,c,i,void 0));return}}for(T in i)i.hasOwnProperty(T)&&(c=i[T],c!=null&&nt(n,a,T,c,i,null))}function yN(n,a,i,c){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var f=null,p=null,b=null,T=null,O=null,G=null,X=null;for(K in i){var ee=i[K];if(i.hasOwnProperty(K)&&ee!=null)switch(K){case"checked":break;case"value":break;case"defaultValue":O=ee;default:c.hasOwnProperty(K)||nt(n,a,K,null,c,ee)}}for(var F in c){var K=c[F];if(ee=i[F],c.hasOwnProperty(F)&&(K!=null||ee!=null))switch(F){case"type":p=K;break;case"name":f=K;break;case"checked":G=K;break;case"defaultChecked":X=K;break;case"value":b=K;break;case"defaultValue":T=K;break;case"children":case"dangerouslySetInnerHTML":if(K!=null)throw Error(r(137,a));break;default:K!==ee&&nt(n,a,F,K,c,ee)}}Gu(n,b,T,O,G,X,p,f);return;case"select":K=b=T=F=null;for(p in i)if(O=i[p],i.hasOwnProperty(p)&&O!=null)switch(p){case"value":break;case"multiple":K=O;default:c.hasOwnProperty(p)||nt(n,a,p,null,c,O)}for(f in c)if(p=c[f],O=i[f],c.hasOwnProperty(f)&&(p!=null||O!=null))switch(f){case"value":F=p;break;case"defaultValue":T=p;break;case"multiple":b=p;default:p!==O&&nt(n,a,f,p,c,O)}a=T,i=b,c=K,F!=null?lr(n,!!i,F,!1):!!c!=!!i&&(a!=null?lr(n,!!i,a,!0):lr(n,!!i,i?[]:"",!1));return;case"textarea":K=F=null;for(T in i)if(f=i[T],i.hasOwnProperty(T)&&f!=null&&!c.hasOwnProperty(T))switch(T){case"value":break;case"children":break;default:nt(n,a,T,null,c,f)}for(b in c)if(f=c[b],p=i[b],c.hasOwnProperty(b)&&(f!=null||p!=null))switch(b){case"value":F=f;break;case"defaultValue":K=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(r(91));break;default:f!==p&&nt(n,a,b,f,c,p)}qp(n,F,K);return;case"option":for(var ve in i)F=i[ve],i.hasOwnProperty(ve)&&F!=null&&!c.hasOwnProperty(ve)&&(ve==="selected"?n.selected=!1:nt(n,a,ve,null,c,F));for(O in c)F=c[O],K=i[O],c.hasOwnProperty(O)&&F!==K&&(F!=null||K!=null)&&(O==="selected"?n.selected=F&&typeof F!="function"&&typeof F!="symbol":nt(n,a,O,F,c,K));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 Ce in i)F=i[Ce],i.hasOwnProperty(Ce)&&F!=null&&!c.hasOwnProperty(Ce)&&nt(n,a,Ce,null,c,F);for(G in c)if(F=c[G],K=i[G],c.hasOwnProperty(G)&&F!==K&&(F!=null||K!=null))switch(G){case"children":case"dangerouslySetInnerHTML":if(F!=null)throw Error(r(137,a));break;default:nt(n,a,G,F,c,K)}return;default:if(Ku(a)){for(var st in i)F=i[st],i.hasOwnProperty(st)&&F!==void 0&&!c.hasOwnProperty(st)&&Mh(n,a,st,void 0,c,F);for(X in c)F=c[X],K=i[X],!c.hasOwnProperty(X)||F===K||F===void 0&&K===void 0||Mh(n,a,X,F,c,K);return}}for(var I in i)F=i[I],i.hasOwnProperty(I)&&F!=null&&!c.hasOwnProperty(I)&&nt(n,a,I,null,c,F);for(ee in c)F=c[ee],K=i[ee],!c.hasOwnProperty(ee)||F===K||F==null&&K==null||nt(n,a,ee,F,c,K)}function Kv(n){switch(n){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function vN(){if(typeof performance.getEntriesByType=="function"){for(var n=0,a=0,i=performance.getEntriesByType("resource"),c=0;c<i.length;c++){var f=i[c],p=f.transferSize,b=f.initiatorType,T=f.duration;if(p&&T&&Kv(b)){for(b=0,T=f.responseEnd,c+=1;c<i.length;c++){var O=i[c],G=O.startTime;if(G>T)break;var X=O.transferSize,ee=O.initiatorType;X&&Kv(ee)&&(O=O.responseEnd,b+=X*(O<T?1:(T-G)/(O-G)))}if(--c,a+=8*(p+b)/(f.duration/1e3),n++,10<n)break}}if(0<n)return a/n/1e6}return navigator.connection&&(n=navigator.connection.downlink,typeof n=="number")?n:5}var Dh=null,Ph=null;function dc(n){return n.nodeType===9?n:n.ownerDocument}function Yv(n){switch(n){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Xv(n,a){if(n===0)switch(a){case"svg":return 1;case"math":return 2;default:return 0}return n===1&&a==="foreignObject"?0:n}function zh(n,a){return n==="textarea"||n==="noscript"||typeof a.children=="string"||typeof a.children=="number"||typeof a.children=="bigint"||typeof a.dangerouslySetInnerHTML=="object"&&a.dangerouslySetInnerHTML!==null&&a.dangerouslySetInnerHTML.__html!=null}var Lh=null;function xN(){var n=window.event;return n&&n.type==="popstate"?n===Lh?!1:(Lh=n,!0):(Lh=null,!1)}var Wv=typeof setTimeout=="function"?setTimeout:void 0,bN=typeof clearTimeout=="function"?clearTimeout:void 0,Jv=typeof Promise=="function"?Promise:void 0,wN=typeof queueMicrotask=="function"?queueMicrotask:typeof Jv<"u"?function(n){return Jv.resolve(null).then(n).catch(SN)}:Wv;function SN(n){setTimeout(function(){throw n})}function Qs(n){return n==="head"}function Qv(n,a){var i=a,c=0;do{var f=i.nextSibling;if(n.removeChild(i),f&&f.nodeType===8)if(i=f.data,i==="/$"||i==="/&"){if(c===0){n.removeChild(f),Vr(a);return}c--}else if(i==="$"||i==="$?"||i==="$~"||i==="$!"||i==="&")c++;else if(i==="html")oo(n.ownerDocument.documentElement);else if(i==="head"){i=n.ownerDocument.head,oo(i);for(var p=i.firstChild;p;){var b=p.nextSibling,T=p.nodeName;p[Ni]||T==="SCRIPT"||T==="STYLE"||T==="LINK"&&p.rel.toLowerCase()==="stylesheet"||i.removeChild(p),p=b}}else i==="body"&&oo(n.ownerDocument.body);i=f}while(i);Vr(a)}function Zv(n,a){var i=n;n=0;do{var c=i.nextSibling;if(i.nodeType===1?a?(i._stashedDisplay=i.style.display,i.style.display="none"):(i.style.display=i._stashedDisplay||"",i.getAttribute("style")===""&&i.removeAttribute("style")):i.nodeType===3&&(a?(i._stashedText=i.nodeValue,i.nodeValue=""):i.nodeValue=i._stashedText||""),c&&c.nodeType===8)if(i=c.data,i==="/$"){if(n===0)break;n--}else i!=="$"&&i!=="$?"&&i!=="$~"&&i!=="$!"||n++;i=c}while(i)}function Uh(n){var a=n.firstChild;for(a&&a.nodeType===10&&(a=a.nextSibling);a;){var i=a;switch(a=a.nextSibling,i.nodeName){case"HTML":case"HEAD":case"BODY":Uh(i),qu(i);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(i.rel.toLowerCase()==="stylesheet")continue}n.removeChild(i)}}function jN(n,a,i,c){for(;n.nodeType===1;){var f=i;if(n.nodeName.toLowerCase()!==a.toLowerCase()){if(!c&&(n.nodeName!=="INPUT"||n.type!=="hidden"))break}else if(c){if(!n[Ni])switch(a){case"meta":if(!n.hasAttribute("itemprop"))break;return n;case"link":if(p=n.getAttribute("rel"),p==="stylesheet"&&n.hasAttribute("data-precedence"))break;if(p!==f.rel||n.getAttribute("href")!==(f.href==null||f.href===""?null:f.href)||n.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin)||n.getAttribute("title")!==(f.title==null?null:f.title))break;return n;case"style":if(n.hasAttribute("data-precedence"))break;return n;case"script":if(p=n.getAttribute("src"),(p!==(f.src==null?null:f.src)||n.getAttribute("type")!==(f.type==null?null:f.type)||n.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&p&&n.hasAttribute("async")&&!n.hasAttribute("itemprop"))break;return n;default:return n}}else if(a==="input"&&n.type==="hidden"){var p=f.name==null?null:""+f.name;if(f.type==="hidden"&&n.getAttribute("name")===p)return n}else return n;if(n=Mn(n.nextSibling),n===null)break}return null}function _N(n,a,i){if(a==="")return null;for(;n.nodeType!==3;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!i||(n=Mn(n.nextSibling),n===null))return null;return n}function ex(n,a){for(;n.nodeType!==8;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!a||(n=Mn(n.nextSibling),n===null))return null;return n}function Bh(n){return n.data==="$?"||n.data==="$~"}function Vh(n){return n.data==="$!"||n.data==="$?"&&n.ownerDocument.readyState!=="loading"}function NN(n,a){var i=n.ownerDocument;if(n.data==="$~")n._reactRetry=a;else if(n.data!=="$?"||i.readyState!=="loading")a();else{var c=function(){a(),i.removeEventListener("DOMContentLoaded",c)};i.addEventListener("DOMContentLoaded",c),n._reactRetry=c}}function Mn(n){for(;n!=null;n=n.nextSibling){var a=n.nodeType;if(a===1||a===3)break;if(a===8){if(a=n.data,a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"||a==="F!"||a==="F")break;if(a==="/$"||a==="/&")return null}}return n}var Ih=null;function tx(n){n=n.nextSibling;for(var a=0;n;){if(n.nodeType===8){var i=n.data;if(i==="/$"||i==="/&"){if(a===0)return Mn(n.nextSibling);a--}else i!=="$"&&i!=="$!"&&i!=="$?"&&i!=="$~"&&i!=="&"||a++}n=n.nextSibling}return null}function nx(n){n=n.previousSibling;for(var a=0;n;){if(n.nodeType===8){var i=n.data;if(i==="$"||i==="$!"||i==="$?"||i==="$~"||i==="&"){if(a===0)return n;a--}else i!=="/$"&&i!=="/&"||a++}n=n.previousSibling}return null}function sx(n,a,i){switch(a=dc(i),n){case"html":if(n=a.documentElement,!n)throw Error(r(452));return n;case"head":if(n=a.head,!n)throw Error(r(453));return n;case"body":if(n=a.body,!n)throw Error(r(454));return n;default:throw Error(r(451))}}function oo(n){for(var a=n.attributes;a.length;)n.removeAttributeNode(a[0]);qu(n)}var Dn=new Map,ax=new Set;function hc(n){return typeof n.getRootNode=="function"?n.getRootNode():n.nodeType===9?n:n.ownerDocument}var Ts=Y.d;Y.d={f:TN,r:EN,D:kN,C:CN,L:AN,m:RN,X:MN,S:ON,M:DN};function TN(){var n=Ts.f(),a=sc();return n||a}function EN(n){var a=rr(n);a!==null&&a.tag===5&&a.type==="form"?wy(a):Ts.r(n)}var Lr=typeof document>"u"?null:document;function rx(n,a,i){var c=Lr;if(c&&typeof a=="string"&&a){var f=Tn(a);f='link[rel="'+n+'"][href="'+f+'"]',typeof i=="string"&&(f+='[crossorigin="'+i+'"]'),ax.has(f)||(ax.add(f),n={rel:n,crossOrigin:i,href:a},c.querySelector(f)===null&&(a=c.createElement("link"),qt(a,"link",n),Mt(a),c.head.appendChild(a)))}}function kN(n){Ts.D(n),rx("dns-prefetch",n,null)}function CN(n,a){Ts.C(n,a),rx("preconnect",n,a)}function AN(n,a,i){Ts.L(n,a,i);var c=Lr;if(c&&n&&a){var f='link[rel="preload"][as="'+Tn(a)+'"]';a==="image"&&i&&i.imageSrcSet?(f+='[imagesrcset="'+Tn(i.imageSrcSet)+'"]',typeof i.imageSizes=="string"&&(f+='[imagesizes="'+Tn(i.imageSizes)+'"]')):f+='[href="'+Tn(n)+'"]';var p=f;switch(a){case"style":p=Ur(n);break;case"script":p=Br(n)}Dn.has(p)||(n=x({rel:"preload",href:a==="image"&&i&&i.imageSrcSet?void 0:n,as:a},i),Dn.set(p,n),c.querySelector(f)!==null||a==="style"&&c.querySelector(lo(p))||a==="script"&&c.querySelector(co(p))||(a=c.createElement("link"),qt(a,"link",n),Mt(a),c.head.appendChild(a)))}}function RN(n,a){Ts.m(n,a);var i=Lr;if(i&&n){var c=a&&typeof a.as=="string"?a.as:"script",f='link[rel="modulepreload"][as="'+Tn(c)+'"][href="'+Tn(n)+'"]',p=f;switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":p=Br(n)}if(!Dn.has(p)&&(n=x({rel:"modulepreload",href:n},a),Dn.set(p,n),i.querySelector(f)===null)){switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(i.querySelector(co(p)))return}c=i.createElement("link"),qt(c,"link",n),Mt(c),i.head.appendChild(c)}}}function ON(n,a,i){Ts.S(n,a,i);var c=Lr;if(c&&n){var f=ir(c).hoistableStyles,p=Ur(n);a=a||"default";var b=f.get(p);if(!b){var T={loading:0,preload:null};if(b=c.querySelector(lo(p)))T.loading=5;else{n=x({rel:"stylesheet",href:n,"data-precedence":a},i),(i=Dn.get(p))&&$h(n,i);var O=b=c.createElement("link");Mt(O),qt(O,"link",n),O._p=new Promise(function(G,X){O.onload=G,O.onerror=X}),O.addEventListener("load",function(){T.loading|=1}),O.addEventListener("error",function(){T.loading|=2}),T.loading|=4,fc(b,a,c)}b={type:"stylesheet",instance:b,count:1,state:T},f.set(p,b)}}}function MN(n,a){Ts.X(n,a);var i=Lr;if(i&&n){var c=ir(i).hoistableScripts,f=Br(n),p=c.get(f);p||(p=i.querySelector(co(f)),p||(n=x({src:n,async:!0},a),(a=Dn.get(f))&&qh(n,a),p=i.createElement("script"),Mt(p),qt(p,"link",n),i.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},c.set(f,p))}}function DN(n,a){Ts.M(n,a);var i=Lr;if(i&&n){var c=ir(i).hoistableScripts,f=Br(n),p=c.get(f);p||(p=i.querySelector(co(f)),p||(n=x({src:n,async:!0,type:"module"},a),(a=Dn.get(f))&&qh(n,a),p=i.createElement("script"),Mt(p),qt(p,"link",n),i.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},c.set(f,p))}}function ix(n,a,i,c){var f=(f=ue.current)?hc(f):null;if(!f)throw Error(r(446));switch(n){case"meta":case"title":return null;case"style":return typeof i.precedence=="string"&&typeof i.href=="string"?(a=Ur(i.href),i=ir(f).hoistableStyles,c=i.get(a),c||(c={type:"style",instance:null,count:0,state:null},i.set(a,c)),c):{type:"void",instance:null,count:0,state:null};case"link":if(i.rel==="stylesheet"&&typeof i.href=="string"&&typeof i.precedence=="string"){n=Ur(i.href);var p=ir(f).hoistableStyles,b=p.get(n);if(b||(f=f.ownerDocument||f,b={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},p.set(n,b),(p=f.querySelector(lo(n)))&&!p._p&&(b.instance=p,b.state.loading=5),Dn.has(n)||(i={rel:"preload",as:"style",href:i.href,crossOrigin:i.crossOrigin,integrity:i.integrity,media:i.media,hrefLang:i.hrefLang,referrerPolicy:i.referrerPolicy},Dn.set(n,i),p||PN(f,n,i,b.state))),a&&c===null)throw Error(r(528,""));return b}if(a&&c!==null)throw Error(r(529,""));return null;case"script":return a=i.async,i=i.src,typeof i=="string"&&a&&typeof a!="function"&&typeof a!="symbol"?(a=Br(i),i=ir(f).hoistableScripts,c=i.get(a),c||(c={type:"script",instance:null,count:0,state:null},i.set(a,c)),c):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,n))}}function Ur(n){return'href="'+Tn(n)+'"'}function lo(n){return'link[rel="stylesheet"]['+n+"]"}function ox(n){return x({},n,{"data-precedence":n.precedence,precedence:null})}function PN(n,a,i,c){n.querySelector('link[rel="preload"][as="style"]['+a+"]")?c.loading=1:(a=n.createElement("link"),c.preload=a,a.addEventListener("load",function(){return c.loading|=1}),a.addEventListener("error",function(){return c.loading|=2}),qt(a,"link",i),Mt(a),n.head.appendChild(a))}function Br(n){return'[src="'+Tn(n)+'"]'}function co(n){return"script[async]"+n}function lx(n,a,i){if(a.count++,a.instance===null)switch(a.type){case"style":var c=n.querySelector('style[data-href~="'+Tn(i.href)+'"]');if(c)return a.instance=c,Mt(c),c;var f=x({},i,{"data-href":i.href,"data-precedence":i.precedence,href:null,precedence:null});return c=(n.ownerDocument||n).createElement("style"),Mt(c),qt(c,"style",f),fc(c,i.precedence,n),a.instance=c;case"stylesheet":f=Ur(i.href);var p=n.querySelector(lo(f));if(p)return a.state.loading|=4,a.instance=p,Mt(p),p;c=ox(i),(f=Dn.get(f))&&$h(c,f),p=(n.ownerDocument||n).createElement("link"),Mt(p);var b=p;return b._p=new Promise(function(T,O){b.onload=T,b.onerror=O}),qt(p,"link",c),a.state.loading|=4,fc(p,i.precedence,n),a.instance=p;case"script":return p=Br(i.src),(f=n.querySelector(co(p)))?(a.instance=f,Mt(f),f):(c=i,(f=Dn.get(p))&&(c=x({},i),qh(c,f)),n=n.ownerDocument||n,f=n.createElement("script"),Mt(f),qt(f,"link",c),n.head.appendChild(f),a.instance=f);case"void":return null;default:throw Error(r(443,a.type))}else a.type==="stylesheet"&&(a.state.loading&4)===0&&(c=a.instance,a.state.loading|=4,fc(c,i.precedence,n));return a.instance}function fc(n,a,i){for(var c=i.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=c.length?c[c.length-1]:null,p=f,b=0;b<c.length;b++){var T=c[b];if(T.dataset.precedence===a)p=T;else if(p!==f)break}p?p.parentNode.insertBefore(n,p.nextSibling):(a=i.nodeType===9?i.head:i,a.insertBefore(n,a.firstChild))}function $h(n,a){n.crossOrigin==null&&(n.crossOrigin=a.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=a.referrerPolicy),n.title==null&&(n.title=a.title)}function qh(n,a){n.crossOrigin==null&&(n.crossOrigin=a.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=a.referrerPolicy),n.integrity==null&&(n.integrity=a.integrity)}var mc=null;function cx(n,a,i){if(mc===null){var c=new Map,f=mc=new Map;f.set(i,c)}else f=mc,c=f.get(i),c||(c=new Map,f.set(i,c));if(c.has(n))return c;for(c.set(n,null),i=i.getElementsByTagName(n),f=0;f<i.length;f++){var p=i[f];if(!(p[Ni]||p[Bt]||n==="link"&&p.getAttribute("rel")==="stylesheet")&&p.namespaceURI!=="http://www.w3.org/2000/svg"){var b=p.getAttribute(a)||"";b=n+b;var T=c.get(b);T?T.push(p):c.set(b,[p])}}return c}function ux(n,a,i){n=n.ownerDocument||n,n.head.insertBefore(i,a==="title"?n.querySelector("head > title"):null)}function zN(n,a,i){if(i===1||a.itemProp!=null)return!1;switch(n){case"meta":case"title":return!0;case"style":if(typeof a.precedence!="string"||typeof a.href!="string"||a.href==="")break;return!0;case"link":if(typeof a.rel!="string"||typeof a.href!="string"||a.href===""||a.onLoad||a.onError)break;return a.rel==="stylesheet"?(n=a.disabled,typeof a.precedence=="string"&&n==null):!0;case"script":if(a.async&&typeof a.async!="function"&&typeof a.async!="symbol"&&!a.onLoad&&!a.onError&&a.src&&typeof a.src=="string")return!0}return!1}function dx(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function LN(n,a,i,c){if(i.type==="stylesheet"&&(typeof c.media!="string"||matchMedia(c.media).matches!==!1)&&(i.state.loading&4)===0){if(i.instance===null){var f=Ur(c.href),p=a.querySelector(lo(f));if(p){a=p._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(n.count++,n=pc.bind(n),a.then(n,n)),i.state.loading|=4,i.instance=p,Mt(p);return}p=a.ownerDocument||a,c=ox(c),(f=Dn.get(f))&&$h(c,f),p=p.createElement("link"),Mt(p);var b=p;b._p=new Promise(function(T,O){b.onload=T,b.onerror=O}),qt(p,"link",c),i.instance=p}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(i,a),(a=i.state.preload)&&(i.state.loading&3)===0&&(n.count++,i=pc.bind(n),a.addEventListener("load",i),a.addEventListener("error",i))}}var Hh=0;function UN(n,a){return n.stylesheets&&n.count===0&&yc(n,n.stylesheets),0<n.count||0<n.imgCount?function(i){var c=setTimeout(function(){if(n.stylesheets&&yc(n,n.stylesheets),n.unsuspend){var p=n.unsuspend;n.unsuspend=null,p()}},6e4+a);0<n.imgBytes&&Hh===0&&(Hh=62500*vN());var f=setTimeout(function(){if(n.waitingForImages=!1,n.count===0&&(n.stylesheets&&yc(n,n.stylesheets),n.unsuspend)){var p=n.unsuspend;n.unsuspend=null,p()}},(n.imgBytes>Hh?50:800)+a);return n.unsuspend=i,function(){n.unsuspend=null,clearTimeout(c),clearTimeout(f)}}:null}function pc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)yc(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var gc=null;function yc(n,a){n.stylesheets=null,n.unsuspend!==null&&(n.count++,gc=new Map,a.forEach(BN,n),gc=null,pc.call(n))}function BN(n,a){if(!(a.state.loading&4)){var i=gc.get(n);if(i)var c=i.get(null);else{i=new Map,gc.set(n,i);for(var f=n.querySelectorAll("link[data-precedence],style[data-precedence]"),p=0;p<f.length;p++){var b=f[p];(b.nodeName==="LINK"||b.getAttribute("media")!=="not all")&&(i.set(b.dataset.precedence,b),c=b)}c&&i.set(null,c)}f=a.instance,b=f.getAttribute("data-precedence"),p=i.get(b)||c,p===c&&i.set(null,f),i.set(b,f),this.count++,c=pc.bind(this),f.addEventListener("load",c),f.addEventListener("error",c),p?p.parentNode.insertBefore(f,p.nextSibling):(n=n.nodeType===9?n.head:n,n.insertBefore(f,n.firstChild)),a.state.loading|=4}}var uo={$$typeof:C,Provider:null,Consumer:null,_currentValue:J,_currentValue2:J,_threadCount:0};function VN(n,a,i,c,f,p,b,T,O){this.tag=1,this.containerInfo=n,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=Bu(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Bu(0),this.hiddenUpdates=Bu(null),this.identifierPrefix=c,this.onUncaughtError=f,this.onCaughtError=p,this.onRecoverableError=b,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=O,this.incompleteTransitions=new Map}function hx(n,a,i,c,f,p,b,T,O,G,X,ee){return n=new VN(n,a,i,b,O,G,X,ee,T),a=1,p===!0&&(a|=24),p=fn(3,null,null,a),n.current=p,p.stateNode=n,a=jd(),a.refCount++,n.pooledCache=a,a.refCount++,p.memoizedState={element:c,isDehydrated:i,cache:a},Ed(p),n}function fx(n){return n?(n=gr,n):gr}function mx(n,a,i,c,f,p){f=fx(f),c.context===null?c.context=f:c.pendingContext=f,c=Is(a),c.payload={element:i},p=p===void 0?null:p,p!==null&&(c.callback=p),i=$s(n,c,a),i!==null&&(ln(i,n,a),$i(i,n,a))}function px(n,a){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var i=n.retryLane;n.retryLane=i!==0&&i<a?i:a}}function Gh(n,a){px(n,a),(n=n.alternate)&&px(n,a)}function gx(n){if(n.tag===13||n.tag===31){var a=_a(n,67108864);a!==null&&ln(a,n,67108864),Gh(n,67108864)}}function yx(n){if(n.tag===13||n.tag===31){var a=vn();a=Vu(a);var i=_a(n,a);i!==null&&ln(i,n,a),Gh(n,a)}}var vc=!0;function IN(n,a,i,c){var f=$.T;$.T=null;var p=Y.p;try{Y.p=2,Fh(n,a,i,c)}finally{Y.p=p,$.T=f}}function $N(n,a,i,c){var f=$.T;$.T=null;var p=Y.p;try{Y.p=8,Fh(n,a,i,c)}finally{Y.p=p,$.T=f}}function Fh(n,a,i,c){if(vc){var f=Kh(c);if(f===null)Oh(n,a,c,xc,i),xx(n,c);else if(HN(f,n,a,i,c))c.stopPropagation();else if(xx(n,c),a&4&&-1<qN.indexOf(n)){for(;f!==null;){var p=rr(f);if(p!==null)switch(p.tag){case 3:if(p=p.stateNode,p.current.memoizedState.isDehydrated){var b=xa(p.pendingLanes);if(b!==0){var T=p;for(T.pendingLanes|=2,T.entangledLanes|=2;b;){var O=1<<31-dn(b);T.entanglements[1]|=O,b&=~O}es(p),(We&6)===0&&(tc=B()+500,ao(0))}}break;case 31:case 13:T=_a(p,2),T!==null&&ln(T,p,2),sc(),Gh(p,2)}if(p=Kh(c),p===null&&Oh(n,a,c,xc,i),p===f)break;f=p}f!==null&&c.stopPropagation()}else Oh(n,a,c,null,i)}}function Kh(n){return n=Xu(n),Yh(n)}var xc=null;function Yh(n){if(xc=null,n=ar(n),n!==null){var a=u(n);if(a===null)n=null;else{var i=a.tag;if(i===13){if(n=d(a),n!==null)return n;n=null}else if(i===31){if(n=h(a),n!==null)return n;n=null}else if(i===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;n=null}else a!==n&&(n=null)}}return xc=n,null}function vx(n){switch(n){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(re()){case De:return 2;case qe:return 8;case ft:case Zt:return 32;case Ve:return 268435456;default:return 32}default:return 32}}var Xh=!1,Zs=null,ea=null,ta=null,ho=new Map,fo=new Map,na=[],qN="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 xx(n,a){switch(n){case"focusin":case"focusout":Zs=null;break;case"dragenter":case"dragleave":ea=null;break;case"mouseover":case"mouseout":ta=null;break;case"pointerover":case"pointerout":ho.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":fo.delete(a.pointerId)}}function mo(n,a,i,c,f,p){return n===null||n.nativeEvent!==p?(n={blockedOn:a,domEventName:i,eventSystemFlags:c,nativeEvent:p,targetContainers:[f]},a!==null&&(a=rr(a),a!==null&&gx(a)),n):(n.eventSystemFlags|=c,a=n.targetContainers,f!==null&&a.indexOf(f)===-1&&a.push(f),n)}function HN(n,a,i,c,f){switch(a){case"focusin":return Zs=mo(Zs,n,a,i,c,f),!0;case"dragenter":return ea=mo(ea,n,a,i,c,f),!0;case"mouseover":return ta=mo(ta,n,a,i,c,f),!0;case"pointerover":var p=f.pointerId;return ho.set(p,mo(ho.get(p)||null,n,a,i,c,f)),!0;case"gotpointercapture":return p=f.pointerId,fo.set(p,mo(fo.get(p)||null,n,a,i,c,f)),!0}return!1}function bx(n){var a=ar(n.target);if(a!==null){var i=u(a);if(i!==null){if(a=i.tag,a===13){if(a=d(i),a!==null){n.blockedOn=a,Dp(n.priority,function(){yx(i)});return}}else if(a===31){if(a=h(i),a!==null){n.blockedOn=a,Dp(n.priority,function(){yx(i)});return}}else if(a===3&&i.stateNode.current.memoizedState.isDehydrated){n.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}n.blockedOn=null}function bc(n){if(n.blockedOn!==null)return!1;for(var a=n.targetContainers;0<a.length;){var i=Kh(n.nativeEvent);if(i===null){i=n.nativeEvent;var c=new i.constructor(i.type,i);Yu=c,i.target.dispatchEvent(c),Yu=null}else return a=rr(i),a!==null&&gx(a),n.blockedOn=i,!1;a.shift()}return!0}function wx(n,a,i){bc(n)&&i.delete(a)}function GN(){Xh=!1,Zs!==null&&bc(Zs)&&(Zs=null),ea!==null&&bc(ea)&&(ea=null),ta!==null&&bc(ta)&&(ta=null),ho.forEach(wx),fo.forEach(wx)}function wc(n,a){n.blockedOn===a&&(n.blockedOn=null,Xh||(Xh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,GN)))}var Sc=null;function Sx(n){Sc!==n&&(Sc=n,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Sc===n&&(Sc=null);for(var a=0;a<n.length;a+=3){var i=n[a],c=n[a+1],f=n[a+2];if(typeof c!="function"){if(Yh(c||i)===null)continue;break}var p=rr(i);p!==null&&(n.splice(a,3),a-=3,Kd(p,{pending:!0,data:f,method:i.method,action:c},c,f))}}))}function Vr(n){function a(O){return wc(O,n)}Zs!==null&&wc(Zs,n),ea!==null&&wc(ea,n),ta!==null&&wc(ta,n),ho.forEach(a),fo.forEach(a);for(var i=0;i<na.length;i++){var c=na[i];c.blockedOn===n&&(c.blockedOn=null)}for(;0<na.length&&(i=na[0],i.blockedOn===null);)bx(i),i.blockedOn===null&&na.shift();if(i=(n.ownerDocument||n).$$reactFormReplay,i!=null)for(c=0;c<i.length;c+=3){var f=i[c],p=i[c+1],b=f[tn]||null;if(typeof p=="function")b||Sx(i);else if(b){var T=null;if(p&&p.hasAttribute("formAction")){if(f=p,b=p[tn]||null)T=b.formAction;else if(Yh(f)!==null)continue}else T=b.action;typeof T=="function"?i[c+1]=T:(i.splice(c,3),c-=3),Sx(i)}}}function jx(){function n(p){p.canIntercept&&p.info==="react-transition"&&p.intercept({handler:function(){return new Promise(function(b){return f=b})},focusReset:"manual",scroll:"manual"})}function a(){f!==null&&(f(),f=null),c||setTimeout(i,20)}function i(){if(!c&&!navigation.transition){var p=navigation.currentEntry;p&&p.url!=null&&navigation.navigate(p.url,{state:p.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var c=!1,f=null;return navigation.addEventListener("navigate",n),navigation.addEventListener("navigatesuccess",a),navigation.addEventListener("navigateerror",a),setTimeout(i,100),function(){c=!0,navigation.removeEventListener("navigate",n),navigation.removeEventListener("navigatesuccess",a),navigation.removeEventListener("navigateerror",a),f!==null&&(f(),f=null)}}}function Wh(n){this._internalRoot=n}jc.prototype.render=Wh.prototype.render=function(n){var a=this._internalRoot;if(a===null)throw Error(r(409));var i=a.current,c=vn();mx(i,c,n,a,null,null)},jc.prototype.unmount=Wh.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var a=n.containerInfo;mx(n.current,2,null,n,null,null),sc(),a[sr]=null}};function jc(n){this._internalRoot=n}jc.prototype.unstable_scheduleHydration=function(n){if(n){var a=Mp();n={blockedOn:null,target:n,priority:a};for(var i=0;i<na.length&&a!==0&&a<na[i].priority;i++);na.splice(i,0,n),i===0&&bx(n)}};var _x=e.version;if(_x!=="19.2.4")throw Error(r(527,_x,"19.2.4"));Y.findDOMNode=function(n){var a=n._reactInternals;if(a===void 0)throw typeof n.render=="function"?Error(r(188)):(n=Object.keys(n).join(","),Error(r(268,n)));return n=g(a),n=n!==null?y(n):null,n=n===null?null:n.stateNode,n};var FN={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:$,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var _c=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!_c.isDisabled&&_c.supportsFiber)try{Ms=_c.inject(FN),Kt=_c}catch{}}return go.createRoot=function(n,a){if(!l(n))throw Error(r(299));var i=!1,c="",f=Ry,p=Oy,b=My;return a!=null&&(a.unstable_strictMode===!0&&(i=!0),a.identifierPrefix!==void 0&&(c=a.identifierPrefix),a.onUncaughtError!==void 0&&(f=a.onUncaughtError),a.onCaughtError!==void 0&&(p=a.onCaughtError),a.onRecoverableError!==void 0&&(b=a.onRecoverableError)),a=hx(n,1,!1,null,null,i,c,null,f,p,b,jx),n[sr]=a.current,Rh(n),new Wh(a)},go.hydrateRoot=function(n,a,i){if(!l(n))throw Error(r(299));var c=!1,f="",p=Ry,b=Oy,T=My,O=null;return i!=null&&(i.unstable_strictMode===!0&&(c=!0),i.identifierPrefix!==void 0&&(f=i.identifierPrefix),i.onUncaughtError!==void 0&&(p=i.onUncaughtError),i.onCaughtError!==void 0&&(b=i.onCaughtError),i.onRecoverableError!==void 0&&(T=i.onRecoverableError),i.formState!==void 0&&(O=i.formState)),a=hx(n,1,!0,a,i??null,c,f,O,p,b,T,jx),a.context=fx(null),i=a.current,c=vn(),c=Vu(c),f=Is(c),f.callback=null,$s(i,f,c),i=c,a.current.lanes=i,_i(a,i),es(a),n[sr]=a.current,Rh(n),new jc(a)},go.version="19.2.4",go}var Dx;function n2(){if(Dx)return Zh.exports;Dx=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Zh.exports=t2(),Zh.exports}var s2=n2(),ss=function(){return ss=Object.assign||function(e){for(var s,r=1,l=arguments.length;r<l;r++){s=arguments[r];for(var u in s)Object.prototype.hasOwnProperty.call(s,u)&&(e[u]=s[u])}return e},ss.apply(this,arguments)};function pi(t,e){var s={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(s[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var l=0,r=Object.getOwnPropertySymbols(t);l<r.length;l++)e.indexOf(r[l])<0&&Object.prototype.propertyIsEnumerable.call(t,r[l])&&(s[r[l]]=t[r[l]]);return s}function a2(t,e,s,r){function l(u){return u instanceof s?u:new s(function(d){d(u)})}return new(s||(s=Promise))(function(u,d){function h(y){try{g(r.next(y))}catch(x){d(x)}}function m(y){try{g(r.throw(y))}catch(x){d(x)}}function g(y){y.done?u(y.value):l(y.value).then(h,m)}g((r=r.apply(t,e||[])).next())})}function r2(t,e,s){if(s||arguments.length===2)for(var r=0,l=e.length,u;r<l;r++)(u||!(r in e))&&(u||(u=Array.prototype.slice.call(e,0,r)),u[r]=e[r]);return t.concat(u||Array.prototype.slice.call(e))}const i2=t=>t?(...e)=>t(...e):(...e)=>fetch(...e);class Dm extends Error{constructor(e,s="FunctionsError",r){super(e),this.name=s,this.context=r}}class o2 extends Dm{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class Px extends Dm{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class zx extends Dm{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var $f;(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})($f||($f={}));class l2{constructor(e,{headers:s={},customFetch:r,region:l=$f.Any}={}){this.url=e,this.headers=s,this.region=l,this.fetch=i2(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){return a2(this,arguments,void 0,function*(s,r={}){var l;let u,d;try{const{headers:h,method:m,body:g,signal:y,timeout:x}=r;let w={},{region:S}=r;S||(S=this.region);const E=new URL(`${this.url}/${s}`);S&&S!=="any"&&(w["x-region"]=S,E.searchParams.set("forceFunctionRegion",S));let j;g&&(h&&!Object.prototype.hasOwnProperty.call(h,"Content-Type")||!h)?typeof Blob<"u"&&g instanceof Blob||g instanceof ArrayBuffer?(w["Content-Type"]="application/octet-stream",j=g):typeof g=="string"?(w["Content-Type"]="text/plain",j=g):typeof FormData<"u"&&g instanceof FormData?j=g:(w["Content-Type"]="application/json",j=JSON.stringify(g)):g&&typeof g!="string"&&!(typeof Blob<"u"&&g instanceof Blob)&&!(g instanceof ArrayBuffer)&&!(typeof FormData<"u"&&g instanceof FormData)?j=JSON.stringify(g):j=g;let _=y;x&&(d=new AbortController,u=setTimeout(()=>d.abort(),x),y?(_=d.signal,y.addEventListener("abort",()=>d.abort())):_=d.signal);const N=yield this.fetch(E.toString(),{method:m||"POST",headers:Object.assign(Object.assign(Object.assign({},w),this.headers),h),body:j,signal:_}).catch(D=>{throw new o2(D)}),k=N.headers.get("x-relay-error");if(k&&k==="true")throw new Px(N);if(!N.ok)throw new zx(N);let C=((l=N.headers.get("Content-Type"))!==null&&l!==void 0?l:"text/plain").split(";")[0].trim(),A;return C==="application/json"?A=yield N.json():C==="application/octet-stream"||C==="application/pdf"?A=yield N.blob():C==="text/event-stream"?A=N:C==="multipart/form-data"?A=yield N.formData():A=yield N.text(),{data:A,error:null,response:N}}catch(h){return{data:null,error:h,response:h instanceof zx||h instanceof Px?h.context:void 0}}finally{u&&clearTimeout(u)}})}}var c2=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.code=t.code}},u2=class{constructor(t){var e,s,r;this.shouldThrowOnError=!1,this.method=t.method,this.url=t.url,this.headers=new Headers(t.headers),this.schema=t.schema,this.body=t.body,this.shouldThrowOnError=(e=t.shouldThrowOnError)!==null&&e!==void 0?e:!1,this.signal=t.signal,this.isMaybeSingle=(s=t.isMaybeSingle)!==null&&s!==void 0?s:!1,this.urlLengthLimit=(r=t.urlLengthLimit)!==null&&r!==void 0?r:8e3,t.fetch?this.fetch=t.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,e){return this.headers=new Headers(this.headers),this.headers.set(t,e),this}then(t,e){var s=this;this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");const r=this.fetch;let l=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{let d=null,h=null,m=null,g=u.status,y=u.statusText;if(u.ok){var x,w;if(s.method!=="HEAD"){var S;const N=await u.text();N===""||(s.headers.get("Accept")==="text/csv"||s.headers.get("Accept")&&(!((S=s.headers.get("Accept"))===null||S===void 0)&&S.includes("application/vnd.pgrst.plan+text"))?h=N:h=JSON.parse(N))}const j=(x=s.headers.get("Prefer"))===null||x===void 0?void 0:x.match(/count=(exact|planned|estimated)/),_=(w=u.headers.get("content-range"))===null||w===void 0?void 0:w.split("/");j&&_&&_.length>1&&(m=parseInt(_[1])),s.isMaybeSingle&&s.method==="GET"&&Array.isArray(h)&&(h.length>1?(d={code:"PGRST116",details:`Results contain ${h.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},h=null,m=null,g=406,y="Not Acceptable"):h.length===1?h=h[0]:h=null)}else{var E;const j=await u.text();try{d=JSON.parse(j),Array.isArray(d)&&u.status===404&&(h=[],d=null,g=200,y="OK")}catch{u.status===404&&j===""?(g=204,y="No Content"):d={message:j}}if(d&&s.isMaybeSingle&&(!(d==null||(E=d.details)===null||E===void 0)&&E.includes("0 rows"))&&(d=null,g=200,y="OK"),d&&s.shouldThrowOnError)throw new c2(d)}return{error:d,data:h,count:m,status:g,statusText:y}});return this.shouldThrowOnError||(l=l.catch(u=>{var d;let h="",m="",g="";const y=u?.cause;if(y){var x,w,S,E;const N=(x=y?.message)!==null&&x!==void 0?x:"",k=(w=y?.code)!==null&&w!==void 0?w:"";h=`${(S=u?.name)!==null&&S!==void 0?S:"FetchError"}: ${u?.message}`,h+=`
|
|
8
|
+
`+c.stack}}var Ut=Object.prototype.hasOwnProperty,Xn=t.unstable_scheduleCallback,wr=t.unstable_cancelCallback,Sr=t.unstable_shouldYield,Uu=t.unstable_requestPaint,B=t.unstable_now,ie=t.unstable_getCurrentPriorityLevel,De=t.unstable_ImmediatePriority,qe=t.unstable_UserBlockingPriority,ft=t.unstable_NormalPriority,Zt=t.unstable_LowPriority,Ve=t.unstable_IdlePriority,en=t.log,ll=t.unstable_setDisableYieldValue,Ms=null,Kt=null;function Wn(n){if(typeof en=="function"&&ll(n),Kt&&typeof Kt.setStrictMode=="function")try{Kt.setStrictMode(Ms,n)}catch{}}var dn=Math.clz32?Math.clz32:Dj,Oj=Math.log,Mj=Math.LN2;function Dj(n){return n>>>=0,n===0?32:31-(Oj(n)/Mj|0)|0}var cl=256,ul=262144,dl=4194304;function xa(n){var a=n&42;if(a!==0)return a;switch(n&-n){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 n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function hl(n,a,r){var c=n.pendingLanes;if(c===0)return 0;var f=0,p=n.suspendedLanes,b=n.pingedLanes;n=n.warmLanes;var T=c&134217727;return T!==0?(c=T&~p,c!==0?f=xa(c):(b&=T,b!==0?f=xa(b):r||(r=T&~n,r!==0&&(f=xa(r))))):(T=c&~p,T!==0?f=xa(T):b!==0?f=xa(b):r||(r=c&~n,r!==0&&(f=xa(r)))),f===0?0:a!==0&&a!==f&&(a&p)===0&&(p=f&-f,r=a&-a,p>=r||p===32&&(r&4194048)!==0)?a:f}function jr(n,a){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&a)===0}function Pj(n,a){switch(n){case 1:case 2:case 4:case 8:case 64:return a+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 a+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 Cp(){var n=dl;return dl<<=1,(dl&62914560)===0&&(dl=4194304),n}function Bu(n){for(var a=[],r=0;31>r;r++)a.push(n);return a}function _r(n,a){n.pendingLanes|=a,a!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function zj(n,a,r,c,f,p){var b=n.pendingLanes;n.pendingLanes=r,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=r,n.entangledLanes&=r,n.errorRecoveryDisabledLanes&=r,n.shellSuspendCounter=0;var T=n.entanglements,O=n.expirationTimes,G=n.hiddenUpdates;for(r=b&~r;0<r;){var X=31-dn(r),ee=1<<X;T[X]=0,O[X]=-1;var F=G[X];if(F!==null)for(G[X]=null,X=0;X<F.length;X++){var K=F[X];K!==null&&(K.lane&=-536870913)}r&=~ee}c!==0&&Ap(n,c,0),p!==0&&f===0&&n.tag!==0&&(n.suspendedLanes|=p&~(b&~a))}function Ap(n,a,r){n.pendingLanes|=a,n.suspendedLanes&=~a;var c=31-dn(a);n.entangledLanes|=a,n.entanglements[c]=n.entanglements[c]|1073741824|r&261930}function Rp(n,a){var r=n.entangledLanes|=a;for(n=n.entanglements;r;){var c=31-dn(r),f=1<<c;f&a|n[c]&a&&(n[c]|=a),r&=~f}}function Op(n,a){var r=a&-a;return r=(r&42)!==0?1:Vu(r),(r&(n.suspendedLanes|a))!==0?0:r}function Vu(n){switch(n){case 2:n=1;break;case 8:n=4;break;case 32:n=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:n=128;break;case 268435456:n=134217728;break;default:n=0}return n}function Iu(n){return n&=-n,2<n?8<n?(n&134217727)!==0?32:268435456:8:2}function Mp(){var n=Y.p;return n!==0?n:(n=window.event,n===void 0?32:vx(n.type))}function Dp(n,a){var r=Y.p;try{return Y.p=n,a()}finally{Y.p=r}}var Ds=Math.random().toString(36).slice(2),Bt="__reactFiber$"+Ds,tn="__reactProps$"+Ds,si="__reactContainer$"+Ds,$u="__reactEvents$"+Ds,Lj="__reactListeners$"+Ds,Uj="__reactHandles$"+Ds,Pp="__reactResources$"+Ds,Nr="__reactMarker$"+Ds;function qu(n){delete n[Bt],delete n[tn],delete n[$u],delete n[Lj],delete n[Uj]}function ai(n){var a=n[Bt];if(a)return a;for(var r=n.parentNode;r;){if(a=r[si]||r[Bt]){if(r=a.alternate,a.child!==null||r!==null&&r.child!==null)for(n=nx(n);n!==null;){if(r=n[Bt])return r;n=nx(n)}return a}n=r,r=n.parentNode}return null}function ii(n){if(n=n[Bt]||n[si]){var a=n.tag;if(a===5||a===6||a===13||a===31||a===26||a===27||a===3)return n}return null}function Tr(n){var a=n.tag;if(a===5||a===26||a===27||a===6)return n.stateNode;throw Error(i(33))}function ri(n){var a=n[Pp];return a||(a=n[Pp]={hoistableStyles:new Map,hoistableScripts:new Map}),a}function Mt(n){n[Nr]=!0}var zp=new Set,Lp={};function ba(n,a){oi(n,a),oi(n+"Capture",a)}function oi(n,a){for(Lp[n]=a,n=0;n<a.length;n++)zp.add(a[n])}var Bj=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]*$"),Up={},Bp={};function Vj(n){return Ut.call(Bp,n)?!0:Ut.call(Up,n)?!1:Bj.test(n)?Bp[n]=!0:(Up[n]=!0,!1)}function fl(n,a,r){if(Vj(a))if(r===null)n.removeAttribute(a);else{switch(typeof r){case"undefined":case"function":case"symbol":n.removeAttribute(a);return;case"boolean":var c=a.toLowerCase().slice(0,5);if(c!=="data-"&&c!=="aria-"){n.removeAttribute(a);return}}n.setAttribute(a,""+r)}}function ml(n,a,r){if(r===null)n.removeAttribute(a);else{switch(typeof r){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(a);return}n.setAttribute(a,""+r)}}function cs(n,a,r,c){if(c===null)n.removeAttribute(r);else{switch(typeof c){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(r);return}n.setAttributeNS(a,r,""+c)}}function Nn(n){switch(typeof n){case"bigint":case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function Vp(n){var a=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function Ij(n,a,r){var c=Object.getOwnPropertyDescriptor(n.constructor.prototype,a);if(!n.hasOwnProperty(a)&&typeof c<"u"&&typeof c.get=="function"&&typeof c.set=="function"){var f=c.get,p=c.set;return Object.defineProperty(n,a,{configurable:!0,get:function(){return f.call(this)},set:function(b){r=""+b,p.call(this,b)}}),Object.defineProperty(n,a,{enumerable:c.enumerable}),{getValue:function(){return r},setValue:function(b){r=""+b},stopTracking:function(){n._valueTracker=null,delete n[a]}}}}function Hu(n){if(!n._valueTracker){var a=Vp(n)?"checked":"value";n._valueTracker=Ij(n,a,""+n[a])}}function Ip(n){if(!n)return!1;var a=n._valueTracker;if(!a)return!0;var r=a.getValue(),c="";return n&&(c=Vp(n)?n.checked?"true":"false":n.value),n=c,n!==r?(a.setValue(n),!0):!1}function pl(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}var $j=/[\n"\\]/g;function Tn(n){return n.replace($j,function(a){return"\\"+a.charCodeAt(0).toString(16)+" "})}function Gu(n,a,r,c,f,p,b,T){n.name="",b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"?n.type=b:n.removeAttribute("type"),a!=null?b==="number"?(a===0&&n.value===""||n.value!=a)&&(n.value=""+Nn(a)):n.value!==""+Nn(a)&&(n.value=""+Nn(a)):b!=="submit"&&b!=="reset"||n.removeAttribute("value"),a!=null?Fu(n,b,Nn(a)):r!=null?Fu(n,b,Nn(r)):c!=null&&n.removeAttribute("value"),f==null&&p!=null&&(n.defaultChecked=!!p),f!=null&&(n.checked=f&&typeof f!="function"&&typeof f!="symbol"),T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?n.name=""+Nn(T):n.removeAttribute("name")}function $p(n,a,r,c,f,p,b,T){if(p!=null&&typeof p!="function"&&typeof p!="symbol"&&typeof p!="boolean"&&(n.type=p),a!=null||r!=null){if(!(p!=="submit"&&p!=="reset"||a!=null)){Hu(n);return}r=r!=null?""+Nn(r):"",a=a!=null?""+Nn(a):r,T||a===n.value||(n.value=a),n.defaultValue=a}c=c??f,c=typeof c!="function"&&typeof c!="symbol"&&!!c,n.checked=T?n.checked:!!c,n.defaultChecked=!!c,b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(n.name=b),Hu(n)}function Fu(n,a,r){a==="number"&&pl(n.ownerDocument)===n||n.defaultValue===""+r||(n.defaultValue=""+r)}function li(n,a,r,c){if(n=n.options,a){a={};for(var f=0;f<r.length;f++)a["$"+r[f]]=!0;for(r=0;r<n.length;r++)f=a.hasOwnProperty("$"+n[r].value),n[r].selected!==f&&(n[r].selected=f),f&&c&&(n[r].defaultSelected=!0)}else{for(r=""+Nn(r),a=null,f=0;f<n.length;f++){if(n[f].value===r){n[f].selected=!0,c&&(n[f].defaultSelected=!0);return}a!==null||n[f].disabled||(a=n[f])}a!==null&&(a.selected=!0)}}function qp(n,a,r){if(a!=null&&(a=""+Nn(a),a!==n.value&&(n.value=a),r==null)){n.defaultValue!==a&&(n.defaultValue=a);return}n.defaultValue=r!=null?""+Nn(r):""}function Hp(n,a,r,c){if(a==null){if(c!=null){if(r!=null)throw Error(i(92));if(_e(c)){if(1<c.length)throw Error(i(93));c=c[0]}r=c}r==null&&(r=""),a=r}r=Nn(a),n.defaultValue=r,c=n.textContent,c===r&&c!==""&&c!==null&&(n.value=c),Hu(n)}function ci(n,a){if(a){var r=n.firstChild;if(r&&r===n.lastChild&&r.nodeType===3){r.nodeValue=a;return}}n.textContent=a}var qj=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 Gp(n,a,r){var c=a.indexOf("--")===0;r==null||typeof r=="boolean"||r===""?c?n.setProperty(a,""):a==="float"?n.cssFloat="":n[a]="":c?n.setProperty(a,r):typeof r!="number"||r===0||qj.has(a)?a==="float"?n.cssFloat=r:n[a]=(""+r).trim():n[a]=r+"px"}function Fp(n,a,r){if(a!=null&&typeof a!="object")throw Error(i(62));if(n=n.style,r!=null){for(var c in r)!r.hasOwnProperty(c)||a!=null&&a.hasOwnProperty(c)||(c.indexOf("--")===0?n.setProperty(c,""):c==="float"?n.cssFloat="":n[c]="");for(var f in a)c=a[f],a.hasOwnProperty(f)&&r[f]!==c&&Gp(n,f,c)}else for(var p in a)a.hasOwnProperty(p)&&Gp(n,p,a[p])}function Ku(n){if(n.indexOf("-")===-1)return!1;switch(n){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 Hj=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"]]),Gj=/^[\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 gl(n){return Gj.test(""+n)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":n}function us(){}var Yu=null;function Xu(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var ui=null,di=null;function Kp(n){var a=ii(n);if(a&&(n=a.stateNode)){var r=n[tn]||null;e:switch(n=a.stateNode,a.type){case"input":if(Gu(n,r.value,r.defaultValue,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name),a=r.name,r.type==="radio"&&a!=null){for(r=n;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll('input[name="'+Tn(""+a)+'"][type="radio"]'),a=0;a<r.length;a++){var c=r[a];if(c!==n&&c.form===n.form){var f=c[tn]||null;if(!f)throw Error(i(90));Gu(c,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name)}}for(a=0;a<r.length;a++)c=r[a],c.form===n.form&&Ip(c)}break e;case"textarea":qp(n,r.value,r.defaultValue);break e;case"select":a=r.value,a!=null&&li(n,!!r.multiple,a,!1)}}}var Wu=!1;function Yp(n,a,r){if(Wu)return n(a,r);Wu=!0;try{var c=n(a);return c}finally{if(Wu=!1,(ui!==null||di!==null)&&(sc(),ui&&(a=ui,n=di,di=ui=null,Kp(a),n)))for(a=0;a<n.length;a++)Kp(n[a])}}function Er(n,a){var r=n.stateNode;if(r===null)return null;var c=r[tn]||null;if(c===null)return null;r=c[a];e:switch(a){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(n=n.type,c=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!c;break e;default:n=!1}if(n)return null;if(r&&typeof r!="function")throw Error(i(231,a,typeof r));return r}var ds=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ju=!1;if(ds)try{var kr={};Object.defineProperty(kr,"passive",{get:function(){Ju=!0}}),window.addEventListener("test",kr,kr),window.removeEventListener("test",kr,kr)}catch{Ju=!1}var Ps=null,Qu=null,yl=null;function Xp(){if(yl)return yl;var n,a=Qu,r=a.length,c,f="value"in Ps?Ps.value:Ps.textContent,p=f.length;for(n=0;n<r&&a[n]===f[n];n++);var b=r-n;for(c=1;c<=b&&a[r-c]===f[p-c];c++);return yl=f.slice(n,1<c?1-c:void 0)}function vl(n){var a=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&a===13&&(n=13)):n=a,n===10&&(n=13),32<=n||n===13?n:0}function xl(){return!0}function Wp(){return!1}function nn(n){function a(r,c,f,p,b){this._reactName=r,this._targetInst=f,this.type=c,this.nativeEvent=p,this.target=b,this.currentTarget=null;for(var T in n)n.hasOwnProperty(T)&&(r=n[T],this[T]=r?r(p):p[T]);return this.isDefaultPrevented=(p.defaultPrevented!=null?p.defaultPrevented:p.returnValue===!1)?xl:Wp,this.isPropagationStopped=Wp,this}return x(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var r=this.nativeEvent;r&&(r.preventDefault?r.preventDefault():typeof r.returnValue!="unknown"&&(r.returnValue=!1),this.isDefaultPrevented=xl)},stopPropagation:function(){var r=this.nativeEvent;r&&(r.stopPropagation?r.stopPropagation():typeof r.cancelBubble!="unknown"&&(r.cancelBubble=!0),this.isPropagationStopped=xl)},persist:function(){},isPersistent:xl}),a}var wa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},bl=nn(wa),Cr=x({},wa,{view:0,detail:0}),Fj=nn(Cr),Zu,ed,Ar,wl=x({},Cr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:nd,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==Ar&&(Ar&&n.type==="mousemove"?(Zu=n.screenX-Ar.screenX,ed=n.screenY-Ar.screenY):ed=Zu=0,Ar=n),Zu)},movementY:function(n){return"movementY"in n?n.movementY:ed}}),Jp=nn(wl),Kj=x({},wl,{dataTransfer:0}),Yj=nn(Kj),Xj=x({},Cr,{relatedTarget:0}),td=nn(Xj),Wj=x({},wa,{animationName:0,elapsedTime:0,pseudoElement:0}),Jj=nn(Wj),Qj=x({},wa,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),Zj=nn(Qj),e_=x({},wa,{data:0}),Qp=nn(e_),t_={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},n_={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"},s_={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function a_(n){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(n):(n=s_[n])?!!a[n]:!1}function nd(){return a_}var i_=x({},Cr,{key:function(n){if(n.key){var a=t_[n.key]||n.key;if(a!=="Unidentified")return a}return n.type==="keypress"?(n=vl(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?n_[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:nd,charCode:function(n){return n.type==="keypress"?vl(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?vl(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),r_=nn(i_),o_=x({},wl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Zp=nn(o_),l_=x({},Cr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:nd}),c_=nn(l_),u_=x({},wa,{propertyName:0,elapsedTime:0,pseudoElement:0}),d_=nn(u_),h_=x({},wl,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),f_=nn(h_),m_=x({},wa,{newState:0,oldState:0}),p_=nn(m_),g_=[9,13,27,32],sd=ds&&"CompositionEvent"in window,Rr=null;ds&&"documentMode"in document&&(Rr=document.documentMode);var y_=ds&&"TextEvent"in window&&!Rr,eg=ds&&(!sd||Rr&&8<Rr&&11>=Rr),tg=" ",ng=!1;function sg(n,a){switch(n){case"keyup":return g_.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ag(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var hi=!1;function v_(n,a){switch(n){case"compositionend":return ag(a);case"keypress":return a.which!==32?null:(ng=!0,tg);case"textInput":return n=a.data,n===tg&&ng?null:n;default:return null}}function x_(n,a){if(hi)return n==="compositionend"||!sd&&sg(n,a)?(n=Xp(),yl=Qu=Ps=null,hi=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1<a.char.length)return a.char;if(a.which)return String.fromCharCode(a.which)}return null;case"compositionend":return eg&&a.locale!=="ko"?null:a.data;default:return null}}var b_={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 ig(n){var a=n&&n.nodeName&&n.nodeName.toLowerCase();return a==="input"?!!b_[n.type]:a==="textarea"}function rg(n,a,r,c){ui?di?di.push(c):di=[c]:ui=c,a=uc(a,"onChange"),0<a.length&&(r=new bl("onChange","change",null,r,c),n.push({event:r,listeners:a}))}var Or=null,Mr=null;function w_(n){$v(n,0)}function Sl(n){var a=Tr(n);if(Ip(a))return n}function og(n,a){if(n==="change")return a}var lg=!1;if(ds){var ad;if(ds){var id="oninput"in document;if(!id){var cg=document.createElement("div");cg.setAttribute("oninput","return;"),id=typeof cg.oninput=="function"}ad=id}else ad=!1;lg=ad&&(!document.documentMode||9<document.documentMode)}function ug(){Or&&(Or.detachEvent("onpropertychange",dg),Mr=Or=null)}function dg(n){if(n.propertyName==="value"&&Sl(Mr)){var a=[];rg(a,Mr,n,Xu(n)),Yp(w_,a)}}function S_(n,a,r){n==="focusin"?(ug(),Or=a,Mr=r,Or.attachEvent("onpropertychange",dg)):n==="focusout"&&ug()}function j_(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return Sl(Mr)}function __(n,a){if(n==="click")return Sl(a)}function N_(n,a){if(n==="input"||n==="change")return Sl(a)}function T_(n,a){return n===a&&(n!==0||1/n===1/a)||n!==n&&a!==a}var hn=typeof Object.is=="function"?Object.is:T_;function Dr(n,a){if(hn(n,a))return!0;if(typeof n!="object"||n===null||typeof a!="object"||a===null)return!1;var r=Object.keys(n),c=Object.keys(a);if(r.length!==c.length)return!1;for(c=0;c<r.length;c++){var f=r[c];if(!Ut.call(a,f)||!hn(n[f],a[f]))return!1}return!0}function hg(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function fg(n,a){var r=hg(n);n=0;for(var c;r;){if(r.nodeType===3){if(c=n+r.textContent.length,n<=a&&c>=a)return{node:r,offset:a-n};n=c}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=hg(r)}}function mg(n,a){return n&&a?n===a?!0:n&&n.nodeType===3?!1:a&&a.nodeType===3?mg(n,a.parentNode):"contains"in n?n.contains(a):n.compareDocumentPosition?!!(n.compareDocumentPosition(a)&16):!1:!1}function pg(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var a=pl(n.document);a instanceof n.HTMLIFrameElement;){try{var r=typeof a.contentWindow.location.href=="string"}catch{r=!1}if(r)n=a.contentWindow;else break;a=pl(n.document)}return a}function rd(n){var a=n&&n.nodeName&&n.nodeName.toLowerCase();return a&&(a==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||a==="textarea"||n.contentEditable==="true")}var E_=ds&&"documentMode"in document&&11>=document.documentMode,fi=null,od=null,Pr=null,ld=!1;function gg(n,a,r){var c=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;ld||fi==null||fi!==pl(c)||(c=fi,"selectionStart"in c&&rd(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),Pr&&Dr(Pr,c)||(Pr=c,c=uc(od,"onSelect"),0<c.length&&(a=new bl("onSelect","select",null,a,r),n.push({event:a,listeners:c}),a.target=fi)))}function Sa(n,a){var r={};return r[n.toLowerCase()]=a.toLowerCase(),r["Webkit"+n]="webkit"+a,r["Moz"+n]="moz"+a,r}var mi={animationend:Sa("Animation","AnimationEnd"),animationiteration:Sa("Animation","AnimationIteration"),animationstart:Sa("Animation","AnimationStart"),transitionrun:Sa("Transition","TransitionRun"),transitionstart:Sa("Transition","TransitionStart"),transitioncancel:Sa("Transition","TransitionCancel"),transitionend:Sa("Transition","TransitionEnd")},cd={},yg={};ds&&(yg=document.createElement("div").style,"AnimationEvent"in window||(delete mi.animationend.animation,delete mi.animationiteration.animation,delete mi.animationstart.animation),"TransitionEvent"in window||delete mi.transitionend.transition);function ja(n){if(cd[n])return cd[n];if(!mi[n])return n;var a=mi[n],r;for(r in a)if(a.hasOwnProperty(r)&&r in yg)return cd[n]=a[r];return n}var vg=ja("animationend"),xg=ja("animationiteration"),bg=ja("animationstart"),k_=ja("transitionrun"),C_=ja("transitionstart"),A_=ja("transitioncancel"),wg=ja("transitionend"),Sg=new Map,ud="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(" ");ud.push("scrollEnd");function Un(n,a){Sg.set(n,a),ba(a,[n])}var jl=typeof reportError=="function"?reportError:function(n){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var a=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof n=="object"&&n!==null&&typeof n.message=="string"?String(n.message):String(n),error:n});if(!window.dispatchEvent(a))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",n);return}console.error(n)},En=[],pi=0,dd=0;function _l(){for(var n=pi,a=dd=pi=0;a<n;){var r=En[a];En[a++]=null;var c=En[a];En[a++]=null;var f=En[a];En[a++]=null;var p=En[a];if(En[a++]=null,c!==null&&f!==null){var b=c.pending;b===null?f.next=f:(f.next=b.next,b.next=f),c.pending=f}p!==0&&jg(r,f,p)}}function Nl(n,a,r,c){En[pi++]=n,En[pi++]=a,En[pi++]=r,En[pi++]=c,dd|=c,n.lanes|=c,n=n.alternate,n!==null&&(n.lanes|=c)}function hd(n,a,r,c){return Nl(n,a,r,c),Tl(n)}function _a(n,a){return Nl(n,null,null,a),Tl(n)}function jg(n,a,r){n.lanes|=r;var c=n.alternate;c!==null&&(c.lanes|=r);for(var f=!1,p=n.return;p!==null;)p.childLanes|=r,c=p.alternate,c!==null&&(c.childLanes|=r),p.tag===22&&(n=p.stateNode,n===null||n._visibility&1||(f=!0)),n=p,p=p.return;return n.tag===3?(p=n.stateNode,f&&a!==null&&(f=31-dn(r),n=p.hiddenUpdates,c=n[f],c===null?n[f]=[a]:c.push(a),a.lane=r|536870912),p):null}function Tl(n){if(50<so)throw so=0,wh=null,Error(i(185));for(var a=n.return;a!==null;)n=a,a=n.return;return n.tag===3?n.stateNode:null}var gi={};function R_(n,a,r,c){this.tag=n,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=a,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function fn(n,a,r,c){return new R_(n,a,r,c)}function fd(n){return n=n.prototype,!(!n||!n.isReactComponent)}function hs(n,a){var r=n.alternate;return r===null?(r=fn(n.tag,a,n.key,n.mode),r.elementType=n.elementType,r.type=n.type,r.stateNode=n.stateNode,r.alternate=n,n.alternate=r):(r.pendingProps=a,r.type=n.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=n.flags&65011712,r.childLanes=n.childLanes,r.lanes=n.lanes,r.child=n.child,r.memoizedProps=n.memoizedProps,r.memoizedState=n.memoizedState,r.updateQueue=n.updateQueue,a=n.dependencies,r.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},r.sibling=n.sibling,r.index=n.index,r.ref=n.ref,r.refCleanup=n.refCleanup,r}function _g(n,a){n.flags&=65011714;var r=n.alternate;return r===null?(n.childLanes=0,n.lanes=a,n.child=null,n.subtreeFlags=0,n.memoizedProps=null,n.memoizedState=null,n.updateQueue=null,n.dependencies=null,n.stateNode=null):(n.childLanes=r.childLanes,n.lanes=r.lanes,n.child=r.child,n.subtreeFlags=0,n.deletions=null,n.memoizedProps=r.memoizedProps,n.memoizedState=r.memoizedState,n.updateQueue=r.updateQueue,n.type=r.type,a=r.dependencies,n.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),n}function El(n,a,r,c,f,p){var b=0;if(c=n,typeof n=="function")fd(n)&&(b=1);else if(typeof n=="string")b=zN(n,r,ne.current)?26:n==="html"||n==="head"||n==="body"?27:5;else e:switch(n){case P:return n=fn(31,r,a,f),n.elementType=P,n.lanes=p,n;case j:return Na(r.children,f,p,a);case _:b=8,f|=24;break;case N:return n=fn(12,r,a,f|2),n.elementType=N,n.lanes=p,n;case D:return n=fn(13,r,a,f),n.elementType=D,n.lanes=p,n;case z:return n=fn(19,r,a,f),n.elementType=z,n.lanes=p,n;default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case C:b=10;break e;case k:b=9;break e;case A:b=11;break e;case V:b=14;break e;case R:b=16,c=null;break e}b=29,r=Error(i(130,n===null?"null":typeof n,"")),c=null}return a=fn(b,r,a,f),a.elementType=n,a.type=c,a.lanes=p,a}function Na(n,a,r,c){return n=fn(7,n,c,a),n.lanes=r,n}function md(n,a,r){return n=fn(6,n,null,a),n.lanes=r,n}function Ng(n){var a=fn(18,null,null,0);return a.stateNode=n,a}function pd(n,a,r){return a=fn(4,n.children!==null?n.children:[],n.key,a),a.lanes=r,a.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},a}var Tg=new WeakMap;function kn(n,a){if(typeof n=="object"&&n!==null){var r=Tg.get(n);return r!==void 0?r:(a={value:n,source:a,stack:at(a)},Tg.set(n,a),a)}return{value:n,source:a,stack:at(a)}}var yi=[],vi=0,kl=null,zr=0,Cn=[],An=0,zs=null,Jn=1,Qn="";function fs(n,a){yi[vi++]=zr,yi[vi++]=kl,kl=n,zr=a}function Eg(n,a,r){Cn[An++]=Jn,Cn[An++]=Qn,Cn[An++]=zs,zs=n;var c=Jn;n=Qn;var f=32-dn(c)-1;c&=~(1<<f),r+=1;var p=32-dn(a)+f;if(30<p){var b=f-f%5;p=(c&(1<<b)-1).toString(32),c>>=b,f-=b,Jn=1<<32-dn(a)+f|r<<f|c,Qn=p+n}else Jn=1<<p|r<<f|c,Qn=n}function gd(n){n.return!==null&&(fs(n,1),Eg(n,1,0))}function yd(n){for(;n===kl;)kl=yi[--vi],yi[vi]=null,zr=yi[--vi],yi[vi]=null;for(;n===zs;)zs=Cn[--An],Cn[An]=null,Qn=Cn[--An],Cn[An]=null,Jn=Cn[--An],Cn[An]=null}function kg(n,a){Cn[An++]=Jn,Cn[An++]=Qn,Cn[An++]=zs,Jn=a.id,Qn=a.overflow,zs=n}var Vt=null,ct=null,Ke=!1,Ls=null,Rn=!1,vd=Error(i(519));function Us(n){var a=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Lr(kn(a,n)),vd}function Cg(n){var a=n.stateNode,r=n.type,c=n.memoizedProps;switch(a[Bt]=n,a[tn]=c,r){case"dialog":$e("cancel",a),$e("close",a);break;case"iframe":case"object":case"embed":$e("load",a);break;case"video":case"audio":for(r=0;r<io.length;r++)$e(io[r],a);break;case"source":$e("error",a);break;case"img":case"image":case"link":$e("error",a),$e("load",a);break;case"details":$e("toggle",a);break;case"input":$e("invalid",a),$p(a,c.value,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name,!0);break;case"select":$e("invalid",a);break;case"textarea":$e("invalid",a),Hp(a,c.value,c.defaultValue,c.children)}r=c.children,typeof r!="string"&&typeof r!="number"&&typeof r!="bigint"||a.textContent===""+r||c.suppressHydrationWarning===!0||Fv(a.textContent,r)?(c.popover!=null&&($e("beforetoggle",a),$e("toggle",a)),c.onScroll!=null&&$e("scroll",a),c.onScrollEnd!=null&&$e("scrollend",a),c.onClick!=null&&(a.onclick=us),a=!0):a=!1,a||Us(n,!0)}function Ag(n){for(Vt=n.return;Vt;)switch(Vt.tag){case 5:case 31:case 13:Rn=!1;return;case 27:case 3:Rn=!0;return;default:Vt=Vt.return}}function xi(n){if(n!==Vt)return!1;if(!Ke)return Ag(n),Ke=!0,!1;var a=n.tag,r;if((r=a!==3&&a!==27)&&((r=a===5)&&(r=n.type,r=!(r!=="form"&&r!=="button")||zh(n.type,n.memoizedProps)),r=!r),r&&ct&&Us(n),Ag(n),a===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(i(317));ct=tx(n)}else if(a===31){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(i(317));ct=tx(n)}else a===27?(a=ct,Qs(n.type)?(n=Ih,Ih=null,ct=n):ct=a):ct=Vt?Mn(n.stateNode.nextSibling):null;return!0}function Ta(){ct=Vt=null,Ke=!1}function xd(){var n=Ls;return n!==null&&(on===null?on=n:on.push.apply(on,n),Ls=null),n}function Lr(n){Ls===null?Ls=[n]:Ls.push(n)}var bd=M(null),Ea=null,ms=null;function Bs(n,a,r){W(bd,a._currentValue),a._currentValue=r}function ps(n){n._currentValue=bd.current,U(bd)}function wd(n,a,r){for(;n!==null;){var c=n.alternate;if((n.childLanes&a)!==a?(n.childLanes|=a,c!==null&&(c.childLanes|=a)):c!==null&&(c.childLanes&a)!==a&&(c.childLanes|=a),n===r)break;n=n.return}}function Sd(n,a,r,c){var f=n.child;for(f!==null&&(f.return=n);f!==null;){var p=f.dependencies;if(p!==null){var b=f.child;p=p.firstContext;e:for(;p!==null;){var T=p;p=f;for(var O=0;O<a.length;O++)if(T.context===a[O]){p.lanes|=r,T=p.alternate,T!==null&&(T.lanes|=r),wd(p.return,r,n),c||(b=null);break e}p=T.next}}else if(f.tag===18){if(b=f.return,b===null)throw Error(i(341));b.lanes|=r,p=b.alternate,p!==null&&(p.lanes|=r),wd(b,r,n),b=null}else b=f.child;if(b!==null)b.return=f;else for(b=f;b!==null;){if(b===n){b=null;break}if(f=b.sibling,f!==null){f.return=b.return,b=f;break}b=b.return}f=b}}function bi(n,a,r,c){n=null;for(var f=a,p=!1;f!==null;){if(!p){if((f.flags&524288)!==0)p=!0;else if((f.flags&262144)!==0)break}if(f.tag===10){var b=f.alternate;if(b===null)throw Error(i(387));if(b=b.memoizedProps,b!==null){var T=f.type;hn(f.pendingProps.value,b.value)||(n!==null?n.push(T):n=[T])}}else if(f===q.current){if(b=f.alternate,b===null)throw Error(i(387));b.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(n!==null?n.push(uo):n=[uo])}f=f.return}n!==null&&Sd(a,n,r,c),a.flags|=262144}function Cl(n){for(n=n.firstContext;n!==null;){if(!hn(n.context._currentValue,n.memoizedValue))return!0;n=n.next}return!1}function ka(n){Ea=n,ms=null,n=n.dependencies,n!==null&&(n.firstContext=null)}function It(n){return Rg(Ea,n)}function Al(n,a){return Ea===null&&ka(n),Rg(n,a)}function Rg(n,a){var r=a._currentValue;if(a={context:a,memoizedValue:r,next:null},ms===null){if(n===null)throw Error(i(308));ms=a,n.dependencies={lanes:0,firstContext:a},n.flags|=524288}else ms=ms.next=a;return r}var O_=typeof AbortController<"u"?AbortController:function(){var n=[],a=this.signal={aborted:!1,addEventListener:function(r,c){n.push(c)}};this.abort=function(){a.aborted=!0,n.forEach(function(r){return r()})}},M_=t.unstable_scheduleCallback,D_=t.unstable_NormalPriority,St={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function jd(){return{controller:new O_,data:new Map,refCount:0}}function Ur(n){n.refCount--,n.refCount===0&&M_(D_,function(){n.controller.abort()})}var Br=null,_d=0,wi=0,Si=null;function P_(n,a){if(Br===null){var r=Br=[];_d=0,wi=Eh(),Si={status:"pending",value:void 0,then:function(c){r.push(c)}}}return _d++,a.then(Og,Og),a}function Og(){if(--_d===0&&Br!==null){Si!==null&&(Si.status="fulfilled");var n=Br;Br=null,wi=0,Si=null;for(var a=0;a<n.length;a++)(0,n[a])()}}function z_(n,a){var r=[],c={status:"pending",value:null,reason:null,then:function(f){r.push(f)}};return n.then(function(){c.status="fulfilled",c.value=a;for(var f=0;f<r.length;f++)(0,r[f])(a)},function(f){for(c.status="rejected",c.reason=f,f=0;f<r.length;f++)(0,r[f])(void 0)}),c}var Mg=$.S;$.S=function(n,a){gv=B(),typeof a=="object"&&a!==null&&typeof a.then=="function"&&P_(n,a),Mg!==null&&Mg(n,a)};var Ca=M(null);function Nd(){var n=Ca.current;return n!==null?n:it.pooledCache}function Rl(n,a){a===null?W(Ca,Ca.current):W(Ca,a.pool)}function Dg(){var n=Nd();return n===null?null:{parent:St._currentValue,pool:n}}var ji=Error(i(460)),Td=Error(i(474)),Ol=Error(i(542)),Ml={then:function(){}};function Pg(n){return n=n.status,n==="fulfilled"||n==="rejected"}function zg(n,a,r){switch(r=n[r],r===void 0?n.push(a):r!==a&&(a.then(us,us),a=r),a.status){case"fulfilled":return a.value;case"rejected":throw n=a.reason,Ug(n),n;default:if(typeof a.status=="string")a.then(us,us);else{if(n=it,n!==null&&100<n.shellSuspendCounter)throw Error(i(482));n=a,n.status="pending",n.then(function(c){if(a.status==="pending"){var f=a;f.status="fulfilled",f.value=c}},function(c){if(a.status==="pending"){var f=a;f.status="rejected",f.reason=c}})}switch(a.status){case"fulfilled":return a.value;case"rejected":throw n=a.reason,Ug(n),n}throw Ra=a,ji}}function Aa(n){try{var a=n._init;return a(n._payload)}catch(r){throw r!==null&&typeof r=="object"&&typeof r.then=="function"?(Ra=r,ji):r}}var Ra=null;function Lg(){if(Ra===null)throw Error(i(459));var n=Ra;return Ra=null,n}function Ug(n){if(n===ji||n===Ol)throw Error(i(483))}var _i=null,Vr=0;function Dl(n){var a=Vr;return Vr+=1,_i===null&&(_i=[]),zg(_i,n,a)}function Ir(n,a){a=a.props.ref,n.ref=a!==void 0?a:null}function Pl(n,a){throw a.$$typeof===w?Error(i(525)):(n=Object.prototype.toString.call(a),Error(i(31,n==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":n)))}function Bg(n){function a(I,L){if(n){var H=I.deletions;H===null?(I.deletions=[L],I.flags|=16):H.push(L)}}function r(I,L){if(!n)return null;for(;L!==null;)a(I,L),L=L.sibling;return null}function c(I){for(var L=new Map;I!==null;)I.key!==null?L.set(I.key,I):L.set(I.index,I),I=I.sibling;return L}function f(I,L){return I=hs(I,L),I.index=0,I.sibling=null,I}function p(I,L,H){return I.index=H,n?(H=I.alternate,H!==null?(H=H.index,H<L?(I.flags|=67108866,L):H):(I.flags|=67108866,L)):(I.flags|=1048576,L)}function b(I){return n&&I.alternate===null&&(I.flags|=67108866),I}function T(I,L,H,Q){return L===null||L.tag!==6?(L=md(H,I.mode,Q),L.return=I,L):(L=f(L,H),L.return=I,L)}function O(I,L,H,Q){var ke=H.type;return ke===j?X(I,L,H.props.children,Q,H.key):L!==null&&(L.elementType===ke||typeof ke=="object"&&ke!==null&&ke.$$typeof===R&&Aa(ke)===L.type)?(L=f(L,H.props),Ir(L,H),L.return=I,L):(L=El(H.type,H.key,H.props,null,I.mode,Q),Ir(L,H),L.return=I,L)}function G(I,L,H,Q){return L===null||L.tag!==4||L.stateNode.containerInfo!==H.containerInfo||L.stateNode.implementation!==H.implementation?(L=pd(H,I.mode,Q),L.return=I,L):(L=f(L,H.children||[]),L.return=I,L)}function X(I,L,H,Q,ke){return L===null||L.tag!==7?(L=Na(H,I.mode,Q,ke),L.return=I,L):(L=f(L,H),L.return=I,L)}function ee(I,L,H){if(typeof L=="string"&&L!==""||typeof L=="number"||typeof L=="bigint")return L=md(""+L,I.mode,H),L.return=I,L;if(typeof L=="object"&&L!==null){switch(L.$$typeof){case S:return H=El(L.type,L.key,L.props,null,I.mode,H),Ir(H,L),H.return=I,H;case E:return L=pd(L,I.mode,H),L.return=I,L;case R:return L=Aa(L),ee(I,L,H)}if(_e(L)||me(L))return L=Na(L,I.mode,H,null),L.return=I,L;if(typeof L.then=="function")return ee(I,Dl(L),H);if(L.$$typeof===C)return ee(I,Al(I,L),H);Pl(I,L)}return null}function F(I,L,H,Q){var ke=L!==null?L.key:null;if(typeof H=="string"&&H!==""||typeof H=="number"||typeof H=="bigint")return ke!==null?null:T(I,L,""+H,Q);if(typeof H=="object"&&H!==null){switch(H.$$typeof){case S:return H.key===ke?O(I,L,H,Q):null;case E:return H.key===ke?G(I,L,H,Q):null;case R:return H=Aa(H),F(I,L,H,Q)}if(_e(H)||me(H))return ke!==null?null:X(I,L,H,Q,null);if(typeof H.then=="function")return F(I,L,Dl(H),Q);if(H.$$typeof===C)return F(I,L,Al(I,H),Q);Pl(I,H)}return null}function K(I,L,H,Q,ke){if(typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint")return I=I.get(H)||null,T(L,I,""+Q,ke);if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case S:return I=I.get(Q.key===null?H:Q.key)||null,O(L,I,Q,ke);case E:return I=I.get(Q.key===null?H:Q.key)||null,G(L,I,Q,ke);case R:return Q=Aa(Q),K(I,L,H,Q,ke)}if(_e(Q)||me(Q))return I=I.get(H)||null,X(L,I,Q,ke,null);if(typeof Q.then=="function")return K(I,L,H,Dl(Q),ke);if(Q.$$typeof===C)return K(I,L,H,Al(L,Q),ke);Pl(L,Q)}return null}function ve(I,L,H,Q){for(var ke=null,Ye=null,Se=L,Le=L=0,Ge=null;Se!==null&&Le<H.length;Le++){Se.index>Le?(Ge=Se,Se=null):Ge=Se.sibling;var Xe=F(I,Se,H[Le],Q);if(Xe===null){Se===null&&(Se=Ge);break}n&&Se&&Xe.alternate===null&&a(I,Se),L=p(Xe,L,Le),Ye===null?ke=Xe:Ye.sibling=Xe,Ye=Xe,Se=Ge}if(Le===H.length)return r(I,Se),Ke&&fs(I,Le),ke;if(Se===null){for(;Le<H.length;Le++)Se=ee(I,H[Le],Q),Se!==null&&(L=p(Se,L,Le),Ye===null?ke=Se:Ye.sibling=Se,Ye=Se);return Ke&&fs(I,Le),ke}for(Se=c(Se);Le<H.length;Le++)Ge=K(Se,I,Le,H[Le],Q),Ge!==null&&(n&&Ge.alternate!==null&&Se.delete(Ge.key===null?Le:Ge.key),L=p(Ge,L,Le),Ye===null?ke=Ge:Ye.sibling=Ge,Ye=Ge);return n&&Se.forEach(function(sa){return a(I,sa)}),Ke&&fs(I,Le),ke}function Ce(I,L,H,Q){if(H==null)throw Error(i(151));for(var ke=null,Ye=null,Se=L,Le=L=0,Ge=null,Xe=H.next();Se!==null&&!Xe.done;Le++,Xe=H.next()){Se.index>Le?(Ge=Se,Se=null):Ge=Se.sibling;var sa=F(I,Se,Xe.value,Q);if(sa===null){Se===null&&(Se=Ge);break}n&&Se&&sa.alternate===null&&a(I,Se),L=p(sa,L,Le),Ye===null?ke=sa:Ye.sibling=sa,Ye=sa,Se=Ge}if(Xe.done)return r(I,Se),Ke&&fs(I,Le),ke;if(Se===null){for(;!Xe.done;Le++,Xe=H.next())Xe=ee(I,Xe.value,Q),Xe!==null&&(L=p(Xe,L,Le),Ye===null?ke=Xe:Ye.sibling=Xe,Ye=Xe);return Ke&&fs(I,Le),ke}for(Se=c(Se);!Xe.done;Le++,Xe=H.next())Xe=K(Se,I,Le,Xe.value,Q),Xe!==null&&(n&&Xe.alternate!==null&&Se.delete(Xe.key===null?Le:Xe.key),L=p(Xe,L,Le),Ye===null?ke=Xe:Ye.sibling=Xe,Ye=Xe);return n&&Se.forEach(function(KN){return a(I,KN)}),Ke&&fs(I,Le),ke}function st(I,L,H,Q){if(typeof H=="object"&&H!==null&&H.type===j&&H.key===null&&(H=H.props.children),typeof H=="object"&&H!==null){switch(H.$$typeof){case S:e:{for(var ke=H.key;L!==null;){if(L.key===ke){if(ke=H.type,ke===j){if(L.tag===7){r(I,L.sibling),Q=f(L,H.props.children),Q.return=I,I=Q;break e}}else if(L.elementType===ke||typeof ke=="object"&&ke!==null&&ke.$$typeof===R&&Aa(ke)===L.type){r(I,L.sibling),Q=f(L,H.props),Ir(Q,H),Q.return=I,I=Q;break e}r(I,L);break}else a(I,L);L=L.sibling}H.type===j?(Q=Na(H.props.children,I.mode,Q,H.key),Q.return=I,I=Q):(Q=El(H.type,H.key,H.props,null,I.mode,Q),Ir(Q,H),Q.return=I,I=Q)}return b(I);case E:e:{for(ke=H.key;L!==null;){if(L.key===ke)if(L.tag===4&&L.stateNode.containerInfo===H.containerInfo&&L.stateNode.implementation===H.implementation){r(I,L.sibling),Q=f(L,H.children||[]),Q.return=I,I=Q;break e}else{r(I,L);break}else a(I,L);L=L.sibling}Q=pd(H,I.mode,Q),Q.return=I,I=Q}return b(I);case R:return H=Aa(H),st(I,L,H,Q)}if(_e(H))return ve(I,L,H,Q);if(me(H)){if(ke=me(H),typeof ke!="function")throw Error(i(150));return H=ke.call(H),Ce(I,L,H,Q)}if(typeof H.then=="function")return st(I,L,Dl(H),Q);if(H.$$typeof===C)return st(I,L,Al(I,H),Q);Pl(I,H)}return typeof H=="string"&&H!==""||typeof H=="number"||typeof H=="bigint"?(H=""+H,L!==null&&L.tag===6?(r(I,L.sibling),Q=f(L,H),Q.return=I,I=Q):(r(I,L),Q=md(H,I.mode,Q),Q.return=I,I=Q),b(I)):r(I,L)}return function(I,L,H,Q){try{Vr=0;var ke=st(I,L,H,Q);return _i=null,ke}catch(Se){if(Se===ji||Se===Ol)throw Se;var Ye=fn(29,Se,null,I.mode);return Ye.lanes=Q,Ye.return=I,Ye}}}var Oa=Bg(!0),Vg=Bg(!1),Vs=!1;function Ed(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function kd(n,a){n=n.updateQueue,a.updateQueue===n&&(a.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,callbacks:null})}function Is(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function $s(n,a,r){var c=n.updateQueue;if(c===null)return null;if(c=c.shared,(We&2)!==0){var f=c.pending;return f===null?a.next=a:(a.next=f.next,f.next=a),c.pending=a,a=Tl(n),jg(n,null,r),a}return Nl(n,c,a,r),Tl(n)}function $r(n,a,r){if(a=a.updateQueue,a!==null&&(a=a.shared,(r&4194048)!==0)){var c=a.lanes;c&=n.pendingLanes,r|=c,a.lanes=r,Rp(n,r)}}function Cd(n,a){var r=n.updateQueue,c=n.alternate;if(c!==null&&(c=c.updateQueue,r===c)){var f=null,p=null;if(r=r.firstBaseUpdate,r!==null){do{var b={lane:r.lane,tag:r.tag,payload:r.payload,callback:null,next:null};p===null?f=p=b:p=p.next=b,r=r.next}while(r!==null);p===null?f=p=a:p=p.next=a}else f=p=a;r={baseState:c.baseState,firstBaseUpdate:f,lastBaseUpdate:p,shared:c.shared,callbacks:c.callbacks},n.updateQueue=r;return}n=r.lastBaseUpdate,n===null?r.firstBaseUpdate=a:n.next=a,r.lastBaseUpdate=a}var Ad=!1;function qr(){if(Ad){var n=Si;if(n!==null)throw n}}function Hr(n,a,r,c){Ad=!1;var f=n.updateQueue;Vs=!1;var p=f.firstBaseUpdate,b=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,G=O.next;O.next=null,b===null?p=G:b.next=G,b=O;var X=n.alternate;X!==null&&(X=X.updateQueue,T=X.lastBaseUpdate,T!==b&&(T===null?X.firstBaseUpdate=G:T.next=G,X.lastBaseUpdate=O))}if(p!==null){var ee=f.baseState;b=0,X=G=O=null,T=p;do{var F=T.lane&-536870913,K=F!==T.lane;if(K?(He&F)===F:(c&F)===F){F!==0&&F===wi&&(Ad=!0),X!==null&&(X=X.next={lane:0,tag:T.tag,payload:T.payload,callback:null,next:null});e:{var ve=n,Ce=T;F=a;var st=r;switch(Ce.tag){case 1:if(ve=Ce.payload,typeof ve=="function"){ee=ve.call(st,ee,F);break e}ee=ve;break e;case 3:ve.flags=ve.flags&-65537|128;case 0:if(ve=Ce.payload,F=typeof ve=="function"?ve.call(st,ee,F):ve,F==null)break e;ee=x({},ee,F);break e;case 2:Vs=!0}}F=T.callback,F!==null&&(n.flags|=64,K&&(n.flags|=8192),K=f.callbacks,K===null?f.callbacks=[F]:K.push(F))}else K={lane:F,tag:T.tag,payload:T.payload,callback:T.callback,next:null},X===null?(G=X=K,O=ee):X=X.next=K,b|=F;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;K=T,T=K.next,K.next=null,f.lastBaseUpdate=K,f.shared.pending=null}}while(!0);X===null&&(O=ee),f.baseState=O,f.firstBaseUpdate=G,f.lastBaseUpdate=X,p===null&&(f.shared.lanes=0),Ks|=b,n.lanes=b,n.memoizedState=ee}}function Ig(n,a){if(typeof n!="function")throw Error(i(191,n));n.call(a)}function $g(n,a){var r=n.callbacks;if(r!==null)for(n.callbacks=null,n=0;n<r.length;n++)Ig(r[n],a)}var Ni=M(null),zl=M(0);function qg(n,a){n=_s,W(zl,n),W(Ni,a),_s=n|a.baseLanes}function Rd(){W(zl,_s),W(Ni,Ni.current)}function Od(){_s=zl.current,U(Ni),U(zl)}var mn=M(null),On=null;function qs(n){var a=n.alternate;W(bt,bt.current&1),W(mn,n),On===null&&(a===null||Ni.current!==null||a.memoizedState!==null)&&(On=n)}function Md(n){W(bt,bt.current),W(mn,n),On===null&&(On=n)}function Hg(n){n.tag===22?(W(bt,bt.current),W(mn,n),On===null&&(On=n)):Hs()}function Hs(){W(bt,bt.current),W(mn,mn.current)}function pn(n){U(mn),On===n&&(On=null),U(bt)}var bt=M(0);function Ll(n){for(var a=n;a!==null;){if(a.tag===13){var r=a.memoizedState;if(r!==null&&(r=r.dehydrated,r===null||Bh(r)||Vh(r)))return a}else if(a.tag===19&&(a.memoizedProps.revealOrder==="forwards"||a.memoizedProps.revealOrder==="backwards"||a.memoizedProps.revealOrder==="unstable_legacy-backwards"||a.memoizedProps.revealOrder==="together")){if((a.flags&128)!==0)return a}else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===n)break;for(;a.sibling===null;){if(a.return===null||a.return===n)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var gs=0,Pe=null,tt=null,jt=null,Ul=!1,Ti=!1,Ma=!1,Bl=0,Gr=0,Ei=null,L_=0;function pt(){throw Error(i(321))}function Dd(n,a){if(a===null)return!1;for(var r=0;r<a.length&&r<n.length;r++)if(!hn(n[r],a[r]))return!1;return!0}function Pd(n,a,r,c,f,p){return gs=p,Pe=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,$.H=n===null||n.memoizedState===null?Ey:Wd,Ma=!1,p=r(c,f),Ma=!1,Ti&&(p=Fg(a,r,c,f)),Gg(n),p}function Gg(n){$.H=Yr;var a=tt!==null&&tt.next!==null;if(gs=0,jt=tt=Pe=null,Ul=!1,Gr=0,Ei=null,a)throw Error(i(300));n===null||_t||(n=n.dependencies,n!==null&&Cl(n)&&(_t=!0))}function Fg(n,a,r,c){Pe=n;var f=0;do{if(Ti&&(Ei=null),Gr=0,Ti=!1,25<=f)throw Error(i(301));if(f+=1,jt=tt=null,n.updateQueue!=null){var p=n.updateQueue;p.lastEffect=null,p.events=null,p.stores=null,p.memoCache!=null&&(p.memoCache.index=0)}$.H=ky,p=a(r,c)}while(Ti);return p}function U_(){var n=$.H,a=n.useState()[0];return a=typeof a.then=="function"?Fr(a):a,n=n.useState()[0],(tt!==null?tt.memoizedState:null)!==n&&(Pe.flags|=1024),a}function zd(){var n=Bl!==0;return Bl=0,n}function Ld(n,a,r){a.updateQueue=n.updateQueue,a.flags&=-2053,n.lanes&=~r}function Ud(n){if(Ul){for(n=n.memoizedState;n!==null;){var a=n.queue;a!==null&&(a.pending=null),n=n.next}Ul=!1}gs=0,jt=tt=Pe=null,Ti=!1,Gr=Bl=0,Ei=null}function Wt(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return jt===null?Pe.memoizedState=jt=n:jt=jt.next=n,jt}function wt(){if(tt===null){var n=Pe.alternate;n=n!==null?n.memoizedState:null}else n=tt.next;var a=jt===null?Pe.memoizedState:jt.next;if(a!==null)jt=a,tt=n;else{if(n===null)throw Pe.alternate===null?Error(i(467)):Error(i(310));tt=n,n={memoizedState:tt.memoizedState,baseState:tt.baseState,baseQueue:tt.baseQueue,queue:tt.queue,next:null},jt===null?Pe.memoizedState=jt=n:jt=jt.next=n}return jt}function Vl(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Fr(n){var a=Gr;return Gr+=1,Ei===null&&(Ei=[]),n=zg(Ei,n,a),a=Pe,(jt===null?a.memoizedState:jt.next)===null&&(a=a.alternate,$.H=a===null||a.memoizedState===null?Ey:Wd),n}function Il(n){if(n!==null&&typeof n=="object"){if(typeof n.then=="function")return Fr(n);if(n.$$typeof===C)return It(n)}throw Error(i(438,String(n)))}function Bd(n){var a=null,r=Pe.updateQueue;if(r!==null&&(a=r.memoCache),a==null){var c=Pe.alternate;c!==null&&(c=c.updateQueue,c!==null&&(c=c.memoCache,c!=null&&(a={data:c.data.map(function(f){return f.slice()}),index:0})))}if(a==null&&(a={data:[],index:0}),r===null&&(r=Vl(),Pe.updateQueue=r),r.memoCache=a,r=a.data[a.index],r===void 0)for(r=a.data[a.index]=Array(n),c=0;c<n;c++)r[c]=Z;return a.index++,r}function ys(n,a){return typeof a=="function"?a(n):a}function $l(n){var a=wt();return Vd(a,tt,n)}function Vd(n,a,r){var c=n.queue;if(c===null)throw Error(i(311));c.lastRenderedReducer=r;var f=n.baseQueue,p=c.pending;if(p!==null){if(f!==null){var b=f.next;f.next=p.next,p.next=b}a.baseQueue=f=p,c.pending=null}if(p=n.baseState,f===null)n.memoizedState=p;else{a=f.next;var T=b=null,O=null,G=a,X=!1;do{var ee=G.lane&-536870913;if(ee!==G.lane?(He&ee)===ee:(gs&ee)===ee){var F=G.revertLane;if(F===0)O!==null&&(O=O.next={lane:0,revertLane:0,gesture:null,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null}),ee===wi&&(X=!0);else if((gs&F)===F){G=G.next,F===wi&&(X=!0);continue}else ee={lane:0,revertLane:G.revertLane,gesture:null,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null},O===null?(T=O=ee,b=p):O=O.next=ee,Pe.lanes|=F,Ks|=F;ee=G.action,Ma&&r(p,ee),p=G.hasEagerState?G.eagerState:r(p,ee)}else F={lane:ee,revertLane:G.revertLane,gesture:G.gesture,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null},O===null?(T=O=F,b=p):O=O.next=F,Pe.lanes|=ee,Ks|=ee;G=G.next}while(G!==null&&G!==a);if(O===null?b=p:O.next=T,!hn(p,n.memoizedState)&&(_t=!0,X&&(r=Si,r!==null)))throw r;n.memoizedState=p,n.baseState=b,n.baseQueue=O,c.lastRenderedState=p}return f===null&&(c.lanes=0),[n.memoizedState,c.dispatch]}function Id(n){var a=wt(),r=a.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var c=r.dispatch,f=r.pending,p=a.memoizedState;if(f!==null){r.pending=null;var b=f=f.next;do p=n(p,b.action),b=b.next;while(b!==f);hn(p,a.memoizedState)||(_t=!0),a.memoizedState=p,a.baseQueue===null&&(a.baseState=p),r.lastRenderedState=p}return[p,c]}function Kg(n,a,r){var c=Pe,f=wt(),p=Ke;if(p){if(r===void 0)throw Error(i(407));r=r()}else r=a();var b=!hn((tt||f).memoizedState,r);if(b&&(f.memoizedState=r,_t=!0),f=f.queue,Hd(Wg.bind(null,c,f,n),[n]),f.getSnapshot!==a||b||jt!==null&&jt.memoizedState.tag&1){if(c.flags|=2048,ki(9,{destroy:void 0},Xg.bind(null,c,f,r,a),null),it===null)throw Error(i(349));p||(gs&127)!==0||Yg(c,a,r)}return r}function Yg(n,a,r){n.flags|=16384,n={getSnapshot:a,value:r},a=Pe.updateQueue,a===null?(a=Vl(),Pe.updateQueue=a,a.stores=[n]):(r=a.stores,r===null?a.stores=[n]:r.push(n))}function Xg(n,a,r,c){a.value=r,a.getSnapshot=c,Jg(a)&&Qg(n)}function Wg(n,a,r){return r(function(){Jg(a)&&Qg(n)})}function Jg(n){var a=n.getSnapshot;n=n.value;try{var r=a();return!hn(n,r)}catch{return!0}}function Qg(n){var a=_a(n,2);a!==null&&ln(a,n,2)}function $d(n){var a=Wt();if(typeof n=="function"){var r=n;if(n=r(),Ma){Wn(!0);try{r()}finally{Wn(!1)}}}return a.memoizedState=a.baseState=n,a.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ys,lastRenderedState:n},a}function Zg(n,a,r,c){return n.baseState=r,Vd(n,tt,typeof c=="function"?c:ys)}function B_(n,a,r,c,f){if(Gl(n))throw Error(i(485));if(n=a.action,n!==null){var p={payload:f,action:n,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(b){p.listeners.push(b)}};$.T!==null?r(!0):p.isTransition=!1,c(p),r=a.pending,r===null?(p.next=a.pending=p,ey(a,p)):(p.next=r.next,a.pending=r.next=p)}}function ey(n,a){var r=a.action,c=a.payload,f=n.state;if(a.isTransition){var p=$.T,b={};$.T=b;try{var T=r(f,c),O=$.S;O!==null&&O(b,T),ty(n,a,T)}catch(G){qd(n,a,G)}finally{p!==null&&b.types!==null&&(p.types=b.types),$.T=p}}else try{p=r(f,c),ty(n,a,p)}catch(G){qd(n,a,G)}}function ty(n,a,r){r!==null&&typeof r=="object"&&typeof r.then=="function"?r.then(function(c){ny(n,a,c)},function(c){return qd(n,a,c)}):ny(n,a,r)}function ny(n,a,r){a.status="fulfilled",a.value=r,sy(a),n.state=r,a=n.pending,a!==null&&(r=a.next,r===a?n.pending=null:(r=r.next,a.next=r,ey(n,r)))}function qd(n,a,r){var c=n.pending;if(n.pending=null,c!==null){c=c.next;do a.status="rejected",a.reason=r,sy(a),a=a.next;while(a!==c)}n.action=null}function sy(n){n=n.listeners;for(var a=0;a<n.length;a++)(0,n[a])()}function ay(n,a){return a}function iy(n,a){if(Ke){var r=it.formState;if(r!==null){e:{var c=Pe;if(Ke){if(ct){t:{for(var f=ct,p=Rn;f.nodeType!==8;){if(!p){f=null;break t}if(f=Mn(f.nextSibling),f===null){f=null;break t}}p=f.data,f=p==="F!"||p==="F"?f:null}if(f){ct=Mn(f.nextSibling),c=f.data==="F!";break e}}Us(c)}c=!1}c&&(a=r[0])}}return r=Wt(),r.memoizedState=r.baseState=a,c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ay,lastRenderedState:a},r.queue=c,r=_y.bind(null,Pe,c),c.dispatch=r,c=$d(!1),p=Xd.bind(null,Pe,!1,c.queue),c=Wt(),f={state:a,dispatch:null,action:n,pending:null},c.queue=f,r=B_.bind(null,Pe,f,p,r),f.dispatch=r,c.memoizedState=n,[a,r,!1]}function ry(n){var a=wt();return oy(a,tt,n)}function oy(n,a,r){if(a=Vd(n,a,ay)[0],n=$l(ys)[0],typeof a=="object"&&a!==null&&typeof a.then=="function")try{var c=Fr(a)}catch(b){throw b===ji?Ol:b}else c=a;a=wt();var f=a.queue,p=f.dispatch;return r!==a.memoizedState&&(Pe.flags|=2048,ki(9,{destroy:void 0},V_.bind(null,f,r),null)),[c,p,n]}function V_(n,a){n.action=a}function ly(n){var a=wt(),r=tt;if(r!==null)return oy(a,r,n);wt(),a=a.memoizedState,r=wt();var c=r.queue.dispatch;return r.memoizedState=n,[a,c,!1]}function ki(n,a,r,c){return n={tag:n,create:r,deps:c,inst:a,next:null},a=Pe.updateQueue,a===null&&(a=Vl(),Pe.updateQueue=a),r=a.lastEffect,r===null?a.lastEffect=n.next=n:(c=r.next,r.next=n,n.next=c,a.lastEffect=n),n}function cy(){return wt().memoizedState}function ql(n,a,r,c){var f=Wt();Pe.flags|=n,f.memoizedState=ki(1|a,{destroy:void 0},r,c===void 0?null:c)}function Hl(n,a,r,c){var f=wt();c=c===void 0?null:c;var p=f.memoizedState.inst;tt!==null&&c!==null&&Dd(c,tt.memoizedState.deps)?f.memoizedState=ki(a,p,r,c):(Pe.flags|=n,f.memoizedState=ki(1|a,p,r,c))}function uy(n,a){ql(8390656,8,n,a)}function Hd(n,a){Hl(2048,8,n,a)}function I_(n){Pe.flags|=4;var a=Pe.updateQueue;if(a===null)a=Vl(),Pe.updateQueue=a,a.events=[n];else{var r=a.events;r===null?a.events=[n]:r.push(n)}}function dy(n){var a=wt().memoizedState;return I_({ref:a,nextImpl:n}),function(){if((We&2)!==0)throw Error(i(440));return a.impl.apply(void 0,arguments)}}function hy(n,a){return Hl(4,2,n,a)}function fy(n,a){return Hl(4,4,n,a)}function my(n,a){if(typeof a=="function"){n=n();var r=a(n);return function(){typeof r=="function"?r():a(null)}}if(a!=null)return n=n(),a.current=n,function(){a.current=null}}function py(n,a,r){r=r!=null?r.concat([n]):null,Hl(4,4,my.bind(null,a,n),r)}function Gd(){}function gy(n,a){var r=wt();a=a===void 0?null:a;var c=r.memoizedState;return a!==null&&Dd(a,c[1])?c[0]:(r.memoizedState=[n,a],n)}function yy(n,a){var r=wt();a=a===void 0?null:a;var c=r.memoizedState;if(a!==null&&Dd(a,c[1]))return c[0];if(c=n(),Ma){Wn(!0);try{n()}finally{Wn(!1)}}return r.memoizedState=[c,a],c}function Fd(n,a,r){return r===void 0||(gs&1073741824)!==0&&(He&261930)===0?n.memoizedState=a:(n.memoizedState=r,n=vv(),Pe.lanes|=n,Ks|=n,r)}function vy(n,a,r,c){return hn(r,a)?r:Ni.current!==null?(n=Fd(n,r,c),hn(n,a)||(_t=!0),n):(gs&42)===0||(gs&1073741824)!==0&&(He&261930)===0?(_t=!0,n.memoizedState=r):(n=vv(),Pe.lanes|=n,Ks|=n,a)}function xy(n,a,r,c,f){var p=Y.p;Y.p=p!==0&&8>p?p:8;var b=$.T,T={};$.T=T,Xd(n,!1,a,r);try{var O=f(),G=$.S;if(G!==null&&G(T,O),O!==null&&typeof O=="object"&&typeof O.then=="function"){var X=z_(O,c);Kr(n,a,X,vn(n))}else Kr(n,a,c,vn(n))}catch(ee){Kr(n,a,{then:function(){},status:"rejected",reason:ee},vn())}finally{Y.p=p,b!==null&&T.types!==null&&(b.types=T.types),$.T=b}}function $_(){}function Kd(n,a,r,c){if(n.tag!==5)throw Error(i(476));var f=by(n).queue;xy(n,f,a,J,r===null?$_:function(){return wy(n),r(c)})}function by(n){var a=n.memoizedState;if(a!==null)return a;a={memoizedState:J,baseState:J,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ys,lastRenderedState:J},next:null};var r={};return a.next={memoizedState:r,baseState:r,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ys,lastRenderedState:r},next:null},n.memoizedState=a,n=n.alternate,n!==null&&(n.memoizedState=a),a}function wy(n){var a=by(n);a.next===null&&(a=n.alternate.memoizedState),Kr(n,a.next.queue,{},vn())}function Yd(){return It(uo)}function Sy(){return wt().memoizedState}function jy(){return wt().memoizedState}function q_(n){for(var a=n.return;a!==null;){switch(a.tag){case 24:case 3:var r=vn();n=Is(r);var c=$s(a,n,r);c!==null&&(ln(c,a,r),$r(c,a,r)),a={cache:jd()},n.payload=a;return}a=a.return}}function H_(n,a,r){var c=vn();r={lane:c,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Gl(n)?Ny(a,r):(r=hd(n,a,r,c),r!==null&&(ln(r,n,c),Ty(r,a,c)))}function _y(n,a,r){var c=vn();Kr(n,a,r,c)}function Kr(n,a,r,c){var f={lane:c,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null};if(Gl(n))Ny(a,f);else{var p=n.alternate;if(n.lanes===0&&(p===null||p.lanes===0)&&(p=a.lastRenderedReducer,p!==null))try{var b=a.lastRenderedState,T=p(b,r);if(f.hasEagerState=!0,f.eagerState=T,hn(T,b))return Nl(n,a,f,0),it===null&&_l(),!1}catch{}if(r=hd(n,a,f,c),r!==null)return ln(r,n,c),Ty(r,a,c),!0}return!1}function Xd(n,a,r,c){if(c={lane:2,revertLane:Eh(),gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},Gl(n)){if(a)throw Error(i(479))}else a=hd(n,r,c,2),a!==null&&ln(a,n,2)}function Gl(n){var a=n.alternate;return n===Pe||a!==null&&a===Pe}function Ny(n,a){Ti=Ul=!0;var r=n.pending;r===null?a.next=a:(a.next=r.next,r.next=a),n.pending=a}function Ty(n,a,r){if((r&4194048)!==0){var c=a.lanes;c&=n.pendingLanes,r|=c,a.lanes=r,Rp(n,r)}}var Yr={readContext:It,use:Il,useCallback:pt,useContext:pt,useEffect:pt,useImperativeHandle:pt,useLayoutEffect:pt,useInsertionEffect:pt,useMemo:pt,useReducer:pt,useRef:pt,useState:pt,useDebugValue:pt,useDeferredValue:pt,useTransition:pt,useSyncExternalStore:pt,useId:pt,useHostTransitionStatus:pt,useFormState:pt,useActionState:pt,useOptimistic:pt,useMemoCache:pt,useCacheRefresh:pt};Yr.useEffectEvent=pt;var Ey={readContext:It,use:Il,useCallback:function(n,a){return Wt().memoizedState=[n,a===void 0?null:a],n},useContext:It,useEffect:uy,useImperativeHandle:function(n,a,r){r=r!=null?r.concat([n]):null,ql(4194308,4,my.bind(null,a,n),r)},useLayoutEffect:function(n,a){return ql(4194308,4,n,a)},useInsertionEffect:function(n,a){ql(4,2,n,a)},useMemo:function(n,a){var r=Wt();a=a===void 0?null:a;var c=n();if(Ma){Wn(!0);try{n()}finally{Wn(!1)}}return r.memoizedState=[c,a],c},useReducer:function(n,a,r){var c=Wt();if(r!==void 0){var f=r(a);if(Ma){Wn(!0);try{r(a)}finally{Wn(!1)}}}else f=a;return c.memoizedState=c.baseState=f,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:f},c.queue=n,n=n.dispatch=H_.bind(null,Pe,n),[c.memoizedState,n]},useRef:function(n){var a=Wt();return n={current:n},a.memoizedState=n},useState:function(n){n=$d(n);var a=n.queue,r=_y.bind(null,Pe,a);return a.dispatch=r,[n.memoizedState,r]},useDebugValue:Gd,useDeferredValue:function(n,a){var r=Wt();return Fd(r,n,a)},useTransition:function(){var n=$d(!1);return n=xy.bind(null,Pe,n.queue,!0,!1),Wt().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,a,r){var c=Pe,f=Wt();if(Ke){if(r===void 0)throw Error(i(407));r=r()}else{if(r=a(),it===null)throw Error(i(349));(He&127)!==0||Yg(c,a,r)}f.memoizedState=r;var p={value:r,getSnapshot:a};return f.queue=p,uy(Wg.bind(null,c,p,n),[n]),c.flags|=2048,ki(9,{destroy:void 0},Xg.bind(null,c,p,r,a),null),r},useId:function(){var n=Wt(),a=it.identifierPrefix;if(Ke){var r=Qn,c=Jn;r=(c&~(1<<32-dn(c)-1)).toString(32)+r,a="_"+a+"R_"+r,r=Bl++,0<r&&(a+="H"+r.toString(32)),a+="_"}else r=L_++,a="_"+a+"r_"+r.toString(32)+"_";return n.memoizedState=a},useHostTransitionStatus:Yd,useFormState:iy,useActionState:iy,useOptimistic:function(n){var a=Wt();a.memoizedState=a.baseState=n;var r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return a.queue=r,a=Xd.bind(null,Pe,!0,r),r.dispatch=a,[n,a]},useMemoCache:Bd,useCacheRefresh:function(){return Wt().memoizedState=q_.bind(null,Pe)},useEffectEvent:function(n){var a=Wt(),r={impl:n};return a.memoizedState=r,function(){if((We&2)!==0)throw Error(i(440));return r.impl.apply(void 0,arguments)}}},Wd={readContext:It,use:Il,useCallback:gy,useContext:It,useEffect:Hd,useImperativeHandle:py,useInsertionEffect:hy,useLayoutEffect:fy,useMemo:yy,useReducer:$l,useRef:cy,useState:function(){return $l(ys)},useDebugValue:Gd,useDeferredValue:function(n,a){var r=wt();return vy(r,tt.memoizedState,n,a)},useTransition:function(){var n=$l(ys)[0],a=wt().memoizedState;return[typeof n=="boolean"?n:Fr(n),a]},useSyncExternalStore:Kg,useId:Sy,useHostTransitionStatus:Yd,useFormState:ry,useActionState:ry,useOptimistic:function(n,a){var r=wt();return Zg(r,tt,n,a)},useMemoCache:Bd,useCacheRefresh:jy};Wd.useEffectEvent=dy;var ky={readContext:It,use:Il,useCallback:gy,useContext:It,useEffect:Hd,useImperativeHandle:py,useInsertionEffect:hy,useLayoutEffect:fy,useMemo:yy,useReducer:Id,useRef:cy,useState:function(){return Id(ys)},useDebugValue:Gd,useDeferredValue:function(n,a){var r=wt();return tt===null?Fd(r,n,a):vy(r,tt.memoizedState,n,a)},useTransition:function(){var n=Id(ys)[0],a=wt().memoizedState;return[typeof n=="boolean"?n:Fr(n),a]},useSyncExternalStore:Kg,useId:Sy,useHostTransitionStatus:Yd,useFormState:ly,useActionState:ly,useOptimistic:function(n,a){var r=wt();return tt!==null?Zg(r,tt,n,a):(r.baseState=n,[n,r.queue.dispatch])},useMemoCache:Bd,useCacheRefresh:jy};ky.useEffectEvent=dy;function Jd(n,a,r,c){a=n.memoizedState,r=r(c,a),r=r==null?a:x({},a,r),n.memoizedState=r,n.lanes===0&&(n.updateQueue.baseState=r)}var Qd={enqueueSetState:function(n,a,r){n=n._reactInternals;var c=vn(),f=Is(c);f.payload=a,r!=null&&(f.callback=r),a=$s(n,f,c),a!==null&&(ln(a,n,c),$r(a,n,c))},enqueueReplaceState:function(n,a,r){n=n._reactInternals;var c=vn(),f=Is(c);f.tag=1,f.payload=a,r!=null&&(f.callback=r),a=$s(n,f,c),a!==null&&(ln(a,n,c),$r(a,n,c))},enqueueForceUpdate:function(n,a){n=n._reactInternals;var r=vn(),c=Is(r);c.tag=2,a!=null&&(c.callback=a),a=$s(n,c,r),a!==null&&(ln(a,n,r),$r(a,n,r))}};function Cy(n,a,r,c,f,p,b){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(c,p,b):a.prototype&&a.prototype.isPureReactComponent?!Dr(r,c)||!Dr(f,p):!0}function Ay(n,a,r,c){n=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(r,c),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(r,c),a.state!==n&&Qd.enqueueReplaceState(a,a.state,null)}function Da(n,a){var r=a;if("ref"in a){r={};for(var c in a)c!=="ref"&&(r[c]=a[c])}if(n=n.defaultProps){r===a&&(r=x({},r));for(var f in n)r[f]===void 0&&(r[f]=n[f])}return r}function Ry(n){jl(n)}function Oy(n){console.error(n)}function My(n){jl(n)}function Fl(n,a){try{var r=n.onUncaughtError;r(a.value,{componentStack:a.stack})}catch(c){setTimeout(function(){throw c})}}function Dy(n,a,r){try{var c=n.onCaughtError;c(r.value,{componentStack:r.stack,errorBoundary:a.tag===1?a.stateNode:null})}catch(f){setTimeout(function(){throw f})}}function Zd(n,a,r){return r=Is(r),r.tag=3,r.payload={element:null},r.callback=function(){Fl(n,a)},r}function Py(n){return n=Is(n),n.tag=3,n}function zy(n,a,r,c){var f=r.type.getDerivedStateFromError;if(typeof f=="function"){var p=c.value;n.payload=function(){return f(p)},n.callback=function(){Dy(a,r,c)}}var b=r.stateNode;b!==null&&typeof b.componentDidCatch=="function"&&(n.callback=function(){Dy(a,r,c),typeof f!="function"&&(Ys===null?Ys=new Set([this]):Ys.add(this));var T=c.stack;this.componentDidCatch(c.value,{componentStack:T!==null?T:""})})}function G_(n,a,r,c,f){if(r.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){if(a=r.alternate,a!==null&&bi(a,r,f,!0),r=mn.current,r!==null){switch(r.tag){case 31:case 13:return On===null?ac():r.alternate===null&>===0&&(gt=3),r.flags&=-257,r.flags|=65536,r.lanes=f,c===Ml?r.flags|=16384:(a=r.updateQueue,a===null?r.updateQueue=new Set([c]):a.add(c),_h(n,c,f)),!1;case 22:return r.flags|=65536,c===Ml?r.flags|=16384:(a=r.updateQueue,a===null?(a={transitions:null,markerInstances:null,retryQueue:new Set([c])},r.updateQueue=a):(r=a.retryQueue,r===null?a.retryQueue=new Set([c]):r.add(c)),_h(n,c,f)),!1}throw Error(i(435,r.tag))}return _h(n,c,f),ac(),!1}if(Ke)return a=mn.current,a!==null?((a.flags&65536)===0&&(a.flags|=256),a.flags|=65536,a.lanes=f,c!==vd&&(n=Error(i(422),{cause:c}),Lr(kn(n,r)))):(c!==vd&&(a=Error(i(423),{cause:c}),Lr(kn(a,r))),n=n.current.alternate,n.flags|=65536,f&=-f,n.lanes|=f,c=kn(c,r),f=Zd(n.stateNode,c,f),Cd(n,f),gt!==4&&(gt=2)),!1;var p=Error(i(520),{cause:c});if(p=kn(p,r),no===null?no=[p]:no.push(p),gt!==4&&(gt=2),a===null)return!0;c=kn(c,r),r=a;do{switch(r.tag){case 3:return r.flags|=65536,n=f&-f,r.lanes|=n,n=Zd(r.stateNode,c,n),Cd(r,n),!1;case 1:if(a=r.type,p=r.stateNode,(r.flags&128)===0&&(typeof a.getDerivedStateFromError=="function"||p!==null&&typeof p.componentDidCatch=="function"&&(Ys===null||!Ys.has(p))))return r.flags|=65536,f&=-f,r.lanes|=f,f=Py(f),zy(f,n,r,c),Cd(r,f),!1}r=r.return}while(r!==null);return!1}var eh=Error(i(461)),_t=!1;function $t(n,a,r,c){a.child=n===null?Vg(a,null,r,c):Oa(a,n.child,r,c)}function Ly(n,a,r,c,f){r=r.render;var p=a.ref;if("ref"in c){var b={};for(var T in c)T!=="ref"&&(b[T]=c[T])}else b=c;return ka(a),c=Pd(n,a,r,b,p,f),T=zd(),n!==null&&!_t?(Ld(n,a,f),vs(n,a,f)):(Ke&&T&&gd(a),a.flags|=1,$t(n,a,c,f),a.child)}function Uy(n,a,r,c,f){if(n===null){var p=r.type;return typeof p=="function"&&!fd(p)&&p.defaultProps===void 0&&r.compare===null?(a.tag=15,a.type=p,By(n,a,p,c,f)):(n=El(r.type,null,c,a,a.mode,f),n.ref=a.ref,n.return=a,a.child=n)}if(p=n.child,!lh(n,f)){var b=p.memoizedProps;if(r=r.compare,r=r!==null?r:Dr,r(b,c)&&n.ref===a.ref)return vs(n,a,f)}return a.flags|=1,n=hs(p,c),n.ref=a.ref,n.return=a,a.child=n}function By(n,a,r,c,f){if(n!==null){var p=n.memoizedProps;if(Dr(p,c)&&n.ref===a.ref)if(_t=!1,a.pendingProps=c=p,lh(n,f))(n.flags&131072)!==0&&(_t=!0);else return a.lanes=n.lanes,vs(n,a,f)}return th(n,a,r,c,f)}function Vy(n,a,r,c){var f=c.children,p=n!==null?n.memoizedState:null;if(n===null&&a.stateNode===null&&(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),c.mode==="hidden"){if((a.flags&128)!==0){if(p=p!==null?p.baseLanes|r:r,n!==null){for(c=a.child=n.child,f=0;c!==null;)f=f|c.lanes|c.childLanes,c=c.sibling;c=f&~p}else c=0,a.child=null;return Iy(n,a,p,r,c)}if((r&536870912)!==0)a.memoizedState={baseLanes:0,cachePool:null},n!==null&&Rl(a,p!==null?p.cachePool:null),p!==null?qg(a,p):Rd(),Hg(a);else return c=a.lanes=536870912,Iy(n,a,p!==null?p.baseLanes|r:r,r,c)}else p!==null?(Rl(a,p.cachePool),qg(a,p),Hs(),a.memoizedState=null):(n!==null&&Rl(a,null),Rd(),Hs());return $t(n,a,f,r),a.child}function Xr(n,a){return n!==null&&n.tag===22||a.stateNode!==null||(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),a.sibling}function Iy(n,a,r,c,f){var p=Nd();return p=p===null?null:{parent:St._currentValue,pool:p},a.memoizedState={baseLanes:r,cachePool:p},n!==null&&Rl(a,null),Rd(),Hg(a),n!==null&&bi(n,a,c,!0),a.childLanes=f,null}function Kl(n,a){return a=Xl({mode:a.mode,children:a.children},n.mode),a.ref=n.ref,n.child=a,a.return=n,a}function $y(n,a,r){return Oa(a,n.child,null,r),n=Kl(a,a.pendingProps),n.flags|=2,pn(a),a.memoizedState=null,n}function F_(n,a,r){var c=a.pendingProps,f=(a.flags&128)!==0;if(a.flags&=-129,n===null){if(Ke){if(c.mode==="hidden")return n=Kl(a,c),a.lanes=536870912,Xr(null,n);if(Md(a),(n=ct)?(n=ex(n,Rn),n=n!==null&&n.data==="&"?n:null,n!==null&&(a.memoizedState={dehydrated:n,treeContext:zs!==null?{id:Jn,overflow:Qn}:null,retryLane:536870912,hydrationErrors:null},r=Ng(n),r.return=a,a.child=r,Vt=a,ct=null)):n=null,n===null)throw Us(a);return a.lanes=536870912,null}return Kl(a,c)}var p=n.memoizedState;if(p!==null){var b=p.dehydrated;if(Md(a),f)if(a.flags&256)a.flags&=-257,a=$y(n,a,r);else if(a.memoizedState!==null)a.child=n.child,a.flags|=128,a=null;else throw Error(i(558));else if(_t||bi(n,a,r,!1),f=(r&n.childLanes)!==0,_t||f){if(c=it,c!==null&&(b=Op(c,r),b!==0&&b!==p.retryLane))throw p.retryLane=b,_a(n,b),ln(c,n,b),eh;ac(),a=$y(n,a,r)}else n=p.treeContext,ct=Mn(b.nextSibling),Vt=a,Ke=!0,Ls=null,Rn=!1,n!==null&&kg(a,n),a=Kl(a,c),a.flags|=4096;return a}return n=hs(n.child,{mode:c.mode,children:c.children}),n.ref=a.ref,a.child=n,n.return=a,n}function Yl(n,a){var r=a.ref;if(r===null)n!==null&&n.ref!==null&&(a.flags|=4194816);else{if(typeof r!="function"&&typeof r!="object")throw Error(i(284));(n===null||n.ref!==r)&&(a.flags|=4194816)}}function th(n,a,r,c,f){return ka(a),r=Pd(n,a,r,c,void 0,f),c=zd(),n!==null&&!_t?(Ld(n,a,f),vs(n,a,f)):(Ke&&c&&gd(a),a.flags|=1,$t(n,a,r,f),a.child)}function qy(n,a,r,c,f,p){return ka(a),a.updateQueue=null,r=Fg(a,c,r,f),Gg(n),c=zd(),n!==null&&!_t?(Ld(n,a,p),vs(n,a,p)):(Ke&&c&&gd(a),a.flags|=1,$t(n,a,r,p),a.child)}function Hy(n,a,r,c,f){if(ka(a),a.stateNode===null){var p=gi,b=r.contextType;typeof b=="object"&&b!==null&&(p=It(b)),p=new r(c,p),a.memoizedState=p.state!==null&&p.state!==void 0?p.state:null,p.updater=Qd,a.stateNode=p,p._reactInternals=a,p=a.stateNode,p.props=c,p.state=a.memoizedState,p.refs={},Ed(a),b=r.contextType,p.context=typeof b=="object"&&b!==null?It(b):gi,p.state=a.memoizedState,b=r.getDerivedStateFromProps,typeof b=="function"&&(Jd(a,r,b,c),p.state=a.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof p.getSnapshotBeforeUpdate=="function"||typeof p.UNSAFE_componentWillMount!="function"&&typeof p.componentWillMount!="function"||(b=p.state,typeof p.componentWillMount=="function"&&p.componentWillMount(),typeof p.UNSAFE_componentWillMount=="function"&&p.UNSAFE_componentWillMount(),b!==p.state&&Qd.enqueueReplaceState(p,p.state,null),Hr(a,c,p,f),qr(),p.state=a.memoizedState),typeof p.componentDidMount=="function"&&(a.flags|=4194308),c=!0}else if(n===null){p=a.stateNode;var T=a.memoizedProps,O=Da(r,T);p.props=O;var G=p.context,X=r.contextType;b=gi,typeof X=="object"&&X!==null&&(b=It(X));var ee=r.getDerivedStateFromProps;X=typeof ee=="function"||typeof p.getSnapshotBeforeUpdate=="function",T=a.pendingProps!==T,X||typeof p.UNSAFE_componentWillReceiveProps!="function"&&typeof p.componentWillReceiveProps!="function"||(T||G!==b)&&Ay(a,p,c,b),Vs=!1;var F=a.memoizedState;p.state=F,Hr(a,c,p,f),qr(),G=a.memoizedState,T||F!==G||Vs?(typeof ee=="function"&&(Jd(a,r,ee,c),G=a.memoizedState),(O=Vs||Cy(a,r,O,c,F,G,b))?(X||typeof p.UNSAFE_componentWillMount!="function"&&typeof p.componentWillMount!="function"||(typeof p.componentWillMount=="function"&&p.componentWillMount(),typeof p.UNSAFE_componentWillMount=="function"&&p.UNSAFE_componentWillMount()),typeof p.componentDidMount=="function"&&(a.flags|=4194308)):(typeof p.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=c,a.memoizedState=G),p.props=c,p.state=G,p.context=b,c=O):(typeof p.componentDidMount=="function"&&(a.flags|=4194308),c=!1)}else{p=a.stateNode,kd(n,a),b=a.memoizedProps,X=Da(r,b),p.props=X,ee=a.pendingProps,F=p.context,G=r.contextType,O=gi,typeof G=="object"&&G!==null&&(O=It(G)),T=r.getDerivedStateFromProps,(G=typeof T=="function"||typeof p.getSnapshotBeforeUpdate=="function")||typeof p.UNSAFE_componentWillReceiveProps!="function"&&typeof p.componentWillReceiveProps!="function"||(b!==ee||F!==O)&&Ay(a,p,c,O),Vs=!1,F=a.memoizedState,p.state=F,Hr(a,c,p,f),qr();var K=a.memoizedState;b!==ee||F!==K||Vs||n!==null&&n.dependencies!==null&&Cl(n.dependencies)?(typeof T=="function"&&(Jd(a,r,T,c),K=a.memoizedState),(X=Vs||Cy(a,r,X,c,F,K,O)||n!==null&&n.dependencies!==null&&Cl(n.dependencies))?(G||typeof p.UNSAFE_componentWillUpdate!="function"&&typeof p.componentWillUpdate!="function"||(typeof p.componentWillUpdate=="function"&&p.componentWillUpdate(c,K,O),typeof p.UNSAFE_componentWillUpdate=="function"&&p.UNSAFE_componentWillUpdate(c,K,O)),typeof p.componentDidUpdate=="function"&&(a.flags|=4),typeof p.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof p.componentDidUpdate!="function"||b===n.memoizedProps&&F===n.memoizedState||(a.flags|=4),typeof p.getSnapshotBeforeUpdate!="function"||b===n.memoizedProps&&F===n.memoizedState||(a.flags|=1024),a.memoizedProps=c,a.memoizedState=K),p.props=c,p.state=K,p.context=O,c=X):(typeof p.componentDidUpdate!="function"||b===n.memoizedProps&&F===n.memoizedState||(a.flags|=4),typeof p.getSnapshotBeforeUpdate!="function"||b===n.memoizedProps&&F===n.memoizedState||(a.flags|=1024),c=!1)}return p=c,Yl(n,a),c=(a.flags&128)!==0,p||c?(p=a.stateNode,r=c&&typeof r.getDerivedStateFromError!="function"?null:p.render(),a.flags|=1,n!==null&&c?(a.child=Oa(a,n.child,null,f),a.child=Oa(a,null,r,f)):$t(n,a,r,f),a.memoizedState=p.state,n=a.child):n=vs(n,a,f),n}function Gy(n,a,r,c){return Ta(),a.flags|=256,$t(n,a,r,c),a.child}var nh={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function sh(n){return{baseLanes:n,cachePool:Dg()}}function ah(n,a,r){return n=n!==null?n.childLanes&~r:0,a&&(n|=yn),n}function Fy(n,a,r){var c=a.pendingProps,f=!1,p=(a.flags&128)!==0,b;if((b=p)||(b=n!==null&&n.memoizedState===null?!1:(bt.current&2)!==0),b&&(f=!0,a.flags&=-129),b=(a.flags&32)!==0,a.flags&=-33,n===null){if(Ke){if(f?qs(a):Hs(),(n=ct)?(n=ex(n,Rn),n=n!==null&&n.data!=="&"?n:null,n!==null&&(a.memoizedState={dehydrated:n,treeContext:zs!==null?{id:Jn,overflow:Qn}:null,retryLane:536870912,hydrationErrors:null},r=Ng(n),r.return=a,a.child=r,Vt=a,ct=null)):n=null,n===null)throw Us(a);return Vh(n)?a.lanes=32:a.lanes=536870912,null}var T=c.children;return c=c.fallback,f?(Hs(),f=a.mode,T=Xl({mode:"hidden",children:T},f),c=Na(c,f,r,null),T.return=a,c.return=a,T.sibling=c,a.child=T,c=a.child,c.memoizedState=sh(r),c.childLanes=ah(n,b,r),a.memoizedState=nh,Xr(null,c)):(qs(a),ih(a,T))}var O=n.memoizedState;if(O!==null&&(T=O.dehydrated,T!==null)){if(p)a.flags&256?(qs(a),a.flags&=-257,a=rh(n,a,r)):a.memoizedState!==null?(Hs(),a.child=n.child,a.flags|=128,a=null):(Hs(),T=c.fallback,f=a.mode,c=Xl({mode:"visible",children:c.children},f),T=Na(T,f,r,null),T.flags|=2,c.return=a,T.return=a,c.sibling=T,a.child=c,Oa(a,n.child,null,r),c=a.child,c.memoizedState=sh(r),c.childLanes=ah(n,b,r),a.memoizedState=nh,a=Xr(null,c));else if(qs(a),Vh(T)){if(b=T.nextSibling&&T.nextSibling.dataset,b)var G=b.dgst;b=G,c=Error(i(419)),c.stack="",c.digest=b,Lr({value:c,source:null,stack:null}),a=rh(n,a,r)}else if(_t||bi(n,a,r,!1),b=(r&n.childLanes)!==0,_t||b){if(b=it,b!==null&&(c=Op(b,r),c!==0&&c!==O.retryLane))throw O.retryLane=c,_a(n,c),ln(b,n,c),eh;Bh(T)||ac(),a=rh(n,a,r)}else Bh(T)?(a.flags|=192,a.child=n.child,a=null):(n=O.treeContext,ct=Mn(T.nextSibling),Vt=a,Ke=!0,Ls=null,Rn=!1,n!==null&&kg(a,n),a=ih(a,c.children),a.flags|=4096);return a}return f?(Hs(),T=c.fallback,f=a.mode,O=n.child,G=O.sibling,c=hs(O,{mode:"hidden",children:c.children}),c.subtreeFlags=O.subtreeFlags&65011712,G!==null?T=hs(G,T):(T=Na(T,f,r,null),T.flags|=2),T.return=a,c.return=a,c.sibling=T,a.child=c,Xr(null,c),c=a.child,T=n.child.memoizedState,T===null?T=sh(r):(f=T.cachePool,f!==null?(O=St._currentValue,f=f.parent!==O?{parent:O,pool:O}:f):f=Dg(),T={baseLanes:T.baseLanes|r,cachePool:f}),c.memoizedState=T,c.childLanes=ah(n,b,r),a.memoizedState=nh,Xr(n.child,c)):(qs(a),r=n.child,n=r.sibling,r=hs(r,{mode:"visible",children:c.children}),r.return=a,r.sibling=null,n!==null&&(b=a.deletions,b===null?(a.deletions=[n],a.flags|=16):b.push(n)),a.child=r,a.memoizedState=null,r)}function ih(n,a){return a=Xl({mode:"visible",children:a},n.mode),a.return=n,n.child=a}function Xl(n,a){return n=fn(22,n,null,a),n.lanes=0,n}function rh(n,a,r){return Oa(a,n.child,null,r),n=ih(a,a.pendingProps.children),n.flags|=2,a.memoizedState=null,n}function Ky(n,a,r){n.lanes|=a;var c=n.alternate;c!==null&&(c.lanes|=a),wd(n.return,a,r)}function oh(n,a,r,c,f,p){var b=n.memoizedState;b===null?n.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:c,tail:r,tailMode:f,treeForkCount:p}:(b.isBackwards=a,b.rendering=null,b.renderingStartTime=0,b.last=c,b.tail=r,b.tailMode=f,b.treeForkCount=p)}function Yy(n,a,r){var c=a.pendingProps,f=c.revealOrder,p=c.tail;c=c.children;var b=bt.current,T=(b&2)!==0;if(T?(b=b&1|2,a.flags|=128):b&=1,W(bt,b),$t(n,a,c,r),c=Ke?zr:0,!T&&n!==null&&(n.flags&128)!==0)e:for(n=a.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&Ky(n,r,a);else if(n.tag===19)Ky(n,r,a);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===a)break e;for(;n.sibling===null;){if(n.return===null||n.return===a)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}switch(f){case"forwards":for(r=a.child,f=null;r!==null;)n=r.alternate,n!==null&&Ll(n)===null&&(f=r),r=r.sibling;r=f,r===null?(f=a.child,a.child=null):(f=r.sibling,r.sibling=null),oh(a,!1,f,r,p,c);break;case"backwards":case"unstable_legacy-backwards":for(r=null,f=a.child,a.child=null;f!==null;){if(n=f.alternate,n!==null&&Ll(n)===null){a.child=f;break}n=f.sibling,f.sibling=r,r=f,f=n}oh(a,!0,r,null,p,c);break;case"together":oh(a,!1,null,null,void 0,c);break;default:a.memoizedState=null}return a.child}function vs(n,a,r){if(n!==null&&(a.dependencies=n.dependencies),Ks|=a.lanes,(r&a.childLanes)===0)if(n!==null){if(bi(n,a,r,!1),(r&a.childLanes)===0)return null}else return null;if(n!==null&&a.child!==n.child)throw Error(i(153));if(a.child!==null){for(n=a.child,r=hs(n,n.pendingProps),a.child=r,r.return=a;n.sibling!==null;)n=n.sibling,r=r.sibling=hs(n,n.pendingProps),r.return=a;r.sibling=null}return a.child}function lh(n,a){return(n.lanes&a)!==0?!0:(n=n.dependencies,!!(n!==null&&Cl(n)))}function K_(n,a,r){switch(a.tag){case 3:fe(a,a.stateNode.containerInfo),Bs(a,St,n.memoizedState.cache),Ta();break;case 27:case 5:ze(a);break;case 4:fe(a,a.stateNode.containerInfo);break;case 10:Bs(a,a.type,a.memoizedProps.value);break;case 31:if(a.memoizedState!==null)return a.flags|=128,Md(a),null;break;case 13:var c=a.memoizedState;if(c!==null)return c.dehydrated!==null?(qs(a),a.flags|=128,null):(r&a.child.childLanes)!==0?Fy(n,a,r):(qs(a),n=vs(n,a,r),n!==null?n.sibling:null);qs(a);break;case 19:var f=(n.flags&128)!==0;if(c=(r&a.childLanes)!==0,c||(bi(n,a,r,!1),c=(r&a.childLanes)!==0),f){if(c)return Yy(n,a,r);a.flags|=128}if(f=a.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),W(bt,bt.current),c)break;return null;case 22:return a.lanes=0,Vy(n,a,r,a.pendingProps);case 24:Bs(a,St,n.memoizedState.cache)}return vs(n,a,r)}function Xy(n,a,r){if(n!==null)if(n.memoizedProps!==a.pendingProps)_t=!0;else{if(!lh(n,r)&&(a.flags&128)===0)return _t=!1,K_(n,a,r);_t=(n.flags&131072)!==0}else _t=!1,Ke&&(a.flags&1048576)!==0&&Eg(a,zr,a.index);switch(a.lanes=0,a.tag){case 16:e:{var c=a.pendingProps;if(n=Aa(a.elementType),a.type=n,typeof n=="function")fd(n)?(c=Da(n,c),a.tag=1,a=Hy(null,a,n,c,r)):(a.tag=0,a=th(null,a,n,c,r));else{if(n!=null){var f=n.$$typeof;if(f===A){a.tag=11,a=Ly(null,a,n,c,r);break e}else if(f===V){a.tag=14,a=Uy(null,a,n,c,r);break e}}throw a=ye(n)||n,Error(i(306,a,""))}}return a;case 0:return th(n,a,a.type,a.pendingProps,r);case 1:return c=a.type,f=Da(c,a.pendingProps),Hy(n,a,c,f,r);case 3:e:{if(fe(a,a.stateNode.containerInfo),n===null)throw Error(i(387));c=a.pendingProps;var p=a.memoizedState;f=p.element,kd(n,a),Hr(a,c,null,r);var b=a.memoizedState;if(c=b.cache,Bs(a,St,c),c!==p.cache&&Sd(a,[St],r,!0),qr(),c=b.element,p.isDehydrated)if(p={element:c,isDehydrated:!1,cache:b.cache},a.updateQueue.baseState=p,a.memoizedState=p,a.flags&256){a=Gy(n,a,c,r);break e}else if(c!==f){f=kn(Error(i(424)),a),Lr(f),a=Gy(n,a,c,r);break e}else for(n=a.stateNode.containerInfo,n.nodeType===9?n=n.body:n=n.nodeName==="HTML"?n.ownerDocument.body:n,ct=Mn(n.firstChild),Vt=a,Ke=!0,Ls=null,Rn=!0,r=Vg(a,null,c,r),a.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(Ta(),c===f){a=vs(n,a,r);break e}$t(n,a,c,r)}a=a.child}return a;case 26:return Yl(n,a),n===null?(r=rx(a.type,null,a.pendingProps,null))?a.memoizedState=r:Ke||(r=a.type,n=a.pendingProps,c=dc(ue.current).createElement(r),c[Bt]=a,c[tn]=n,qt(c,r,n),Mt(c),a.stateNode=c):a.memoizedState=rx(a.type,n.memoizedProps,a.pendingProps,n.memoizedState),null;case 27:return ze(a),n===null&&Ke&&(c=a.stateNode=sx(a.type,a.pendingProps,ue.current),Vt=a,Rn=!0,f=ct,Qs(a.type)?(Ih=f,ct=Mn(c.firstChild)):ct=f),$t(n,a,a.pendingProps.children,r),Yl(n,a),n===null&&(a.flags|=4194304),a.child;case 5:return n===null&&Ke&&((f=c=ct)&&(c=jN(c,a.type,a.pendingProps,Rn),c!==null?(a.stateNode=c,Vt=a,ct=Mn(c.firstChild),Rn=!1,f=!0):f=!1),f||Us(a)),ze(a),f=a.type,p=a.pendingProps,b=n!==null?n.memoizedProps:null,c=p.children,zh(f,p)?c=null:b!==null&&zh(f,b)&&(a.flags|=32),a.memoizedState!==null&&(f=Pd(n,a,U_,null,null,r),uo._currentValue=f),Yl(n,a),$t(n,a,c,r),a.child;case 6:return n===null&&Ke&&((n=r=ct)&&(r=_N(r,a.pendingProps,Rn),r!==null?(a.stateNode=r,Vt=a,ct=null,n=!0):n=!1),n||Us(a)),null;case 13:return Fy(n,a,r);case 4:return fe(a,a.stateNode.containerInfo),c=a.pendingProps,n===null?a.child=Oa(a,null,c,r):$t(n,a,c,r),a.child;case 11:return Ly(n,a,a.type,a.pendingProps,r);case 7:return $t(n,a,a.pendingProps,r),a.child;case 8:return $t(n,a,a.pendingProps.children,r),a.child;case 12:return $t(n,a,a.pendingProps.children,r),a.child;case 10:return c=a.pendingProps,Bs(a,a.type,c.value),$t(n,a,c.children,r),a.child;case 9:return f=a.type._context,c=a.pendingProps.children,ka(a),f=It(f),c=c(f),a.flags|=1,$t(n,a,c,r),a.child;case 14:return Uy(n,a,a.type,a.pendingProps,r);case 15:return By(n,a,a.type,a.pendingProps,r);case 19:return Yy(n,a,r);case 31:return F_(n,a,r);case 22:return Vy(n,a,r,a.pendingProps);case 24:return ka(a),c=It(St),n===null?(f=Nd(),f===null&&(f=it,p=jd(),f.pooledCache=p,p.refCount++,p!==null&&(f.pooledCacheLanes|=r),f=p),a.memoizedState={parent:c,cache:f},Ed(a),Bs(a,St,f)):((n.lanes&r)!==0&&(kd(n,a),Hr(a,null,null,r),qr()),f=n.memoizedState,p=a.memoizedState,f.parent!==c?(f={parent:c,cache:c},a.memoizedState=f,a.lanes===0&&(a.memoizedState=a.updateQueue.baseState=f),Bs(a,St,c)):(c=p.cache,Bs(a,St,c),c!==f.cache&&Sd(a,[St],r,!0))),$t(n,a,a.pendingProps.children,r),a.child;case 29:throw a.pendingProps}throw Error(i(156,a.tag))}function xs(n){n.flags|=4}function ch(n,a,r,c,f){if((a=(n.mode&32)!==0)&&(a=!1),a){if(n.flags|=16777216,(f&335544128)===f)if(n.stateNode.complete)n.flags|=8192;else if(Sv())n.flags|=8192;else throw Ra=Ml,Td}else n.flags&=-16777217}function Wy(n,a){if(a.type!=="stylesheet"||(a.state.loading&4)!==0)n.flags&=-16777217;else if(n.flags|=16777216,!dx(a))if(Sv())n.flags|=8192;else throw Ra=Ml,Td}function Wl(n,a){a!==null&&(n.flags|=4),n.flags&16384&&(a=n.tag!==22?Cp():536870912,n.lanes|=a,Oi|=a)}function Wr(n,a){if(!Ke)switch(n.tailMode){case"hidden":a=n.tail;for(var r=null;a!==null;)a.alternate!==null&&(r=a),a=a.sibling;r===null?n.tail=null:r.sibling=null;break;case"collapsed":r=n.tail;for(var c=null;r!==null;)r.alternate!==null&&(c=r),r=r.sibling;c===null?a||n.tail===null?n.tail=null:n.tail.sibling=null:c.sibling=null}}function ut(n){var a=n.alternate!==null&&n.alternate.child===n.child,r=0,c=0;if(a)for(var f=n.child;f!==null;)r|=f.lanes|f.childLanes,c|=f.subtreeFlags&65011712,c|=f.flags&65011712,f.return=n,f=f.sibling;else for(f=n.child;f!==null;)r|=f.lanes|f.childLanes,c|=f.subtreeFlags,c|=f.flags,f.return=n,f=f.sibling;return n.subtreeFlags|=c,n.childLanes=r,a}function Y_(n,a,r){var c=a.pendingProps;switch(yd(a),a.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ut(a),null;case 1:return ut(a),null;case 3:return r=a.stateNode,c=null,n!==null&&(c=n.memoizedState.cache),a.memoizedState.cache!==c&&(a.flags|=2048),ps(St),re(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(n===null||n.child===null)&&(xi(a)?xs(a):n===null||n.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,xd())),ut(a),null;case 26:var f=a.type,p=a.memoizedState;return n===null?(xs(a),p!==null?(ut(a),Wy(a,p)):(ut(a),ch(a,f,null,c,r))):p?p!==n.memoizedState?(xs(a),ut(a),Wy(a,p)):(ut(a),a.flags&=-16777217):(n=n.memoizedProps,n!==c&&xs(a),ut(a),ch(a,f,n,c,r)),null;case 27:if(Be(a),r=ue.current,f=a.type,n!==null&&a.stateNode!=null)n.memoizedProps!==c&&xs(a);else{if(!c){if(a.stateNode===null)throw Error(i(166));return ut(a),null}n=ne.current,xi(a)?Cg(a):(n=sx(f,c,r),a.stateNode=n,xs(a))}return ut(a),null;case 5:if(Be(a),f=a.type,n!==null&&a.stateNode!=null)n.memoizedProps!==c&&xs(a);else{if(!c){if(a.stateNode===null)throw Error(i(166));return ut(a),null}if(p=ne.current,xi(a))Cg(a);else{var b=dc(ue.current);switch(p){case 1:p=b.createElementNS("http://www.w3.org/2000/svg",f);break;case 2:p=b.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;default:switch(f){case"svg":p=b.createElementNS("http://www.w3.org/2000/svg",f);break;case"math":p=b.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;case"script":p=b.createElement("div"),p.innerHTML="<script><\/script>",p=p.removeChild(p.firstChild);break;case"select":p=typeof c.is=="string"?b.createElement("select",{is:c.is}):b.createElement("select"),c.multiple?p.multiple=!0:c.size&&(p.size=c.size);break;default:p=typeof c.is=="string"?b.createElement(f,{is:c.is}):b.createElement(f)}}p[Bt]=a,p[tn]=c;e:for(b=a.child;b!==null;){if(b.tag===5||b.tag===6)p.appendChild(b.stateNode);else if(b.tag!==4&&b.tag!==27&&b.child!==null){b.child.return=b,b=b.child;continue}if(b===a)break e;for(;b.sibling===null;){if(b.return===null||b.return===a)break e;b=b.return}b.sibling.return=b.return,b=b.sibling}a.stateNode=p;e:switch(qt(p,f,c),f){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}c&&xs(a)}}return ut(a),ch(a,a.type,n===null?null:n.memoizedProps,a.pendingProps,r),null;case 6:if(n&&a.stateNode!=null)n.memoizedProps!==c&&xs(a);else{if(typeof c!="string"&&a.stateNode===null)throw Error(i(166));if(n=ue.current,xi(a)){if(n=a.stateNode,r=a.memoizedProps,c=null,f=Vt,f!==null)switch(f.tag){case 27:case 5:c=f.memoizedProps}n[Bt]=a,n=!!(n.nodeValue===r||c!==null&&c.suppressHydrationWarning===!0||Fv(n.nodeValue,r)),n||Us(a,!0)}else n=dc(n).createTextNode(c),n[Bt]=a,a.stateNode=n}return ut(a),null;case 31:if(r=a.memoizedState,n===null||n.memoizedState!==null){if(c=xi(a),r!==null){if(n===null){if(!c)throw Error(i(318));if(n=a.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(i(557));n[Bt]=a}else Ta(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;ut(a),n=!1}else r=xd(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=r),n=!0;if(!n)return a.flags&256?(pn(a),a):(pn(a),null);if((a.flags&128)!==0)throw Error(i(558))}return ut(a),null;case 13:if(c=a.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(f=xi(a),c!==null&&c.dehydrated!==null){if(n===null){if(!f)throw Error(i(318));if(f=a.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(i(317));f[Bt]=a}else Ta(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;ut(a),f=!1}else f=xd(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=f),f=!0;if(!f)return a.flags&256?(pn(a),a):(pn(a),null)}return pn(a),(a.flags&128)!==0?(a.lanes=r,a):(r=c!==null,n=n!==null&&n.memoizedState!==null,r&&(c=a.child,f=null,c.alternate!==null&&c.alternate.memoizedState!==null&&c.alternate.memoizedState.cachePool!==null&&(f=c.alternate.memoizedState.cachePool.pool),p=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(p=c.memoizedState.cachePool.pool),p!==f&&(c.flags|=2048)),r!==n&&r&&(a.child.flags|=8192),Wl(a,a.updateQueue),ut(a),null);case 4:return re(),n===null&&Rh(a.stateNode.containerInfo),ut(a),null;case 10:return ps(a.type),ut(a),null;case 19:if(U(bt),c=a.memoizedState,c===null)return ut(a),null;if(f=(a.flags&128)!==0,p=c.rendering,p===null)if(f)Wr(c,!1);else{if(gt!==0||n!==null&&(n.flags&128)!==0)for(n=a.child;n!==null;){if(p=Ll(n),p!==null){for(a.flags|=128,Wr(c,!1),n=p.updateQueue,a.updateQueue=n,Wl(a,n),a.subtreeFlags=0,n=r,r=a.child;r!==null;)_g(r,n),r=r.sibling;return W(bt,bt.current&1|2),Ke&&fs(a,c.treeForkCount),a.child}n=n.sibling}c.tail!==null&&B()>tc&&(a.flags|=128,f=!0,Wr(c,!1),a.lanes=4194304)}else{if(!f)if(n=Ll(p),n!==null){if(a.flags|=128,f=!0,n=n.updateQueue,a.updateQueue=n,Wl(a,n),Wr(c,!0),c.tail===null&&c.tailMode==="hidden"&&!p.alternate&&!Ke)return ut(a),null}else 2*B()-c.renderingStartTime>tc&&r!==536870912&&(a.flags|=128,f=!0,Wr(c,!1),a.lanes=4194304);c.isBackwards?(p.sibling=a.child,a.child=p):(n=c.last,n!==null?n.sibling=p:a.child=p,c.last=p)}return c.tail!==null?(n=c.tail,c.rendering=n,c.tail=n.sibling,c.renderingStartTime=B(),n.sibling=null,r=bt.current,W(bt,f?r&1|2:r&1),Ke&&fs(a,c.treeForkCount),n):(ut(a),null);case 22:case 23:return pn(a),Od(),c=a.memoizedState!==null,n!==null?n.memoizedState!==null!==c&&(a.flags|=8192):c&&(a.flags|=8192),c?(r&536870912)!==0&&(a.flags&128)===0&&(ut(a),a.subtreeFlags&6&&(a.flags|=8192)):ut(a),r=a.updateQueue,r!==null&&Wl(a,r.retryQueue),r=null,n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(r=n.memoizedState.cachePool.pool),c=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(c=a.memoizedState.cachePool.pool),c!==r&&(a.flags|=2048),n!==null&&U(Ca),null;case 24:return r=null,n!==null&&(r=n.memoizedState.cache),a.memoizedState.cache!==r&&(a.flags|=2048),ps(St),ut(a),null;case 25:return null;case 30:return null}throw Error(i(156,a.tag))}function X_(n,a){switch(yd(a),a.tag){case 1:return n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 3:return ps(St),re(),n=a.flags,(n&65536)!==0&&(n&128)===0?(a.flags=n&-65537|128,a):null;case 26:case 27:case 5:return Be(a),null;case 31:if(a.memoizedState!==null){if(pn(a),a.alternate===null)throw Error(i(340));Ta()}return n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 13:if(pn(a),n=a.memoizedState,n!==null&&n.dehydrated!==null){if(a.alternate===null)throw Error(i(340));Ta()}return n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 19:return U(bt),null;case 4:return re(),null;case 10:return ps(a.type),null;case 22:case 23:return pn(a),Od(),n!==null&&U(Ca),n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 24:return ps(St),null;case 25:return null;default:return null}}function Jy(n,a){switch(yd(a),a.tag){case 3:ps(St),re();break;case 26:case 27:case 5:Be(a);break;case 4:re();break;case 31:a.memoizedState!==null&&pn(a);break;case 13:pn(a);break;case 19:U(bt);break;case 10:ps(a.type);break;case 22:case 23:pn(a),Od(),n!==null&&U(Ca);break;case 24:ps(St)}}function Jr(n,a){try{var r=a.updateQueue,c=r!==null?r.lastEffect:null;if(c!==null){var f=c.next;r=f;do{if((r.tag&n)===n){c=void 0;var p=r.create,b=r.inst;c=p(),b.destroy=c}r=r.next}while(r!==f)}}catch(T){Ze(a,a.return,T)}}function Gs(n,a,r){try{var c=a.updateQueue,f=c!==null?c.lastEffect:null;if(f!==null){var p=f.next;c=p;do{if((c.tag&n)===n){var b=c.inst,T=b.destroy;if(T!==void 0){b.destroy=void 0,f=a;var O=r,G=T;try{G()}catch(X){Ze(f,O,X)}}}c=c.next}while(c!==p)}}catch(X){Ze(a,a.return,X)}}function Qy(n){var a=n.updateQueue;if(a!==null){var r=n.stateNode;try{$g(a,r)}catch(c){Ze(n,n.return,c)}}}function Zy(n,a,r){r.props=Da(n.type,n.memoizedProps),r.state=n.memoizedState;try{r.componentWillUnmount()}catch(c){Ze(n,a,c)}}function Qr(n,a){try{var r=n.ref;if(r!==null){switch(n.tag){case 26:case 27:case 5:var c=n.stateNode;break;case 30:c=n.stateNode;break;default:c=n.stateNode}typeof r=="function"?n.refCleanup=r(c):r.current=c}}catch(f){Ze(n,a,f)}}function Zn(n,a){var r=n.ref,c=n.refCleanup;if(r!==null)if(typeof c=="function")try{c()}catch(f){Ze(n,a,f)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof r=="function")try{r(null)}catch(f){Ze(n,a,f)}else r.current=null}function ev(n){var a=n.type,r=n.memoizedProps,c=n.stateNode;try{e:switch(a){case"button":case"input":case"select":case"textarea":r.autoFocus&&c.focus();break e;case"img":r.src?c.src=r.src:r.srcSet&&(c.srcset=r.srcSet)}}catch(f){Ze(n,n.return,f)}}function uh(n,a,r){try{var c=n.stateNode;yN(c,n.type,r,a),c[tn]=a}catch(f){Ze(n,n.return,f)}}function tv(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&Qs(n.type)||n.tag===4}function dh(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||tv(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.tag===27&&Qs(n.type)||n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function hh(n,a,r){var c=n.tag;if(c===5||c===6)n=n.stateNode,a?(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r).insertBefore(n,a):(a=r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,a.appendChild(n),r=r._reactRootContainer,r!=null||a.onclick!==null||(a.onclick=us));else if(c!==4&&(c===27&&Qs(n.type)&&(r=n.stateNode,a=null),n=n.child,n!==null))for(hh(n,a,r),n=n.sibling;n!==null;)hh(n,a,r),n=n.sibling}function Jl(n,a,r){var c=n.tag;if(c===5||c===6)n=n.stateNode,a?r.insertBefore(n,a):r.appendChild(n);else if(c!==4&&(c===27&&Qs(n.type)&&(r=n.stateNode),n=n.child,n!==null))for(Jl(n,a,r),n=n.sibling;n!==null;)Jl(n,a,r),n=n.sibling}function nv(n){var a=n.stateNode,r=n.memoizedProps;try{for(var c=n.type,f=a.attributes;f.length;)a.removeAttributeNode(f[0]);qt(a,c,r),a[Bt]=n,a[tn]=r}catch(p){Ze(n,n.return,p)}}var bs=!1,Nt=!1,fh=!1,sv=typeof WeakSet=="function"?WeakSet:Set,Dt=null;function W_(n,a){if(n=n.containerInfo,Dh=vc,n=pg(n),rd(n)){if("selectionStart"in n)var r={start:n.selectionStart,end:n.selectionEnd};else e:{r=(r=n.ownerDocument)&&r.defaultView||window;var c=r.getSelection&&r.getSelection();if(c&&c.rangeCount!==0){r=c.anchorNode;var f=c.anchorOffset,p=c.focusNode;c=c.focusOffset;try{r.nodeType,p.nodeType}catch{r=null;break e}var b=0,T=-1,O=-1,G=0,X=0,ee=n,F=null;t:for(;;){for(var K;ee!==r||f!==0&&ee.nodeType!==3||(T=b+f),ee!==p||c!==0&&ee.nodeType!==3||(O=b+c),ee.nodeType===3&&(b+=ee.nodeValue.length),(K=ee.firstChild)!==null;)F=ee,ee=K;for(;;){if(ee===n)break t;if(F===r&&++G===f&&(T=b),F===p&&++X===c&&(O=b),(K=ee.nextSibling)!==null)break;ee=F,F=ee.parentNode}ee=K}r=T===-1||O===-1?null:{start:T,end:O}}else r=null}r=r||{start:0,end:0}}else r=null;for(Ph={focusedElem:n,selectionRange:r},vc=!1,Dt=a;Dt!==null;)if(a=Dt,n=a.child,(a.subtreeFlags&1028)!==0&&n!==null)n.return=a,Dt=n;else for(;Dt!==null;){switch(a=Dt,p=a.alternate,n=a.flags,a.tag){case 0:if((n&4)!==0&&(n=a.updateQueue,n=n!==null?n.events:null,n!==null))for(r=0;r<n.length;r++)f=n[r],f.ref.impl=f.nextImpl;break;case 11:case 15:break;case 1:if((n&1024)!==0&&p!==null){n=void 0,r=a,f=p.memoizedProps,p=p.memoizedState,c=r.stateNode;try{var ve=Da(r.type,f);n=c.getSnapshotBeforeUpdate(ve,p),c.__reactInternalSnapshotBeforeUpdate=n}catch(Ce){Ze(r,r.return,Ce)}}break;case 3:if((n&1024)!==0){if(n=a.stateNode.containerInfo,r=n.nodeType,r===9)Uh(n);else if(r===1)switch(n.nodeName){case"HEAD":case"HTML":case"BODY":Uh(n);break;default:n.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((n&1024)!==0)throw Error(i(163))}if(n=a.sibling,n!==null){n.return=a.return,Dt=n;break}Dt=a.return}}function av(n,a,r){var c=r.flags;switch(r.tag){case 0:case 11:case 15:Ss(n,r),c&4&&Jr(5,r);break;case 1:if(Ss(n,r),c&4)if(n=r.stateNode,a===null)try{n.componentDidMount()}catch(b){Ze(r,r.return,b)}else{var f=Da(r.type,a.memoizedProps);a=a.memoizedState;try{n.componentDidUpdate(f,a,n.__reactInternalSnapshotBeforeUpdate)}catch(b){Ze(r,r.return,b)}}c&64&&Qy(r),c&512&&Qr(r,r.return);break;case 3:if(Ss(n,r),c&64&&(n=r.updateQueue,n!==null)){if(a=null,r.child!==null)switch(r.child.tag){case 27:case 5:a=r.child.stateNode;break;case 1:a=r.child.stateNode}try{$g(n,a)}catch(b){Ze(r,r.return,b)}}break;case 27:a===null&&c&4&&nv(r);case 26:case 5:Ss(n,r),a===null&&c&4&&ev(r),c&512&&Qr(r,r.return);break;case 12:Ss(n,r);break;case 31:Ss(n,r),c&4&&ov(n,r);break;case 13:Ss(n,r),c&4&&lv(n,r),c&64&&(n=r.memoizedState,n!==null&&(n=n.dehydrated,n!==null&&(r=iN.bind(null,r),NN(n,r))));break;case 22:if(c=r.memoizedState!==null||bs,!c){a=a!==null&&a.memoizedState!==null||Nt,f=bs;var p=Nt;bs=c,(Nt=a)&&!p?js(n,r,(r.subtreeFlags&8772)!==0):Ss(n,r),bs=f,Nt=p}break;case 30:break;default:Ss(n,r)}}function iv(n){var a=n.alternate;a!==null&&(n.alternate=null,iv(a)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(a=n.stateNode,a!==null&&qu(a)),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}var dt=null,sn=!1;function ws(n,a,r){for(r=r.child;r!==null;)rv(n,a,r),r=r.sibling}function rv(n,a,r){if(Kt&&typeof Kt.onCommitFiberUnmount=="function")try{Kt.onCommitFiberUnmount(Ms,r)}catch{}switch(r.tag){case 26:Nt||Zn(r,a),ws(n,a,r),r.memoizedState?r.memoizedState.count--:r.stateNode&&(r=r.stateNode,r.parentNode.removeChild(r));break;case 27:Nt||Zn(r,a);var c=dt,f=sn;Qs(r.type)&&(dt=r.stateNode,sn=!1),ws(n,a,r),oo(r.stateNode),dt=c,sn=f;break;case 5:Nt||Zn(r,a);case 6:if(c=dt,f=sn,dt=null,ws(n,a,r),dt=c,sn=f,dt!==null)if(sn)try{(dt.nodeType===9?dt.body:dt.nodeName==="HTML"?dt.ownerDocument.body:dt).removeChild(r.stateNode)}catch(p){Ze(r,a,p)}else try{dt.removeChild(r.stateNode)}catch(p){Ze(r,a,p)}break;case 18:dt!==null&&(sn?(n=dt,Qv(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,r.stateNode),Vi(n)):Qv(dt,r.stateNode));break;case 4:c=dt,f=sn,dt=r.stateNode.containerInfo,sn=!0,ws(n,a,r),dt=c,sn=f;break;case 0:case 11:case 14:case 15:Gs(2,r,a),Nt||Gs(4,r,a),ws(n,a,r);break;case 1:Nt||(Zn(r,a),c=r.stateNode,typeof c.componentWillUnmount=="function"&&Zy(r,a,c)),ws(n,a,r);break;case 21:ws(n,a,r);break;case 22:Nt=(c=Nt)||r.memoizedState!==null,ws(n,a,r),Nt=c;break;default:ws(n,a,r)}}function ov(n,a){if(a.memoizedState===null&&(n=a.alternate,n!==null&&(n=n.memoizedState,n!==null))){n=n.dehydrated;try{Vi(n)}catch(r){Ze(a,a.return,r)}}}function lv(n,a){if(a.memoizedState===null&&(n=a.alternate,n!==null&&(n=n.memoizedState,n!==null&&(n=n.dehydrated,n!==null))))try{Vi(n)}catch(r){Ze(a,a.return,r)}}function J_(n){switch(n.tag){case 31:case 13:case 19:var a=n.stateNode;return a===null&&(a=n.stateNode=new sv),a;case 22:return n=n.stateNode,a=n._retryCache,a===null&&(a=n._retryCache=new sv),a;default:throw Error(i(435,n.tag))}}function Ql(n,a){var r=J_(n);a.forEach(function(c){if(!r.has(c)){r.add(c);var f=rN.bind(null,n,c);c.then(f,f)}})}function an(n,a){var r=a.deletions;if(r!==null)for(var c=0;c<r.length;c++){var f=r[c],p=n,b=a,T=b;e:for(;T!==null;){switch(T.tag){case 27:if(Qs(T.type)){dt=T.stateNode,sn=!1;break e}break;case 5:dt=T.stateNode,sn=!1;break e;case 3:case 4:dt=T.stateNode.containerInfo,sn=!0;break e}T=T.return}if(dt===null)throw Error(i(160));rv(p,b,f),dt=null,sn=!1,p=f.alternate,p!==null&&(p.return=null),f.return=null}if(a.subtreeFlags&13886)for(a=a.child;a!==null;)cv(a,n),a=a.sibling}var Bn=null;function cv(n,a){var r=n.alternate,c=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:an(a,n),rn(n),c&4&&(Gs(3,n,n.return),Jr(3,n),Gs(5,n,n.return));break;case 1:an(a,n),rn(n),c&512&&(Nt||r===null||Zn(r,r.return)),c&64&&bs&&(n=n.updateQueue,n!==null&&(c=n.callbacks,c!==null&&(r=n.shared.hiddenCallbacks,n.shared.hiddenCallbacks=r===null?c:r.concat(c))));break;case 26:var f=Bn;if(an(a,n),rn(n),c&512&&(Nt||r===null||Zn(r,r.return)),c&4){var p=r!==null?r.memoizedState:null;if(c=n.memoizedState,r===null)if(c===null)if(n.stateNode===null){e:{c=n.type,r=n.memoizedProps,f=f.ownerDocument||f;t:switch(c){case"title":p=f.getElementsByTagName("title")[0],(!p||p[Nr]||p[Bt]||p.namespaceURI==="http://www.w3.org/2000/svg"||p.hasAttribute("itemprop"))&&(p=f.createElement(c),f.head.insertBefore(p,f.querySelector("head > title"))),qt(p,c,r),p[Bt]=n,Mt(p),c=p;break e;case"link":var b=cx("link","href",f).get(c+(r.href||""));if(b){for(var T=0;T<b.length;T++)if(p=b[T],p.getAttribute("href")===(r.href==null||r.href===""?null:r.href)&&p.getAttribute("rel")===(r.rel==null?null:r.rel)&&p.getAttribute("title")===(r.title==null?null:r.title)&&p.getAttribute("crossorigin")===(r.crossOrigin==null?null:r.crossOrigin)){b.splice(T,1);break t}}p=f.createElement(c),qt(p,c,r),f.head.appendChild(p);break;case"meta":if(b=cx("meta","content",f).get(c+(r.content||""))){for(T=0;T<b.length;T++)if(p=b[T],p.getAttribute("content")===(r.content==null?null:""+r.content)&&p.getAttribute("name")===(r.name==null?null:r.name)&&p.getAttribute("property")===(r.property==null?null:r.property)&&p.getAttribute("http-equiv")===(r.httpEquiv==null?null:r.httpEquiv)&&p.getAttribute("charset")===(r.charSet==null?null:r.charSet)){b.splice(T,1);break t}}p=f.createElement(c),qt(p,c,r),f.head.appendChild(p);break;default:throw Error(i(468,c))}p[Bt]=n,Mt(p),c=p}n.stateNode=c}else ux(f,n.type,n.stateNode);else n.stateNode=lx(f,c,n.memoizedProps);else p!==c?(p===null?r.stateNode!==null&&(r=r.stateNode,r.parentNode.removeChild(r)):p.count--,c===null?ux(f,n.type,n.stateNode):lx(f,c,n.memoizedProps)):c===null&&n.stateNode!==null&&uh(n,n.memoizedProps,r.memoizedProps)}break;case 27:an(a,n),rn(n),c&512&&(Nt||r===null||Zn(r,r.return)),r!==null&&c&4&&uh(n,n.memoizedProps,r.memoizedProps);break;case 5:if(an(a,n),rn(n),c&512&&(Nt||r===null||Zn(r,r.return)),n.flags&32){f=n.stateNode;try{ci(f,"")}catch(ve){Ze(n,n.return,ve)}}c&4&&n.stateNode!=null&&(f=n.memoizedProps,uh(n,f,r!==null?r.memoizedProps:f)),c&1024&&(fh=!0);break;case 6:if(an(a,n),rn(n),c&4){if(n.stateNode===null)throw Error(i(162));c=n.memoizedProps,r=n.stateNode;try{r.nodeValue=c}catch(ve){Ze(n,n.return,ve)}}break;case 3:if(mc=null,f=Bn,Bn=hc(a.containerInfo),an(a,n),Bn=f,rn(n),c&4&&r!==null&&r.memoizedState.isDehydrated)try{Vi(a.containerInfo)}catch(ve){Ze(n,n.return,ve)}fh&&(fh=!1,uv(n));break;case 4:c=Bn,Bn=hc(n.stateNode.containerInfo),an(a,n),rn(n),Bn=c;break;case 12:an(a,n),rn(n);break;case 31:an(a,n),rn(n),c&4&&(c=n.updateQueue,c!==null&&(n.updateQueue=null,Ql(n,c)));break;case 13:an(a,n),rn(n),n.child.flags&8192&&n.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(ec=B()),c&4&&(c=n.updateQueue,c!==null&&(n.updateQueue=null,Ql(n,c)));break;case 22:f=n.memoizedState!==null;var O=r!==null&&r.memoizedState!==null,G=bs,X=Nt;if(bs=G||f,Nt=X||O,an(a,n),Nt=X,bs=G,rn(n),c&8192)e:for(a=n.stateNode,a._visibility=f?a._visibility&-2:a._visibility|1,f&&(r===null||O||bs||Nt||Pa(n)),r=null,a=n;;){if(a.tag===5||a.tag===26){if(r===null){O=r=a;try{if(p=O.stateNode,f)b=p.style,typeof b.setProperty=="function"?b.setProperty("display","none","important"):b.display="none";else{T=O.stateNode;var ee=O.memoizedProps.style,F=ee!=null&&ee.hasOwnProperty("display")?ee.display:null;T.style.display=F==null||typeof F=="boolean"?"":(""+F).trim()}}catch(ve){Ze(O,O.return,ve)}}}else if(a.tag===6){if(r===null){O=a;try{O.stateNode.nodeValue=f?"":O.memoizedProps}catch(ve){Ze(O,O.return,ve)}}}else if(a.tag===18){if(r===null){O=a;try{var K=O.stateNode;f?Zv(K,!0):Zv(O.stateNode,!1)}catch(ve){Ze(O,O.return,ve)}}}else if((a.tag!==22&&a.tag!==23||a.memoizedState===null||a===n)&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===n)break e;for(;a.sibling===null;){if(a.return===null||a.return===n)break e;r===a&&(r=null),a=a.return}r===a&&(r=null),a.sibling.return=a.return,a=a.sibling}c&4&&(c=n.updateQueue,c!==null&&(r=c.retryQueue,r!==null&&(c.retryQueue=null,Ql(n,r))));break;case 19:an(a,n),rn(n),c&4&&(c=n.updateQueue,c!==null&&(n.updateQueue=null,Ql(n,c)));break;case 30:break;case 21:break;default:an(a,n),rn(n)}}function rn(n){var a=n.flags;if(a&2){try{for(var r,c=n.return;c!==null;){if(tv(c)){r=c;break}c=c.return}if(r==null)throw Error(i(160));switch(r.tag){case 27:var f=r.stateNode,p=dh(n);Jl(n,p,f);break;case 5:var b=r.stateNode;r.flags&32&&(ci(b,""),r.flags&=-33);var T=dh(n);Jl(n,T,b);break;case 3:case 4:var O=r.stateNode.containerInfo,G=dh(n);hh(n,G,O);break;default:throw Error(i(161))}}catch(X){Ze(n,n.return,X)}n.flags&=-3}a&4096&&(n.flags&=-4097)}function uv(n){if(n.subtreeFlags&1024)for(n=n.child;n!==null;){var a=n;uv(a),a.tag===5&&a.flags&1024&&a.stateNode.reset(),n=n.sibling}}function Ss(n,a){if(a.subtreeFlags&8772)for(a=a.child;a!==null;)av(n,a.alternate,a),a=a.sibling}function Pa(n){for(n=n.child;n!==null;){var a=n;switch(a.tag){case 0:case 11:case 14:case 15:Gs(4,a,a.return),Pa(a);break;case 1:Zn(a,a.return);var r=a.stateNode;typeof r.componentWillUnmount=="function"&&Zy(a,a.return,r),Pa(a);break;case 27:oo(a.stateNode);case 26:case 5:Zn(a,a.return),Pa(a);break;case 22:a.memoizedState===null&&Pa(a);break;case 30:Pa(a);break;default:Pa(a)}n=n.sibling}}function js(n,a,r){for(r=r&&(a.subtreeFlags&8772)!==0,a=a.child;a!==null;){var c=a.alternate,f=n,p=a,b=p.flags;switch(p.tag){case 0:case 11:case 15:js(f,p,r),Jr(4,p);break;case 1:if(js(f,p,r),c=p,f=c.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(G){Ze(c,c.return,G)}if(c=p,f=c.updateQueue,f!==null){var T=c.stateNode;try{var O=f.shared.hiddenCallbacks;if(O!==null)for(f.shared.hiddenCallbacks=null,f=0;f<O.length;f++)Ig(O[f],T)}catch(G){Ze(c,c.return,G)}}r&&b&64&&Qy(p),Qr(p,p.return);break;case 27:nv(p);case 26:case 5:js(f,p,r),r&&c===null&&b&4&&ev(p),Qr(p,p.return);break;case 12:js(f,p,r);break;case 31:js(f,p,r),r&&b&4&&ov(f,p);break;case 13:js(f,p,r),r&&b&4&&lv(f,p);break;case 22:p.memoizedState===null&&js(f,p,r),Qr(p,p.return);break;case 30:break;default:js(f,p,r)}a=a.sibling}}function mh(n,a){var r=null;n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(r=n.memoizedState.cachePool.pool),n=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(n=a.memoizedState.cachePool.pool),n!==r&&(n!=null&&n.refCount++,r!=null&&Ur(r))}function ph(n,a){n=null,a.alternate!==null&&(n=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==n&&(a.refCount++,n!=null&&Ur(n))}function Vn(n,a,r,c){if(a.subtreeFlags&10256)for(a=a.child;a!==null;)dv(n,a,r,c),a=a.sibling}function dv(n,a,r,c){var f=a.flags;switch(a.tag){case 0:case 11:case 15:Vn(n,a,r,c),f&2048&&Jr(9,a);break;case 1:Vn(n,a,r,c);break;case 3:Vn(n,a,r,c),f&2048&&(n=null,a.alternate!==null&&(n=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==n&&(a.refCount++,n!=null&&Ur(n)));break;case 12:if(f&2048){Vn(n,a,r,c),n=a.stateNode;try{var p=a.memoizedProps,b=p.id,T=p.onPostCommit;typeof T=="function"&&T(b,a.alternate===null?"mount":"update",n.passiveEffectDuration,-0)}catch(O){Ze(a,a.return,O)}}else Vn(n,a,r,c);break;case 31:Vn(n,a,r,c);break;case 13:Vn(n,a,r,c);break;case 23:break;case 22:p=a.stateNode,b=a.alternate,a.memoizedState!==null?p._visibility&2?Vn(n,a,r,c):Zr(n,a):p._visibility&2?Vn(n,a,r,c):(p._visibility|=2,Ci(n,a,r,c,(a.subtreeFlags&10256)!==0||!1)),f&2048&&mh(b,a);break;case 24:Vn(n,a,r,c),f&2048&&ph(a.alternate,a);break;default:Vn(n,a,r,c)}}function Ci(n,a,r,c,f){for(f=f&&((a.subtreeFlags&10256)!==0||!1),a=a.child;a!==null;){var p=n,b=a,T=r,O=c,G=b.flags;switch(b.tag){case 0:case 11:case 15:Ci(p,b,T,O,f),Jr(8,b);break;case 23:break;case 22:var X=b.stateNode;b.memoizedState!==null?X._visibility&2?Ci(p,b,T,O,f):Zr(p,b):(X._visibility|=2,Ci(p,b,T,O,f)),f&&G&2048&&mh(b.alternate,b);break;case 24:Ci(p,b,T,O,f),f&&G&2048&&ph(b.alternate,b);break;default:Ci(p,b,T,O,f)}a=a.sibling}}function Zr(n,a){if(a.subtreeFlags&10256)for(a=a.child;a!==null;){var r=n,c=a,f=c.flags;switch(c.tag){case 22:Zr(r,c),f&2048&&mh(c.alternate,c);break;case 24:Zr(r,c),f&2048&&ph(c.alternate,c);break;default:Zr(r,c)}a=a.sibling}}var eo=8192;function Ai(n,a,r){if(n.subtreeFlags&eo)for(n=n.child;n!==null;)hv(n,a,r),n=n.sibling}function hv(n,a,r){switch(n.tag){case 26:Ai(n,a,r),n.flags&eo&&n.memoizedState!==null&&LN(r,Bn,n.memoizedState,n.memoizedProps);break;case 5:Ai(n,a,r);break;case 3:case 4:var c=Bn;Bn=hc(n.stateNode.containerInfo),Ai(n,a,r),Bn=c;break;case 22:n.memoizedState===null&&(c=n.alternate,c!==null&&c.memoizedState!==null?(c=eo,eo=16777216,Ai(n,a,r),eo=c):Ai(n,a,r));break;default:Ai(n,a,r)}}function fv(n){var a=n.alternate;if(a!==null&&(n=a.child,n!==null)){a.child=null;do a=n.sibling,n.sibling=null,n=a;while(n!==null)}}function to(n){var a=n.deletions;if((n.flags&16)!==0){if(a!==null)for(var r=0;r<a.length;r++){var c=a[r];Dt=c,pv(c,n)}fv(n)}if(n.subtreeFlags&10256)for(n=n.child;n!==null;)mv(n),n=n.sibling}function mv(n){switch(n.tag){case 0:case 11:case 15:to(n),n.flags&2048&&Gs(9,n,n.return);break;case 3:to(n);break;case 12:to(n);break;case 22:var a=n.stateNode;n.memoizedState!==null&&a._visibility&2&&(n.return===null||n.return.tag!==13)?(a._visibility&=-3,Zl(n)):to(n);break;default:to(n)}}function Zl(n){var a=n.deletions;if((n.flags&16)!==0){if(a!==null)for(var r=0;r<a.length;r++){var c=a[r];Dt=c,pv(c,n)}fv(n)}for(n=n.child;n!==null;){switch(a=n,a.tag){case 0:case 11:case 15:Gs(8,a,a.return),Zl(a);break;case 22:r=a.stateNode,r._visibility&2&&(r._visibility&=-3,Zl(a));break;default:Zl(a)}n=n.sibling}}function pv(n,a){for(;Dt!==null;){var r=Dt;switch(r.tag){case 0:case 11:case 15:Gs(8,r,a);break;case 23:case 22:if(r.memoizedState!==null&&r.memoizedState.cachePool!==null){var c=r.memoizedState.cachePool.pool;c!=null&&c.refCount++}break;case 24:Ur(r.memoizedState.cache)}if(c=r.child,c!==null)c.return=r,Dt=c;else e:for(r=n;Dt!==null;){c=Dt;var f=c.sibling,p=c.return;if(iv(c),c===r){Dt=null;break e}if(f!==null){f.return=p,Dt=f;break e}Dt=p}}}var Q_={getCacheForType:function(n){var a=It(St),r=a.data.get(n);return r===void 0&&(r=n(),a.data.set(n,r)),r},cacheSignal:function(){return It(St).controller.signal}},Z_=typeof WeakMap=="function"?WeakMap:Map,We=0,it=null,Ie=null,He=0,Qe=0,gn=null,Fs=!1,Ri=!1,gh=!1,_s=0,gt=0,Ks=0,za=0,yh=0,yn=0,Oi=0,no=null,on=null,vh=!1,ec=0,gv=0,tc=1/0,nc=null,Ys=null,Ct=0,Xs=null,Mi=null,Ns=0,xh=0,bh=null,yv=null,so=0,wh=null;function vn(){return(We&2)!==0&&He!==0?He&-He:$.T!==null?Eh():Mp()}function vv(){if(yn===0)if((He&536870912)===0||Ke){var n=ul;ul<<=1,(ul&3932160)===0&&(ul=262144),yn=n}else yn=536870912;return n=mn.current,n!==null&&(n.flags|=32),yn}function ln(n,a,r){(n===it&&(Qe===2||Qe===9)||n.cancelPendingCommit!==null)&&(Di(n,0),Ws(n,He,yn,!1)),_r(n,r),((We&2)===0||n!==it)&&(n===it&&((We&2)===0&&(za|=r),gt===4&&Ws(n,He,yn,!1)),es(n))}function xv(n,a,r){if((We&6)!==0)throw Error(i(327));var c=!r&&(a&127)===0&&(a&n.expiredLanes)===0||jr(n,a),f=c?nN(n,a):jh(n,a,!0),p=c;do{if(f===0){Ri&&!c&&Ws(n,a,0,!1);break}else{if(r=n.current.alternate,p&&!eN(r)){f=jh(n,a,!1),p=!1;continue}if(f===2){if(p=a,n.errorRecoveryDisabledLanes&p)var b=0;else b=n.pendingLanes&-536870913,b=b!==0?b:b&536870912?536870912:0;if(b!==0){a=b;e:{var T=n;f=no;var O=T.current.memoizedState.isDehydrated;if(O&&(Di(T,b).flags|=256),b=jh(T,b,!1),b!==2){if(gh&&!O){T.errorRecoveryDisabledLanes|=p,za|=p,f=4;break e}p=on,on=f,p!==null&&(on===null?on=p:on.push.apply(on,p))}f=b}if(p=!1,f!==2)continue}}if(f===1){Di(n,0),Ws(n,a,0,!0);break}e:{switch(c=n,p=f,p){case 0:case 1:throw Error(i(345));case 4:if((a&4194048)!==a)break;case 6:Ws(c,a,yn,!Fs);break e;case 2:on=null;break;case 3:case 5:break;default:throw Error(i(329))}if((a&62914560)===a&&(f=ec+300-B(),10<f)){if(Ws(c,a,yn,!Fs),hl(c,0,!0)!==0)break e;Ns=a,c.timeoutHandle=Wv(bv.bind(null,c,r,on,nc,vh,a,yn,za,Oi,Fs,p,"Throttled",-0,0),f);break e}bv(c,r,on,nc,vh,a,yn,za,Oi,Fs,p,null,-0,0)}}break}while(!0);es(n)}function bv(n,a,r,c,f,p,b,T,O,G,X,ee,F,K){if(n.timeoutHandle=-1,ee=a.subtreeFlags,ee&8192||(ee&16785408)===16785408){ee={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:us},hv(a,p,ee);var ve=(p&62914560)===p?ec-B():(p&4194048)===p?gv-B():0;if(ve=UN(ee,ve),ve!==null){Ns=p,n.cancelPendingCommit=ve(kv.bind(null,n,a,p,r,c,f,b,T,O,X,ee,null,F,K)),Ws(n,p,b,!G);return}}kv(n,a,p,r,c,f,b,T,O)}function eN(n){for(var a=n;;){var r=a.tag;if((r===0||r===11||r===15)&&a.flags&16384&&(r=a.updateQueue,r!==null&&(r=r.stores,r!==null)))for(var c=0;c<r.length;c++){var f=r[c],p=f.getSnapshot;f=f.value;try{if(!hn(p(),f))return!1}catch{return!1}}if(r=a.child,a.subtreeFlags&16384&&r!==null)r.return=a,a=r;else{if(a===n)break;for(;a.sibling===null;){if(a.return===null||a.return===n)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function Ws(n,a,r,c){a&=~yh,a&=~za,n.suspendedLanes|=a,n.pingedLanes&=~a,c&&(n.warmLanes|=a),c=n.expirationTimes;for(var f=a;0<f;){var p=31-dn(f),b=1<<p;c[p]=-1,f&=~b}r!==0&&Ap(n,r,a)}function sc(){return(We&6)===0?(ao(0),!1):!0}function Sh(){if(Ie!==null){if(Qe===0)var n=Ie.return;else n=Ie,ms=Ea=null,Ud(n),_i=null,Vr=0,n=Ie;for(;n!==null;)Jy(n.alternate,n),n=n.return;Ie=null}}function Di(n,a){var r=n.timeoutHandle;r!==-1&&(n.timeoutHandle=-1,bN(r)),r=n.cancelPendingCommit,r!==null&&(n.cancelPendingCommit=null,r()),Ns=0,Sh(),it=n,Ie=r=hs(n.current,null),He=a,Qe=0,gn=null,Fs=!1,Ri=jr(n,a),gh=!1,Oi=yn=yh=za=Ks=gt=0,on=no=null,vh=!1,(a&8)!==0&&(a|=a&32);var c=n.entangledLanes;if(c!==0)for(n=n.entanglements,c&=a;0<c;){var f=31-dn(c),p=1<<f;a|=n[f],c&=~p}return _s=a,_l(),r}function wv(n,a){Pe=null,$.H=Yr,a===ji||a===Ol?(a=Lg(),Qe=3):a===Td?(a=Lg(),Qe=4):Qe=a===eh?8:a!==null&&typeof a=="object"&&typeof a.then=="function"?6:1,gn=a,Ie===null&&(gt=1,Fl(n,kn(a,n.current)))}function Sv(){var n=mn.current;return n===null?!0:(He&4194048)===He?On===null:(He&62914560)===He||(He&536870912)!==0?n===On:!1}function jv(){var n=$.H;return $.H=Yr,n===null?Yr:n}function _v(){var n=$.A;return $.A=Q_,n}function ac(){gt=4,Fs||(He&4194048)!==He&&mn.current!==null||(Ri=!0),(Ks&134217727)===0&&(za&134217727)===0||it===null||Ws(it,He,yn,!1)}function jh(n,a,r){var c=We;We|=2;var f=jv(),p=_v();(it!==n||He!==a)&&(nc=null,Di(n,a)),a=!1;var b=gt;e:do try{if(Qe!==0&&Ie!==null){var T=Ie,O=gn;switch(Qe){case 8:Sh(),b=6;break e;case 3:case 2:case 9:case 6:mn.current===null&&(a=!0);var G=Qe;if(Qe=0,gn=null,Pi(n,T,O,G),r&&Ri){b=0;break e}break;default:G=Qe,Qe=0,gn=null,Pi(n,T,O,G)}}tN(),b=gt;break}catch(X){wv(n,X)}while(!0);return a&&n.shellSuspendCounter++,ms=Ea=null,We=c,$.H=f,$.A=p,Ie===null&&(it=null,He=0,_l()),b}function tN(){for(;Ie!==null;)Nv(Ie)}function nN(n,a){var r=We;We|=2;var c=jv(),f=_v();it!==n||He!==a?(nc=null,tc=B()+500,Di(n,a)):Ri=jr(n,a);e:do try{if(Qe!==0&&Ie!==null){a=Ie;var p=gn;t:switch(Qe){case 1:Qe=0,gn=null,Pi(n,a,p,1);break;case 2:case 9:if(Pg(p)){Qe=0,gn=null,Tv(a);break}a=function(){Qe!==2&&Qe!==9||it!==n||(Qe=7),es(n)},p.then(a,a);break e;case 3:Qe=7;break e;case 4:Qe=5;break e;case 7:Pg(p)?(Qe=0,gn=null,Tv(a)):(Qe=0,gn=null,Pi(n,a,p,7));break;case 5:var b=null;switch(Ie.tag){case 26:b=Ie.memoizedState;case 5:case 27:var T=Ie;if(b?dx(b):T.stateNode.complete){Qe=0,gn=null;var O=T.sibling;if(O!==null)Ie=O;else{var G=T.return;G!==null?(Ie=G,ic(G)):Ie=null}break t}}Qe=0,gn=null,Pi(n,a,p,5);break;case 6:Qe=0,gn=null,Pi(n,a,p,6);break;case 8:Sh(),gt=6;break e;default:throw Error(i(462))}}sN();break}catch(X){wv(n,X)}while(!0);return ms=Ea=null,$.H=c,$.A=f,We=r,Ie!==null?0:(it=null,He=0,_l(),gt)}function sN(){for(;Ie!==null&&!Sr();)Nv(Ie)}function Nv(n){var a=Xy(n.alternate,n,_s);n.memoizedProps=n.pendingProps,a===null?ic(n):Ie=a}function Tv(n){var a=n,r=a.alternate;switch(a.tag){case 15:case 0:a=qy(r,a,a.pendingProps,a.type,void 0,He);break;case 11:a=qy(r,a,a.pendingProps,a.type.render,a.ref,He);break;case 5:Ud(a);default:Jy(r,a),a=Ie=_g(a,_s),a=Xy(r,a,_s)}n.memoizedProps=n.pendingProps,a===null?ic(n):Ie=a}function Pi(n,a,r,c){ms=Ea=null,Ud(a),_i=null,Vr=0;var f=a.return;try{if(G_(n,f,a,r,He)){gt=1,Fl(n,kn(r,n.current)),Ie=null;return}}catch(p){if(f!==null)throw Ie=f,p;gt=1,Fl(n,kn(r,n.current)),Ie=null;return}a.flags&32768?(Ke||c===1?n=!0:Ri||(He&536870912)!==0?n=!1:(Fs=n=!0,(c===2||c===9||c===3||c===6)&&(c=mn.current,c!==null&&c.tag===13&&(c.flags|=16384))),Ev(a,n)):ic(a)}function ic(n){var a=n;do{if((a.flags&32768)!==0){Ev(a,Fs);return}n=a.return;var r=Y_(a.alternate,a,_s);if(r!==null){Ie=r;return}if(a=a.sibling,a!==null){Ie=a;return}Ie=a=n}while(a!==null);gt===0&&(gt=5)}function Ev(n,a){do{var r=X_(n.alternate,n);if(r!==null){r.flags&=32767,Ie=r;return}if(r=n.return,r!==null&&(r.flags|=32768,r.subtreeFlags=0,r.deletions=null),!a&&(n=n.sibling,n!==null)){Ie=n;return}Ie=n=r}while(n!==null);gt=6,Ie=null}function kv(n,a,r,c,f,p,b,T,O){n.cancelPendingCommit=null;do rc();while(Ct!==0);if((We&6)!==0)throw Error(i(327));if(a!==null){if(a===n.current)throw Error(i(177));if(p=a.lanes|a.childLanes,p|=dd,zj(n,r,p,b,T,O),n===it&&(Ie=it=null,He=0),Mi=a,Xs=n,Ns=r,xh=p,bh=f,yv=c,(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?(n.callbackNode=null,n.callbackPriority=0,oN(ft,function(){return Mv(),null})):(n.callbackNode=null,n.callbackPriority=0),c=(a.flags&13878)!==0,(a.subtreeFlags&13878)!==0||c){c=$.T,$.T=null,f=Y.p,Y.p=2,b=We,We|=4;try{W_(n,a,r)}finally{We=b,Y.p=f,$.T=c}}Ct=1,Cv(),Av(),Rv()}}function Cv(){if(Ct===1){Ct=0;var n=Xs,a=Mi,r=(a.flags&13878)!==0;if((a.subtreeFlags&13878)!==0||r){r=$.T,$.T=null;var c=Y.p;Y.p=2;var f=We;We|=4;try{cv(a,n);var p=Ph,b=pg(n.containerInfo),T=p.focusedElem,O=p.selectionRange;if(b!==T&&T&&T.ownerDocument&&mg(T.ownerDocument.documentElement,T)){if(O!==null&&rd(T)){var G=O.start,X=O.end;if(X===void 0&&(X=G),"selectionStart"in T)T.selectionStart=G,T.selectionEnd=Math.min(X,T.value.length);else{var ee=T.ownerDocument||document,F=ee&&ee.defaultView||window;if(F.getSelection){var K=F.getSelection(),ve=T.textContent.length,Ce=Math.min(O.start,ve),st=O.end===void 0?Ce:Math.min(O.end,ve);!K.extend&&Ce>st&&(b=st,st=Ce,Ce=b);var I=fg(T,Ce),L=fg(T,st);if(I&&L&&(K.rangeCount!==1||K.anchorNode!==I.node||K.anchorOffset!==I.offset||K.focusNode!==L.node||K.focusOffset!==L.offset)){var H=ee.createRange();H.setStart(I.node,I.offset),K.removeAllRanges(),Ce>st?(K.addRange(H),K.extend(L.node,L.offset)):(H.setEnd(L.node,L.offset),K.addRange(H))}}}}for(ee=[],K=T;K=K.parentNode;)K.nodeType===1&&ee.push({element:K,left:K.scrollLeft,top:K.scrollTop});for(typeof T.focus=="function"&&T.focus(),T=0;T<ee.length;T++){var Q=ee[T];Q.element.scrollLeft=Q.left,Q.element.scrollTop=Q.top}}vc=!!Dh,Ph=Dh=null}finally{We=f,Y.p=c,$.T=r}}n.current=a,Ct=2}}function Av(){if(Ct===2){Ct=0;var n=Xs,a=Mi,r=(a.flags&8772)!==0;if((a.subtreeFlags&8772)!==0||r){r=$.T,$.T=null;var c=Y.p;Y.p=2;var f=We;We|=4;try{av(n,a.alternate,a)}finally{We=f,Y.p=c,$.T=r}}Ct=3}}function Rv(){if(Ct===4||Ct===3){Ct=0,Uu();var n=Xs,a=Mi,r=Ns,c=yv;(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?Ct=5:(Ct=0,Mi=Xs=null,Ov(n,n.pendingLanes));var f=n.pendingLanes;if(f===0&&(Ys=null),Iu(r),a=a.stateNode,Kt&&typeof Kt.onCommitFiberRoot=="function")try{Kt.onCommitFiberRoot(Ms,a,void 0,(a.current.flags&128)===128)}catch{}if(c!==null){a=$.T,f=Y.p,Y.p=2,$.T=null;try{for(var p=n.onRecoverableError,b=0;b<c.length;b++){var T=c[b];p(T.value,{componentStack:T.stack})}}finally{$.T=a,Y.p=f}}(Ns&3)!==0&&rc(),es(n),f=n.pendingLanes,(r&261930)!==0&&(f&42)!==0?n===wh?so++:(so=0,wh=n):so=0,ao(0)}}function Ov(n,a){(n.pooledCacheLanes&=a)===0&&(a=n.pooledCache,a!=null&&(n.pooledCache=null,Ur(a)))}function rc(){return Cv(),Av(),Rv(),Mv()}function Mv(){if(Ct!==5)return!1;var n=Xs,a=xh;xh=0;var r=Iu(Ns),c=$.T,f=Y.p;try{Y.p=32>r?32:r,$.T=null,r=bh,bh=null;var p=Xs,b=Ns;if(Ct=0,Mi=Xs=null,Ns=0,(We&6)!==0)throw Error(i(331));var T=We;if(We|=4,mv(p.current),dv(p,p.current,b,r),We=T,ao(0,!1),Kt&&typeof Kt.onPostCommitFiberRoot=="function")try{Kt.onPostCommitFiberRoot(Ms,p)}catch{}return!0}finally{Y.p=f,$.T=c,Ov(n,a)}}function Dv(n,a,r){a=kn(r,a),a=Zd(n.stateNode,a,2),n=$s(n,a,2),n!==null&&(_r(n,2),es(n))}function Ze(n,a,r){if(n.tag===3)Dv(n,n,r);else for(;a!==null;){if(a.tag===3){Dv(a,n,r);break}else if(a.tag===1){var c=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Ys===null||!Ys.has(c))){n=kn(r,n),r=Py(2),c=$s(a,r,2),c!==null&&(zy(r,c,a,n),_r(c,2),es(c));break}}a=a.return}}function _h(n,a,r){var c=n.pingCache;if(c===null){c=n.pingCache=new Z_;var f=new Set;c.set(a,f)}else f=c.get(a),f===void 0&&(f=new Set,c.set(a,f));f.has(r)||(gh=!0,f.add(r),n=aN.bind(null,n,a,r),a.then(n,n))}function aN(n,a,r){var c=n.pingCache;c!==null&&c.delete(a),n.pingedLanes|=n.suspendedLanes&r,n.warmLanes&=~r,it===n&&(He&r)===r&&(gt===4||gt===3&&(He&62914560)===He&&300>B()-ec?(We&2)===0&&Di(n,0):yh|=r,Oi===He&&(Oi=0)),es(n)}function Pv(n,a){a===0&&(a=Cp()),n=_a(n,a),n!==null&&(_r(n,a),es(n))}function iN(n){var a=n.memoizedState,r=0;a!==null&&(r=a.retryLane),Pv(n,r)}function rN(n,a){var r=0;switch(n.tag){case 31:case 13:var c=n.stateNode,f=n.memoizedState;f!==null&&(r=f.retryLane);break;case 19:c=n.stateNode;break;case 22:c=n.stateNode._retryCache;break;default:throw Error(i(314))}c!==null&&c.delete(a),Pv(n,r)}function oN(n,a){return Xn(n,a)}var oc=null,zi=null,Nh=!1,lc=!1,Th=!1,Js=0;function es(n){n!==zi&&n.next===null&&(zi===null?oc=zi=n:zi=zi.next=n),lc=!0,Nh||(Nh=!0,cN())}function ao(n,a){if(!Th&&lc){Th=!0;do for(var r=!1,c=oc;c!==null;){if(n!==0){var f=c.pendingLanes;if(f===0)var p=0;else{var b=c.suspendedLanes,T=c.pingedLanes;p=(1<<31-dn(42|n)+1)-1,p&=f&~(b&~T),p=p&201326741?p&201326741|1:p?p|2:0}p!==0&&(r=!0,Bv(c,p))}else p=He,p=hl(c,c===it?p:0,c.cancelPendingCommit!==null||c.timeoutHandle!==-1),(p&3)===0||jr(c,p)||(r=!0,Bv(c,p));c=c.next}while(r);Th=!1}}function lN(){zv()}function zv(){lc=Nh=!1;var n=0;Js!==0&&xN()&&(n=Js);for(var a=B(),r=null,c=oc;c!==null;){var f=c.next,p=Lv(c,a);p===0?(c.next=null,r===null?oc=f:r.next=f,f===null&&(zi=r)):(r=c,(n!==0||(p&3)!==0)&&(lc=!0)),c=f}Ct!==0&&Ct!==5||ao(n),Js!==0&&(Js=0)}function Lv(n,a){for(var r=n.suspendedLanes,c=n.pingedLanes,f=n.expirationTimes,p=n.pendingLanes&-62914561;0<p;){var b=31-dn(p),T=1<<b,O=f[b];O===-1?((T&r)===0||(T&c)!==0)&&(f[b]=Pj(T,a)):O<=a&&(n.expiredLanes|=T),p&=~T}if(a=it,r=He,r=hl(n,n===a?r:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),c=n.callbackNode,r===0||n===a&&(Qe===2||Qe===9)||n.cancelPendingCommit!==null)return c!==null&&c!==null&&wr(c),n.callbackNode=null,n.callbackPriority=0;if((r&3)===0||jr(n,r)){if(a=r&-r,a===n.callbackPriority)return a;switch(c!==null&&wr(c),Iu(r)){case 2:case 8:r=qe;break;case 32:r=ft;break;case 268435456:r=Ve;break;default:r=ft}return c=Uv.bind(null,n),r=Xn(r,c),n.callbackPriority=a,n.callbackNode=r,a}return c!==null&&c!==null&&wr(c),n.callbackPriority=2,n.callbackNode=null,2}function Uv(n,a){if(Ct!==0&&Ct!==5)return n.callbackNode=null,n.callbackPriority=0,null;var r=n.callbackNode;if(rc()&&n.callbackNode!==r)return null;var c=He;return c=hl(n,n===it?c:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),c===0?null:(xv(n,c,a),Lv(n,B()),n.callbackNode!=null&&n.callbackNode===r?Uv.bind(null,n):null)}function Bv(n,a){if(rc())return null;xv(n,a,!0)}function cN(){wN(function(){(We&6)!==0?Xn(De,lN):zv()})}function Eh(){if(Js===0){var n=wi;n===0&&(n=cl,cl<<=1,(cl&261888)===0&&(cl=256)),Js=n}return Js}function Vv(n){return n==null||typeof n=="symbol"||typeof n=="boolean"?null:typeof n=="function"?n:gl(""+n)}function Iv(n,a){var r=a.ownerDocument.createElement("input");return r.name=a.name,r.value=a.value,n.id&&r.setAttribute("form",n.id),a.parentNode.insertBefore(r,a),n=new FormData(n),r.parentNode.removeChild(r),n}function uN(n,a,r,c,f){if(a==="submit"&&r&&r.stateNode===f){var p=Vv((f[tn]||null).action),b=c.submitter;b&&(a=(a=b[tn]||null)?Vv(a.formAction):b.getAttribute("formAction"),a!==null&&(p=a,b=null));var T=new bl("action","action",null,c,f);n.push({event:T,listeners:[{instance:null,listener:function(){if(c.defaultPrevented){if(Js!==0){var O=b?Iv(f,b):new FormData(f);Kd(r,{pending:!0,data:O,method:f.method,action:p},null,O)}}else typeof p=="function"&&(T.preventDefault(),O=b?Iv(f,b):new FormData(f),Kd(r,{pending:!0,data:O,method:f.method,action:p},p,O))},currentTarget:f}]})}}for(var kh=0;kh<ud.length;kh++){var Ch=ud[kh],dN=Ch.toLowerCase(),hN=Ch[0].toUpperCase()+Ch.slice(1);Un(dN,"on"+hN)}Un(vg,"onAnimationEnd"),Un(xg,"onAnimationIteration"),Un(bg,"onAnimationStart"),Un("dblclick","onDoubleClick"),Un("focusin","onFocus"),Un("focusout","onBlur"),Un(k_,"onTransitionRun"),Un(C_,"onTransitionStart"),Un(A_,"onTransitionCancel"),Un(wg,"onTransitionEnd"),oi("onMouseEnter",["mouseout","mouseover"]),oi("onMouseLeave",["mouseout","mouseover"]),oi("onPointerEnter",["pointerout","pointerover"]),oi("onPointerLeave",["pointerout","pointerover"]),ba("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ba("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ba("onBeforeInput",["compositionend","keypress","textInput","paste"]),ba("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ba("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ba("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var io="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(" "),fN=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(io));function $v(n,a){a=(a&4)!==0;for(var r=0;r<n.length;r++){var c=n[r],f=c.event;c=c.listeners;e:{var p=void 0;if(a)for(var b=c.length-1;0<=b;b--){var T=c[b],O=T.instance,G=T.currentTarget;if(T=T.listener,O!==p&&f.isPropagationStopped())break e;p=T,f.currentTarget=G;try{p(f)}catch(X){jl(X)}f.currentTarget=null,p=O}else for(b=0;b<c.length;b++){if(T=c[b],O=T.instance,G=T.currentTarget,T=T.listener,O!==p&&f.isPropagationStopped())break e;p=T,f.currentTarget=G;try{p(f)}catch(X){jl(X)}f.currentTarget=null,p=O}}}}function $e(n,a){var r=a[$u];r===void 0&&(r=a[$u]=new Set);var c=n+"__bubble";r.has(c)||(qv(a,n,2,!1),r.add(c))}function Ah(n,a,r){var c=0;a&&(c|=4),qv(r,n,c,a)}var cc="_reactListening"+Math.random().toString(36).slice(2);function Rh(n){if(!n[cc]){n[cc]=!0,zp.forEach(function(r){r!=="selectionchange"&&(fN.has(r)||Ah(r,!1,n),Ah(r,!0,n))});var a=n.nodeType===9?n:n.ownerDocument;a===null||a[cc]||(a[cc]=!0,Ah("selectionchange",!1,a))}}function qv(n,a,r,c){switch(vx(a)){case 2:var f=IN;break;case 8:f=$N;break;default:f=Fh}r=f.bind(null,a,r,n),f=void 0,!Ju||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(f=!0),c?f!==void 0?n.addEventListener(a,r,{capture:!0,passive:f}):n.addEventListener(a,r,!0):f!==void 0?n.addEventListener(a,r,{passive:f}):n.addEventListener(a,r,!1)}function Oh(n,a,r,c,f){var p=c;if((a&1)===0&&(a&2)===0&&c!==null)e:for(;;){if(c===null)return;var b=c.tag;if(b===3||b===4){var T=c.stateNode.containerInfo;if(T===f)break;if(b===4)for(b=c.return;b!==null;){var O=b.tag;if((O===3||O===4)&&b.stateNode.containerInfo===f)return;b=b.return}for(;T!==null;){if(b=ai(T),b===null)return;if(O=b.tag,O===5||O===6||O===26||O===27){c=p=b;continue e}T=T.parentNode}}c=c.return}Yp(function(){var G=p,X=Xu(r),ee=[];e:{var F=Sg.get(n);if(F!==void 0){var K=bl,ve=n;switch(n){case"keypress":if(vl(r)===0)break e;case"keydown":case"keyup":K=r_;break;case"focusin":ve="focus",K=td;break;case"focusout":ve="blur",K=td;break;case"beforeblur":case"afterblur":K=td;break;case"click":if(r.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":K=Jp;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":K=Yj;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":K=c_;break;case vg:case xg:case bg:K=Jj;break;case wg:K=d_;break;case"scroll":case"scrollend":K=Fj;break;case"wheel":K=f_;break;case"copy":case"cut":case"paste":K=Zj;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":K=Zp;break;case"toggle":case"beforetoggle":K=p_}var Ce=(a&4)!==0,st=!Ce&&(n==="scroll"||n==="scrollend"),I=Ce?F!==null?F+"Capture":null:F;Ce=[];for(var L=G,H;L!==null;){var Q=L;if(H=Q.stateNode,Q=Q.tag,Q!==5&&Q!==26&&Q!==27||H===null||I===null||(Q=Er(L,I),Q!=null&&Ce.push(ro(L,Q,H))),st)break;L=L.return}0<Ce.length&&(F=new K(F,ve,null,r,X),ee.push({event:F,listeners:Ce}))}}if((a&7)===0){e:{if(F=n==="mouseover"||n==="pointerover",K=n==="mouseout"||n==="pointerout",F&&r!==Yu&&(ve=r.relatedTarget||r.fromElement)&&(ai(ve)||ve[si]))break e;if((K||F)&&(F=X.window===X?X:(F=X.ownerDocument)?F.defaultView||F.parentWindow:window,K?(ve=r.relatedTarget||r.toElement,K=G,ve=ve?ai(ve):null,ve!==null&&(st=u(ve),Ce=ve.tag,ve!==st||Ce!==5&&Ce!==27&&Ce!==6)&&(ve=null)):(K=null,ve=G),K!==ve)){if(Ce=Jp,Q="onMouseLeave",I="onMouseEnter",L="mouse",(n==="pointerout"||n==="pointerover")&&(Ce=Zp,Q="onPointerLeave",I="onPointerEnter",L="pointer"),st=K==null?F:Tr(K),H=ve==null?F:Tr(ve),F=new Ce(Q,L+"leave",K,r,X),F.target=st,F.relatedTarget=H,Q=null,ai(X)===G&&(Ce=new Ce(I,L+"enter",ve,r,X),Ce.target=H,Ce.relatedTarget=st,Q=Ce),st=Q,K&&ve)t:{for(Ce=mN,I=K,L=ve,H=0,Q=I;Q;Q=Ce(Q))H++;Q=0;for(var ke=L;ke;ke=Ce(ke))Q++;for(;0<H-Q;)I=Ce(I),H--;for(;0<Q-H;)L=Ce(L),Q--;for(;H--;){if(I===L||L!==null&&I===L.alternate){Ce=I;break t}I=Ce(I),L=Ce(L)}Ce=null}else Ce=null;K!==null&&Hv(ee,F,K,Ce,!1),ve!==null&&st!==null&&Hv(ee,st,ve,Ce,!0)}}e:{if(F=G?Tr(G):window,K=F.nodeName&&F.nodeName.toLowerCase(),K==="select"||K==="input"&&F.type==="file")var Ye=og;else if(ig(F))if(lg)Ye=N_;else{Ye=j_;var Se=S_}else K=F.nodeName,!K||K.toLowerCase()!=="input"||F.type!=="checkbox"&&F.type!=="radio"?G&&Ku(G.elementType)&&(Ye=og):Ye=__;if(Ye&&(Ye=Ye(n,G))){rg(ee,Ye,r,X);break e}Se&&Se(n,F,G),n==="focusout"&&G&&F.type==="number"&&G.memoizedProps.value!=null&&Fu(F,"number",F.value)}switch(Se=G?Tr(G):window,n){case"focusin":(ig(Se)||Se.contentEditable==="true")&&(fi=Se,od=G,Pr=null);break;case"focusout":Pr=od=fi=null;break;case"mousedown":ld=!0;break;case"contextmenu":case"mouseup":case"dragend":ld=!1,gg(ee,r,X);break;case"selectionchange":if(E_)break;case"keydown":case"keyup":gg(ee,r,X)}var Le;if(sd)e:{switch(n){case"compositionstart":var Ge="onCompositionStart";break e;case"compositionend":Ge="onCompositionEnd";break e;case"compositionupdate":Ge="onCompositionUpdate";break e}Ge=void 0}else hi?sg(n,r)&&(Ge="onCompositionEnd"):n==="keydown"&&r.keyCode===229&&(Ge="onCompositionStart");Ge&&(eg&&r.locale!=="ko"&&(hi||Ge!=="onCompositionStart"?Ge==="onCompositionEnd"&&hi&&(Le=Xp()):(Ps=X,Qu="value"in Ps?Ps.value:Ps.textContent,hi=!0)),Se=uc(G,Ge),0<Se.length&&(Ge=new Qp(Ge,n,null,r,X),ee.push({event:Ge,listeners:Se}),Le?Ge.data=Le:(Le=ag(r),Le!==null&&(Ge.data=Le)))),(Le=y_?v_(n,r):x_(n,r))&&(Ge=uc(G,"onBeforeInput"),0<Ge.length&&(Se=new Qp("onBeforeInput","beforeinput",null,r,X),ee.push({event:Se,listeners:Ge}),Se.data=Le)),uN(ee,n,G,r,X)}$v(ee,a)})}function ro(n,a,r){return{instance:n,listener:a,currentTarget:r}}function uc(n,a){for(var r=a+"Capture",c=[];n!==null;){var f=n,p=f.stateNode;if(f=f.tag,f!==5&&f!==26&&f!==27||p===null||(f=Er(n,r),f!=null&&c.unshift(ro(n,f,p)),f=Er(n,a),f!=null&&c.push(ro(n,f,p))),n.tag===3)return c;n=n.return}return[]}function mN(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5&&n.tag!==27);return n||null}function Hv(n,a,r,c,f){for(var p=a._reactName,b=[];r!==null&&r!==c;){var T=r,O=T.alternate,G=T.stateNode;if(T=T.tag,O!==null&&O===c)break;T!==5&&T!==26&&T!==27||G===null||(O=G,f?(G=Er(r,p),G!=null&&b.unshift(ro(r,G,O))):f||(G=Er(r,p),G!=null&&b.push(ro(r,G,O)))),r=r.return}b.length!==0&&n.push({event:a,listeners:b})}var pN=/\r\n?/g,gN=/\u0000|\uFFFD/g;function Gv(n){return(typeof n=="string"?n:""+n).replace(pN,`
|
|
9
|
+
`).replace(gN,"")}function Fv(n,a){return a=Gv(a),Gv(n)===a}function nt(n,a,r,c,f,p){switch(r){case"children":typeof c=="string"?a==="body"||a==="textarea"&&c===""||ci(n,c):(typeof c=="number"||typeof c=="bigint")&&a!=="body"&&ci(n,""+c);break;case"className":ml(n,"class",c);break;case"tabIndex":ml(n,"tabindex",c);break;case"dir":case"role":case"viewBox":case"width":case"height":ml(n,r,c);break;case"style":Fp(n,c,p);break;case"data":if(a!=="object"){ml(n,"data",c);break}case"src":case"href":if(c===""&&(a!=="a"||r!=="href")){n.removeAttribute(r);break}if(c==null||typeof c=="function"||typeof c=="symbol"||typeof c=="boolean"){n.removeAttribute(r);break}c=gl(""+c),n.setAttribute(r,c);break;case"action":case"formAction":if(typeof c=="function"){n.setAttribute(r,"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 p=="function"&&(r==="formAction"?(a!=="input"&&nt(n,a,"name",f.name,f,null),nt(n,a,"formEncType",f.formEncType,f,null),nt(n,a,"formMethod",f.formMethod,f,null),nt(n,a,"formTarget",f.formTarget,f,null)):(nt(n,a,"encType",f.encType,f,null),nt(n,a,"method",f.method,f,null),nt(n,a,"target",f.target,f,null)));if(c==null||typeof c=="symbol"||typeof c=="boolean"){n.removeAttribute(r);break}c=gl(""+c),n.setAttribute(r,c);break;case"onClick":c!=null&&(n.onclick=us);break;case"onScroll":c!=null&&$e("scroll",n);break;case"onScrollEnd":c!=null&&$e("scrollend",n);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(i(61));if(r=c.__html,r!=null){if(f.children!=null)throw Error(i(60));n.innerHTML=r}}break;case"multiple":n.multiple=c&&typeof c!="function"&&typeof c!="symbol";break;case"muted":n.muted=c&&typeof c!="function"&&typeof c!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(c==null||typeof c=="function"||typeof c=="boolean"||typeof c=="symbol"){n.removeAttribute("xlink:href");break}r=gl(""+c),n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":c!=null&&typeof c!="function"&&typeof c!="symbol"?n.setAttribute(r,""+c):n.removeAttribute(r);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":c&&typeof c!="function"&&typeof c!="symbol"?n.setAttribute(r,""):n.removeAttribute(r);break;case"capture":case"download":c===!0?n.setAttribute(r,""):c!==!1&&c!=null&&typeof c!="function"&&typeof c!="symbol"?n.setAttribute(r,c):n.removeAttribute(r);break;case"cols":case"rows":case"size":case"span":c!=null&&typeof c!="function"&&typeof c!="symbol"&&!isNaN(c)&&1<=c?n.setAttribute(r,c):n.removeAttribute(r);break;case"rowSpan":case"start":c==null||typeof c=="function"||typeof c=="symbol"||isNaN(c)?n.removeAttribute(r):n.setAttribute(r,c);break;case"popover":$e("beforetoggle",n),$e("toggle",n),fl(n,"popover",c);break;case"xlinkActuate":cs(n,"http://www.w3.org/1999/xlink","xlink:actuate",c);break;case"xlinkArcrole":cs(n,"http://www.w3.org/1999/xlink","xlink:arcrole",c);break;case"xlinkRole":cs(n,"http://www.w3.org/1999/xlink","xlink:role",c);break;case"xlinkShow":cs(n,"http://www.w3.org/1999/xlink","xlink:show",c);break;case"xlinkTitle":cs(n,"http://www.w3.org/1999/xlink","xlink:title",c);break;case"xlinkType":cs(n,"http://www.w3.org/1999/xlink","xlink:type",c);break;case"xmlBase":cs(n,"http://www.w3.org/XML/1998/namespace","xml:base",c);break;case"xmlLang":cs(n,"http://www.w3.org/XML/1998/namespace","xml:lang",c);break;case"xmlSpace":cs(n,"http://www.w3.org/XML/1998/namespace","xml:space",c);break;case"is":fl(n,"is",c);break;case"innerText":case"textContent":break;default:(!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(r=Hj.get(r)||r,fl(n,r,c))}}function Mh(n,a,r,c,f,p){switch(r){case"style":Fp(n,c,p);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(i(61));if(r=c.__html,r!=null){if(f.children!=null)throw Error(i(60));n.innerHTML=r}}break;case"children":typeof c=="string"?ci(n,c):(typeof c=="number"||typeof c=="bigint")&&ci(n,""+c);break;case"onScroll":c!=null&&$e("scroll",n);break;case"onScrollEnd":c!=null&&$e("scrollend",n);break;case"onClick":c!=null&&(n.onclick=us);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Lp.hasOwnProperty(r))e:{if(r[0]==="o"&&r[1]==="n"&&(f=r.endsWith("Capture"),a=r.slice(2,f?r.length-7:void 0),p=n[tn]||null,p=p!=null?p[r]:null,typeof p=="function"&&n.removeEventListener(a,p,f),typeof c=="function")){typeof p!="function"&&p!==null&&(r in n?n[r]=null:n.hasAttribute(r)&&n.removeAttribute(r)),n.addEventListener(a,c,f);break e}r in n?n[r]=c:c===!0?n.setAttribute(r,""):fl(n,r,c)}}}function qt(n,a,r){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":$e("error",n),$e("load",n);var c=!1,f=!1,p;for(p in r)if(r.hasOwnProperty(p)){var b=r[p];if(b!=null)switch(p){case"src":c=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,a));default:nt(n,a,p,b,r,null)}}f&&nt(n,a,"srcSet",r.srcSet,r,null),c&&nt(n,a,"src",r.src,r,null);return;case"input":$e("invalid",n);var T=p=b=f=null,O=null,G=null;for(c in r)if(r.hasOwnProperty(c)){var X=r[c];if(X!=null)switch(c){case"name":f=X;break;case"type":b=X;break;case"checked":O=X;break;case"defaultChecked":G=X;break;case"value":p=X;break;case"defaultValue":T=X;break;case"children":case"dangerouslySetInnerHTML":if(X!=null)throw Error(i(137,a));break;default:nt(n,a,c,X,r,null)}}$p(n,p,T,O,G,b,f,!1);return;case"select":$e("invalid",n),c=b=p=null;for(f in r)if(r.hasOwnProperty(f)&&(T=r[f],T!=null))switch(f){case"value":p=T;break;case"defaultValue":b=T;break;case"multiple":c=T;default:nt(n,a,f,T,r,null)}a=p,r=b,n.multiple=!!c,a!=null?li(n,!!c,a,!1):r!=null&&li(n,!!c,r,!0);return;case"textarea":$e("invalid",n),p=f=c=null;for(b in r)if(r.hasOwnProperty(b)&&(T=r[b],T!=null))switch(b){case"value":c=T;break;case"defaultValue":f=T;break;case"children":p=T;break;case"dangerouslySetInnerHTML":if(T!=null)throw Error(i(91));break;default:nt(n,a,b,T,r,null)}Hp(n,c,f,p);return;case"option":for(O in r)r.hasOwnProperty(O)&&(c=r[O],c!=null)&&(O==="selected"?n.selected=c&&typeof c!="function"&&typeof c!="symbol":nt(n,a,O,c,r,null));return;case"dialog":$e("beforetoggle",n),$e("toggle",n),$e("cancel",n),$e("close",n);break;case"iframe":case"object":$e("load",n);break;case"video":case"audio":for(c=0;c<io.length;c++)$e(io[c],n);break;case"image":$e("error",n),$e("load",n);break;case"details":$e("toggle",n);break;case"embed":case"source":case"link":$e("error",n),$e("load",n);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(G in r)if(r.hasOwnProperty(G)&&(c=r[G],c!=null))switch(G){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,a));default:nt(n,a,G,c,r,null)}return;default:if(Ku(a)){for(X in r)r.hasOwnProperty(X)&&(c=r[X],c!==void 0&&Mh(n,a,X,c,r,void 0));return}}for(T in r)r.hasOwnProperty(T)&&(c=r[T],c!=null&&nt(n,a,T,c,r,null))}function yN(n,a,r,c){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var f=null,p=null,b=null,T=null,O=null,G=null,X=null;for(K in r){var ee=r[K];if(r.hasOwnProperty(K)&&ee!=null)switch(K){case"checked":break;case"value":break;case"defaultValue":O=ee;default:c.hasOwnProperty(K)||nt(n,a,K,null,c,ee)}}for(var F in c){var K=c[F];if(ee=r[F],c.hasOwnProperty(F)&&(K!=null||ee!=null))switch(F){case"type":p=K;break;case"name":f=K;break;case"checked":G=K;break;case"defaultChecked":X=K;break;case"value":b=K;break;case"defaultValue":T=K;break;case"children":case"dangerouslySetInnerHTML":if(K!=null)throw Error(i(137,a));break;default:K!==ee&&nt(n,a,F,K,c,ee)}}Gu(n,b,T,O,G,X,p,f);return;case"select":K=b=T=F=null;for(p in r)if(O=r[p],r.hasOwnProperty(p)&&O!=null)switch(p){case"value":break;case"multiple":K=O;default:c.hasOwnProperty(p)||nt(n,a,p,null,c,O)}for(f in c)if(p=c[f],O=r[f],c.hasOwnProperty(f)&&(p!=null||O!=null))switch(f){case"value":F=p;break;case"defaultValue":T=p;break;case"multiple":b=p;default:p!==O&&nt(n,a,f,p,c,O)}a=T,r=b,c=K,F!=null?li(n,!!r,F,!1):!!c!=!!r&&(a!=null?li(n,!!r,a,!0):li(n,!!r,r?[]:"",!1));return;case"textarea":K=F=null;for(T in r)if(f=r[T],r.hasOwnProperty(T)&&f!=null&&!c.hasOwnProperty(T))switch(T){case"value":break;case"children":break;default:nt(n,a,T,null,c,f)}for(b in c)if(f=c[b],p=r[b],c.hasOwnProperty(b)&&(f!=null||p!=null))switch(b){case"value":F=f;break;case"defaultValue":K=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(i(91));break;default:f!==p&&nt(n,a,b,f,c,p)}qp(n,F,K);return;case"option":for(var ve in r)F=r[ve],r.hasOwnProperty(ve)&&F!=null&&!c.hasOwnProperty(ve)&&(ve==="selected"?n.selected=!1:nt(n,a,ve,null,c,F));for(O in c)F=c[O],K=r[O],c.hasOwnProperty(O)&&F!==K&&(F!=null||K!=null)&&(O==="selected"?n.selected=F&&typeof F!="function"&&typeof F!="symbol":nt(n,a,O,F,c,K));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 Ce in r)F=r[Ce],r.hasOwnProperty(Ce)&&F!=null&&!c.hasOwnProperty(Ce)&&nt(n,a,Ce,null,c,F);for(G in c)if(F=c[G],K=r[G],c.hasOwnProperty(G)&&F!==K&&(F!=null||K!=null))switch(G){case"children":case"dangerouslySetInnerHTML":if(F!=null)throw Error(i(137,a));break;default:nt(n,a,G,F,c,K)}return;default:if(Ku(a)){for(var st in r)F=r[st],r.hasOwnProperty(st)&&F!==void 0&&!c.hasOwnProperty(st)&&Mh(n,a,st,void 0,c,F);for(X in c)F=c[X],K=r[X],!c.hasOwnProperty(X)||F===K||F===void 0&&K===void 0||Mh(n,a,X,F,c,K);return}}for(var I in r)F=r[I],r.hasOwnProperty(I)&&F!=null&&!c.hasOwnProperty(I)&&nt(n,a,I,null,c,F);for(ee in c)F=c[ee],K=r[ee],!c.hasOwnProperty(ee)||F===K||F==null&&K==null||nt(n,a,ee,F,c,K)}function Kv(n){switch(n){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function vN(){if(typeof performance.getEntriesByType=="function"){for(var n=0,a=0,r=performance.getEntriesByType("resource"),c=0;c<r.length;c++){var f=r[c],p=f.transferSize,b=f.initiatorType,T=f.duration;if(p&&T&&Kv(b)){for(b=0,T=f.responseEnd,c+=1;c<r.length;c++){var O=r[c],G=O.startTime;if(G>T)break;var X=O.transferSize,ee=O.initiatorType;X&&Kv(ee)&&(O=O.responseEnd,b+=X*(O<T?1:(T-G)/(O-G)))}if(--c,a+=8*(p+b)/(f.duration/1e3),n++,10<n)break}}if(0<n)return a/n/1e6}return navigator.connection&&(n=navigator.connection.downlink,typeof n=="number")?n:5}var Dh=null,Ph=null;function dc(n){return n.nodeType===9?n:n.ownerDocument}function Yv(n){switch(n){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Xv(n,a){if(n===0)switch(a){case"svg":return 1;case"math":return 2;default:return 0}return n===1&&a==="foreignObject"?0:n}function zh(n,a){return n==="textarea"||n==="noscript"||typeof a.children=="string"||typeof a.children=="number"||typeof a.children=="bigint"||typeof a.dangerouslySetInnerHTML=="object"&&a.dangerouslySetInnerHTML!==null&&a.dangerouslySetInnerHTML.__html!=null}var Lh=null;function xN(){var n=window.event;return n&&n.type==="popstate"?n===Lh?!1:(Lh=n,!0):(Lh=null,!1)}var Wv=typeof setTimeout=="function"?setTimeout:void 0,bN=typeof clearTimeout=="function"?clearTimeout:void 0,Jv=typeof Promise=="function"?Promise:void 0,wN=typeof queueMicrotask=="function"?queueMicrotask:typeof Jv<"u"?function(n){return Jv.resolve(null).then(n).catch(SN)}:Wv;function SN(n){setTimeout(function(){throw n})}function Qs(n){return n==="head"}function Qv(n,a){var r=a,c=0;do{var f=r.nextSibling;if(n.removeChild(r),f&&f.nodeType===8)if(r=f.data,r==="/$"||r==="/&"){if(c===0){n.removeChild(f),Vi(a);return}c--}else if(r==="$"||r==="$?"||r==="$~"||r==="$!"||r==="&")c++;else if(r==="html")oo(n.ownerDocument.documentElement);else if(r==="head"){r=n.ownerDocument.head,oo(r);for(var p=r.firstChild;p;){var b=p.nextSibling,T=p.nodeName;p[Nr]||T==="SCRIPT"||T==="STYLE"||T==="LINK"&&p.rel.toLowerCase()==="stylesheet"||r.removeChild(p),p=b}}else r==="body"&&oo(n.ownerDocument.body);r=f}while(r);Vi(a)}function Zv(n,a){var r=n;n=0;do{var c=r.nextSibling;if(r.nodeType===1?a?(r._stashedDisplay=r.style.display,r.style.display="none"):(r.style.display=r._stashedDisplay||"",r.getAttribute("style")===""&&r.removeAttribute("style")):r.nodeType===3&&(a?(r._stashedText=r.nodeValue,r.nodeValue=""):r.nodeValue=r._stashedText||""),c&&c.nodeType===8)if(r=c.data,r==="/$"){if(n===0)break;n--}else r!=="$"&&r!=="$?"&&r!=="$~"&&r!=="$!"||n++;r=c}while(r)}function Uh(n){var a=n.firstChild;for(a&&a.nodeType===10&&(a=a.nextSibling);a;){var r=a;switch(a=a.nextSibling,r.nodeName){case"HTML":case"HEAD":case"BODY":Uh(r),qu(r);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(r.rel.toLowerCase()==="stylesheet")continue}n.removeChild(r)}}function jN(n,a,r,c){for(;n.nodeType===1;){var f=r;if(n.nodeName.toLowerCase()!==a.toLowerCase()){if(!c&&(n.nodeName!=="INPUT"||n.type!=="hidden"))break}else if(c){if(!n[Nr])switch(a){case"meta":if(!n.hasAttribute("itemprop"))break;return n;case"link":if(p=n.getAttribute("rel"),p==="stylesheet"&&n.hasAttribute("data-precedence"))break;if(p!==f.rel||n.getAttribute("href")!==(f.href==null||f.href===""?null:f.href)||n.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin)||n.getAttribute("title")!==(f.title==null?null:f.title))break;return n;case"style":if(n.hasAttribute("data-precedence"))break;return n;case"script":if(p=n.getAttribute("src"),(p!==(f.src==null?null:f.src)||n.getAttribute("type")!==(f.type==null?null:f.type)||n.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&p&&n.hasAttribute("async")&&!n.hasAttribute("itemprop"))break;return n;default:return n}}else if(a==="input"&&n.type==="hidden"){var p=f.name==null?null:""+f.name;if(f.type==="hidden"&&n.getAttribute("name")===p)return n}else return n;if(n=Mn(n.nextSibling),n===null)break}return null}function _N(n,a,r){if(a==="")return null;for(;n.nodeType!==3;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!r||(n=Mn(n.nextSibling),n===null))return null;return n}function ex(n,a){for(;n.nodeType!==8;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!a||(n=Mn(n.nextSibling),n===null))return null;return n}function Bh(n){return n.data==="$?"||n.data==="$~"}function Vh(n){return n.data==="$!"||n.data==="$?"&&n.ownerDocument.readyState!=="loading"}function NN(n,a){var r=n.ownerDocument;if(n.data==="$~")n._reactRetry=a;else if(n.data!=="$?"||r.readyState!=="loading")a();else{var c=function(){a(),r.removeEventListener("DOMContentLoaded",c)};r.addEventListener("DOMContentLoaded",c),n._reactRetry=c}}function Mn(n){for(;n!=null;n=n.nextSibling){var a=n.nodeType;if(a===1||a===3)break;if(a===8){if(a=n.data,a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"||a==="F!"||a==="F")break;if(a==="/$"||a==="/&")return null}}return n}var Ih=null;function tx(n){n=n.nextSibling;for(var a=0;n;){if(n.nodeType===8){var r=n.data;if(r==="/$"||r==="/&"){if(a===0)return Mn(n.nextSibling);a--}else r!=="$"&&r!=="$!"&&r!=="$?"&&r!=="$~"&&r!=="&"||a++}n=n.nextSibling}return null}function nx(n){n=n.previousSibling;for(var a=0;n;){if(n.nodeType===8){var r=n.data;if(r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"){if(a===0)return n;a--}else r!=="/$"&&r!=="/&"||a++}n=n.previousSibling}return null}function sx(n,a,r){switch(a=dc(r),n){case"html":if(n=a.documentElement,!n)throw Error(i(452));return n;case"head":if(n=a.head,!n)throw Error(i(453));return n;case"body":if(n=a.body,!n)throw Error(i(454));return n;default:throw Error(i(451))}}function oo(n){for(var a=n.attributes;a.length;)n.removeAttributeNode(a[0]);qu(n)}var Dn=new Map,ax=new Set;function hc(n){return typeof n.getRootNode=="function"?n.getRootNode():n.nodeType===9?n:n.ownerDocument}var Ts=Y.d;Y.d={f:TN,r:EN,D:kN,C:CN,L:AN,m:RN,X:MN,S:ON,M:DN};function TN(){var n=Ts.f(),a=sc();return n||a}function EN(n){var a=ii(n);a!==null&&a.tag===5&&a.type==="form"?wy(a):Ts.r(n)}var Li=typeof document>"u"?null:document;function ix(n,a,r){var c=Li;if(c&&typeof a=="string"&&a){var f=Tn(a);f='link[rel="'+n+'"][href="'+f+'"]',typeof r=="string"&&(f+='[crossorigin="'+r+'"]'),ax.has(f)||(ax.add(f),n={rel:n,crossOrigin:r,href:a},c.querySelector(f)===null&&(a=c.createElement("link"),qt(a,"link",n),Mt(a),c.head.appendChild(a)))}}function kN(n){Ts.D(n),ix("dns-prefetch",n,null)}function CN(n,a){Ts.C(n,a),ix("preconnect",n,a)}function AN(n,a,r){Ts.L(n,a,r);var c=Li;if(c&&n&&a){var f='link[rel="preload"][as="'+Tn(a)+'"]';a==="image"&&r&&r.imageSrcSet?(f+='[imagesrcset="'+Tn(r.imageSrcSet)+'"]',typeof r.imageSizes=="string"&&(f+='[imagesizes="'+Tn(r.imageSizes)+'"]')):f+='[href="'+Tn(n)+'"]';var p=f;switch(a){case"style":p=Ui(n);break;case"script":p=Bi(n)}Dn.has(p)||(n=x({rel:"preload",href:a==="image"&&r&&r.imageSrcSet?void 0:n,as:a},r),Dn.set(p,n),c.querySelector(f)!==null||a==="style"&&c.querySelector(lo(p))||a==="script"&&c.querySelector(co(p))||(a=c.createElement("link"),qt(a,"link",n),Mt(a),c.head.appendChild(a)))}}function RN(n,a){Ts.m(n,a);var r=Li;if(r&&n){var c=a&&typeof a.as=="string"?a.as:"script",f='link[rel="modulepreload"][as="'+Tn(c)+'"][href="'+Tn(n)+'"]',p=f;switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":p=Bi(n)}if(!Dn.has(p)&&(n=x({rel:"modulepreload",href:n},a),Dn.set(p,n),r.querySelector(f)===null)){switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(r.querySelector(co(p)))return}c=r.createElement("link"),qt(c,"link",n),Mt(c),r.head.appendChild(c)}}}function ON(n,a,r){Ts.S(n,a,r);var c=Li;if(c&&n){var f=ri(c).hoistableStyles,p=Ui(n);a=a||"default";var b=f.get(p);if(!b){var T={loading:0,preload:null};if(b=c.querySelector(lo(p)))T.loading=5;else{n=x({rel:"stylesheet",href:n,"data-precedence":a},r),(r=Dn.get(p))&&$h(n,r);var O=b=c.createElement("link");Mt(O),qt(O,"link",n),O._p=new Promise(function(G,X){O.onload=G,O.onerror=X}),O.addEventListener("load",function(){T.loading|=1}),O.addEventListener("error",function(){T.loading|=2}),T.loading|=4,fc(b,a,c)}b={type:"stylesheet",instance:b,count:1,state:T},f.set(p,b)}}}function MN(n,a){Ts.X(n,a);var r=Li;if(r&&n){var c=ri(r).hoistableScripts,f=Bi(n),p=c.get(f);p||(p=r.querySelector(co(f)),p||(n=x({src:n,async:!0},a),(a=Dn.get(f))&&qh(n,a),p=r.createElement("script"),Mt(p),qt(p,"link",n),r.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},c.set(f,p))}}function DN(n,a){Ts.M(n,a);var r=Li;if(r&&n){var c=ri(r).hoistableScripts,f=Bi(n),p=c.get(f);p||(p=r.querySelector(co(f)),p||(n=x({src:n,async:!0,type:"module"},a),(a=Dn.get(f))&&qh(n,a),p=r.createElement("script"),Mt(p),qt(p,"link",n),r.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},c.set(f,p))}}function rx(n,a,r,c){var f=(f=ue.current)?hc(f):null;if(!f)throw Error(i(446));switch(n){case"meta":case"title":return null;case"style":return typeof r.precedence=="string"&&typeof r.href=="string"?(a=Ui(r.href),r=ri(f).hoistableStyles,c=r.get(a),c||(c={type:"style",instance:null,count:0,state:null},r.set(a,c)),c):{type:"void",instance:null,count:0,state:null};case"link":if(r.rel==="stylesheet"&&typeof r.href=="string"&&typeof r.precedence=="string"){n=Ui(r.href);var p=ri(f).hoistableStyles,b=p.get(n);if(b||(f=f.ownerDocument||f,b={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},p.set(n,b),(p=f.querySelector(lo(n)))&&!p._p&&(b.instance=p,b.state.loading=5),Dn.has(n)||(r={rel:"preload",as:"style",href:r.href,crossOrigin:r.crossOrigin,integrity:r.integrity,media:r.media,hrefLang:r.hrefLang,referrerPolicy:r.referrerPolicy},Dn.set(n,r),p||PN(f,n,r,b.state))),a&&c===null)throw Error(i(528,""));return b}if(a&&c!==null)throw Error(i(529,""));return null;case"script":return a=r.async,r=r.src,typeof r=="string"&&a&&typeof a!="function"&&typeof a!="symbol"?(a=Bi(r),r=ri(f).hoistableScripts,c=r.get(a),c||(c={type:"script",instance:null,count:0,state:null},r.set(a,c)),c):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,n))}}function Ui(n){return'href="'+Tn(n)+'"'}function lo(n){return'link[rel="stylesheet"]['+n+"]"}function ox(n){return x({},n,{"data-precedence":n.precedence,precedence:null})}function PN(n,a,r,c){n.querySelector('link[rel="preload"][as="style"]['+a+"]")?c.loading=1:(a=n.createElement("link"),c.preload=a,a.addEventListener("load",function(){return c.loading|=1}),a.addEventListener("error",function(){return c.loading|=2}),qt(a,"link",r),Mt(a),n.head.appendChild(a))}function Bi(n){return'[src="'+Tn(n)+'"]'}function co(n){return"script[async]"+n}function lx(n,a,r){if(a.count++,a.instance===null)switch(a.type){case"style":var c=n.querySelector('style[data-href~="'+Tn(r.href)+'"]');if(c)return a.instance=c,Mt(c),c;var f=x({},r,{"data-href":r.href,"data-precedence":r.precedence,href:null,precedence:null});return c=(n.ownerDocument||n).createElement("style"),Mt(c),qt(c,"style",f),fc(c,r.precedence,n),a.instance=c;case"stylesheet":f=Ui(r.href);var p=n.querySelector(lo(f));if(p)return a.state.loading|=4,a.instance=p,Mt(p),p;c=ox(r),(f=Dn.get(f))&&$h(c,f),p=(n.ownerDocument||n).createElement("link"),Mt(p);var b=p;return b._p=new Promise(function(T,O){b.onload=T,b.onerror=O}),qt(p,"link",c),a.state.loading|=4,fc(p,r.precedence,n),a.instance=p;case"script":return p=Bi(r.src),(f=n.querySelector(co(p)))?(a.instance=f,Mt(f),f):(c=r,(f=Dn.get(p))&&(c=x({},r),qh(c,f)),n=n.ownerDocument||n,f=n.createElement("script"),Mt(f),qt(f,"link",c),n.head.appendChild(f),a.instance=f);case"void":return null;default:throw Error(i(443,a.type))}else a.type==="stylesheet"&&(a.state.loading&4)===0&&(c=a.instance,a.state.loading|=4,fc(c,r.precedence,n));return a.instance}function fc(n,a,r){for(var c=r.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=c.length?c[c.length-1]:null,p=f,b=0;b<c.length;b++){var T=c[b];if(T.dataset.precedence===a)p=T;else if(p!==f)break}p?p.parentNode.insertBefore(n,p.nextSibling):(a=r.nodeType===9?r.head:r,a.insertBefore(n,a.firstChild))}function $h(n,a){n.crossOrigin==null&&(n.crossOrigin=a.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=a.referrerPolicy),n.title==null&&(n.title=a.title)}function qh(n,a){n.crossOrigin==null&&(n.crossOrigin=a.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=a.referrerPolicy),n.integrity==null&&(n.integrity=a.integrity)}var mc=null;function cx(n,a,r){if(mc===null){var c=new Map,f=mc=new Map;f.set(r,c)}else f=mc,c=f.get(r),c||(c=new Map,f.set(r,c));if(c.has(n))return c;for(c.set(n,null),r=r.getElementsByTagName(n),f=0;f<r.length;f++){var p=r[f];if(!(p[Nr]||p[Bt]||n==="link"&&p.getAttribute("rel")==="stylesheet")&&p.namespaceURI!=="http://www.w3.org/2000/svg"){var b=p.getAttribute(a)||"";b=n+b;var T=c.get(b);T?T.push(p):c.set(b,[p])}}return c}function ux(n,a,r){n=n.ownerDocument||n,n.head.insertBefore(r,a==="title"?n.querySelector("head > title"):null)}function zN(n,a,r){if(r===1||a.itemProp!=null)return!1;switch(n){case"meta":case"title":return!0;case"style":if(typeof a.precedence!="string"||typeof a.href!="string"||a.href==="")break;return!0;case"link":if(typeof a.rel!="string"||typeof a.href!="string"||a.href===""||a.onLoad||a.onError)break;return a.rel==="stylesheet"?(n=a.disabled,typeof a.precedence=="string"&&n==null):!0;case"script":if(a.async&&typeof a.async!="function"&&typeof a.async!="symbol"&&!a.onLoad&&!a.onError&&a.src&&typeof a.src=="string")return!0}return!1}function dx(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function LN(n,a,r,c){if(r.type==="stylesheet"&&(typeof c.media!="string"||matchMedia(c.media).matches!==!1)&&(r.state.loading&4)===0){if(r.instance===null){var f=Ui(c.href),p=a.querySelector(lo(f));if(p){a=p._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(n.count++,n=pc.bind(n),a.then(n,n)),r.state.loading|=4,r.instance=p,Mt(p);return}p=a.ownerDocument||a,c=ox(c),(f=Dn.get(f))&&$h(c,f),p=p.createElement("link"),Mt(p);var b=p;b._p=new Promise(function(T,O){b.onload=T,b.onerror=O}),qt(p,"link",c),r.instance=p}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(r,a),(a=r.state.preload)&&(r.state.loading&3)===0&&(n.count++,r=pc.bind(n),a.addEventListener("load",r),a.addEventListener("error",r))}}var Hh=0;function UN(n,a){return n.stylesheets&&n.count===0&&yc(n,n.stylesheets),0<n.count||0<n.imgCount?function(r){var c=setTimeout(function(){if(n.stylesheets&&yc(n,n.stylesheets),n.unsuspend){var p=n.unsuspend;n.unsuspend=null,p()}},6e4+a);0<n.imgBytes&&Hh===0&&(Hh=62500*vN());var f=setTimeout(function(){if(n.waitingForImages=!1,n.count===0&&(n.stylesheets&&yc(n,n.stylesheets),n.unsuspend)){var p=n.unsuspend;n.unsuspend=null,p()}},(n.imgBytes>Hh?50:800)+a);return n.unsuspend=r,function(){n.unsuspend=null,clearTimeout(c),clearTimeout(f)}}:null}function pc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)yc(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var gc=null;function yc(n,a){n.stylesheets=null,n.unsuspend!==null&&(n.count++,gc=new Map,a.forEach(BN,n),gc=null,pc.call(n))}function BN(n,a){if(!(a.state.loading&4)){var r=gc.get(n);if(r)var c=r.get(null);else{r=new Map,gc.set(n,r);for(var f=n.querySelectorAll("link[data-precedence],style[data-precedence]"),p=0;p<f.length;p++){var b=f[p];(b.nodeName==="LINK"||b.getAttribute("media")!=="not all")&&(r.set(b.dataset.precedence,b),c=b)}c&&r.set(null,c)}f=a.instance,b=f.getAttribute("data-precedence"),p=r.get(b)||c,p===c&&r.set(null,f),r.set(b,f),this.count++,c=pc.bind(this),f.addEventListener("load",c),f.addEventListener("error",c),p?p.parentNode.insertBefore(f,p.nextSibling):(n=n.nodeType===9?n.head:n,n.insertBefore(f,n.firstChild)),a.state.loading|=4}}var uo={$$typeof:C,Provider:null,Consumer:null,_currentValue:J,_currentValue2:J,_threadCount:0};function VN(n,a,r,c,f,p,b,T,O){this.tag=1,this.containerInfo=n,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=Bu(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Bu(0),this.hiddenUpdates=Bu(null),this.identifierPrefix=c,this.onUncaughtError=f,this.onCaughtError=p,this.onRecoverableError=b,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=O,this.incompleteTransitions=new Map}function hx(n,a,r,c,f,p,b,T,O,G,X,ee){return n=new VN(n,a,r,b,O,G,X,ee,T),a=1,p===!0&&(a|=24),p=fn(3,null,null,a),n.current=p,p.stateNode=n,a=jd(),a.refCount++,n.pooledCache=a,a.refCount++,p.memoizedState={element:c,isDehydrated:r,cache:a},Ed(p),n}function fx(n){return n?(n=gi,n):gi}function mx(n,a,r,c,f,p){f=fx(f),c.context===null?c.context=f:c.pendingContext=f,c=Is(a),c.payload={element:r},p=p===void 0?null:p,p!==null&&(c.callback=p),r=$s(n,c,a),r!==null&&(ln(r,n,a),$r(r,n,a))}function px(n,a){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var r=n.retryLane;n.retryLane=r!==0&&r<a?r:a}}function Gh(n,a){px(n,a),(n=n.alternate)&&px(n,a)}function gx(n){if(n.tag===13||n.tag===31){var a=_a(n,67108864);a!==null&&ln(a,n,67108864),Gh(n,67108864)}}function yx(n){if(n.tag===13||n.tag===31){var a=vn();a=Vu(a);var r=_a(n,a);r!==null&&ln(r,n,a),Gh(n,a)}}var vc=!0;function IN(n,a,r,c){var f=$.T;$.T=null;var p=Y.p;try{Y.p=2,Fh(n,a,r,c)}finally{Y.p=p,$.T=f}}function $N(n,a,r,c){var f=$.T;$.T=null;var p=Y.p;try{Y.p=8,Fh(n,a,r,c)}finally{Y.p=p,$.T=f}}function Fh(n,a,r,c){if(vc){var f=Kh(c);if(f===null)Oh(n,a,c,xc,r),xx(n,c);else if(HN(f,n,a,r,c))c.stopPropagation();else if(xx(n,c),a&4&&-1<qN.indexOf(n)){for(;f!==null;){var p=ii(f);if(p!==null)switch(p.tag){case 3:if(p=p.stateNode,p.current.memoizedState.isDehydrated){var b=xa(p.pendingLanes);if(b!==0){var T=p;for(T.pendingLanes|=2,T.entangledLanes|=2;b;){var O=1<<31-dn(b);T.entanglements[1]|=O,b&=~O}es(p),(We&6)===0&&(tc=B()+500,ao(0))}}break;case 31:case 13:T=_a(p,2),T!==null&&ln(T,p,2),sc(),Gh(p,2)}if(p=Kh(c),p===null&&Oh(n,a,c,xc,r),p===f)break;f=p}f!==null&&c.stopPropagation()}else Oh(n,a,c,null,r)}}function Kh(n){return n=Xu(n),Yh(n)}var xc=null;function Yh(n){if(xc=null,n=ai(n),n!==null){var a=u(n);if(a===null)n=null;else{var r=a.tag;if(r===13){if(n=d(a),n!==null)return n;n=null}else if(r===31){if(n=h(a),n!==null)return n;n=null}else if(r===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;n=null}else a!==n&&(n=null)}}return xc=n,null}function vx(n){switch(n){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(ie()){case De:return 2;case qe:return 8;case ft:case Zt:return 32;case Ve:return 268435456;default:return 32}default:return 32}}var Xh=!1,Zs=null,ea=null,ta=null,ho=new Map,fo=new Map,na=[],qN="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 xx(n,a){switch(n){case"focusin":case"focusout":Zs=null;break;case"dragenter":case"dragleave":ea=null;break;case"mouseover":case"mouseout":ta=null;break;case"pointerover":case"pointerout":ho.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":fo.delete(a.pointerId)}}function mo(n,a,r,c,f,p){return n===null||n.nativeEvent!==p?(n={blockedOn:a,domEventName:r,eventSystemFlags:c,nativeEvent:p,targetContainers:[f]},a!==null&&(a=ii(a),a!==null&&gx(a)),n):(n.eventSystemFlags|=c,a=n.targetContainers,f!==null&&a.indexOf(f)===-1&&a.push(f),n)}function HN(n,a,r,c,f){switch(a){case"focusin":return Zs=mo(Zs,n,a,r,c,f),!0;case"dragenter":return ea=mo(ea,n,a,r,c,f),!0;case"mouseover":return ta=mo(ta,n,a,r,c,f),!0;case"pointerover":var p=f.pointerId;return ho.set(p,mo(ho.get(p)||null,n,a,r,c,f)),!0;case"gotpointercapture":return p=f.pointerId,fo.set(p,mo(fo.get(p)||null,n,a,r,c,f)),!0}return!1}function bx(n){var a=ai(n.target);if(a!==null){var r=u(a);if(r!==null){if(a=r.tag,a===13){if(a=d(r),a!==null){n.blockedOn=a,Dp(n.priority,function(){yx(r)});return}}else if(a===31){if(a=h(r),a!==null){n.blockedOn=a,Dp(n.priority,function(){yx(r)});return}}else if(a===3&&r.stateNode.current.memoizedState.isDehydrated){n.blockedOn=r.tag===3?r.stateNode.containerInfo:null;return}}}n.blockedOn=null}function bc(n){if(n.blockedOn!==null)return!1;for(var a=n.targetContainers;0<a.length;){var r=Kh(n.nativeEvent);if(r===null){r=n.nativeEvent;var c=new r.constructor(r.type,r);Yu=c,r.target.dispatchEvent(c),Yu=null}else return a=ii(r),a!==null&&gx(a),n.blockedOn=r,!1;a.shift()}return!0}function wx(n,a,r){bc(n)&&r.delete(a)}function GN(){Xh=!1,Zs!==null&&bc(Zs)&&(Zs=null),ea!==null&&bc(ea)&&(ea=null),ta!==null&&bc(ta)&&(ta=null),ho.forEach(wx),fo.forEach(wx)}function wc(n,a){n.blockedOn===a&&(n.blockedOn=null,Xh||(Xh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,GN)))}var Sc=null;function Sx(n){Sc!==n&&(Sc=n,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Sc===n&&(Sc=null);for(var a=0;a<n.length;a+=3){var r=n[a],c=n[a+1],f=n[a+2];if(typeof c!="function"){if(Yh(c||r)===null)continue;break}var p=ii(r);p!==null&&(n.splice(a,3),a-=3,Kd(p,{pending:!0,data:f,method:r.method,action:c},c,f))}}))}function Vi(n){function a(O){return wc(O,n)}Zs!==null&&wc(Zs,n),ea!==null&&wc(ea,n),ta!==null&&wc(ta,n),ho.forEach(a),fo.forEach(a);for(var r=0;r<na.length;r++){var c=na[r];c.blockedOn===n&&(c.blockedOn=null)}for(;0<na.length&&(r=na[0],r.blockedOn===null);)bx(r),r.blockedOn===null&&na.shift();if(r=(n.ownerDocument||n).$$reactFormReplay,r!=null)for(c=0;c<r.length;c+=3){var f=r[c],p=r[c+1],b=f[tn]||null;if(typeof p=="function")b||Sx(r);else if(b){var T=null;if(p&&p.hasAttribute("formAction")){if(f=p,b=p[tn]||null)T=b.formAction;else if(Yh(f)!==null)continue}else T=b.action;typeof T=="function"?r[c+1]=T:(r.splice(c,3),c-=3),Sx(r)}}}function jx(){function n(p){p.canIntercept&&p.info==="react-transition"&&p.intercept({handler:function(){return new Promise(function(b){return f=b})},focusReset:"manual",scroll:"manual"})}function a(){f!==null&&(f(),f=null),c||setTimeout(r,20)}function r(){if(!c&&!navigation.transition){var p=navigation.currentEntry;p&&p.url!=null&&navigation.navigate(p.url,{state:p.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var c=!1,f=null;return navigation.addEventListener("navigate",n),navigation.addEventListener("navigatesuccess",a),navigation.addEventListener("navigateerror",a),setTimeout(r,100),function(){c=!0,navigation.removeEventListener("navigate",n),navigation.removeEventListener("navigatesuccess",a),navigation.removeEventListener("navigateerror",a),f!==null&&(f(),f=null)}}}function Wh(n){this._internalRoot=n}jc.prototype.render=Wh.prototype.render=function(n){var a=this._internalRoot;if(a===null)throw Error(i(409));var r=a.current,c=vn();mx(r,c,n,a,null,null)},jc.prototype.unmount=Wh.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var a=n.containerInfo;mx(n.current,2,null,n,null,null),sc(),a[si]=null}};function jc(n){this._internalRoot=n}jc.prototype.unstable_scheduleHydration=function(n){if(n){var a=Mp();n={blockedOn:null,target:n,priority:a};for(var r=0;r<na.length&&a!==0&&a<na[r].priority;r++);na.splice(r,0,n),r===0&&bx(n)}};var _x=e.version;if(_x!=="19.2.4")throw Error(i(527,_x,"19.2.4"));Y.findDOMNode=function(n){var a=n._reactInternals;if(a===void 0)throw typeof n.render=="function"?Error(i(188)):(n=Object.keys(n).join(","),Error(i(268,n)));return n=g(a),n=n!==null?y(n):null,n=n===null?null:n.stateNode,n};var FN={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:$,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var _c=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!_c.isDisabled&&_c.supportsFiber)try{Ms=_c.inject(FN),Kt=_c}catch{}}return go.createRoot=function(n,a){if(!l(n))throw Error(i(299));var r=!1,c="",f=Ry,p=Oy,b=My;return a!=null&&(a.unstable_strictMode===!0&&(r=!0),a.identifierPrefix!==void 0&&(c=a.identifierPrefix),a.onUncaughtError!==void 0&&(f=a.onUncaughtError),a.onCaughtError!==void 0&&(p=a.onCaughtError),a.onRecoverableError!==void 0&&(b=a.onRecoverableError)),a=hx(n,1,!1,null,null,r,c,null,f,p,b,jx),n[si]=a.current,Rh(n),new Wh(a)},go.hydrateRoot=function(n,a,r){if(!l(n))throw Error(i(299));var c=!1,f="",p=Ry,b=Oy,T=My,O=null;return r!=null&&(r.unstable_strictMode===!0&&(c=!0),r.identifierPrefix!==void 0&&(f=r.identifierPrefix),r.onUncaughtError!==void 0&&(p=r.onUncaughtError),r.onCaughtError!==void 0&&(b=r.onCaughtError),r.onRecoverableError!==void 0&&(T=r.onRecoverableError),r.formState!==void 0&&(O=r.formState)),a=hx(n,1,!0,a,r??null,c,f,O,p,b,T,jx),a.context=fx(null),r=a.current,c=vn(),c=Vu(c),f=Is(c),f.callback=null,$s(r,f,c),r=c,a.current.lanes=r,_r(a,r),es(a),n[si]=a.current,Rh(n),new jc(a)},go.version="19.2.4",go}var Dx;function n2(){if(Dx)return Zh.exports;Dx=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Zh.exports=t2(),Zh.exports}var s2=n2(),ss=function(){return ss=Object.assign||function(e){for(var s,i=1,l=arguments.length;i<l;i++){s=arguments[i];for(var u in s)Object.prototype.hasOwnProperty.call(s,u)&&(e[u]=s[u])}return e},ss.apply(this,arguments)};function pr(t,e){var s={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(s[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var l=0,i=Object.getOwnPropertySymbols(t);l<i.length;l++)e.indexOf(i[l])<0&&Object.prototype.propertyIsEnumerable.call(t,i[l])&&(s[i[l]]=t[i[l]]);return s}function a2(t,e,s,i){function l(u){return u instanceof s?u:new s(function(d){d(u)})}return new(s||(s=Promise))(function(u,d){function h(y){try{g(i.next(y))}catch(x){d(x)}}function m(y){try{g(i.throw(y))}catch(x){d(x)}}function g(y){y.done?u(y.value):l(y.value).then(h,m)}g((i=i.apply(t,e||[])).next())})}function i2(t,e,s){if(s||arguments.length===2)for(var i=0,l=e.length,u;i<l;i++)(u||!(i in e))&&(u||(u=Array.prototype.slice.call(e,0,i)),u[i]=e[i]);return t.concat(u||Array.prototype.slice.call(e))}const r2=t=>t?(...e)=>t(...e):(...e)=>fetch(...e);class Dm extends Error{constructor(e,s="FunctionsError",i){super(e),this.name=s,this.context=i}}class o2 extends Dm{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class Px extends Dm{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class zx extends Dm{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var $f;(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})($f||($f={}));class l2{constructor(e,{headers:s={},customFetch:i,region:l=$f.Any}={}){this.url=e,this.headers=s,this.region=l,this.fetch=r2(i)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){return a2(this,arguments,void 0,function*(s,i={}){var l;let u,d;try{const{headers:h,method:m,body:g,signal:y,timeout:x}=i;let w={},{region:S}=i;S||(S=this.region);const E=new URL(`${this.url}/${s}`);S&&S!=="any"&&(w["x-region"]=S,E.searchParams.set("forceFunctionRegion",S));let j;g&&(h&&!Object.prototype.hasOwnProperty.call(h,"Content-Type")||!h)?typeof Blob<"u"&&g instanceof Blob||g instanceof ArrayBuffer?(w["Content-Type"]="application/octet-stream",j=g):typeof g=="string"?(w["Content-Type"]="text/plain",j=g):typeof FormData<"u"&&g instanceof FormData?j=g:(w["Content-Type"]="application/json",j=JSON.stringify(g)):g&&typeof g!="string"&&!(typeof Blob<"u"&&g instanceof Blob)&&!(g instanceof ArrayBuffer)&&!(typeof FormData<"u"&&g instanceof FormData)?j=JSON.stringify(g):j=g;let _=y;x&&(d=new AbortController,u=setTimeout(()=>d.abort(),x),y?(_=d.signal,y.addEventListener("abort",()=>d.abort())):_=d.signal);const N=yield this.fetch(E.toString(),{method:m||"POST",headers:Object.assign(Object.assign(Object.assign({},w),this.headers),h),body:j,signal:_}).catch(D=>{throw new o2(D)}),k=N.headers.get("x-relay-error");if(k&&k==="true")throw new Px(N);if(!N.ok)throw new zx(N);let C=((l=N.headers.get("Content-Type"))!==null&&l!==void 0?l:"text/plain").split(";")[0].trim(),A;return C==="application/json"?A=yield N.json():C==="application/octet-stream"||C==="application/pdf"?A=yield N.blob():C==="text/event-stream"?A=N:C==="multipart/form-data"?A=yield N.formData():A=yield N.text(),{data:A,error:null,response:N}}catch(h){return{data:null,error:h,response:h instanceof zx||h instanceof Px?h.context:void 0}}finally{u&&clearTimeout(u)}})}}var c2=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.code=t.code}},u2=class{constructor(t){var e,s,i;this.shouldThrowOnError=!1,this.method=t.method,this.url=t.url,this.headers=new Headers(t.headers),this.schema=t.schema,this.body=t.body,this.shouldThrowOnError=(e=t.shouldThrowOnError)!==null&&e!==void 0?e:!1,this.signal=t.signal,this.isMaybeSingle=(s=t.isMaybeSingle)!==null&&s!==void 0?s:!1,this.urlLengthLimit=(i=t.urlLengthLimit)!==null&&i!==void 0?i:8e3,t.fetch?this.fetch=t.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,e){return this.headers=new Headers(this.headers),this.headers.set(t,e),this}then(t,e){var s=this;this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");const i=this.fetch;let l=i(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{let d=null,h=null,m=null,g=u.status,y=u.statusText;if(u.ok){var x,w;if(s.method!=="HEAD"){var S;const N=await u.text();N===""||(s.headers.get("Accept")==="text/csv"||s.headers.get("Accept")&&(!((S=s.headers.get("Accept"))===null||S===void 0)&&S.includes("application/vnd.pgrst.plan+text"))?h=N:h=JSON.parse(N))}const j=(x=s.headers.get("Prefer"))===null||x===void 0?void 0:x.match(/count=(exact|planned|estimated)/),_=(w=u.headers.get("content-range"))===null||w===void 0?void 0:w.split("/");j&&_&&_.length>1&&(m=parseInt(_[1])),s.isMaybeSingle&&s.method==="GET"&&Array.isArray(h)&&(h.length>1?(d={code:"PGRST116",details:`Results contain ${h.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},h=null,m=null,g=406,y="Not Acceptable"):h.length===1?h=h[0]:h=null)}else{var E;const j=await u.text();try{d=JSON.parse(j),Array.isArray(d)&&u.status===404&&(h=[],d=null,g=200,y="OK")}catch{u.status===404&&j===""?(g=204,y="No Content"):d={message:j}}if(d&&s.isMaybeSingle&&(!(d==null||(E=d.details)===null||E===void 0)&&E.includes("0 rows"))&&(d=null,g=200,y="OK"),d&&s.shouldThrowOnError)throw new c2(d)}return{error:d,data:h,count:m,status:g,statusText:y}});return this.shouldThrowOnError||(l=l.catch(u=>{var d;let h="",m="",g="";const y=u?.cause;if(y){var x,w,S,E;const N=(x=y?.message)!==null&&x!==void 0?x:"",k=(w=y?.code)!==null&&w!==void 0?w:"";h=`${(S=u?.name)!==null&&S!==void 0?S:"FetchError"}: ${u?.message}`,h+=`
|
|
10
10
|
|
|
11
11
|
Caused by: ${(E=y?.name)!==null&&E!==void 0?E:"Error"}: ${N}`,k&&(h+=` (${k})`),y?.stack&&(h+=`
|
|
12
|
-
${y.stack}`)}else{var j;h=(j=u?.stack)!==null&&j!==void 0?j:""}const _=this.url.toString().length;return u?.name==="AbortError"||u?.code==="ABORT_ERR"?(g="",m="Request was aborted (timeout or manual cancellation)",_>this.urlLengthLimit&&(m+=`. Note: Your request URL is ${_} 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.`)):(y?.name==="HeadersOverflowError"||y?.code==="UND_ERR_HEADERS_OVERFLOW")&&(g="",m="HTTP headers exceeded server limits (typically 16KB)",_>this.urlLengthLimit&&(m+=`. Your request URL is ${_} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{error:{message:`${(d=u?.name)!==null&&d!==void 0?d:"FetchError"}: ${u?.message}`,details:h,hint:m,code:g},data:null,count:null,status:0,statusText:""}})),l.then(t,e)}returns(){return this}overrideTypes(){return this}},d2=class extends u2{select(t){let e=!1;const s=(t??"*").split("").map(r=>/\s/.test(r)&&!e?"":(r==='"'&&(e=!e),r)).join("");return this.url.searchParams.set("select",s),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:e=!0,nullsFirst:s,foreignTable:r,referencedTable:l=r}={}){const u=l?`${l}.order`:"order",d=this.url.searchParams.get(u);return this.url.searchParams.set(u,`${d?`${d},`:""}${t}.${e?"asc":"desc"}${s===void 0?"":s?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:e,referencedTable:s=e}={}){const r=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(r,`${t}`),this}range(t,e,{foreignTable:s,referencedTable:r=s}={}){const l=typeof r>"u"?"offset":`${r}.offset`,u=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(l,`${t}`),this.url.searchParams.set(u,`${e-t+1}`),this}abortSignal(t){return this.signal=t,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:t=!1,verbose:e=!1,settings:s=!1,buffers:r=!1,wal:l=!1,format:u="text"}={}){var d;const h=[t?"analyze":null,e?"verbose":null,s?"settings":null,r?"buffers":null,l?"wal":null].filter(Boolean).join("|"),m=(d=this.headers.get("Accept"))!==null&&d!==void 0?d:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${u}; for="${m}"; options=${h};`),u==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(t){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${t}`),this}};const Lx=new RegExp("[,()]");var Wr=class extends d2{eq(t,e){return this.url.searchParams.append(t,`eq.${e}`),this}neq(t,e){return this.url.searchParams.append(t,`neq.${e}`),this}gt(t,e){return this.url.searchParams.append(t,`gt.${e}`),this}gte(t,e){return this.url.searchParams.append(t,`gte.${e}`),this}lt(t,e){return this.url.searchParams.append(t,`lt.${e}`),this}lte(t,e){return this.url.searchParams.append(t,`lte.${e}`),this}like(t,e){return this.url.searchParams.append(t,`like.${e}`),this}likeAllOf(t,e){return this.url.searchParams.append(t,`like(all).{${e.join(",")}}`),this}likeAnyOf(t,e){return this.url.searchParams.append(t,`like(any).{${e.join(",")}}`),this}ilike(t,e){return this.url.searchParams.append(t,`ilike.${e}`),this}ilikeAllOf(t,e){return this.url.searchParams.append(t,`ilike(all).{${e.join(",")}}`),this}ilikeAnyOf(t,e){return this.url.searchParams.append(t,`ilike(any).{${e.join(",")}}`),this}regexMatch(t,e){return this.url.searchParams.append(t,`match.${e}`),this}regexIMatch(t,e){return this.url.searchParams.append(t,`imatch.${e}`),this}is(t,e){return this.url.searchParams.append(t,`is.${e}`),this}isDistinct(t,e){return this.url.searchParams.append(t,`isdistinct.${e}`),this}in(t,e){const s=Array.from(new Set(e)).map(r=>typeof r=="string"&&Lx.test(r)?`"${r}"`:`${r}`).join(",");return this.url.searchParams.append(t,`in.(${s})`),this}notIn(t,e){const s=Array.from(new Set(e)).map(r=>typeof r=="string"&&Lx.test(r)?`"${r}"`:`${r}`).join(",");return this.url.searchParams.append(t,`not.in.(${s})`),this}contains(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cs.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cs.{${e.join(",")}}`):this.url.searchParams.append(t,`cs.${JSON.stringify(e)}`),this}containedBy(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cd.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cd.{${e.join(",")}}`):this.url.searchParams.append(t,`cd.${JSON.stringify(e)}`),this}rangeGt(t,e){return this.url.searchParams.append(t,`sr.${e}`),this}rangeGte(t,e){return this.url.searchParams.append(t,`nxl.${e}`),this}rangeLt(t,e){return this.url.searchParams.append(t,`sl.${e}`),this}rangeLte(t,e){return this.url.searchParams.append(t,`nxr.${e}`),this}rangeAdjacent(t,e){return this.url.searchParams.append(t,`adj.${e}`),this}overlaps(t,e){return typeof e=="string"?this.url.searchParams.append(t,`ov.${e}`):this.url.searchParams.append(t,`ov.{${e.join(",")}}`),this}textSearch(t,e,{config:s,type:r}={}){let l="";r==="plain"?l="pl":r==="phrase"?l="ph":r==="websearch"&&(l="w");const u=s===void 0?"":`(${s})`;return this.url.searchParams.append(t,`${l}fts${u}.${e}`),this}match(t){return Object.entries(t).forEach(([e,s])=>{this.url.searchParams.append(e,`eq.${s}`)}),this}not(t,e,s){return this.url.searchParams.append(t,`not.${e}.${s}`),this}or(t,{foreignTable:e,referencedTable:s=e}={}){const r=s?`${s}.or`:"or";return this.url.searchParams.append(r,`(${t})`),this}filter(t,e,s){return this.url.searchParams.append(t,`${e}.${s}`),this}},h2=class{constructor(t,{headers:e={},schema:s,fetch:r,urlLengthLimit:l=8e3}){this.url=t,this.headers=new Headers(e),this.schema=s,this.fetch=r,this.urlLengthLimit=l}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(t,e){const{head:s=!1,count:r}=e??{},l=s?"HEAD":"GET";let u=!1;const d=(t??"*").split("").map(g=>/\s/.test(g)&&!u?"":(g==='"'&&(u=!u),g)).join(""),{url:h,headers:m}=this.cloneRequestState();return h.searchParams.set("select",d),r&&m.append("Prefer",`count=${r}`),new Wr({method:l,url:h,headers:m,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}insert(t,{count:e,defaultToNull:s=!0}={}){var r;const l="POST",{url:u,headers:d}=this.cloneRequestState();if(e&&d.append("Prefer",`count=${e}`),s||d.append("Prefer","missing=default"),Array.isArray(t)){const h=t.reduce((m,g)=>m.concat(Object.keys(g)),[]);if(h.length>0){const m=[...new Set(h)].map(g=>`"${g}"`);u.searchParams.set("columns",m.join(","))}}return new Wr({method:l,url:u,headers:d,schema:this.schema,body:t,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch,urlLengthLimit:this.urlLengthLimit})}upsert(t,{onConflict:e,ignoreDuplicates:s=!1,count:r,defaultToNull:l=!0}={}){var u;const d="POST",{url:h,headers:m}=this.cloneRequestState();if(m.append("Prefer",`resolution=${s?"ignore":"merge"}-duplicates`),e!==void 0&&h.searchParams.set("on_conflict",e),r&&m.append("Prefer",`count=${r}`),l||m.append("Prefer","missing=default"),Array.isArray(t)){const g=t.reduce((y,x)=>y.concat(Object.keys(x)),[]);if(g.length>0){const y=[...new Set(g)].map(x=>`"${x}"`);h.searchParams.set("columns",y.join(","))}}return new Wr({method:d,url:h,headers:m,schema:this.schema,body:t,fetch:(u=this.fetch)!==null&&u!==void 0?u:fetch,urlLengthLimit:this.urlLengthLimit})}update(t,{count:e}={}){var s;const r="PATCH",{url:l,headers:u}=this.cloneRequestState();return e&&u.append("Prefer",`count=${e}`),new Wr({method:r,url:l,headers:u,schema:this.schema,body:t,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch,urlLengthLimit:this.urlLengthLimit})}delete({count:t}={}){var e;const s="DELETE",{url:r,headers:l}=this.cloneRequestState();return t&&l.append("Prefer",`count=${t}`),new Wr({method:s,url:r,headers:l,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch,urlLengthLimit:this.urlLengthLimit})}};function Oo(t){"@babel/helpers - typeof";return Oo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Oo(t)}function f2(t,e){if(Oo(t)!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var r=s.call(t,e);if(Oo(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function m2(t){var e=f2(t,"string");return Oo(e)=="symbol"?e:e+""}function p2(t,e,s){return(e=m2(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function Ux(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(t,l).enumerable})),s.push.apply(s,r)}return s}function Nc(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?Ux(Object(s),!0).forEach(function(r){p2(t,r,s[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Ux(Object(s)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(s,r))})}return t}var g2=class nw{constructor(e,{headers:s={},schema:r,fetch:l,timeout:u,urlLengthLimit:d=8e3}={}){this.url=e,this.headers=new Headers(s),this.schemaName=r,this.urlLengthLimit=d;const h=l??globalThis.fetch;u!==void 0&&u>0?this.fetch=(m,g)=>{const y=new AbortController,x=setTimeout(()=>y.abort(),u),w=g?.signal;if(w){if(w.aborted)return clearTimeout(x),h(m,g);const S=()=>{clearTimeout(x),y.abort()};return w.addEventListener("abort",S,{once:!0}),h(m,Nc(Nc({},g),{},{signal:y.signal})).finally(()=>{clearTimeout(x),w.removeEventListener("abort",S)})}return h(m,Nc(Nc({},g),{},{signal:y.signal})).finally(()=>clearTimeout(x))}:this.fetch=h}from(e){if(!e||typeof e!="string"||e.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new h2(new URL(`${this.url}/${e}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}schema(e){return new nw(this.url,{headers:this.headers,schema:e,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}rpc(e,s={},{head:r=!1,get:l=!1,count:u}={}){var d;let h;const m=new URL(`${this.url}/rpc/${e}`);let g;const y=S=>S!==null&&typeof S=="object"&&(!Array.isArray(S)||S.some(y)),x=r&&Object.values(s).some(y);x?(h="POST",g=s):r||l?(h=r?"HEAD":"GET",Object.entries(s).filter(([S,E])=>E!==void 0).map(([S,E])=>[S,Array.isArray(E)?`{${E.join(",")}}`:`${E}`]).forEach(([S,E])=>{m.searchParams.append(S,E)})):(h="POST",g=s);const w=new Headers(this.headers);return x?w.set("Prefer",u?`count=${u},return=minimal`:"return=minimal"):u&&w.set("Prefer",`count=${u}`),new Wr({method:h,url:m,headers:w,schema:this.schemaName,body:g,fetch:(d=this.fetch)!==null&&d!==void 0?d:fetch,urlLengthLimit:this.urlLengthLimit})}};class y2{constructor(){}static detectEnvironment(){var e;if(typeof WebSocket<"u")return{type:"native",constructor:WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocket<"u")return{type:"native",constructor:globalThis.WebSocket};if(typeof global<"u"&&typeof global.WebSocket<"u")return{type:"native",constructor:global.WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&globalThis.EdgeRuntime||typeof navigator<"u"&&(!((e=navigator.userAgent)===null||e===void 0)&&e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};const s=globalThis.process;if(s){const r=s.versions;if(r&&r.node){const l=r.node,u=parseInt(l.replace(/^v/,"").split(".")[0]);return u>=22?typeof globalThis.WebSocket<"u"?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${u} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${u} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option:
|
|
12
|
+
${y.stack}`)}else{var j;h=(j=u?.stack)!==null&&j!==void 0?j:""}const _=this.url.toString().length;return u?.name==="AbortError"||u?.code==="ABORT_ERR"?(g="",m="Request was aborted (timeout or manual cancellation)",_>this.urlLengthLimit&&(m+=`. Note: Your request URL is ${_} 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.`)):(y?.name==="HeadersOverflowError"||y?.code==="UND_ERR_HEADERS_OVERFLOW")&&(g="",m="HTTP headers exceeded server limits (typically 16KB)",_>this.urlLengthLimit&&(m+=`. Your request URL is ${_} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{error:{message:`${(d=u?.name)!==null&&d!==void 0?d:"FetchError"}: ${u?.message}`,details:h,hint:m,code:g},data:null,count:null,status:0,statusText:""}})),l.then(t,e)}returns(){return this}overrideTypes(){return this}},d2=class extends u2{select(t){let e=!1;const s=(t??"*").split("").map(i=>/\s/.test(i)&&!e?"":(i==='"'&&(e=!e),i)).join("");return this.url.searchParams.set("select",s),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:e=!0,nullsFirst:s,foreignTable:i,referencedTable:l=i}={}){const u=l?`${l}.order`:"order",d=this.url.searchParams.get(u);return this.url.searchParams.set(u,`${d?`${d},`:""}${t}.${e?"asc":"desc"}${s===void 0?"":s?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:e,referencedTable:s=e}={}){const i=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(i,`${t}`),this}range(t,e,{foreignTable:s,referencedTable:i=s}={}){const l=typeof i>"u"?"offset":`${i}.offset`,u=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(l,`${t}`),this.url.searchParams.set(u,`${e-t+1}`),this}abortSignal(t){return this.signal=t,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:t=!1,verbose:e=!1,settings:s=!1,buffers:i=!1,wal:l=!1,format:u="text"}={}){var d;const h=[t?"analyze":null,e?"verbose":null,s?"settings":null,i?"buffers":null,l?"wal":null].filter(Boolean).join("|"),m=(d=this.headers.get("Accept"))!==null&&d!==void 0?d:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${u}; for="${m}"; options=${h};`),u==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(t){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${t}`),this}};const Lx=new RegExp("[,()]");var Wi=class extends d2{eq(t,e){return this.url.searchParams.append(t,`eq.${e}`),this}neq(t,e){return this.url.searchParams.append(t,`neq.${e}`),this}gt(t,e){return this.url.searchParams.append(t,`gt.${e}`),this}gte(t,e){return this.url.searchParams.append(t,`gte.${e}`),this}lt(t,e){return this.url.searchParams.append(t,`lt.${e}`),this}lte(t,e){return this.url.searchParams.append(t,`lte.${e}`),this}like(t,e){return this.url.searchParams.append(t,`like.${e}`),this}likeAllOf(t,e){return this.url.searchParams.append(t,`like(all).{${e.join(",")}}`),this}likeAnyOf(t,e){return this.url.searchParams.append(t,`like(any).{${e.join(",")}}`),this}ilike(t,e){return this.url.searchParams.append(t,`ilike.${e}`),this}ilikeAllOf(t,e){return this.url.searchParams.append(t,`ilike(all).{${e.join(",")}}`),this}ilikeAnyOf(t,e){return this.url.searchParams.append(t,`ilike(any).{${e.join(",")}}`),this}regexMatch(t,e){return this.url.searchParams.append(t,`match.${e}`),this}regexIMatch(t,e){return this.url.searchParams.append(t,`imatch.${e}`),this}is(t,e){return this.url.searchParams.append(t,`is.${e}`),this}isDistinct(t,e){return this.url.searchParams.append(t,`isdistinct.${e}`),this}in(t,e){const s=Array.from(new Set(e)).map(i=>typeof i=="string"&&Lx.test(i)?`"${i}"`:`${i}`).join(",");return this.url.searchParams.append(t,`in.(${s})`),this}notIn(t,e){const s=Array.from(new Set(e)).map(i=>typeof i=="string"&&Lx.test(i)?`"${i}"`:`${i}`).join(",");return this.url.searchParams.append(t,`not.in.(${s})`),this}contains(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cs.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cs.{${e.join(",")}}`):this.url.searchParams.append(t,`cs.${JSON.stringify(e)}`),this}containedBy(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cd.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cd.{${e.join(",")}}`):this.url.searchParams.append(t,`cd.${JSON.stringify(e)}`),this}rangeGt(t,e){return this.url.searchParams.append(t,`sr.${e}`),this}rangeGte(t,e){return this.url.searchParams.append(t,`nxl.${e}`),this}rangeLt(t,e){return this.url.searchParams.append(t,`sl.${e}`),this}rangeLte(t,e){return this.url.searchParams.append(t,`nxr.${e}`),this}rangeAdjacent(t,e){return this.url.searchParams.append(t,`adj.${e}`),this}overlaps(t,e){return typeof e=="string"?this.url.searchParams.append(t,`ov.${e}`):this.url.searchParams.append(t,`ov.{${e.join(",")}}`),this}textSearch(t,e,{config:s,type:i}={}){let l="";i==="plain"?l="pl":i==="phrase"?l="ph":i==="websearch"&&(l="w");const u=s===void 0?"":`(${s})`;return this.url.searchParams.append(t,`${l}fts${u}.${e}`),this}match(t){return Object.entries(t).forEach(([e,s])=>{this.url.searchParams.append(e,`eq.${s}`)}),this}not(t,e,s){return this.url.searchParams.append(t,`not.${e}.${s}`),this}or(t,{foreignTable:e,referencedTable:s=e}={}){const i=s?`${s}.or`:"or";return this.url.searchParams.append(i,`(${t})`),this}filter(t,e,s){return this.url.searchParams.append(t,`${e}.${s}`),this}},h2=class{constructor(t,{headers:e={},schema:s,fetch:i,urlLengthLimit:l=8e3}){this.url=t,this.headers=new Headers(e),this.schema=s,this.fetch=i,this.urlLengthLimit=l}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(t,e){const{head:s=!1,count:i}=e??{},l=s?"HEAD":"GET";let u=!1;const d=(t??"*").split("").map(g=>/\s/.test(g)&&!u?"":(g==='"'&&(u=!u),g)).join(""),{url:h,headers:m}=this.cloneRequestState();return h.searchParams.set("select",d),i&&m.append("Prefer",`count=${i}`),new Wi({method:l,url:h,headers:m,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}insert(t,{count:e,defaultToNull:s=!0}={}){var i;const l="POST",{url:u,headers:d}=this.cloneRequestState();if(e&&d.append("Prefer",`count=${e}`),s||d.append("Prefer","missing=default"),Array.isArray(t)){const h=t.reduce((m,g)=>m.concat(Object.keys(g)),[]);if(h.length>0){const m=[...new Set(h)].map(g=>`"${g}"`);u.searchParams.set("columns",m.join(","))}}return new Wi({method:l,url:u,headers:d,schema:this.schema,body:t,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch,urlLengthLimit:this.urlLengthLimit})}upsert(t,{onConflict:e,ignoreDuplicates:s=!1,count:i,defaultToNull:l=!0}={}){var u;const d="POST",{url:h,headers:m}=this.cloneRequestState();if(m.append("Prefer",`resolution=${s?"ignore":"merge"}-duplicates`),e!==void 0&&h.searchParams.set("on_conflict",e),i&&m.append("Prefer",`count=${i}`),l||m.append("Prefer","missing=default"),Array.isArray(t)){const g=t.reduce((y,x)=>y.concat(Object.keys(x)),[]);if(g.length>0){const y=[...new Set(g)].map(x=>`"${x}"`);h.searchParams.set("columns",y.join(","))}}return new Wi({method:d,url:h,headers:m,schema:this.schema,body:t,fetch:(u=this.fetch)!==null&&u!==void 0?u:fetch,urlLengthLimit:this.urlLengthLimit})}update(t,{count:e}={}){var s;const i="PATCH",{url:l,headers:u}=this.cloneRequestState();return e&&u.append("Prefer",`count=${e}`),new Wi({method:i,url:l,headers:u,schema:this.schema,body:t,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch,urlLengthLimit:this.urlLengthLimit})}delete({count:t}={}){var e;const s="DELETE",{url:i,headers:l}=this.cloneRequestState();return t&&l.append("Prefer",`count=${t}`),new Wi({method:s,url:i,headers:l,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch,urlLengthLimit:this.urlLengthLimit})}};function Oo(t){"@babel/helpers - typeof";return Oo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Oo(t)}function f2(t,e){if(Oo(t)!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var i=s.call(t,e);if(Oo(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function m2(t){var e=f2(t,"string");return Oo(e)=="symbol"?e:e+""}function p2(t,e,s){return(e=m2(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function Ux(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(l){return Object.getOwnPropertyDescriptor(t,l).enumerable})),s.push.apply(s,i)}return s}function Nc(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?Ux(Object(s),!0).forEach(function(i){p2(t,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Ux(Object(s)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(s,i))})}return t}var g2=class nw{constructor(e,{headers:s={},schema:i,fetch:l,timeout:u,urlLengthLimit:d=8e3}={}){this.url=e,this.headers=new Headers(s),this.schemaName=i,this.urlLengthLimit=d;const h=l??globalThis.fetch;u!==void 0&&u>0?this.fetch=(m,g)=>{const y=new AbortController,x=setTimeout(()=>y.abort(),u),w=g?.signal;if(w){if(w.aborted)return clearTimeout(x),h(m,g);const S=()=>{clearTimeout(x),y.abort()};return w.addEventListener("abort",S,{once:!0}),h(m,Nc(Nc({},g),{},{signal:y.signal})).finally(()=>{clearTimeout(x),w.removeEventListener("abort",S)})}return h(m,Nc(Nc({},g),{},{signal:y.signal})).finally(()=>clearTimeout(x))}:this.fetch=h}from(e){if(!e||typeof e!="string"||e.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new h2(new URL(`${this.url}/${e}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}schema(e){return new nw(this.url,{headers:this.headers,schema:e,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}rpc(e,s={},{head:i=!1,get:l=!1,count:u}={}){var d;let h;const m=new URL(`${this.url}/rpc/${e}`);let g;const y=S=>S!==null&&typeof S=="object"&&(!Array.isArray(S)||S.some(y)),x=i&&Object.values(s).some(y);x?(h="POST",g=s):i||l?(h=i?"HEAD":"GET",Object.entries(s).filter(([S,E])=>E!==void 0).map(([S,E])=>[S,Array.isArray(E)?`{${E.join(",")}}`:`${E}`]).forEach(([S,E])=>{m.searchParams.append(S,E)})):(h="POST",g=s);const w=new Headers(this.headers);return x?w.set("Prefer",u?`count=${u},return=minimal`:"return=minimal"):u&&w.set("Prefer",`count=${u}`),new Wi({method:h,url:m,headers:w,schema:this.schemaName,body:g,fetch:(d=this.fetch)!==null&&d!==void 0?d:fetch,urlLengthLimit:this.urlLengthLimit})}};class y2{constructor(){}static detectEnvironment(){var e;if(typeof WebSocket<"u")return{type:"native",constructor:WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocket<"u")return{type:"native",constructor:globalThis.WebSocket};if(typeof global<"u"&&typeof global.WebSocket<"u")return{type:"native",constructor:global.WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&globalThis.EdgeRuntime||typeof navigator<"u"&&(!((e=navigator.userAgent)===null||e===void 0)&&e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};const s=globalThis.process;if(s){const i=s.versions;if(i&&i.node){const l=i.node,u=parseInt(l.replace(/^v/,"").split(".")[0]);return u>=22?typeof globalThis.WebSocket<"u"?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${u} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${u} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option:
|
|
13
13
|
import ws from "ws"
|
|
14
14
|
new RealtimeClient(url, { transport: ws })`}}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const e=this.detectEnvironment();if(e.constructor)return e.constructor;let s=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(s+=`
|
|
15
15
|
|
|
16
|
-
Suggested solution: ${e.workaround}`),new Error(s)}static createWebSocket(e,s){const r=this.getWebSocketConstructor();return new r(e,s)}static isWebSocketSupported(){try{const e=this.detectEnvironment();return e.type==="native"||e.type==="ws"}catch{return!1}}}const v2="2.97.0",x2=`realtime-js/${v2}`,b2="1.0.0",sw="2.0.0",Bx=sw,qf=1e4,w2=1e3,S2=100;var ca;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(ca||(ca={}));var Rt;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(Rt||(Rt={}));var Gn;(function(t){t.close="phx_close",t.error="phx_error",t.join="phx_join",t.reply="phx_reply",t.leave="phx_leave",t.access_token="access_token"})(Gn||(Gn={}));var Hf;(function(t){t.websocket="websocket"})(Hf||(Hf={}));var Ha;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(Ha||(Ha={}));class j2{constructor(e){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=e??[]}encode(e,s){if(e.event===this.BROADCAST_EVENT&&!(e.payload instanceof ArrayBuffer)&&typeof e.payload.event=="string")return s(this._binaryEncodeUserBroadcastPush(e));let r=[e.join_ref,e.ref,e.topic,e.event,e.payload];return s(JSON.stringify(r))}_binaryEncodeUserBroadcastPush(e){var s;return this._isArrayBuffer((s=e.payload)===null||s===void 0?void 0:s.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)}_encodeBinaryUserBroadcastPush(e){var s,r;const l=(r=(s=e.payload)===null||s===void 0?void 0:s.payload)!==null&&r!==void 0?r:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,l)}_encodeJsonUserBroadcastPush(e){var s,r;const l=(r=(s=e.payload)===null||s===void 0?void 0:s.payload)!==null&&r!==void 0?r:{},d=new TextEncoder().encode(JSON.stringify(l)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,d)}_encodeUserBroadcastPush(e,s,r){var l,u;const d=e.topic,h=(l=e.ref)!==null&&l!==void 0?l:"",m=(u=e.join_ref)!==null&&u!==void 0?u:"",g=e.payload.event,y=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},x=Object.keys(y).length===0?"":JSON.stringify(y);if(m.length>255)throw new Error(`joinRef length ${m.length} exceeds maximum of 255`);if(h.length>255)throw new Error(`ref length ${h.length} exceeds maximum of 255`);if(d.length>255)throw new Error(`topic length ${d.length} exceeds maximum of 255`);if(g.length>255)throw new Error(`userEvent length ${g.length} exceeds maximum of 255`);if(x.length>255)throw new Error(`metadata length ${x.length} exceeds maximum of 255`);const w=this.USER_BROADCAST_PUSH_META_LENGTH+m.length+h.length+d.length+g.length+x.length,S=new ArrayBuffer(this.HEADER_LENGTH+w);let E=new DataView(S),j=0;E.setUint8(j++,this.KINDS.userBroadcastPush),E.setUint8(j++,m.length),E.setUint8(j++,h.length),E.setUint8(j++,d.length),E.setUint8(j++,g.length),E.setUint8(j++,x.length),E.setUint8(j++,s),Array.from(m,N=>E.setUint8(j++,N.charCodeAt(0))),Array.from(h,N=>E.setUint8(j++,N.charCodeAt(0))),Array.from(d,N=>E.setUint8(j++,N.charCodeAt(0))),Array.from(g,N=>E.setUint8(j++,N.charCodeAt(0))),Array.from(x,N=>E.setUint8(j++,N.charCodeAt(0)));var _=new Uint8Array(S.byteLength+r.byteLength);return _.set(new Uint8Array(S),0),_.set(new Uint8Array(r),S.byteLength),_.buffer}decode(e,s){if(this._isArrayBuffer(e)){let r=this._binaryDecode(e);return s(r)}if(typeof e=="string"){const r=JSON.parse(e),[l,u,d,h,m]=r;return s({join_ref:l,ref:u,topic:d,event:h,payload:m})}return s({})}_binaryDecode(e){const s=new DataView(e),r=s.getUint8(0),l=new TextDecoder;if(r===this.KINDS.userBroadcast)return this._decodeUserBroadcast(e,s,l)}_decodeUserBroadcast(e,s,r){const l=s.getUint8(1),u=s.getUint8(2),d=s.getUint8(3),h=s.getUint8(4);let m=this.HEADER_LENGTH+4;const g=r.decode(e.slice(m,m+l));m=m+l;const y=r.decode(e.slice(m,m+u));m=m+u;const x=r.decode(e.slice(m,m+d));m=m+d;const w=e.slice(m,e.byteLength),S=h===this.JSON_ENCODING?JSON.parse(r.decode(w)):w,E={type:this.BROADCAST_EVENT,event:y,payload:S};return d>0&&(E.meta=JSON.parse(x)),{join_ref:null,ref:null,topic:g,event:this.BROADCAST_EVENT,payload:E}}_isArrayBuffer(e){var s;return e instanceof ArrayBuffer||((s=e?.constructor)===null||s===void 0?void 0:s.name)==="ArrayBuffer"}_pick(e,s){return!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([r])=>s.includes(r)))}}class aw{constructor(e,s){this.callback=e,this.timerCalc=s,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=s}reset(){this.tries=0,clearTimeout(this.timer),this.timer=void 0}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}var ot;(function(t){t.abstime="abstime",t.bool="bool",t.date="date",t.daterange="daterange",t.float4="float4",t.float8="float8",t.int2="int2",t.int4="int4",t.int4range="int4range",t.int8="int8",t.int8range="int8range",t.json="json",t.jsonb="jsonb",t.money="money",t.numeric="numeric",t.oid="oid",t.reltime="reltime",t.text="text",t.time="time",t.timestamp="timestamp",t.timestamptz="timestamptz",t.timetz="timetz",t.tsrange="tsrange",t.tstzrange="tstzrange"})(ot||(ot={}));const Vx=(t,e,s={})=>{var r;const l=(r=s.skipTypes)!==null&&r!==void 0?r:[];return e?Object.keys(e).reduce((u,d)=>(u[d]=_2(d,t,e,l),u),{}):{}},_2=(t,e,s,r)=>{const l=e.find(h=>h.name===t),u=l?.type,d=s[t];return u&&!r.includes(u)?rw(u,d):Gf(d)},rw=(t,e)=>{if(t.charAt(0)==="_"){const s=t.slice(1,t.length);return k2(e,s)}switch(t){case ot.bool:return N2(e);case ot.float4:case ot.float8:case ot.int2:case ot.int4:case ot.int8:case ot.numeric:case ot.oid:return T2(e);case ot.json:case ot.jsonb:return E2(e);case ot.timestamp:return C2(e);case ot.abstime:case ot.date:case ot.daterange:case ot.int4range:case ot.int8range:case ot.money:case ot.reltime:case ot.text:case ot.time:case ot.timestamptz:case ot.timetz:case ot.tsrange:case ot.tstzrange:return Gf(e);default:return Gf(e)}},Gf=t=>t,N2=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},T2=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},E2=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t},k2=(t,e)=>{if(typeof t!="string")return t;const s=t.length-1,r=t[s];if(t[0]==="{"&&r==="}"){let u;const d=t.slice(1,s);try{u=JSON.parse("["+d+"]")}catch{u=d?d.split(","):[]}return u.map(h=>rw(e,h))}return t},C2=t=>typeof t=="string"?t.replace(" ","T"):t,iw=t=>{const e=new URL(t);return e.protocol=e.protocol.replace(/^ws/i,"http"),e.pathname=e.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),e.pathname===""||e.pathname==="/"?e.pathname="/api/broadcast":e.pathname=e.pathname+"/api/broadcast",e.href};class sf{constructor(e,s,r={},l=qf){this.channel=e,this.event=s,this.payload=r,this.timeout=l,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,s){var r;return this._hasReceived(e)&&s((r=this.receivedResp)===null||r===void 0?void 0:r.response),this.recHooks.push({status:e,callback:s}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const e=s=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=s,this._matchReceive(s)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,s){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:s})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:s}){this.recHooks.filter(r=>r.status===e).forEach(r=>r.callback(s))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}var Ix;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(Ix||(Ix={}));class No{constructor(e,s){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const r=s?.events||{state:"presence_state",diff:"presence_diff"};this.channel._on(r.state,{},l=>{const{onJoin:u,onLeave:d,onSync:h}=this.caller;this.joinRef=this.channel._joinRef(),this.state=No.syncState(this.state,l,u,d),this.pendingDiffs.forEach(m=>{this.state=No.syncDiff(this.state,m,u,d)}),this.pendingDiffs=[],h()}),this.channel._on(r.diff,{},l=>{const{onJoin:u,onLeave:d,onSync:h}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(l):(this.state=No.syncDiff(this.state,l,u,d),h())}),this.onJoin((l,u,d)=>{this.channel._trigger("presence",{event:"join",key:l,currentPresences:u,newPresences:d})}),this.onLeave((l,u,d)=>{this.channel._trigger("presence",{event:"leave",key:l,currentPresences:u,leftPresences:d})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,s,r,l){const u=this.cloneDeep(e),d=this.transformState(s),h={},m={};return this.map(u,(g,y)=>{d[g]||(m[g]=y)}),this.map(d,(g,y)=>{const x=u[g];if(x){const w=y.map(_=>_.presence_ref),S=x.map(_=>_.presence_ref),E=y.filter(_=>S.indexOf(_.presence_ref)<0),j=x.filter(_=>w.indexOf(_.presence_ref)<0);E.length>0&&(h[g]=E),j.length>0&&(m[g]=j)}else h[g]=y}),this.syncDiff(u,{joins:h,leaves:m},r,l)}static syncDiff(e,s,r,l){const{joins:u,leaves:d}={joins:this.transformState(s.joins),leaves:this.transformState(s.leaves)};return r||(r=()=>{}),l||(l=()=>{}),this.map(u,(h,m)=>{var g;const y=(g=e[h])!==null&&g!==void 0?g:[];if(e[h]=this.cloneDeep(m),y.length>0){const x=e[h].map(S=>S.presence_ref),w=y.filter(S=>x.indexOf(S.presence_ref)<0);e[h].unshift(...w)}r(h,y,m)}),this.map(d,(h,m)=>{let g=e[h];if(!g)return;const y=m.map(x=>x.presence_ref);g=g.filter(x=>y.indexOf(x.presence_ref)<0),e[h]=g,l(h,g,m),g.length===0&&delete e[h]}),e}static map(e,s){return Object.getOwnPropertyNames(e).map(r=>s(r,e[r]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((s,r)=>{const l=e[r];return"metas"in l?s[r]=l.metas.map(u=>(u.presence_ref=u.phx_ref,delete u.phx_ref,delete u.phx_ref_prev,u)):s[r]=l,s},{})}static cloneDeep(e){return JSON.parse(JSON.stringify(e))}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var $x;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})($x||($x={}));var To;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(To||(To={}));var ks;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(ks||(ks={}));class ei{constructor(e,s={config:{}},r){var l,u;if(this.topic=e,this.params=s,this.socket=r,this.bindings={},this.state=Rt.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},s.config),this.timeout=this.socket.timeout,this.joinPush=new sf(this,Gn.join,this.params,this.timeout),this.rejoinTimer=new aw(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=Rt.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(d=>d.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=Rt.closed,this.socket._remove(this)}),this._onError(d=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,d),this.state=Rt.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=Rt.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",d=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,d),this.state=Rt.errored,this.rejoinTimer.scheduleTimeout())}),this._on(Gn.reply,{},(d,h)=>{this._trigger(this._replyEventName(h),d)}),this.presence=new No(this),this.broadcastEndpointURL=iw(this.socket.endPoint),this.private=this.params.config.private||!1,!this.private&&(!((u=(l=this.params.config)===null||l===void 0?void 0:l.broadcast)===null||u===void 0)&&u.replay))throw`tried to use replay on public channel '${this.topic}'. It must be a private channel.`}subscribe(e,s=this.timeout){var r,l,u;if(this.socket.isConnected()||this.socket.connect(),this.state==Rt.closed){const{config:{broadcast:d,presence:h,private:m}}=this.params,g=(l=(r=this.bindings.postgres_changes)===null||r===void 0?void 0:r.map(S=>S.filter))!==null&&l!==void 0?l:[],y=!!this.bindings[To.PRESENCE]&&this.bindings[To.PRESENCE].length>0||((u=this.params.config.presence)===null||u===void 0?void 0:u.enabled)===!0,x={},w={broadcast:d,presence:Object.assign(Object.assign({},h),{enabled:y}),postgres_changes:g,private:m};this.socket.accessTokenValue&&(x.access_token=this.socket.accessTokenValue),this._onError(S=>e?.(ks.CHANNEL_ERROR,S)),this._onClose(()=>e?.(ks.CLOSED)),this.updateJoinPayload(Object.assign({config:w},x)),this.joinedOnce=!0,this._rejoin(s),this.joinPush.receive("ok",async({postgres_changes:S})=>{var E;if(this.socket._isManualToken()||this.socket.setAuth(),S===void 0){e?.(ks.SUBSCRIBED);return}else{const j=this.bindings.postgres_changes,_=(E=j?.length)!==null&&E!==void 0?E:0,N=[];for(let k=0;k<_;k++){const C=j[k],{filter:{event:A,schema:D,table:U,filter:V}}=C,R=S&&S[k];if(R&&R.event===A&&ei.isFilterValueEqual(R.schema,D)&&ei.isFilterValueEqual(R.table,U)&&ei.isFilterValueEqual(R.filter,V))N.push(Object.assign(Object.assign({},C),{id:R.id}));else{this.unsubscribe(),this.state=Rt.errored,e?.(ks.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=N,e&&e(ks.SUBSCRIBED);return}}).receive("error",S=>{this.state=Rt.errored,e?.(ks.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(S).join(", ")||"error")))}).receive("timeout",()=>{e?.(ks.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(e,s={}){return await this.send({type:"presence",event:"track",payload:e},s.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,s,r){return this.state===Rt.joined&&e===To.PRESENCE&&(this.socket.log("channel",`resubscribe to ${this.topic} due to change in presence callbacks on joined channel`),this.unsubscribe().then(async()=>await this.subscribe())),this._on(e,s,r)}async httpSend(e,s,r={}){var l;if(s==null)return Promise.reject("Payload is required for httpSend()");const u={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(u.Authorization=`Bearer ${this.socket.accessTokenValue}`);const d={method:"POST",headers:u,body:JSON.stringify({messages:[{topic:this.subTopic,event:e,payload:s,private:this.private}]})},h=await this._fetchWithTimeout(this.broadcastEndpointURL,d,(l=r.timeout)!==null&&l!==void 0?l:this.timeout);if(h.status===202)return{success:!0};let m=h.statusText;try{const g=await h.json();m=g.error||g.message||m}catch{}return Promise.reject(new Error(m))}async send(e,s={}){var r,l;if(!this._canPush()&&e.type==="broadcast"){console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");const{event:u,payload:d}=e,h={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(h.Authorization=`Bearer ${this.socket.accessTokenValue}`);const m={method:"POST",headers:h,body:JSON.stringify({messages:[{topic:this.subTopic,event:u,payload:d,private:this.private}]})};try{const g=await this._fetchWithTimeout(this.broadcastEndpointURL,m,(r=s.timeout)!==null&&r!==void 0?r:this.timeout);return await((l=g.body)===null||l===void 0?void 0:l.cancel()),g.ok?"ok":"error"}catch(g){return g.name==="AbortError"?"timed out":"error"}}else return new Promise(u=>{var d,h,m;const g=this._push(e.type,e,s.timeout||this.timeout);e.type==="broadcast"&&!(!((m=(h=(d=this.params)===null||d===void 0?void 0:d.config)===null||h===void 0?void 0:h.broadcast)===null||m===void 0)&&m.ack)&&u("ok"),g.receive("ok",()=>u("ok")),g.receive("error",()=>u("error")),g.receive("timeout",()=>u("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=Rt.leaving;const s=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(Gn.close,"leave",this._joinRef())};this.joinPush.destroy();let r=null;return new Promise(l=>{r=new sf(this,Gn.leave,{},e),r.receive("ok",()=>{s(),l("ok")}).receive("timeout",()=>{s(),l("timed out")}).receive("error",()=>{l("error")}),r.send(),this._canPush()||r.trigger("ok",{})}).finally(()=>{r?.destroy()})}teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=Rt.closed,this.bindings={}}async _fetchWithTimeout(e,s,r){const l=new AbortController,u=setTimeout(()=>l.abort(),r),d=await this.socket.fetch(e,Object.assign(Object.assign({},s),{signal:l.signal}));return clearTimeout(u),d}_push(e,s,r=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let l=new sf(this,e,s,r);return this._canPush()?l.send():this._addToPushBuffer(l),l}_addToPushBuffer(e){if(e.startTimeout(),this.pushBuffer.push(e),this.pushBuffer.length>S2){const s=this.pushBuffer.shift();s&&(s.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${s.event}`,s.payload))}}_onMessage(e,s,r){return s}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,s,r){var l,u;const d=e.toLocaleLowerCase(),{close:h,error:m,leave:g,join:y}=Gn;if(r&&[h,m,g,y].indexOf(d)>=0&&r!==this._joinRef())return;let w=this._onMessage(d,s,r);if(s&&!w)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(d)?(l=this.bindings.postgres_changes)===null||l===void 0||l.filter(S=>{var E,j,_;return((E=S.filter)===null||E===void 0?void 0:E.event)==="*"||((_=(j=S.filter)===null||j===void 0?void 0:j.event)===null||_===void 0?void 0:_.toLocaleLowerCase())===d}).map(S=>S.callback(w,r)):(u=this.bindings[d])===null||u===void 0||u.filter(S=>{var E,j,_,N,k,C;if(["broadcast","presence","postgres_changes"].includes(d))if("id"in S){const A=S.id,D=(E=S.filter)===null||E===void 0?void 0:E.event;return A&&((j=s.ids)===null||j===void 0?void 0:j.includes(A))&&(D==="*"||D?.toLocaleLowerCase()===((_=s.data)===null||_===void 0?void 0:_.type.toLocaleLowerCase()))}else{const A=(k=(N=S?.filter)===null||N===void 0?void 0:N.event)===null||k===void 0?void 0:k.toLocaleLowerCase();return A==="*"||A===((C=s?.event)===null||C===void 0?void 0:C.toLocaleLowerCase())}else return S.type.toLocaleLowerCase()===d}).map(S=>{if(typeof w=="object"&&"ids"in w){const E=w.data,{schema:j,table:_,commit_timestamp:N,type:k,errors:C}=E;w=Object.assign(Object.assign({},{schema:j,table:_,commit_timestamp:N,eventType:k,new:{},old:{},errors:C}),this._getPayloadRecords(E))}S.callback(w,r)})}_isClosed(){return this.state===Rt.closed}_isJoined(){return this.state===Rt.joined}_isJoining(){return this.state===Rt.joining}_isLeaving(){return this.state===Rt.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,s,r){const l=e.toLocaleLowerCase(),u={type:l,filter:s,callback:r};return this.bindings[l]?this.bindings[l].push(u):this.bindings[l]=[u],this}_off(e,s){const r=e.toLocaleLowerCase();return this.bindings[r]&&(this.bindings[r]=this.bindings[r].filter(l=>{var u;return!(((u=l.type)===null||u===void 0?void 0:u.toLocaleLowerCase())===r&&ei.isEqual(l.filter,s))})),this}static isEqual(e,s){if(Object.keys(e).length!==Object.keys(s).length)return!1;for(const r in e)if(e[r]!==s[r])return!1;return!0}static isFilterValueEqual(e,s){return(e??void 0)===(s??void 0)}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(Gn.close,{},e)}_onError(e){this._on(Gn.error,{},s=>e(s))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=Rt.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const s={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(s.new=Vx(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(s.old=Vx(e.columns,e.old_record)),s}}const af=()=>{},Tc={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},A2=[1e3,2e3,5e3,1e4],R2=1e4,O2=`
|
|
16
|
+
Suggested solution: ${e.workaround}`),new Error(s)}static createWebSocket(e,s){const i=this.getWebSocketConstructor();return new i(e,s)}static isWebSocketSupported(){try{const e=this.detectEnvironment();return e.type==="native"||e.type==="ws"}catch{return!1}}}const v2="2.97.0",x2=`realtime-js/${v2}`,b2="1.0.0",sw="2.0.0",Bx=sw,qf=1e4,w2=1e3,S2=100;var ca;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(ca||(ca={}));var Rt;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(Rt||(Rt={}));var Gn;(function(t){t.close="phx_close",t.error="phx_error",t.join="phx_join",t.reply="phx_reply",t.leave="phx_leave",t.access_token="access_token"})(Gn||(Gn={}));var Hf;(function(t){t.websocket="websocket"})(Hf||(Hf={}));var Ha;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(Ha||(Ha={}));class j2{constructor(e){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=e??[]}encode(e,s){if(e.event===this.BROADCAST_EVENT&&!(e.payload instanceof ArrayBuffer)&&typeof e.payload.event=="string")return s(this._binaryEncodeUserBroadcastPush(e));let i=[e.join_ref,e.ref,e.topic,e.event,e.payload];return s(JSON.stringify(i))}_binaryEncodeUserBroadcastPush(e){var s;return this._isArrayBuffer((s=e.payload)===null||s===void 0?void 0:s.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)}_encodeBinaryUserBroadcastPush(e){var s,i;const l=(i=(s=e.payload)===null||s===void 0?void 0:s.payload)!==null&&i!==void 0?i:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,l)}_encodeJsonUserBroadcastPush(e){var s,i;const l=(i=(s=e.payload)===null||s===void 0?void 0:s.payload)!==null&&i!==void 0?i:{},d=new TextEncoder().encode(JSON.stringify(l)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,d)}_encodeUserBroadcastPush(e,s,i){var l,u;const d=e.topic,h=(l=e.ref)!==null&&l!==void 0?l:"",m=(u=e.join_ref)!==null&&u!==void 0?u:"",g=e.payload.event,y=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},x=Object.keys(y).length===0?"":JSON.stringify(y);if(m.length>255)throw new Error(`joinRef length ${m.length} exceeds maximum of 255`);if(h.length>255)throw new Error(`ref length ${h.length} exceeds maximum of 255`);if(d.length>255)throw new Error(`topic length ${d.length} exceeds maximum of 255`);if(g.length>255)throw new Error(`userEvent length ${g.length} exceeds maximum of 255`);if(x.length>255)throw new Error(`metadata length ${x.length} exceeds maximum of 255`);const w=this.USER_BROADCAST_PUSH_META_LENGTH+m.length+h.length+d.length+g.length+x.length,S=new ArrayBuffer(this.HEADER_LENGTH+w);let E=new DataView(S),j=0;E.setUint8(j++,this.KINDS.userBroadcastPush),E.setUint8(j++,m.length),E.setUint8(j++,h.length),E.setUint8(j++,d.length),E.setUint8(j++,g.length),E.setUint8(j++,x.length),E.setUint8(j++,s),Array.from(m,N=>E.setUint8(j++,N.charCodeAt(0))),Array.from(h,N=>E.setUint8(j++,N.charCodeAt(0))),Array.from(d,N=>E.setUint8(j++,N.charCodeAt(0))),Array.from(g,N=>E.setUint8(j++,N.charCodeAt(0))),Array.from(x,N=>E.setUint8(j++,N.charCodeAt(0)));var _=new Uint8Array(S.byteLength+i.byteLength);return _.set(new Uint8Array(S),0),_.set(new Uint8Array(i),S.byteLength),_.buffer}decode(e,s){if(this._isArrayBuffer(e)){let i=this._binaryDecode(e);return s(i)}if(typeof e=="string"){const i=JSON.parse(e),[l,u,d,h,m]=i;return s({join_ref:l,ref:u,topic:d,event:h,payload:m})}return s({})}_binaryDecode(e){const s=new DataView(e),i=s.getUint8(0),l=new TextDecoder;if(i===this.KINDS.userBroadcast)return this._decodeUserBroadcast(e,s,l)}_decodeUserBroadcast(e,s,i){const l=s.getUint8(1),u=s.getUint8(2),d=s.getUint8(3),h=s.getUint8(4);let m=this.HEADER_LENGTH+4;const g=i.decode(e.slice(m,m+l));m=m+l;const y=i.decode(e.slice(m,m+u));m=m+u;const x=i.decode(e.slice(m,m+d));m=m+d;const w=e.slice(m,e.byteLength),S=h===this.JSON_ENCODING?JSON.parse(i.decode(w)):w,E={type:this.BROADCAST_EVENT,event:y,payload:S};return d>0&&(E.meta=JSON.parse(x)),{join_ref:null,ref:null,topic:g,event:this.BROADCAST_EVENT,payload:E}}_isArrayBuffer(e){var s;return e instanceof ArrayBuffer||((s=e?.constructor)===null||s===void 0?void 0:s.name)==="ArrayBuffer"}_pick(e,s){return!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([i])=>s.includes(i)))}}class aw{constructor(e,s){this.callback=e,this.timerCalc=s,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=s}reset(){this.tries=0,clearTimeout(this.timer),this.timer=void 0}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}var ot;(function(t){t.abstime="abstime",t.bool="bool",t.date="date",t.daterange="daterange",t.float4="float4",t.float8="float8",t.int2="int2",t.int4="int4",t.int4range="int4range",t.int8="int8",t.int8range="int8range",t.json="json",t.jsonb="jsonb",t.money="money",t.numeric="numeric",t.oid="oid",t.reltime="reltime",t.text="text",t.time="time",t.timestamp="timestamp",t.timestamptz="timestamptz",t.timetz="timetz",t.tsrange="tsrange",t.tstzrange="tstzrange"})(ot||(ot={}));const Vx=(t,e,s={})=>{var i;const l=(i=s.skipTypes)!==null&&i!==void 0?i:[];return e?Object.keys(e).reduce((u,d)=>(u[d]=_2(d,t,e,l),u),{}):{}},_2=(t,e,s,i)=>{const l=e.find(h=>h.name===t),u=l?.type,d=s[t];return u&&!i.includes(u)?iw(u,d):Gf(d)},iw=(t,e)=>{if(t.charAt(0)==="_"){const s=t.slice(1,t.length);return k2(e,s)}switch(t){case ot.bool:return N2(e);case ot.float4:case ot.float8:case ot.int2:case ot.int4:case ot.int8:case ot.numeric:case ot.oid:return T2(e);case ot.json:case ot.jsonb:return E2(e);case ot.timestamp:return C2(e);case ot.abstime:case ot.date:case ot.daterange:case ot.int4range:case ot.int8range:case ot.money:case ot.reltime:case ot.text:case ot.time:case ot.timestamptz:case ot.timetz:case ot.tsrange:case ot.tstzrange:return Gf(e);default:return Gf(e)}},Gf=t=>t,N2=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},T2=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},E2=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t},k2=(t,e)=>{if(typeof t!="string")return t;const s=t.length-1,i=t[s];if(t[0]==="{"&&i==="}"){let u;const d=t.slice(1,s);try{u=JSON.parse("["+d+"]")}catch{u=d?d.split(","):[]}return u.map(h=>iw(e,h))}return t},C2=t=>typeof t=="string"?t.replace(" ","T"):t,rw=t=>{const e=new URL(t);return e.protocol=e.protocol.replace(/^ws/i,"http"),e.pathname=e.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),e.pathname===""||e.pathname==="/"?e.pathname="/api/broadcast":e.pathname=e.pathname+"/api/broadcast",e.href};class sf{constructor(e,s,i={},l=qf){this.channel=e,this.event=s,this.payload=i,this.timeout=l,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,s){var i;return this._hasReceived(e)&&s((i=this.receivedResp)===null||i===void 0?void 0:i.response),this.recHooks.push({status:e,callback:s}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const e=s=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=s,this._matchReceive(s)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,s){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:s})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:s}){this.recHooks.filter(i=>i.status===e).forEach(i=>i.callback(s))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}var Ix;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(Ix||(Ix={}));class No{constructor(e,s){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const i=s?.events||{state:"presence_state",diff:"presence_diff"};this.channel._on(i.state,{},l=>{const{onJoin:u,onLeave:d,onSync:h}=this.caller;this.joinRef=this.channel._joinRef(),this.state=No.syncState(this.state,l,u,d),this.pendingDiffs.forEach(m=>{this.state=No.syncDiff(this.state,m,u,d)}),this.pendingDiffs=[],h()}),this.channel._on(i.diff,{},l=>{const{onJoin:u,onLeave:d,onSync:h}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(l):(this.state=No.syncDiff(this.state,l,u,d),h())}),this.onJoin((l,u,d)=>{this.channel._trigger("presence",{event:"join",key:l,currentPresences:u,newPresences:d})}),this.onLeave((l,u,d)=>{this.channel._trigger("presence",{event:"leave",key:l,currentPresences:u,leftPresences:d})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,s,i,l){const u=this.cloneDeep(e),d=this.transformState(s),h={},m={};return this.map(u,(g,y)=>{d[g]||(m[g]=y)}),this.map(d,(g,y)=>{const x=u[g];if(x){const w=y.map(_=>_.presence_ref),S=x.map(_=>_.presence_ref),E=y.filter(_=>S.indexOf(_.presence_ref)<0),j=x.filter(_=>w.indexOf(_.presence_ref)<0);E.length>0&&(h[g]=E),j.length>0&&(m[g]=j)}else h[g]=y}),this.syncDiff(u,{joins:h,leaves:m},i,l)}static syncDiff(e,s,i,l){const{joins:u,leaves:d}={joins:this.transformState(s.joins),leaves:this.transformState(s.leaves)};return i||(i=()=>{}),l||(l=()=>{}),this.map(u,(h,m)=>{var g;const y=(g=e[h])!==null&&g!==void 0?g:[];if(e[h]=this.cloneDeep(m),y.length>0){const x=e[h].map(S=>S.presence_ref),w=y.filter(S=>x.indexOf(S.presence_ref)<0);e[h].unshift(...w)}i(h,y,m)}),this.map(d,(h,m)=>{let g=e[h];if(!g)return;const y=m.map(x=>x.presence_ref);g=g.filter(x=>y.indexOf(x.presence_ref)<0),e[h]=g,l(h,g,m),g.length===0&&delete e[h]}),e}static map(e,s){return Object.getOwnPropertyNames(e).map(i=>s(i,e[i]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((s,i)=>{const l=e[i];return"metas"in l?s[i]=l.metas.map(u=>(u.presence_ref=u.phx_ref,delete u.phx_ref,delete u.phx_ref_prev,u)):s[i]=l,s},{})}static cloneDeep(e){return JSON.parse(JSON.stringify(e))}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var $x;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})($x||($x={}));var To;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(To||(To={}));var ks;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(ks||(ks={}));class er{constructor(e,s={config:{}},i){var l,u;if(this.topic=e,this.params=s,this.socket=i,this.bindings={},this.state=Rt.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},s.config),this.timeout=this.socket.timeout,this.joinPush=new sf(this,Gn.join,this.params,this.timeout),this.rejoinTimer=new aw(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=Rt.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(d=>d.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=Rt.closed,this.socket._remove(this)}),this._onError(d=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,d),this.state=Rt.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=Rt.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",d=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,d),this.state=Rt.errored,this.rejoinTimer.scheduleTimeout())}),this._on(Gn.reply,{},(d,h)=>{this._trigger(this._replyEventName(h),d)}),this.presence=new No(this),this.broadcastEndpointURL=rw(this.socket.endPoint),this.private=this.params.config.private||!1,!this.private&&(!((u=(l=this.params.config)===null||l===void 0?void 0:l.broadcast)===null||u===void 0)&&u.replay))throw`tried to use replay on public channel '${this.topic}'. It must be a private channel.`}subscribe(e,s=this.timeout){var i,l,u;if(this.socket.isConnected()||this.socket.connect(),this.state==Rt.closed){const{config:{broadcast:d,presence:h,private:m}}=this.params,g=(l=(i=this.bindings.postgres_changes)===null||i===void 0?void 0:i.map(S=>S.filter))!==null&&l!==void 0?l:[],y=!!this.bindings[To.PRESENCE]&&this.bindings[To.PRESENCE].length>0||((u=this.params.config.presence)===null||u===void 0?void 0:u.enabled)===!0,x={},w={broadcast:d,presence:Object.assign(Object.assign({},h),{enabled:y}),postgres_changes:g,private:m};this.socket.accessTokenValue&&(x.access_token=this.socket.accessTokenValue),this._onError(S=>e?.(ks.CHANNEL_ERROR,S)),this._onClose(()=>e?.(ks.CLOSED)),this.updateJoinPayload(Object.assign({config:w},x)),this.joinedOnce=!0,this._rejoin(s),this.joinPush.receive("ok",async({postgres_changes:S})=>{var E;if(this.socket._isManualToken()||this.socket.setAuth(),S===void 0){e?.(ks.SUBSCRIBED);return}else{const j=this.bindings.postgres_changes,_=(E=j?.length)!==null&&E!==void 0?E:0,N=[];for(let k=0;k<_;k++){const C=j[k],{filter:{event:A,schema:D,table:z,filter:V}}=C,R=S&&S[k];if(R&&R.event===A&&er.isFilterValueEqual(R.schema,D)&&er.isFilterValueEqual(R.table,z)&&er.isFilterValueEqual(R.filter,V))N.push(Object.assign(Object.assign({},C),{id:R.id}));else{this.unsubscribe(),this.state=Rt.errored,e?.(ks.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=N,e&&e(ks.SUBSCRIBED);return}}).receive("error",S=>{this.state=Rt.errored,e?.(ks.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(S).join(", ")||"error")))}).receive("timeout",()=>{e?.(ks.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(e,s={}){return await this.send({type:"presence",event:"track",payload:e},s.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,s,i){return this.state===Rt.joined&&e===To.PRESENCE&&(this.socket.log("channel",`resubscribe to ${this.topic} due to change in presence callbacks on joined channel`),this.unsubscribe().then(async()=>await this.subscribe())),this._on(e,s,i)}async httpSend(e,s,i={}){var l;if(s==null)return Promise.reject("Payload is required for httpSend()");const u={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(u.Authorization=`Bearer ${this.socket.accessTokenValue}`);const d={method:"POST",headers:u,body:JSON.stringify({messages:[{topic:this.subTopic,event:e,payload:s,private:this.private}]})},h=await this._fetchWithTimeout(this.broadcastEndpointURL,d,(l=i.timeout)!==null&&l!==void 0?l:this.timeout);if(h.status===202)return{success:!0};let m=h.statusText;try{const g=await h.json();m=g.error||g.message||m}catch{}return Promise.reject(new Error(m))}async send(e,s={}){var i,l;if(!this._canPush()&&e.type==="broadcast"){console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");const{event:u,payload:d}=e,h={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(h.Authorization=`Bearer ${this.socket.accessTokenValue}`);const m={method:"POST",headers:h,body:JSON.stringify({messages:[{topic:this.subTopic,event:u,payload:d,private:this.private}]})};try{const g=await this._fetchWithTimeout(this.broadcastEndpointURL,m,(i=s.timeout)!==null&&i!==void 0?i:this.timeout);return await((l=g.body)===null||l===void 0?void 0:l.cancel()),g.ok?"ok":"error"}catch(g){return g.name==="AbortError"?"timed out":"error"}}else return new Promise(u=>{var d,h,m;const g=this._push(e.type,e,s.timeout||this.timeout);e.type==="broadcast"&&!(!((m=(h=(d=this.params)===null||d===void 0?void 0:d.config)===null||h===void 0?void 0:h.broadcast)===null||m===void 0)&&m.ack)&&u("ok"),g.receive("ok",()=>u("ok")),g.receive("error",()=>u("error")),g.receive("timeout",()=>u("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=Rt.leaving;const s=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(Gn.close,"leave",this._joinRef())};this.joinPush.destroy();let i=null;return new Promise(l=>{i=new sf(this,Gn.leave,{},e),i.receive("ok",()=>{s(),l("ok")}).receive("timeout",()=>{s(),l("timed out")}).receive("error",()=>{l("error")}),i.send(),this._canPush()||i.trigger("ok",{})}).finally(()=>{i?.destroy()})}teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=Rt.closed,this.bindings={}}async _fetchWithTimeout(e,s,i){const l=new AbortController,u=setTimeout(()=>l.abort(),i),d=await this.socket.fetch(e,Object.assign(Object.assign({},s),{signal:l.signal}));return clearTimeout(u),d}_push(e,s,i=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let l=new sf(this,e,s,i);return this._canPush()?l.send():this._addToPushBuffer(l),l}_addToPushBuffer(e){if(e.startTimeout(),this.pushBuffer.push(e),this.pushBuffer.length>S2){const s=this.pushBuffer.shift();s&&(s.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${s.event}`,s.payload))}}_onMessage(e,s,i){return s}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,s,i){var l,u;const d=e.toLocaleLowerCase(),{close:h,error:m,leave:g,join:y}=Gn;if(i&&[h,m,g,y].indexOf(d)>=0&&i!==this._joinRef())return;let w=this._onMessage(d,s,i);if(s&&!w)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(d)?(l=this.bindings.postgres_changes)===null||l===void 0||l.filter(S=>{var E,j,_;return((E=S.filter)===null||E===void 0?void 0:E.event)==="*"||((_=(j=S.filter)===null||j===void 0?void 0:j.event)===null||_===void 0?void 0:_.toLocaleLowerCase())===d}).map(S=>S.callback(w,i)):(u=this.bindings[d])===null||u===void 0||u.filter(S=>{var E,j,_,N,k,C;if(["broadcast","presence","postgres_changes"].includes(d))if("id"in S){const A=S.id,D=(E=S.filter)===null||E===void 0?void 0:E.event;return A&&((j=s.ids)===null||j===void 0?void 0:j.includes(A))&&(D==="*"||D?.toLocaleLowerCase()===((_=s.data)===null||_===void 0?void 0:_.type.toLocaleLowerCase()))}else{const A=(k=(N=S?.filter)===null||N===void 0?void 0:N.event)===null||k===void 0?void 0:k.toLocaleLowerCase();return A==="*"||A===((C=s?.event)===null||C===void 0?void 0:C.toLocaleLowerCase())}else return S.type.toLocaleLowerCase()===d}).map(S=>{if(typeof w=="object"&&"ids"in w){const E=w.data,{schema:j,table:_,commit_timestamp:N,type:k,errors:C}=E;w=Object.assign(Object.assign({},{schema:j,table:_,commit_timestamp:N,eventType:k,new:{},old:{},errors:C}),this._getPayloadRecords(E))}S.callback(w,i)})}_isClosed(){return this.state===Rt.closed}_isJoined(){return this.state===Rt.joined}_isJoining(){return this.state===Rt.joining}_isLeaving(){return this.state===Rt.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,s,i){const l=e.toLocaleLowerCase(),u={type:l,filter:s,callback:i};return this.bindings[l]?this.bindings[l].push(u):this.bindings[l]=[u],this}_off(e,s){const i=e.toLocaleLowerCase();return this.bindings[i]&&(this.bindings[i]=this.bindings[i].filter(l=>{var u;return!(((u=l.type)===null||u===void 0?void 0:u.toLocaleLowerCase())===i&&er.isEqual(l.filter,s))})),this}static isEqual(e,s){if(Object.keys(e).length!==Object.keys(s).length)return!1;for(const i in e)if(e[i]!==s[i])return!1;return!0}static isFilterValueEqual(e,s){return(e??void 0)===(s??void 0)}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(Gn.close,{},e)}_onError(e){this._on(Gn.error,{},s=>e(s))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=Rt.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const s={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(s.new=Vx(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(s.old=Vx(e.columns,e.old_record)),s}}const af=()=>{},Tc={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},A2=[1e3,2e3,5e3,1e4],R2=1e4,O2=`
|
|
17
17
|
addEventListener("message", (e) => {
|
|
18
18
|
if (e.data.event === "start") {
|
|
19
19
|
setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
|
|
20
20
|
}
|
|
21
|
-
});`;class M2{constructor(e,s){var
|
|
21
|
+
});`;class M2{constructor(e,s){var i;if(this.accessTokenValue=null,this.apiKey=null,this._manuallySetToken=!1,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=qf,this.transport=null,this.heartbeatIntervalMs=Tc.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=af,this.ref=0,this.reconnectTimer=null,this.vsn=Bx,this.logger=af,this.conn=null,this.sendBuffer=[],this.serializer=new j2,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._connectionState="disconnected",this._wasManualDisconnect=!1,this._authPromise=null,this._heartbeatSentAt=null,this._resolveFetch=l=>l?(...u)=>l(...u):(...u)=>fetch(...u),!(!((i=s?.params)===null||i===void 0)&&i.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=s.params.apikey,this.endPoint=`${e}/${Hf.websocket}`,this.httpEndpoint=rw(e),this._initializeOptions(s),this._setupReconnectionTimer(),this.fetch=this._resolveFetch(s?.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.conn!==null&&this.isConnected())){if(this._setConnectionState("connecting"),this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this.transport)this.conn=new this.transport(this.endpointURL());else try{this.conn=y2.createWebSocket(this.endpointURL())}catch(e){this._setConnectionState("disconnected");const s=e.message;throw s.includes("Node.js")?new Error(`${s}
|
|
22
22
|
|
|
23
23
|
To use Realtime in Node.js, you need to provide a WebSocket implementation:
|
|
24
24
|
|
|
@@ -31,9 +31,9 @@ Option 2: Install and provide the "ws" package:
|
|
|
31
31
|
const client = new RealtimeClient(url, {
|
|
32
32
|
...options,
|
|
33
33
|
transport: ws
|
|
34
|
-
})`):new Error(`WebSocket not available: ${s}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:this.vsn}))}disconnect(e,s){if(!this.isDisconnecting())if(this._setConnectionState("disconnecting",!0),this.conn){const r=setTimeout(()=>{this._setConnectionState("disconnected")},100);this.conn.onclose=()=>{clearTimeout(r),this._setConnectionState("disconnected")},typeof this.conn.close=="function"&&(e?this.conn.close(e,s??""):this.conn.close()),this._teardownConnection()}else this._setConnectionState("disconnected")}getChannels(){return this.channels}async removeChannel(e){const s=await e.unsubscribe();return this.channels.length===0&&this.disconnect(),s}async removeAllChannels(){const e=await Promise.all(this.channels.map(s=>s.unsubscribe()));return this.channels=[],this.disconnect(),e}log(e,s,r){this.logger(e,s,r)}connectionState(){switch(this.conn&&this.conn.readyState){case ca.connecting:return Ha.Connecting;case ca.open:return Ha.Open;case ca.closing:return Ha.Closing;default:return Ha.Closed}}isConnected(){return this.connectionState()===Ha.Open}isConnecting(){return this._connectionState==="connecting"}isDisconnecting(){return this._connectionState==="disconnecting"}channel(e,s={config:{}}){const r=`realtime:${e}`,l=this.getChannels().find(u=>u.topic===r);if(l)return l;{const u=new ei(`realtime:${e}`,s,this);return this.channels.push(u),u}}push(e){const{topic:s,event:r,payload:l,ref:u}=e,d=()=>{this.encode(e,h=>{var m;(m=this.conn)===null||m===void 0||m.send(h)})};this.log("push",`${s} ${r} (${u})`,l),this.isConnected()?d():this.sendBuffer.push(d)}async setAuth(e=null){this._authPromise=this._performAuth(e);try{await this._authPromise}finally{this._authPromise=null}}_isManualToken(){return this._manuallySetToken}async sendHeartbeat(){var e;if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(s){this.log("error","error in heartbeat callback",s)}return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this._heartbeatSentAt=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(s){this.log("error","error in heartbeat callback",s)}this._wasManualDisconnect=!1,(e=this.conn)===null||e===void 0||e.close(w2,"heartbeat timeout"),setTimeout(()=>{var s;this.isConnected()||(s=this.reconnectTimer)===null||s===void 0||s.scheduleTimeout()},Tc.HEARTBEAT_TIMEOUT_FALLBACK);return}this._heartbeatSentAt=Date.now(),this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(s){this.log("error","error in heartbeat callback",s)}this._setAuthSafely("heartbeat")}onHeartbeat(e){this.heartbeatCallback=e}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let s=this.channels.find(r=>r.topic===e&&(r._isJoined()||r._isJoining()));s&&(this.log("transport",`leaving duplicate topic "${e}"`),s.unsubscribe())}_remove(e){this.channels=this.channels.filter(s=>s.topic!==e.topic)}_onConnMessage(e){this.decode(e.data,s=>{if(s.topic==="phoenix"&&s.event==="phx_reply"&&s.ref&&s.ref===this.pendingHeartbeatRef){const g=this._heartbeatSentAt?Date.now()-this._heartbeatSentAt:void 0;try{this.heartbeatCallback(s.payload.status==="ok"?"ok":"error",g)}catch(y){this.log("error","error in heartbeat callback",y)}this._heartbeatSentAt=null,this.pendingHeartbeatRef=null}const{topic:r,event:l,payload:u,ref:d}=s,h=d?`(${d})`:"",m=u.status||"";this.log("receive",`${m} ${r} ${l} ${h}`.trim(),u),this.channels.filter(g=>g._isMember(r)).forEach(g=>g._trigger(l,u,d)),this._triggerStateCallbacks("message",s)})}_clearTimer(e){var s;e==="heartbeat"&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):e==="reconnect"&&((s=this.reconnectTimer)===null||s===void 0||s.reset())}_clearAllTimers(){this._clearTimer("heartbeat"),this._clearTimer("reconnect")}_setupConnectionHandlers(){this.conn&&("binaryType"in this.conn&&(this.conn.binaryType="arraybuffer"),this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e),this.conn.readyState===ca.open&&this._onConnOpen())}_teardownConnection(){if(this.conn){if(this.conn.readyState===ca.open||this.conn.readyState===ca.connecting)try{this.conn.close()}catch(e){this.log("error","Error closing connection",e)}this.conn.onopen=null,this.conn.onerror=null,this.conn.onmessage=null,this.conn.onclose=null,this.conn=null}this._clearAllTimers(),this._terminateWorker(),this.channels.forEach(e=>e.teardown())}_onConnOpen(){this._setConnectionState("connected"),this.log("transport",`connected to ${this.endpointURL()}`),(this._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve())).then(()=>{this.flushSendBuffer()}).catch(s=>{this.log("error","error waiting for auth on connect",s),this.flushSendBuffer()}),this._clearTimer("reconnect"),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this._triggerStateCallbacks("open")}_startHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=s=>{this.log("worker","worker error",s.message),this._terminateWorker()},this.workerRef.onmessage=s=>{s.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_terminateWorker(){this.workerRef&&(this.log("worker","terminating worker"),this.workerRef.terminate(),this.workerRef=void 0)}_onConnClose(e){var s;this._setConnectionState("disconnected"),this.log("transport","close",e),this._triggerChanError(),this._clearTimer("heartbeat"),this._wasManualDisconnect||(s=this.reconnectTimer)===null||s===void 0||s.scheduleTimeout(),this._triggerStateCallbacks("close",e)}_onConnError(e){this._setConnectionState("disconnected"),this.log("transport",`${e}`),this._triggerChanError(),this._triggerStateCallbacks("error",e);try{this.heartbeatCallback("error")}catch(s){this.log("error","error in heartbeat callback",s)}}_triggerChanError(){this.channels.forEach(e=>e._trigger(Gn.error))}_appendParams(e,s){if(Object.keys(s).length===0)return e;const r=e.match(/\?/)?"&":"?",l=new URLSearchParams(s);return`${e}${r}${l}`}_workerObjectUrl(e){let s;if(e)s=e;else{const r=new Blob([O2],{type:"application/javascript"});s=URL.createObjectURL(r)}return s}_setConnectionState(e,s=!1){this._connectionState=e,e==="connecting"?this._wasManualDisconnect=!1:e==="disconnecting"&&(this._wasManualDisconnect=s)}async _performAuth(e=null){let s,r=!1;if(e)s=e,r=!0;else if(this.accessToken)try{s=await this.accessToken()}catch(l){this.log("error","Error fetching access token from callback",l),s=this.accessTokenValue}else s=this.accessTokenValue;r?this._manuallySetToken=!0:this.accessToken&&(this._manuallySetToken=!1),this.accessTokenValue!=s&&(this.accessTokenValue=s,this.channels.forEach(l=>{const u={access_token:s,version:x2};s&&l.updateJoinPayload(u),l.joinedOnce&&l._isJoined()&&l._push(Gn.access_token,{access_token:s})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(e="general"){this._isManualToken()||this.setAuth().catch(s=>{this.log("error",`Error setting auth in ${e}`,s)})}_triggerStateCallbacks(e,s){try{this.stateChangeCallbacks[e].forEach(r=>{try{r(s)}catch(l){this.log("error",`error in ${e} callback`,l)}})}catch(r){this.log("error",`error triggering ${e} callbacks`,r)}}_setupReconnectionTimer(){this.reconnectTimer=new aw(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},Tc.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(e){var s,r,l,u,d,h,m,g,y,x,w,S;switch(this.transport=(s=e?.transport)!==null&&s!==void 0?s:null,this.timeout=(r=e?.timeout)!==null&&r!==void 0?r:qf,this.heartbeatIntervalMs=(l=e?.heartbeatIntervalMs)!==null&&l!==void 0?l:Tc.HEARTBEAT_INTERVAL,this.worker=(u=e?.worker)!==null&&u!==void 0?u:!1,this.accessToken=(d=e?.accessToken)!==null&&d!==void 0?d:null,this.heartbeatCallback=(h=e?.heartbeatCallback)!==null&&h!==void 0?h:af,this.vsn=(m=e?.vsn)!==null&&m!==void 0?m:Bx,e?.params&&(this.params=e.params),e?.logger&&(this.logger=e.logger),(e?.logLevel||e?.log_level)&&(this.logLevel=e.logLevel||e.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=(g=e?.reconnectAfterMs)!==null&&g!==void 0?g:(E=>A2[E-1]||R2),this.vsn){case b2:this.encode=(y=e?.encode)!==null&&y!==void 0?y:((E,j)=>j(JSON.stringify(E))),this.decode=(x=e?.decode)!==null&&x!==void 0?x:((E,j)=>j(JSON.parse(E)));break;case sw:this.encode=(w=e?.encode)!==null&&w!==void 0?w:this.serializer.encode.bind(this.serializer),this.decode=(S=e?.decode)!==null&&S!==void 0?S:this.serializer.decode.bind(this.serializer);break;default:throw new Error(`Unsupported serializer version: ${this.vsn}`)}if(this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=e?.workerUrl}}}var Mo=class extends Error{constructor(t,e){super(t),this.name="IcebergError",this.status=e.status,this.icebergType=e.icebergType,this.icebergCode=e.icebergCode,this.details=e.details,this.isCommitStateUnknown=e.icebergType==="CommitStateUnknownException"||[500,502,504].includes(e.status)&&e.icebergType?.includes("CommitState")===!0}isNotFound(){return this.status===404}isConflict(){return this.status===409}isAuthenticationTimeout(){return this.status===419}};function D2(t,e,s){const r=new URL(e,t);if(s)for(const[l,u]of Object.entries(s))u!==void 0&&r.searchParams.set(l,u);return r.toString()}async function P2(t){return!t||t.type==="none"?{}:t.type==="bearer"?{Authorization:`Bearer ${t.token}`}:t.type==="header"?{[t.name]:t.value}:t.type==="custom"?await t.getHeaders():{}}function z2(t){const e=t.fetchImpl??globalThis.fetch;return{async request({method:s,path:r,query:l,body:u,headers:d}){const h=D2(t.baseUrl,r,l),m=await P2(t.auth),g=await e(h,{method:s,headers:{...u?{"Content-Type":"application/json"}:{},...m,...d},body:u?JSON.stringify(u):void 0}),y=await g.text(),x=(g.headers.get("content-type")||"").includes("application/json"),w=x&&y?JSON.parse(y):y;if(!g.ok){const S=x?w:void 0,E=S?.error;throw new Mo(E?.message??`Request failed with status ${g.status}`,{status:g.status,icebergType:E?.type,icebergCode:E?.code,details:S})}return{status:g.status,headers:g.headers,data:w}}}}function Ec(t){return t.join("")}var L2=class{constructor(t,e=""){this.client=t,this.prefix=e}async listNamespaces(t){const e=t?{parent:Ec(t.namespace)}:void 0;return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces`,query:e})).data.namespaces.map(r=>({namespace:r}))}async createNamespace(t,e){const s={namespace:t.namespace,properties:e?.properties};return(await this.client.request({method:"POST",path:`${this.prefix}/namespaces`,body:s})).data}async dropNamespace(t){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${Ec(t.namespace)}`})}async loadNamespaceMetadata(t){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Ec(t.namespace)}`})).data.properties}}async namespaceExists(t){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${Ec(t.namespace)}`}),!0}catch(e){if(e instanceof Mo&&e.status===404)return!1;throw e}}async createNamespaceIfNotExists(t,e){try{return await this.createNamespace(t,e)}catch(s){if(s instanceof Mo&&s.status===409)return;throw s}}};function Ir(t){return t.join("")}var U2=class{constructor(t,e="",s){this.client=t,this.prefix=e,this.accessDelegation=s}async listTables(t){return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Ir(t.namespace)}/tables`})).data.identifiers}async createTable(t,e){const s={};return this.accessDelegation&&(s["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${Ir(t.namespace)}/tables`,body:e,headers:s})).data.metadata}async updateTable(t,e){const s=await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${Ir(t.namespace)}/tables/${t.name}`,body:e});return{"metadata-location":s.data["metadata-location"],metadata:s.data.metadata}}async dropTable(t,e){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${Ir(t.namespace)}/tables/${t.name}`,query:{purgeRequested:String(e?.purge??!1)}})}async loadTable(t){const e={};return this.accessDelegation&&(e["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Ir(t.namespace)}/tables/${t.name}`,headers:e})).data.metadata}async tableExists(t){const e={};this.accessDelegation&&(e["X-Iceberg-Access-Delegation"]=this.accessDelegation);try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${Ir(t.namespace)}/tables/${t.name}`,headers:e}),!0}catch(s){if(s instanceof Mo&&s.status===404)return!1;throw s}}async createTableIfNotExists(t,e){try{return await this.createTable(t,e)}catch(s){if(s instanceof Mo&&s.status===409)return await this.loadTable({namespace:t.namespace,name:e.name});throw s}}},B2=class{constructor(t){let e="v1";t.catalogName&&(e+=`/${t.catalogName}`);const s=t.baseUrl.endsWith("/")?t.baseUrl:`${t.baseUrl}/`;this.client=z2({baseUrl:s,auth:t.auth,fetchImpl:t.fetch}),this.accessDelegation=t.accessDelegation?.join(","),this.namespaceOps=new L2(this.client,e),this.tableOps=new U2(this.client,e,this.accessDelegation)}async listNamespaces(t){return this.namespaceOps.listNamespaces(t)}async createNamespace(t,e){return this.namespaceOps.createNamespace(t,e)}async dropNamespace(t){await this.namespaceOps.dropNamespace(t)}async loadNamespaceMetadata(t){return this.namespaceOps.loadNamespaceMetadata(t)}async listTables(t){return this.tableOps.listTables(t)}async createTable(t,e){return this.tableOps.createTable(t,e)}async updateTable(t,e){return this.tableOps.updateTable(t,e)}async dropTable(t,e){await this.tableOps.dropTable(t,e)}async loadTable(t){return this.tableOps.loadTable(t)}async namespaceExists(t){return this.namespaceOps.namespaceExists(t)}async tableExists(t){return this.tableOps.tableExists(t)}async createNamespaceIfNotExists(t,e){return this.namespaceOps.createNamespaceIfNotExists(t,e)}async createTableIfNotExists(t,e){return this.tableOps.createTableIfNotExists(t,e)}},ju=class extends Error{constructor(t,e="storage",s,r){super(t),this.__isStorageError=!0,this.namespace=e,this.name=e==="vectors"?"StorageVectorsError":"StorageError",this.status=s,this.statusCode=r}};function _u(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}var kc=class extends ju{constructor(t,e,s,r="storage"){super(t,r,e,s),this.name=r==="vectors"?"StorageVectorsApiError":"StorageApiError",this.status=e,this.statusCode=s}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}},ow=class extends ju{constructor(t,e,s="storage"){super(t,s),this.name=s==="vectors"?"StorageVectorsUnknownError":"StorageUnknownError",this.originalError=e}};const V2=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),I2=t=>{if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},Ff=t=>{if(Array.isArray(t))return t.map(s=>Ff(s));if(typeof t=="function"||t!==Object(t))return t;const e={};return Object.entries(t).forEach(([s,r])=>{const l=s.replace(/([-_][a-z])/gi,u=>u.toUpperCase().replace(/[-_]/g,""));e[l]=Ff(r)}),e},$2=t=>!t||typeof t!="string"||t.length===0||t.length>100||t.trim()!==t||t.includes("/")||t.includes("\\")?!1:/^[\w!.\*'() &$@=;:+,?-]+$/.test(t);function Do(t){"@babel/helpers - typeof";return Do=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Do(t)}function q2(t,e){if(Do(t)!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var r=s.call(t,e);if(Do(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function H2(t){var e=q2(t,"string");return Do(e)=="symbol"?e:e+""}function G2(t,e,s){return(e=H2(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function qx(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(t,l).enumerable})),s.push.apply(s,r)}return s}function Ae(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?qx(Object(s),!0).forEach(function(r){G2(t,r,s[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):qx(Object(s)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(s,r))})}return t}const Hx=t=>{var e;return t.msg||t.message||t.error_description||(typeof t.error=="string"?t.error:(e=t.error)===null||e===void 0?void 0:e.message)||JSON.stringify(t)},F2=async(t,e,s,r)=>{if(t&&typeof t=="object"&&"status"in t&&"ok"in t&&typeof t.status=="number"&&!s?.noResolveJson){const l=t,u=l.status||500;if(typeof l.json=="function")l.json().then(d=>{const h=d?.statusCode||d?.code||u+"";e(new kc(Hx(d),u,h,r))}).catch(()=>{if(r==="vectors"){const d=u+"";e(new kc(l.statusText||`HTTP ${u} error`,u,d,r))}else{const d=u+"";e(new kc(l.statusText||`HTTP ${u} error`,u,d,r))}});else{const d=u+"";e(new kc(l.statusText||`HTTP ${u} error`,u,d,r))}}else e(new ow(Hx(t),t,r))},K2=(t,e,s,r)=>{const l={method:t,headers:e?.headers||{}};return t==="GET"||t==="HEAD"||!r?Ae(Ae({},l),s):(I2(r)?(l.headers=Ae({"Content-Type":"application/json"},e?.headers),l.body=JSON.stringify(r)):l.body=r,e?.duplex&&(l.duplex=e.duplex),Ae(Ae({},l),s))};async function yo(t,e,s,r,l,u,d){return new Promise((h,m)=>{t(s,K2(e,r,l,u)).then(g=>{if(!g.ok)throw g;if(r?.noResolveJson)return g;if(d==="vectors"){const y=g.headers.get("content-type");if(g.headers.get("content-length")==="0"||g.status===204)return{};if(!y||!y.includes("application/json"))return{}}return g.json()}).then(g=>h(g)).catch(g=>F2(g,m,r,d))})}function lw(t="storage"){return{get:async(e,s,r,l)=>yo(e,"GET",s,r,l,void 0,t),post:async(e,s,r,l,u)=>yo(e,"POST",s,l,u,r,t),put:async(e,s,r,l,u)=>yo(e,"PUT",s,l,u,r,t),head:async(e,s,r,l)=>yo(e,"HEAD",s,Ae(Ae({},r),{},{noResolveJson:!0}),l,void 0,t),remove:async(e,s,r,l,u)=>yo(e,"DELETE",s,l,u,r,t)}}const Y2=lw("storage"),{get:Po,post:Hn,put:Kf,head:X2,remove:Pm}=Y2,bn=lw("vectors");var gi=class{constructor(t,e={},s,r="storage"){this.shouldThrowOnError=!1,this.url=t,this.headers=e,this.fetch=V2(s),this.namespace=r}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,e){return this.headers=Ae(Ae({},this.headers),{},{[t]:e}),this}async handleOperation(t){var e=this;try{return{data:await t(),error:null}}catch(s){if(e.shouldThrowOnError)throw s;if(_u(s))return{data:null,error:s};throw s}}},W2=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e}then(t,e){return this.execute().then(t,e)}async execute(){var t=this;try{return{data:(await t.downloadFn()).body,error:null}}catch(e){if(t.shouldThrowOnError)throw e;if(_u(e))return{data:null,error:e};throw e}}};let cw;cw=Symbol.toStringTag;var J2=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e,this[cw]="BlobDownloadBuilder",this.promise=null}asStream(){return new W2(this.downloadFn,this.shouldThrowOnError)}then(t,e){return this.getPromise().then(t,e)}catch(t){return this.getPromise().catch(t)}finally(t){return this.getPromise().finally(t)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){var t=this;try{return{data:await(await t.downloadFn()).blob(),error:null}}catch(e){if(t.shouldThrowOnError)throw e;if(_u(e))return{data:null,error:e};throw e}}};const Q2={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},Gx={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var Z2=class extends gi{constructor(t,e={},s,r){super(t,e,r,"storage"),this.bucketId=s}async uploadOrUpdate(t,e,s,r){var l=this;return l.handleOperation(async()=>{let u;const d=Ae(Ae({},Gx),r);let h=Ae(Ae({},l.headers),t==="POST"&&{"x-upsert":String(d.upsert)});const m=d.metadata;typeof Blob<"u"&&s instanceof Blob?(u=new FormData,u.append("cacheControl",d.cacheControl),m&&u.append("metadata",l.encodeMetadata(m)),u.append("",s)):typeof FormData<"u"&&s instanceof FormData?(u=s,u.has("cacheControl")||u.append("cacheControl",d.cacheControl),m&&!u.has("metadata")&&u.append("metadata",l.encodeMetadata(m))):(u=s,h["cache-control"]=`max-age=${d.cacheControl}`,h["content-type"]=d.contentType,m&&(h["x-metadata"]=l.toBase64(l.encodeMetadata(m))),(typeof ReadableStream<"u"&&u instanceof ReadableStream||u&&typeof u=="object"&&"pipe"in u&&typeof u.pipe=="function")&&!d.duplex&&(d.duplex="half")),r?.headers&&(h=Ae(Ae({},h),r.headers));const g=l._removeEmptyFolders(e),y=l._getFinalPath(g),x=await(t=="PUT"?Kf:Hn)(l.fetch,`${l.url}/object/${y}`,u,Ae({headers:h},d?.duplex?{duplex:d.duplex}:{}));return{path:g,id:x.Id,fullPath:x.Key}})}async upload(t,e,s){return this.uploadOrUpdate("POST",t,e,s)}async uploadToSignedUrl(t,e,s,r){var l=this;const u=l._removeEmptyFolders(t),d=l._getFinalPath(u),h=new URL(l.url+`/object/upload/sign/${d}`);return h.searchParams.set("token",e),l.handleOperation(async()=>{let m;const g=Ae({upsert:Gx.upsert},r),y=Ae(Ae({},l.headers),{"x-upsert":String(g.upsert)});return typeof Blob<"u"&&s instanceof Blob?(m=new FormData,m.append("cacheControl",g.cacheControl),m.append("",s)):typeof FormData<"u"&&s instanceof FormData?(m=s,m.append("cacheControl",g.cacheControl)):(m=s,y["cache-control"]=`max-age=${g.cacheControl}`,y["content-type"]=g.contentType),{path:u,fullPath:(await Kf(l.fetch,h.toString(),m,{headers:y})).Key}})}async createSignedUploadUrl(t,e){var s=this;return s.handleOperation(async()=>{let r=s._getFinalPath(t);const l=Ae({},s.headers);e?.upsert&&(l["x-upsert"]="true");const u=await Hn(s.fetch,`${s.url}/object/upload/sign/${r}`,{},{headers:l}),d=new URL(s.url+u.url),h=d.searchParams.get("token");if(!h)throw new ju("No token returned by API");return{signedUrl:d.toString(),path:t,token:h}})}async update(t,e,s){return this.uploadOrUpdate("PUT",t,e,s)}async move(t,e,s){var r=this;return r.handleOperation(async()=>await Hn(r.fetch,`${r.url}/object/move`,{bucketId:r.bucketId,sourceKey:t,destinationKey:e,destinationBucket:s?.destinationBucket},{headers:r.headers}))}async copy(t,e,s){var r=this;return r.handleOperation(async()=>({path:(await Hn(r.fetch,`${r.url}/object/copy`,{bucketId:r.bucketId,sourceKey:t,destinationKey:e,destinationBucket:s?.destinationBucket},{headers:r.headers})).Key}))}async createSignedUrl(t,e,s){var r=this;return r.handleOperation(async()=>{let l=r._getFinalPath(t),u=await Hn(r.fetch,`${r.url}/object/sign/${l}`,Ae({expiresIn:e},s?.transform?{transform:s.transform}:{}),{headers:r.headers});const d=s?.download?`&download=${s.download===!0?"":s.download}`:"";return{signedUrl:encodeURI(`${r.url}${u.signedURL}${d}`)}})}async createSignedUrls(t,e,s){var r=this;return r.handleOperation(async()=>{const l=await Hn(r.fetch,`${r.url}/object/sign/${r.bucketId}`,{expiresIn:e,paths:t},{headers:r.headers}),u=s?.download?`&download=${s.download===!0?"":s.download}`:"";return l.map(d=>Ae(Ae({},d),{},{signedUrl:d.signedURL?encodeURI(`${r.url}${d.signedURL}${u}`):null}))})}download(t,e,s){const r=typeof e?.transform<"u"?"render/image/authenticated":"object",l=this.transformOptsToQueryString(e?.transform||{}),u=l?`?${l}`:"",d=this._getFinalPath(t),h=()=>Po(this.fetch,`${this.url}/${r}/${d}${u}`,{headers:this.headers,noResolveJson:!0},s);return new J2(h,this.shouldThrowOnError)}async info(t){var e=this;const s=e._getFinalPath(t);return e.handleOperation(async()=>Ff(await Po(e.fetch,`${e.url}/object/info/${s}`,{headers:e.headers})))}async exists(t){var e=this;const s=e._getFinalPath(t);try{return await X2(e.fetch,`${e.url}/object/${s}`,{headers:e.headers}),{data:!0,error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(_u(r)&&r instanceof ow){const l=r.originalError;if([400,404].includes(l?.status))return{data:!1,error:r}}throw r}}getPublicUrl(t,e){const s=this._getFinalPath(t),r=[],l=e?.download?`download=${e.download===!0?"":e.download}`:"";l!==""&&r.push(l);const u=typeof e?.transform<"u"?"render/image":"object",d=this.transformOptsToQueryString(e?.transform||{});d!==""&&r.push(d);let h=r.join("&");return h!==""&&(h=`?${h}`),{data:{publicUrl:encodeURI(`${this.url}/${u}/public/${s}${h}`)}}}async remove(t){var e=this;return e.handleOperation(async()=>await Pm(e.fetch,`${e.url}/object/${e.bucketId}`,{prefixes:t},{headers:e.headers}))}async list(t,e,s){var r=this;return r.handleOperation(async()=>{const l=Ae(Ae(Ae({},Q2),e),{},{prefix:t||""});return await Hn(r.fetch,`${r.url}/object/list/${r.bucketId}`,l,{headers:r.headers},s)})}async listV2(t,e){var s=this;return s.handleOperation(async()=>{const r=Ae({},t);return await Hn(s.fetch,`${s.url}/object/list-v2/${s.bucketId}`,r,{headers:s.headers},e)})}encodeMetadata(t){return JSON.stringify(t)}toBase64(t){return typeof Buffer<"u"?Buffer.from(t).toString("base64"):btoa(t)}_getFinalPath(t){return`${this.bucketId}/${t.replace(/^\/+/,"")}`}_removeEmptyFolders(t){return t.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(t){const e=[];return t.width&&e.push(`width=${t.width}`),t.height&&e.push(`height=${t.height}`),t.resize&&e.push(`resize=${t.resize}`),t.format&&e.push(`format=${t.format}`),t.quality&&e.push(`quality=${t.quality}`),e.join("&")}};const eT="2.97.0",Wo={"X-Client-Info":`storage-js/${eT}`};var tT=class extends gi{constructor(t,e={},s,r){const l=new URL(t);r?.useNewHostname&&/supabase\.(co|in|red)$/.test(l.hostname)&&!l.hostname.includes("storage.supabase.")&&(l.hostname=l.hostname.replace("supabase.","storage.supabase."));const u=l.href.replace(/\/$/,""),d=Ae(Ae({},Wo),e);super(u,d,s,"storage")}async listBuckets(t){var e=this;return e.handleOperation(async()=>{const s=e.listBucketOptionsToQueryString(t);return await Po(e.fetch,`${e.url}/bucket${s}`,{headers:e.headers})})}async getBucket(t){var e=this;return e.handleOperation(async()=>await Po(e.fetch,`${e.url}/bucket/${t}`,{headers:e.headers}))}async createBucket(t,e={public:!1}){var s=this;return s.handleOperation(async()=>await Hn(s.fetch,`${s.url}/bucket`,{id:t,name:t,type:e.type,public:e.public,file_size_limit:e.fileSizeLimit,allowed_mime_types:e.allowedMimeTypes},{headers:s.headers}))}async updateBucket(t,e){var s=this;return s.handleOperation(async()=>await Kf(s.fetch,`${s.url}/bucket/${t}`,{id:t,name:t,public:e.public,file_size_limit:e.fileSizeLimit,allowed_mime_types:e.allowedMimeTypes},{headers:s.headers}))}async emptyBucket(t){var e=this;return e.handleOperation(async()=>await Hn(e.fetch,`${e.url}/bucket/${t}/empty`,{},{headers:e.headers}))}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await Pm(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}))}listBucketOptionsToQueryString(t){const e={};return t&&("limit"in t&&(e.limit=String(t.limit)),"offset"in t&&(e.offset=String(t.offset)),t.search&&(e.search=t.search),t.sortColumn&&(e.sortColumn=t.sortColumn),t.sortOrder&&(e.sortOrder=t.sortOrder)),Object.keys(e).length>0?"?"+new URLSearchParams(e).toString():""}},nT=class extends gi{constructor(t,e={},s){const r=t.replace(/\/$/,""),l=Ae(Ae({},Wo),e);super(r,l,s,"storage")}async createBucket(t){var e=this;return e.handleOperation(async()=>await Hn(e.fetch,`${e.url}/bucket`,{name:t},{headers:e.headers}))}async listBuckets(t){var e=this;return e.handleOperation(async()=>{const s=new URLSearchParams;t?.limit!==void 0&&s.set("limit",t.limit.toString()),t?.offset!==void 0&&s.set("offset",t.offset.toString()),t?.sortColumn&&s.set("sortColumn",t.sortColumn),t?.sortOrder&&s.set("sortOrder",t.sortOrder),t?.search&&s.set("search",t.search);const r=s.toString(),l=r?`${e.url}/bucket?${r}`:`${e.url}/bucket`;return await Po(e.fetch,l,{headers:e.headers})})}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await Pm(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}))}from(t){var e=this;if(!$2(t))throw new ju("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 s=new B2({baseUrl:this.url,catalogName:t,auth:{type:"custom",getHeaders:async()=>e.headers},fetch:this.fetch}),r=this.shouldThrowOnError;return new Proxy(s,{get(l,u){const d=l[u];return typeof d!="function"?d:async(...h)=>{try{return{data:await d.apply(l,h),error:null}}catch(m){if(r)throw m;return{data:null,error:m}}}}})}},sT=class extends gi{constructor(t,e={},s){const r=t.replace(/\/$/,""),l=Ae(Ae({},Wo),{},{"Content-Type":"application/json"},e);super(r,l,s,"vectors")}async createIndex(t){var e=this;return e.handleOperation(async()=>await bn.post(e.fetch,`${e.url}/CreateIndex`,t,{headers:e.headers})||{})}async getIndex(t,e){var s=this;return s.handleOperation(async()=>await bn.post(s.fetch,`${s.url}/GetIndex`,{vectorBucketName:t,indexName:e},{headers:s.headers}))}async listIndexes(t){var e=this;return e.handleOperation(async()=>await bn.post(e.fetch,`${e.url}/ListIndexes`,t,{headers:e.headers}))}async deleteIndex(t,e){var s=this;return s.handleOperation(async()=>await bn.post(s.fetch,`${s.url}/DeleteIndex`,{vectorBucketName:t,indexName:e},{headers:s.headers})||{})}},aT=class extends gi{constructor(t,e={},s){const r=t.replace(/\/$/,""),l=Ae(Ae({},Wo),{},{"Content-Type":"application/json"},e);super(r,l,s,"vectors")}async putVectors(t){var e=this;if(t.vectors.length<1||t.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return e.handleOperation(async()=>await bn.post(e.fetch,`${e.url}/PutVectors`,t,{headers:e.headers})||{})}async getVectors(t){var e=this;return e.handleOperation(async()=>await bn.post(e.fetch,`${e.url}/GetVectors`,t,{headers:e.headers}))}async listVectors(t){var e=this;if(t.segmentCount!==void 0){if(t.segmentCount<1||t.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");if(t.segmentIndex!==void 0&&(t.segmentIndex<0||t.segmentIndex>=t.segmentCount))throw new Error(`segmentIndex must be between 0 and ${t.segmentCount-1}`)}return e.handleOperation(async()=>await bn.post(e.fetch,`${e.url}/ListVectors`,t,{headers:e.headers}))}async queryVectors(t){var e=this;return e.handleOperation(async()=>await bn.post(e.fetch,`${e.url}/QueryVectors`,t,{headers:e.headers}))}async deleteVectors(t){var e=this;if(t.keys.length<1||t.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return e.handleOperation(async()=>await bn.post(e.fetch,`${e.url}/DeleteVectors`,t,{headers:e.headers})||{})}},rT=class extends gi{constructor(t,e={},s){const r=t.replace(/\/$/,""),l=Ae(Ae({},Wo),{},{"Content-Type":"application/json"},e);super(r,l,s,"vectors")}async createBucket(t){var e=this;return e.handleOperation(async()=>await bn.post(e.fetch,`${e.url}/CreateVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{})}async getBucket(t){var e=this;return e.handleOperation(async()=>await bn.post(e.fetch,`${e.url}/GetVectorBucket`,{vectorBucketName:t},{headers:e.headers}))}async listBuckets(t={}){var e=this;return e.handleOperation(async()=>await bn.post(e.fetch,`${e.url}/ListVectorBuckets`,t,{headers:e.headers}))}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await bn.post(e.fetch,`${e.url}/DeleteVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{})}},iT=class extends rT{constructor(t,e={}){super(t,e.headers||{},e.fetch)}from(t){return new oT(this.url,this.headers,t,this.fetch)}async createBucket(t){var e=()=>super.createBucket,s=this;return e().call(s,t)}async getBucket(t){var e=()=>super.getBucket,s=this;return e().call(s,t)}async listBuckets(t={}){var e=()=>super.listBuckets,s=this;return e().call(s,t)}async deleteBucket(t){var e=()=>super.deleteBucket,s=this;return e().call(s,t)}},oT=class extends sT{constructor(t,e,s,r){super(t,e,r),this.vectorBucketName=s}async createIndex(t){var e=()=>super.createIndex,s=this;return e().call(s,Ae(Ae({},t),{},{vectorBucketName:s.vectorBucketName}))}async listIndexes(t={}){var e=()=>super.listIndexes,s=this;return e().call(s,Ae(Ae({},t),{},{vectorBucketName:s.vectorBucketName}))}async getIndex(t){var e=()=>super.getIndex,s=this;return e().call(s,s.vectorBucketName,t)}async deleteIndex(t){var e=()=>super.deleteIndex,s=this;return e().call(s,s.vectorBucketName,t)}index(t){return new lT(this.url,this.headers,this.vectorBucketName,t,this.fetch)}},lT=class extends aT{constructor(t,e,s,r,l){super(t,e,l),this.vectorBucketName=s,this.indexName=r}async putVectors(t){var e=()=>super.putVectors,s=this;return e().call(s,Ae(Ae({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}async getVectors(t){var e=()=>super.getVectors,s=this;return e().call(s,Ae(Ae({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}async listVectors(t={}){var e=()=>super.listVectors,s=this;return e().call(s,Ae(Ae({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}async queryVectors(t){var e=()=>super.queryVectors,s=this;return e().call(s,Ae(Ae({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}async deleteVectors(t){var e=()=>super.deleteVectors,s=this;return e().call(s,Ae(Ae({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}},cT=class extends tT{constructor(t,e={},s,r){super(t,e,s,r)}from(t){return new Z2(this.url,this.headers,t,this.fetch)}get vectors(){return new iT(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new nT(this.url+"/iceberg",this.headers,this.fetch)}};const uw="2.97.0",Jr=30*1e3,Yf=3,rf=Yf*Jr,uT="http://localhost:9999",dT="supabase.auth.token",hT={"X-Client-Info":`gotrue-js/${uw}`},Xf="X-Supabase-Api-Version",dw={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},fT=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,mT=600*1e3;class zo extends Error{constructor(e,s,r){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=s,this.code=r}}function Ne(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class pT extends zo{constructor(e,s,r){super(e,s,r),this.name="AuthApiError",this.status=s,this.code=r}}function gT(t){return Ne(t)&&t.name==="AuthApiError"}class Ga extends zo{constructor(e,s){super(e),this.name="AuthUnknownError",this.originalError=s}}class Rs extends zo{constructor(e,s,r,l){super(e,r,l),this.name=s,this.status=r}}class xn extends Rs{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function of(t){return Ne(t)&&t.name==="AuthSessionMissingError"}class $r extends Rs{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class Cc extends Rs{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class Ac extends Rs{constructor(e,s=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=s}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function yT(t){return Ne(t)&&t.name==="AuthImplicitGrantRedirectError"}class Fx extends Rs{constructor(e,s=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=s}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class vT extends Rs{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 Wf extends Rs{constructor(e,s){super(e,"AuthRetryableFetchError",s,void 0)}}function lf(t){return Ne(t)&&t.name==="AuthRetryableFetchError"}class Kx extends Rs{constructor(e,s,r){super(e,"AuthWeakPasswordError",s,"weak_password"),this.reasons=r}}class Jf extends Rs{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const su="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),Yx=`
|
|
35
|
-
\r=`.split(""),xT=(()=>{const t=new Array(128);for(let e=0;e<t.length;e+=1)t[e]=-1;for(let e=0;e<Yx.length;e+=1)t[Yx[e].charCodeAt(0)]=-2;for(let e=0;e<su.length;e+=1)t[su[e].charCodeAt(0)]=e;return t})();function Xx(t,e,s){if(t!==null)for(e.queue=e.queue<<8|t,e.queuedBits+=8;e.queuedBits>=6;){const r=e.queue>>e.queuedBits-6&63;s(su[r]),e.queuedBits-=6}else if(e.queuedBits>0)for(e.queue=e.queue<<6-e.queuedBits,e.queuedBits=6;e.queuedBits>=6;){const r=e.queue>>e.queuedBits-6&63;s(su[r]),e.queuedBits-=6}}function hw(t,e,s){const r=xT[t];if(r>-1)for(e.queue=e.queue<<6|r,e.queuedBits+=6;e.queuedBits>=8;)s(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(r===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function Wx(t){const e=[],s=d=>{e.push(String.fromCodePoint(d))},r={utf8seq:0,codepoint:0},l={queue:0,queuedBits:0},u=d=>{ST(d,r,s)};for(let d=0;d<t.length;d+=1)hw(t.charCodeAt(d),l,u);return e.join("")}function bT(t,e){if(t<=127){e(t);return}else if(t<=2047){e(192|t>>6),e(128|t&63);return}else if(t<=65535){e(224|t>>12),e(128|t>>6&63),e(128|t&63);return}else if(t<=1114111){e(240|t>>18),e(128|t>>12&63),e(128|t>>6&63),e(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function wT(t,e){for(let s=0;s<t.length;s+=1){let r=t.charCodeAt(s);if(r>55295&&r<=56319){const l=(r-55296)*1024&65535;r=(t.charCodeAt(s+1)-56320&65535|l)+65536,s+=1}bT(r,e)}}function ST(t,e,s){if(e.utf8seq===0){if(t<=127){s(t);return}for(let r=1;r<6;r+=1)if((t>>7-r&1)===0){e.utf8seq=r;break}if(e.utf8seq===2)e.codepoint=t&31;else if(e.utf8seq===3)e.codepoint=t&15;else if(e.utf8seq===4)e.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|t&63,e.utf8seq-=1,e.utf8seq===0&&s(e.codepoint)}}function oi(t){const e=[],s={queue:0,queuedBits:0},r=l=>{e.push(l)};for(let l=0;l<t.length;l+=1)hw(t.charCodeAt(l),s,r);return new Uint8Array(e)}function jT(t){const e=[];return wT(t,s=>e.push(s)),new Uint8Array(e)}function Fa(t){const e=[],s={queue:0,queuedBits:0},r=l=>{e.push(l)};return t.forEach(l=>Xx(l,s,r)),Xx(null,s,r),e.join("")}function _T(t){return Math.round(Date.now()/1e3)+t}function NT(){return Symbol("auth-callback")}const Gt=()=>typeof window<"u"&&typeof document<"u",La={tested:!1,writable:!1},fw=()=>{if(!Gt())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(La.tested)return La.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),La.tested=!0,La.writable=!0}catch{La.tested=!0,La.writable=!1}return La.writable};function TT(t){const e={},s=new URL(t);if(s.hash&&s.hash[0]==="#")try{new URLSearchParams(s.hash.substring(1)).forEach((l,u)=>{e[u]=l})}catch{}return s.searchParams.forEach((r,l)=>{e[l]=r}),e}const mw=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),ET=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",Qr=async(t,e,s)=>{await t.setItem(e,JSON.stringify(s))},Ua=async(t,e)=>{const s=await t.getItem(e);if(!s)return null;try{return JSON.parse(s)}catch{return s}},Ht=async(t,e)=>{await t.removeItem(e)};class Nu{constructor(){this.promise=new Nu.promiseConstructor((e,s)=>{this.resolve=e,this.reject=s})}}Nu.promiseConstructor=Promise;function Rc(t){const e=t.split(".");if(e.length!==3)throw new Jf("Invalid JWT structure");for(let r=0;r<e.length;r++)if(!fT.test(e[r]))throw new Jf("JWT not in base64url format");return{header:JSON.parse(Wx(e[0])),payload:JSON.parse(Wx(e[1])),signature:oi(e[2]),raw:{header:e[0],payload:e[1]}}}async function kT(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}function CT(t,e){return new Promise((r,l)=>{(async()=>{for(let u=0;u<1/0;u++)try{const d=await t(u);if(!e(u,null,d)){r(d);return}}catch(d){if(!e(u,d)){l(d);return}}})()})}function AT(t){return("0"+t.toString(16)).substr(-2)}function RT(){const e=new Uint32Array(56);if(typeof crypto>"u"){const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",r=s.length;let l="";for(let u=0;u<56;u++)l+=s.charAt(Math.floor(Math.random()*r));return l}return crypto.getRandomValues(e),Array.from(e,AT).join("")}async function OT(t){const s=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",s),l=new Uint8Array(r);return Array.from(l).map(u=>String.fromCharCode(u)).join("")}async function MT(t){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),t;const s=await OT(t);return btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function qr(t,e,s=!1){const r=RT();let l=r;s&&(l+="/PASSWORD_RECOVERY"),await Qr(t,`${e}-code-verifier`,l);const u=await MT(r);return[u,r===u?"plain":"s256"]}const DT=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function PT(t){const e=t.headers.get(Xf);if(!e||!e.match(DT))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function zT(t){if(!t)throw new Error("Missing exp claim");const e=Math.floor(Date.now()/1e3);if(t<=e)throw new Error("JWT has expired")}function LT(t){switch(t){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const UT=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function Hr(t){if(!UT.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function cf(){const t={};return new Proxy(t,{get:(e,s)=>{if(s==="__isUserNotAvailableProxy")return!0;if(typeof s=="symbol"){const r=s.toString();if(r==="Symbol(Symbol.toPrimitive)"||r==="Symbol(Symbol.toStringTag)"||r==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${s}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,s)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${s}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,s)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${s}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function BT(t,e){return new Proxy(t,{get:(s,r,l)=>{if(r==="__isInsecureUserWarningProxy")return!0;if(typeof r=="symbol"){const u=r.toString();if(u==="Symbol(Symbol.toPrimitive)"||u==="Symbol(Symbol.toStringTag)"||u==="Symbol(util.inspect.custom)"||u==="Symbol(nodejs.util.inspect.custom)")return Reflect.get(s,r,l)}return!e.value&&typeof r=="string"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),e.value=!0),Reflect.get(s,r,l)}})}function Jx(t){return JSON.parse(JSON.stringify(t))}const $a=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),VT=[502,503,504];async function Qx(t){var e;if(!ET(t))throw new Wf($a(t),0);if(VT.includes(t.status))throw new Wf($a(t),t.status);let s;try{s=await t.json()}catch(u){throw new Ga($a(u),u)}let r;const l=PT(t);if(l&&l.getTime()>=dw["2024-01-01"].timestamp&&typeof s=="object"&&s&&typeof s.code=="string"?r=s.code:typeof s=="object"&&s&&typeof s.error_code=="string"&&(r=s.error_code),r){if(r==="weak_password")throw new Kx($a(s),t.status,((e=s.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(r==="session_not_found")throw new xn}else if(typeof s=="object"&&s&&typeof s.weak_password=="object"&&s.weak_password&&Array.isArray(s.weak_password.reasons)&&s.weak_password.reasons.length&&s.weak_password.reasons.reduce((u,d)=>u&&typeof d=="string",!0))throw new Kx($a(s),t.status,s.weak_password.reasons);throw new pT($a(s),t.status||500,r)}const IT=(t,e,s,r)=>{const l={method:t,headers:e?.headers||{}};return t==="GET"?l:(l.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e?.headers),l.body=JSON.stringify(r),Object.assign(Object.assign({},l),s))};async function Re(t,e,s,r){var l;const u=Object.assign({},r?.headers);u[Xf]||(u[Xf]=dw["2024-01-01"].name),r?.jwt&&(u.Authorization=`Bearer ${r.jwt}`);const d=(l=r?.query)!==null&&l!==void 0?l:{};r?.redirectTo&&(d.redirect_to=r.redirectTo);const h=Object.keys(d).length?"?"+new URLSearchParams(d).toString():"",m=await $T(t,e,s+h,{headers:u,noResolveJson:r?.noResolveJson},{},r?.body);return r?.xform?r?.xform(m):{data:Object.assign({},m),error:null}}async function $T(t,e,s,r,l,u){const d=IT(e,r,l,u);let h;try{h=await t(s,Object.assign({},d))}catch(m){throw console.error(m),new Wf($a(m),0)}if(h.ok||await Qx(h),r?.noResolveJson)return h;try{return await h.json()}catch(m){await Qx(m)}}function $n(t){var e;let s=null;GT(t)&&(s=Object.assign({},t),t.expires_at||(s.expires_at=_T(t.expires_in)));const r=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:s,user:r},error:null}}function Zx(t){const e=$n(t);return!e.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((s,r)=>s&&typeof r=="string",!0)&&(e.data.weak_password=t.weak_password),e}function ua(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function qT(t){return{data:t,error:null}}function HT(t){const{action_link:e,email_otp:s,hashed_token:r,redirect_to:l,verification_type:u}=t,d=pi(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),h={action_link:e,email_otp:s,hashed_token:r,redirect_to:l,verification_type:u},m=Object.assign({},d);return{data:{properties:h,user:m},error:null}}function e0(t){return t}function GT(t){return t.access_token&&t.refresh_token&&t.expires_in}const uf=["global","local","others"];class FT{constructor({url:e="",headers:s={},fetch:r}){this.url=e,this.headers=s,this.fetch=mw(r),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),updateClient:this._updateOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)}}async signOut(e,s=uf[0]){if(uf.indexOf(s)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${uf.join(", ")}`);try{return await Re(this.fetch,"POST",`${this.url}/logout?scope=${s}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(r){if(Ne(r))return{data:null,error:r};throw r}}async inviteUserByEmail(e,s={}){try{return await Re(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:s.data},headers:this.headers,redirectTo:s.redirectTo,xform:ua})}catch(r){if(Ne(r))return{data:{user:null},error:r};throw r}}async generateLink(e){try{const{options:s}=e,r=pi(e,["options"]),l=Object.assign(Object.assign({},r),s);return"newEmail"in r&&(l.new_email=r?.newEmail,delete l.newEmail),await Re(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:l,headers:this.headers,xform:HT,redirectTo:s?.redirectTo})}catch(s){if(Ne(s))return{data:{properties:null,user:null},error:s};throw s}}async createUser(e){try{return await Re(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:ua})}catch(s){if(Ne(s))return{data:{user:null},error:s};throw s}}async listUsers(e){var s,r,l,u,d,h,m;try{const g={nextPage:null,lastPage:0,total:0},y=await Re(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(s=e?.page)===null||s===void 0?void 0:s.toString())!==null&&r!==void 0?r:"",per_page:(u=(l=e?.perPage)===null||l===void 0?void 0:l.toString())!==null&&u!==void 0?u:""},xform:e0});if(y.error)throw y.error;const x=await y.json(),w=(d=y.headers.get("x-total-count"))!==null&&d!==void 0?d:0,S=(m=(h=y.headers.get("link"))===null||h===void 0?void 0:h.split(","))!==null&&m!==void 0?m:[];return S.length>0&&(S.forEach(E=>{const j=parseInt(E.split(";")[0].split("=")[1].substring(0,1)),_=JSON.parse(E.split(";")[1].split("=")[1]);g[`${_}Page`]=j}),g.total=parseInt(w)),{data:Object.assign(Object.assign({},x),g),error:null}}catch(g){if(Ne(g))return{data:{users:[]},error:g};throw g}}async getUserById(e){Hr(e);try{return await Re(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:ua})}catch(s){if(Ne(s))return{data:{user:null},error:s};throw s}}async updateUserById(e,s){Hr(e);try{return await Re(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:s,headers:this.headers,xform:ua})}catch(r){if(Ne(r))return{data:{user:null},error:r};throw r}}async deleteUser(e,s=!1){Hr(e);try{return await Re(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:s},xform:ua})}catch(r){if(Ne(r))return{data:{user:null},error:r};throw r}}async _listFactors(e){Hr(e.userId);try{const{data:s,error:r}=await Re(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:l=>({data:{factors:l},error:null})});return{data:s,error:r}}catch(s){if(Ne(s))return{data:null,error:s};throw s}}async _deleteFactor(e){Hr(e.userId),Hr(e.id);try{return{data:await Re(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(s){if(Ne(s))return{data:null,error:s};throw s}}async _listOAuthClients(e){var s,r,l,u,d,h,m;try{const g={nextPage:null,lastPage:0,total:0},y=await Re(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(s=e?.page)===null||s===void 0?void 0:s.toString())!==null&&r!==void 0?r:"",per_page:(u=(l=e?.perPage)===null||l===void 0?void 0:l.toString())!==null&&u!==void 0?u:""},xform:e0});if(y.error)throw y.error;const x=await y.json(),w=(d=y.headers.get("x-total-count"))!==null&&d!==void 0?d:0,S=(m=(h=y.headers.get("link"))===null||h===void 0?void 0:h.split(","))!==null&&m!==void 0?m:[];return S.length>0&&(S.forEach(E=>{const j=parseInt(E.split(";")[0].split("=")[1].substring(0,1)),_=JSON.parse(E.split(";")[1].split("=")[1]);g[`${_}Page`]=j}),g.total=parseInt(w)),{data:Object.assign(Object.assign({},x),g),error:null}}catch(g){if(Ne(g))return{data:{clients:[]},error:g};throw g}}async _createOAuthClient(e){try{return await Re(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(Ne(s))return{data:null,error:s};throw s}}async _getOAuthClient(e){try{return await Re(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(Ne(s))return{data:null,error:s};throw s}}async _updateOAuthClient(e,s){try{return await Re(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${e}`,{body:s,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Ne(r))return{data:null,error:r};throw r}}async _deleteOAuthClient(e){try{return await Re(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(s){if(Ne(s))return{data:null,error:s};throw s}}async _regenerateOAuthClientSecret(e){try{return await Re(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(Ne(s))return{data:null,error:s};throw s}}}function t0(t={}){return{getItem:e=>t[e]||null,setItem:(e,s)=>{t[e]=s},removeItem:e=>{delete t[e]}}}const Gr={debug:!!(globalThis&&fw()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class pw extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class n0 extends pw{}async function KT(t,e,s){Gr.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const r=new globalThis.AbortController;e>0&&setTimeout(()=>{r.abort(),Gr.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},e),await Promise.resolve();try{return await globalThis.navigator.locks.request(t,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:r.signal},async l=>{if(l){Gr.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,l.name);try{return await s()}finally{Gr.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,l.name)}}else{if(e===0)throw Gr.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new n0(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(Gr.debug)try{const u=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(u,null," "))}catch(u){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",u)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await s()}})}catch(l){throw l?.name==="AbortError"?new n0(`Acquiring an exclusive Navigator LockManager lock "${t}" timed out waiting ${e}ms`):l}}function YT(){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 gw(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function XT(t){return parseInt(t,16)}function WT(t){const e=new TextEncoder().encode(t);return"0x"+Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")}function JT(t){var e;const{chainId:s,domain:r,expirationTime:l,issuedAt:u=new Date,nonce:d,notBefore:h,requestId:m,resources:g,scheme:y,uri:x,version:w}=t;{if(!Number.isInteger(s))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${s}`);if(!r)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(d&&d.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${d}`);if(!x)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(w!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${w}`);if(!((e=t.statement)===null||e===void 0)&&e.includes(`
|
|
36
|
-
`))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${t.statement}`)}const S=gw(t.address),E=y?`${y}://${
|
|
34
|
+
})`):new Error(`WebSocket not available: ${s}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:this.vsn}))}disconnect(e,s){if(!this.isDisconnecting())if(this._setConnectionState("disconnecting",!0),this.conn){const i=setTimeout(()=>{this._setConnectionState("disconnected")},100);this.conn.onclose=()=>{clearTimeout(i),this._setConnectionState("disconnected")},typeof this.conn.close=="function"&&(e?this.conn.close(e,s??""):this.conn.close()),this._teardownConnection()}else this._setConnectionState("disconnected")}getChannels(){return this.channels}async removeChannel(e){const s=await e.unsubscribe();return this.channels.length===0&&this.disconnect(),s}async removeAllChannels(){const e=await Promise.all(this.channels.map(s=>s.unsubscribe()));return this.channels=[],this.disconnect(),e}log(e,s,i){this.logger(e,s,i)}connectionState(){switch(this.conn&&this.conn.readyState){case ca.connecting:return Ha.Connecting;case ca.open:return Ha.Open;case ca.closing:return Ha.Closing;default:return Ha.Closed}}isConnected(){return this.connectionState()===Ha.Open}isConnecting(){return this._connectionState==="connecting"}isDisconnecting(){return this._connectionState==="disconnecting"}channel(e,s={config:{}}){const i=`realtime:${e}`,l=this.getChannels().find(u=>u.topic===i);if(l)return l;{const u=new er(`realtime:${e}`,s,this);return this.channels.push(u),u}}push(e){const{topic:s,event:i,payload:l,ref:u}=e,d=()=>{this.encode(e,h=>{var m;(m=this.conn)===null||m===void 0||m.send(h)})};this.log("push",`${s} ${i} (${u})`,l),this.isConnected()?d():this.sendBuffer.push(d)}async setAuth(e=null){this._authPromise=this._performAuth(e);try{await this._authPromise}finally{this._authPromise=null}}_isManualToken(){return this._manuallySetToken}async sendHeartbeat(){var e;if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(s){this.log("error","error in heartbeat callback",s)}return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this._heartbeatSentAt=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(s){this.log("error","error in heartbeat callback",s)}this._wasManualDisconnect=!1,(e=this.conn)===null||e===void 0||e.close(w2,"heartbeat timeout"),setTimeout(()=>{var s;this.isConnected()||(s=this.reconnectTimer)===null||s===void 0||s.scheduleTimeout()},Tc.HEARTBEAT_TIMEOUT_FALLBACK);return}this._heartbeatSentAt=Date.now(),this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(s){this.log("error","error in heartbeat callback",s)}this._setAuthSafely("heartbeat")}onHeartbeat(e){this.heartbeatCallback=e}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let s=this.channels.find(i=>i.topic===e&&(i._isJoined()||i._isJoining()));s&&(this.log("transport",`leaving duplicate topic "${e}"`),s.unsubscribe())}_remove(e){this.channels=this.channels.filter(s=>s.topic!==e.topic)}_onConnMessage(e){this.decode(e.data,s=>{if(s.topic==="phoenix"&&s.event==="phx_reply"&&s.ref&&s.ref===this.pendingHeartbeatRef){const g=this._heartbeatSentAt?Date.now()-this._heartbeatSentAt:void 0;try{this.heartbeatCallback(s.payload.status==="ok"?"ok":"error",g)}catch(y){this.log("error","error in heartbeat callback",y)}this._heartbeatSentAt=null,this.pendingHeartbeatRef=null}const{topic:i,event:l,payload:u,ref:d}=s,h=d?`(${d})`:"",m=u.status||"";this.log("receive",`${m} ${i} ${l} ${h}`.trim(),u),this.channels.filter(g=>g._isMember(i)).forEach(g=>g._trigger(l,u,d)),this._triggerStateCallbacks("message",s)})}_clearTimer(e){var s;e==="heartbeat"&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):e==="reconnect"&&((s=this.reconnectTimer)===null||s===void 0||s.reset())}_clearAllTimers(){this._clearTimer("heartbeat"),this._clearTimer("reconnect")}_setupConnectionHandlers(){this.conn&&("binaryType"in this.conn&&(this.conn.binaryType="arraybuffer"),this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e),this.conn.readyState===ca.open&&this._onConnOpen())}_teardownConnection(){if(this.conn){if(this.conn.readyState===ca.open||this.conn.readyState===ca.connecting)try{this.conn.close()}catch(e){this.log("error","Error closing connection",e)}this.conn.onopen=null,this.conn.onerror=null,this.conn.onmessage=null,this.conn.onclose=null,this.conn=null}this._clearAllTimers(),this._terminateWorker(),this.channels.forEach(e=>e.teardown())}_onConnOpen(){this._setConnectionState("connected"),this.log("transport",`connected to ${this.endpointURL()}`),(this._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve())).then(()=>{this.flushSendBuffer()}).catch(s=>{this.log("error","error waiting for auth on connect",s),this.flushSendBuffer()}),this._clearTimer("reconnect"),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this._triggerStateCallbacks("open")}_startHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=s=>{this.log("worker","worker error",s.message),this._terminateWorker()},this.workerRef.onmessage=s=>{s.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_terminateWorker(){this.workerRef&&(this.log("worker","terminating worker"),this.workerRef.terminate(),this.workerRef=void 0)}_onConnClose(e){var s;this._setConnectionState("disconnected"),this.log("transport","close",e),this._triggerChanError(),this._clearTimer("heartbeat"),this._wasManualDisconnect||(s=this.reconnectTimer)===null||s===void 0||s.scheduleTimeout(),this._triggerStateCallbacks("close",e)}_onConnError(e){this._setConnectionState("disconnected"),this.log("transport",`${e}`),this._triggerChanError(),this._triggerStateCallbacks("error",e);try{this.heartbeatCallback("error")}catch(s){this.log("error","error in heartbeat callback",s)}}_triggerChanError(){this.channels.forEach(e=>e._trigger(Gn.error))}_appendParams(e,s){if(Object.keys(s).length===0)return e;const i=e.match(/\?/)?"&":"?",l=new URLSearchParams(s);return`${e}${i}${l}`}_workerObjectUrl(e){let s;if(e)s=e;else{const i=new Blob([O2],{type:"application/javascript"});s=URL.createObjectURL(i)}return s}_setConnectionState(e,s=!1){this._connectionState=e,e==="connecting"?this._wasManualDisconnect=!1:e==="disconnecting"&&(this._wasManualDisconnect=s)}async _performAuth(e=null){let s,i=!1;if(e)s=e,i=!0;else if(this.accessToken)try{s=await this.accessToken()}catch(l){this.log("error","Error fetching access token from callback",l),s=this.accessTokenValue}else s=this.accessTokenValue;i?this._manuallySetToken=!0:this.accessToken&&(this._manuallySetToken=!1),this.accessTokenValue!=s&&(this.accessTokenValue=s,this.channels.forEach(l=>{const u={access_token:s,version:x2};s&&l.updateJoinPayload(u),l.joinedOnce&&l._isJoined()&&l._push(Gn.access_token,{access_token:s})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(e="general"){this._isManualToken()||this.setAuth().catch(s=>{this.log("error",`Error setting auth in ${e}`,s)})}_triggerStateCallbacks(e,s){try{this.stateChangeCallbacks[e].forEach(i=>{try{i(s)}catch(l){this.log("error",`error in ${e} callback`,l)}})}catch(i){this.log("error",`error triggering ${e} callbacks`,i)}}_setupReconnectionTimer(){this.reconnectTimer=new aw(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},Tc.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(e){var s,i,l,u,d,h,m,g,y,x,w,S;switch(this.transport=(s=e?.transport)!==null&&s!==void 0?s:null,this.timeout=(i=e?.timeout)!==null&&i!==void 0?i:qf,this.heartbeatIntervalMs=(l=e?.heartbeatIntervalMs)!==null&&l!==void 0?l:Tc.HEARTBEAT_INTERVAL,this.worker=(u=e?.worker)!==null&&u!==void 0?u:!1,this.accessToken=(d=e?.accessToken)!==null&&d!==void 0?d:null,this.heartbeatCallback=(h=e?.heartbeatCallback)!==null&&h!==void 0?h:af,this.vsn=(m=e?.vsn)!==null&&m!==void 0?m:Bx,e?.params&&(this.params=e.params),e?.logger&&(this.logger=e.logger),(e?.logLevel||e?.log_level)&&(this.logLevel=e.logLevel||e.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=(g=e?.reconnectAfterMs)!==null&&g!==void 0?g:(E=>A2[E-1]||R2),this.vsn){case b2:this.encode=(y=e?.encode)!==null&&y!==void 0?y:((E,j)=>j(JSON.stringify(E))),this.decode=(x=e?.decode)!==null&&x!==void 0?x:((E,j)=>j(JSON.parse(E)));break;case sw:this.encode=(w=e?.encode)!==null&&w!==void 0?w:this.serializer.encode.bind(this.serializer),this.decode=(S=e?.decode)!==null&&S!==void 0?S:this.serializer.decode.bind(this.serializer);break;default:throw new Error(`Unsupported serializer version: ${this.vsn}`)}if(this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=e?.workerUrl}}}var Mo=class extends Error{constructor(t,e){super(t),this.name="IcebergError",this.status=e.status,this.icebergType=e.icebergType,this.icebergCode=e.icebergCode,this.details=e.details,this.isCommitStateUnknown=e.icebergType==="CommitStateUnknownException"||[500,502,504].includes(e.status)&&e.icebergType?.includes("CommitState")===!0}isNotFound(){return this.status===404}isConflict(){return this.status===409}isAuthenticationTimeout(){return this.status===419}};function D2(t,e,s){const i=new URL(e,t);if(s)for(const[l,u]of Object.entries(s))u!==void 0&&i.searchParams.set(l,u);return i.toString()}async function P2(t){return!t||t.type==="none"?{}:t.type==="bearer"?{Authorization:`Bearer ${t.token}`}:t.type==="header"?{[t.name]:t.value}:t.type==="custom"?await t.getHeaders():{}}function z2(t){const e=t.fetchImpl??globalThis.fetch;return{async request({method:s,path:i,query:l,body:u,headers:d}){const h=D2(t.baseUrl,i,l),m=await P2(t.auth),g=await e(h,{method:s,headers:{...u?{"Content-Type":"application/json"}:{},...m,...d},body:u?JSON.stringify(u):void 0}),y=await g.text(),x=(g.headers.get("content-type")||"").includes("application/json"),w=x&&y?JSON.parse(y):y;if(!g.ok){const S=x?w:void 0,E=S?.error;throw new Mo(E?.message??`Request failed with status ${g.status}`,{status:g.status,icebergType:E?.type,icebergCode:E?.code,details:S})}return{status:g.status,headers:g.headers,data:w}}}}function Ec(t){return t.join("")}var L2=class{constructor(t,e=""){this.client=t,this.prefix=e}async listNamespaces(t){const e=t?{parent:Ec(t.namespace)}:void 0;return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces`,query:e})).data.namespaces.map(i=>({namespace:i}))}async createNamespace(t,e){const s={namespace:t.namespace,properties:e?.properties};return(await this.client.request({method:"POST",path:`${this.prefix}/namespaces`,body:s})).data}async dropNamespace(t){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${Ec(t.namespace)}`})}async loadNamespaceMetadata(t){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Ec(t.namespace)}`})).data.properties}}async namespaceExists(t){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${Ec(t.namespace)}`}),!0}catch(e){if(e instanceof Mo&&e.status===404)return!1;throw e}}async createNamespaceIfNotExists(t,e){try{return await this.createNamespace(t,e)}catch(s){if(s instanceof Mo&&s.status===409)return;throw s}}};function Ii(t){return t.join("")}var U2=class{constructor(t,e="",s){this.client=t,this.prefix=e,this.accessDelegation=s}async listTables(t){return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Ii(t.namespace)}/tables`})).data.identifiers}async createTable(t,e){const s={};return this.accessDelegation&&(s["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${Ii(t.namespace)}/tables`,body:e,headers:s})).data.metadata}async updateTable(t,e){const s=await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${Ii(t.namespace)}/tables/${t.name}`,body:e});return{"metadata-location":s.data["metadata-location"],metadata:s.data.metadata}}async dropTable(t,e){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${Ii(t.namespace)}/tables/${t.name}`,query:{purgeRequested:String(e?.purge??!1)}})}async loadTable(t){const e={};return this.accessDelegation&&(e["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Ii(t.namespace)}/tables/${t.name}`,headers:e})).data.metadata}async tableExists(t){const e={};this.accessDelegation&&(e["X-Iceberg-Access-Delegation"]=this.accessDelegation);try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${Ii(t.namespace)}/tables/${t.name}`,headers:e}),!0}catch(s){if(s instanceof Mo&&s.status===404)return!1;throw s}}async createTableIfNotExists(t,e){try{return await this.createTable(t,e)}catch(s){if(s instanceof Mo&&s.status===409)return await this.loadTable({namespace:t.namespace,name:e.name});throw s}}},B2=class{constructor(t){let e="v1";t.catalogName&&(e+=`/${t.catalogName}`);const s=t.baseUrl.endsWith("/")?t.baseUrl:`${t.baseUrl}/`;this.client=z2({baseUrl:s,auth:t.auth,fetchImpl:t.fetch}),this.accessDelegation=t.accessDelegation?.join(","),this.namespaceOps=new L2(this.client,e),this.tableOps=new U2(this.client,e,this.accessDelegation)}async listNamespaces(t){return this.namespaceOps.listNamespaces(t)}async createNamespace(t,e){return this.namespaceOps.createNamespace(t,e)}async dropNamespace(t){await this.namespaceOps.dropNamespace(t)}async loadNamespaceMetadata(t){return this.namespaceOps.loadNamespaceMetadata(t)}async listTables(t){return this.tableOps.listTables(t)}async createTable(t,e){return this.tableOps.createTable(t,e)}async updateTable(t,e){return this.tableOps.updateTable(t,e)}async dropTable(t,e){await this.tableOps.dropTable(t,e)}async loadTable(t){return this.tableOps.loadTable(t)}async namespaceExists(t){return this.namespaceOps.namespaceExists(t)}async tableExists(t){return this.tableOps.tableExists(t)}async createNamespaceIfNotExists(t,e){return this.namespaceOps.createNamespaceIfNotExists(t,e)}async createTableIfNotExists(t,e){return this.tableOps.createTableIfNotExists(t,e)}},ju=class extends Error{constructor(t,e="storage",s,i){super(t),this.__isStorageError=!0,this.namespace=e,this.name=e==="vectors"?"StorageVectorsError":"StorageError",this.status=s,this.statusCode=i}};function _u(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}var kc=class extends ju{constructor(t,e,s,i="storage"){super(t,i,e,s),this.name=i==="vectors"?"StorageVectorsApiError":"StorageApiError",this.status=e,this.statusCode=s}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}},ow=class extends ju{constructor(t,e,s="storage"){super(t,s),this.name=s==="vectors"?"StorageVectorsUnknownError":"StorageUnknownError",this.originalError=e}};const V2=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),I2=t=>{if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},Ff=t=>{if(Array.isArray(t))return t.map(s=>Ff(s));if(typeof t=="function"||t!==Object(t))return t;const e={};return Object.entries(t).forEach(([s,i])=>{const l=s.replace(/([-_][a-z])/gi,u=>u.toUpperCase().replace(/[-_]/g,""));e[l]=Ff(i)}),e},$2=t=>!t||typeof t!="string"||t.length===0||t.length>100||t.trim()!==t||t.includes("/")||t.includes("\\")?!1:/^[\w!.\*'() &$@=;:+,?-]+$/.test(t);function Do(t){"@babel/helpers - typeof";return Do=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Do(t)}function q2(t,e){if(Do(t)!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var i=s.call(t,e);if(Do(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function H2(t){var e=q2(t,"string");return Do(e)=="symbol"?e:e+""}function G2(t,e,s){return(e=H2(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function qx(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(l){return Object.getOwnPropertyDescriptor(t,l).enumerable})),s.push.apply(s,i)}return s}function Ae(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?qx(Object(s),!0).forEach(function(i){G2(t,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):qx(Object(s)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(s,i))})}return t}const Hx=t=>{var e;return t.msg||t.message||t.error_description||(typeof t.error=="string"?t.error:(e=t.error)===null||e===void 0?void 0:e.message)||JSON.stringify(t)},F2=async(t,e,s,i)=>{if(t&&typeof t=="object"&&"status"in t&&"ok"in t&&typeof t.status=="number"&&!s?.noResolveJson){const l=t,u=l.status||500;if(typeof l.json=="function")l.json().then(d=>{const h=d?.statusCode||d?.code||u+"";e(new kc(Hx(d),u,h,i))}).catch(()=>{if(i==="vectors"){const d=u+"";e(new kc(l.statusText||`HTTP ${u} error`,u,d,i))}else{const d=u+"";e(new kc(l.statusText||`HTTP ${u} error`,u,d,i))}});else{const d=u+"";e(new kc(l.statusText||`HTTP ${u} error`,u,d,i))}}else e(new ow(Hx(t),t,i))},K2=(t,e,s,i)=>{const l={method:t,headers:e?.headers||{}};return t==="GET"||t==="HEAD"||!i?Ae(Ae({},l),s):(I2(i)?(l.headers=Ae({"Content-Type":"application/json"},e?.headers),l.body=JSON.stringify(i)):l.body=i,e?.duplex&&(l.duplex=e.duplex),Ae(Ae({},l),s))};async function yo(t,e,s,i,l,u,d){return new Promise((h,m)=>{t(s,K2(e,i,l,u)).then(g=>{if(!g.ok)throw g;if(i?.noResolveJson)return g;if(d==="vectors"){const y=g.headers.get("content-type");if(g.headers.get("content-length")==="0"||g.status===204)return{};if(!y||!y.includes("application/json"))return{}}return g.json()}).then(g=>h(g)).catch(g=>F2(g,m,i,d))})}function lw(t="storage"){return{get:async(e,s,i,l)=>yo(e,"GET",s,i,l,void 0,t),post:async(e,s,i,l,u)=>yo(e,"POST",s,l,u,i,t),put:async(e,s,i,l,u)=>yo(e,"PUT",s,l,u,i,t),head:async(e,s,i,l)=>yo(e,"HEAD",s,Ae(Ae({},i),{},{noResolveJson:!0}),l,void 0,t),remove:async(e,s,i,l,u)=>yo(e,"DELETE",s,l,u,i,t)}}const Y2=lw("storage"),{get:Po,post:Hn,put:Kf,head:X2,remove:Pm}=Y2,bn=lw("vectors");var gr=class{constructor(t,e={},s,i="storage"){this.shouldThrowOnError=!1,this.url=t,this.headers=e,this.fetch=V2(s),this.namespace=i}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,e){return this.headers=Ae(Ae({},this.headers),{},{[t]:e}),this}async handleOperation(t){var e=this;try{return{data:await t(),error:null}}catch(s){if(e.shouldThrowOnError)throw s;if(_u(s))return{data:null,error:s};throw s}}},W2=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e}then(t,e){return this.execute().then(t,e)}async execute(){var t=this;try{return{data:(await t.downloadFn()).body,error:null}}catch(e){if(t.shouldThrowOnError)throw e;if(_u(e))return{data:null,error:e};throw e}}};let cw;cw=Symbol.toStringTag;var J2=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e,this[cw]="BlobDownloadBuilder",this.promise=null}asStream(){return new W2(this.downloadFn,this.shouldThrowOnError)}then(t,e){return this.getPromise().then(t,e)}catch(t){return this.getPromise().catch(t)}finally(t){return this.getPromise().finally(t)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){var t=this;try{return{data:await(await t.downloadFn()).blob(),error:null}}catch(e){if(t.shouldThrowOnError)throw e;if(_u(e))return{data:null,error:e};throw e}}};const Q2={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},Gx={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var Z2=class extends gr{constructor(t,e={},s,i){super(t,e,i,"storage"),this.bucketId=s}async uploadOrUpdate(t,e,s,i){var l=this;return l.handleOperation(async()=>{let u;const d=Ae(Ae({},Gx),i);let h=Ae(Ae({},l.headers),t==="POST"&&{"x-upsert":String(d.upsert)});const m=d.metadata;typeof Blob<"u"&&s instanceof Blob?(u=new FormData,u.append("cacheControl",d.cacheControl),m&&u.append("metadata",l.encodeMetadata(m)),u.append("",s)):typeof FormData<"u"&&s instanceof FormData?(u=s,u.has("cacheControl")||u.append("cacheControl",d.cacheControl),m&&!u.has("metadata")&&u.append("metadata",l.encodeMetadata(m))):(u=s,h["cache-control"]=`max-age=${d.cacheControl}`,h["content-type"]=d.contentType,m&&(h["x-metadata"]=l.toBase64(l.encodeMetadata(m))),(typeof ReadableStream<"u"&&u instanceof ReadableStream||u&&typeof u=="object"&&"pipe"in u&&typeof u.pipe=="function")&&!d.duplex&&(d.duplex="half")),i?.headers&&(h=Ae(Ae({},h),i.headers));const g=l._removeEmptyFolders(e),y=l._getFinalPath(g),x=await(t=="PUT"?Kf:Hn)(l.fetch,`${l.url}/object/${y}`,u,Ae({headers:h},d?.duplex?{duplex:d.duplex}:{}));return{path:g,id:x.Id,fullPath:x.Key}})}async upload(t,e,s){return this.uploadOrUpdate("POST",t,e,s)}async uploadToSignedUrl(t,e,s,i){var l=this;const u=l._removeEmptyFolders(t),d=l._getFinalPath(u),h=new URL(l.url+`/object/upload/sign/${d}`);return h.searchParams.set("token",e),l.handleOperation(async()=>{let m;const g=Ae({upsert:Gx.upsert},i),y=Ae(Ae({},l.headers),{"x-upsert":String(g.upsert)});return typeof Blob<"u"&&s instanceof Blob?(m=new FormData,m.append("cacheControl",g.cacheControl),m.append("",s)):typeof FormData<"u"&&s instanceof FormData?(m=s,m.append("cacheControl",g.cacheControl)):(m=s,y["cache-control"]=`max-age=${g.cacheControl}`,y["content-type"]=g.contentType),{path:u,fullPath:(await Kf(l.fetch,h.toString(),m,{headers:y})).Key}})}async createSignedUploadUrl(t,e){var s=this;return s.handleOperation(async()=>{let i=s._getFinalPath(t);const l=Ae({},s.headers);e?.upsert&&(l["x-upsert"]="true");const u=await Hn(s.fetch,`${s.url}/object/upload/sign/${i}`,{},{headers:l}),d=new URL(s.url+u.url),h=d.searchParams.get("token");if(!h)throw new ju("No token returned by API");return{signedUrl:d.toString(),path:t,token:h}})}async update(t,e,s){return this.uploadOrUpdate("PUT",t,e,s)}async move(t,e,s){var i=this;return i.handleOperation(async()=>await Hn(i.fetch,`${i.url}/object/move`,{bucketId:i.bucketId,sourceKey:t,destinationKey:e,destinationBucket:s?.destinationBucket},{headers:i.headers}))}async copy(t,e,s){var i=this;return i.handleOperation(async()=>({path:(await Hn(i.fetch,`${i.url}/object/copy`,{bucketId:i.bucketId,sourceKey:t,destinationKey:e,destinationBucket:s?.destinationBucket},{headers:i.headers})).Key}))}async createSignedUrl(t,e,s){var i=this;return i.handleOperation(async()=>{let l=i._getFinalPath(t),u=await Hn(i.fetch,`${i.url}/object/sign/${l}`,Ae({expiresIn:e},s?.transform?{transform:s.transform}:{}),{headers:i.headers});const d=s?.download?`&download=${s.download===!0?"":s.download}`:"";return{signedUrl:encodeURI(`${i.url}${u.signedURL}${d}`)}})}async createSignedUrls(t,e,s){var i=this;return i.handleOperation(async()=>{const l=await Hn(i.fetch,`${i.url}/object/sign/${i.bucketId}`,{expiresIn:e,paths:t},{headers:i.headers}),u=s?.download?`&download=${s.download===!0?"":s.download}`:"";return l.map(d=>Ae(Ae({},d),{},{signedUrl:d.signedURL?encodeURI(`${i.url}${d.signedURL}${u}`):null}))})}download(t,e,s){const i=typeof e?.transform<"u"?"render/image/authenticated":"object",l=this.transformOptsToQueryString(e?.transform||{}),u=l?`?${l}`:"",d=this._getFinalPath(t),h=()=>Po(this.fetch,`${this.url}/${i}/${d}${u}`,{headers:this.headers,noResolveJson:!0},s);return new J2(h,this.shouldThrowOnError)}async info(t){var e=this;const s=e._getFinalPath(t);return e.handleOperation(async()=>Ff(await Po(e.fetch,`${e.url}/object/info/${s}`,{headers:e.headers})))}async exists(t){var e=this;const s=e._getFinalPath(t);try{return await X2(e.fetch,`${e.url}/object/${s}`,{headers:e.headers}),{data:!0,error:null}}catch(i){if(e.shouldThrowOnError)throw i;if(_u(i)&&i instanceof ow){const l=i.originalError;if([400,404].includes(l?.status))return{data:!1,error:i}}throw i}}getPublicUrl(t,e){const s=this._getFinalPath(t),i=[],l=e?.download?`download=${e.download===!0?"":e.download}`:"";l!==""&&i.push(l);const u=typeof e?.transform<"u"?"render/image":"object",d=this.transformOptsToQueryString(e?.transform||{});d!==""&&i.push(d);let h=i.join("&");return h!==""&&(h=`?${h}`),{data:{publicUrl:encodeURI(`${this.url}/${u}/public/${s}${h}`)}}}async remove(t){var e=this;return e.handleOperation(async()=>await Pm(e.fetch,`${e.url}/object/${e.bucketId}`,{prefixes:t},{headers:e.headers}))}async list(t,e,s){var i=this;return i.handleOperation(async()=>{const l=Ae(Ae(Ae({},Q2),e),{},{prefix:t||""});return await Hn(i.fetch,`${i.url}/object/list/${i.bucketId}`,l,{headers:i.headers},s)})}async listV2(t,e){var s=this;return s.handleOperation(async()=>{const i=Ae({},t);return await Hn(s.fetch,`${s.url}/object/list-v2/${s.bucketId}`,i,{headers:s.headers},e)})}encodeMetadata(t){return JSON.stringify(t)}toBase64(t){return typeof Buffer<"u"?Buffer.from(t).toString("base64"):btoa(t)}_getFinalPath(t){return`${this.bucketId}/${t.replace(/^\/+/,"")}`}_removeEmptyFolders(t){return t.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(t){const e=[];return t.width&&e.push(`width=${t.width}`),t.height&&e.push(`height=${t.height}`),t.resize&&e.push(`resize=${t.resize}`),t.format&&e.push(`format=${t.format}`),t.quality&&e.push(`quality=${t.quality}`),e.join("&")}};const eT="2.97.0",Wo={"X-Client-Info":`storage-js/${eT}`};var tT=class extends gr{constructor(t,e={},s,i){const l=new URL(t);i?.useNewHostname&&/supabase\.(co|in|red)$/.test(l.hostname)&&!l.hostname.includes("storage.supabase.")&&(l.hostname=l.hostname.replace("supabase.","storage.supabase."));const u=l.href.replace(/\/$/,""),d=Ae(Ae({},Wo),e);super(u,d,s,"storage")}async listBuckets(t){var e=this;return e.handleOperation(async()=>{const s=e.listBucketOptionsToQueryString(t);return await Po(e.fetch,`${e.url}/bucket${s}`,{headers:e.headers})})}async getBucket(t){var e=this;return e.handleOperation(async()=>await Po(e.fetch,`${e.url}/bucket/${t}`,{headers:e.headers}))}async createBucket(t,e={public:!1}){var s=this;return s.handleOperation(async()=>await Hn(s.fetch,`${s.url}/bucket`,{id:t,name:t,type:e.type,public:e.public,file_size_limit:e.fileSizeLimit,allowed_mime_types:e.allowedMimeTypes},{headers:s.headers}))}async updateBucket(t,e){var s=this;return s.handleOperation(async()=>await Kf(s.fetch,`${s.url}/bucket/${t}`,{id:t,name:t,public:e.public,file_size_limit:e.fileSizeLimit,allowed_mime_types:e.allowedMimeTypes},{headers:s.headers}))}async emptyBucket(t){var e=this;return e.handleOperation(async()=>await Hn(e.fetch,`${e.url}/bucket/${t}/empty`,{},{headers:e.headers}))}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await Pm(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}))}listBucketOptionsToQueryString(t){const e={};return t&&("limit"in t&&(e.limit=String(t.limit)),"offset"in t&&(e.offset=String(t.offset)),t.search&&(e.search=t.search),t.sortColumn&&(e.sortColumn=t.sortColumn),t.sortOrder&&(e.sortOrder=t.sortOrder)),Object.keys(e).length>0?"?"+new URLSearchParams(e).toString():""}},nT=class extends gr{constructor(t,e={},s){const i=t.replace(/\/$/,""),l=Ae(Ae({},Wo),e);super(i,l,s,"storage")}async createBucket(t){var e=this;return e.handleOperation(async()=>await Hn(e.fetch,`${e.url}/bucket`,{name:t},{headers:e.headers}))}async listBuckets(t){var e=this;return e.handleOperation(async()=>{const s=new URLSearchParams;t?.limit!==void 0&&s.set("limit",t.limit.toString()),t?.offset!==void 0&&s.set("offset",t.offset.toString()),t?.sortColumn&&s.set("sortColumn",t.sortColumn),t?.sortOrder&&s.set("sortOrder",t.sortOrder),t?.search&&s.set("search",t.search);const i=s.toString(),l=i?`${e.url}/bucket?${i}`:`${e.url}/bucket`;return await Po(e.fetch,l,{headers:e.headers})})}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await Pm(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}))}from(t){var e=this;if(!$2(t))throw new ju("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 s=new B2({baseUrl:this.url,catalogName:t,auth:{type:"custom",getHeaders:async()=>e.headers},fetch:this.fetch}),i=this.shouldThrowOnError;return new Proxy(s,{get(l,u){const d=l[u];return typeof d!="function"?d:async(...h)=>{try{return{data:await d.apply(l,h),error:null}}catch(m){if(i)throw m;return{data:null,error:m}}}}})}},sT=class extends gr{constructor(t,e={},s){const i=t.replace(/\/$/,""),l=Ae(Ae({},Wo),{},{"Content-Type":"application/json"},e);super(i,l,s,"vectors")}async createIndex(t){var e=this;return e.handleOperation(async()=>await bn.post(e.fetch,`${e.url}/CreateIndex`,t,{headers:e.headers})||{})}async getIndex(t,e){var s=this;return s.handleOperation(async()=>await bn.post(s.fetch,`${s.url}/GetIndex`,{vectorBucketName:t,indexName:e},{headers:s.headers}))}async listIndexes(t){var e=this;return e.handleOperation(async()=>await bn.post(e.fetch,`${e.url}/ListIndexes`,t,{headers:e.headers}))}async deleteIndex(t,e){var s=this;return s.handleOperation(async()=>await bn.post(s.fetch,`${s.url}/DeleteIndex`,{vectorBucketName:t,indexName:e},{headers:s.headers})||{})}},aT=class extends gr{constructor(t,e={},s){const i=t.replace(/\/$/,""),l=Ae(Ae({},Wo),{},{"Content-Type":"application/json"},e);super(i,l,s,"vectors")}async putVectors(t){var e=this;if(t.vectors.length<1||t.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return e.handleOperation(async()=>await bn.post(e.fetch,`${e.url}/PutVectors`,t,{headers:e.headers})||{})}async getVectors(t){var e=this;return e.handleOperation(async()=>await bn.post(e.fetch,`${e.url}/GetVectors`,t,{headers:e.headers}))}async listVectors(t){var e=this;if(t.segmentCount!==void 0){if(t.segmentCount<1||t.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");if(t.segmentIndex!==void 0&&(t.segmentIndex<0||t.segmentIndex>=t.segmentCount))throw new Error(`segmentIndex must be between 0 and ${t.segmentCount-1}`)}return e.handleOperation(async()=>await bn.post(e.fetch,`${e.url}/ListVectors`,t,{headers:e.headers}))}async queryVectors(t){var e=this;return e.handleOperation(async()=>await bn.post(e.fetch,`${e.url}/QueryVectors`,t,{headers:e.headers}))}async deleteVectors(t){var e=this;if(t.keys.length<1||t.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return e.handleOperation(async()=>await bn.post(e.fetch,`${e.url}/DeleteVectors`,t,{headers:e.headers})||{})}},iT=class extends gr{constructor(t,e={},s){const i=t.replace(/\/$/,""),l=Ae(Ae({},Wo),{},{"Content-Type":"application/json"},e);super(i,l,s,"vectors")}async createBucket(t){var e=this;return e.handleOperation(async()=>await bn.post(e.fetch,`${e.url}/CreateVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{})}async getBucket(t){var e=this;return e.handleOperation(async()=>await bn.post(e.fetch,`${e.url}/GetVectorBucket`,{vectorBucketName:t},{headers:e.headers}))}async listBuckets(t={}){var e=this;return e.handleOperation(async()=>await bn.post(e.fetch,`${e.url}/ListVectorBuckets`,t,{headers:e.headers}))}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await bn.post(e.fetch,`${e.url}/DeleteVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{})}},rT=class extends iT{constructor(t,e={}){super(t,e.headers||{},e.fetch)}from(t){return new oT(this.url,this.headers,t,this.fetch)}async createBucket(t){var e=()=>super.createBucket,s=this;return e().call(s,t)}async getBucket(t){var e=()=>super.getBucket,s=this;return e().call(s,t)}async listBuckets(t={}){var e=()=>super.listBuckets,s=this;return e().call(s,t)}async deleteBucket(t){var e=()=>super.deleteBucket,s=this;return e().call(s,t)}},oT=class extends sT{constructor(t,e,s,i){super(t,e,i),this.vectorBucketName=s}async createIndex(t){var e=()=>super.createIndex,s=this;return e().call(s,Ae(Ae({},t),{},{vectorBucketName:s.vectorBucketName}))}async listIndexes(t={}){var e=()=>super.listIndexes,s=this;return e().call(s,Ae(Ae({},t),{},{vectorBucketName:s.vectorBucketName}))}async getIndex(t){var e=()=>super.getIndex,s=this;return e().call(s,s.vectorBucketName,t)}async deleteIndex(t){var e=()=>super.deleteIndex,s=this;return e().call(s,s.vectorBucketName,t)}index(t){return new lT(this.url,this.headers,this.vectorBucketName,t,this.fetch)}},lT=class extends aT{constructor(t,e,s,i,l){super(t,e,l),this.vectorBucketName=s,this.indexName=i}async putVectors(t){var e=()=>super.putVectors,s=this;return e().call(s,Ae(Ae({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}async getVectors(t){var e=()=>super.getVectors,s=this;return e().call(s,Ae(Ae({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}async listVectors(t={}){var e=()=>super.listVectors,s=this;return e().call(s,Ae(Ae({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}async queryVectors(t){var e=()=>super.queryVectors,s=this;return e().call(s,Ae(Ae({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}async deleteVectors(t){var e=()=>super.deleteVectors,s=this;return e().call(s,Ae(Ae({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}},cT=class extends tT{constructor(t,e={},s,i){super(t,e,s,i)}from(t){return new Z2(this.url,this.headers,t,this.fetch)}get vectors(){return new rT(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new nT(this.url+"/iceberg",this.headers,this.fetch)}};const uw="2.97.0",Ji=30*1e3,Yf=3,rf=Yf*Ji,uT="http://localhost:9999",dT="supabase.auth.token",hT={"X-Client-Info":`gotrue-js/${uw}`},Xf="X-Supabase-Api-Version",dw={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},fT=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,mT=600*1e3;class zo extends Error{constructor(e,s,i){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=s,this.code=i}}function Ne(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class pT extends zo{constructor(e,s,i){super(e,s,i),this.name="AuthApiError",this.status=s,this.code=i}}function gT(t){return Ne(t)&&t.name==="AuthApiError"}class Ga extends zo{constructor(e,s){super(e),this.name="AuthUnknownError",this.originalError=s}}class Rs extends zo{constructor(e,s,i,l){super(e,i,l),this.name=s,this.status=i}}class xn extends Rs{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function of(t){return Ne(t)&&t.name==="AuthSessionMissingError"}class $i extends Rs{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class Cc extends Rs{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class Ac extends Rs{constructor(e,s=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=s}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function yT(t){return Ne(t)&&t.name==="AuthImplicitGrantRedirectError"}class Fx extends Rs{constructor(e,s=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=s}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class vT extends Rs{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 Wf extends Rs{constructor(e,s){super(e,"AuthRetryableFetchError",s,void 0)}}function lf(t){return Ne(t)&&t.name==="AuthRetryableFetchError"}class Kx extends Rs{constructor(e,s,i){super(e,"AuthWeakPasswordError",s,"weak_password"),this.reasons=i}}class Jf extends Rs{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const su="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),Yx=`
|
|
35
|
+
\r=`.split(""),xT=(()=>{const t=new Array(128);for(let e=0;e<t.length;e+=1)t[e]=-1;for(let e=0;e<Yx.length;e+=1)t[Yx[e].charCodeAt(0)]=-2;for(let e=0;e<su.length;e+=1)t[su[e].charCodeAt(0)]=e;return t})();function Xx(t,e,s){if(t!==null)for(e.queue=e.queue<<8|t,e.queuedBits+=8;e.queuedBits>=6;){const i=e.queue>>e.queuedBits-6&63;s(su[i]),e.queuedBits-=6}else if(e.queuedBits>0)for(e.queue=e.queue<<6-e.queuedBits,e.queuedBits=6;e.queuedBits>=6;){const i=e.queue>>e.queuedBits-6&63;s(su[i]),e.queuedBits-=6}}function hw(t,e,s){const i=xT[t];if(i>-1)for(e.queue=e.queue<<6|i,e.queuedBits+=6;e.queuedBits>=8;)s(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(i===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function Wx(t){const e=[],s=d=>{e.push(String.fromCodePoint(d))},i={utf8seq:0,codepoint:0},l={queue:0,queuedBits:0},u=d=>{ST(d,i,s)};for(let d=0;d<t.length;d+=1)hw(t.charCodeAt(d),l,u);return e.join("")}function bT(t,e){if(t<=127){e(t);return}else if(t<=2047){e(192|t>>6),e(128|t&63);return}else if(t<=65535){e(224|t>>12),e(128|t>>6&63),e(128|t&63);return}else if(t<=1114111){e(240|t>>18),e(128|t>>12&63),e(128|t>>6&63),e(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function wT(t,e){for(let s=0;s<t.length;s+=1){let i=t.charCodeAt(s);if(i>55295&&i<=56319){const l=(i-55296)*1024&65535;i=(t.charCodeAt(s+1)-56320&65535|l)+65536,s+=1}bT(i,e)}}function ST(t,e,s){if(e.utf8seq===0){if(t<=127){s(t);return}for(let i=1;i<6;i+=1)if((t>>7-i&1)===0){e.utf8seq=i;break}if(e.utf8seq===2)e.codepoint=t&31;else if(e.utf8seq===3)e.codepoint=t&15;else if(e.utf8seq===4)e.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|t&63,e.utf8seq-=1,e.utf8seq===0&&s(e.codepoint)}}function or(t){const e=[],s={queue:0,queuedBits:0},i=l=>{e.push(l)};for(let l=0;l<t.length;l+=1)hw(t.charCodeAt(l),s,i);return new Uint8Array(e)}function jT(t){const e=[];return wT(t,s=>e.push(s)),new Uint8Array(e)}function Fa(t){const e=[],s={queue:0,queuedBits:0},i=l=>{e.push(l)};return t.forEach(l=>Xx(l,s,i)),Xx(null,s,i),e.join("")}function _T(t){return Math.round(Date.now()/1e3)+t}function NT(){return Symbol("auth-callback")}const Gt=()=>typeof window<"u"&&typeof document<"u",La={tested:!1,writable:!1},fw=()=>{if(!Gt())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(La.tested)return La.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),La.tested=!0,La.writable=!0}catch{La.tested=!0,La.writable=!1}return La.writable};function TT(t){const e={},s=new URL(t);if(s.hash&&s.hash[0]==="#")try{new URLSearchParams(s.hash.substring(1)).forEach((l,u)=>{e[u]=l})}catch{}return s.searchParams.forEach((i,l)=>{e[l]=i}),e}const mw=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),ET=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",Qi=async(t,e,s)=>{await t.setItem(e,JSON.stringify(s))},Ua=async(t,e)=>{const s=await t.getItem(e);if(!s)return null;try{return JSON.parse(s)}catch{return s}},Ht=async(t,e)=>{await t.removeItem(e)};class Nu{constructor(){this.promise=new Nu.promiseConstructor((e,s)=>{this.resolve=e,this.reject=s})}}Nu.promiseConstructor=Promise;function Rc(t){const e=t.split(".");if(e.length!==3)throw new Jf("Invalid JWT structure");for(let i=0;i<e.length;i++)if(!fT.test(e[i]))throw new Jf("JWT not in base64url format");return{header:JSON.parse(Wx(e[0])),payload:JSON.parse(Wx(e[1])),signature:or(e[2]),raw:{header:e[0],payload:e[1]}}}async function kT(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}function CT(t,e){return new Promise((i,l)=>{(async()=>{for(let u=0;u<1/0;u++)try{const d=await t(u);if(!e(u,null,d)){i(d);return}}catch(d){if(!e(u,d)){l(d);return}}})()})}function AT(t){return("0"+t.toString(16)).substr(-2)}function RT(){const e=new Uint32Array(56);if(typeof crypto>"u"){const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",i=s.length;let l="";for(let u=0;u<56;u++)l+=s.charAt(Math.floor(Math.random()*i));return l}return crypto.getRandomValues(e),Array.from(e,AT).join("")}async function OT(t){const s=new TextEncoder().encode(t),i=await crypto.subtle.digest("SHA-256",s),l=new Uint8Array(i);return Array.from(l).map(u=>String.fromCharCode(u)).join("")}async function MT(t){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),t;const s=await OT(t);return btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function qi(t,e,s=!1){const i=RT();let l=i;s&&(l+="/PASSWORD_RECOVERY"),await Qi(t,`${e}-code-verifier`,l);const u=await MT(i);return[u,i===u?"plain":"s256"]}const DT=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function PT(t){const e=t.headers.get(Xf);if(!e||!e.match(DT))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function zT(t){if(!t)throw new Error("Missing exp claim");const e=Math.floor(Date.now()/1e3);if(t<=e)throw new Error("JWT has expired")}function LT(t){switch(t){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const UT=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function Hi(t){if(!UT.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function cf(){const t={};return new Proxy(t,{get:(e,s)=>{if(s==="__isUserNotAvailableProxy")return!0;if(typeof s=="symbol"){const i=s.toString();if(i==="Symbol(Symbol.toPrimitive)"||i==="Symbol(Symbol.toStringTag)"||i==="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 "${s}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,s)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${s}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,s)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${s}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function BT(t,e){return new Proxy(t,{get:(s,i,l)=>{if(i==="__isInsecureUserWarningProxy")return!0;if(typeof i=="symbol"){const u=i.toString();if(u==="Symbol(Symbol.toPrimitive)"||u==="Symbol(Symbol.toStringTag)"||u==="Symbol(util.inspect.custom)"||u==="Symbol(nodejs.util.inspect.custom)")return Reflect.get(s,i,l)}return!e.value&&typeof i=="string"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),e.value=!0),Reflect.get(s,i,l)}})}function Jx(t){return JSON.parse(JSON.stringify(t))}const $a=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),VT=[502,503,504];async function Qx(t){var e;if(!ET(t))throw new Wf($a(t),0);if(VT.includes(t.status))throw new Wf($a(t),t.status);let s;try{s=await t.json()}catch(u){throw new Ga($a(u),u)}let i;const l=PT(t);if(l&&l.getTime()>=dw["2024-01-01"].timestamp&&typeof s=="object"&&s&&typeof s.code=="string"?i=s.code:typeof s=="object"&&s&&typeof s.error_code=="string"&&(i=s.error_code),i){if(i==="weak_password")throw new Kx($a(s),t.status,((e=s.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(i==="session_not_found")throw new xn}else if(typeof s=="object"&&s&&typeof s.weak_password=="object"&&s.weak_password&&Array.isArray(s.weak_password.reasons)&&s.weak_password.reasons.length&&s.weak_password.reasons.reduce((u,d)=>u&&typeof d=="string",!0))throw new Kx($a(s),t.status,s.weak_password.reasons);throw new pT($a(s),t.status||500,i)}const IT=(t,e,s,i)=>{const l={method:t,headers:e?.headers||{}};return t==="GET"?l:(l.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e?.headers),l.body=JSON.stringify(i),Object.assign(Object.assign({},l),s))};async function Re(t,e,s,i){var l;const u=Object.assign({},i?.headers);u[Xf]||(u[Xf]=dw["2024-01-01"].name),i?.jwt&&(u.Authorization=`Bearer ${i.jwt}`);const d=(l=i?.query)!==null&&l!==void 0?l:{};i?.redirectTo&&(d.redirect_to=i.redirectTo);const h=Object.keys(d).length?"?"+new URLSearchParams(d).toString():"",m=await $T(t,e,s+h,{headers:u,noResolveJson:i?.noResolveJson},{},i?.body);return i?.xform?i?.xform(m):{data:Object.assign({},m),error:null}}async function $T(t,e,s,i,l,u){const d=IT(e,i,l,u);let h;try{h=await t(s,Object.assign({},d))}catch(m){throw console.error(m),new Wf($a(m),0)}if(h.ok||await Qx(h),i?.noResolveJson)return h;try{return await h.json()}catch(m){await Qx(m)}}function $n(t){var e;let s=null;GT(t)&&(s=Object.assign({},t),t.expires_at||(s.expires_at=_T(t.expires_in)));const i=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:s,user:i},error:null}}function Zx(t){const e=$n(t);return!e.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((s,i)=>s&&typeof i=="string",!0)&&(e.data.weak_password=t.weak_password),e}function ua(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function qT(t){return{data:t,error:null}}function HT(t){const{action_link:e,email_otp:s,hashed_token:i,redirect_to:l,verification_type:u}=t,d=pr(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),h={action_link:e,email_otp:s,hashed_token:i,redirect_to:l,verification_type:u},m=Object.assign({},d);return{data:{properties:h,user:m},error:null}}function e0(t){return t}function GT(t){return t.access_token&&t.refresh_token&&t.expires_in}const uf=["global","local","others"];class FT{constructor({url:e="",headers:s={},fetch:i}){this.url=e,this.headers=s,this.fetch=mw(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)}}async signOut(e,s=uf[0]){if(uf.indexOf(s)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${uf.join(", ")}`);try{return await Re(this.fetch,"POST",`${this.url}/logout?scope=${s}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(i){if(Ne(i))return{data:null,error:i};throw i}}async inviteUserByEmail(e,s={}){try{return await Re(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:s.data},headers:this.headers,redirectTo:s.redirectTo,xform:ua})}catch(i){if(Ne(i))return{data:{user:null},error:i};throw i}}async generateLink(e){try{const{options:s}=e,i=pr(e,["options"]),l=Object.assign(Object.assign({},i),s);return"newEmail"in i&&(l.new_email=i?.newEmail,delete l.newEmail),await Re(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:l,headers:this.headers,xform:HT,redirectTo:s?.redirectTo})}catch(s){if(Ne(s))return{data:{properties:null,user:null},error:s};throw s}}async createUser(e){try{return await Re(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:ua})}catch(s){if(Ne(s))return{data:{user:null},error:s};throw s}}async listUsers(e){var s,i,l,u,d,h,m;try{const g={nextPage:null,lastPage:0,total:0},y=await Re(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(i=(s=e?.page)===null||s===void 0?void 0:s.toString())!==null&&i!==void 0?i:"",per_page:(u=(l=e?.perPage)===null||l===void 0?void 0:l.toString())!==null&&u!==void 0?u:""},xform:e0});if(y.error)throw y.error;const x=await y.json(),w=(d=y.headers.get("x-total-count"))!==null&&d!==void 0?d:0,S=(m=(h=y.headers.get("link"))===null||h===void 0?void 0:h.split(","))!==null&&m!==void 0?m:[];return S.length>0&&(S.forEach(E=>{const j=parseInt(E.split(";")[0].split("=")[1].substring(0,1)),_=JSON.parse(E.split(";")[1].split("=")[1]);g[`${_}Page`]=j}),g.total=parseInt(w)),{data:Object.assign(Object.assign({},x),g),error:null}}catch(g){if(Ne(g))return{data:{users:[]},error:g};throw g}}async getUserById(e){Hi(e);try{return await Re(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:ua})}catch(s){if(Ne(s))return{data:{user:null},error:s};throw s}}async updateUserById(e,s){Hi(e);try{return await Re(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:s,headers:this.headers,xform:ua})}catch(i){if(Ne(i))return{data:{user:null},error:i};throw i}}async deleteUser(e,s=!1){Hi(e);try{return await Re(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:s},xform:ua})}catch(i){if(Ne(i))return{data:{user:null},error:i};throw i}}async _listFactors(e){Hi(e.userId);try{const{data:s,error:i}=await Re(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:l=>({data:{factors:l},error:null})});return{data:s,error:i}}catch(s){if(Ne(s))return{data:null,error:s};throw s}}async _deleteFactor(e){Hi(e.userId),Hi(e.id);try{return{data:await Re(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(s){if(Ne(s))return{data:null,error:s};throw s}}async _listOAuthClients(e){var s,i,l,u,d,h,m;try{const g={nextPage:null,lastPage:0,total:0},y=await Re(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(i=(s=e?.page)===null||s===void 0?void 0:s.toString())!==null&&i!==void 0?i:"",per_page:(u=(l=e?.perPage)===null||l===void 0?void 0:l.toString())!==null&&u!==void 0?u:""},xform:e0});if(y.error)throw y.error;const x=await y.json(),w=(d=y.headers.get("x-total-count"))!==null&&d!==void 0?d:0,S=(m=(h=y.headers.get("link"))===null||h===void 0?void 0:h.split(","))!==null&&m!==void 0?m:[];return S.length>0&&(S.forEach(E=>{const j=parseInt(E.split(";")[0].split("=")[1].substring(0,1)),_=JSON.parse(E.split(";")[1].split("=")[1]);g[`${_}Page`]=j}),g.total=parseInt(w)),{data:Object.assign(Object.assign({},x),g),error:null}}catch(g){if(Ne(g))return{data:{clients:[]},error:g};throw g}}async _createOAuthClient(e){try{return await Re(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(Ne(s))return{data:null,error:s};throw s}}async _getOAuthClient(e){try{return await Re(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(Ne(s))return{data:null,error:s};throw s}}async _updateOAuthClient(e,s){try{return await Re(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${e}`,{body:s,headers:this.headers,xform:i=>({data:i,error:null})})}catch(i){if(Ne(i))return{data:null,error:i};throw i}}async _deleteOAuthClient(e){try{return await Re(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(s){if(Ne(s))return{data:null,error:s};throw s}}async _regenerateOAuthClientSecret(e){try{return await Re(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(Ne(s))return{data:null,error:s};throw s}}}function t0(t={}){return{getItem:e=>t[e]||null,setItem:(e,s)=>{t[e]=s},removeItem:e=>{delete t[e]}}}const Gi={debug:!!(globalThis&&fw()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class pw extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class n0 extends pw{}async function KT(t,e,s){Gi.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const i=new globalThis.AbortController;e>0&&setTimeout(()=>{i.abort(),Gi.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},e),await Promise.resolve();try{return await globalThis.navigator.locks.request(t,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:i.signal},async l=>{if(l){Gi.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,l.name);try{return await s()}finally{Gi.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,l.name)}}else{if(e===0)throw Gi.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new n0(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(Gi.debug)try{const u=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(u,null," "))}catch(u){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",u)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await s()}})}catch(l){throw l?.name==="AbortError"?new n0(`Acquiring an exclusive Navigator LockManager lock "${t}" timed out waiting ${e}ms`):l}}function YT(){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 gw(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function XT(t){return parseInt(t,16)}function WT(t){const e=new TextEncoder().encode(t);return"0x"+Array.from(e,i=>i.toString(16).padStart(2,"0")).join("")}function JT(t){var e;const{chainId:s,domain:i,expirationTime:l,issuedAt:u=new Date,nonce:d,notBefore:h,requestId:m,resources:g,scheme:y,uri:x,version:w}=t;{if(!Number.isInteger(s))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${s}`);if(!i)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(d&&d.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${d}`);if(!x)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(w!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${w}`);if(!((e=t.statement)===null||e===void 0)&&e.includes(`
|
|
36
|
+
`))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${t.statement}`)}const S=gw(t.address),E=y?`${y}://${i}`:i,j=t.statement?`${t.statement}
|
|
37
37
|
`:"",_=`${E} wants you to sign in with your Ethereum account:
|
|
38
38
|
${S}
|
|
39
39
|
|
|
@@ -47,53 +47,53 @@ Not Before: ${h.toISOString()}`),m&&(N+=`
|
|
|
47
47
|
Request ID: ${m}`),g){let k=`
|
|
48
48
|
Resources:`;for(const C of g){if(!C||typeof C!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${C}`);k+=`
|
|
49
49
|
- ${C}`}N+=k}return`${_}
|
|
50
|
-
${N}`}class Tt extends Error{constructor({message:e,code:s,cause:r,name:l}){var u;super(e,{cause:r}),this.__isWebAuthnError=!0,this.name=(u=l??(r instanceof Error?r.name:void 0))!==null&&u!==void 0?u:"Unknown Error",this.code=s}}class au extends Tt{constructor(e,s){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:s,message:e}),this.name="WebAuthnUnknownError",this.originalError=s}}function QT({error:t,options:e}){var s,r,l;const{publicKey:u}=e;if(!u)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new Tt({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((s=u.authenticatorSelection)===null||s===void 0?void 0:s.requireResidentKey)===!0)return new Tt({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(e.mediation==="conditional"&&((r=u.authenticatorSelection)===null||r===void 0?void 0:r.userVerification)==="required")return new Tt({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((l=u.authenticatorSelection)===null||l===void 0?void 0:l.userVerification)==="required")return new Tt({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if(t.name==="InvalidStateError")return new Tt({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new Tt({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return u.pubKeyCredParams.filter(h=>h.type==="public-key").length===0?new Tt({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new Tt({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if(t.name==="SecurityError"){const d=window.location.hostname;if(yw(d)){if(u.rp.id!==d)return new Tt({message:`The RP ID "${u.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Tt({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(u.user.id.byteLength<1||u.user.id.byteLength>64)return new Tt({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if(t.name==="UnknownError")return new Tt({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new Tt({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function ZT({error:t,options:e}){const{publicKey:s}=e;if(!s)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new Tt({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new Tt({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const r=window.location.hostname;if(yw(r)){if(s.rpId!==r)return new Tt({message:`The RP ID "${s.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Tt({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new Tt({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new Tt({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class eE{createNewAbortSignal(){if(this.controller){const s=new Error("Cancelling existing WebAuthn API call for new one");s.name="AbortError",this.controller.abort(s)}const e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){const e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}const tE=new eE;function nE(t){if(!t)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(t);const{challenge:e,user:s,excludeCredentials:r}=t,l=pi(t,["challenge","user","excludeCredentials"]),u=oi(e).buffer,d=Object.assign(Object.assign({},s),{id:oi(s.id).buffer}),h=Object.assign(Object.assign({},l),{challenge:u,user:d});if(r&&r.length>0){h.excludeCredentials=new Array(r.length);for(let m=0;m<r.length;m++){const g=r[m];h.excludeCredentials[m]=Object.assign(Object.assign({},g),{id:oi(g.id).buffer,type:g.type||"public-key",transports:g.transports})}}return h}function sE(t){if(!t)throw new Error("Credential request options are required");if(typeof PublicKeyCredential<"u"&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseRequestOptionsFromJSON=="function")return PublicKeyCredential.parseRequestOptionsFromJSON(t);const{challenge:e,allowCredentials:s}=t,r=pi(t,["challenge","allowCredentials"]),l=oi(e).buffer,u=Object.assign(Object.assign({},r),{challenge:l});if(s&&s.length>0){u.allowCredentials=new Array(s.length);for(let d=0;d<s.length;d++){const h=s[d];u.allowCredentials[d]=Object.assign(Object.assign({},h),{id:oi(h.id).buffer,type:h.type||"public-key",transports:h.transports})}}return u}function aE(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const s=t;return{id:t.id,rawId:t.id,response:{attestationObject:Fa(new Uint8Array(t.response.attestationObject)),clientDataJSON:Fa(new Uint8Array(t.response.clientDataJSON))},type:"public-key",clientExtensionResults:t.getClientExtensionResults(),authenticatorAttachment:(e=s.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function rE(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const s=t,r=t.getClientExtensionResults(),l=t.response;return{id:t.id,rawId:t.id,response:{authenticatorData:Fa(new Uint8Array(l.authenticatorData)),clientDataJSON:Fa(new Uint8Array(l.clientDataJSON)),signature:Fa(new Uint8Array(l.signature)),userHandle:l.userHandle?Fa(new Uint8Array(l.userHandle)):void 0},type:"public-key",clientExtensionResults:r,authenticatorAttachment:(e=s.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function yw(t){return t==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(t)}function s0(){var t,e;return!!(Gt()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&typeof((t=navigator?.credentials)===null||t===void 0?void 0:t.create)=="function"&&typeof((e=navigator?.credentials)===null||e===void 0?void 0:e.get)=="function")}async function iE(t){try{const e=await navigator.credentials.create(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new au("Browser returned unexpected credential type",e)}:{data:null,error:new au("Empty credential response",e)}}catch(e){return{data:null,error:QT({error:e,options:t})}}}async function oE(t){try{const e=await navigator.credentials.get(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new au("Browser returned unexpected credential type",e)}:{data:null,error:new au("Empty credential response",e)}}catch(e){return{data:null,error:ZT({error:e,options:t})}}}const lE={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},cE={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function ru(...t){const e=l=>l!==null&&typeof l=="object"&&!Array.isArray(l),s=l=>l instanceof ArrayBuffer||ArrayBuffer.isView(l),r={};for(const l of t)if(l)for(const u in l){const d=l[u];if(d!==void 0)if(Array.isArray(d))r[u]=d;else if(s(d))r[u]=d;else if(e(d)){const h=r[u];e(h)?r[u]=ru(h,d):r[u]=ru(d)}else r[u]=d}return r}function uE(t,e){return ru(lE,t,e||{})}function dE(t,e){return ru(cE,t,e||{})}class hE{constructor(e){this.client=e,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(e){return this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))}async _challenge({factorId:e,webauthn:s,friendlyName:r,signal:l},u){var d;try{const{data:h,error:m}=await this.client.mfa.challenge({factorId:e,webauthn:s});if(!h)return{data:null,error:m};const g=l??tE.createNewAbortSignal();if(h.webauthn.type==="create"){const{user:y}=h.webauthn.credential_options.publicKey;if(!y.name){const x=r;if(x)y.name=`${y.id}:${x}`;else{const S=(await this.client.getUser()).data.user,E=((d=S?.user_metadata)===null||d===void 0?void 0:d.name)||S?.email||S?.id||"User";y.name=`${y.id}:${E}`}}y.displayName||(y.displayName=y.name)}switch(h.webauthn.type){case"create":{const y=uE(h.webauthn.credential_options.publicKey,u?.create),{data:x,error:w}=await iE({publicKey:y,signal:g});return x?{data:{factorId:e,challengeId:h.id,webauthn:{type:h.webauthn.type,credential_response:x}},error:null}:{data:null,error:w}}case"request":{const y=dE(h.webauthn.credential_options.publicKey,u?.request),{data:x,error:w}=await oE(Object.assign(Object.assign({},h.webauthn.credential_options),{publicKey:y,signal:g}));return x?{data:{factorId:e,challengeId:h.id,webauthn:{type:h.webauthn.type,credential_response:x}},error:null}:{data:null,error:w}}}}catch(h){return Ne(h)?{data:null,error:h}:{data:null,error:new Ga("Unexpected error in challenge",h)}}}async _verify({challengeId:e,factorId:s,webauthn:r}){return this.client.mfa.verify({factorId:s,challengeId:e,webauthn:r})}async _authenticate({factorId:e,webauthn:{rpId:s=typeof window<"u"?window.location.hostname:void 0,rpOrigins:r=typeof window<"u"?[window.location.origin]:void 0,signal:l}={}},u){if(!s)return{data:null,error:new zo("rpId is required for WebAuthn authentication")};try{if(!s0())return{data:null,error:new Ga("Browser does not support WebAuthn",null)};const{data:d,error:h}=await this.challenge({factorId:e,webauthn:{rpId:s,rpOrigins:r},signal:l},{request:u});if(!d)return{data:null,error:h};const{webauthn:m}=d;return this._verify({factorId:e,challengeId:d.challengeId,webauthn:{type:m.type,rpId:s,rpOrigins:r,credential_response:m.credential_response}})}catch(d){return Ne(d)?{data:null,error:d}:{data:null,error:new Ga("Unexpected error in authenticate",d)}}}async _register({friendlyName:e,webauthn:{rpId:s=typeof window<"u"?window.location.hostname:void 0,rpOrigins:r=typeof window<"u"?[window.location.origin]:void 0,signal:l}={}},u){if(!s)return{data:null,error:new zo("rpId is required for WebAuthn registration")};try{if(!s0())return{data:null,error:new Ga("Browser does not support WebAuthn",null)};const{data:d,error:h}=await this._enroll({friendlyName:e});if(!d)return await this.client.mfa.listFactors().then(y=>{var x;return(x=y.data)===null||x===void 0?void 0:x.all.find(w=>w.factor_type==="webauthn"&&w.friendly_name===e&&w.status!=="unverified")}).then(y=>y?this.client.mfa.unenroll({factorId:y?.id}):void 0),{data:null,error:h};const{data:m,error:g}=await this._challenge({factorId:d.id,friendlyName:d.friendly_name,webauthn:{rpId:s,rpOrigins:r},signal:l},{create:u});return m?this._verify({factorId:d.id,challengeId:m.challengeId,webauthn:{rpId:s,rpOrigins:r,type:m.webauthn.type,credential_response:m.webauthn.credential_response}}):{data:null,error:g}}catch(d){return Ne(d)?{data:null,error:d}:{data:null,error:new Ga("Unexpected error in register",d)}}}}YT();const fE={url:uT,storageKey:dT,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:hT,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:1e4,skipAutoInitialize:!1};async function a0(t,e,s){return await s()}const Fr={};class Lo{get jwks(){var e,s;return(s=(e=Fr[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&s!==void 0?s:{keys:[]}}set jwks(e){Fr[this.storageKey]=Object.assign(Object.assign({},Fr[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,s;return(s=(e=Fr[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&s!==void 0?s:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){Fr[this.storageKey]=Object.assign(Object.assign({},Fr[this.storageKey]),{cachedAt:e})}constructor(e){var s,r,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 u=Object.assign(Object.assign({},fE),e);if(this.storageKey=u.storageKey,this.instanceID=(s=Lo.nextInstanceID[this.storageKey])!==null&&s!==void 0?s:0,Lo.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!u.debug,typeof u.debug=="function"&&(this.logger=u.debug),this.instanceID>0&&Gt()){const d=`${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(d),this.logDebugMessages&&console.trace(d)}if(this.persistSession=u.persistSession,this.autoRefreshToken=u.autoRefreshToken,this.admin=new FT({url:u.url,headers:u.headers,fetch:u.fetch}),this.url=u.url,this.headers=u.headers,this.fetch=mw(u.fetch),this.lock=u.lock||a0,this.detectSessionInUrl=u.detectSessionInUrl,this.flowType=u.flowType,this.hasCustomAuthorizationHeader=u.hasCustomAuthorizationHeader,this.throwOnError=u.throwOnError,this.lockAcquireTimeout=u.lockAcquireTimeout,u.lock?this.lock=u.lock:this.persistSession&&Gt()&&(!((r=globalThis?.navigator)===null||r===void 0)&&r.locks)?this.lock=KT:this.lock=a0,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 hE(this)},this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this),listGrants:this._listOAuthGrants.bind(this),revokeGrant:this._revokeOAuthGrant.bind(this)},this.persistSession?(u.storage?this.storage=u.storage:fw()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=t0(this.memoryStorage)),u.userStorage&&(this.userStorage=u.userStorage)):(this.memoryStorage={},this.storage=t0(this.memoryStorage)),Gt()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(d){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",d)}(l=this.broadcastChannel)===null||l===void 0||l.addEventListener("message",async d=>{this._debug("received broadcast notification from other tab or client",d);try{await this._notifyAllSubscribers(d.data.event,d.data.session,!1)}catch(h){this._debug("#broadcastChannel","error",h)}})}u.skipAutoInitialize||this.initialize().catch(d=>{this._debug("#initialize()","error",d)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${uw}) ${new Date().toISOString()}`}_debug(...e){return this.logDebugMessages&&this.logger(this._logPrefix(),...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(this.lockAcquireTimeout,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var e;try{let s={},r="none";if(Gt()&&(s=TT(window.location.href),this._isImplicitGrantCallback(s)?r="implicit":await this._isPKCECallback(s)&&(r="pkce")),Gt()&&this.detectSessionInUrl&&r!=="none"){const{data:l,error:u}=await this._getSessionFromURL(s,r);if(u){if(this._debug("#_initialize()","error detecting session from URL",u),yT(u)){const m=(e=u.details)===null||e===void 0?void 0:e.code;if(m==="identity_already_exists"||m==="identity_not_found"||m==="single_identity_not_deletable")return{error:u}}return{error:u}}const{session:d,redirectType:h}=l;return this._debug("#_initialize()","detected session in URL",d,"redirect type",h),await this._saveSession(d),setTimeout(async()=>{h==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",d):await this._notifyAllSubscribers("SIGNED_IN",d)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(s){return Ne(s)?this._returnResult({error:s}):this._returnResult({error:new Ga("Unexpected error during initialization",s)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var s,r,l;try{const u=await Re(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(r=(s=e?.options)===null||s===void 0?void 0:s.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:(l=e?.options)===null||l===void 0?void 0:l.captchaToken}},xform:$n}),{data:d,error:h}=u;if(h||!d)return this._returnResult({data:{user:null,session:null},error:h});const m=d.session,g=d.user;return d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("SIGNED_IN",m)),this._returnResult({data:{user:g,session:m},error:null})}catch(u){if(Ne(u))return this._returnResult({data:{user:null,session:null},error:u});throw u}}async signUp(e){var s,r,l;try{let u;if("email"in e){const{email:y,password:x,options:w}=e;let S=null,E=null;this.flowType==="pkce"&&([S,E]=await qr(this.storage,this.storageKey)),u=await Re(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:w?.emailRedirectTo,body:{email:y,password:x,data:(s=w?.data)!==null&&s!==void 0?s:{},gotrue_meta_security:{captcha_token:w?.captchaToken},code_challenge:S,code_challenge_method:E},xform:$n})}else if("phone"in e){const{phone:y,password:x,options:w}=e;u=await Re(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:y,password:x,data:(r=w?.data)!==null&&r!==void 0?r:{},channel:(l=w?.channel)!==null&&l!==void 0?l:"sms",gotrue_meta_security:{captcha_token:w?.captchaToken}},xform:$n})}else throw new Cc("You must provide either an email or phone number and a password");const{data:d,error:h}=u;if(h||!d)return await Ht(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:h});const m=d.session,g=d.user;return d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("SIGNED_IN",m)),this._returnResult({data:{user:g,session:m},error:null})}catch(u){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(u))return this._returnResult({data:{user:null,session:null},error:u});throw u}}async signInWithPassword(e){try{let s;if("email"in e){const{email:u,password:d,options:h}=e;s=await Re(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:u,password:d,gotrue_meta_security:{captcha_token:h?.captchaToken}},xform:Zx})}else if("phone"in e){const{phone:u,password:d,options:h}=e;s=await Re(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:u,password:d,gotrue_meta_security:{captcha_token:h?.captchaToken}},xform:Zx})}else throw new Cc("You must provide either an email or phone number and a password");const{data:r,error:l}=s;if(l)return this._returnResult({data:{user:null,session:null},error:l});if(!r||!r.session||!r.user){const u=new $r;return this._returnResult({data:{user:null,session:null},error:u})}return r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),this._returnResult({data:Object.assign({user:r.user,session:r.session},r.weak_password?{weakPassword:r.weak_password}:null),error:l})}catch(s){if(Ne(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async signInWithOAuth(e){var s,r,l,u;return await this._handleProviderSignIn(e.provider,{redirectTo:(s=e.options)===null||s===void 0?void 0:s.redirectTo,scopes:(r=e.options)===null||r===void 0?void 0:r.scopes,queryParams:(l=e.options)===null||l===void 0?void 0:l.queryParams,skipBrowserRedirect:(u=e.options)===null||u===void 0?void 0:u.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){const{chain:s}=e;switch(s){case"ethereum":return await this.signInWithEthereum(e);case"solana":return await this.signInWithSolana(e);default:throw new Error(`@supabase/auth-js: Unsupported chain "${s}"`)}}async signInWithEthereum(e){var s,r,l,u,d,h,m,g,y,x,w;let S,E;if("message"in e)S=e.message,E=e.signature;else{const{chain:j,wallet:_,statement:N,options:k}=e;let C;if(Gt())if(typeof _=="object")C=_;else{const P=window;if("ethereum"in P&&typeof P.ethereum=="object"&&"request"in P.ethereum&&typeof P.ethereum.request=="function")C=P.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 _!="object"||!k?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");C=_}const A=new URL((s=k?.url)!==null&&s!==void 0?s:window.location.href),D=await C.request({method:"eth_requestAccounts"}).then(P=>P).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!D||D.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const U=gw(D[0]);let V=(r=k?.signInWithEthereum)===null||r===void 0?void 0:r.chainId;if(!V){const P=await C.request({method:"eth_chainId"});V=XT(P)}const R={domain:A.host,address:U,statement:N,uri:A.href,version:"1",chainId:V,nonce:(l=k?.signInWithEthereum)===null||l===void 0?void 0:l.nonce,issuedAt:(d=(u=k?.signInWithEthereum)===null||u===void 0?void 0:u.issuedAt)!==null&&d!==void 0?d:new Date,expirationTime:(h=k?.signInWithEthereum)===null||h===void 0?void 0:h.expirationTime,notBefore:(m=k?.signInWithEthereum)===null||m===void 0?void 0:m.notBefore,requestId:(g=k?.signInWithEthereum)===null||g===void 0?void 0:g.requestId,resources:(y=k?.signInWithEthereum)===null||y===void 0?void 0:y.resources};S=JT(R),E=await C.request({method:"personal_sign",params:[WT(S),U]})}try{const{data:j,error:_}=await Re(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:S,signature:E},!((x=e.options)===null||x===void 0)&&x.captchaToken?{gotrue_meta_security:{captcha_token:(w=e.options)===null||w===void 0?void 0:w.captchaToken}}:null),xform:$n});if(_)throw _;if(!j||!j.session||!j.user){const N=new $r;return this._returnResult({data:{user:null,session:null},error:N})}return j.session&&(await this._saveSession(j.session),await this._notifyAllSubscribers("SIGNED_IN",j.session)),this._returnResult({data:Object.assign({},j),error:_})}catch(j){if(Ne(j))return this._returnResult({data:{user:null,session:null},error:j});throw j}}async signInWithSolana(e){var s,r,l,u,d,h,m,g,y,x,w,S;let E,j;if("message"in e)E=e.message,j=e.signature;else{const{chain:_,wallet:N,statement:k,options:C}=e;let A;if(Gt())if(typeof N=="object")A=N;else{const U=window;if("solana"in U&&typeof U.solana=="object"&&("signIn"in U.solana&&typeof U.solana.signIn=="function"||"signMessage"in U.solana&&typeof U.solana.signMessage=="function"))A=U.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"||!C?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");A=N}const D=new URL((s=C?.url)!==null&&s!==void 0?s:window.location.href);if("signIn"in A&&A.signIn){const U=await A.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},C?.signInWithSolana),{version:"1",domain:D.host,uri:D.href}),k?{statement:k}:null));let V;if(Array.isArray(U)&&U[0]&&typeof U[0]=="object")V=U[0];else if(U&&typeof U=="object"&&"signedMessage"in U&&"signature"in U)V=U;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in V&&"signature"in V&&(typeof V.signedMessage=="string"||V.signedMessage instanceof Uint8Array)&&V.signature instanceof Uint8Array)E=typeof V.signedMessage=="string"?V.signedMessage:new TextDecoder().decode(V.signedMessage),j=V.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in A)||typeof A.signMessage!="function"||!("publicKey"in A)||typeof A!="object"||!A.publicKey||!("toBase58"in A.publicKey)||typeof A.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");E=[`${D.host} wants you to sign in with your Solana account:`,A.publicKey.toBase58(),...k?["",k,""]:[""],"Version: 1",`URI: ${D.href}`,`Issued At: ${(l=(r=C?.signInWithSolana)===null||r===void 0?void 0:r.issuedAt)!==null&&l!==void 0?l:new Date().toISOString()}`,...!((u=C?.signInWithSolana)===null||u===void 0)&&u.notBefore?[`Not Before: ${C.signInWithSolana.notBefore}`]:[],...!((d=C?.signInWithSolana)===null||d===void 0)&&d.expirationTime?[`Expiration Time: ${C.signInWithSolana.expirationTime}`]:[],...!((h=C?.signInWithSolana)===null||h===void 0)&&h.chainId?[`Chain ID: ${C.signInWithSolana.chainId}`]:[],...!((m=C?.signInWithSolana)===null||m===void 0)&&m.nonce?[`Nonce: ${C.signInWithSolana.nonce}`]:[],...!((g=C?.signInWithSolana)===null||g===void 0)&&g.requestId?[`Request ID: ${C.signInWithSolana.requestId}`]:[],...!((x=(y=C?.signInWithSolana)===null||y===void 0?void 0:y.resources)===null||x===void 0)&&x.length?["Resources",...C.signInWithSolana.resources.map(V=>`- ${V}`)]:[]].join(`
|
|
51
|
-
`);const U=await A.signMessage(new TextEncoder().encode(E),"utf8");if(!U||!(U instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");j=U}}try{const{data:_,error:N}=await Re(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:E,signature:Fa(j)},!((w=e.options)===null||w===void 0)&&w.captchaToken?{gotrue_meta_security:{captcha_token:(S=e.options)===null||S===void 0?void 0:S.captchaToken}}:null),xform:$n});if(N)throw N;if(!_||!_.session||!_.user){const k=new $r;return this._returnResult({data:{user:null,session:null},error:k})}return _.session&&(await this._saveSession(_.session),await this._notifyAllSubscribers("SIGNED_IN",_.session)),this._returnResult({data:Object.assign({},_),error:N})}catch(_){if(Ne(_))return this._returnResult({data:{user:null,session:null},error:_});throw _}}async _exchangeCodeForSession(e){const s=await Ua(this.storage,`${this.storageKey}-code-verifier`),[r,l]=(s??"").split("/");try{if(!r&&this.flowType==="pkce")throw new vT;const{data:u,error:d}=await Re(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:r},xform:$n});if(await Ht(this.storage,`${this.storageKey}-code-verifier`),d)throw d;if(!u||!u.session||!u.user){const h=new $r;return this._returnResult({data:{user:null,session:null,redirectType:null},error:h})}return u.session&&(await this._saveSession(u.session),await this._notifyAllSubscribers("SIGNED_IN",u.session)),this._returnResult({data:Object.assign(Object.assign({},u),{redirectType:l??null}),error:d})}catch(u){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(u))return this._returnResult({data:{user:null,session:null,redirectType:null},error:u});throw u}}async signInWithIdToken(e){try{const{options:s,provider:r,token:l,access_token:u,nonce:d}=e,h=await Re(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:l,access_token:u,nonce:d,gotrue_meta_security:{captcha_token:s?.captchaToken}},xform:$n}),{data:m,error:g}=h;if(g)return this._returnResult({data:{user:null,session:null},error:g});if(!m||!m.session||!m.user){const y=new $r;return this._returnResult({data:{user:null,session:null},error:y})}return m.session&&(await this._saveSession(m.session),await this._notifyAllSubscribers("SIGNED_IN",m.session)),this._returnResult({data:m,error:g})}catch(s){if(Ne(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async signInWithOtp(e){var s,r,l,u,d;try{if("email"in e){const{email:h,options:m}=e;let g=null,y=null;this.flowType==="pkce"&&([g,y]=await qr(this.storage,this.storageKey));const{error:x}=await Re(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:h,data:(s=m?.data)!==null&&s!==void 0?s:{},create_user:(r=m?.shouldCreateUser)!==null&&r!==void 0?r:!0,gotrue_meta_security:{captcha_token:m?.captchaToken},code_challenge:g,code_challenge_method:y},redirectTo:m?.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:x})}if("phone"in e){const{phone:h,options:m}=e,{data:g,error:y}=await Re(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:h,data:(l=m?.data)!==null&&l!==void 0?l:{},create_user:(u=m?.shouldCreateUser)!==null&&u!==void 0?u:!0,gotrue_meta_security:{captcha_token:m?.captchaToken},channel:(d=m?.channel)!==null&&d!==void 0?d:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:g?.message_id},error:y})}throw new Cc("You must provide either an email or phone number.")}catch(h){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(h))return this._returnResult({data:{user:null,session:null},error:h});throw h}}async verifyOtp(e){var s,r;try{let l,u;"options"in e&&(l=(s=e.options)===null||s===void 0?void 0:s.redirectTo,u=(r=e.options)===null||r===void 0?void 0:r.captchaToken);const{data:d,error:h}=await Re(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:u}}),redirectTo:l,xform:$n});if(h)throw h;if(!d)throw new Error("An error occurred on token verification.");const m=d.session,g=d.user;return m?.access_token&&(await this._saveSession(m),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",m)),this._returnResult({data:{user:g,session:m},error:null})}catch(l){if(Ne(l))return this._returnResult({data:{user:null,session:null},error:l});throw l}}async signInWithSSO(e){var s,r,l,u,d;try{let h=null,m=null;this.flowType==="pkce"&&([h,m]=await qr(this.storage,this.storageKey));const g=await Re(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(r=(s=e.options)===null||s===void 0?void 0:s.redirectTo)!==null&&r!==void 0?r:void 0}),!((l=e?.options)===null||l===void 0)&&l.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:h,code_challenge_method:m}),headers:this.headers,xform:qT});return!((u=g.data)===null||u===void 0)&&u.url&&Gt()&&!(!((d=e.options)===null||d===void 0)&&d.skipBrowserRedirect)&&window.location.assign(g.data.url),this._returnResult(g)}catch(h){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(h))return this._returnResult({data:null,error:h});throw h}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:s},error:r}=e;if(r)throw r;if(!s)throw new xn;const{error:l}=await Re(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:s.access_token});return this._returnResult({data:{user:null,session:null},error:l})})}catch(e){if(Ne(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){try{const s=`${this.url}/resend`;if("email"in e){const{email:r,type:l,options:u}=e,{error:d}=await Re(this.fetch,"POST",s,{headers:this.headers,body:{email:r,type:l,gotrue_meta_security:{captcha_token:u?.captchaToken}},redirectTo:u?.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:d})}else if("phone"in e){const{phone:r,type:l,options:u}=e,{data:d,error:h}=await Re(this.fetch,"POST",s,{headers:this.headers,body:{phone:r,type:l,gotrue_meta_security:{captcha_token:u?.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:d?.message_id},error:h})}throw new Cc("You must provide either an email or phone number and a type")}catch(s){if(Ne(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async getSession(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async s=>s))}async _acquireLock(e,s){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),l=(async()=>(await r,await s()))();return this.pendingInLock.push((async()=>{try{await l}catch{}})()),l}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const r=s();for(this.pendingInLock.push((async()=>{try{await r}catch{}})()),await r;this.pendingInLock.length;){const l=[...this.pendingInLock];await Promise.all(l),this.pendingInLock.splice(0,l.length)}return await r}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const s=await this.__loadSession();return await e(s)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const s=await Ua(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",s),s!==null&&(this._isValidSession(s)?e=s:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const r=e.expires_at?e.expires_at*1e3-Date.now()<rf:!1;if(this._debug("#__loadSession()",`session has${r?"":" not"} expired`,"expires_at",e.expires_at),!r){if(this.userStorage){const d=await Ua(this.userStorage,this.storageKey+"-user");d?.user?e.user=d.user:e.user=cf()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){const d={value:this.suppressGetSessionWarning};e.user=BT(e.user,d),d.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:e},error:null}}const{data:l,error:u}=await this._callRefreshToken(e.refresh_token);return u?this._returnResult({data:{session:null},error:u}):this._returnResult({data:{session:l},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;const s=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser());return s.data.user&&(this.suppressGetSessionWarning=!0),s}async _getUser(e){try{return e?await Re(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:ua}):await this._useSession(async s=>{var r,l,u;const{data:d,error:h}=s;if(h)throw h;return!(!((r=d.session)===null||r===void 0)&&r.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new xn}:await Re(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(u=(l=d.session)===null||l===void 0?void 0:l.access_token)!==null&&u!==void 0?u:void 0,xform:ua})})}catch(s){if(Ne(s))return of(s)&&(await this._removeSession(),await Ht(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:s});throw s}}async updateUser(e,s={}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(e,s))}async _updateUser(e,s={}){try{return await this._useSession(async r=>{const{data:l,error:u}=r;if(u)throw u;if(!l.session)throw new xn;const d=l.session;let h=null,m=null;this.flowType==="pkce"&&e.email!=null&&([h,m]=await qr(this.storage,this.storageKey));const{data:g,error:y}=await Re(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:s?.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:h,code_challenge_method:m}),jwt:d.access_token,xform:ua});if(y)throw y;return d.user=g.user,await this._saveSession(d),await this._notifyAllSubscribers("USER_UPDATED",d),this._returnResult({data:{user:d.user},error:null})})}catch(r){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(r))return this._returnResult({data:{user:null},error:r});throw r}}async setSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new xn;const s=Date.now()/1e3;let r=s,l=!0,u=null;const{payload:d}=Rc(e.access_token);if(d.exp&&(r=d.exp,l=r<=s),l){const{data:h,error:m}=await this._callRefreshToken(e.refresh_token);if(m)return this._returnResult({data:{user:null,session:null},error:m});if(!h)return{data:{user:null,session:null},error:null};u=h}else{const{data:h,error:m}=await this._getUser(e.access_token);if(m)return this._returnResult({data:{user:null,session:null},error:m});u={access_token:e.access_token,refresh_token:e.refresh_token,user:h.user,token_type:"bearer",expires_in:r-s,expires_at:r},await this._saveSession(u),await this._notifyAllSubscribers("SIGNED_IN",u)}return this._returnResult({data:{user:u.user,session:u},error:null})}catch(s){if(Ne(s))return this._returnResult({data:{session:null,user:null},error:s});throw s}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async s=>{var r;if(!e){const{data:d,error:h}=s;if(h)throw h;e=(r=d.session)!==null&&r!==void 0?r:void 0}if(!e?.refresh_token)throw new xn;const{data:l,error:u}=await this._callRefreshToken(e.refresh_token);return u?this._returnResult({data:{user:null,session:null},error:u}):l?this._returnResult({data:{user:l.user,session:l},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(s){if(Ne(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async _getSessionFromURL(e,s){try{if(!Gt())throw new Ac("No browser detected.");if(e.error||e.error_description||e.error_code)throw new Ac(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(s){case"implicit":if(this.flowType==="pkce")throw new Fx("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new Ac("Not a valid implicit grant flow url.");break;default:}if(s==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new Fx("No code detected.");const{data:k,error:C}=await this._exchangeCodeForSession(e.code);if(C)throw C;const A=new URL(window.location.href);return A.searchParams.delete("code"),window.history.replaceState(window.history.state,"",A.toString()),{data:{session:k.session,redirectType:null},error:null}}const{provider_token:r,provider_refresh_token:l,access_token:u,refresh_token:d,expires_in:h,expires_at:m,token_type:g}=e;if(!u||!h||!d||!g)throw new Ac("No session defined in URL");const y=Math.round(Date.now()/1e3),x=parseInt(h);let w=y+x;m&&(w=parseInt(m));const S=w-y;S*1e3<=Jr&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${S}s, should have been closer to ${x}s`);const E=w-x;y-E>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",E,w,y):y-E<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",E,w,y);const{data:j,error:_}=await this._getUser(u);if(_)throw _;const N={provider_token:r,provider_refresh_token:l,access_token:u,expires_in:x,expires_at:w,refresh_token:d,token_type:g,user:j.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:N,redirectType:e.type},error:null})}catch(r){if(Ne(r))return this._returnResult({data:{session:null,redirectType:null},error:r});throw r}}_isImplicitGrantCallback(e){return typeof this.detectSessionInUrl=="function"?this.detectSessionInUrl(new URL(window.location.href),e):!!(e.access_token||e.error_description)}async _isPKCECallback(e){const s=await Ua(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&s)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async s=>{var r;const{data:l,error:u}=s;if(u&&!of(u))return this._returnResult({error:u});const d=(r=l.session)===null||r===void 0?void 0:r.access_token;if(d){const{error:h}=await this.admin.signOut(d,e);if(h&&!(gT(h)&&(h.status===404||h.status===401||h.status===403)||of(h)))return this._returnResult({error:h})}return e!=="others"&&(await this._removeSession(),await Ht(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(e){const s=NT(),r={id:s,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",s),this.stateChangeEmitters.delete(s)}};return this._debug("#onAuthStateChange()","registered callback with id",s),this.stateChangeEmitters.set(s,r),(async()=>(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(s)})))(),{data:{subscription:r}}}async _emitInitialSession(e){return await this._useSession(async s=>{var r,l;try{const{data:{session:u},error:d}=s;if(d)throw d;await((r=this.stateChangeEmitters.get(e))===null||r===void 0?void 0:r.callback("INITIAL_SESSION",u)),this._debug("INITIAL_SESSION","callback id",e,"session",u)}catch(u){await((l=this.stateChangeEmitters.get(e))===null||l===void 0?void 0:l.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",u),console.error(u)}})}async resetPasswordForEmail(e,s={}){let r=null,l=null;this.flowType==="pkce"&&([r,l]=await qr(this.storage,this.storageKey,!0));try{return await Re(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:r,code_challenge_method:l,gotrue_meta_security:{captcha_token:s.captchaToken}},headers:this.headers,redirectTo:s.redirectTo})}catch(u){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(u))return this._returnResult({data:null,error:u});throw u}}async getUserIdentities(){var e;try{const{data:s,error:r}=await this.getUser();if(r)throw r;return this._returnResult({data:{identities:(e=s.user.identities)!==null&&e!==void 0?e:[]},error:null})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var s;try{const{data:r,error:l}=await this._useSession(async u=>{var d,h,m,g,y;const{data:x,error:w}=u;if(w)throw w;const S=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(d=e.options)===null||d===void 0?void 0:d.redirectTo,scopes:(h=e.options)===null||h===void 0?void 0:h.scopes,queryParams:(m=e.options)===null||m===void 0?void 0:m.queryParams,skipBrowserRedirect:!0});return await Re(this.fetch,"GET",S,{headers:this.headers,jwt:(y=(g=x.session)===null||g===void 0?void 0:g.access_token)!==null&&y!==void 0?y:void 0})});if(l)throw l;return Gt()&&!(!((s=e.options)===null||s===void 0)&&s.skipBrowserRedirect)&&window.location.assign(r?.url),this._returnResult({data:{provider:e.provider,url:r?.url},error:null})}catch(r){if(Ne(r))return this._returnResult({data:{provider:e.provider,url:null},error:r});throw r}}async linkIdentityIdToken(e){return await this._useSession(async s=>{var r;try{const{error:l,data:{session:u}}=s;if(l)throw l;const{options:d,provider:h,token:m,access_token:g,nonce:y}=e,x=await Re(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(r=u?.access_token)!==null&&r!==void 0?r:void 0,body:{provider:h,id_token:m,access_token:g,nonce:y,link_identity:!0,gotrue_meta_security:{captcha_token:d?.captchaToken}},xform:$n}),{data:w,error:S}=x;return S?this._returnResult({data:{user:null,session:null},error:S}):!w||!w.session||!w.user?this._returnResult({data:{user:null,session:null},error:new $r}):(w.session&&(await this._saveSession(w.session),await this._notifyAllSubscribers("USER_UPDATED",w.session)),this._returnResult({data:w,error:S}))}catch(l){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(l))return this._returnResult({data:{user:null,session:null},error:l});throw l}})}async unlinkIdentity(e){try{return await this._useSession(async s=>{var r,l;const{data:u,error:d}=s;if(d)throw d;return await Re(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(l=(r=u.session)===null||r===void 0?void 0:r.access_token)!==null&&l!==void 0?l:void 0})})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async _refreshAccessToken(e){const s=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{const r=Date.now();return await CT(async l=>(l>0&&await kT(200*Math.pow(2,l-1)),this._debug(s,"refreshing attempt",l),await Re(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:$n})),(l,u)=>{const d=200*Math.pow(2,l);return u&&lf(u)&&Date.now()+d-r<Jr})}catch(r){if(this._debug(s,"error",r),Ne(r))return this._returnResult({data:{session:null,user:null},error:r});throw r}finally{this._debug(s,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,s){const r=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:s.redirectTo,scopes:s.scopes,queryParams:s.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",s,"url",r),Gt()&&!s.skipBrowserRedirect&&window.location.assign(r),{data:{provider:e,url:r},error:null}}async _recoverAndRefresh(){var e,s;const r="#_recoverAndRefresh()";this._debug(r,"begin");try{const l=await Ua(this.storage,this.storageKey);if(l&&this.userStorage){let d=await Ua(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!d&&(d={user:l.user},await Qr(this.userStorage,this.storageKey+"-user",d)),l.user=(e=d?.user)!==null&&e!==void 0?e:cf()}else if(l&&!l.user&&!l.user){const d=await Ua(this.storage,this.storageKey+"-user");d&&d?.user?(l.user=d.user,await Ht(this.storage,this.storageKey+"-user"),await Qr(this.storage,this.storageKey,l)):l.user=cf()}if(this._debug(r,"session from storage",l),!this._isValidSession(l)){this._debug(r,"session is not valid"),l!==null&&await this._removeSession();return}const u=((s=l.expires_at)!==null&&s!==void 0?s:1/0)*1e3-Date.now()<rf;if(this._debug(r,`session has${u?"":" not"} expired with margin of ${rf}s`),u){if(this.autoRefreshToken&&l.refresh_token){const{error:d}=await this._callRefreshToken(l.refresh_token);d&&(console.error(d),lf(d)||(this._debug(r,"refresh failed with a non-retryable error, removing the session",d),await this._removeSession()))}}else if(l.user&&l.user.__isUserNotAvailableProxy===!0)try{const{data:d,error:h}=await this._getUser(l.access_token);!h&&d?.user?(l.user=d.user,await this._saveSession(l),await this._notifyAllSubscribers("SIGNED_IN",l)):this._debug(r,"could not get user data, skipping SIGNED_IN notification")}catch(d){console.error("Error getting user data:",d),this._debug(r,"error getting user data, skipping SIGNED_IN notification",d)}else await this._notifyAllSubscribers("SIGNED_IN",l)}catch(l){this._debug(r,"error",l),console.error(l);return}finally{this._debug(r,"end")}}async _callRefreshToken(e){var s,r;if(!e)throw new xn;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const l=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(l,"begin");try{this.refreshingDeferred=new Nu;const{data:u,error:d}=await this._refreshAccessToken(e);if(d)throw d;if(!u.session)throw new xn;await this._saveSession(u.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",u.session);const h={data:u.session,error:null};return this.refreshingDeferred.resolve(h),h}catch(u){if(this._debug(l,"error",u),Ne(u)){const d={data:null,error:u};return lf(u)||await this._removeSession(),(s=this.refreshingDeferred)===null||s===void 0||s.resolve(d),d}throw(r=this.refreshingDeferred)===null||r===void 0||r.reject(u),u}finally{this.refreshingDeferred=null,this._debug(l,"end")}}async _notifyAllSubscribers(e,s,r=!0){const l=`#_notifyAllSubscribers(${e})`;this._debug(l,"begin",s,`broadcast = ${r}`);try{this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:e,session:s});const u=[],d=Array.from(this.stateChangeEmitters.values()).map(async h=>{try{await h.callback(e,s)}catch(m){u.push(m)}});if(await Promise.all(d),u.length>0){for(let h=0;h<u.length;h+=1)console.error(u[h]);throw u[0]}}finally{this._debug(l,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await Ht(this.storage,`${this.storageKey}-code-verifier`);const s=Object.assign({},e),r=s.user&&s.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!r&&s.user&&await Qr(this.userStorage,this.storageKey+"-user",{user:s.user});const l=Object.assign({},s);delete l.user;const u=Jx(l);await Qr(this.storage,this.storageKey,u)}else{const l=Jx(s);await Qr(this.storage,this.storageKey,l)}}async _removeSession(){this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await Ht(this.storage,this.storageKey),await Ht(this.storage,this.storageKey+"-code-verifier"),await Ht(this.storage,this.storageKey+"-user"),this.userStorage&&await Ht(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&Gt()&&window?.removeEventListener&&window.removeEventListener("visibilitychange",e)}catch(s){console.error("removing visibilitychange callback failed",s)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),Jr);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e);const s=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);this.autoRefreshTickTimeout=s,s&&typeof s=="object"&&typeof s.unref=="function"?s.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(s)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e);const s=this.autoRefreshTickTimeout;this.autoRefreshTickTimeout=null,s&&clearTimeout(s)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async s=>{const{data:{session:r}}=s;if(!r||!r.refresh_token||!r.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const l=Math.floor((r.expires_at*1e3-e)/Jr);this._debug("#_autoRefreshTokenTick()",`access token expires in ${l} ticks, a tick lasts ${Jr}ms, refresh threshold is ${Yf} ticks`),l<=Yf&&await this._callRefreshToken(r.refresh_token)})}catch(s){console.error("Auto refresh tick failed with error. This is likely a transient error.",s)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof pw)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!Gt()||!window?.addEventListener)return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(e){this._debug("#visibilityChangedCallback","error",e)}},window?.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const s=`#_onVisibilityChanged(${e})`;this._debug(s,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{if(document.visibilityState!=="visible"){this._debug(s,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,s,r){const l=[`provider=${encodeURIComponent(s)}`];if(r?.redirectTo&&l.push(`redirect_to=${encodeURIComponent(r.redirectTo)}`),r?.scopes&&l.push(`scopes=${encodeURIComponent(r.scopes)}`),this.flowType==="pkce"){const[u,d]=await qr(this.storage,this.storageKey),h=new URLSearchParams({code_challenge:`${encodeURIComponent(u)}`,code_challenge_method:`${encodeURIComponent(d)}`});l.push(h.toString())}if(r?.queryParams){const u=new URLSearchParams(r.queryParams);l.push(u.toString())}return r?.skipBrowserRedirect&&l.push(`skip_http_redirect=${r.skipBrowserRedirect}`),`${e}?${l.join("&")}`}async _unenroll(e){try{return await this._useSession(async s=>{var r;const{data:l,error:u}=s;return u?this._returnResult({data:null,error:u}):await Re(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(r=l?.session)===null||r===void 0?void 0:r.access_token})})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async _enroll(e){try{return await this._useSession(async s=>{var r,l;const{data:u,error:d}=s;if(d)return this._returnResult({data:null,error:d});const h=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:e.factorType==="totp"?{issuer:e.issuer}:{}),{data:m,error:g}=await Re(this.fetch,"POST",`${this.url}/factors`,{body:h,headers:this.headers,jwt:(r=u?.session)===null||r===void 0?void 0:r.access_token});return g?this._returnResult({data:null,error:g}):(e.factorType==="totp"&&m.type==="totp"&&(!((l=m?.totp)===null||l===void 0)&&l.qr_code)&&(m.totp.qr_code=`data:image/svg+xml;utf-8,${m.totp.qr_code}`),this._returnResult({data:m,error:null}))})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async _verify(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async s=>{var r;const{data:l,error:u}=s;if(u)return this._returnResult({data:null,error:u});const d=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:e.webauthn.type==="create"?aE(e.webauthn.credential_response):rE(e.webauthn.credential_response)})}:{code:e.code}),{data:h,error:m}=await Re(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:d,headers:this.headers,jwt:(r=l?.session)===null||r===void 0?void 0:r.access_token});return m?this._returnResult({data:null,error:m}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+h.expires_in},h)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",h),this._returnResult({data:h,error:m}))})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}})}async _challenge(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async s=>{var r;const{data:l,error:u}=s;if(u)return this._returnResult({data:null,error:u});const d=await Re(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(r=l?.session)===null||r===void 0?void 0:r.access_token});if(d.error)return d;const{data:h}=d;if(h.type!=="webauthn")return{data:h,error:null};switch(h.webauthn.type){case"create":return{data:Object.assign(Object.assign({},h),{webauthn:Object.assign(Object.assign({},h.webauthn),{credential_options:Object.assign(Object.assign({},h.webauthn.credential_options),{publicKey:nE(h.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},h),{webauthn:Object.assign(Object.assign({},h.webauthn),{credential_options:Object.assign(Object.assign({},h.webauthn.credential_options),{publicKey:sE(h.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}})}async _challengeAndVerify(e){const{data:s,error:r}=await this._challenge({factorId:e.factorId});return r?this._returnResult({data:null,error:r}):await this._verify({factorId:e.factorId,challengeId:s.id,code:e.code})}async _listFactors(){var e;const{data:{user:s},error:r}=await this.getUser();if(r)return{data:null,error:r};const l={all:[],phone:[],totp:[],webauthn:[]};for(const u of(e=s?.factors)!==null&&e!==void 0?e:[])l.all.push(u),u.status==="verified"&&l[u.factor_type].push(u);return{data:l,error:null}}async _getAuthenticatorAssuranceLevel(e){var s,r,l,u;if(e)try{const{payload:S}=Rc(e);let E=null;S.aal&&(E=S.aal);let j=E;const{data:{user:_},error:N}=await this.getUser(e);if(N)return this._returnResult({data:null,error:N});((r=(s=_?.factors)===null||s===void 0?void 0:s.filter(A=>A.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(j="aal2");const C=S.amr||[];return{data:{currentLevel:E,nextLevel:j,currentAuthenticationMethods:C},error:null}}catch(S){if(Ne(S))return this._returnResult({data:null,error:S});throw S}const{data:{session:d},error:h}=await this.getSession();if(h)return this._returnResult({data:null,error:h});if(!d)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:m}=Rc(d.access_token);let g=null;m.aal&&(g=m.aal);let y=g;((u=(l=d.user.factors)===null||l===void 0?void 0:l.filter(S=>S.status==="verified"))!==null&&u!==void 0?u:[]).length>0&&(y="aal2");const w=m.amr||[];return{data:{currentLevel:g,nextLevel:y,currentAuthenticationMethods:w},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async s=>{const{data:{session:r},error:l}=s;return l?this._returnResult({data:null,error:l}):r?await Re(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:r.access_token,xform:u=>({data:u,error:null})}):this._returnResult({data:null,error:new xn})})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async _approveAuthorization(e,s){try{return await this._useSession(async r=>{const{data:{session:l},error:u}=r;if(u)return this._returnResult({data:null,error:u});if(!l)return this._returnResult({data:null,error:new xn});const d=await Re(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:l.access_token,body:{action:"approve"},xform:h=>({data:h,error:null})});return d.data&&d.data.redirect_url&&Gt()&&!s?.skipBrowserRedirect&&window.location.assign(d.data.redirect_url),d})}catch(r){if(Ne(r))return this._returnResult({data:null,error:r});throw r}}async _denyAuthorization(e,s){try{return await this._useSession(async r=>{const{data:{session:l},error:u}=r;if(u)return this._returnResult({data:null,error:u});if(!l)return this._returnResult({data:null,error:new xn});const d=await Re(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:l.access_token,body:{action:"deny"},xform:h=>({data:h,error:null})});return d.data&&d.data.redirect_url&&Gt()&&!s?.skipBrowserRedirect&&window.location.assign(d.data.redirect_url),d})}catch(r){if(Ne(r))return this._returnResult({data:null,error:r});throw r}}async _listOAuthGrants(){try{return await this._useSession(async e=>{const{data:{session:s},error:r}=e;return r?this._returnResult({data:null,error:r}):s?await Re(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:s.access_token,xform:l=>({data:l,error:null})}):this._returnResult({data:null,error:new xn})})}catch(e){if(Ne(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async s=>{const{data:{session:r},error:l}=s;return l?this._returnResult({data:null,error:l}):r?(await Re(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:r.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new xn})})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async fetchJwk(e,s={keys:[]}){let r=s.keys.find(h=>h.kid===e);if(r)return r;const l=Date.now();if(r=this.jwks.keys.find(h=>h.kid===e),r&&this.jwks_cached_at+mT>l)return r;const{data:u,error:d}=await Re(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(d)throw d;return!u.keys||u.keys.length===0||(this.jwks=u,this.jwks_cached_at=l,r=u.keys.find(h=>h.kid===e),!r)?null:r}async getClaims(e,s={}){try{let r=e;if(!r){const{data:S,error:E}=await this.getSession();if(E||!S.session)return this._returnResult({data:null,error:E});r=S.session.access_token}const{header:l,payload:u,signature:d,raw:{header:h,payload:m}}=Rc(r);s?.allowExpired||zT(u.exp);const g=!l.alg||l.alg.startsWith("HS")||!l.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(l.kid,s?.keys?{keys:s.keys}:s?.jwks);if(!g){const{error:S}=await this.getUser(r);if(S)throw S;return{data:{claims:u,header:l,signature:d},error:null}}const y=LT(l.alg),x=await crypto.subtle.importKey("jwk",g,y,!0,["verify"]);if(!await crypto.subtle.verify(y,x,d,jT(`${h}.${m}`)))throw new Jf("Invalid JWT signature");return{data:{claims:u,header:l,signature:d},error:null}}catch(r){if(Ne(r))return this._returnResult({data:null,error:r});throw r}}}Lo.nextInstanceID={};const mE=Lo,pE="2.97.0";let wo="";typeof Deno<"u"?wo="deno":typeof document<"u"?wo="web":typeof navigator<"u"&&navigator.product==="ReactNative"?wo="react-native":wo="node";const gE={"X-Client-Info":`supabase-js-${wo}/${pE}`},yE={headers:gE},vE={schema:"public"},xE={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},bE={};function Uo(t){"@babel/helpers - typeof";return Uo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Uo(t)}function wE(t,e){if(Uo(t)!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var r=s.call(t,e);if(Uo(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function SE(t){var e=wE(t,"string");return Uo(e)=="symbol"?e:e+""}function jE(t,e,s){return(e=SE(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function r0(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(t,l).enumerable})),s.push.apply(s,r)}return s}function yt(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?r0(Object(s),!0).forEach(function(r){jE(t,r,s[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):r0(Object(s)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(s,r))})}return t}const _E=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),NE=()=>Headers,TE=(t,e,s)=>{const r=_E(s),l=NE();return async(u,d)=>{var h;const m=(h=await e())!==null&&h!==void 0?h:t;let g=new l(d?.headers);return g.has("apikey")||g.set("apikey",t),g.has("Authorization")||g.set("Authorization",`Bearer ${m}`),r(u,yt(yt({},d),{},{headers:g}))}};function EE(t){return t.endsWith("/")?t:t+"/"}function kE(t,e){var s,r;const{db:l,auth:u,realtime:d,global:h}=t,{db:m,auth:g,realtime:y,global:x}=e,w={db:yt(yt({},m),l),auth:yt(yt({},g),u),realtime:yt(yt({},y),d),storage:{},global:yt(yt(yt({},x),h),{},{headers:yt(yt({},(s=x?.headers)!==null&&s!==void 0?s:{}),(r=h?.headers)!==null&&r!==void 0?r:{})}),accessToken:async()=>""};return t.accessToken?w.accessToken=t.accessToken:delete w.accessToken,w}function CE(t){const e=t?.trim();if(!e)throw new Error("supabaseUrl is required.");if(!e.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(EE(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var AE=class extends mE{constructor(t){super(t)}},RE=class{constructor(t,e,s){var r,l;this.supabaseUrl=t,this.supabaseKey=e;const u=CE(t);if(!e)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",u),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",u),this.storageUrl=new URL("storage/v1",u),this.functionsUrl=new URL("functions/v1",u);const d=`sb-${u.hostname.split(".")[0]}-auth-token`,h={db:vE,realtime:bE,auth:yt(yt({},xE),{},{storageKey:d}),global:yE},m=kE(s??{},h);if(this.storageKey=(r=m.auth.storageKey)!==null&&r!==void 0?r:"",this.headers=(l=m.global.headers)!==null&&l!==void 0?l:{},m.accessToken)this.accessToken=m.accessToken,this.auth=new Proxy({},{get:(y,x)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(x)} is not possible`)}});else{var g;this.auth=this._initSupabaseAuthClient((g=m.auth)!==null&&g!==void 0?g:{},this.headers,m.global.fetch)}this.fetch=TE(e,this._getAccessToken.bind(this),m.global.fetch),this.realtime=this._initRealtimeClient(yt({headers:this.headers,accessToken:this._getAccessToken.bind(this)},m.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(y=>this.realtime.setAuth(y)).catch(y=>console.warn("Failed to set initial Realtime auth token:",y)),this.rest=new g2(new URL("rest/v1",u).href,{headers:this.headers,schema:m.db.schema,fetch:this.fetch,timeout:m.db.timeout,urlLengthLimit:m.db.urlLengthLimit}),this.storage=new cT(this.storageUrl.href,this.headers,this.fetch,s?.storage),m.accessToken||this._listenForAuthEvents()}get functions(){return new l2(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(t){return this.rest.from(t)}schema(t){return this.rest.schema(t)}rpc(t,e={},s={head:!1,get:!1,count:void 0}){return this.rest.rpc(t,e,s)}channel(t,e={config:{}}){return this.realtime.channel(t,e)}getChannels(){return this.realtime.getChannels()}removeChannel(t){return this.realtime.removeChannel(t)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var t=this,e,s;if(t.accessToken)return await t.accessToken();const{data:r}=await t.auth.getSession();return(e=(s=r.session)===null||s===void 0?void 0:s.access_token)!==null&&e!==void 0?e:t.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:t,persistSession:e,detectSessionInUrl:s,storage:r,userStorage:l,storageKey:u,flowType:d,lock:h,debug:m,throwOnError:g},y,x){const w={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new AE({url:this.authUrl.href,headers:yt(yt({},w),y),storageKey:u,autoRefreshToken:t,persistSession:e,detectSessionInUrl:s,storage:r,userStorage:l,flowType:d,lock:h,debug:m,throwOnError:g,fetch:x,hasCustomAuthorizationHeader:Object.keys(this.headers).some(S=>S.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new M2(this.realtimeUrl.href,yt(yt({},t),{},{params:yt(yt({},{apikey:this.supabaseKey}),t?.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,e)=>{this._handleTokenChanged(t,"CLIENT",e?.access_token)})}_handleTokenChanged(t,e,s){(t==="TOKEN_REFRESHED"||t==="SIGNED_IN")&&this.changedAccessToken!==s?(this.changedAccessToken=s,this.realtime.setAuth(s)):t==="SIGNED_OUT"&&(this.realtime.setAuth(),e=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};const zm=(t,e,s)=>new RE(t,e,s);function OE(){if(typeof window<"u")return!1;const t=globalThis.process;if(!t)return!1;const e=t.version;if(e==null)return!1;const s=e.match(/^v(\d+)\./);return s?parseInt(s[1],10)<=18:!1}OE()&&console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");function vw(t){var e,s,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var l=t.length;for(e=0;e<l;e++)t[e]&&(s=vw(t[e]))&&(r&&(r+=" "),r+=s)}else for(s in t)t[s]&&(r&&(r+=" "),r+=s);return r}function xw(){for(var t,e,s=0,r="",l=arguments.length;s<l;s++)(t=arguments[s])&&(e=vw(t))&&(r&&(r+=" "),r+=e);return r}const ME=(t,e)=>{const s=new Array(t.length+e.length);for(let r=0;r<t.length;r++)s[r]=t[r];for(let r=0;r<e.length;r++)s[t.length+r]=e[r];return s},DE=(t,e)=>({classGroupId:t,validator:e}),bw=(t=new Map,e=null,s)=>({nextPart:t,validators:e,classGroupId:s}),iu="-",i0=[],PE="arbitrary..",zE=t=>{const e=UE(t),{conflictingClassGroups:s,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:d=>{if(d.startsWith("[")&&d.endsWith("]"))return LE(d);const h=d.split(iu),m=h[0]===""&&h.length>1?1:0;return ww(h,m,e)},getConflictingClassGroupIds:(d,h)=>{if(h){const m=r[d],g=s[d];return m?g?ME(g,m):m:g||i0}return s[d]||i0}}},ww=(t,e,s)=>{if(t.length-e===0)return s.classGroupId;const l=t[e],u=s.nextPart.get(l);if(u){const g=ww(t,e+1,u);if(g)return g}const d=s.validators;if(d===null)return;const h=e===0?t.join(iu):t.slice(e).join(iu),m=d.length;for(let g=0;g<m;g++){const y=d[g];if(y.validator(h))return y.classGroupId}},LE=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),s=e.indexOf(":"),r=e.slice(0,s);return r?PE+r:void 0})(),UE=t=>{const{theme:e,classGroups:s}=t;return BE(s,e)},BE=(t,e)=>{const s=bw();for(const r in t){const l=t[r];Lm(l,s,r,e)}return s},Lm=(t,e,s,r)=>{const l=t.length;for(let u=0;u<l;u++){const d=t[u];VE(d,e,s,r)}},VE=(t,e,s,r)=>{if(typeof t=="string"){IE(t,e,s);return}if(typeof t=="function"){$E(t,e,s,r);return}qE(t,e,s,r)},IE=(t,e,s)=>{const r=t===""?e:Sw(e,t);r.classGroupId=s},$E=(t,e,s,r)=>{if(HE(t)){Lm(t(r),e,s,r);return}e.validators===null&&(e.validators=[]),e.validators.push(DE(s,t))},qE=(t,e,s,r)=>{const l=Object.entries(t),u=l.length;for(let d=0;d<u;d++){const[h,m]=l[d];Lm(m,Sw(e,h),s,r)}},Sw=(t,e)=>{let s=t;const r=e.split(iu),l=r.length;for(let u=0;u<l;u++){const d=r[u];let h=s.nextPart.get(d);h||(h=bw(),s.nextPart.set(d,h)),s=h}return s},HE=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,GE=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,s=Object.create(null),r=Object.create(null);const l=(u,d)=>{s[u]=d,e++,e>t&&(e=0,r=s,s=Object.create(null))};return{get(u){let d=s[u];if(d!==void 0)return d;if((d=r[u])!==void 0)return l(u,d),d},set(u,d){u in s?s[u]=d:l(u,d)}}},Qf="!",o0=":",FE=[],l0=(t,e,s,r,l)=>({modifiers:t,hasImportantModifier:e,baseClassName:s,maybePostfixModifierPosition:r,isExternal:l}),KE=t=>{const{prefix:e,experimentalParseClassName:s}=t;let r=l=>{const u=[];let d=0,h=0,m=0,g;const y=l.length;for(let j=0;j<y;j++){const _=l[j];if(d===0&&h===0){if(_===o0){u.push(l.slice(m,j)),m=j+1;continue}if(_==="/"){g=j;continue}}_==="["?d++:_==="]"?d--:_==="("?h++:_===")"&&h--}const x=u.length===0?l:l.slice(m);let w=x,S=!1;x.endsWith(Qf)?(w=x.slice(0,-1),S=!0):x.startsWith(Qf)&&(w=x.slice(1),S=!0);const E=g&&g>m?g-m:void 0;return l0(u,S,w,E)};if(e){const l=e+o0,u=r;r=d=>d.startsWith(l)?u(d.slice(l.length)):l0(FE,!1,d,void 0,!0)}if(s){const l=r;r=u=>s({className:u,parseClassName:l})}return r},YE=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((s,r)=>{e.set(s,1e6+r)}),s=>{const r=[];let l=[];for(let u=0;u<s.length;u++){const d=s[u],h=d[0]==="[",m=e.has(d);h||m?(l.length>0&&(l.sort(),r.push(...l),l=[]),r.push(d)):l.push(d)}return l.length>0&&(l.sort(),r.push(...l)),r}},XE=t=>({cache:GE(t.cacheSize),parseClassName:KE(t),sortModifiers:YE(t),...zE(t)}),WE=/\s+/,JE=(t,e)=>{const{parseClassName:s,getClassGroupId:r,getConflictingClassGroupIds:l,sortModifiers:u}=e,d=[],h=t.trim().split(WE);let m="";for(let g=h.length-1;g>=0;g-=1){const y=h[g],{isExternal:x,modifiers:w,hasImportantModifier:S,baseClassName:E,maybePostfixModifierPosition:j}=s(y);if(x){m=y+(m.length>0?" "+m:m);continue}let _=!!j,N=r(_?E.substring(0,j):E);if(!N){if(!_){m=y+(m.length>0?" "+m:m);continue}if(N=r(E),!N){m=y+(m.length>0?" "+m:m);continue}_=!1}const k=w.length===0?"":w.length===1?w[0]:u(w).join(":"),C=S?k+Qf:k,A=C+N;if(d.indexOf(A)>-1)continue;d.push(A);const D=l(N,_);for(let U=0;U<D.length;++U){const V=D[U];d.push(C+V)}m=y+(m.length>0?" "+m:m)}return m},QE=(...t)=>{let e=0,s,r,l="";for(;e<t.length;)(s=t[e++])&&(r=jw(s))&&(l&&(l+=" "),l+=r);return l},jw=t=>{if(typeof t=="string")return t;let e,s="";for(let r=0;r<t.length;r++)t[r]&&(e=jw(t[r]))&&(s&&(s+=" "),s+=e);return s},ZE=(t,...e)=>{let s,r,l,u;const d=m=>{const g=e.reduce((y,x)=>x(y),t());return s=XE(g),r=s.cache.get,l=s.cache.set,u=h,h(m)},h=m=>{const g=r(m);if(g)return g;const y=JE(m,s);return l(m,y),y};return u=d,(...m)=>u(QE(...m))},ek=[],At=t=>{const e=s=>s[t]||ek;return e.isThemeGetter=!0,e},_w=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Nw=/^\((?:(\w[\w-]*):)?(.+)\)$/i,tk=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,nk=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,sk=/\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$/,ak=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,rk=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ik=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,aa=t=>tk.test(t),Ue=t=>!!t&&!Number.isNaN(Number(t)),ra=t=>!!t&&Number.isInteger(Number(t)),df=t=>t.endsWith("%")&&Ue(t.slice(0,-1)),Es=t=>nk.test(t),Tw=()=>!0,ok=t=>sk.test(t)&&!ak.test(t),Um=()=>!1,lk=t=>rk.test(t),ck=t=>ik.test(t),uk=t=>!xe(t)&&!we(t),dk=t=>ga(t,Cw,Um),xe=t=>_w.test(t),Ba=t=>ga(t,Aw,ok),c0=t=>ga(t,xk,Ue),hk=t=>ga(t,Ow,Tw),fk=t=>ga(t,Rw,Um),u0=t=>ga(t,Ew,Um),mk=t=>ga(t,kw,ck),Oc=t=>ga(t,Mw,lk),we=t=>Nw.test(t),vo=t=>tr(t,Aw),pk=t=>tr(t,Rw),d0=t=>tr(t,Ew),gk=t=>tr(t,Cw),yk=t=>tr(t,kw),Mc=t=>tr(t,Mw,!0),vk=t=>tr(t,Ow,!0),ga=(t,e,s)=>{const r=_w.exec(t);return r?r[1]?e(r[1]):s(r[2]):!1},tr=(t,e,s=!1)=>{const r=Nw.exec(t);return r?r[1]?e(r[1]):s:!1},Ew=t=>t==="position"||t==="percentage",kw=t=>t==="image"||t==="url",Cw=t=>t==="length"||t==="size"||t==="bg-size",Aw=t=>t==="length",xk=t=>t==="number",Rw=t=>t==="family-name",Ow=t=>t==="number"||t==="weight",Mw=t=>t==="shadow",bk=()=>{const t=At("color"),e=At("font"),s=At("text"),r=At("font-weight"),l=At("tracking"),u=At("leading"),d=At("breakpoint"),h=At("container"),m=At("spacing"),g=At("radius"),y=At("shadow"),x=At("inset-shadow"),w=At("text-shadow"),S=At("drop-shadow"),E=At("blur"),j=At("perspective"),_=At("aspect"),N=At("ease"),k=At("animate"),C=()=>["auto","avoid","all","avoid-page","page","left","right","column"],A=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],D=()=>[...A(),we,xe],U=()=>["auto","hidden","clip","visible","scroll"],V=()=>["auto","contain","none"],R=()=>[we,xe,m],P=()=>[aa,"full","auto",...R()],Z=()=>[ra,"none","subgrid",we,xe],te=()=>["auto",{span:["full",ra,we,xe]},ra,we,xe],me=()=>[ra,"auto",we,xe],Ee=()=>["auto","min","max","fr",we,xe],ye=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],_e=()=>["start","end","center","stretch","center-safe","end-safe"],$=()=>["auto",...R()],Y=()=>[aa,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],J=()=>[aa,"screen","full","dvw","lvw","svw","min","max","fit",...R()],pe=()=>[aa,"screen","full","lh","dvh","lvh","svh","min","max","fit",...R()],se=()=>[t,we,xe],M=()=>[...A(),d0,u0,{position:[we,xe]}],L=()=>["no-repeat",{repeat:["","x","y","space","round"]}],W=()=>["auto","cover","contain",gk,dk,{size:[we,xe]}],ne=()=>[df,vo,Ba],oe=()=>["","none","full",g,we,xe],ue=()=>["",Ue,vo,Ba],q=()=>["solid","dashed","dotted","double"],fe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ie=()=>[Ue,df,d0,u0],ze=()=>["","none",E,we,xe],Be=()=>["none",Ue,we,xe],kt=()=>["none",Ue,we,xe],et=()=>[Ue,we,xe],le=()=>[aa,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Es],breakpoint:[Es],color:[Tw],container:[Es],"drop-shadow":[Es],ease:["in","out","in-out"],font:[uk],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Es],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Es],shadow:[Es],spacing:["px",Ue],text:[Es],"text-shadow":[Es],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",aa,xe,we,_]}],container:["container"],columns:[{columns:[Ue,xe,we,h]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"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:D()}],overflow:[{overflow:U()}],"overflow-x":[{"overflow-x":U()}],"overflow-y":[{"overflow-y":U()}],overscroll:[{overscroll:V()}],"overscroll-x":[{"overscroll-x":V()}],"overscroll-y":[{"overscroll-y":V()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:P()}],"inset-x":[{"inset-x":P()}],"inset-y":[{"inset-y":P()}],start:[{"inset-s":P(),start:P()}],end:[{"inset-e":P(),end:P()}],"inset-bs":[{"inset-bs":P()}],"inset-be":[{"inset-be":P()}],top:[{top:P()}],right:[{right:P()}],bottom:[{bottom:P()}],left:[{left:P()}],visibility:["visible","invisible","collapse"],z:[{z:[ra,"auto",we,xe]}],basis:[{basis:[aa,"full","auto",h,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ue,aa,"auto","initial","none",xe]}],grow:[{grow:["",Ue,we,xe]}],shrink:[{shrink:["",Ue,we,xe]}],order:[{order:[ra,"first","last","none",we,xe]}],"grid-cols":[{"grid-cols":Z()}],"col-start-end":[{col:te()}],"col-start":[{"col-start":me()}],"col-end":[{"col-end":me()}],"grid-rows":[{"grid-rows":Z()}],"row-start-end":[{row:te()}],"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":Ee()}],"auto-rows":[{"auto-rows":Ee()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...ye(),"normal"]}],"justify-items":[{"justify-items":[..._e(),"normal"]}],"justify-self":[{"justify-self":["auto",..._e()]}],"align-content":[{content:["normal",...ye()]}],"align-items":[{items:[..._e(),{baseline:["","last"]}]}],"align-self":[{self:["auto",..._e(),{baseline:["","last"]}]}],"place-content":[{"place-content":ye()}],"place-items":[{"place-items":[..._e(),"baseline"]}],"place-self":[{"place-self":["auto",..._e()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pbs:[{pbs:R()}],pbe:[{pbe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:$()}],mx:[{mx:$()}],my:[{my:$()}],ms:[{ms:$()}],me:[{me:$()}],mbs:[{mbs:$()}],mbe:[{mbe:$()}],mt:[{mt:$()}],mr:[{mr:$()}],mb:[{mb:$()}],ml:[{ml:$()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:Y()}],"inline-size":[{inline:["auto",...J()]}],"min-inline-size":[{"min-inline":["auto",...J()]}],"max-inline-size":[{"max-inline":["none",...J()]}],"block-size":[{block:["auto",...pe()]}],"min-block-size":[{"min-block":["auto",...pe()]}],"max-block-size":[{"max-block":["none",...pe()]}],w:[{w:[h,"screen",...Y()]}],"min-w":[{"min-w":[h,"screen","none",...Y()]}],"max-w":[{"max-w":[h,"screen","none","prose",{screen:[d]},...Y()]}],h:[{h:["screen","lh",...Y()]}],"min-h":[{"min-h":["screen","lh","none",...Y()]}],"max-h":[{"max-h":["screen","lh",...Y()]}],"font-size":[{text:["base",s,vo,Ba]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,vk,hk]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",df,xe]}],"font-family":[{font:[pk,fk,e]}],"font-features":[{"font-features":[xe]}],"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:[l,we,xe]}],"line-clamp":[{"line-clamp":[Ue,"none",we,c0]}],leading:[{leading:[u,...R()]}],"list-image":[{"list-image":["none",we,xe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",we,xe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:se()}],"text-color":[{text:se()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...q(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ue,"from-font","auto",we,Ba]}],"text-decoration-color":[{decoration:se()}],"underline-offset":[{"underline-offset":[Ue,"auto",we,xe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",we,xe]}],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",we,xe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:M()}],"bg-repeat":[{bg:L()}],"bg-size":[{bg:W()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ra,we,xe],radial:["",we,xe],conic:[ra,we,xe]},yk,mk]}],"bg-color":[{bg:se()}],"gradient-from-pos":[{from:ne()}],"gradient-via-pos":[{via:ne()}],"gradient-to-pos":[{to:ne()}],"gradient-from":[{from:se()}],"gradient-via":[{via:se()}],"gradient-to":[{to:se()}],rounded:[{rounded:oe()}],"rounded-s":[{"rounded-s":oe()}],"rounded-e":[{"rounded-e":oe()}],"rounded-t":[{"rounded-t":oe()}],"rounded-r":[{"rounded-r":oe()}],"rounded-b":[{"rounded-b":oe()}],"rounded-l":[{"rounded-l":oe()}],"rounded-ss":[{"rounded-ss":oe()}],"rounded-se":[{"rounded-se":oe()}],"rounded-ee":[{"rounded-ee":oe()}],"rounded-es":[{"rounded-es":oe()}],"rounded-tl":[{"rounded-tl":oe()}],"rounded-tr":[{"rounded-tr":oe()}],"rounded-br":[{"rounded-br":oe()}],"rounded-bl":[{"rounded-bl":oe()}],"border-w":[{border:ue()}],"border-w-x":[{"border-x":ue()}],"border-w-y":[{"border-y":ue()}],"border-w-s":[{"border-s":ue()}],"border-w-e":[{"border-e":ue()}],"border-w-bs":[{"border-bs":ue()}],"border-w-be":[{"border-be":ue()}],"border-w-t":[{"border-t":ue()}],"border-w-r":[{"border-r":ue()}],"border-w-b":[{"border-b":ue()}],"border-w-l":[{"border-l":ue()}],"divide-x":[{"divide-x":ue()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ue()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...q(),"hidden","none"]}],"divide-style":[{divide:[...q(),"hidden","none"]}],"border-color":[{border:se()}],"border-color-x":[{"border-x":se()}],"border-color-y":[{"border-y":se()}],"border-color-s":[{"border-s":se()}],"border-color-e":[{"border-e":se()}],"border-color-bs":[{"border-bs":se()}],"border-color-be":[{"border-be":se()}],"border-color-t":[{"border-t":se()}],"border-color-r":[{"border-r":se()}],"border-color-b":[{"border-b":se()}],"border-color-l":[{"border-l":se()}],"divide-color":[{divide:se()}],"outline-style":[{outline:[...q(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ue,we,xe]}],"outline-w":[{outline:["",Ue,vo,Ba]}],"outline-color":[{outline:se()}],shadow:[{shadow:["","none",y,Mc,Oc]}],"shadow-color":[{shadow:se()}],"inset-shadow":[{"inset-shadow":["none",x,Mc,Oc]}],"inset-shadow-color":[{"inset-shadow":se()}],"ring-w":[{ring:ue()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:se()}],"ring-offset-w":[{"ring-offset":[Ue,Ba]}],"ring-offset-color":[{"ring-offset":se()}],"inset-ring-w":[{"inset-ring":ue()}],"inset-ring-color":[{"inset-ring":se()}],"text-shadow":[{"text-shadow":["none",w,Mc,Oc]}],"text-shadow-color":[{"text-shadow":se()}],opacity:[{opacity:[Ue,we,xe]}],"mix-blend":[{"mix-blend":[...fe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":fe()}],"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":[Ue]}],"mask-image-linear-from-pos":[{"mask-linear-from":ie()}],"mask-image-linear-to-pos":[{"mask-linear-to":ie()}],"mask-image-linear-from-color":[{"mask-linear-from":se()}],"mask-image-linear-to-color":[{"mask-linear-to":se()}],"mask-image-t-from-pos":[{"mask-t-from":ie()}],"mask-image-t-to-pos":[{"mask-t-to":ie()}],"mask-image-t-from-color":[{"mask-t-from":se()}],"mask-image-t-to-color":[{"mask-t-to":se()}],"mask-image-r-from-pos":[{"mask-r-from":ie()}],"mask-image-r-to-pos":[{"mask-r-to":ie()}],"mask-image-r-from-color":[{"mask-r-from":se()}],"mask-image-r-to-color":[{"mask-r-to":se()}],"mask-image-b-from-pos":[{"mask-b-from":ie()}],"mask-image-b-to-pos":[{"mask-b-to":ie()}],"mask-image-b-from-color":[{"mask-b-from":se()}],"mask-image-b-to-color":[{"mask-b-to":se()}],"mask-image-l-from-pos":[{"mask-l-from":ie()}],"mask-image-l-to-pos":[{"mask-l-to":ie()}],"mask-image-l-from-color":[{"mask-l-from":se()}],"mask-image-l-to-color":[{"mask-l-to":se()}],"mask-image-x-from-pos":[{"mask-x-from":ie()}],"mask-image-x-to-pos":[{"mask-x-to":ie()}],"mask-image-x-from-color":[{"mask-x-from":se()}],"mask-image-x-to-color":[{"mask-x-to":se()}],"mask-image-y-from-pos":[{"mask-y-from":ie()}],"mask-image-y-to-pos":[{"mask-y-to":ie()}],"mask-image-y-from-color":[{"mask-y-from":se()}],"mask-image-y-to-color":[{"mask-y-to":se()}],"mask-image-radial":[{"mask-radial":[we,xe]}],"mask-image-radial-from-pos":[{"mask-radial-from":ie()}],"mask-image-radial-to-pos":[{"mask-radial-to":ie()}],"mask-image-radial-from-color":[{"mask-radial-from":se()}],"mask-image-radial-to-color":[{"mask-radial-to":se()}],"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":A()}],"mask-image-conic-pos":[{"mask-conic":[Ue]}],"mask-image-conic-from-pos":[{"mask-conic-from":ie()}],"mask-image-conic-to-pos":[{"mask-conic-to":ie()}],"mask-image-conic-from-color":[{"mask-conic-from":se()}],"mask-image-conic-to-color":[{"mask-conic-to":se()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:M()}],"mask-repeat":[{mask:L()}],"mask-size":[{mask:W()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",we,xe]}],filter:[{filter:["","none",we,xe]}],blur:[{blur:ze()}],brightness:[{brightness:[Ue,we,xe]}],contrast:[{contrast:[Ue,we,xe]}],"drop-shadow":[{"drop-shadow":["","none",S,Mc,Oc]}],"drop-shadow-color":[{"drop-shadow":se()}],grayscale:[{grayscale:["",Ue,we,xe]}],"hue-rotate":[{"hue-rotate":[Ue,we,xe]}],invert:[{invert:["",Ue,we,xe]}],saturate:[{saturate:[Ue,we,xe]}],sepia:[{sepia:["",Ue,we,xe]}],"backdrop-filter":[{"backdrop-filter":["","none",we,xe]}],"backdrop-blur":[{"backdrop-blur":ze()}],"backdrop-brightness":[{"backdrop-brightness":[Ue,we,xe]}],"backdrop-contrast":[{"backdrop-contrast":[Ue,we,xe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ue,we,xe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ue,we,xe]}],"backdrop-invert":[{"backdrop-invert":["",Ue,we,xe]}],"backdrop-opacity":[{"backdrop-opacity":[Ue,we,xe]}],"backdrop-saturate":[{"backdrop-saturate":[Ue,we,xe]}],"backdrop-sepia":[{"backdrop-sepia":["",Ue,we,xe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",we,xe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ue,"initial",we,xe]}],ease:[{ease:["linear","initial",N,we,xe]}],delay:[{delay:[Ue,we,xe]}],animate:[{animate:["none",k,we,xe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[j,we,xe]}],"perspective-origin":[{"perspective-origin":D()}],rotate:[{rotate:Be()}],"rotate-x":[{"rotate-x":Be()}],"rotate-y":[{"rotate-y":Be()}],"rotate-z":[{"rotate-z":Be()}],scale:[{scale:kt()}],"scale-x":[{"scale-x":kt()}],"scale-y":[{"scale-y":kt()}],"scale-z":[{"scale-z":kt()}],"scale-3d":["scale-3d"],skew:[{skew:et()}],"skew-x":[{"skew-x":et()}],"skew-y":[{"skew-y":et()}],transform:[{transform:[we,xe,"","none","gpu","cpu"]}],"transform-origin":[{origin:D()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:le()}],"translate-x":[{"translate-x":le()}],"translate-y":[{"translate-y":le()}],"translate-z":[{"translate-z":le()}],"translate-none":["translate-none"],accent:[{accent:se()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:se()}],"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",we,xe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mbs":[{"scroll-mbs":R()}],"scroll-mbe":[{"scroll-mbe":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pbs":[{"scroll-pbs":R()}],"scroll-pbe":[{"scroll-pbe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"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",we,xe]}],fill:[{fill:["none",...se()]}],"stroke-w":[{stroke:[Ue,vo,Ba,c0]}],stroke:[{stroke:["none",...se()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{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"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},wk=ZE(bk);function ge(...t){return wk(xw(t))}const ht=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("rounded-xl border bg-card text-card-foreground shadow",t),...e}));ht.displayName="Card";const zt=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("flex flex-col space-y-1.5 p-6",t),...e}));zt.displayName="CardHeader";const Lt=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("font-semibold leading-none tracking-tight",t),...e}));Lt.displayName="CardTitle";const wn=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("text-sm text-muted-foreground",t),...e}));wn.displayName="CardDescription";const xt=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("p-6 pt-0",t),...e}));xt.displayName="CardContent";const Tu=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("flex items-center p-6 pt-0",t),...e}));Tu.displayName="CardFooter";function ou({className:t}){return o.jsx("img",{src:"/folio-logo.svg",alt:"Folio Logo",className:ge("w-full h-full object-contain",t)})}const Dw=(...t)=>t.filter((e,s,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===s).join(" ").trim();const Sk=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const jk=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,r)=>r?r.toUpperCase():s.toLowerCase());const h0=t=>{const e=jk(t);return e.charAt(0).toUpperCase()+e.slice(1)};var _k={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Nk=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const Tk=v.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:s=2,absoluteStrokeWidth:r,className:l="",children:u,iconNode:d,...h},m)=>v.createElement("svg",{ref:m,..._k,width:e,height:e,stroke:t,strokeWidth:r?Number(s)*24/Number(e):s,className:Dw("lucide",l),...!u&&!Nk(h)&&{"aria-hidden":"true"},...h},[...d.map(([g,y])=>v.createElement(g,y)),...Array.isArray(u)?u:[u]]));const he=(t,e)=>{const s=v.forwardRef(({className:r,...l},u)=>v.createElement(Tk,{ref:u,iconNode:e,className:Dw(`lucide-${Sk(h0(t))}`,`lucide-${t}`,r),...l}));return s.displayName=h0(t),s};const Ek=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],ui=he("activity",Ek);const kk=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Ck=he("arrow-right",kk);const Ak=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],Rk=he("book-open",Ak);const Ok=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Zf=he("bot",Ok);const Mk=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],Pw=he("brain",Mk);const Dk=[["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"}]],Pk=he("building-2",Dk);const zk=[["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"}]],zw=he("calendar",zk);const Lk=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],Uk=he("camera",Lk);const Bk=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],as=he("check",Bk);const Vk=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Bo=he("chevron-down",Vk);const Ik=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Jo=he("chevron-left",Ik);const $k=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],di=he("chevron-right",$k);const qk=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],lu=he("chevron-up",qk);const Hk=[["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"}]],Sn=he("circle-alert",Hk);const Gk=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Fk=he("circle-check-big",Gk);const Kk=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],os=he("circle-check",Kk);const Yk=[["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"}]],Lw=he("circle-x",Yk);const Xk=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],Qo=he("clock",Xk);const Wk=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],f0=he("cloud",Wk);const Jk=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Qk=he("copy",Jk);const Zk=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],Bm=he("cpu",Zk);const eC=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Eu=he("database",eC);const tC=[["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"}]],Uw=he("external-link",tC);const nC=[["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"}]],sC=he("eye-off",nC);const aC=[["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"}]],rC=he("eye",aC);const iC=[["path",{d:"M4 12V4a2 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 8v12a2 2 0 0 1-2 2",key:"jrl274"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 16h2v6",key:"1bxocy"}],["path",{d:"M10 22h4",key:"ceow96"}],["rect",{x:"2",y:"16",width:"4",height:"6",rx:"2",key:"r45zd0"}]],oC=he("file-digit",iC);const lC=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Vm=he("file-text",lC);const cC=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Bw=he("funnel",cC);const uC=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],dC=he("globe",uC);const hC=[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]],fC=he("hard-drive",hC);const mC=[["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"}]],pC=he("history",mC);const gC=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Im=he("info",gC);const yC=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],Zo=he("key",yC);const vC=[["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"}]],xC=he("layers",vC);const bC=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],m0=he("layout-dashboard",bC);const wC=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],it=he("loader-circle",wC);const SC=[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]],Vw=he("log-in",SC);const jC=[["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"}]],Iw=he("log-out",jC);const _C=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],Vo=he("mail",_C);const NC=[["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"}]],cu=he("message-square",NC);const TC=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],$w=he("minimize-2",TC);const EC=[["path",{d:"M5 12h14",key:"1ays0h"}]],em=he("minus",EC);const kC=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],CC=he("moon",kC);const AC=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],RC=he("package",AC);const OC=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],qw=he("play",OC);const MC=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Wa=he("plus",MC);const DC=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],PC=he("refresh-ccw",DC);const zC=[["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"}]],ma=he("refresh-cw",zC);const LC=[["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}],["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09",key:"u4xsad"}],["path",{d:"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z",key:"676m9"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05",key:"92ym6u"}]],UC=he("rocket",LC);const BC=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],VC=he("save",BC);const IC=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],Hw=he("scroll-text",IC);const $C=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],qC=he("search",$C);const HC=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],GC=he("send",HC);const FC=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],KC=he("server",FC);const YC=[["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"}]],$m=he("settings-2",YC);const XC=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],WC=he("settings",XC);const JC=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],p0=he("share-2",JC);const QC=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],uu=he("shield-alert",QC);const ZC=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ya=he("shield-check",ZC);const eA=[["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"}]],Cs=he("sparkles",eA);const tA=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],nA=he("sun",tA);const sA=[["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"}]],du=he("tag",sA);const aA=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Io=he("terminal",aA);const rA=[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]],iA=he("test-tube",rA);const oA=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],lA=he("toggle-left",oA);const cA=[["circle",{cx:"15",cy:"12",r:"3",key:"1afu0r"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],uA=he("toggle-right",cA);const dA=[["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"}]],el=he("trash-2",dA);const hA=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Gw=he("triangle-alert",hA);const fA=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],tm=he("upload",fA);const mA=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],pA=he("user-plus",mA);const gA=[["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"}]],ku=he("user",gA);const yA=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],nm=he("volume-2",yA);const vA=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]],Fw=he("volume-x",vA);const xA=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],zn=he("x",xA);const bA=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],hu=he("zap",bA),Cu="folio_supabase_config";function g0(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.url=="string"&&typeof e.anonKey=="string"&&e.url.startsWith("http")&&e.anonKey.length>20&&!e.url.includes("placeholder.supabase.co")}function $o(){try{const e=localStorage.getItem(Cu);if(e){const s=JSON.parse(e);if(g0(s))return s}}catch{}const t={url:void 0,anonKey:void 0};return g0(t)?t:null}function hf(t){localStorage.setItem(Cu,JSON.stringify(t))}function wA(){localStorage.removeItem(Cu)}async function SA(t,e){if(!t.startsWith("http://")&&!t.startsWith("https://"))return{valid:!1,error:"Invalid URL format"};const s=e.startsWith("eyJ"),r=e.startsWith("sb_publishable_");if(!s&&!r)return{valid:!1,error:"Invalid anon key format"};if(r)return{valid:!0};const l=new AbortController,u=setTimeout(()=>l.abort("Validation timeout"),12e3);try{const d=await fetch(`${t}/rest/v1/`,{method:"GET",headers:{apikey:e,Authorization:`Bearer ${e}`},signal:l.signal});return d.ok?(clearTimeout(u),{valid:!0}):(clearTimeout(u),{valid:!1,error:`Connection failed (${d.status})`})}catch(d){return clearTimeout(u),d instanceof DOMException&&d.name==="AbortError"?{valid:!1,error:"Connection validation timed out (12s). Check project URL/key and network."}:{valid:!1,error:d instanceof Error?d.message:"Connection failed"}}}function jA(){return localStorage.getItem(Cu)?"ui":"none"}let Dc=null;function un(){const t=$o();return t?(Dc||(Dc=zm(t.url,t.anonKey,{auth:{autoRefreshToken:!0,persistSession:!0}})),Dc):(Dc=null,null)}function ff(){const t=$o(),e=t?`${t.url}/functions/v1`:"",s=t?.anonKey??"",u=window.location.port==="5173"?void 0||"http://localhost:3006":window.location.origin;return{edgeFunctionsUrl:e,expressApiUrl:u,anonKey:s}}class _A{edgeFunctionsUrl;expressApiUrl;anonKey;constructor(){const e=ff();this.edgeFunctionsUrl=e.edgeFunctionsUrl,this.expressApiUrl=e.expressApiUrl,this.anonKey=e.anonKey}async request(e,s,r={}){const{auth:l=!1,token:u,...d}=r,h={"Content-Type":"application/json",...d.headers||{}};l&&u&&(h.Authorization=`Bearer ${u}`);try{const m=await fetch(`${e}${s}`,{...d,headers:h}),g=await m.json().catch(()=>({}));return m.ok?{data:g}:{error:{code:g?.error?.code||"API_ERROR",message:g?.error?.message||g?.error||`Request failed (${m.status})`}}}catch(m){return{error:{code:"NETWORK_ERROR",message:m instanceof Error?m.message:"Network error"}}}}edgeRequest(e,s={}){const r={...s.headers||{},apikey:this.anonKey};return this.request(this.edgeFunctionsUrl,e,{...s,headers:r})}expressRequest(e,s={}){const r=ff(),l={...s.headers||{},"X-Supabase-Url":r.edgeFunctionsUrl.replace("/functions/v1",""),"X-Supabase-Anon-Key":r.anonKey};return this.request(this.expressApiUrl,e,{...s,headers:l})}get(e,s={}){return this.expressRequest(e,{method:"GET",...s,auth:!0})}post(e,s,r={}){return this.expressRequest(e,{method:"POST",body:s?JSON.stringify(s):void 0,...r,auth:!0})}getChatSessions(e){return this.expressRequest("/api/chat/sessions",{method:"GET",auth:!!e,token:e})}getDashboardStats(e){return this.expressRequest("/api/stats",{method:"GET",auth:!!e,token:e})}createChatSession(e){return this.expressRequest("/api/chat/sessions",{method:"POST",auth:!!e,token:e})}getChatMessages(e,s){return this.expressRequest(`/api/chat/sessions/${e}/messages`,{method:"GET",auth:!!s,token:s})}sendChatMessage(e,s){return this.expressRequest("/api/chat/message",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}getHealth(){return this.expressRequest("/api/health",{method:"GET"})}testSupabase(e,s){return this.expressRequest("/api/setup/test-supabase",{method:"POST",body:JSON.stringify({url:e,anonKey:s})})}dispatchProcessingJob(e,s){return this.expressRequest("/api/processing/dispatch",{method:"POST",auth:!!s,token:s,body:JSON.stringify({source_type:"manual",payload:e})})}getSettings(e){return this.expressRequest("/api/settings",{method:"GET",auth:!!e,token:e})}updateSettings(e,s){return this.expressRequest("/api/settings",{method:"PATCH",auth:!!s,token:s,body:JSON.stringify(e)})}getAccounts(e){return this.expressRequest("/api/accounts",{method:"GET",auth:!!e,token:e})}disconnectAccount(e,s){return this.expressRequest("/api/accounts/disconnect",{method:"POST",auth:!!s,token:s,body:JSON.stringify({accountId:e})})}getRules(e){return this.expressRequest("/api/rules",{method:"GET",auth:!!e,token:e})}createRule(e,s){return this.expressRequest("/api/rules",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}updateRule(e,s,r){return this.expressRequest(`/api/rules/${e}`,{method:"PATCH",auth:!!r,token:r,body:JSON.stringify(s)})}deleteRule(e,s){return this.expressRequest(`/api/rules/${e}`,{method:"DELETE",auth:!!s,token:s})}toggleRule(e,s){return this.expressRequest(`/api/rules/${e}/toggle`,{method:"POST",auth:!!s,token:s})}getStats(e){return this.expressRequest("/api/stats",{method:"GET",auth:!!e,token:e})}getProfile(e){return this.edgeRequest("/api-v1-profile",{method:"GET",auth:!!e,token:e})}updateProfile(e,s){return this.edgeRequest("/api-v1-profile",{method:"PATCH",auth:!!s,token:s,body:JSON.stringify(e)})}getChatProviders(e){return this.expressRequest("/api/sdk/providers/chat",{method:"GET",auth:!!e,token:e})}getEmbedProviders(e){return this.expressRequest("/api/sdk/providers/embed",{method:"GET",auth:!!e,token:e})}testLlm(e,s){return this.expressRequest("/api/sdk/test-llm",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}getGmailAuthUrl(e,s,r){return this.expressRequest("/api/accounts/gmail/auth-url",{method:"POST",auth:!!r,token:r,body:JSON.stringify({clientId:e,clientSecret:s})})}connectGmail(e,s,r,l){return this.expressRequest("/api/accounts/gmail/connect",{method:"POST",auth:!!l,token:l,body:JSON.stringify({authCode:e,clientId:s,clientSecret:r})})}getGoogleDriveAuthUrl(e,s){return this.expressRequest("/api/accounts/google-drive/auth-url",{method:"POST",auth:!!s,token:s,body:JSON.stringify({clientId:e})})}connectGoogleDrive(e,s,r,l){return this.expressRequest("/api/accounts/google-drive/connect",{method:"POST",auth:!!l,token:l,body:JSON.stringify({authCode:e,clientId:s,clientSecret:r})})}startMicrosoftDeviceFlow(e,s,r){return this.expressRequest("/api/accounts/microsoft/device-flow",{method:"POST",auth:!!r,token:r,body:JSON.stringify({clientId:e,tenantId:s})})}pollMicrosoftDeviceCode(e,s,r,l){return this.expressRequest("/api/accounts/microsoft/poll",{method:"POST",auth:!!l,token:l,body:JSON.stringify({deviceCode:e,clientId:s,tenantId:r})})}connectImap(e,s){return this.expressRequest("/api/accounts/imap/connect",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}setup(e){return this.edgeRequest("/setup",{method:"POST",body:JSON.stringify(e)})}getPolicies(e){return this.expressRequest("/api/policies",{auth:!!e,token:e})}savePolicy(e,s){return this.expressRequest("/api/policies",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}deletePolicy(e,s){return this.expressRequest(`/api/policies/${e}`,{method:"DELETE",auth:!!s,token:s})}patchPolicy(e,s,r){return this.expressRequest(`/api/policies/${e}`,{method:"PATCH",auth:!!r,token:r,body:JSON.stringify(s)})}reloadPolicies(e){return this.expressRequest("/api/policies/reload",{method:"POST",auth:!!e,token:e})}synthesizePolicy(e,s){return this.expressRequest("/api/policies/synthesize",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}getSDKChatProviders(){return this.expressRequest("/api/sdk/providers/chat")}getIngestions(e={},s){const r=new URLSearchParams;e.page&&r.set("page",String(e.page)),e.pageSize&&r.set("pageSize",String(e.pageSize)),e.q&&r.set("q",e.q);const l=r.toString()?`?${r}`:"";return this.expressRequest(`/api/ingestions${l}`,{auth:!!s,token:s})}uploadDocument(e,s){const r=new FormData;r.append("file",e);const l=ff(),u={"X-Supabase-Url":l.edgeFunctionsUrl.replace("/functions/v1",""),"X-Supabase-Anon-Key":l.anonKey};return s&&(u.Authorization=`Bearer ${s}`),fetch(`${l.expressApiUrl}/api/ingestions/upload`,{method:"POST",headers:u,body:r}).then(d=>d.json())}rerunIngestion(e,s){return this.expressRequest(`/api/ingestions/${e}/rerun`,{method:"POST",auth:!!s,token:s})}matchIngestionToPolicy(e,s,r){const l=s.learn!==!1,u=s.rerun!==!1;return this.expressRequest(`/api/ingestions/${e}/match`,{method:"POST",auth:!!r,token:r,body:JSON.stringify({policy_id:s.policyId,learn:l,rerun:u,allow_side_effects:s.allowSideEffects===!0})})}suggestPolicyRefinement(e,s,r){return this.expressRequest(`/api/ingestions/${e}/refine-policy`,{method:"POST",auth:!!r,token:r,body:JSON.stringify({policy_id:s.policyId,provider:s.provider,model:s.model})})}deleteIngestion(e,s){return this.expressRequest(`/api/ingestions/${e}`,{method:"DELETE",auth:!!s,token:s})}updateIngestionTags(e,s,r){return this.expressRequest(`/api/ingestions/${e}/tags`,{method:"PATCH",auth:!!r,token:r,body:JSON.stringify({tags:s})})}summarizeIngestion(e,s){return this.expressRequest(`/api/ingestions/${e}/summarize`,{method:"POST",auth:!!s,token:s})}getBaselineConfig(e){return this.expressRequest("/api/baseline-config",{auth:!!e,token:e})}getBaselineConfigHistory(e){return this.expressRequest("/api/baseline-config/history",{auth:!!e,token:e})}saveBaselineConfig(e,s){return this.expressRequest("/api/baseline-config",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}activateBaselineConfig(e,s){return this.expressRequest(`/api/baseline-config/${e}/activate`,{method:"POST",auth:!!s,token:s})}suggestBaselineConfig(e,s){return this.expressRequest("/api/baseline-config/suggest",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}}const Te=new _A;let ns=[],sm=new Set;function am(){sm.forEach(t=>t())}const ce={success:(t,e)=>Pc("success",t,e),error:(t,e)=>Pc("error",t,e),info:(t,e)=>Pc("info",t,e),warning:(t,e)=>Pc("warning",t,e)};function Pc(t,e,s=5e3){const r=ns.findIndex(u=>u.message===e&&u.type===t);if(r!==-1){const u=ns[r];ns=[...ns],ns[r]={...u,count:(u.count||1)+1,lastUpdated:Date.now()},am();return}const l=Math.random().toString(36).substr(2,9);ns=[...ns,{id:l,type:t,message:e,duration:s,count:1,lastUpdated:Date.now()}],am(),s>0&&setTimeout(()=>Kw(l),s)}function Kw(t){ns=ns.filter(e=>e.id!==t),am()}function NA(){const[,t]=v.useState(0);return v.useEffect(()=>{const e=()=>t(s=>s+1);return sm.add(e),()=>{sm.delete(e)}},[]),ns}const TA={success:Fk,error:Sn,info:Im,warning:Gw},EA={success:"bg-emerald-500/10 border-emerald-500/20 text-emerald-600 dark:text-emerald-400",error:"bg-destructive/10 border-destructive/20 text-destructive",info:"bg-blue-500/10 border-blue-500/20 text-blue-600 dark:text-blue-400",warning:"bg-yellow-500/10 border-yellow-500/20 text-yellow-600 dark:text-yellow-400"};function kA({toast:t}){const e=TA[t.type];return o.jsxs("div",{className:ge("flex items-start gap-3 p-4 rounded-lg border shadow-lg backdrop-blur-sm","animate-in slide-in-from-left-full duration-300",EA[t.type]),children:[o.jsxs("div",{className:"relative",children:[o.jsx(e,{className:"w-5 h-5 flex-shrink-0 mt-0.5"}),t.count&&t.count>1&&o.jsx("span",{className:"absolute -top-2 -right-2 bg-primary text-primary-foreground text-[10px] font-bold px-1.5 rounded-full border border-background scale-90 animate-in zoom-in duration-200",children:t.count})]}),o.jsx("p",{className:"text-sm flex-1",children:t.message}),o.jsx("button",{onClick:()=>Kw(t.id),className:"p-1 hover:bg-black/10 rounded transition-colors",children:o.jsx(zn,{className:"w-4 h-4"})})]})}function CA(){const t=NA();return t.length===0?null:o.jsx("div",{className:"fixed bottom-4 left-4 z-[100] flex flex-col-reverse gap-2 max-w-sm w-full",children:t.map(e=>o.jsx(kA,{toast:e},e.id))})}function AA({configSnapshot:t,configSource:e,setActivePage:s}){const[r,l]=v.useState(null),[u,d]=v.useState(!0),[h,m]=v.useState(!1),[g,y]=v.useState(!1),x=v.useRef(null),w=v.useCallback(async()=>{d(!0);try{const j=un();if(!j)return;const{data:_}=await j.auth.getSession(),N=_.session?.access_token??null;if(!N)return;const k=await Te.getDashboardStats(N);k.data?.success&&l(k.data.stats)}catch(j){console.error("Failed to fetch dashboard stats",j)}finally{d(!1)}},[]);v.useEffect(()=>{w()},[w]);const S=async j=>{const _=Array.from(j);if(_.length){s("funnel"),y(!0);try{const N=un();if(!N)return;const{data:k}=await N.auth.getSession(),C=k.session?.access_token??null;if(!C)return;for(const A of _){ce.info(`Ingesting ${A.name}…`);const D=await Te.uploadDocument?.(A,C);if(D?.success)if(D.ingestion?.status==="duplicate"){const U=D.ingestion.extracted?.original_filename??"a previous upload";ce.warning(`${A.name} is a duplicate of "${U}" — skipped.`)}else ce.success(`${A.name} → ${D.ingestion?.status}`);else ce.error(`Failed to ingest ${A.name}`)}await w()}finally{y(!1)}}},E=j=>{j.preventDefault(),m(!1),S(j.dataTransfer.files)};return o.jsxs("div",{className:"w-full mx-auto px-8 py-10 space-y-12 animate-in fade-in duration-700",children:[o.jsxs("div",{className:"text-center space-y-3",children:[o.jsxs("h2",{className:"text-4xl font-black tracking-tight flex items-center justify-center gap-3",children:[o.jsx(ou,{className:"w-10 h-10 animate-pulse"}),"Command Center"]}),o.jsx("p",{className:"text-muted-foreground text-lg max-w-2xl mx-auto",children:"Central intelligence hub for document ingestion, routing, and synthetic knowledge."})]}),o.jsxs("div",{className:"w-full space-y-10",children:[o.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[o.jsx(zc,{title:"Documents Ingested",value:r?.totalDocuments,icon:o.jsx(Vm,{className:"w-5 h-5 text-blue-500"}),isLoading:u,colorClass:"bg-blue-500/10"}),o.jsx(zc,{title:"Active Policies",value:r?.activePolicies,icon:o.jsx(p0,{className:"w-5 h-5 text-emerald-500"}),isLoading:u,colorClass:"bg-emerald-500/10"}),o.jsx(zc,{title:"Knowledge Chunks",value:r?.ragChunks,icon:o.jsx(Eu,{className:"w-5 h-5 text-purple-500"}),isLoading:u,colorClass:"bg-purple-500/10"}),o.jsx(zc,{title:"Automation Runs",value:r?.automationRuns,icon:o.jsx(ui,{className:"w-5 h-5 text-amber-500"}),isLoading:u,colorClass:"bg-amber-500/10"})]}),o.jsxs("div",{className:"grid lg:grid-cols-3 gap-6",children:[o.jsx("div",{className:"lg:col-span-2",children:o.jsxs("div",{onDragOver:j=>{j.preventDefault(),m(!0)},onDragLeave:()=>m(!1),onDrop:E,onClick:()=>x.current?.click(),className:ge("h-full rounded-2xl border-2 border-dashed transition-all cursor-pointer flex flex-col items-center justify-center gap-4 py-16",h?"border-primary bg-primary/5 scale-[1.01]":"border-muted-foreground/20 hover:border-primary/50 hover:bg-muted/30"),children:[o.jsx("input",{ref:x,type:"file",multiple:!0,hidden:!0,onChange:j=>j.target.files&&S(j.target.files)}),g?o.jsx(it,{className:"w-12 h-12 animate-spin text-primary"}):o.jsx(tm,{className:ge("w-12 h-12 transition-colors",h?"text-primary":"text-muted-foreground/50")}),o.jsxs("div",{className:"text-center space-y-1",children:[o.jsx("p",{className:"text-lg font-medium text-foreground",children:h?"Drop to ingest...":"Drag & drop files to ingest"}),o.jsx("p",{className:"text-sm text-muted-foreground/60",children:"Supports .pdf, .docx, .md, .txt (up to 20MB)"})]})]})}),o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs(ht,{className:"flex-1 cursor-pointer hover:border-primary/50 hover:bg-muted/30 transition-all flex flex-col items-center justify-center p-6 text-center shadow-sm",onClick:()=>s("chat"),children:[o.jsx("div",{className:"w-12 h-12 rounded-xl bg-indigo-500/10 flex items-center justify-center mb-4",children:o.jsx(cu,{className:"w-6 h-6 text-indigo-500"})}),o.jsx("h3",{className:"font-bold mb-1",children:"Chat with Data"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Ask questions against your vectorized knowledge base."})]}),o.jsxs(ht,{className:"flex-1 cursor-pointer hover:border-primary/50 hover:bg-muted/30 transition-all flex flex-col items-center justify-center p-6 text-center shadow-sm",onClick:()=>s("policies"),children:[o.jsx("div",{className:"w-12 h-12 rounded-xl bg-orange-500/10 flex items-center justify-center mb-4",children:o.jsx(p0,{className:"w-6 h-6 text-orange-500"})}),o.jsx("h3",{className:"font-bold mb-1",children:"Create Policy"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Define a new routing and automation contract."})]})]})]})]})]})}function zc({title:t,value:e,icon:s,isLoading:r,colorClass:l}){return o.jsx(ht,{className:"shadow-sm",children:o.jsxs(xt,{className:"p-6",children:[o.jsx("div",{className:"flex items-center justify-between mb-4",children:o.jsx("div",{className:ge("w-10 h-10 rounded-xl flex items-center justify-center",l),children:s})}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"text-sm text-muted-foreground font-medium",children:t}),r?o.jsx("div",{className:"h-8 w-16 bg-muted animate-pulse rounded-md"}):o.jsx("p",{className:"text-3xl font-black",children:e!==void 0?e.toLocaleString():"0"})]})]})})}function y0(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Au(...t){return e=>{let s=!1;const r=t.map(l=>{const u=y0(l,e);return!s&&typeof u=="function"&&(s=!0),u});if(s)return()=>{for(let l=0;l<r.length;l++){const u=r[l];typeof u=="function"?u():y0(t[l],null)}}}}function nr(...t){return v.useCallback(Au(...t),t)}var RA=Symbol.for("react.lazy"),fu=Mm[" use ".trim().toString()];function OA(t){return typeof t=="object"&&t!==null&&"then"in t}function Yw(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===RA&&"_payload"in t&&OA(t._payload)}function Xw(t){const e=DA(t),s=v.forwardRef((r,l)=>{let{children:u,...d}=r;Yw(u)&&typeof fu=="function"&&(u=fu(u._payload));const h=v.Children.toArray(u),m=h.find(zA);if(m){const g=m.props.children,y=h.map(x=>x===m?v.Children.count(g)>1?v.Children.only(null):v.isValidElement(g)?g.props.children:null:x);return o.jsx(e,{...d,ref:l,children:v.isValidElement(g)?v.cloneElement(g,void 0,y):null})}return o.jsx(e,{...d,ref:l,children:u})});return s.displayName=`${t}.Slot`,s}var MA=Xw("Slot");function DA(t){const e=v.forwardRef((s,r)=>{let{children:l,...u}=s;if(Yw(l)&&typeof fu=="function"&&(l=fu(l._payload)),v.isValidElement(l)){const d=UA(l),h=LA(u,l.props);return l.type!==v.Fragment&&(h.ref=r?Au(r,d):d),v.cloneElement(l,h)}return v.Children.count(l)>1?v.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var PA=Symbol("radix.slottable");function zA(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===PA}function LA(t,e){const s={...e};for(const r in e){const l=t[r],u=e[r];/^on[A-Z]/.test(r)?l&&u?s[r]=(...h)=>{const m=u(...h);return l(...h),m}:l&&(s[r]=l):r==="style"?s[r]={...l,...u}:r==="className"&&(s[r]=[l,u].filter(Boolean).join(" "))}return{...t,...s}}function UA(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning;return s?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning,s?t.props.ref:t.props.ref||t.ref)}const v0=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,x0=xw,qm=(t,e)=>s=>{var r;if(e?.variants==null)return x0(t,s?.class,s?.className);const{variants:l,defaultVariants:u}=e,d=Object.keys(l).map(g=>{const y=s?.[g],x=u?.[g];if(y===null)return null;const w=v0(y)||v0(x);return l[g][w]}),h=s&&Object.entries(s).reduce((g,y)=>{let[x,w]=y;return w===void 0||(g[x]=w),g},{}),m=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((g,y)=>{let{class:x,className:w,...S}=y;return Object.entries(S).every(E=>{let[j,_]=E;return Array.isArray(_)?_.includes({...u,...h}[j]):{...u,...h}[j]===_})?[...g,x,w]:g},[]);return x0(t,d,m,s?.class,s?.className)},BA=qm("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 ring-ring/10 dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 focus-visible:ring-4 focus-visible:outline-1 aria-invalid:focus-visible:ring-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-sm hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-xs hover:bg-destructive/90",outline:"border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-xs 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"}}),ae=v.forwardRef(({className:t,variant:e,size:s,asChild:r=!1,...l},u)=>{const d=r?MA:"button";return o.jsx(d,{className:ge(BA({variant:e,size:s,className:t})),ref:u,...l})});ae.displayName="Button";const je=v.forwardRef(({className:t,type:e,...s},r)=>o.jsx("input",{type:e,className:ge("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",t),ref:r,...s}));je.displayName="Input";var Ww=tw();const VA=Zb(Ww);var IA=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],$A=IA.reduce((t,e)=>{const s=Xw(`Primitive.${e}`),r=v.forwardRef((l,u)=>{const{asChild:d,...h}=l,m=d?s:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(m,{...h,ref:u})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),qA="Label",Jw=v.forwardRef((t,e)=>o.jsx($A.label,{...t,ref:e,onMouseDown:s=>{s.target.closest("button, input, select, textarea")||(t.onMouseDown?.(s),!s.defaultPrevented&&s.detail>1&&s.preventDefault())}}));Jw.displayName=qA;var HA=Jw;function Je({className:t,...e}){return o.jsx(HA,{"data-slot":"label",className:ge("flex items-center gap-2 text-sm leading-none font-medium select-none text-muted-foreground group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...e})}const GA=qm("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Pt({className:t,variant:e,...s}){return o.jsx("div",{className:ge(GA({variant:e}),t),...s})}const FA=qm("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),jn=v.forwardRef(({className:t,variant:e,...s},r)=>o.jsx("div",{ref:r,role:"alert",className:ge(FA({variant:e}),t),...s}));jn.displayName="Alert";const Hm=v.forwardRef(({className:t,...e},s)=>o.jsx("h5",{ref:s,className:ge("mb-1 font-medium leading-none tracking-tight",t),...e}));Hm.displayName="AlertTitle";const _n=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("text-sm [&_p]:leading-relaxed",t),...e}));_n.displayName="AlertDescription";function KA({supabase:t,initStatus:e,sessionStatus:s,sessionEmail:r,onRefresh:l}){const[u,d]=v.useState(""),[h,m]=v.useState(""),[g,y]=v.useState(""),[x,w]=v.useState(""),[S,E]=v.useState(!1),[j,_]=v.useState(null),N=e==="empty";async function k(){E(!0),_(null);const{error:U}=await t.auth.signInWithPassword({email:u,password:h});U?_(U.message):l(),E(!1)}async function C(){E(!0),_(null);try{const U=await Te.setup({email:u,password:h,first_name:g,last_name:x});if(U.error)throw new Error(typeof U.error=="string"?U.error:U.error.message);const{error:V}=await t.auth.signInWithPassword({email:u,password:h});if(V)throw V;l()}catch(U){_(U.message||"Failed to initialize foundation.")}finally{E(!1)}}async function A(){E(!0),_(null);const{error:U}=await t.auth.signUp({email:u,password:h,options:{data:{first_name:g,last_name:x}}});U?_(U.message):l(),E(!1)}async function D(){E(!0),await t.auth.signOut(),l(),E(!1)}return s==="authenticated"?o.jsxs("div",{className:"space-y-4 animate-in fade-in duration-500",children:[o.jsxs("div",{className:"flex items-center gap-4 p-4 rounded-xl bg-primary/5 border border-primary/10",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-primary flex items-center justify-center text-primary-foreground",children:o.jsx(ku,{className:"w-5 h-5"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-xs font-bold uppercase tracking-widest text-muted-foreground leading-none mb-1",children:"Authenticated as"}),o.jsx("p",{className:"text-sm font-medium truncate",children:r})]})]}),e==="missing_view"&&o.jsxs(jn,{variant:"destructive",className:"bg-destructive/5 text-destructive border-destructive/20",children:[o.jsx(uu,{className:"w-4 h-4"}),o.jsx(_n,{className:"text-xs",children:"Database views missing. Foundation may be corrupted."})]}),o.jsxs(ae,{variant:"outline",className:"w-full h-11 hover:bg-destructive hover:text-destructive-reveal group transition-all duration-300",onClick:D,disabled:S,children:[S?o.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(Iw,{className:"w-4 h-4 mr-2 group-hover:rotate-180 transition-transform duration-500"}),"Logout Protocol"]})]}):o.jsxs("div",{className:"space-y-4 animate-in fade-in duration-500",children:[o.jsxs("div",{className:"grid gap-4",children:[N&&o.jsxs("div",{className:"grid grid-cols-2 gap-4 animate-in slide-in-from-top-2 duration-300",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"auth-firstname",children:"First Name"}),o.jsx(je,{id:"auth-firstname",placeholder:"Agent",value:g,onChange:U=>y(U.target.value),className:"h-10"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"auth-lastname",children:"Last Name"}),o.jsx(je,{id:"auth-lastname",placeholder:"Zero",value:x,onChange:U=>w(U.target.value),className:"h-10"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"auth-email",children:"Email Address"}),o.jsxs("div",{className:"relative",children:[o.jsx(Vo,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),o.jsx(je,{id:"auth-email",type:"email",placeholder:"admin@example.com",value:u,onChange:U=>d(U.target.value),className:"pl-9 h-10"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"auth-password",children:"Security Key"}),o.jsxs("div",{className:"relative",children:[o.jsx(Zo,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),o.jsx(je,{id:"auth-password",type:"password",placeholder:"••••••••",value:h,onChange:U=>m(U.target.value),className:"pl-9 h-10",autoComplete:N?"new-password":"current-password"})]})]})]}),j&&o.jsx(jn,{variant:"destructive",className:"py-2 px-3",children:o.jsx(_n,{className:"text-[11px] leading-relaxed italic",children:j})}),o.jsx("div",{className:"pt-2",children:N?o.jsxs(ae,{className:"w-full h-11 shadow-lg shadow-primary/20",onClick:C,disabled:S||!u||!h||!g,children:[S?o.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(ya,{className:"w-4 h-4 mr-2"}),"Initialize Primary Admin"]}):o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs(ae,{className:"h-10",onClick:k,disabled:S||!u||!h,children:[S?o.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(Vw,{className:"w-4 h-4 mr-2"}),"Login"]}),o.jsxs(ae,{variant:"secondary",className:"h-10",onClick:A,disabled:S||!u||!h,children:[o.jsx(pA,{className:"w-4 h-4 mr-2"}),"Enroll"]})]})}),o.jsx("p",{className:"text-[10px] text-center text-muted-foreground uppercase tracking-widest font-bold opacity-50 pt-2",children:N?"Foundation Assembly Phase":"Foundation Access Required"})]})}const ha="0.1.7",YA="20260228000001";async function XA(t,e){const s=Promise.resolve(t);let r=null;const l=new Promise((u,d)=>{r=setTimeout(()=>{d(new Error(`Operation timed out after ${e}ms`))},e)});try{return await Promise.race([s,l])}finally{r&&clearTimeout(r)}}async function WA(t){try{const{data:e,error:s}=await XA(t.rpc("get_latest_migration_timestamp"),12e3);if(s)return s.code==="42883"?{latestMigrationTimestamp:"0"}:{latestMigrationTimestamp:null};const r=e??null;return r&&r>="29990000000000"?{latestMigrationTimestamp:null}:{latestMigrationTimestamp:r}}catch{return{latestMigrationTimestamp:null}}}async function Qw(t){const e=await WA(t);return!e.latestMigrationTimestamp||e.latestMigrationTimestamp.trim()===""?{needsMigration:!0,appVersion:ha,latestMigrationTimestamp:e.latestMigrationTimestamp,message:"Database migration state unknown."}:YA>e.latestMigrationTimestamp?{needsMigration:!0,appVersion:ha,latestMigrationTimestamp:e.latestMigrationTimestamp,message:`Database is behind (${e.latestMigrationTimestamp}).`}:{needsMigration:!1,appVersion:ha,latestMigrationTimestamp:e.latestMigrationTimestamp,message:"Database schema is up-to-date."}}function JA({supabase:t,sessionEmail:e,sessionStatus:s,initStatus:r,configSnapshot:l,configSource:u,onRefresh:d,onLaunchSetup:h,onResetSetup:m}){const[g,y]=v.useState("profile"),[x,w]=v.useState(null),[S,E]=v.useState(!1);async function j(){if(!t)return;E(!0);const{data:{user:k}}=await t.auth.getUser();if(k){const{data:C}=await t.from("profiles").select("*").eq("id",k.id).single();C&&w(C)}E(!1)}v.useEffect(()=>{s==="authenticated"&&t&&j()},[s,t]);const _=[{id:"profile",label:"Profile",icon:ku},{id:"security",label:"Security",icon:ya},{id:"supabase",label:"Supabase",icon:Eu}];async function N(){t&&(await t.auth.signOut(),d())}return o.jsxs("div",{className:"max-w-6xl mx-auto space-y-8 animate-in fade-in duration-700",children:[o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsx("h1",{className:"text-4xl font-black tracking-tight",children:"Account Settings"}),o.jsx("p",{className:"text-muted-foreground text-lg",children:"Manage your profile and foundational preferences."})]}),o.jsxs("div",{className:"flex flex-col md:flex-row gap-12 items-start",children:[o.jsxs("aside",{className:"w-full md:w-72 flex flex-col gap-8 shrink-0",children:[o.jsx("nav",{className:"space-y-1",children:_.map(k=>{const C=k.icon,A=g===k.id;return o.jsxs("button",{onClick:()=>y(k.id),className:ge("w-full flex items-center gap-3 px-4 py-3 text-sm font-bold rounded-xl transition-all duration-300",A?"bg-foreground text-background shadow-lg shadow-foreground/10":"text-muted-foreground hover:bg-muted/60 hover:text-foreground"),children:[o.jsx(C,{className:ge("w-5 h-5",A?"text-background":"text-muted-foreground/60")}),k.label]},k.id)})}),o.jsxs("div",{className:"pt-8 border-t space-y-6",children:[o.jsxs("button",{onClick:N,className:"group w-full flex items-center gap-3 px-4 py-2 text-sm font-bold rounded-xl transition-all duration-300 text-destructive hover:bg-destructive/10",children:[o.jsx(Iw,{className:"w-5 h-5 transition-transform group-hover:translate-x-1"}),"Logout"]}),o.jsxs("div",{className:"px-4",children:[o.jsx("p",{className:"text-[10px] font-black text-muted-foreground/40 uppercase tracking-widest mb-1",children:"Version"}),o.jsxs("p",{className:"text-xs font-mono text-muted-foreground/60",children:["v",ha]})]})]})]}),o.jsxs("div",{className:"flex-1 w-full animate-in slide-in-from-right-4 duration-500",children:[g==="profile"&&o.jsx(QA,{sessionEmail:e,sessionStatus:s,supabase:t,initStatus:r,profile:x,onProfileUpdate:j,onRefresh:d,isLoading:S}),g==="security"&&o.jsx(ZA,{supabase:t}),g==="supabase"&&o.jsx(eR,{configSnapshot:l,configSource:u,onLaunchSetup:h,onResetSetup:m})]})]})]})}function QA({sessionEmail:t,sessionStatus:e,supabase:s,initStatus:r,profile:l,onProfileUpdate:u,onRefresh:d,isLoading:h}){const[m,g]=v.useState(""),[y,x]=v.useState(""),[w,S]=v.useState(!0),[E,j]=v.useState(!1),[_,N]=v.useState(!1);v.useEffect(()=>{l&&(g(l.first_name||""),x(l.last_name||""))},[l]);const k=async()=>{if(!s||!l)return;j(!0);const{error:A}=await s.from("profiles").update({first_name:m,last_name:y}).eq("id",l.id);A||u(),j(!1)},C=async A=>{const D=A.target.files?.[0];if(!(!D||!s||!l)){N(!0);try{const U=D.name.split(".").pop(),V=`${l.id}/${Math.random()}.${U}`,{error:R}=await s.storage.from("avatars").upload(V,D);if(R)throw R;const{data:{publicUrl:P}}=s.storage.from("avatars").getPublicUrl(V);await s.from("profiles").update({avatar_url:P}).eq("id",l.id),u()}catch(U){console.error("Upload error:",U)}finally{N(!1)}}};return o.jsxs(ht,{className:"border-border/40 shadow-xl shadow-black/5 bg-card/50 backdrop-blur-sm overflow-hidden",children:[o.jsxs(zt,{className:"p-8 border-b bg-muted/20",children:[o.jsx(Lt,{className:"text-2xl font-black",children:"Profile Information"}),o.jsx(wn,{className:"text-base",children:"Update your personal foundation details."})]}),o.jsx(xt,{className:"p-8 space-y-10",children:h?o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(it,{className:"w-8 h-8 animate-spin text-primary"})}):e==="authenticated"?o.jsxs("div",{className:"space-y-10",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-8",children:[o.jsxs("div",{className:"relative group",children:[o.jsx("div",{className:"w-32 h-32 rounded-full bg-primary/10 border-4 border-background shadow-2xl overflow-hidden flex items-center justify-center",children:l?.avatar_url?o.jsx("img",{src:l.avatar_url,alt:"Avatar",className:"w-full h-full object-cover"}):t?o.jsx("span",{className:"text-4xl font-black text-primary",children:t.charAt(0).toUpperCase()}):o.jsx(ku,{className:"w-12 h-12 text-primary/40"})}),o.jsxs("label",{className:"absolute bottom-1 right-1 h-10 w-10 rounded-full bg-background border shadow-lg flex items-center justify-center hover:scale-110 transition-transform cursor-pointer",children:[_?o.jsx(it,{className:"w-4 h-4 animate-spin text-muted-foreground"}):o.jsx(Uk,{className:"w-5 h-5 text-muted-foreground"}),o.jsx("input",{type:"file",className:"hidden",accept:"image/*",onChange:C,disabled:_})]})]}),o.jsxs("div",{className:"flex-1 w-full grid grid-cols-1 sm:grid-cols-2 gap-6",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"firstName",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"First Name"}),o.jsx(je,{id:"firstName",placeholder:"Trung",value:m,onChange:A=>g(A.target.value),className:"h-12 rounded-xl bg-background/50 border-border/40"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"lastName",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Last Name"}),o.jsx(je,{id:"lastName",placeholder:"Le",value:y,onChange:A=>x(A.target.value),className:"h-12 rounded-xl bg-background/50 border-border/40"})]}),o.jsxs("div",{className:"sm:col-span-2 space-y-2",children:[o.jsx(Je,{htmlFor:"email",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Email Address"}),o.jsx(je,{id:"email",value:t||"",disabled:!0,className:"h-12 rounded-xl bg-muted/40 border-border/40 opacity-70 cursor-not-allowed"}),o.jsx("p",{className:"text-[10px] text-muted-foreground/60 font-bold ml-1",children:"This is your login email and cannot be changed."})]})]})]}),o.jsxs("div",{className:"pt-8 border-t flex items-center justify-between",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("h4",{className:"text-base font-bold",children:"Sound & Haptic Feedback"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Play chimes and haptic pulses for system events."})]}),o.jsxs(ae,{variant:w?"default":"outline",className:ge("h-11 px-6 rounded-xl font-bold transition-all",w?"shadow-lg shadow-primary/20":""),onClick:()=>S(!w),children:[w?o.jsx(nm,{className:"w-4 h-4 mr-2"}):o.jsx(Fw,{className:"w-4 h-4 mr-2"}),w?"Enabled":"Disabled"]})]})]}):o.jsxs("div",{className:"py-8",children:[o.jsxs("div",{className:"flex items-center gap-3 border-b pb-4 mb-6",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center text-primary",children:o.jsx(ya,{className:"w-6 h-6"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-bold",children:"Authentication Gateway"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Access your foundational profile."})]})]}),s&&o.jsx(KA,{supabase:s,initStatus:r,sessionStatus:e,sessionEmail:t,onRefresh:d})]})}),e==="authenticated"&&!h&&o.jsx(Tu,{className:"bg-muted/20 p-8 flex justify-end",children:o.jsxs(ae,{className:"h-12 px-8 rounded-xl font-bold shadow-xl shadow-primary/20",onClick:k,disabled:E,children:[E?o.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(VC,{className:"w-4 h-4 mr-2"}),"Save Changes"]})})]})}function ZA({supabase:t}){const[e,s]=v.useState(""),[r,l]=v.useState(""),[u,d]=v.useState(!1),[h,m]=v.useState(null),g=async()=>{if(!t)return;if(e!==r){m({type:"error",msg:"Passwords do not match."});return}if(e.length<8){m({type:"error",msg:"Password must be at least 8 characters."});return}d(!0),m(null);const{error:y}=await t.auth.updateUser({password:e});y?m({type:"error",msg:y.message}):(m({type:"success",msg:"Password updated successfully."}),s(""),l("")),d(!1)};return o.jsxs(ht,{className:"border-border/40 shadow-xl shadow-black/5 bg-card/50 backdrop-blur-sm overflow-hidden",children:[o.jsxs(zt,{className:"p-8 border-b bg-muted/20",children:[o.jsx(Lt,{className:"text-2xl font-black",children:"Security Protocol"}),o.jsx(wn,{className:"text-base",children:"Manage your foundation credentials and access keys."})]}),o.jsxs(xt,{className:"p-8 space-y-8",children:[h&&o.jsxs(jn,{variant:h.type==="error"?"destructive":"default",className:ge("animate-in fade-in slide-in-from-top-2 duration-300",h.type==="success"?"bg-emerald-500/10 text-emerald-600 border-emerald-500/20":""),children:[h.type==="success"?o.jsx(os,{className:"h-4 w-4"}):o.jsx(uu,{className:"h-4 w-4"}),o.jsx(_n,{className:"text-sm font-bold",children:h.msg})]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-8",children:[o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"newPass",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"New Password"}),o.jsx(je,{id:"newPass",type:"password",placeholder:"••••••••",value:e,onChange:y=>s(y.target.value),className:"h-12 rounded-xl bg-background/50 border-border/40"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"confirmPass",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Confirm Password"}),o.jsx(je,{id:"confirmPass",type:"password",placeholder:"••••••••",value:r,onChange:y=>l(y.target.value),className:"h-12 rounded-xl bg-background/50 border-border/40"})]})]}),o.jsxs("div",{className:"bg-muted/30 p-6 rounded-2xl border border-border/40 space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/10 flex items-center justify-center text-primary",children:o.jsx(uu,{className:"w-5 h-5"})}),o.jsx("h5",{className:"font-bold",children:"Security Tip"})]}),o.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"Use a password at least 12 characters long with a mix of letters, numbers, and symbols to ensure your foundational data remains secure."})]})]})]}),o.jsx(Tu,{className:"bg-muted/20 p-8 flex justify-end",children:o.jsxs(ae,{className:"h-12 px-8 rounded-xl font-bold shadow-xl shadow-primary/20",onClick:g,disabled:u||!e||!r,children:[u?o.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(Zo,{className:"w-4 h-4 mr-2"}),"Update Password"]})})]})}function eR({configSnapshot:t,configSource:e,onLaunchSetup:s,onResetSetup:r}){return o.jsxs("div",{className:"space-y-8 animate-in fade-in duration-700",children:[o.jsxs("div",{className:"flex items-center gap-3 border-b pb-4",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center text-primary",children:o.jsx(Eu,{className:"w-6 h-6"})}),o.jsxs("div",{className:"flex-1",children:[o.jsx("h3",{className:"text-lg font-bold",children:"Supabase Configuration"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Primary storage and identity gateway."})]}),o.jsxs(Pt,{variant:"secondary",className:"text-[10px] font-black uppercase tracking-widest px-3 py-1",children:["Source: ",e]})]}),o.jsxs(ht,{className:"border-border/40 shadow-sm bg-card/50 backdrop-blur-sm",children:[o.jsx(xt,{className:"p-8 space-y-8",children:t?o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("span",{className:"text-[10px] font-black uppercase text-muted-foreground tracking-widest pl-1",children:"API Endpoint"}),o.jsx("div",{className:"bg-muted/30 p-4 rounded-2xl border border-border/40 backdrop-blur-sm shadow-inner",children:o.jsx("p",{className:"text-sm font-semibold truncate text-foreground/80",children:t.url})})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("span",{className:"text-[10px] font-black uppercase text-muted-foreground tracking-widest pl-1",children:"Project Identifier"}),o.jsx("div",{className:"bg-muted/30 p-4 rounded-2xl border border-border/40 font-mono shadow-inner",children:o.jsx("p",{className:"text-sm font-semibold text-foreground/80",children:t.url.split("//")[1]?.split(".")[0]||"Unknown"})})]}),o.jsxs("div",{className:"md:col-span-2 space-y-2",children:[o.jsx("span",{className:"text-[10px] font-black uppercase text-muted-foreground tracking-widest pl-1",children:"Service Role Access (Masked)"}),o.jsxs("div",{className:"bg-muted/30 p-4 rounded-2xl border border-border/40 flex items-center justify-between shadow-inner",children:[o.jsxs("p",{className:"text-sm font-mono text-muted-foreground",children:[t.anonKey.slice(0,6),"...",t.anonKey.slice(-6)]}),o.jsx(Pt,{variant:"outline",className:"text-[9px] font-bold",children:"Standard Key"})]})]})]}):o.jsxs(jn,{className:"bg-amber-500/5 border-amber-500/20 text-amber-600 dark:text-amber-400 p-6 rounded-2xl shadow-sm",children:[o.jsx(Sn,{className:"w-5 h-5"}),o.jsx(Hm,{className:"font-bold mb-1",children:"Infrastructure Standby"}),o.jsx(_n,{className:"text-sm opacity-90",children:"The foundation has not been initialized. You must run the setup wizard to continue."})]})}),o.jsxs(Tu,{className:"bg-muted/20 p-8 flex gap-4 border-t",children:[o.jsxs(ae,{variant:t?"outline":"default",className:"flex-1 h-12 rounded-xl font-bold shadow-sm",onClick:s,children:[t?o.jsx(WC,{className:"w-4 h-4 mr-2"}):o.jsx(Wa,{className:"w-4 h-4 mr-2"}),t?"Run Setup Wizard":"Launch Initializer"]}),t&&o.jsx(ae,{variant:"ghost",size:"icon",className:"h-12 w-12 rounded-xl text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",onClick:r,title:"Reset All Configuration",children:o.jsx(PC,{className:"w-5 h-5"})})]})]}),o.jsxs("div",{className:"space-y-6 pt-4",children:[o.jsxs("div",{className:"flex items-center gap-3 border-b pb-4",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-destructive/10 flex items-center justify-center text-destructive",children:o.jsx(Sn,{className:"w-6 h-6"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-bold text-destructive",children:"Advanced Maintenance"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Destructive actions and system-level overrides."})]})]}),o.jsx(ht,{className:"border-destructive/20 bg-destructive/5 overflow-hidden shadow-sm",children:o.jsxs(xt,{className:"p-8",children:[o.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"Fully resetting the foundation will purge all local storage cached parameters. This action is irreversible and will force a fresh bootstrap flow upon next launch."}),o.jsx(ae,{variant:"link",className:"px-0 text-destructive h-auto text-xs font-black uppercase tracking-widest mt-4 hover:no-underline hover:opacity-70 transition-opacity",onClick:r,children:"Wipe Local Foundation Buffer"})]})})]})]})}const tR={theme:"system",setTheme:()=>null},Zw=v.createContext(tR);function nR({children:t,defaultTheme:e="system",storageKey:s="vite-ui-theme"}){const[r,l]=v.useState(()=>localStorage.getItem(s)||e);v.useEffect(()=>{const d=window.document.documentElement;if(d.classList.remove("light","dark"),r==="system"){const h=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";d.classList.add(h);return}d.classList.add(r)},[r]);const u=v.useMemo(()=>({theme:r,setTheme:d=>{localStorage.setItem(s,d),l(d)}}),[r,s]);return o.jsx(Zw.Provider,{value:u,children:t})}const sR=()=>{const t=v.useContext(Zw);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t};function e1(){const{setTheme:t,theme:e}=sR();return o.jsxs(ae,{variant:"ghost",size:"icon",onClick:()=>t(e==="dark"?"light":"dark"),className:"text-muted-foreground hover:bg-muted/60 transition-all duration-300 h-9 w-9 rounded-full",title:`Switch to ${e==="dark"?"light":"dark"} mode`,children:[e==="dark"?o.jsx(nA,{className:"h-[1.2rem] w-[1.2rem]"}):o.jsx(CC,{className:"h-[1.2rem] w-[1.2rem]"}),o.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}function fa(t,e,{checkForDefaultPrevented:s=!0}={}){return function(l){if(t?.(l),s===!1||!l.defaultPrevented)return e?.(l)}}function aR(t,e){const s=v.createContext(e),r=u=>{const{children:d,...h}=u,m=v.useMemo(()=>h,Object.values(h));return o.jsx(s.Provider,{value:m,children:d})};r.displayName=t+"Provider";function l(u){const d=v.useContext(s);if(d)return d;if(e!==void 0)return e;throw new Error(`\`${u}\` must be used within \`${t}\``)}return[r,l]}function rR(t,e=[]){let s=[];function r(u,d){const h=v.createContext(d),m=s.length;s=[...s,d];const g=x=>{const{scope:w,children:S,...E}=x,j=w?.[t]?.[m]||h,_=v.useMemo(()=>E,Object.values(E));return o.jsx(j.Provider,{value:_,children:S})};g.displayName=u+"Provider";function y(x,w){const S=w?.[t]?.[m]||h,E=v.useContext(S);if(E)return E;if(d!==void 0)return d;throw new Error(`\`${x}\` must be used within \`${u}\``)}return[g,y]}const l=()=>{const u=s.map(d=>v.createContext(d));return function(h){const m=h?.[t]||u;return v.useMemo(()=>({[`__scope${t}`]:{...h,[t]:m}}),[h,m])}};return l.scopeName=t,[r,iR(l,...e)]}function iR(...t){const e=t[0];if(t.length===1)return e;const s=()=>{const r=t.map(l=>({useScope:l(),scopeName:l.scopeName}));return function(u){const d=r.reduce((h,{useScope:m,scopeName:g})=>{const x=m(u)[`__scope${g}`];return{...h,...x}},{});return v.useMemo(()=>({[`__scope${e.scopeName}`]:d}),[d])}};return s.scopeName=e.scopeName,s}var qo=globalThis?.document?v.useLayoutEffect:()=>{},oR=Mm[" useId ".trim().toString()]||(()=>{}),lR=0;function mf(t){const[e,s]=v.useState(oR());return qo(()=>{s(r=>r??String(lR++))},[t]),t||(e?`radix-${e}`:"")}var cR=Mm[" useInsertionEffect ".trim().toString()]||qo;function uR({prop:t,defaultProp:e,onChange:s=()=>{},caller:r}){const[l,u,d]=dR({defaultProp:e,onChange:s}),h=t!==void 0,m=h?t:l;{const y=v.useRef(t!==void 0);v.useEffect(()=>{const x=y.current;x!==h&&console.warn(`${r} is changing from ${x?"controlled":"uncontrolled"} to ${h?"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.`),y.current=h},[h,r])}const g=v.useCallback(y=>{if(h){const x=hR(y)?y(t):y;x!==t&&d.current?.(x)}else u(y)},[h,t,u,d]);return[m,g]}function dR({defaultProp:t,onChange:e}){const[s,r]=v.useState(t),l=v.useRef(s),u=v.useRef(e);return cR(()=>{u.current=e},[e]),v.useEffect(()=>{l.current!==s&&(u.current?.(s),l.current=s)},[s,l]),[s,r,u]}function hR(t){return typeof t=="function"}function fR(t){const e=mR(t),s=v.forwardRef((r,l)=>{const{children:u,...d}=r,h=v.Children.toArray(u),m=h.find(gR);if(m){const g=m.props.children,y=h.map(x=>x===m?v.Children.count(g)>1?v.Children.only(null):v.isValidElement(g)?g.props.children:null:x);return o.jsx(e,{...d,ref:l,children:v.isValidElement(g)?v.cloneElement(g,void 0,y):null})}return o.jsx(e,{...d,ref:l,children:u})});return s.displayName=`${t}.Slot`,s}function mR(t){const e=v.forwardRef((s,r)=>{const{children:l,...u}=s;if(v.isValidElement(l)){const d=vR(l),h=yR(u,l.props);return l.type!==v.Fragment&&(h.ref=r?Au(r,d):d),v.cloneElement(l,h)}return v.Children.count(l)>1?v.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var pR=Symbol("radix.slottable");function gR(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===pR}function yR(t,e){const s={...e};for(const r in e){const l=t[r],u=e[r];/^on[A-Z]/.test(r)?l&&u?s[r]=(...h)=>{const m=u(...h);return l(...h),m}:l&&(s[r]=l):r==="style"?s[r]={...l,...u}:r==="className"&&(s[r]=[l,u].filter(Boolean).join(" "))}return{...t,...s}}function vR(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning;return s?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning,s?t.props.ref:t.props.ref||t.ref)}var xR=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Os=xR.reduce((t,e)=>{const s=fR(`Primitive.${e}`),r=v.forwardRef((l,u)=>{const{asChild:d,...h}=l,m=d?s:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(m,{...h,ref:u})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function bR(t,e){t&&Ww.flushSync(()=>t.dispatchEvent(e))}function Ho(t){const e=v.useRef(t);return v.useEffect(()=>{e.current=t}),v.useMemo(()=>(...s)=>e.current?.(...s),[])}function wR(t,e=globalThis?.document){const s=Ho(t);v.useEffect(()=>{const r=l=>{l.key==="Escape"&&s(l)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[s,e])}var SR="DismissableLayer",rm="dismissableLayer.update",jR="dismissableLayer.pointerDownOutside",_R="dismissableLayer.focusOutside",b0,t1=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),n1=v.forwardRef((t,e)=>{const{disableOutsidePointerEvents:s=!1,onEscapeKeyDown:r,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:d,onDismiss:h,...m}=t,g=v.useContext(t1),[y,x]=v.useState(null),w=y?.ownerDocument??globalThis?.document,[,S]=v.useState({}),E=nr(e,V=>x(V)),j=Array.from(g.layers),[_]=[...g.layersWithOutsidePointerEventsDisabled].slice(-1),N=j.indexOf(_),k=y?j.indexOf(y):-1,C=g.layersWithOutsidePointerEventsDisabled.size>0,A=k>=N,D=ER(V=>{const R=V.target,P=[...g.branches].some(Z=>Z.contains(R));!A||P||(l?.(V),d?.(V),V.defaultPrevented||h?.())},w),U=kR(V=>{const R=V.target;[...g.branches].some(Z=>Z.contains(R))||(u?.(V),d?.(V),V.defaultPrevented||h?.())},w);return wR(V=>{k===g.layers.size-1&&(r?.(V),!V.defaultPrevented&&h&&(V.preventDefault(),h()))},w),v.useEffect(()=>{if(y)return s&&(g.layersWithOutsidePointerEventsDisabled.size===0&&(b0=w.body.style.pointerEvents,w.body.style.pointerEvents="none"),g.layersWithOutsidePointerEventsDisabled.add(y)),g.layers.add(y),w0(),()=>{s&&g.layersWithOutsidePointerEventsDisabled.size===1&&(w.body.style.pointerEvents=b0)}},[y,w,s,g]),v.useEffect(()=>()=>{y&&(g.layers.delete(y),g.layersWithOutsidePointerEventsDisabled.delete(y),w0())},[y,g]),v.useEffect(()=>{const V=()=>S({});return document.addEventListener(rm,V),()=>document.removeEventListener(rm,V)},[]),o.jsx(Os.div,{...m,ref:E,style:{pointerEvents:C?A?"auto":"none":void 0,...t.style},onFocusCapture:fa(t.onFocusCapture,U.onFocusCapture),onBlurCapture:fa(t.onBlurCapture,U.onBlurCapture),onPointerDownCapture:fa(t.onPointerDownCapture,D.onPointerDownCapture)})});n1.displayName=SR;var NR="DismissableLayerBranch",TR=v.forwardRef((t,e)=>{const s=v.useContext(t1),r=v.useRef(null),l=nr(e,r);return v.useEffect(()=>{const u=r.current;if(u)return s.branches.add(u),()=>{s.branches.delete(u)}},[s.branches]),o.jsx(Os.div,{...t,ref:l})});TR.displayName=NR;function ER(t,e=globalThis?.document){const s=Ho(t),r=v.useRef(!1),l=v.useRef(()=>{});return v.useEffect(()=>{const u=h=>{if(h.target&&!r.current){let m=function(){s1(jR,s,g,{discrete:!0})};const g={originalEvent:h};h.pointerType==="touch"?(e.removeEventListener("click",l.current),l.current=m,e.addEventListener("click",l.current,{once:!0})):m()}else e.removeEventListener("click",l.current);r.current=!1},d=window.setTimeout(()=>{e.addEventListener("pointerdown",u)},0);return()=>{window.clearTimeout(d),e.removeEventListener("pointerdown",u),e.removeEventListener("click",l.current)}},[e,s]),{onPointerDownCapture:()=>r.current=!0}}function kR(t,e=globalThis?.document){const s=Ho(t),r=v.useRef(!1);return v.useEffect(()=>{const l=u=>{u.target&&!r.current&&s1(_R,s,{originalEvent:u},{discrete:!1})};return e.addEventListener("focusin",l),()=>e.removeEventListener("focusin",l)},[e,s]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function w0(){const t=new CustomEvent(rm);document.dispatchEvent(t)}function s1(t,e,s,{discrete:r}){const l=s.originalEvent.target,u=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:s});e&&l.addEventListener(t,e,{once:!0}),r?bR(l,u):l.dispatchEvent(u)}var pf="focusScope.autoFocusOnMount",gf="focusScope.autoFocusOnUnmount",S0={bubbles:!1,cancelable:!0},CR="FocusScope",a1=v.forwardRef((t,e)=>{const{loop:s=!1,trapped:r=!1,onMountAutoFocus:l,onUnmountAutoFocus:u,...d}=t,[h,m]=v.useState(null),g=Ho(l),y=Ho(u),x=v.useRef(null),w=nr(e,j=>m(j)),S=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(r){let j=function(C){if(S.paused||!h)return;const A=C.target;h.contains(A)?x.current=A:oa(x.current,{select:!0})},_=function(C){if(S.paused||!h)return;const A=C.relatedTarget;A!==null&&(h.contains(A)||oa(x.current,{select:!0}))},N=function(C){if(document.activeElement===document.body)for(const D of C)D.removedNodes.length>0&&oa(h)};document.addEventListener("focusin",j),document.addEventListener("focusout",_);const k=new MutationObserver(N);return h&&k.observe(h,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",_),k.disconnect()}}},[r,h,S.paused]),v.useEffect(()=>{if(h){_0.add(S);const j=document.activeElement;if(!h.contains(j)){const N=new CustomEvent(pf,S0);h.addEventListener(pf,g),h.dispatchEvent(N),N.defaultPrevented||(AR(PR(r1(h)),{select:!0}),document.activeElement===j&&oa(h))}return()=>{h.removeEventListener(pf,g),setTimeout(()=>{const N=new CustomEvent(gf,S0);h.addEventListener(gf,y),h.dispatchEvent(N),N.defaultPrevented||oa(j??document.body,{select:!0}),h.removeEventListener(gf,y),_0.remove(S)},0)}}},[h,g,y,S]);const E=v.useCallback(j=>{if(!s&&!r||S.paused)return;const _=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,N=document.activeElement;if(_&&N){const k=j.currentTarget,[C,A]=RR(k);C&&A?!j.shiftKey&&N===A?(j.preventDefault(),s&&oa(C,{select:!0})):j.shiftKey&&N===C&&(j.preventDefault(),s&&oa(A,{select:!0})):N===k&&j.preventDefault()}},[s,r,S.paused]);return o.jsx(Os.div,{tabIndex:-1,...d,ref:w,onKeyDown:E})});a1.displayName=CR;function AR(t,{select:e=!1}={}){const s=document.activeElement;for(const r of t)if(oa(r,{select:e}),document.activeElement!==s)return}function RR(t){const e=r1(t),s=j0(e,t),r=j0(e.reverse(),t);return[s,r]}function r1(t){const e=[],s=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const l=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||l?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)e.push(s.currentNode);return e}function j0(t,e){for(const s of t)if(!OR(s,{upTo:e}))return s}function OR(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function MR(t){return t instanceof HTMLInputElement&&"select"in t}function oa(t,{select:e=!1}={}){if(t&&t.focus){const s=document.activeElement;t.focus({preventScroll:!0}),t!==s&&MR(t)&&e&&t.select()}}var _0=DR();function DR(){let t=[];return{add(e){const s=t[0];e!==s&&s?.pause(),t=N0(t,e),t.unshift(e)},remove(e){t=N0(t,e),t[0]?.resume()}}}function N0(t,e){const s=[...t],r=s.indexOf(e);return r!==-1&&s.splice(r,1),s}function PR(t){return t.filter(e=>e.tagName!=="A")}var zR="Portal",i1=v.forwardRef((t,e)=>{const{container:s,...r}=t,[l,u]=v.useState(!1);qo(()=>u(!0),[]);const d=s||l&&globalThis?.document?.body;return d?VA.createPortal(o.jsx(Os.div,{...r,ref:e}),d):null});i1.displayName=zR;function LR(t,e){return v.useReducer((s,r)=>e[s][r]??s,t)}var Ru=t=>{const{present:e,children:s}=t,r=UR(e),l=typeof s=="function"?s({present:r.isPresent}):v.Children.only(s),u=nr(r.ref,BR(l));return typeof s=="function"||r.isPresent?v.cloneElement(l,{ref:u}):null};Ru.displayName="Presence";function UR(t){const[e,s]=v.useState(),r=v.useRef(null),l=v.useRef(t),u=v.useRef("none"),d=t?"mounted":"unmounted",[h,m]=LR(d,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const g=Lc(r.current);u.current=h==="mounted"?g:"none"},[h]),qo(()=>{const g=r.current,y=l.current;if(y!==t){const w=u.current,S=Lc(g);t?m("MOUNT"):S==="none"||g?.display==="none"?m("UNMOUNT"):m(y&&w!==S?"ANIMATION_OUT":"UNMOUNT"),l.current=t}},[t,m]),qo(()=>{if(e){let g;const y=e.ownerDocument.defaultView??window,x=S=>{const j=Lc(r.current).includes(CSS.escape(S.animationName));if(S.target===e&&j&&(m("ANIMATION_END"),!l.current)){const _=e.style.animationFillMode;e.style.animationFillMode="forwards",g=y.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=_)})}},w=S=>{S.target===e&&(u.current=Lc(r.current))};return e.addEventListener("animationstart",w),e.addEventListener("animationcancel",x),e.addEventListener("animationend",x),()=>{y.clearTimeout(g),e.removeEventListener("animationstart",w),e.removeEventListener("animationcancel",x),e.removeEventListener("animationend",x)}}else m("ANIMATION_END")},[e,m]),{isPresent:["mounted","unmountSuspended"].includes(h),ref:v.useCallback(g=>{r.current=g?getComputedStyle(g):null,s(g)},[])}}function Lc(t){return t?.animationName||"none"}function BR(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning;return s?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning,s?t.props.ref:t.props.ref||t.ref)}var yf=0;function VR(){v.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??T0()),document.body.insertAdjacentElement("beforeend",t[1]??T0()),yf++,()=>{yf===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),yf--}},[])}function T0(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var Yc="right-scroll-bar-position",Xc="width-before-scroll-bar",IR="with-scroll-bars-hidden",$R="--removed-body-scroll-bar-size";function vf(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function qR(t,e){var s=v.useState(function(){return{value:t,callback:e,facade:{get current(){return s.value},set current(r){var l=s.value;l!==r&&(s.value=r,s.callback(r,l))}}}})[0];return s.callback=e,s.facade}var HR=typeof window<"u"?v.useLayoutEffect:v.useEffect,E0=new WeakMap;function GR(t,e){var s=qR(null,function(r){return t.forEach(function(l){return vf(l,r)})});return HR(function(){var r=E0.get(s);if(r){var l=new Set(r),u=new Set(t),d=s.current;l.forEach(function(h){u.has(h)||vf(h,null)}),u.forEach(function(h){l.has(h)||vf(h,d)})}E0.set(s,t)},[t]),s}function FR(t){return t}function KR(t,e){e===void 0&&(e=FR);var s=[],r=!1,l={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return s.length?s[s.length-1]:t},useMedium:function(u){var d=e(u,r);return s.push(d),function(){s=s.filter(function(h){return h!==d})}},assignSyncMedium:function(u){for(r=!0;s.length;){var d=s;s=[],d.forEach(u)}s={push:function(h){return u(h)},filter:function(){return s}}},assignMedium:function(u){r=!0;var d=[];if(s.length){var h=s;s=[],h.forEach(u),d=s}var m=function(){var y=d;d=[],y.forEach(u)},g=function(){return Promise.resolve().then(m)};g(),s={push:function(y){d.push(y),g()},filter:function(y){return d=d.filter(y),s}}}};return l}function YR(t){t===void 0&&(t={});var e=KR(null);return e.options=ss({async:!0,ssr:!1},t),e}var o1=function(t){var e=t.sideCar,s=pi(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return v.createElement(r,ss({},s))};o1.isSideCarExport=!0;function XR(t,e){return t.useMedium(e),o1}var l1=YR(),xf=function(){},Ou=v.forwardRef(function(t,e){var s=v.useRef(null),r=v.useState({onScrollCapture:xf,onWheelCapture:xf,onTouchMoveCapture:xf}),l=r[0],u=r[1],d=t.forwardProps,h=t.children,m=t.className,g=t.removeScrollBar,y=t.enabled,x=t.shards,w=t.sideCar,S=t.noRelative,E=t.noIsolation,j=t.inert,_=t.allowPinchZoom,N=t.as,k=N===void 0?"div":N,C=t.gapMode,A=pi(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),D=w,U=GR([s,e]),V=ss(ss({},A),l);return v.createElement(v.Fragment,null,y&&v.createElement(D,{sideCar:l1,removeScrollBar:g,shards:x,noRelative:S,noIsolation:E,inert:j,setCallbacks:u,allowPinchZoom:!!_,lockRef:s,gapMode:C}),d?v.cloneElement(v.Children.only(h),ss(ss({},V),{ref:U})):v.createElement(k,ss({},V,{className:m,ref:U}),h))});Ou.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Ou.classNames={fullWidth:Xc,zeroRight:Yc};var WR=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function JR(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=WR();return e&&t.setAttribute("nonce",e),t}function QR(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function ZR(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var eO=function(){var t=0,e=null;return{add:function(s){t==0&&(e=JR())&&(QR(e,s),ZR(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},tO=function(){var t=eO();return function(e,s){v.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&s])}},c1=function(){var t=tO(),e=function(s){var r=s.styles,l=s.dynamic;return t(r,l),null};return e},nO={left:0,top:0,right:0,gap:0},bf=function(t){return parseInt(t||"",10)||0},sO=function(t){var e=window.getComputedStyle(document.body),s=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],l=e[t==="padding"?"paddingRight":"marginRight"];return[bf(s),bf(r),bf(l)]},aO=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return nO;var e=sO(t),s=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-s+e[2]-e[0])}},rO=c1(),li="data-scroll-locked",iO=function(t,e,s,r){var l=t.left,u=t.top,d=t.right,h=t.gap;return s===void 0&&(s="margin"),`
|
|
50
|
+
${N}`}class Tt extends Error{constructor({message:e,code:s,cause:i,name:l}){var u;super(e,{cause:i}),this.__isWebAuthnError=!0,this.name=(u=l??(i instanceof Error?i.name:void 0))!==null&&u!==void 0?u:"Unknown Error",this.code=s}}class au extends Tt{constructor(e,s){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:s,message:e}),this.name="WebAuthnUnknownError",this.originalError=s}}function QT({error:t,options:e}){var s,i,l;const{publicKey:u}=e;if(!u)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new Tt({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((s=u.authenticatorSelection)===null||s===void 0?void 0:s.requireResidentKey)===!0)return new Tt({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(e.mediation==="conditional"&&((i=u.authenticatorSelection)===null||i===void 0?void 0:i.userVerification)==="required")return new Tt({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((l=u.authenticatorSelection)===null||l===void 0?void 0:l.userVerification)==="required")return new Tt({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if(t.name==="InvalidStateError")return new Tt({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new Tt({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return u.pubKeyCredParams.filter(h=>h.type==="public-key").length===0?new Tt({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new Tt({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if(t.name==="SecurityError"){const d=window.location.hostname;if(yw(d)){if(u.rp.id!==d)return new Tt({message:`The RP ID "${u.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Tt({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(u.user.id.byteLength<1||u.user.id.byteLength>64)return new Tt({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if(t.name==="UnknownError")return new Tt({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new Tt({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function ZT({error:t,options:e}){const{publicKey:s}=e;if(!s)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new Tt({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new Tt({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const i=window.location.hostname;if(yw(i)){if(s.rpId!==i)return new Tt({message:`The RP ID "${s.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Tt({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new Tt({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new Tt({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class eE{createNewAbortSignal(){if(this.controller){const s=new Error("Cancelling existing WebAuthn API call for new one");s.name="AbortError",this.controller.abort(s)}const e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){const e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}const tE=new eE;function nE(t){if(!t)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(t);const{challenge:e,user:s,excludeCredentials:i}=t,l=pr(t,["challenge","user","excludeCredentials"]),u=or(e).buffer,d=Object.assign(Object.assign({},s),{id:or(s.id).buffer}),h=Object.assign(Object.assign({},l),{challenge:u,user:d});if(i&&i.length>0){h.excludeCredentials=new Array(i.length);for(let m=0;m<i.length;m++){const g=i[m];h.excludeCredentials[m]=Object.assign(Object.assign({},g),{id:or(g.id).buffer,type:g.type||"public-key",transports:g.transports})}}return h}function sE(t){if(!t)throw new Error("Credential request options are required");if(typeof PublicKeyCredential<"u"&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseRequestOptionsFromJSON=="function")return PublicKeyCredential.parseRequestOptionsFromJSON(t);const{challenge:e,allowCredentials:s}=t,i=pr(t,["challenge","allowCredentials"]),l=or(e).buffer,u=Object.assign(Object.assign({},i),{challenge:l});if(s&&s.length>0){u.allowCredentials=new Array(s.length);for(let d=0;d<s.length;d++){const h=s[d];u.allowCredentials[d]=Object.assign(Object.assign({},h),{id:or(h.id).buffer,type:h.type||"public-key",transports:h.transports})}}return u}function aE(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const s=t;return{id:t.id,rawId:t.id,response:{attestationObject:Fa(new Uint8Array(t.response.attestationObject)),clientDataJSON:Fa(new Uint8Array(t.response.clientDataJSON))},type:"public-key",clientExtensionResults:t.getClientExtensionResults(),authenticatorAttachment:(e=s.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function iE(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const s=t,i=t.getClientExtensionResults(),l=t.response;return{id:t.id,rawId:t.id,response:{authenticatorData:Fa(new Uint8Array(l.authenticatorData)),clientDataJSON:Fa(new Uint8Array(l.clientDataJSON)),signature:Fa(new Uint8Array(l.signature)),userHandle:l.userHandle?Fa(new Uint8Array(l.userHandle)):void 0},type:"public-key",clientExtensionResults:i,authenticatorAttachment:(e=s.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function yw(t){return t==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(t)}function s0(){var t,e;return!!(Gt()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&typeof((t=navigator?.credentials)===null||t===void 0?void 0:t.create)=="function"&&typeof((e=navigator?.credentials)===null||e===void 0?void 0:e.get)=="function")}async function rE(t){try{const e=await navigator.credentials.create(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new au("Browser returned unexpected credential type",e)}:{data:null,error:new au("Empty credential response",e)}}catch(e){return{data:null,error:QT({error:e,options:t})}}}async function oE(t){try{const e=await navigator.credentials.get(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new au("Browser returned unexpected credential type",e)}:{data:null,error:new au("Empty credential response",e)}}catch(e){return{data:null,error:ZT({error:e,options:t})}}}const lE={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},cE={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function iu(...t){const e=l=>l!==null&&typeof l=="object"&&!Array.isArray(l),s=l=>l instanceof ArrayBuffer||ArrayBuffer.isView(l),i={};for(const l of t)if(l)for(const u in l){const d=l[u];if(d!==void 0)if(Array.isArray(d))i[u]=d;else if(s(d))i[u]=d;else if(e(d)){const h=i[u];e(h)?i[u]=iu(h,d):i[u]=iu(d)}else i[u]=d}return i}function uE(t,e){return iu(lE,t,e||{})}function dE(t,e){return iu(cE,t,e||{})}class hE{constructor(e){this.client=e,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(e){return this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))}async _challenge({factorId:e,webauthn:s,friendlyName:i,signal:l},u){var d;try{const{data:h,error:m}=await this.client.mfa.challenge({factorId:e,webauthn:s});if(!h)return{data:null,error:m};const g=l??tE.createNewAbortSignal();if(h.webauthn.type==="create"){const{user:y}=h.webauthn.credential_options.publicKey;if(!y.name){const x=i;if(x)y.name=`${y.id}:${x}`;else{const S=(await this.client.getUser()).data.user,E=((d=S?.user_metadata)===null||d===void 0?void 0:d.name)||S?.email||S?.id||"User";y.name=`${y.id}:${E}`}}y.displayName||(y.displayName=y.name)}switch(h.webauthn.type){case"create":{const y=uE(h.webauthn.credential_options.publicKey,u?.create),{data:x,error:w}=await rE({publicKey:y,signal:g});return x?{data:{factorId:e,challengeId:h.id,webauthn:{type:h.webauthn.type,credential_response:x}},error:null}:{data:null,error:w}}case"request":{const y=dE(h.webauthn.credential_options.publicKey,u?.request),{data:x,error:w}=await oE(Object.assign(Object.assign({},h.webauthn.credential_options),{publicKey:y,signal:g}));return x?{data:{factorId:e,challengeId:h.id,webauthn:{type:h.webauthn.type,credential_response:x}},error:null}:{data:null,error:w}}}}catch(h){return Ne(h)?{data:null,error:h}:{data:null,error:new Ga("Unexpected error in challenge",h)}}}async _verify({challengeId:e,factorId:s,webauthn:i}){return this.client.mfa.verify({factorId:s,challengeId:e,webauthn:i})}async _authenticate({factorId:e,webauthn:{rpId:s=typeof window<"u"?window.location.hostname:void 0,rpOrigins:i=typeof window<"u"?[window.location.origin]:void 0,signal:l}={}},u){if(!s)return{data:null,error:new zo("rpId is required for WebAuthn authentication")};try{if(!s0())return{data:null,error:new Ga("Browser does not support WebAuthn",null)};const{data:d,error:h}=await this.challenge({factorId:e,webauthn:{rpId:s,rpOrigins:i},signal:l},{request:u});if(!d)return{data:null,error:h};const{webauthn:m}=d;return this._verify({factorId:e,challengeId:d.challengeId,webauthn:{type:m.type,rpId:s,rpOrigins:i,credential_response:m.credential_response}})}catch(d){return Ne(d)?{data:null,error:d}:{data:null,error:new Ga("Unexpected error in authenticate",d)}}}async _register({friendlyName:e,webauthn:{rpId:s=typeof window<"u"?window.location.hostname:void 0,rpOrigins:i=typeof window<"u"?[window.location.origin]:void 0,signal:l}={}},u){if(!s)return{data:null,error:new zo("rpId is required for WebAuthn registration")};try{if(!s0())return{data:null,error:new Ga("Browser does not support WebAuthn",null)};const{data:d,error:h}=await this._enroll({friendlyName:e});if(!d)return await this.client.mfa.listFactors().then(y=>{var x;return(x=y.data)===null||x===void 0?void 0:x.all.find(w=>w.factor_type==="webauthn"&&w.friendly_name===e&&w.status!=="unverified")}).then(y=>y?this.client.mfa.unenroll({factorId:y?.id}):void 0),{data:null,error:h};const{data:m,error:g}=await this._challenge({factorId:d.id,friendlyName:d.friendly_name,webauthn:{rpId:s,rpOrigins:i},signal:l},{create:u});return m?this._verify({factorId:d.id,challengeId:m.challengeId,webauthn:{rpId:s,rpOrigins:i,type:m.webauthn.type,credential_response:m.webauthn.credential_response}}):{data:null,error:g}}catch(d){return Ne(d)?{data:null,error:d}:{data:null,error:new Ga("Unexpected error in register",d)}}}}YT();const fE={url:uT,storageKey:dT,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:hT,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:1e4,skipAutoInitialize:!1};async function a0(t,e,s){return await s()}const Fi={};class Lo{get jwks(){var e,s;return(s=(e=Fi[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&s!==void 0?s:{keys:[]}}set jwks(e){Fi[this.storageKey]=Object.assign(Object.assign({},Fi[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,s;return(s=(e=Fi[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&s!==void 0?s:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){Fi[this.storageKey]=Object.assign(Object.assign({},Fi[this.storageKey]),{cachedAt:e})}constructor(e){var s,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 u=Object.assign(Object.assign({},fE),e);if(this.storageKey=u.storageKey,this.instanceID=(s=Lo.nextInstanceID[this.storageKey])!==null&&s!==void 0?s:0,Lo.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!u.debug,typeof u.debug=="function"&&(this.logger=u.debug),this.instanceID>0&&Gt()){const d=`${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(d),this.logDebugMessages&&console.trace(d)}if(this.persistSession=u.persistSession,this.autoRefreshToken=u.autoRefreshToken,this.admin=new FT({url:u.url,headers:u.headers,fetch:u.fetch}),this.url=u.url,this.headers=u.headers,this.fetch=mw(u.fetch),this.lock=u.lock||a0,this.detectSessionInUrl=u.detectSessionInUrl,this.flowType=u.flowType,this.hasCustomAuthorizationHeader=u.hasCustomAuthorizationHeader,this.throwOnError=u.throwOnError,this.lockAcquireTimeout=u.lockAcquireTimeout,u.lock?this.lock=u.lock:this.persistSession&&Gt()&&(!((i=globalThis?.navigator)===null||i===void 0)&&i.locks)?this.lock=KT:this.lock=a0,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 hE(this)},this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this),listGrants:this._listOAuthGrants.bind(this),revokeGrant:this._revokeOAuthGrant.bind(this)},this.persistSession?(u.storage?this.storage=u.storage:fw()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=t0(this.memoryStorage)),u.userStorage&&(this.userStorage=u.userStorage)):(this.memoryStorage={},this.storage=t0(this.memoryStorage)),Gt()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(d){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",d)}(l=this.broadcastChannel)===null||l===void 0||l.addEventListener("message",async d=>{this._debug("received broadcast notification from other tab or client",d);try{await this._notifyAllSubscribers(d.data.event,d.data.session,!1)}catch(h){this._debug("#broadcastChannel","error",h)}})}u.skipAutoInitialize||this.initialize().catch(d=>{this._debug("#initialize()","error",d)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${uw}) ${new Date().toISOString()}`}_debug(...e){return this.logDebugMessages&&this.logger(this._logPrefix(),...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(this.lockAcquireTimeout,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var e;try{let s={},i="none";if(Gt()&&(s=TT(window.location.href),this._isImplicitGrantCallback(s)?i="implicit":await this._isPKCECallback(s)&&(i="pkce")),Gt()&&this.detectSessionInUrl&&i!=="none"){const{data:l,error:u}=await this._getSessionFromURL(s,i);if(u){if(this._debug("#_initialize()","error detecting session from URL",u),yT(u)){const m=(e=u.details)===null||e===void 0?void 0:e.code;if(m==="identity_already_exists"||m==="identity_not_found"||m==="single_identity_not_deletable")return{error:u}}return{error:u}}const{session:d,redirectType:h}=l;return this._debug("#_initialize()","detected session in URL",d,"redirect type",h),await this._saveSession(d),setTimeout(async()=>{h==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",d):await this._notifyAllSubscribers("SIGNED_IN",d)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(s){return Ne(s)?this._returnResult({error:s}):this._returnResult({error:new Ga("Unexpected error during initialization",s)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var s,i,l;try{const u=await Re(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(i=(s=e?.options)===null||s===void 0?void 0:s.data)!==null&&i!==void 0?i:{},gotrue_meta_security:{captcha_token:(l=e?.options)===null||l===void 0?void 0:l.captchaToken}},xform:$n}),{data:d,error:h}=u;if(h||!d)return this._returnResult({data:{user:null,session:null},error:h});const m=d.session,g=d.user;return d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("SIGNED_IN",m)),this._returnResult({data:{user:g,session:m},error:null})}catch(u){if(Ne(u))return this._returnResult({data:{user:null,session:null},error:u});throw u}}async signUp(e){var s,i,l;try{let u;if("email"in e){const{email:y,password:x,options:w}=e;let S=null,E=null;this.flowType==="pkce"&&([S,E]=await qi(this.storage,this.storageKey)),u=await Re(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:w?.emailRedirectTo,body:{email:y,password:x,data:(s=w?.data)!==null&&s!==void 0?s:{},gotrue_meta_security:{captcha_token:w?.captchaToken},code_challenge:S,code_challenge_method:E},xform:$n})}else if("phone"in e){const{phone:y,password:x,options:w}=e;u=await Re(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:y,password:x,data:(i=w?.data)!==null&&i!==void 0?i:{},channel:(l=w?.channel)!==null&&l!==void 0?l:"sms",gotrue_meta_security:{captcha_token:w?.captchaToken}},xform:$n})}else throw new Cc("You must provide either an email or phone number and a password");const{data:d,error:h}=u;if(h||!d)return await Ht(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:h});const m=d.session,g=d.user;return d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("SIGNED_IN",m)),this._returnResult({data:{user:g,session:m},error:null})}catch(u){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(u))return this._returnResult({data:{user:null,session:null},error:u});throw u}}async signInWithPassword(e){try{let s;if("email"in e){const{email:u,password:d,options:h}=e;s=await Re(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:u,password:d,gotrue_meta_security:{captcha_token:h?.captchaToken}},xform:Zx})}else if("phone"in e){const{phone:u,password:d,options:h}=e;s=await Re(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:u,password:d,gotrue_meta_security:{captcha_token:h?.captchaToken}},xform:Zx})}else throw new Cc("You must provide either an email or phone number and a password");const{data:i,error:l}=s;if(l)return this._returnResult({data:{user:null,session:null},error:l});if(!i||!i.session||!i.user){const u=new $i;return this._returnResult({data:{user:null,session:null},error:u})}return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",i.session)),this._returnResult({data:Object.assign({user:i.user,session:i.session},i.weak_password?{weakPassword:i.weak_password}:null),error:l})}catch(s){if(Ne(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async signInWithOAuth(e){var s,i,l,u;return await this._handleProviderSignIn(e.provider,{redirectTo:(s=e.options)===null||s===void 0?void 0:s.redirectTo,scopes:(i=e.options)===null||i===void 0?void 0:i.scopes,queryParams:(l=e.options)===null||l===void 0?void 0:l.queryParams,skipBrowserRedirect:(u=e.options)===null||u===void 0?void 0:u.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){const{chain:s}=e;switch(s){case"ethereum":return await this.signInWithEthereum(e);case"solana":return await this.signInWithSolana(e);default:throw new Error(`@supabase/auth-js: Unsupported chain "${s}"`)}}async signInWithEthereum(e){var s,i,l,u,d,h,m,g,y,x,w;let S,E;if("message"in e)S=e.message,E=e.signature;else{const{chain:j,wallet:_,statement:N,options:k}=e;let C;if(Gt())if(typeof _=="object")C=_;else{const P=window;if("ethereum"in P&&typeof P.ethereum=="object"&&"request"in P.ethereum&&typeof P.ethereum.request=="function")C=P.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 _!="object"||!k?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");C=_}const A=new URL((s=k?.url)!==null&&s!==void 0?s:window.location.href),D=await C.request({method:"eth_requestAccounts"}).then(P=>P).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!D||D.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const z=gw(D[0]);let V=(i=k?.signInWithEthereum)===null||i===void 0?void 0:i.chainId;if(!V){const P=await C.request({method:"eth_chainId"});V=XT(P)}const R={domain:A.host,address:z,statement:N,uri:A.href,version:"1",chainId:V,nonce:(l=k?.signInWithEthereum)===null||l===void 0?void 0:l.nonce,issuedAt:(d=(u=k?.signInWithEthereum)===null||u===void 0?void 0:u.issuedAt)!==null&&d!==void 0?d:new Date,expirationTime:(h=k?.signInWithEthereum)===null||h===void 0?void 0:h.expirationTime,notBefore:(m=k?.signInWithEthereum)===null||m===void 0?void 0:m.notBefore,requestId:(g=k?.signInWithEthereum)===null||g===void 0?void 0:g.requestId,resources:(y=k?.signInWithEthereum)===null||y===void 0?void 0:y.resources};S=JT(R),E=await C.request({method:"personal_sign",params:[WT(S),z]})}try{const{data:j,error:_}=await Re(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:S,signature:E},!((x=e.options)===null||x===void 0)&&x.captchaToken?{gotrue_meta_security:{captcha_token:(w=e.options)===null||w===void 0?void 0:w.captchaToken}}:null),xform:$n});if(_)throw _;if(!j||!j.session||!j.user){const N=new $i;return this._returnResult({data:{user:null,session:null},error:N})}return j.session&&(await this._saveSession(j.session),await this._notifyAllSubscribers("SIGNED_IN",j.session)),this._returnResult({data:Object.assign({},j),error:_})}catch(j){if(Ne(j))return this._returnResult({data:{user:null,session:null},error:j});throw j}}async signInWithSolana(e){var s,i,l,u,d,h,m,g,y,x,w,S;let E,j;if("message"in e)E=e.message,j=e.signature;else{const{chain:_,wallet:N,statement:k,options:C}=e;let A;if(Gt())if(typeof N=="object")A=N;else{const z=window;if("solana"in z&&typeof z.solana=="object"&&("signIn"in z.solana&&typeof z.solana.signIn=="function"||"signMessage"in z.solana&&typeof z.solana.signMessage=="function"))A=z.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"||!C?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");A=N}const D=new URL((s=C?.url)!==null&&s!==void 0?s:window.location.href);if("signIn"in A&&A.signIn){const z=await A.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},C?.signInWithSolana),{version:"1",domain:D.host,uri:D.href}),k?{statement:k}:null));let V;if(Array.isArray(z)&&z[0]&&typeof z[0]=="object")V=z[0];else if(z&&typeof z=="object"&&"signedMessage"in z&&"signature"in z)V=z;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in V&&"signature"in V&&(typeof V.signedMessage=="string"||V.signedMessage instanceof Uint8Array)&&V.signature instanceof Uint8Array)E=typeof V.signedMessage=="string"?V.signedMessage:new TextDecoder().decode(V.signedMessage),j=V.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in A)||typeof A.signMessage!="function"||!("publicKey"in A)||typeof A!="object"||!A.publicKey||!("toBase58"in A.publicKey)||typeof A.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");E=[`${D.host} wants you to sign in with your Solana account:`,A.publicKey.toBase58(),...k?["",k,""]:[""],"Version: 1",`URI: ${D.href}`,`Issued At: ${(l=(i=C?.signInWithSolana)===null||i===void 0?void 0:i.issuedAt)!==null&&l!==void 0?l:new Date().toISOString()}`,...!((u=C?.signInWithSolana)===null||u===void 0)&&u.notBefore?[`Not Before: ${C.signInWithSolana.notBefore}`]:[],...!((d=C?.signInWithSolana)===null||d===void 0)&&d.expirationTime?[`Expiration Time: ${C.signInWithSolana.expirationTime}`]:[],...!((h=C?.signInWithSolana)===null||h===void 0)&&h.chainId?[`Chain ID: ${C.signInWithSolana.chainId}`]:[],...!((m=C?.signInWithSolana)===null||m===void 0)&&m.nonce?[`Nonce: ${C.signInWithSolana.nonce}`]:[],...!((g=C?.signInWithSolana)===null||g===void 0)&&g.requestId?[`Request ID: ${C.signInWithSolana.requestId}`]:[],...!((x=(y=C?.signInWithSolana)===null||y===void 0?void 0:y.resources)===null||x===void 0)&&x.length?["Resources",...C.signInWithSolana.resources.map(V=>`- ${V}`)]:[]].join(`
|
|
51
|
+
`);const z=await A.signMessage(new TextEncoder().encode(E),"utf8");if(!z||!(z instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");j=z}}try{const{data:_,error:N}=await Re(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:E,signature:Fa(j)},!((w=e.options)===null||w===void 0)&&w.captchaToken?{gotrue_meta_security:{captcha_token:(S=e.options)===null||S===void 0?void 0:S.captchaToken}}:null),xform:$n});if(N)throw N;if(!_||!_.session||!_.user){const k=new $i;return this._returnResult({data:{user:null,session:null},error:k})}return _.session&&(await this._saveSession(_.session),await this._notifyAllSubscribers("SIGNED_IN",_.session)),this._returnResult({data:Object.assign({},_),error:N})}catch(_){if(Ne(_))return this._returnResult({data:{user:null,session:null},error:_});throw _}}async _exchangeCodeForSession(e){const s=await Ua(this.storage,`${this.storageKey}-code-verifier`),[i,l]=(s??"").split("/");try{if(!i&&this.flowType==="pkce")throw new vT;const{data:u,error:d}=await Re(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:i},xform:$n});if(await Ht(this.storage,`${this.storageKey}-code-verifier`),d)throw d;if(!u||!u.session||!u.user){const h=new $i;return this._returnResult({data:{user:null,session:null,redirectType:null},error:h})}return u.session&&(await this._saveSession(u.session),await this._notifyAllSubscribers("SIGNED_IN",u.session)),this._returnResult({data:Object.assign(Object.assign({},u),{redirectType:l??null}),error:d})}catch(u){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(u))return this._returnResult({data:{user:null,session:null,redirectType:null},error:u});throw u}}async signInWithIdToken(e){try{const{options:s,provider:i,token:l,access_token:u,nonce:d}=e,h=await Re(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:i,id_token:l,access_token:u,nonce:d,gotrue_meta_security:{captcha_token:s?.captchaToken}},xform:$n}),{data:m,error:g}=h;if(g)return this._returnResult({data:{user:null,session:null},error:g});if(!m||!m.session||!m.user){const y=new $i;return this._returnResult({data:{user:null,session:null},error:y})}return m.session&&(await this._saveSession(m.session),await this._notifyAllSubscribers("SIGNED_IN",m.session)),this._returnResult({data:m,error:g})}catch(s){if(Ne(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async signInWithOtp(e){var s,i,l,u,d;try{if("email"in e){const{email:h,options:m}=e;let g=null,y=null;this.flowType==="pkce"&&([g,y]=await qi(this.storage,this.storageKey));const{error:x}=await Re(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:h,data:(s=m?.data)!==null&&s!==void 0?s:{},create_user:(i=m?.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:m?.captchaToken},code_challenge:g,code_challenge_method:y},redirectTo:m?.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:x})}if("phone"in e){const{phone:h,options:m}=e,{data:g,error:y}=await Re(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:h,data:(l=m?.data)!==null&&l!==void 0?l:{},create_user:(u=m?.shouldCreateUser)!==null&&u!==void 0?u:!0,gotrue_meta_security:{captcha_token:m?.captchaToken},channel:(d=m?.channel)!==null&&d!==void 0?d:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:g?.message_id},error:y})}throw new Cc("You must provide either an email or phone number.")}catch(h){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(h))return this._returnResult({data:{user:null,session:null},error:h});throw h}}async verifyOtp(e){var s,i;try{let l,u;"options"in e&&(l=(s=e.options)===null||s===void 0?void 0:s.redirectTo,u=(i=e.options)===null||i===void 0?void 0:i.captchaToken);const{data:d,error:h}=await Re(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:u}}),redirectTo:l,xform:$n});if(h)throw h;if(!d)throw new Error("An error occurred on token verification.");const m=d.session,g=d.user;return m?.access_token&&(await this._saveSession(m),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",m)),this._returnResult({data:{user:g,session:m},error:null})}catch(l){if(Ne(l))return this._returnResult({data:{user:null,session:null},error:l});throw l}}async signInWithSSO(e){var s,i,l,u,d;try{let h=null,m=null;this.flowType==="pkce"&&([h,m]=await qi(this.storage,this.storageKey));const g=await Re(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(i=(s=e.options)===null||s===void 0?void 0:s.redirectTo)!==null&&i!==void 0?i:void 0}),!((l=e?.options)===null||l===void 0)&&l.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:h,code_challenge_method:m}),headers:this.headers,xform:qT});return!((u=g.data)===null||u===void 0)&&u.url&&Gt()&&!(!((d=e.options)===null||d===void 0)&&d.skipBrowserRedirect)&&window.location.assign(g.data.url),this._returnResult(g)}catch(h){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(h))return this._returnResult({data:null,error:h});throw h}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:s},error:i}=e;if(i)throw i;if(!s)throw new xn;const{error:l}=await Re(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:s.access_token});return this._returnResult({data:{user:null,session:null},error:l})})}catch(e){if(Ne(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){try{const s=`${this.url}/resend`;if("email"in e){const{email:i,type:l,options:u}=e,{error:d}=await Re(this.fetch,"POST",s,{headers:this.headers,body:{email:i,type:l,gotrue_meta_security:{captcha_token:u?.captchaToken}},redirectTo:u?.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:d})}else if("phone"in e){const{phone:i,type:l,options:u}=e,{data:d,error:h}=await Re(this.fetch,"POST",s,{headers:this.headers,body:{phone:i,type:l,gotrue_meta_security:{captcha_token:u?.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:d?.message_id},error:h})}throw new Cc("You must provide either an email or phone number and a type")}catch(s){if(Ne(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async getSession(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async s=>s))}async _acquireLock(e,s){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const i=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),l=(async()=>(await i,await s()))();return this.pendingInLock.push((async()=>{try{await l}catch{}})()),l}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const i=s();for(this.pendingInLock.push((async()=>{try{await i}catch{}})()),await i;this.pendingInLock.length;){const l=[...this.pendingInLock];await Promise.all(l),this.pendingInLock.splice(0,l.length)}return await i}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const s=await this.__loadSession();return await e(s)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const s=await Ua(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",s),s!==null&&(this._isValidSession(s)?e=s:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const i=e.expires_at?e.expires_at*1e3-Date.now()<rf:!1;if(this._debug("#__loadSession()",`session has${i?"":" not"} expired`,"expires_at",e.expires_at),!i){if(this.userStorage){const d=await Ua(this.userStorage,this.storageKey+"-user");d?.user?e.user=d.user:e.user=cf()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){const d={value:this.suppressGetSessionWarning};e.user=BT(e.user,d),d.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:e},error:null}}const{data:l,error:u}=await this._callRefreshToken(e.refresh_token);return u?this._returnResult({data:{session:null},error:u}):this._returnResult({data:{session:l},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;const s=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser());return s.data.user&&(this.suppressGetSessionWarning=!0),s}async _getUser(e){try{return e?await Re(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:ua}):await this._useSession(async s=>{var i,l,u;const{data:d,error:h}=s;if(h)throw h;return!(!((i=d.session)===null||i===void 0)&&i.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new xn}:await Re(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(u=(l=d.session)===null||l===void 0?void 0:l.access_token)!==null&&u!==void 0?u:void 0,xform:ua})})}catch(s){if(Ne(s))return of(s)&&(await this._removeSession(),await Ht(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:s});throw s}}async updateUser(e,s={}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(e,s))}async _updateUser(e,s={}){try{return await this._useSession(async i=>{const{data:l,error:u}=i;if(u)throw u;if(!l.session)throw new xn;const d=l.session;let h=null,m=null;this.flowType==="pkce"&&e.email!=null&&([h,m]=await qi(this.storage,this.storageKey));const{data:g,error:y}=await Re(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:s?.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:h,code_challenge_method:m}),jwt:d.access_token,xform:ua});if(y)throw y;return d.user=g.user,await this._saveSession(d),await this._notifyAllSubscribers("USER_UPDATED",d),this._returnResult({data:{user:d.user},error:null})})}catch(i){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(i))return this._returnResult({data:{user:null},error:i});throw i}}async setSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new xn;const s=Date.now()/1e3;let i=s,l=!0,u=null;const{payload:d}=Rc(e.access_token);if(d.exp&&(i=d.exp,l=i<=s),l){const{data:h,error:m}=await this._callRefreshToken(e.refresh_token);if(m)return this._returnResult({data:{user:null,session:null},error:m});if(!h)return{data:{user:null,session:null},error:null};u=h}else{const{data:h,error:m}=await this._getUser(e.access_token);if(m)return this._returnResult({data:{user:null,session:null},error:m});u={access_token:e.access_token,refresh_token:e.refresh_token,user:h.user,token_type:"bearer",expires_in:i-s,expires_at:i},await this._saveSession(u),await this._notifyAllSubscribers("SIGNED_IN",u)}return this._returnResult({data:{user:u.user,session:u},error:null})}catch(s){if(Ne(s))return this._returnResult({data:{session:null,user:null},error:s});throw s}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async s=>{var i;if(!e){const{data:d,error:h}=s;if(h)throw h;e=(i=d.session)!==null&&i!==void 0?i:void 0}if(!e?.refresh_token)throw new xn;const{data:l,error:u}=await this._callRefreshToken(e.refresh_token);return u?this._returnResult({data:{user:null,session:null},error:u}):l?this._returnResult({data:{user:l.user,session:l},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(s){if(Ne(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async _getSessionFromURL(e,s){try{if(!Gt())throw new Ac("No browser detected.");if(e.error||e.error_description||e.error_code)throw new Ac(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(s){case"implicit":if(this.flowType==="pkce")throw new Fx("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new Ac("Not a valid implicit grant flow url.");break;default:}if(s==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new Fx("No code detected.");const{data:k,error:C}=await this._exchangeCodeForSession(e.code);if(C)throw C;const A=new URL(window.location.href);return A.searchParams.delete("code"),window.history.replaceState(window.history.state,"",A.toString()),{data:{session:k.session,redirectType:null},error:null}}const{provider_token:i,provider_refresh_token:l,access_token:u,refresh_token:d,expires_in:h,expires_at:m,token_type:g}=e;if(!u||!h||!d||!g)throw new Ac("No session defined in URL");const y=Math.round(Date.now()/1e3),x=parseInt(h);let w=y+x;m&&(w=parseInt(m));const S=w-y;S*1e3<=Ji&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${S}s, should have been closer to ${x}s`);const E=w-x;y-E>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",E,w,y):y-E<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",E,w,y);const{data:j,error:_}=await this._getUser(u);if(_)throw _;const N={provider_token:i,provider_refresh_token:l,access_token:u,expires_in:x,expires_at:w,refresh_token:d,token_type:g,user:j.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:N,redirectType:e.type},error:null})}catch(i){if(Ne(i))return this._returnResult({data:{session:null,redirectType:null},error:i});throw i}}_isImplicitGrantCallback(e){return typeof this.detectSessionInUrl=="function"?this.detectSessionInUrl(new URL(window.location.href),e):!!(e.access_token||e.error_description)}async _isPKCECallback(e){const s=await Ua(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&s)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async s=>{var i;const{data:l,error:u}=s;if(u&&!of(u))return this._returnResult({error:u});const d=(i=l.session)===null||i===void 0?void 0:i.access_token;if(d){const{error:h}=await this.admin.signOut(d,e);if(h&&!(gT(h)&&(h.status===404||h.status===401||h.status===403)||of(h)))return this._returnResult({error:h})}return e!=="others"&&(await this._removeSession(),await Ht(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(e){const s=NT(),i={id:s,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",s),this.stateChangeEmitters.delete(s)}};return this._debug("#onAuthStateChange()","registered callback with id",s),this.stateChangeEmitters.set(s,i),(async()=>(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(s)})))(),{data:{subscription:i}}}async _emitInitialSession(e){return await this._useSession(async s=>{var i,l;try{const{data:{session:u},error:d}=s;if(d)throw d;await((i=this.stateChangeEmitters.get(e))===null||i===void 0?void 0:i.callback("INITIAL_SESSION",u)),this._debug("INITIAL_SESSION","callback id",e,"session",u)}catch(u){await((l=this.stateChangeEmitters.get(e))===null||l===void 0?void 0:l.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",u),console.error(u)}})}async resetPasswordForEmail(e,s={}){let i=null,l=null;this.flowType==="pkce"&&([i,l]=await qi(this.storage,this.storageKey,!0));try{return await Re(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:i,code_challenge_method:l,gotrue_meta_security:{captcha_token:s.captchaToken}},headers:this.headers,redirectTo:s.redirectTo})}catch(u){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(u))return this._returnResult({data:null,error:u});throw u}}async getUserIdentities(){var e;try{const{data:s,error:i}=await this.getUser();if(i)throw i;return this._returnResult({data:{identities:(e=s.user.identities)!==null&&e!==void 0?e:[]},error:null})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var s;try{const{data:i,error:l}=await this._useSession(async u=>{var d,h,m,g,y;const{data:x,error:w}=u;if(w)throw w;const S=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(d=e.options)===null||d===void 0?void 0:d.redirectTo,scopes:(h=e.options)===null||h===void 0?void 0:h.scopes,queryParams:(m=e.options)===null||m===void 0?void 0:m.queryParams,skipBrowserRedirect:!0});return await Re(this.fetch,"GET",S,{headers:this.headers,jwt:(y=(g=x.session)===null||g===void 0?void 0:g.access_token)!==null&&y!==void 0?y:void 0})});if(l)throw l;return Gt()&&!(!((s=e.options)===null||s===void 0)&&s.skipBrowserRedirect)&&window.location.assign(i?.url),this._returnResult({data:{provider:e.provider,url:i?.url},error:null})}catch(i){if(Ne(i))return this._returnResult({data:{provider:e.provider,url:null},error:i});throw i}}async linkIdentityIdToken(e){return await this._useSession(async s=>{var i;try{const{error:l,data:{session:u}}=s;if(l)throw l;const{options:d,provider:h,token:m,access_token:g,nonce:y}=e,x=await Re(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(i=u?.access_token)!==null&&i!==void 0?i:void 0,body:{provider:h,id_token:m,access_token:g,nonce:y,link_identity:!0,gotrue_meta_security:{captcha_token:d?.captchaToken}},xform:$n}),{data:w,error:S}=x;return S?this._returnResult({data:{user:null,session:null},error:S}):!w||!w.session||!w.user?this._returnResult({data:{user:null,session:null},error:new $i}):(w.session&&(await this._saveSession(w.session),await this._notifyAllSubscribers("USER_UPDATED",w.session)),this._returnResult({data:w,error:S}))}catch(l){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(l))return this._returnResult({data:{user:null,session:null},error:l});throw l}})}async unlinkIdentity(e){try{return await this._useSession(async s=>{var i,l;const{data:u,error:d}=s;if(d)throw d;return await Re(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(l=(i=u.session)===null||i===void 0?void 0:i.access_token)!==null&&l!==void 0?l:void 0})})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async _refreshAccessToken(e){const s=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{const i=Date.now();return await CT(async l=>(l>0&&await kT(200*Math.pow(2,l-1)),this._debug(s,"refreshing attempt",l),await Re(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:$n})),(l,u)=>{const d=200*Math.pow(2,l);return u&&lf(u)&&Date.now()+d-i<Ji})}catch(i){if(this._debug(s,"error",i),Ne(i))return this._returnResult({data:{session:null,user:null},error:i});throw i}finally{this._debug(s,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,s){const i=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:s.redirectTo,scopes:s.scopes,queryParams:s.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",s,"url",i),Gt()&&!s.skipBrowserRedirect&&window.location.assign(i),{data:{provider:e,url:i},error:null}}async _recoverAndRefresh(){var e,s;const i="#_recoverAndRefresh()";this._debug(i,"begin");try{const l=await Ua(this.storage,this.storageKey);if(l&&this.userStorage){let d=await Ua(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!d&&(d={user:l.user},await Qi(this.userStorage,this.storageKey+"-user",d)),l.user=(e=d?.user)!==null&&e!==void 0?e:cf()}else if(l&&!l.user&&!l.user){const d=await Ua(this.storage,this.storageKey+"-user");d&&d?.user?(l.user=d.user,await Ht(this.storage,this.storageKey+"-user"),await Qi(this.storage,this.storageKey,l)):l.user=cf()}if(this._debug(i,"session from storage",l),!this._isValidSession(l)){this._debug(i,"session is not valid"),l!==null&&await this._removeSession();return}const u=((s=l.expires_at)!==null&&s!==void 0?s:1/0)*1e3-Date.now()<rf;if(this._debug(i,`session has${u?"":" not"} expired with margin of ${rf}s`),u){if(this.autoRefreshToken&&l.refresh_token){const{error:d}=await this._callRefreshToken(l.refresh_token);d&&(console.error(d),lf(d)||(this._debug(i,"refresh failed with a non-retryable error, removing the session",d),await this._removeSession()))}}else if(l.user&&l.user.__isUserNotAvailableProxy===!0)try{const{data:d,error:h}=await this._getUser(l.access_token);!h&&d?.user?(l.user=d.user,await this._saveSession(l),await this._notifyAllSubscribers("SIGNED_IN",l)):this._debug(i,"could not get user data, skipping SIGNED_IN notification")}catch(d){console.error("Error getting user data:",d),this._debug(i,"error getting user data, skipping SIGNED_IN notification",d)}else await this._notifyAllSubscribers("SIGNED_IN",l)}catch(l){this._debug(i,"error",l),console.error(l);return}finally{this._debug(i,"end")}}async _callRefreshToken(e){var s,i;if(!e)throw new xn;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const l=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(l,"begin");try{this.refreshingDeferred=new Nu;const{data:u,error:d}=await this._refreshAccessToken(e);if(d)throw d;if(!u.session)throw new xn;await this._saveSession(u.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",u.session);const h={data:u.session,error:null};return this.refreshingDeferred.resolve(h),h}catch(u){if(this._debug(l,"error",u),Ne(u)){const d={data:null,error:u};return lf(u)||await this._removeSession(),(s=this.refreshingDeferred)===null||s===void 0||s.resolve(d),d}throw(i=this.refreshingDeferred)===null||i===void 0||i.reject(u),u}finally{this.refreshingDeferred=null,this._debug(l,"end")}}async _notifyAllSubscribers(e,s,i=!0){const l=`#_notifyAllSubscribers(${e})`;this._debug(l,"begin",s,`broadcast = ${i}`);try{this.broadcastChannel&&i&&this.broadcastChannel.postMessage({event:e,session:s});const u=[],d=Array.from(this.stateChangeEmitters.values()).map(async h=>{try{await h.callback(e,s)}catch(m){u.push(m)}});if(await Promise.all(d),u.length>0){for(let h=0;h<u.length;h+=1)console.error(u[h]);throw u[0]}}finally{this._debug(l,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await Ht(this.storage,`${this.storageKey}-code-verifier`);const s=Object.assign({},e),i=s.user&&s.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!i&&s.user&&await Qi(this.userStorage,this.storageKey+"-user",{user:s.user});const l=Object.assign({},s);delete l.user;const u=Jx(l);await Qi(this.storage,this.storageKey,u)}else{const l=Jx(s);await Qi(this.storage,this.storageKey,l)}}async _removeSession(){this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await Ht(this.storage,this.storageKey),await Ht(this.storage,this.storageKey+"-code-verifier"),await Ht(this.storage,this.storageKey+"-user"),this.userStorage&&await Ht(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&Gt()&&window?.removeEventListener&&window.removeEventListener("visibilitychange",e)}catch(s){console.error("removing visibilitychange callback failed",s)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),Ji);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e);const s=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);this.autoRefreshTickTimeout=s,s&&typeof s=="object"&&typeof s.unref=="function"?s.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(s)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e);const s=this.autoRefreshTickTimeout;this.autoRefreshTickTimeout=null,s&&clearTimeout(s)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async s=>{const{data:{session:i}}=s;if(!i||!i.refresh_token||!i.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const l=Math.floor((i.expires_at*1e3-e)/Ji);this._debug("#_autoRefreshTokenTick()",`access token expires in ${l} ticks, a tick lasts ${Ji}ms, refresh threshold is ${Yf} ticks`),l<=Yf&&await this._callRefreshToken(i.refresh_token)})}catch(s){console.error("Auto refresh tick failed with error. This is likely a transient error.",s)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof pw)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!Gt()||!window?.addEventListener)return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(e){this._debug("#visibilityChangedCallback","error",e)}},window?.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const s=`#_onVisibilityChanged(${e})`;this._debug(s,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{if(document.visibilityState!=="visible"){this._debug(s,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,s,i){const l=[`provider=${encodeURIComponent(s)}`];if(i?.redirectTo&&l.push(`redirect_to=${encodeURIComponent(i.redirectTo)}`),i?.scopes&&l.push(`scopes=${encodeURIComponent(i.scopes)}`),this.flowType==="pkce"){const[u,d]=await qi(this.storage,this.storageKey),h=new URLSearchParams({code_challenge:`${encodeURIComponent(u)}`,code_challenge_method:`${encodeURIComponent(d)}`});l.push(h.toString())}if(i?.queryParams){const u=new URLSearchParams(i.queryParams);l.push(u.toString())}return i?.skipBrowserRedirect&&l.push(`skip_http_redirect=${i.skipBrowserRedirect}`),`${e}?${l.join("&")}`}async _unenroll(e){try{return await this._useSession(async s=>{var i;const{data:l,error:u}=s;return u?this._returnResult({data:null,error:u}):await Re(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(i=l?.session)===null||i===void 0?void 0:i.access_token})})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async _enroll(e){try{return await this._useSession(async s=>{var i,l;const{data:u,error:d}=s;if(d)return this._returnResult({data:null,error:d});const h=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:e.factorType==="totp"?{issuer:e.issuer}:{}),{data:m,error:g}=await Re(this.fetch,"POST",`${this.url}/factors`,{body:h,headers:this.headers,jwt:(i=u?.session)===null||i===void 0?void 0:i.access_token});return g?this._returnResult({data:null,error:g}):(e.factorType==="totp"&&m.type==="totp"&&(!((l=m?.totp)===null||l===void 0)&&l.qr_code)&&(m.totp.qr_code=`data:image/svg+xml;utf-8,${m.totp.qr_code}`),this._returnResult({data:m,error:null}))})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async _verify(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async s=>{var i;const{data:l,error:u}=s;if(u)return this._returnResult({data:null,error:u});const d=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:e.webauthn.type==="create"?aE(e.webauthn.credential_response):iE(e.webauthn.credential_response)})}:{code:e.code}),{data:h,error:m}=await Re(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:d,headers:this.headers,jwt:(i=l?.session)===null||i===void 0?void 0:i.access_token});return m?this._returnResult({data:null,error:m}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+h.expires_in},h)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",h),this._returnResult({data:h,error:m}))})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}})}async _challenge(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async s=>{var i;const{data:l,error:u}=s;if(u)return this._returnResult({data:null,error:u});const d=await Re(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(i=l?.session)===null||i===void 0?void 0:i.access_token});if(d.error)return d;const{data:h}=d;if(h.type!=="webauthn")return{data:h,error:null};switch(h.webauthn.type){case"create":return{data:Object.assign(Object.assign({},h),{webauthn:Object.assign(Object.assign({},h.webauthn),{credential_options:Object.assign(Object.assign({},h.webauthn.credential_options),{publicKey:nE(h.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},h),{webauthn:Object.assign(Object.assign({},h.webauthn),{credential_options:Object.assign(Object.assign({},h.webauthn.credential_options),{publicKey:sE(h.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}})}async _challengeAndVerify(e){const{data:s,error:i}=await this._challenge({factorId:e.factorId});return i?this._returnResult({data:null,error:i}):await this._verify({factorId:e.factorId,challengeId:s.id,code:e.code})}async _listFactors(){var e;const{data:{user:s},error:i}=await this.getUser();if(i)return{data:null,error:i};const l={all:[],phone:[],totp:[],webauthn:[]};for(const u of(e=s?.factors)!==null&&e!==void 0?e:[])l.all.push(u),u.status==="verified"&&l[u.factor_type].push(u);return{data:l,error:null}}async _getAuthenticatorAssuranceLevel(e){var s,i,l,u;if(e)try{const{payload:S}=Rc(e);let E=null;S.aal&&(E=S.aal);let j=E;const{data:{user:_},error:N}=await this.getUser(e);if(N)return this._returnResult({data:null,error:N});((i=(s=_?.factors)===null||s===void 0?void 0:s.filter(A=>A.status==="verified"))!==null&&i!==void 0?i:[]).length>0&&(j="aal2");const C=S.amr||[];return{data:{currentLevel:E,nextLevel:j,currentAuthenticationMethods:C},error:null}}catch(S){if(Ne(S))return this._returnResult({data:null,error:S});throw S}const{data:{session:d},error:h}=await this.getSession();if(h)return this._returnResult({data:null,error:h});if(!d)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:m}=Rc(d.access_token);let g=null;m.aal&&(g=m.aal);let y=g;((u=(l=d.user.factors)===null||l===void 0?void 0:l.filter(S=>S.status==="verified"))!==null&&u!==void 0?u:[]).length>0&&(y="aal2");const w=m.amr||[];return{data:{currentLevel:g,nextLevel:y,currentAuthenticationMethods:w},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async s=>{const{data:{session:i},error:l}=s;return l?this._returnResult({data:null,error:l}):i?await Re(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:i.access_token,xform:u=>({data:u,error:null})}):this._returnResult({data:null,error:new xn})})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async _approveAuthorization(e,s){try{return await this._useSession(async i=>{const{data:{session:l},error:u}=i;if(u)return this._returnResult({data:null,error:u});if(!l)return this._returnResult({data:null,error:new xn});const d=await Re(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:l.access_token,body:{action:"approve"},xform:h=>({data:h,error:null})});return d.data&&d.data.redirect_url&&Gt()&&!s?.skipBrowserRedirect&&window.location.assign(d.data.redirect_url),d})}catch(i){if(Ne(i))return this._returnResult({data:null,error:i});throw i}}async _denyAuthorization(e,s){try{return await this._useSession(async i=>{const{data:{session:l},error:u}=i;if(u)return this._returnResult({data:null,error:u});if(!l)return this._returnResult({data:null,error:new xn});const d=await Re(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:l.access_token,body:{action:"deny"},xform:h=>({data:h,error:null})});return d.data&&d.data.redirect_url&&Gt()&&!s?.skipBrowserRedirect&&window.location.assign(d.data.redirect_url),d})}catch(i){if(Ne(i))return this._returnResult({data:null,error:i});throw i}}async _listOAuthGrants(){try{return await this._useSession(async e=>{const{data:{session:s},error:i}=e;return i?this._returnResult({data:null,error:i}):s?await Re(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:s.access_token,xform:l=>({data:l,error:null})}):this._returnResult({data:null,error:new xn})})}catch(e){if(Ne(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async s=>{const{data:{session:i},error:l}=s;return l?this._returnResult({data:null,error:l}):i?(await Re(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:i.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new xn})})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async fetchJwk(e,s={keys:[]}){let i=s.keys.find(h=>h.kid===e);if(i)return i;const l=Date.now();if(i=this.jwks.keys.find(h=>h.kid===e),i&&this.jwks_cached_at+mT>l)return i;const{data:u,error:d}=await Re(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(d)throw d;return!u.keys||u.keys.length===0||(this.jwks=u,this.jwks_cached_at=l,i=u.keys.find(h=>h.kid===e),!i)?null:i}async getClaims(e,s={}){try{let i=e;if(!i){const{data:S,error:E}=await this.getSession();if(E||!S.session)return this._returnResult({data:null,error:E});i=S.session.access_token}const{header:l,payload:u,signature:d,raw:{header:h,payload:m}}=Rc(i);s?.allowExpired||zT(u.exp);const g=!l.alg||l.alg.startsWith("HS")||!l.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(l.kid,s?.keys?{keys:s.keys}:s?.jwks);if(!g){const{error:S}=await this.getUser(i);if(S)throw S;return{data:{claims:u,header:l,signature:d},error:null}}const y=LT(l.alg),x=await crypto.subtle.importKey("jwk",g,y,!0,["verify"]);if(!await crypto.subtle.verify(y,x,d,jT(`${h}.${m}`)))throw new Jf("Invalid JWT signature");return{data:{claims:u,header:l,signature:d},error:null}}catch(i){if(Ne(i))return this._returnResult({data:null,error:i});throw i}}}Lo.nextInstanceID={};const mE=Lo,pE="2.97.0";let wo="";typeof Deno<"u"?wo="deno":typeof document<"u"?wo="web":typeof navigator<"u"&&navigator.product==="ReactNative"?wo="react-native":wo="node";const gE={"X-Client-Info":`supabase-js-${wo}/${pE}`},yE={headers:gE},vE={schema:"public"},xE={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},bE={};function Uo(t){"@babel/helpers - typeof";return Uo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Uo(t)}function wE(t,e){if(Uo(t)!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var i=s.call(t,e);if(Uo(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function SE(t){var e=wE(t,"string");return Uo(e)=="symbol"?e:e+""}function jE(t,e,s){return(e=SE(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function i0(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(l){return Object.getOwnPropertyDescriptor(t,l).enumerable})),s.push.apply(s,i)}return s}function yt(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?i0(Object(s),!0).forEach(function(i){jE(t,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):i0(Object(s)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(s,i))})}return t}const _E=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),NE=()=>Headers,TE=(t,e,s)=>{const i=_E(s),l=NE();return async(u,d)=>{var h;const m=(h=await e())!==null&&h!==void 0?h:t;let g=new l(d?.headers);return g.has("apikey")||g.set("apikey",t),g.has("Authorization")||g.set("Authorization",`Bearer ${m}`),i(u,yt(yt({},d),{},{headers:g}))}};function EE(t){return t.endsWith("/")?t:t+"/"}function kE(t,e){var s,i;const{db:l,auth:u,realtime:d,global:h}=t,{db:m,auth:g,realtime:y,global:x}=e,w={db:yt(yt({},m),l),auth:yt(yt({},g),u),realtime:yt(yt({},y),d),storage:{},global:yt(yt(yt({},x),h),{},{headers:yt(yt({},(s=x?.headers)!==null&&s!==void 0?s:{}),(i=h?.headers)!==null&&i!==void 0?i:{})}),accessToken:async()=>""};return t.accessToken?w.accessToken=t.accessToken:delete w.accessToken,w}function CE(t){const e=t?.trim();if(!e)throw new Error("supabaseUrl is required.");if(!e.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(EE(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var AE=class extends mE{constructor(t){super(t)}},RE=class{constructor(t,e,s){var i,l;this.supabaseUrl=t,this.supabaseKey=e;const u=CE(t);if(!e)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",u),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",u),this.storageUrl=new URL("storage/v1",u),this.functionsUrl=new URL("functions/v1",u);const d=`sb-${u.hostname.split(".")[0]}-auth-token`,h={db:vE,realtime:bE,auth:yt(yt({},xE),{},{storageKey:d}),global:yE},m=kE(s??{},h);if(this.storageKey=(i=m.auth.storageKey)!==null&&i!==void 0?i:"",this.headers=(l=m.global.headers)!==null&&l!==void 0?l:{},m.accessToken)this.accessToken=m.accessToken,this.auth=new Proxy({},{get:(y,x)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(x)} is not possible`)}});else{var g;this.auth=this._initSupabaseAuthClient((g=m.auth)!==null&&g!==void 0?g:{},this.headers,m.global.fetch)}this.fetch=TE(e,this._getAccessToken.bind(this),m.global.fetch),this.realtime=this._initRealtimeClient(yt({headers:this.headers,accessToken:this._getAccessToken.bind(this)},m.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(y=>this.realtime.setAuth(y)).catch(y=>console.warn("Failed to set initial Realtime auth token:",y)),this.rest=new g2(new URL("rest/v1",u).href,{headers:this.headers,schema:m.db.schema,fetch:this.fetch,timeout:m.db.timeout,urlLengthLimit:m.db.urlLengthLimit}),this.storage=new cT(this.storageUrl.href,this.headers,this.fetch,s?.storage),m.accessToken||this._listenForAuthEvents()}get functions(){return new l2(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(t){return this.rest.from(t)}schema(t){return this.rest.schema(t)}rpc(t,e={},s={head:!1,get:!1,count:void 0}){return this.rest.rpc(t,e,s)}channel(t,e={config:{}}){return this.realtime.channel(t,e)}getChannels(){return this.realtime.getChannels()}removeChannel(t){return this.realtime.removeChannel(t)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var t=this,e,s;if(t.accessToken)return await t.accessToken();const{data:i}=await t.auth.getSession();return(e=(s=i.session)===null||s===void 0?void 0:s.access_token)!==null&&e!==void 0?e:t.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:t,persistSession:e,detectSessionInUrl:s,storage:i,userStorage:l,storageKey:u,flowType:d,lock:h,debug:m,throwOnError:g},y,x){const w={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new AE({url:this.authUrl.href,headers:yt(yt({},w),y),storageKey:u,autoRefreshToken:t,persistSession:e,detectSessionInUrl:s,storage:i,userStorage:l,flowType:d,lock:h,debug:m,throwOnError:g,fetch:x,hasCustomAuthorizationHeader:Object.keys(this.headers).some(S=>S.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new M2(this.realtimeUrl.href,yt(yt({},t),{},{params:yt(yt({},{apikey:this.supabaseKey}),t?.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,e)=>{this._handleTokenChanged(t,"CLIENT",e?.access_token)})}_handleTokenChanged(t,e,s){(t==="TOKEN_REFRESHED"||t==="SIGNED_IN")&&this.changedAccessToken!==s?(this.changedAccessToken=s,this.realtime.setAuth(s)):t==="SIGNED_OUT"&&(this.realtime.setAuth(),e=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};const zm=(t,e,s)=>new RE(t,e,s);function OE(){if(typeof window<"u")return!1;const t=globalThis.process;if(!t)return!1;const e=t.version;if(e==null)return!1;const s=e.match(/^v(\d+)\./);return s?parseInt(s[1],10)<=18:!1}OE()&&console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");function vw(t){var e,s,i="";if(typeof t=="string"||typeof t=="number")i+=t;else if(typeof t=="object")if(Array.isArray(t)){var l=t.length;for(e=0;e<l;e++)t[e]&&(s=vw(t[e]))&&(i&&(i+=" "),i+=s)}else for(s in t)t[s]&&(i&&(i+=" "),i+=s);return i}function xw(){for(var t,e,s=0,i="",l=arguments.length;s<l;s++)(t=arguments[s])&&(e=vw(t))&&(i&&(i+=" "),i+=e);return i}const ME=(t,e)=>{const s=new Array(t.length+e.length);for(let i=0;i<t.length;i++)s[i]=t[i];for(let i=0;i<e.length;i++)s[t.length+i]=e[i];return s},DE=(t,e)=>({classGroupId:t,validator:e}),bw=(t=new Map,e=null,s)=>({nextPart:t,validators:e,classGroupId:s}),ru="-",r0=[],PE="arbitrary..",zE=t=>{const e=UE(t),{conflictingClassGroups:s,conflictingClassGroupModifiers:i}=t;return{getClassGroupId:d=>{if(d.startsWith("[")&&d.endsWith("]"))return LE(d);const h=d.split(ru),m=h[0]===""&&h.length>1?1:0;return ww(h,m,e)},getConflictingClassGroupIds:(d,h)=>{if(h){const m=i[d],g=s[d];return m?g?ME(g,m):m:g||r0}return s[d]||r0}}},ww=(t,e,s)=>{if(t.length-e===0)return s.classGroupId;const l=t[e],u=s.nextPart.get(l);if(u){const g=ww(t,e+1,u);if(g)return g}const d=s.validators;if(d===null)return;const h=e===0?t.join(ru):t.slice(e).join(ru),m=d.length;for(let g=0;g<m;g++){const y=d[g];if(y.validator(h))return y.classGroupId}},LE=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),s=e.indexOf(":"),i=e.slice(0,s);return i?PE+i:void 0})(),UE=t=>{const{theme:e,classGroups:s}=t;return BE(s,e)},BE=(t,e)=>{const s=bw();for(const i in t){const l=t[i];Lm(l,s,i,e)}return s},Lm=(t,e,s,i)=>{const l=t.length;for(let u=0;u<l;u++){const d=t[u];VE(d,e,s,i)}},VE=(t,e,s,i)=>{if(typeof t=="string"){IE(t,e,s);return}if(typeof t=="function"){$E(t,e,s,i);return}qE(t,e,s,i)},IE=(t,e,s)=>{const i=t===""?e:Sw(e,t);i.classGroupId=s},$E=(t,e,s,i)=>{if(HE(t)){Lm(t(i),e,s,i);return}e.validators===null&&(e.validators=[]),e.validators.push(DE(s,t))},qE=(t,e,s,i)=>{const l=Object.entries(t),u=l.length;for(let d=0;d<u;d++){const[h,m]=l[d];Lm(m,Sw(e,h),s,i)}},Sw=(t,e)=>{let s=t;const i=e.split(ru),l=i.length;for(let u=0;u<l;u++){const d=i[u];let h=s.nextPart.get(d);h||(h=bw(),s.nextPart.set(d,h)),s=h}return s},HE=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,GE=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,s=Object.create(null),i=Object.create(null);const l=(u,d)=>{s[u]=d,e++,e>t&&(e=0,i=s,s=Object.create(null))};return{get(u){let d=s[u];if(d!==void 0)return d;if((d=i[u])!==void 0)return l(u,d),d},set(u,d){u in s?s[u]=d:l(u,d)}}},Qf="!",o0=":",FE=[],l0=(t,e,s,i,l)=>({modifiers:t,hasImportantModifier:e,baseClassName:s,maybePostfixModifierPosition:i,isExternal:l}),KE=t=>{const{prefix:e,experimentalParseClassName:s}=t;let i=l=>{const u=[];let d=0,h=0,m=0,g;const y=l.length;for(let j=0;j<y;j++){const _=l[j];if(d===0&&h===0){if(_===o0){u.push(l.slice(m,j)),m=j+1;continue}if(_==="/"){g=j;continue}}_==="["?d++:_==="]"?d--:_==="("?h++:_===")"&&h--}const x=u.length===0?l:l.slice(m);let w=x,S=!1;x.endsWith(Qf)?(w=x.slice(0,-1),S=!0):x.startsWith(Qf)&&(w=x.slice(1),S=!0);const E=g&&g>m?g-m:void 0;return l0(u,S,w,E)};if(e){const l=e+o0,u=i;i=d=>d.startsWith(l)?u(d.slice(l.length)):l0(FE,!1,d,void 0,!0)}if(s){const l=i;i=u=>s({className:u,parseClassName:l})}return i},YE=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((s,i)=>{e.set(s,1e6+i)}),s=>{const i=[];let l=[];for(let u=0;u<s.length;u++){const d=s[u],h=d[0]==="[",m=e.has(d);h||m?(l.length>0&&(l.sort(),i.push(...l),l=[]),i.push(d)):l.push(d)}return l.length>0&&(l.sort(),i.push(...l)),i}},XE=t=>({cache:GE(t.cacheSize),parseClassName:KE(t),sortModifiers:YE(t),...zE(t)}),WE=/\s+/,JE=(t,e)=>{const{parseClassName:s,getClassGroupId:i,getConflictingClassGroupIds:l,sortModifiers:u}=e,d=[],h=t.trim().split(WE);let m="";for(let g=h.length-1;g>=0;g-=1){const y=h[g],{isExternal:x,modifiers:w,hasImportantModifier:S,baseClassName:E,maybePostfixModifierPosition:j}=s(y);if(x){m=y+(m.length>0?" "+m:m);continue}let _=!!j,N=i(_?E.substring(0,j):E);if(!N){if(!_){m=y+(m.length>0?" "+m:m);continue}if(N=i(E),!N){m=y+(m.length>0?" "+m:m);continue}_=!1}const k=w.length===0?"":w.length===1?w[0]:u(w).join(":"),C=S?k+Qf:k,A=C+N;if(d.indexOf(A)>-1)continue;d.push(A);const D=l(N,_);for(let z=0;z<D.length;++z){const V=D[z];d.push(C+V)}m=y+(m.length>0?" "+m:m)}return m},QE=(...t)=>{let e=0,s,i,l="";for(;e<t.length;)(s=t[e++])&&(i=jw(s))&&(l&&(l+=" "),l+=i);return l},jw=t=>{if(typeof t=="string")return t;let e,s="";for(let i=0;i<t.length;i++)t[i]&&(e=jw(t[i]))&&(s&&(s+=" "),s+=e);return s},ZE=(t,...e)=>{let s,i,l,u;const d=m=>{const g=e.reduce((y,x)=>x(y),t());return s=XE(g),i=s.cache.get,l=s.cache.set,u=h,h(m)},h=m=>{const g=i(m);if(g)return g;const y=JE(m,s);return l(m,y),y};return u=d,(...m)=>u(QE(...m))},ek=[],At=t=>{const e=s=>s[t]||ek;return e.isThemeGetter=!0,e},_w=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Nw=/^\((?:(\w[\w-]*):)?(.+)\)$/i,tk=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,nk=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,sk=/\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$/,ak=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ik=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,rk=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,aa=t=>tk.test(t),Ue=t=>!!t&&!Number.isNaN(Number(t)),ia=t=>!!t&&Number.isInteger(Number(t)),df=t=>t.endsWith("%")&&Ue(t.slice(0,-1)),Es=t=>nk.test(t),Tw=()=>!0,ok=t=>sk.test(t)&&!ak.test(t),Um=()=>!1,lk=t=>ik.test(t),ck=t=>rk.test(t),uk=t=>!xe(t)&&!we(t),dk=t=>ga(t,Cw,Um),xe=t=>_w.test(t),Ba=t=>ga(t,Aw,ok),c0=t=>ga(t,xk,Ue),hk=t=>ga(t,Ow,Tw),fk=t=>ga(t,Rw,Um),u0=t=>ga(t,Ew,Um),mk=t=>ga(t,kw,ck),Oc=t=>ga(t,Mw,lk),we=t=>Nw.test(t),vo=t=>ti(t,Aw),pk=t=>ti(t,Rw),d0=t=>ti(t,Ew),gk=t=>ti(t,Cw),yk=t=>ti(t,kw),Mc=t=>ti(t,Mw,!0),vk=t=>ti(t,Ow,!0),ga=(t,e,s)=>{const i=_w.exec(t);return i?i[1]?e(i[1]):s(i[2]):!1},ti=(t,e,s=!1)=>{const i=Nw.exec(t);return i?i[1]?e(i[1]):s:!1},Ew=t=>t==="position"||t==="percentage",kw=t=>t==="image"||t==="url",Cw=t=>t==="length"||t==="size"||t==="bg-size",Aw=t=>t==="length",xk=t=>t==="number",Rw=t=>t==="family-name",Ow=t=>t==="number"||t==="weight",Mw=t=>t==="shadow",bk=()=>{const t=At("color"),e=At("font"),s=At("text"),i=At("font-weight"),l=At("tracking"),u=At("leading"),d=At("breakpoint"),h=At("container"),m=At("spacing"),g=At("radius"),y=At("shadow"),x=At("inset-shadow"),w=At("text-shadow"),S=At("drop-shadow"),E=At("blur"),j=At("perspective"),_=At("aspect"),N=At("ease"),k=At("animate"),C=()=>["auto","avoid","all","avoid-page","page","left","right","column"],A=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],D=()=>[...A(),we,xe],z=()=>["auto","hidden","clip","visible","scroll"],V=()=>["auto","contain","none"],R=()=>[we,xe,m],P=()=>[aa,"full","auto",...R()],Z=()=>[ia,"none","subgrid",we,xe],te=()=>["auto",{span:["full",ia,we,xe]},ia,we,xe],me=()=>[ia,"auto",we,xe],Ee=()=>["auto","min","max","fr",we,xe],ye=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],_e=()=>["start","end","center","stretch","center-safe","end-safe"],$=()=>["auto",...R()],Y=()=>[aa,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],J=()=>[aa,"screen","full","dvw","lvw","svw","min","max","fit",...R()],pe=()=>[aa,"screen","full","lh","dvh","lvh","svh","min","max","fit",...R()],se=()=>[t,we,xe],M=()=>[...A(),d0,u0,{position:[we,xe]}],U=()=>["no-repeat",{repeat:["","x","y","space","round"]}],W=()=>["auto","cover","contain",gk,dk,{size:[we,xe]}],ne=()=>[df,vo,Ba],oe=()=>["","none","full",g,we,xe],ue=()=>["",Ue,vo,Ba],q=()=>["solid","dashed","dotted","double"],fe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],re=()=>[Ue,df,d0,u0],ze=()=>["","none",E,we,xe],Be=()=>["none",Ue,we,xe],kt=()=>["none",Ue,we,xe],et=()=>[Ue,we,xe],le=()=>[aa,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Es],breakpoint:[Es],color:[Tw],container:[Es],"drop-shadow":[Es],ease:["in","out","in-out"],font:[uk],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Es],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Es],shadow:[Es],spacing:["px",Ue],text:[Es],"text-shadow":[Es],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",aa,xe,we,_]}],container:["container"],columns:[{columns:[Ue,xe,we,h]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"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:D()}],overflow:[{overflow:z()}],"overflow-x":[{"overflow-x":z()}],"overflow-y":[{"overflow-y":z()}],overscroll:[{overscroll:V()}],"overscroll-x":[{"overscroll-x":V()}],"overscroll-y":[{"overscroll-y":V()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:P()}],"inset-x":[{"inset-x":P()}],"inset-y":[{"inset-y":P()}],start:[{"inset-s":P(),start:P()}],end:[{"inset-e":P(),end:P()}],"inset-bs":[{"inset-bs":P()}],"inset-be":[{"inset-be":P()}],top:[{top:P()}],right:[{right:P()}],bottom:[{bottom:P()}],left:[{left:P()}],visibility:["visible","invisible","collapse"],z:[{z:[ia,"auto",we,xe]}],basis:[{basis:[aa,"full","auto",h,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ue,aa,"auto","initial","none",xe]}],grow:[{grow:["",Ue,we,xe]}],shrink:[{shrink:["",Ue,we,xe]}],order:[{order:[ia,"first","last","none",we,xe]}],"grid-cols":[{"grid-cols":Z()}],"col-start-end":[{col:te()}],"col-start":[{"col-start":me()}],"col-end":[{"col-end":me()}],"grid-rows":[{"grid-rows":Z()}],"row-start-end":[{row:te()}],"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":Ee()}],"auto-rows":[{"auto-rows":Ee()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...ye(),"normal"]}],"justify-items":[{"justify-items":[..._e(),"normal"]}],"justify-self":[{"justify-self":["auto",..._e()]}],"align-content":[{content:["normal",...ye()]}],"align-items":[{items:[..._e(),{baseline:["","last"]}]}],"align-self":[{self:["auto",..._e(),{baseline:["","last"]}]}],"place-content":[{"place-content":ye()}],"place-items":[{"place-items":[..._e(),"baseline"]}],"place-self":[{"place-self":["auto",..._e()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pbs:[{pbs:R()}],pbe:[{pbe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:$()}],mx:[{mx:$()}],my:[{my:$()}],ms:[{ms:$()}],me:[{me:$()}],mbs:[{mbs:$()}],mbe:[{mbe:$()}],mt:[{mt:$()}],mr:[{mr:$()}],mb:[{mb:$()}],ml:[{ml:$()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:Y()}],"inline-size":[{inline:["auto",...J()]}],"min-inline-size":[{"min-inline":["auto",...J()]}],"max-inline-size":[{"max-inline":["none",...J()]}],"block-size":[{block:["auto",...pe()]}],"min-block-size":[{"min-block":["auto",...pe()]}],"max-block-size":[{"max-block":["none",...pe()]}],w:[{w:[h,"screen",...Y()]}],"min-w":[{"min-w":[h,"screen","none",...Y()]}],"max-w":[{"max-w":[h,"screen","none","prose",{screen:[d]},...Y()]}],h:[{h:["screen","lh",...Y()]}],"min-h":[{"min-h":["screen","lh","none",...Y()]}],"max-h":[{"max-h":["screen","lh",...Y()]}],"font-size":[{text:["base",s,vo,Ba]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[i,vk,hk]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",df,xe]}],"font-family":[{font:[pk,fk,e]}],"font-features":[{"font-features":[xe]}],"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:[l,we,xe]}],"line-clamp":[{"line-clamp":[Ue,"none",we,c0]}],leading:[{leading:[u,...R()]}],"list-image":[{"list-image":["none",we,xe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",we,xe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:se()}],"text-color":[{text:se()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...q(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ue,"from-font","auto",we,Ba]}],"text-decoration-color":[{decoration:se()}],"underline-offset":[{"underline-offset":[Ue,"auto",we,xe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",we,xe]}],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",we,xe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:M()}],"bg-repeat":[{bg:U()}],"bg-size":[{bg:W()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ia,we,xe],radial:["",we,xe],conic:[ia,we,xe]},yk,mk]}],"bg-color":[{bg:se()}],"gradient-from-pos":[{from:ne()}],"gradient-via-pos":[{via:ne()}],"gradient-to-pos":[{to:ne()}],"gradient-from":[{from:se()}],"gradient-via":[{via:se()}],"gradient-to":[{to:se()}],rounded:[{rounded:oe()}],"rounded-s":[{"rounded-s":oe()}],"rounded-e":[{"rounded-e":oe()}],"rounded-t":[{"rounded-t":oe()}],"rounded-r":[{"rounded-r":oe()}],"rounded-b":[{"rounded-b":oe()}],"rounded-l":[{"rounded-l":oe()}],"rounded-ss":[{"rounded-ss":oe()}],"rounded-se":[{"rounded-se":oe()}],"rounded-ee":[{"rounded-ee":oe()}],"rounded-es":[{"rounded-es":oe()}],"rounded-tl":[{"rounded-tl":oe()}],"rounded-tr":[{"rounded-tr":oe()}],"rounded-br":[{"rounded-br":oe()}],"rounded-bl":[{"rounded-bl":oe()}],"border-w":[{border:ue()}],"border-w-x":[{"border-x":ue()}],"border-w-y":[{"border-y":ue()}],"border-w-s":[{"border-s":ue()}],"border-w-e":[{"border-e":ue()}],"border-w-bs":[{"border-bs":ue()}],"border-w-be":[{"border-be":ue()}],"border-w-t":[{"border-t":ue()}],"border-w-r":[{"border-r":ue()}],"border-w-b":[{"border-b":ue()}],"border-w-l":[{"border-l":ue()}],"divide-x":[{"divide-x":ue()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ue()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...q(),"hidden","none"]}],"divide-style":[{divide:[...q(),"hidden","none"]}],"border-color":[{border:se()}],"border-color-x":[{"border-x":se()}],"border-color-y":[{"border-y":se()}],"border-color-s":[{"border-s":se()}],"border-color-e":[{"border-e":se()}],"border-color-bs":[{"border-bs":se()}],"border-color-be":[{"border-be":se()}],"border-color-t":[{"border-t":se()}],"border-color-r":[{"border-r":se()}],"border-color-b":[{"border-b":se()}],"border-color-l":[{"border-l":se()}],"divide-color":[{divide:se()}],"outline-style":[{outline:[...q(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ue,we,xe]}],"outline-w":[{outline:["",Ue,vo,Ba]}],"outline-color":[{outline:se()}],shadow:[{shadow:["","none",y,Mc,Oc]}],"shadow-color":[{shadow:se()}],"inset-shadow":[{"inset-shadow":["none",x,Mc,Oc]}],"inset-shadow-color":[{"inset-shadow":se()}],"ring-w":[{ring:ue()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:se()}],"ring-offset-w":[{"ring-offset":[Ue,Ba]}],"ring-offset-color":[{"ring-offset":se()}],"inset-ring-w":[{"inset-ring":ue()}],"inset-ring-color":[{"inset-ring":se()}],"text-shadow":[{"text-shadow":["none",w,Mc,Oc]}],"text-shadow-color":[{"text-shadow":se()}],opacity:[{opacity:[Ue,we,xe]}],"mix-blend":[{"mix-blend":[...fe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":fe()}],"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":[Ue]}],"mask-image-linear-from-pos":[{"mask-linear-from":re()}],"mask-image-linear-to-pos":[{"mask-linear-to":re()}],"mask-image-linear-from-color":[{"mask-linear-from":se()}],"mask-image-linear-to-color":[{"mask-linear-to":se()}],"mask-image-t-from-pos":[{"mask-t-from":re()}],"mask-image-t-to-pos":[{"mask-t-to":re()}],"mask-image-t-from-color":[{"mask-t-from":se()}],"mask-image-t-to-color":[{"mask-t-to":se()}],"mask-image-r-from-pos":[{"mask-r-from":re()}],"mask-image-r-to-pos":[{"mask-r-to":re()}],"mask-image-r-from-color":[{"mask-r-from":se()}],"mask-image-r-to-color":[{"mask-r-to":se()}],"mask-image-b-from-pos":[{"mask-b-from":re()}],"mask-image-b-to-pos":[{"mask-b-to":re()}],"mask-image-b-from-color":[{"mask-b-from":se()}],"mask-image-b-to-color":[{"mask-b-to":se()}],"mask-image-l-from-pos":[{"mask-l-from":re()}],"mask-image-l-to-pos":[{"mask-l-to":re()}],"mask-image-l-from-color":[{"mask-l-from":se()}],"mask-image-l-to-color":[{"mask-l-to":se()}],"mask-image-x-from-pos":[{"mask-x-from":re()}],"mask-image-x-to-pos":[{"mask-x-to":re()}],"mask-image-x-from-color":[{"mask-x-from":se()}],"mask-image-x-to-color":[{"mask-x-to":se()}],"mask-image-y-from-pos":[{"mask-y-from":re()}],"mask-image-y-to-pos":[{"mask-y-to":re()}],"mask-image-y-from-color":[{"mask-y-from":se()}],"mask-image-y-to-color":[{"mask-y-to":se()}],"mask-image-radial":[{"mask-radial":[we,xe]}],"mask-image-radial-from-pos":[{"mask-radial-from":re()}],"mask-image-radial-to-pos":[{"mask-radial-to":re()}],"mask-image-radial-from-color":[{"mask-radial-from":se()}],"mask-image-radial-to-color":[{"mask-radial-to":se()}],"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":A()}],"mask-image-conic-pos":[{"mask-conic":[Ue]}],"mask-image-conic-from-pos":[{"mask-conic-from":re()}],"mask-image-conic-to-pos":[{"mask-conic-to":re()}],"mask-image-conic-from-color":[{"mask-conic-from":se()}],"mask-image-conic-to-color":[{"mask-conic-to":se()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:M()}],"mask-repeat":[{mask:U()}],"mask-size":[{mask:W()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",we,xe]}],filter:[{filter:["","none",we,xe]}],blur:[{blur:ze()}],brightness:[{brightness:[Ue,we,xe]}],contrast:[{contrast:[Ue,we,xe]}],"drop-shadow":[{"drop-shadow":["","none",S,Mc,Oc]}],"drop-shadow-color":[{"drop-shadow":se()}],grayscale:[{grayscale:["",Ue,we,xe]}],"hue-rotate":[{"hue-rotate":[Ue,we,xe]}],invert:[{invert:["",Ue,we,xe]}],saturate:[{saturate:[Ue,we,xe]}],sepia:[{sepia:["",Ue,we,xe]}],"backdrop-filter":[{"backdrop-filter":["","none",we,xe]}],"backdrop-blur":[{"backdrop-blur":ze()}],"backdrop-brightness":[{"backdrop-brightness":[Ue,we,xe]}],"backdrop-contrast":[{"backdrop-contrast":[Ue,we,xe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ue,we,xe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ue,we,xe]}],"backdrop-invert":[{"backdrop-invert":["",Ue,we,xe]}],"backdrop-opacity":[{"backdrop-opacity":[Ue,we,xe]}],"backdrop-saturate":[{"backdrop-saturate":[Ue,we,xe]}],"backdrop-sepia":[{"backdrop-sepia":["",Ue,we,xe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",we,xe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ue,"initial",we,xe]}],ease:[{ease:["linear","initial",N,we,xe]}],delay:[{delay:[Ue,we,xe]}],animate:[{animate:["none",k,we,xe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[j,we,xe]}],"perspective-origin":[{"perspective-origin":D()}],rotate:[{rotate:Be()}],"rotate-x":[{"rotate-x":Be()}],"rotate-y":[{"rotate-y":Be()}],"rotate-z":[{"rotate-z":Be()}],scale:[{scale:kt()}],"scale-x":[{"scale-x":kt()}],"scale-y":[{"scale-y":kt()}],"scale-z":[{"scale-z":kt()}],"scale-3d":["scale-3d"],skew:[{skew:et()}],"skew-x":[{"skew-x":et()}],"skew-y":[{"skew-y":et()}],transform:[{transform:[we,xe,"","none","gpu","cpu"]}],"transform-origin":[{origin:D()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:le()}],"translate-x":[{"translate-x":le()}],"translate-y":[{"translate-y":le()}],"translate-z":[{"translate-z":le()}],"translate-none":["translate-none"],accent:[{accent:se()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:se()}],"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",we,xe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mbs":[{"scroll-mbs":R()}],"scroll-mbe":[{"scroll-mbe":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pbs":[{"scroll-pbs":R()}],"scroll-pbe":[{"scroll-pbe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"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",we,xe]}],fill:[{fill:["none",...se()]}],"stroke-w":[{stroke:[Ue,vo,Ba,c0]}],stroke:[{stroke:["none",...se()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{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"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},wk=ZE(bk);function ge(...t){return wk(xw(t))}const ht=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("rounded-xl border bg-card text-card-foreground shadow",t),...e}));ht.displayName="Card";const zt=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("flex flex-col space-y-1.5 p-6",t),...e}));zt.displayName="CardHeader";const Lt=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("font-semibold leading-none tracking-tight",t),...e}));Lt.displayName="CardTitle";const wn=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("text-sm text-muted-foreground",t),...e}));wn.displayName="CardDescription";const xt=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("p-6 pt-0",t),...e}));xt.displayName="CardContent";const Tu=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("flex items-center p-6 pt-0",t),...e}));Tu.displayName="CardFooter";function ou({className:t}){return o.jsx("img",{src:"/folio-logo.svg",alt:"Folio Logo",className:ge("w-full h-full object-contain",t)})}const Dw=(...t)=>t.filter((e,s,i)=>!!e&&e.trim()!==""&&i.indexOf(e)===s).join(" ").trim();const Sk=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const jk=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,i)=>i?i.toUpperCase():s.toLowerCase());const h0=t=>{const e=jk(t);return e.charAt(0).toUpperCase()+e.slice(1)};var _k={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Nk=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const Tk=v.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:s=2,absoluteStrokeWidth:i,className:l="",children:u,iconNode:d,...h},m)=>v.createElement("svg",{ref:m,..._k,width:e,height:e,stroke:t,strokeWidth:i?Number(s)*24/Number(e):s,className:Dw("lucide",l),...!u&&!Nk(h)&&{"aria-hidden":"true"},...h},[...d.map(([g,y])=>v.createElement(g,y)),...Array.isArray(u)?u:[u]]));const he=(t,e)=>{const s=v.forwardRef(({className:i,...l},u)=>v.createElement(Tk,{ref:u,iconNode:e,className:Dw(`lucide-${Sk(h0(t))}`,`lucide-${t}`,i),...l}));return s.displayName=h0(t),s};const Ek=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],ur=he("activity",Ek);const kk=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Ck=he("arrow-right",kk);const Ak=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],Rk=he("book-open",Ak);const Ok=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Zf=he("bot",Ok);const Mk=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],Pw=he("brain",Mk);const Dk=[["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"}]],Pk=he("building-2",Dk);const zk=[["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"}]],zw=he("calendar",zk);const Lk=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],Uk=he("camera",Lk);const Bk=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],as=he("check",Bk);const Vk=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Bo=he("chevron-down",Vk);const Ik=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Jo=he("chevron-left",Ik);const $k=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],dr=he("chevron-right",$k);const qk=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],lu=he("chevron-up",qk);const Hk=[["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"}]],Sn=he("circle-alert",Hk);const Gk=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Fk=he("circle-check-big",Gk);const Kk=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],os=he("circle-check",Kk);const Yk=[["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"}]],Lw=he("circle-x",Yk);const Xk=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],Qo=he("clock",Xk);const Wk=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],f0=he("cloud",Wk);const Jk=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Qk=he("copy",Jk);const Zk=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],Bm=he("cpu",Zk);const eC=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Eu=he("database",eC);const tC=[["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"}]],Uw=he("external-link",tC);const nC=[["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"}]],sC=he("eye-off",nC);const aC=[["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"}]],iC=he("eye",aC);const rC=[["path",{d:"M4 12V4a2 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 8v12a2 2 0 0 1-2 2",key:"jrl274"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 16h2v6",key:"1bxocy"}],["path",{d:"M10 22h4",key:"ceow96"}],["rect",{x:"2",y:"16",width:"4",height:"6",rx:"2",key:"r45zd0"}]],oC=he("file-digit",rC);const lC=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Vm=he("file-text",lC);const cC=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Bw=he("funnel",cC);const uC=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],dC=he("globe",uC);const hC=[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]],fC=he("hard-drive",hC);const mC=[["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"}]],pC=he("history",mC);const gC=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Im=he("info",gC);const yC=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],Zo=he("key",yC);const vC=[["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"}]],xC=he("layers",vC);const bC=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],m0=he("layout-dashboard",bC);const wC=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],rt=he("loader-circle",wC);const SC=[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]],Vw=he("log-in",SC);const jC=[["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"}]],Iw=he("log-out",jC);const _C=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],Vo=he("mail",_C);const NC=[["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"}]],cu=he("message-square",NC);const TC=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],$w=he("minimize-2",TC);const EC=[["path",{d:"M5 12h14",key:"1ays0h"}]],em=he("minus",EC);const kC=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],CC=he("moon",kC);const AC=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],RC=he("package",AC);const OC=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],qw=he("play",OC);const MC=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Wa=he("plus",MC);const DC=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],PC=he("refresh-ccw",DC);const zC=[["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"}]],ma=he("refresh-cw",zC);const LC=[["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}],["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09",key:"u4xsad"}],["path",{d:"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z",key:"676m9"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05",key:"92ym6u"}]],UC=he("rocket",LC);const BC=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],VC=he("save",BC);const IC=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],Hw=he("scroll-text",IC);const $C=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],qC=he("search",$C);const HC=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],GC=he("send",HC);const FC=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],KC=he("server",FC);const YC=[["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"}]],$m=he("settings-2",YC);const XC=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],WC=he("settings",XC);const JC=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],p0=he("share-2",JC);const QC=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],uu=he("shield-alert",QC);const ZC=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ya=he("shield-check",ZC);const eA=[["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"}]],Cs=he("sparkles",eA);const tA=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],nA=he("sun",tA);const sA=[["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"}]],du=he("tag",sA);const aA=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Io=he("terminal",aA);const iA=[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]],rA=he("test-tube",iA);const oA=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],lA=he("toggle-left",oA);const cA=[["circle",{cx:"15",cy:"12",r:"3",key:"1afu0r"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],uA=he("toggle-right",cA);const dA=[["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"}]],el=he("trash-2",dA);const hA=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Gw=he("triangle-alert",hA);const fA=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],tm=he("upload",fA);const mA=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],pA=he("user-plus",mA);const gA=[["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"}]],ku=he("user",gA);const yA=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],nm=he("volume-2",yA);const vA=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]],Fw=he("volume-x",vA);const xA=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],zn=he("x",xA);const bA=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],hu=he("zap",bA),Cu="folio_supabase_config";function g0(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.url=="string"&&typeof e.anonKey=="string"&&e.url.startsWith("http")&&e.anonKey.length>20&&!e.url.includes("placeholder.supabase.co")}function $o(){try{const e=localStorage.getItem(Cu);if(e){const s=JSON.parse(e);if(g0(s))return s}}catch{}const t={url:void 0,anonKey:void 0};return g0(t)?t:null}function hf(t){localStorage.setItem(Cu,JSON.stringify(t))}function wA(){localStorage.removeItem(Cu)}async function SA(t,e){if(!t.startsWith("http://")&&!t.startsWith("https://"))return{valid:!1,error:"Invalid URL format"};const s=e.startsWith("eyJ"),i=e.startsWith("sb_publishable_");if(!s&&!i)return{valid:!1,error:"Invalid anon key format"};if(i)return{valid:!0};const l=new AbortController,u=setTimeout(()=>l.abort("Validation timeout"),12e3);try{const d=await fetch(`${t}/rest/v1/`,{method:"GET",headers:{apikey:e,Authorization:`Bearer ${e}`},signal:l.signal});return d.ok?(clearTimeout(u),{valid:!0}):(clearTimeout(u),{valid:!1,error:`Connection failed (${d.status})`})}catch(d){return clearTimeout(u),d instanceof DOMException&&d.name==="AbortError"?{valid:!1,error:"Connection validation timed out (12s). Check project URL/key and network."}:{valid:!1,error:d instanceof Error?d.message:"Connection failed"}}}function jA(){return localStorage.getItem(Cu)?"ui":"none"}let Dc=null;function un(){const t=$o();return t?(Dc||(Dc=zm(t.url,t.anonKey,{auth:{autoRefreshToken:!0,persistSession:!0}})),Dc):(Dc=null,null)}function ff(){const t=$o(),e=t?`${t.url}/functions/v1`:"",s=t?.anonKey??"",u=window.location.port==="5173"?void 0||"http://localhost:3006":window.location.origin;return{edgeFunctionsUrl:e,expressApiUrl:u,anonKey:s}}class _A{edgeFunctionsUrl;expressApiUrl;anonKey;constructor(){const e=ff();this.edgeFunctionsUrl=e.edgeFunctionsUrl,this.expressApiUrl=e.expressApiUrl,this.anonKey=e.anonKey}async request(e,s,i={}){const{auth:l=!1,token:u,...d}=i,h={"Content-Type":"application/json",...d.headers||{}};l&&u&&(h.Authorization=`Bearer ${u}`);try{const m=await fetch(`${e}${s}`,{...d,headers:h}),g=await m.json().catch(()=>({}));return m.ok?{data:g}:{error:{code:g?.error?.code||"API_ERROR",message:g?.error?.message||g?.error||`Request failed (${m.status})`}}}catch(m){return{error:{code:"NETWORK_ERROR",message:m instanceof Error?m.message:"Network error"}}}}edgeRequest(e,s={}){const i={...s.headers||{},apikey:this.anonKey};return this.request(this.edgeFunctionsUrl,e,{...s,headers:i})}expressRequest(e,s={}){const i=ff(),l={...s.headers||{},"X-Supabase-Url":i.edgeFunctionsUrl.replace("/functions/v1",""),"X-Supabase-Anon-Key":i.anonKey};return this.request(this.expressApiUrl,e,{...s,headers:l})}get(e,s={}){return this.expressRequest(e,{method:"GET",...s,auth:!0})}post(e,s,i={}){return this.expressRequest(e,{method:"POST",body:s?JSON.stringify(s):void 0,...i,auth:!0})}getChatSessions(e){return this.expressRequest("/api/chat/sessions",{method:"GET",auth:!!e,token:e})}getDashboardStats(e){return this.expressRequest("/api/stats",{method:"GET",auth:!!e,token:e})}createChatSession(e){return this.expressRequest("/api/chat/sessions",{method:"POST",auth:!!e,token:e})}getChatMessages(e,s){return this.expressRequest(`/api/chat/sessions/${e}/messages`,{method:"GET",auth:!!s,token:s})}sendChatMessage(e,s){return this.expressRequest("/api/chat/message",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}getHealth(){return this.expressRequest("/api/health",{method:"GET"})}testSupabase(e,s){return this.expressRequest("/api/setup/test-supabase",{method:"POST",body:JSON.stringify({url:e,anonKey:s})})}dispatchProcessingJob(e,s){return this.expressRequest("/api/processing/dispatch",{method:"POST",auth:!!s,token:s,body:JSON.stringify({source_type:"manual",payload:e})})}getSettings(e){return this.expressRequest("/api/settings",{method:"GET",auth:!!e,token:e})}updateSettings(e,s){return this.expressRequest("/api/settings",{method:"PATCH",auth:!!s,token:s,body:JSON.stringify(e)})}getAccounts(e){return this.expressRequest("/api/accounts",{method:"GET",auth:!!e,token:e})}disconnectAccount(e,s){return this.expressRequest("/api/accounts/disconnect",{method:"POST",auth:!!s,token:s,body:JSON.stringify({accountId:e})})}getRules(e){return this.expressRequest("/api/rules",{method:"GET",auth:!!e,token:e})}createRule(e,s){return this.expressRequest("/api/rules",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}updateRule(e,s,i){return this.expressRequest(`/api/rules/${e}`,{method:"PATCH",auth:!!i,token:i,body:JSON.stringify(s)})}deleteRule(e,s){return this.expressRequest(`/api/rules/${e}`,{method:"DELETE",auth:!!s,token:s})}toggleRule(e,s){return this.expressRequest(`/api/rules/${e}/toggle`,{method:"POST",auth:!!s,token:s})}getStats(e){return this.expressRequest("/api/stats",{method:"GET",auth:!!e,token:e})}getProfile(e){return this.edgeRequest("/api-v1-profile",{method:"GET",auth:!!e,token:e})}updateProfile(e,s){return this.edgeRequest("/api-v1-profile",{method:"PATCH",auth:!!s,token:s,body:JSON.stringify(e)})}getChatProviders(e){return this.expressRequest("/api/sdk/providers/chat",{method:"GET",auth:!!e,token:e})}getEmbedProviders(e){return this.expressRequest("/api/sdk/providers/embed",{method:"GET",auth:!!e,token:e})}testLlm(e,s){return this.expressRequest("/api/sdk/test-llm",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}getGmailAuthUrl(e,s,i){return this.expressRequest("/api/accounts/gmail/auth-url",{method:"POST",auth:!!i,token:i,body:JSON.stringify({clientId:e,clientSecret:s})})}connectGmail(e,s,i,l){return this.expressRequest("/api/accounts/gmail/connect",{method:"POST",auth:!!l,token:l,body:JSON.stringify({authCode:e,clientId:s,clientSecret:i})})}getGoogleDriveAuthUrl(e,s){return this.expressRequest("/api/accounts/google-drive/auth-url",{method:"POST",auth:!!s,token:s,body:JSON.stringify({clientId:e})})}connectGoogleDrive(e,s,i,l){return this.expressRequest("/api/accounts/google-drive/connect",{method:"POST",auth:!!l,token:l,body:JSON.stringify({authCode:e,clientId:s,clientSecret:i})})}startMicrosoftDeviceFlow(e,s,i){return this.expressRequest("/api/accounts/microsoft/device-flow",{method:"POST",auth:!!i,token:i,body:JSON.stringify({clientId:e,tenantId:s})})}pollMicrosoftDeviceCode(e,s,i,l){return this.expressRequest("/api/accounts/microsoft/poll",{method:"POST",auth:!!l,token:l,body:JSON.stringify({deviceCode:e,clientId:s,tenantId:i})})}connectImap(e,s){return this.expressRequest("/api/accounts/imap/connect",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}setup(e){return this.edgeRequest("/setup",{method:"POST",body:JSON.stringify(e)})}getPolicies(e){return this.expressRequest("/api/policies",{auth:!!e,token:e})}savePolicy(e,s){return this.expressRequest("/api/policies",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}deletePolicy(e,s){return this.expressRequest(`/api/policies/${e}`,{method:"DELETE",auth:!!s,token:s})}patchPolicy(e,s,i){return this.expressRequest(`/api/policies/${e}`,{method:"PATCH",auth:!!i,token:i,body:JSON.stringify(s)})}reloadPolicies(e){return this.expressRequest("/api/policies/reload",{method:"POST",auth:!!e,token:e})}synthesizePolicy(e,s){return this.expressRequest("/api/policies/synthesize",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}getSDKChatProviders(){return this.expressRequest("/api/sdk/providers/chat")}getIngestions(e={},s){const i=new URLSearchParams;e.page&&i.set("page",String(e.page)),e.pageSize&&i.set("pageSize",String(e.pageSize)),e.q&&i.set("q",e.q);const l=i.toString()?`?${i}`:"";return this.expressRequest(`/api/ingestions${l}`,{auth:!!s,token:s})}uploadDocument(e,s){const i=new FormData;i.append("file",e);const l=ff(),u={"X-Supabase-Url":l.edgeFunctionsUrl.replace("/functions/v1",""),"X-Supabase-Anon-Key":l.anonKey};return s&&(u.Authorization=`Bearer ${s}`),fetch(`${l.expressApiUrl}/api/ingestions/upload`,{method:"POST",headers:u,body:i}).then(d=>d.json())}rerunIngestion(e,s){return this.expressRequest(`/api/ingestions/${e}/rerun`,{method:"POST",auth:!!s,token:s})}matchIngestionToPolicy(e,s,i){const l=s.learn!==!1,u=s.rerun!==!1;return this.expressRequest(`/api/ingestions/${e}/match`,{method:"POST",auth:!!i,token:i,body:JSON.stringify({policy_id:s.policyId,learn:l,rerun:u,allow_side_effects:s.allowSideEffects===!0})})}suggestPolicyRefinement(e,s,i){return this.expressRequest(`/api/ingestions/${e}/refine-policy`,{method:"POST",auth:!!i,token:i,body:JSON.stringify({policy_id:s.policyId,provider:s.provider,model:s.model})})}deleteIngestion(e,s){return this.expressRequest(`/api/ingestions/${e}`,{method:"DELETE",auth:!!s,token:s})}updateIngestionTags(e,s,i){return this.expressRequest(`/api/ingestions/${e}/tags`,{method:"PATCH",auth:!!i,token:i,body:JSON.stringify({tags:s})})}summarizeIngestion(e,s){return this.expressRequest(`/api/ingestions/${e}/summarize`,{method:"POST",auth:!!s,token:s})}getBaselineConfig(e){return this.expressRequest("/api/baseline-config",{auth:!!e,token:e})}getBaselineConfigHistory(e){return this.expressRequest("/api/baseline-config/history",{auth:!!e,token:e})}saveBaselineConfig(e,s){return this.expressRequest("/api/baseline-config",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}activateBaselineConfig(e,s){return this.expressRequest(`/api/baseline-config/${e}/activate`,{method:"POST",auth:!!s,token:s})}suggestBaselineConfig(e,s){return this.expressRequest("/api/baseline-config/suggest",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}}const Te=new _A;let ns=[],sm=new Set;function am(){sm.forEach(t=>t())}const ce={success:(t,e)=>Pc("success",t,e),error:(t,e)=>Pc("error",t,e),info:(t,e)=>Pc("info",t,e),warning:(t,e)=>Pc("warning",t,e)};function Pc(t,e,s=5e3){const i=ns.findIndex(u=>u.message===e&&u.type===t);if(i!==-1){const u=ns[i];ns=[...ns],ns[i]={...u,count:(u.count||1)+1,lastUpdated:Date.now()},am();return}const l=Math.random().toString(36).substr(2,9);ns=[...ns,{id:l,type:t,message:e,duration:s,count:1,lastUpdated:Date.now()}],am(),s>0&&setTimeout(()=>Kw(l),s)}function Kw(t){ns=ns.filter(e=>e.id!==t),am()}function NA(){const[,t]=v.useState(0);return v.useEffect(()=>{const e=()=>t(s=>s+1);return sm.add(e),()=>{sm.delete(e)}},[]),ns}const TA={success:Fk,error:Sn,info:Im,warning:Gw},EA={success:"bg-emerald-500/10 border-emerald-500/20 text-emerald-600 dark:text-emerald-400",error:"bg-destructive/10 border-destructive/20 text-destructive",info:"bg-blue-500/10 border-blue-500/20 text-blue-600 dark:text-blue-400",warning:"bg-yellow-500/10 border-yellow-500/20 text-yellow-600 dark:text-yellow-400"};function kA({toast:t}){const e=TA[t.type];return o.jsxs("div",{className:ge("flex items-start gap-3 p-4 rounded-lg border shadow-lg backdrop-blur-sm","animate-in slide-in-from-left-full duration-300",EA[t.type]),children:[o.jsxs("div",{className:"relative",children:[o.jsx(e,{className:"w-5 h-5 flex-shrink-0 mt-0.5"}),t.count&&t.count>1&&o.jsx("span",{className:"absolute -top-2 -right-2 bg-primary text-primary-foreground text-[10px] font-bold px-1.5 rounded-full border border-background scale-90 animate-in zoom-in duration-200",children:t.count})]}),o.jsx("p",{className:"text-sm flex-1",children:t.message}),o.jsx("button",{onClick:()=>Kw(t.id),className:"p-1 hover:bg-black/10 rounded transition-colors",children:o.jsx(zn,{className:"w-4 h-4"})})]})}function CA(){const t=NA();return t.length===0?null:o.jsx("div",{className:"fixed bottom-4 left-4 z-[100] flex flex-col-reverse gap-2 max-w-sm w-full",children:t.map(e=>o.jsx(kA,{toast:e},e.id))})}function AA({configSnapshot:t,configSource:e,setActivePage:s}){const[i,l]=v.useState(null),[u,d]=v.useState(!0),[h,m]=v.useState(!1),[g,y]=v.useState(!1),x=v.useRef(null),w=v.useCallback(async()=>{d(!0);try{const j=un();if(!j)return;const{data:_}=await j.auth.getSession(),N=_.session?.access_token??null;if(!N)return;const k=await Te.getDashboardStats(N);k.data?.success&&l(k.data.stats)}catch(j){console.error("Failed to fetch dashboard stats",j)}finally{d(!1)}},[]);v.useEffect(()=>{w()},[w]);const S=async j=>{const _=Array.from(j);if(_.length){s("funnel"),y(!0);try{const N=un();if(!N)return;const{data:k}=await N.auth.getSession(),C=k.session?.access_token??null;if(!C)return;for(const A of _){ce.info(`Ingesting ${A.name}…`);const D=await Te.uploadDocument?.(A,C);if(D?.success)if(D.ingestion?.status==="duplicate"){const z=D.ingestion.extracted?.original_filename??"a previous upload";ce.warning(`${A.name} is a duplicate of "${z}" — skipped.`)}else ce.success(`${A.name} → ${D.ingestion?.status}`);else ce.error(`Failed to ingest ${A.name}`)}await w()}finally{y(!1)}}},E=j=>{j.preventDefault(),m(!1),S(j.dataTransfer.files)};return o.jsxs("div",{className:"w-full mx-auto px-8 py-10 space-y-12 animate-in fade-in duration-700",children:[o.jsxs("div",{className:"text-center space-y-3",children:[o.jsxs("h2",{className:"text-4xl font-black tracking-tight flex items-center justify-center gap-3",children:[o.jsx(ou,{className:"w-10 h-10 animate-pulse"}),"Command Center"]}),o.jsx("p",{className:"text-muted-foreground text-lg max-w-2xl mx-auto",children:"Central intelligence hub for document ingestion, routing, and synthetic knowledge."})]}),o.jsxs("div",{className:"w-full space-y-10",children:[o.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[o.jsx(zc,{title:"Documents Ingested",value:i?.totalDocuments,icon:o.jsx(Vm,{className:"w-5 h-5 text-blue-500"}),isLoading:u,colorClass:"bg-blue-500/10"}),o.jsx(zc,{title:"Active Policies",value:i?.activePolicies,icon:o.jsx(p0,{className:"w-5 h-5 text-emerald-500"}),isLoading:u,colorClass:"bg-emerald-500/10"}),o.jsx(zc,{title:"Knowledge Chunks",value:i?.ragChunks,icon:o.jsx(Eu,{className:"w-5 h-5 text-purple-500"}),isLoading:u,colorClass:"bg-purple-500/10"}),o.jsx(zc,{title:"Automation Runs",value:i?.automationRuns,icon:o.jsx(ur,{className:"w-5 h-5 text-amber-500"}),isLoading:u,colorClass:"bg-amber-500/10"})]}),o.jsxs("div",{className:"grid lg:grid-cols-3 gap-6",children:[o.jsx("div",{className:"lg:col-span-2",children:o.jsxs("div",{onDragOver:j=>{j.preventDefault(),m(!0)},onDragLeave:()=>m(!1),onDrop:E,onClick:()=>x.current?.click(),className:ge("h-full rounded-2xl border-2 border-dashed transition-all cursor-pointer flex flex-col items-center justify-center gap-4 py-16",h?"border-primary bg-primary/5 scale-[1.01]":"border-muted-foreground/20 hover:border-primary/50 hover:bg-muted/30"),children:[o.jsx("input",{ref:x,type:"file",multiple:!0,hidden:!0,onChange:j=>j.target.files&&S(j.target.files)}),g?o.jsx(rt,{className:"w-12 h-12 animate-spin text-primary"}):o.jsx(tm,{className:ge("w-12 h-12 transition-colors",h?"text-primary":"text-muted-foreground/50")}),o.jsxs("div",{className:"text-center space-y-1",children:[o.jsx("p",{className:"text-lg font-medium text-foreground",children:h?"Drop to ingest...":"Drag & drop files to ingest"}),o.jsx("p",{className:"text-sm text-muted-foreground/60",children:"Supports .pdf, .docx, .md, .txt (up to 20MB)"})]})]})}),o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs(ht,{className:"flex-1 cursor-pointer hover:border-primary/50 hover:bg-muted/30 transition-all flex flex-col items-center justify-center p-6 text-center shadow-sm",onClick:()=>s("chat"),children:[o.jsx("div",{className:"w-12 h-12 rounded-xl bg-indigo-500/10 flex items-center justify-center mb-4",children:o.jsx(cu,{className:"w-6 h-6 text-indigo-500"})}),o.jsx("h3",{className:"font-bold mb-1",children:"Chat with Data"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Ask questions against your vectorized knowledge base."})]}),o.jsxs(ht,{className:"flex-1 cursor-pointer hover:border-primary/50 hover:bg-muted/30 transition-all flex flex-col items-center justify-center p-6 text-center shadow-sm",onClick:()=>s("policies"),children:[o.jsx("div",{className:"w-12 h-12 rounded-xl bg-orange-500/10 flex items-center justify-center mb-4",children:o.jsx(p0,{className:"w-6 h-6 text-orange-500"})}),o.jsx("h3",{className:"font-bold mb-1",children:"Create Policy"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Define a new routing and automation contract."})]})]})]})]})]})}function zc({title:t,value:e,icon:s,isLoading:i,colorClass:l}){return o.jsx(ht,{className:"shadow-sm",children:o.jsxs(xt,{className:"p-6",children:[o.jsx("div",{className:"flex items-center justify-between mb-4",children:o.jsx("div",{className:ge("w-10 h-10 rounded-xl flex items-center justify-center",l),children:s})}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"text-sm text-muted-foreground font-medium",children:t}),i?o.jsx("div",{className:"h-8 w-16 bg-muted animate-pulse rounded-md"}):o.jsx("p",{className:"text-3xl font-black",children:e!==void 0?e.toLocaleString():"0"})]})]})})}function y0(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Au(...t){return e=>{let s=!1;const i=t.map(l=>{const u=y0(l,e);return!s&&typeof u=="function"&&(s=!0),u});if(s)return()=>{for(let l=0;l<i.length;l++){const u=i[l];typeof u=="function"?u():y0(t[l],null)}}}}function ni(...t){return v.useCallback(Au(...t),t)}var RA=Symbol.for("react.lazy"),fu=Mm[" use ".trim().toString()];function OA(t){return typeof t=="object"&&t!==null&&"then"in t}function Yw(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===RA&&"_payload"in t&&OA(t._payload)}function Xw(t){const e=DA(t),s=v.forwardRef((i,l)=>{let{children:u,...d}=i;Yw(u)&&typeof fu=="function"&&(u=fu(u._payload));const h=v.Children.toArray(u),m=h.find(zA);if(m){const g=m.props.children,y=h.map(x=>x===m?v.Children.count(g)>1?v.Children.only(null):v.isValidElement(g)?g.props.children:null:x);return o.jsx(e,{...d,ref:l,children:v.isValidElement(g)?v.cloneElement(g,void 0,y):null})}return o.jsx(e,{...d,ref:l,children:u})});return s.displayName=`${t}.Slot`,s}var MA=Xw("Slot");function DA(t){const e=v.forwardRef((s,i)=>{let{children:l,...u}=s;if(Yw(l)&&typeof fu=="function"&&(l=fu(l._payload)),v.isValidElement(l)){const d=UA(l),h=LA(u,l.props);return l.type!==v.Fragment&&(h.ref=i?Au(i,d):d),v.cloneElement(l,h)}return v.Children.count(l)>1?v.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var PA=Symbol("radix.slottable");function zA(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===PA}function LA(t,e){const s={...e};for(const i in e){const l=t[i],u=e[i];/^on[A-Z]/.test(i)?l&&u?s[i]=(...h)=>{const m=u(...h);return l(...h),m}:l&&(s[i]=l):i==="style"?s[i]={...l,...u}:i==="className"&&(s[i]=[l,u].filter(Boolean).join(" "))}return{...t,...s}}function UA(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning;return s?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning,s?t.props.ref:t.props.ref||t.ref)}const v0=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,x0=xw,qm=(t,e)=>s=>{var i;if(e?.variants==null)return x0(t,s?.class,s?.className);const{variants:l,defaultVariants:u}=e,d=Object.keys(l).map(g=>{const y=s?.[g],x=u?.[g];if(y===null)return null;const w=v0(y)||v0(x);return l[g][w]}),h=s&&Object.entries(s).reduce((g,y)=>{let[x,w]=y;return w===void 0||(g[x]=w),g},{}),m=e==null||(i=e.compoundVariants)===null||i===void 0?void 0:i.reduce((g,y)=>{let{class:x,className:w,...S}=y;return Object.entries(S).every(E=>{let[j,_]=E;return Array.isArray(_)?_.includes({...u,...h}[j]):{...u,...h}[j]===_})?[...g,x,w]:g},[]);return x0(t,d,m,s?.class,s?.className)},BA=qm("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 ring-ring/10 dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 focus-visible:ring-4 focus-visible:outline-1 aria-invalid:focus-visible:ring-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-sm hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-xs hover:bg-destructive/90",outline:"border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-xs 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"}}),ae=v.forwardRef(({className:t,variant:e,size:s,asChild:i=!1,...l},u)=>{const d=i?MA:"button";return o.jsx(d,{className:ge(BA({variant:e,size:s,className:t})),ref:u,...l})});ae.displayName="Button";const je=v.forwardRef(({className:t,type:e,...s},i)=>o.jsx("input",{type:e,className:ge("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",t),ref:i,...s}));je.displayName="Input";var Ww=tw();const VA=Zb(Ww);var IA=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],$A=IA.reduce((t,e)=>{const s=Xw(`Primitive.${e}`),i=v.forwardRef((l,u)=>{const{asChild:d,...h}=l,m=d?s:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(m,{...h,ref:u})});return i.displayName=`Primitive.${e}`,{...t,[e]:i}},{}),qA="Label",Jw=v.forwardRef((t,e)=>o.jsx($A.label,{...t,ref:e,onMouseDown:s=>{s.target.closest("button, input, select, textarea")||(t.onMouseDown?.(s),!s.defaultPrevented&&s.detail>1&&s.preventDefault())}}));Jw.displayName=qA;var HA=Jw;function Je({className:t,...e}){return o.jsx(HA,{"data-slot":"label",className:ge("flex items-center gap-2 text-sm leading-none font-medium select-none text-muted-foreground group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...e})}const GA=qm("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Pt({className:t,variant:e,...s}){return o.jsx("div",{className:ge(GA({variant:e}),t),...s})}const FA=qm("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),jn=v.forwardRef(({className:t,variant:e,...s},i)=>o.jsx("div",{ref:i,role:"alert",className:ge(FA({variant:e}),t),...s}));jn.displayName="Alert";const Hm=v.forwardRef(({className:t,...e},s)=>o.jsx("h5",{ref:s,className:ge("mb-1 font-medium leading-none tracking-tight",t),...e}));Hm.displayName="AlertTitle";const _n=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("text-sm [&_p]:leading-relaxed",t),...e}));_n.displayName="AlertDescription";function KA({supabase:t,initStatus:e,sessionStatus:s,sessionEmail:i,onRefresh:l}){const[u,d]=v.useState(""),[h,m]=v.useState(""),[g,y]=v.useState(""),[x,w]=v.useState(""),[S,E]=v.useState(!1),[j,_]=v.useState(null),N=e==="empty";async function k(){E(!0),_(null);const{error:z}=await t.auth.signInWithPassword({email:u,password:h});z?_(z.message):l(),E(!1)}async function C(){E(!0),_(null);try{const z=await Te.setup({email:u,password:h,first_name:g,last_name:x});if(z.error)throw new Error(typeof z.error=="string"?z.error:z.error.message);const{error:V}=await t.auth.signInWithPassword({email:u,password:h});if(V)throw V;l()}catch(z){_(z.message||"Failed to initialize foundation.")}finally{E(!1)}}async function A(){E(!0),_(null);const{error:z}=await t.auth.signUp({email:u,password:h,options:{data:{first_name:g,last_name:x}}});z?_(z.message):l(),E(!1)}async function D(){E(!0),await t.auth.signOut(),l(),E(!1)}return s==="authenticated"?o.jsxs("div",{className:"space-y-4 animate-in fade-in duration-500",children:[o.jsxs("div",{className:"flex items-center gap-4 p-4 rounded-xl bg-primary/5 border border-primary/10",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-primary flex items-center justify-center text-primary-foreground",children:o.jsx(ku,{className:"w-5 h-5"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-xs font-bold uppercase tracking-widest text-muted-foreground leading-none mb-1",children:"Authenticated as"}),o.jsx("p",{className:"text-sm font-medium truncate",children:i})]})]}),e==="missing_view"&&o.jsxs(jn,{variant:"destructive",className:"bg-destructive/5 text-destructive border-destructive/20",children:[o.jsx(uu,{className:"w-4 h-4"}),o.jsx(_n,{className:"text-xs",children:"Database views missing. Foundation may be corrupted."})]}),o.jsxs(ae,{variant:"outline",className:"w-full h-11 hover:bg-destructive hover:text-destructive-reveal group transition-all duration-300",onClick:D,disabled:S,children:[S?o.jsx(rt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(Iw,{className:"w-4 h-4 mr-2 group-hover:rotate-180 transition-transform duration-500"}),"Logout Protocol"]})]}):o.jsxs("div",{className:"space-y-4 animate-in fade-in duration-500",children:[o.jsxs("div",{className:"grid gap-4",children:[N&&o.jsxs("div",{className:"grid grid-cols-2 gap-4 animate-in slide-in-from-top-2 duration-300",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"auth-firstname",children:"First Name"}),o.jsx(je,{id:"auth-firstname",placeholder:"Agent",value:g,onChange:z=>y(z.target.value),className:"h-10"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"auth-lastname",children:"Last Name"}),o.jsx(je,{id:"auth-lastname",placeholder:"Zero",value:x,onChange:z=>w(z.target.value),className:"h-10"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"auth-email",children:"Email Address"}),o.jsxs("div",{className:"relative",children:[o.jsx(Vo,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),o.jsx(je,{id:"auth-email",type:"email",placeholder:"admin@example.com",value:u,onChange:z=>d(z.target.value),className:"pl-9 h-10"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"auth-password",children:"Security Key"}),o.jsxs("div",{className:"relative",children:[o.jsx(Zo,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),o.jsx(je,{id:"auth-password",type:"password",placeholder:"••••••••",value:h,onChange:z=>m(z.target.value),className:"pl-9 h-10",autoComplete:N?"new-password":"current-password"})]})]})]}),j&&o.jsx(jn,{variant:"destructive",className:"py-2 px-3",children:o.jsx(_n,{className:"text-[11px] leading-relaxed italic",children:j})}),o.jsx("div",{className:"pt-2",children:N?o.jsxs(ae,{className:"w-full h-11 shadow-lg shadow-primary/20",onClick:C,disabled:S||!u||!h||!g,children:[S?o.jsx(rt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(ya,{className:"w-4 h-4 mr-2"}),"Initialize Primary Admin"]}):o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs(ae,{className:"h-10",onClick:k,disabled:S||!u||!h,children:[S?o.jsx(rt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(Vw,{className:"w-4 h-4 mr-2"}),"Login"]}),o.jsxs(ae,{variant:"secondary",className:"h-10",onClick:A,disabled:S||!u||!h,children:[o.jsx(pA,{className:"w-4 h-4 mr-2"}),"Enroll"]})]})}),o.jsx("p",{className:"text-[10px] text-center text-muted-foreground uppercase tracking-widest font-bold opacity-50 pt-2",children:N?"Foundation Assembly Phase":"Foundation Access Required"})]})}const ha="0.1.8",YA="20260228000001";async function XA(t,e){const s=Promise.resolve(t);let i=null;const l=new Promise((u,d)=>{i=setTimeout(()=>{d(new Error(`Operation timed out after ${e}ms`))},e)});try{return await Promise.race([s,l])}finally{i&&clearTimeout(i)}}async function WA(t){try{const{data:e,error:s}=await XA(t.rpc("get_latest_migration_timestamp"),12e3);if(s)return s.code==="42883"?{latestMigrationTimestamp:"0"}:{latestMigrationTimestamp:null};const i=e??null;return i&&i>="29990000000000"?{latestMigrationTimestamp:null}:{latestMigrationTimestamp:i}}catch{return{latestMigrationTimestamp:null}}}async function Qw(t){const e=await WA(t);return!e.latestMigrationTimestamp||e.latestMigrationTimestamp.trim()===""?{needsMigration:!0,appVersion:ha,latestMigrationTimestamp:e.latestMigrationTimestamp,message:"Database migration state unknown."}:YA>e.latestMigrationTimestamp?{needsMigration:!0,appVersion:ha,latestMigrationTimestamp:e.latestMigrationTimestamp,message:`Database is behind (${e.latestMigrationTimestamp}).`}:{needsMigration:!1,appVersion:ha,latestMigrationTimestamp:e.latestMigrationTimestamp,message:"Database schema is up-to-date."}}function JA({supabase:t,sessionEmail:e,sessionStatus:s,initStatus:i,configSnapshot:l,configSource:u,onRefresh:d,onLaunchSetup:h,onResetSetup:m}){const[g,y]=v.useState("profile"),[x,w]=v.useState(null),[S,E]=v.useState(!1);async function j(){if(!t)return;E(!0);const{data:{user:k}}=await t.auth.getUser();if(k){const{data:C}=await t.from("profiles").select("*").eq("id",k.id).single();C&&w(C)}E(!1)}v.useEffect(()=>{s==="authenticated"&&t&&j()},[s,t]);const _=[{id:"profile",label:"Profile",icon:ku},{id:"security",label:"Security",icon:ya},{id:"supabase",label:"Supabase",icon:Eu}];async function N(){t&&(await t.auth.signOut(),d())}return o.jsxs("div",{className:"max-w-6xl mx-auto space-y-8 animate-in fade-in duration-700",children:[o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsx("h1",{className:"text-4xl font-black tracking-tight",children:"Account Settings"}),o.jsx("p",{className:"text-muted-foreground text-lg",children:"Manage your profile and foundational preferences."})]}),o.jsxs("div",{className:"flex flex-col md:flex-row gap-12 items-start",children:[o.jsxs("aside",{className:"w-full md:w-72 flex flex-col gap-8 shrink-0",children:[o.jsx("nav",{className:"space-y-1",children:_.map(k=>{const C=k.icon,A=g===k.id;return o.jsxs("button",{onClick:()=>y(k.id),className:ge("w-full flex items-center gap-3 px-4 py-3 text-sm font-bold rounded-xl transition-all duration-300",A?"bg-foreground text-background shadow-lg shadow-foreground/10":"text-muted-foreground hover:bg-muted/60 hover:text-foreground"),children:[o.jsx(C,{className:ge("w-5 h-5",A?"text-background":"text-muted-foreground/60")}),k.label]},k.id)})}),o.jsxs("div",{className:"pt-8 border-t space-y-6",children:[o.jsxs("button",{onClick:N,className:"group w-full flex items-center gap-3 px-4 py-2 text-sm font-bold rounded-xl transition-all duration-300 text-destructive hover:bg-destructive/10",children:[o.jsx(Iw,{className:"w-5 h-5 transition-transform group-hover:translate-x-1"}),"Logout"]}),o.jsxs("div",{className:"px-4",children:[o.jsx("p",{className:"text-[10px] font-black text-muted-foreground/40 uppercase tracking-widest mb-1",children:"Version"}),o.jsxs("p",{className:"text-xs font-mono text-muted-foreground/60",children:["v",ha]})]})]})]}),o.jsxs("div",{className:"flex-1 w-full animate-in slide-in-from-right-4 duration-500",children:[g==="profile"&&o.jsx(QA,{sessionEmail:e,sessionStatus:s,supabase:t,initStatus:i,profile:x,onProfileUpdate:j,onRefresh:d,isLoading:S}),g==="security"&&o.jsx(ZA,{supabase:t}),g==="supabase"&&o.jsx(eR,{configSnapshot:l,configSource:u,onLaunchSetup:h,onResetSetup:m})]})]})]})}function QA({sessionEmail:t,sessionStatus:e,supabase:s,initStatus:i,profile:l,onProfileUpdate:u,onRefresh:d,isLoading:h}){const[m,g]=v.useState(""),[y,x]=v.useState(""),[w,S]=v.useState(!0),[E,j]=v.useState(!1),[_,N]=v.useState(!1);v.useEffect(()=>{l&&(g(l.first_name||""),x(l.last_name||""))},[l]);const k=async()=>{if(!s||!l)return;j(!0);const{error:A}=await s.from("profiles").update({first_name:m,last_name:y}).eq("id",l.id);A||u(),j(!1)},C=async A=>{const D=A.target.files?.[0];if(!(!D||!s||!l)){N(!0);try{const z=D.name.split(".").pop(),V=`${l.id}/${Math.random()}.${z}`,{error:R}=await s.storage.from("avatars").upload(V,D);if(R)throw R;const{data:{publicUrl:P}}=s.storage.from("avatars").getPublicUrl(V);await s.from("profiles").update({avatar_url:P}).eq("id",l.id),u()}catch(z){console.error("Upload error:",z)}finally{N(!1)}}};return o.jsxs(ht,{className:"border-border/40 shadow-xl shadow-black/5 bg-card/50 backdrop-blur-sm overflow-hidden",children:[o.jsxs(zt,{className:"p-8 border-b bg-muted/20",children:[o.jsx(Lt,{className:"text-2xl font-black",children:"Profile Information"}),o.jsx(wn,{className:"text-base",children:"Update your personal foundation details."})]}),o.jsx(xt,{className:"p-8 space-y-10",children:h?o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(rt,{className:"w-8 h-8 animate-spin text-primary"})}):e==="authenticated"?o.jsxs("div",{className:"space-y-10",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-8",children:[o.jsxs("div",{className:"relative group",children:[o.jsx("div",{className:"w-32 h-32 rounded-full bg-primary/10 border-4 border-background shadow-2xl overflow-hidden flex items-center justify-center",children:l?.avatar_url?o.jsx("img",{src:l.avatar_url,alt:"Avatar",className:"w-full h-full object-cover"}):t?o.jsx("span",{className:"text-4xl font-black text-primary",children:t.charAt(0).toUpperCase()}):o.jsx(ku,{className:"w-12 h-12 text-primary/40"})}),o.jsxs("label",{className:"absolute bottom-1 right-1 h-10 w-10 rounded-full bg-background border shadow-lg flex items-center justify-center hover:scale-110 transition-transform cursor-pointer",children:[_?o.jsx(rt,{className:"w-4 h-4 animate-spin text-muted-foreground"}):o.jsx(Uk,{className:"w-5 h-5 text-muted-foreground"}),o.jsx("input",{type:"file",className:"hidden",accept:"image/*",onChange:C,disabled:_})]})]}),o.jsxs("div",{className:"flex-1 w-full grid grid-cols-1 sm:grid-cols-2 gap-6",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"firstName",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"First Name"}),o.jsx(je,{id:"firstName",placeholder:"Trung",value:m,onChange:A=>g(A.target.value),className:"h-12 rounded-xl bg-background/50 border-border/40"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"lastName",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Last Name"}),o.jsx(je,{id:"lastName",placeholder:"Le",value:y,onChange:A=>x(A.target.value),className:"h-12 rounded-xl bg-background/50 border-border/40"})]}),o.jsxs("div",{className:"sm:col-span-2 space-y-2",children:[o.jsx(Je,{htmlFor:"email",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Email Address"}),o.jsx(je,{id:"email",value:t||"",disabled:!0,className:"h-12 rounded-xl bg-muted/40 border-border/40 opacity-70 cursor-not-allowed"}),o.jsx("p",{className:"text-[10px] text-muted-foreground/60 font-bold ml-1",children:"This is your login email and cannot be changed."})]})]})]}),o.jsxs("div",{className:"pt-8 border-t flex items-center justify-between",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("h4",{className:"text-base font-bold",children:"Sound & Haptic Feedback"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Play chimes and haptic pulses for system events."})]}),o.jsxs(ae,{variant:w?"default":"outline",className:ge("h-11 px-6 rounded-xl font-bold transition-all",w?"shadow-lg shadow-primary/20":""),onClick:()=>S(!w),children:[w?o.jsx(nm,{className:"w-4 h-4 mr-2"}):o.jsx(Fw,{className:"w-4 h-4 mr-2"}),w?"Enabled":"Disabled"]})]})]}):o.jsxs("div",{className:"py-8",children:[o.jsxs("div",{className:"flex items-center gap-3 border-b pb-4 mb-6",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center text-primary",children:o.jsx(ya,{className:"w-6 h-6"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-bold",children:"Authentication Gateway"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Access your foundational profile."})]})]}),s&&o.jsx(KA,{supabase:s,initStatus:i,sessionStatus:e,sessionEmail:t,onRefresh:d})]})}),e==="authenticated"&&!h&&o.jsx(Tu,{className:"bg-muted/20 p-8 flex justify-end",children:o.jsxs(ae,{className:"h-12 px-8 rounded-xl font-bold shadow-xl shadow-primary/20",onClick:k,disabled:E,children:[E?o.jsx(rt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(VC,{className:"w-4 h-4 mr-2"}),"Save Changes"]})})]})}function ZA({supabase:t}){const[e,s]=v.useState(""),[i,l]=v.useState(""),[u,d]=v.useState(!1),[h,m]=v.useState(null),g=async()=>{if(!t)return;if(e!==i){m({type:"error",msg:"Passwords do not match."});return}if(e.length<8){m({type:"error",msg:"Password must be at least 8 characters."});return}d(!0),m(null);const{error:y}=await t.auth.updateUser({password:e});y?m({type:"error",msg:y.message}):(m({type:"success",msg:"Password updated successfully."}),s(""),l("")),d(!1)};return o.jsxs(ht,{className:"border-border/40 shadow-xl shadow-black/5 bg-card/50 backdrop-blur-sm overflow-hidden",children:[o.jsxs(zt,{className:"p-8 border-b bg-muted/20",children:[o.jsx(Lt,{className:"text-2xl font-black",children:"Security Protocol"}),o.jsx(wn,{className:"text-base",children:"Manage your foundation credentials and access keys."})]}),o.jsxs(xt,{className:"p-8 space-y-8",children:[h&&o.jsxs(jn,{variant:h.type==="error"?"destructive":"default",className:ge("animate-in fade-in slide-in-from-top-2 duration-300",h.type==="success"?"bg-emerald-500/10 text-emerald-600 border-emerald-500/20":""),children:[h.type==="success"?o.jsx(os,{className:"h-4 w-4"}):o.jsx(uu,{className:"h-4 w-4"}),o.jsx(_n,{className:"text-sm font-bold",children:h.msg})]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-8",children:[o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"newPass",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"New Password"}),o.jsx(je,{id:"newPass",type:"password",placeholder:"••••••••",value:e,onChange:y=>s(y.target.value),className:"h-12 rounded-xl bg-background/50 border-border/40"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"confirmPass",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Confirm Password"}),o.jsx(je,{id:"confirmPass",type:"password",placeholder:"••••••••",value:i,onChange:y=>l(y.target.value),className:"h-12 rounded-xl bg-background/50 border-border/40"})]})]}),o.jsxs("div",{className:"bg-muted/30 p-6 rounded-2xl border border-border/40 space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/10 flex items-center justify-center text-primary",children:o.jsx(uu,{className:"w-5 h-5"})}),o.jsx("h5",{className:"font-bold",children:"Security Tip"})]}),o.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"Use a password at least 12 characters long with a mix of letters, numbers, and symbols to ensure your foundational data remains secure."})]})]})]}),o.jsx(Tu,{className:"bg-muted/20 p-8 flex justify-end",children:o.jsxs(ae,{className:"h-12 px-8 rounded-xl font-bold shadow-xl shadow-primary/20",onClick:g,disabled:u||!e||!i,children:[u?o.jsx(rt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(Zo,{className:"w-4 h-4 mr-2"}),"Update Password"]})})]})}function eR({configSnapshot:t,configSource:e,onLaunchSetup:s,onResetSetup:i}){return o.jsxs("div",{className:"space-y-8 animate-in fade-in duration-700",children:[o.jsxs("div",{className:"flex items-center gap-3 border-b pb-4",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center text-primary",children:o.jsx(Eu,{className:"w-6 h-6"})}),o.jsxs("div",{className:"flex-1",children:[o.jsx("h3",{className:"text-lg font-bold",children:"Supabase Configuration"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Primary storage and identity gateway."})]}),o.jsxs(Pt,{variant:"secondary",className:"text-[10px] font-black uppercase tracking-widest px-3 py-1",children:["Source: ",e]})]}),o.jsxs(ht,{className:"border-border/40 shadow-sm bg-card/50 backdrop-blur-sm",children:[o.jsx(xt,{className:"p-8 space-y-8",children:t?o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("span",{className:"text-[10px] font-black uppercase text-muted-foreground tracking-widest pl-1",children:"API Endpoint"}),o.jsx("div",{className:"bg-muted/30 p-4 rounded-2xl border border-border/40 backdrop-blur-sm shadow-inner",children:o.jsx("p",{className:"text-sm font-semibold truncate text-foreground/80",children:t.url})})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("span",{className:"text-[10px] font-black uppercase text-muted-foreground tracking-widest pl-1",children:"Project Identifier"}),o.jsx("div",{className:"bg-muted/30 p-4 rounded-2xl border border-border/40 font-mono shadow-inner",children:o.jsx("p",{className:"text-sm font-semibold text-foreground/80",children:t.url.split("//")[1]?.split(".")[0]||"Unknown"})})]}),o.jsxs("div",{className:"md:col-span-2 space-y-2",children:[o.jsx("span",{className:"text-[10px] font-black uppercase text-muted-foreground tracking-widest pl-1",children:"Service Role Access (Masked)"}),o.jsxs("div",{className:"bg-muted/30 p-4 rounded-2xl border border-border/40 flex items-center justify-between shadow-inner",children:[o.jsxs("p",{className:"text-sm font-mono text-muted-foreground",children:[t.anonKey.slice(0,6),"...",t.anonKey.slice(-6)]}),o.jsx(Pt,{variant:"outline",className:"text-[9px] font-bold",children:"Standard Key"})]})]})]}):o.jsxs(jn,{className:"bg-amber-500/5 border-amber-500/20 text-amber-600 dark:text-amber-400 p-6 rounded-2xl shadow-sm",children:[o.jsx(Sn,{className:"w-5 h-5"}),o.jsx(Hm,{className:"font-bold mb-1",children:"Infrastructure Standby"}),o.jsx(_n,{className:"text-sm opacity-90",children:"The foundation has not been initialized. You must run the setup wizard to continue."})]})}),o.jsxs(Tu,{className:"bg-muted/20 p-8 flex gap-4 border-t",children:[o.jsxs(ae,{variant:t?"outline":"default",className:"flex-1 h-12 rounded-xl font-bold shadow-sm",onClick:s,children:[t?o.jsx(WC,{className:"w-4 h-4 mr-2"}):o.jsx(Wa,{className:"w-4 h-4 mr-2"}),t?"Run Setup Wizard":"Launch Initializer"]}),t&&o.jsx(ae,{variant:"ghost",size:"icon",className:"h-12 w-12 rounded-xl text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",onClick:i,title:"Reset All Configuration",children:o.jsx(PC,{className:"w-5 h-5"})})]})]}),o.jsxs("div",{className:"space-y-6 pt-4",children:[o.jsxs("div",{className:"flex items-center gap-3 border-b pb-4",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-destructive/10 flex items-center justify-center text-destructive",children:o.jsx(Sn,{className:"w-6 h-6"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-bold text-destructive",children:"Advanced Maintenance"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Destructive actions and system-level overrides."})]})]}),o.jsx(ht,{className:"border-destructive/20 bg-destructive/5 overflow-hidden shadow-sm",children:o.jsxs(xt,{className:"p-8",children:[o.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"Fully resetting the foundation will purge all local storage cached parameters. This action is irreversible and will force a fresh bootstrap flow upon next launch."}),o.jsx(ae,{variant:"link",className:"px-0 text-destructive h-auto text-xs font-black uppercase tracking-widest mt-4 hover:no-underline hover:opacity-70 transition-opacity",onClick:i,children:"Wipe Local Foundation Buffer"})]})})]})]})}const tR={theme:"system",setTheme:()=>null},Zw=v.createContext(tR);function nR({children:t,defaultTheme:e="system",storageKey:s="vite-ui-theme"}){const[i,l]=v.useState(()=>localStorage.getItem(s)||e);v.useEffect(()=>{const d=window.document.documentElement;if(d.classList.remove("light","dark"),i==="system"){const h=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";d.classList.add(h);return}d.classList.add(i)},[i]);const u=v.useMemo(()=>({theme:i,setTheme:d=>{localStorage.setItem(s,d),l(d)}}),[i,s]);return o.jsx(Zw.Provider,{value:u,children:t})}const sR=()=>{const t=v.useContext(Zw);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t};function e1(){const{setTheme:t,theme:e}=sR();return o.jsxs(ae,{variant:"ghost",size:"icon",onClick:()=>t(e==="dark"?"light":"dark"),className:"text-muted-foreground hover:bg-muted/60 transition-all duration-300 h-9 w-9 rounded-full",title:`Switch to ${e==="dark"?"light":"dark"} mode`,children:[e==="dark"?o.jsx(nA,{className:"h-[1.2rem] w-[1.2rem]"}):o.jsx(CC,{className:"h-[1.2rem] w-[1.2rem]"}),o.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}function fa(t,e,{checkForDefaultPrevented:s=!0}={}){return function(l){if(t?.(l),s===!1||!l.defaultPrevented)return e?.(l)}}function aR(t,e){const s=v.createContext(e),i=u=>{const{children:d,...h}=u,m=v.useMemo(()=>h,Object.values(h));return o.jsx(s.Provider,{value:m,children:d})};i.displayName=t+"Provider";function l(u){const d=v.useContext(s);if(d)return d;if(e!==void 0)return e;throw new Error(`\`${u}\` must be used within \`${t}\``)}return[i,l]}function iR(t,e=[]){let s=[];function i(u,d){const h=v.createContext(d),m=s.length;s=[...s,d];const g=x=>{const{scope:w,children:S,...E}=x,j=w?.[t]?.[m]||h,_=v.useMemo(()=>E,Object.values(E));return o.jsx(j.Provider,{value:_,children:S})};g.displayName=u+"Provider";function y(x,w){const S=w?.[t]?.[m]||h,E=v.useContext(S);if(E)return E;if(d!==void 0)return d;throw new Error(`\`${x}\` must be used within \`${u}\``)}return[g,y]}const l=()=>{const u=s.map(d=>v.createContext(d));return function(h){const m=h?.[t]||u;return v.useMemo(()=>({[`__scope${t}`]:{...h,[t]:m}}),[h,m])}};return l.scopeName=t,[i,rR(l,...e)]}function rR(...t){const e=t[0];if(t.length===1)return e;const s=()=>{const i=t.map(l=>({useScope:l(),scopeName:l.scopeName}));return function(u){const d=i.reduce((h,{useScope:m,scopeName:g})=>{const x=m(u)[`__scope${g}`];return{...h,...x}},{});return v.useMemo(()=>({[`__scope${e.scopeName}`]:d}),[d])}};return s.scopeName=e.scopeName,s}var qo=globalThis?.document?v.useLayoutEffect:()=>{},oR=Mm[" useId ".trim().toString()]||(()=>{}),lR=0;function mf(t){const[e,s]=v.useState(oR());return qo(()=>{s(i=>i??String(lR++))},[t]),t||(e?`radix-${e}`:"")}var cR=Mm[" useInsertionEffect ".trim().toString()]||qo;function uR({prop:t,defaultProp:e,onChange:s=()=>{},caller:i}){const[l,u,d]=dR({defaultProp:e,onChange:s}),h=t!==void 0,m=h?t:l;{const y=v.useRef(t!==void 0);v.useEffect(()=>{const x=y.current;x!==h&&console.warn(`${i} is changing from ${x?"controlled":"uncontrolled"} to ${h?"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.`),y.current=h},[h,i])}const g=v.useCallback(y=>{if(h){const x=hR(y)?y(t):y;x!==t&&d.current?.(x)}else u(y)},[h,t,u,d]);return[m,g]}function dR({defaultProp:t,onChange:e}){const[s,i]=v.useState(t),l=v.useRef(s),u=v.useRef(e);return cR(()=>{u.current=e},[e]),v.useEffect(()=>{l.current!==s&&(u.current?.(s),l.current=s)},[s,l]),[s,i,u]}function hR(t){return typeof t=="function"}function fR(t){const e=mR(t),s=v.forwardRef((i,l)=>{const{children:u,...d}=i,h=v.Children.toArray(u),m=h.find(gR);if(m){const g=m.props.children,y=h.map(x=>x===m?v.Children.count(g)>1?v.Children.only(null):v.isValidElement(g)?g.props.children:null:x);return o.jsx(e,{...d,ref:l,children:v.isValidElement(g)?v.cloneElement(g,void 0,y):null})}return o.jsx(e,{...d,ref:l,children:u})});return s.displayName=`${t}.Slot`,s}function mR(t){const e=v.forwardRef((s,i)=>{const{children:l,...u}=s;if(v.isValidElement(l)){const d=vR(l),h=yR(u,l.props);return l.type!==v.Fragment&&(h.ref=i?Au(i,d):d),v.cloneElement(l,h)}return v.Children.count(l)>1?v.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var pR=Symbol("radix.slottable");function gR(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===pR}function yR(t,e){const s={...e};for(const i in e){const l=t[i],u=e[i];/^on[A-Z]/.test(i)?l&&u?s[i]=(...h)=>{const m=u(...h);return l(...h),m}:l&&(s[i]=l):i==="style"?s[i]={...l,...u}:i==="className"&&(s[i]=[l,u].filter(Boolean).join(" "))}return{...t,...s}}function vR(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning;return s?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning,s?t.props.ref:t.props.ref||t.ref)}var xR=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Os=xR.reduce((t,e)=>{const s=fR(`Primitive.${e}`),i=v.forwardRef((l,u)=>{const{asChild:d,...h}=l,m=d?s:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(m,{...h,ref:u})});return i.displayName=`Primitive.${e}`,{...t,[e]:i}},{});function bR(t,e){t&&Ww.flushSync(()=>t.dispatchEvent(e))}function Ho(t){const e=v.useRef(t);return v.useEffect(()=>{e.current=t}),v.useMemo(()=>(...s)=>e.current?.(...s),[])}function wR(t,e=globalThis?.document){const s=Ho(t);v.useEffect(()=>{const i=l=>{l.key==="Escape"&&s(l)};return e.addEventListener("keydown",i,{capture:!0}),()=>e.removeEventListener("keydown",i,{capture:!0})},[s,e])}var SR="DismissableLayer",im="dismissableLayer.update",jR="dismissableLayer.pointerDownOutside",_R="dismissableLayer.focusOutside",b0,t1=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),n1=v.forwardRef((t,e)=>{const{disableOutsidePointerEvents:s=!1,onEscapeKeyDown:i,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:d,onDismiss:h,...m}=t,g=v.useContext(t1),[y,x]=v.useState(null),w=y?.ownerDocument??globalThis?.document,[,S]=v.useState({}),E=ni(e,V=>x(V)),j=Array.from(g.layers),[_]=[...g.layersWithOutsidePointerEventsDisabled].slice(-1),N=j.indexOf(_),k=y?j.indexOf(y):-1,C=g.layersWithOutsidePointerEventsDisabled.size>0,A=k>=N,D=ER(V=>{const R=V.target,P=[...g.branches].some(Z=>Z.contains(R));!A||P||(l?.(V),d?.(V),V.defaultPrevented||h?.())},w),z=kR(V=>{const R=V.target;[...g.branches].some(Z=>Z.contains(R))||(u?.(V),d?.(V),V.defaultPrevented||h?.())},w);return wR(V=>{k===g.layers.size-1&&(i?.(V),!V.defaultPrevented&&h&&(V.preventDefault(),h()))},w),v.useEffect(()=>{if(y)return s&&(g.layersWithOutsidePointerEventsDisabled.size===0&&(b0=w.body.style.pointerEvents,w.body.style.pointerEvents="none"),g.layersWithOutsidePointerEventsDisabled.add(y)),g.layers.add(y),w0(),()=>{s&&g.layersWithOutsidePointerEventsDisabled.size===1&&(w.body.style.pointerEvents=b0)}},[y,w,s,g]),v.useEffect(()=>()=>{y&&(g.layers.delete(y),g.layersWithOutsidePointerEventsDisabled.delete(y),w0())},[y,g]),v.useEffect(()=>{const V=()=>S({});return document.addEventListener(im,V),()=>document.removeEventListener(im,V)},[]),o.jsx(Os.div,{...m,ref:E,style:{pointerEvents:C?A?"auto":"none":void 0,...t.style},onFocusCapture:fa(t.onFocusCapture,z.onFocusCapture),onBlurCapture:fa(t.onBlurCapture,z.onBlurCapture),onPointerDownCapture:fa(t.onPointerDownCapture,D.onPointerDownCapture)})});n1.displayName=SR;var NR="DismissableLayerBranch",TR=v.forwardRef((t,e)=>{const s=v.useContext(t1),i=v.useRef(null),l=ni(e,i);return v.useEffect(()=>{const u=i.current;if(u)return s.branches.add(u),()=>{s.branches.delete(u)}},[s.branches]),o.jsx(Os.div,{...t,ref:l})});TR.displayName=NR;function ER(t,e=globalThis?.document){const s=Ho(t),i=v.useRef(!1),l=v.useRef(()=>{});return v.useEffect(()=>{const u=h=>{if(h.target&&!i.current){let m=function(){s1(jR,s,g,{discrete:!0})};const g={originalEvent:h};h.pointerType==="touch"?(e.removeEventListener("click",l.current),l.current=m,e.addEventListener("click",l.current,{once:!0})):m()}else e.removeEventListener("click",l.current);i.current=!1},d=window.setTimeout(()=>{e.addEventListener("pointerdown",u)},0);return()=>{window.clearTimeout(d),e.removeEventListener("pointerdown",u),e.removeEventListener("click",l.current)}},[e,s]),{onPointerDownCapture:()=>i.current=!0}}function kR(t,e=globalThis?.document){const s=Ho(t),i=v.useRef(!1);return v.useEffect(()=>{const l=u=>{u.target&&!i.current&&s1(_R,s,{originalEvent:u},{discrete:!1})};return e.addEventListener("focusin",l),()=>e.removeEventListener("focusin",l)},[e,s]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}function w0(){const t=new CustomEvent(im);document.dispatchEvent(t)}function s1(t,e,s,{discrete:i}){const l=s.originalEvent.target,u=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:s});e&&l.addEventListener(t,e,{once:!0}),i?bR(l,u):l.dispatchEvent(u)}var pf="focusScope.autoFocusOnMount",gf="focusScope.autoFocusOnUnmount",S0={bubbles:!1,cancelable:!0},CR="FocusScope",a1=v.forwardRef((t,e)=>{const{loop:s=!1,trapped:i=!1,onMountAutoFocus:l,onUnmountAutoFocus:u,...d}=t,[h,m]=v.useState(null),g=Ho(l),y=Ho(u),x=v.useRef(null),w=ni(e,j=>m(j)),S=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(i){let j=function(C){if(S.paused||!h)return;const A=C.target;h.contains(A)?x.current=A:oa(x.current,{select:!0})},_=function(C){if(S.paused||!h)return;const A=C.relatedTarget;A!==null&&(h.contains(A)||oa(x.current,{select:!0}))},N=function(C){if(document.activeElement===document.body)for(const D of C)D.removedNodes.length>0&&oa(h)};document.addEventListener("focusin",j),document.addEventListener("focusout",_);const k=new MutationObserver(N);return h&&k.observe(h,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",_),k.disconnect()}}},[i,h,S.paused]),v.useEffect(()=>{if(h){_0.add(S);const j=document.activeElement;if(!h.contains(j)){const N=new CustomEvent(pf,S0);h.addEventListener(pf,g),h.dispatchEvent(N),N.defaultPrevented||(AR(PR(i1(h)),{select:!0}),document.activeElement===j&&oa(h))}return()=>{h.removeEventListener(pf,g),setTimeout(()=>{const N=new CustomEvent(gf,S0);h.addEventListener(gf,y),h.dispatchEvent(N),N.defaultPrevented||oa(j??document.body,{select:!0}),h.removeEventListener(gf,y),_0.remove(S)},0)}}},[h,g,y,S]);const E=v.useCallback(j=>{if(!s&&!i||S.paused)return;const _=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,N=document.activeElement;if(_&&N){const k=j.currentTarget,[C,A]=RR(k);C&&A?!j.shiftKey&&N===A?(j.preventDefault(),s&&oa(C,{select:!0})):j.shiftKey&&N===C&&(j.preventDefault(),s&&oa(A,{select:!0})):N===k&&j.preventDefault()}},[s,i,S.paused]);return o.jsx(Os.div,{tabIndex:-1,...d,ref:w,onKeyDown:E})});a1.displayName=CR;function AR(t,{select:e=!1}={}){const s=document.activeElement;for(const i of t)if(oa(i,{select:e}),document.activeElement!==s)return}function RR(t){const e=i1(t),s=j0(e,t),i=j0(e.reverse(),t);return[s,i]}function i1(t){const e=[],s=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>{const l=i.tagName==="INPUT"&&i.type==="hidden";return i.disabled||i.hidden||l?NodeFilter.FILTER_SKIP:i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)e.push(s.currentNode);return e}function j0(t,e){for(const s of t)if(!OR(s,{upTo:e}))return s}function OR(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function MR(t){return t instanceof HTMLInputElement&&"select"in t}function oa(t,{select:e=!1}={}){if(t&&t.focus){const s=document.activeElement;t.focus({preventScroll:!0}),t!==s&&MR(t)&&e&&t.select()}}var _0=DR();function DR(){let t=[];return{add(e){const s=t[0];e!==s&&s?.pause(),t=N0(t,e),t.unshift(e)},remove(e){t=N0(t,e),t[0]?.resume()}}}function N0(t,e){const s=[...t],i=s.indexOf(e);return i!==-1&&s.splice(i,1),s}function PR(t){return t.filter(e=>e.tagName!=="A")}var zR="Portal",r1=v.forwardRef((t,e)=>{const{container:s,...i}=t,[l,u]=v.useState(!1);qo(()=>u(!0),[]);const d=s||l&&globalThis?.document?.body;return d?VA.createPortal(o.jsx(Os.div,{...i,ref:e}),d):null});r1.displayName=zR;function LR(t,e){return v.useReducer((s,i)=>e[s][i]??s,t)}var Ru=t=>{const{present:e,children:s}=t,i=UR(e),l=typeof s=="function"?s({present:i.isPresent}):v.Children.only(s),u=ni(i.ref,BR(l));return typeof s=="function"||i.isPresent?v.cloneElement(l,{ref:u}):null};Ru.displayName="Presence";function UR(t){const[e,s]=v.useState(),i=v.useRef(null),l=v.useRef(t),u=v.useRef("none"),d=t?"mounted":"unmounted",[h,m]=LR(d,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const g=Lc(i.current);u.current=h==="mounted"?g:"none"},[h]),qo(()=>{const g=i.current,y=l.current;if(y!==t){const w=u.current,S=Lc(g);t?m("MOUNT"):S==="none"||g?.display==="none"?m("UNMOUNT"):m(y&&w!==S?"ANIMATION_OUT":"UNMOUNT"),l.current=t}},[t,m]),qo(()=>{if(e){let g;const y=e.ownerDocument.defaultView??window,x=S=>{const j=Lc(i.current).includes(CSS.escape(S.animationName));if(S.target===e&&j&&(m("ANIMATION_END"),!l.current)){const _=e.style.animationFillMode;e.style.animationFillMode="forwards",g=y.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=_)})}},w=S=>{S.target===e&&(u.current=Lc(i.current))};return e.addEventListener("animationstart",w),e.addEventListener("animationcancel",x),e.addEventListener("animationend",x),()=>{y.clearTimeout(g),e.removeEventListener("animationstart",w),e.removeEventListener("animationcancel",x),e.removeEventListener("animationend",x)}}else m("ANIMATION_END")},[e,m]),{isPresent:["mounted","unmountSuspended"].includes(h),ref:v.useCallback(g=>{i.current=g?getComputedStyle(g):null,s(g)},[])}}function Lc(t){return t?.animationName||"none"}function BR(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning;return s?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning,s?t.props.ref:t.props.ref||t.ref)}var yf=0;function VR(){v.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??T0()),document.body.insertAdjacentElement("beforeend",t[1]??T0()),yf++,()=>{yf===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),yf--}},[])}function T0(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var Yc="right-scroll-bar-position",Xc="width-before-scroll-bar",IR="with-scroll-bars-hidden",$R="--removed-body-scroll-bar-size";function vf(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function qR(t,e){var s=v.useState(function(){return{value:t,callback:e,facade:{get current(){return s.value},set current(i){var l=s.value;l!==i&&(s.value=i,s.callback(i,l))}}}})[0];return s.callback=e,s.facade}var HR=typeof window<"u"?v.useLayoutEffect:v.useEffect,E0=new WeakMap;function GR(t,e){var s=qR(null,function(i){return t.forEach(function(l){return vf(l,i)})});return HR(function(){var i=E0.get(s);if(i){var l=new Set(i),u=new Set(t),d=s.current;l.forEach(function(h){u.has(h)||vf(h,null)}),u.forEach(function(h){l.has(h)||vf(h,d)})}E0.set(s,t)},[t]),s}function FR(t){return t}function KR(t,e){e===void 0&&(e=FR);var s=[],i=!1,l={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return s.length?s[s.length-1]:t},useMedium:function(u){var d=e(u,i);return s.push(d),function(){s=s.filter(function(h){return h!==d})}},assignSyncMedium:function(u){for(i=!0;s.length;){var d=s;s=[],d.forEach(u)}s={push:function(h){return u(h)},filter:function(){return s}}},assignMedium:function(u){i=!0;var d=[];if(s.length){var h=s;s=[],h.forEach(u),d=s}var m=function(){var y=d;d=[],y.forEach(u)},g=function(){return Promise.resolve().then(m)};g(),s={push:function(y){d.push(y),g()},filter:function(y){return d=d.filter(y),s}}}};return l}function YR(t){t===void 0&&(t={});var e=KR(null);return e.options=ss({async:!0,ssr:!1},t),e}var o1=function(t){var e=t.sideCar,s=pr(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var i=e.read();if(!i)throw new Error("Sidecar medium not found");return v.createElement(i,ss({},s))};o1.isSideCarExport=!0;function XR(t,e){return t.useMedium(e),o1}var l1=YR(),xf=function(){},Ou=v.forwardRef(function(t,e){var s=v.useRef(null),i=v.useState({onScrollCapture:xf,onWheelCapture:xf,onTouchMoveCapture:xf}),l=i[0],u=i[1],d=t.forwardProps,h=t.children,m=t.className,g=t.removeScrollBar,y=t.enabled,x=t.shards,w=t.sideCar,S=t.noRelative,E=t.noIsolation,j=t.inert,_=t.allowPinchZoom,N=t.as,k=N===void 0?"div":N,C=t.gapMode,A=pr(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),D=w,z=GR([s,e]),V=ss(ss({},A),l);return v.createElement(v.Fragment,null,y&&v.createElement(D,{sideCar:l1,removeScrollBar:g,shards:x,noRelative:S,noIsolation:E,inert:j,setCallbacks:u,allowPinchZoom:!!_,lockRef:s,gapMode:C}),d?v.cloneElement(v.Children.only(h),ss(ss({},V),{ref:z})):v.createElement(k,ss({},V,{className:m,ref:z}),h))});Ou.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Ou.classNames={fullWidth:Xc,zeroRight:Yc};var WR=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function JR(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=WR();return e&&t.setAttribute("nonce",e),t}function QR(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function ZR(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var eO=function(){var t=0,e=null;return{add:function(s){t==0&&(e=JR())&&(QR(e,s),ZR(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},tO=function(){var t=eO();return function(e,s){v.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&s])}},c1=function(){var t=tO(),e=function(s){var i=s.styles,l=s.dynamic;return t(i,l),null};return e},nO={left:0,top:0,right:0,gap:0},bf=function(t){return parseInt(t||"",10)||0},sO=function(t){var e=window.getComputedStyle(document.body),s=e[t==="padding"?"paddingLeft":"marginLeft"],i=e[t==="padding"?"paddingTop":"marginTop"],l=e[t==="padding"?"paddingRight":"marginRight"];return[bf(s),bf(i),bf(l)]},aO=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return nO;var e=sO(t),s=document.documentElement.clientWidth,i=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,i-s+e[2]-e[0])}},iO=c1(),lr="data-scroll-locked",rO=function(t,e,s,i){var l=t.left,u=t.top,d=t.right,h=t.gap;return s===void 0&&(s="margin"),`
|
|
52
52
|
.`.concat(IR,` {
|
|
53
|
-
overflow: hidden `).concat(
|
|
54
|
-
padding-right: `).concat(h,"px ").concat(
|
|
53
|
+
overflow: hidden `).concat(i,`;
|
|
54
|
+
padding-right: `).concat(h,"px ").concat(i,`;
|
|
55
55
|
}
|
|
56
|
-
body[`).concat(
|
|
57
|
-
overflow: hidden `).concat(
|
|
56
|
+
body[`).concat(lr,`] {
|
|
57
|
+
overflow: hidden `).concat(i,`;
|
|
58
58
|
overscroll-behavior: contain;
|
|
59
|
-
`).concat([e&&"position: relative ".concat(
|
|
59
|
+
`).concat([e&&"position: relative ".concat(i,";"),s==="margin"&&`
|
|
60
60
|
padding-left: `.concat(l,`px;
|
|
61
61
|
padding-top: `).concat(u,`px;
|
|
62
62
|
padding-right: `).concat(d,`px;
|
|
63
63
|
margin-left:0;
|
|
64
64
|
margin-top:0;
|
|
65
|
-
margin-right: `).concat(h,"px ").concat(
|
|
66
|
-
`),s==="padding"&&"padding-right: ".concat(h,"px ").concat(
|
|
65
|
+
margin-right: `).concat(h,"px ").concat(i,`;
|
|
66
|
+
`),s==="padding"&&"padding-right: ".concat(h,"px ").concat(i,";")].filter(Boolean).join(""),`
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
.`).concat(Yc,` {
|
|
70
|
-
right: `).concat(h,"px ").concat(
|
|
70
|
+
right: `).concat(h,"px ").concat(i,`;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
.`).concat(Xc,` {
|
|
74
|
-
margin-right: `).concat(h,"px ").concat(
|
|
74
|
+
margin-right: `).concat(h,"px ").concat(i,`;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
.`).concat(Yc," .").concat(Yc,` {
|
|
78
|
-
right: 0 `).concat(
|
|
78
|
+
right: 0 `).concat(i,`;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
.`).concat(Xc," .").concat(Xc,` {
|
|
82
|
-
margin-right: 0 `).concat(
|
|
82
|
+
margin-right: 0 `).concat(i,`;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
body[`).concat(
|
|
85
|
+
body[`).concat(lr,`] {
|
|
86
86
|
`).concat($R,": ").concat(h,`px;
|
|
87
87
|
}
|
|
88
|
-
`)},k0=function(){var t=parseInt(document.body.getAttribute(
|
|
88
|
+
`)},k0=function(){var t=parseInt(document.body.getAttribute(lr)||"0",10);return isFinite(t)?t:0},oO=function(){v.useEffect(function(){return document.body.setAttribute(lr,(k0()+1).toString()),function(){var t=k0()-1;t<=0?document.body.removeAttribute(lr):document.body.setAttribute(lr,t.toString())}},[])},lO=function(t){var e=t.noRelative,s=t.noImportant,i=t.gapMode,l=i===void 0?"margin":i;oO();var u=v.useMemo(function(){return aO(l)},[l]);return v.createElement(iO,{styles:rO(u,!e,l,s?"":"!important")})},rm=!1;if(typeof window<"u")try{var Uc=Object.defineProperty({},"passive",{get:function(){return rm=!0,!0}});window.addEventListener("test",Uc,Uc),window.removeEventListener("test",Uc,Uc)}catch{rm=!1}var Ki=rm?{passive:!1}:!1,cO=function(t){return t.tagName==="TEXTAREA"},u1=function(t,e){if(!(t instanceof Element))return!1;var s=window.getComputedStyle(t);return s[e]!=="hidden"&&!(s.overflowY===s.overflowX&&!cO(t)&&s[e]==="visible")},uO=function(t){return u1(t,"overflowY")},dO=function(t){return u1(t,"overflowX")},C0=function(t,e){var s=e.ownerDocument,i=e;do{typeof ShadowRoot<"u"&&i instanceof ShadowRoot&&(i=i.host);var l=d1(t,i);if(l){var u=h1(t,i),d=u[1],h=u[2];if(d>h)return!0}i=i.parentNode}while(i&&i!==s.body);return!1},hO=function(t){var e=t.scrollTop,s=t.scrollHeight,i=t.clientHeight;return[e,s,i]},fO=function(t){var e=t.scrollLeft,s=t.scrollWidth,i=t.clientWidth;return[e,s,i]},d1=function(t,e){return t==="v"?uO(e):dO(e)},h1=function(t,e){return t==="v"?hO(e):fO(e)},mO=function(t,e){return t==="h"&&e==="rtl"?-1:1},pO=function(t,e,s,i,l){var u=mO(t,window.getComputedStyle(e).direction),d=u*i,h=s.target,m=e.contains(h),g=!1,y=d>0,x=0,w=0;do{if(!h)break;var S=h1(t,h),E=S[0],j=S[1],_=S[2],N=j-_-u*E;(E||N)&&d1(t,h)&&(x+=N,w+=E);var k=h.parentNode;h=k&&k.nodeType===Node.DOCUMENT_FRAGMENT_NODE?k.host:k}while(!m&&h!==document.body||m&&(e.contains(h)||e===h));return(y&&Math.abs(x)<1||!y&&Math.abs(w)<1)&&(g=!0),g},Bc=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},A0=function(t){return[t.deltaX,t.deltaY]},R0=function(t){return t&&"current"in t?t.current:t},gO=function(t,e){return t[0]===e[0]&&t[1]===e[1]},yO=function(t){return`
|
|
89
89
|
.block-interactivity-`.concat(t,` {pointer-events: none;}
|
|
90
90
|
.allow-interactivity-`).concat(t,` {pointer-events: all;}
|
|
91
|
-
`)},vO=0,Yr=[];function xO(t){var e=v.useRef([]),s=v.useRef([0,0]),r=v.useRef(),l=v.useState(vO++)[0],u=v.useState(c1)[0],d=v.useRef(t);v.useEffect(function(){d.current=t},[t]),v.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(l));var j=r2([t.lockRef.current],(t.shards||[]).map(R0),!0).filter(Boolean);return j.forEach(function(_){return _.classList.add("allow-interactivity-".concat(l))}),function(){document.body.classList.remove("block-interactivity-".concat(l)),j.forEach(function(_){return _.classList.remove("allow-interactivity-".concat(l))})}}},[t.inert,t.lockRef.current,t.shards]);var h=v.useCallback(function(j,_){if("touches"in j&&j.touches.length===2||j.type==="wheel"&&j.ctrlKey)return!d.current.allowPinchZoom;var N=Bc(j),k=s.current,C="deltaX"in j?j.deltaX:k[0]-N[0],A="deltaY"in j?j.deltaY:k[1]-N[1],D,U=j.target,V=Math.abs(C)>Math.abs(A)?"h":"v";if("touches"in j&&V==="h"&&U.type==="range")return!1;var R=window.getSelection(),P=R&&R.anchorNode,Z=P?P===U||P.contains(U):!1;if(Z)return!1;var te=C0(V,U);if(!te)return!0;if(te?D=V:(D=V==="v"?"h":"v",te=C0(V,U)),!te)return!1;if(!r.current&&"changedTouches"in j&&(C||A)&&(r.current=D),!D)return!0;var me=r.current||D;return pO(me,_,j,me==="h"?C:A)},[]),m=v.useCallback(function(j){var _=j;if(!(!Yr.length||Yr[Yr.length-1]!==u)){var N="deltaY"in _?A0(_):Bc(_),k=e.current.filter(function(D){return D.name===_.type&&(D.target===_.target||_.target===D.shadowParent)&&gO(D.delta,N)})[0];if(k&&k.should){_.cancelable&&_.preventDefault();return}if(!k){var C=(d.current.shards||[]).map(R0).filter(Boolean).filter(function(D){return D.contains(_.target)}),A=C.length>0?h(_,C[0]):!d.current.noIsolation;A&&_.cancelable&&_.preventDefault()}}},[]),g=v.useCallback(function(j,_,N,k){var C={name:j,delta:_,target:N,should:k,shadowParent:bO(N)};e.current.push(C),setTimeout(function(){e.current=e.current.filter(function(A){return A!==C})},1)},[]),y=v.useCallback(function(j){s.current=Bc(j),r.current=void 0},[]),x=v.useCallback(function(j){g(j.type,A0(j),j.target,h(j,t.lockRef.current))},[]),w=v.useCallback(function(j){g(j.type,Bc(j),j.target,h(j,t.lockRef.current))},[]);v.useEffect(function(){return Yr.push(u),t.setCallbacks({onScrollCapture:x,onWheelCapture:x,onTouchMoveCapture:w}),document.addEventListener("wheel",m,Kr),document.addEventListener("touchmove",m,Kr),document.addEventListener("touchstart",y,Kr),function(){Yr=Yr.filter(function(j){return j!==u}),document.removeEventListener("wheel",m,Kr),document.removeEventListener("touchmove",m,Kr),document.removeEventListener("touchstart",y,Kr)}},[]);var S=t.removeScrollBar,E=t.inert;return v.createElement(v.Fragment,null,E?v.createElement(u,{styles:yO(l)}):null,S?v.createElement(lO,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function bO(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const wO=XR(l1,xO);var f1=v.forwardRef(function(t,e){return v.createElement(Ou,ss({},t,{ref:e,sideCar:wO}))});f1.classNames=Ou.classNames;var SO=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Xr=new WeakMap,Vc=new WeakMap,Ic={},wf=0,m1=function(t){return t&&(t.host||m1(t.parentNode))},jO=function(t,e){return e.map(function(s){if(t.contains(s))return s;var r=m1(s);return r&&t.contains(r)?r:(console.error("aria-hidden",s,"in not contained inside",t,". Doing nothing"),null)}).filter(function(s){return!!s})},_O=function(t,e,s,r){var l=jO(e,Array.isArray(t)?t:[t]);Ic[s]||(Ic[s]=new WeakMap);var u=Ic[s],d=[],h=new Set,m=new Set(l),g=function(x){!x||h.has(x)||(h.add(x),g(x.parentNode))};l.forEach(g);var y=function(x){!x||m.has(x)||Array.prototype.forEach.call(x.children,function(w){if(h.has(w))y(w);else try{var S=w.getAttribute(r),E=S!==null&&S!=="false",j=(Xr.get(w)||0)+1,_=(u.get(w)||0)+1;Xr.set(w,j),u.set(w,_),d.push(w),j===1&&E&&Vc.set(w,!0),_===1&&w.setAttribute(s,"true"),E||w.setAttribute(r,"true")}catch(N){console.error("aria-hidden: cannot operate on ",w,N)}})};return y(e),h.clear(),wf++,function(){d.forEach(function(x){var w=Xr.get(x)-1,S=u.get(x)-1;Xr.set(x,w),u.set(x,S),w||(Vc.has(x)||x.removeAttribute(r),Vc.delete(x)),S||x.removeAttribute(s)}),wf--,wf||(Xr=new WeakMap,Xr=new WeakMap,Vc=new WeakMap,Ic={})}},NO=function(t,e,s){s===void 0&&(s="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),l=SO(t);return l?(r.push.apply(r,Array.from(l.querySelectorAll("[aria-live], script"))),_O(r,l,s,"aria-hidden")):function(){return null}};function TO(t){const e=EO(t),s=v.forwardRef((r,l)=>{const{children:u,...d}=r,h=v.Children.toArray(u),m=h.find(CO);if(m){const g=m.props.children,y=h.map(x=>x===m?v.Children.count(g)>1?v.Children.only(null):v.isValidElement(g)?g.props.children:null:x);return o.jsx(e,{...d,ref:l,children:v.isValidElement(g)?v.cloneElement(g,void 0,y):null})}return o.jsx(e,{...d,ref:l,children:u})});return s.displayName=`${t}.Slot`,s}function EO(t){const e=v.forwardRef((s,r)=>{const{children:l,...u}=s;if(v.isValidElement(l)){const d=RO(l),h=AO(u,l.props);return l.type!==v.Fragment&&(h.ref=r?Au(r,d):d),v.cloneElement(l,h)}return v.Children.count(l)>1?v.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var kO=Symbol("radix.slottable");function CO(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===kO}function AO(t,e){const s={...e};for(const r in e){const l=t[r],u=e[r];/^on[A-Z]/.test(r)?l&&u?s[r]=(...h)=>{const m=u(...h);return l(...h),m}:l&&(s[r]=l):r==="style"?s[r]={...l,...u}:r==="className"&&(s[r]=[l,u].filter(Boolean).join(" "))}return{...t,...s}}function RO(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning;return s?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning,s?t.props.ref:t.props.ref||t.ref)}var Mu="Dialog",[p1]=rR(Mu),[OO,Yn]=p1(Mu),g1=t=>{const{__scopeDialog:e,children:s,open:r,defaultOpen:l,onOpenChange:u,modal:d=!0}=t,h=v.useRef(null),m=v.useRef(null),[g,y]=uR({prop:r,defaultProp:l??!1,onChange:u,caller:Mu});return o.jsx(OO,{scope:e,triggerRef:h,contentRef:m,contentId:mf(),titleId:mf(),descriptionId:mf(),open:g,onOpenChange:y,onOpenToggle:v.useCallback(()=>y(x=>!x),[y]),modal:d,children:s})};g1.displayName=Mu;var y1="DialogTrigger",MO=v.forwardRef((t,e)=>{const{__scopeDialog:s,...r}=t,l=Yn(y1,s),u=nr(e,l.triggerRef);return o.jsx(Os.button,{type:"button","aria-haspopup":"dialog","aria-expanded":l.open,"aria-controls":l.contentId,"data-state":Km(l.open),...r,ref:u,onClick:fa(t.onClick,l.onOpenToggle)})});MO.displayName=y1;var Gm="DialogPortal",[DO,v1]=p1(Gm,{forceMount:void 0}),x1=t=>{const{__scopeDialog:e,forceMount:s,children:r,container:l}=t,u=Yn(Gm,e);return o.jsx(DO,{scope:e,forceMount:s,children:v.Children.map(r,d=>o.jsx(Ru,{present:s||u.open,children:o.jsx(i1,{asChild:!0,container:l,children:d})}))})};x1.displayName=Gm;var mu="DialogOverlay",b1=v.forwardRef((t,e)=>{const s=v1(mu,t.__scopeDialog),{forceMount:r=s.forceMount,...l}=t,u=Yn(mu,t.__scopeDialog);return u.modal?o.jsx(Ru,{present:r||u.open,children:o.jsx(zO,{...l,ref:e})}):null});b1.displayName=mu;var PO=TO("DialogOverlay.RemoveScroll"),zO=v.forwardRef((t,e)=>{const{__scopeDialog:s,...r}=t,l=Yn(mu,s);return o.jsx(f1,{as:PO,allowPinchZoom:!0,shards:[l.contentRef],children:o.jsx(Os.div,{"data-state":Km(l.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),Qa="DialogContent",w1=v.forwardRef((t,e)=>{const s=v1(Qa,t.__scopeDialog),{forceMount:r=s.forceMount,...l}=t,u=Yn(Qa,t.__scopeDialog);return o.jsx(Ru,{present:r||u.open,children:u.modal?o.jsx(LO,{...l,ref:e}):o.jsx(UO,{...l,ref:e})})});w1.displayName=Qa;var LO=v.forwardRef((t,e)=>{const s=Yn(Qa,t.__scopeDialog),r=v.useRef(null),l=nr(e,s.contentRef,r);return v.useEffect(()=>{const u=r.current;if(u)return NO(u)},[]),o.jsx(S1,{...t,ref:l,trapFocus:s.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:fa(t.onCloseAutoFocus,u=>{u.preventDefault(),s.triggerRef.current?.focus()}),onPointerDownOutside:fa(t.onPointerDownOutside,u=>{const d=u.detail.originalEvent,h=d.button===0&&d.ctrlKey===!0;(d.button===2||h)&&u.preventDefault()}),onFocusOutside:fa(t.onFocusOutside,u=>u.preventDefault())})}),UO=v.forwardRef((t,e)=>{const s=Yn(Qa,t.__scopeDialog),r=v.useRef(!1),l=v.useRef(!1);return o.jsx(S1,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:u=>{t.onCloseAutoFocus?.(u),u.defaultPrevented||(r.current||s.triggerRef.current?.focus(),u.preventDefault()),r.current=!1,l.current=!1},onInteractOutside:u=>{t.onInteractOutside?.(u),u.defaultPrevented||(r.current=!0,u.detail.originalEvent.type==="pointerdown"&&(l.current=!0));const d=u.target;s.triggerRef.current?.contains(d)&&u.preventDefault(),u.detail.originalEvent.type==="focusin"&&l.current&&u.preventDefault()}})}),S1=v.forwardRef((t,e)=>{const{__scopeDialog:s,trapFocus:r,onOpenAutoFocus:l,onCloseAutoFocus:u,...d}=t,h=Yn(Qa,s),m=v.useRef(null),g=nr(e,m);return VR(),o.jsxs(o.Fragment,{children:[o.jsx(a1,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:l,onUnmountAutoFocus:u,children:o.jsx(n1,{role:"dialog",id:h.contentId,"aria-describedby":h.descriptionId,"aria-labelledby":h.titleId,"data-state":Km(h.open),...d,ref:g,onDismiss:()=>h.onOpenChange(!1)})}),o.jsxs(o.Fragment,{children:[o.jsx(BO,{titleId:h.titleId}),o.jsx(IO,{contentRef:m,descriptionId:h.descriptionId})]})]})}),Fm="DialogTitle",j1=v.forwardRef((t,e)=>{const{__scopeDialog:s,...r}=t,l=Yn(Fm,s);return o.jsx(Os.h2,{id:l.titleId,...r,ref:e})});j1.displayName=Fm;var _1="DialogDescription",N1=v.forwardRef((t,e)=>{const{__scopeDialog:s,...r}=t,l=Yn(_1,s);return o.jsx(Os.p,{id:l.descriptionId,...r,ref:e})});N1.displayName=_1;var T1="DialogClose",E1=v.forwardRef((t,e)=>{const{__scopeDialog:s,...r}=t,l=Yn(T1,s);return o.jsx(Os.button,{type:"button",...r,ref:e,onClick:fa(t.onClick,()=>l.onOpenChange(!1))})});E1.displayName=T1;function Km(t){return t?"open":"closed"}var k1="DialogTitleWarning",[oP,C1]=aR(k1,{contentName:Qa,titleName:Fm,docsSlug:"dialog"}),BO=({titleId:t})=>{const e=C1(k1),s=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
91
|
+
`)},vO=0,Yi=[];function xO(t){var e=v.useRef([]),s=v.useRef([0,0]),i=v.useRef(),l=v.useState(vO++)[0],u=v.useState(c1)[0],d=v.useRef(t);v.useEffect(function(){d.current=t},[t]),v.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(l));var j=i2([t.lockRef.current],(t.shards||[]).map(R0),!0).filter(Boolean);return j.forEach(function(_){return _.classList.add("allow-interactivity-".concat(l))}),function(){document.body.classList.remove("block-interactivity-".concat(l)),j.forEach(function(_){return _.classList.remove("allow-interactivity-".concat(l))})}}},[t.inert,t.lockRef.current,t.shards]);var h=v.useCallback(function(j,_){if("touches"in j&&j.touches.length===2||j.type==="wheel"&&j.ctrlKey)return!d.current.allowPinchZoom;var N=Bc(j),k=s.current,C="deltaX"in j?j.deltaX:k[0]-N[0],A="deltaY"in j?j.deltaY:k[1]-N[1],D,z=j.target,V=Math.abs(C)>Math.abs(A)?"h":"v";if("touches"in j&&V==="h"&&z.type==="range")return!1;var R=window.getSelection(),P=R&&R.anchorNode,Z=P?P===z||P.contains(z):!1;if(Z)return!1;var te=C0(V,z);if(!te)return!0;if(te?D=V:(D=V==="v"?"h":"v",te=C0(V,z)),!te)return!1;if(!i.current&&"changedTouches"in j&&(C||A)&&(i.current=D),!D)return!0;var me=i.current||D;return pO(me,_,j,me==="h"?C:A)},[]),m=v.useCallback(function(j){var _=j;if(!(!Yi.length||Yi[Yi.length-1]!==u)){var N="deltaY"in _?A0(_):Bc(_),k=e.current.filter(function(D){return D.name===_.type&&(D.target===_.target||_.target===D.shadowParent)&&gO(D.delta,N)})[0];if(k&&k.should){_.cancelable&&_.preventDefault();return}if(!k){var C=(d.current.shards||[]).map(R0).filter(Boolean).filter(function(D){return D.contains(_.target)}),A=C.length>0?h(_,C[0]):!d.current.noIsolation;A&&_.cancelable&&_.preventDefault()}}},[]),g=v.useCallback(function(j,_,N,k){var C={name:j,delta:_,target:N,should:k,shadowParent:bO(N)};e.current.push(C),setTimeout(function(){e.current=e.current.filter(function(A){return A!==C})},1)},[]),y=v.useCallback(function(j){s.current=Bc(j),i.current=void 0},[]),x=v.useCallback(function(j){g(j.type,A0(j),j.target,h(j,t.lockRef.current))},[]),w=v.useCallback(function(j){g(j.type,Bc(j),j.target,h(j,t.lockRef.current))},[]);v.useEffect(function(){return Yi.push(u),t.setCallbacks({onScrollCapture:x,onWheelCapture:x,onTouchMoveCapture:w}),document.addEventListener("wheel",m,Ki),document.addEventListener("touchmove",m,Ki),document.addEventListener("touchstart",y,Ki),function(){Yi=Yi.filter(function(j){return j!==u}),document.removeEventListener("wheel",m,Ki),document.removeEventListener("touchmove",m,Ki),document.removeEventListener("touchstart",y,Ki)}},[]);var S=t.removeScrollBar,E=t.inert;return v.createElement(v.Fragment,null,E?v.createElement(u,{styles:yO(l)}):null,S?v.createElement(lO,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function bO(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const wO=XR(l1,xO);var f1=v.forwardRef(function(t,e){return v.createElement(Ou,ss({},t,{ref:e,sideCar:wO}))});f1.classNames=Ou.classNames;var SO=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Xi=new WeakMap,Vc=new WeakMap,Ic={},wf=0,m1=function(t){return t&&(t.host||m1(t.parentNode))},jO=function(t,e){return e.map(function(s){if(t.contains(s))return s;var i=m1(s);return i&&t.contains(i)?i:(console.error("aria-hidden",s,"in not contained inside",t,". Doing nothing"),null)}).filter(function(s){return!!s})},_O=function(t,e,s,i){var l=jO(e,Array.isArray(t)?t:[t]);Ic[s]||(Ic[s]=new WeakMap);var u=Ic[s],d=[],h=new Set,m=new Set(l),g=function(x){!x||h.has(x)||(h.add(x),g(x.parentNode))};l.forEach(g);var y=function(x){!x||m.has(x)||Array.prototype.forEach.call(x.children,function(w){if(h.has(w))y(w);else try{var S=w.getAttribute(i),E=S!==null&&S!=="false",j=(Xi.get(w)||0)+1,_=(u.get(w)||0)+1;Xi.set(w,j),u.set(w,_),d.push(w),j===1&&E&&Vc.set(w,!0),_===1&&w.setAttribute(s,"true"),E||w.setAttribute(i,"true")}catch(N){console.error("aria-hidden: cannot operate on ",w,N)}})};return y(e),h.clear(),wf++,function(){d.forEach(function(x){var w=Xi.get(x)-1,S=u.get(x)-1;Xi.set(x,w),u.set(x,S),w||(Vc.has(x)||x.removeAttribute(i),Vc.delete(x)),S||x.removeAttribute(s)}),wf--,wf||(Xi=new WeakMap,Xi=new WeakMap,Vc=new WeakMap,Ic={})}},NO=function(t,e,s){s===void 0&&(s="data-aria-hidden");var i=Array.from(Array.isArray(t)?t:[t]),l=SO(t);return l?(i.push.apply(i,Array.from(l.querySelectorAll("[aria-live], script"))),_O(i,l,s,"aria-hidden")):function(){return null}};function TO(t){const e=EO(t),s=v.forwardRef((i,l)=>{const{children:u,...d}=i,h=v.Children.toArray(u),m=h.find(CO);if(m){const g=m.props.children,y=h.map(x=>x===m?v.Children.count(g)>1?v.Children.only(null):v.isValidElement(g)?g.props.children:null:x);return o.jsx(e,{...d,ref:l,children:v.isValidElement(g)?v.cloneElement(g,void 0,y):null})}return o.jsx(e,{...d,ref:l,children:u})});return s.displayName=`${t}.Slot`,s}function EO(t){const e=v.forwardRef((s,i)=>{const{children:l,...u}=s;if(v.isValidElement(l)){const d=RO(l),h=AO(u,l.props);return l.type!==v.Fragment&&(h.ref=i?Au(i,d):d),v.cloneElement(l,h)}return v.Children.count(l)>1?v.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var kO=Symbol("radix.slottable");function CO(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===kO}function AO(t,e){const s={...e};for(const i in e){const l=t[i],u=e[i];/^on[A-Z]/.test(i)?l&&u?s[i]=(...h)=>{const m=u(...h);return l(...h),m}:l&&(s[i]=l):i==="style"?s[i]={...l,...u}:i==="className"&&(s[i]=[l,u].filter(Boolean).join(" "))}return{...t,...s}}function RO(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning;return s?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning,s?t.props.ref:t.props.ref||t.ref)}var Mu="Dialog",[p1]=iR(Mu),[OO,Yn]=p1(Mu),g1=t=>{const{__scopeDialog:e,children:s,open:i,defaultOpen:l,onOpenChange:u,modal:d=!0}=t,h=v.useRef(null),m=v.useRef(null),[g,y]=uR({prop:i,defaultProp:l??!1,onChange:u,caller:Mu});return o.jsx(OO,{scope:e,triggerRef:h,contentRef:m,contentId:mf(),titleId:mf(),descriptionId:mf(),open:g,onOpenChange:y,onOpenToggle:v.useCallback(()=>y(x=>!x),[y]),modal:d,children:s})};g1.displayName=Mu;var y1="DialogTrigger",MO=v.forwardRef((t,e)=>{const{__scopeDialog:s,...i}=t,l=Yn(y1,s),u=ni(e,l.triggerRef);return o.jsx(Os.button,{type:"button","aria-haspopup":"dialog","aria-expanded":l.open,"aria-controls":l.contentId,"data-state":Km(l.open),...i,ref:u,onClick:fa(t.onClick,l.onOpenToggle)})});MO.displayName=y1;var Gm="DialogPortal",[DO,v1]=p1(Gm,{forceMount:void 0}),x1=t=>{const{__scopeDialog:e,forceMount:s,children:i,container:l}=t,u=Yn(Gm,e);return o.jsx(DO,{scope:e,forceMount:s,children:v.Children.map(i,d=>o.jsx(Ru,{present:s||u.open,children:o.jsx(r1,{asChild:!0,container:l,children:d})}))})};x1.displayName=Gm;var mu="DialogOverlay",b1=v.forwardRef((t,e)=>{const s=v1(mu,t.__scopeDialog),{forceMount:i=s.forceMount,...l}=t,u=Yn(mu,t.__scopeDialog);return u.modal?o.jsx(Ru,{present:i||u.open,children:o.jsx(zO,{...l,ref:e})}):null});b1.displayName=mu;var PO=TO("DialogOverlay.RemoveScroll"),zO=v.forwardRef((t,e)=>{const{__scopeDialog:s,...i}=t,l=Yn(mu,s);return o.jsx(f1,{as:PO,allowPinchZoom:!0,shards:[l.contentRef],children:o.jsx(Os.div,{"data-state":Km(l.open),...i,ref:e,style:{pointerEvents:"auto",...i.style}})})}),Qa="DialogContent",w1=v.forwardRef((t,e)=>{const s=v1(Qa,t.__scopeDialog),{forceMount:i=s.forceMount,...l}=t,u=Yn(Qa,t.__scopeDialog);return o.jsx(Ru,{present:i||u.open,children:u.modal?o.jsx(LO,{...l,ref:e}):o.jsx(UO,{...l,ref:e})})});w1.displayName=Qa;var LO=v.forwardRef((t,e)=>{const s=Yn(Qa,t.__scopeDialog),i=v.useRef(null),l=ni(e,s.contentRef,i);return v.useEffect(()=>{const u=i.current;if(u)return NO(u)},[]),o.jsx(S1,{...t,ref:l,trapFocus:s.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:fa(t.onCloseAutoFocus,u=>{u.preventDefault(),s.triggerRef.current?.focus()}),onPointerDownOutside:fa(t.onPointerDownOutside,u=>{const d=u.detail.originalEvent,h=d.button===0&&d.ctrlKey===!0;(d.button===2||h)&&u.preventDefault()}),onFocusOutside:fa(t.onFocusOutside,u=>u.preventDefault())})}),UO=v.forwardRef((t,e)=>{const s=Yn(Qa,t.__scopeDialog),i=v.useRef(!1),l=v.useRef(!1);return o.jsx(S1,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:u=>{t.onCloseAutoFocus?.(u),u.defaultPrevented||(i.current||s.triggerRef.current?.focus(),u.preventDefault()),i.current=!1,l.current=!1},onInteractOutside:u=>{t.onInteractOutside?.(u),u.defaultPrevented||(i.current=!0,u.detail.originalEvent.type==="pointerdown"&&(l.current=!0));const d=u.target;s.triggerRef.current?.contains(d)&&u.preventDefault(),u.detail.originalEvent.type==="focusin"&&l.current&&u.preventDefault()}})}),S1=v.forwardRef((t,e)=>{const{__scopeDialog:s,trapFocus:i,onOpenAutoFocus:l,onCloseAutoFocus:u,...d}=t,h=Yn(Qa,s),m=v.useRef(null),g=ni(e,m);return VR(),o.jsxs(o.Fragment,{children:[o.jsx(a1,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:l,onUnmountAutoFocus:u,children:o.jsx(n1,{role:"dialog",id:h.contentId,"aria-describedby":h.descriptionId,"aria-labelledby":h.titleId,"data-state":Km(h.open),...d,ref:g,onDismiss:()=>h.onOpenChange(!1)})}),o.jsxs(o.Fragment,{children:[o.jsx(BO,{titleId:h.titleId}),o.jsx(IO,{contentRef:m,descriptionId:h.descriptionId})]})]})}),Fm="DialogTitle",j1=v.forwardRef((t,e)=>{const{__scopeDialog:s,...i}=t,l=Yn(Fm,s);return o.jsx(Os.h2,{id:l.titleId,...i,ref:e})});j1.displayName=Fm;var _1="DialogDescription",N1=v.forwardRef((t,e)=>{const{__scopeDialog:s,...i}=t,l=Yn(_1,s);return o.jsx(Os.p,{id:l.descriptionId,...i,ref:e})});N1.displayName=_1;var T1="DialogClose",E1=v.forwardRef((t,e)=>{const{__scopeDialog:s,...i}=t,l=Yn(T1,s);return o.jsx(Os.button,{type:"button",...i,ref:e,onClick:fa(t.onClick,()=>l.onOpenChange(!1))})});E1.displayName=T1;function Km(t){return t?"open":"closed"}var k1="DialogTitleWarning",[oP,C1]=aR(k1,{contentName:Qa,titleName:Fm,docsSlug:"dialog"}),BO=({titleId:t})=>{const e=C1(k1),s=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
92
92
|
|
|
93
93
|
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
94
94
|
|
|
95
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return v.useEffect(()=>{t&&(document.getElementById(t)||console.error(s))},[s,t]),null},VO="DialogDescriptionWarning",IO=({contentRef:t,descriptionId:e})=>{const
|
|
96
|
-
`);this.buffer=r.pop()||"";for(const l of r)if(l.startsWith("data: "))try{const u=JSON.parse(l.slice(6));s.push(u)}catch{}return s}flush(){if(!this.buffer.trim())return[];const e=[];if(this.buffer.startsWith("data: "))try{e.push(JSON.parse(this.buffer.slice(6)))}catch{}return this.buffer="",e}reset(){this.buffer=""}}async function R1(t,e,s={}){const{timeout:r=3e5,onError:l}=s;if(!t.body)throw new Error("Response body is empty");const u=t.body.getReader(),d=new TextDecoder,h=new JO,m=setTimeout(()=>{u.cancel("Timeout").catch(()=>{})},r);try{for(;;){const{value:g,done:y}=await u.read();if(y){h.flush().forEach(e);break}const x=d.decode(g,{stream:!0});h.processChunk(x).forEach(e)}}catch(g){const y=g instanceof Error?g:new Error(String(g));if(l)l(y);else throw y}finally{clearTimeout(m),h.reset()}}class rs extends Error{constructor(e,s,r){super(e),this.code=s,this.status=r,this.name="SetupApiError"}}async function QO(t){const e=await fetch("/api/setup/organizations",{headers:{Authorization:`Bearer ${t}`}}),s=await e.text();let r={};if(s.trim())try{r=JSON.parse(s)}catch{r={message:s.trim()}}if(!e.ok){const l=typeof r?.error=="string"&&r.error||typeof r?.message=="string"&&r.message||`${e.status} ${e.statusText} while fetching organizations`,u=e.status===500||e.status===502?" If local API is not running, start `npm run dev:api` and retry.":"";throw new rs(`${l}${u}`,"FETCH_ORGS_FAILED",e.status)}return r}async function ZO(t,e){const s=await fetch("/api/setup/auto-provision",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.accessToken}`},body:JSON.stringify({orgId:t.orgId,projectName:t.projectName,region:t.region})});if(!s.ok){const r=await s.json().catch(()=>({}));throw new rs(r?.error||"Failed to auto-provision","PROVISION_FAILED",s.status)}await R1(s,e,{timeout:36e4,onError:r=>{throw new rs(`Provisioning stream error: ${r.message}`,"STREAM_ERROR")}})}async function e5(t){const e=await fetch(`/api/setup/projects/${encodeURIComponent(t.projectRef)}/credentials`,{headers:{Authorization:`Bearer ${t.accessToken}`}}),s=await e.json().catch(()=>({}));if(!e.ok)throw new rs(s?.error||"Failed to recover project credentials","RECOVERY_FAILED",e.status);return{projectId:String(s.projectId||t.projectRef),url:String(s.url||`https://${t.projectRef}.supabase.co`),anonKey:String(s.anonKey||""),dbPass:""}}async function t5(t,e){const s=await fetch("/api/migrate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectRef:t.projectRef,accessToken:t.accessToken,anonKey:t.anonKey})});if(!s.ok){const r=await s.json().catch(()=>({}));throw new rs(r?.error||"Failed to run migration","MIGRATION_FAILED",s.status)}await R1(s,e,{timeout:6e5,onError:r=>{throw new rs(`Migration stream error: ${r.message}`,"STREAM_ERROR")}})}const om={step:"welcome",managed:{accessToken:"",organizations:[],selectedOrg:"",projectName:"Folio-Core",region:"us-east-1",isFetchingOrgs:!1},manual:{url:"",anonKey:""},projectId:"",logs:[],error:null,isMigrating:!1,migrationStatus:null};function n5(t,e){switch(e.type){case"SET_STEP":return{...t,step:e.payload,error:null};case"SET_ACCESS_TOKEN":return{...t,managed:{...t.managed,accessToken:e.payload}};case"SET_ORGANIZATIONS":return{...t,managed:{...t.managed,organizations:e.payload,selectedOrg:e.payload.length>0?e.payload[0].id:""}};case"SET_SELECTED_ORG":return{...t,managed:{...t.managed,selectedOrg:e.payload}};case"SET_PROJECT_NAME":return{...t,managed:{...t.managed,projectName:e.payload}};case"SET_REGION":return{...t,managed:{...t.managed,region:e.payload}};case"SET_FETCHING_ORGS":return{...t,managed:{...t.managed,isFetchingOrgs:e.payload}};case"SET_MANUAL_URL":return{...t,manual:{...t.manual,url:e.payload}};case"SET_MANUAL_ANON_KEY":return{...t,manual:{...t.manual,anonKey:e.payload}};case"SET_PROJECT_ID":return{...t,projectId:e.payload};case"ADD_LOG":return{...t,logs:[...t.logs,{...e.payload,timestamp:Date.now()}].slice(-500)};case"CLEAR_LOGS":return{...t,logs:[]};case"SET_ERROR":return{...t,error:e.payload};case"SET_MIGRATING":return{...t,isMigrating:e.payload};case"SET_MIGRATION_STATUS":return{...t,migrationStatus:e.payload};case"RESET_MANAGED_FLOW":return{...t,managed:{...om.managed},error:null};case"RESET_MANUAL_FLOW":return{...t,manual:{...om.manual},error:null};default:return t}}const Ym=v.forwardRef(({className:t,...e},s)=>o.jsx("textarea",{className:ge("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:s,...e}));Ym.displayName="Textarea";function Sf(t){const e=t.trim();return e?e.startsWith("http://")||e.startsWith("https://")?e:`https://${e}.supabase.co`:""}function s5(t){const e=t.trim();if(!e)return{valid:!1,message:"URL is required"};if(e.startsWith("http://")||e.startsWith("https://"))try{return new URL(e).hostname.endsWith(".supabase.co")?{valid:!0,message:"Valid Supabase URL"}:{valid:!1,message:"URL must be a supabase.co domain"}}catch{return{valid:!1,message:"Invalid URL format"}}return/^[a-z0-9-]+$/.test(e)?{valid:!0,message:"Project ID detected"}:{valid:!1,message:"Enter a valid URL or project ID"}}function a5(t){const e=t.trim();return e?e.startsWith("sb_publishable_")?e.length<25?{valid:!1,message:"Incomplete publishable key"}:{valid:!0,message:"Valid publishable key"}:e.startsWith("eyJ")?e.length<50?{valid:!1,message:"Incomplete anon key"}:{valid:!0,message:"Valid anon key"}:{valid:!1,message:"Invalid API key format"}:{valid:!1,message:"API key is required"}}function O1(t){const e=t.trim();return e?e.startsWith("sbp_")?e.length<20?{valid:!1,message:"Token is too short"}:{valid:!0,message:"Valid access token"}:{valid:!1,message:"Token must start with sbp_"}:{valid:!1,message:"Access token is required"}}function O0(t){const e=t.trim();if(!e)return null;if(!e.includes(".")&&!e.includes("/"))return e;try{return new URL(e.startsWith("http")?e:`https://${e}`).hostname.split(".")[0]||null}catch{return null}}function r5({url:t,anonKey:e,error:s,onUrlChange:r,onAnonKeyChange:l,onSave:u,onBack:d}){const h=s5(t),m=a5(e);return o.jsxs("div",{className:"flex flex-col gap-6 animate-in fade-in slide-in-from-right-4 duration-500",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Manual Credentials"}),o.jsx("p",{className:"text-muted-foreground text-sm",children:"Connect Folio to an existing Supabase project with URL and anon key."})]}),o.jsxs("div",{className:"grid gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"supabase-url",children:"Supabase URL or Project ID"}),o.jsx(je,{id:"supabase-url",value:t,onChange:g=>r(g.target.value),placeholder:"https://project.supabase.co or project-id",className:!h.valid&&t.length>0?"border-destructive focus-visible:ring-destructive":""}),t.length>0&&o.jsxs("p",{className:ge("text-xs flex items-center gap-1",h.valid?"text-emerald-500":"text-destructive"),children:[h.valid?o.jsx(os,{className:"w-3"}):o.jsx(Sn,{className:"w-3"}),h.message]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"supabase-anon-key",children:"Anon Key"}),o.jsx(Ym,{id:"supabase-anon-key",value:e,onChange:g=>l(g.target.value),placeholder:"eyJ...",className:ge("min-h-[120px] font-mono text-xs",!m.valid&&e.length>0?"border-destructive focus-visible:ring-destructive":"")}),e.length>0&&o.jsxs("p",{className:ge("text-xs flex items-center gap-1",m.valid?"text-emerald-500":"text-destructive"),children:[m.valid?o.jsx(os,{className:"w-3"}):o.jsx(Sn,{className:"w-3"}),m.message]})]})]}),s&&o.jsxs(jn,{variant:"destructive",children:[o.jsx(Sn,{className:"h-4 w-4"}),o.jsx(_n,{children:s})]}),o.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[o.jsxs(ae,{variant:"ghost",size:"sm",className:"text-muted-foreground",onClick:d,children:[o.jsx(Jo,{className:"w-4 h-4 mr-1"}),"Back"]}),o.jsx(ae,{className:"ml-auto",onClick:u,disabled:!h.valid||!m.valid,children:"Validate and Continue"})]})]})}const nl=v.createContext(null),i5=({children:t,value:e,onValueChange:s,...r})=>{const[l,u]=v.useState(!1),d=v.useRef(null);return v.useEffect(()=>{const h=m=>{d.current&&!d.current.contains(m.target)&&u(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]),o.jsx(nl.Provider,{value:{value:e,onValueChange:s,open:l,setOpen:u},children:o.jsx("div",{ref:d,className:"relative inline-block w-full",...r,children:t})})},M1=v.forwardRef(({className:t,children:e,...s},r)=>{const l=v.useContext(nl);return o.jsxs("button",{ref:r,type:"button",onClick:()=>l?.setOpen(!l.open),className:ge("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:[e,o.jsx("svg",{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",className:"h-4 w-4 opacity-50",children:o.jsx("path",{d:"m6 9 6 6 6-6"})})]})});M1.displayName="SelectTrigger";const D1=v.forwardRef(({className:t,placeholder:e,...s},r)=>{const l=v.useContext(nl);return v.Children.toArray(s.children),o.jsx("span",{ref:r,className:ge("pointer-events-none",t),...s,children:l?.value||e})});D1.displayName="SelectValue";const P1=v.forwardRef(({className:t,children:e,position:s="popper",...r},l)=>v.useContext(nl)?.open?o.jsx("div",{ref:l,className:ge("absolute z-50 min-w-[8rem] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md animate-in fade-in-80 mt-1",s==="popper"&&"translate-y-1",t),...r,children:o.jsx("div",{className:"p-1 bg-white dark:bg-zinc-950",children:e})}):null);P1.displayName="SelectContent";const z1=v.forwardRef(({className:t,children:e,value:s,...r},l)=>{const u=v.useContext(nl);return o.jsxs("div",{ref:l,className:ge("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none hover:bg-accent hover:text-accent-foreground cursor-pointer",t),onClick:()=>{u?.onValueChange?.(s),u?.setOpen(!1)},...r,children:[o.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u?.value===s&&o.jsx("svg",{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",className:"h-4 w-4",children:o.jsx("polyline",{points:"20 6 9 17 4 12"})})}),o.jsx("span",{className:"truncate",children:e})]})});z1.displayName="SelectItem";const o5=[{value:"us-east-1",label:"US East (N. Virginia)"},{value:"us-west-1",label:"US West (N. California)"},{value:"eu-central-1",label:"Europe (Frankfurt)"},{value:"ap-southeast-1",label:"Asia Pacific (Singapore)"}];function l5({organizations:t,selectedOrg:e,projectName:s,region:r,onOrgSelect:l,onProjectNameChange:u,onRegionChange:d,onProvision:h,onBack:m}){return o.jsxs("div",{className:"flex flex-col gap-6 animate-in fade-in slide-in-from-right-4 duration-500",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Provisioning Parameters"}),o.jsx("p",{className:"text-muted-foreground text-sm",children:"Choose an organization and project configuration for Folio deployment."})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"project-name",children:"Project Name"}),o.jsx(je,{id:"project-name",value:s,onChange:g=>u(g.target.value),placeholder:"my-folio-app"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"region",children:"Region"}),o.jsxs(i5,{value:r,onValueChange:d,children:[o.jsx(M1,{id:"region",children:o.jsx(D1,{placeholder:"Select region"})}),o.jsx(P1,{children:o5.map(g=>o.jsx(z1,{value:g.value,children:g.label},g.value))})]})]})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs(Je,{className:"flex items-center gap-2",children:[o.jsx(Pk,{className:"w-4 h-4"}),"Select Organization"]}),o.jsx("div",{className:"grid gap-2 max-h-[160px] overflow-y-auto p-1 rounded-lg border bg-muted/20",children:t.map(g=>o.jsxs("button",{onClick:()=>l(g.id),className:ge("flex items-center justify-between p-3 rounded-md border text-sm transition-all",e===g.id?"bg-primary text-primary-foreground border-primary shadow-sm":"bg-background hover:border-primary/50"),children:[o.jsx("span",{children:g.name}),e===g.id&&o.jsx(dC,{className:"w-3 h-3 opacity-70"})]},g.id))})]}),o.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[o.jsxs(ae,{variant:"ghost",size:"sm",className:"text-muted-foreground",onClick:m,children:[o.jsx(Jo,{className:"w-4 h-4 mr-1"}),"Back"]}),o.jsxs(ae,{className:"ml-auto",onClick:h,disabled:!e||!s,children:[o.jsx(UC,{className:"mr-2 h-4 w-4"}),"Auto-Provision"]})]})]})}function c5({accessToken:t,error:e,isFetching:s,onTokenChange:r,onFetchOrgs:l,onBack:u}){const d=O1(t);return o.jsxs("div",{className:"flex flex-col gap-6 animate-in fade-in slide-in-from-right-4 duration-500",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Supabase Access Token"}),o.jsxs("p",{className:"text-muted-foreground text-sm",children:["Enter a management token (",o.jsx("code",{className:"text-primary",children:"sbp_..."}),") so Folio can discover organizations and provision a project."]})]}),o.jsx("div",{className:"grid gap-4",children:o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"access-token",children:"Personal Access Token"}),o.jsxs("div",{className:"relative",children:[o.jsx(Zo,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),o.jsx(je,{id:"access-token",type:"password",value:t,onChange:h=>r(h.target.value),placeholder:"sbp_xxxxxxxxxxxxx",className:ge("pl-9",!d.valid&&t.length>0?"border-destructive focus-visible:ring-destructive":"")})]}),t.length>0&&o.jsxs("p",{className:ge("text-xs flex items-center gap-1",d.valid?"text-emerald-500":"text-destructive"),children:[d.valid?o.jsx(os,{className:"w-3"}):o.jsx(Sn,{className:"w-3"}),d.message]})]})}),e&&o.jsxs(jn,{variant:"destructive",children:[o.jsx(Sn,{className:"h-4 w-4"}),o.jsx(_n,{children:e})]}),o.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[o.jsxs(ae,{variant:"ghost",size:"sm",className:"text-muted-foreground",onClick:u,disabled:s,children:[o.jsx(Jo,{className:"w-4 h-4 mr-1"}),"Back"]}),o.jsx(ae,{className:"ml-auto",onClick:l,disabled:!d.valid||s,children:s?o.jsxs(o.Fragment,{children:[o.jsx(it,{className:"mr-2 h-4 w-4 animate-spin"}),"Fetching..."]}):"Fetch Organizations"})]})]})}function L1({logs:t}){const e=v.useRef(null);return v.useEffect(()=>{e.current?.scrollIntoView({behavior:"smooth"})},[t]),o.jsxs("div",{className:"bg-zinc-950 rounded-xl border border-zinc-800 overflow-hidden shadow-2xl flex flex-col h-[300px]",role:"log","aria-live":"polite","aria-label":"Setup logs",children:[o.jsxs("div",{className:"flex items-center gap-1.5 px-4 py-2 border-b border-zinc-800 bg-zinc-900/50",children:[o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-500/80"}),o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-amber-500/80"}),o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-emerald-500/80"}),o.jsx("span",{className:"ml-2 text-[10px] uppercase tracking-widest text-zinc-500 font-bold",children:"Foundation Trace"})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-4 font-mono text-[13px] leading-relaxed scrollbar-thin scrollbar-thumb-zinc-800",children:[t.length===0?o.jsx("div",{className:"text-zinc-600 italic",children:"Awaiting setup activity..."}):t.map((s,r)=>o.jsxs("div",{className:ge("mb-1 flex gap-3",s.type==="error"&&"text-red-400",s.type==="success"&&"text-emerald-400",s.type==="info"&&"text-blue-400",s.type==="stderr"&&"text-amber-400",s.type==="stdout"&&"text-zinc-300"),children:[o.jsx("span",{className:"text-zinc-600 shrink-0 select-none",children:new Date(s.timestamp).toLocaleTimeString([],{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}),o.jsx("span",{className:"break-all",children:s.message})]},`${s.timestamp}-${s.type}-${s.message}-${r}`)),o.jsx("div",{ref:e})]})]})}function u5({logs:t,error:e,isMigrating:s,migrationStatus:r,accessToken:l,onTokenChange:u,onRunMigration:d,onBypass:h}){const m=r?!r.needsMigration:!1;return o.jsxs("div",{className:"flex flex-col gap-6 animate-in fade-in slide-in-from-right-4 duration-500",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Database Migration"}),o.jsx("p",{className:"text-muted-foreground text-sm",children:r?.message||`Run migration to align database with app v${ha}.`})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(Je,{htmlFor:"migration-token",className:"flex items-center gap-2",children:[o.jsx(Zo,{className:"w-4 h-4"}),"Supabase Access Token"]}),o.jsx(je,{id:"migration-token",type:"password",value:l,onChange:g=>u(g.target.value),placeholder:"sbp_xxxxxxxxxxxxx"})]}),o.jsx(L1,{logs:t}),e&&o.jsxs(jn,{variant:"destructive",children:[o.jsx(Sn,{className:"h-4 w-4"}),o.jsx(_n,{children:e})]}),o.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[m&&o.jsx(ae,{variant:"ghost",size:"sm",onClick:h,disabled:s,children:"Skip for now"}),o.jsx(ae,{className:"ml-auto",onClick:d,disabled:s||l.trim()==="",children:s?o.jsxs(o.Fragment,{children:[o.jsx(it,{className:"mr-2 h-4 w-4 animate-spin"}),"Migrating..."]}):o.jsxs(o.Fragment,{children:[o.jsx(qw,{className:"mr-2 h-4 w-4"}),"Run Migration"]})})]})]})}function d5({logs:t,error:e,onRetry:s}){return o.jsxs("div",{className:"flex flex-col gap-6 animate-in fade-in slide-in-from-right-4 duration-500",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Provisioning"}),o.jsxs("p",{className:"text-muted-foreground text-sm flex items-center gap-2",children:[!e&&o.jsx(it,{className:"w-4 h-4 animate-spin text-primary"}),"Folio is creating a Supabase project and preparing runtime credentials."]})]}),o.jsx(L1,{logs:t}),e?o.jsx("div",{className:"flex items-center gap-3",children:o.jsxs(ae,{variant:"destructive",onClick:s,children:[o.jsx(Sn,{className:"w-4 h-4 mr-2"}),"Retry Provisioning"]})}):null]})}function h5({onManaged:t,onManual:e,onBack:s}){return o.jsxs("div",{className:"flex flex-col h-full justify-center gap-10 animate-in fade-in slide-in-from-right-4 duration-500",children:[o.jsxs("div",{className:"space-y-3",children:[o.jsx("h2",{className:"text-4xl font-black tracking-tight",children:"Setup Mode"}),o.jsx("p",{className:"text-muted-foreground text-lg leading-relaxed max-w-md",children:"Select whether Folio should auto-provision a project or connect to an existing one."})]}),o.jsxs("div",{className:"grid gap-6",children:[o.jsxs("button",{onClick:t,className:"group relative flex flex-col items-start p-8 text-left border border-border/40 rounded-3xl hover:border-primary hover:bg-primary/5 hover:shadow-xl hover:shadow-primary/5 transition-all duration-300",children:[o.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[o.jsx("div",{className:"w-12 h-12 rounded-2xl bg-primary/10 flex items-center justify-center text-primary group-hover:scale-110 transition-transform duration-500",children:o.jsx(hu,{className:"w-6 h-6 fill-primary/20"})}),o.jsx("strong",{className:"text-xl font-bold",children:"Managed Setup"})]}),o.jsx("span",{className:"text-muted-foreground leading-relaxed",children:"Use an access token to auto-provision project + run migration automatically. Recommended for most users."}),o.jsx("div",{className:"absolute top-8 right-8 opacity-0 group-hover:opacity-100 transition-opacity duration-300",children:o.jsx(di,{className:"w-6 h-6 text-primary"})})]}),o.jsxs("button",{onClick:e,className:"group relative flex flex-col items-start p-8 text-left border border-border/40 rounded-3xl hover:border-primary hover:bg-primary/5 hover:shadow-xl hover:shadow-primary/5 transition-all duration-300",children:[o.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[o.jsx("div",{className:"w-12 h-12 rounded-2xl bg-muted flex items-center justify-center text-muted-foreground group-hover:bg-primary/10 group-hover:text-primary group-hover:scale-110 transition-all duration-500",children:o.jsx($m,{className:"w-6 h-6"})}),o.jsx("strong",{className:"text-xl font-bold",children:"Manual Connection"})]}),o.jsx("span",{className:"text-muted-foreground leading-relaxed",children:"Provide your own Supabase URL + anon key. Use this if you already have a configured project."}),o.jsx("div",{className:"absolute top-8 right-8 opacity-0 group-hover:opacity-100 transition-opacity duration-300",children:o.jsx(di,{className:"w-6 h-6 text-primary"})})]})]}),o.jsx("div",{className:"pt-4",children:o.jsxs(ae,{variant:"ghost",size:"sm",className:"w-fit -ml-2 text-muted-foreground hover:text-foreground h-10 px-4 rounded-xl font-bold",onClick:s,children:[o.jsx(Jo,{className:"w-4 h-4 mr-1"}),"Back to Welcome"]})})]})}function f5({onNext:t}){return o.jsxs("div",{className:"flex flex-col h-full justify-center gap-12 animate-in fade-in slide-in-from-bottom-4 duration-700",children:[o.jsxs("div",{className:"space-y-4 text-center sm:text-left",children:[o.jsxs("h2",{className:"text-5xl font-black tracking-tight leading-tight",children:["Welcome to ",o.jsx("span",{className:"text-primary",children:"Folio"})]}),o.jsx("p",{className:"text-muted-foreground text-lg max-w-lg leading-relaxed",children:"Let's configure your foundation runtime: local desktop app, remote Supabase database, and RealTimeX SDK backend connectivity."})]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-6",children:[o.jsxs(ht,{className:"bg-muted/30 border-border/40 shadow-sm hover:shadow-md transition-all duration-300",children:[o.jsx(zt,{className:"pb-3 px-6",children:o.jsxs(Lt,{className:"flex items-center gap-2 text-base font-bold",children:[o.jsx(ya,{className:"w-5 h-5 text-primary"}),"Secure by Default"]})}),o.jsx(xt,{className:"px-6 pb-6",children:o.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"Credentials are stored locally and used to configure runtime contracts only."})})]}),o.jsxs(ht,{className:"bg-muted/30 border-border/40 shadow-sm hover:shadow-md transition-all duration-300",children:[o.jsx(zt,{className:"pb-3 px-6",children:o.jsxs(Lt,{className:"flex items-center gap-2 text-base font-bold",children:[o.jsx(xC,{className:"w-5 h-5 text-primary"}),"No Feature Lock-In"]})}),o.jsx(xt,{className:"px-6 pb-6",children:o.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"This step only prepares infrastructure, not document automation features."})})]})]}),o.jsx("div",{className:"pt-4 flex justify-center sm:justify-start",children:o.jsx(ae,{size:"lg",className:"h-14 px-10 rounded-2xl text-base font-black shadow-xl shadow-primary/20 hover:scale-105 transition-all",onClick:t,children:"Start Setup"})})]})}function m5({onComplete:t,open:e=!0,canClose:s=!1}){const[r,l]=v.useReducer(n5,om),u=v.useRef("");v.useEffect(()=>()=>{u.current=""},[]);const d=v.useCallback((j,_)=>{l({type:"ADD_LOG",payload:{type:j,message:_}})},[]),h=v.useCallback(()=>{u.current="",t()},[t]),m=v.useCallback(async()=>{l({type:"SET_ERROR",payload:null}),l({type:"SET_FETCHING_ORGS",payload:!0});const j=r.managed.accessToken.trim(),_=O1(j);if(!_.valid){l({type:"SET_ERROR",payload:_.message||"Invalid token"}),l({type:"SET_FETCHING_ORGS",payload:!1});return}try{u.current=j;const N=await QO(j);l({type:"SET_ORGANIZATIONS",payload:N}),l({type:"SET_STEP",payload:"managed-org"})}catch(N){const k=N instanceof rs?N.message:String(N);l({type:"SET_ERROR",payload:k})}finally{l({type:"SET_FETCHING_ORGS",payload:!1})}},[r.managed.accessToken]),g=v.useCallback(async j=>{const _=j?.projectRef||r.projectId||O0(r.manual.url),N=j?.accessToken||u.current||r.managed.accessToken.trim(),k=j?.url||r.manual.url,C=j?.anonKey||r.manual.anonKey;if(!_||!N){l({type:"SET_ERROR",payload:"Project ID and access token are required for migration."});return}l({type:"SET_STEP",payload:"migration"}),l({type:"SET_ERROR",payload:null}),l({type:"SET_MIGRATING",payload:!0}),l({type:"CLEAR_LOGS"});let A=!1;try{if(await t5({projectRef:_,accessToken:N,anonKey:C},D=>{if(D.type==="stdout"){d("stdout",String(D.data));return}if(D.type==="stderr"){d("stderr",String(D.data));return}if(D.type==="info"){d("info",String(D.data));return}if(D.type==="error"){d("error",String(D.data));return}D.type==="done"&&(A=D.data==="success")}),!A)throw new Error("Migration did not complete successfully.");k&&C&&hf({url:Sf(k),anonKey:C.trim()}),d("success","Migration completed. Setup is ready."),setTimeout(()=>h(),600)}catch(D){const U=D instanceof rs?D.message:String(D);l({type:"SET_ERROR",payload:U}),d("error",U)}finally{l({type:"SET_MIGRATING",payload:!1})}},[d,h,r.managed.accessToken,r.manual.anonKey,r.manual.url,r.projectId]),y=v.useCallback(async()=>{l({type:"SET_ERROR",payload:null}),l({type:"SET_STEP",payload:"provisioning"}),l({type:"CLEAR_LOGS"}),d("info","Starting managed provisioning...");const j=u.current||r.managed.accessToken.trim(),_={result:null,projectId:"",receivedDone:!1,receivedError:!1},N=k=>{_.result=k,l({type:"SET_PROJECT_ID",payload:k.projectId}),hf({url:Sf(k.url),anonKey:k.anonKey.trim()}),l({type:"SET_MIGRATION_STATUS",payload:{needsMigration:!0,appVersion:ha,latestMigrationTimestamp:null,message:"Fresh project created. Migration is required."}}),d("success","Project ready. Starting migration...")};try{if(await ZO({accessToken:j,orgId:r.managed.selectedOrg,projectName:r.managed.projectName,region:r.managed.region},k=>{if(k.type==="project_id"){_.projectId=String(k.data),l({type:"SET_PROJECT_ID",payload:_.projectId});return}if(k.type==="info"){d("info",String(k.data));return}if(k.type==="error"){_.receivedError=!0,d("error",String(k.data)),l({type:"SET_ERROR",payload:String(k.data)});return}if(k.type==="success"){N(k.data);return}k.type==="done"&&(_.receivedDone=!0)}),!_.result&&_.projectId){d("info","Provisioning stream disconnected. Recovering credentials from existing project...");const k=await e5({accessToken:j,projectRef:_.projectId});N(k)}if(!_.result){const k=_.receivedError?"Provisioning failed before credentials were available. Retry or use manual setup.":_.receivedDone?"Provisioning ended without credentials. Retry or use manual setup.":"Provisioning stream ended unexpectedly. The project may still be provisioning; retry in a moment.";throw new rs(k,"PROVISION_INCOMPLETE")}await g({projectRef:_.result.projectId,accessToken:j,url:_.result.url,anonKey:_.result.anonKey})}catch(k){const C=k instanceof rs?k.message:String(k);l({type:"SET_ERROR",payload:C}),d("error",C)}},[d,g,r.managed.accessToken,r.managed.projectName,r.managed.region,r.managed.selectedOrg]),x=v.useCallback(async()=>{l({type:"SET_ERROR",payload:null}),l({type:"SET_STEP",payload:"validating"});const j=Sf(r.manual.url),_=r.manual.anonKey.trim(),N=await SA(j,_);if(!N.valid){l({type:"SET_ERROR",payload:N.error||"Connection validation failed."}),l({type:"SET_STEP",payload:"credentials"});return}hf({url:j,anonKey:_}),l({type:"SET_MANUAL_URL",payload:j});const k=O0(j);k&&l({type:"SET_PROJECT_ID",payload:k});try{const C=zm(j,_),A=await Qw(C);l({type:"SET_MIGRATION_STATUS",payload:{needsMigration:A.needsMigration,appVersion:A.appVersion,latestMigrationTimestamp:A.latestMigrationTimestamp,message:A.message}}),A.needsMigration?l({type:"SET_STEP",payload:"migration"}):h()}catch{l({type:"SET_MIGRATION_STATUS",payload:{needsMigration:!0,appVersion:ha,latestMigrationTimestamp:null,message:"Could not verify migration status. Run migration to continue."}}),l({type:"SET_STEP",payload:"migration"})}},[h,r.manual.anonKey,r.manual.url]);if(!e)return null;const w=[{key:"welcome",label:"Welcome"},{key:"config",label:"Configuration",subSteps:["type","managed-token","managed-org","credentials"]},{key:"validation",label:"Validation",subSteps:["provisioning","validating"]},{key:"migration",label:"Migration"}],E=r.step==="welcome"?"welcome":["type","managed-token","managed-org","credentials"].includes(r.step)?"config":["provisioning","validating"].includes(r.step)?"validation":"migration";return o.jsxs(Za,{open:e,onOpenChange:j=>{!j&&s&&t()},children:[o.jsx(A1,{className:"bg-zinc-950/80 backdrop-blur-sm"}),o.jsx(er,{className:"sm:max-w-[1100px] w-full p-0 overflow-hidden border-none shadow-2xl",children:o.jsxs("div",{className:"flex w-full min-h-[700px]",children:[o.jsxs("aside",{className:"w-[300px] border-r bg-muted/30 p-8 flex flex-col gap-10",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Folio Setup"}),o.jsx("p",{className:"text-xs text-muted-foreground font-medium uppercase tracking-wider",children:"Foundation Parity Mode"})]}),o.jsx("nav",{className:"flex-1",children:o.jsx("ul",{className:"space-y-4",children:w.map(j=>{const _=E===j.key,N=w.findIndex(k=>k.key===E)>w.findIndex(k=>k.key===j.key);return o.jsxs("li",{className:"flex items-center gap-3",children:[o.jsx("div",{className:ge("w-6 h-6 rounded-full flex items-center justify-center border transition-all duration-300",_?"border-primary bg-primary text-primary-foreground shadow-sm scale-110":N?"border-emerald-500 bg-emerald-50 text-emerald-500":"border-muted text-muted-foreground"),children:N?o.jsx(os,{className:"w-4 h-4"}):o.jsx("div",{className:"text-[10px] font-bold",children:w.indexOf(j)+1})}),o.jsx("span",{className:ge("text-sm font-medium transition-colors",_?"text-foreground":"text-muted-foreground"),children:j.label})]},j.key)})})}),o.jsxs("div",{className:"mt-auto pt-6 border-t flex items-center justify-between",children:[o.jsxs("span",{className:"text-[10px] font-bold text-muted-foreground/50 uppercase tracking-widest",children:["Version ",ha]}),o.jsx(Pt,{variant:"outline",className:"text-[10px] py-0 h-4",children:"Production"})]})]}),o.jsx("main",{className:"flex-1 p-12 bg-background relative flex flex-col",children:o.jsxs("div",{className:"max-w-[700px] w-full mx-auto flex-1",children:[r.step==="welcome"&&o.jsx(f5,{onNext:()=>l({type:"SET_STEP",payload:"type"})}),r.step==="type"&&o.jsx(h5,{onManaged:()=>{l({type:"RESET_MANUAL_FLOW"}),l({type:"SET_STEP",payload:"managed-token"})},onManual:()=>{l({type:"RESET_MANAGED_FLOW"}),l({type:"SET_STEP",payload:"credentials"})},onBack:()=>l({type:"SET_STEP",payload:"welcome"})}),r.step==="managed-token"&&o.jsx(c5,{accessToken:r.managed.accessToken,error:r.error,isFetching:r.managed.isFetchingOrgs,onTokenChange:j=>l({type:"SET_ACCESS_TOKEN",payload:j}),onFetchOrgs:m,onBack:()=>l({type:"SET_STEP",payload:"type"})}),r.step==="managed-org"&&o.jsx(l5,{organizations:r.managed.organizations,selectedOrg:r.managed.selectedOrg,projectName:r.managed.projectName,region:r.managed.region,onOrgSelect:j=>l({type:"SET_SELECTED_ORG",payload:j}),onProjectNameChange:j=>l({type:"SET_PROJECT_NAME",payload:j}),onRegionChange:j=>l({type:"SET_REGION",payload:j}),onProvision:y,onBack:()=>l({type:"SET_STEP",payload:"managed-token"})}),r.step==="provisioning"&&o.jsx(d5,{logs:r.logs,error:r.error,onRetry:()=>l({type:"SET_STEP",payload:"managed-token"})}),r.step==="credentials"&&o.jsx(r5,{url:r.manual.url,anonKey:r.manual.anonKey,error:r.error,onUrlChange:j=>l({type:"SET_MANUAL_URL",payload:j}),onAnonKeyChange:j=>l({type:"SET_MANUAL_ANON_KEY",payload:j}),onSave:x,onBack:()=>l({type:"SET_STEP",payload:"type"})}),r.step==="validating"&&o.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center space-y-4 animate-in fade-in zoom-in-95 duration-500",children:[o.jsx("div",{className:"w-12 h-12 rounded-full border-4 border-primary border-t-transparent animate-spin"}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("h2",{className:"text-xl font-bold",children:"Validating Credentials"}),o.jsx("p",{className:"text-muted-foreground text-sm",children:"Please wait while Folio verifies your Supabase configuration."})]})]}),r.step==="migration"&&o.jsx(u5,{logs:r.logs,error:r.error,isMigrating:r.isMigrating,migrationStatus:r.migrationStatus,accessToken:r.managed.accessToken,onTokenChange:j=>l({type:"SET_ACCESS_TOKEN",payload:j}),onRunMigration:()=>g(),onBypass:h})]})})]})})]})}const Xm=v.createContext({});function Wm(t){const e=v.useRef(null);return e.current===null&&(e.current=t()),e.current}const U1=typeof window<"u",B1=U1?v.useLayoutEffect:v.useEffect,Du=v.createContext(null);function Jm(t,e){t.indexOf(e)===-1&&t.push(e)}function pu(t,e){const s=t.indexOf(e);s>-1&&t.splice(s,1)}const ls=(t,e,s)=>s>e?e:s<t?t:s;let Qm=()=>{};const As={},V1=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function I1(t){return typeof t=="object"&&t!==null}const $1=t=>/^0[^.\s]+$/u.test(t);function q1(t){let e;return()=>(e===void 0&&(e=t()),e)}const Ln=t=>t,p5=(t,e)=>s=>e(t(s)),sl=(...t)=>t.reduce(p5),Go=(t,e,s)=>{const r=e-t;return r===0?1:(s-t)/r};class Zm{constructor(){this.subscriptions=[]}add(e){return Jm(this.subscriptions,e),()=>pu(this.subscriptions,e)}notify(e,s,r){const l=this.subscriptions.length;if(l)if(l===1)this.subscriptions[0](e,s,r);else for(let u=0;u<l;u++){const d=this.subscriptions[u];d&&d(e,s,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Fn=t=>t*1e3,Pn=t=>t/1e3;function H1(t,e){return e?t*(1e3/e):0}const G1=(t,e,s)=>(((1-3*s+3*e)*t+(3*s-6*e))*t+3*e)*t,g5=1e-7,y5=12;function v5(t,e,s,r,l){let u,d,h=0;do d=e+(s-e)/2,u=G1(d,r,l)-t,u>0?s=d:e=d;while(Math.abs(u)>g5&&++h<y5);return d}function al(t,e,s,r){if(t===e&&s===r)return Ln;const l=u=>v5(u,0,1,t,s);return u=>u===0||u===1?u:G1(l(u),e,r)}const F1=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,K1=t=>e=>1-t(1-e),Y1=al(.33,1.53,.69,.99),ep=K1(Y1),X1=F1(ep),W1=t=>(t*=2)<1?.5*ep(t):.5*(2-Math.pow(2,-10*(t-1))),tp=t=>1-Math.sin(Math.acos(t)),J1=K1(tp),Q1=F1(tp),x5=al(.42,0,1,1),b5=al(0,0,.58,1),Z1=al(.42,0,.58,1),w5=t=>Array.isArray(t)&&typeof t[0]!="number",eS=t=>Array.isArray(t)&&typeof t[0]=="number",S5={linear:Ln,easeIn:x5,easeInOut:Z1,easeOut:b5,circIn:tp,circInOut:Q1,circOut:J1,backIn:ep,backInOut:X1,backOut:Y1,anticipate:W1},j5=t=>typeof t=="string",M0=t=>{if(eS(t)){Qm(t.length===4);const[e,s,r,l]=t;return al(e,s,r,l)}else if(j5(t))return S5[t];return t},$c=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function _5(t,e){let s=new Set,r=new Set,l=!1,u=!1;const d=new WeakSet;let h={delta:0,timestamp:0,isProcessing:!1};function m(y){d.has(y)&&(g.schedule(y),t()),y(h)}const g={schedule:(y,x=!1,w=!1)=>{const E=w&&l?s:r;return x&&d.add(y),E.has(y)||E.add(y),y},cancel:y=>{r.delete(y),d.delete(y)},process:y=>{if(h=y,l){u=!0;return}l=!0,[s,r]=[r,s],s.forEach(m),s.clear(),l=!1,u&&(u=!1,g.process(y))}};return g}const N5=40;function tS(t,e){let s=!1,r=!0;const l={delta:0,timestamp:0,isProcessing:!1},u=()=>s=!0,d=$c.reduce((C,A)=>(C[A]=_5(u),C),{}),{setup:h,read:m,resolveKeyframes:g,preUpdate:y,update:x,preRender:w,render:S,postRender:E}=d,j=()=>{const C=As.useManualTiming?l.timestamp:performance.now();s=!1,As.useManualTiming||(l.delta=r?1e3/60:Math.max(Math.min(C-l.timestamp,N5),1)),l.timestamp=C,l.isProcessing=!0,h.process(l),m.process(l),g.process(l),y.process(l),x.process(l),w.process(l),S.process(l),E.process(l),l.isProcessing=!1,s&&e&&(r=!1,t(j))},_=()=>{s=!0,r=!0,l.isProcessing||t(j)};return{schedule:$c.reduce((C,A)=>{const D=d[A];return C[A]=(U,V=!1,R=!1)=>(s||_(),D.schedule(U,V,R)),C},{}),cancel:C=>{for(let A=0;A<$c.length;A++)d[$c[A]].cancel(C)},state:l,steps:d}}const{schedule:lt,cancel:pa,state:Ft,steps:jf}=tS(typeof requestAnimationFrame<"u"?requestAnimationFrame:Ln,!0);let Wc;function T5(){Wc=void 0}const Jt={now:()=>(Wc===void 0&&Jt.set(Ft.isProcessing||As.useManualTiming?Ft.timestamp:performance.now()),Wc),set:t=>{Wc=t,queueMicrotask(T5)}},nS=t=>e=>typeof e=="string"&&e.startsWith(t),sS=nS("--"),E5=nS("var(--"),np=t=>E5(t)?k5.test(t.split("/*")[0].trim()):!1,k5=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function D0(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const yi={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Fo={...yi,transform:t=>ls(0,1,t)},qc={...yi,default:1},Eo=t=>Math.round(t*1e5)/1e5,sp=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function C5(t){return t==null}const A5=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,ap=(t,e)=>s=>!!(typeof s=="string"&&A5.test(s)&&s.startsWith(t)||e&&!C5(s)&&Object.prototype.hasOwnProperty.call(s,e)),aS=(t,e,s)=>r=>{if(typeof r!="string")return r;const[l,u,d,h]=r.match(sp);return{[t]:parseFloat(l),[e]:parseFloat(u),[s]:parseFloat(d),alpha:h!==void 0?parseFloat(h):1}},R5=t=>ls(0,255,t),_f={...yi,transform:t=>Math.round(R5(t))},Ka={test:ap("rgb","red"),parse:aS("red","green","blue"),transform:({red:t,green:e,blue:s,alpha:r=1})=>"rgba("+_f.transform(t)+", "+_f.transform(e)+", "+_f.transform(s)+", "+Eo(Fo.transform(r))+")"};function O5(t){let e="",s="",r="",l="";return t.length>5?(e=t.substring(1,3),s=t.substring(3,5),r=t.substring(5,7),l=t.substring(7,9)):(e=t.substring(1,2),s=t.substring(2,3),r=t.substring(3,4),l=t.substring(4,5),e+=e,s+=s,r+=r,l+=l),{red:parseInt(e,16),green:parseInt(s,16),blue:parseInt(r,16),alpha:l?parseInt(l,16)/255:1}}const lm={test:ap("#"),parse:O5,transform:Ka.transform},rl=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),la=rl("deg"),is=rl("%"),be=rl("px"),M5=rl("vh"),D5=rl("vw"),P0={...is,parse:t=>is.parse(t)/100,transform:t=>is.transform(t*100)},ni={test:ap("hsl","hue"),parse:aS("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:s,alpha:r=1})=>"hsla("+Math.round(t)+", "+is.transform(Eo(e))+", "+is.transform(Eo(s))+", "+Eo(Fo.transform(r))+")"},Et={test:t=>Ka.test(t)||lm.test(t)||ni.test(t),parse:t=>Ka.test(t)?Ka.parse(t):ni.test(t)?ni.parse(t):lm.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Ka.transform(t):ni.transform(t),getAnimatableNone:t=>{const e=Et.parse(t);return e.alpha=0,Et.transform(e)}},P5=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function z5(t){return isNaN(t)&&typeof t=="string"&&(t.match(sp)?.length||0)+(t.match(P5)?.length||0)>0}const rS="number",iS="color",L5="var",U5="var(",z0="${}",B5=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Ko(t){const e=t.toString(),s=[],r={color:[],number:[],var:[]},l=[];let u=0;const h=e.replace(B5,m=>(Et.test(m)?(r.color.push(u),l.push(iS),s.push(Et.parse(m))):m.startsWith(U5)?(r.var.push(u),l.push(L5),s.push(m)):(r.number.push(u),l.push(rS),s.push(parseFloat(m))),++u,z0)).split(z0);return{values:s,split:h,indexes:r,types:l}}function oS(t){return Ko(t).values}function lS(t){const{split:e,types:s}=Ko(t),r=e.length;return l=>{let u="";for(let d=0;d<r;d++)if(u+=e[d],l[d]!==void 0){const h=s[d];h===rS?u+=Eo(l[d]):h===iS?u+=Et.transform(l[d]):u+=l[d]}return u}}const V5=t=>typeof t=="number"?0:Et.test(t)?Et.getAnimatableNone(t):t;function I5(t){const e=oS(t);return lS(t)(e.map(V5))}const Kn={test:z5,parse:oS,createTransformer:lS,getAnimatableNone:I5};function Nf(t,e,s){return s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+(e-t)*6*s:s<1/2?e:s<2/3?t+(e-t)*(2/3-s)*6:t}function $5({hue:t,saturation:e,lightness:s,alpha:r}){t/=360,e/=100,s/=100;let l=0,u=0,d=0;if(!e)l=u=d=s;else{const h=s<.5?s*(1+e):s+e-s*e,m=2*s-h;l=Nf(m,h,t+1/3),u=Nf(m,h,t),d=Nf(m,h,t-1/3)}return{red:Math.round(l*255),green:Math.round(u*255),blue:Math.round(d*255),alpha:r}}function gu(t,e){return s=>s>0?e:t}const mt=(t,e,s)=>t+(e-t)*s,Tf=(t,e,s)=>{const r=t*t,l=s*(e*e-r)+r;return l<0?0:Math.sqrt(l)},q5=[lm,Ka,ni],H5=t=>q5.find(e=>e.test(t));function L0(t){const e=H5(t);if(!e)return!1;let s=e.parse(t);return e===ni&&(s=$5(s)),s}const U0=(t,e)=>{const s=L0(t),r=L0(e);if(!s||!r)return gu(t,e);const l={...s};return u=>(l.red=Tf(s.red,r.red,u),l.green=Tf(s.green,r.green,u),l.blue=Tf(s.blue,r.blue,u),l.alpha=mt(s.alpha,r.alpha,u),Ka.transform(l))},cm=new Set(["none","hidden"]);function G5(t,e){return cm.has(t)?s=>s<=0?t:e:s=>s>=1?e:t}function F5(t,e){return s=>mt(t,e,s)}function rp(t){return typeof t=="number"?F5:typeof t=="string"?np(t)?gu:Et.test(t)?U0:X5:Array.isArray(t)?cS:typeof t=="object"?Et.test(t)?U0:K5:gu}function cS(t,e){const s=[...t],r=s.length,l=t.map((u,d)=>rp(u)(u,e[d]));return u=>{for(let d=0;d<r;d++)s[d]=l[d](u);return s}}function K5(t,e){const s={...t,...e},r={};for(const l in s)t[l]!==void 0&&e[l]!==void 0&&(r[l]=rp(t[l])(t[l],e[l]));return l=>{for(const u in r)s[u]=r[u](l);return s}}function Y5(t,e){const s=[],r={color:0,var:0,number:0};for(let l=0;l<e.values.length;l++){const u=e.types[l],d=t.indexes[u][r[u]],h=t.values[d]??0;s[l]=h,r[u]++}return s}const X5=(t,e)=>{const s=Kn.createTransformer(e),r=Ko(t),l=Ko(e);return r.indexes.var.length===l.indexes.var.length&&r.indexes.color.length===l.indexes.color.length&&r.indexes.number.length>=l.indexes.number.length?cm.has(t)&&!l.values.length||cm.has(e)&&!r.values.length?G5(t,e):sl(cS(Y5(r,l),l.values),s):gu(t,e)};function uS(t,e,s){return typeof t=="number"&&typeof e=="number"&&typeof s=="number"?mt(t,e,s):rp(t)(t,e)}const W5=t=>{const e=({timestamp:s})=>t(s);return{start:(s=!0)=>lt.update(e,s),stop:()=>pa(e),now:()=>Ft.isProcessing?Ft.timestamp:Jt.now()}},dS=(t,e,s=10)=>{let r="";const l=Math.max(Math.round(e/s),2);for(let u=0;u<l;u++)r+=Math.round(t(u/(l-1))*1e4)/1e4+", ";return`linear(${r.substring(0,r.length-2)})`},yu=2e4;function ip(t){let e=0;const s=50;let r=t.next(e);for(;!r.done&&e<yu;)e+=s,r=t.next(e);return e>=yu?1/0:e}function J5(t,e=100,s){const r=s({...t,keyframes:[0,e]}),l=Math.min(ip(r),yu);return{type:"keyframes",ease:u=>r.next(l*u).value/e,duration:Pn(l)}}const Q5=5;function hS(t,e,s){const r=Math.max(e-Q5,0);return H1(s-t(r),e-r)}const vt={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},Ef=.001;function Z5({duration:t=vt.duration,bounce:e=vt.bounce,velocity:s=vt.velocity,mass:r=vt.mass}){let l,u,d=1-e;d=ls(vt.minDamping,vt.maxDamping,d),t=ls(vt.minDuration,vt.maxDuration,Pn(t)),d<1?(l=g=>{const y=g*d,x=y*t,w=y-s,S=um(g,d),E=Math.exp(-x);return Ef-w/S*E},u=g=>{const x=g*d*t,w=x*s+s,S=Math.pow(d,2)*Math.pow(g,2)*t,E=Math.exp(-x),j=um(Math.pow(g,2),d);return(-l(g)+Ef>0?-1:1)*((w-S)*E)/j}):(l=g=>{const y=Math.exp(-g*t),x=(g-s)*t+1;return-Ef+y*x},u=g=>{const y=Math.exp(-g*t),x=(s-g)*(t*t);return y*x});const h=5/t,m=t4(l,u,h);if(t=Fn(t),isNaN(m))return{stiffness:vt.stiffness,damping:vt.damping,duration:t};{const g=Math.pow(m,2)*r;return{stiffness:g,damping:d*2*Math.sqrt(r*g),duration:t}}}const e4=12;function t4(t,e,s){let r=s;for(let l=1;l<e4;l++)r=r-t(r)/e(r);return r}function um(t,e){return t*Math.sqrt(1-e*e)}const n4=["duration","bounce"],s4=["stiffness","damping","mass"];function B0(t,e){return e.some(s=>t[s]!==void 0)}function a4(t){let e={velocity:vt.velocity,stiffness:vt.stiffness,damping:vt.damping,mass:vt.mass,isResolvedFromDuration:!1,...t};if(!B0(t,s4)&&B0(t,n4))if(e.velocity=0,t.visualDuration){const s=t.visualDuration,r=2*Math.PI/(s*1.2),l=r*r,u=2*ls(.05,1,1-(t.bounce||0))*Math.sqrt(l);e={...e,mass:vt.mass,stiffness:l,damping:u}}else{const s=Z5({...t,velocity:0});e={...e,...s,mass:vt.mass},e.isResolvedFromDuration=!0}return e}function vu(t=vt.visualDuration,e=vt.bounce){const s=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:r,restDelta:l}=s;const u=s.keyframes[0],d=s.keyframes[s.keyframes.length-1],h={done:!1,value:u},{stiffness:m,damping:g,mass:y,duration:x,velocity:w,isResolvedFromDuration:S}=a4({...s,velocity:-Pn(s.velocity||0)}),E=w||0,j=g/(2*Math.sqrt(m*y)),_=d-u,N=Pn(Math.sqrt(m/y)),k=Math.abs(_)<5;r||(r=k?vt.restSpeed.granular:vt.restSpeed.default),l||(l=k?vt.restDelta.granular:vt.restDelta.default);let C;if(j<1){const D=um(N,j);C=U=>{const V=Math.exp(-j*N*U);return d-V*((E+j*N*_)/D*Math.sin(D*U)+_*Math.cos(D*U))}}else if(j===1)C=D=>d-Math.exp(-N*D)*(_+(E+N*_)*D);else{const D=N*Math.sqrt(j*j-1);C=U=>{const V=Math.exp(-j*N*U),R=Math.min(D*U,300);return d-V*((E+j*N*_)*Math.sinh(R)+D*_*Math.cosh(R))/D}}const A={calculatedDuration:S&&x||null,next:D=>{const U=C(D);if(S)h.done=D>=x;else{let V=D===0?E:0;j<1&&(V=D===0?Fn(E):hS(C,D,U));const R=Math.abs(V)<=r,P=Math.abs(d-U)<=l;h.done=R&&P}return h.value=h.done?d:U,h},toString:()=>{const D=Math.min(ip(A),yu),U=dS(V=>A.next(D*V).value,D,30);return D+"ms "+U},toTransition:()=>{}};return A}vu.applyToOptions=t=>{const e=J5(t,100,vu);return t.ease=e.ease,t.duration=Fn(e.duration),t.type="keyframes",t};function dm({keyframes:t,velocity:e=0,power:s=.8,timeConstant:r=325,bounceDamping:l=10,bounceStiffness:u=500,modifyTarget:d,min:h,max:m,restDelta:g=.5,restSpeed:y}){const x=t[0],w={done:!1,value:x},S=R=>h!==void 0&&R<h||m!==void 0&&R>m,E=R=>h===void 0?m:m===void 0||Math.abs(h-R)<Math.abs(m-R)?h:m;let j=s*e;const _=x+j,N=d===void 0?_:d(_);N!==_&&(j=N-x);const k=R=>-j*Math.exp(-R/r),C=R=>N+k(R),A=R=>{const P=k(R),Z=C(R);w.done=Math.abs(P)<=g,w.value=w.done?N:Z};let D,U;const V=R=>{S(w.value)&&(D=R,U=vu({keyframes:[w.value,E(w.value)],velocity:hS(C,R,w.value),damping:l,stiffness:u,restDelta:g,restSpeed:y}))};return V(0),{calculatedDuration:null,next:R=>{let P=!1;return!U&&D===void 0&&(P=!0,A(R),V(R)),D!==void 0&&R>=D?U.next(R-D):(!P&&A(R),w)}}}function r4(t,e,s){const r=[],l=s||As.mix||uS,u=t.length-1;for(let d=0;d<u;d++){let h=l(t[d],t[d+1]);if(e){const m=Array.isArray(e)?e[d]||Ln:e;h=sl(m,h)}r.push(h)}return r}function i4(t,e,{clamp:s=!0,ease:r,mixer:l}={}){const u=t.length;if(Qm(u===e.length),u===1)return()=>e[0];if(u===2&&e[0]===e[1])return()=>e[1];const d=t[0]===t[1];t[0]>t[u-1]&&(t=[...t].reverse(),e=[...e].reverse());const h=r4(e,r,l),m=h.length,g=y=>{if(d&&y<t[0])return e[0];let x=0;if(m>1)for(;x<t.length-2&&!(y<t[x+1]);x++);const w=Go(t[x],t[x+1],y);return h[x](w)};return s?y=>g(ls(t[0],t[u-1],y)):g}function o4(t,e){const s=t[t.length-1];for(let r=1;r<=e;r++){const l=Go(0,e,r);t.push(mt(s,1,l))}}function l4(t){const e=[0];return o4(e,t.length-1),e}function c4(t,e){return t.map(s=>s*e)}function u4(t,e){return t.map(()=>e||Z1).splice(0,t.length-1)}function ko({duration:t=300,keyframes:e,times:s,ease:r="easeInOut"}){const l=w5(r)?r.map(M0):M0(r),u={done:!1,value:e[0]},d=c4(s&&s.length===e.length?s:l4(e),t),h=i4(d,e,{ease:Array.isArray(l)?l:u4(e,l)});return{calculatedDuration:t,next:m=>(u.value=h(m),u.done=m>=t,u)}}const d4=t=>t!==null;function op(t,{repeat:e,repeatType:s="loop"},r,l=1){const u=t.filter(d4),h=l<0||e&&s!=="loop"&&e%2===1?0:u.length-1;return!h||r===void 0?u[h]:r}const h4={decay:dm,inertia:dm,tween:ko,keyframes:ko,spring:vu};function fS(t){typeof t.type=="string"&&(t.type=h4[t.type])}class lp{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,s){return this.finished.then(e,s)}}const f4=t=>t/100;class cp extends lp{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:s}=this.options;s&&s.updatedAt!==Jt.now()&&this.tick(Jt.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;fS(e);const{type:s=ko,repeat:r=0,repeatDelay:l=0,repeatType:u,velocity:d=0}=e;let{keyframes:h}=e;const m=s||ko;m!==ko&&typeof h[0]!="number"&&(this.mixKeyframes=sl(f4,uS(h[0],h[1])),h=[0,100]);const g=m({...e,keyframes:h});u==="mirror"&&(this.mirroredGenerator=m({...e,keyframes:[...h].reverse(),velocity:-d})),g.calculatedDuration===null&&(g.calculatedDuration=ip(g));const{calculatedDuration:y}=g;this.calculatedDuration=y,this.resolvedDuration=y+l,this.totalDuration=this.resolvedDuration*(r+1)-l,this.generator=g}updateTime(e){const s=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=s}tick(e,s=!1){const{generator:r,totalDuration:l,mixKeyframes:u,mirroredGenerator:d,resolvedDuration:h,calculatedDuration:m}=this;if(this.startTime===null)return r.next(0);const{delay:g=0,keyframes:y,repeat:x,repeatType:w,repeatDelay:S,type:E,onUpdate:j,finalKeyframe:_}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-l/this.speed,this.startTime)),s?this.currentTime=e:this.updateTime(e);const N=this.currentTime-g*(this.playbackSpeed>=0?1:-1),k=this.playbackSpeed>=0?N<0:N>l;this.currentTime=Math.max(N,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=l);let C=this.currentTime,A=r;if(x){const R=Math.min(this.currentTime,l)/h;let P=Math.floor(R),Z=R%1;!Z&&R>=1&&(Z=1),Z===1&&P--,P=Math.min(P,x+1),P%2&&(w==="reverse"?(Z=1-Z,S&&(Z-=S/h)):w==="mirror"&&(A=d)),C=ls(0,1,Z)*h}const D=k?{done:!1,value:y[0]}:A.next(C);u&&(D.value=u(D.value));let{done:U}=D;!k&&m!==null&&(U=this.playbackSpeed>=0?this.currentTime>=l:this.currentTime<=0);const V=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&U);return V&&E!==dm&&(D.value=op(y,this.options,_,this.speed)),j&&j(D.value),V&&this.finish(),D}then(e,s){return this.finished.then(e,s)}get duration(){return Pn(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+Pn(e)}get time(){return Pn(this.currentTime)}set time(e){e=Fn(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(Jt.now());const s=this.playbackSpeed!==e;this.playbackSpeed=e,s&&(this.time=Pn(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=W5,startTime:s}=this.options;this.driver||(this.driver=e(l=>this.tick(l))),this.options.onPlay?.();const r=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=r):this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime||(this.startTime=s??r),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Jt.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function m4(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const Ya=t=>t*180/Math.PI,hm=t=>{const e=Ya(Math.atan2(t[1],t[0]));return fm(e)},p4={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:hm,rotateZ:hm,skewX:t=>Ya(Math.atan(t[1])),skewY:t=>Ya(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},fm=t=>(t=t%360,t<0&&(t+=360),t),V0=hm,I0=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),$0=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),g4={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:I0,scaleY:$0,scale:t=>(I0(t)+$0(t))/2,rotateX:t=>fm(Ya(Math.atan2(t[6],t[5]))),rotateY:t=>fm(Ya(Math.atan2(-t[2],t[0]))),rotateZ:V0,rotate:V0,skewX:t=>Ya(Math.atan(t[4])),skewY:t=>Ya(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function mm(t){return t.includes("scale")?1:0}function pm(t,e){if(!t||t==="none")return mm(e);const s=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,l;if(s)r=g4,l=s;else{const h=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=p4,l=h}if(!l)return mm(e);const u=r[e],d=l[1].split(",").map(v4);return typeof u=="function"?u(d):d[u]}const y4=(t,e)=>{const{transform:s="none"}=getComputedStyle(t);return pm(s,e)};function v4(t){return parseFloat(t.trim())}const vi=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],xi=new Set(vi),q0=t=>t===yi||t===be,x4=new Set(["x","y","z"]),b4=vi.filter(t=>!x4.has(t));function w4(t){const e=[];return b4.forEach(s=>{const r=t.getValue(s);r!==void 0&&(e.push([s,r.get()]),r.set(s.startsWith("scale")?1:0))}),e}const da={width:({x:t},{paddingLeft:e="0",paddingRight:s="0"})=>t.max-t.min-parseFloat(e)-parseFloat(s),height:({y:t},{paddingTop:e="0",paddingBottom:s="0"})=>t.max-t.min-parseFloat(e)-parseFloat(s),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>pm(e,"x"),y:(t,{transform:e})=>pm(e,"y")};da.translateX=da.x;da.translateY=da.y;const Ja=new Set;let gm=!1,ym=!1,vm=!1;function mS(){if(ym){const t=Array.from(Ja).filter(r=>r.needsMeasurement),e=new Set(t.map(r=>r.element)),s=new Map;e.forEach(r=>{const l=w4(r);l.length&&(s.set(r,l),r.render())}),t.forEach(r=>r.measureInitialState()),e.forEach(r=>{r.render();const l=s.get(r);l&&l.forEach(([u,d])=>{r.getValue(u)?.set(d)})}),t.forEach(r=>r.measureEndState()),t.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}ym=!1,gm=!1,Ja.forEach(t=>t.complete(vm)),Ja.clear()}function pS(){Ja.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(ym=!0)})}function S4(){vm=!0,pS(),mS(),vm=!1}class up{constructor(e,s,r,l,u,d=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=s,this.name=r,this.motionValue=l,this.element=u,this.isAsync=d}scheduleResolve(){this.state="scheduled",this.isAsync?(Ja.add(this),gm||(gm=!0,lt.read(pS),lt.resolveKeyframes(mS))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:s,element:r,motionValue:l}=this;if(e[0]===null){const u=l?.get(),d=e[e.length-1];if(u!==void 0)e[0]=u;else if(r&&s){const h=r.readValue(s,d);h!=null&&(e[0]=h)}e[0]===void 0&&(e[0]=d),l&&u===void 0&&l.set(e[0])}m4(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Ja.delete(this)}cancel(){this.state==="scheduled"&&(Ja.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const j4=t=>t.startsWith("--");function _4(t,e,s){j4(e)?t.style.setProperty(e,s):t.style[e]=s}const N4={};function gS(t,e){const s=q1(t);return()=>N4[e]??s()}const T4=gS(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),yS=gS(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),So=([t,e,s,r])=>`cubic-bezier(${t}, ${e}, ${s}, ${r})`,H0={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:So([0,.65,.55,1]),circOut:So([.55,0,1,.45]),backIn:So([.31,.01,.66,-.59]),backOut:So([.33,1.53,.69,.99])};function vS(t,e){if(t)return typeof t=="function"?yS()?dS(t,e):"ease-out":eS(t)?So(t):Array.isArray(t)?t.map(s=>vS(s,e)||H0.easeOut):H0[t]}function E4(t,e,s,{delay:r=0,duration:l=300,repeat:u=0,repeatType:d="loop",ease:h="easeOut",times:m}={},g=void 0){const y={[e]:s};m&&(y.offset=m);const x=vS(h,l);Array.isArray(x)&&(y.easing=x);const w={delay:r,duration:l,easing:Array.isArray(x)?"linear":x,fill:"both",iterations:u+1,direction:d==="reverse"?"alternate":"normal"};return g&&(w.pseudoElement=g),t.animate(y,w)}function xS(t){return typeof t=="function"&&"applyToOptions"in t}function k4({type:t,...e}){return xS(t)&&yS()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class bS extends lp{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;const{element:s,name:r,keyframes:l,pseudoElement:u,allowFlatten:d=!1,finalKeyframe:h,onComplete:m}=e;this.isPseudoElement=!!u,this.allowFlatten=d,this.options=e,Qm(typeof e.type!="string");const g=k4(e);this.animation=E4(s,r,l,g,u),g.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!u){const y=op(l,this.options,h,this.speed);this.updateMotionValue?this.updateMotionValue(y):_4(s,r,y),this.animation.cancel()}m?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){const e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return Pn(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+Pn(e)}get time(){return Pn(Number(this.animation.currentTime)||0)}set time(e){this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Fn(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,observe:s}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&T4()?(this.animation.timeline=e,Ln):s(this)}}const wS={anticipate:W1,backInOut:X1,circInOut:Q1};function C4(t){return t in wS}function A4(t){typeof t.ease=="string"&&C4(t.ease)&&(t.ease=wS[t.ease])}const kf=10;class R4 extends bS{constructor(e){A4(e),fS(e),super(e),e.startTime!==void 0&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:s,onUpdate:r,onComplete:l,element:u,...d}=this.options;if(!s)return;if(e!==void 0){s.set(e);return}const h=new cp({...d,autoplay:!1}),m=Math.max(kf,Jt.now()-this.startTime),g=ls(0,kf,m-kf);s.setWithVelocity(h.sample(Math.max(0,m-g)).value,h.sample(m).value,g),h.stop()}}const G0=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Kn.test(t)||t==="0")&&!t.startsWith("url("));function O4(t){const e=t[0];if(t.length===1)return!0;for(let s=0;s<t.length;s++)if(t[s]!==e)return!0}function M4(t,e,s,r){const l=t[0];if(l===null)return!1;if(e==="display"||e==="visibility")return!0;const u=t[t.length-1],d=G0(l,e),h=G0(u,e);return!d||!h?!1:O4(t)||(s==="spring"||xS(s))&&r}function xm(t){t.duration=0,t.type="keyframes"}const D4=new Set(["opacity","clipPath","filter","transform"]),P4=q1(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function z4(t){const{motionValue:e,name:s,repeatDelay:r,repeatType:l,damping:u,type:d}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:m,transformTemplate:g}=e.owner.getProps();return P4()&&s&&D4.has(s)&&(s!=="transform"||!g)&&!m&&!r&&l!=="mirror"&&u!==0&&d!=="inertia"}const L4=40;class U4 extends lp{constructor({autoplay:e=!0,delay:s=0,type:r="keyframes",repeat:l=0,repeatDelay:u=0,repeatType:d="loop",keyframes:h,name:m,motionValue:g,element:y,...x}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Jt.now();const w={autoplay:e,delay:s,type:r,repeat:l,repeatDelay:u,repeatType:d,name:m,motionValue:g,element:y,...x},S=y?.KeyframeResolver||up;this.keyframeResolver=new S(h,(E,j,_)=>this.onKeyframesResolved(E,j,w,!_),m,g,y),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,s,r,l){this.keyframeResolver=void 0;const{name:u,type:d,velocity:h,delay:m,isHandoff:g,onUpdate:y}=r;this.resolvedAt=Jt.now(),M4(e,u,d,h)||((As.instantAnimations||!m)&&y?.(op(e,r,s)),e[0]=e[e.length-1],xm(r),r.repeat=0);const w={startTime:l?this.resolvedAt?this.resolvedAt-this.createdAt>L4?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:s,...r,keyframes:e},S=!g&&z4(w),E=w.motionValue?.owner?.current,j=S?new R4({...w,element:E}):new cp(w);j.finished.then(()=>{this.notifyFinished()}).catch(Ln),this.pendingTimeline&&(this.stopTimeline=j.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=j}get finished(){return this._animation?this.animation.finished:this._finished}then(e,s){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),S4()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}function SS(t,e,s,r=0,l=1){const u=Array.from(t).sort((g,y)=>g.sortNodePosition(y)).indexOf(e),d=t.size,h=(d-1)*r;return typeof s=="function"?s(u,d):l===1?u*r:h-u*r}const B4=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function V4(t){const e=B4.exec(t);if(!e)return[,];const[,s,r,l]=e;return[`--${s??r}`,l]}function jS(t,e,s=1){const[r,l]=V4(t);if(!r)return;const u=window.getComputedStyle(e).getPropertyValue(r);if(u){const d=u.trim();return V1(d)?parseFloat(d):d}return np(l)?jS(l,e,s+1):l}const I4={type:"spring",stiffness:500,damping:25,restSpeed:10},$4=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),q4={type:"keyframes",duration:.8},H4={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},G4=(t,{keyframes:e})=>e.length>2?q4:xi.has(t)?t.startsWith("scale")?$4(e[1]):I4:H4,F4=t=>t!==null;function K4(t,{repeat:e,repeatType:s="loop"},r){const l=t.filter(F4),u=e&&s!=="loop"&&e%2===1?0:l.length-1;return l[u]}function _S(t,e){if(t?.inherit&&e){const{inherit:s,...r}=t;return{...e,...r}}return t}function dp(t,e){const s=t?.[e]??t?.default??t;return s!==t?_S(s,t):s}function Y4({when:t,delay:e,delayChildren:s,staggerChildren:r,staggerDirection:l,repeat:u,repeatType:d,repeatDelay:h,from:m,elapsed:g,...y}){return!!Object.keys(y).length}const hp=(t,e,s,r={},l,u)=>d=>{const h=dp(r,t)||{},m=h.delay||r.delay||0;let{elapsed:g=0}=r;g=g-Fn(m);const y={keyframes:Array.isArray(s)?s:[null,s],ease:"easeOut",velocity:e.getVelocity(),...h,delay:-g,onUpdate:w=>{e.set(w),h.onUpdate&&h.onUpdate(w)},onComplete:()=>{d(),h.onComplete&&h.onComplete()},name:t,motionValue:e,element:u?void 0:l};Y4(h)||Object.assign(y,G4(t,y)),y.duration&&(y.duration=Fn(y.duration)),y.repeatDelay&&(y.repeatDelay=Fn(y.repeatDelay)),y.from!==void 0&&(y.keyframes[0]=y.from);let x=!1;if((y.type===!1||y.duration===0&&!y.repeatDelay)&&(xm(y),y.delay===0&&(x=!0)),(As.instantAnimations||As.skipAnimations||l?.shouldSkipAnimations)&&(x=!0,xm(y),y.delay=0),y.allowFlatten=!h.type&&!h.ease,x&&!u&&e.get()!==void 0){const w=K4(y.keyframes,h);if(w!==void 0){lt.update(()=>{y.onUpdate(w),y.onComplete()});return}}return h.isSync?new cp(y):new U4(y)};function F0(t){const e=[{},{}];return t?.values.forEach((s,r)=>{e[0][r]=s.get(),e[1][r]=s.getVelocity()}),e}function fp(t,e,s,r){if(typeof e=="function"){const[l,u]=F0(r);e=e(s!==void 0?s:t.custom,l,u)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[l,u]=F0(r);e=e(s!==void 0?s:t.custom,l,u)}return e}function ci(t,e,s){const r=t.getProps();return fp(r,e,s!==void 0?s:r.custom,t)}const NS=new Set(["width","height","top","left","right","bottom",...vi]),K0=30,X4=t=>!isNaN(parseFloat(t));class W4{constructor(e,s={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=r=>{const l=Jt.now();if(this.updatedAt!==l&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const u of this.dependents)u.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=s.owner}setCurrent(e){this.current=e,this.updatedAt=Jt.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=X4(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,s){this.events[e]||(this.events[e]=new Zm);const r=this.events[e].add(s);return e==="change"?()=>{r(),lt.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,s){this.passiveEffect=e,this.stopPassiveEffect=s}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,s,r){this.set(s),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-r}jump(e,s=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,s&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=Jt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>K0)return 0;const s=Math.min(this.updatedAt-this.prevUpdatedAt,K0);return H1(parseFloat(this.current)-parseFloat(this.prevFrameValue),s)}start(e){return this.stop(),new Promise(s=>{this.hasAnimated=!0,this.animation=e(s),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function mi(t,e){return new W4(t,e)}const bm=t=>Array.isArray(t);function J4(t,e,s){t.hasValue(e)?t.getValue(e).set(s):t.addValue(e,mi(s))}function Q4(t){return bm(t)?t[t.length-1]||0:t}function Z4(t,e){const s=ci(t,e);let{transitionEnd:r={},transition:l={},...u}=s||{};u={...u,...r};for(const d in u){const h=Q4(u[d]);J4(t,d,h)}}const Xt=t=>!!(t&&t.getVelocity);function eM(t){return!!(Xt(t)&&t.add)}function wm(t,e){const s=t.getValue("willChange");if(eM(s))return s.add(e);if(!s&&As.WillChange){const r=new As.WillChange("auto");t.addValue("willChange",r),r.add(e)}}function mp(t){return t.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}const tM="framerAppearId",TS="data-"+mp(tM);function ES(t){return t.props[TS]}function nM({protectedKeys:t,needsAnimating:e},s){const r=t.hasOwnProperty(s)&&e[s]!==!0;return e[s]=!1,r}function kS(t,e,{delay:s=0,transitionOverride:r,type:l}={}){let{transition:u,transitionEnd:d,...h}=e;const m=t.getDefaultTransition();u=u?_S(u,m):m;const g=u?.reduceMotion;r&&(u=r);const y=[],x=l&&t.animationState&&t.animationState.getState()[l];for(const w in h){const S=t.getValue(w,t.latestValues[w]??null),E=h[w];if(E===void 0||x&&nM(x,w))continue;const j={delay:s,...dp(u||{},w)},_=S.get();if(_!==void 0&&!S.isAnimating&&!Array.isArray(E)&&E===_&&!j.velocity)continue;let N=!1;if(window.MotionHandoffAnimation){const A=ES(t);if(A){const D=window.MotionHandoffAnimation(A,w,lt);D!==null&&(j.startTime=D,N=!0)}}wm(t,w);const k=g??t.shouldReduceMotion;S.start(hp(w,S,E,k&&NS.has(w)?{type:!1}:j,t,N));const C=S.animation;C&&y.push(C)}if(d){const w=()=>lt.update(()=>{d&&Z4(t,d)});y.length?Promise.all(y).then(w):w()}return y}function Sm(t,e,s={}){const r=ci(t,e,s.type==="exit"?t.presenceContext?.custom:void 0);let{transition:l=t.getDefaultTransition()||{}}=r||{};s.transitionOverride&&(l=s.transitionOverride);const u=r?()=>Promise.all(kS(t,r,s)):()=>Promise.resolve(),d=t.variantChildren&&t.variantChildren.size?(m=0)=>{const{delayChildren:g=0,staggerChildren:y,staggerDirection:x}=l;return sM(t,e,m,g,y,x,s)}:()=>Promise.resolve(),{when:h}=l;if(h){const[m,g]=h==="beforeChildren"?[u,d]:[d,u];return m().then(()=>g())}else return Promise.all([u(),d(s.delay)])}function sM(t,e,s=0,r=0,l=0,u=1,d){const h=[];for(const m of t.variantChildren)m.notify("AnimationStart",e),h.push(Sm(m,e,{...d,delay:s+(typeof r=="function"?0:r)+SS(t.variantChildren,m,r,l,u)}).then(()=>m.notify("AnimationComplete",e)));return Promise.all(h)}function aM(t,e,s={}){t.notify("AnimationStart",e);let r;if(Array.isArray(e)){const l=e.map(u=>Sm(t,u,s));r=Promise.all(l)}else if(typeof e=="string")r=Sm(t,e,s);else{const l=typeof e=="function"?ci(t,e,s.custom):e;r=Promise.all(kS(t,l,s))}return r.then(()=>{t.notify("AnimationComplete",e)})}const rM={test:t=>t==="auto",parse:t=>t},CS=t=>e=>e.test(t),AS=[yi,be,is,la,D5,M5,rM],Y0=t=>AS.find(CS(t));function iM(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||$1(t):!0}const oM=new Set(["brightness","contrast","saturate","opacity"]);function lM(t){const[e,s]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[r]=s.match(sp)||[];if(!r)return t;const l=s.replace(r,"");let u=oM.has(e)?1:0;return r!==s&&(u*=100),e+"("+u+l+")"}const cM=/\b([a-z-]*)\(.*?\)/gu,jm={...Kn,getAnimatableNone:t=>{const e=t.match(cM);return e?e.map(lM).join(" "):t}},_m={...Kn,getAnimatableNone:t=>{const e=Kn.parse(t);return Kn.createTransformer(t)(e.map(r=>typeof r=="number"?0:typeof r=="object"?{...r,alpha:1}:r))}},X0={...yi,transform:Math.round},uM={rotate:la,rotateX:la,rotateY:la,rotateZ:la,scale:qc,scaleX:qc,scaleY:qc,scaleZ:qc,skew:la,skewX:la,skewY:la,distance:be,translateX:be,translateY:be,translateZ:be,x:be,y:be,z:be,perspective:be,transformPerspective:be,opacity:Fo,originX:P0,originY:P0,originZ:be},pp={borderWidth:be,borderTopWidth:be,borderRightWidth:be,borderBottomWidth:be,borderLeftWidth:be,borderRadius:be,borderTopLeftRadius:be,borderTopRightRadius:be,borderBottomRightRadius:be,borderBottomLeftRadius:be,width:be,maxWidth:be,height:be,maxHeight:be,top:be,right:be,bottom:be,left:be,inset:be,insetBlock:be,insetBlockStart:be,insetBlockEnd:be,insetInline:be,insetInlineStart:be,insetInlineEnd:be,padding:be,paddingTop:be,paddingRight:be,paddingBottom:be,paddingLeft:be,paddingBlock:be,paddingBlockStart:be,paddingBlockEnd:be,paddingInline:be,paddingInlineStart:be,paddingInlineEnd:be,margin:be,marginTop:be,marginRight:be,marginBottom:be,marginLeft:be,marginBlock:be,marginBlockStart:be,marginBlockEnd:be,marginInline:be,marginInlineStart:be,marginInlineEnd:be,fontSize:be,backgroundPositionX:be,backgroundPositionY:be,...uM,zIndex:X0,fillOpacity:Fo,strokeOpacity:Fo,numOctaves:X0},dM={...pp,color:Et,backgroundColor:Et,outlineColor:Et,fill:Et,stroke:Et,borderColor:Et,borderTopColor:Et,borderRightColor:Et,borderBottomColor:Et,borderLeftColor:Et,filter:jm,WebkitFilter:jm,mask:_m,WebkitMask:_m},RS=t=>dM[t],hM=new Set([jm,_m]);function OS(t,e){let s=RS(t);return hM.has(s)||(s=Kn),s.getAnimatableNone?s.getAnimatableNone(e):void 0}const fM=new Set(["auto","none","0"]);function mM(t,e,s){let r=0,l;for(;r<t.length&&!l;){const u=t[r];typeof u=="string"&&!fM.has(u)&&Ko(u).values.length&&(l=t[r]),r++}if(l&&s)for(const u of e)t[u]=OS(s,l)}class pM extends up{constructor(e,s,r,l,u){super(e,s,r,l,u,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:s,name:r}=this;if(!s||!s.current)return;super.readKeyframes();for(let y=0;y<e.length;y++){let x=e[y];if(typeof x=="string"&&(x=x.trim(),np(x))){const w=jS(x,s.current);w!==void 0&&(e[y]=w),y===e.length-1&&(this.finalKeyframe=x)}}if(this.resolveNoneKeyframes(),!NS.has(r)||e.length!==2)return;const[l,u]=e,d=Y0(l),h=Y0(u),m=D0(l),g=D0(u);if(m!==g&&da[r]){this.needsMeasurement=!0;return}if(d!==h)if(q0(d)&&q0(h))for(let y=0;y<e.length;y++){const x=e[y];typeof x=="string"&&(e[y]=parseFloat(x))}else da[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:s}=this,r=[];for(let l=0;l<e.length;l++)(e[l]===null||iM(e[l]))&&r.push(l);r.length&&mM(e,r,s)}measureInitialState(){const{element:e,unresolvedKeyframes:s,name:r}=this;if(!e||!e.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=da[r](e.measureViewportBox(),window.getComputedStyle(e.current)),s[0]=this.measuredOrigin;const l=s[s.length-1];l!==void 0&&e.getValue(r,l).jump(l,!1)}measureEndState(){const{element:e,name:s,unresolvedKeyframes:r}=this;if(!e||!e.current)return;const l=e.getValue(s);l&&l.jump(this.measuredOrigin,!1);const u=r.length-1,d=r[u];r[u]=da[s](e.measureViewportBox(),window.getComputedStyle(e.current)),d!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=d),this.removedTransforms?.length&&this.removedTransforms.forEach(([h,m])=>{e.getValue(h).set(m)}),this.resolveNoneKeyframes()}}const gM=new Set(["opacity","clipPath","filter","transform"]);function MS(t,e,s){if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){let r=document;const l=s?.[t]??r.querySelectorAll(t);return l?Array.from(l):[]}return Array.from(t).filter(r=>r!=null)}const DS=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function Nm(t){return I1(t)&&"offsetHeight"in t}const{schedule:gp}=tS(queueMicrotask,!1),qn={x:!1,y:!1};function PS(){return qn.x||qn.y}function yM(t){return t==="x"||t==="y"?qn[t]?null:(qn[t]=!0,()=>{qn[t]=!1}):qn.x||qn.y?null:(qn.x=qn.y=!0,()=>{qn.x=qn.y=!1})}function zS(t,e){const s=MS(t),r=new AbortController,l={passive:!0,...e,signal:r.signal};return[s,l,()=>r.abort()]}function vM(t){return!(t.pointerType==="touch"||PS())}function xM(t,e,s={}){const[r,l,u]=zS(t,s);return r.forEach(d=>{let h=!1,m=!1,g;const y=()=>{d.removeEventListener("pointerleave",E)},x=_=>{g&&(g(_),g=void 0),y()},w=_=>{h=!1,window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w),m&&(m=!1,x(_))},S=()=>{h=!0,window.addEventListener("pointerup",w,l),window.addEventListener("pointercancel",w,l)},E=_=>{if(_.pointerType!=="touch"){if(h){m=!0;return}x(_)}},j=_=>{if(!vM(_))return;m=!1;const N=e(d,_);typeof N=="function"&&(g=N,d.addEventListener("pointerleave",E,l))};d.addEventListener("pointerenter",j,l),d.addEventListener("pointerdown",S,l)}),u}const LS=(t,e)=>e?t===e?!0:LS(t,e.parentElement):!1,yp=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,bM=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function wM(t){return bM.has(t.tagName)||t.isContentEditable===!0}const SM=new Set(["INPUT","SELECT","TEXTAREA"]);function jM(t){return SM.has(t.tagName)||t.isContentEditable===!0}const Jc=new WeakSet;function W0(t){return e=>{e.key==="Enter"&&t(e)}}function Cf(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const _M=(t,e)=>{const s=t.currentTarget;if(!s)return;const r=W0(()=>{if(Jc.has(s))return;Cf(s,"down");const l=W0(()=>{Cf(s,"up")}),u=()=>Cf(s,"cancel");s.addEventListener("keyup",l,e),s.addEventListener("blur",u,e)});s.addEventListener("keydown",r,e),s.addEventListener("blur",()=>s.removeEventListener("keydown",r),e)};function J0(t){return yp(t)&&!PS()}const Q0=new WeakSet;function NM(t,e,s={}){const[r,l,u]=zS(t,s),d=h=>{const m=h.currentTarget;if(!J0(h)||Q0.has(h))return;Jc.add(m),s.stopPropagation&&Q0.add(h);const g=e(m,h),y=(S,E)=>{window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",w),Jc.has(m)&&Jc.delete(m),J0(S)&&typeof g=="function"&&g(S,{success:E})},x=S=>{y(S,m===window||m===document||s.useGlobalTarget||LS(m,S.target))},w=S=>{y(S,!1)};window.addEventListener("pointerup",x,l),window.addEventListener("pointercancel",w,l)};return r.forEach(h=>{(s.useGlobalTarget?window:h).addEventListener("pointerdown",d,l),Nm(h)&&(h.addEventListener("focus",g=>_M(g,l)),!wM(h)&&!h.hasAttribute("tabindex")&&(h.tabIndex=0))}),u}function vp(t){return I1(t)&&"ownerSVGElement"in t}const Qc=new WeakMap;let Zc;const US=(t,e,s)=>(r,l)=>l&&l[0]?l[0][t+"Size"]:vp(r)&&"getBBox"in r?r.getBBox()[e]:r[s],TM=US("inline","width","offsetWidth"),EM=US("block","height","offsetHeight");function kM({target:t,borderBoxSize:e}){Qc.get(t)?.forEach(s=>{s(t,{get width(){return TM(t,e)},get height(){return EM(t,e)}})})}function CM(t){t.forEach(kM)}function AM(){typeof ResizeObserver>"u"||(Zc=new ResizeObserver(CM))}function RM(t,e){Zc||AM();const s=MS(t);return s.forEach(r=>{let l=Qc.get(r);l||(l=new Set,Qc.set(r,l)),l.add(e),Zc?.observe(r)}),()=>{s.forEach(r=>{const l=Qc.get(r);l?.delete(e),l?.size||Zc?.unobserve(r)})}}const eu=new Set;let si;function OM(){si=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};eu.forEach(e=>e(t))},window.addEventListener("resize",si)}function MM(t){return eu.add(t),si||OM(),()=>{eu.delete(t),!eu.size&&typeof si=="function"&&(window.removeEventListener("resize",si),si=void 0)}}function Z0(t,e){return typeof t=="function"?MM(t):RM(t,e)}function DM(t){return vp(t)&&t.tagName==="svg"}const PM=[...AS,Et,Kn],zM=t=>PM.find(CS(t)),eb=()=>({translate:0,scale:1,origin:0,originPoint:0}),ai=()=>({x:eb(),y:eb()}),tb=()=>({min:0,max:0}),Ot=()=>({x:tb(),y:tb()}),LM=new WeakMap;function Pu(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Yo(t){return typeof t=="string"||Array.isArray(t)}const xp=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],bp=["initial",...xp];function zu(t){return Pu(t.animate)||bp.some(e=>Yo(t[e]))}function BS(t){return!!(zu(t)||t.variants)}function UM(t,e,s){for(const r in e){const l=e[r],u=s[r];if(Xt(l))t.addValue(r,l);else if(Xt(u))t.addValue(r,mi(l,{owner:t}));else if(u!==l)if(t.hasValue(r)){const d=t.getValue(r);d.liveStyle===!0?d.jump(l):d.hasAnimated||d.set(l)}else{const d=t.getStaticValue(r);t.addValue(r,mi(d!==void 0?d:l,{owner:t}))}}for(const r in s)e[r]===void 0&&t.removeValue(r);return e}const Tm={current:null},VS={current:!1},BM=typeof window<"u";function VM(){if(VS.current=!0,!!BM)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>Tm.current=t.matches;t.addEventListener("change",e),e()}else Tm.current=!1}const nb=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let xu={};function IS(t){xu=t}function IM(){return xu}class $M{scrapeMotionValuesFromProps(e,s,r){return{}}constructor({parent:e,props:s,presenceContext:r,reducedMotionConfig:l,skipAnimations:u,blockInitialAnimation:d,visualState:h},m={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=up,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const S=Jt.now();this.renderScheduledAt<S&&(this.renderScheduledAt=S,lt.render(this.render,!1,!0))};const{latestValues:g,renderState:y}=h;this.latestValues=g,this.baseTarget={...g},this.initialValues=s.initial?{...g}:{},this.renderState=y,this.parent=e,this.props=s,this.presenceContext=r,this.depth=e?e.depth+1:0,this.reducedMotionConfig=l,this.skipAnimationsConfig=u,this.options=m,this.blockInitialAnimation=!!d,this.isControllingVariants=zu(s),this.isVariantNode=BS(s),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:x,...w}=this.scrapeMotionValuesFromProps(s,{},this);for(const S in w){const E=w[S];g[S]!==void 0&&Xt(E)&&E.set(g[S])}}mount(e){if(this.hasBeenMounted)for(const s in this.initialValues)this.values.get(s)?.jump(this.initialValues[s]),this.latestValues[s]=this.initialValues[s];this.current=e,LM.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((s,r)=>this.bindToMotionValue(r,s)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(VS.current||VM(),this.shouldReduceMotion=Tm.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),pa(this.notifyUpdate),pa(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const s=this.features[e];s&&(s.unmount(),s.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,s){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),s.accelerate&&gM.has(e)&&this.current instanceof HTMLElement){const{factory:d,keyframes:h,times:m,ease:g,duration:y}=s.accelerate,x=new bS({element:this.current,name:e,keyframes:h,times:m,ease:g,duration:Fn(y)}),w=d(x);this.valueSubscriptions.set(e,()=>{w(),x.cancel()});return}const r=xi.has(e);r&&this.onBindTransform&&this.onBindTransform();const l=s.on("change",d=>{this.latestValues[e]=d,this.props.onUpdate&<.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let u;typeof window<"u"&&window.MotionCheckAppearSync&&(u=window.MotionCheckAppearSync(this,e,s)),this.valueSubscriptions.set(e,()=>{l(),u&&u(),s.owner&&s.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in xu){const s=xu[e];if(!s)continue;const{isEnabled:r,Feature:l}=s;if(!this.features[e]&&l&&r(this.props)&&(this.features[e]=new l(this)),this.features[e]){const u=this.features[e];u.isMounted?u.update():(u.mount(),u.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Ot()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,s){this.latestValues[e]=s}update(e,s){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=s;for(let r=0;r<nb.length;r++){const l=nb[r];this.propEventSubscriptions[l]&&(this.propEventSubscriptions[l](),delete this.propEventSubscriptions[l]);const u="on"+l,d=e[u];d&&(this.propEventSubscriptions[l]=this.on(l,d))}this.prevMotionValues=UM(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const s=this.getClosestVariantNode();if(s)return s.variantChildren&&s.variantChildren.add(e),()=>s.variantChildren.delete(e)}addValue(e,s){const r=this.values.get(e);s!==r&&(r&&this.removeValue(e),this.bindToMotionValue(e,s),this.values.set(e,s),this.latestValues[e]=s.get())}removeValue(e){this.values.delete(e);const s=this.valueSubscriptions.get(e);s&&(s(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,s){if(this.props.values&&this.props.values[e])return this.props.values[e];let r=this.values.get(e);return r===void 0&&s!==void 0&&(r=mi(s===null?void 0:s,{owner:this}),this.addValue(e,r)),r}readValue(e,s){let r=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return r!=null&&(typeof r=="string"&&(V1(r)||$1(r))?r=parseFloat(r):!zM(r)&&Kn.test(s)&&(r=OS(e,s)),this.setBaseTarget(e,Xt(r)?r.get():r)),Xt(r)?r.get():r}setBaseTarget(e,s){this.baseTarget[e]=s}getBaseTarget(e){const{initial:s}=this.props;let r;if(typeof s=="string"||typeof s=="object"){const u=fp(this.props,s,this.presenceContext?.custom);u&&(r=u[e])}if(s&&r!==void 0)return r;const l=this.getBaseTargetFromProps(this.props,e);return l!==void 0&&!Xt(l)?l:this.initialValues[e]!==void 0&&r===void 0?void 0:this.baseTarget[e]}on(e,s){return this.events[e]||(this.events[e]=new Zm),this.events[e].add(s)}notify(e,...s){this.events[e]&&this.events[e].notify(...s)}scheduleRenderMicrotask(){gp.render(this.render)}}class $S extends $M{constructor(){super(...arguments),this.KeyframeResolver=pM}sortInstanceNodePosition(e,s){return e.compareDocumentPosition(s)&2?1:-1}getBaseTargetFromProps(e,s){const r=e.style;return r?r[s]:void 0}removeValueFromRenderState(e,{vars:s,style:r}){delete s[e],delete r[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;Xt(e)&&(this.childSubscription=e.on("change",s=>{this.current&&(this.current.textContent=`${s}`)}))}}class va{constructor(e){this.isMounted=!1,this.node=e}update(){}}function qS({top:t,left:e,right:s,bottom:r}){return{x:{min:e,max:s},y:{min:t,max:r}}}function qM({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function HM(t,e){if(!e)return t;const s=e({x:t.left,y:t.top}),r=e({x:t.right,y:t.bottom});return{top:s.y,left:s.x,bottom:r.y,right:r.x}}function Af(t){return t===void 0||t===1}function Em({scale:t,scaleX:e,scaleY:s}){return!Af(t)||!Af(e)||!Af(s)}function qa(t){return Em(t)||HS(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function HS(t){return sb(t.x)||sb(t.y)}function sb(t){return t&&t!=="0%"}function bu(t,e,s){const r=t-s,l=e*r;return s+l}function ab(t,e,s,r,l){return l!==void 0&&(t=bu(t,l,r)),bu(t,s,r)+e}function km(t,e=0,s=1,r,l){t.min=ab(t.min,e,s,r,l),t.max=ab(t.max,e,s,r,l)}function GS(t,{x:e,y:s}){km(t.x,e.translate,e.scale,e.originPoint),km(t.y,s.translate,s.scale,s.originPoint)}const rb=.999999999999,ib=1.0000000000001;function GM(t,e,s,r=!1){const l=s.length;if(!l)return;e.x=e.y=1;let u,d;for(let h=0;h<l;h++){u=s[h],d=u.projectionDelta;const{visualElement:m}=u.options;m&&m.props.style&&m.props.style.display==="contents"||(r&&u.options.layoutScroll&&u.scroll&&u!==u.root&&ii(t,{x:-u.scroll.offset.x,y:-u.scroll.offset.y}),d&&(e.x*=d.x.scale,e.y*=d.y.scale,GS(t,d)),r&&qa(u.latestValues)&&ii(t,u.latestValues))}e.x<ib&&e.x>rb&&(e.x=1),e.y<ib&&e.y>rb&&(e.y=1)}function ri(t,e){t.min=t.min+e,t.max=t.max+e}function ob(t,e,s,r,l=.5){const u=mt(t.min,t.max,l);km(t,e,s,u,r)}function ii(t,e){ob(t.x,e.x,e.scaleX,e.scale,e.originX),ob(t.y,e.y,e.scaleY,e.scale,e.originY)}function FS(t,e){return qS(HM(t.getBoundingClientRect(),e))}function FM(t,e,s){const r=FS(t,s),{scroll:l}=e;return l&&(ri(r.x,l.offset.x),ri(r.y,l.offset.y)),r}const KM={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},YM=vi.length;function XM(t,e,s){let r="",l=!0;for(let u=0;u<YM;u++){const d=vi[u],h=t[d];if(h===void 0)continue;let m=!0;if(typeof h=="number")m=h===(d.startsWith("scale")?1:0);else{const g=parseFloat(h);m=d.startsWith("scale")?g===1:g===0}if(!m||s){const g=DS(h,pp[d]);if(!m){l=!1;const y=KM[d]||d;r+=`${y}(${g}) `}s&&(e[d]=g)}}return r=r.trim(),s?r=s(e,l?"":r):l&&(r="none"),r}function wp(t,e,s){const{style:r,vars:l,transformOrigin:u}=t;let d=!1,h=!1;for(const m in e){const g=e[m];if(xi.has(m)){d=!0;continue}else if(sS(m)){l[m]=g;continue}else{const y=DS(g,pp[m]);m.startsWith("origin")?(h=!0,u[m]=y):r[m]=y}}if(e.transform||(d||s?r.transform=XM(e,t.transform,s):r.transform&&(r.transform="none")),h){const{originX:m="50%",originY:g="50%",originZ:y=0}=u;r.transformOrigin=`${m} ${g} ${y}`}}function KS(t,{style:e,vars:s},r,l){const u=t.style;let d;for(d in e)u[d]=e[d];l?.applyProjectionStyles(u,r);for(d in s)u.setProperty(d,s[d])}function lb(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const xo={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(be.test(t))t=parseFloat(t);else return t;const s=lb(t,e.target.x),r=lb(t,e.target.y);return`${s}% ${r}%`}},WM={correct:(t,{treeScale:e,projectionDelta:s})=>{const r=t,l=Kn.parse(t);if(l.length>5)return r;const u=Kn.createTransformer(t),d=typeof l[0]!="number"?1:0,h=s.x.scale*e.x,m=s.y.scale*e.y;l[0+d]/=h,l[1+d]/=m;const g=mt(h,m,.5);return typeof l[2+d]=="number"&&(l[2+d]/=g),typeof l[3+d]=="number"&&(l[3+d]/=g),u(l)}},Cm={borderRadius:{...xo,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:xo,borderTopRightRadius:xo,borderBottomLeftRadius:xo,borderBottomRightRadius:xo,boxShadow:WM};function YS(t,{layout:e,layoutId:s}){return xi.has(t)||t.startsWith("origin")||(e||s!==void 0)&&(!!Cm[t]||t==="opacity")}function Sp(t,e,s){const r=t.style,l=e?.style,u={};if(!r)return u;for(const d in r)(Xt(r[d])||l&&Xt(l[d])||YS(d,t)||s?.getValue(d)?.liveStyle!==void 0)&&(u[d]=r[d]);return u}function JM(t){return window.getComputedStyle(t)}class QM extends $S{constructor(){super(...arguments),this.type="html",this.renderInstance=KS}readValueFromInstance(e,s){if(xi.has(s))return this.projection?.isProjecting?mm(s):y4(e,s);{const r=JM(e),l=(sS(s)?r.getPropertyValue(s):r[s])||0;return typeof l=="string"?l.trim():l}}measureInstanceViewportBox(e,{transformPagePoint:s}){return FS(e,s)}build(e,s,r){wp(e,s,r.transformTemplate)}scrapeMotionValuesFromProps(e,s,r){return Sp(e,s,r)}}const ZM={offset:"stroke-dashoffset",array:"stroke-dasharray"},eD={offset:"strokeDashoffset",array:"strokeDasharray"};function tD(t,e,s=1,r=0,l=!0){t.pathLength=1;const u=l?ZM:eD;t[u.offset]=`${-r}`,t[u.array]=`${e} ${s}`}const nD=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function XS(t,{attrX:e,attrY:s,attrScale:r,pathLength:l,pathSpacing:u=1,pathOffset:d=0,...h},m,g,y){if(wp(t,h,g),m){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:x,style:w}=t;x.transform&&(w.transform=x.transform,delete x.transform),(w.transform||x.transformOrigin)&&(w.transformOrigin=x.transformOrigin??"50% 50%",delete x.transformOrigin),w.transform&&(w.transformBox=y?.transformBox??"fill-box",delete x.transformBox);for(const S of nD)x[S]!==void 0&&(w[S]=x[S],delete x[S]);e!==void 0&&(x.x=e),s!==void 0&&(x.y=s),r!==void 0&&(x.scale=r),l!==void 0&&tD(x,l,u,d,!1)}const WS=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),JS=t=>typeof t=="string"&&t.toLowerCase()==="svg";function sD(t,e,s,r){KS(t,e,void 0,r);for(const l in e.attrs)t.setAttribute(WS.has(l)?l:mp(l),e.attrs[l])}function QS(t,e,s){const r=Sp(t,e,s);for(const l in t)if(Xt(t[l])||Xt(e[l])){const u=vi.indexOf(l)!==-1?"attr"+l.charAt(0).toUpperCase()+l.substring(1):l;r[u]=t[l]}return r}class aD extends $S{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Ot}getBaseTargetFromProps(e,s){return e[s]}readValueFromInstance(e,s){if(xi.has(s)){const r=RS(s);return r&&r.default||0}return s=WS.has(s)?s:mp(s),e.getAttribute(s)}scrapeMotionValuesFromProps(e,s,r){return QS(e,s,r)}build(e,s,r){XS(e,s,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(e,s,r,l){sD(e,s,r,l)}mount(e){this.isSVGTag=JS(e.tagName),super.mount(e)}}const rD=bp.length;function ZS(t){if(!t)return;if(!t.isControllingVariants){const s=t.parent?ZS(t.parent)||{}:{};return t.props.initial!==void 0&&(s.initial=t.props.initial),s}const e={};for(let s=0;s<rD;s++){const r=bp[s],l=t.props[r];(Yo(l)||l===!1)&&(e[r]=l)}return e}function ej(t,e){if(!Array.isArray(e))return!1;const s=e.length;if(s!==t.length)return!1;for(let r=0;r<s;r++)if(e[r]!==t[r])return!1;return!0}const iD=[...xp].reverse(),oD=xp.length;function lD(t){return e=>Promise.all(e.map(({animation:s,options:r})=>aM(t,s,r)))}function cD(t){let e=lD(t),s=cb(),r=!0;const l=m=>(g,y)=>{const x=ci(t,y,m==="exit"?t.presenceContext?.custom:void 0);if(x){const{transition:w,transitionEnd:S,...E}=x;g={...g,...E,...S}}return g};function u(m){e=m(t)}function d(m){const{props:g}=t,y=ZS(t.parent)||{},x=[],w=new Set;let S={},E=1/0;for(let _=0;_<oD;_++){const N=iD[_],k=s[N],C=g[N]!==void 0?g[N]:y[N],A=Yo(C),D=N===m?k.isActive:null;D===!1&&(E=_);let U=C===y[N]&&C!==g[N]&&A;if(U&&r&&t.manuallyAnimateOnMount&&(U=!1),k.protectedKeys={...S},!k.isActive&&D===null||!C&&!k.prevProp||Pu(C)||typeof C=="boolean")continue;if(N==="exit"&&k.isActive&&D!==!0){k.prevResolvedValues&&(S={...S,...k.prevResolvedValues});continue}const V=uD(k.prevProp,C);let R=V||N===m&&k.isActive&&!U&&A||_>E&&A,P=!1;const Z=Array.isArray(C)?C:[C];let te=Z.reduce(l(N),{});D===!1&&(te={});const{prevResolvedValues:me={}}=k,Ee={...me,...te},ye=Y=>{R=!0,w.has(Y)&&(P=!0,w.delete(Y)),k.needsAnimating[Y]=!0;const J=t.getValue(Y);J&&(J.liveStyle=!1)};for(const Y in Ee){const J=te[Y],pe=me[Y];if(S.hasOwnProperty(Y))continue;let se=!1;bm(J)&&bm(pe)?se=!ej(J,pe):se=J!==pe,se?J!=null?ye(Y):w.add(Y):J!==void 0&&w.has(Y)?ye(Y):k.protectedKeys[Y]=!0}k.prevProp=C,k.prevResolvedValues=te,k.isActive&&(S={...S,...te}),r&&t.blockInitialAnimation&&(R=!1);const _e=U&&V;R&&(!_e||P)&&x.push(...Z.map(Y=>{const J={type:N};if(typeof Y=="string"&&r&&!_e&&t.manuallyAnimateOnMount&&t.parent){const{parent:pe}=t,se=ci(pe,Y);if(pe.enteringChildren&&se){const{delayChildren:M}=se.transition||{};J.delay=SS(pe.enteringChildren,t,M)}}return{animation:Y,options:J}}))}if(w.size){const _={};if(typeof g.initial!="boolean"){const N=ci(t,Array.isArray(g.initial)?g.initial[0]:g.initial);N&&N.transition&&(_.transition=N.transition)}w.forEach(N=>{const k=t.getBaseTarget(N),C=t.getValue(N);C&&(C.liveStyle=!0),_[N]=k??null}),x.push({animation:_})}let j=!!x.length;return r&&(g.initial===!1||g.initial===g.animate)&&!t.manuallyAnimateOnMount&&(j=!1),r=!1,j?e(x):Promise.resolve()}function h(m,g){if(s[m].isActive===g)return Promise.resolve();t.variantChildren?.forEach(x=>x.animationState?.setActive(m,g)),s[m].isActive=g;const y=d(m);for(const x in s)s[x].protectedKeys={};return y}return{animateChanges:d,setActive:h,setAnimateFunction:u,getState:()=>s,reset:()=>{s=cb()}}}function uD(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!ej(e,t):!1}function Va(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function cb(){return{animate:Va(!0),whileInView:Va(),whileHover:Va(),whileTap:Va(),whileDrag:Va(),whileFocus:Va(),exit:Va()}}function ub(t,e){t.min=e.min,t.max=e.max}function In(t,e){ub(t.x,e.x),ub(t.y,e.y)}function db(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}const tj=1e-4,dD=1-tj,hD=1+tj,nj=.01,fD=0-nj,mD=0+nj;function Qt(t){return t.max-t.min}function pD(t,e,s){return Math.abs(t-e)<=s}function hb(t,e,s,r=.5){t.origin=r,t.originPoint=mt(e.min,e.max,t.origin),t.scale=Qt(s)/Qt(e),t.translate=mt(s.min,s.max,t.origin)-t.originPoint,(t.scale>=dD&&t.scale<=hD||isNaN(t.scale))&&(t.scale=1),(t.translate>=fD&&t.translate<=mD||isNaN(t.translate))&&(t.translate=0)}function Co(t,e,s,r){hb(t.x,e.x,s.x,r?r.originX:void 0),hb(t.y,e.y,s.y,r?r.originY:void 0)}function fb(t,e,s){t.min=s.min+e.min,t.max=t.min+Qt(e)}function gD(t,e,s){fb(t.x,e.x,s.x),fb(t.y,e.y,s.y)}function mb(t,e,s){t.min=e.min-s.min,t.max=t.min+Qt(e)}function wu(t,e,s){mb(t.x,e.x,s.x),mb(t.y,e.y,s.y)}function pb(t,e,s,r,l){return t-=e,t=bu(t,1/s,r),l!==void 0&&(t=bu(t,1/l,r)),t}function yD(t,e=0,s=1,r=.5,l,u=t,d=t){if(is.test(e)&&(e=parseFloat(e),e=mt(d.min,d.max,e/100)-d.min),typeof e!="number")return;let h=mt(u.min,u.max,r);t===u&&(h-=e),t.min=pb(t.min,e,s,h,l),t.max=pb(t.max,e,s,h,l)}function gb(t,e,[s,r,l],u,d){yD(t,e[s],e[r],e[l],e.scale,u,d)}const vD=["x","scaleX","originX"],xD=["y","scaleY","originY"];function yb(t,e,s,r){gb(t.x,e,vD,s?s.x:void 0,r?r.x:void 0),gb(t.y,e,xD,s?s.y:void 0,r?r.y:void 0)}function vb(t){return t.translate===0&&t.scale===1}function sj(t){return vb(t.x)&&vb(t.y)}function xb(t,e){return t.min===e.min&&t.max===e.max}function bD(t,e){return xb(t.x,e.x)&&xb(t.y,e.y)}function bb(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function aj(t,e){return bb(t.x,e.x)&&bb(t.y,e.y)}function wb(t){return Qt(t.x)/Qt(t.y)}function Sb(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}function ts(t){return[t("x"),t("y")]}function wD(t,e,s){let r="";const l=t.x.translate/e.x,u=t.y.translate/e.y,d=s?.z||0;if((l||u||d)&&(r=`translate3d(${l}px, ${u}px, ${d}px) `),(e.x!==1||e.y!==1)&&(r+=`scale(${1/e.x}, ${1/e.y}) `),s){const{transformPerspective:g,rotate:y,rotateX:x,rotateY:w,skewX:S,skewY:E}=s;g&&(r=`perspective(${g}px) ${r}`),y&&(r+=`rotate(${y}deg) `),x&&(r+=`rotateX(${x}deg) `),w&&(r+=`rotateY(${w}deg) `),S&&(r+=`skewX(${S}deg) `),E&&(r+=`skewY(${E}deg) `)}const h=t.x.scale*e.x,m=t.y.scale*e.y;return(h!==1||m!==1)&&(r+=`scale(${h}, ${m})`),r||"none"}const rj=["TopLeft","TopRight","BottomLeft","BottomRight"],SD=rj.length,jb=t=>typeof t=="string"?parseFloat(t):t,_b=t=>typeof t=="number"||be.test(t);function jD(t,e,s,r,l,u){l?(t.opacity=mt(0,s.opacity??1,_D(r)),t.opacityExit=mt(e.opacity??1,0,ND(r))):u&&(t.opacity=mt(e.opacity??1,s.opacity??1,r));for(let d=0;d<SD;d++){const h=`border${rj[d]}Radius`;let m=Nb(e,h),g=Nb(s,h);if(m===void 0&&g===void 0)continue;m||(m=0),g||(g=0),m===0||g===0||_b(m)===_b(g)?(t[h]=Math.max(mt(jb(m),jb(g),r),0),(is.test(g)||is.test(m))&&(t[h]+="%")):t[h]=g}(e.rotate||s.rotate)&&(t.rotate=mt(e.rotate||0,s.rotate||0,r))}function Nb(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const _D=ij(0,.5,J1),ND=ij(.5,.95,Ln);function ij(t,e,s){return r=>r<t?0:r>e?1:s(Go(t,e,r))}function TD(t,e,s){const r=Xt(t)?t:mi(t);return r.start(hp("",r,e,s)),r.animation}function Xo(t,e,s,r={passive:!0}){return t.addEventListener(e,s,r),()=>t.removeEventListener(e,s)}const ED=(t,e)=>t.depth-e.depth;class kD{constructor(){this.children=[],this.isDirty=!1}add(e){Jm(this.children,e),this.isDirty=!0}remove(e){pu(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(ED),this.isDirty=!1,this.children.forEach(e)}}function CD(t,e){const s=Jt.now(),r=({timestamp:l})=>{const u=l-s;u>=e&&(pa(r),t(u-e))};return lt.setup(r,!0),()=>pa(r)}function tu(t){return Xt(t)?t.get():t}class AD{constructor(){this.members=[]}add(e){Jm(this.members,e);for(let s=this.members.length-1;s>=0;s--){const r=this.members[s];if(r===e||r===this.lead||r===this.prevLead)continue;const l=r.instance;l&&l.isConnected===!1&&r.isPresent!==!1&&!r.snapshot&&pu(this.members,r)}e.scheduleRender()}remove(e){if(pu(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const s=this.members[this.members.length-1];s&&this.promote(s)}}relegate(e){const s=this.members.findIndex(l=>e===l);if(s===0)return!1;let r;for(let l=s;l>=0;l--){const u=this.members[l],d=u.instance;if(u.isPresent!==!1&&(!d||d.isConnected!==!1)){r=u;break}}return r?(this.promote(r),!0):!1}promote(e,s){const r=this.lead;if(e!==r&&(this.prevLead=r,this.lead=e,e.show(),r)){r.instance&&r.scheduleRender(),e.scheduleRender();const l=r.options.layoutDependency,u=e.options.layoutDependency;if(!(l!==void 0&&u!==void 0&&l===u)){const m=r.instance;m&&m.isConnected===!1&&!r.snapshot||(e.resumeFrom=r,s&&(e.resumeFrom.preserveOpacity=!0),r.snapshot&&(e.snapshot=r.snapshot,e.snapshot.latestValues=r.animationValues||r.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0))}const{crossfade:h}=e.options;h===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:s,resumingFrom:r}=e;s.onExitComplete&&s.onExitComplete(),r&&r.options.onExitComplete&&r.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}const nu={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Rf=["","X","Y","Z"],RD=1e3;let OD=0;function Of(t,e,s,r){const{latestValues:l}=e;l[t]&&(s[t]=l[t],e.setStaticValue(t,0),r&&(r[t]=0))}function oj(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const s=ES(e);if(window.MotionHasOptimisedAnimation(s,"transform")){const{layout:l,layoutId:u}=t.options;window.MotionCancelOptimisedAnimation(s,"transform",lt,!(l||u))}const{parent:r}=t;r&&!r.hasCheckedOptimisedAppear&&oj(r)}function lj({attachResizeListener:t,defaultParent:e,measureScroll:s,checkIsScrollRoot:r,resetTransform:l}){return class{constructor(d={},h=e?.()){this.id=OD++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(PD),this.nodes.forEach(BD),this.nodes.forEach(VD),this.nodes.forEach(zD)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=d,this.root=h?h.root||h:this,this.path=h?[...h.path,h]:[],this.parent=h,this.depth=h?h.depth+1:0;for(let m=0;m<this.path.length;m++)this.path[m].shouldResetTransform=!0;this.root===this&&(this.nodes=new kD)}addEventListener(d,h){return this.eventHandlers.has(d)||this.eventHandlers.set(d,new Zm),this.eventHandlers.get(d).add(h)}notifyListeners(d,...h){const m=this.eventHandlers.get(d);m&&m.notify(...h)}hasListeners(d){return this.eventHandlers.has(d)}mount(d){if(this.instance)return;this.isSVG=vp(d)&&!DM(d),this.instance=d;const{layoutId:h,layout:m,visualElement:g}=this.options;if(g&&!g.current&&g.mount(d),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(m||h)&&(this.isLayoutDirty=!0),t){let y,x=0;const w=()=>this.root.updateBlockedByResize=!1;lt.read(()=>{x=window.innerWidth}),t(d,()=>{const S=window.innerWidth;S!==x&&(x=S,this.root.updateBlockedByResize=!0,y&&y(),y=CD(w,250),nu.hasAnimatedSinceResize&&(nu.hasAnimatedSinceResize=!1,this.nodes.forEach(kb)))})}h&&this.root.registerSharedNode(h,this),this.options.animate!==!1&&g&&(h||m)&&this.addEventListener("didUpdate",({delta:y,hasLayoutChanged:x,hasRelativeLayoutChanged:w,layout:S})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const E=this.options.transition||g.getDefaultTransition()||GD,{onLayoutAnimationStart:j,onLayoutAnimationComplete:_}=g.getProps(),N=!this.targetLayout||!aj(this.targetLayout,S),k=!x&&w;if(this.options.layoutRoot||this.resumeFrom||k||x&&(N||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const C={...dp(E,"layout"),onPlay:j,onComplete:_};(g.shouldReduceMotion||this.options.layoutRoot)&&(C.delay=0,C.type=!1),this.startAnimation(C),this.setAnimationOrigin(y,k)}else x||kb(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=S})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const d=this.getStack();d&&d.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),pa(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(ID),this.animationId++)}getTransformTemplate(){const{visualElement:d}=this.options;return d&&d.getProps().transformTemplate}willUpdate(d=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&oj(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let y=0;y<this.path.length;y++){const x=this.path[y];x.shouldResetTransform=!0,x.updateScroll("snapshot"),x.options.layoutRoot&&x.willUpdate(!1)}const{layoutId:h,layout:m}=this.options;if(h===void 0&&!m)return;const g=this.getTransformTemplate();this.prevTransformTemplateValue=g?g(this.latestValues,""):void 0,this.updateSnapshot(),d&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Tb);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Eb);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(UD),this.nodes.forEach(MD),this.nodes.forEach(DD)):this.nodes.forEach(Eb),this.clearAllSnapshots();const h=Jt.now();Ft.delta=ls(0,1e3/60,h-Ft.timestamp),Ft.timestamp=h,Ft.isProcessing=!0,jf.update.process(Ft),jf.preRender.process(Ft),jf.render.process(Ft),Ft.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,gp.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(LD),this.sharedNodes.forEach($D)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,lt.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){lt.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Qt(this.snapshot.measuredBox.x)&&!Qt(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let m=0;m<this.path.length;m++)this.path[m].updateScroll();const d=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected=Ot(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:h}=this.options;h&&h.notify("LayoutMeasure",this.layout.layoutBox,d?d.layoutBox:void 0)}updateScroll(d="measure"){let h=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===d&&(h=!1),h&&this.instance){const m=r(this.instance);this.scroll={animationId:this.root.animationId,phase:d,isRoot:m,offset:s(this.instance),wasRoot:this.scroll?this.scroll.isRoot:m}}}resetTransform(){if(!l)return;const d=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,h=this.projectionDelta&&!sj(this.projectionDelta),m=this.getTransformTemplate(),g=m?m(this.latestValues,""):void 0,y=g!==this.prevTransformTemplateValue;d&&this.instance&&(h||qa(this.latestValues)||y)&&(l(this.instance,g),this.shouldResetTransform=!1,this.scheduleRender())}measure(d=!0){const h=this.measurePageBox();let m=this.removeElementScroll(h);return d&&(m=this.removeTransform(m)),FD(m),{animationId:this.root.animationId,measuredBox:h,layoutBox:m,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:d}=this.options;if(!d)return Ot();const h=d.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(KD))){const{scroll:g}=this.root;g&&(ri(h.x,g.offset.x),ri(h.y,g.offset.y))}return h}removeElementScroll(d){const h=Ot();if(In(h,d),this.scroll?.wasRoot)return h;for(let m=0;m<this.path.length;m++){const g=this.path[m],{scroll:y,options:x}=g;g!==this.root&&y&&x.layoutScroll&&(y.wasRoot&&In(h,d),ri(h.x,y.offset.x),ri(h.y,y.offset.y))}return h}applyTransform(d,h=!1){const m=Ot();In(m,d);for(let g=0;g<this.path.length;g++){const y=this.path[g];!h&&y.options.layoutScroll&&y.scroll&&y!==y.root&&ii(m,{x:-y.scroll.offset.x,y:-y.scroll.offset.y}),qa(y.latestValues)&&ii(m,y.latestValues)}return qa(this.latestValues)&&ii(m,this.latestValues),m}removeTransform(d){const h=Ot();In(h,d);for(let m=0;m<this.path.length;m++){const g=this.path[m];if(!g.instance||!qa(g.latestValues))continue;Em(g.latestValues)&&g.updateSnapshot();const y=Ot(),x=g.measurePageBox();In(y,x),yb(h,g.latestValues,g.snapshot?g.snapshot.layoutBox:void 0,y)}return qa(this.latestValues)&&yb(h,this.latestValues),h}setTargetDelta(d){this.targetDelta=d,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(d){this.options={...this.options,...d,crossfade:d.crossfade!==void 0?d.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Ft.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(d=!1){const h=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=h.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=h.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=h.isSharedProjectionDirty);const m=!!this.resumingFrom||this!==h;if(!(d||m&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:y,layoutId:x}=this.options;if(!this.layout||!(y||x))return;this.resolvedRelativeTargetAt=Ft.timestamp;const w=this.getClosestProjectingParent();w&&this.linkedParentVersion!==w.layoutVersion&&!w.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(w&&w.layout?this.createRelativeTarget(w,this.layout.layoutBox,w.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=Ot(),this.targetWithTransforms=Ot()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),gD(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):In(this.target,this.layout.layoutBox),GS(this.target,this.targetDelta)):In(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,w&&!!w.resumingFrom==!!this.resumingFrom&&!w.options.layoutScroll&&w.target&&this.animationProgress!==1?this.createRelativeTarget(w,this.target,w.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||Em(this.parent.latestValues)||HS(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(d,h,m){this.relativeParent=d,this.linkedParentVersion=d.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Ot(),this.relativeTargetOrigin=Ot(),wu(this.relativeTargetOrigin,h,m),In(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){const d=this.getLead(),h=!!this.resumingFrom||this!==d;let m=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(m=!1),h&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(m=!1),this.resolvedRelativeTargetAt===Ft.timestamp&&(m=!1),m)return;const{layout:g,layoutId:y}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(g||y))return;In(this.layoutCorrected,this.layout.layoutBox);const x=this.treeScale.x,w=this.treeScale.y;GM(this.layoutCorrected,this.treeScale,this.path,h),d.layout&&!d.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(d.target=d.layout.layoutBox,d.targetWithTransforms=Ot());const{target:S}=d;if(!S){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(db(this.prevProjectionDelta.x,this.projectionDelta.x),db(this.prevProjectionDelta.y,this.projectionDelta.y)),Co(this.projectionDelta,this.layoutCorrected,S,this.latestValues),(this.treeScale.x!==x||this.treeScale.y!==w||!Sb(this.projectionDelta.x,this.prevProjectionDelta.x)||!Sb(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",S))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(d=!0){if(this.options.visualElement?.scheduleRender(),d){const h=this.getStack();h&&h.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=ai(),this.projectionDelta=ai(),this.projectionDeltaWithTransform=ai()}setAnimationOrigin(d,h=!1){const m=this.snapshot,g=m?m.latestValues:{},y={...this.latestValues},x=ai();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!h;const w=Ot(),S=m?m.source:void 0,E=this.layout?this.layout.source:void 0,j=S!==E,_=this.getStack(),N=!_||_.members.length<=1,k=!!(j&&!N&&this.options.crossfade===!0&&!this.path.some(HD));this.animationProgress=0;let C;this.mixTargetDelta=A=>{const D=A/1e3;Cb(x.x,d.x,D),Cb(x.y,d.y,D),this.setTargetDelta(x),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(wu(w,this.layout.layoutBox,this.relativeParent.layout.layoutBox),qD(this.relativeTarget,this.relativeTargetOrigin,w,D),C&&bD(this.relativeTarget,C)&&(this.isProjectionDirty=!1),C||(C=Ot()),In(C,this.relativeTarget)),j&&(this.animationValues=y,jD(y,g,this.latestValues,D,k,N)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=D},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(d){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(pa(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=lt.update(()=>{nu.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=mi(0)),this.motionValue.jump(0,!1),this.currentAnimation=TD(this.motionValue,[0,1e3],{...d,velocity:0,isSync:!0,onUpdate:h=>{this.mixTargetDelta(h),d.onUpdate&&d.onUpdate(h)},onStop:()=>{},onComplete:()=>{d.onComplete&&d.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const d=this.getStack();d&&d.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(RD),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const d=this.getLead();let{targetWithTransforms:h,target:m,layout:g,latestValues:y}=d;if(!(!h||!m||!g)){if(this!==d&&this.layout&&g&&cj(this.options.animationType,this.layout.layoutBox,g.layoutBox)){m=this.target||Ot();const x=Qt(this.layout.layoutBox.x);m.x.min=d.target.x.min,m.x.max=m.x.min+x;const w=Qt(this.layout.layoutBox.y);m.y.min=d.target.y.min,m.y.max=m.y.min+w}In(h,m),ii(h,y),Co(this.projectionDeltaWithTransform,this.layoutCorrected,h,y)}}registerSharedNode(d,h){this.sharedNodes.has(d)||this.sharedNodes.set(d,new AD),this.sharedNodes.get(d).add(h);const g=h.options.initialPromotionConfig;h.promote({transition:g?g.transition:void 0,preserveFollowOpacity:g&&g.shouldPreserveFollowOpacity?g.shouldPreserveFollowOpacity(h):void 0})}isLead(){const d=this.getStack();return d?d.lead===this:!0}getLead(){const{layoutId:d}=this.options;return d?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:d}=this.options;return d?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:d}=this.options;if(d)return this.root.sharedNodes.get(d)}promote({needsReset:d,transition:h,preserveFollowOpacity:m}={}){const g=this.getStack();g&&g.promote(this,m),d&&(this.projectionDelta=void 0,this.needsReset=!0),h&&this.setOptions({transition:h})}relegate(){const d=this.getStack();return d?d.relegate(this):!1}resetSkewAndRotation(){const{visualElement:d}=this.options;if(!d)return;let h=!1;const{latestValues:m}=d;if((m.z||m.rotate||m.rotateX||m.rotateY||m.rotateZ||m.skewX||m.skewY)&&(h=!0),!h)return;const g={};m.z&&Of("z",d,g,this.animationValues);for(let y=0;y<Rf.length;y++)Of(`rotate${Rf[y]}`,d,g,this.animationValues),Of(`skew${Rf[y]}`,d,g,this.animationValues);d.render();for(const y in g)d.setStaticValue(y,g[y]),this.animationValues&&(this.animationValues[y]=g[y]);d.scheduleRender()}applyProjectionStyles(d,h){if(!this.instance||this.isSVG)return;if(!this.isVisible){d.visibility="hidden";return}const m=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,d.visibility="",d.opacity="",d.pointerEvents=tu(h?.pointerEvents)||"",d.transform=m?m(this.latestValues,""):"none";return}const g=this.getLead();if(!this.projectionDelta||!this.layout||!g.target){this.options.layoutId&&(d.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,d.pointerEvents=tu(h?.pointerEvents)||""),this.hasProjected&&!qa(this.latestValues)&&(d.transform=m?m({},""):"none",this.hasProjected=!1);return}d.visibility="";const y=g.animationValues||g.latestValues;this.applyTransformsToTarget();let x=wD(this.projectionDeltaWithTransform,this.treeScale,y);m&&(x=m(y,x)),d.transform=x;const{x:w,y:S}=this.projectionDelta;d.transformOrigin=`${w.origin*100}% ${S.origin*100}% 0`,g.animationValues?d.opacity=g===this?y.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:y.opacityExit:d.opacity=g===this?y.opacity!==void 0?y.opacity:"":y.opacityExit!==void 0?y.opacityExit:0;for(const E in Cm){if(y[E]===void 0)continue;const{correct:j,applyTo:_,isCSSVariable:N}=Cm[E],k=x==="none"?y[E]:j(y[E],g);if(_){const C=_.length;for(let A=0;A<C;A++)d[_[A]]=k}else N?this.options.visualElement.renderState.vars[E]=k:d[E]=k}this.options.layoutId&&(d.pointerEvents=g===this?tu(h?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(d=>d.currentAnimation?.stop()),this.root.nodes.forEach(Tb),this.root.sharedNodes.clear()}}}function MD(t){t.updateLayout()}function DD(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:s,measuredBox:r}=t.layout,{animationType:l}=t.options,u=e.source!==t.layout.source;l==="size"?ts(y=>{const x=u?e.measuredBox[y]:e.layoutBox[y],w=Qt(x);x.min=s[y].min,x.max=x.min+w}):cj(l,e.layoutBox,s)&&ts(y=>{const x=u?e.measuredBox[y]:e.layoutBox[y],w=Qt(s[y]);x.max=x.min+w,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[y].max=t.relativeTarget[y].min+w)});const d=ai();Co(d,s,e.layoutBox);const h=ai();u?Co(h,t.applyTransform(r,!0),e.measuredBox):Co(h,s,e.layoutBox);const m=!sj(d);let g=!1;if(!t.resumeFrom){const y=t.getClosestProjectingParent();if(y&&!y.resumeFrom){const{snapshot:x,layout:w}=y;if(x&&w){const S=Ot();wu(S,e.layoutBox,x.layoutBox);const E=Ot();wu(E,s,w.layoutBox),aj(S,E)||(g=!0),y.options.layoutRoot&&(t.relativeTarget=E,t.relativeTargetOrigin=S,t.relativeParent=y)}}}t.notifyListeners("didUpdate",{layout:s,snapshot:e,delta:h,layoutDelta:d,hasLayoutChanged:m,hasRelativeLayoutChanged:g})}else if(t.isLead()){const{onExitComplete:s}=t.options;s&&s()}t.options.transition=void 0}function PD(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function zD(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function LD(t){t.clearSnapshot()}function Tb(t){t.clearMeasurements()}function Eb(t){t.isLayoutDirty=!1}function UD(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function kb(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function BD(t){t.resolveTargetDelta()}function VD(t){t.calcProjection()}function ID(t){t.resetSkewAndRotation()}function $D(t){t.removeLeadSnapshot()}function Cb(t,e,s){t.translate=mt(e.translate,0,s),t.scale=mt(e.scale,1,s),t.origin=e.origin,t.originPoint=e.originPoint}function Ab(t,e,s,r){t.min=mt(e.min,s.min,r),t.max=mt(e.max,s.max,r)}function qD(t,e,s,r){Ab(t.x,e.x,s.x,r),Ab(t.y,e.y,s.y,r)}function HD(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const GD={duration:.45,ease:[.4,0,.1,1]},Rb=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),Ob=Rb("applewebkit/")&&!Rb("chrome/")?Math.round:Ln;function Mb(t){t.min=Ob(t.min),t.max=Ob(t.max)}function FD(t){Mb(t.x),Mb(t.y)}function cj(t,e,s){return t==="position"||t==="preserve-aspect"&&!pD(wb(e),wb(s),.2)}function KD(t){return t!==t.root&&t.scroll?.wasRoot}const YD=lj({attachResizeListener:(t,e)=>Xo(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),Mf={current:void 0},uj=lj({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Mf.current){const t=new YD({});t.mount(window),t.setOptions({layoutScroll:!0}),Mf.current=t}return Mf.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),jp=v.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function Db(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function XD(...t){return e=>{let s=!1;const r=t.map(l=>{const u=Db(l,e);return!s&&typeof u=="function"&&(s=!0),u});if(s)return()=>{for(let l=0;l<r.length;l++){const u=r[l];typeof u=="function"?u():Db(t[l],null)}}}}function WD(...t){return v.useCallback(XD(...t),t)}class JD extends v.Component{getSnapshotBeforeUpdate(e){const s=this.props.childRef.current;if(s&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const r=s.offsetParent,l=Nm(r)&&r.offsetWidth||0,u=Nm(r)&&r.offsetHeight||0,d=this.props.sizeRef.current;d.height=s.offsetHeight||0,d.width=s.offsetWidth||0,d.top=s.offsetTop,d.left=s.offsetLeft,d.right=l-d.width-d.left,d.bottom=u-d.height-d.top}return null}componentDidUpdate(){}render(){return this.props.children}}function QD({children:t,isPresent:e,anchorX:s,anchorY:r,root:l,pop:u}){const d=v.useId(),h=v.useRef(null),m=v.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0}),{nonce:g}=v.useContext(jp),y=t.props?.ref??t?.ref,x=WD(h,y);return v.useInsertionEffect(()=>{const{width:w,height:S,top:E,left:j,right:_,bottom:N}=m.current;if(e||u===!1||!h.current||!w||!S)return;const k=s==="left"?`left: ${j}`:`right: ${_}`,C=r==="bottom"?`bottom: ${N}`:`top: ${E}`;h.current.dataset.motionPopId=d;const A=document.createElement("style");g&&(A.nonce=g);const D=l??document.head;return D.appendChild(A),A.sheet&&A.sheet.insertRule(`
|
|
95
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return v.useEffect(()=>{t&&(document.getElementById(t)||console.error(s))},[s,t]),null},VO="DialogDescriptionWarning",IO=({contentRef:t,descriptionId:e})=>{const i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${C1(VO).contentName}}.`;return v.useEffect(()=>{const l=t.current?.getAttribute("aria-describedby");e&&l&&(document.getElementById(e)||console.warn(i))},[i,t,e]),null},$O=g1,qO=x1,HO=b1,GO=w1,FO=j1,KO=N1,YO=E1;function Za({...t}){return o.jsx($O,{"data-slot":"dialog",...t})}function XO({...t}){return o.jsx(qO,{"data-slot":"dialog-portal",...t})}function A1({className:t,...e}){return o.jsx(HO,{"data-slot":"dialog-overlay",className:ge("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...e})}function ei({className:t,children:e,...s}){return o.jsxs(XO,{"data-slot":"dialog-portal",children:[o.jsx(A1,{}),o.jsxs(GO,{"data-slot":"dialog-content",className:ge("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",t),...s,children:[e,o.jsxs(YO,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[o.jsx(zn,{}),o.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function hr({className:t,...e}){return o.jsx("div",{"data-slot":"dialog-header",className:ge("flex flex-col gap-2 text-center sm:text-left",t),...e})}function tr({className:t,...e}){return o.jsx("div",{"data-slot":"dialog-footer",className:ge("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function fr({className:t,...e}){return o.jsx(FO,{"data-slot":"dialog-title",className:ge("text-lg leading-none font-semibold",t),...e})}function tl({className:t,...e}){return o.jsx(KO,{"data-slot":"dialog-description",className:ge("text-muted-foreground text-sm",t),...e})}function WO({open:t,onOpenChange:e,health:s,isBootstrapping:i,initStatus:l,sessionStatus:u,migrationStatus:d,onRunMigration:h}){return o.jsx(Za,{open:t,onOpenChange:e,children:o.jsxs(ei,{className:"sm:max-w-md",children:[o.jsxs(hr,{children:[o.jsxs(fr,{className:"flex items-center gap-2",children:[o.jsx(ur,{className:"w-5 h-5 text-primary"}),"Runtime Health Engine"]}),o.jsx(tl,{children:"Diagnostic overview of active foundation services."})]}),o.jsxs("div",{className:"space-y-4 py-4",children:[[{label:"API Provider",value:s,status:s==="ok"?"success":s==="error"?"error":"warning"},{label:"Bootstrap Cycle",value:i?"running":"stable",status:i?"warning":"success"},{label:"Init Integrity",value:l,status:l==="initialized"?"success":l==="error"?"error":"warning"},{label:"Auth Context",value:u,status:u==="authenticated"?"success":u==="error"?"error":"warning"}].map(m=>o.jsxs("div",{className:"flex items-center justify-between p-3 rounded-xl bg-muted/50 border",children:[o.jsx("span",{className:"text-sm font-medium",children:m.label}),o.jsx(Pt,{variant:"outline",className:ge("text-[10px] uppercase font-bold",m.status==="success"&&"border-emerald-500/50 text-emerald-500 bg-emerald-500/5",m.status==="warning"&&"border-amber-500/50 text-amber-500 bg-amber-500/5",m.status==="error"&&"border-destructive/50 text-destructive bg-destructive/5"),children:m.value})]},m.label)),o.jsxs("div",{className:ge("p-4 rounded-xl border flex flex-col gap-3 transition-all",d?.needsMigration?"bg-amber-500/10 border-amber-500/20 text-amber-600 dark:text-amber-500":"bg-primary/5 border-primary/10 text-primary"),children:[o.jsxs("div",{className:"flex items-center gap-3",children:[d?.needsMigration?o.jsx(ur,{className:"w-4 h-4 shrink-0 animate-pulse"}):o.jsx(ya,{className:"w-4 h-4 shrink-0"}),o.jsx("p",{className:"text-xs font-semibold leading-relaxed",children:d?d.message:"Checking database schema migration parity..."})]}),d?.needsMigration&&h&&o.jsx(ae,{size:"sm",className:"w-full bg-amber-500 hover:bg-amber-600 text-white font-black text-[10px] uppercase tracking-widest h-8 rounded-lg",onClick:h,children:"Run System Migration"})]})]})]})})}class JO{buffer="";processChunk(e){const s=[];this.buffer+=e;const i=this.buffer.split(`
|
|
96
|
+
`);this.buffer=i.pop()||"";for(const l of i)if(l.startsWith("data: "))try{const u=JSON.parse(l.slice(6));s.push(u)}catch{}return s}flush(){if(!this.buffer.trim())return[];const e=[];if(this.buffer.startsWith("data: "))try{e.push(JSON.parse(this.buffer.slice(6)))}catch{}return this.buffer="",e}reset(){this.buffer=""}}async function R1(t,e,s={}){const{timeout:i=3e5,onError:l}=s;if(!t.body)throw new Error("Response body is empty");const u=t.body.getReader(),d=new TextDecoder,h=new JO,m=setTimeout(()=>{u.cancel("Timeout").catch(()=>{})},i);try{for(;;){const{value:g,done:y}=await u.read();if(y){h.flush().forEach(e);break}const x=d.decode(g,{stream:!0});h.processChunk(x).forEach(e)}}catch(g){const y=g instanceof Error?g:new Error(String(g));if(l)l(y);else throw y}finally{clearTimeout(m),h.reset()}}class is extends Error{constructor(e,s,i){super(e),this.code=s,this.status=i,this.name="SetupApiError"}}async function QO(t){const e=await fetch("/api/setup/organizations",{headers:{Authorization:`Bearer ${t}`}}),s=await e.text();let i={};if(s.trim())try{i=JSON.parse(s)}catch{i={message:s.trim()}}if(!e.ok){const l=typeof i?.error=="string"&&i.error||typeof i?.message=="string"&&i.message||`${e.status} ${e.statusText} while fetching organizations`,u=e.status===500||e.status===502?" If local API is not running, start `npm run dev:api` and retry.":"";throw new is(`${l}${u}`,"FETCH_ORGS_FAILED",e.status)}return i}async function ZO(t,e){const s=await fetch("/api/setup/auto-provision",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.accessToken}`},body:JSON.stringify({orgId:t.orgId,projectName:t.projectName,region:t.region})});if(!s.ok){const i=await s.json().catch(()=>({}));throw new is(i?.error||"Failed to auto-provision","PROVISION_FAILED",s.status)}await R1(s,e,{timeout:36e4,onError:i=>{throw new is(`Provisioning stream error: ${i.message}`,"STREAM_ERROR")}})}async function e5(t){const e=await fetch(`/api/setup/projects/${encodeURIComponent(t.projectRef)}/credentials`,{headers:{Authorization:`Bearer ${t.accessToken}`}}),s=await e.json().catch(()=>({}));if(!e.ok)throw new is(s?.error||"Failed to recover project credentials","RECOVERY_FAILED",e.status);return{projectId:String(s.projectId||t.projectRef),url:String(s.url||`https://${t.projectRef}.supabase.co`),anonKey:String(s.anonKey||""),dbPass:""}}async function t5(t,e){const s=await fetch("/api/migrate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectRef:t.projectRef,accessToken:t.accessToken,anonKey:t.anonKey})});if(!s.ok){const i=await s.json().catch(()=>({}));throw new is(i?.error||"Failed to run migration","MIGRATION_FAILED",s.status)}await R1(s,e,{timeout:6e5,onError:i=>{throw new is(`Migration stream error: ${i.message}`,"STREAM_ERROR")}})}const om={step:"welcome",managed:{accessToken:"",organizations:[],selectedOrg:"",projectName:"Folio-Core",region:"us-east-1",isFetchingOrgs:!1},manual:{url:"",anonKey:""},projectId:"",logs:[],error:null,isMigrating:!1,migrationStatus:null};function n5(t,e){switch(e.type){case"SET_STEP":return{...t,step:e.payload,error:null};case"SET_ACCESS_TOKEN":return{...t,managed:{...t.managed,accessToken:e.payload}};case"SET_ORGANIZATIONS":return{...t,managed:{...t.managed,organizations:e.payload,selectedOrg:e.payload.length>0?e.payload[0].id:""}};case"SET_SELECTED_ORG":return{...t,managed:{...t.managed,selectedOrg:e.payload}};case"SET_PROJECT_NAME":return{...t,managed:{...t.managed,projectName:e.payload}};case"SET_REGION":return{...t,managed:{...t.managed,region:e.payload}};case"SET_FETCHING_ORGS":return{...t,managed:{...t.managed,isFetchingOrgs:e.payload}};case"SET_MANUAL_URL":return{...t,manual:{...t.manual,url:e.payload}};case"SET_MANUAL_ANON_KEY":return{...t,manual:{...t.manual,anonKey:e.payload}};case"SET_PROJECT_ID":return{...t,projectId:e.payload};case"ADD_LOG":return{...t,logs:[...t.logs,{...e.payload,timestamp:Date.now()}].slice(-500)};case"CLEAR_LOGS":return{...t,logs:[]};case"SET_ERROR":return{...t,error:e.payload};case"SET_MIGRATING":return{...t,isMigrating:e.payload};case"SET_MIGRATION_STATUS":return{...t,migrationStatus:e.payload};case"RESET_MANAGED_FLOW":return{...t,managed:{...om.managed},error:null};case"RESET_MANUAL_FLOW":return{...t,manual:{...om.manual},error:null};default:return t}}const Ym=v.forwardRef(({className:t,...e},s)=>o.jsx("textarea",{className:ge("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:s,...e}));Ym.displayName="Textarea";function Sf(t){const e=t.trim();return e?e.startsWith("http://")||e.startsWith("https://")?e:`https://${e}.supabase.co`:""}function s5(t){const e=t.trim();if(!e)return{valid:!1,message:"URL is required"};if(e.startsWith("http://")||e.startsWith("https://"))try{return new URL(e).hostname.endsWith(".supabase.co")?{valid:!0,message:"Valid Supabase URL"}:{valid:!1,message:"URL must be a supabase.co domain"}}catch{return{valid:!1,message:"Invalid URL format"}}return/^[a-z0-9-]+$/.test(e)?{valid:!0,message:"Project ID detected"}:{valid:!1,message:"Enter a valid URL or project ID"}}function a5(t){const e=t.trim();return e?e.startsWith("sb_publishable_")?e.length<25?{valid:!1,message:"Incomplete publishable key"}:{valid:!0,message:"Valid publishable key"}:e.startsWith("eyJ")?e.length<50?{valid:!1,message:"Incomplete anon key"}:{valid:!0,message:"Valid anon key"}:{valid:!1,message:"Invalid API key format"}:{valid:!1,message:"API key is required"}}function O1(t){const e=t.trim();return e?e.startsWith("sbp_")?e.length<20?{valid:!1,message:"Token is too short"}:{valid:!0,message:"Valid access token"}:{valid:!1,message:"Token must start with sbp_"}:{valid:!1,message:"Access token is required"}}function O0(t){const e=t.trim();if(!e)return null;if(!e.includes(".")&&!e.includes("/"))return e;try{return new URL(e.startsWith("http")?e:`https://${e}`).hostname.split(".")[0]||null}catch{return null}}function i5({url:t,anonKey:e,error:s,onUrlChange:i,onAnonKeyChange:l,onSave:u,onBack:d}){const h=s5(t),m=a5(e);return o.jsxs("div",{className:"flex flex-col gap-6 animate-in fade-in slide-in-from-right-4 duration-500",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Manual Credentials"}),o.jsx("p",{className:"text-muted-foreground text-sm",children:"Connect Folio to an existing Supabase project with URL and anon key."})]}),o.jsxs("div",{className:"grid gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"supabase-url",children:"Supabase URL or Project ID"}),o.jsx(je,{id:"supabase-url",value:t,onChange:g=>i(g.target.value),placeholder:"https://project.supabase.co or project-id",className:!h.valid&&t.length>0?"border-destructive focus-visible:ring-destructive":""}),t.length>0&&o.jsxs("p",{className:ge("text-xs flex items-center gap-1",h.valid?"text-emerald-500":"text-destructive"),children:[h.valid?o.jsx(os,{className:"w-3"}):o.jsx(Sn,{className:"w-3"}),h.message]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"supabase-anon-key",children:"Anon Key"}),o.jsx(Ym,{id:"supabase-anon-key",value:e,onChange:g=>l(g.target.value),placeholder:"eyJ...",className:ge("min-h-[120px] font-mono text-xs",!m.valid&&e.length>0?"border-destructive focus-visible:ring-destructive":"")}),e.length>0&&o.jsxs("p",{className:ge("text-xs flex items-center gap-1",m.valid?"text-emerald-500":"text-destructive"),children:[m.valid?o.jsx(os,{className:"w-3"}):o.jsx(Sn,{className:"w-3"}),m.message]})]})]}),s&&o.jsxs(jn,{variant:"destructive",children:[o.jsx(Sn,{className:"h-4 w-4"}),o.jsx(_n,{children:s})]}),o.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[o.jsxs(ae,{variant:"ghost",size:"sm",className:"text-muted-foreground",onClick:d,children:[o.jsx(Jo,{className:"w-4 h-4 mr-1"}),"Back"]}),o.jsx(ae,{className:"ml-auto",onClick:u,disabled:!h.valid||!m.valid,children:"Validate and Continue"})]})]})}const nl=v.createContext(null),r5=({children:t,value:e,onValueChange:s,...i})=>{const[l,u]=v.useState(!1),d=v.useRef(null);return v.useEffect(()=>{const h=m=>{d.current&&!d.current.contains(m.target)&&u(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]),o.jsx(nl.Provider,{value:{value:e,onValueChange:s,open:l,setOpen:u},children:o.jsx("div",{ref:d,className:"relative inline-block w-full",...i,children:t})})},M1=v.forwardRef(({className:t,children:e,...s},i)=>{const l=v.useContext(nl);return o.jsxs("button",{ref:i,type:"button",onClick:()=>l?.setOpen(!l.open),className:ge("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:[e,o.jsx("svg",{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",className:"h-4 w-4 opacity-50",children:o.jsx("path",{d:"m6 9 6 6 6-6"})})]})});M1.displayName="SelectTrigger";const D1=v.forwardRef(({className:t,placeholder:e,...s},i)=>{const l=v.useContext(nl);return v.Children.toArray(s.children),o.jsx("span",{ref:i,className:ge("pointer-events-none",t),...s,children:l?.value||e})});D1.displayName="SelectValue";const P1=v.forwardRef(({className:t,children:e,position:s="popper",...i},l)=>v.useContext(nl)?.open?o.jsx("div",{ref:l,className:ge("absolute z-50 min-w-[8rem] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md animate-in fade-in-80 mt-1",s==="popper"&&"translate-y-1",t),...i,children:o.jsx("div",{className:"p-1 bg-white dark:bg-zinc-950",children:e})}):null);P1.displayName="SelectContent";const z1=v.forwardRef(({className:t,children:e,value:s,...i},l)=>{const u=v.useContext(nl);return o.jsxs("div",{ref:l,className:ge("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none hover:bg-accent hover:text-accent-foreground cursor-pointer",t),onClick:()=>{u?.onValueChange?.(s),u?.setOpen(!1)},...i,children:[o.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u?.value===s&&o.jsx("svg",{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",className:"h-4 w-4",children:o.jsx("polyline",{points:"20 6 9 17 4 12"})})}),o.jsx("span",{className:"truncate",children:e})]})});z1.displayName="SelectItem";const o5=[{value:"us-east-1",label:"US East (N. Virginia)"},{value:"us-west-1",label:"US West (N. California)"},{value:"eu-central-1",label:"Europe (Frankfurt)"},{value:"ap-southeast-1",label:"Asia Pacific (Singapore)"}];function l5({organizations:t,selectedOrg:e,projectName:s,region:i,onOrgSelect:l,onProjectNameChange:u,onRegionChange:d,onProvision:h,onBack:m}){return o.jsxs("div",{className:"flex flex-col gap-6 animate-in fade-in slide-in-from-right-4 duration-500",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Provisioning Parameters"}),o.jsx("p",{className:"text-muted-foreground text-sm",children:"Choose an organization and project configuration for Folio deployment."})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"project-name",children:"Project Name"}),o.jsx(je,{id:"project-name",value:s,onChange:g=>u(g.target.value),placeholder:"my-folio-app"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"region",children:"Region"}),o.jsxs(r5,{value:i,onValueChange:d,children:[o.jsx(M1,{id:"region",children:o.jsx(D1,{placeholder:"Select region"})}),o.jsx(P1,{children:o5.map(g=>o.jsx(z1,{value:g.value,children:g.label},g.value))})]})]})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs(Je,{className:"flex items-center gap-2",children:[o.jsx(Pk,{className:"w-4 h-4"}),"Select Organization"]}),o.jsx("div",{className:"grid gap-2 max-h-[160px] overflow-y-auto p-1 rounded-lg border bg-muted/20",children:t.map(g=>o.jsxs("button",{onClick:()=>l(g.id),className:ge("flex items-center justify-between p-3 rounded-md border text-sm transition-all",e===g.id?"bg-primary text-primary-foreground border-primary shadow-sm":"bg-background hover:border-primary/50"),children:[o.jsx("span",{children:g.name}),e===g.id&&o.jsx(dC,{className:"w-3 h-3 opacity-70"})]},g.id))})]}),o.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[o.jsxs(ae,{variant:"ghost",size:"sm",className:"text-muted-foreground",onClick:m,children:[o.jsx(Jo,{className:"w-4 h-4 mr-1"}),"Back"]}),o.jsxs(ae,{className:"ml-auto",onClick:h,disabled:!e||!s,children:[o.jsx(UC,{className:"mr-2 h-4 w-4"}),"Auto-Provision"]})]})]})}function c5({accessToken:t,error:e,isFetching:s,onTokenChange:i,onFetchOrgs:l,onBack:u}){const d=O1(t);return o.jsxs("div",{className:"flex flex-col gap-6 animate-in fade-in slide-in-from-right-4 duration-500",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Supabase Access Token"}),o.jsxs("p",{className:"text-muted-foreground text-sm",children:["Enter a management token (",o.jsx("code",{className:"text-primary",children:"sbp_..."}),") so Folio can discover organizations and provision a project."]})]}),o.jsx("div",{className:"grid gap-4",children:o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"access-token",children:"Personal Access Token"}),o.jsxs("div",{className:"relative",children:[o.jsx(Zo,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),o.jsx(je,{id:"access-token",type:"password",value:t,onChange:h=>i(h.target.value),placeholder:"sbp_xxxxxxxxxxxxx",className:ge("pl-9",!d.valid&&t.length>0?"border-destructive focus-visible:ring-destructive":"")})]}),t.length>0&&o.jsxs("p",{className:ge("text-xs flex items-center gap-1",d.valid?"text-emerald-500":"text-destructive"),children:[d.valid?o.jsx(os,{className:"w-3"}):o.jsx(Sn,{className:"w-3"}),d.message]})]})}),e&&o.jsxs(jn,{variant:"destructive",children:[o.jsx(Sn,{className:"h-4 w-4"}),o.jsx(_n,{children:e})]}),o.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[o.jsxs(ae,{variant:"ghost",size:"sm",className:"text-muted-foreground",onClick:u,disabled:s,children:[o.jsx(Jo,{className:"w-4 h-4 mr-1"}),"Back"]}),o.jsx(ae,{className:"ml-auto",onClick:l,disabled:!d.valid||s,children:s?o.jsxs(o.Fragment,{children:[o.jsx(rt,{className:"mr-2 h-4 w-4 animate-spin"}),"Fetching..."]}):"Fetch Organizations"})]})]})}function L1({logs:t}){const e=v.useRef(null);return v.useEffect(()=>{e.current?.scrollIntoView({behavior:"smooth"})},[t]),o.jsxs("div",{className:"bg-zinc-950 rounded-xl border border-zinc-800 overflow-hidden shadow-2xl flex flex-col h-[300px]",role:"log","aria-live":"polite","aria-label":"Setup logs",children:[o.jsxs("div",{className:"flex items-center gap-1.5 px-4 py-2 border-b border-zinc-800 bg-zinc-900/50",children:[o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-500/80"}),o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-amber-500/80"}),o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-emerald-500/80"}),o.jsx("span",{className:"ml-2 text-[10px] uppercase tracking-widest text-zinc-500 font-bold",children:"Foundation Trace"})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-4 font-mono text-[13px] leading-relaxed scrollbar-thin scrollbar-thumb-zinc-800",children:[t.length===0?o.jsx("div",{className:"text-zinc-600 italic",children:"Awaiting setup activity..."}):t.map((s,i)=>o.jsxs("div",{className:ge("mb-1 flex gap-3",s.type==="error"&&"text-red-400",s.type==="success"&&"text-emerald-400",s.type==="info"&&"text-blue-400",s.type==="stderr"&&"text-amber-400",s.type==="stdout"&&"text-zinc-300"),children:[o.jsx("span",{className:"text-zinc-600 shrink-0 select-none",children:new Date(s.timestamp).toLocaleTimeString([],{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}),o.jsx("span",{className:"break-all",children:s.message})]},`${s.timestamp}-${s.type}-${s.message}-${i}`)),o.jsx("div",{ref:e})]})]})}function u5({logs:t,error:e,isMigrating:s,migrationStatus:i,accessToken:l,onTokenChange:u,onRunMigration:d,onBypass:h}){const m=i?!i.needsMigration:!1;return o.jsxs("div",{className:"flex flex-col gap-6 animate-in fade-in slide-in-from-right-4 duration-500",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Database Migration"}),o.jsx("p",{className:"text-muted-foreground text-sm",children:i?.message||`Run migration to align database with app v${ha}.`})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(Je,{htmlFor:"migration-token",className:"flex items-center gap-2",children:[o.jsx(Zo,{className:"w-4 h-4"}),"Supabase Access Token"]}),o.jsx(je,{id:"migration-token",type:"password",value:l,onChange:g=>u(g.target.value),placeholder:"sbp_xxxxxxxxxxxxx"})]}),o.jsx(L1,{logs:t}),e&&o.jsxs(jn,{variant:"destructive",children:[o.jsx(Sn,{className:"h-4 w-4"}),o.jsx(_n,{children:e})]}),o.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[m&&o.jsx(ae,{variant:"ghost",size:"sm",onClick:h,disabled:s,children:"Skip for now"}),o.jsx(ae,{className:"ml-auto",onClick:d,disabled:s||l.trim()==="",children:s?o.jsxs(o.Fragment,{children:[o.jsx(rt,{className:"mr-2 h-4 w-4 animate-spin"}),"Migrating..."]}):o.jsxs(o.Fragment,{children:[o.jsx(qw,{className:"mr-2 h-4 w-4"}),"Run Migration"]})})]})]})}function d5({logs:t,error:e,onRetry:s}){return o.jsxs("div",{className:"flex flex-col gap-6 animate-in fade-in slide-in-from-right-4 duration-500",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Provisioning"}),o.jsxs("p",{className:"text-muted-foreground text-sm flex items-center gap-2",children:[!e&&o.jsx(rt,{className:"w-4 h-4 animate-spin text-primary"}),"Folio is creating a Supabase project and preparing runtime credentials."]})]}),o.jsx(L1,{logs:t}),e?o.jsx("div",{className:"flex items-center gap-3",children:o.jsxs(ae,{variant:"destructive",onClick:s,children:[o.jsx(Sn,{className:"w-4 h-4 mr-2"}),"Retry Provisioning"]})}):null]})}function h5({onManaged:t,onManual:e,onBack:s}){return o.jsxs("div",{className:"flex flex-col h-full justify-center gap-10 animate-in fade-in slide-in-from-right-4 duration-500",children:[o.jsxs("div",{className:"space-y-3",children:[o.jsx("h2",{className:"text-4xl font-black tracking-tight",children:"Setup Mode"}),o.jsx("p",{className:"text-muted-foreground text-lg leading-relaxed max-w-md",children:"Select whether Folio should auto-provision a project or connect to an existing one."})]}),o.jsxs("div",{className:"grid gap-6",children:[o.jsxs("button",{onClick:t,className:"group relative flex flex-col items-start p-8 text-left border border-border/40 rounded-3xl hover:border-primary hover:bg-primary/5 hover:shadow-xl hover:shadow-primary/5 transition-all duration-300",children:[o.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[o.jsx("div",{className:"w-12 h-12 rounded-2xl bg-primary/10 flex items-center justify-center text-primary group-hover:scale-110 transition-transform duration-500",children:o.jsx(hu,{className:"w-6 h-6 fill-primary/20"})}),o.jsx("strong",{className:"text-xl font-bold",children:"Managed Setup"})]}),o.jsx("span",{className:"text-muted-foreground leading-relaxed",children:"Use an access token to auto-provision project + run migration automatically. Recommended for most users."}),o.jsx("div",{className:"absolute top-8 right-8 opacity-0 group-hover:opacity-100 transition-opacity duration-300",children:o.jsx(dr,{className:"w-6 h-6 text-primary"})})]}),o.jsxs("button",{onClick:e,className:"group relative flex flex-col items-start p-8 text-left border border-border/40 rounded-3xl hover:border-primary hover:bg-primary/5 hover:shadow-xl hover:shadow-primary/5 transition-all duration-300",children:[o.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[o.jsx("div",{className:"w-12 h-12 rounded-2xl bg-muted flex items-center justify-center text-muted-foreground group-hover:bg-primary/10 group-hover:text-primary group-hover:scale-110 transition-all duration-500",children:o.jsx($m,{className:"w-6 h-6"})}),o.jsx("strong",{className:"text-xl font-bold",children:"Manual Connection"})]}),o.jsx("span",{className:"text-muted-foreground leading-relaxed",children:"Provide your own Supabase URL + anon key. Use this if you already have a configured project."}),o.jsx("div",{className:"absolute top-8 right-8 opacity-0 group-hover:opacity-100 transition-opacity duration-300",children:o.jsx(dr,{className:"w-6 h-6 text-primary"})})]})]}),o.jsx("div",{className:"pt-4",children:o.jsxs(ae,{variant:"ghost",size:"sm",className:"w-fit -ml-2 text-muted-foreground hover:text-foreground h-10 px-4 rounded-xl font-bold",onClick:s,children:[o.jsx(Jo,{className:"w-4 h-4 mr-1"}),"Back to Welcome"]})})]})}function f5({onNext:t}){return o.jsxs("div",{className:"flex flex-col h-full justify-center gap-12 animate-in fade-in slide-in-from-bottom-4 duration-700",children:[o.jsxs("div",{className:"space-y-4 text-center sm:text-left",children:[o.jsxs("h2",{className:"text-5xl font-black tracking-tight leading-tight",children:["Welcome to ",o.jsx("span",{className:"text-primary",children:"Folio"})]}),o.jsx("p",{className:"text-muted-foreground text-lg max-w-lg leading-relaxed",children:"Let's configure your foundation runtime: local desktop app, remote Supabase database, and RealTimeX SDK backend connectivity."})]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-6",children:[o.jsxs(ht,{className:"bg-muted/30 border-border/40 shadow-sm hover:shadow-md transition-all duration-300",children:[o.jsx(zt,{className:"pb-3 px-6",children:o.jsxs(Lt,{className:"flex items-center gap-2 text-base font-bold",children:[o.jsx(ya,{className:"w-5 h-5 text-primary"}),"Secure by Default"]})}),o.jsx(xt,{className:"px-6 pb-6",children:o.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"Credentials are stored locally and used to configure runtime contracts only."})})]}),o.jsxs(ht,{className:"bg-muted/30 border-border/40 shadow-sm hover:shadow-md transition-all duration-300",children:[o.jsx(zt,{className:"pb-3 px-6",children:o.jsxs(Lt,{className:"flex items-center gap-2 text-base font-bold",children:[o.jsx(xC,{className:"w-5 h-5 text-primary"}),"No Feature Lock-In"]})}),o.jsx(xt,{className:"px-6 pb-6",children:o.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"This step only prepares infrastructure, not document automation features."})})]})]}),o.jsx("div",{className:"pt-4 flex justify-center sm:justify-start",children:o.jsx(ae,{size:"lg",className:"h-14 px-10 rounded-2xl text-base font-black shadow-xl shadow-primary/20 hover:scale-105 transition-all",onClick:t,children:"Start Setup"})})]})}function m5({onComplete:t,open:e=!0,canClose:s=!1}){const[i,l]=v.useReducer(n5,om),u=v.useRef("");v.useEffect(()=>()=>{u.current=""},[]);const d=v.useCallback((j,_)=>{l({type:"ADD_LOG",payload:{type:j,message:_}})},[]),h=v.useCallback(()=>{u.current="",t()},[t]),m=v.useCallback(async()=>{l({type:"SET_ERROR",payload:null}),l({type:"SET_FETCHING_ORGS",payload:!0});const j=i.managed.accessToken.trim(),_=O1(j);if(!_.valid){l({type:"SET_ERROR",payload:_.message||"Invalid token"}),l({type:"SET_FETCHING_ORGS",payload:!1});return}try{u.current=j;const N=await QO(j);l({type:"SET_ORGANIZATIONS",payload:N}),l({type:"SET_STEP",payload:"managed-org"})}catch(N){const k=N instanceof is?N.message:String(N);l({type:"SET_ERROR",payload:k})}finally{l({type:"SET_FETCHING_ORGS",payload:!1})}},[i.managed.accessToken]),g=v.useCallback(async j=>{const _=j?.projectRef||i.projectId||O0(i.manual.url),N=j?.accessToken||u.current||i.managed.accessToken.trim(),k=j?.url||i.manual.url,C=j?.anonKey||i.manual.anonKey;if(!_||!N){l({type:"SET_ERROR",payload:"Project ID and access token are required for migration."});return}l({type:"SET_STEP",payload:"migration"}),l({type:"SET_ERROR",payload:null}),l({type:"SET_MIGRATING",payload:!0}),l({type:"CLEAR_LOGS"});let A=!1;try{if(await t5({projectRef:_,accessToken:N,anonKey:C},D=>{if(D.type==="stdout"){d("stdout",String(D.data));return}if(D.type==="stderr"){d("stderr",String(D.data));return}if(D.type==="info"){d("info",String(D.data));return}if(D.type==="error"){d("error",String(D.data));return}D.type==="done"&&(A=D.data==="success")}),!A)throw new Error("Migration did not complete successfully.");k&&C&&hf({url:Sf(k),anonKey:C.trim()}),d("success","Migration completed. Setup is ready."),setTimeout(()=>h(),600)}catch(D){const z=D instanceof is?D.message:String(D);l({type:"SET_ERROR",payload:z}),d("error",z)}finally{l({type:"SET_MIGRATING",payload:!1})}},[d,h,i.managed.accessToken,i.manual.anonKey,i.manual.url,i.projectId]),y=v.useCallback(async()=>{l({type:"SET_ERROR",payload:null}),l({type:"SET_STEP",payload:"provisioning"}),l({type:"CLEAR_LOGS"}),d("info","Starting managed provisioning...");const j=u.current||i.managed.accessToken.trim(),_={result:null,projectId:"",receivedDone:!1,receivedError:!1},N=k=>{_.result=k,l({type:"SET_PROJECT_ID",payload:k.projectId}),hf({url:Sf(k.url),anonKey:k.anonKey.trim()}),l({type:"SET_MIGRATION_STATUS",payload:{needsMigration:!0,appVersion:ha,latestMigrationTimestamp:null,message:"Fresh project created. Migration is required."}}),d("success","Project ready. Starting migration...")};try{if(await ZO({accessToken:j,orgId:i.managed.selectedOrg,projectName:i.managed.projectName,region:i.managed.region},k=>{if(k.type==="project_id"){_.projectId=String(k.data),l({type:"SET_PROJECT_ID",payload:_.projectId});return}if(k.type==="info"){d("info",String(k.data));return}if(k.type==="error"){_.receivedError=!0,d("error",String(k.data)),l({type:"SET_ERROR",payload:String(k.data)});return}if(k.type==="success"){N(k.data);return}k.type==="done"&&(_.receivedDone=!0)}),!_.result&&_.projectId){d("info","Provisioning stream disconnected. Recovering credentials from existing project...");const k=await e5({accessToken:j,projectRef:_.projectId});N(k)}if(!_.result){const k=_.receivedError?"Provisioning failed before credentials were available. Retry or use manual setup.":_.receivedDone?"Provisioning ended without credentials. Retry or use manual setup.":"Provisioning stream ended unexpectedly. The project may still be provisioning; retry in a moment.";throw new is(k,"PROVISION_INCOMPLETE")}await g({projectRef:_.result.projectId,accessToken:j,url:_.result.url,anonKey:_.result.anonKey})}catch(k){const C=k instanceof is?k.message:String(k);l({type:"SET_ERROR",payload:C}),d("error",C)}},[d,g,i.managed.accessToken,i.managed.projectName,i.managed.region,i.managed.selectedOrg]),x=v.useCallback(async()=>{l({type:"SET_ERROR",payload:null}),l({type:"SET_STEP",payload:"validating"});const j=Sf(i.manual.url),_=i.manual.anonKey.trim(),N=await SA(j,_);if(!N.valid){l({type:"SET_ERROR",payload:N.error||"Connection validation failed."}),l({type:"SET_STEP",payload:"credentials"});return}hf({url:j,anonKey:_}),l({type:"SET_MANUAL_URL",payload:j});const k=O0(j);k&&l({type:"SET_PROJECT_ID",payload:k});try{const C=zm(j,_),A=await Qw(C);l({type:"SET_MIGRATION_STATUS",payload:{needsMigration:A.needsMigration,appVersion:A.appVersion,latestMigrationTimestamp:A.latestMigrationTimestamp,message:A.message}}),A.needsMigration?l({type:"SET_STEP",payload:"migration"}):h()}catch{l({type:"SET_MIGRATION_STATUS",payload:{needsMigration:!0,appVersion:ha,latestMigrationTimestamp:null,message:"Could not verify migration status. Run migration to continue."}}),l({type:"SET_STEP",payload:"migration"})}},[h,i.manual.anonKey,i.manual.url]);if(!e)return null;const w=[{key:"welcome",label:"Welcome"},{key:"config",label:"Configuration",subSteps:["type","managed-token","managed-org","credentials"]},{key:"validation",label:"Validation",subSteps:["provisioning","validating"]},{key:"migration",label:"Migration"}],E=i.step==="welcome"?"welcome":["type","managed-token","managed-org","credentials"].includes(i.step)?"config":["provisioning","validating"].includes(i.step)?"validation":"migration";return o.jsxs(Za,{open:e,onOpenChange:j=>{!j&&s&&t()},children:[o.jsx(A1,{className:"bg-zinc-950/80 backdrop-blur-sm"}),o.jsx(ei,{className:"sm:max-w-[1100px] w-full p-0 overflow-hidden border-none shadow-2xl",children:o.jsxs("div",{className:"flex w-full min-h-[700px]",children:[o.jsxs("aside",{className:"w-[300px] border-r bg-muted/30 p-8 flex flex-col gap-10",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Folio Setup"}),o.jsx("p",{className:"text-xs text-muted-foreground font-medium uppercase tracking-wider",children:"Foundation Parity Mode"})]}),o.jsx("nav",{className:"flex-1",children:o.jsx("ul",{className:"space-y-4",children:w.map(j=>{const _=E===j.key,N=w.findIndex(k=>k.key===E)>w.findIndex(k=>k.key===j.key);return o.jsxs("li",{className:"flex items-center gap-3",children:[o.jsx("div",{className:ge("w-6 h-6 rounded-full flex items-center justify-center border transition-all duration-300",_?"border-primary bg-primary text-primary-foreground shadow-sm scale-110":N?"border-emerald-500 bg-emerald-50 text-emerald-500":"border-muted text-muted-foreground"),children:N?o.jsx(os,{className:"w-4 h-4"}):o.jsx("div",{className:"text-[10px] font-bold",children:w.indexOf(j)+1})}),o.jsx("span",{className:ge("text-sm font-medium transition-colors",_?"text-foreground":"text-muted-foreground"),children:j.label})]},j.key)})})}),o.jsxs("div",{className:"mt-auto pt-6 border-t flex items-center justify-between",children:[o.jsxs("span",{className:"text-[10px] font-bold text-muted-foreground/50 uppercase tracking-widest",children:["Version ",ha]}),o.jsx(Pt,{variant:"outline",className:"text-[10px] py-0 h-4",children:"Production"})]})]}),o.jsx("main",{className:"flex-1 p-12 bg-background relative flex flex-col",children:o.jsxs("div",{className:"max-w-[700px] w-full mx-auto flex-1",children:[i.step==="welcome"&&o.jsx(f5,{onNext:()=>l({type:"SET_STEP",payload:"type"})}),i.step==="type"&&o.jsx(h5,{onManaged:()=>{l({type:"RESET_MANUAL_FLOW"}),l({type:"SET_STEP",payload:"managed-token"})},onManual:()=>{l({type:"RESET_MANAGED_FLOW"}),l({type:"SET_STEP",payload:"credentials"})},onBack:()=>l({type:"SET_STEP",payload:"welcome"})}),i.step==="managed-token"&&o.jsx(c5,{accessToken:i.managed.accessToken,error:i.error,isFetching:i.managed.isFetchingOrgs,onTokenChange:j=>l({type:"SET_ACCESS_TOKEN",payload:j}),onFetchOrgs:m,onBack:()=>l({type:"SET_STEP",payload:"type"})}),i.step==="managed-org"&&o.jsx(l5,{organizations:i.managed.organizations,selectedOrg:i.managed.selectedOrg,projectName:i.managed.projectName,region:i.managed.region,onOrgSelect:j=>l({type:"SET_SELECTED_ORG",payload:j}),onProjectNameChange:j=>l({type:"SET_PROJECT_NAME",payload:j}),onRegionChange:j=>l({type:"SET_REGION",payload:j}),onProvision:y,onBack:()=>l({type:"SET_STEP",payload:"managed-token"})}),i.step==="provisioning"&&o.jsx(d5,{logs:i.logs,error:i.error,onRetry:()=>l({type:"SET_STEP",payload:"managed-token"})}),i.step==="credentials"&&o.jsx(i5,{url:i.manual.url,anonKey:i.manual.anonKey,error:i.error,onUrlChange:j=>l({type:"SET_MANUAL_URL",payload:j}),onAnonKeyChange:j=>l({type:"SET_MANUAL_ANON_KEY",payload:j}),onSave:x,onBack:()=>l({type:"SET_STEP",payload:"type"})}),i.step==="validating"&&o.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center space-y-4 animate-in fade-in zoom-in-95 duration-500",children:[o.jsx("div",{className:"w-12 h-12 rounded-full border-4 border-primary border-t-transparent animate-spin"}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("h2",{className:"text-xl font-bold",children:"Validating Credentials"}),o.jsx("p",{className:"text-muted-foreground text-sm",children:"Please wait while Folio verifies your Supabase configuration."})]})]}),i.step==="migration"&&o.jsx(u5,{logs:i.logs,error:i.error,isMigrating:i.isMigrating,migrationStatus:i.migrationStatus,accessToken:i.managed.accessToken,onTokenChange:j=>l({type:"SET_ACCESS_TOKEN",payload:j}),onRunMigration:()=>g(),onBypass:h})]})})]})})]})}const Xm=v.createContext({});function Wm(t){const e=v.useRef(null);return e.current===null&&(e.current=t()),e.current}const U1=typeof window<"u",B1=U1?v.useLayoutEffect:v.useEffect,Du=v.createContext(null);function Jm(t,e){t.indexOf(e)===-1&&t.push(e)}function pu(t,e){const s=t.indexOf(e);s>-1&&t.splice(s,1)}const ls=(t,e,s)=>s>e?e:s<t?t:s;let Qm=()=>{};const As={},V1=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function I1(t){return typeof t=="object"&&t!==null}const $1=t=>/^0[^.\s]+$/u.test(t);function q1(t){let e;return()=>(e===void 0&&(e=t()),e)}const Ln=t=>t,p5=(t,e)=>s=>e(t(s)),sl=(...t)=>t.reduce(p5),Go=(t,e,s)=>{const i=e-t;return i===0?1:(s-t)/i};class Zm{constructor(){this.subscriptions=[]}add(e){return Jm(this.subscriptions,e),()=>pu(this.subscriptions,e)}notify(e,s,i){const l=this.subscriptions.length;if(l)if(l===1)this.subscriptions[0](e,s,i);else for(let u=0;u<l;u++){const d=this.subscriptions[u];d&&d(e,s,i)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Fn=t=>t*1e3,Pn=t=>t/1e3;function H1(t,e){return e?t*(1e3/e):0}const G1=(t,e,s)=>(((1-3*s+3*e)*t+(3*s-6*e))*t+3*e)*t,g5=1e-7,y5=12;function v5(t,e,s,i,l){let u,d,h=0;do d=e+(s-e)/2,u=G1(d,i,l)-t,u>0?s=d:e=d;while(Math.abs(u)>g5&&++h<y5);return d}function al(t,e,s,i){if(t===e&&s===i)return Ln;const l=u=>v5(u,0,1,t,s);return u=>u===0||u===1?u:G1(l(u),e,i)}const F1=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,K1=t=>e=>1-t(1-e),Y1=al(.33,1.53,.69,.99),ep=K1(Y1),X1=F1(ep),W1=t=>(t*=2)<1?.5*ep(t):.5*(2-Math.pow(2,-10*(t-1))),tp=t=>1-Math.sin(Math.acos(t)),J1=K1(tp),Q1=F1(tp),x5=al(.42,0,1,1),b5=al(0,0,.58,1),Z1=al(.42,0,.58,1),w5=t=>Array.isArray(t)&&typeof t[0]!="number",eS=t=>Array.isArray(t)&&typeof t[0]=="number",S5={linear:Ln,easeIn:x5,easeInOut:Z1,easeOut:b5,circIn:tp,circInOut:Q1,circOut:J1,backIn:ep,backInOut:X1,backOut:Y1,anticipate:W1},j5=t=>typeof t=="string",M0=t=>{if(eS(t)){Qm(t.length===4);const[e,s,i,l]=t;return al(e,s,i,l)}else if(j5(t))return S5[t];return t},$c=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function _5(t,e){let s=new Set,i=new Set,l=!1,u=!1;const d=new WeakSet;let h={delta:0,timestamp:0,isProcessing:!1};function m(y){d.has(y)&&(g.schedule(y),t()),y(h)}const g={schedule:(y,x=!1,w=!1)=>{const E=w&&l?s:i;return x&&d.add(y),E.has(y)||E.add(y),y},cancel:y=>{i.delete(y),d.delete(y)},process:y=>{if(h=y,l){u=!0;return}l=!0,[s,i]=[i,s],s.forEach(m),s.clear(),l=!1,u&&(u=!1,g.process(y))}};return g}const N5=40;function tS(t,e){let s=!1,i=!0;const l={delta:0,timestamp:0,isProcessing:!1},u=()=>s=!0,d=$c.reduce((C,A)=>(C[A]=_5(u),C),{}),{setup:h,read:m,resolveKeyframes:g,preUpdate:y,update:x,preRender:w,render:S,postRender:E}=d,j=()=>{const C=As.useManualTiming?l.timestamp:performance.now();s=!1,As.useManualTiming||(l.delta=i?1e3/60:Math.max(Math.min(C-l.timestamp,N5),1)),l.timestamp=C,l.isProcessing=!0,h.process(l),m.process(l),g.process(l),y.process(l),x.process(l),w.process(l),S.process(l),E.process(l),l.isProcessing=!1,s&&e&&(i=!1,t(j))},_=()=>{s=!0,i=!0,l.isProcessing||t(j)};return{schedule:$c.reduce((C,A)=>{const D=d[A];return C[A]=(z,V=!1,R=!1)=>(s||_(),D.schedule(z,V,R)),C},{}),cancel:C=>{for(let A=0;A<$c.length;A++)d[$c[A]].cancel(C)},state:l,steps:d}}const{schedule:lt,cancel:pa,state:Ft,steps:jf}=tS(typeof requestAnimationFrame<"u"?requestAnimationFrame:Ln,!0);let Wc;function T5(){Wc=void 0}const Jt={now:()=>(Wc===void 0&&Jt.set(Ft.isProcessing||As.useManualTiming?Ft.timestamp:performance.now()),Wc),set:t=>{Wc=t,queueMicrotask(T5)}},nS=t=>e=>typeof e=="string"&&e.startsWith(t),sS=nS("--"),E5=nS("var(--"),np=t=>E5(t)?k5.test(t.split("/*")[0].trim()):!1,k5=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function D0(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const yr={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Fo={...yr,transform:t=>ls(0,1,t)},qc={...yr,default:1},Eo=t=>Math.round(t*1e5)/1e5,sp=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function C5(t){return t==null}const A5=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,ap=(t,e)=>s=>!!(typeof s=="string"&&A5.test(s)&&s.startsWith(t)||e&&!C5(s)&&Object.prototype.hasOwnProperty.call(s,e)),aS=(t,e,s)=>i=>{if(typeof i!="string")return i;const[l,u,d,h]=i.match(sp);return{[t]:parseFloat(l),[e]:parseFloat(u),[s]:parseFloat(d),alpha:h!==void 0?parseFloat(h):1}},R5=t=>ls(0,255,t),_f={...yr,transform:t=>Math.round(R5(t))},Ka={test:ap("rgb","red"),parse:aS("red","green","blue"),transform:({red:t,green:e,blue:s,alpha:i=1})=>"rgba("+_f.transform(t)+", "+_f.transform(e)+", "+_f.transform(s)+", "+Eo(Fo.transform(i))+")"};function O5(t){let e="",s="",i="",l="";return t.length>5?(e=t.substring(1,3),s=t.substring(3,5),i=t.substring(5,7),l=t.substring(7,9)):(e=t.substring(1,2),s=t.substring(2,3),i=t.substring(3,4),l=t.substring(4,5),e+=e,s+=s,i+=i,l+=l),{red:parseInt(e,16),green:parseInt(s,16),blue:parseInt(i,16),alpha:l?parseInt(l,16)/255:1}}const lm={test:ap("#"),parse:O5,transform:Ka.transform},il=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),la=il("deg"),rs=il("%"),be=il("px"),M5=il("vh"),D5=il("vw"),P0={...rs,parse:t=>rs.parse(t)/100,transform:t=>rs.transform(t*100)},nr={test:ap("hsl","hue"),parse:aS("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:s,alpha:i=1})=>"hsla("+Math.round(t)+", "+rs.transform(Eo(e))+", "+rs.transform(Eo(s))+", "+Eo(Fo.transform(i))+")"},Et={test:t=>Ka.test(t)||lm.test(t)||nr.test(t),parse:t=>Ka.test(t)?Ka.parse(t):nr.test(t)?nr.parse(t):lm.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Ka.transform(t):nr.transform(t),getAnimatableNone:t=>{const e=Et.parse(t);return e.alpha=0,Et.transform(e)}},P5=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function z5(t){return isNaN(t)&&typeof t=="string"&&(t.match(sp)?.length||0)+(t.match(P5)?.length||0)>0}const iS="number",rS="color",L5="var",U5="var(",z0="${}",B5=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Ko(t){const e=t.toString(),s=[],i={color:[],number:[],var:[]},l=[];let u=0;const h=e.replace(B5,m=>(Et.test(m)?(i.color.push(u),l.push(rS),s.push(Et.parse(m))):m.startsWith(U5)?(i.var.push(u),l.push(L5),s.push(m)):(i.number.push(u),l.push(iS),s.push(parseFloat(m))),++u,z0)).split(z0);return{values:s,split:h,indexes:i,types:l}}function oS(t){return Ko(t).values}function lS(t){const{split:e,types:s}=Ko(t),i=e.length;return l=>{let u="";for(let d=0;d<i;d++)if(u+=e[d],l[d]!==void 0){const h=s[d];h===iS?u+=Eo(l[d]):h===rS?u+=Et.transform(l[d]):u+=l[d]}return u}}const V5=t=>typeof t=="number"?0:Et.test(t)?Et.getAnimatableNone(t):t;function I5(t){const e=oS(t);return lS(t)(e.map(V5))}const Kn={test:z5,parse:oS,createTransformer:lS,getAnimatableNone:I5};function Nf(t,e,s){return s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+(e-t)*6*s:s<1/2?e:s<2/3?t+(e-t)*(2/3-s)*6:t}function $5({hue:t,saturation:e,lightness:s,alpha:i}){t/=360,e/=100,s/=100;let l=0,u=0,d=0;if(!e)l=u=d=s;else{const h=s<.5?s*(1+e):s+e-s*e,m=2*s-h;l=Nf(m,h,t+1/3),u=Nf(m,h,t),d=Nf(m,h,t-1/3)}return{red:Math.round(l*255),green:Math.round(u*255),blue:Math.round(d*255),alpha:i}}function gu(t,e){return s=>s>0?e:t}const mt=(t,e,s)=>t+(e-t)*s,Tf=(t,e,s)=>{const i=t*t,l=s*(e*e-i)+i;return l<0?0:Math.sqrt(l)},q5=[lm,Ka,nr],H5=t=>q5.find(e=>e.test(t));function L0(t){const e=H5(t);if(!e)return!1;let s=e.parse(t);return e===nr&&(s=$5(s)),s}const U0=(t,e)=>{const s=L0(t),i=L0(e);if(!s||!i)return gu(t,e);const l={...s};return u=>(l.red=Tf(s.red,i.red,u),l.green=Tf(s.green,i.green,u),l.blue=Tf(s.blue,i.blue,u),l.alpha=mt(s.alpha,i.alpha,u),Ka.transform(l))},cm=new Set(["none","hidden"]);function G5(t,e){return cm.has(t)?s=>s<=0?t:e:s=>s>=1?e:t}function F5(t,e){return s=>mt(t,e,s)}function ip(t){return typeof t=="number"?F5:typeof t=="string"?np(t)?gu:Et.test(t)?U0:X5:Array.isArray(t)?cS:typeof t=="object"?Et.test(t)?U0:K5:gu}function cS(t,e){const s=[...t],i=s.length,l=t.map((u,d)=>ip(u)(u,e[d]));return u=>{for(let d=0;d<i;d++)s[d]=l[d](u);return s}}function K5(t,e){const s={...t,...e},i={};for(const l in s)t[l]!==void 0&&e[l]!==void 0&&(i[l]=ip(t[l])(t[l],e[l]));return l=>{for(const u in i)s[u]=i[u](l);return s}}function Y5(t,e){const s=[],i={color:0,var:0,number:0};for(let l=0;l<e.values.length;l++){const u=e.types[l],d=t.indexes[u][i[u]],h=t.values[d]??0;s[l]=h,i[u]++}return s}const X5=(t,e)=>{const s=Kn.createTransformer(e),i=Ko(t),l=Ko(e);return i.indexes.var.length===l.indexes.var.length&&i.indexes.color.length===l.indexes.color.length&&i.indexes.number.length>=l.indexes.number.length?cm.has(t)&&!l.values.length||cm.has(e)&&!i.values.length?G5(t,e):sl(cS(Y5(i,l),l.values),s):gu(t,e)};function uS(t,e,s){return typeof t=="number"&&typeof e=="number"&&typeof s=="number"?mt(t,e,s):ip(t)(t,e)}const W5=t=>{const e=({timestamp:s})=>t(s);return{start:(s=!0)=>lt.update(e,s),stop:()=>pa(e),now:()=>Ft.isProcessing?Ft.timestamp:Jt.now()}},dS=(t,e,s=10)=>{let i="";const l=Math.max(Math.round(e/s),2);for(let u=0;u<l;u++)i+=Math.round(t(u/(l-1))*1e4)/1e4+", ";return`linear(${i.substring(0,i.length-2)})`},yu=2e4;function rp(t){let e=0;const s=50;let i=t.next(e);for(;!i.done&&e<yu;)e+=s,i=t.next(e);return e>=yu?1/0:e}function J5(t,e=100,s){const i=s({...t,keyframes:[0,e]}),l=Math.min(rp(i),yu);return{type:"keyframes",ease:u=>i.next(l*u).value/e,duration:Pn(l)}}const Q5=5;function hS(t,e,s){const i=Math.max(e-Q5,0);return H1(s-t(i),e-i)}const vt={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},Ef=.001;function Z5({duration:t=vt.duration,bounce:e=vt.bounce,velocity:s=vt.velocity,mass:i=vt.mass}){let l,u,d=1-e;d=ls(vt.minDamping,vt.maxDamping,d),t=ls(vt.minDuration,vt.maxDuration,Pn(t)),d<1?(l=g=>{const y=g*d,x=y*t,w=y-s,S=um(g,d),E=Math.exp(-x);return Ef-w/S*E},u=g=>{const x=g*d*t,w=x*s+s,S=Math.pow(d,2)*Math.pow(g,2)*t,E=Math.exp(-x),j=um(Math.pow(g,2),d);return(-l(g)+Ef>0?-1:1)*((w-S)*E)/j}):(l=g=>{const y=Math.exp(-g*t),x=(g-s)*t+1;return-Ef+y*x},u=g=>{const y=Math.exp(-g*t),x=(s-g)*(t*t);return y*x});const h=5/t,m=t4(l,u,h);if(t=Fn(t),isNaN(m))return{stiffness:vt.stiffness,damping:vt.damping,duration:t};{const g=Math.pow(m,2)*i;return{stiffness:g,damping:d*2*Math.sqrt(i*g),duration:t}}}const e4=12;function t4(t,e,s){let i=s;for(let l=1;l<e4;l++)i=i-t(i)/e(i);return i}function um(t,e){return t*Math.sqrt(1-e*e)}const n4=["duration","bounce"],s4=["stiffness","damping","mass"];function B0(t,e){return e.some(s=>t[s]!==void 0)}function a4(t){let e={velocity:vt.velocity,stiffness:vt.stiffness,damping:vt.damping,mass:vt.mass,isResolvedFromDuration:!1,...t};if(!B0(t,s4)&&B0(t,n4))if(e.velocity=0,t.visualDuration){const s=t.visualDuration,i=2*Math.PI/(s*1.2),l=i*i,u=2*ls(.05,1,1-(t.bounce||0))*Math.sqrt(l);e={...e,mass:vt.mass,stiffness:l,damping:u}}else{const s=Z5({...t,velocity:0});e={...e,...s,mass:vt.mass},e.isResolvedFromDuration=!0}return e}function vu(t=vt.visualDuration,e=vt.bounce){const s=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:i,restDelta:l}=s;const u=s.keyframes[0],d=s.keyframes[s.keyframes.length-1],h={done:!1,value:u},{stiffness:m,damping:g,mass:y,duration:x,velocity:w,isResolvedFromDuration:S}=a4({...s,velocity:-Pn(s.velocity||0)}),E=w||0,j=g/(2*Math.sqrt(m*y)),_=d-u,N=Pn(Math.sqrt(m/y)),k=Math.abs(_)<5;i||(i=k?vt.restSpeed.granular:vt.restSpeed.default),l||(l=k?vt.restDelta.granular:vt.restDelta.default);let C;if(j<1){const D=um(N,j);C=z=>{const V=Math.exp(-j*N*z);return d-V*((E+j*N*_)/D*Math.sin(D*z)+_*Math.cos(D*z))}}else if(j===1)C=D=>d-Math.exp(-N*D)*(_+(E+N*_)*D);else{const D=N*Math.sqrt(j*j-1);C=z=>{const V=Math.exp(-j*N*z),R=Math.min(D*z,300);return d-V*((E+j*N*_)*Math.sinh(R)+D*_*Math.cosh(R))/D}}const A={calculatedDuration:S&&x||null,next:D=>{const z=C(D);if(S)h.done=D>=x;else{let V=D===0?E:0;j<1&&(V=D===0?Fn(E):hS(C,D,z));const R=Math.abs(V)<=i,P=Math.abs(d-z)<=l;h.done=R&&P}return h.value=h.done?d:z,h},toString:()=>{const D=Math.min(rp(A),yu),z=dS(V=>A.next(D*V).value,D,30);return D+"ms "+z},toTransition:()=>{}};return A}vu.applyToOptions=t=>{const e=J5(t,100,vu);return t.ease=e.ease,t.duration=Fn(e.duration),t.type="keyframes",t};function dm({keyframes:t,velocity:e=0,power:s=.8,timeConstant:i=325,bounceDamping:l=10,bounceStiffness:u=500,modifyTarget:d,min:h,max:m,restDelta:g=.5,restSpeed:y}){const x=t[0],w={done:!1,value:x},S=R=>h!==void 0&&R<h||m!==void 0&&R>m,E=R=>h===void 0?m:m===void 0||Math.abs(h-R)<Math.abs(m-R)?h:m;let j=s*e;const _=x+j,N=d===void 0?_:d(_);N!==_&&(j=N-x);const k=R=>-j*Math.exp(-R/i),C=R=>N+k(R),A=R=>{const P=k(R),Z=C(R);w.done=Math.abs(P)<=g,w.value=w.done?N:Z};let D,z;const V=R=>{S(w.value)&&(D=R,z=vu({keyframes:[w.value,E(w.value)],velocity:hS(C,R,w.value),damping:l,stiffness:u,restDelta:g,restSpeed:y}))};return V(0),{calculatedDuration:null,next:R=>{let P=!1;return!z&&D===void 0&&(P=!0,A(R),V(R)),D!==void 0&&R>=D?z.next(R-D):(!P&&A(R),w)}}}function i4(t,e,s){const i=[],l=s||As.mix||uS,u=t.length-1;for(let d=0;d<u;d++){let h=l(t[d],t[d+1]);if(e){const m=Array.isArray(e)?e[d]||Ln:e;h=sl(m,h)}i.push(h)}return i}function r4(t,e,{clamp:s=!0,ease:i,mixer:l}={}){const u=t.length;if(Qm(u===e.length),u===1)return()=>e[0];if(u===2&&e[0]===e[1])return()=>e[1];const d=t[0]===t[1];t[0]>t[u-1]&&(t=[...t].reverse(),e=[...e].reverse());const h=i4(e,i,l),m=h.length,g=y=>{if(d&&y<t[0])return e[0];let x=0;if(m>1)for(;x<t.length-2&&!(y<t[x+1]);x++);const w=Go(t[x],t[x+1],y);return h[x](w)};return s?y=>g(ls(t[0],t[u-1],y)):g}function o4(t,e){const s=t[t.length-1];for(let i=1;i<=e;i++){const l=Go(0,e,i);t.push(mt(s,1,l))}}function l4(t){const e=[0];return o4(e,t.length-1),e}function c4(t,e){return t.map(s=>s*e)}function u4(t,e){return t.map(()=>e||Z1).splice(0,t.length-1)}function ko({duration:t=300,keyframes:e,times:s,ease:i="easeInOut"}){const l=w5(i)?i.map(M0):M0(i),u={done:!1,value:e[0]},d=c4(s&&s.length===e.length?s:l4(e),t),h=r4(d,e,{ease:Array.isArray(l)?l:u4(e,l)});return{calculatedDuration:t,next:m=>(u.value=h(m),u.done=m>=t,u)}}const d4=t=>t!==null;function op(t,{repeat:e,repeatType:s="loop"},i,l=1){const u=t.filter(d4),h=l<0||e&&s!=="loop"&&e%2===1?0:u.length-1;return!h||i===void 0?u[h]:i}const h4={decay:dm,inertia:dm,tween:ko,keyframes:ko,spring:vu};function fS(t){typeof t.type=="string"&&(t.type=h4[t.type])}class lp{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,s){return this.finished.then(e,s)}}const f4=t=>t/100;class cp extends lp{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:s}=this.options;s&&s.updatedAt!==Jt.now()&&this.tick(Jt.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;fS(e);const{type:s=ko,repeat:i=0,repeatDelay:l=0,repeatType:u,velocity:d=0}=e;let{keyframes:h}=e;const m=s||ko;m!==ko&&typeof h[0]!="number"&&(this.mixKeyframes=sl(f4,uS(h[0],h[1])),h=[0,100]);const g=m({...e,keyframes:h});u==="mirror"&&(this.mirroredGenerator=m({...e,keyframes:[...h].reverse(),velocity:-d})),g.calculatedDuration===null&&(g.calculatedDuration=rp(g));const{calculatedDuration:y}=g;this.calculatedDuration=y,this.resolvedDuration=y+l,this.totalDuration=this.resolvedDuration*(i+1)-l,this.generator=g}updateTime(e){const s=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=s}tick(e,s=!1){const{generator:i,totalDuration:l,mixKeyframes:u,mirroredGenerator:d,resolvedDuration:h,calculatedDuration:m}=this;if(this.startTime===null)return i.next(0);const{delay:g=0,keyframes:y,repeat:x,repeatType:w,repeatDelay:S,type:E,onUpdate:j,finalKeyframe:_}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-l/this.speed,this.startTime)),s?this.currentTime=e:this.updateTime(e);const N=this.currentTime-g*(this.playbackSpeed>=0?1:-1),k=this.playbackSpeed>=0?N<0:N>l;this.currentTime=Math.max(N,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=l);let C=this.currentTime,A=i;if(x){const R=Math.min(this.currentTime,l)/h;let P=Math.floor(R),Z=R%1;!Z&&R>=1&&(Z=1),Z===1&&P--,P=Math.min(P,x+1),P%2&&(w==="reverse"?(Z=1-Z,S&&(Z-=S/h)):w==="mirror"&&(A=d)),C=ls(0,1,Z)*h}const D=k?{done:!1,value:y[0]}:A.next(C);u&&(D.value=u(D.value));let{done:z}=D;!k&&m!==null&&(z=this.playbackSpeed>=0?this.currentTime>=l:this.currentTime<=0);const V=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&z);return V&&E!==dm&&(D.value=op(y,this.options,_,this.speed)),j&&j(D.value),V&&this.finish(),D}then(e,s){return this.finished.then(e,s)}get duration(){return Pn(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+Pn(e)}get time(){return Pn(this.currentTime)}set time(e){e=Fn(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(Jt.now());const s=this.playbackSpeed!==e;this.playbackSpeed=e,s&&(this.time=Pn(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=W5,startTime:s}=this.options;this.driver||(this.driver=e(l=>this.tick(l))),this.options.onPlay?.();const i=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=i):this.holdTime!==null?this.startTime=i-this.holdTime:this.startTime||(this.startTime=s??i),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Jt.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function m4(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const Ya=t=>t*180/Math.PI,hm=t=>{const e=Ya(Math.atan2(t[1],t[0]));return fm(e)},p4={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:hm,rotateZ:hm,skewX:t=>Ya(Math.atan(t[1])),skewY:t=>Ya(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},fm=t=>(t=t%360,t<0&&(t+=360),t),V0=hm,I0=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),$0=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),g4={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:I0,scaleY:$0,scale:t=>(I0(t)+$0(t))/2,rotateX:t=>fm(Ya(Math.atan2(t[6],t[5]))),rotateY:t=>fm(Ya(Math.atan2(-t[2],t[0]))),rotateZ:V0,rotate:V0,skewX:t=>Ya(Math.atan(t[4])),skewY:t=>Ya(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function mm(t){return t.includes("scale")?1:0}function pm(t,e){if(!t||t==="none")return mm(e);const s=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let i,l;if(s)i=g4,l=s;else{const h=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);i=p4,l=h}if(!l)return mm(e);const u=i[e],d=l[1].split(",").map(v4);return typeof u=="function"?u(d):d[u]}const y4=(t,e)=>{const{transform:s="none"}=getComputedStyle(t);return pm(s,e)};function v4(t){return parseFloat(t.trim())}const vr=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],xr=new Set(vr),q0=t=>t===yr||t===be,x4=new Set(["x","y","z"]),b4=vr.filter(t=>!x4.has(t));function w4(t){const e=[];return b4.forEach(s=>{const i=t.getValue(s);i!==void 0&&(e.push([s,i.get()]),i.set(s.startsWith("scale")?1:0))}),e}const da={width:({x:t},{paddingLeft:e="0",paddingRight:s="0"})=>t.max-t.min-parseFloat(e)-parseFloat(s),height:({y:t},{paddingTop:e="0",paddingBottom:s="0"})=>t.max-t.min-parseFloat(e)-parseFloat(s),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>pm(e,"x"),y:(t,{transform:e})=>pm(e,"y")};da.translateX=da.x;da.translateY=da.y;const Ja=new Set;let gm=!1,ym=!1,vm=!1;function mS(){if(ym){const t=Array.from(Ja).filter(i=>i.needsMeasurement),e=new Set(t.map(i=>i.element)),s=new Map;e.forEach(i=>{const l=w4(i);l.length&&(s.set(i,l),i.render())}),t.forEach(i=>i.measureInitialState()),e.forEach(i=>{i.render();const l=s.get(i);l&&l.forEach(([u,d])=>{i.getValue(u)?.set(d)})}),t.forEach(i=>i.measureEndState()),t.forEach(i=>{i.suspendedScrollY!==void 0&&window.scrollTo(0,i.suspendedScrollY)})}ym=!1,gm=!1,Ja.forEach(t=>t.complete(vm)),Ja.clear()}function pS(){Ja.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(ym=!0)})}function S4(){vm=!0,pS(),mS(),vm=!1}class up{constructor(e,s,i,l,u,d=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=s,this.name=i,this.motionValue=l,this.element=u,this.isAsync=d}scheduleResolve(){this.state="scheduled",this.isAsync?(Ja.add(this),gm||(gm=!0,lt.read(pS),lt.resolveKeyframes(mS))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:s,element:i,motionValue:l}=this;if(e[0]===null){const u=l?.get(),d=e[e.length-1];if(u!==void 0)e[0]=u;else if(i&&s){const h=i.readValue(s,d);h!=null&&(e[0]=h)}e[0]===void 0&&(e[0]=d),l&&u===void 0&&l.set(e[0])}m4(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Ja.delete(this)}cancel(){this.state==="scheduled"&&(Ja.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const j4=t=>t.startsWith("--");function _4(t,e,s){j4(e)?t.style.setProperty(e,s):t.style[e]=s}const N4={};function gS(t,e){const s=q1(t);return()=>N4[e]??s()}const T4=gS(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),yS=gS(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),So=([t,e,s,i])=>`cubic-bezier(${t}, ${e}, ${s}, ${i})`,H0={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:So([0,.65,.55,1]),circOut:So([.55,0,1,.45]),backIn:So([.31,.01,.66,-.59]),backOut:So([.33,1.53,.69,.99])};function vS(t,e){if(t)return typeof t=="function"?yS()?dS(t,e):"ease-out":eS(t)?So(t):Array.isArray(t)?t.map(s=>vS(s,e)||H0.easeOut):H0[t]}function E4(t,e,s,{delay:i=0,duration:l=300,repeat:u=0,repeatType:d="loop",ease:h="easeOut",times:m}={},g=void 0){const y={[e]:s};m&&(y.offset=m);const x=vS(h,l);Array.isArray(x)&&(y.easing=x);const w={delay:i,duration:l,easing:Array.isArray(x)?"linear":x,fill:"both",iterations:u+1,direction:d==="reverse"?"alternate":"normal"};return g&&(w.pseudoElement=g),t.animate(y,w)}function xS(t){return typeof t=="function"&&"applyToOptions"in t}function k4({type:t,...e}){return xS(t)&&yS()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class bS extends lp{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;const{element:s,name:i,keyframes:l,pseudoElement:u,allowFlatten:d=!1,finalKeyframe:h,onComplete:m}=e;this.isPseudoElement=!!u,this.allowFlatten=d,this.options=e,Qm(typeof e.type!="string");const g=k4(e);this.animation=E4(s,i,l,g,u),g.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!u){const y=op(l,this.options,h,this.speed);this.updateMotionValue?this.updateMotionValue(y):_4(s,i,y),this.animation.cancel()}m?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){const e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return Pn(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+Pn(e)}get time(){return Pn(Number(this.animation.currentTime)||0)}set time(e){this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Fn(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,observe:s}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&T4()?(this.animation.timeline=e,Ln):s(this)}}const wS={anticipate:W1,backInOut:X1,circInOut:Q1};function C4(t){return t in wS}function A4(t){typeof t.ease=="string"&&C4(t.ease)&&(t.ease=wS[t.ease])}const kf=10;class R4 extends bS{constructor(e){A4(e),fS(e),super(e),e.startTime!==void 0&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:s,onUpdate:i,onComplete:l,element:u,...d}=this.options;if(!s)return;if(e!==void 0){s.set(e);return}const h=new cp({...d,autoplay:!1}),m=Math.max(kf,Jt.now()-this.startTime),g=ls(0,kf,m-kf);s.setWithVelocity(h.sample(Math.max(0,m-g)).value,h.sample(m).value,g),h.stop()}}const G0=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Kn.test(t)||t==="0")&&!t.startsWith("url("));function O4(t){const e=t[0];if(t.length===1)return!0;for(let s=0;s<t.length;s++)if(t[s]!==e)return!0}function M4(t,e,s,i){const l=t[0];if(l===null)return!1;if(e==="display"||e==="visibility")return!0;const u=t[t.length-1],d=G0(l,e),h=G0(u,e);return!d||!h?!1:O4(t)||(s==="spring"||xS(s))&&i}function xm(t){t.duration=0,t.type="keyframes"}const D4=new Set(["opacity","clipPath","filter","transform"]),P4=q1(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function z4(t){const{motionValue:e,name:s,repeatDelay:i,repeatType:l,damping:u,type:d}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:m,transformTemplate:g}=e.owner.getProps();return P4()&&s&&D4.has(s)&&(s!=="transform"||!g)&&!m&&!i&&l!=="mirror"&&u!==0&&d!=="inertia"}const L4=40;class U4 extends lp{constructor({autoplay:e=!0,delay:s=0,type:i="keyframes",repeat:l=0,repeatDelay:u=0,repeatType:d="loop",keyframes:h,name:m,motionValue:g,element:y,...x}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Jt.now();const w={autoplay:e,delay:s,type:i,repeat:l,repeatDelay:u,repeatType:d,name:m,motionValue:g,element:y,...x},S=y?.KeyframeResolver||up;this.keyframeResolver=new S(h,(E,j,_)=>this.onKeyframesResolved(E,j,w,!_),m,g,y),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,s,i,l){this.keyframeResolver=void 0;const{name:u,type:d,velocity:h,delay:m,isHandoff:g,onUpdate:y}=i;this.resolvedAt=Jt.now(),M4(e,u,d,h)||((As.instantAnimations||!m)&&y?.(op(e,i,s)),e[0]=e[e.length-1],xm(i),i.repeat=0);const w={startTime:l?this.resolvedAt?this.resolvedAt-this.createdAt>L4?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:s,...i,keyframes:e},S=!g&&z4(w),E=w.motionValue?.owner?.current,j=S?new R4({...w,element:E}):new cp(w);j.finished.then(()=>{this.notifyFinished()}).catch(Ln),this.pendingTimeline&&(this.stopTimeline=j.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=j}get finished(){return this._animation?this.animation.finished:this._finished}then(e,s){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),S4()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}function SS(t,e,s,i=0,l=1){const u=Array.from(t).sort((g,y)=>g.sortNodePosition(y)).indexOf(e),d=t.size,h=(d-1)*i;return typeof s=="function"?s(u,d):l===1?u*i:h-u*i}const B4=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function V4(t){const e=B4.exec(t);if(!e)return[,];const[,s,i,l]=e;return[`--${s??i}`,l]}function jS(t,e,s=1){const[i,l]=V4(t);if(!i)return;const u=window.getComputedStyle(e).getPropertyValue(i);if(u){const d=u.trim();return V1(d)?parseFloat(d):d}return np(l)?jS(l,e,s+1):l}const I4={type:"spring",stiffness:500,damping:25,restSpeed:10},$4=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),q4={type:"keyframes",duration:.8},H4={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},G4=(t,{keyframes:e})=>e.length>2?q4:xr.has(t)?t.startsWith("scale")?$4(e[1]):I4:H4,F4=t=>t!==null;function K4(t,{repeat:e,repeatType:s="loop"},i){const l=t.filter(F4),u=e&&s!=="loop"&&e%2===1?0:l.length-1;return l[u]}function _S(t,e){if(t?.inherit&&e){const{inherit:s,...i}=t;return{...e,...i}}return t}function dp(t,e){const s=t?.[e]??t?.default??t;return s!==t?_S(s,t):s}function Y4({when:t,delay:e,delayChildren:s,staggerChildren:i,staggerDirection:l,repeat:u,repeatType:d,repeatDelay:h,from:m,elapsed:g,...y}){return!!Object.keys(y).length}const hp=(t,e,s,i={},l,u)=>d=>{const h=dp(i,t)||{},m=h.delay||i.delay||0;let{elapsed:g=0}=i;g=g-Fn(m);const y={keyframes:Array.isArray(s)?s:[null,s],ease:"easeOut",velocity:e.getVelocity(),...h,delay:-g,onUpdate:w=>{e.set(w),h.onUpdate&&h.onUpdate(w)},onComplete:()=>{d(),h.onComplete&&h.onComplete()},name:t,motionValue:e,element:u?void 0:l};Y4(h)||Object.assign(y,G4(t,y)),y.duration&&(y.duration=Fn(y.duration)),y.repeatDelay&&(y.repeatDelay=Fn(y.repeatDelay)),y.from!==void 0&&(y.keyframes[0]=y.from);let x=!1;if((y.type===!1||y.duration===0&&!y.repeatDelay)&&(xm(y),y.delay===0&&(x=!0)),(As.instantAnimations||As.skipAnimations||l?.shouldSkipAnimations)&&(x=!0,xm(y),y.delay=0),y.allowFlatten=!h.type&&!h.ease,x&&!u&&e.get()!==void 0){const w=K4(y.keyframes,h);if(w!==void 0){lt.update(()=>{y.onUpdate(w),y.onComplete()});return}}return h.isSync?new cp(y):new U4(y)};function F0(t){const e=[{},{}];return t?.values.forEach((s,i)=>{e[0][i]=s.get(),e[1][i]=s.getVelocity()}),e}function fp(t,e,s,i){if(typeof e=="function"){const[l,u]=F0(i);e=e(s!==void 0?s:t.custom,l,u)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[l,u]=F0(i);e=e(s!==void 0?s:t.custom,l,u)}return e}function cr(t,e,s){const i=t.getProps();return fp(i,e,s!==void 0?s:i.custom,t)}const NS=new Set(["width","height","top","left","right","bottom",...vr]),K0=30,X4=t=>!isNaN(parseFloat(t));class W4{constructor(e,s={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=i=>{const l=Jt.now();if(this.updatedAt!==l&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(i),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const u of this.dependents)u.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=s.owner}setCurrent(e){this.current=e,this.updatedAt=Jt.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=X4(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,s){this.events[e]||(this.events[e]=new Zm);const i=this.events[e].add(s);return e==="change"?()=>{i(),lt.read(()=>{this.events.change.getSize()||this.stop()})}:i}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,s){this.passiveEffect=e,this.stopPassiveEffect=s}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,s,i){this.set(s),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-i}jump(e,s=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,s&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=Jt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>K0)return 0;const s=Math.min(this.updatedAt-this.prevUpdatedAt,K0);return H1(parseFloat(this.current)-parseFloat(this.prevFrameValue),s)}start(e){return this.stop(),new Promise(s=>{this.hasAnimated=!0,this.animation=e(s),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function mr(t,e){return new W4(t,e)}const bm=t=>Array.isArray(t);function J4(t,e,s){t.hasValue(e)?t.getValue(e).set(s):t.addValue(e,mr(s))}function Q4(t){return bm(t)?t[t.length-1]||0:t}function Z4(t,e){const s=cr(t,e);let{transitionEnd:i={},transition:l={},...u}=s||{};u={...u,...i};for(const d in u){const h=Q4(u[d]);J4(t,d,h)}}const Xt=t=>!!(t&&t.getVelocity);function eM(t){return!!(Xt(t)&&t.add)}function wm(t,e){const s=t.getValue("willChange");if(eM(s))return s.add(e);if(!s&&As.WillChange){const i=new As.WillChange("auto");t.addValue("willChange",i),i.add(e)}}function mp(t){return t.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}const tM="framerAppearId",TS="data-"+mp(tM);function ES(t){return t.props[TS]}function nM({protectedKeys:t,needsAnimating:e},s){const i=t.hasOwnProperty(s)&&e[s]!==!0;return e[s]=!1,i}function kS(t,e,{delay:s=0,transitionOverride:i,type:l}={}){let{transition:u,transitionEnd:d,...h}=e;const m=t.getDefaultTransition();u=u?_S(u,m):m;const g=u?.reduceMotion;i&&(u=i);const y=[],x=l&&t.animationState&&t.animationState.getState()[l];for(const w in h){const S=t.getValue(w,t.latestValues[w]??null),E=h[w];if(E===void 0||x&&nM(x,w))continue;const j={delay:s,...dp(u||{},w)},_=S.get();if(_!==void 0&&!S.isAnimating&&!Array.isArray(E)&&E===_&&!j.velocity)continue;let N=!1;if(window.MotionHandoffAnimation){const A=ES(t);if(A){const D=window.MotionHandoffAnimation(A,w,lt);D!==null&&(j.startTime=D,N=!0)}}wm(t,w);const k=g??t.shouldReduceMotion;S.start(hp(w,S,E,k&&NS.has(w)?{type:!1}:j,t,N));const C=S.animation;C&&y.push(C)}if(d){const w=()=>lt.update(()=>{d&&Z4(t,d)});y.length?Promise.all(y).then(w):w()}return y}function Sm(t,e,s={}){const i=cr(t,e,s.type==="exit"?t.presenceContext?.custom:void 0);let{transition:l=t.getDefaultTransition()||{}}=i||{};s.transitionOverride&&(l=s.transitionOverride);const u=i?()=>Promise.all(kS(t,i,s)):()=>Promise.resolve(),d=t.variantChildren&&t.variantChildren.size?(m=0)=>{const{delayChildren:g=0,staggerChildren:y,staggerDirection:x}=l;return sM(t,e,m,g,y,x,s)}:()=>Promise.resolve(),{when:h}=l;if(h){const[m,g]=h==="beforeChildren"?[u,d]:[d,u];return m().then(()=>g())}else return Promise.all([u(),d(s.delay)])}function sM(t,e,s=0,i=0,l=0,u=1,d){const h=[];for(const m of t.variantChildren)m.notify("AnimationStart",e),h.push(Sm(m,e,{...d,delay:s+(typeof i=="function"?0:i)+SS(t.variantChildren,m,i,l,u)}).then(()=>m.notify("AnimationComplete",e)));return Promise.all(h)}function aM(t,e,s={}){t.notify("AnimationStart",e);let i;if(Array.isArray(e)){const l=e.map(u=>Sm(t,u,s));i=Promise.all(l)}else if(typeof e=="string")i=Sm(t,e,s);else{const l=typeof e=="function"?cr(t,e,s.custom):e;i=Promise.all(kS(t,l,s))}return i.then(()=>{t.notify("AnimationComplete",e)})}const iM={test:t=>t==="auto",parse:t=>t},CS=t=>e=>e.test(t),AS=[yr,be,rs,la,D5,M5,iM],Y0=t=>AS.find(CS(t));function rM(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||$1(t):!0}const oM=new Set(["brightness","contrast","saturate","opacity"]);function lM(t){const[e,s]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[i]=s.match(sp)||[];if(!i)return t;const l=s.replace(i,"");let u=oM.has(e)?1:0;return i!==s&&(u*=100),e+"("+u+l+")"}const cM=/\b([a-z-]*)\(.*?\)/gu,jm={...Kn,getAnimatableNone:t=>{const e=t.match(cM);return e?e.map(lM).join(" "):t}},_m={...Kn,getAnimatableNone:t=>{const e=Kn.parse(t);return Kn.createTransformer(t)(e.map(i=>typeof i=="number"?0:typeof i=="object"?{...i,alpha:1}:i))}},X0={...yr,transform:Math.round},uM={rotate:la,rotateX:la,rotateY:la,rotateZ:la,scale:qc,scaleX:qc,scaleY:qc,scaleZ:qc,skew:la,skewX:la,skewY:la,distance:be,translateX:be,translateY:be,translateZ:be,x:be,y:be,z:be,perspective:be,transformPerspective:be,opacity:Fo,originX:P0,originY:P0,originZ:be},pp={borderWidth:be,borderTopWidth:be,borderRightWidth:be,borderBottomWidth:be,borderLeftWidth:be,borderRadius:be,borderTopLeftRadius:be,borderTopRightRadius:be,borderBottomRightRadius:be,borderBottomLeftRadius:be,width:be,maxWidth:be,height:be,maxHeight:be,top:be,right:be,bottom:be,left:be,inset:be,insetBlock:be,insetBlockStart:be,insetBlockEnd:be,insetInline:be,insetInlineStart:be,insetInlineEnd:be,padding:be,paddingTop:be,paddingRight:be,paddingBottom:be,paddingLeft:be,paddingBlock:be,paddingBlockStart:be,paddingBlockEnd:be,paddingInline:be,paddingInlineStart:be,paddingInlineEnd:be,margin:be,marginTop:be,marginRight:be,marginBottom:be,marginLeft:be,marginBlock:be,marginBlockStart:be,marginBlockEnd:be,marginInline:be,marginInlineStart:be,marginInlineEnd:be,fontSize:be,backgroundPositionX:be,backgroundPositionY:be,...uM,zIndex:X0,fillOpacity:Fo,strokeOpacity:Fo,numOctaves:X0},dM={...pp,color:Et,backgroundColor:Et,outlineColor:Et,fill:Et,stroke:Et,borderColor:Et,borderTopColor:Et,borderRightColor:Et,borderBottomColor:Et,borderLeftColor:Et,filter:jm,WebkitFilter:jm,mask:_m,WebkitMask:_m},RS=t=>dM[t],hM=new Set([jm,_m]);function OS(t,e){let s=RS(t);return hM.has(s)||(s=Kn),s.getAnimatableNone?s.getAnimatableNone(e):void 0}const fM=new Set(["auto","none","0"]);function mM(t,e,s){let i=0,l;for(;i<t.length&&!l;){const u=t[i];typeof u=="string"&&!fM.has(u)&&Ko(u).values.length&&(l=t[i]),i++}if(l&&s)for(const u of e)t[u]=OS(s,l)}class pM extends up{constructor(e,s,i,l,u){super(e,s,i,l,u,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:s,name:i}=this;if(!s||!s.current)return;super.readKeyframes();for(let y=0;y<e.length;y++){let x=e[y];if(typeof x=="string"&&(x=x.trim(),np(x))){const w=jS(x,s.current);w!==void 0&&(e[y]=w),y===e.length-1&&(this.finalKeyframe=x)}}if(this.resolveNoneKeyframes(),!NS.has(i)||e.length!==2)return;const[l,u]=e,d=Y0(l),h=Y0(u),m=D0(l),g=D0(u);if(m!==g&&da[i]){this.needsMeasurement=!0;return}if(d!==h)if(q0(d)&&q0(h))for(let y=0;y<e.length;y++){const x=e[y];typeof x=="string"&&(e[y]=parseFloat(x))}else da[i]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:s}=this,i=[];for(let l=0;l<e.length;l++)(e[l]===null||rM(e[l]))&&i.push(l);i.length&&mM(e,i,s)}measureInitialState(){const{element:e,unresolvedKeyframes:s,name:i}=this;if(!e||!e.current)return;i==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=da[i](e.measureViewportBox(),window.getComputedStyle(e.current)),s[0]=this.measuredOrigin;const l=s[s.length-1];l!==void 0&&e.getValue(i,l).jump(l,!1)}measureEndState(){const{element:e,name:s,unresolvedKeyframes:i}=this;if(!e||!e.current)return;const l=e.getValue(s);l&&l.jump(this.measuredOrigin,!1);const u=i.length-1,d=i[u];i[u]=da[s](e.measureViewportBox(),window.getComputedStyle(e.current)),d!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=d),this.removedTransforms?.length&&this.removedTransforms.forEach(([h,m])=>{e.getValue(h).set(m)}),this.resolveNoneKeyframes()}}const gM=new Set(["opacity","clipPath","filter","transform"]);function MS(t,e,s){if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){let i=document;const l=s?.[t]??i.querySelectorAll(t);return l?Array.from(l):[]}return Array.from(t).filter(i=>i!=null)}const DS=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function Nm(t){return I1(t)&&"offsetHeight"in t}const{schedule:gp}=tS(queueMicrotask,!1),qn={x:!1,y:!1};function PS(){return qn.x||qn.y}function yM(t){return t==="x"||t==="y"?qn[t]?null:(qn[t]=!0,()=>{qn[t]=!1}):qn.x||qn.y?null:(qn.x=qn.y=!0,()=>{qn.x=qn.y=!1})}function zS(t,e){const s=MS(t),i=new AbortController,l={passive:!0,...e,signal:i.signal};return[s,l,()=>i.abort()]}function vM(t){return!(t.pointerType==="touch"||PS())}function xM(t,e,s={}){const[i,l,u]=zS(t,s);return i.forEach(d=>{let h=!1,m=!1,g;const y=()=>{d.removeEventListener("pointerleave",E)},x=_=>{g&&(g(_),g=void 0),y()},w=_=>{h=!1,window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w),m&&(m=!1,x(_))},S=()=>{h=!0,window.addEventListener("pointerup",w,l),window.addEventListener("pointercancel",w,l)},E=_=>{if(_.pointerType!=="touch"){if(h){m=!0;return}x(_)}},j=_=>{if(!vM(_))return;m=!1;const N=e(d,_);typeof N=="function"&&(g=N,d.addEventListener("pointerleave",E,l))};d.addEventListener("pointerenter",j,l),d.addEventListener("pointerdown",S,l)}),u}const LS=(t,e)=>e?t===e?!0:LS(t,e.parentElement):!1,yp=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,bM=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function wM(t){return bM.has(t.tagName)||t.isContentEditable===!0}const SM=new Set(["INPUT","SELECT","TEXTAREA"]);function jM(t){return SM.has(t.tagName)||t.isContentEditable===!0}const Jc=new WeakSet;function W0(t){return e=>{e.key==="Enter"&&t(e)}}function Cf(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const _M=(t,e)=>{const s=t.currentTarget;if(!s)return;const i=W0(()=>{if(Jc.has(s))return;Cf(s,"down");const l=W0(()=>{Cf(s,"up")}),u=()=>Cf(s,"cancel");s.addEventListener("keyup",l,e),s.addEventListener("blur",u,e)});s.addEventListener("keydown",i,e),s.addEventListener("blur",()=>s.removeEventListener("keydown",i),e)};function J0(t){return yp(t)&&!PS()}const Q0=new WeakSet;function NM(t,e,s={}){const[i,l,u]=zS(t,s),d=h=>{const m=h.currentTarget;if(!J0(h)||Q0.has(h))return;Jc.add(m),s.stopPropagation&&Q0.add(h);const g=e(m,h),y=(S,E)=>{window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",w),Jc.has(m)&&Jc.delete(m),J0(S)&&typeof g=="function"&&g(S,{success:E})},x=S=>{y(S,m===window||m===document||s.useGlobalTarget||LS(m,S.target))},w=S=>{y(S,!1)};window.addEventListener("pointerup",x,l),window.addEventListener("pointercancel",w,l)};return i.forEach(h=>{(s.useGlobalTarget?window:h).addEventListener("pointerdown",d,l),Nm(h)&&(h.addEventListener("focus",g=>_M(g,l)),!wM(h)&&!h.hasAttribute("tabindex")&&(h.tabIndex=0))}),u}function vp(t){return I1(t)&&"ownerSVGElement"in t}const Qc=new WeakMap;let Zc;const US=(t,e,s)=>(i,l)=>l&&l[0]?l[0][t+"Size"]:vp(i)&&"getBBox"in i?i.getBBox()[e]:i[s],TM=US("inline","width","offsetWidth"),EM=US("block","height","offsetHeight");function kM({target:t,borderBoxSize:e}){Qc.get(t)?.forEach(s=>{s(t,{get width(){return TM(t,e)},get height(){return EM(t,e)}})})}function CM(t){t.forEach(kM)}function AM(){typeof ResizeObserver>"u"||(Zc=new ResizeObserver(CM))}function RM(t,e){Zc||AM();const s=MS(t);return s.forEach(i=>{let l=Qc.get(i);l||(l=new Set,Qc.set(i,l)),l.add(e),Zc?.observe(i)}),()=>{s.forEach(i=>{const l=Qc.get(i);l?.delete(e),l?.size||Zc?.unobserve(i)})}}const eu=new Set;let sr;function OM(){sr=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};eu.forEach(e=>e(t))},window.addEventListener("resize",sr)}function MM(t){return eu.add(t),sr||OM(),()=>{eu.delete(t),!eu.size&&typeof sr=="function"&&(window.removeEventListener("resize",sr),sr=void 0)}}function Z0(t,e){return typeof t=="function"?MM(t):RM(t,e)}function DM(t){return vp(t)&&t.tagName==="svg"}const PM=[...AS,Et,Kn],zM=t=>PM.find(CS(t)),eb=()=>({translate:0,scale:1,origin:0,originPoint:0}),ar=()=>({x:eb(),y:eb()}),tb=()=>({min:0,max:0}),Ot=()=>({x:tb(),y:tb()}),LM=new WeakMap;function Pu(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Yo(t){return typeof t=="string"||Array.isArray(t)}const xp=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],bp=["initial",...xp];function zu(t){return Pu(t.animate)||bp.some(e=>Yo(t[e]))}function BS(t){return!!(zu(t)||t.variants)}function UM(t,e,s){for(const i in e){const l=e[i],u=s[i];if(Xt(l))t.addValue(i,l);else if(Xt(u))t.addValue(i,mr(l,{owner:t}));else if(u!==l)if(t.hasValue(i)){const d=t.getValue(i);d.liveStyle===!0?d.jump(l):d.hasAnimated||d.set(l)}else{const d=t.getStaticValue(i);t.addValue(i,mr(d!==void 0?d:l,{owner:t}))}}for(const i in s)e[i]===void 0&&t.removeValue(i);return e}const Tm={current:null},VS={current:!1},BM=typeof window<"u";function VM(){if(VS.current=!0,!!BM)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>Tm.current=t.matches;t.addEventListener("change",e),e()}else Tm.current=!1}const nb=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let xu={};function IS(t){xu=t}function IM(){return xu}class $M{scrapeMotionValuesFromProps(e,s,i){return{}}constructor({parent:e,props:s,presenceContext:i,reducedMotionConfig:l,skipAnimations:u,blockInitialAnimation:d,visualState:h},m={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=up,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const S=Jt.now();this.renderScheduledAt<S&&(this.renderScheduledAt=S,lt.render(this.render,!1,!0))};const{latestValues:g,renderState:y}=h;this.latestValues=g,this.baseTarget={...g},this.initialValues=s.initial?{...g}:{},this.renderState=y,this.parent=e,this.props=s,this.presenceContext=i,this.depth=e?e.depth+1:0,this.reducedMotionConfig=l,this.skipAnimationsConfig=u,this.options=m,this.blockInitialAnimation=!!d,this.isControllingVariants=zu(s),this.isVariantNode=BS(s),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:x,...w}=this.scrapeMotionValuesFromProps(s,{},this);for(const S in w){const E=w[S];g[S]!==void 0&&Xt(E)&&E.set(g[S])}}mount(e){if(this.hasBeenMounted)for(const s in this.initialValues)this.values.get(s)?.jump(this.initialValues[s]),this.latestValues[s]=this.initialValues[s];this.current=e,LM.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((s,i)=>this.bindToMotionValue(i,s)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(VS.current||VM(),this.shouldReduceMotion=Tm.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),pa(this.notifyUpdate),pa(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const s=this.features[e];s&&(s.unmount(),s.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,s){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),s.accelerate&&gM.has(e)&&this.current instanceof HTMLElement){const{factory:d,keyframes:h,times:m,ease:g,duration:y}=s.accelerate,x=new bS({element:this.current,name:e,keyframes:h,times:m,ease:g,duration:Fn(y)}),w=d(x);this.valueSubscriptions.set(e,()=>{w(),x.cancel()});return}const i=xr.has(e);i&&this.onBindTransform&&this.onBindTransform();const l=s.on("change",d=>{this.latestValues[e]=d,this.props.onUpdate&<.preRender(this.notifyUpdate),i&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let u;typeof window<"u"&&window.MotionCheckAppearSync&&(u=window.MotionCheckAppearSync(this,e,s)),this.valueSubscriptions.set(e,()=>{l(),u&&u(),s.owner&&s.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in xu){const s=xu[e];if(!s)continue;const{isEnabled:i,Feature:l}=s;if(!this.features[e]&&l&&i(this.props)&&(this.features[e]=new l(this)),this.features[e]){const u=this.features[e];u.isMounted?u.update():(u.mount(),u.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Ot()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,s){this.latestValues[e]=s}update(e,s){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=s;for(let i=0;i<nb.length;i++){const l=nb[i];this.propEventSubscriptions[l]&&(this.propEventSubscriptions[l](),delete this.propEventSubscriptions[l]);const u="on"+l,d=e[u];d&&(this.propEventSubscriptions[l]=this.on(l,d))}this.prevMotionValues=UM(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const s=this.getClosestVariantNode();if(s)return s.variantChildren&&s.variantChildren.add(e),()=>s.variantChildren.delete(e)}addValue(e,s){const i=this.values.get(e);s!==i&&(i&&this.removeValue(e),this.bindToMotionValue(e,s),this.values.set(e,s),this.latestValues[e]=s.get())}removeValue(e){this.values.delete(e);const s=this.valueSubscriptions.get(e);s&&(s(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,s){if(this.props.values&&this.props.values[e])return this.props.values[e];let i=this.values.get(e);return i===void 0&&s!==void 0&&(i=mr(s===null?void 0:s,{owner:this}),this.addValue(e,i)),i}readValue(e,s){let i=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return i!=null&&(typeof i=="string"&&(V1(i)||$1(i))?i=parseFloat(i):!zM(i)&&Kn.test(s)&&(i=OS(e,s)),this.setBaseTarget(e,Xt(i)?i.get():i)),Xt(i)?i.get():i}setBaseTarget(e,s){this.baseTarget[e]=s}getBaseTarget(e){const{initial:s}=this.props;let i;if(typeof s=="string"||typeof s=="object"){const u=fp(this.props,s,this.presenceContext?.custom);u&&(i=u[e])}if(s&&i!==void 0)return i;const l=this.getBaseTargetFromProps(this.props,e);return l!==void 0&&!Xt(l)?l:this.initialValues[e]!==void 0&&i===void 0?void 0:this.baseTarget[e]}on(e,s){return this.events[e]||(this.events[e]=new Zm),this.events[e].add(s)}notify(e,...s){this.events[e]&&this.events[e].notify(...s)}scheduleRenderMicrotask(){gp.render(this.render)}}class $S extends $M{constructor(){super(...arguments),this.KeyframeResolver=pM}sortInstanceNodePosition(e,s){return e.compareDocumentPosition(s)&2?1:-1}getBaseTargetFromProps(e,s){const i=e.style;return i?i[s]:void 0}removeValueFromRenderState(e,{vars:s,style:i}){delete s[e],delete i[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;Xt(e)&&(this.childSubscription=e.on("change",s=>{this.current&&(this.current.textContent=`${s}`)}))}}class va{constructor(e){this.isMounted=!1,this.node=e}update(){}}function qS({top:t,left:e,right:s,bottom:i}){return{x:{min:e,max:s},y:{min:t,max:i}}}function qM({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function HM(t,e){if(!e)return t;const s=e({x:t.left,y:t.top}),i=e({x:t.right,y:t.bottom});return{top:s.y,left:s.x,bottom:i.y,right:i.x}}function Af(t){return t===void 0||t===1}function Em({scale:t,scaleX:e,scaleY:s}){return!Af(t)||!Af(e)||!Af(s)}function qa(t){return Em(t)||HS(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function HS(t){return sb(t.x)||sb(t.y)}function sb(t){return t&&t!=="0%"}function bu(t,e,s){const i=t-s,l=e*i;return s+l}function ab(t,e,s,i,l){return l!==void 0&&(t=bu(t,l,i)),bu(t,s,i)+e}function km(t,e=0,s=1,i,l){t.min=ab(t.min,e,s,i,l),t.max=ab(t.max,e,s,i,l)}function GS(t,{x:e,y:s}){km(t.x,e.translate,e.scale,e.originPoint),km(t.y,s.translate,s.scale,s.originPoint)}const ib=.999999999999,rb=1.0000000000001;function GM(t,e,s,i=!1){const l=s.length;if(!l)return;e.x=e.y=1;let u,d;for(let h=0;h<l;h++){u=s[h],d=u.projectionDelta;const{visualElement:m}=u.options;m&&m.props.style&&m.props.style.display==="contents"||(i&&u.options.layoutScroll&&u.scroll&&u!==u.root&&rr(t,{x:-u.scroll.offset.x,y:-u.scroll.offset.y}),d&&(e.x*=d.x.scale,e.y*=d.y.scale,GS(t,d)),i&&qa(u.latestValues)&&rr(t,u.latestValues))}e.x<rb&&e.x>ib&&(e.x=1),e.y<rb&&e.y>ib&&(e.y=1)}function ir(t,e){t.min=t.min+e,t.max=t.max+e}function ob(t,e,s,i,l=.5){const u=mt(t.min,t.max,l);km(t,e,s,u,i)}function rr(t,e){ob(t.x,e.x,e.scaleX,e.scale,e.originX),ob(t.y,e.y,e.scaleY,e.scale,e.originY)}function FS(t,e){return qS(HM(t.getBoundingClientRect(),e))}function FM(t,e,s){const i=FS(t,s),{scroll:l}=e;return l&&(ir(i.x,l.offset.x),ir(i.y,l.offset.y)),i}const KM={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},YM=vr.length;function XM(t,e,s){let i="",l=!0;for(let u=0;u<YM;u++){const d=vr[u],h=t[d];if(h===void 0)continue;let m=!0;if(typeof h=="number")m=h===(d.startsWith("scale")?1:0);else{const g=parseFloat(h);m=d.startsWith("scale")?g===1:g===0}if(!m||s){const g=DS(h,pp[d]);if(!m){l=!1;const y=KM[d]||d;i+=`${y}(${g}) `}s&&(e[d]=g)}}return i=i.trim(),s?i=s(e,l?"":i):l&&(i="none"),i}function wp(t,e,s){const{style:i,vars:l,transformOrigin:u}=t;let d=!1,h=!1;for(const m in e){const g=e[m];if(xr.has(m)){d=!0;continue}else if(sS(m)){l[m]=g;continue}else{const y=DS(g,pp[m]);m.startsWith("origin")?(h=!0,u[m]=y):i[m]=y}}if(e.transform||(d||s?i.transform=XM(e,t.transform,s):i.transform&&(i.transform="none")),h){const{originX:m="50%",originY:g="50%",originZ:y=0}=u;i.transformOrigin=`${m} ${g} ${y}`}}function KS(t,{style:e,vars:s},i,l){const u=t.style;let d;for(d in e)u[d]=e[d];l?.applyProjectionStyles(u,i);for(d in s)u.setProperty(d,s[d])}function lb(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const xo={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(be.test(t))t=parseFloat(t);else return t;const s=lb(t,e.target.x),i=lb(t,e.target.y);return`${s}% ${i}%`}},WM={correct:(t,{treeScale:e,projectionDelta:s})=>{const i=t,l=Kn.parse(t);if(l.length>5)return i;const u=Kn.createTransformer(t),d=typeof l[0]!="number"?1:0,h=s.x.scale*e.x,m=s.y.scale*e.y;l[0+d]/=h,l[1+d]/=m;const g=mt(h,m,.5);return typeof l[2+d]=="number"&&(l[2+d]/=g),typeof l[3+d]=="number"&&(l[3+d]/=g),u(l)}},Cm={borderRadius:{...xo,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:xo,borderTopRightRadius:xo,borderBottomLeftRadius:xo,borderBottomRightRadius:xo,boxShadow:WM};function YS(t,{layout:e,layoutId:s}){return xr.has(t)||t.startsWith("origin")||(e||s!==void 0)&&(!!Cm[t]||t==="opacity")}function Sp(t,e,s){const i=t.style,l=e?.style,u={};if(!i)return u;for(const d in i)(Xt(i[d])||l&&Xt(l[d])||YS(d,t)||s?.getValue(d)?.liveStyle!==void 0)&&(u[d]=i[d]);return u}function JM(t){return window.getComputedStyle(t)}class QM extends $S{constructor(){super(...arguments),this.type="html",this.renderInstance=KS}readValueFromInstance(e,s){if(xr.has(s))return this.projection?.isProjecting?mm(s):y4(e,s);{const i=JM(e),l=(sS(s)?i.getPropertyValue(s):i[s])||0;return typeof l=="string"?l.trim():l}}measureInstanceViewportBox(e,{transformPagePoint:s}){return FS(e,s)}build(e,s,i){wp(e,s,i.transformTemplate)}scrapeMotionValuesFromProps(e,s,i){return Sp(e,s,i)}}const ZM={offset:"stroke-dashoffset",array:"stroke-dasharray"},eD={offset:"strokeDashoffset",array:"strokeDasharray"};function tD(t,e,s=1,i=0,l=!0){t.pathLength=1;const u=l?ZM:eD;t[u.offset]=`${-i}`,t[u.array]=`${e} ${s}`}const nD=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function XS(t,{attrX:e,attrY:s,attrScale:i,pathLength:l,pathSpacing:u=1,pathOffset:d=0,...h},m,g,y){if(wp(t,h,g),m){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:x,style:w}=t;x.transform&&(w.transform=x.transform,delete x.transform),(w.transform||x.transformOrigin)&&(w.transformOrigin=x.transformOrigin??"50% 50%",delete x.transformOrigin),w.transform&&(w.transformBox=y?.transformBox??"fill-box",delete x.transformBox);for(const S of nD)x[S]!==void 0&&(w[S]=x[S],delete x[S]);e!==void 0&&(x.x=e),s!==void 0&&(x.y=s),i!==void 0&&(x.scale=i),l!==void 0&&tD(x,l,u,d,!1)}const WS=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),JS=t=>typeof t=="string"&&t.toLowerCase()==="svg";function sD(t,e,s,i){KS(t,e,void 0,i);for(const l in e.attrs)t.setAttribute(WS.has(l)?l:mp(l),e.attrs[l])}function QS(t,e,s){const i=Sp(t,e,s);for(const l in t)if(Xt(t[l])||Xt(e[l])){const u=vr.indexOf(l)!==-1?"attr"+l.charAt(0).toUpperCase()+l.substring(1):l;i[u]=t[l]}return i}class aD extends $S{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Ot}getBaseTargetFromProps(e,s){return e[s]}readValueFromInstance(e,s){if(xr.has(s)){const i=RS(s);return i&&i.default||0}return s=WS.has(s)?s:mp(s),e.getAttribute(s)}scrapeMotionValuesFromProps(e,s,i){return QS(e,s,i)}build(e,s,i){XS(e,s,this.isSVGTag,i.transformTemplate,i.style)}renderInstance(e,s,i,l){sD(e,s,i,l)}mount(e){this.isSVGTag=JS(e.tagName),super.mount(e)}}const iD=bp.length;function ZS(t){if(!t)return;if(!t.isControllingVariants){const s=t.parent?ZS(t.parent)||{}:{};return t.props.initial!==void 0&&(s.initial=t.props.initial),s}const e={};for(let s=0;s<iD;s++){const i=bp[s],l=t.props[i];(Yo(l)||l===!1)&&(e[i]=l)}return e}function ej(t,e){if(!Array.isArray(e))return!1;const s=e.length;if(s!==t.length)return!1;for(let i=0;i<s;i++)if(e[i]!==t[i])return!1;return!0}const rD=[...xp].reverse(),oD=xp.length;function lD(t){return e=>Promise.all(e.map(({animation:s,options:i})=>aM(t,s,i)))}function cD(t){let e=lD(t),s=cb(),i=!0;const l=m=>(g,y)=>{const x=cr(t,y,m==="exit"?t.presenceContext?.custom:void 0);if(x){const{transition:w,transitionEnd:S,...E}=x;g={...g,...E,...S}}return g};function u(m){e=m(t)}function d(m){const{props:g}=t,y=ZS(t.parent)||{},x=[],w=new Set;let S={},E=1/0;for(let _=0;_<oD;_++){const N=rD[_],k=s[N],C=g[N]!==void 0?g[N]:y[N],A=Yo(C),D=N===m?k.isActive:null;D===!1&&(E=_);let z=C===y[N]&&C!==g[N]&&A;if(z&&i&&t.manuallyAnimateOnMount&&(z=!1),k.protectedKeys={...S},!k.isActive&&D===null||!C&&!k.prevProp||Pu(C)||typeof C=="boolean")continue;if(N==="exit"&&k.isActive&&D!==!0){k.prevResolvedValues&&(S={...S,...k.prevResolvedValues});continue}const V=uD(k.prevProp,C);let R=V||N===m&&k.isActive&&!z&&A||_>E&&A,P=!1;const Z=Array.isArray(C)?C:[C];let te=Z.reduce(l(N),{});D===!1&&(te={});const{prevResolvedValues:me={}}=k,Ee={...me,...te},ye=Y=>{R=!0,w.has(Y)&&(P=!0,w.delete(Y)),k.needsAnimating[Y]=!0;const J=t.getValue(Y);J&&(J.liveStyle=!1)};for(const Y in Ee){const J=te[Y],pe=me[Y];if(S.hasOwnProperty(Y))continue;let se=!1;bm(J)&&bm(pe)?se=!ej(J,pe):se=J!==pe,se?J!=null?ye(Y):w.add(Y):J!==void 0&&w.has(Y)?ye(Y):k.protectedKeys[Y]=!0}k.prevProp=C,k.prevResolvedValues=te,k.isActive&&(S={...S,...te}),i&&t.blockInitialAnimation&&(R=!1);const _e=z&&V;R&&(!_e||P)&&x.push(...Z.map(Y=>{const J={type:N};if(typeof Y=="string"&&i&&!_e&&t.manuallyAnimateOnMount&&t.parent){const{parent:pe}=t,se=cr(pe,Y);if(pe.enteringChildren&&se){const{delayChildren:M}=se.transition||{};J.delay=SS(pe.enteringChildren,t,M)}}return{animation:Y,options:J}}))}if(w.size){const _={};if(typeof g.initial!="boolean"){const N=cr(t,Array.isArray(g.initial)?g.initial[0]:g.initial);N&&N.transition&&(_.transition=N.transition)}w.forEach(N=>{const k=t.getBaseTarget(N),C=t.getValue(N);C&&(C.liveStyle=!0),_[N]=k??null}),x.push({animation:_})}let j=!!x.length;return i&&(g.initial===!1||g.initial===g.animate)&&!t.manuallyAnimateOnMount&&(j=!1),i=!1,j?e(x):Promise.resolve()}function h(m,g){if(s[m].isActive===g)return Promise.resolve();t.variantChildren?.forEach(x=>x.animationState?.setActive(m,g)),s[m].isActive=g;const y=d(m);for(const x in s)s[x].protectedKeys={};return y}return{animateChanges:d,setActive:h,setAnimateFunction:u,getState:()=>s,reset:()=>{s=cb()}}}function uD(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!ej(e,t):!1}function Va(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function cb(){return{animate:Va(!0),whileInView:Va(),whileHover:Va(),whileTap:Va(),whileDrag:Va(),whileFocus:Va(),exit:Va()}}function ub(t,e){t.min=e.min,t.max=e.max}function In(t,e){ub(t.x,e.x),ub(t.y,e.y)}function db(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}const tj=1e-4,dD=1-tj,hD=1+tj,nj=.01,fD=0-nj,mD=0+nj;function Qt(t){return t.max-t.min}function pD(t,e,s){return Math.abs(t-e)<=s}function hb(t,e,s,i=.5){t.origin=i,t.originPoint=mt(e.min,e.max,t.origin),t.scale=Qt(s)/Qt(e),t.translate=mt(s.min,s.max,t.origin)-t.originPoint,(t.scale>=dD&&t.scale<=hD||isNaN(t.scale))&&(t.scale=1),(t.translate>=fD&&t.translate<=mD||isNaN(t.translate))&&(t.translate=0)}function Co(t,e,s,i){hb(t.x,e.x,s.x,i?i.originX:void 0),hb(t.y,e.y,s.y,i?i.originY:void 0)}function fb(t,e,s){t.min=s.min+e.min,t.max=t.min+Qt(e)}function gD(t,e,s){fb(t.x,e.x,s.x),fb(t.y,e.y,s.y)}function mb(t,e,s){t.min=e.min-s.min,t.max=t.min+Qt(e)}function wu(t,e,s){mb(t.x,e.x,s.x),mb(t.y,e.y,s.y)}function pb(t,e,s,i,l){return t-=e,t=bu(t,1/s,i),l!==void 0&&(t=bu(t,1/l,i)),t}function yD(t,e=0,s=1,i=.5,l,u=t,d=t){if(rs.test(e)&&(e=parseFloat(e),e=mt(d.min,d.max,e/100)-d.min),typeof e!="number")return;let h=mt(u.min,u.max,i);t===u&&(h-=e),t.min=pb(t.min,e,s,h,l),t.max=pb(t.max,e,s,h,l)}function gb(t,e,[s,i,l],u,d){yD(t,e[s],e[i],e[l],e.scale,u,d)}const vD=["x","scaleX","originX"],xD=["y","scaleY","originY"];function yb(t,e,s,i){gb(t.x,e,vD,s?s.x:void 0,i?i.x:void 0),gb(t.y,e,xD,s?s.y:void 0,i?i.y:void 0)}function vb(t){return t.translate===0&&t.scale===1}function sj(t){return vb(t.x)&&vb(t.y)}function xb(t,e){return t.min===e.min&&t.max===e.max}function bD(t,e){return xb(t.x,e.x)&&xb(t.y,e.y)}function bb(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function aj(t,e){return bb(t.x,e.x)&&bb(t.y,e.y)}function wb(t){return Qt(t.x)/Qt(t.y)}function Sb(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}function ts(t){return[t("x"),t("y")]}function wD(t,e,s){let i="";const l=t.x.translate/e.x,u=t.y.translate/e.y,d=s?.z||0;if((l||u||d)&&(i=`translate3d(${l}px, ${u}px, ${d}px) `),(e.x!==1||e.y!==1)&&(i+=`scale(${1/e.x}, ${1/e.y}) `),s){const{transformPerspective:g,rotate:y,rotateX:x,rotateY:w,skewX:S,skewY:E}=s;g&&(i=`perspective(${g}px) ${i}`),y&&(i+=`rotate(${y}deg) `),x&&(i+=`rotateX(${x}deg) `),w&&(i+=`rotateY(${w}deg) `),S&&(i+=`skewX(${S}deg) `),E&&(i+=`skewY(${E}deg) `)}const h=t.x.scale*e.x,m=t.y.scale*e.y;return(h!==1||m!==1)&&(i+=`scale(${h}, ${m})`),i||"none"}const ij=["TopLeft","TopRight","BottomLeft","BottomRight"],SD=ij.length,jb=t=>typeof t=="string"?parseFloat(t):t,_b=t=>typeof t=="number"||be.test(t);function jD(t,e,s,i,l,u){l?(t.opacity=mt(0,s.opacity??1,_D(i)),t.opacityExit=mt(e.opacity??1,0,ND(i))):u&&(t.opacity=mt(e.opacity??1,s.opacity??1,i));for(let d=0;d<SD;d++){const h=`border${ij[d]}Radius`;let m=Nb(e,h),g=Nb(s,h);if(m===void 0&&g===void 0)continue;m||(m=0),g||(g=0),m===0||g===0||_b(m)===_b(g)?(t[h]=Math.max(mt(jb(m),jb(g),i),0),(rs.test(g)||rs.test(m))&&(t[h]+="%")):t[h]=g}(e.rotate||s.rotate)&&(t.rotate=mt(e.rotate||0,s.rotate||0,i))}function Nb(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const _D=rj(0,.5,J1),ND=rj(.5,.95,Ln);function rj(t,e,s){return i=>i<t?0:i>e?1:s(Go(t,e,i))}function TD(t,e,s){const i=Xt(t)?t:mr(t);return i.start(hp("",i,e,s)),i.animation}function Xo(t,e,s,i={passive:!0}){return t.addEventListener(e,s,i),()=>t.removeEventListener(e,s)}const ED=(t,e)=>t.depth-e.depth;class kD{constructor(){this.children=[],this.isDirty=!1}add(e){Jm(this.children,e),this.isDirty=!0}remove(e){pu(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(ED),this.isDirty=!1,this.children.forEach(e)}}function CD(t,e){const s=Jt.now(),i=({timestamp:l})=>{const u=l-s;u>=e&&(pa(i),t(u-e))};return lt.setup(i,!0),()=>pa(i)}function tu(t){return Xt(t)?t.get():t}class AD{constructor(){this.members=[]}add(e){Jm(this.members,e);for(let s=this.members.length-1;s>=0;s--){const i=this.members[s];if(i===e||i===this.lead||i===this.prevLead)continue;const l=i.instance;l&&l.isConnected===!1&&i.isPresent!==!1&&!i.snapshot&&pu(this.members,i)}e.scheduleRender()}remove(e){if(pu(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const s=this.members[this.members.length-1];s&&this.promote(s)}}relegate(e){const s=this.members.findIndex(l=>e===l);if(s===0)return!1;let i;for(let l=s;l>=0;l--){const u=this.members[l],d=u.instance;if(u.isPresent!==!1&&(!d||d.isConnected!==!1)){i=u;break}}return i?(this.promote(i),!0):!1}promote(e,s){const i=this.lead;if(e!==i&&(this.prevLead=i,this.lead=e,e.show(),i)){i.instance&&i.scheduleRender(),e.scheduleRender();const l=i.options.layoutDependency,u=e.options.layoutDependency;if(!(l!==void 0&&u!==void 0&&l===u)){const m=i.instance;m&&m.isConnected===!1&&!i.snapshot||(e.resumeFrom=i,s&&(e.resumeFrom.preserveOpacity=!0),i.snapshot&&(e.snapshot=i.snapshot,e.snapshot.latestValues=i.animationValues||i.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0))}const{crossfade:h}=e.options;h===!1&&i.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:s,resumingFrom:i}=e;s.onExitComplete&&s.onExitComplete(),i&&i.options.onExitComplete&&i.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}const nu={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Rf=["","X","Y","Z"],RD=1e3;let OD=0;function Of(t,e,s,i){const{latestValues:l}=e;l[t]&&(s[t]=l[t],e.setStaticValue(t,0),i&&(i[t]=0))}function oj(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const s=ES(e);if(window.MotionHasOptimisedAnimation(s,"transform")){const{layout:l,layoutId:u}=t.options;window.MotionCancelOptimisedAnimation(s,"transform",lt,!(l||u))}const{parent:i}=t;i&&!i.hasCheckedOptimisedAppear&&oj(i)}function lj({attachResizeListener:t,defaultParent:e,measureScroll:s,checkIsScrollRoot:i,resetTransform:l}){return class{constructor(d={},h=e?.()){this.id=OD++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(PD),this.nodes.forEach(BD),this.nodes.forEach(VD),this.nodes.forEach(zD)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=d,this.root=h?h.root||h:this,this.path=h?[...h.path,h]:[],this.parent=h,this.depth=h?h.depth+1:0;for(let m=0;m<this.path.length;m++)this.path[m].shouldResetTransform=!0;this.root===this&&(this.nodes=new kD)}addEventListener(d,h){return this.eventHandlers.has(d)||this.eventHandlers.set(d,new Zm),this.eventHandlers.get(d).add(h)}notifyListeners(d,...h){const m=this.eventHandlers.get(d);m&&m.notify(...h)}hasListeners(d){return this.eventHandlers.has(d)}mount(d){if(this.instance)return;this.isSVG=vp(d)&&!DM(d),this.instance=d;const{layoutId:h,layout:m,visualElement:g}=this.options;if(g&&!g.current&&g.mount(d),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(m||h)&&(this.isLayoutDirty=!0),t){let y,x=0;const w=()=>this.root.updateBlockedByResize=!1;lt.read(()=>{x=window.innerWidth}),t(d,()=>{const S=window.innerWidth;S!==x&&(x=S,this.root.updateBlockedByResize=!0,y&&y(),y=CD(w,250),nu.hasAnimatedSinceResize&&(nu.hasAnimatedSinceResize=!1,this.nodes.forEach(kb)))})}h&&this.root.registerSharedNode(h,this),this.options.animate!==!1&&g&&(h||m)&&this.addEventListener("didUpdate",({delta:y,hasLayoutChanged:x,hasRelativeLayoutChanged:w,layout:S})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const E=this.options.transition||g.getDefaultTransition()||GD,{onLayoutAnimationStart:j,onLayoutAnimationComplete:_}=g.getProps(),N=!this.targetLayout||!aj(this.targetLayout,S),k=!x&&w;if(this.options.layoutRoot||this.resumeFrom||k||x&&(N||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const C={...dp(E,"layout"),onPlay:j,onComplete:_};(g.shouldReduceMotion||this.options.layoutRoot)&&(C.delay=0,C.type=!1),this.startAnimation(C),this.setAnimationOrigin(y,k)}else x||kb(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=S})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const d=this.getStack();d&&d.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),pa(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(ID),this.animationId++)}getTransformTemplate(){const{visualElement:d}=this.options;return d&&d.getProps().transformTemplate}willUpdate(d=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&oj(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let y=0;y<this.path.length;y++){const x=this.path[y];x.shouldResetTransform=!0,x.updateScroll("snapshot"),x.options.layoutRoot&&x.willUpdate(!1)}const{layoutId:h,layout:m}=this.options;if(h===void 0&&!m)return;const g=this.getTransformTemplate();this.prevTransformTemplateValue=g?g(this.latestValues,""):void 0,this.updateSnapshot(),d&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Tb);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Eb);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(UD),this.nodes.forEach(MD),this.nodes.forEach(DD)):this.nodes.forEach(Eb),this.clearAllSnapshots();const h=Jt.now();Ft.delta=ls(0,1e3/60,h-Ft.timestamp),Ft.timestamp=h,Ft.isProcessing=!0,jf.update.process(Ft),jf.preRender.process(Ft),jf.render.process(Ft),Ft.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,gp.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(LD),this.sharedNodes.forEach($D)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,lt.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){lt.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Qt(this.snapshot.measuredBox.x)&&!Qt(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let m=0;m<this.path.length;m++)this.path[m].updateScroll();const d=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected=Ot(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:h}=this.options;h&&h.notify("LayoutMeasure",this.layout.layoutBox,d?d.layoutBox:void 0)}updateScroll(d="measure"){let h=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===d&&(h=!1),h&&this.instance){const m=i(this.instance);this.scroll={animationId:this.root.animationId,phase:d,isRoot:m,offset:s(this.instance),wasRoot:this.scroll?this.scroll.isRoot:m}}}resetTransform(){if(!l)return;const d=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,h=this.projectionDelta&&!sj(this.projectionDelta),m=this.getTransformTemplate(),g=m?m(this.latestValues,""):void 0,y=g!==this.prevTransformTemplateValue;d&&this.instance&&(h||qa(this.latestValues)||y)&&(l(this.instance,g),this.shouldResetTransform=!1,this.scheduleRender())}measure(d=!0){const h=this.measurePageBox();let m=this.removeElementScroll(h);return d&&(m=this.removeTransform(m)),FD(m),{animationId:this.root.animationId,measuredBox:h,layoutBox:m,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:d}=this.options;if(!d)return Ot();const h=d.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(KD))){const{scroll:g}=this.root;g&&(ir(h.x,g.offset.x),ir(h.y,g.offset.y))}return h}removeElementScroll(d){const h=Ot();if(In(h,d),this.scroll?.wasRoot)return h;for(let m=0;m<this.path.length;m++){const g=this.path[m],{scroll:y,options:x}=g;g!==this.root&&y&&x.layoutScroll&&(y.wasRoot&&In(h,d),ir(h.x,y.offset.x),ir(h.y,y.offset.y))}return h}applyTransform(d,h=!1){const m=Ot();In(m,d);for(let g=0;g<this.path.length;g++){const y=this.path[g];!h&&y.options.layoutScroll&&y.scroll&&y!==y.root&&rr(m,{x:-y.scroll.offset.x,y:-y.scroll.offset.y}),qa(y.latestValues)&&rr(m,y.latestValues)}return qa(this.latestValues)&&rr(m,this.latestValues),m}removeTransform(d){const h=Ot();In(h,d);for(let m=0;m<this.path.length;m++){const g=this.path[m];if(!g.instance||!qa(g.latestValues))continue;Em(g.latestValues)&&g.updateSnapshot();const y=Ot(),x=g.measurePageBox();In(y,x),yb(h,g.latestValues,g.snapshot?g.snapshot.layoutBox:void 0,y)}return qa(this.latestValues)&&yb(h,this.latestValues),h}setTargetDelta(d){this.targetDelta=d,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(d){this.options={...this.options,...d,crossfade:d.crossfade!==void 0?d.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Ft.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(d=!1){const h=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=h.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=h.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=h.isSharedProjectionDirty);const m=!!this.resumingFrom||this!==h;if(!(d||m&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:y,layoutId:x}=this.options;if(!this.layout||!(y||x))return;this.resolvedRelativeTargetAt=Ft.timestamp;const w=this.getClosestProjectingParent();w&&this.linkedParentVersion!==w.layoutVersion&&!w.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(w&&w.layout?this.createRelativeTarget(w,this.layout.layoutBox,w.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=Ot(),this.targetWithTransforms=Ot()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),gD(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):In(this.target,this.layout.layoutBox),GS(this.target,this.targetDelta)):In(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,w&&!!w.resumingFrom==!!this.resumingFrom&&!w.options.layoutScroll&&w.target&&this.animationProgress!==1?this.createRelativeTarget(w,this.target,w.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||Em(this.parent.latestValues)||HS(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(d,h,m){this.relativeParent=d,this.linkedParentVersion=d.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Ot(),this.relativeTargetOrigin=Ot(),wu(this.relativeTargetOrigin,h,m),In(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){const d=this.getLead(),h=!!this.resumingFrom||this!==d;let m=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(m=!1),h&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(m=!1),this.resolvedRelativeTargetAt===Ft.timestamp&&(m=!1),m)return;const{layout:g,layoutId:y}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(g||y))return;In(this.layoutCorrected,this.layout.layoutBox);const x=this.treeScale.x,w=this.treeScale.y;GM(this.layoutCorrected,this.treeScale,this.path,h),d.layout&&!d.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(d.target=d.layout.layoutBox,d.targetWithTransforms=Ot());const{target:S}=d;if(!S){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(db(this.prevProjectionDelta.x,this.projectionDelta.x),db(this.prevProjectionDelta.y,this.projectionDelta.y)),Co(this.projectionDelta,this.layoutCorrected,S,this.latestValues),(this.treeScale.x!==x||this.treeScale.y!==w||!Sb(this.projectionDelta.x,this.prevProjectionDelta.x)||!Sb(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",S))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(d=!0){if(this.options.visualElement?.scheduleRender(),d){const h=this.getStack();h&&h.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=ar(),this.projectionDelta=ar(),this.projectionDeltaWithTransform=ar()}setAnimationOrigin(d,h=!1){const m=this.snapshot,g=m?m.latestValues:{},y={...this.latestValues},x=ar();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!h;const w=Ot(),S=m?m.source:void 0,E=this.layout?this.layout.source:void 0,j=S!==E,_=this.getStack(),N=!_||_.members.length<=1,k=!!(j&&!N&&this.options.crossfade===!0&&!this.path.some(HD));this.animationProgress=0;let C;this.mixTargetDelta=A=>{const D=A/1e3;Cb(x.x,d.x,D),Cb(x.y,d.y,D),this.setTargetDelta(x),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(wu(w,this.layout.layoutBox,this.relativeParent.layout.layoutBox),qD(this.relativeTarget,this.relativeTargetOrigin,w,D),C&&bD(this.relativeTarget,C)&&(this.isProjectionDirty=!1),C||(C=Ot()),In(C,this.relativeTarget)),j&&(this.animationValues=y,jD(y,g,this.latestValues,D,k,N)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=D},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(d){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(pa(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=lt.update(()=>{nu.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=mr(0)),this.motionValue.jump(0,!1),this.currentAnimation=TD(this.motionValue,[0,1e3],{...d,velocity:0,isSync:!0,onUpdate:h=>{this.mixTargetDelta(h),d.onUpdate&&d.onUpdate(h)},onStop:()=>{},onComplete:()=>{d.onComplete&&d.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const d=this.getStack();d&&d.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(RD),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const d=this.getLead();let{targetWithTransforms:h,target:m,layout:g,latestValues:y}=d;if(!(!h||!m||!g)){if(this!==d&&this.layout&&g&&cj(this.options.animationType,this.layout.layoutBox,g.layoutBox)){m=this.target||Ot();const x=Qt(this.layout.layoutBox.x);m.x.min=d.target.x.min,m.x.max=m.x.min+x;const w=Qt(this.layout.layoutBox.y);m.y.min=d.target.y.min,m.y.max=m.y.min+w}In(h,m),rr(h,y),Co(this.projectionDeltaWithTransform,this.layoutCorrected,h,y)}}registerSharedNode(d,h){this.sharedNodes.has(d)||this.sharedNodes.set(d,new AD),this.sharedNodes.get(d).add(h);const g=h.options.initialPromotionConfig;h.promote({transition:g?g.transition:void 0,preserveFollowOpacity:g&&g.shouldPreserveFollowOpacity?g.shouldPreserveFollowOpacity(h):void 0})}isLead(){const d=this.getStack();return d?d.lead===this:!0}getLead(){const{layoutId:d}=this.options;return d?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:d}=this.options;return d?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:d}=this.options;if(d)return this.root.sharedNodes.get(d)}promote({needsReset:d,transition:h,preserveFollowOpacity:m}={}){const g=this.getStack();g&&g.promote(this,m),d&&(this.projectionDelta=void 0,this.needsReset=!0),h&&this.setOptions({transition:h})}relegate(){const d=this.getStack();return d?d.relegate(this):!1}resetSkewAndRotation(){const{visualElement:d}=this.options;if(!d)return;let h=!1;const{latestValues:m}=d;if((m.z||m.rotate||m.rotateX||m.rotateY||m.rotateZ||m.skewX||m.skewY)&&(h=!0),!h)return;const g={};m.z&&Of("z",d,g,this.animationValues);for(let y=0;y<Rf.length;y++)Of(`rotate${Rf[y]}`,d,g,this.animationValues),Of(`skew${Rf[y]}`,d,g,this.animationValues);d.render();for(const y in g)d.setStaticValue(y,g[y]),this.animationValues&&(this.animationValues[y]=g[y]);d.scheduleRender()}applyProjectionStyles(d,h){if(!this.instance||this.isSVG)return;if(!this.isVisible){d.visibility="hidden";return}const m=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,d.visibility="",d.opacity="",d.pointerEvents=tu(h?.pointerEvents)||"",d.transform=m?m(this.latestValues,""):"none";return}const g=this.getLead();if(!this.projectionDelta||!this.layout||!g.target){this.options.layoutId&&(d.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,d.pointerEvents=tu(h?.pointerEvents)||""),this.hasProjected&&!qa(this.latestValues)&&(d.transform=m?m({},""):"none",this.hasProjected=!1);return}d.visibility="";const y=g.animationValues||g.latestValues;this.applyTransformsToTarget();let x=wD(this.projectionDeltaWithTransform,this.treeScale,y);m&&(x=m(y,x)),d.transform=x;const{x:w,y:S}=this.projectionDelta;d.transformOrigin=`${w.origin*100}% ${S.origin*100}% 0`,g.animationValues?d.opacity=g===this?y.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:y.opacityExit:d.opacity=g===this?y.opacity!==void 0?y.opacity:"":y.opacityExit!==void 0?y.opacityExit:0;for(const E in Cm){if(y[E]===void 0)continue;const{correct:j,applyTo:_,isCSSVariable:N}=Cm[E],k=x==="none"?y[E]:j(y[E],g);if(_){const C=_.length;for(let A=0;A<C;A++)d[_[A]]=k}else N?this.options.visualElement.renderState.vars[E]=k:d[E]=k}this.options.layoutId&&(d.pointerEvents=g===this?tu(h?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(d=>d.currentAnimation?.stop()),this.root.nodes.forEach(Tb),this.root.sharedNodes.clear()}}}function MD(t){t.updateLayout()}function DD(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:s,measuredBox:i}=t.layout,{animationType:l}=t.options,u=e.source!==t.layout.source;l==="size"?ts(y=>{const x=u?e.measuredBox[y]:e.layoutBox[y],w=Qt(x);x.min=s[y].min,x.max=x.min+w}):cj(l,e.layoutBox,s)&&ts(y=>{const x=u?e.measuredBox[y]:e.layoutBox[y],w=Qt(s[y]);x.max=x.min+w,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[y].max=t.relativeTarget[y].min+w)});const d=ar();Co(d,s,e.layoutBox);const h=ar();u?Co(h,t.applyTransform(i,!0),e.measuredBox):Co(h,s,e.layoutBox);const m=!sj(d);let g=!1;if(!t.resumeFrom){const y=t.getClosestProjectingParent();if(y&&!y.resumeFrom){const{snapshot:x,layout:w}=y;if(x&&w){const S=Ot();wu(S,e.layoutBox,x.layoutBox);const E=Ot();wu(E,s,w.layoutBox),aj(S,E)||(g=!0),y.options.layoutRoot&&(t.relativeTarget=E,t.relativeTargetOrigin=S,t.relativeParent=y)}}}t.notifyListeners("didUpdate",{layout:s,snapshot:e,delta:h,layoutDelta:d,hasLayoutChanged:m,hasRelativeLayoutChanged:g})}else if(t.isLead()){const{onExitComplete:s}=t.options;s&&s()}t.options.transition=void 0}function PD(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function zD(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function LD(t){t.clearSnapshot()}function Tb(t){t.clearMeasurements()}function Eb(t){t.isLayoutDirty=!1}function UD(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function kb(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function BD(t){t.resolveTargetDelta()}function VD(t){t.calcProjection()}function ID(t){t.resetSkewAndRotation()}function $D(t){t.removeLeadSnapshot()}function Cb(t,e,s){t.translate=mt(e.translate,0,s),t.scale=mt(e.scale,1,s),t.origin=e.origin,t.originPoint=e.originPoint}function Ab(t,e,s,i){t.min=mt(e.min,s.min,i),t.max=mt(e.max,s.max,i)}function qD(t,e,s,i){Ab(t.x,e.x,s.x,i),Ab(t.y,e.y,s.y,i)}function HD(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const GD={duration:.45,ease:[.4,0,.1,1]},Rb=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),Ob=Rb("applewebkit/")&&!Rb("chrome/")?Math.round:Ln;function Mb(t){t.min=Ob(t.min),t.max=Ob(t.max)}function FD(t){Mb(t.x),Mb(t.y)}function cj(t,e,s){return t==="position"||t==="preserve-aspect"&&!pD(wb(e),wb(s),.2)}function KD(t){return t!==t.root&&t.scroll?.wasRoot}const YD=lj({attachResizeListener:(t,e)=>Xo(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),Mf={current:void 0},uj=lj({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Mf.current){const t=new YD({});t.mount(window),t.setOptions({layoutScroll:!0}),Mf.current=t}return Mf.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),jp=v.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function Db(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function XD(...t){return e=>{let s=!1;const i=t.map(l=>{const u=Db(l,e);return!s&&typeof u=="function"&&(s=!0),u});if(s)return()=>{for(let l=0;l<i.length;l++){const u=i[l];typeof u=="function"?u():Db(t[l],null)}}}}function WD(...t){return v.useCallback(XD(...t),t)}class JD extends v.Component{getSnapshotBeforeUpdate(e){const s=this.props.childRef.current;if(s&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const i=s.offsetParent,l=Nm(i)&&i.offsetWidth||0,u=Nm(i)&&i.offsetHeight||0,d=this.props.sizeRef.current;d.height=s.offsetHeight||0,d.width=s.offsetWidth||0,d.top=s.offsetTop,d.left=s.offsetLeft,d.right=l-d.width-d.left,d.bottom=u-d.height-d.top}return null}componentDidUpdate(){}render(){return this.props.children}}function QD({children:t,isPresent:e,anchorX:s,anchorY:i,root:l,pop:u}){const d=v.useId(),h=v.useRef(null),m=v.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0}),{nonce:g}=v.useContext(jp),y=t.props?.ref??t?.ref,x=WD(h,y);return v.useInsertionEffect(()=>{const{width:w,height:S,top:E,left:j,right:_,bottom:N}=m.current;if(e||u===!1||!h.current||!w||!S)return;const k=s==="left"?`left: ${j}`:`right: ${_}`,C=i==="bottom"?`bottom: ${N}`:`top: ${E}`;h.current.dataset.motionPopId=d;const A=document.createElement("style");g&&(A.nonce=g);const D=l??document.head;return D.appendChild(A),A.sheet&&A.sheet.insertRule(`
|
|
97
97
|
[data-motion-pop-id="${d}"] {
|
|
98
98
|
position: absolute !important;
|
|
99
99
|
width: ${w}px !important;
|
|
@@ -101,13 +101,13 @@ For more information, see https://radix-ui.com/primitives/docs/components/${e.do
|
|
|
101
101
|
${k}px !important;
|
|
102
102
|
${C}px !important;
|
|
103
103
|
}
|
|
104
|
-
`),()=>{D.contains(A)&&D.removeChild(A)}},[e]),o.jsx(JD,{isPresent:e,childRef:h,sizeRef:m,pop:u,children:u===!1?t:v.cloneElement(t,{ref:x})})}const ZD=({children:t,initial:e,isPresent:s,onExitComplete:r,custom:l,presenceAffectsLayout:u,mode:d,anchorX:h,anchorY:m,root:g})=>{const y=Wm(e3),x=v.useId();let w=!0,S=v.useMemo(()=>(w=!1,{id:x,initial:e,isPresent:s,custom:l,onExitComplete:E=>{y.set(E,!0);for(const j of y.values())if(!j)return;r&&r()},register:E=>(y.set(E,!1),()=>y.delete(E))}),[s,y,r]);return u&&w&&(S={...S}),v.useMemo(()=>{y.forEach((E,j)=>y.set(j,!1))},[s]),v.useEffect(()=>{!s&&!y.size&&r&&r()},[s]),t=o.jsx(QD,{pop:d==="popLayout",isPresent:s,anchorX:h,anchorY:m,root:g,children:t}),o.jsx(Du.Provider,{value:S,children:t})};function e3(){return new Map}function dj(t=!0){const e=v.useContext(Du);if(e===null)return[!0,null];const{isPresent:s,onExitComplete:r,register:l}=e,u=v.useId();v.useEffect(()=>{if(t)return l(u)},[t]);const d=v.useCallback(()=>t&&r&&r(u),[u,r,t]);return!s&&r?[!1,d]:[!0]}const Hc=t=>t.key||"";function Pb(t){const e=[];return v.Children.forEach(t,s=>{v.isValidElement(s)&&e.push(s)}),e}const _p=({children:t,custom:e,initial:s=!0,onExitComplete:r,presenceAffectsLayout:l=!0,mode:u="sync",propagate:d=!1,anchorX:h="left",anchorY:m="top",root:g})=>{const[y,x]=dj(d),w=v.useMemo(()=>Pb(t),[t]),S=d&&!y?[]:w.map(Hc),E=v.useRef(!0),j=v.useRef(w),_=Wm(()=>new Map),N=v.useRef(new Set),[k,C]=v.useState(w),[A,D]=v.useState(w);B1(()=>{E.current=!1,j.current=w;for(let R=0;R<A.length;R++){const P=Hc(A[R]);S.includes(P)?(_.delete(P),N.current.delete(P)):_.get(P)!==!0&&_.set(P,!1)}},[A,S.length,S.join("-")]);const U=[];if(w!==k){let R=[...w];for(let P=0;P<A.length;P++){const Z=A[P],te=Hc(Z);S.includes(te)||(R.splice(P,0,Z),U.push(Z))}return u==="wait"&&U.length&&(R=U),D(Pb(R)),C(w),null}const{forceRender:V}=v.useContext(Xm);return o.jsx(o.Fragment,{children:A.map(R=>{const P=Hc(R),Z=d&&!y?!1:w===A||S.includes(P),te=()=>{if(N.current.has(P))return;if(N.current.add(P),_.has(P))_.set(P,!0);else return;let me=!0;_.forEach(Ee=>{Ee||(me=!1)}),me&&(V?.(),D(j.current),d&&x?.(),r&&r())};return o.jsx(ZD,{isPresent:Z,initial:!E.current||s?void 0:!1,custom:e,presenceAffectsLayout:l,mode:u,root:g,onExitComplete:Z?void 0:te,anchorX:h,anchorY:m,children:R},P)})})},hj=v.createContext({strict:!1}),zb={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let Lb=!1;function t3(){if(Lb)return;const t={};for(const e in zb)t[e]={isEnabled:s=>zb[e].some(r=>!!s[r])};IS(t),Lb=!0}function fj(){return t3(),IM()}function n3(t){const e=fj();for(const s in t)e[s]={...e[s],...t[s]};IS(e)}const s3=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function Su(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||s3.has(t)}let mj=t=>!Su(t);function a3(t){typeof t=="function"&&(mj=e=>e.startsWith("on")?!Su(e):t(e))}try{a3(require("@emotion/is-prop-valid").default)}catch{}function r3(t,e,s){const r={};for(const l in t)l==="values"&&typeof t.values=="object"||(mj(l)||s===!0&&Su(l)||!e&&!Su(l)||t.draggable&&l.startsWith("onDrag"))&&(r[l]=t[l]);return r}const Lu=v.createContext({});function i3(t,e){if(zu(t)){const{initial:s,animate:r}=t;return{initial:s===!1||Yo(s)?s:void 0,animate:Yo(r)?r:void 0}}return t.inherit!==!1?e:{}}function o3(t){const{initial:e,animate:s}=i3(t,v.useContext(Lu));return v.useMemo(()=>({initial:e,animate:s}),[Ub(e),Ub(s)])}function Ub(t){return Array.isArray(t)?t.join(" "):t}const Np=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function pj(t,e,s){for(const r in e)!Xt(e[r])&&!YS(r,s)&&(t[r]=e[r])}function l3({transformTemplate:t},e){return v.useMemo(()=>{const s=Np();return wp(s,e,t),Object.assign({},s.vars,s.style)},[e])}function c3(t,e){const s=t.style||{},r={};return pj(r,s,t),Object.assign(r,l3(t,e)),r}function u3(t,e){const s={},r=c3(t,e);return t.drag&&t.dragListener!==!1&&(s.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(s.tabIndex=0),s.style=r,s}const gj=()=>({...Np(),attrs:{}});function d3(t,e,s,r){const l=v.useMemo(()=>{const u=gj();return XS(u,e,JS(r),t.transformTemplate,t.style),{...u.attrs,style:{...u.style}}},[e]);if(t.style){const u={};pj(u,t.style,t),l.style={...u,...l.style}}return l}const h3=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Tp(t){return typeof t!="string"||t.includes("-")?!1:!!(h3.indexOf(t)>-1||/[A-Z]/u.test(t))}function f3(t,e,s,{latestValues:r},l,u=!1,d){const m=(d??Tp(t)?d3:u3)(e,r,l,t),g=r3(e,typeof t=="string",u),y=t!==v.Fragment?{...g,...m,ref:s}:{},{children:x}=e,w=v.useMemo(()=>Xt(x)?x.get():x,[x]);return v.createElement(t,{...y,children:w})}function m3({scrapeMotionValuesFromProps:t,createRenderState:e},s,r,l){return{latestValues:p3(s,r,l,t),renderState:e()}}function p3(t,e,s,r){const l={},u=r(t,{});for(const w in u)l[w]=tu(u[w]);let{initial:d,animate:h}=t;const m=zu(t),g=BS(t);e&&g&&!m&&t.inherit!==!1&&(d===void 0&&(d=e.initial),h===void 0&&(h=e.animate));let y=s?s.initial===!1:!1;y=y||d===!1;const x=y?h:d;if(x&&typeof x!="boolean"&&!Pu(x)){const w=Array.isArray(x)?x:[x];for(let S=0;S<w.length;S++){const E=fp(t,w[S]);if(E){const{transitionEnd:j,transition:_,...N}=E;for(const k in N){let C=N[k];if(Array.isArray(C)){const A=y?C.length-1:0;C=C[A]}C!==null&&(l[k]=C)}for(const k in j)l[k]=j[k]}}}return l}const yj=t=>(e,s)=>{const r=v.useContext(Lu),l=v.useContext(Du),u=()=>m3(t,e,r,l);return s?u():Wm(u)},g3=yj({scrapeMotionValuesFromProps:Sp,createRenderState:Np}),y3=yj({scrapeMotionValuesFromProps:QS,createRenderState:gj}),v3=Symbol.for("motionComponentSymbol");function x3(t,e,s){const r=v.useRef(s);v.useInsertionEffect(()=>{r.current=s});const l=v.useRef(null);return v.useCallback(u=>{u&&t.onMount?.(u),e&&(u?e.mount(u):e.unmount());const d=r.current;if(typeof d=="function")if(u){const h=d(u);typeof h=="function"&&(l.current=h)}else l.current?(l.current(),l.current=null):d(u);else d&&(d.current=u)},[e])}const vj=v.createContext({});function Zr(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function b3(t,e,s,r,l,u){const{visualElement:d}=v.useContext(Lu),h=v.useContext(hj),m=v.useContext(Du),g=v.useContext(jp),y=g.reducedMotion,x=g.skipAnimations,w=v.useRef(null),S=v.useRef(!1);r=r||h.renderer,!w.current&&r&&(w.current=r(t,{visualState:e,parent:d,props:s,presenceContext:m,blockInitialAnimation:m?m.initial===!1:!1,reducedMotionConfig:y,skipAnimations:x,isSVG:u}),S.current&&w.current&&(w.current.manuallyAnimateOnMount=!0));const E=w.current,j=v.useContext(vj);E&&!E.projection&&l&&(E.type==="html"||E.type==="svg")&&w3(w.current,s,l,j);const _=v.useRef(!1);v.useInsertionEffect(()=>{E&&_.current&&E.update(s,m)});const N=s[TS],k=v.useRef(!!N&&!window.MotionHandoffIsComplete?.(N)&&window.MotionHasOptimisedAnimation?.(N));return B1(()=>{S.current=!0,E&&(_.current=!0,window.MotionIsMounted=!0,E.updateFeatures(),E.scheduleRenderMicrotask(),k.current&&E.animationState&&E.animationState.animateChanges())}),v.useEffect(()=>{E&&(!k.current&&E.animationState&&E.animationState.animateChanges(),k.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(N)}),k.current=!1),E.enteringChildren=void 0)}),E}function w3(t,e,s,r){const{layoutId:l,layout:u,drag:d,dragConstraints:h,layoutScroll:m,layoutRoot:g,layoutCrossfade:y}=e;t.projection=new s(t.latestValues,e["data-framer-portal-id"]?void 0:xj(t.parent)),t.projection.setOptions({layoutId:l,layout:u,alwaysMeasureLayout:!!d||h&&Zr(h),visualElement:t,animationType:typeof u=="string"?u:"both",initialPromotionConfig:r,crossfade:y,layoutScroll:m,layoutRoot:g})}function xj(t){if(t)return t.options.allowProjection!==!1?t.projection:xj(t.parent)}function Df(t,{forwardMotionProps:e=!1,type:s}={},r,l){r&&n3(r);const u=s?s==="svg":Tp(t),d=u?y3:g3;function h(g,y){let x;const w={...v.useContext(jp),...g,layoutId:S3(g)},{isStatic:S}=w,E=o3(g),j=d(g,S);if(!S&&U1){j3();const _=_3(w);x=_.MeasureLayout,E.visualElement=b3(t,j,w,l,_.ProjectionNode,u)}return o.jsxs(Lu.Provider,{value:E,children:[x&&E.visualElement?o.jsx(x,{visualElement:E.visualElement,...w}):null,f3(t,g,x3(j,E.visualElement,y),j,S,e,u)]})}h.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const m=v.forwardRef(h);return m[v3]=t,m}function S3({layoutId:t}){const e=v.useContext(Xm).id;return e&&t!==void 0?e+"-"+t:t}function j3(t,e){v.useContext(hj).strict}function _3(t){const e=fj(),{drag:s,layout:r}=e;if(!s&&!r)return{};const l={...s,...r};return{MeasureLayout:s?.isEnabled(t)||r?.isEnabled(t)?l.MeasureLayout:void 0,ProjectionNode:l.ProjectionNode}}function N3(t,e){if(typeof Proxy>"u")return Df;const s=new Map,r=(u,d)=>Df(u,d,t,e),l=(u,d)=>r(u,d);return new Proxy(l,{get:(u,d)=>d==="create"?r:(s.has(d)||s.set(d,Df(d,void 0,t,e)),s.get(d))})}const T3=(t,e)=>e.isSVG??Tp(t)?new aD(e):new QM(e,{allowProjection:t!==v.Fragment});class E3 extends va{constructor(e){super(e),e.animationState||(e.animationState=cD(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();Pu(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:s}=this.node.prevProps||{};e!==s&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let k3=0;class C3 extends va{constructor(){super(...arguments),this.id=k3++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:s}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===r)return;const l=this.node.animationState.setActive("exit",!e);s&&!e&&l.then(()=>{s(this.id)})}mount(){const{register:e,onExitComplete:s}=this.node.presenceContext||{};s&&s(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const A3={animation:{Feature:E3},exit:{Feature:C3}};function il(t){return{point:{x:t.pageX,y:t.pageY}}}const R3=t=>e=>yp(e)&&t(e,il(e));function Ao(t,e,s,r){return Xo(t,e,R3(s),r)}const bj=({current:t})=>t?t.ownerDocument.defaultView:null,Bb=(t,e)=>Math.abs(t-e);function O3(t,e){const s=Bb(t.x,e.x),r=Bb(t.y,e.y);return Math.sqrt(s**2+r**2)}const Vb=new Set(["auto","scroll"]);class wj{constructor(e,s,{transformPagePoint:r,contextWindow:l=window,dragSnapToOrigin:u=!1,distanceThreshold:d=3,element:h}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=S=>{this.handleScroll(S.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const S=zf(this.lastMoveEventInfo,this.history),E=this.startEvent!==null,j=O3(S.offset,{x:0,y:0})>=this.distanceThreshold;if(!E&&!j)return;const{point:_}=S,{timestamp:N}=Ft;this.history.push({..._,timestamp:N});const{onStart:k,onMove:C}=this.handlers;E||(k&&k(this.lastMoveEvent,S),this.startEvent=this.lastMoveEvent),C&&C(this.lastMoveEvent,S)},this.handlePointerMove=(S,E)=>{this.lastMoveEvent=S,this.lastMoveEventInfo=Pf(E,this.transformPagePoint),lt.update(this.updatePoint,!0)},this.handlePointerUp=(S,E)=>{this.end();const{onEnd:j,onSessionEnd:_,resumeAnimation:N}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&N&&N(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const k=zf(S.type==="pointercancel"?this.lastMoveEventInfo:Pf(E,this.transformPagePoint),this.history);this.startEvent&&j&&j(S,k),_&&_(S,k)},!yp(e))return;this.dragSnapToOrigin=u,this.handlers=s,this.transformPagePoint=r,this.distanceThreshold=d,this.contextWindow=l||window;const m=il(e),g=Pf(m,this.transformPagePoint),{point:y}=g,{timestamp:x}=Ft;this.history=[{...y,timestamp:x}];const{onSessionStart:w}=s;w&&w(e,zf(g,this.history)),this.removeListeners=sl(Ao(this.contextWindow,"pointermove",this.handlePointerMove),Ao(this.contextWindow,"pointerup",this.handlePointerUp),Ao(this.contextWindow,"pointercancel",this.handlePointerUp)),h&&this.startScrollTracking(h)}startScrollTracking(e){let s=e.parentElement;for(;s;){const r=getComputedStyle(s);(Vb.has(r.overflowX)||Vb.has(r.overflowY))&&this.scrollPositions.set(s,{x:s.scrollLeft,y:s.scrollTop}),s=s.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){const s=this.scrollPositions.get(e);if(!s)return;const r=e===window,l=r?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},u={x:l.x-s.x,y:l.y-s.y};u.x===0&&u.y===0||(r?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=u.x,this.lastMoveEventInfo.point.y+=u.y):this.history.length>0&&(this.history[0].x-=u.x,this.history[0].y-=u.y),this.scrollPositions.set(e,l),lt.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),pa(this.updatePoint)}}function Pf(t,e){return e?{point:e(t.point)}:t}function Ib(t,e){return{x:t.x-e.x,y:t.y-e.y}}function zf({point:t},e){return{point:t,delta:Ib(t,Sj(e)),offset:Ib(t,M3(e)),velocity:D3(e,.1)}}function M3(t){return t[0]}function Sj(t){return t[t.length-1]}function D3(t,e){if(t.length<2)return{x:0,y:0};let s=t.length-1,r=null;const l=Sj(t);for(;s>=0&&(r=t[s],!(l.timestamp-r.timestamp>Fn(e)));)s--;if(!r)return{x:0,y:0};r===t[0]&&t.length>2&&l.timestamp-r.timestamp>Fn(e)*2&&(r=t[1]);const u=Pn(l.timestamp-r.timestamp);if(u===0)return{x:0,y:0};const d={x:(l.x-r.x)/u,y:(l.y-r.y)/u};return d.x===1/0&&(d.x=0),d.y===1/0&&(d.y=0),d}function P3(t,{min:e,max:s},r){return e!==void 0&&t<e?t=r?mt(e,t,r.min):Math.max(t,e):s!==void 0&&t>s&&(t=r?mt(s,t,r.max):Math.min(t,s)),t}function $b(t,e,s){return{min:e!==void 0?t.min+e:void 0,max:s!==void 0?t.max+s-(t.max-t.min):void 0}}function z3(t,{top:e,left:s,bottom:r,right:l}){return{x:$b(t.x,s,l),y:$b(t.y,e,r)}}function qb(t,e){let s=e.min-t.min,r=e.max-t.max;return e.max-e.min<t.max-t.min&&([s,r]=[r,s]),{min:s,max:r}}function L3(t,e){return{x:qb(t.x,e.x),y:qb(t.y,e.y)}}function U3(t,e){let s=.5;const r=Qt(t),l=Qt(e);return l>r?s=Go(e.min,e.max-r,t.min):r>l&&(s=Go(t.min,t.max-l,e.min)),ls(0,1,s)}function B3(t,e){const s={};return e.min!==void 0&&(s.min=e.min-t.min),e.max!==void 0&&(s.max=e.max-t.min),s}const Am=.35;function V3(t=Am){return t===!1?t=0:t===!0&&(t=Am),{x:Hb(t,"left","right"),y:Hb(t,"top","bottom")}}function Hb(t,e,s){return{min:Gb(t,e),max:Gb(t,s)}}function Gb(t,e){return typeof t=="number"?t:t[e]||0}const I3=new WeakMap;class $3{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Ot(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:s=!1,distanceThreshold:r}={}){const{presenceContext:l}=this.visualElement;if(l&&l.isPresent===!1)return;const u=x=>{s&&this.snapToCursor(il(x).point),this.stopAnimation()},d=(x,w)=>{const{drag:S,dragPropagation:E,onDragStart:j}=this.getProps();if(S&&!E&&(this.openDragLock&&this.openDragLock(),this.openDragLock=yM(S),!this.openDragLock))return;this.latestPointerEvent=x,this.latestPanInfo=w,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),ts(N=>{let k=this.getAxisMotionValue(N).get()||0;if(is.test(k)){const{projection:C}=this.visualElement;if(C&&C.layout){const A=C.layout.layoutBox[N];A&&(k=Qt(A)*(parseFloat(k)/100))}}this.originPoint[N]=k}),j&<.update(()=>j(x,w),!1,!0),wm(this.visualElement,"transform");const{animationState:_}=this.visualElement;_&&_.setActive("whileDrag",!0)},h=(x,w)=>{this.latestPointerEvent=x,this.latestPanInfo=w;const{dragPropagation:S,dragDirectionLock:E,onDirectionLock:j,onDrag:_}=this.getProps();if(!S&&!this.openDragLock)return;const{offset:N}=w;if(E&&this.currentDirection===null){this.currentDirection=H3(N),this.currentDirection!==null&&j&&j(this.currentDirection);return}this.updateAxis("x",w.point,N),this.updateAxis("y",w.point,N),this.visualElement.render(),_&<.update(()=>_(x,w),!1,!0)},m=(x,w)=>{this.latestPointerEvent=x,this.latestPanInfo=w,this.stop(x,w),this.latestPointerEvent=null,this.latestPanInfo=null},g=()=>{const{dragSnapToOrigin:x}=this.getProps();(x||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:y}=this.getProps();this.panSession=new wj(e,{onSessionStart:u,onStart:d,onMove:h,onSessionEnd:m,resumeAnimation:g},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:y,distanceThreshold:r,contextWindow:bj(this.visualElement),element:this.visualElement.current})}stop(e,s){const r=e||this.latestPointerEvent,l=s||this.latestPanInfo,u=this.isDragging;if(this.cancel(),!u||!l||!r)return;const{velocity:d}=l;this.startAnimation(d);const{onDragEnd:h}=this.getProps();h&<.postRender(()=>h(r,l))}cancel(){this.isDragging=!1;const{projection:e,animationState:s}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),s&&s.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,s,r){const{drag:l}=this.getProps();if(!r||!Gc(e,l,this.currentDirection))return;const u=this.getAxisMotionValue(e);let d=this.originPoint[e]+r[e];this.constraints&&this.constraints[e]&&(d=P3(d,this.constraints[e],this.elastic[e])),u.set(d)}resolveConstraints(){const{dragConstraints:e,dragElastic:s}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,l=this.constraints;e&&Zr(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&r?this.constraints=z3(r.layoutBox,e):this.constraints=!1,this.elastic=V3(s),l!==this.constraints&&!Zr(e)&&r&&this.constraints&&!this.hasMutatedConstraints&&ts(u=>{this.constraints!==!1&&this.getAxisMotionValue(u)&&(this.constraints[u]=B3(r.layoutBox[u],this.constraints[u]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:s}=this.getProps();if(!e||!Zr(e))return!1;const r=e.current,{projection:l}=this.visualElement;if(!l||!l.layout)return!1;const u=FM(r,l.root,this.visualElement.getTransformPagePoint());let d=L3(l.layout.layoutBox,u);if(s){const h=s(qM(d));this.hasMutatedConstraints=!!h,h&&(d=qS(h))}return d}startAnimation(e){const{drag:s,dragMomentum:r,dragElastic:l,dragTransition:u,dragSnapToOrigin:d,onDragTransitionEnd:h}=this.getProps(),m=this.constraints||{},g=ts(y=>{if(!Gc(y,s,this.currentDirection))return;let x=m&&m[y]||{};d&&(x={min:0,max:0});const w=l?200:1e6,S=l?40:1e7,E={type:"inertia",velocity:r?e[y]:0,bounceStiffness:w,bounceDamping:S,timeConstant:750,restDelta:1,restSpeed:10,...u,...x};return this.startAxisValueAnimation(y,E)});return Promise.all(g).then(h)}startAxisValueAnimation(e,s){const r=this.getAxisMotionValue(e);return wm(this.visualElement,e),r.start(hp(e,r,0,s,this.visualElement,!1))}stopAnimation(){ts(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){const s=`_drag${e.toUpperCase()}`,r=this.visualElement.getProps(),l=r[s];return l||this.visualElement.getValue(e,(r.initial?r.initial[e]:void 0)||0)}snapToCursor(e){ts(s=>{const{drag:r}=this.getProps();if(!Gc(s,r,this.currentDirection))return;const{projection:l}=this.visualElement,u=this.getAxisMotionValue(s);if(l&&l.layout){const{min:d,max:h}=l.layout.layoutBox[s],m=u.get()||0;u.set(e[s]-mt(d,h,.5)+m)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:s}=this.getProps(),{projection:r}=this.visualElement;if(!Zr(s)||!r||!this.constraints)return;this.stopAnimation();const l={x:0,y:0};ts(d=>{const h=this.getAxisMotionValue(d);if(h&&this.constraints!==!1){const m=h.get();l[d]=U3({min:m,max:m},this.constraints[d])}});const{transformTemplate:u}=this.visualElement.getProps();this.visualElement.current.style.transform=u?u({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.constraints=!1,this.resolveConstraints(),ts(d=>{if(!Gc(d,e,null))return;const h=this.getAxisMotionValue(d),{min:m,max:g}=this.constraints[d];h.set(mt(m,g,l[d]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;I3.set(this.visualElement,this);const e=this.visualElement.current,s=Ao(e,"pointerdown",g=>{const{drag:y,dragListener:x=!0}=this.getProps(),w=g.target,S=w!==e&&jM(w);y&&x&&!S&&this.start(g)});let r;const l=()=>{const{dragConstraints:g}=this.getProps();Zr(g)&&g.current&&(this.constraints=this.resolveRefConstraints(),r||(r=q3(e,g.current,()=>this.scalePositionWithinConstraints())))},{projection:u}=this.visualElement,d=u.addEventListener("measure",l);u&&!u.layout&&(u.root&&u.root.updateScroll(),u.updateLayout()),lt.read(l);const h=Xo(window,"resize",()=>this.scalePositionWithinConstraints()),m=u.addEventListener("didUpdate",(({delta:g,hasLayoutChanged:y})=>{this.isDragging&&y&&(ts(x=>{const w=this.getAxisMotionValue(x);w&&(this.originPoint[x]+=g[x].translate,w.set(w.get()+g[x].translate))}),this.visualElement.render())}));return()=>{h(),s(),d(),m&&m(),r&&r()}}getProps(){const e=this.visualElement.getProps(),{drag:s=!1,dragDirectionLock:r=!1,dragPropagation:l=!1,dragConstraints:u=!1,dragElastic:d=Am,dragMomentum:h=!0}=e;return{...e,drag:s,dragDirectionLock:r,dragPropagation:l,dragConstraints:u,dragElastic:d,dragMomentum:h}}}function Fb(t){let e=!0;return()=>{if(e){e=!1;return}t()}}function q3(t,e,s){const r=Z0(t,Fb(s)),l=Z0(e,Fb(s));return()=>{r(),l()}}function Gc(t,e,s){return(e===!0||e===t)&&(s===null||s===t)}function H3(t,e=10){let s=null;return Math.abs(t.y)>e?s="y":Math.abs(t.x)>e&&(s="x"),s}class G3 extends va{constructor(e){super(e),this.removeGroupControls=Ln,this.removeListeners=Ln,this.controls=new $3(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ln}update(){const{dragControls:e}=this.node.getProps(),{dragControls:s}=this.node.prevProps||{};e!==s&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const Lf=t=>(e,s)=>{t&<.update(()=>t(e,s),!1,!0)};class F3 extends va{constructor(){super(...arguments),this.removePointerDownListener=Ln}onPointerDown(e){this.session=new wj(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:bj(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:s,onPan:r,onPanEnd:l}=this.node.getProps();return{onSessionStart:Lf(e),onStart:Lf(s),onMove:Lf(r),onEnd:(u,d)=>{delete this.session,l&<.postRender(()=>l(u,d))}}}mount(){this.removePointerDownListener=Ao(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let Uf=!1;class K3 extends v.Component{componentDidMount(){const{visualElement:e,layoutGroup:s,switchLayoutGroup:r,layoutId:l}=this.props,{projection:u}=e;u&&(s.group&&s.group.add(u),r&&r.register&&l&&r.register(u),Uf&&u.root.didUpdate(),u.addEventListener("animationComplete",()=>{this.safeToRemove()}),u.setOptions({...u.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),nu.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:s,visualElement:r,drag:l,isPresent:u}=this.props,{projection:d}=r;return d&&(d.isPresent=u,e.layoutDependency!==s&&d.setOptions({...d.options,layoutDependency:s}),Uf=!0,l||e.layoutDependency!==s||s===void 0||e.isPresent!==u?d.willUpdate():this.safeToRemove(),e.isPresent!==u&&(u?d.promote():d.relegate()||lt.postRender(()=>{const h=d.getStack();(!h||!h.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),gp.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:s,switchLayoutGroup:r}=this.props,{projection:l}=e;Uf=!0,l&&(l.scheduleCheckAfterUnmount(),s&&s.group&&s.group.remove(l),r&&r.deregister&&r.deregister(l))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function jj(t){const[e,s]=dj(),r=v.useContext(Xm);return o.jsx(K3,{...t,layoutGroup:r,switchLayoutGroup:v.useContext(vj),isPresent:e,safeToRemove:s})}const Y3={pan:{Feature:F3},drag:{Feature:G3,ProjectionNode:uj,MeasureLayout:jj}};function Kb(t,e,s){const{props:r}=t;t.animationState&&r.whileHover&&t.animationState.setActive("whileHover",s==="Start");const l="onHover"+s,u=r[l];u&<.postRender(()=>u(e,il(e)))}class X3 extends va{mount(){const{current:e}=this.node;e&&(this.unmount=xM(e,(s,r)=>(Kb(this.node,r,"Start"),l=>Kb(this.node,l,"End"))))}unmount(){}}class W3 extends va{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=sl(Xo(this.node.current,"focus",()=>this.onFocus()),Xo(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Yb(t,e,s){const{props:r}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&r.whileTap&&t.animationState.setActive("whileTap",s==="Start");const l="onTap"+(s==="End"?"":s),u=r[l];u&<.postRender(()=>u(e,il(e)))}class J3 extends va{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:s,propagate:r}=this.node.props;this.unmount=NM(e,(l,u)=>(Yb(this.node,u,"Start"),(d,{success:h})=>Yb(this.node,d,h?"End":"Cancel")),{useGlobalTarget:s,stopPropagation:r?.tap===!1})}unmount(){}}const Rm=new WeakMap,Bf=new WeakMap,Q3=t=>{const e=Rm.get(t.target);e&&e(t)},Z3=t=>{t.forEach(Q3)};function e6({root:t,...e}){const s=t||document;Bf.has(s)||Bf.set(s,{});const r=Bf.get(s),l=JSON.stringify(e);return r[l]||(r[l]=new IntersectionObserver(Z3,{root:t,...e})),r[l]}function t6(t,e,s){const r=e6(e);return Rm.set(t,s),r.observe(t),()=>{Rm.delete(t),r.unobserve(t)}}const n6={some:0,all:1};class s6 extends va{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:s,margin:r,amount:l="some",once:u}=e,d={root:s?s.current:void 0,rootMargin:r,threshold:typeof l=="number"?l:n6[l]},h=m=>{const{isIntersecting:g}=m;if(this.isInView===g||(this.isInView=g,u&&!g&&this.hasEnteredView))return;g&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",g);const{onViewportEnter:y,onViewportLeave:x}=this.node.getProps(),w=g?y:x;w&&w(m)};return t6(this.node.current,d,h)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:s}=this.node;["amount","margin","root"].some(a6(e,s))&&this.startObserver()}unmount(){}}function a6({viewport:t={}},{viewport:e={}}={}){return s=>t[s]!==e[s]}const r6={inView:{Feature:s6},tap:{Feature:J3},focus:{Feature:W3},hover:{Feature:X3}},i6={layout:{ProjectionNode:uj,MeasureLayout:jj}},o6={...A3,...r6,...Y3,...i6},Ro=N3(o6,T3);function l6({supabase:t,initStatus:e,onSuccess:s,onResetConfigs:r}){const[l,u]=v.useState(""),[d,h]=v.useState(""),[m,g]=v.useState(""),[y,x]=v.useState(""),[w,S]=v.useState(!1),[E,j]=v.useState(null),[_,N]=v.useState(!1),[k,C]=v.useState(e==="empty");v.useEffect(()=>{C(e==="empty")},[e]);async function A(U){U.preventDefault(),S(!0),j(null);try{const{error:V}=await t.auth.signInWithPassword({email:l,password:d});if(V)throw V;s()}catch(V){j(V.message||"Authentication failed.")}finally{S(!1)}}async function D(U){U.preventDefault(),S(!0),j(null);try{const V=await Te.setup({email:l,password:d,first_name:m,last_name:y});if(V.error)throw new Error(typeof V.error=="string"?V.error:V.error.message);const{error:R}=await t.auth.signInWithPassword({email:l,password:d});if(R)throw R;s()}catch(V){j(V.message||"Failed to initialize foundation.")}finally{S(!1)}}return o.jsxs("div",{className:"min-h-screen bg-background flex items-center justify-center p-6 relative overflow-hidden",children:[o.jsxs("div",{className:"absolute top-0 left-0 w-full h-full overflow-hidden pointer-events-none opacity-20",children:[o.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[40%] h-[40%] bg-primary/20 blur-[120px] rounded-full animate-pulse"}),o.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[40%] h-[40%] bg-primary/10 blur-[120px] rounded-full animate-pulse delay-700"})]}),o.jsxs("div",{className:"absolute top-8 right-8 flex items-center gap-4 z-50",children:[o.jsx(e1,{}),o.jsxs("div",{className:"hidden sm:flex items-center gap-2 px-3 py-1.5 bg-muted/40 rounded-full border border-border/40 cursor-pointer hover:bg-muted/60 transition-colors group",children:[o.jsx(ou,{className:"w-3.5 h-3.5"}),o.jsx("span",{className:"text-[10px] font-extrabold tracking-widest text-muted-foreground",children:"EN"})]})]}),o.jsxs(Ro.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8,ease:"easeOut"},className:"w-full max-w-[450px] relative z-10",children:[o.jsxs("div",{className:"bg-card/40 backdrop-blur-2xl border border-border/40 p-10 rounded-[2.5rem] shadow-2xl shadow-black/10 space-y-8 overflow-hidden relative",children:[o.jsx("div",{className:"absolute top-0 left-0 w-full h-1 bg-gradient-to-r from-transparent via-primary/40 to-transparent"}),o.jsxs("div",{className:"text-center space-y-4",children:[o.jsx("div",{className:"mx-auto w-16 h-16 bg-primary rounded-2xl flex items-center justify-center shadow-xl shadow-primary/20 hover:scale-105 transition-transform duration-500",children:o.jsx(ou,{className:"w-10 h-10"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-4xl font-black tracking-tighter uppercase italic text-foreground leading-none",children:k?"Initialization":"Access Gate"}),o.jsx("p",{className:"text-[10px] text-muted-foreground font-black tracking-[0.3em] uppercase mt-2 opacity-60",children:k?"Primary Administrator Enrollment":"Foundational Identity Required"})]})]}),o.jsxs("form",{onSubmit:k?D:A,className:"space-y-6",children:[o.jsx(_p,{mode:"wait",children:k&&o.jsxs(Ro.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{className:"text-[10px] font-black uppercase tracking-widest text-muted-foreground ml-1",children:"First Name"}),o.jsx(je,{placeholder:"Agent",value:m,onChange:U=>g(U.target.value),required:k,className:"h-12 bg-background/50 border-border/40 rounded-xl"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{className:"text-[10px] font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Last Name"}),o.jsx(je,{placeholder:"Zero",value:y,onChange:U=>x(U.target.value),required:k,className:"h-12 bg-background/50 border-border/40 rounded-xl"})]})]})}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{className:"text-[10px] font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Email Coordinates"}),o.jsxs("div",{className:"relative group",children:[o.jsx(Vo,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4.5 h-4.5 text-muted-foreground/40 group-focus-within:text-primary transition-colors"}),o.jsx(je,{type:"email",placeholder:"admin@realtimex.ai",value:l,onChange:U=>u(U.target.value),required:!0,className:"pl-12 h-14 bg-background/50 border-border/40 rounded-2xl focus:ring-primary/20 font-medium"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{className:"text-[10px] font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Security Key"}),o.jsxs("div",{className:"relative group",children:[o.jsx(Zo,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4.5 h-4.5 text-muted-foreground/40 group-focus-within:text-primary transition-colors"}),o.jsx(je,{type:_?"text":"password",placeholder:"••••••••",value:d,onChange:U=>h(U.target.value),required:!0,className:"pl-12 pr-12 h-14 bg-background/50 border-border/40 rounded-2xl focus:ring-primary/20 font-medium"}),o.jsx("button",{type:"button",onClick:()=>N(!_),className:"absolute right-4 top-1/2 -translate-y-1/2 text-muted-foreground/40 hover:text-primary transition-colors focus:outline-none",children:_?o.jsx(sC,{className:"w-5 h-5"}):o.jsx(rC,{className:"w-5 h-5"})})]})]}),E&&o.jsx(Ro.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},children:o.jsxs(jn,{variant:"destructive",className:"bg-destructive/5 text-destructive border-destructive/20 py-3 rounded-2xl",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Sn,{className:"w-4 h-4 shrink-0"}),o.jsx(_n,{className:"text-xs font-bold leading-relaxed",children:E})]}),(E.includes("fetch")||E.includes("connection"))&&r&&o.jsx(ae,{variant:"link",size:"sm",onClick:r,className:"text-[10px] font-black uppercase tracking-tighter text-destructive h-auto p-0 mt-2 ml-6 hover:no-underline hover:opacity-70",children:"Reset Configuration Foundation"})]})}),o.jsx(ae,{size:"lg",className:"w-full h-14 rounded-2xl text-base font-black shadow-xl shadow-primary/20 hover:scale-[1.02] active:scale-[0.98] transition-all duration-300",disabled:w,children:w?o.jsx(it,{className:"w-5 h-5 animate-spin"}):o.jsxs(o.Fragment,{children:[k?o.jsx(ya,{className:"w-5 h-5 mr-3"}):o.jsx(Vw,{className:"w-5 h-5 mr-3"}),k?"Engage Administrator":"Log In to Dashboard"]})})]}),o.jsx("div",{className:"pt-6 border-t border-border/10",children:o.jsxs("button",{type:"button",onClick:()=>{j(null),C(!k)},className:"w-full text-[10px] font-black uppercase tracking-[0.2em] text-muted-foreground hover:text-primary transition-colors flex items-center justify-center gap-2 group",children:[k?"Already have an account? Access Gate":"First time? Enroll Primary Admin",o.jsx(Ck,{className:"w-3 h-3 group-hover:translate-x-1 transition-transform"})]})})]}),o.jsx("div",{className:"mt-10 text-center",children:o.jsx("p",{className:"text-[10px] font-black text-muted-foreground/30 uppercase tracking-[0.5em]",children:"Powered by Foundations Protocol 2026"})})]})]})}const c6={"app.name":"Folio","common.loading":"Loading...","common.save":"Save Changes","common.cancel":"Cancel","common.delete":"Delete","common.success":"Success","common.error":"Error","common.warning":"Warning","common.syncNow":"Sync Now","common.syncing":"Syncing...","common.stopSync":"Stop Sync","common.saveChanges":"Save Changes","common.previous":"Previous","common.next":"Next","nav.dashboard":"Dashboard","nav.configuration":"Configuration","nav.accountSettings":"Account Settings","nav.signOut":"Sign Out","config.title":"Foundation Configuration","config.llmSettings":"AI Intelligence Settings","config.accounts.title":"Email Accounts","config.accounts.desc":"Connect and manage your email accounts","config.accounts.addNew":"Add New Account","config.accounts.yourAccounts":"Your Connected Accounts","config.accounts.noAccounts":"No email accounts connected yet","config.accounts.disconnect":"Disconnect","config.gmail.connect":"Connect Gmail","config.gmail.connectDesc":"Connect your Google account","config.outlook.connect":"Connect Outlook","config.outlook.connectDesc":"Connect your Microsoft account","config.model.title":"AI Model Configuration","config.model.desc":"Configure your AI model and processing settings","config.llm.title":"LLM","config.model.provider":"LLM Provider","config.model.name":"Model Name","config.model.selectModel":"Select a model","config.model.syncInterval":"Sync Interval (minutes)","config.model.intelligentRename":"Intelligent Rename","config.model.checkConnection":"Check Connection","config.model.saveConfig":"Save Configuration","config.providers.gmail":"Gmail","config.providers.outlook":"Outlook","config.providers.imap":"IMAP / SMTP","config.embed.title":"Embedding (RAG)","config.embed.desc":"Configure embeddings for knowledge base search.","config.byok.title":"Provider Credentials (BYOK)","config.byok.desc":"Configure your own API keys and OAuth credentials.","config.byok.googleTitle":"Google Cloud","config.byok.microsoftTitle":"Microsoft Azure","config.byok.clientId":"Client ID","config.byok.clientSecret":"Client Secret","config.imap.title":"Connect via IMAP","config.imap.connect":"Connect IMAP Account","config.imap.desc":"Connect any email provider using IMAP/SMTP.","config.voice.title":"Voice & Speech","config.voice.desc":"Configure text-to-speech for AI interaction.","config.voice.autoTitle":"Auto-Speak Responses","config.voice.provider":"TTS Provider","config.voice.voice":"Voice","config.voice.speed":"Speed","config.voice.quality":"Quality","config.toast.settingsSaved":"Settings saved successfully","config.toast.connectionFailed":"Failed to connect to provider","config.toast.accountDisconnected":"Account disconnected","config.gmail.authSteps":"Follow the prompts in the popup to authorize access.","config.gmail.credentialsDesc":"Enter your Google OAuth credentials.","config.outlook.credentialsDesc":"Enter your Microsoft Azure credentials.","config.outlook.instructions":"Use the device code below to authenticate.","setup.back":"Back","setup.engage":"Connect"},u6=c6,_j=v.createContext(void 0);function d6({children:t}){const[e]=v.useState("en"),[s]=v.useState(!1),r=v.useCallback(d=>{},[]),l=v.useCallback(d=>u6[d]||d,[]),u=v.useMemo(()=>({language:e,setLanguage:r,t:l,isLoading:s}),[e,l,s]);return o.jsx(_j.Provider,{value:u,children:t})}function bi(){const t=v.useContext(_j);if(t===void 0)throw new Error("useLanguage must be used within a LanguageProvider");return t}function Ia(t,e){return t?typeof t=="string"?t:t.message||e:e}const Nj={user:null,isAuthenticated:!1,profile:null,accounts:[],rules:[],settings:null,stats:null,isLoading:!0,isInitialized:!1,error:null};function h6(t,e){switch(e.type){case"SET_USER":{const s=!!e.payload;return{...t,user:e.payload,isAuthenticated:s,isLoading:!1}}case"SET_LOADING":return{...t,isLoading:e.payload};case"SET_INITIALIZED":return{...t,isInitialized:e.payload};case"SET_ERROR":return{...t,error:e.payload,isLoading:!1};case"SET_PROFILE":return{...t,profile:e.payload};case"UPDATE_PROFILE":return{...t,profile:e.payload};case"SET_ACCOUNTS":return{...t,accounts:e.payload};case"ADD_ACCOUNT":return{...t,accounts:[e.payload,...t.accounts]};case"REMOVE_ACCOUNT":return{...t,accounts:t.accounts.filter(s=>s.id!==e.payload)};case"SET_RULES":return{...t,rules:e.payload};case"ADD_RULE":return{...t,rules:[e.payload,...t.rules]};case"UPDATE_RULE":return{...t,rules:t.rules.map(s=>s.id===e.payload.id?e.payload:s)};case"REMOVE_RULE":return{...t,rules:t.rules.filter(s=>s.id!==e.payload)};case"SET_SETTINGS":return{...t,settings:e.payload};case"SET_STATS":return{...t,stats:e.payload};case"CLEAR_DATA":return{...Nj,isLoading:!1,isInitialized:!0};default:return t}}const Tj=v.createContext(null);function f6({children:t}){const[e,s]=v.useReducer(h6,Nj),r=v.useMemo(()=>un(),[]);v.useEffect(()=>{if(!r){s({type:"SET_INITIALIZED",payload:!0});return}async function d(){if(!r)return;const{data:{session:h}}=await r.auth.getSession();s({type:"SET_USER",payload:h?.user||null}),s({type:"SET_INITIALIZED",payload:!0});const{data:{subscription:m}}=r.auth.onAuthStateChange((g,y)=>{s({type:"SET_USER",payload:y?.user||null}),y||s({type:"CLEAR_DATA"})});return()=>m.unsubscribe()}d()},[r]);const l=v.useMemo(()=>({fetchAccounts:async()=>{if(!r)return;const{data:{session:d}}=await r.auth.getSession(),h=await Te.getAccounts(d?.access_token);h.data&&s({type:"SET_ACCOUNTS",payload:h.data.accounts})},fetchRules:async()=>{if(!r)return;const{data:{session:d}}=await r.auth.getSession(),h=await Te.getRules(d?.access_token);h.data&&s({type:"SET_RULES",payload:h.data.rules})},fetchSettings:async()=>{if(!r)return;const{data:{session:d}}=await r.auth.getSession(),h=await Te.getSettings(d?.access_token);h.data&&h.data.settings&&s({type:"SET_SETTINGS",payload:h.data.settings})},fetchProfile:async()=>{if(!r)return;const{data:{session:d}}=await r.auth.getSession(),h=await Te.getProfile(d?.access_token);h.data&&s({type:"SET_PROFILE",payload:h.data})},fetchStats:async()=>{if(!r)return;const{data:{session:d}}=await r.auth.getSession(),h=await Te.getStats(d?.access_token);h.data&&s({type:"SET_STATS",payload:h.data.stats})},disconnectAccount:async d=>{if(!r)return!1;const{data:{session:h}}=await r.auth.getSession(),m=await Te.disconnectAccount(d,h?.access_token);return m.data?.success?(s({type:"REMOVE_ACCOUNT",payload:d}),!0):(s({type:"SET_ERROR",payload:Ia(m.error,"Failed to disconnect")}),!1)},updateSettings:async d=>{if(!r)return!1;const{data:{session:h}}=await r.auth.getSession(),m=await Te.updateSettings(d,h?.access_token);return m.data&&m.data.settings?(s({type:"SET_SETTINGS",payload:m.data.settings}),!0):(s({type:"SET_ERROR",payload:Ia(m.error,"Failed to update settings")}),!1)},updateProfile:async d=>{if(!r)return!1;const{data:{session:h}}=await r.auth.getSession(),m=await Te.updateProfile(d,h?.access_token);return m.data?(s({type:"UPDATE_PROFILE",payload:m.data}),!0):(s({type:"SET_ERROR",payload:Ia(m.error,"Failed to update profile")}),!1)},createRule:async d=>{if(!r)return!1;const{data:{session:h}}=await r.auth.getSession(),m=await Te.createRule(d,h?.access_token);return m.data?(s({type:"ADD_RULE",payload:m.data.rule}),!0):(s({type:"SET_ERROR",payload:Ia(m.error,"Failed to create rule")}),!1)},updateRule:async(d,h)=>{if(!r)return!1;const{data:{session:m}}=await r.auth.getSession(),g=await Te.updateRule(d,h,m?.access_token);return g.data?(s({type:"UPDATE_RULE",payload:g.data.rule}),!0):(s({type:"SET_ERROR",payload:Ia(g.error,"Failed to update rule")}),!1)},deleteRule:async d=>{if(!r)return!1;const{data:{session:h}}=await r.auth.getSession(),m=await Te.deleteRule(d,h?.access_token);return m.data?.success?(s({type:"REMOVE_RULE",payload:d}),!0):(s({type:"SET_ERROR",payload:Ia(m.error,"Failed to delete rule")}),!1)},toggleRule:async d=>{if(!r)return!1;const{data:{session:h}}=await r.auth.getSession(),m=await Te.toggleRule(d,h?.access_token);return m.data?(s({type:"UPDATE_RULE",payload:m.data.rule}),!0):(s({type:"SET_ERROR",payload:Ia(m.error,"Failed to toggle rule")}),!1)}}),[e.accounts,e.rules]),u=v.useMemo(()=>({state:e,dispatch:s,actions:l,supabase:r}),[e,l,r]);return o.jsx(Tj.Provider,{value:u,children:t})}function ol(){const t=v.useContext(Tj);if(!t)throw new Error("useApp must be used within AppProvider");return t}function m6(t){return null}function cn({className:t,size:e="md",text:s}){const r={sm:"w-4 h-4",md:"w-6 h-6",lg:"w-10 h-10"};return o.jsxs("div",{className:ge("flex flex-col items-center justify-center gap-3",t),children:[o.jsx(it,{className:ge("animate-spin text-primary",r[e])}),s&&o.jsx("p",{className:"text-sm text-muted-foreground animate-pulse",children:s})]})}function p6({open:t,onOpenChange:e}){const{t:s}=bi(),{actions:r}=ol(),[l,u]=v.useState(!1),[d,h]=v.useState(""),[m,g]=v.useState(""),[y,x]=v.useState(""),[w,S]=v.useState(993),[E,j]=v.useState(""),[_,N]=v.useState(465),[k,C]=v.useState(!0),[A,D]=v.useState(!0),U=R=>{const P=R.target.value;if(h(P),P.includes("@")){const Z=P.split("@")[1].toLowerCase();Z.includes("gmail.com")?(x("imap.gmail.com"),j("smtp.gmail.com"),S(993),C(!0),N(465),D(!0)):Z.includes("outlook.com")||Z.includes("hotmail.com")?(x("outlook.office365.com"),j("smtp.office365.com"),S(993),C(!0),N(587),D(!1)):Z.includes("yahoo.com")?(x("imap.mail.yahoo.com"),j("smtp.mail.yahoo.com"),S(993),C(!0),N(465),D(!0)):Z.includes("icloud.com")?(x("imap.mail.me.com"),j("smtp.mail.me.com"),S(993),C(!0),N(587),D(!1)):Z.includes("fastmail.com")&&(x("imap.fastmail.com"),j("smtp.fastmail.com"),S(993),C(!0),N(465),D(!0))}},V=async()=>{if(!d||!m||!y||!E){ce.error(s("config.imap.missingFields"));return}u(!0);try{(await Te.connectImap({email:d,password:m,imapHost:y,imapPort:Number(w),smtpHost:E,smtpPort:Number(_),imapSecure:k,smtpSecure:A})).data?.success?(ce.success(s("config.imap.connected")),e(!1),r.fetchAccounts(),h(""),g(""),x(""),j(""),S(993),N(465),C(!0),D(!0)):ce.error(s("config.imap.connectFailed"))}catch(R){console.error("IMAP Connect Error:",R),ce.error(s("config.imap.connectFailed"))}finally{u(!1)}};return o.jsx(Za,{open:t,onOpenChange:e,children:o.jsxs(er,{className:"sm:max-w-2xl",children:[o.jsxs(hi,{children:[o.jsxs(fi,{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-8 h-8 rounded-full bg-slate-100 dark:bg-slate-800 flex items-center justify-center text-slate-600 dark:text-slate-400 font-bold text-sm",children:o.jsx(Vo,{className:"w-4 h-4"})}),s("config.imap.connect")]}),o.jsx(tl,{children:s("config.imap.desc")})]}),o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsxs("div",{className:"p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg flex gap-3",children:[o.jsx(Sn,{className:"w-5 h-5 text-blue-600 dark:text-blue-400 shrink-0 mt-0.5"}),o.jsxs("div",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-1",children:[o.jsx("p",{className:"font-medium",children:s("config.imap.appPasswordTitle")}),o.jsx("p",{children:s("config.imap.appPasswordDesc")})]})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:s("config.imap.emailLabel")}),o.jsx(je,{placeholder:"you@example.com",value:d,onChange:U,type:"email"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:s("config.imap.passwordLabel")}),o.jsx(je,{placeholder:"xxxx-xxxx-xxxx-xxxx",value:m,onChange:R=>g(R.target.value),type:"password"})]}),o.jsxs("div",{className:"pt-2",children:[o.jsxs("div",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[o.jsx(KC,{className:"w-4 h-4"}),s("config.imap.serverSettings")]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4 p-4 border rounded-lg bg-secondary/10",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"IMAP Host"}),o.jsx(je,{className:"h-8 text-xs font-mono",placeholder:"imap.example.com",value:y,onChange:R=>x(R.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Port"}),o.jsx(je,{className:"h-8 text-xs font-mono",placeholder:"993",type:"number",value:w,onChange:R=>{const P=parseInt(R.target.value)||993;S(P),C(P===993)}}),o.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:k,onChange:R=>C(R.target.checked),className:"accent-primary"}),o.jsx("span",{className:"text-xs text-muted-foreground",children:"Implicit TLS"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"SMTP Host"}),o.jsx(je,{className:"h-8 text-xs font-mono",placeholder:"smtp.example.com",value:E,onChange:R=>j(R.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Port"}),o.jsx(je,{className:"h-8 text-xs font-mono",placeholder:"465",type:"number",value:_,onChange:R=>{const P=parseInt(R.target.value)||465;N(P),D(P===465)}}),o.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:A,onChange:R=>D(R.target.checked),className:"accent-primary"}),o.jsx("span",{className:"text-xs text-muted-foreground",children:"Implicit TLS"})]})]})]})]})]})]}),o.jsxs(ti,{children:[o.jsx(ae,{variant:"outline",onClick:()=>e(!1),children:s("common.cancel")}),o.jsxs(ae,{onClick:V,disabled:l||!d||!m||!y||!E,children:[l?o.jsx(cn,{size:"sm",className:"mr-2"}):o.jsx(as,{className:"w-4 h-4 mr-2"}),s("config.imap.connectBtn")]})]})]})})}function g6({localSettings:t,setLocalSettings:e,handleSaveSettings:s,savingSettings:r}){const{state:l,actions:u,supabase:d}=ol(),{t:h}=bi(),[m,g]=v.useState(!1),[y,x]=v.useState("credentials"),[w,S]=v.useState(""),[E,j]=v.useState(""),[_,N]=v.useState(""),[k,C]=v.useState(""),[A,D]=v.useState(!1),[U,V]=v.useState(!1),[R,P]=v.useState(!1),[Z,te]=v.useState("credentials"),[me,Ee]=v.useState(""),[ye,_e]=v.useState(""),[$,Y]=v.useState(!1),[J,pe]=v.useState(null),[se,M]=v.useState(!1),[L,W]=v.useState(!1),[ne,oe]=v.useState(!1),ue=v.useRef(null),q=()=>{x("credentials"),S(""),j(""),N(""),C(""),g(!0)},fe=de=>{S(de);try{const Me=JSON.parse(de),at=Me.installed||Me.web||Me;at.client_id&&j(at.client_id),at.client_secret&&N(at.client_secret)}catch{}},ie=async()=>{if(!E||!_){ce.error(h("config.toast.missingGmailCreds"));return}D(!0);try{if(await u.updateSettings({google_client_id:E,google_client_secret:_})){const Me=d?(await d.auth.getSession()).data.session?.access_token:void 0,at=await Te.getGmailAuthUrl(E,_,Me);at.data?.authUrl?(window.open(at.data.authUrl,"_blank"),x("code"),ce.success(h("config.toast.authorizeAndPaste"))):ce.error(h("config.toast.oauthUrlFailed"))}else ce.error(h("config.toast.saveCredsFailed"))}catch{ce.error(h("config.toast.saveCredsFailed"))}finally{D(!1)}},ze=async()=>{if(!k.trim()){ce.error(h("config.toast.missingAuthCode"));return}V(!0);try{const de=d?(await d.auth.getSession()).data.session?.access_token:void 0;(await Te.connectGmail(k.trim(),E,_,de)).data?.success?(ce.success(h("config.toast.gmailConnected")),g(!1),u.fetchAccounts()):ce.error(h("config.toast.gmailConnectFailed"))}catch{ce.error(h("config.toast.gmailConnectFailed"))}finally{V(!1)}},Be=()=>{te("credentials"),Ee(""),_e(""),P(!0)},kt=async()=>{if(!me){ce.error(h("config.toast.missingOutlookClientId"));return}Y(!0);try{if(await u.updateSettings({microsoft_client_id:me,microsoft_tenant_id:ye||"common"})){const Me=d?(await d.auth.getSession()).data.session?.access_token:void 0,at=await Te.startMicrosoftDeviceFlow(me,ye||"common",Me);at.data?.deviceCode?(pe(at.data.deviceCode),te("device-code"),M(!0),et(at.data.deviceCode.deviceCode,me,ye||"common")):ce.error(h("config.toast.deviceFlowFailed"))}else ce.error(h("config.toast.saveCredsFailed"))}catch{ce.error(h("config.toast.saveCredsFailed"))}finally{Y(!1)}},et=async(de,Me,at)=>{const Ut=setInterval(async()=>{try{const Xn=d?(await d.auth.getSession()).data.session?.access_token:void 0;(await Te.pollMicrosoftDeviceCode(de,Me,at,Xn)).data?.success&&(clearInterval(Ut),pe(null),M(!1),P(!1),ce.success(h("config.toast.outlookConnected")),u.fetchAccounts())}catch{}},5e3);setTimeout(()=>clearInterval(Ut),900*1e3)},le=async de=>{if(!confirm(h("config.toast.disconnectConfirm")))return;await u.disconnectAccount(de)&&ce.success(h("config.toast.accountDisconnected"))},Fe=de=>de==="gmail"?o.jsx("div",{className:"w-10 h-10 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center text-red-600 dark:text-red-400 font-bold",children:"G"}):de==="imap"?o.jsx("div",{className:"w-10 h-10 rounded-full bg-slate-100 dark:bg-slate-800 flex items-center justify-center text-slate-600 dark:text-slate-400",children:o.jsx(Vo,{className:"w-5 h-5"})}):o.jsx("div",{className:"w-10 h-10 rounded-full bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center text-blue-600 dark:text-blue-400 font-bold",children:"O"});return o.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[o.jsx(Za,{open:m,onOpenChange:g,children:o.jsxs(er,{className:"sm:max-w-lg",children:[o.jsxs(hi,{children:[o.jsxs(fi,{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-8 h-8 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center text-red-600 dark:text-red-400 font-bold text-sm",children:"G"}),h("config.gmail.connect")]}),o.jsx(tl,{children:h(y==="credentials"?"config.gmail.credentialsDesc":"config.gmail.authCodeDesc")})]}),y==="credentials"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:h("config.gmail.pasteJson")}),o.jsx("textarea",{className:"w-full h-24 p-3 text-xs font-mono border rounded-lg bg-secondary/10 resize-none focus:outline-none focus:ring-2 focus:ring-primary",placeholder:'{"installed":{"client_id":"...","client_secret":"..."}}',value:w,onChange:de=>fe(de.target.value)})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:h("config.byok.clientId")}),o.jsx(je,{placeholder:h("config.gmail.clientIdPlaceholder"),value:E,onChange:de=>j(de.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:h("config.byok.clientSecret")}),o.jsx(je,{type:"password",placeholder:h("config.gmail.clientSecretPlaceholder"),value:_,onChange:de=>N(de.target.value)})]})]})]}),o.jsxs(ti,{children:[o.jsx(ae,{variant:"outline",onClick:()=>g(!1),children:h("common.cancel")}),o.jsxs(ae,{onClick:ie,disabled:A||!E||!_,children:[A?o.jsx(cn,{size:"sm",className:"mr-2"}):o.jsx(as,{className:"w-4 h-4 mr-2"}),h("common.save")," & Connect"]})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"space-y-4 py-4",children:o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:h("config.gmail.authCode")}),o.jsx(je,{placeholder:h("config.gmail.authCodePlaceholder"),value:k,onChange:de=>C(de.target.value),className:"font-mono"})]})}),o.jsxs(ti,{children:[o.jsx(ae,{variant:"outline",onClick:()=>x("credentials"),children:h("setup.back")}),o.jsxs(ae,{onClick:ze,disabled:U||!k.trim(),children:[U?o.jsx(cn,{size:"sm",className:"mr-2"}):o.jsx(as,{className:"w-4 h-4 mr-2"}),"Connect"]})]})]})]})}),o.jsx(Za,{open:R,onOpenChange:P,children:o.jsxs(er,{className:"sm:max-w-lg",children:[o.jsx(hi,{children:o.jsxs(fi,{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-8 h-8 rounded-full bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center text-blue-600 dark:text-blue-400 font-bold text-sm",children:"O"}),h("config.outlook.connect")]})}),Z==="credentials"?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"space-y-4 py-4",children:o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:h("config.outlook.clientId")}),o.jsx(je,{placeholder:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",value:me,onChange:de=>Ee(de.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:h("config.outlook.tenantIdOptional")}),o.jsx(je,{placeholder:h("config.outlook.tenantPlaceholder"),value:ye,onChange:de=>_e(de.target.value)})]})]})}),o.jsxs(ti,{children:[o.jsx(ae,{variant:"outline",onClick:()=>P(!1),children:h("common.cancel")}),o.jsxs(ae,{onClick:kt,disabled:$||!me,children:[$?o.jsx(cn,{size:"sm",className:"mr-2"}):o.jsx(as,{className:"w-4 h-4 mr-2"}),"Save & Connect"]})]})]}):o.jsxs(o.Fragment,{children:[J&&o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsx("p",{className:"text-sm mb-4",children:J.message}),o.jsx("div",{className:"bg-secondary/10 p-4 rounded-lg flex items-center justify-center",children:o.jsx("code",{className:"text-2xl font-mono font-bold tracking-wider",children:J.userCode})}),o.jsx(ae,{className:"w-full",onClick:()=>window.open(J.verificationUri,"_blank"),children:"Open Login Page"}),o.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs text-muted-foreground",children:[o.jsx(cn,{size:"sm"})," Waiting for authentication..."]})]}),o.jsx(ti,{children:o.jsx(ae,{variant:"outline",onClick:()=>P(!1),children:h("common.cancel")})})]})]})}),o.jsx(p6,{open:L,onOpenChange:W}),o.jsx("div",{ref:ue,children:o.jsxs(ht,{children:[o.jsxs(zt,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>oe(!ne),children:[o.jsxs(Lt,{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ya,{className:"w-5 h-5 text-orange-500"}),h("config.byok.title")]}),ne?o.jsx(Bo,{className:"w-5 h-5"}):o.jsx(di,{className:"w-5 h-5"})]}),o.jsx(wn,{children:h("config.byok.desc")})]}),ne&&o.jsxs(xt,{className:"space-y-6 animate-in slide-in-from-top-2",children:[o.jsxs("div",{className:"space-y-4 border-b pb-4",children:[o.jsxs("h4",{className:"font-medium flex items-center gap-2",children:[o.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500"})," Google"]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsx(je,{type:"password",placeholder:"Client ID",value:t.google_client_id||"",onChange:de=>e(Me=>({...Me,google_client_id:de.target.value}))}),o.jsx(je,{type:"password",placeholder:"Client Secret",value:t.google_client_secret||"",onChange:de=>e(Me=>({...Me,google_client_secret:de.target.value}))})]})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("h4",{className:"font-medium flex items-center gap-2",children:[o.jsx("span",{className:"w-2 h-2 rounded-full bg-blue-500"})," Microsoft"]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[o.jsx(je,{type:"password",placeholder:"Client ID",value:t.microsoft_client_id||"",onChange:de=>e(Me=>({...Me,microsoft_client_id:de.target.value}))}),o.jsx(je,{type:"password",placeholder:"Client Secret",value:t.microsoft_client_secret||"",onChange:de=>e(Me=>({...Me,microsoft_client_secret:de.target.value}))}),o.jsx(je,{placeholder:"Tenant ID",value:t.microsoft_tenant_id||"",onChange:de=>e(Me=>({...Me,microsoft_tenant_id:de.target.value}))})]})]}),o.jsx("div",{className:"flex justify-end mt-4",children:o.jsxs(ae,{onClick:s,disabled:r,variant:"secondary",children:[r?o.jsx(cn,{size:"sm",className:"mr-2"}):o.jsx(as,{className:"w-4 h-4 mr-2"}),"Save API Credentials"]})})]})]})}),o.jsxs(ht,{children:[o.jsxs(zt,{children:[o.jsxs(Lt,{className:"flex items-center gap-2",children:[o.jsx(Eu,{className:"w-5 h-5 text-primary"})," ",h("config.accounts.title")]}),o.jsx(wn,{children:h("config.accounts.desc")})]}),o.jsx(xt,{children:o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[o.jsxs("div",{className:"space-y-4",children:[o.jsx("h3",{className:"text-sm font-semibold",children:h("config.accounts.addNew")}),o.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[o.jsxs(ae,{variant:"outline",className:"h-auto py-4 border-dashed justify-start",onClick:q,children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center mr-3 text-red-600 font-bold",children:"G"}),o.jsx("div",{className:"text-left font-medium",children:"Connect Gmail"})]}),o.jsxs(ae,{variant:"outline",className:"h-auto py-4 border-dashed justify-start",onClick:Be,children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center mr-3 text-blue-600 font-bold",children:"O"}),o.jsx("div",{className:"text-left font-medium",children:"Connect Outlook"})]}),o.jsxs(ae,{variant:"outline",className:"h-auto py-4 border-dashed justify-start",onClick:()=>W(!0),children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-slate-100 dark:bg-slate-800 flex items-center justify-center mr-3 text-slate-600",children:o.jsx(Vo,{})}),o.jsx("div",{className:"text-left font-medium",children:"Connect IMAP"})]})]})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsx("h3",{className:"text-sm font-semibold",children:h("config.accounts.yourAccounts")}),l.accounts.length===0?o.jsx("div",{className:"py-8 text-center text-muted-foreground border-2 border-dashed rounded-lg",children:"No accounts connected"}):o.jsx("div",{className:"space-y-3",children:l.accounts.map(de=>o.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg bg-card",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[Fe(de.provider),o.jsxs("div",{children:[o.jsx("div",{className:"font-medium text-sm",children:de.email_address}),o.jsx("div",{className:"text-[10px] text-muted-foreground uppercase",children:de.provider})]})]}),o.jsx(ae,{variant:"ghost",size:"sm",onClick:()=>le(de.id),className:"text-destructive",children:o.jsx(el,{className:"w-4 h-4"})})]},de.id))})]})]})})]})]})}const Ej=v.createContext(void 0);function y6({children:t}){const[e,s]=v.useState(!1),[r,l]=v.useState(!1),[u,d]=v.useState(null),h=v.useRef(null),m=v.useRef(null),g=v.useRef(null),y=v.useRef(null),x=v.useRef(0),w=v.useCallback(()=>{if(y.current&&(y.current.cancel().catch(()=>{}),y.current=null),g.current){try{g.current.stop(),g.current.disconnect()}catch{}g.current=null}h.current&&(h.current.pause(),h.current.currentTime=0,h.current=null),s(!1),l(!1),d(null),x.current++},[]),S=v.useCallback((N,k)=>new Promise((C,A)=>{N.decodeAudioData(k,D=>{const U=N.createBufferSource();U.buffer=D,U.connect(N.destination),U.onended=()=>C(),U.start(0),g.current=U},D=>A(D))}),[]),E=v.useCallback(async(N,k,C={})=>{w();const A=x.current;l(!0),d(k||null);try{const D=await fetch("/api/tts/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:N,...C})});if(!D.ok)throw new Error("TTS generation failed");const U=await D.blob(),V=URL.createObjectURL(U),R=new Audio(V);h.current=R,R.onplay=()=>s(!0),R.onended=()=>{x.current===A&&(s(!1),l(!1),d(null),URL.revokeObjectURL(V))},R.onerror=()=>{x.current===A&&(s(!1),l(!1),d(null),URL.revokeObjectURL(V))},await R.play()}catch(D){console.error("[TTSContext] Speak failed:",D),x.current===A&&(l(!1),d(null))}},[w]),j=v.useCallback(async(N,k,C={})=>{w();const A=x.current;l(!0),d(k||null);try{const D=await fetch("/api/tts/stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:N,...C})});if(!D.ok)throw new Error("TTS streaming failed");const U=D.body?.getReader();if(!U)throw new Error("No response body");y.current=U;const V=new TextDecoder;let R="";const P=[];m.current||(m.current=new(window.AudioContext||window.webkitAudioContext));const Z=m.current;for(;x.current===A;){const{done:te,value:me}=await U.read();if(te)break;R+=V.decode(me,{stream:!0});const Ee=R.split(`
|
|
105
|
-
`);R=Ee.pop()||"";for(const ye of Ee){const _e=ye.trim();if(!_e||!_e.startsWith("data:"))continue;const $=_e.slice(5).trim();if($)try{const Y=JSON.parse($);if(Y.audio){const J=atob(Y.audio),pe=new Uint8Array(J.length);for(let se=0;se<J.length;se++)pe[se]=J.charCodeAt(se);P.push(pe.buffer),P.length===1&&(s(!0),await S(Z,pe.buffer))}}catch{}}}if(x.current===A)for(let te=1;te<P.length&&x.current===A;te++)await S(Z,P[te]);x.current===A&&(s(!1),l(!1),d(null))}catch(D){console.error("[TTSContext] Stream failed:",D),x.current===A&&(s(!1),l(!1),d(null))}},[w,S]),_=v.useMemo(()=>({isPlaying:e,isSpeaking:r,speakingId:u,currentAudio:h.current,speak:E,speakStream:j,stop:w}),[e,r,u,E,j,w]);return o.jsx(Ej.Provider,{value:_,children:t})}function v6(){const t=v.useContext(Ej);if(t===void 0)throw new Error("useTTSContext must be used within a TTSProvider");return t}function x6(){const{speak:t,speakStream:e,stop:s,isPlaying:r,isSpeaking:l,speakingId:u}=v6(),d=v.useCallback(async(m,g,y={})=>t(m,g,y),[t]),h=v.useCallback(async(m,g,y={})=>e(m,g,y),[e]);return{speak:d,speakStream:h,stop:s,isPlaying:r,isSpeaking:l,speakingId:u}}function b6(){const{t}=bi(),{state:e,actions:s}=ol(),{speak:r}=x6(),[l,u]=v.useState(e.settings?.tts_provider||"piper_local"),[d,h]=v.useState(e.settings?.tts_voice||null),[m,g]=v.useState(e.settings?.tts_speed||1),[y,x]=v.useState(e.settings?.tts_quality||10),[w,S]=v.useState(e.settings?.tts_auto_play??!0),[E,j]=v.useState([]),[_,N]=v.useState(!1),[k,C]=v.useState(!1),[A,D]=v.useState(!1);v.useEffect(()=>{e.settings&&(u(e.settings.tts_provider||"piper_local"),h(e.settings.tts_voice||null),g(e.settings.tts_speed||1),x(e.settings.tts_quality||10),S(e.settings.tts_auto_play??!0))},[e.settings]),v.useEffect(()=>{(async()=>{N(!0);try{const me=await fetch("/api/tts/providers");if(me.ok){const Ee=await me.json();if(Ee.success&&Ee.providers&&(j(Ee.providers),!l&&Ee.providers.length>0)){const ye=Ee.providers[0];u(ye.id),ye.config?.voices?.length>0&&h(ye.config.voices[0])}}else ce.error(t("config.voice.toast.providersFailed"))}catch(me){console.error("Error fetching TTS providers:",me),ce.error(t("config.voice.toast.serviceFailed"))}finally{N(!1)}})()},[t,l]);const V=E.find(te=>te.id===l)?.config?.voices||[],R=te=>{u(te);const me=E.find(Ee=>Ee.id===te);me&&me.config?.voices&&me.config.voices.length>0?h(me.config.voices[0]):h(null)},P=async()=>{C(!0);try{const te=t("config.voice.testText");await r(te,void 0,{provider:l,voice:d||void 0,speed:m,quality:y})}catch(te){console.error("TTS test failed:",te),ce.error(t("config.voice.toast.testFailed"))}finally{C(!1)}},Z=async()=>{D(!0),await s.updateSettings({tts_provider:l,tts_voice:d,tts_speed:m,tts_quality:y,tts_auto_play:w})?ce.success(t("config.voice.toast.saved")):ce.error(t("config.voice.toast.saveFailed")),D(!1)};return o.jsxs(ht,{children:[o.jsxs(zt,{children:[o.jsxs(Lt,{className:"flex items-center gap-2",children:[o.jsx(nm,{className:"w-5 h-5 text-purple-500"}),t("config.voice.title")]}),o.jsx(wn,{children:t("config.voice.desc")})]}),o.jsxs(xt,{className:"space-y-6",children:[o.jsxs("div",{className:"flex items-center justify-between pb-4 border-b text-sm",children:[o.jsxs("div",{className:"space-y-0.5",children:[o.jsx("label",{className:"font-medium",children:t("config.voice.autoTitle")}),o.jsx("p",{className:"text-xs text-muted-foreground",children:t("config.voice.autoHelp")})]}),o.jsxs(ae,{variant:w?"default":"outline",size:"sm",onClick:()=>S(!w),className:"gap-2",children:[w?o.jsx(nm,{className:"w-4 h-4"}):o.jsx(Fw,{className:"w-4 h-4"}),t(w?"common.enabled":"common.disabled")]})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:t("config.voice.provider")}),_?o.jsxs("div",{className:"h-10 border rounded-md flex items-center px-3 bg-muted/20",children:[o.jsx(cn,{size:"sm",className:"mr-2"}),o.jsx("span",{className:"text-xs text-muted-foreground italic",children:t("config.voice.loadingProviders")})]}):o.jsxs("select",{className:"w-full h-10 px-3 border rounded-md bg-background text-sm focus:outline-none focus:ring-2 focus:ring-primary",value:l,onChange:te=>R(te.target.value),disabled:_,children:[E.length===0&&o.jsx("option",{value:"piper_local",children:t("config.voice.piperLocal")}),E.map(te=>o.jsx("option",{value:te.id,children:te.name},te.id))]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:t("config.voice.voice")}),V.length>0?o.jsxs("select",{className:"w-full h-10 px-3 border rounded-md bg-background text-sm focus:outline-none focus:ring-2 focus:ring-primary",value:d||"",onChange:te=>h(te.target.value),disabled:_,children:[!d&&o.jsx("option",{value:"",children:t("config.voice.selectVoice")}),V.map(te=>o.jsx("option",{value:te,children:te},te))]}):o.jsx("div",{className:"h-10 border rounded-md flex items-center px-3 bg-muted/20 text-xs text-muted-foreground",children:t("config.voice.noVoices")})]})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"text-sm font-medium",children:t("config.voice.speed")}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:[m.toFixed(1),"x"]})]}),o.jsx("input",{type:"range",min:"0.5",max:"2.0",step:"0.1",value:m,onChange:te=>g(parseFloat(te.target.value)),className:"w-full h-2 bg-secondary rounded-lg appearance-none cursor-pointer accent-primary"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"text-sm font-medium",children:t("config.voice.quality")}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:[y,"/20"]})]}),o.jsx("input",{type:"range",min:"1",max:"20",step:"1",value:y,onChange:te=>x(parseInt(te.target.value,10)),className:"w-full h-2 bg-secondary rounded-lg appearance-none cursor-pointer accent-primary"})]})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[o.jsxs(ae,{variant:"outline",onClick:P,disabled:k,children:[k?o.jsx(cn,{size:"sm",className:"mr-2"}):o.jsx(iA,{className:"w-4 h-4 mr-2"}),t("config.voice.test")]}),o.jsxs(ae,{onClick:Z,disabled:A,children:[A?o.jsx(cn,{size:"sm",className:"mr-2"}):o.jsx(ma,{className:"w-4 h-4 mr-2"}),t("config.voice.save")]})]})]})]})}function w6(t,e){const s=[],r=(t.llm_provider||e||"").trim(),l=(t.llm_model||"").trim(),u=r&&l?`${r}:${l}`:"",d=t.vision_model_capabilities;if(d&&typeof d=="object"&&!Array.isArray(d))for(const[h,m]of Object.entries(d)){if(!m||typeof m!="object"||Array.isArray(m))continue;const g=m,y=g.state;if(y!=="supported"&&y!=="unsupported")continue;const x=h.indexOf(":"),w=x>=0?h.slice(0,x):"unknown",S=x>=0?h.slice(x+1):h;s.push({key:h,provider:w,model:S,state:y,learnedAt:g.learned_at,expiresAt:g.expires_at,reason:g.reason,isCurrent:h===u})}return u&&!s.some(h=>h.key===u)&&s.unshift({key:u,provider:r,model:l,state:"unknown",isCurrent:!0}),s.sort((h,m)=>h.isCurrent&&!m.isCurrent?-1:!h.isCurrent&&m.isCurrent?1:`${h.provider}:${h.model}`.localeCompare(`${m.provider}:${m.model}`)),s}function S6(t){return t==="supported"?"default":t==="unsupported"?"destructive":"secondary"}function Xb(t){return t.replace(/[^a-zA-Z0-9_-]/g,"-")}function j6({localSettings:t,setLocalSettings:e,handleSaveSettings:s,savingSettings:r,handleTestConnection:l,testingLlm:u,providersWithSaved:d,modelsWithSaved:h,embedProvidersWithSaved:m,embedModelsWithSaved:g,handleProviderChange:y,handleEmbedProviderChange:x,DEFAULT_PROVIDER:w}){const{t:S}=bi(),E=w6(t,w),j=(N,k,C)=>{const A=`${N}:${k}`;e(D=>{const U=D?.vision_model_capabilities&&typeof D.vision_model_capabilities=="object"&&!Array.isArray(D.vision_model_capabilities)?{...D.vision_model_capabilities}:{};if(C==="unknown")delete U[A];else{const V=new Date().toISOString(),R=C==="supported"?180:30,P=new Date(Date.now()+R*24*60*60*1e3).toISOString();U[A]={...U[A]||{},state:C,learned_at:V,expires_at:P,reason:"manual_override"}}return{...D,vision_model_capabilities:U}})},_=()=>{e(N=>({...N,vision_model_capabilities:{}}))};return o.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[o.jsxs(ht,{children:[o.jsx(zt,{children:o.jsxs(Lt,{className:"flex items-center gap-2",children:[o.jsx(ma,{className:"w-5 h-5 text-indigo-500"}),"AI Model Configuration"]})}),o.jsxs(xt,{className:"space-y-6",children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[o.jsxs("div",{className:"space-y-4",children:[o.jsx("label",{className:"text-sm font-medium",htmlFor:"llm-provider-select",children:"LLM Provider"}),o.jsxs("select",{id:"llm-provider-select",className:"w-full h-10 border rounded-md px-3 bg-background",value:t.llm_provider||w,onChange:N=>y(N.target.value),children:[o.jsx("option",{value:w,children:"RealTimeX AI"}),d.filter(N=>N.provider!==w).map(N=>o.jsx("option",{value:N.provider,children:N.name||N.provider},N.provider))]}),o.jsx("label",{className:"text-sm font-medium",htmlFor:"llm-model-select",children:"LLM Model"}),o.jsx("select",{id:"llm-model-select",className:"w-full h-10 border rounded-md px-3 bg-background",value:t.llm_model||"",onChange:N=>e(k=>({...k,llm_model:N.target.value})),children:h.map(N=>o.jsx("option",{value:N.id,children:N.name||N.id},N.id))})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsx("label",{className:"text-sm font-medium",htmlFor:"embedding-provider-select",children:"Embedding Provider"}),o.jsxs("select",{id:"embedding-provider-select",className:"w-full h-10 border rounded-md px-3 bg-background",value:t.embedding_provider||w,onChange:N=>x(N.target.value),children:[o.jsx("option",{value:w,children:"RealTimeX Embed"}),m.filter(N=>N.provider!==w).map(N=>o.jsx("option",{value:N.provider,children:N.name||N.provider},N.provider))]}),o.jsx("label",{className:"text-sm font-medium",htmlFor:"embedding-model-select",children:"Embedding Model"}),o.jsx("select",{id:"embedding-model-select",className:"w-full h-10 border rounded-md px-3 bg-background",value:t.embedding_model||"",onChange:N=>e(k=>({...k,embedding_model:N.target.value})),children:g.map(N=>o.jsx("option",{value:N.id,children:N.name||N.id},N.id))})]})]}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(ae,{variant:"outline",onClick:l,disabled:u,children:"Test Connection"}),o.jsxs(ae,{onClick:s,disabled:r,children:[r?o.jsx(cn,{size:"sm",className:"mr-2"}):o.jsx(as,{className:"w-4 h-4 mr-2"}),"Save AI Config"]})]})]})]}),o.jsx(b6,{}),o.jsxs(ht,{children:[o.jsxs(zt,{children:[o.jsxs(Lt,{className:"flex items-center gap-2",children:[o.jsx(Zf,{className:"w-5 h-5 text-primary"}),"Vision Capability Overrides"]}),o.jsxs("p",{className:"text-sm text-muted-foreground",children:["Review and edit learned multimodal support per model. Set to ",o.jsx("span",{className:"font-medium",children:"Unknown"})," to let Folio probe again."]})]}),o.jsxs(xt,{className:"space-y-4",children:[E.length===0?o.jsx("div",{className:"rounded-md border border-dashed p-4 text-sm text-muted-foreground",children:"No model capability entries yet."}):o.jsx("div",{className:"space-y-3",children:E.map(N=>o.jsx("div",{className:"rounded-md border p-3",children:o.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsxs("p",{className:"font-medium break-all",children:[N.provider," / ",N.model]}),N.isCurrent?o.jsx(Pt,{variant:"outline",children:"Current"}):null,o.jsx(Pt,{variant:S6(N.state),children:N.state})]}),o.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:[N.reason?`reason: ${N.reason}`:"reason: not set",N.expiresAt?` • expires: ${new Date(N.expiresAt).toLocaleString()}`:""]})]}),o.jsxs("div",{className:"w-full md:w-[180px]",children:[o.jsx("label",{className:"sr-only",htmlFor:`vision-state-${Xb(N.key)}`,children:"Vision capability state"}),o.jsxs("select",{id:`vision-state-${Xb(N.key)}`,className:"w-full h-10 border rounded-md px-3 bg-background",value:N.state,onChange:k=>j(N.provider,N.model,k.target.value),children:[o.jsx("option",{value:"unknown",children:"Unknown (auto-probe)"}),o.jsx("option",{value:"supported",children:"Supported"}),o.jsx("option",{value:"unsupported",children:"Unsupported"})]})]})]})},N.key))}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(ae,{variant:"outline",onClick:_,children:"Reset Learned Map"}),o.jsxs(ae,{onClick:s,disabled:r,children:[r?o.jsx(cn,{size:"sm",className:"mr-2"}):o.jsx(as,{className:"w-4 h-4 mr-2"}),"Save Capability Overrides"]})]})]})]}),o.jsxs(ht,{children:[o.jsx(zt,{children:o.jsxs(Lt,{className:"flex items-center gap-2",children:[o.jsx(Qo,{className:"w-5 h-5 text-primary"})," System Settings"]})}),o.jsxs(xt,{className:"space-y-6",children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",htmlFor:"sync-interval-input",children:"Sync Interval (minutes)"}),o.jsx(je,{id:"sync-interval-input",type:"number",value:t.sync_interval_minutes||5,onChange:N=>e(k=>({...k,sync_interval_minutes:parseInt(N.target.value)}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",htmlFor:"storage-path-input",children:"Storage Path"}),o.jsx(je,{id:"storage-path-input",placeholder:"/path/to/storage",value:t.storage_path||"",onChange:N=>e(k=>({...k,storage_path:N.target.value}))})]})]}),o.jsx("div",{className:"flex justify-end",children:o.jsxs(ae,{onClick:s,disabled:r,children:[r?o.jsx(cn,{size:"sm",className:"mr-2"}):o.jsx(as,{className:"w-4 h-4 mr-2"}),"Save System Settings"]})})]})]})]})}function _6(){const{t}=bi(),{supabase:e}=ol(),[s,r]=v.useState([]),[l,u]=v.useState(!0),[d,h]=v.useState(!1),[m,g]=v.useState("credentials"),[y,x]=v.useState(""),[w,S]=v.useState(""),[E,j]=v.useState(""),[_,N]=v.useState(""),[k,C]=v.useState(!1);v.useEffect(()=>{A()},[]);const A=async()=>{try{const R=e?(await e.auth.getSession()).data.session?.access_token:void 0,P=await Te.getAccounts(R);P.data&&P.data.accounts&&r(P.data.accounts)}catch(R){console.error(R)}finally{u(!1)}},D=R=>{N(R);try{const P=JSON.parse(R),Z=P.web||P.installed;Z?.client_id&&Z?.client_secret&&(x(Z.client_id),S(Z.client_secret))}catch{}},U=async()=>{if(!y||!w){ce.error(t("config.gmail.error.missingCreds")||"Please provide Client ID and Secret");return}try{C(!0);const R=e?(await e.auth.getSession()).data.session?.access_token:void 0,P=await Te.getGoogleDriveAuthUrl(y.trim(),R);P.data?.authUrl?(window.open(P.data.authUrl,"_blank","width=600,height=700"),g("auth_code")):ce.error(t("config.gmail.error.authUrl")||"Failed to generate auth URL")}catch{ce.error(t("config.gmail.error.authUrl")||"Failed to generate auth URL")}finally{C(!1)}},V=async()=>{if(!E){ce.error(t("config.gmail.error.missingCode")||"Please provide Auth Code");return}try{C(!0);const R=e?(await e.auth.getSession()).data.session?.access_token:void 0,P=await Te.connectGoogleDrive(E.trim(),y.trim(),w.trim(),R);P.data?.success?(ce.success("Successfully connected to Google Drive"),h(!1),j(""),A()):ce.error(P.error?.message||"Failed to connect")}catch{ce.error("An error occurred while connecting")}finally{C(!1)}};return o.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[o.jsx(Za,{open:d,onOpenChange:h,children:o.jsxs(er,{className:"sm:max-w-lg",children:[o.jsxs(hi,{children:[o.jsxs(fi,{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-8 h-8 rounded-full bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center text-blue-600 dark:text-blue-400 font-bold text-sm",children:"G"}),"Connect Google Drive"]}),o.jsx(tl,{children:m==="credentials"?"Provide your Google Cloud project credentials.":"Paste the authorization code."})]}),m==="credentials"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:"Paste credentials JSON"}),o.jsx("textarea",{className:"w-full h-24 p-3 text-xs font-mono border rounded-lg bg-secondary/10 resize-none focus:outline-none focus:ring-2 focus:ring-primary",placeholder:'{"installed":{"client_id":"...","client_secret":"..."}}',value:_,onChange:R=>D(R.target.value)})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:"Client ID"}),o.jsx(je,{placeholder:"Enter Client ID",value:y,onChange:R=>x(R.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:"Client Secret"}),o.jsx(je,{type:"password",placeholder:"Enter Client Secret",value:w,onChange:R=>S(R.target.value)})]})]})]}),o.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[o.jsx(ae,{variant:"ghost",onClick:()=>h(!1),children:"Cancel"}),o.jsxs(ae,{onClick:U,disabled:k||!y||!w,children:[k?"Generating...":"Next"," ",o.jsx(di,{className:"w-4 h-4 ml-1"})]})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"space-y-4 py-4",children:o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:"Authorization Code"}),o.jsx(je,{placeholder:"Paste the code from Google here",value:E,onChange:R=>j(R.target.value),autoFocus:!0}),o.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"A new window was opened for you to authorize the app. Once you approve, paste the code here."})]})}),o.jsxs("div",{className:"flex justify-between pt-4 border-t",children:[o.jsx(ae,{variant:"ghost",onClick:()=>g("credentials"),children:"Back"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(ae,{variant:"ghost",onClick:()=>h(!1),children:"Cancel"}),o.jsx(ae,{onClick:V,disabled:k||!E,children:k?"Connecting...":"Connect Drive"})]})]})]})]})}),o.jsxs(ht,{children:[o.jsxs(zt,{children:[o.jsxs(Lt,{className:"flex items-center gap-2",children:[o.jsx(f0,{className:"w-5 h-5 text-sky-500"}),"Cloud Storage"]}),o.jsx(wn,{children:"Connect cloud drives like Google Drive or Dropbox to allow Folio to read and write documents directly to your cloud."})]}),o.jsx(xt,{children:o.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[o.jsxs(ht,{className:"flex flex-col border-dashed hover:border-solid hover:border-blue-300 transition-colors",children:[o.jsxs(zt,{className:"pb-3 text-center",children:[o.jsx("div",{className:"w-12 h-12 mx-auto rounded-xl bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center text-blue-600 dark:text-blue-400 mb-2",children:o.jsx(fC,{className:"w-6 h-6"})}),o.jsx(Lt,{className:"text-base",children:"Google Drive"}),o.jsx(wn,{className:"text-xs",children:"Sync files to and from Google Drive"})]}),o.jsx(xt,{className:"flex-1 flex flex-col justify-end pt-0",children:s.some(R=>R.provider==="google_drive"&&R.is_connected)?o.jsxs(ae,{className:"w-full gap-2 text-xs",variant:"secondary",disabled:!0,children:[o.jsx(os,{className:"w-4 h-4 text-green-500"}),"Connected"]}):o.jsx(ae,{className:"w-full gap-2 text-xs",variant:"outline",onClick:()=>{g("credentials"),h(!0)},children:"Connect Google Drive"})})]}),o.jsxs(ht,{className:"flex flex-col border-dashed opacity-50 cursor-not-allowed",children:[o.jsxs(zt,{className:"pb-3 text-center",children:[o.jsx("div",{className:"w-12 h-12 mx-auto rounded-xl bg-blue-100 flex items-center justify-center text-blue-600 mb-2",children:o.jsx(f0,{className:"w-6 h-6"})}),o.jsx(Lt,{className:"text-base",children:"Dropbox"}),o.jsx(wn,{className:"text-xs",children:"Coming soon"})]}),o.jsx(xt,{className:"flex-1 flex flex-col justify-end pt-0",children:o.jsx(ae,{className:"w-full gap-2 text-xs",variant:"outline",disabled:!0,children:"Coming Soon"})})]})]})})]})]})}function N6(t,e){return t?typeof t=="string"?t:typeof t=="object"&&"message"in t?t.message:e:e}const T6=["string","number","date","currency","string[]"];function E6(){const[t,e]=v.useState(null),[s,r]=v.useState(!0),[l,u]=v.useState(!1),[d,h]=v.useState(""),[m,g]=v.useState([]),[y,x]=v.useState(null),[w,S]=v.useState([]),[E,j]=v.useState(!1),[_,N]=v.useState(!1),[k,C]=v.useState(""),[A,D]=v.useState(!1),[U,V]=v.useState(null),[R,P]=v.useState([]),[Z,te]=v.useState(""),[me,Ee]=v.useState("");v.useEffect(()=>{(async()=>{r(!0);try{const fe=un(),{data:ie}=await(fe?.auth.getSession()??Promise.resolve({data:{session:null}})),ze=ie.session?.access_token??null;e(ze);const Be=await Te.getBaselineConfig(ze);Be.data&&(Be.data.config?(h(Be.data.config.context??""),g(Be.data.config.fields),x(Be.data.config.version)):g(Be.data.defaults))}catch{ce.error("Failed to load baseline config")}finally{r(!1)}})()},[]);const ye=v.useCallback(async()=>{try{const fe=(await Te.getSDKChatProviders())?.data?.providers??[];P(fe),fe.length>0&&!Z&&(te(fe[0].provider),Ee(fe[0].models?.[0]?.id??""))}catch{}},[Z]);v.useEffect(()=>{_&&R.length===0&&ye()},[_,R.length,ye]);const _e=async()=>{const q=await Te.getBaselineConfigHistory(t);q.data&&S(q.data.history),j(!0)},$=q=>g(fe=>fe.map(ie=>ie.key===q?{...ie,enabled:!ie.enabled}:ie)),Y=(q,fe)=>g(ie=>ie.map(ze=>ze.key===q?{...ze,description:fe}:ze)),J=()=>g(q=>[...q,{key:"",type:"string",description:"",enabled:!0,is_default:!1}]),pe=(q,fe)=>g(ie=>ie.map((ze,Be)=>Be===q?{...ze,...fe}:ze)),se=q=>g(fe=>fe.filter((ie,ze)=>ze!==q)),M=async()=>{if(m.filter(ie=>ie.enabled).length===0){ce.error("At least one field must be enabled");return}if(m.filter(ie=>!ie.is_default&&ie.enabled&&(!ie.key.trim()||!ie.description.trim())).length>0){ce.error("Custom fields require both a key and a description");return}u(!0);try{const ie=await Te.saveBaselineConfig({context:d||null,fields:m,activate:!0},t);ie.data?.success?(x(ie.data.config.version),ce.success(`Baseline config saved as v${ie.data.config.version}`),E&&_e()):ce.error("Failed to save config")}finally{u(!1)}},L=async(q,fe)=>{(await Te.activateBaselineConfig(q,t)).data?.success&&(x(fe),ce.success(`v${fe} is now active`),_e())},W=async()=>{if(k.trim()){D(!0),V(null);try{const q=await Te.suggestBaselineConfig({description:k,provider:Z||void 0,model:me||void 0},t);q.data?.suggestion?(V(q.data.suggestion),ce.success("Suggestion ready — review and apply below.")):ce.error(N6(q.error,"Suggestion failed."))}catch{ce.error("LLM suggestion failed.")}finally{D(!1)}}},ne=()=>{U&&(h(U.context),g(q=>{const fe=new Set(q.map(ze=>ze.key)),ie=U.fields.filter(ze=>ze.key&&!fe.has(ze.key));return[...q,...ie]}),V(null),C(""),N(!1),ce.success("Suggestion applied — review fields then Save & Activate."))};if(s)return o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(cn,{size:"md"})});const oe=m.filter(q=>q.is_default),ue=m.filter(q=>!q.is_default);return o.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[o.jsxs(ht,{className:"border-violet-500/20 bg-violet-500/5",children:[o.jsxs(zt,{className:"cursor-pointer select-none",onClick:()=>{N(q=>!q),V(null)},children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs(Lt,{className:"flex items-center gap-2 text-base",children:[o.jsx(Cs,{className:"w-4 h-4 text-violet-500"}),"Magic Composer"]}),_?o.jsx(lu,{className:"w-4 h-4 text-muted-foreground"}):o.jsx(Bo,{className:"w-4 h-4 text-muted-foreground"})]}),!_&&o.jsx(wn,{children:"Describe your workflow — AI will suggest a context string and custom fields."})]}),_&&o.jsxs(xt,{className:"space-y-4 pt-0",children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Describe your workflow — AI will suggest a context string and custom fields tailored to your documents."}),R.length>0&&o.jsxs("div",{className:"flex gap-2 items-center",children:[o.jsx(Bm,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"}),o.jsx("select",{value:`${Z}::${me}`,onChange:q=>{const[fe,ie]=q.target.value.split("::");te(fe),Ee(ie)},className:"text-xs rounded-lg border border-border/40 bg-background px-2 py-1 flex-1 max-w-xs",children:R.flatMap(q=>(q.models??[]).map(fe=>o.jsxs("option",{value:`${q.provider}::${fe.id}`,children:[q.provider," / ",fe.id]},`${q.provider}::${fe.id}`)))}),o.jsx("span",{className:"text-[10px] text-muted-foreground",children:"for suggestion"})]}),o.jsxs("div",{className:"flex gap-3 items-start",children:[o.jsx("textarea",{className:`flex-1 min-h-[80px] rounded-md border bg-background px-3 py-2 text-sm resize-y
|
|
104
|
+
`),()=>{D.contains(A)&&D.removeChild(A)}},[e]),o.jsx(JD,{isPresent:e,childRef:h,sizeRef:m,pop:u,children:u===!1?t:v.cloneElement(t,{ref:x})})}const ZD=({children:t,initial:e,isPresent:s,onExitComplete:i,custom:l,presenceAffectsLayout:u,mode:d,anchorX:h,anchorY:m,root:g})=>{const y=Wm(e3),x=v.useId();let w=!0,S=v.useMemo(()=>(w=!1,{id:x,initial:e,isPresent:s,custom:l,onExitComplete:E=>{y.set(E,!0);for(const j of y.values())if(!j)return;i&&i()},register:E=>(y.set(E,!1),()=>y.delete(E))}),[s,y,i]);return u&&w&&(S={...S}),v.useMemo(()=>{y.forEach((E,j)=>y.set(j,!1))},[s]),v.useEffect(()=>{!s&&!y.size&&i&&i()},[s]),t=o.jsx(QD,{pop:d==="popLayout",isPresent:s,anchorX:h,anchorY:m,root:g,children:t}),o.jsx(Du.Provider,{value:S,children:t})};function e3(){return new Map}function dj(t=!0){const e=v.useContext(Du);if(e===null)return[!0,null];const{isPresent:s,onExitComplete:i,register:l}=e,u=v.useId();v.useEffect(()=>{if(t)return l(u)},[t]);const d=v.useCallback(()=>t&&i&&i(u),[u,i,t]);return!s&&i?[!1,d]:[!0]}const Hc=t=>t.key||"";function Pb(t){const e=[];return v.Children.forEach(t,s=>{v.isValidElement(s)&&e.push(s)}),e}const _p=({children:t,custom:e,initial:s=!0,onExitComplete:i,presenceAffectsLayout:l=!0,mode:u="sync",propagate:d=!1,anchorX:h="left",anchorY:m="top",root:g})=>{const[y,x]=dj(d),w=v.useMemo(()=>Pb(t),[t]),S=d&&!y?[]:w.map(Hc),E=v.useRef(!0),j=v.useRef(w),_=Wm(()=>new Map),N=v.useRef(new Set),[k,C]=v.useState(w),[A,D]=v.useState(w);B1(()=>{E.current=!1,j.current=w;for(let R=0;R<A.length;R++){const P=Hc(A[R]);S.includes(P)?(_.delete(P),N.current.delete(P)):_.get(P)!==!0&&_.set(P,!1)}},[A,S.length,S.join("-")]);const z=[];if(w!==k){let R=[...w];for(let P=0;P<A.length;P++){const Z=A[P],te=Hc(Z);S.includes(te)||(R.splice(P,0,Z),z.push(Z))}return u==="wait"&&z.length&&(R=z),D(Pb(R)),C(w),null}const{forceRender:V}=v.useContext(Xm);return o.jsx(o.Fragment,{children:A.map(R=>{const P=Hc(R),Z=d&&!y?!1:w===A||S.includes(P),te=()=>{if(N.current.has(P))return;if(N.current.add(P),_.has(P))_.set(P,!0);else return;let me=!0;_.forEach(Ee=>{Ee||(me=!1)}),me&&(V?.(),D(j.current),d&&x?.(),i&&i())};return o.jsx(ZD,{isPresent:Z,initial:!E.current||s?void 0:!1,custom:e,presenceAffectsLayout:l,mode:u,root:g,onExitComplete:Z?void 0:te,anchorX:h,anchorY:m,children:R},P)})})},hj=v.createContext({strict:!1}),zb={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let Lb=!1;function t3(){if(Lb)return;const t={};for(const e in zb)t[e]={isEnabled:s=>zb[e].some(i=>!!s[i])};IS(t),Lb=!0}function fj(){return t3(),IM()}function n3(t){const e=fj();for(const s in t)e[s]={...e[s],...t[s]};IS(e)}const s3=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function Su(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||s3.has(t)}let mj=t=>!Su(t);function a3(t){typeof t=="function"&&(mj=e=>e.startsWith("on")?!Su(e):t(e))}try{a3(require("@emotion/is-prop-valid").default)}catch{}function i3(t,e,s){const i={};for(const l in t)l==="values"&&typeof t.values=="object"||(mj(l)||s===!0&&Su(l)||!e&&!Su(l)||t.draggable&&l.startsWith("onDrag"))&&(i[l]=t[l]);return i}const Lu=v.createContext({});function r3(t,e){if(zu(t)){const{initial:s,animate:i}=t;return{initial:s===!1||Yo(s)?s:void 0,animate:Yo(i)?i:void 0}}return t.inherit!==!1?e:{}}function o3(t){const{initial:e,animate:s}=r3(t,v.useContext(Lu));return v.useMemo(()=>({initial:e,animate:s}),[Ub(e),Ub(s)])}function Ub(t){return Array.isArray(t)?t.join(" "):t}const Np=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function pj(t,e,s){for(const i in e)!Xt(e[i])&&!YS(i,s)&&(t[i]=e[i])}function l3({transformTemplate:t},e){return v.useMemo(()=>{const s=Np();return wp(s,e,t),Object.assign({},s.vars,s.style)},[e])}function c3(t,e){const s=t.style||{},i={};return pj(i,s,t),Object.assign(i,l3(t,e)),i}function u3(t,e){const s={},i=c3(t,e);return t.drag&&t.dragListener!==!1&&(s.draggable=!1,i.userSelect=i.WebkitUserSelect=i.WebkitTouchCallout="none",i.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(s.tabIndex=0),s.style=i,s}const gj=()=>({...Np(),attrs:{}});function d3(t,e,s,i){const l=v.useMemo(()=>{const u=gj();return XS(u,e,JS(i),t.transformTemplate,t.style),{...u.attrs,style:{...u.style}}},[e]);if(t.style){const u={};pj(u,t.style,t),l.style={...u,...l.style}}return l}const h3=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Tp(t){return typeof t!="string"||t.includes("-")?!1:!!(h3.indexOf(t)>-1||/[A-Z]/u.test(t))}function f3(t,e,s,{latestValues:i},l,u=!1,d){const m=(d??Tp(t)?d3:u3)(e,i,l,t),g=i3(e,typeof t=="string",u),y=t!==v.Fragment?{...g,...m,ref:s}:{},{children:x}=e,w=v.useMemo(()=>Xt(x)?x.get():x,[x]);return v.createElement(t,{...y,children:w})}function m3({scrapeMotionValuesFromProps:t,createRenderState:e},s,i,l){return{latestValues:p3(s,i,l,t),renderState:e()}}function p3(t,e,s,i){const l={},u=i(t,{});for(const w in u)l[w]=tu(u[w]);let{initial:d,animate:h}=t;const m=zu(t),g=BS(t);e&&g&&!m&&t.inherit!==!1&&(d===void 0&&(d=e.initial),h===void 0&&(h=e.animate));let y=s?s.initial===!1:!1;y=y||d===!1;const x=y?h:d;if(x&&typeof x!="boolean"&&!Pu(x)){const w=Array.isArray(x)?x:[x];for(let S=0;S<w.length;S++){const E=fp(t,w[S]);if(E){const{transitionEnd:j,transition:_,...N}=E;for(const k in N){let C=N[k];if(Array.isArray(C)){const A=y?C.length-1:0;C=C[A]}C!==null&&(l[k]=C)}for(const k in j)l[k]=j[k]}}}return l}const yj=t=>(e,s)=>{const i=v.useContext(Lu),l=v.useContext(Du),u=()=>m3(t,e,i,l);return s?u():Wm(u)},g3=yj({scrapeMotionValuesFromProps:Sp,createRenderState:Np}),y3=yj({scrapeMotionValuesFromProps:QS,createRenderState:gj}),v3=Symbol.for("motionComponentSymbol");function x3(t,e,s){const i=v.useRef(s);v.useInsertionEffect(()=>{i.current=s});const l=v.useRef(null);return v.useCallback(u=>{u&&t.onMount?.(u),e&&(u?e.mount(u):e.unmount());const d=i.current;if(typeof d=="function")if(u){const h=d(u);typeof h=="function"&&(l.current=h)}else l.current?(l.current(),l.current=null):d(u);else d&&(d.current=u)},[e])}const vj=v.createContext({});function Zi(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function b3(t,e,s,i,l,u){const{visualElement:d}=v.useContext(Lu),h=v.useContext(hj),m=v.useContext(Du),g=v.useContext(jp),y=g.reducedMotion,x=g.skipAnimations,w=v.useRef(null),S=v.useRef(!1);i=i||h.renderer,!w.current&&i&&(w.current=i(t,{visualState:e,parent:d,props:s,presenceContext:m,blockInitialAnimation:m?m.initial===!1:!1,reducedMotionConfig:y,skipAnimations:x,isSVG:u}),S.current&&w.current&&(w.current.manuallyAnimateOnMount=!0));const E=w.current,j=v.useContext(vj);E&&!E.projection&&l&&(E.type==="html"||E.type==="svg")&&w3(w.current,s,l,j);const _=v.useRef(!1);v.useInsertionEffect(()=>{E&&_.current&&E.update(s,m)});const N=s[TS],k=v.useRef(!!N&&!window.MotionHandoffIsComplete?.(N)&&window.MotionHasOptimisedAnimation?.(N));return B1(()=>{S.current=!0,E&&(_.current=!0,window.MotionIsMounted=!0,E.updateFeatures(),E.scheduleRenderMicrotask(),k.current&&E.animationState&&E.animationState.animateChanges())}),v.useEffect(()=>{E&&(!k.current&&E.animationState&&E.animationState.animateChanges(),k.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(N)}),k.current=!1),E.enteringChildren=void 0)}),E}function w3(t,e,s,i){const{layoutId:l,layout:u,drag:d,dragConstraints:h,layoutScroll:m,layoutRoot:g,layoutCrossfade:y}=e;t.projection=new s(t.latestValues,e["data-framer-portal-id"]?void 0:xj(t.parent)),t.projection.setOptions({layoutId:l,layout:u,alwaysMeasureLayout:!!d||h&&Zi(h),visualElement:t,animationType:typeof u=="string"?u:"both",initialPromotionConfig:i,crossfade:y,layoutScroll:m,layoutRoot:g})}function xj(t){if(t)return t.options.allowProjection!==!1?t.projection:xj(t.parent)}function Df(t,{forwardMotionProps:e=!1,type:s}={},i,l){i&&n3(i);const u=s?s==="svg":Tp(t),d=u?y3:g3;function h(g,y){let x;const w={...v.useContext(jp),...g,layoutId:S3(g)},{isStatic:S}=w,E=o3(g),j=d(g,S);if(!S&&U1){j3();const _=_3(w);x=_.MeasureLayout,E.visualElement=b3(t,j,w,l,_.ProjectionNode,u)}return o.jsxs(Lu.Provider,{value:E,children:[x&&E.visualElement?o.jsx(x,{visualElement:E.visualElement,...w}):null,f3(t,g,x3(j,E.visualElement,y),j,S,e,u)]})}h.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const m=v.forwardRef(h);return m[v3]=t,m}function S3({layoutId:t}){const e=v.useContext(Xm).id;return e&&t!==void 0?e+"-"+t:t}function j3(t,e){v.useContext(hj).strict}function _3(t){const e=fj(),{drag:s,layout:i}=e;if(!s&&!i)return{};const l={...s,...i};return{MeasureLayout:s?.isEnabled(t)||i?.isEnabled(t)?l.MeasureLayout:void 0,ProjectionNode:l.ProjectionNode}}function N3(t,e){if(typeof Proxy>"u")return Df;const s=new Map,i=(u,d)=>Df(u,d,t,e),l=(u,d)=>i(u,d);return new Proxy(l,{get:(u,d)=>d==="create"?i:(s.has(d)||s.set(d,Df(d,void 0,t,e)),s.get(d))})}const T3=(t,e)=>e.isSVG??Tp(t)?new aD(e):new QM(e,{allowProjection:t!==v.Fragment});class E3 extends va{constructor(e){super(e),e.animationState||(e.animationState=cD(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();Pu(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:s}=this.node.prevProps||{};e!==s&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let k3=0;class C3 extends va{constructor(){super(...arguments),this.id=k3++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:s}=this.node.presenceContext,{isPresent:i}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===i)return;const l=this.node.animationState.setActive("exit",!e);s&&!e&&l.then(()=>{s(this.id)})}mount(){const{register:e,onExitComplete:s}=this.node.presenceContext||{};s&&s(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const A3={animation:{Feature:E3},exit:{Feature:C3}};function rl(t){return{point:{x:t.pageX,y:t.pageY}}}const R3=t=>e=>yp(e)&&t(e,rl(e));function Ao(t,e,s,i){return Xo(t,e,R3(s),i)}const bj=({current:t})=>t?t.ownerDocument.defaultView:null,Bb=(t,e)=>Math.abs(t-e);function O3(t,e){const s=Bb(t.x,e.x),i=Bb(t.y,e.y);return Math.sqrt(s**2+i**2)}const Vb=new Set(["auto","scroll"]);class wj{constructor(e,s,{transformPagePoint:i,contextWindow:l=window,dragSnapToOrigin:u=!1,distanceThreshold:d=3,element:h}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=S=>{this.handleScroll(S.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const S=zf(this.lastMoveEventInfo,this.history),E=this.startEvent!==null,j=O3(S.offset,{x:0,y:0})>=this.distanceThreshold;if(!E&&!j)return;const{point:_}=S,{timestamp:N}=Ft;this.history.push({..._,timestamp:N});const{onStart:k,onMove:C}=this.handlers;E||(k&&k(this.lastMoveEvent,S),this.startEvent=this.lastMoveEvent),C&&C(this.lastMoveEvent,S)},this.handlePointerMove=(S,E)=>{this.lastMoveEvent=S,this.lastMoveEventInfo=Pf(E,this.transformPagePoint),lt.update(this.updatePoint,!0)},this.handlePointerUp=(S,E)=>{this.end();const{onEnd:j,onSessionEnd:_,resumeAnimation:N}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&N&&N(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const k=zf(S.type==="pointercancel"?this.lastMoveEventInfo:Pf(E,this.transformPagePoint),this.history);this.startEvent&&j&&j(S,k),_&&_(S,k)},!yp(e))return;this.dragSnapToOrigin=u,this.handlers=s,this.transformPagePoint=i,this.distanceThreshold=d,this.contextWindow=l||window;const m=rl(e),g=Pf(m,this.transformPagePoint),{point:y}=g,{timestamp:x}=Ft;this.history=[{...y,timestamp:x}];const{onSessionStart:w}=s;w&&w(e,zf(g,this.history)),this.removeListeners=sl(Ao(this.contextWindow,"pointermove",this.handlePointerMove),Ao(this.contextWindow,"pointerup",this.handlePointerUp),Ao(this.contextWindow,"pointercancel",this.handlePointerUp)),h&&this.startScrollTracking(h)}startScrollTracking(e){let s=e.parentElement;for(;s;){const i=getComputedStyle(s);(Vb.has(i.overflowX)||Vb.has(i.overflowY))&&this.scrollPositions.set(s,{x:s.scrollLeft,y:s.scrollTop}),s=s.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){const s=this.scrollPositions.get(e);if(!s)return;const i=e===window,l=i?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},u={x:l.x-s.x,y:l.y-s.y};u.x===0&&u.y===0||(i?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=u.x,this.lastMoveEventInfo.point.y+=u.y):this.history.length>0&&(this.history[0].x-=u.x,this.history[0].y-=u.y),this.scrollPositions.set(e,l),lt.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),pa(this.updatePoint)}}function Pf(t,e){return e?{point:e(t.point)}:t}function Ib(t,e){return{x:t.x-e.x,y:t.y-e.y}}function zf({point:t},e){return{point:t,delta:Ib(t,Sj(e)),offset:Ib(t,M3(e)),velocity:D3(e,.1)}}function M3(t){return t[0]}function Sj(t){return t[t.length-1]}function D3(t,e){if(t.length<2)return{x:0,y:0};let s=t.length-1,i=null;const l=Sj(t);for(;s>=0&&(i=t[s],!(l.timestamp-i.timestamp>Fn(e)));)s--;if(!i)return{x:0,y:0};i===t[0]&&t.length>2&&l.timestamp-i.timestamp>Fn(e)*2&&(i=t[1]);const u=Pn(l.timestamp-i.timestamp);if(u===0)return{x:0,y:0};const d={x:(l.x-i.x)/u,y:(l.y-i.y)/u};return d.x===1/0&&(d.x=0),d.y===1/0&&(d.y=0),d}function P3(t,{min:e,max:s},i){return e!==void 0&&t<e?t=i?mt(e,t,i.min):Math.max(t,e):s!==void 0&&t>s&&(t=i?mt(s,t,i.max):Math.min(t,s)),t}function $b(t,e,s){return{min:e!==void 0?t.min+e:void 0,max:s!==void 0?t.max+s-(t.max-t.min):void 0}}function z3(t,{top:e,left:s,bottom:i,right:l}){return{x:$b(t.x,s,l),y:$b(t.y,e,i)}}function qb(t,e){let s=e.min-t.min,i=e.max-t.max;return e.max-e.min<t.max-t.min&&([s,i]=[i,s]),{min:s,max:i}}function L3(t,e){return{x:qb(t.x,e.x),y:qb(t.y,e.y)}}function U3(t,e){let s=.5;const i=Qt(t),l=Qt(e);return l>i?s=Go(e.min,e.max-i,t.min):i>l&&(s=Go(t.min,t.max-l,e.min)),ls(0,1,s)}function B3(t,e){const s={};return e.min!==void 0&&(s.min=e.min-t.min),e.max!==void 0&&(s.max=e.max-t.min),s}const Am=.35;function V3(t=Am){return t===!1?t=0:t===!0&&(t=Am),{x:Hb(t,"left","right"),y:Hb(t,"top","bottom")}}function Hb(t,e,s){return{min:Gb(t,e),max:Gb(t,s)}}function Gb(t,e){return typeof t=="number"?t:t[e]||0}const I3=new WeakMap;class $3{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Ot(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:s=!1,distanceThreshold:i}={}){const{presenceContext:l}=this.visualElement;if(l&&l.isPresent===!1)return;const u=x=>{s&&this.snapToCursor(rl(x).point),this.stopAnimation()},d=(x,w)=>{const{drag:S,dragPropagation:E,onDragStart:j}=this.getProps();if(S&&!E&&(this.openDragLock&&this.openDragLock(),this.openDragLock=yM(S),!this.openDragLock))return;this.latestPointerEvent=x,this.latestPanInfo=w,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),ts(N=>{let k=this.getAxisMotionValue(N).get()||0;if(rs.test(k)){const{projection:C}=this.visualElement;if(C&&C.layout){const A=C.layout.layoutBox[N];A&&(k=Qt(A)*(parseFloat(k)/100))}}this.originPoint[N]=k}),j&<.update(()=>j(x,w),!1,!0),wm(this.visualElement,"transform");const{animationState:_}=this.visualElement;_&&_.setActive("whileDrag",!0)},h=(x,w)=>{this.latestPointerEvent=x,this.latestPanInfo=w;const{dragPropagation:S,dragDirectionLock:E,onDirectionLock:j,onDrag:_}=this.getProps();if(!S&&!this.openDragLock)return;const{offset:N}=w;if(E&&this.currentDirection===null){this.currentDirection=H3(N),this.currentDirection!==null&&j&&j(this.currentDirection);return}this.updateAxis("x",w.point,N),this.updateAxis("y",w.point,N),this.visualElement.render(),_&<.update(()=>_(x,w),!1,!0)},m=(x,w)=>{this.latestPointerEvent=x,this.latestPanInfo=w,this.stop(x,w),this.latestPointerEvent=null,this.latestPanInfo=null},g=()=>{const{dragSnapToOrigin:x}=this.getProps();(x||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:y}=this.getProps();this.panSession=new wj(e,{onSessionStart:u,onStart:d,onMove:h,onSessionEnd:m,resumeAnimation:g},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:y,distanceThreshold:i,contextWindow:bj(this.visualElement),element:this.visualElement.current})}stop(e,s){const i=e||this.latestPointerEvent,l=s||this.latestPanInfo,u=this.isDragging;if(this.cancel(),!u||!l||!i)return;const{velocity:d}=l;this.startAnimation(d);const{onDragEnd:h}=this.getProps();h&<.postRender(()=>h(i,l))}cancel(){this.isDragging=!1;const{projection:e,animationState:s}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:i}=this.getProps();!i&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),s&&s.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,s,i){const{drag:l}=this.getProps();if(!i||!Gc(e,l,this.currentDirection))return;const u=this.getAxisMotionValue(e);let d=this.originPoint[e]+i[e];this.constraints&&this.constraints[e]&&(d=P3(d,this.constraints[e],this.elastic[e])),u.set(d)}resolveConstraints(){const{dragConstraints:e,dragElastic:s}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,l=this.constraints;e&&Zi(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&i?this.constraints=z3(i.layoutBox,e):this.constraints=!1,this.elastic=V3(s),l!==this.constraints&&!Zi(e)&&i&&this.constraints&&!this.hasMutatedConstraints&&ts(u=>{this.constraints!==!1&&this.getAxisMotionValue(u)&&(this.constraints[u]=B3(i.layoutBox[u],this.constraints[u]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:s}=this.getProps();if(!e||!Zi(e))return!1;const i=e.current,{projection:l}=this.visualElement;if(!l||!l.layout)return!1;const u=FM(i,l.root,this.visualElement.getTransformPagePoint());let d=L3(l.layout.layoutBox,u);if(s){const h=s(qM(d));this.hasMutatedConstraints=!!h,h&&(d=qS(h))}return d}startAnimation(e){const{drag:s,dragMomentum:i,dragElastic:l,dragTransition:u,dragSnapToOrigin:d,onDragTransitionEnd:h}=this.getProps(),m=this.constraints||{},g=ts(y=>{if(!Gc(y,s,this.currentDirection))return;let x=m&&m[y]||{};d&&(x={min:0,max:0});const w=l?200:1e6,S=l?40:1e7,E={type:"inertia",velocity:i?e[y]:0,bounceStiffness:w,bounceDamping:S,timeConstant:750,restDelta:1,restSpeed:10,...u,...x};return this.startAxisValueAnimation(y,E)});return Promise.all(g).then(h)}startAxisValueAnimation(e,s){const i=this.getAxisMotionValue(e);return wm(this.visualElement,e),i.start(hp(e,i,0,s,this.visualElement,!1))}stopAnimation(){ts(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){const s=`_drag${e.toUpperCase()}`,i=this.visualElement.getProps(),l=i[s];return l||this.visualElement.getValue(e,(i.initial?i.initial[e]:void 0)||0)}snapToCursor(e){ts(s=>{const{drag:i}=this.getProps();if(!Gc(s,i,this.currentDirection))return;const{projection:l}=this.visualElement,u=this.getAxisMotionValue(s);if(l&&l.layout){const{min:d,max:h}=l.layout.layoutBox[s],m=u.get()||0;u.set(e[s]-mt(d,h,.5)+m)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:s}=this.getProps(),{projection:i}=this.visualElement;if(!Zi(s)||!i||!this.constraints)return;this.stopAnimation();const l={x:0,y:0};ts(d=>{const h=this.getAxisMotionValue(d);if(h&&this.constraints!==!1){const m=h.get();l[d]=U3({min:m,max:m},this.constraints[d])}});const{transformTemplate:u}=this.visualElement.getProps();this.visualElement.current.style.transform=u?u({},""):"none",i.root&&i.root.updateScroll(),i.updateLayout(),this.constraints=!1,this.resolveConstraints(),ts(d=>{if(!Gc(d,e,null))return;const h=this.getAxisMotionValue(d),{min:m,max:g}=this.constraints[d];h.set(mt(m,g,l[d]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;I3.set(this.visualElement,this);const e=this.visualElement.current,s=Ao(e,"pointerdown",g=>{const{drag:y,dragListener:x=!0}=this.getProps(),w=g.target,S=w!==e&&jM(w);y&&x&&!S&&this.start(g)});let i;const l=()=>{const{dragConstraints:g}=this.getProps();Zi(g)&&g.current&&(this.constraints=this.resolveRefConstraints(),i||(i=q3(e,g.current,()=>this.scalePositionWithinConstraints())))},{projection:u}=this.visualElement,d=u.addEventListener("measure",l);u&&!u.layout&&(u.root&&u.root.updateScroll(),u.updateLayout()),lt.read(l);const h=Xo(window,"resize",()=>this.scalePositionWithinConstraints()),m=u.addEventListener("didUpdate",(({delta:g,hasLayoutChanged:y})=>{this.isDragging&&y&&(ts(x=>{const w=this.getAxisMotionValue(x);w&&(this.originPoint[x]+=g[x].translate,w.set(w.get()+g[x].translate))}),this.visualElement.render())}));return()=>{h(),s(),d(),m&&m(),i&&i()}}getProps(){const e=this.visualElement.getProps(),{drag:s=!1,dragDirectionLock:i=!1,dragPropagation:l=!1,dragConstraints:u=!1,dragElastic:d=Am,dragMomentum:h=!0}=e;return{...e,drag:s,dragDirectionLock:i,dragPropagation:l,dragConstraints:u,dragElastic:d,dragMomentum:h}}}function Fb(t){let e=!0;return()=>{if(e){e=!1;return}t()}}function q3(t,e,s){const i=Z0(t,Fb(s)),l=Z0(e,Fb(s));return()=>{i(),l()}}function Gc(t,e,s){return(e===!0||e===t)&&(s===null||s===t)}function H3(t,e=10){let s=null;return Math.abs(t.y)>e?s="y":Math.abs(t.x)>e&&(s="x"),s}class G3 extends va{constructor(e){super(e),this.removeGroupControls=Ln,this.removeListeners=Ln,this.controls=new $3(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ln}update(){const{dragControls:e}=this.node.getProps(),{dragControls:s}=this.node.prevProps||{};e!==s&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const Lf=t=>(e,s)=>{t&<.update(()=>t(e,s),!1,!0)};class F3 extends va{constructor(){super(...arguments),this.removePointerDownListener=Ln}onPointerDown(e){this.session=new wj(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:bj(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:s,onPan:i,onPanEnd:l}=this.node.getProps();return{onSessionStart:Lf(e),onStart:Lf(s),onMove:Lf(i),onEnd:(u,d)=>{delete this.session,l&<.postRender(()=>l(u,d))}}}mount(){this.removePointerDownListener=Ao(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let Uf=!1;class K3 extends v.Component{componentDidMount(){const{visualElement:e,layoutGroup:s,switchLayoutGroup:i,layoutId:l}=this.props,{projection:u}=e;u&&(s.group&&s.group.add(u),i&&i.register&&l&&i.register(u),Uf&&u.root.didUpdate(),u.addEventListener("animationComplete",()=>{this.safeToRemove()}),u.setOptions({...u.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),nu.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:s,visualElement:i,drag:l,isPresent:u}=this.props,{projection:d}=i;return d&&(d.isPresent=u,e.layoutDependency!==s&&d.setOptions({...d.options,layoutDependency:s}),Uf=!0,l||e.layoutDependency!==s||s===void 0||e.isPresent!==u?d.willUpdate():this.safeToRemove(),e.isPresent!==u&&(u?d.promote():d.relegate()||lt.postRender(()=>{const h=d.getStack();(!h||!h.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),gp.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:s,switchLayoutGroup:i}=this.props,{projection:l}=e;Uf=!0,l&&(l.scheduleCheckAfterUnmount(),s&&s.group&&s.group.remove(l),i&&i.deregister&&i.deregister(l))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function jj(t){const[e,s]=dj(),i=v.useContext(Xm);return o.jsx(K3,{...t,layoutGroup:i,switchLayoutGroup:v.useContext(vj),isPresent:e,safeToRemove:s})}const Y3={pan:{Feature:F3},drag:{Feature:G3,ProjectionNode:uj,MeasureLayout:jj}};function Kb(t,e,s){const{props:i}=t;t.animationState&&i.whileHover&&t.animationState.setActive("whileHover",s==="Start");const l="onHover"+s,u=i[l];u&<.postRender(()=>u(e,rl(e)))}class X3 extends va{mount(){const{current:e}=this.node;e&&(this.unmount=xM(e,(s,i)=>(Kb(this.node,i,"Start"),l=>Kb(this.node,l,"End"))))}unmount(){}}class W3 extends va{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=sl(Xo(this.node.current,"focus",()=>this.onFocus()),Xo(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Yb(t,e,s){const{props:i}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&i.whileTap&&t.animationState.setActive("whileTap",s==="Start");const l="onTap"+(s==="End"?"":s),u=i[l];u&<.postRender(()=>u(e,rl(e)))}class J3 extends va{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:s,propagate:i}=this.node.props;this.unmount=NM(e,(l,u)=>(Yb(this.node,u,"Start"),(d,{success:h})=>Yb(this.node,d,h?"End":"Cancel")),{useGlobalTarget:s,stopPropagation:i?.tap===!1})}unmount(){}}const Rm=new WeakMap,Bf=new WeakMap,Q3=t=>{const e=Rm.get(t.target);e&&e(t)},Z3=t=>{t.forEach(Q3)};function e6({root:t,...e}){const s=t||document;Bf.has(s)||Bf.set(s,{});const i=Bf.get(s),l=JSON.stringify(e);return i[l]||(i[l]=new IntersectionObserver(Z3,{root:t,...e})),i[l]}function t6(t,e,s){const i=e6(e);return Rm.set(t,s),i.observe(t),()=>{Rm.delete(t),i.unobserve(t)}}const n6={some:0,all:1};class s6 extends va{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:s,margin:i,amount:l="some",once:u}=e,d={root:s?s.current:void 0,rootMargin:i,threshold:typeof l=="number"?l:n6[l]},h=m=>{const{isIntersecting:g}=m;if(this.isInView===g||(this.isInView=g,u&&!g&&this.hasEnteredView))return;g&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",g);const{onViewportEnter:y,onViewportLeave:x}=this.node.getProps(),w=g?y:x;w&&w(m)};return t6(this.node.current,d,h)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:s}=this.node;["amount","margin","root"].some(a6(e,s))&&this.startObserver()}unmount(){}}function a6({viewport:t={}},{viewport:e={}}={}){return s=>t[s]!==e[s]}const i6={inView:{Feature:s6},tap:{Feature:J3},focus:{Feature:W3},hover:{Feature:X3}},r6={layout:{ProjectionNode:uj,MeasureLayout:jj}},o6={...A3,...i6,...Y3,...r6},Ro=N3(o6,T3);function l6({supabase:t,initStatus:e,onSuccess:s,onResetConfigs:i}){const[l,u]=v.useState(""),[d,h]=v.useState(""),[m,g]=v.useState(""),[y,x]=v.useState(""),[w,S]=v.useState(!1),[E,j]=v.useState(null),[_,N]=v.useState(!1),[k,C]=v.useState(e==="empty");v.useEffect(()=>{C(e==="empty")},[e]);async function A(z){z.preventDefault(),S(!0),j(null);try{const{error:V}=await t.auth.signInWithPassword({email:l,password:d});if(V)throw V;s()}catch(V){j(V.message||"Authentication failed.")}finally{S(!1)}}async function D(z){z.preventDefault(),S(!0),j(null);try{const V=await Te.setup({email:l,password:d,first_name:m,last_name:y});if(V.error)throw new Error(typeof V.error=="string"?V.error:V.error.message);const{error:R}=await t.auth.signInWithPassword({email:l,password:d});if(R)throw R;s()}catch(V){j(V.message||"Failed to initialize foundation.")}finally{S(!1)}}return o.jsxs("div",{className:"min-h-screen bg-background flex items-center justify-center p-6 relative overflow-hidden",children:[o.jsxs("div",{className:"absolute top-0 left-0 w-full h-full overflow-hidden pointer-events-none opacity-20",children:[o.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[40%] h-[40%] bg-primary/20 blur-[120px] rounded-full animate-pulse"}),o.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[40%] h-[40%] bg-primary/10 blur-[120px] rounded-full animate-pulse delay-700"})]}),o.jsxs("div",{className:"absolute top-8 right-8 flex items-center gap-4 z-50",children:[o.jsx(e1,{}),o.jsxs("div",{className:"hidden sm:flex items-center gap-2 px-3 py-1.5 bg-muted/40 rounded-full border border-border/40 cursor-pointer hover:bg-muted/60 transition-colors group",children:[o.jsx(ou,{className:"w-3.5 h-3.5"}),o.jsx("span",{className:"text-[10px] font-extrabold tracking-widest text-muted-foreground",children:"EN"})]})]}),o.jsxs(Ro.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8,ease:"easeOut"},className:"w-full max-w-[450px] relative z-10",children:[o.jsxs("div",{className:"bg-card/40 backdrop-blur-2xl border border-border/40 p-10 rounded-[2.5rem] shadow-2xl shadow-black/10 space-y-8 overflow-hidden relative",children:[o.jsx("div",{className:"absolute top-0 left-0 w-full h-1 bg-gradient-to-r from-transparent via-primary/40 to-transparent"}),o.jsxs("div",{className:"text-center space-y-4",children:[o.jsx("div",{className:"mx-auto w-16 h-16 bg-primary rounded-2xl flex items-center justify-center shadow-xl shadow-primary/20 hover:scale-105 transition-transform duration-500",children:o.jsx(ou,{className:"w-10 h-10"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-4xl font-black tracking-tighter uppercase italic text-foreground leading-none",children:k?"Initialization":"Access Gate"}),o.jsx("p",{className:"text-[10px] text-muted-foreground font-black tracking-[0.3em] uppercase mt-2 opacity-60",children:k?"Primary Administrator Enrollment":"Foundational Identity Required"})]})]}),o.jsxs("form",{onSubmit:k?D:A,className:"space-y-6",children:[o.jsx(_p,{mode:"wait",children:k&&o.jsxs(Ro.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{className:"text-[10px] font-black uppercase tracking-widest text-muted-foreground ml-1",children:"First Name"}),o.jsx(je,{placeholder:"Agent",value:m,onChange:z=>g(z.target.value),required:k,className:"h-12 bg-background/50 border-border/40 rounded-xl"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{className:"text-[10px] font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Last Name"}),o.jsx(je,{placeholder:"Zero",value:y,onChange:z=>x(z.target.value),required:k,className:"h-12 bg-background/50 border-border/40 rounded-xl"})]})]})}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{className:"text-[10px] font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Email Coordinates"}),o.jsxs("div",{className:"relative group",children:[o.jsx(Vo,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4.5 h-4.5 text-muted-foreground/40 group-focus-within:text-primary transition-colors"}),o.jsx(je,{type:"email",placeholder:"admin@realtimex.ai",value:l,onChange:z=>u(z.target.value),required:!0,className:"pl-12 h-14 bg-background/50 border-border/40 rounded-2xl focus:ring-primary/20 font-medium"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{className:"text-[10px] font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Security Key"}),o.jsxs("div",{className:"relative group",children:[o.jsx(Zo,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4.5 h-4.5 text-muted-foreground/40 group-focus-within:text-primary transition-colors"}),o.jsx(je,{type:_?"text":"password",placeholder:"••••••••",value:d,onChange:z=>h(z.target.value),required:!0,className:"pl-12 pr-12 h-14 bg-background/50 border-border/40 rounded-2xl focus:ring-primary/20 font-medium"}),o.jsx("button",{type:"button",onClick:()=>N(!_),className:"absolute right-4 top-1/2 -translate-y-1/2 text-muted-foreground/40 hover:text-primary transition-colors focus:outline-none",children:_?o.jsx(sC,{className:"w-5 h-5"}):o.jsx(iC,{className:"w-5 h-5"})})]})]}),E&&o.jsx(Ro.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},children:o.jsxs(jn,{variant:"destructive",className:"bg-destructive/5 text-destructive border-destructive/20 py-3 rounded-2xl",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Sn,{className:"w-4 h-4 shrink-0"}),o.jsx(_n,{className:"text-xs font-bold leading-relaxed",children:E})]}),(E.includes("fetch")||E.includes("connection"))&&i&&o.jsx(ae,{variant:"link",size:"sm",onClick:i,className:"text-[10px] font-black uppercase tracking-tighter text-destructive h-auto p-0 mt-2 ml-6 hover:no-underline hover:opacity-70",children:"Reset Configuration Foundation"})]})}),o.jsx(ae,{size:"lg",className:"w-full h-14 rounded-2xl text-base font-black shadow-xl shadow-primary/20 hover:scale-[1.02] active:scale-[0.98] transition-all duration-300",disabled:w,children:w?o.jsx(rt,{className:"w-5 h-5 animate-spin"}):o.jsxs(o.Fragment,{children:[k?o.jsx(ya,{className:"w-5 h-5 mr-3"}):o.jsx(Vw,{className:"w-5 h-5 mr-3"}),k?"Engage Administrator":"Log In to Dashboard"]})})]}),o.jsx("div",{className:"pt-6 border-t border-border/10",children:o.jsxs("button",{type:"button",onClick:()=>{j(null),C(!k)},className:"w-full text-[10px] font-black uppercase tracking-[0.2em] text-muted-foreground hover:text-primary transition-colors flex items-center justify-center gap-2 group",children:[k?"Already have an account? Access Gate":"First time? Enroll Primary Admin",o.jsx(Ck,{className:"w-3 h-3 group-hover:translate-x-1 transition-transform"})]})})]}),o.jsx("div",{className:"mt-10 text-center",children:o.jsx("p",{className:"text-[10px] font-black text-muted-foreground/30 uppercase tracking-[0.5em]",children:"Powered by Foundations Protocol 2026"})})]})]})}const c6={"app.name":"Folio","common.loading":"Loading...","common.save":"Save Changes","common.cancel":"Cancel","common.delete":"Delete","common.success":"Success","common.error":"Error","common.warning":"Warning","common.syncNow":"Sync Now","common.syncing":"Syncing...","common.stopSync":"Stop Sync","common.saveChanges":"Save Changes","common.previous":"Previous","common.next":"Next","nav.dashboard":"Dashboard","nav.configuration":"Configuration","nav.accountSettings":"Account Settings","nav.signOut":"Sign Out","config.title":"Foundation Configuration","config.llmSettings":"AI Intelligence Settings","config.accounts.title":"Email Accounts","config.accounts.desc":"Connect and manage your email accounts","config.accounts.addNew":"Add New Account","config.accounts.yourAccounts":"Your Connected Accounts","config.accounts.noAccounts":"No email accounts connected yet","config.accounts.disconnect":"Disconnect","config.gmail.connect":"Connect Gmail","config.gmail.connectDesc":"Connect your Google account","config.outlook.connect":"Connect Outlook","config.outlook.connectDesc":"Connect your Microsoft account","config.model.title":"AI Model Configuration","config.model.desc":"Configure your AI model and processing settings","config.llm.title":"LLM","config.model.provider":"LLM Provider","config.model.name":"Model Name","config.model.selectModel":"Select a model","config.model.syncInterval":"Sync Interval (minutes)","config.model.intelligentRename":"Intelligent Rename","config.model.checkConnection":"Check Connection","config.model.saveConfig":"Save Configuration","config.providers.gmail":"Gmail","config.providers.outlook":"Outlook","config.providers.imap":"IMAP / SMTP","config.embed.title":"Embedding (RAG)","config.embed.desc":"Configure embeddings for knowledge base search.","config.byok.title":"Provider Credentials (BYOK)","config.byok.desc":"Configure your own API keys and OAuth credentials.","config.byok.googleTitle":"Google Cloud","config.byok.microsoftTitle":"Microsoft Azure","config.byok.clientId":"Client ID","config.byok.clientSecret":"Client Secret","config.imap.title":"Connect via IMAP","config.imap.connect":"Connect IMAP Account","config.imap.desc":"Connect any email provider using IMAP/SMTP.","config.voice.title":"Voice & Speech","config.voice.desc":"Configure text-to-speech for AI interaction.","config.voice.autoTitle":"Auto-Speak Responses","config.voice.provider":"TTS Provider","config.voice.voice":"Voice","config.voice.speed":"Speed","config.voice.quality":"Quality","config.toast.settingsSaved":"Settings saved successfully","config.toast.connectionFailed":"Failed to connect to provider","config.toast.accountDisconnected":"Account disconnected","config.gmail.authSteps":"Follow the prompts in the popup to authorize access.","config.gmail.credentialsDesc":"Enter your Google OAuth credentials.","config.outlook.credentialsDesc":"Enter your Microsoft Azure credentials.","config.outlook.instructions":"Use the device code below to authenticate.","setup.back":"Back","setup.engage":"Connect"},u6=c6,_j=v.createContext(void 0);function d6({children:t}){const[e]=v.useState("en"),[s]=v.useState(!1),i=v.useCallback(d=>{},[]),l=v.useCallback(d=>u6[d]||d,[]),u=v.useMemo(()=>({language:e,setLanguage:i,t:l,isLoading:s}),[e,l,s]);return o.jsx(_j.Provider,{value:u,children:t})}function br(){const t=v.useContext(_j);if(t===void 0)throw new Error("useLanguage must be used within a LanguageProvider");return t}function Ia(t,e){return t?typeof t=="string"?t:t.message||e:e}const Nj={user:null,isAuthenticated:!1,profile:null,accounts:[],rules:[],settings:null,stats:null,isLoading:!0,isInitialized:!1,error:null};function h6(t,e){switch(e.type){case"SET_USER":{const s=!!e.payload;return{...t,user:e.payload,isAuthenticated:s,isLoading:!1}}case"SET_LOADING":return{...t,isLoading:e.payload};case"SET_INITIALIZED":return{...t,isInitialized:e.payload};case"SET_ERROR":return{...t,error:e.payload,isLoading:!1};case"SET_PROFILE":return{...t,profile:e.payload};case"UPDATE_PROFILE":return{...t,profile:e.payload};case"SET_ACCOUNTS":return{...t,accounts:e.payload};case"ADD_ACCOUNT":return{...t,accounts:[e.payload,...t.accounts]};case"REMOVE_ACCOUNT":return{...t,accounts:t.accounts.filter(s=>s.id!==e.payload)};case"SET_RULES":return{...t,rules:e.payload};case"ADD_RULE":return{...t,rules:[e.payload,...t.rules]};case"UPDATE_RULE":return{...t,rules:t.rules.map(s=>s.id===e.payload.id?e.payload:s)};case"REMOVE_RULE":return{...t,rules:t.rules.filter(s=>s.id!==e.payload)};case"SET_SETTINGS":return{...t,settings:e.payload};case"SET_STATS":return{...t,stats:e.payload};case"CLEAR_DATA":return{...Nj,isLoading:!1,isInitialized:!0};default:return t}}const Tj=v.createContext(null);function f6({children:t}){const[e,s]=v.useReducer(h6,Nj),i=v.useMemo(()=>un(),[]);v.useEffect(()=>{if(!i){s({type:"SET_INITIALIZED",payload:!0});return}async function d(){if(!i)return;const{data:{session:h}}=await i.auth.getSession();s({type:"SET_USER",payload:h?.user||null}),s({type:"SET_INITIALIZED",payload:!0});const{data:{subscription:m}}=i.auth.onAuthStateChange((g,y)=>{s({type:"SET_USER",payload:y?.user||null}),y||s({type:"CLEAR_DATA"})});return()=>m.unsubscribe()}d()},[i]);const l=v.useMemo(()=>({fetchAccounts:async()=>{if(!i)return;const{data:{session:d}}=await i.auth.getSession(),h=await Te.getAccounts(d?.access_token);h.data&&s({type:"SET_ACCOUNTS",payload:h.data.accounts})},fetchRules:async()=>{if(!i)return;const{data:{session:d}}=await i.auth.getSession(),h=await Te.getRules(d?.access_token);h.data&&s({type:"SET_RULES",payload:h.data.rules})},fetchSettings:async()=>{if(!i)return;const{data:{session:d}}=await i.auth.getSession(),h=await Te.getSettings(d?.access_token);h.data&&h.data.settings&&s({type:"SET_SETTINGS",payload:h.data.settings})},fetchProfile:async()=>{if(!i)return;const{data:{session:d}}=await i.auth.getSession(),h=await Te.getProfile(d?.access_token);h.data&&s({type:"SET_PROFILE",payload:h.data})},fetchStats:async()=>{if(!i)return;const{data:{session:d}}=await i.auth.getSession(),h=await Te.getStats(d?.access_token);h.data&&s({type:"SET_STATS",payload:h.data.stats})},disconnectAccount:async d=>{if(!i)return!1;const{data:{session:h}}=await i.auth.getSession(),m=await Te.disconnectAccount(d,h?.access_token);return m.data?.success?(s({type:"REMOVE_ACCOUNT",payload:d}),!0):(s({type:"SET_ERROR",payload:Ia(m.error,"Failed to disconnect")}),!1)},updateSettings:async d=>{if(!i)return!1;const{data:{session:h}}=await i.auth.getSession(),m=await Te.updateSettings(d,h?.access_token);return m.data&&m.data.settings?(s({type:"SET_SETTINGS",payload:m.data.settings}),!0):(s({type:"SET_ERROR",payload:Ia(m.error,"Failed to update settings")}),!1)},updateProfile:async d=>{if(!i)return!1;const{data:{session:h}}=await i.auth.getSession(),m=await Te.updateProfile(d,h?.access_token);return m.data?(s({type:"UPDATE_PROFILE",payload:m.data}),!0):(s({type:"SET_ERROR",payload:Ia(m.error,"Failed to update profile")}),!1)},createRule:async d=>{if(!i)return!1;const{data:{session:h}}=await i.auth.getSession(),m=await Te.createRule(d,h?.access_token);return m.data?(s({type:"ADD_RULE",payload:m.data.rule}),!0):(s({type:"SET_ERROR",payload:Ia(m.error,"Failed to create rule")}),!1)},updateRule:async(d,h)=>{if(!i)return!1;const{data:{session:m}}=await i.auth.getSession(),g=await Te.updateRule(d,h,m?.access_token);return g.data?(s({type:"UPDATE_RULE",payload:g.data.rule}),!0):(s({type:"SET_ERROR",payload:Ia(g.error,"Failed to update rule")}),!1)},deleteRule:async d=>{if(!i)return!1;const{data:{session:h}}=await i.auth.getSession(),m=await Te.deleteRule(d,h?.access_token);return m.data?.success?(s({type:"REMOVE_RULE",payload:d}),!0):(s({type:"SET_ERROR",payload:Ia(m.error,"Failed to delete rule")}),!1)},toggleRule:async d=>{if(!i)return!1;const{data:{session:h}}=await i.auth.getSession(),m=await Te.toggleRule(d,h?.access_token);return m.data?(s({type:"UPDATE_RULE",payload:m.data.rule}),!0):(s({type:"SET_ERROR",payload:Ia(m.error,"Failed to toggle rule")}),!1)}}),[e.accounts,e.rules]),u=v.useMemo(()=>({state:e,dispatch:s,actions:l,supabase:i}),[e,l,i]);return o.jsx(Tj.Provider,{value:u,children:t})}function ol(){const t=v.useContext(Tj);if(!t)throw new Error("useApp must be used within AppProvider");return t}function m6(t){return null}function cn({className:t,size:e="md",text:s}){const i={sm:"w-4 h-4",md:"w-6 h-6",lg:"w-10 h-10"};return o.jsxs("div",{className:ge("flex flex-col items-center justify-center gap-3",t),children:[o.jsx(rt,{className:ge("animate-spin text-primary",i[e])}),s&&o.jsx("p",{className:"text-sm text-muted-foreground animate-pulse",children:s})]})}function p6({open:t,onOpenChange:e}){const{t:s}=br(),{actions:i}=ol(),[l,u]=v.useState(!1),[d,h]=v.useState(""),[m,g]=v.useState(""),[y,x]=v.useState(""),[w,S]=v.useState(993),[E,j]=v.useState(""),[_,N]=v.useState(465),[k,C]=v.useState(!0),[A,D]=v.useState(!0),z=R=>{const P=R.target.value;if(h(P),P.includes("@")){const Z=P.split("@")[1].toLowerCase();Z.includes("gmail.com")?(x("imap.gmail.com"),j("smtp.gmail.com"),S(993),C(!0),N(465),D(!0)):Z.includes("outlook.com")||Z.includes("hotmail.com")?(x("outlook.office365.com"),j("smtp.office365.com"),S(993),C(!0),N(587),D(!1)):Z.includes("yahoo.com")?(x("imap.mail.yahoo.com"),j("smtp.mail.yahoo.com"),S(993),C(!0),N(465),D(!0)):Z.includes("icloud.com")?(x("imap.mail.me.com"),j("smtp.mail.me.com"),S(993),C(!0),N(587),D(!1)):Z.includes("fastmail.com")&&(x("imap.fastmail.com"),j("smtp.fastmail.com"),S(993),C(!0),N(465),D(!0))}},V=async()=>{if(!d||!m||!y||!E){ce.error(s("config.imap.missingFields"));return}u(!0);try{(await Te.connectImap({email:d,password:m,imapHost:y,imapPort:Number(w),smtpHost:E,smtpPort:Number(_),imapSecure:k,smtpSecure:A})).data?.success?(ce.success(s("config.imap.connected")),e(!1),i.fetchAccounts(),h(""),g(""),x(""),j(""),S(993),N(465),C(!0),D(!0)):ce.error(s("config.imap.connectFailed"))}catch(R){console.error("IMAP Connect Error:",R),ce.error(s("config.imap.connectFailed"))}finally{u(!1)}};return o.jsx(Za,{open:t,onOpenChange:e,children:o.jsxs(ei,{className:"sm:max-w-2xl",children:[o.jsxs(hr,{children:[o.jsxs(fr,{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-8 h-8 rounded-full bg-slate-100 dark:bg-slate-800 flex items-center justify-center text-slate-600 dark:text-slate-400 font-bold text-sm",children:o.jsx(Vo,{className:"w-4 h-4"})}),s("config.imap.connect")]}),o.jsx(tl,{children:s("config.imap.desc")})]}),o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsxs("div",{className:"p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg flex gap-3",children:[o.jsx(Sn,{className:"w-5 h-5 text-blue-600 dark:text-blue-400 shrink-0 mt-0.5"}),o.jsxs("div",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-1",children:[o.jsx("p",{className:"font-medium",children:s("config.imap.appPasswordTitle")}),o.jsx("p",{children:s("config.imap.appPasswordDesc")})]})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:s("config.imap.emailLabel")}),o.jsx(je,{placeholder:"you@example.com",value:d,onChange:z,type:"email"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:s("config.imap.passwordLabel")}),o.jsx(je,{placeholder:"xxxx-xxxx-xxxx-xxxx",value:m,onChange:R=>g(R.target.value),type:"password"})]}),o.jsxs("div",{className:"pt-2",children:[o.jsxs("div",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[o.jsx(KC,{className:"w-4 h-4"}),s("config.imap.serverSettings")]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4 p-4 border rounded-lg bg-secondary/10",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"IMAP Host"}),o.jsx(je,{className:"h-8 text-xs font-mono",placeholder:"imap.example.com",value:y,onChange:R=>x(R.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Port"}),o.jsx(je,{className:"h-8 text-xs font-mono",placeholder:"993",type:"number",value:w,onChange:R=>{const P=parseInt(R.target.value)||993;S(P),C(P===993)}}),o.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:k,onChange:R=>C(R.target.checked),className:"accent-primary"}),o.jsx("span",{className:"text-xs text-muted-foreground",children:"Implicit TLS"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"SMTP Host"}),o.jsx(je,{className:"h-8 text-xs font-mono",placeholder:"smtp.example.com",value:E,onChange:R=>j(R.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Port"}),o.jsx(je,{className:"h-8 text-xs font-mono",placeholder:"465",type:"number",value:_,onChange:R=>{const P=parseInt(R.target.value)||465;N(P),D(P===465)}}),o.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:A,onChange:R=>D(R.target.checked),className:"accent-primary"}),o.jsx("span",{className:"text-xs text-muted-foreground",children:"Implicit TLS"})]})]})]})]})]})]}),o.jsxs(tr,{children:[o.jsx(ae,{variant:"outline",onClick:()=>e(!1),children:s("common.cancel")}),o.jsxs(ae,{onClick:V,disabled:l||!d||!m||!y||!E,children:[l?o.jsx(cn,{size:"sm",className:"mr-2"}):o.jsx(as,{className:"w-4 h-4 mr-2"}),s("config.imap.connectBtn")]})]})]})})}function g6({localSettings:t,setLocalSettings:e,handleSaveSettings:s,savingSettings:i}){const{state:l,actions:u,supabase:d}=ol(),{t:h}=br(),[m,g]=v.useState(!1),[y,x]=v.useState("credentials"),[w,S]=v.useState(""),[E,j]=v.useState(""),[_,N]=v.useState(""),[k,C]=v.useState(""),[A,D]=v.useState(!1),[z,V]=v.useState(!1),[R,P]=v.useState(!1),[Z,te]=v.useState("credentials"),[me,Ee]=v.useState(""),[ye,_e]=v.useState(""),[$,Y]=v.useState(!1),[J,pe]=v.useState(null),[se,M]=v.useState(!1),[U,W]=v.useState(!1),[ne,oe]=v.useState(!1),ue=v.useRef(null),q=()=>{x("credentials"),S(""),j(""),N(""),C(""),g(!0)},fe=de=>{S(de);try{const Me=JSON.parse(de),at=Me.installed||Me.web||Me;at.client_id&&j(at.client_id),at.client_secret&&N(at.client_secret)}catch{}},re=async()=>{if(!E||!_){ce.error(h("config.toast.missingGmailCreds"));return}D(!0);try{if(await u.updateSettings({google_client_id:E,google_client_secret:_})){const Me=d?(await d.auth.getSession()).data.session?.access_token:void 0,at=await Te.getGmailAuthUrl(E,_,Me);at.data?.authUrl?(window.open(at.data.authUrl,"_blank"),x("code"),ce.success(h("config.toast.authorizeAndPaste"))):ce.error(h("config.toast.oauthUrlFailed"))}else ce.error(h("config.toast.saveCredsFailed"))}catch{ce.error(h("config.toast.saveCredsFailed"))}finally{D(!1)}},ze=async()=>{if(!k.trim()){ce.error(h("config.toast.missingAuthCode"));return}V(!0);try{const de=d?(await d.auth.getSession()).data.session?.access_token:void 0;(await Te.connectGmail(k.trim(),E,_,de)).data?.success?(ce.success(h("config.toast.gmailConnected")),g(!1),u.fetchAccounts()):ce.error(h("config.toast.gmailConnectFailed"))}catch{ce.error(h("config.toast.gmailConnectFailed"))}finally{V(!1)}},Be=()=>{te("credentials"),Ee(""),_e(""),P(!0)},kt=async()=>{if(!me){ce.error(h("config.toast.missingOutlookClientId"));return}Y(!0);try{if(await u.updateSettings({microsoft_client_id:me,microsoft_tenant_id:ye||"common"})){const Me=d?(await d.auth.getSession()).data.session?.access_token:void 0,at=await Te.startMicrosoftDeviceFlow(me,ye||"common",Me);at.data?.deviceCode?(pe(at.data.deviceCode),te("device-code"),M(!0),et(at.data.deviceCode.deviceCode,me,ye||"common")):ce.error(h("config.toast.deviceFlowFailed"))}else ce.error(h("config.toast.saveCredsFailed"))}catch{ce.error(h("config.toast.saveCredsFailed"))}finally{Y(!1)}},et=async(de,Me,at)=>{const Ut=setInterval(async()=>{try{const Xn=d?(await d.auth.getSession()).data.session?.access_token:void 0;(await Te.pollMicrosoftDeviceCode(de,Me,at,Xn)).data?.success&&(clearInterval(Ut),pe(null),M(!1),P(!1),ce.success(h("config.toast.outlookConnected")),u.fetchAccounts())}catch{}},5e3);setTimeout(()=>clearInterval(Ut),900*1e3)},le=async de=>{if(!confirm(h("config.toast.disconnectConfirm")))return;await u.disconnectAccount(de)&&ce.success(h("config.toast.accountDisconnected"))},Fe=de=>de==="gmail"?o.jsx("div",{className:"w-10 h-10 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center text-red-600 dark:text-red-400 font-bold",children:"G"}):de==="imap"?o.jsx("div",{className:"w-10 h-10 rounded-full bg-slate-100 dark:bg-slate-800 flex items-center justify-center text-slate-600 dark:text-slate-400",children:o.jsx(Vo,{className:"w-5 h-5"})}):o.jsx("div",{className:"w-10 h-10 rounded-full bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center text-blue-600 dark:text-blue-400 font-bold",children:"O"});return o.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[o.jsx(Za,{open:m,onOpenChange:g,children:o.jsxs(ei,{className:"sm:max-w-lg",children:[o.jsxs(hr,{children:[o.jsxs(fr,{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-8 h-8 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center text-red-600 dark:text-red-400 font-bold text-sm",children:"G"}),h("config.gmail.connect")]}),o.jsx(tl,{children:h(y==="credentials"?"config.gmail.credentialsDesc":"config.gmail.authCodeDesc")})]}),y==="credentials"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:h("config.gmail.pasteJson")}),o.jsx("textarea",{className:"w-full h-24 p-3 text-xs font-mono border rounded-lg bg-secondary/10 resize-none focus:outline-none focus:ring-2 focus:ring-primary",placeholder:'{"installed":{"client_id":"...","client_secret":"..."}}',value:w,onChange:de=>fe(de.target.value)})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:h("config.byok.clientId")}),o.jsx(je,{placeholder:h("config.gmail.clientIdPlaceholder"),value:E,onChange:de=>j(de.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:h("config.byok.clientSecret")}),o.jsx(je,{type:"password",placeholder:h("config.gmail.clientSecretPlaceholder"),value:_,onChange:de=>N(de.target.value)})]})]})]}),o.jsxs(tr,{children:[o.jsx(ae,{variant:"outline",onClick:()=>g(!1),children:h("common.cancel")}),o.jsxs(ae,{onClick:re,disabled:A||!E||!_,children:[A?o.jsx(cn,{size:"sm",className:"mr-2"}):o.jsx(as,{className:"w-4 h-4 mr-2"}),h("common.save")," & Connect"]})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"space-y-4 py-4",children:o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:h("config.gmail.authCode")}),o.jsx(je,{placeholder:h("config.gmail.authCodePlaceholder"),value:k,onChange:de=>C(de.target.value),className:"font-mono"})]})}),o.jsxs(tr,{children:[o.jsx(ae,{variant:"outline",onClick:()=>x("credentials"),children:h("setup.back")}),o.jsxs(ae,{onClick:ze,disabled:z||!k.trim(),children:[z?o.jsx(cn,{size:"sm",className:"mr-2"}):o.jsx(as,{className:"w-4 h-4 mr-2"}),"Connect"]})]})]})]})}),o.jsx(Za,{open:R,onOpenChange:P,children:o.jsxs(ei,{className:"sm:max-w-lg",children:[o.jsx(hr,{children:o.jsxs(fr,{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-8 h-8 rounded-full bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center text-blue-600 dark:text-blue-400 font-bold text-sm",children:"O"}),h("config.outlook.connect")]})}),Z==="credentials"?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"space-y-4 py-4",children:o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:h("config.outlook.clientId")}),o.jsx(je,{placeholder:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",value:me,onChange:de=>Ee(de.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:h("config.outlook.tenantIdOptional")}),o.jsx(je,{placeholder:h("config.outlook.tenantPlaceholder"),value:ye,onChange:de=>_e(de.target.value)})]})]})}),o.jsxs(tr,{children:[o.jsx(ae,{variant:"outline",onClick:()=>P(!1),children:h("common.cancel")}),o.jsxs(ae,{onClick:kt,disabled:$||!me,children:[$?o.jsx(cn,{size:"sm",className:"mr-2"}):o.jsx(as,{className:"w-4 h-4 mr-2"}),"Save & Connect"]})]})]}):o.jsxs(o.Fragment,{children:[J&&o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsx("p",{className:"text-sm mb-4",children:J.message}),o.jsx("div",{className:"bg-secondary/10 p-4 rounded-lg flex items-center justify-center",children:o.jsx("code",{className:"text-2xl font-mono font-bold tracking-wider",children:J.userCode})}),o.jsx(ae,{className:"w-full",onClick:()=>window.open(J.verificationUri,"_blank"),children:"Open Login Page"}),o.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs text-muted-foreground",children:[o.jsx(cn,{size:"sm"})," Waiting for authentication..."]})]}),o.jsx(tr,{children:o.jsx(ae,{variant:"outline",onClick:()=>P(!1),children:h("common.cancel")})})]})]})}),o.jsx(p6,{open:U,onOpenChange:W}),o.jsx("div",{ref:ue,children:o.jsxs(ht,{children:[o.jsxs(zt,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>oe(!ne),children:[o.jsxs(Lt,{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ya,{className:"w-5 h-5 text-orange-500"}),h("config.byok.title")]}),ne?o.jsx(Bo,{className:"w-5 h-5"}):o.jsx(dr,{className:"w-5 h-5"})]}),o.jsx(wn,{children:h("config.byok.desc")})]}),ne&&o.jsxs(xt,{className:"space-y-6 animate-in slide-in-from-top-2",children:[o.jsxs("div",{className:"space-y-4 border-b pb-4",children:[o.jsxs("h4",{className:"font-medium flex items-center gap-2",children:[o.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500"})," Google"]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsx(je,{type:"password",placeholder:"Client ID",value:t.google_client_id||"",onChange:de=>e(Me=>({...Me,google_client_id:de.target.value}))}),o.jsx(je,{type:"password",placeholder:"Client Secret",value:t.google_client_secret||"",onChange:de=>e(Me=>({...Me,google_client_secret:de.target.value}))})]})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("h4",{className:"font-medium flex items-center gap-2",children:[o.jsx("span",{className:"w-2 h-2 rounded-full bg-blue-500"})," Microsoft"]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[o.jsx(je,{type:"password",placeholder:"Client ID",value:t.microsoft_client_id||"",onChange:de=>e(Me=>({...Me,microsoft_client_id:de.target.value}))}),o.jsx(je,{type:"password",placeholder:"Client Secret",value:t.microsoft_client_secret||"",onChange:de=>e(Me=>({...Me,microsoft_client_secret:de.target.value}))}),o.jsx(je,{placeholder:"Tenant ID",value:t.microsoft_tenant_id||"",onChange:de=>e(Me=>({...Me,microsoft_tenant_id:de.target.value}))})]})]}),o.jsx("div",{className:"flex justify-end mt-4",children:o.jsxs(ae,{onClick:s,disabled:i,variant:"secondary",children:[i?o.jsx(cn,{size:"sm",className:"mr-2"}):o.jsx(as,{className:"w-4 h-4 mr-2"}),"Save API Credentials"]})})]})]})}),o.jsxs(ht,{children:[o.jsxs(zt,{children:[o.jsxs(Lt,{className:"flex items-center gap-2",children:[o.jsx(Eu,{className:"w-5 h-5 text-primary"})," ",h("config.accounts.title")]}),o.jsx(wn,{children:h("config.accounts.desc")})]}),o.jsx(xt,{children:o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[o.jsxs("div",{className:"space-y-4",children:[o.jsx("h3",{className:"text-sm font-semibold",children:h("config.accounts.addNew")}),o.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[o.jsxs(ae,{variant:"outline",className:"h-auto py-4 border-dashed justify-start",onClick:q,children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center mr-3 text-red-600 font-bold",children:"G"}),o.jsx("div",{className:"text-left font-medium",children:"Connect Gmail"})]}),o.jsxs(ae,{variant:"outline",className:"h-auto py-4 border-dashed justify-start",onClick:Be,children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center mr-3 text-blue-600 font-bold",children:"O"}),o.jsx("div",{className:"text-left font-medium",children:"Connect Outlook"})]}),o.jsxs(ae,{variant:"outline",className:"h-auto py-4 border-dashed justify-start",onClick:()=>W(!0),children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-slate-100 dark:bg-slate-800 flex items-center justify-center mr-3 text-slate-600",children:o.jsx(Vo,{})}),o.jsx("div",{className:"text-left font-medium",children:"Connect IMAP"})]})]})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsx("h3",{className:"text-sm font-semibold",children:h("config.accounts.yourAccounts")}),l.accounts.length===0?o.jsx("div",{className:"py-8 text-center text-muted-foreground border-2 border-dashed rounded-lg",children:"No accounts connected"}):o.jsx("div",{className:"space-y-3",children:l.accounts.map(de=>o.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg bg-card",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[Fe(de.provider),o.jsxs("div",{children:[o.jsx("div",{className:"font-medium text-sm",children:de.email_address}),o.jsx("div",{className:"text-[10px] text-muted-foreground uppercase",children:de.provider})]})]}),o.jsx(ae,{variant:"ghost",size:"sm",onClick:()=>le(de.id),className:"text-destructive",children:o.jsx(el,{className:"w-4 h-4"})})]},de.id))})]})]})})]})]})}const Ej=v.createContext(void 0);function y6({children:t}){const[e,s]=v.useState(!1),[i,l]=v.useState(!1),[u,d]=v.useState(null),h=v.useRef(null),m=v.useRef(null),g=v.useRef(null),y=v.useRef(null),x=v.useRef(0),w=v.useCallback(()=>{if(y.current&&(y.current.cancel().catch(()=>{}),y.current=null),g.current){try{g.current.stop(),g.current.disconnect()}catch{}g.current=null}h.current&&(h.current.pause(),h.current.currentTime=0,h.current=null),s(!1),l(!1),d(null),x.current++},[]),S=v.useCallback((N,k)=>new Promise((C,A)=>{N.decodeAudioData(k,D=>{const z=N.createBufferSource();z.buffer=D,z.connect(N.destination),z.onended=()=>C(),z.start(0),g.current=z},D=>A(D))}),[]),E=v.useCallback(async(N,k,C={})=>{w();const A=x.current;l(!0),d(k||null);try{const D=await fetch("/api/tts/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:N,...C})});if(!D.ok)throw new Error("TTS generation failed");const z=await D.blob(),V=URL.createObjectURL(z),R=new Audio(V);h.current=R,R.onplay=()=>s(!0),R.onended=()=>{x.current===A&&(s(!1),l(!1),d(null),URL.revokeObjectURL(V))},R.onerror=()=>{x.current===A&&(s(!1),l(!1),d(null),URL.revokeObjectURL(V))},await R.play()}catch(D){console.error("[TTSContext] Speak failed:",D),x.current===A&&(l(!1),d(null))}},[w]),j=v.useCallback(async(N,k,C={})=>{w();const A=x.current;l(!0),d(k||null);try{const D=await fetch("/api/tts/stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:N,...C})});if(!D.ok)throw new Error("TTS streaming failed");const z=D.body?.getReader();if(!z)throw new Error("No response body");y.current=z;const V=new TextDecoder;let R="";const P=[];m.current||(m.current=new(window.AudioContext||window.webkitAudioContext));const Z=m.current;for(;x.current===A;){const{done:te,value:me}=await z.read();if(te)break;R+=V.decode(me,{stream:!0});const Ee=R.split(`
|
|
105
|
+
`);R=Ee.pop()||"";for(const ye of Ee){const _e=ye.trim();if(!_e||!_e.startsWith("data:"))continue;const $=_e.slice(5).trim();if($)try{const Y=JSON.parse($);if(Y.audio){const J=atob(Y.audio),pe=new Uint8Array(J.length);for(let se=0;se<J.length;se++)pe[se]=J.charCodeAt(se);P.push(pe.buffer),P.length===1&&(s(!0),await S(Z,pe.buffer))}}catch{}}}if(x.current===A)for(let te=1;te<P.length&&x.current===A;te++)await S(Z,P[te]);x.current===A&&(s(!1),l(!1),d(null))}catch(D){console.error("[TTSContext] Stream failed:",D),x.current===A&&(s(!1),l(!1),d(null))}},[w,S]),_=v.useMemo(()=>({isPlaying:e,isSpeaking:i,speakingId:u,currentAudio:h.current,speak:E,speakStream:j,stop:w}),[e,i,u,E,j,w]);return o.jsx(Ej.Provider,{value:_,children:t})}function v6(){const t=v.useContext(Ej);if(t===void 0)throw new Error("useTTSContext must be used within a TTSProvider");return t}function x6(){const{speak:t,speakStream:e,stop:s,isPlaying:i,isSpeaking:l,speakingId:u}=v6(),d=v.useCallback(async(m,g,y={})=>t(m,g,y),[t]),h=v.useCallback(async(m,g,y={})=>e(m,g,y),[e]);return{speak:d,speakStream:h,stop:s,isPlaying:i,isSpeaking:l,speakingId:u}}function b6(){const{t}=br(),{state:e,actions:s}=ol(),{speak:i}=x6(),[l,u]=v.useState(e.settings?.tts_provider||"piper_local"),[d,h]=v.useState(e.settings?.tts_voice||null),[m,g]=v.useState(e.settings?.tts_speed||1),[y,x]=v.useState(e.settings?.tts_quality||10),[w,S]=v.useState(e.settings?.tts_auto_play??!0),[E,j]=v.useState([]),[_,N]=v.useState(!1),[k,C]=v.useState(!1),[A,D]=v.useState(!1);v.useEffect(()=>{e.settings&&(u(e.settings.tts_provider||"piper_local"),h(e.settings.tts_voice||null),g(e.settings.tts_speed||1),x(e.settings.tts_quality||10),S(e.settings.tts_auto_play??!0))},[e.settings]),v.useEffect(()=>{(async()=>{N(!0);try{const me=await fetch("/api/tts/providers");if(me.ok){const Ee=await me.json();if(Ee.success&&Ee.providers&&(j(Ee.providers),!l&&Ee.providers.length>0)){const ye=Ee.providers[0];u(ye.id),ye.config?.voices?.length>0&&h(ye.config.voices[0])}}else ce.error(t("config.voice.toast.providersFailed"))}catch(me){console.error("Error fetching TTS providers:",me),ce.error(t("config.voice.toast.serviceFailed"))}finally{N(!1)}})()},[t,l]);const V=E.find(te=>te.id===l)?.config?.voices||[],R=te=>{u(te);const me=E.find(Ee=>Ee.id===te);me&&me.config?.voices&&me.config.voices.length>0?h(me.config.voices[0]):h(null)},P=async()=>{C(!0);try{const te=t("config.voice.testText");await i(te,void 0,{provider:l,voice:d||void 0,speed:m,quality:y})}catch(te){console.error("TTS test failed:",te),ce.error(t("config.voice.toast.testFailed"))}finally{C(!1)}},Z=async()=>{D(!0),await s.updateSettings({tts_provider:l,tts_voice:d,tts_speed:m,tts_quality:y,tts_auto_play:w})?ce.success(t("config.voice.toast.saved")):ce.error(t("config.voice.toast.saveFailed")),D(!1)};return o.jsxs(ht,{children:[o.jsxs(zt,{children:[o.jsxs(Lt,{className:"flex items-center gap-2",children:[o.jsx(nm,{className:"w-5 h-5 text-purple-500"}),t("config.voice.title")]}),o.jsx(wn,{children:t("config.voice.desc")})]}),o.jsxs(xt,{className:"space-y-6",children:[o.jsxs("div",{className:"flex items-center justify-between pb-4 border-b text-sm",children:[o.jsxs("div",{className:"space-y-0.5",children:[o.jsx("label",{className:"font-medium",children:t("config.voice.autoTitle")}),o.jsx("p",{className:"text-xs text-muted-foreground",children:t("config.voice.autoHelp")})]}),o.jsxs(ae,{variant:w?"default":"outline",size:"sm",onClick:()=>S(!w),className:"gap-2",children:[w?o.jsx(nm,{className:"w-4 h-4"}):o.jsx(Fw,{className:"w-4 h-4"}),t(w?"common.enabled":"common.disabled")]})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:t("config.voice.provider")}),_?o.jsxs("div",{className:"h-10 border rounded-md flex items-center px-3 bg-muted/20",children:[o.jsx(cn,{size:"sm",className:"mr-2"}),o.jsx("span",{className:"text-xs text-muted-foreground italic",children:t("config.voice.loadingProviders")})]}):o.jsxs("select",{className:"w-full h-10 px-3 border rounded-md bg-background text-sm focus:outline-none focus:ring-2 focus:ring-primary",value:l,onChange:te=>R(te.target.value),disabled:_,children:[E.length===0&&o.jsx("option",{value:"piper_local",children:t("config.voice.piperLocal")}),E.map(te=>o.jsx("option",{value:te.id,children:te.name},te.id))]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:t("config.voice.voice")}),V.length>0?o.jsxs("select",{className:"w-full h-10 px-3 border rounded-md bg-background text-sm focus:outline-none focus:ring-2 focus:ring-primary",value:d||"",onChange:te=>h(te.target.value),disabled:_,children:[!d&&o.jsx("option",{value:"",children:t("config.voice.selectVoice")}),V.map(te=>o.jsx("option",{value:te,children:te},te))]}):o.jsx("div",{className:"h-10 border rounded-md flex items-center px-3 bg-muted/20 text-xs text-muted-foreground",children:t("config.voice.noVoices")})]})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"text-sm font-medium",children:t("config.voice.speed")}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:[m.toFixed(1),"x"]})]}),o.jsx("input",{type:"range",min:"0.5",max:"2.0",step:"0.1",value:m,onChange:te=>g(parseFloat(te.target.value)),className:"w-full h-2 bg-secondary rounded-lg appearance-none cursor-pointer accent-primary"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"text-sm font-medium",children:t("config.voice.quality")}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:[y,"/20"]})]}),o.jsx("input",{type:"range",min:"1",max:"20",step:"1",value:y,onChange:te=>x(parseInt(te.target.value,10)),className:"w-full h-2 bg-secondary rounded-lg appearance-none cursor-pointer accent-primary"})]})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[o.jsxs(ae,{variant:"outline",onClick:P,disabled:k,children:[k?o.jsx(cn,{size:"sm",className:"mr-2"}):o.jsx(rA,{className:"w-4 h-4 mr-2"}),t("config.voice.test")]}),o.jsxs(ae,{onClick:Z,disabled:A,children:[A?o.jsx(cn,{size:"sm",className:"mr-2"}):o.jsx(ma,{className:"w-4 h-4 mr-2"}),t("config.voice.save")]})]})]})]})}function w6(t,e){const s=[],i=(t.llm_provider||e||"").trim(),l=(t.llm_model||"").trim(),u=i&&l?`${i}:${l}`:"",d=t.vision_model_capabilities;if(d&&typeof d=="object"&&!Array.isArray(d))for(const[h,m]of Object.entries(d)){if(!m||typeof m!="object"||Array.isArray(m))continue;const g=m,y=g.state;if(y!=="supported"&&y!=="unsupported")continue;const x=h.indexOf(":"),w=x>=0?h.slice(0,x):"unknown",S=x>=0?h.slice(x+1):h;s.push({key:h,provider:w,model:S,state:y,learnedAt:g.learned_at,expiresAt:g.expires_at,reason:g.reason,isCurrent:h===u})}return u&&!s.some(h=>h.key===u)&&s.unshift({key:u,provider:i,model:l,state:"unknown",isCurrent:!0}),s.sort((h,m)=>h.isCurrent&&!m.isCurrent?-1:!h.isCurrent&&m.isCurrent?1:`${h.provider}:${h.model}`.localeCompare(`${m.provider}:${m.model}`)),s}function S6(t){return t==="supported"?"default":t==="unsupported"?"destructive":"secondary"}function Xb(t){return t.replace(/[^a-zA-Z0-9_-]/g,"-")}function j6({localSettings:t,setLocalSettings:e,handleSaveSettings:s,savingSettings:i,handleTestConnection:l,testingLlm:u,providersWithSaved:d,modelsWithSaved:h,embedProvidersWithSaved:m,embedModelsWithSaved:g,handleProviderChange:y,handleEmbedProviderChange:x,DEFAULT_PROVIDER:w}){const{t:S}=br(),E=w6(t,w),j=(N,k,C)=>{const A=`${N}:${k}`;e(D=>{const z=D?.vision_model_capabilities&&typeof D.vision_model_capabilities=="object"&&!Array.isArray(D.vision_model_capabilities)?{...D.vision_model_capabilities}:{};if(C==="unknown")delete z[A];else{const V=new Date().toISOString(),R=C==="supported"?180:30,P=new Date(Date.now()+R*24*60*60*1e3).toISOString();z[A]={...z[A]||{},state:C,learned_at:V,expires_at:P,reason:"manual_override"}}return{...D,vision_model_capabilities:z}})},_=()=>{e(N=>({...N,vision_model_capabilities:{}}))};return o.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[o.jsxs(ht,{children:[o.jsx(zt,{children:o.jsxs(Lt,{className:"flex items-center gap-2",children:[o.jsx(ma,{className:"w-5 h-5 text-indigo-500"}),"AI Model Configuration"]})}),o.jsxs(xt,{className:"space-y-6",children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[o.jsxs("div",{className:"space-y-4",children:[o.jsx("label",{className:"text-sm font-medium",htmlFor:"llm-provider-select",children:"LLM Provider"}),o.jsxs("select",{id:"llm-provider-select",className:"w-full h-10 border rounded-md px-3 bg-background",value:t.llm_provider||w,onChange:N=>y(N.target.value),children:[o.jsx("option",{value:w,children:"RealTimeX AI"}),d.filter(N=>N.provider!==w).map(N=>o.jsx("option",{value:N.provider,children:N.name||N.provider},N.provider))]}),o.jsx("label",{className:"text-sm font-medium",htmlFor:"llm-model-select",children:"LLM Model"}),o.jsx("select",{id:"llm-model-select",className:"w-full h-10 border rounded-md px-3 bg-background",value:t.llm_model||"",onChange:N=>e(k=>({...k,llm_model:N.target.value})),children:h.map(N=>o.jsx("option",{value:N.id,children:N.name||N.id},N.id))})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsx("label",{className:"text-sm font-medium",htmlFor:"embedding-provider-select",children:"Embedding Provider"}),o.jsxs("select",{id:"embedding-provider-select",className:"w-full h-10 border rounded-md px-3 bg-background",value:t.embedding_provider||w,onChange:N=>x(N.target.value),children:[o.jsx("option",{value:w,children:"RealTimeX Embed"}),m.filter(N=>N.provider!==w).map(N=>o.jsx("option",{value:N.provider,children:N.name||N.provider},N.provider))]}),o.jsx("label",{className:"text-sm font-medium",htmlFor:"embedding-model-select",children:"Embedding Model"}),o.jsx("select",{id:"embedding-model-select",className:"w-full h-10 border rounded-md px-3 bg-background",value:t.embedding_model||"",onChange:N=>e(k=>({...k,embedding_model:N.target.value})),children:g.map(N=>o.jsx("option",{value:N.id,children:N.name||N.id},N.id))})]})]}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(ae,{variant:"outline",onClick:l,disabled:u,children:"Test Connection"}),o.jsxs(ae,{onClick:s,disabled:i,children:[i?o.jsx(cn,{size:"sm",className:"mr-2"}):o.jsx(as,{className:"w-4 h-4 mr-2"}),"Save AI Config"]})]})]})]}),o.jsx(b6,{}),o.jsxs(ht,{children:[o.jsxs(zt,{children:[o.jsxs(Lt,{className:"flex items-center gap-2",children:[o.jsx(Zf,{className:"w-5 h-5 text-primary"}),"Vision Capability Overrides"]}),o.jsxs("p",{className:"text-sm text-muted-foreground",children:["Review and edit learned multimodal support per model. Set to ",o.jsx("span",{className:"font-medium",children:"Unknown"})," to let Folio probe again."]})]}),o.jsxs(xt,{className:"space-y-4",children:[E.length===0?o.jsx("div",{className:"rounded-md border border-dashed p-4 text-sm text-muted-foreground",children:"No model capability entries yet."}):o.jsx("div",{className:"space-y-3",children:E.map(N=>o.jsx("div",{className:"rounded-md border p-3",children:o.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsxs("p",{className:"font-medium break-all",children:[N.provider," / ",N.model]}),N.isCurrent?o.jsx(Pt,{variant:"outline",children:"Current"}):null,o.jsx(Pt,{variant:S6(N.state),children:N.state})]}),o.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:[N.reason?`reason: ${N.reason}`:"reason: not set",N.expiresAt?` • expires: ${new Date(N.expiresAt).toLocaleString()}`:""]})]}),o.jsxs("div",{className:"w-full md:w-[180px]",children:[o.jsx("label",{className:"sr-only",htmlFor:`vision-state-${Xb(N.key)}`,children:"Vision capability state"}),o.jsxs("select",{id:`vision-state-${Xb(N.key)}`,className:"w-full h-10 border rounded-md px-3 bg-background",value:N.state,onChange:k=>j(N.provider,N.model,k.target.value),children:[o.jsx("option",{value:"unknown",children:"Unknown (auto-probe)"}),o.jsx("option",{value:"supported",children:"Supported"}),o.jsx("option",{value:"unsupported",children:"Unsupported"})]})]})]})},N.key))}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(ae,{variant:"outline",onClick:_,children:"Reset Learned Map"}),o.jsxs(ae,{onClick:s,disabled:i,children:[i?o.jsx(cn,{size:"sm",className:"mr-2"}):o.jsx(as,{className:"w-4 h-4 mr-2"}),"Save Capability Overrides"]})]})]})]}),o.jsxs(ht,{children:[o.jsx(zt,{children:o.jsxs(Lt,{className:"flex items-center gap-2",children:[o.jsx(Qo,{className:"w-5 h-5 text-primary"})," System Settings"]})}),o.jsxs(xt,{className:"space-y-6",children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",htmlFor:"sync-interval-input",children:"Sync Interval (minutes)"}),o.jsx(je,{id:"sync-interval-input",type:"number",value:t.sync_interval_minutes||5,onChange:N=>e(k=>({...k,sync_interval_minutes:parseInt(N.target.value)}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",htmlFor:"storage-path-input",children:"Storage Path"}),o.jsx(je,{id:"storage-path-input",placeholder:"/path/to/storage",value:t.storage_path||"",onChange:N=>e(k=>({...k,storage_path:N.target.value}))})]})]}),o.jsx("div",{className:"flex justify-end",children:o.jsxs(ae,{onClick:s,disabled:i,children:[i?o.jsx(cn,{size:"sm",className:"mr-2"}):o.jsx(as,{className:"w-4 h-4 mr-2"}),"Save System Settings"]})})]})]})]})}function _6(){const{t}=br(),{supabase:e}=ol(),[s,i]=v.useState([]),[l,u]=v.useState(!0),[d,h]=v.useState(!1),[m,g]=v.useState("credentials"),[y,x]=v.useState(""),[w,S]=v.useState(""),[E,j]=v.useState(""),[_,N]=v.useState(""),[k,C]=v.useState(!1);v.useEffect(()=>{A()},[]);const A=async()=>{try{const R=e?(await e.auth.getSession()).data.session?.access_token:void 0,P=await Te.getAccounts(R);P.data&&P.data.accounts&&i(P.data.accounts)}catch(R){console.error(R)}finally{u(!1)}},D=R=>{N(R);try{const P=JSON.parse(R),Z=P.web||P.installed;Z?.client_id&&Z?.client_secret&&(x(Z.client_id),S(Z.client_secret))}catch{}},z=async()=>{if(!y||!w){ce.error(t("config.gmail.error.missingCreds")||"Please provide Client ID and Secret");return}try{C(!0);const R=e?(await e.auth.getSession()).data.session?.access_token:void 0,P=await Te.getGoogleDriveAuthUrl(y.trim(),R);P.data?.authUrl?(window.open(P.data.authUrl,"_blank","width=600,height=700"),g("auth_code")):ce.error(t("config.gmail.error.authUrl")||"Failed to generate auth URL")}catch{ce.error(t("config.gmail.error.authUrl")||"Failed to generate auth URL")}finally{C(!1)}},V=async()=>{if(!E){ce.error(t("config.gmail.error.missingCode")||"Please provide Auth Code");return}try{C(!0);const R=e?(await e.auth.getSession()).data.session?.access_token:void 0,P=await Te.connectGoogleDrive(E.trim(),y.trim(),w.trim(),R);P.data?.success?(ce.success("Successfully connected to Google Drive"),h(!1),j(""),A()):ce.error(P.error?.message||"Failed to connect")}catch{ce.error("An error occurred while connecting")}finally{C(!1)}};return o.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[o.jsx(Za,{open:d,onOpenChange:h,children:o.jsxs(ei,{className:"sm:max-w-lg",children:[o.jsxs(hr,{children:[o.jsxs(fr,{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-8 h-8 rounded-full bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center text-blue-600 dark:text-blue-400 font-bold text-sm",children:"G"}),"Connect Google Drive"]}),o.jsx(tl,{children:m==="credentials"?"Provide your Google Cloud project credentials.":"Paste the authorization code."})]}),m==="credentials"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:"Paste credentials JSON"}),o.jsx("textarea",{className:"w-full h-24 p-3 text-xs font-mono border rounded-lg bg-secondary/10 resize-none focus:outline-none focus:ring-2 focus:ring-primary",placeholder:'{"installed":{"client_id":"...","client_secret":"..."}}',value:_,onChange:R=>D(R.target.value)})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:"Client ID"}),o.jsx(je,{placeholder:"Enter Client ID",value:y,onChange:R=>x(R.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:"Client Secret"}),o.jsx(je,{type:"password",placeholder:"Enter Client Secret",value:w,onChange:R=>S(R.target.value)})]})]})]}),o.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[o.jsx(ae,{variant:"ghost",onClick:()=>h(!1),children:"Cancel"}),o.jsxs(ae,{onClick:z,disabled:k||!y||!w,children:[k?"Generating...":"Next"," ",o.jsx(dr,{className:"w-4 h-4 ml-1"})]})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"space-y-4 py-4",children:o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:"Authorization Code"}),o.jsx(je,{placeholder:"Paste the code from Google here",value:E,onChange:R=>j(R.target.value),autoFocus:!0}),o.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"A new window was opened for you to authorize the app. Once you approve, paste the code here."})]})}),o.jsxs("div",{className:"flex justify-between pt-4 border-t",children:[o.jsx(ae,{variant:"ghost",onClick:()=>g("credentials"),children:"Back"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(ae,{variant:"ghost",onClick:()=>h(!1),children:"Cancel"}),o.jsx(ae,{onClick:V,disabled:k||!E,children:k?"Connecting...":"Connect Drive"})]})]})]})]})}),o.jsxs(ht,{children:[o.jsxs(zt,{children:[o.jsxs(Lt,{className:"flex items-center gap-2",children:[o.jsx(f0,{className:"w-5 h-5 text-sky-500"}),"Cloud Storage"]}),o.jsx(wn,{children:"Connect cloud drives like Google Drive or Dropbox to allow Folio to read and write documents directly to your cloud."})]}),o.jsx(xt,{children:o.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[o.jsxs(ht,{className:"flex flex-col border-dashed hover:border-solid hover:border-blue-300 transition-colors",children:[o.jsxs(zt,{className:"pb-3 text-center",children:[o.jsx("div",{className:"w-12 h-12 mx-auto rounded-xl bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center text-blue-600 dark:text-blue-400 mb-2",children:o.jsx(fC,{className:"w-6 h-6"})}),o.jsx(Lt,{className:"text-base",children:"Google Drive"}),o.jsx(wn,{className:"text-xs",children:"Sync files to and from Google Drive"})]}),o.jsx(xt,{className:"flex-1 flex flex-col justify-end pt-0",children:s.some(R=>R.provider==="google_drive"&&R.is_connected)?o.jsxs(ae,{className:"w-full gap-2 text-xs",variant:"secondary",disabled:!0,children:[o.jsx(os,{className:"w-4 h-4 text-green-500"}),"Connected"]}):o.jsx(ae,{className:"w-full gap-2 text-xs",variant:"outline",onClick:()=>{g("credentials"),h(!0)},children:"Connect Google Drive"})})]}),o.jsxs(ht,{className:"flex flex-col border-dashed opacity-50 cursor-not-allowed",children:[o.jsxs(zt,{className:"pb-3 text-center",children:[o.jsx("div",{className:"w-12 h-12 mx-auto rounded-xl bg-blue-100 flex items-center justify-center text-blue-600 mb-2",children:o.jsx(f0,{className:"w-6 h-6"})}),o.jsx(Lt,{className:"text-base",children:"Dropbox"}),o.jsx(wn,{className:"text-xs",children:"Coming soon"})]}),o.jsx(xt,{className:"flex-1 flex flex-col justify-end pt-0",children:o.jsx(ae,{className:"w-full gap-2 text-xs",variant:"outline",disabled:!0,children:"Coming Soon"})})]})]})})]})]})}function N6(t,e){return t?typeof t=="string"?t:typeof t=="object"&&"message"in t?t.message:e:e}const T6=["string","number","date","currency","string[]"];function E6(){const[t,e]=v.useState(null),[s,i]=v.useState(!0),[l,u]=v.useState(!1),[d,h]=v.useState(""),[m,g]=v.useState([]),[y,x]=v.useState(null),[w,S]=v.useState([]),[E,j]=v.useState(!1),[_,N]=v.useState(!1),[k,C]=v.useState(""),[A,D]=v.useState(!1),[z,V]=v.useState(null),[R,P]=v.useState([]),[Z,te]=v.useState(""),[me,Ee]=v.useState("");v.useEffect(()=>{(async()=>{i(!0);try{const fe=un(),{data:re}=await(fe?.auth.getSession()??Promise.resolve({data:{session:null}})),ze=re.session?.access_token??null;e(ze);const Be=await Te.getBaselineConfig(ze);Be.data&&(Be.data.config?(h(Be.data.config.context??""),g(Be.data.config.fields),x(Be.data.config.version)):g(Be.data.defaults))}catch{ce.error("Failed to load baseline config")}finally{i(!1)}})()},[]);const ye=v.useCallback(async()=>{try{const fe=(await Te.getSDKChatProviders())?.data?.providers??[];P(fe),fe.length>0&&!Z&&(te(fe[0].provider),Ee(fe[0].models?.[0]?.id??""))}catch{}},[Z]);v.useEffect(()=>{_&&R.length===0&&ye()},[_,R.length,ye]);const _e=async()=>{const q=await Te.getBaselineConfigHistory(t);q.data&&S(q.data.history),j(!0)},$=q=>g(fe=>fe.map(re=>re.key===q?{...re,enabled:!re.enabled}:re)),Y=(q,fe)=>g(re=>re.map(ze=>ze.key===q?{...ze,description:fe}:ze)),J=()=>g(q=>[...q,{key:"",type:"string",description:"",enabled:!0,is_default:!1}]),pe=(q,fe)=>g(re=>re.map((ze,Be)=>Be===q?{...ze,...fe}:ze)),se=q=>g(fe=>fe.filter((re,ze)=>ze!==q)),M=async()=>{if(m.filter(re=>re.enabled).length===0){ce.error("At least one field must be enabled");return}if(m.filter(re=>!re.is_default&&re.enabled&&(!re.key.trim()||!re.description.trim())).length>0){ce.error("Custom fields require both a key and a description");return}u(!0);try{const re=await Te.saveBaselineConfig({context:d||null,fields:m,activate:!0},t);re.data?.success?(x(re.data.config.version),ce.success(`Baseline config saved as v${re.data.config.version}`),E&&_e()):ce.error("Failed to save config")}finally{u(!1)}},U=async(q,fe)=>{(await Te.activateBaselineConfig(q,t)).data?.success&&(x(fe),ce.success(`v${fe} is now active`),_e())},W=async()=>{if(k.trim()){D(!0),V(null);try{const q=await Te.suggestBaselineConfig({description:k,provider:Z||void 0,model:me||void 0},t);q.data?.suggestion?(V(q.data.suggestion),ce.success("Suggestion ready — review and apply below.")):ce.error(N6(q.error,"Suggestion failed."))}catch{ce.error("LLM suggestion failed.")}finally{D(!1)}}},ne=()=>{z&&(h(z.context),g(q=>{const fe=new Set(q.map(ze=>ze.key)),re=z.fields.filter(ze=>ze.key&&!fe.has(ze.key));return[...q,...re]}),V(null),C(""),N(!1),ce.success("Suggestion applied — review fields then Save & Activate."))};if(s)return o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(cn,{size:"md"})});const oe=m.filter(q=>q.is_default),ue=m.filter(q=>!q.is_default);return o.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[o.jsxs(ht,{className:"border-violet-500/20 bg-violet-500/5",children:[o.jsxs(zt,{className:"cursor-pointer select-none",onClick:()=>{N(q=>!q),V(null)},children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs(Lt,{className:"flex items-center gap-2 text-base",children:[o.jsx(Cs,{className:"w-4 h-4 text-violet-500"}),"Magic Composer"]}),_?o.jsx(lu,{className:"w-4 h-4 text-muted-foreground"}):o.jsx(Bo,{className:"w-4 h-4 text-muted-foreground"})]}),!_&&o.jsx(wn,{children:"Describe your workflow — AI will suggest a context string and custom fields."})]}),_&&o.jsxs(xt,{className:"space-y-4 pt-0",children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Describe your workflow — AI will suggest a context string and custom fields tailored to your documents."}),R.length>0&&o.jsxs("div",{className:"flex gap-2 items-center",children:[o.jsx(Bm,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"}),o.jsx("select",{value:`${Z}::${me}`,onChange:q=>{const[fe,re]=q.target.value.split("::");te(fe),Ee(re)},className:"text-xs rounded-lg border border-border/40 bg-background px-2 py-1 flex-1 max-w-xs",children:R.flatMap(q=>(q.models??[]).map(fe=>o.jsxs("option",{value:`${q.provider}::${fe.id}`,children:[q.provider," / ",fe.id]},`${q.provider}::${fe.id}`)))}),o.jsx("span",{className:"text-[10px] text-muted-foreground",children:"for suggestion"})]}),o.jsxs("div",{className:"flex gap-3 items-start",children:[o.jsx("textarea",{className:`flex-1 min-h-[80px] rounded-md border bg-background px-3 py-2 text-sm resize-y
|
|
106
106
|
focus:outline-none focus:ring-2 focus:ring-ring placeholder:text-muted-foreground`,placeholder:'e.g. "I process SaaS vendor invoices, software licences, and employment contracts for a startup. Vendors include Stripe, AWS, and GitHub. Documents are in English and French."',value:k,onChange:q=>C(q.target.value),onKeyDown:q=>{q.key==="Enter"&&(q.metaKey||q.ctrlKey)&&W()}}),o.jsx(ae,{onClick:W,disabled:A||!k.trim(),className:`h-10 w-10 p-0 rounded-xl flex items-center justify-center bg-violet-500 hover:bg-violet-600
|
|
107
|
-
text-white shadow-lg shadow-violet-500/20 hover:scale-105 active:scale-95 transition-all`,title:"Suggest baseline config with AI (⌘↵)",children:A?o.jsx(
|
|
108
|
-
animate-in slide-in-from-bottom-2 duration-300`,children:[o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsx("p",{className:"text-xs font-semibold text-violet-600 dark:text-violet-400",children:"AI Suggestion"}),o.jsx("button",{type:"button",onClick:()=>V(null),className:"text-muted-foreground hover:text-foreground transition-colors",children:o.jsx(zn,{className:"w-3.5 h-3.5"})})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Extraction Context"}),o.jsx("p",{className:"text-xs bg-muted/60 rounded-lg px-3 py-2 leading-relaxed",children:
|
|
107
|
+
text-white shadow-lg shadow-violet-500/20 hover:scale-105 active:scale-95 transition-all`,title:"Suggest baseline config with AI (⌘↵)",children:A?o.jsx(rt,{className:"w-4 h-4 animate-spin"}):o.jsx(Cs,{className:"w-4 h-4"})})]}),z&&o.jsxs("div",{className:`rounded-xl border border-violet-500/20 bg-violet-500/5 p-4 space-y-3
|
|
108
|
+
animate-in slide-in-from-bottom-2 duration-300`,children:[o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsx("p",{className:"text-xs font-semibold text-violet-600 dark:text-violet-400",children:"AI Suggestion"}),o.jsx("button",{type:"button",onClick:()=>V(null),className:"text-muted-foreground hover:text-foreground transition-colors",children:o.jsx(zn,{className:"w-3.5 h-3.5"})})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Extraction Context"}),o.jsx("p",{className:"text-xs bg-muted/60 rounded-lg px-3 py-2 leading-relaxed",children:z.context})]}),z.fields.length>0&&o.jsxs("div",{className:"space-y-1",children:[o.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:["Custom Fields to Add (",z.fields.length,")"]}),o.jsx("div",{className:"space-y-1.5",children:z.fields.map((q,fe)=>o.jsxs("div",{className:"flex items-start gap-2 bg-muted/60 rounded-lg px-3 py-2",children:[o.jsx("code",{className:"text-xs font-mono mt-0.5 shrink-0",children:q.key}),o.jsx(Pt,{variant:"outline",className:"text-[10px] px-1.5 py-0 shrink-0",children:q.type}),o.jsx("span",{className:"text-xs text-muted-foreground leading-snug",children:q.description})]},fe))})]}),z.fields.length===0&&o.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No additional custom fields suggested for this workflow."}),o.jsxs("div",{className:"flex gap-2 pt-1",children:[o.jsx(ae,{size:"sm",onClick:ne,className:`flex-1 h-8 rounded-xl font-black text-[10px] uppercase tracking-widest
|
|
109
109
|
bg-violet-500 hover:bg-violet-600 text-white`,children:"Apply Suggestion"}),o.jsx(ae,{size:"sm",variant:"outline",onClick:()=>V(null),className:"h-8 px-3 rounded-xl",children:"Discard"})]})]})]})]}),o.jsxs(ht,{children:[o.jsxs(zt,{children:[o.jsxs(Lt,{className:"flex items-center gap-2",children:[o.jsx(Pw,{className:"w-5 h-5 text-violet-500"}),"Extraction Context"]}),o.jsx(wn,{children:"Describe the kinds of documents you typically process. This context is injected directly into the extraction prompt, helping the model specialise for your workflow."})]}),o.jsx(xt,{children:o.jsx("textarea",{className:`w-full min-h-[96px] rounded-md border bg-background px-3 py-2 text-sm resize-y
|
|
110
110
|
focus:outline-none focus:ring-2 focus:ring-ring placeholder:text-muted-foreground`,placeholder:'e.g. "I primarily process SaaS vendor invoices and software contracts. Documents are in English and French. Frequent vendors include Stripe, AWS, and GitHub."',value:d,onChange:q=>h(q.target.value)})})]}),o.jsxs(ht,{children:[o.jsxs(zt,{children:[o.jsx(Lt,{className:"text-base",children:"Default Fields"}),o.jsx(wn,{children:"Built-in fields extracted from every document. Toggle to enable or disable. Edit the description to give the model a better hint for your documents."})]}),o.jsx(xt,{className:"space-y-3",children:oe.map(q=>o.jsxs("div",{className:"flex items-start gap-3 group",children:[o.jsx("button",{type:"button",onClick:()=>$(q.key),className:`mt-0.5 flex-shrink-0 w-5 h-5 rounded border-2 flex items-center justify-center transition-colors
|
|
111
|
-
${q.enabled?"bg-violet-500 border-violet-500":"border-muted-foreground/40 bg-background"}`,children:q.enabled&&o.jsx(as,{className:"w-3 h-3 text-white"})}),o.jsxs("div",{className:"flex-1 space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("code",{className:"text-xs font-mono bg-muted px-1.5 py-0.5 rounded",children:q.key}),o.jsx(Pt,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:q.type})]}),o.jsx(je,{className:"h-7 text-xs",value:q.description,disabled:!q.enabled,onChange:fe=>Y(q.key,fe.target.value)})]})]},q.key))})]}),o.jsxs(ht,{children:[o.jsx(zt,{children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx(Lt,{className:"text-base",children:"Custom Fields"}),o.jsx(wn,{className:"mt-1",children:"Add fields specific to your workflow — project codes, contract types, department names, or any entity your documents carry."})]}),o.jsxs(ae,{variant:"outline",size:"sm",onClick:J,className:"gap-1.5",children:[o.jsx(Wa,{className:"w-3.5 h-3.5"}),"Add Field"]})]})}),ue.length>0&&o.jsx(xt,{className:"space-y-4",children:m.map((q,fe)=>q.is_default?null:o.jsxs("div",{className:"grid grid-cols-[1fr_120px_1fr_32px] gap-2 items-start",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-muted-foreground",children:"Key"}),o.jsx(je,{className:"h-8 text-xs font-mono",placeholder:"e.g. project_code",value:q.key,onChange:ie=>pe(fe,{key:ie.target.value.toLowerCase().replace(/\s+/g,"_")})})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-muted-foreground",children:"Type"}),o.jsx("select",{className:"w-full h-8 text-xs border rounded-md px-2 bg-background",value:q.type,onChange:ie=>pe(fe,{type:ie.target.value}),children:T6.map(ie=>o.jsx("option",{value:ie,children:ie},ie))})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-muted-foreground",children:"Description / hint for the model"}),o.jsx(je,{className:"h-8 text-xs",placeholder:"What this field contains",value:q.description,onChange:ie=>pe(fe,{description:ie.target.value})})]}),o.jsx("button",{type:"button",onClick:()=>se(fe),className:"mt-6 p-1 rounded text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",children:o.jsx(el,{className:"w-3.5 h-3.5"})})]},fe))})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("button",{type:"button",onClick:E?()=>j(!1):_e,className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[o.jsx(pC,{className:"w-3.5 h-3.5"}),"Version history",y!==null&&o.jsxs(Pt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 ml-1",children:["v",y," active"]}),E?o.jsx(lu,{className:"w-3 h-3"}):o.jsx(Bo,{className:"w-3 h-3"})]}),o.jsxs(ae,{onClick:M,disabled:l,className:"gap-2",children:[l?o.jsx(cn,{size:"sm"}):o.jsx(as,{className:"w-4 h-4"}),"Save & Activate"]})]}),E&&o.jsx(ht,{children:o.jsx(xt,{className:"pt-4 space-y-2",children:w.length===0?o.jsx("p",{className:"text-xs text-muted-foreground text-center py-4",children:"No saved versions yet"}):w.map(q=>o.jsxs("div",{className:"flex items-center justify-between py-2 px-3 rounded-lg border bg-muted/30",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("span",{className:"text-sm font-mono font-medium",children:["v",q.version]}),q.is_active&&o.jsx(Pt,{className:"text-[10px] px-1.5 py-0 bg-violet-500 text-white",children:"active"}),o.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(q.created_at).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",q.fields.filter(fe=>fe.enabled).length," fields",q.context?" · context set":""]})]}),!q.is_active&&o.jsx(ae,{variant:"outline",size:"sm",className:"h-6 text-xs px-2",onClick:()=>L(q.id,q.version),children:"Activate"})]},q.id))})})]})}const Ep=v.createContext(null),kj=v.forwardRef(({className:t,defaultValue:e,value:s,onValueChange:r,...l},u)=>{const[d,h]=v.useState(e||""),m=s!==void 0?s:d,g=v.useCallback(y=>{r&&r(y),s===void 0&&h(y)},[r,s]);return o.jsx(Ep.Provider,{value:{value:m,onValueChange:g},children:o.jsx("div",{ref:u,className:t,...l})})});kj.displayName="Tabs";const Cj=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...e}));Cj.displayName="TabsList";const jo=v.forwardRef(({className:t,value:e,onClick:s,...r},l)=>{const u=v.useContext(Ep);if(!u)throw new Error("TabsTrigger must be used within Tabs");const d=u.value===e;return o.jsx("button",{ref:l,type:"button",role:"tab","aria-selected":d,"data-state":d?"active":"inactive",className:ge("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background 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 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",t),onClick:h=>{u.onValueChange(e),s?.(h)},...r})});jo.displayName="TabsTrigger";const _o=v.forwardRef(({className:t,value:e,...s},r)=>{const l=v.useContext(Ep);if(!l)throw new Error("TabsContent must be used within Tabs");return l.value!==e?null:o.jsx("div",{ref:r,role:"tabpanel","data-state":"active",className:ge("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...s})});_o.displayName="TabsContent";const bo="realtimexai";function k6(){const{state:t,actions:e}=ol(),{t:s}=bi(),[r,l]=v.useState(!1),[u,d]=v.useState(!1),[h,m]=v.useState({});m6({system_instruction:s("config.agent.systemInstruction"),data:{accounts_count:t.accounts.length,connected_providers:t.accounts.map(P=>P.provider),rules_count:t.rules.length,active_rules:t.rules.filter(P=>P.is_enabled).map(P=>P.name),current_settings:{llm_provider:h.llm_provider,llm_model:h.llm_model}}});const[g,y]=v.useState([]),[x,w]=v.useState([]);v.useEffect(()=>{(async()=>{try{const te=await Te.getChatProviders();te.data&&y(te.data.providers||[])}catch(te){console.error(te)}})(),(async()=>{try{const te=await Te.getEmbedProviders();te.data&&w(te.data.providers||[])}catch(te){console.error(te)}})()},[s]);const E=g.find(P=>P.provider===(h.llm_provider||bo))?.models||[],_=x.find(P=>P.provider===(h.embedding_provider||bo))?.models||[],N=v.useMemo(()=>!h.llm_model||E.some(Z=>Z.id===h.llm_model)?E:[{id:h.llm_model,name:`${h.llm_model} (saved)`},...E],[E,h.llm_model]),k=v.useMemo(()=>!h.llm_provider||h.llm_provider===bo||g.some(Z=>Z.provider===h.llm_provider)?g:[{provider:h.llm_provider,name:`${h.llm_provider} (saved)`,models:[]},...g],[g,h.llm_provider]),C=v.useMemo(()=>!h.embedding_model||_.some(Z=>Z.id===h.embedding_model)?_:[{id:h.embedding_model,name:`${h.embedding_model} (saved)`},..._],[_,h.embedding_model]),A=v.useMemo(()=>!h.embedding_provider||h.embedding_provider===bo||x.some(Z=>Z.provider===h.embedding_provider)?x:[{provider:h.embedding_provider,name:`${h.embedding_provider} (saved)`,models:[]},...x],[x,h.embedding_provider]),D=P=>{const Z=g.find(te=>te.provider===P);m(te=>({...te,llm_provider:P,llm_model:Z?.models?.[0]?.id||""}))},U=P=>{const Z=x.find(te=>te.provider===P);m(te=>({...te,embedding_provider:P,embedding_model:Z?.models?.[0]?.id||""}))},V=async()=>{d(!0);try{const P=await Te.testLlm({llm_provider:h.llm_provider||void 0,llm_model:h.llm_model||void 0});P.data?.success?ce.success(P.data.message):ce.error(s("config.toast.connectionFailed"))}catch{ce.error(s("config.toast.connectionFailed"))}finally{d(!1)}};v.useEffect(()=>{e.fetchAccounts(),e.fetchRules(),e.fetchSettings()},[]),v.useEffect(()=>{t.settings&&m(t.settings)},[t.settings]);const R=async()=>{l(!0);const P=await e.updateSettings(h);l(!1),P&&ce.success(s("config.toast.settingsSaved"))};return o.jsxs("div",{className:"w-full mx-auto px-8 py-10 space-y-6 animate-in fade-in duration-500 flex flex-col h-full",children:[o.jsx("div",{className:"flex items-center justify-between",children:o.jsxs("div",{children:[o.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Configuration"}),o.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage your connected integrations and AI providers."})]})}),o.jsxs(kj,{defaultValue:"mail",className:"w-full",children:[o.jsxs(Cj,{className:"grid w-full grid-cols-4 max-w-lg h-12",children:[o.jsx(jo,{value:"mail",className:"h-10",children:"Mail"}),o.jsx(jo,{value:"storage",className:"h-10",children:"Storage"}),o.jsx(jo,{value:"intelligence",className:"h-10",children:"Intelligence"}),o.jsx(jo,{value:"baseline",className:"h-10",children:"Baseline"})]}),o.jsxs("div",{className:"mt-8",children:[o.jsx(_o,{value:"mail",className:"m-0 border-none p-0 outline-none",children:o.jsx(g6,{localSettings:h,setLocalSettings:m,handleSaveSettings:R,savingSettings:r})}),o.jsx(_o,{value:"storage",className:"m-0 border-none p-0 outline-none",children:o.jsx(_6,{})}),o.jsx(_o,{value:"intelligence",className:"m-0 border-none p-0 outline-none",children:o.jsx(j6,{localSettings:h,setLocalSettings:m,handleSaveSettings:R,savingSettings:r,handleTestConnection:V,testingLlm:u,providersWithSaved:k,modelsWithSaved:N,embedProvidersWithSaved:A,embedModelsWithSaved:C,handleProviderChange:D,handleEmbedProviderChange:U,DEFAULT_PROVIDER:bo})}),o.jsx(_o,{value:"baseline",className:"m-0 border-none p-0 outline-none",children:o.jsx(E6,{})})]})]})]})}function C6({status:t,onSnooze:e,onOpenModal:s}){const[r,l]=v.useState(!1),[u,d]=v.useState(!1),h=g=>{const y=new Date(Date.now()+g*60*60*1e3);e?.(y),ce.success(`Reminder snoozed until ${y.toLocaleTimeString()}`)},m=["Enhanced TTS voice support (Piper, Supertonic)","Real-time audio streaming infrastructure","Improved AI model provider resolution"];return r?o.jsx("div",{className:"fixed top-24 left-1/2 -translate-x-1/2 z-[60] animate-in slide-in-from-top-5",children:o.jsxs("button",{onClick:()=>l(!1),className:"flex items-center gap-2 px-4 py-2 bg-amber-500 text-amber-950 rounded-full shadow-2xl shadow-amber-500/20 hover:scale-105 active:scale-95 transition-all text-[11px] font-black uppercase tracking-widest border border-amber-400/50 backdrop-blur-md",children:[o.jsx(Cs,{className:"h-3.5 w-3.5"}),o.jsx("span",{children:"System Update Available"})]})}):o.jsx("div",{className:"fixed top-0 left-0 right-0 z-[60] animate-in slide-in-from-top-10 duration-700",children:o.jsxs("div",{className:"bg-amber-500 text-amber-950 px-6 py-4 shadow-2xl border-b border-amber-400/50 backdrop-blur-xl relative overflow-hidden",children:[o.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-white/10 rounded-full -translate-y-1/2 translate-x-1/2 blur-3xl pointer-events-none"}),o.jsx("div",{className:"max-w-5xl mx-auto relative",children:o.jsxs("div",{className:"flex items-start gap-6",children:[o.jsx("div",{className:"w-12 h-12 rounded-2xl bg-amber-950/10 flex items-center justify-center shrink-0",children:o.jsx(Gw,{className:"h-6 w-6"})}),o.jsxs("div",{className:"flex-1 space-y-3",children:[o.jsxs("div",{className:"flex items-start justify-between gap-4",children:[o.jsxs("div",{children:[o.jsxs("h2",{className:"text-lg font-black tracking-tight flex items-center gap-2",children:["Foundational Update Required",o.jsxs("span",{className:"text-[10px] px-2 py-0.5 bg-amber-950/10 rounded-full border border-amber-950/20 uppercase tracking-widest font-black",children:["v",t.appVersion]})]}),o.jsx("p",{className:"text-sm font-medium opacity-80 mt-1 max-w-2xl leading-relaxed",children:"New architecture components detected. Migration is necessary to enable real-time audio streaming and enhanced AI provider resolution."})]}),o.jsx(ae,{size:"icon",variant:"ghost",className:"h-8 w-8 text-amber-950 hover:bg-amber-950/10 rounded-full shrink-0",onClick:()=>l(!0),children:o.jsx($w,{className:"h-4 w-4"})})]}),u&&o.jsxs("div",{className:"bg-amber-950/5 rounded-2xl p-4 border border-amber-950/10 animate-in fade-in slide-in-from-top-2",children:[o.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest opacity-60 mb-3",children:"Protocol Improvements:"}),o.jsx("ul",{className:"grid grid-cols-1 md:grid-cols-2 gap-x-8 gap-y-2",children:m.map((g,y)=>o.jsxs("li",{className:"text-xs flex items-center gap-2 font-bold",children:[o.jsx("div",{className:"w-1 h-1 rounded-full bg-amber-950/40"}),g]},y))})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-1",children:[o.jsx(ae,{size:"sm",className:"h-9 px-6 bg-amber-950 text-amber-50 hover:bg-black rounded-full font-black text-[10px] uppercase tracking-[0.2em] shadow-xl shadow-amber-950/20 active:scale-95 transition-all",onClick:s,children:"Apply Update Now"}),o.jsx("div",{className:"h-4 w-px bg-amber-950/20 hidden sm:block mx-1"}),o.jsxs(ae,{size:"sm",variant:"ghost",className:"h-9 text-amber-950 font-black text-[10px] uppercase tracking-widest hover:bg-amber-950/10 rounded-full",onClick:()=>h(1),children:[o.jsx(Qo,{className:"h-3.5 w-3.5 mr-2 opacity-60"}),"Snooze 1h"]}),o.jsxs(ae,{size:"sm",variant:"ghost",className:"h-9 text-amber-950 font-black text-[10px] uppercase tracking-widest hover:bg-amber-950/10 rounded-full",onClick:()=>h(24),children:[o.jsx(zw,{className:"h-3.5 w-3.5 mr-2 opacity-60"}),"Tomorrow"]}),o.jsxs(ae,{size:"sm",variant:"ghost",className:"h-9 text-amber-950 font-black text-[10px] uppercase tracking-widest hover:bg-amber-950/10 rounded-full ml-auto",onClick:()=>d(!u),children:[u?o.jsx(lu,{className:"h-4 w-4"}):o.jsx(Bo,{className:"h-4 w-4"}),o.jsx("span",{className:"ml-2",children:u?"Hide Details":"Inspect Protocol"})]})]})]})]})})]})})}function A6({open:t,onOpenChange:e,status:s,onSnooze:r}){const l=$o(),u=j=>{const _=new Date(Date.now()+j*60*60*1e3);r?.(_),ce.success(`Reminder snoozed until ${_.toLocaleTimeString()}`),e(!1)},[d,h]=v.useState(!1),[m,g]=v.useState([]),[y,x]=v.useState(""),w=v.useRef(null),S=v.useMemo(()=>{const j=l?.url;if(!j)return"";try{return new URL(j).hostname.split(".")[0]||""}catch{return""}},[l?.url]);v.useEffect(()=>{w.current&&w.current.scrollIntoView({behavior:"smooth"})},[m]);const E=async()=>{if(!S){ce.error("Foundation Error: Missing Project ID");return}if(!y){ce.error("Security Error: Provide a Supabase Access Token.");return}h(!0),g(["[System] Initializing migration protocol...","[Auth] Verifying project credentials..."]);try{const j=await fetch("/api/migrate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectRef:S,accessToken:y})});if(!j.ok)throw new Error(`Migration engine failed: ${j.status}`);const _=j.body?.getReader();if(!_)throw new Error("Failed to initialize log stream.");const N=new TextDecoder;let k="",C=!1;for(;;){const{done:A,value:D}=await _.read();if(A)break;k+=N.decode(D,{stream:!0});const U=k.split(`
|
|
112
|
-
`);k=U.pop()||"";for(const V of U){const R=V.trim();if(!(!R||!R.startsWith("data: ")))try{const P=JSON.parse(R.substring(6));P.type==="done"?P.data==="success"&&(C=!0):P.data&&g(Z=>[...Z,P.data])}catch{}}}if(C)g(A=>[...A,"","═".repeat(50),"✅ FOUNDATION UPDATED","","✓ Database schema synchronized","✓ API contracts verified","","System will reload to apply changes...","═".repeat(50)]),setTimeout(()=>{window.location.reload()},2e3);else throw new Error("Migration completed with errors.")}catch(j){console.error(j),g(_=>[..._,"",`❌ FATAL ERROR: ${j instanceof Error?j.message:String(j)}`]),ce.error("Migration interrupted. Consult system logs.")}finally{h(!1)}};return o.jsx(Za,{open:t,onOpenChange:j=>!d&&e(j),children:o.jsx(er,{className:"max-h-[90vh] sm:max-w-4xl overflow-y-auto border-none bg-background/95 backdrop-blur-2xl shadow-2xl p-0 gap-0 selection:bg-primary/20",children:o.jsxs("div",{className:"bg-gradient-to-br from-primary/5 via-transparent to-transparent",children:[o.jsx(hi,{className:"p-8 pb-4",children:o.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[o.jsx("div",{className:"w-12 h-12 rounded-2xl bg-primary/10 flex items-center justify-center",children:o.jsx(hu,{className:"h-6 w-6 text-primary"})}),o.jsxs("div",{children:[o.jsx(fi,{className:"text-2xl font-black tracking-tight",children:"Database Setup Required"}),o.jsxs(tl,{className:"text-xs font-bold uppercase tracking-[0.2em] opacity-60",children:["Foundational Registry Sync • ",s.appVersion]})]})]})}),o.jsxs("div",{className:"px-8 pb-8 space-y-6",children:[o.jsxs(jn,{className:"bg-muted/40 border-none rounded-2xl p-4",children:[o.jsx(Im,{className:"h-4 w-4 text-primary"}),o.jsxs(_n,{className:"text-xs font-medium leading-relaxed",children:["Your application requires a database schema update to enable new features like ",o.jsx("strong",{children:"Enhanced TTS Engine"})," and ",o.jsx("strong",{children:"Real-time Intelligence Streaming"}),". Existing data remains untouched."]})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[o.jsx("div",{className:"space-y-4",children:o.jsxs("div",{className:"rounded-2xl border bg-card/50 shadow-sm p-6 space-y-4",children:[o.jsx("h3",{className:"text-[10px] font-black uppercase tracking-[0.2em] text-muted-foreground",children:"Security Credentials"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"project-id",className:"text-[10px] uppercase tracking-widest font-black opacity-60",children:"Project Identity"}),o.jsx(je,{id:"project-id",value:S,disabled:!0,readOnly:!0,className:"h-10 bg-muted/50 border-none font-mono text-xs rounded-xl"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx(Je,{htmlFor:"access-token",className:"text-[10px] uppercase tracking-widest font-black opacity-60",children:"Personal Access Token"}),o.jsxs("a",{href:"https://supabase.com/dashboard/account/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] font-black tracking-widest text-primary hover:underline flex items-center gap-1",children:["GENERATE ",o.jsx(Uw,{className:"h-2.5 w-2.5"})]})]}),o.jsx(je,{id:"access-token",type:"password",placeholder:"sbp_...",value:y,onChange:j=>x(j.target.value),disabled:d,className:"h-10 bg-background border-border/40 focus:ring-primary/20 rounded-xl font-mono text-xs"})]}),o.jsx(ae,{onClick:E,disabled:d||!y,className:"w-full h-11 rounded-xl bg-primary text-primary-foreground font-black text-[10px] uppercase tracking-[0.2em] shadow-lg shadow-primary/20 hover:scale-[1.02] active:scale-[0.98] transition-all",children:d?o.jsxs(o.Fragment,{children:[o.jsx(it,{className:"mr-2 h-4 w-4 animate-spin"}),"Deploying..."]}):o.jsxs(o.Fragment,{children:[o.jsx(ya,{className:"mr-2 h-4 w-4"}),"Initialize Protocol"]})})]})]})}),o.jsxs("div",{className:"flex flex-col rounded-2xl border bg-zinc-950/95 text-zinc-400 font-mono text-[11px] p-5 shadow-inner min-h-[300px] overflow-hidden",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-4 shrink-0",children:[o.jsxs("div",{className:"flex gap-1.5",children:[o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-500/20"}),o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-amber-500/20"}),o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-emerald-500/20"})]}),o.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest opacity-40 ml-2",children:"Foundation Terminal"})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:[m.length===0?o.jsxs("div",{className:"text-zinc-700 italic flex flex-col items-center justify-center h-full opacity-50",children:[o.jsx(Io,{className:"h-8 w-8 mb-2"}),o.jsx("span",{children:"Awaiting synchronization..."})]}):m.map((j,_)=>o.jsxs("div",{className:ge("mb-1.5 leading-relaxed break-words",j.includes("✅")||j.includes("success")?"text-emerald-400":j.includes("❌")||j.includes("Error")?"text-red-400 font-bold":j.includes("🚀")||j.includes("[System]")?"text-primary":""),children:[o.jsx("span",{className:"opacity-30 mr-2",children:_+1}),j]},_)),o.jsx("div",{ref:w})]})]})]})]}),o.jsx(ti,{className:"p-8 pt-0 flex-col sm:flex-row gap-3",children:o.jsxs("div",{className:"flex gap-3 w-full",children:[o.jsxs(ae,{type:"button",variant:"secondary",onClick:()=>u(1),disabled:d,className:"flex-1 h-11 rounded-xl font-black text-[10px] uppercase tracking-widest",children:[o.jsx(Qo,{className:"h-4 w-4 mr-2 opacity-60"}),"Snooze 1h"]}),o.jsxs(ae,{type:"button",variant:"secondary",onClick:()=>u(24),disabled:d,className:"flex-1 h-11 rounded-xl font-black text-[10px] uppercase tracking-widest",children:[o.jsx(zw,{className:"h-4 w-4 mr-2 opacity-60"}),"Tomorrow"]})]})})]})})})}const R6=[{id:"bay-area-utilities",name:"Bay Area Utilities",description:"PG&E, Recology, EBMUD, and SCE bill handling",policies:4,tags:["utilities","california"]},{id:"freelancer-tax",name:"Freelancer Tax Pack",description:"1099-NEC, W-9, invoices, and estimated taxes",policies:6,tags:["finance","tax"]},{id:"medical-records",name:"Medical Records",description:"EOB, lab results, prescription receipts",policies:5,tags:["health","insurance"]},{id:"legal-docs",name:"Legal Documents",description:"Contracts, notices, deeds, and court documents",policies:3,tags:["legal","priority"]}];function O6({initialCompose:t,onInitialConsumed:e}){const[s,r]=v.useState([]),[l,u]=v.useState(!0),[d,h]=v.useState(""),[m,g]=v.useState(!1),[y,x]=v.useState(null),[w,S]=v.useState(!1),[E,j]=v.useState(!1),[_,N]=v.useState(null),[k,C]=v.useState("policies"),[A,D]=v.useState([]),[U,V]=v.useState(""),[R,P]=v.useState(""),[Z,te]=v.useState(null),[me,Ee]=v.useState(null),[ye,_e]=v.useState(null),[$,Y]=v.useState(!1),[J,pe]=v.useState({name:"",description:"",keywords:"",matchStrategy:"ANY",actions:[{type:"copy",destination:"",filename:"",columns:[],spreadsheet_id:"",range:""}],tags:"",priority:100}),[se,M]=v.useState(!1),L=v.useCallback(async()=>{u(!0);const B=await Te.getPolicies?.(Z);B?.data?.policies&&r(B.data.policies),u(!1)},[Z]),W=v.useCallback(async()=>{try{const re=(await Te.getSDKChatProviders?.())?.data?.providers??[];D(re),re.length>0&&!U&&(V(re[0].provider),P(re[0].models?.[0]?.id??""))}catch{}},[U]);v.useEffect(()=>{const B=un();B&&B.auth.getSession().then(({data:re})=>{te(re.session?.access_token??null)})},[]),v.useEffect(()=>{L(),W()},[L,W]),v.useEffect(()=>{t&&(h(t),e?.())},[t,e]);const ne=async()=>{if(d.trim()){g(!0),x(null);try{const B=await Te.synthesizePolicy?.({description:d,provider:U||void 0,model:R||void 0},Z);if(B?.data?.policy){x(B.data.policy),S(!1);const re=B.data.warning;re?ce.warning(re):ce.success("Policy synthesized! Review and save below.")}else ce.error(B?.data?.error??"Synthesis failed.")}catch{ce.error("LLM synthesis failed.")}finally{g(!1)}}},oe=async B=>{j(!0);try{await Te.savePolicy?.(B,Z),ce.success(`Policy "${B.metadata.name}" saved.`),x(null),h(""),await L()}catch{ce.error("Failed to save policy.")}finally{j(!1)}},ue=async B=>{window.confirm(`Delete policy "${B}"?`)&&(await Te.deletePolicy?.(B,Z),ce.success("Policy deleted."),await L())},q=async B=>{r(re=>re.map(De=>De.metadata.id===B.metadata.id?{...De,metadata:{...De.metadata,enabled:!De.metadata.enabled}}:De));try{await Te.patchPolicy?.(B.metadata.id,{enabled:!B.metadata.enabled},Z)}catch{ce.error("Failed to toggle policy."),await L()}},fe=B=>{Ee(B.metadata.id),_e({name:B.metadata.name,description:B.metadata.description,tags:(B.metadata.tags??[]).join(", "),priority:B.metadata.priority})},ie=()=>{Ee(null),_e(null)},ze=async B=>{if(ye)try{await Te.patchPolicy?.(B,{name:ye.name,description:ye.description,tags:ye.tags.split(",").map(re=>re.trim()).filter(Boolean),priority:ye.priority},Z),ce.success("Policy updated."),Ee(null),_e(null),await L()}catch{ce.error("Failed to save edits.")}},Be=B=>{h(B.metadata.description),C("policies"),ce.success("Description pre-filled — edit and click ✨ to re-synthesize.")},kt=async()=>{await Te.reloadPolicies?.(Z),await L(),ce.success("Policies reloaded.")},et=(B,re,De)=>{pe(qe=>{const ft=qe.actions.map((Zt,Ve)=>Ve===B?{...Zt,[re]:De}:Zt);return{...qe,actions:ft}})},le=()=>{pe(B=>({...B,actions:[...B.actions,{type:"copy",destination:"",filename:"",columns:[],spreadsheet_id:"",range:""}]}))},Fe=B=>{pe(re=>({...re,actions:re.actions.filter((De,qe)=>qe!==B)}))},de=B=>B.type==="append_to_google_sheet"&&!B.spreadsheet_id?.trim(),Me=J.actions.some(de),at=async()=>{if(!J.name.trim())return;const B=J.actions.findIndex(de);if(B!==-1){ce.error(`Action #${B+1}: "Append to Google Sheet" requires Spreadsheet ID or Google Sheet URL.`);return}M(!0);try{const re=J.name.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),De=J.keywords.split(",").map(Ve=>Ve.trim()).filter(Boolean),qe=J.tags.split(",").map(Ve=>Ve.trim()).filter(Boolean),ft=J.actions.filter(Ve=>Ve.type==="copy_to_gdrive"||Ve.type==="auto_rename"||Ve.type==="append_to_google_sheet"||Ve.destination.trim()).map(Ve=>{const en={type:Ve.type};if(Ve.type==="copy")en.destination=Ve.destination,Ve.filename&&(en.filename=Ve.filename);else if(Ve.type==="rename")en.destination=Ve.destination;else if(Ve.type!=="auto_rename"){if(Ve.type==="copy_to_gdrive")Ve.destination.trim()&&(en.destination=Ve.destination.trim()),Ve.filename&&(en.filename=Ve.filename);else if(Ve.type==="log_csv")en.path=Ve.destination;else if(Ve.type==="append_to_google_sheet"){const ll=Ve.spreadsheet_id?.trim();ll&&(en.spreadsheet_id=ll);const Ms=Ve.range?.trim();Ms&&(en.range=Ms);const Kt=(Ve.columns??[]).map(Wn=>Wn.trim()).filter(Boolean);Kt.length>0&&(en.columns=Kt)}}return en}),Zt={metadata:{id:re,name:J.name.trim(),description:J.description.trim(),priority:J.priority,tags:qe,enabled:!0},spec:{match:{strategy:J.matchStrategy,conditions:De.length>0?[{type:"keyword",value:De}]:[{type:"keyword",value:[]}]},extract:[],actions:ft}};await Te.savePolicy?.(Zt,Z),ce.success(`Policy "${Zt.metadata.name}" created.`),Y(!1),pe({name:"",description:"",keywords:"",matchStrategy:"ANY",actions:[{type:"copy",destination:"",filename:"",columns:[],spreadsheet_id:"",range:""}],tags:"",priority:100}),await L()}catch{ce.error("Failed to create policy.")}finally{M(!1)}},Ut=B=>{if(B.type==="append_to_google_sheet"){const re=B.spreadsheet_id?.trim()||B.spreadsheet_url?.trim()||"",De=B.range?.trim()||"";return re&&De?`${re} (${De})`:re||De}return B.type==="log_csv"?B.path?.trim()||"":B.destination?.trim()||B.pattern?.trim()||""},Xn=(B,re)=>{x(De=>{if(!De)return De;const qe=(De.spec.actions??[]).map((ft,Zt)=>Zt===B?{...ft,...re}:ft);return{...De,spec:{...De.spec,actions:qe}}})},Si=(B=>{if(!B)return[];const re=[];B.metadata.name?.trim()||re.push("Policy name is missing."),B.metadata.id?.trim()||re.push("Policy id is missing.");const De=B.spec.actions??[];return De.length===0&&re.push("At least one action is required."),De.forEach((qe,ft)=>{qe.type==="append_to_google_sheet"&&(qe.spreadsheet_id?.trim()||qe.spreadsheet_url?.trim()||re.push(`Action #${ft+1} append_to_google_sheet is missing spreadsheet_id / URL.`)),qe.type==="copy"&&!qe.destination?.trim()&&re.push(`Action #${ft+1} copy is missing destination.`),qe.type==="rename"&&!(qe.pattern?.trim()||qe.destination?.trim())&&re.push(`Action #${ft+1} rename is missing pattern.`)}),re})(y),Uu=!!y&&Si.length===0&&!E;return o.jsxs("div",{className:"w-full mx-auto px-8 py-10 space-y-10 animate-in fade-in duration-500",children:[o.jsxs("div",{className:"flex items-end justify-between",children:[o.jsxs("div",{children:[o.jsxs("h1",{className:"text-3xl font-black tracking-tight flex items-center gap-3",children:[o.jsx(Hw,{className:"w-8 h-8 text-primary"}),"Policy Engine"]}),o.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Define automation rules that govern how Folio handles your documents."})]}),o.jsxs(ae,{variant:"outline",size:"sm",onClick:kt,className:"gap-2 rounded-xl",children:[o.jsx(ma,{className:"w-4 h-4"}),"Reload"]})]}),o.jsx("div",{className:"flex gap-1 p-1 rounded-2xl bg-muted/50 border w-fit",children:["policies","packs"].map(B=>o.jsx("button",{onClick:()=>C(B),className:ge("px-5 py-2 rounded-xl text-xs font-black uppercase tracking-widest transition-all",k===B?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:B==="policies"?"Active Policies":"Policy Packs"},B))}),k==="policies"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"rounded-2xl border bg-card/60 backdrop-blur-sm p-6 shadow-sm space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[o.jsx(Cs,{className:"w-4 h-4 text-primary"}),o.jsx("h2",{className:"text-sm font-black uppercase tracking-widest",children:"Magic Composer"})]}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Describe a rule in plain English. Click ✨ to generate the policy automatically."}),A.length>0&&o.jsxs("div",{className:"flex gap-2 items-center",children:[o.jsx(Bm,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"}),o.jsx("select",{value:`${U}::${R}`,onChange:B=>{const[re,De]=B.target.value.split("::");V(re),P(De)},className:"text-xs rounded-lg border border-border/40 bg-background px-2 py-1 text-foreground flex-1 max-w-xs",children:A.flatMap(B=>(B.models??[]).map(re=>o.jsxs("option",{value:`${B.provider}::${re.id}`,children:[B.provider," / ",re.id]},`${B.provider}::${re.id}`)))}),o.jsx("span",{className:"text-[10px] text-muted-foreground",children:"for synthesis"})]}),o.jsxs("div",{className:"flex gap-3 items-start",children:[o.jsx(Ym,{placeholder:"e.g. If I get a bill from Tesla, move it to /Car/ folder and log the amount to my CSV…",value:d,onChange:B=>h(B.target.value),className:"flex-1 min-h-[80px] resize-none rounded-xl border-border/40 bg-background text-sm",onKeyDown:B=>{B.key==="Enter"&&(B.metaKey||B.ctrlKey)&&ne()}}),o.jsx(ae,{onClick:ne,disabled:m||!d.trim(),className:ge("h-10 w-10 p-0 rounded-xl flex items-center justify-center transition-all","bg-primary text-primary-foreground shadow-lg shadow-primary/20","hover:scale-105 active:scale-95"),title:"Synthesize policy with AI",children:m?o.jsx(it,{className:"w-4 h-4 animate-spin"}):o.jsx(Cs,{className:"w-4 h-4"})})]}),y&&o.jsxs("div",{className:"rounded-xl border border-primary/20 bg-primary/5 p-4 space-y-3 animate-in slide-in-from-bottom-2 duration-300",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"font-black text-sm",children:y.metadata.name}),o.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:y.metadata.description})]}),o.jsxs(Pt,{variant:"outline",className:"text-[10px] uppercase font-bold",children:["Priority ",y.metadata.priority]})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3 text-xs text-muted-foreground",children:[o.jsxs("div",{className:"rounded-lg bg-muted/60 p-2",children:[o.jsx("div",{className:"font-bold uppercase tracking-widest text-[9px] mb-1 text-foreground",children:"Match"}),o.jsxs("div",{className:"space-y-1",children:[y.spec.match.conditions.length===0&&o.jsx("div",{children:"—"}),y.spec.match.conditions.map((B,re)=>o.jsxs("div",{children:[o.jsx("span",{className:"font-mono bg-muted px-1 rounded text-[10px]",children:B.type})," ",Array.isArray(B.value)?B.value.join(", "):B.value]},`${B.type}-${re}`))]})]}),o.jsxs("div",{className:"rounded-lg bg-muted/60 p-2",children:[o.jsx("div",{className:"font-bold uppercase tracking-widest text-[9px] mb-1 text-foreground",children:"Extract"}),o.jsxs("div",{className:"space-y-1",children:[(y.spec.extract?.length??0)===0&&o.jsx("div",{children:"—"}),y.spec.extract?.map(B=>o.jsxs("div",{children:[o.jsx("span",{className:"font-mono bg-muted px-1 rounded text-[10px]",children:B.key})," ","(",B.type,")",B.required?" *":""]},B.key))]})]}),o.jsxs("div",{className:"rounded-lg bg-muted/60 p-2",children:[o.jsx("div",{className:"font-bold uppercase tracking-widest text-[9px] mb-1 text-foreground",children:"Actions"}),o.jsxs("div",{className:"space-y-2",children:[(y.spec.actions?.length??0)===0&&o.jsx("div",{children:"—"}),y.spec.actions?.map((B,re)=>o.jsxs("div",{className:"rounded-md border border-border/50 bg-background/80 p-2 space-y-1.5",children:[o.jsxs("div",{children:[o.jsx("span",{className:"font-mono bg-muted px-1 rounded text-[10px]",children:B.type})," ",Ut(B)]}),B.type==="copy_to_gdrive"&&o.jsx(je,{value:B.destination??"",onChange:De=>Xn(re,{destination:De.target.value}),placeholder:"Google Drive folder ID",className:"h-7 text-[11px] rounded-lg font-mono"}),B.type==="append_to_google_sheet"&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(je,{value:B.spreadsheet_id??B.spreadsheet_url??"",onChange:De=>Xn(re,{spreadsheet_id:De.target.value,spreadsheet_url:void 0}),placeholder:"Spreadsheet ID or URL",className:"h-7 text-[11px] rounded-lg font-mono"}),o.jsx(je,{value:B.range??"",onChange:De=>Xn(re,{range:De.target.value}),placeholder:"Optional range (e.g. Sheet1!A:Z)",className:"h-7 text-[11px] rounded-lg font-mono"})]})]},`${B.type}-${re}`))]})]})]}),Si.length>0?o.jsx(jn,{className:"rounded-xl border-red-200 bg-red-50",children:o.jsxs(_n,{className:"text-xs text-red-700",children:[o.jsx("div",{className:"font-semibold mb-1",children:"Fix before saving:"}),o.jsx("div",{className:"space-y-0.5",children:Si.map((B,re)=>o.jsx("div",{children:B},`synth-issue-${re}`))})]})}):o.jsx("div",{className:"text-[11px] text-emerald-700 font-semibold",children:"Policy looks valid for save."}),o.jsx("div",{className:"flex gap-2",children:o.jsx(ae,{type:"button",size:"sm",variant:"outline",onClick:()=>S(B=>!B),className:"h-7 px-2 rounded-lg text-[10px] uppercase tracking-widest",children:w?"Hide JSON":"Show JSON"})}),w&&o.jsx("pre",{className:"rounded-lg border border-border/40 bg-background p-3 text-[11px] overflow-auto max-h-72 whitespace-pre-wrap font-mono",children:JSON.stringify(y,null,2)}),o.jsxs("div",{className:"flex gap-2 pt-1",children:[o.jsx(ae,{size:"sm",onClick:()=>oe(y),disabled:!Uu,className:"flex-1 h-8 rounded-xl font-black text-[10px] uppercase tracking-widest",children:E?o.jsx(it,{className:"w-3 h-3 animate-spin"}):"Save Policy"}),o.jsx(ae,{size:"sm",variant:"outline",onClick:()=>{x(null),S(!1)},className:"h-8 px-3 rounded-xl",children:"Discard"})]})]})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("h2",{className:"text-xs font-black uppercase tracking-widest text-muted-foreground",children:["Active Policies (",s.length,")"]}),o.jsx(ae,{size:"sm",variant:$?"secondary":"outline",onClick:()=>Y(B=>!B),className:"h-7 px-3 rounded-xl gap-1.5 text-[10px] font-black uppercase tracking-widest",children:$?o.jsxs(o.Fragment,{children:[o.jsx(zn,{className:"w-3 h-3"}),"Cancel"]}):o.jsxs(o.Fragment,{children:[o.jsx(hu,{className:"w-3 h-3"}),"Quick Create"]})})]}),$&&o.jsxs("div",{className:"rounded-2xl border border-primary/20 bg-primary/5 p-5 space-y-4 animate-in slide-in-from-top-2 duration-200",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(hu,{className:"w-3.5 h-3.5 text-primary"}),o.jsx("span",{className:"text-xs font-black uppercase tracking-widest text-primary",children:"Quick Create Policy"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{className:"col-span-2 space-y-1",children:[o.jsx(Je,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Name *"}),o.jsx(je,{placeholder:"e.g. Tesla Invoice Handler",value:J.name,onChange:B=>pe({...J,name:B.target.value}),className:"h-8 text-sm rounded-xl border-border/40 bg-background"})]}),o.jsxs("div",{className:"col-span-2 space-y-1",children:[o.jsx(Je,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Description"}),o.jsx(je,{placeholder:"What does this policy do?",value:J.description,onChange:B=>pe({...J,description:B.target.value}),className:"h-8 text-xs rounded-xl border-border/40 bg-background"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(Je,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Match Keywords"}),o.jsx(je,{placeholder:"tesla, invoice, PG&E (comma-sep)",value:J.keywords,onChange:B=>pe({...J,keywords:B.target.value}),className:"h-8 text-xs rounded-xl border-border/40 bg-background"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(Je,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Match Strategy"}),o.jsxs("select",{value:J.matchStrategy,onChange:B=>pe({...J,matchStrategy:B.target.value}),className:"h-8 w-full text-xs rounded-xl border border-border/40 bg-background px-3 text-foreground",children:[o.jsx("option",{value:"ANY",children:"ANY keyword matches"}),o.jsx("option",{value:"ALL",children:"ALL keywords match"})]})]}),o.jsxs("div",{className:"col-span-2 space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(Je,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Actions"}),o.jsxs("button",{type:"button",onClick:le,className:"flex items-center gap-1 text-[10px] font-bold text-primary hover:text-primary/80 transition-colors",children:[o.jsx(Wa,{className:"w-3 h-3"}),"Add Action"]})]}),o.jsx("div",{className:"space-y-2",children:J.actions.map((B,re)=>{const De=!B.filename||B.filename===""?"original":B.filename==="auto"?"auto":"custom";return o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"grid grid-cols-[9rem_minmax(0,1fr)] gap-2 items-start",children:[o.jsxs("select",{value:B.type,onChange:qe=>et(re,"type",qe.target.value),className:"h-8 text-xs rounded-xl border border-border/40 bg-background px-2 text-foreground w-full",children:[o.jsx("option",{value:"copy",children:"Copy to folder"}),o.jsx("option",{value:"rename",children:"Rename file (Pattern)"}),o.jsx("option",{value:"log_csv",children:"Log to CSV"}),o.jsx("option",{value:"copy_to_gdrive",children:"Copy to Google Drive"}),o.jsx("option",{value:"append_to_google_sheet",children:"Append to Google Sheet"})]}),o.jsxs("div",{className:"flex gap-2 items-center min-w-0",children:[B.type!=="append_to_google_sheet"&&o.jsx(je,{placeholder:B.type==="copy"?"/Car/":B.type==="copy_to_gdrive"?"Folder ID (empty = My Drive root)":B.type==="rename"?"Tesla-{date}":"/logs/invoices.csv",value:B.destination,onChange:qe=>et(re,"destination",qe.target.value),className:"h-8 text-xs rounded-xl border-border/40 bg-background font-mono flex-1 min-w-0"}),J.actions.length>1&&o.jsx("button",{type:"button",onClick:()=>Fe(re),className:"text-muted-foreground hover:text-destructive transition-colors shrink-0 p-1",children:o.jsx(zn,{className:"w-3.5 h-3.5"})})]})]}),(B.type==="copy"||B.type==="copy_to_gdrive")&&o.jsxs("div",{className:"grid grid-cols-[9rem_minmax(0,1fr)] gap-2 items-center",children:[o.jsx("div",{"aria-hidden":"true"}),o.jsxs("div",{className:"flex gap-2 items-center min-w-0",children:[o.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:"Filename:"}),o.jsxs("select",{value:De,onChange:qe=>{const ft=qe.target.value;ft==="original"?et(re,"filename",""):ft==="auto"?et(re,"filename","auto"):et(re,"filename","{date}_{issuer}_{document_type}")},className:"h-7 text-xs rounded-lg border border-border/40 bg-background px-2 text-foreground shrink-0",children:[o.jsx("option",{value:"original",children:"Keep original"}),o.jsx("option",{value:"auto",children:"Smart rename (AI)"}),o.jsx("option",{value:"custom",children:"Custom pattern"})]}),De==="custom"&&o.jsx(je,{value:B.filename,onChange:qe=>et(re,"filename",qe.target.value),placeholder:"{date}_{issuer}_{document_type}",className:"h-7 text-xs rounded-lg border-border/40 bg-background font-mono flex-1 min-w-0"})]})]}),B.type==="append_to_google_sheet"&&o.jsxs("div",{className:"grid grid-cols-[9rem_minmax(0,1fr)] gap-2",children:[o.jsx("div",{"aria-hidden":"true"}),o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsxs("div",{className:"flex gap-2",children:[o.jsx(je,{placeholder:"Spreadsheet ID or Google Sheet URL",value:B.spreadsheet_id||"",onChange:qe=>et(re,"spreadsheet_id",qe.target.value),className:"h-7 text-xs rounded-lg flex-1"}),o.jsx(je,{placeholder:"Optional tab/range (e.g. Sheet1!A:F)",value:B.range||"",onChange:qe=>et(re,"range",qe.target.value),className:"h-7 text-xs rounded-lg w-32"})]}),o.jsxs("div",{className:"flex flex-col gap-1.5 p-2 rounded-lg border border-border/40 bg-muted/20",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(Je,{className:"text-[10px] uppercase font-bold text-muted-foreground",children:"Columns Mapping (A, B, C...)"}),o.jsxs(ae,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-[10px] px-2 py-0",onClick:()=>{const qe=[...B.columns||[],""];et(re,"columns",qe)},children:[o.jsx(Wa,{className:"w-3 h-3 mr-1"})," Add Col"]})]}),(B.columns||[]).map((qe,ft)=>o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"text-[10px] font-mono text-muted-foreground w-4 flex-shrink-0 text-center",children:String.fromCharCode(65+ft)}),o.jsx(je,{placeholder:"e.g. {Date} or Static Text",value:qe,onChange:Zt=>{const Ve=[...B.columns||[]];Ve[ft]=Zt.target.value,et(re,"columns",Ve)},className:"h-7 text-xs rounded-lg font-mono flex-1"}),o.jsx("button",{type:"button",onClick:()=>{const Zt=(B.columns||[]).filter((Ve,en)=>en!==ft);et(re,"columns",Zt)},className:"text-muted-foreground hover:text-destructive p-1",children:o.jsx(zn,{className:"w-3 h-3"})})]},ft)),(!B.columns||B.columns.length===0)&&o.jsx("div",{className:"text-[10px] text-muted-foreground italic text-center py-1",children:"No explicit mapping provided. Folio will auto-map by reading header row from the sheet template."})]})]})]})]},re)})})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(Je,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Tags"}),o.jsx(je,{placeholder:"finance, cars (comma-sep)",value:J.tags,onChange:B=>pe({...J,tags:B.target.value}),className:"h-8 text-xs rounded-xl border-border/40 bg-background"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(Je,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Priority"}),o.jsx(je,{type:"number",min:1,max:999,value:J.priority,onChange:B=>pe({...J,priority:Number(B.target.value)}),className:"h-8 text-xs rounded-xl border-border/40 bg-background"})]})]}),Me&&o.jsx("p",{className:"text-[10px] text-destructive",children:'"Append to Google Sheet" actions require a Spreadsheet ID or Google Sheet URL.'}),o.jsxs("div",{className:"flex gap-2 pt-1",children:[o.jsx(ae,{size:"sm",onClick:at,disabled:se||!J.name.trim()||Me,className:"flex-1 h-8 rounded-xl font-black text-[10px] uppercase tracking-widest gap-1.5",children:se?o.jsx(it,{className:"w-3 h-3 animate-spin"}):o.jsxs(o.Fragment,{children:[o.jsx(Wa,{className:"w-3 h-3"}),"Create Policy"]})}),o.jsx(ae,{size:"sm",variant:"outline",onClick:()=>Y(!1),className:"h-8 px-3 rounded-xl",children:"Cancel"})]})]}),l?o.jsxs("div",{className:"flex items-center justify-center py-16 text-muted-foreground",children:[o.jsx(it,{className:"w-6 h-6 animate-spin mr-3"}),"Loading policies..."]}):s.length===0?o.jsxs(jn,{className:"rounded-2xl border-dashed",children:[o.jsx(Im,{className:"h-4 w-4"}),o.jsx(_n,{className:"text-sm",children:"No policies yet. Use the Magic Composer above to create your first one."})]}):o.jsx("div",{className:"space-y-2",children:s.map(B=>o.jsxs("div",{className:ge("rounded-2xl border bg-card/50 shadow-sm overflow-hidden transition-all",B.metadata.enabled===!1&&"opacity-60"),children:[o.jsxs("div",{className:"flex items-center gap-3 px-5 py-4",children:[o.jsx("button",{title:B.metadata.enabled===!1?"Enable policy":"Disable policy",onClick:()=>q(B),className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:B.metadata.enabled===!1?o.jsx(lA,{className:"w-5 h-5 text-muted-foreground"}):o.jsx(uA,{className:"w-5 h-5 text-primary"})}),o.jsx("div",{className:"flex-1 min-w-0",children:me===B.metadata.id&&ye?o.jsxs("div",{className:"space-y-2",onClick:re=>re.stopPropagation(),children:[o.jsx(je,{value:ye.name,onChange:re=>_e({...ye,name:re.target.value}),placeholder:"Policy name",className:"h-7 text-sm font-semibold"}),o.jsx(je,{value:ye.description,onChange:re=>_e({...ye,description:re.target.value}),placeholder:"Description",className:"h-7 text-xs"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(je,{value:ye.tags,onChange:re=>_e({...ye,tags:re.target.value}),placeholder:"Tags (comma-separated)",className:"h-7 text-xs flex-1"}),o.jsx(je,{type:"number",value:ye.priority,onChange:re=>_e({...ye,priority:Number(re.target.value)}),placeholder:"Priority",className:"h-7 text-xs w-20",min:1,max:999})]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx("span",{className:"font-bold text-sm truncate",children:B.metadata.name}),o.jsxs(Pt,{variant:"outline",className:"text-[9px] shrink-0",children:["P",B.metadata.priority]}),(B.metadata.learning_examples??0)>0&&o.jsxs(Pt,{variant:"secondary",className:"text-[9px] shrink-0",children:["Learned ",B.metadata.learning_examples]}),B.metadata.tags?.map(re=>o.jsxs(Pt,{variant:"secondary",className:"text-[9px] gap-1 shrink-0",children:[o.jsx(du,{className:"w-2.5 h-2.5"}),re]},re))]}),o.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:B.metadata.description})]})}),o.jsx("div",{className:"flex items-center gap-1 shrink-0",children:me===B.metadata.id?o.jsxs(o.Fragment,{children:[o.jsx(ae,{size:"sm",variant:"default",className:"h-7 px-2 text-xs",onClick:()=>ze(B.metadata.id),children:"Save"}),o.jsx(ae,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs",onClick:ie,children:"Cancel"})]}):o.jsxs(o.Fragment,{children:[o.jsx("button",{title:"Edit metadata",onClick:()=>fe(B),className:"text-muted-foreground hover:text-foreground transition-colors p-1",children:o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-4 h-4",children:[o.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),o.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),o.jsx("button",{title:"Re-compose with AI",onClick:()=>Be(B),className:"text-muted-foreground hover:text-primary transition-colors p-1",children:o.jsx(Cs,{className:"w-4 h-4"})}),o.jsx("button",{className:"text-muted-foreground hover:text-foreground transition-colors p-1",onClick:()=>N(_===B.metadata.id?null:B.metadata.id),children:_===B.metadata.id?o.jsx(lu,{className:"w-4 h-4"}):o.jsx(Bo,{className:"w-4 h-4"})}),o.jsx("button",{onClick:()=>ue(B.metadata.id),className:"text-muted-foreground hover:text-destructive transition-colors p-1",children:o.jsx(el,{className:"w-4 h-4"})})]})})]}),_===B.metadata.id&&o.jsxs("div",{className:"border-t px-5 py-4 bg-muted/20 space-y-3 animate-in slide-in-from-top-2 duration-200",children:[o.jsxs("div",{className:"grid grid-cols-3 gap-3 text-xs",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"font-bold uppercase tracking-widest text-[9px] text-muted-foreground mb-1",children:["Match (",B.spec.match.strategy,")"]}),B.spec.match.conditions.map((re,De)=>o.jsxs("div",{className:"text-muted-foreground",children:[o.jsx("span",{className:"font-mono bg-muted px-1 rounded text-[10px]",children:re.type})," ",Array.isArray(re.value)?re.value.join(", "):re.value]},De))]}),o.jsxs("div",{children:[o.jsx("div",{className:"font-bold uppercase tracking-widest text-[9px] text-muted-foreground mb-1",children:"Extract"}),B.spec.extract?.map(re=>o.jsxs("div",{className:"text-muted-foreground",children:[o.jsx("span",{className:"font-mono bg-muted px-1 rounded text-[10px]",children:re.key})," ","(",re.type,")",re.required?" *":""]},re.key))??o.jsx("span",{className:"text-muted-foreground/60",children:"—"})]}),o.jsxs("div",{children:[o.jsx("div",{className:"font-bold uppercase tracking-widest text-[9px] text-muted-foreground mb-1",children:"Actions"}),B.spec.actions?.map((re,De)=>o.jsxs("div",{className:"text-muted-foreground",children:[o.jsx("span",{className:"font-mono bg-muted px-1 rounded text-[10px]",children:re.type})," ",Ut(re)]},De))??o.jsx("span",{className:"text-muted-foreground/60",children:"—"})]})]}),(B.metadata.learning_examples??0)>0&&o.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Learned examples: ",B.metadata.learning_examples,B.metadata.learning_last_at?` · last on ${new Date(B.metadata.learning_last_at).toLocaleDateString()}`:""]})]})]},B.metadata.id))})]})]}),k==="packs"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Import curated policy bundles to instantly configure Folio for common use cases."}),o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:R6.map(B=>o.jsxs("div",{className:"rounded-2xl border bg-card/60 p-5 space-y-3 hover:border-primary/30 hover:shadow-md transition-all group",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsx("p",{className:"font-black text-sm",children:B.name}),o.jsxs(Pt,{variant:"outline",className:"text-[9px] shrink-0",children:[B.policies," policies"]})]}),o.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:B.description})]}),o.jsx("div",{className:"flex flex-wrap gap-1",children:B.tags.map(re=>o.jsxs(Pt,{variant:"secondary",className:"text-[9px] gap-1",children:[o.jsx(du,{className:"w-2.5 h-2.5"}),re]},re))}),o.jsxs(ae,{size:"sm",variant:"outline",className:"w-full h-8 rounded-xl font-black text-[10px] uppercase tracking-widest group-hover:border-primary/40 transition-all",onClick:()=>ce.info(`"${B.name}" import coming soon!`),children:[o.jsx(RC,{className:"w-3 h-3 mr-2"}),"Import Pack"]})]},B.id))})]})]})}function Xa(t){return!t||typeof t!="object"||Array.isArray(t)?null:t}function Wb(t){const e=[];for(const s of t){const r=Xa(s);if(!r)continue;const l=Xa(r.metadata)??{},u=Xa(r.spec)??{},d=Array.isArray(u.actions)?u.actions:[],h=typeof l.id=="string"?l.id.trim():"";if(!h)continue;const m=d.map(g=>{const y=Xa(g);return typeof y?.type=="string"?y.type.trim():""}).filter(g=>g==="append_to_google_sheet"||g==="webhook"||g==="copy_to_gdrive"||g==="copy"||g==="log_csv"||g==="notify");e.push({id:h,name:typeof l.name=="string"?l.name:h,priority:typeof l.priority=="number"?l.priority:100,riskyActions:m,learningExamples:typeof l.learning_examples=="number"?l.learning_examples:0,learningLastAt:typeof l.learning_last_at=="string"?l.learning_last_at:null})}return e.sort((s,r)=>r.priority-s.priority),e}function M6(t){if(!Array.isArray(t)||t.length===0)return null;const s=[...t].reverse().find(h=>{const m=String(h?.step??"").toLowerCase();return m.includes("learned fallback")||m.includes("learned policy candidate selected")});if(!s)return null;const r=String(s.step??"").toLowerCase(),l=Xa(s.details);if(!l)return null;const u=typeof l.reason=="string"?l.reason:r.includes("candidate selected")?"accepted":void 0,d=Xa(l.bestCandidate)??(typeof l.policyId=="string"||typeof l.score=="number"||typeof l.support=="number"?{policyId:l.policyId,score:l.score,support:l.support}:void 0);return{reason:u,evaluatedPolicies:typeof l.evaluatedPolicies=="number"?l.evaluatedPolicies:void 0,evaluatedSamples:typeof l.evaluatedSamples=="number"?l.evaluatedSamples:void 0,bestCandidate:d,topCandidates:Array.isArray(l.topCandidates)?l.topCandidates.map(h=>Xa(h)).filter(h=>!!h):void 0}}function D6(t){if(!t)return"No learned candidate details available yet.";switch(t){case"accepted":return"Learned fallback selected a policy candidate.";case"no_policy_ids":return"No candidate policies available for learned fallback.";case"no_document_features":return"Document had insufficient signals for learned fallback scoring.";case"no_feedback_samples":return"No learned examples yet. Match at least one document with learning enabled.";case"no_valid_samples":return"Learned examples exist but were too sparse to score.";case"score_below_threshold":return"A candidate was found but confidence stayed below threshold.";case"read_error":return"Learned fallback could not read feedback history.";default:return t.replace(/_/g," ")}}function P6({status:t}){return{pending:o.jsx(Qo,{className:"w-4 h-4 text-muted-foreground"}),processing:o.jsx(it,{className:"w-4 h-4 text-blue-500 animate-spin"}),matched:o.jsx(os,{className:"w-4 h-4 text-emerald-500"}),no_match:o.jsx(em,{className:"w-4 h-4 text-amber-500"}),duplicate:o.jsx(em,{className:"w-4 h-4 text-emerald-500"}),error:o.jsx(Lw,{className:"w-4 h-4 text-destructive"})}[t]??null}function ia({children:t}){return o.jsx("div",{className:"text-[9px] font-bold uppercase tracking-widest text-muted-foreground mb-1.5",children:t})}function z6(t){const e=[];t.status==="no_match"?e.push(`I have a document named "${t.filename}" that wasn't matched by any policy.`):e.push(`I have a document named "${t.filename}" that matched a policy, but I want to create a better, more specific policy for it.`),t.mime_type&&e.push(`It is a ${t.mime_type} file.`);const s=t.extracted?Object.entries(t.extracted).filter(([r,l])=>r!=="_enrichment"&&l!=null):[];if(s.length>0){const r=s.map(([l,u])=>`${l}: ${String(u)}`).join(", ");e.push(`Partial data already extracted: ${r}.`)}return e.push("Create a policy to handle this exact type of document — infer the document type, define strict match conditions, extract key fields, and route it to an appropriate folder."),e.join(" ")}function Jb(t){if(t==null)return"null";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}const L6=["issuer","vendor","sender","document_type","date","due_date","amount","total","currency"];function U6({extracted:t}){const e=L6.filter(s=>t[s]!=null&&String(t[s]).trim()!=="").map(s=>({key:s,value:String(t[s])}));return e.length===0?null:o.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.map(({key:s,value:r})=>o.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] px-2 py-0.5 rounded-full bg-muted border",children:[o.jsx("span",{className:"text-muted-foreground font-mono",children:s}),o.jsx("span",{className:"font-medium",children:r})]},s))})}function B6({tags:t,onChange:e}){const[s,r]=v.useState(""),l=v.useRef(null),u=m=>e(t.filter(g=>g!==m)),d=()=>{const m=s.toLowerCase().trim().replace(/\s+/g,"-");if(!m||t.includes(m)){r("");return}e([...t,m]),r("")},h=m=>{m.key==="Enter"||m.key===","?(m.preventDefault(),d()):m.key==="Backspace"&&!s&&t.length>0&&e(t.slice(0,-1))};return o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 rounded-xl border px-3 py-2 bg-background min-h-[36px] cursor-text",role:"button",tabIndex:0,onClick:()=>l.current?.focus(),onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),l.current?.focus())},children:[t.map(m=>o.jsxs("span",{className:ge("inline-flex items-center gap-1 text-[10px] px-2 py-0.5 rounded-full border",kp(m)),children:[m,o.jsx("button",{onClick:g=>{g.stopPropagation(),u(m)},className:"ml-0.5 opacity-60 hover:opacity-100 transition-opacity","aria-label":`Remove ${m}`,children:o.jsx(zn,{className:"w-2.5 h-2.5"})})]},m)),o.jsx("input",{ref:l,value:s,onChange:m=>r(m.target.value),onKeyDown:h,onBlur:d,placeholder:t.length?"":"Add tags…",className:"flex-1 min-w-[80px] bg-transparent text-xs outline-none placeholder:text-muted-foreground/50"}),s&&o.jsx("button",{onClick:d,className:"text-muted-foreground hover:text-foreground transition-colors",children:o.jsx(Wa,{className:"w-3 h-3"})})]})}function V6({ingestion:t,onClose:e,onRerun:s,onTagsChange:r,onComposePolicy:l,onManualMatch:u}){const d=t.extracted&&Object.keys(t.extracted).length>0?t.extracted:null,h=d&&typeof d._enrichment=="object"&&d._enrichment!==null?d._enrichment:null,m=t.actions_taken?.length?t.actions_taken:null,[g,y]=v.useState(t.summary??null),[x,w]=v.useState(!1),[S,E]=v.useState([]),[j,_]=v.useState(!1),[N,k]=v.useState(""),[C,A]=v.useState(!0),[D,U]=v.useState(!0),[V,R]=v.useState(!1),[P,Z]=v.useState(!1),[te,me]=v.useState(null),[Ee,ye]=v.useState(!1),[_e,$]=v.useState(!1),[Y,J]=v.useState(null),[pe,se]=v.useState([]),[M,L]=v.useState(null),[W,ne]=v.useState(!1),oe=t.status!=="pending"&&t.status!=="processing",ue=!!u&&!t.policy_name&&t.status!=="pending"&&t.status!=="processing",q=M6(t.trace);v.useEffect(()=>{if(!oe||g)return;let le=!1;return(async()=>{w(!0);try{const de=(await un()?.auth.getSession())?.data?.session?.access_token??null,Me=await Te.summarizeIngestion(t.id,de);if(le)return;Me.data?.summary&&y(Me.data.summary)}catch{}finally{le||w(!1)}})(),()=>{le=!0}},[t.id]),v.useEffect(()=>{if(!ue)return;let le=!1;return(async()=>{_(!0),me(null);try{const de=(await un()?.auth.getSession())?.data?.session?.access_token??null,Me=await Te.getPolicies(de);if(le)return;if(Me?.error){const Ut=typeof Me.error=="string"?Me.error:Me.error.message;throw new Error(Ut||"Failed to load policies.")}const at=Wb(Me?.data?.policies??[]);E(at),k(Ut=>Ut||at[0]?.id||"")}catch{le||(E([]),me("Failed to load policies."))}finally{le||_(!1)}})(),()=>{le=!0}},[ue,t.id]);const fe=v.useCallback(async()=>{if(!u||!N||P)return;const Fe=S.find(de=>de.id===N)?.riskyActions??[];if(D&&Fe.length>0&&!V){me(`Re-run may trigger side-effect actions: ${Fe.join(", ")}. Enable side-effect confirmation to continue.`);return}Z(!0),me(null);try{await u({policyId:N,learn:C,rerun:D,allowSideEffects:D?V:!1}),J(null),se([]),L(null)}catch(de){const Me=de instanceof Error?de.message:String(de);me(Me||"Failed to assign policy.")}finally{Z(!1)}},[V,P,C,u,S,D,N]),ie=v.useCallback(async()=>{if(!(!N||Ee||_e)){ye(!0),L(null),J(null),se([]);try{const Fe=(await un()?.auth.getSession())?.data?.session?.access_token??null,de=await Te.suggestPolicyRefinement(t.id,{policyId:N},Fe);if(de?.error){const Ut=typeof de.error=="string"?de.error:de.error.message;throw new Error(Ut||"Unable to suggest refinement.")}const Me=de?.data?.suggestion?.policy;if(!Me)throw new Error("No policy refinement draft was returned.");const at=Array.isArray(de?.data?.suggestion?.rationale)?de.data.suggestion.rationale.map(Ut=>String(Ut).trim()).filter(Boolean):[];J(Me),se(at),ne(!1)}catch(le){const Fe=le instanceof Error?le.message:String(le);L(Fe||"Unable to suggest refinement.")}finally{ye(!1)}}},[t.id,_e,Ee,N]),ze=v.useCallback(async()=>{if(!(!Y||_e)){$(!0),L(null);try{const Fe=(await un()?.auth.getSession())?.data?.session?.access_token??null,de=await Te.savePolicy(Y,Fe);if(de?.error){const at=typeof de.error=="string"?de.error:de.error.message;throw new Error(at||"Failed to apply refinement.")}ce.success(`Applied refinement to policy "${Y.metadata.name}".`),J(null),se([]),L(null),ne(!1);const Me=await Te.getPolicies(Fe);if(!Me?.error){const at=Wb(Me?.data?.policies??[]);E(at)}}catch(le){const Fe=le instanceof Error?le.message:String(le);L(Fe||"Failed to apply refinement.")}finally{$(!1)}}},[_e,Y]),Be=S.find(le=>le.id===N),kt=Be?.riskyActions??[],et=v.useCallback(le=>{le.target===le.currentTarget&&e()},[e]);return o.jsx("div",{className:"fixed inset-0 z-50 bg-black/40 backdrop-blur-sm flex items-center justify-center p-4",role:"button",tabIndex:0,onClick:et,onKeyDown:le=>{le.key==="Escape"&&(le.preventDefault(),e()),(le.key==="Enter"||le.key===" ")&&le.target===le.currentTarget&&(le.preventDefault(),e())},children:o.jsxs("div",{className:"bg-background border rounded-2xl shadow-2xl w-full max-w-xl flex flex-col overflow-hidden animate-in zoom-in-95 duration-200",children:[o.jsxs("div",{className:"flex items-start gap-3 px-6 pt-5 pb-4 border-b",children:[o.jsx("div",{className:"w-8 h-8 rounded-lg bg-muted flex items-center justify-center shrink-0 mt-0.5",children:o.jsx(Vm,{className:"w-4 h-4 text-muted-foreground"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("h2",{className:"font-bold text-sm truncate",title:t.filename,children:t.filename}),o.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[t.source," · ",new Date(t.created_at).toLocaleString(),t.file_size&&` · ${(t.file_size/1024).toFixed(1)}KB`]})]}),o.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[o.jsx(P6,{status:t.status}),o.jsx("button",{onClick:e,className:"text-muted-foreground hover:text-foreground transition-colors",children:o.jsx(zn,{className:"w-4 h-4"})})]})]}),o.jsxs("div",{className:"px-6 py-5 space-y-5 overflow-y-auto max-h-[65vh]",children:[oe&&o.jsxs("div",{children:[o.jsx(ia,{children:o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx(Cs,{className:"w-2.5 h-2.5"}),"Summary"]})}),d&&o.jsx("div",{className:"mb-2",children:o.jsx(U6,{extracted:d})}),x?o.jsxs("div",{className:"space-y-2",children:[o.jsx("div",{className:"h-3 rounded bg-muted animate-pulse w-full"}),o.jsx("div",{className:"h-3 rounded bg-muted animate-pulse w-5/6"}),o.jsx("div",{className:"h-3 rounded bg-muted animate-pulse w-4/6"})]}):g?o.jsx("p",{className:"text-xs text-foreground/80 leading-relaxed",children:g}):o.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No summary available."})]}),!oe&&o.jsx("div",{className:"rounded-xl bg-muted/40 border px-4 py-3 text-xs text-muted-foreground text-center",children:"Summary will be available after processing completes."}),o.jsxs("div",{children:[o.jsx(ia,{children:o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx(du,{className:"w-2.5 h-2.5"}),"Tags"]})}),o.jsx(B6,{tags:t.tags??[],onChange:r}),o.jsx("p",{className:"text-[10px] text-muted-foreground mt-1.5",children:"Enter to add · Backspace to remove · spaces become hyphens"})]}),o.jsxs("div",{children:[o.jsx(ia,{children:"Policy Matched"}),t.policy_name?o.jsx(Pt,{variant:"secondary",children:t.policy_name}):o.jsxs("div",{className:"space-y-2",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"No policy matched"}),ue&&o.jsxs("div",{className:"rounded-xl border bg-muted/20 p-3 space-y-2",children:[o.jsx("p",{className:"text-[10px] uppercase tracking-wider font-semibold text-muted-foreground",children:"Assign To Existing Policy"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("select",{className:"flex-1 h-8 rounded-lg border bg-background px-2 text-xs outline-none focus:ring-2 focus:ring-primary/30",value:N,onChange:le=>{k(le.target.value),R(!1),me(null),J(null),se([]),L(null)},disabled:j||P||S.length===0,children:S.length===0?o.jsx("option",{value:"",children:j?"Loading policies…":"No active policies"}):S.map(le=>o.jsx("option",{value:le.id,children:le.learningExamples>0?`${le.name} (${le.learningExamples} learned)`:le.name},le.id))}),o.jsx(ae,{variant:"outline",size:"sm",className:"h-8 rounded-lg",disabled:P||j||!N,onClick:fe,children:P?o.jsx(it,{className:"w-3.5 h-3.5 animate-spin"}):"Match To Policy"}),o.jsx(ae,{variant:"outline",size:"sm",className:"h-8 rounded-lg",disabled:Ee||_e||j||!N,onClick:ie,children:Ee?o.jsx(it,{className:"w-3.5 h-3.5 animate-spin"}):"Suggest Refinement"})]}),Be&&o.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Learned examples for this policy: ",Be.learningExamples,Be.learningLastAt?` · last on ${new Date(Be.learningLastAt).toLocaleDateString()}`:""]}),o.jsxs("label",{className:"inline-flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[o.jsx("input",{type:"checkbox",className:"rounded border-muted-foreground/40",checked:C,onChange:le=>A(le.target.checked),disabled:P}),"Learn from this match"]}),o.jsxs("label",{className:"inline-flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[o.jsx("input",{type:"checkbox",className:"rounded border-muted-foreground/40",checked:D,onChange:le=>{U(le.target.checked),R(!1),me(null)},disabled:P}),"Re-run ingestion now (recommended)"]}),D&&kt.length>0&&o.jsxs("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/10 p-2 text-[11px] text-amber-700 space-y-1",children:[o.jsxs("p",{children:["This policy has side-effect actions: ",kt.join(", ")]}),o.jsxs("label",{className:"inline-flex items-center gap-1.5 text-[11px]",children:[o.jsx("input",{type:"checkbox",className:"rounded border-amber-500/40",checked:V,onChange:le=>R(le.target.checked),disabled:P}),"I understand this may create external writes on re-run"]})]}),(Y||M)&&o.jsxs("div",{className:"rounded-lg border border-primary/20 bg-primary/5 p-2.5 space-y-2",children:[o.jsx("p",{className:"text-[10px] uppercase tracking-wider font-semibold text-primary",children:"Policy Refinement Preview"}),M&&o.jsx("p",{className:"text-[11px] text-destructive",children:M}),Y&&o.jsxs(o.Fragment,{children:[o.jsxs("p",{className:"text-[11px] text-foreground/90",children:[Y.metadata.name," · ",Y.spec.match.conditions.length," match conditions · ",(Y.spec.extract??[]).length," extract fields"]}),pe.length>0&&o.jsx("div",{className:"space-y-1",children:pe.map((le,Fe)=>o.jsx("p",{className:"text-[10px] text-muted-foreground",children:le},`refine-rationale-${Fe}`))}),o.jsxs("div",{className:"flex gap-1.5",children:[o.jsx(ae,{variant:"outline",size:"sm",className:"h-7 rounded-lg text-[10px]",onClick:()=>ne(le=>!le),children:W?"Hide JSON":"Show JSON"}),o.jsx(ae,{size:"sm",className:"h-7 rounded-lg text-[10px]",onClick:ze,disabled:_e,children:_e?o.jsx(it,{className:"w-3.5 h-3.5 animate-spin"}):"Apply To Policy"}),o.jsx(ae,{variant:"ghost",size:"sm",className:"h-7 rounded-lg text-[10px]",onClick:()=>{J(null),se([]),L(null),ne(!1)},children:"Discard"})]}),W&&o.jsx("pre",{className:"rounded-md border border-border/40 bg-background p-2 text-[10px] overflow-auto max-h-48 whitespace-pre-wrap font-mono",children:JSON.stringify(Y,null,2)})]})]}),te&&o.jsx("p",{className:"text-[11px] text-destructive",children:te})]})]})]}),q&&o.jsxs("div",{children:[o.jsx(ia,{children:"Learning Diagnostics"}),o.jsxs("div",{className:"rounded-xl border bg-muted/20 px-4 py-3 space-y-1.5",children:[o.jsx("p",{className:"text-xs text-foreground/90",children:D6(q.reason)}),(q.evaluatedPolicies!==void 0||q.evaluatedSamples!==void 0)&&o.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Evaluated policies: ",q.evaluatedPolicies??0," · samples: ",q.evaluatedSamples??0]}),q.bestCandidate&&o.jsxs("p",{className:"text-[11px] text-muted-foreground font-mono",children:["Best: ",String(q.bestCandidate.policyId??"-")," · score ",String(q.bestCandidate.score??"-")," · support ",String(q.bestCandidate.support??"-"),q.bestCandidate.requiredScore!==void 0?` · needed ${String(q.bestCandidate.requiredScore)}`:""]})]})]}),d&&o.jsxs("div",{children:[o.jsx(ia,{children:"Extracted Data"}),o.jsx("div",{className:"rounded-xl border overflow-hidden",children:Object.entries(d).filter(([le])=>le!=="_enrichment").map(([le,Fe])=>o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 text-xs border-b last:border-0",children:[o.jsx("span",{className:"font-mono text-muted-foreground",children:le}),o.jsx("span",{className:"font-medium text-right max-w-[55%] truncate",children:Jb(Fe)})]},le))})]}),h&&Object.keys(h).length>0&&o.jsxs("div",{children:[o.jsx(ia,{children:"Enrichment Data"}),o.jsx("div",{className:"rounded-xl border overflow-hidden",children:Object.entries(h).map(([le,Fe])=>o.jsxs("div",{className:"px-4 py-2 text-xs border-b last:border-0",children:[o.jsx("div",{className:"font-mono text-muted-foreground mb-1",children:le}),o.jsx("pre",{className:"font-medium whitespace-pre-wrap break-all",children:Jb(Fe)})]},le))})]}),m&&o.jsxs("div",{children:[o.jsx(ia,{children:"Actions Taken"}),o.jsx("ul",{className:"space-y-1",children:m.map((le,Fe)=>o.jsxs("li",{className:"flex items-center gap-2 text-xs",children:[o.jsx(os,{className:"w-3 h-3 text-emerald-500 shrink-0"}),o.jsx("span",{className:"text-muted-foreground",children:String(le)})]},Fe))})]}),t.error_message&&o.jsxs("div",{children:[o.jsx(ia,{children:"Error"}),o.jsx("div",{className:"rounded-xl bg-destructive/5 border border-destructive/20 px-4 py-3",children:o.jsx("p",{className:"text-xs text-destructive font-mono break-all",children:t.error_message})})]}),!d&&!m&&!t.error_message&&oe&&!x&&!g&&o.jsx("p",{className:"text-xs text-muted-foreground text-center py-4",children:"No extracted data or actions recorded."})]}),o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t bg-muted/20",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(ae,{variant:"outline",size:"sm",onClick:s,className:"gap-2 rounded-xl",children:[o.jsx(ma,{className:"w-3.5 h-3.5"}),"Re-run"]}),l&&o.jsxs(ae,{variant:"outline",size:"sm",onClick:()=>l(z6(t)),className:"gap-2 rounded-xl border-primary/30 text-primary hover:bg-primary/5 hover:text-primary",children:[o.jsx(Cs,{className:"w-3.5 h-3.5"}),"Create Policy"]})]}),o.jsx(ae,{variant:"ghost",size:"sm",onClick:e,className:"rounded-xl",children:"Close"})]})]})})}function I6({children:t}){return o.jsx("h3",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-3",children:t})}function $6({ingestion:t,onClose:e}){return o.jsx("div",{className:"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm flex items-center justify-center p-4 animate-in fade-in duration-200",children:o.jsxs("div",{className:"bg-card w-full max-w-3xl rounded-2xl shadow-xl border overflow-hidden flex flex-col max-h-[90vh]",children:[o.jsxs("div",{className:"px-6 py-4 border-b flex items-center justify-between bg-muted/20",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-8 h-8 rounded-lg bg-emerald-500/10 flex items-center justify-center",children:o.jsx(Io,{className:"w-4 h-4 text-emerald-500"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"font-semibold",children:"AI Processing Trace"}),o.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[400px]",title:t.filename,children:t.filename})]})]}),o.jsx("button",{onClick:e,className:"p-2 -mr-2 text-muted-foreground hover:text-foreground hover:bg-muted rounded-xl transition-colors",children:o.jsx(zn,{className:"w-4 h-4"})})]}),o.jsx("div",{className:"p-6 overflow-y-auto space-y-6",children:t.trace&&t.trace.length>0?o.jsxs("div",{children:[o.jsx(I6,{children:"Execution Log"}),o.jsx("div",{className:"rounded-xl bg-zinc-950 text-emerald-400 p-4 font-mono text-[11px] space-y-3 overflow-x-auto border border-zinc-800 shadow-inner max-h-[60vh] overflow-y-auto",children:[...t.trace].reverse().map((s,r)=>o.jsxs("div",{className:`flex gap-3 leading-relaxed ${s.step.startsWith("---")?"text-zinc-500 my-4 text-center justify-center":""}`,children:[!s.step.startsWith("---")&&o.jsx("span",{className:"opacity-40 shrink-0",children:new Date(s.timestamp).toLocaleTimeString([],{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}),o.jsxs("div",{className:s.step.startsWith("---")?"font-bold uppercase tracking-widest":"",children:[o.jsx("span",{className:"font-semibold text-zinc-100",children:s.step}),s.details&&Object.keys(s.details).length>0&&o.jsxs("pre",{className:"mt-1 flex text-emerald-500/80 whitespace-pre-wrap text-[10px]",children:[o.jsx("span",{className:"select-none opacity-30 mr-2",children:"↳"}),JSON.stringify(s.details,null,2)]})]})]},r))})]}):o.jsx("p",{className:"text-sm text-muted-foreground text-center py-12 border-2 border-dashed rounded-xl",children:"No trace logs available for this ingestion."})})]})})}const Qb=["bg-blue-500/10 text-blue-600 border-blue-500/20","bg-emerald-500/10 text-emerald-600 border-emerald-500/20","bg-amber-500/10 text-amber-700 border-amber-500/20","bg-violet-500/10 text-violet-600 border-violet-500/20","bg-rose-500/10 text-rose-600 border-rose-500/20","bg-cyan-500/10 text-cyan-600 border-cyan-500/20","bg-orange-500/10 text-orange-600 border-orange-500/20"];function kp(t){let e=0;for(const s of t)e=e*31+s.charCodeAt(0)>>>0;return Qb[e%Qb.length]}function q6({status:t}){const e={pending:{label:"Pending",icon:o.jsx(Qo,{className:"w-3 h-3"}),cls:"bg-muted text-muted-foreground"},processing:{label:"Processing",icon:o.jsx(it,{className:"w-3 h-3 animate-spin"}),cls:"bg-blue-500/10 text-blue-500"},matched:{label:"Matched",icon:o.jsx(os,{className:"w-3 h-3"}),cls:"bg-emerald-500/10 text-emerald-500"},no_match:{label:"No Match",icon:o.jsx(em,{className:"w-3 h-3"}),cls:"bg-amber-500/10 text-amber-600"},error:{label:"Error",icon:o.jsx(Lw,{className:"w-3 h-3"}),cls:"bg-destructive/10 text-destructive"},duplicate:{label:"Duplicate",icon:o.jsx(Qk,{className:"w-3 h-3"}),cls:"bg-violet-500/10 text-violet-500"}},s=e[t]??e.pending;return o.jsxs("span",{className:ge("inline-flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded-full",s.cls),children:[s.icon,s.label]})}function H6({source:t}){const e={upload:"📄",dropzone:"📂",email:"📧",url:"🔗"};return o.jsxs("span",{className:"text-xs text-muted-foreground",children:[e[t]??"📄"," ",t]})}function G6(t){return t?t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/(1024*1024)).toFixed(1)}MB`:""}function F6({tags:t,activeFilters:e,onToggle:s}){if(!t.length)return null;const r=t.slice(0,3),l=t.length-r.length;return o.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[r.map(u=>o.jsx("button",{onClick:d=>s(u,d),className:ge("inline-flex items-center text-[9px] px-1.5 py-0 rounded-full border transition-all",kp(u),e.has(u)&&"ring-1 ring-current font-semibold"),children:u},u)),l>0&&o.jsxs("span",{className:"text-[9px] text-muted-foreground",children:["+",l]})]})}function K6({allTags:t,activeFilters:e,onToggle:s,onClear:r}){return t.length?o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground shrink-0",children:[o.jsx(du,{className:"w-3 h-3"}),o.jsx("span",{children:"Filter by tag:"})]}),o.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:t.map(l=>o.jsx("button",{onClick:()=>s(l),className:ge("inline-flex items-center text-[10px] px-2 py-0.5 rounded-full border transition-all",kp(l),e.has(l)?"ring-1 ring-current font-semibold shadow-sm":"opacity-70 hover:opacity-100"),children:l},l))}),e.size>0&&o.jsxs("button",{onClick:r,className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors",children:[o.jsx(zn,{className:"w-3 h-3"}),"Clear"]})]}):null}const Vf=20;function Y6({page:t,total:e,pageSize:s,onPage:r}){const l=Math.max(1,Math.ceil(e/s));if(l<=1&&e<=s)return null;const u=e===0?0:(t-1)*s+1,d=Math.min(t*s,e);return o.jsxs("div",{className:"flex items-center justify-between px-1 pt-2",children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:e===0?"No results":`${u}–${d} of ${e}`}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(ae,{variant:"outline",size:"sm",className:"h-7 px-2 rounded-lg",onClick:()=>r(t-1),disabled:t<=1,children:o.jsx(Jo,{className:"w-3.5 h-3.5"})}),o.jsxs("span",{className:"text-xs text-muted-foreground px-2",children:["Page ",t," of ",l]}),o.jsx(ae,{variant:"outline",size:"sm",className:"h-7 px-2 rounded-lg",onClick:()=>r(t+1),disabled:t>=l,children:o.jsx(di,{className:"w-3.5 h-3.5"})})]})]})}function X6({onComposePolicyForDoc:t}){const[e,s]=v.useState([]),[r,l]=v.useState(0),[u,d]=v.useState(1),[h,m]=v.useState(!0),[g,y]=v.useState(!1),[x,w]=v.useState(!1),[S,E]=v.useState(null),[j,_]=v.useState(null),[N,k]=v.useState(null),[C,A]=v.useState(new Set),[D,U]=v.useState([]),[V,R]=v.useState(""),[P,Z]=v.useState(""),te=v.useRef(null),me=v.useRef(null),Ee=L=>{R(L),te.current&&clearTimeout(te.current),te.current=setTimeout(()=>{Z(L),d(1)},300)},ye=v.useCallback(async(L=u)=>{if(S===null)return;m(!0);const W=await Te.getIngestions({page:L,pageSize:Vf,q:P||void 0},S),ne=W?.data?.ingestions??[];s(ne),l(W?.data?.total??0),m(!1),U(oe=>[...new Set([...oe,...ne.flatMap(q=>q.tags??[])])].sort())},[S,P,u]);v.useEffect(()=>{const L=un();L&&L.auth.getSession().then(({data:W})=>{E(W.session?.access_token??null)})},[]),v.useEffect(()=>{S!==null&&ye(u)},[S,P,u]);const _e=v.useMemo(()=>C.size?e.filter(L=>[...C].every(W=>L.tags?.includes(W))):e,[e,C]),$=L=>{A(W=>{const ne=new Set(W);return ne.has(L)?ne.delete(L):ne.add(L),ne}),d(1)},Y=async L=>{const W=Array.from(L);if(W.length){w(!0);try{for(const ne of W){ce.info(`Ingesting ${ne.name}…`);const oe=await Te.uploadDocument?.(ne,S);if(oe?.success)if(oe.ingestion?.status==="duplicate"){const ue=oe.ingestion.extracted?.original_filename??"a previous upload";ce.warning(`${ne.name} is a duplicate of "${ue}" — skipped.`)}else ce.success(`${ne.name} → ${oe.ingestion?.status}`);else ce.error(`Failed to ingest ${ne.name}`)}d(1),await ye(1)}finally{w(!1)}}},J=L=>{L.preventDefault(),y(!1),Y(L.dataTransfer.files)},pe=async(L,W)=>{W.stopPropagation(),await Te.rerunIngestion?.(L,S),ce.success("Re-running…"),await ye(u)},se=async(L,W)=>{if(W.stopPropagation(),!window.confirm("Delete this ingestion record?"))return;await Te.deleteIngestion?.(L,S),ce.success("Deleted.");const ne=r-1,oe=Math.max(1,Math.ceil(ne/Vf)),ue=Math.min(u,oe);d(ue),await ye(ue)},M=async(L,W)=>{s(ne=>ne.map(oe=>oe.id===L?{...oe,tags:W}:oe)),j?.id===L&&_(ne=>ne&&{...ne,tags:W}),await Te.updateIngestionTags(L,W,S),U(ne=>[...new Set([...ne,...W])].sort())};return o.jsxs("div",{className:"w-full mx-auto px-8 py-10 space-y-6 animate-in fade-in duration-500",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-9 h-9 rounded-xl bg-primary/10 flex items-center justify-center",children:o.jsx(Bw,{className:"w-5 h-5 text-primary"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-xl font-bold",children:"Funnel"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Document ingestion pipeline"})]})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(ae,{variant:"outline",size:"sm",onClick:()=>ye(u),className:"gap-2 rounded-xl",children:[o.jsx(ma,{className:"w-3.5 h-3.5"}),"Refresh"]}),o.jsxs(ae,{size:"sm",onClick:()=>me.current?.click(),disabled:x,className:"gap-2 rounded-xl",children:[x?o.jsx(it,{className:"w-3.5 h-3.5 animate-spin"}):o.jsx(tm,{className:"w-3.5 h-3.5"}),"Upload"]}),o.jsx("input",{ref:me,type:"file",multiple:!0,hidden:!0,onChange:L=>L.target.files&&Y(L.target.files)})]})]}),o.jsxs("div",{onDragOver:L=>{L.preventDefault(),y(!0)},onDragLeave:()=>y(!1),onDrop:J,onClick:()=>me.current?.click(),className:ge("rounded-2xl border-2 border-dashed transition-all cursor-pointer flex flex-col items-center justify-center gap-2 py-8",g?"border-primary bg-primary/5 scale-[1.01]":"border-muted-foreground/20 hover:border-primary/50 hover:bg-muted/30"),children:[o.jsx(tm,{className:ge("w-8 h-8 transition-colors",g?"text-primary":"text-muted-foreground/50")}),o.jsx("p",{className:"text-sm text-muted-foreground",children:g?"Drop to ingest":"Drag & drop files here, or click to browse"}),o.jsx("p",{className:"text-xs text-muted-foreground/60",children:".txt, .md, .pdf, .docx — up to 20MB"})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"relative",children:[o.jsx(qC,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground pointer-events-none"}),o.jsx("input",{type:"text",value:V,onChange:L=>Ee(L.target.value),placeholder:"Search filename, policy, summary…",className:"w-full pl-9 pr-9 py-2 text-sm rounded-xl border bg-background placeholder:text-muted-foreground/50 outline-none focus:ring-2 focus:ring-primary/30 transition"}),V&&o.jsx("button",{onClick:()=>{R(""),Z(""),d(1)},className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",children:o.jsx(zn,{className:"w-3.5 h-3.5"})})]}),D.length>0&&o.jsx(K6,{allTags:D,activeFilters:C,onToggle:$,onClear:()=>A(new Set)})]}),o.jsx("div",{className:"rounded-2xl border overflow-hidden",children:o.jsxs("table",{className:"w-full text-sm",children:[o.jsx("thead",{className:"bg-muted/40 border-b",children:o.jsxs("tr",{children:[o.jsx("th",{className:"text-left px-5 py-3 text-xs font-semibold text-muted-foreground",children:"File"}),o.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-muted-foreground",children:"Status"}),o.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-muted-foreground",children:"Policy"}),o.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-muted-foreground",children:"Source"}),o.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-muted-foreground",children:"Date"}),o.jsx("th",{className:"px-4 py-3"})]})}),o.jsx("tbody",{className:"divide-y",children:h?o.jsx("tr",{children:o.jsxs("td",{colSpan:6,className:"text-center py-12 text-muted-foreground",children:[o.jsx(it,{className:"w-5 h-5 animate-spin mx-auto mb-2"}),"Loading…"]})}):_e.length===0?o.jsx("tr",{children:o.jsxs("td",{colSpan:6,className:"text-center py-16 text-muted-foreground",children:[o.jsx(Vm,{className:"w-8 h-8 mx-auto mb-3 opacity-30"}),o.jsx("p",{className:"text-sm",children:P||C.size>0?"No documents match your search.":"No ingestions yet — upload a document above."}),(P||C.size>0)&&o.jsx("button",{className:"mt-2 text-xs text-primary hover:underline",onClick:()=>{R(""),Z(""),A(new Set),d(1)},children:"Clear filters"})]})}):_e.map(L=>o.jsxs("tr",{onClick:()=>_(L),className:ge("cursor-pointer transition-colors",L.status==="processing"?"animate-pulse bg-blue-500/5 hover:bg-blue-500/10":"hover:bg-muted/30"),children:[o.jsxs("td",{className:"px-5 py-3.5",children:[o.jsx("div",{className:"font-medium text-sm truncate max-w-[220px]",title:L.filename,children:L.filename}),L.status==="duplicate"?o.jsxs("div",{className:"text-xs text-violet-500/80 truncate max-w-[220px]",children:["↳ ",L.extracted?.original_filename??"previously processed"]}):L.file_size&&o.jsx("div",{className:"text-xs text-muted-foreground",children:G6(L.file_size)}),o.jsx(F6,{tags:L.tags??[],activeFilters:C,onToggle:(W,ne)=>{ne.stopPropagation(),$(W)}})]}),o.jsx("td",{className:"px-4 py-3.5",children:o.jsx(q6,{status:L.status})}),o.jsx("td",{className:"px-4 py-3.5",children:L.policy_name?o.jsx(Pt,{variant:"secondary",className:"text-[10px]",children:L.policy_name}):o.jsx("span",{className:"text-muted-foreground/50 text-xs",children:"—"})}),o.jsx("td",{className:"px-4 py-3.5",children:o.jsx(H6,{source:L.source})}),o.jsx("td",{className:"px-4 py-3.5 text-xs text-muted-foreground whitespace-nowrap",children:new Date(L.created_at).toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"})}),o.jsx("td",{className:"px-4 py-3.5",children:o.jsxs("div",{className:"flex items-center gap-1 justify-end",children:[o.jsx("button",{title:"View Processing Trace",onClick:W=>{W.stopPropagation(),k(L)},className:"text-muted-foreground hover:text-emerald-500 p-1 transition-colors",children:o.jsx(Io,{className:"w-3.5 h-3.5"})}),o.jsx("button",{title:"Re-run",onClick:W=>pe(L.id,W),className:"text-muted-foreground hover:text-foreground p-1 transition-colors",children:o.jsx(ma,{className:"w-3.5 h-3.5"})}),o.jsx("button",{title:"Delete",onClick:W=>se(L.id,W),className:"text-muted-foreground hover:text-destructive p-1 transition-colors",children:o.jsx(el,{className:"w-3.5 h-3.5"})}),o.jsx(di,{className:"w-3.5 h-3.5 text-muted-foreground/40"})]})})]},L.id))})]})}),o.jsx(Y6,{page:u,total:r,pageSize:Vf,onPage:L=>d(L)}),j&&o.jsx(V6,{ingestion:j,onClose:()=>_(null),onTagsChange:L=>M(j.id,L),onRerun:async()=>{await Te.rerunIngestion?.(j.id,S),await ye(u),_(null),ce.success("Re-running ingestion…")},onComposePolicy:t?L=>{_(null),t(L)}:void 0,onManualMatch:async({policyId:L,learn:W,rerun:ne,allowSideEffects:oe})=>{const ue=await Te.matchIngestionToPolicy(j.id,{policyId:L,learn:W,rerun:ne,allowSideEffects:oe},S);if(ue?.error){const fe=typeof ue.error=="string"?ue.error:ue.error.message;throw new Error(fe||"Failed to match ingestion to policy.")}const q=ue?.data?.ingestion;if(!q)throw new Error("Match succeeded but updated ingestion payload is missing.");q&&(s(fe=>fe.map(ie=>ie.id===q.id?q:ie)),_(q)),await ye(u),ne?ce.success(W?"Policy matched, learned, and re-run started.":"Policy matched and re-run started."):ce.success(W?"Policy match saved and learned.":"Policy match saved.")}}),N&&o.jsx($6,{ingestion:N,onClose:()=>k(null)})]})}function W6({activeSessionId:t,onSelectSession:e,refreshTrigger:s}){const[r,l]=v.useState([]),[u,d]=v.useState(!0),h=v.useCallback(async()=>{const y=un();if(!y)return null;const{data:x}=await y.auth.getSession();return x.session?.access_token??null},[]),m=v.useCallback(async()=>{try{const y=await h(),x=await Te.getChatSessions(y);x.data?.success&&l(x.data.sessions)}catch(y){console.error("Failed to fetch sessions",y)}finally{d(!1)}},[h]);v.useEffect(()=>{m()},[m,s]);const g=async(y,x)=>{y.stopPropagation();try{const w=await un();if(!w)return;const{error:S}=await w.from("chat_sessions").delete().eq("id",x);S||(l(E=>E.filter(j=>j.id!==x)),t===x&&e(null))}catch(w){console.error(w)}};return o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsx("div",{className:"p-3 border-b border-border bg-surface/15",children:o.jsxs("button",{onClick:()=>e(null),className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-primary/10 hover:bg-primary/20 text-primary rounded-xl transition-all font-semibold text-sm border border-primary/20 cursor-pointer",children:[o.jsx(Wa,{size:16}),"New Chat"]})}),o.jsx("div",{className:"flex-1 overflow-y-auto p-2 space-y-1 scrollbar-on-hover",children:u?o.jsx("div",{className:"p-4 text-center text-xs text-muted-foreground",children:"Loading..."}):r.length===0?o.jsxs("div",{className:"p-8 text-center text-muted-foreground",children:[o.jsx(cu,{size:24,className:"mx-auto opacity-20 mb-2"}),o.jsx("p",{className:"text-xs",children:"No chat history"})]}):r.map(y=>o.jsxs("div",{onClick:()=>e(y.id),className:`group flex items-center justify-between px-3 py-3 rounded-lg cursor-pointer transition-all text-sm ${t===y.id?"bg-primary/15 text-foreground ring-1 ring-primary/30 font-medium":"text-muted-foreground hover:bg-surface/50 hover:text-foreground"}`,children:[o.jsxs("div",{className:"flex items-center gap-2.5 overflow-hidden",children:[o.jsx(cu,{size:14,className:t===y.id?"text-primary":"opacity-50"}),o.jsx("span",{className:"truncate",children:y.title})]}),o.jsx("button",{onClick:x=>g(x,y.id),className:"opacity-0 group-hover:opacity-100 p-1.5 hover:bg-destructive/10 hover:text-destructive rounded transition-all",children:o.jsx(el,{size:12})})]},y.id))})]})}function J6({message:t}){const e=t.role==="user",s=r=>r.split(`
|
|
113
|
-
`).map((l,u)=>o.jsxs("span",{children:[l,o.jsx("br",{})]},u));return o.jsx("div",{className:`flex w-full ${e?"justify-end":"justify-start"}`,children:o.jsxs("div",{className:`flex gap-3 max-w-[85%] ${e?"flex-row-reverse":"flex-row"}`,children:[o.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center shrink-0 shadow-sm ${e?"bg-primary text-primary-foreground":"bg-surface border border-border shadow-inner text-foreground"}`,children:e?o.jsx(ku,{size:14,strokeWidth:2.5}):o.jsx(Zf,{size:14,className:"text-primary",strokeWidth:2.5})}),o.jsxs("div",{className:`flex flex-col ${e?"items-end":"items-start"}`,children:[o.jsx("div",{className:`px-4 py-3 rounded-2xl text-[13px] leading-relaxed shadow-sm ${e?"bg-primary text-primary-foreground rounded-tr-sm":"bg-surface border border-border/60 text-foreground rounded-tl-sm"}`,children:o.jsx("div",{className:"font-sans break-words whitespace-pre-wrap",children:s(t.content)})}),o.jsxs("div",{className:"flex items-center gap-2 mt-1.5 px-1",children:[o.jsx("span",{className:"text-[10px] text-muted-foreground/50 font-medium tracking-wide",children:new Date(t.created_at).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}),!e&&t.context_sources&&t.context_sources.length>0&&o.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-secondary/20 text-secondary border border-secondary/20 flex items-center gap-1 font-medium",children:[o.jsx(Zf,{size:10}),t.context_sources.length," sources"]})]})]})]})})}function Fc(t){return typeof t=="string"?t:t&&typeof t=="object"&&"message"in t&&typeof t.message=="string"?t.message:"Request failed"}function Q6({sessionId:t,onContextUpdate:e,onSessionCreated:s}){const[r,l]=v.useState([]),[u,d]=v.useState(""),[h,m]=v.useState(!1),[g,y]=v.useState(!1),[x,w]=v.useState(!1),S=v.useRef(null),E=v.useRef(null),j=v.useRef(!0),_=v.useRef(null),N=v.useRef(null),k=v.useRef(null),C=v.useCallback(async()=>{const P=un();if(!P)return null;const{data:Z}=await P.auth.getSession();return Z.session?.access_token??null},[]),A=v.useCallback(async P=>{try{const Z=await C();if(!Z)throw new Error("Authentication required");const te=await Te.getChatMessages(P,Z);if(te.error)throw new Error(Fc(te.error));if(te.data?.success&&N.current===P){l(te.data.messages);const me=te.data.messages.filter(Ee=>Ee.role==="assistant"&&Array.isArray(Ee.context_sources)).flatMap(Ee=>Ee.context_sources??[]);e(me)}}catch(Z){console.error("Failed to fetch messages",Z),ce.error("Failed to load chat history")}finally{N.current===P&&w(!1)}},[C,e]);v.useEffect(()=>{if(t){if(k.current===t){k.current=null,w(!1);return}l([]),w(!0),N.current=t,A(t)}else l([]),w(!1),e([]),N.current=null},[t,A,e]),v.useEffect(()=>{j.current&&S.current&&S.current.scrollIntoView({behavior:"smooth"})},[r,g]);const D=()=>{const P=E.current;if(!P)return;const Z=P.scrollHeight-P.scrollTop-P.clientHeight;j.current=Z<64},U=async P=>{if(P?.preventDefault(),!u.trim()||h)return;const Z=u.trim();d(""),_.current&&(_.current.style.height="auto"),m(!0),y(!0);try{const te=await C();if(!te)throw new Error("Authentication required");const me={id:"temp-"+Date.now(),role:"user",content:Z,created_at:new Date().toISOString()};l($=>[...$,me]);let Ee=t;if(!Ee){const $=await Te.createChatSession(te);if($.error)throw new Error(Fc($.error));if($.data?.success)Ee=$.data.session.id,k.current=Ee,s(Ee);else throw new Error("Failed to create session")}const ye=await Te.sendChatMessage({sessionId:Ee,content:Z},te);if(ye.error)throw new Error(Fc(ye.error));const _e=ye.data?.message;ye.data?.success&&_e&&(l($=>[...$,_e]),_e.context_sources&&_e.context_sources.length>0&&e(_e.context_sources))}catch(te){console.error("Message failed",te),ce.error(Fc(te)||"Failed to send message"),l(me=>[...me,{id:"err-"+Date.now(),role:"assistant",content:"I encountered an error trying to process that request.",created_at:new Date().toISOString()}])}finally{m(!1),y(!1)}},V=P=>{P.key==="Enter"&&!P.shiftKey&&(P.preventDefault(),U())},R=["Find me the latest invoice from AWS.","What is the late penalty on the ACME contract?","Show me receipts from last week.","Summarize my recent cloud hosting expenses."];return o.jsxs(o.Fragment,{children:[o.jsxs("div",{ref:E,onScroll:D,className:"flex-1 overflow-y-auto p-5 space-y-6 scrollbar-on-hover",children:[x?o.jsxs("div",{className:"flex-1 h-full flex items-center justify-center text-muted-foreground gap-2",children:[o.jsx(ma,{size:18,className:"animate-spin"}),o.jsx("span",{className:"text-sm",children:"Loading history..."})]}):r.length===0?o.jsxs("div",{className:"h-full flex flex-col items-center justify-center p-8 text-center text-muted-foreground/80",children:[o.jsx("div",{className:"w-16 h-16 bg-primary/10 rounded-2xl flex items-center justify-center mb-6 text-primary",children:o.jsx(Cs,{size:32})}),o.jsx("h3",{className:"text-2xl font-bold mb-3 text-foreground tracking-tight",children:"Chat with your Documents"}),o.jsx("p",{className:"text-sm max-w-sm mx-auto mb-10 leading-relaxed",children:"Folio has seamlessly read and memorized your files using Semantic Search. Ask any question to retrieve precise answers and exact page citations."}),o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 max-w-lg w-full",children:R.map((P,Z)=>o.jsx("button",{onClick:()=>d(P),className:"text-left p-3.5 text-xs font-medium bg-surface/30 hover:bg-surface border border-border/50 hover:border-border rounded-xl transition-all cursor-pointer shadow-sm hover:shadow",children:P},Z))})]}):o.jsxs(o.Fragment,{children:[r.map(P=>o.jsx(J6,{message:P},P.id)),o.jsx(_p,{children:g&&o.jsx(Ro.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:"flex justify-start w-full",children:o.jsx("div",{className:"bg-surface border border-border/50 rounded-2xl rounded-tl-none px-4 py-3.5 flex items-center gap-3 shadow-sm",children:o.jsxs("div",{className:"flex gap-1.5",children:[o.jsx("span",{className:"w-1.5 h-1.5 bg-primary/60 rounded-full animate-bounce",style:{animationDelay:"0s"}}),o.jsx("span",{className:"w-1.5 h-1.5 bg-primary/60 rounded-full animate-bounce",style:{animationDelay:"0.15s"}}),o.jsx("span",{className:"w-1.5 h-1.5 bg-primary/60 rounded-full animate-bounce",style:{animationDelay:"0.3s"}})]})})})})]}),o.jsx("div",{ref:S})]}),o.jsx("div",{className:"p-4 bg-surface/40 backdrop-blur-xl border-t border-border/50",children:o.jsx("form",{onSubmit:U,className:"relative max-w-4xl mx-auto",children:o.jsxs("div",{className:"relative flex items-end gap-2 bg-surface/80 border border-border/60 hover:border-border rounded-2xl px-3 py-2 shadow-sm transition-all focus-within:ring-2 focus-within:ring-primary/20 focus-within:border-primary/50",children:[o.jsx("textarea",{ref:_,value:u,onChange:P=>{d(P.target.value),P.target.style.height="auto",P.target.style.height=Math.min(P.target.scrollHeight,200)+"px"},onKeyDown:V,placeholder:"Message Folio AI...",rows:1,className:"w-full bg-transparent border-none focus:ring-0 focus:outline-none py-2.5 pl-1 text-sm text-foreground resize-none min-h-[44px] max-h-[200px] placeholder:text-muted-foreground/50",disabled:h}),o.jsx("button",{type:"submit",disabled:!u.trim()||h,className:"p-2.5 mb-1 bg-primary text-primary-foreground rounded-xl shadow-md hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed transition-all shrink-0 cursor-pointer",children:h?o.jsx(ma,{size:18,className:"animate-spin"}):o.jsx(GC,{size:18})})]})})})]})}function Z6({sources:t,onClose:e}){return!t||t.length===0?null:o.jsx(_p,{children:o.jsxs(Ro.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},className:"flex flex-col h-full",children:[o.jsxs("div",{className:"p-4 border-b border-border flex items-center justify-between bg-surface/15",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground/80",children:[o.jsx(Rk,{size:16,className:"text-secondary"}),o.jsx("span",{children:"Retrieved Context"})]}),o.jsx("button",{onClick:e,className:"p-1 hover:bg-surface rounded-md text-muted-foreground hover:text-foreground transition-colors cursor-pointer",children:o.jsx(zn,{size:14})})]}),o.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-3 scrollbar-on-hover",children:t.map((s,r)=>{const l=Math.round(s.similarity*100);return o.jsxs("div",{className:"p-3 bg-surface/20 hover:bg-surface/50 border border-border rounded-xl transition-all group",children:[o.jsxs("div",{className:"flex justify-between items-start mb-2",children:[o.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-bold",children:[o.jsx("span",{className:"flex items-center justify-center w-4 h-4 bg-primary/10 text-primary rounded",children:r+1}),o.jsxs("span",{className:`px-1.5 py-0.5 rounded border ${l>=80?"bg-amber-500/10 text-amber-600 border-amber-500/20":"bg-blue-500/10 text-blue-500 border-blue-500/20"}`,children:[l,"% Match"]})]}),o.jsx("button",{onClick:()=>{console.log("Open Ingestion ID:",s.ingestion_id)},className:"opacity-0 group-hover:opacity-100 focus-visible:opacity-100 text-muted-foreground hover:text-primary transition-opacity focus-visible:ring-2 focus-visible:ring-primary/40 rounded cursor-pointer",title:"View Source Document",children:o.jsx(Uw,{size:12})})]}),o.jsxs("div",{className:"text-[11px] text-muted-foreground leading-relaxed line-clamp-4 font-mono bg-black/5 p-2 rounded-lg border border-border/40",children:['"',s.content,'"']})]},r)})}),o.jsxs("div",{className:"p-3 border-t border-border bg-surface/20 text-[10px] text-center text-muted-foreground/50 font-medium",children:[t.length," document chunk",t.length!==1?"s":""," retrieved"]})]})})}function eP(){const[t,e]=v.useState(null),[s,r]=v.useState([]),[l,u]=v.useState(!1),[d,h]=v.useState(0),m=v.useCallback(y=>{e(y),h(x=>x+1)},[]),g=v.useCallback(y=>{r(y),y.length>0&&u(!0)},[]);return o.jsxs("div",{className:"flex w-full h-[calc(100vh-15rem)] min-h-[540px] gap-4 overflow-hidden animate-in fade-in duration-500",children:[o.jsx("div",{className:"w-64 shrink-0 flex flex-col h-full bg-surface/25 backdrop-blur-xl border border-border rounded-xl overflow-hidden shadow-sm",children:o.jsx(W6,{activeSessionId:t,onSelectSession:e,refreshTrigger:d})}),o.jsx("div",{className:"flex-1 min-w-0 flex flex-col h-full bg-surface/60 rounded-xl overflow-hidden border border-border relative shadow-sm",children:o.jsx(Q6,{sessionId:t,onContextUpdate:g,onSessionCreated:m})}),l&&o.jsx("div",{className:"w-80 shrink-0 flex flex-col h-full bg-surface/25 backdrop-blur-xl border border-border rounded-xl overflow-hidden shadow-sm",children:o.jsx(Z6,{sources:s,onClose:()=>u(!1)})})]})}const Aj=v.createContext(void 0);function tP({children:t}){const[e,s]=v.useState(!1),r=v.useCallback(()=>s(!0),[]),l=v.useCallback(()=>s(!1),[]),u=v.useMemo(()=>({isExpanded:e,setIsExpanded:s,openTerminal:r,closeTerminal:l}),[e,r,l]);return o.jsx(Aj.Provider,{value:u,children:t})}function nP(){const t=v.useContext(Aj);if(t===void 0)throw new Error("useTerminal must be used within a TerminalProvider");return t}const sP=/(https?:\/\/[^\s<>"'`]+)/g;function If(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Rj(t){if(typeof t!="string"||t.trim().length===0)return null;try{const e=new URL(t.trim());return e.protocol!=="http:"&&e.protocol!=="https:"?null:e.toString()}catch{return null}}function aP(t){if(!If(t)||!If(t.remediation))return null;const e=t.remediation,s=typeof e.title=="string"?e.title.trim():"",r=typeof e.summary=="string"?e.summary.trim():"",l=typeof e.code=="string"?e.code.trim():"",u=Array.isArray(e.steps)?e.steps.filter(h=>typeof h=="string").map(h=>h.trim()).filter(Boolean):[],d=Array.isArray(e.links)?e.links.filter(If).map(h=>{const m=Rj(h.url);return m?{label:typeof h.label=="string"&&h.label.trim().length>0?h.label.trim():"Open help link",url:m}:null}).filter(h=>h!==null):[];return!s&&!r&&!l&&u.length===0&&d.length===0?null:{...s?{title:s}:{},...r?{summary:r}:{},...l?{code:l}:{},steps:u,links:d}}function Kc(t){const e=[];let s=0;for(const r of t.matchAll(sP)){const l=r[0]??"",u=r.index??0,d=u+l.length;u>s&&e.push(o.jsx("span",{children:t.slice(s,u)},`txt-${s}-${u}`));const h=Rj(l);h?e.push(o.jsx("a",{href:h,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 decoration-current/50 hover:decoration-current",onClick:m=>m.stopPropagation(),children:h},`url-${u}-${h}`)):e.push(o.jsx("span",{children:l},`txt-${u}-${d}`)),s=d}return s<t.length&&e.push(o.jsx("span",{children:t.slice(s)},`txt-${s}-${t.length}`)),e.length>0?o.jsx(o.Fragment,{children:e}):t}function rP(){const t=un(),{isExpanded:e,openTerminal:s,closeTerminal:r}=nP(),[l,u]=v.useState([]),[d,h]=v.useState(new Set),[m,g]=v.useState(!1),y=v.useRef(null);v.useEffect(()=>{let _=!0;const N=async()=>{if(!t)return;const{data:{user:A}}=await t.auth.getUser();if(!A)return;const{data:D,error:U}=await t.from("processing_events").select("*").eq("user_id",A.id).order("created_at",{ascending:!1}).limit(50);if(D&&_){u(D);const V=new Set;D.forEach(R=>{R.event_type==="error"&&R.details?.error&&V.add(R.id)}),h(V)}},k=async()=>{if(!t)return null;const{data:{user:A}}=await t.auth.getUser();return A?t.channel("processing_events_realtime").on("postgres_changes",{event:"INSERT",schema:"public",table:"processing_events",filter:`user_id=eq.${A.id}`},D=>{const U=D.new;_&&(U.event_type==="error"&&U.details?.error&&h(V=>new Set(V).add(U.id)),u(V=>{const R=[U,...V];return U.details?.is_completion&&setTimeout(()=>{_&&r()},3e3),R.length>100?R.slice(0,100):R}),g(!0),setTimeout(()=>g(!1),500))}).subscribe():null};N();const C=k();return()=>{_=!1,C.then(A=>{A&&t&&t.removeChannel(A)})}},[t,s,r]);const x=(_,N)=>{N.stopPropagation(),h(k=>{const C=new Set(k);return C.has(_)?C.delete(_):C.add(_),C})},w=_=>{switch(_.event_type){case"error":return"border-l-rose-500/50 bg-rose-500/5 text-rose-200";case"action":return"border-l-indigo-500/50 bg-indigo-500/5 text-indigo-200";case"analysis":return"border-l-amber-500/50 bg-amber-500/5 text-amber-200";default:return"border-l-emerald-500/30 text-emerald-100 hover:bg-white/5"}},S=_=>{if(!_)return o.jsx(ui,{className:"w-3.5 h-3.5"});const N=_.toLowerCase();return N.includes("triage")?o.jsx(oC,{className:"w-3.5 h-3.5"}):N.includes("extraction")?o.jsx(Pw,{className:"w-3.5 h-3.5"}):N.includes("matching")?o.jsx($m,{className:"w-3.5 h-3.5"}):N.includes("action")?o.jsx(qw,{className:"w-3.5 h-3.5"}):N.includes("completed")?o.jsx(os,{className:"w-3.5 h-3.5"}):N.includes("error")?o.jsx(uu,{className:"w-3.5 h-3.5"}):o.jsx(Bm,{className:"w-3.5 h-3.5"})},E=_=>_||"System",j=_=>{const N=_.details?.action||_.details?.error;if(typeof N=="string"&&N.trim().length>0)return N;const k=JSON.stringify(_.details);return typeof k=="string"&&k.trim().length>0?k:"Event received."};return e?o.jsxs("div",{className:"fixed bottom-4 right-4 z-50 w-[450px] bg-[#0A0D14] border border-white/10 rounded-xl shadow-2xl flex flex-col overflow-hidden transition-all duration-300 ease-out h-[600px] max-h-[85vh]",children:[o.jsxs("div",{className:"px-4 py-3 border-b border-white/10 bg-white/5 flex items-center justify-between shrink-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Io,{className:"w-4 h-4 text-emerald-400"}),o.jsx("h3",{className:"font-semibold text-sm text-zinc-100 uppercase tracking-widest",children:"Live Trace"}),o.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-emerald-500/10 border border-emerald-500/20 ml-2",children:[o.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${m?"bg-emerald-400 animate-pulse":"bg-emerald-500/50"}`}),o.jsx("span",{className:"text-[9px] font-medium text-emerald-400/80 uppercase tracking-widest",children:m?"Streaming":"Connected"})]})]}),o.jsx("button",{onClick:_=>{_.stopPropagation(),r()},className:"p-1.5 hover:bg-white/10 rounded-md text-zinc-400 hover:text-white transition-colors",children:o.jsx($w,{className:"w-4 h-4"})})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-2 font-mono text-xs flex flex-col gap-1.5 custom-scrollbar bg-[#05070A]",children:[l.length===0?o.jsxs("div",{className:"flex items-center justify-center h-full text-zinc-500 flex-col gap-2",children:[o.jsx(ui,{className:"w-6 h-6 opacity-20"}),o.jsx("span",{className:"text-sm",children:"Waiting for ingestion events..."})]}):l.map(_=>{const N=d.has(_.id),k=aP(_.details);return o.jsx("div",{className:`border-l-2 pl-3 py-2 pr-2 rounded-r-md transition-colors ${w(_)}`,children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"shrink-0 pt-0.5 opacity-60",children:S(_.agent_state)}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[o.jsx("span",{className:"text-[10px] opacity-50 shrink-0",children:new Date(_.created_at).toLocaleTimeString([],{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}),o.jsx("span",{className:"text-[10px] font-bold tracking-wider uppercase opacity-80 shrink-0",children:E(_.agent_state)}),_.ingestion_id&&o.jsx("span",{className:"text-[10px] text-zinc-500 truncate ml-auto uppercase",title:_.ingestion_id,children:_.ingestion_id.substring(0,8)})]}),o.jsx("div",{className:"leading-relaxed break-words whitespace-pre-wrap",children:Kc(j(_))}),_.event_type==="error"&&k&&o.jsxs("div",{className:"mt-2 rounded border border-amber-400/30 bg-amber-500/10 px-2.5 py-2 text-[10px] text-amber-100 space-y-1.5",children:[o.jsx("p",{className:"font-semibold uppercase tracking-wider text-[9px] text-amber-200",children:"Suggested Fix"}),k.title&&o.jsx("p",{className:"font-semibold text-amber-100",children:Kc(k.title)}),k.summary&&o.jsx("p",{className:"text-amber-100/90",children:Kc(k.summary)}),k.code&&o.jsxs("p",{className:"text-amber-200/90",children:["Code: ",k.code]}),k.steps.length>0&&o.jsx("ol",{className:"list-decimal pl-4 space-y-1 text-amber-100/90",children:k.steps.map(C=>o.jsx("li",{children:Kc(C)},`${_.id}-fix-step-${C}-${C.length}`))}),k.links.length>0&&o.jsx("div",{className:"flex flex-wrap gap-1.5 pt-0.5",children:k.links.map(C=>o.jsx("a",{href:C.url,target:"_blank",rel:"noreferrer",className:"inline-flex items-center rounded border border-amber-300/40 px-2 py-1 text-[9px] font-semibold uppercase tracking-wider text-amber-100 hover:bg-amber-300/10",onClick:A=>A.stopPropagation(),children:C.label},`${_.id}-fix-link-${C.url}`))})]}),_.event_type!=="info"&&_.details&&Object.keys(_.details).length>(_.details.action?1:0)&&o.jsx("div",{className:"mt-2 text-[10px]",children:_.event_type==="error"?o.jsxs("div",{className:"bg-rose-950/30 rounded border border-rose-500/20 overflow-hidden",children:[o.jsxs("button",{className:"w-full text-left px-2 py-1 flex justify-between items-center hover:bg-rose-500/10 text-rose-300 font-semibold uppercase tracking-wider text-[9px]",onClick:C=>x(_.id,C),children:[o.jsx("span",{children:"Error Details"}),o.jsx("span",{className:"opacity-50",children:N?"Hide":"Show"})]}),N&&o.jsx("pre",{className:"p-2 border-t border-rose-500/20 overflow-x-auto text-rose-200/80 custom-scrollbar",children:JSON.stringify(_.details,null,2)})]}):o.jsx("div",{className:"bg-black/20 rounded border border-white/5 p-2 overflow-x-auto text-white/50 custom-scrollbar",children:o.jsx("pre",{children:JSON.stringify(Object.fromEntries(Object.entries(_.details).filter(([C])=>C!=="action")),null,2)})})})]})]})},_.id)}),o.jsx("div",{ref:y,className:"h-4 shrink-0"})]}),o.jsxs("div",{className:"shrink-0 p-3 bg-white/5 border-t border-white/10 flex items-center gap-2 text-zinc-500 text-xs",children:[o.jsx("span",{className:"text-emerald-500/50 font-bold",children:"➜"}),o.jsx("span",{className:"animate-pulse",children:"_"})]})]}):o.jsxs("button",{type:"button",className:"fixed bottom-4 right-4 z-50 bg-[#0A0D14] border border-white/10 rounded-full py-2 px-4 shadow-xl flex items-center gap-3 cursor-pointer transition-all hover:bg-[#11141D] hover:border-white/20",onClick:s,children:[o.jsxs("div",{className:"relative",children:[o.jsx(Io,{className:`w-4 h-4 ${m?"text-emerald-400":"text-zinc-400"}`}),m&&o.jsx("div",{className:"absolute inset-0 bg-emerald-400/20 blur-sm rounded-full animate-pulse"})]}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-xs font-medium text-zinc-200",children:"Live Trace"}),o.jsx("span",{className:"text-[10px] text-zinc-500 leading-none mt-0.5",children:l.length>0?E(l[0].agent_state):"Idle"})]}),o.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500/50 shadow-[0_0_8px_rgba(16,185,129,0.5)] ml-1"})]})}function iP(){const t=v.useMemo(()=>$o(),[]),[e,s]=v.useState("dashboard"),[r,l]=v.useState(null),[u,d]=v.useState(!t),[h,m]=v.useState(!1),[g,y]=v.useState("not_checked"),[x,w]=v.useState("Folio ready. Run setup to configure runtime contracts."),[S,E]=v.useState(t),j=jA(),[_,N]=v.useState(!1),[k,C]=v.useState(0),[A,D]=v.useState("unknown"),[U,V]=v.useState("unknown"),[R,P]=v.useState(null),[Z,te]=v.useState(null),[me,Ee]=v.useState(!1),[ye,_e]=v.useState(()=>{const q=localStorage.getItem("folio_migration_snoozed_until");return q?new Date(q):null}),[$,Y]=v.useState(null),J=v.useMemo(()=>S?zm(S.url,S.anonKey,{auth:{autoRefreshToken:!0,persistSession:!0}}):null,[S]);v.useEffect(()=>{if(!J){V("unknown"),P(null);return}const{data:q}=J.auth.onAuthStateChange((fe,ie)=>{V(ie?.user?"authenticated":"anonymous"),P(ie?.user?.email??null),C(ze=>ze+1)});return()=>{q.subscription.unsubscribe()}},[J]),v.useEffect(()=>{let q=!1;async function fe(ze,Be){const kt=Promise.resolve(ze);let et=null;const le=new Promise((Fe,de)=>{et=setTimeout(()=>{de(new Error(`Operation timed out after ${Be}ms`))},Be)});try{return await Promise.race([kt,le])}finally{et&&clearTimeout(et)}}async function ie(){if(!J){D("unknown"),V("unknown"),P(null),te(null),Y(null);return}N(!0),Y(null);try{const{data:ze,error:Be}=await fe(J.from("init_state").select("is_initialized").single(),12e3);if(Be)if(Be.code==="42P01")D("missing_view");else throw D("error"),new Error(Be.message||"Failed to query init_state");else{const Fe=Number(ze.is_initialized??0)>0;D(Fe?"initialized":"empty")}const{data:kt,error:et}=await fe(J.auth.getSession(),12e3);if(et)V("error"),P(null);else{const Fe=kt.session?.user??null;V(Fe?"authenticated":"anonymous"),P(Fe?.email??null)}const le=await fe(Qw(J),12e3);te(le)}catch(ze){const Be=ze instanceof Error?ze.message:String(ze);q||(Y(Be),w(`Bootstrap check failed: ${Be}`))}finally{q||N(!1)}}return ie(),()=>{q=!0}},[J,k]);function pe(){const q=$o();E(q),d(!1),w("Setup complete. Foundation runtime is configured."),y("not_checked"),C(fe=>fe+1)}function se(){wA(),E(null),D("unknown"),V("unknown"),P(null),te(null),Y(null),d(!0),w("Stored setup was cleared. Run setup wizard again."),y("not_checked"),C(q=>q+1)}function M(){C(q=>q+1)}const L=q=>{_e(q),localStorage.setItem("folio_migration_snoozed_until",q.toISOString())},W=v.useMemo(()=>!(!Z?.needsMigration||ye&&ye>new Date),[Z,ye]),ne=[{id:"dashboard",label:"Dashboard",icon:m0},{id:"chat",label:"Chat",icon:cu},{id:"funnel",label:"Funnel",icon:Bw},{id:"policies",label:"Policies",icon:Hw},{id:"config",label:"Configuration",icon:$m}];return u||!S?o.jsx("div",{className:"min-h-screen bg-background",children:o.jsx(m5,{open:u||!S,canClose:!!S,onComplete:pe})}):A==="empty"||A==="missing_view"||U!=="authenticated"?_&&A==="unknown"?o.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:o.jsxs("div",{className:"flex flex-col items-center gap-4",children:[o.jsx(it,{className:"w-10 h-10 animate-spin text-primary opacity-50"}),o.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.3em] text-muted-foreground animate-pulse",children:"Initializing Engine..."})]})}):o.jsx(l6,{supabase:J,initStatus:A,onSuccess:M,onResetConfigs:se}):o.jsx(tP,{children:o.jsxs("div",{className:"min-h-screen bg-background text-foreground selection:bg-primary/10 flex flex-col font-sans animate-in fade-in duration-1000",children:[W&&Z&&o.jsx(C6,{status:Z,onSnooze:L,onOpenModal:()=>Ee(!0)}),Z&&o.jsx(A6,{open:me,onOpenChange:Ee,status:Z,onSnooze:L}),o.jsx("header",{className:ge("border-b bg-background/80 backdrop-blur-xl sticky top-0 z-50 transition-all duration-500",W&&"mt-24 sm:mt-20"),children:o.jsxs("div",{className:"container max-w-[1400px] mx-auto px-8 h-20 flex items-center",children:[o.jsxs("div",{className:"flex items-center gap-3 w-[280px]",children:[o.jsx("div",{className:"w-9 h-9 flex items-center justify-center",children:o.jsx(ou,{className:"w-8 h-8"})}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h1",{className:"text-xl font-bold tracking-tight text-foreground/90",children:"Folio"}),o.jsx("div",{className:"flex items-center",children:o.jsxs("span",{className:"relative flex h-2 w-2",children:[o.jsx("span",{className:ge("animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",g==="ok"?"bg-emerald-400":"bg-primary/40")}),o.jsx("span",{className:ge("relative inline-flex rounded-full h-2 w-2",g==="ok"?"bg-emerald-500":"bg-primary/60")})]})})]})]}),o.jsx("nav",{className:"flex-1 hidden md:flex items-center justify-center gap-2",children:ne.map(q=>o.jsxs("button",{onClick:()=>s(q.id),className:ge("flex items-center gap-2 px-4 py-2 rounded-xl text-sm font-semibold transition-all duration-300",e===q.id?"bg-primary/10 text-primary shadow-sm":"text-muted-foreground/80 hover:bg-muted/60 hover:text-foreground"),children:[o.jsx(q.icon,{className:ge("w-4.5 h-4.5",e===q.id?"text-primary":"text-muted-foreground/60")}),q.label]},q.id))}),o.jsxs("div",{className:"flex items-center justify-end gap-5 w-[280px]",children:[o.jsxs("div",{className:"hidden lg:flex items-center gap-2 px-3 py-1.5 bg-muted/40 rounded-full border border-border/40 cursor-pointer hover:bg-muted/60 transition-colors",children:[o.jsx("img",{src:"https://flagcdn.com/w40/us.png",className:"w-4 h-3 rounded-sm opacity-80",alt:"EN"}),o.jsx("span",{className:"text-[10px] font-extrabold tracking-widest text-muted-foreground",children:"EN"})]}),o.jsxs(ae,{variant:"ghost",size:"icon",className:ge("rounded-full h-9 w-9 transition-all relative group",Z?.needsMigration?"text-red-500 hover:bg-red-500/10":"text-muted-foreground hover:bg-muted/60"),onClick:()=>m(!0),children:[o.jsx(ui,{className:ge("w-5 h-5",Z?.needsMigration&&"animate-pulse")}),Z?.needsMigration&&o.jsx("span",{className:"absolute top-1 right-1 h-2 w-2 rounded-full bg-red-500 ring-4 ring-red-500/20 animate-ping"})]}),o.jsx(e1,{}),o.jsx("div",{className:"w-10 h-10 rounded-full overflow-hidden border-2 border-background shadow-lg cursor-pointer ring-1 ring-border/20",onClick:()=>s("account"),children:o.jsx("div",{className:"w-full h-full bg-primary flex items-center justify-center text-primary-foreground font-black text-xs",children:R?.charAt(0).toUpperCase()||"A"})})]})]})}),o.jsxs("main",{className:"flex-1 w-full px-6 py-12 mx-auto max-w-[1600px]",children:[$&&o.jsxs(jn,{variant:"destructive",className:"mb-10 animate-in fade-in slide-in-from-top-4 duration-500",children:[o.jsx(Sn,{className:"h-5 w-5"}),o.jsx(Hm,{className:"font-bold",children:"Protocol Connection Failure"}),o.jsx(_n,{className:"text-[13px] opacity-90",children:$})]}),e==="dashboard"&&o.jsx(AA,{configSnapshot:S,configSource:j,setActivePage:s}),e==="chat"&&o.jsx(eP,{}),e==="funnel"&&o.jsx(X6,{onComposePolicyForDoc:q=>{l(q),s("policies")}}),e==="policies"&&o.jsx(O6,{initialCompose:r,onInitialConsumed:()=>l(null)}),e==="config"&&o.jsx(k6,{}),e==="account"&&o.jsx(JA,{supabase:J,sessionEmail:R,sessionStatus:U,initStatus:A,configSnapshot:S,configSource:j,onRefresh:M,onLaunchSetup:()=>d(!0),onResetSetup:se})]}),o.jsx(rP,{}),o.jsx("div",{className:"fixed bottom-6 left-6 z-[60]",children:o.jsx(ae,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full shadow-xl bg-background border border-border/40 text-muted-foreground hover:text-primary hover:scale-110 transition-all",children:o.jsx(m0,{className:"w-6 h-6"})})}),o.jsx("footer",{className:"border-t bg-card/20 py-10 mt-auto",children:o.jsxs("div",{className:"container max-w-7xl mx-auto px-8 flex items-center justify-between text-[11px] text-muted-foreground font-bold uppercase tracking-[0.2em] opacity-40",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{children:"Core Foundation Protocol"}),o.jsx("div",{className:"w-1 h-1 rounded-full bg-muted-foreground"}),o.jsx("span",{children:"2026"})]}),o.jsxs("div",{className:"flex items-center gap-8",children:[o.jsx("a",{href:"#",className:"hover:text-foreground transition-colors",children:"Whitepaper"}),o.jsx("a",{href:"#",className:"hover:text-foreground transition-colors",children:"Foundation Registry"})]})]})}),o.jsx(WO,{open:h,onOpenChange:m,health:g,isBootstrapping:_,initStatus:A||"unknown",sessionStatus:U||"unknown",migrationStatus:Z,onRunMigration:()=>{m(!1),Ee(!0)}})]})})}s2.createRoot(document.getElementById("root")).render(o.jsx(ew.StrictMode,{children:o.jsx(nR,{defaultTheme:"dark",storageKey:"folio-theme",children:o.jsx(d6,{children:o.jsx(f6,{children:o.jsxs(y6,{children:[o.jsx(iP,{}),o.jsx(CA,{})]})})})})}));
|
|
111
|
+
${q.enabled?"bg-violet-500 border-violet-500":"border-muted-foreground/40 bg-background"}`,children:q.enabled&&o.jsx(as,{className:"w-3 h-3 text-white"})}),o.jsxs("div",{className:"flex-1 space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("code",{className:"text-xs font-mono bg-muted px-1.5 py-0.5 rounded",children:q.key}),o.jsx(Pt,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:q.type})]}),o.jsx(je,{className:"h-7 text-xs",value:q.description,disabled:!q.enabled,onChange:fe=>Y(q.key,fe.target.value)})]})]},q.key))})]}),o.jsxs(ht,{children:[o.jsx(zt,{children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx(Lt,{className:"text-base",children:"Custom Fields"}),o.jsx(wn,{className:"mt-1",children:"Add fields specific to your workflow — project codes, contract types, department names, or any entity your documents carry."})]}),o.jsxs(ae,{variant:"outline",size:"sm",onClick:J,className:"gap-1.5",children:[o.jsx(Wa,{className:"w-3.5 h-3.5"}),"Add Field"]})]})}),ue.length>0&&o.jsx(xt,{className:"space-y-4",children:m.map((q,fe)=>q.is_default?null:o.jsxs("div",{className:"grid grid-cols-[1fr_120px_1fr_32px] gap-2 items-start",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-muted-foreground",children:"Key"}),o.jsx(je,{className:"h-8 text-xs font-mono",placeholder:"e.g. project_code",value:q.key,onChange:re=>pe(fe,{key:re.target.value.toLowerCase().replace(/\s+/g,"_")})})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-muted-foreground",children:"Type"}),o.jsx("select",{className:"w-full h-8 text-xs border rounded-md px-2 bg-background",value:q.type,onChange:re=>pe(fe,{type:re.target.value}),children:T6.map(re=>o.jsx("option",{value:re,children:re},re))})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-muted-foreground",children:"Description / hint for the model"}),o.jsx(je,{className:"h-8 text-xs",placeholder:"What this field contains",value:q.description,onChange:re=>pe(fe,{description:re.target.value})})]}),o.jsx("button",{type:"button",onClick:()=>se(fe),className:"mt-6 p-1 rounded text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",children:o.jsx(el,{className:"w-3.5 h-3.5"})})]},fe))})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("button",{type:"button",onClick:E?()=>j(!1):_e,className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[o.jsx(pC,{className:"w-3.5 h-3.5"}),"Version history",y!==null&&o.jsxs(Pt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 ml-1",children:["v",y," active"]}),E?o.jsx(lu,{className:"w-3 h-3"}):o.jsx(Bo,{className:"w-3 h-3"})]}),o.jsxs(ae,{onClick:M,disabled:l,className:"gap-2",children:[l?o.jsx(cn,{size:"sm"}):o.jsx(as,{className:"w-4 h-4"}),"Save & Activate"]})]}),E&&o.jsx(ht,{children:o.jsx(xt,{className:"pt-4 space-y-2",children:w.length===0?o.jsx("p",{className:"text-xs text-muted-foreground text-center py-4",children:"No saved versions yet"}):w.map(q=>o.jsxs("div",{className:"flex items-center justify-between py-2 px-3 rounded-lg border bg-muted/30",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("span",{className:"text-sm font-mono font-medium",children:["v",q.version]}),q.is_active&&o.jsx(Pt,{className:"text-[10px] px-1.5 py-0 bg-violet-500 text-white",children:"active"}),o.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(q.created_at).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",q.fields.filter(fe=>fe.enabled).length," fields",q.context?" · context set":""]})]}),!q.is_active&&o.jsx(ae,{variant:"outline",size:"sm",className:"h-6 text-xs px-2",onClick:()=>U(q.id,q.version),children:"Activate"})]},q.id))})})]})}const Ep=v.createContext(null),kj=v.forwardRef(({className:t,defaultValue:e,value:s,onValueChange:i,...l},u)=>{const[d,h]=v.useState(e||""),m=s!==void 0?s:d,g=v.useCallback(y=>{i&&i(y),s===void 0&&h(y)},[i,s]);return o.jsx(Ep.Provider,{value:{value:m,onValueChange:g},children:o.jsx("div",{ref:u,className:t,...l})})});kj.displayName="Tabs";const Cj=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...e}));Cj.displayName="TabsList";const jo=v.forwardRef(({className:t,value:e,onClick:s,...i},l)=>{const u=v.useContext(Ep);if(!u)throw new Error("TabsTrigger must be used within Tabs");const d=u.value===e;return o.jsx("button",{ref:l,type:"button",role:"tab","aria-selected":d,"data-state":d?"active":"inactive",className:ge("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background 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 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",t),onClick:h=>{u.onValueChange(e),s?.(h)},...i})});jo.displayName="TabsTrigger";const _o=v.forwardRef(({className:t,value:e,...s},i)=>{const l=v.useContext(Ep);if(!l)throw new Error("TabsContent must be used within Tabs");return l.value!==e?null:o.jsx("div",{ref:i,role:"tabpanel","data-state":"active",className:ge("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...s})});_o.displayName="TabsContent";const bo="realtimexai";function k6(){const{state:t,actions:e}=ol(),{t:s}=br(),[i,l]=v.useState(!1),[u,d]=v.useState(!1),[h,m]=v.useState({});m6({system_instruction:s("config.agent.systemInstruction"),data:{accounts_count:t.accounts.length,connected_providers:t.accounts.map(P=>P.provider),rules_count:t.rules.length,active_rules:t.rules.filter(P=>P.is_enabled).map(P=>P.name),current_settings:{llm_provider:h.llm_provider,llm_model:h.llm_model}}});const[g,y]=v.useState([]),[x,w]=v.useState([]);v.useEffect(()=>{(async()=>{try{const te=await Te.getChatProviders();te.data&&y(te.data.providers||[])}catch(te){console.error(te)}})(),(async()=>{try{const te=await Te.getEmbedProviders();te.data&&w(te.data.providers||[])}catch(te){console.error(te)}})()},[s]);const E=g.find(P=>P.provider===(h.llm_provider||bo))?.models||[],_=x.find(P=>P.provider===(h.embedding_provider||bo))?.models||[],N=v.useMemo(()=>!h.llm_model||E.some(Z=>Z.id===h.llm_model)?E:[{id:h.llm_model,name:`${h.llm_model} (saved)`},...E],[E,h.llm_model]),k=v.useMemo(()=>!h.llm_provider||h.llm_provider===bo||g.some(Z=>Z.provider===h.llm_provider)?g:[{provider:h.llm_provider,name:`${h.llm_provider} (saved)`,models:[]},...g],[g,h.llm_provider]),C=v.useMemo(()=>!h.embedding_model||_.some(Z=>Z.id===h.embedding_model)?_:[{id:h.embedding_model,name:`${h.embedding_model} (saved)`},..._],[_,h.embedding_model]),A=v.useMemo(()=>!h.embedding_provider||h.embedding_provider===bo||x.some(Z=>Z.provider===h.embedding_provider)?x:[{provider:h.embedding_provider,name:`${h.embedding_provider} (saved)`,models:[]},...x],[x,h.embedding_provider]),D=P=>{const Z=g.find(te=>te.provider===P);m(te=>({...te,llm_provider:P,llm_model:Z?.models?.[0]?.id||""}))},z=P=>{const Z=x.find(te=>te.provider===P);m(te=>({...te,embedding_provider:P,embedding_model:Z?.models?.[0]?.id||""}))},V=async()=>{d(!0);try{const P=await Te.testLlm({llm_provider:h.llm_provider||void 0,llm_model:h.llm_model||void 0});P.data?.success?ce.success(P.data.message):ce.error(s("config.toast.connectionFailed"))}catch{ce.error(s("config.toast.connectionFailed"))}finally{d(!1)}};v.useEffect(()=>{e.fetchAccounts(),e.fetchRules(),e.fetchSettings()},[]),v.useEffect(()=>{t.settings&&m(t.settings)},[t.settings]);const R=async()=>{l(!0);const P=await e.updateSettings(h);l(!1),P&&ce.success(s("config.toast.settingsSaved"))};return o.jsxs("div",{className:"w-full mx-auto px-8 py-10 space-y-6 animate-in fade-in duration-500 flex flex-col h-full",children:[o.jsx("div",{className:"flex items-center justify-between",children:o.jsxs("div",{children:[o.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Configuration"}),o.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage your connected integrations and AI providers."})]})}),o.jsxs(kj,{defaultValue:"mail",className:"w-full",children:[o.jsxs(Cj,{className:"grid w-full grid-cols-4 max-w-lg h-12",children:[o.jsx(jo,{value:"mail",className:"h-10",children:"Mail"}),o.jsx(jo,{value:"storage",className:"h-10",children:"Storage"}),o.jsx(jo,{value:"intelligence",className:"h-10",children:"Intelligence"}),o.jsx(jo,{value:"baseline",className:"h-10",children:"Baseline"})]}),o.jsxs("div",{className:"mt-8",children:[o.jsx(_o,{value:"mail",className:"m-0 border-none p-0 outline-none",children:o.jsx(g6,{localSettings:h,setLocalSettings:m,handleSaveSettings:R,savingSettings:i})}),o.jsx(_o,{value:"storage",className:"m-0 border-none p-0 outline-none",children:o.jsx(_6,{})}),o.jsx(_o,{value:"intelligence",className:"m-0 border-none p-0 outline-none",children:o.jsx(j6,{localSettings:h,setLocalSettings:m,handleSaveSettings:R,savingSettings:i,handleTestConnection:V,testingLlm:u,providersWithSaved:k,modelsWithSaved:N,embedProvidersWithSaved:A,embedModelsWithSaved:C,handleProviderChange:D,handleEmbedProviderChange:z,DEFAULT_PROVIDER:bo})}),o.jsx(_o,{value:"baseline",className:"m-0 border-none p-0 outline-none",children:o.jsx(E6,{})})]})]})]})}function C6({status:t,onSnooze:e,onOpenModal:s}){const[i,l]=v.useState(!1),[u,d]=v.useState(!1),h=g=>{const y=new Date(Date.now()+g*60*60*1e3);e?.(y),ce.success(`Reminder snoozed until ${y.toLocaleTimeString()}`)},m=["Enhanced TTS voice support (Piper, Supertonic)","Real-time audio streaming infrastructure","Improved AI model provider resolution"];return i?o.jsx("div",{className:"fixed top-24 left-1/2 -translate-x-1/2 z-[60] animate-in slide-in-from-top-5",children:o.jsxs("button",{onClick:()=>l(!1),className:"flex items-center gap-2 px-4 py-2 bg-amber-500 text-amber-950 rounded-full shadow-2xl shadow-amber-500/20 hover:scale-105 active:scale-95 transition-all text-[11px] font-black uppercase tracking-widest border border-amber-400/50 backdrop-blur-md",children:[o.jsx(Cs,{className:"h-3.5 w-3.5"}),o.jsx("span",{children:"System Update Available"})]})}):o.jsx("div",{className:"fixed top-0 left-0 right-0 z-[60] animate-in slide-in-from-top-10 duration-700",children:o.jsxs("div",{className:"bg-amber-500 text-amber-950 px-6 py-4 shadow-2xl border-b border-amber-400/50 backdrop-blur-xl relative overflow-hidden",children:[o.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-white/10 rounded-full -translate-y-1/2 translate-x-1/2 blur-3xl pointer-events-none"}),o.jsx("div",{className:"max-w-5xl mx-auto relative",children:o.jsxs("div",{className:"flex items-start gap-6",children:[o.jsx("div",{className:"w-12 h-12 rounded-2xl bg-amber-950/10 flex items-center justify-center shrink-0",children:o.jsx(Gw,{className:"h-6 w-6"})}),o.jsxs("div",{className:"flex-1 space-y-3",children:[o.jsxs("div",{className:"flex items-start justify-between gap-4",children:[o.jsxs("div",{children:[o.jsxs("h2",{className:"text-lg font-black tracking-tight flex items-center gap-2",children:["Foundational Update Required",o.jsxs("span",{className:"text-[10px] px-2 py-0.5 bg-amber-950/10 rounded-full border border-amber-950/20 uppercase tracking-widest font-black",children:["v",t.appVersion]})]}),o.jsx("p",{className:"text-sm font-medium opacity-80 mt-1 max-w-2xl leading-relaxed",children:"New architecture components detected. Migration is necessary to enable real-time audio streaming and enhanced AI provider resolution."})]}),o.jsx(ae,{size:"icon",variant:"ghost",className:"h-8 w-8 text-amber-950 hover:bg-amber-950/10 rounded-full shrink-0",onClick:()=>l(!0),children:o.jsx($w,{className:"h-4 w-4"})})]}),u&&o.jsxs("div",{className:"bg-amber-950/5 rounded-2xl p-4 border border-amber-950/10 animate-in fade-in slide-in-from-top-2",children:[o.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest opacity-60 mb-3",children:"Protocol Improvements:"}),o.jsx("ul",{className:"grid grid-cols-1 md:grid-cols-2 gap-x-8 gap-y-2",children:m.map((g,y)=>o.jsxs("li",{className:"text-xs flex items-center gap-2 font-bold",children:[o.jsx("div",{className:"w-1 h-1 rounded-full bg-amber-950/40"}),g]},y))})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-1",children:[o.jsx(ae,{size:"sm",className:"h-9 px-6 bg-amber-950 text-amber-50 hover:bg-black rounded-full font-black text-[10px] uppercase tracking-[0.2em] shadow-xl shadow-amber-950/20 active:scale-95 transition-all",onClick:s,children:"Apply Update Now"}),o.jsx("div",{className:"h-4 w-px bg-amber-950/20 hidden sm:block mx-1"}),o.jsxs(ae,{size:"sm",variant:"ghost",className:"h-9 text-amber-950 font-black text-[10px] uppercase tracking-widest hover:bg-amber-950/10 rounded-full",onClick:()=>h(1),children:[o.jsx(Qo,{className:"h-3.5 w-3.5 mr-2 opacity-60"}),"Snooze 1h"]}),o.jsxs(ae,{size:"sm",variant:"ghost",className:"h-9 text-amber-950 font-black text-[10px] uppercase tracking-widest hover:bg-amber-950/10 rounded-full",onClick:()=>h(24),children:[o.jsx(zw,{className:"h-3.5 w-3.5 mr-2 opacity-60"}),"Tomorrow"]}),o.jsxs(ae,{size:"sm",variant:"ghost",className:"h-9 text-amber-950 font-black text-[10px] uppercase tracking-widest hover:bg-amber-950/10 rounded-full ml-auto",onClick:()=>d(!u),children:[u?o.jsx(lu,{className:"h-4 w-4"}):o.jsx(Bo,{className:"h-4 w-4"}),o.jsx("span",{className:"ml-2",children:u?"Hide Details":"Inspect Protocol"})]})]})]})]})})]})})}function A6({open:t,onOpenChange:e,status:s,onSnooze:i}){const l=$o(),u=j=>{const _=new Date(Date.now()+j*60*60*1e3);i?.(_),ce.success(`Reminder snoozed until ${_.toLocaleTimeString()}`),e(!1)},[d,h]=v.useState(!1),[m,g]=v.useState([]),[y,x]=v.useState(""),w=v.useRef(null),S=v.useMemo(()=>{const j=l?.url;if(!j)return"";try{return new URL(j).hostname.split(".")[0]||""}catch{return""}},[l?.url]);v.useEffect(()=>{w.current&&w.current.scrollIntoView({behavior:"smooth"})},[m]);const E=async()=>{if(!S){ce.error("Foundation Error: Missing Project ID");return}if(!y){ce.error("Security Error: Provide a Supabase Access Token.");return}h(!0),g(["[System] Initializing migration protocol...","[Auth] Verifying project credentials..."]);try{const j=await fetch("/api/migrate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectRef:S,accessToken:y})});if(!j.ok)throw new Error(`Migration engine failed: ${j.status}`);const _=j.body?.getReader();if(!_)throw new Error("Failed to initialize log stream.");const N=new TextDecoder;let k="",C=!1;for(;;){const{done:A,value:D}=await _.read();if(A)break;k+=N.decode(D,{stream:!0});const z=k.split(`
|
|
112
|
+
`);k=z.pop()||"";for(const V of z){const R=V.trim();if(!(!R||!R.startsWith("data: ")))try{const P=JSON.parse(R.substring(6));P.type==="done"?P.data==="success"&&(C=!0):P.data&&g(Z=>[...Z,P.data])}catch{}}}if(C)g(A=>[...A,"","═".repeat(50),"✅ FOUNDATION UPDATED","","✓ Database schema synchronized","✓ API contracts verified","","System will reload to apply changes...","═".repeat(50)]),setTimeout(()=>{window.location.reload()},2e3);else throw new Error("Migration completed with errors.")}catch(j){console.error(j),g(_=>[..._,"",`❌ FATAL ERROR: ${j instanceof Error?j.message:String(j)}`]),ce.error("Migration interrupted. Consult system logs.")}finally{h(!1)}};return o.jsx(Za,{open:t,onOpenChange:j=>!d&&e(j),children:o.jsx(ei,{className:"max-h-[90vh] sm:max-w-4xl overflow-y-auto border-none bg-background/95 backdrop-blur-2xl shadow-2xl p-0 gap-0 selection:bg-primary/20",children:o.jsxs("div",{className:"bg-gradient-to-br from-primary/5 via-transparent to-transparent",children:[o.jsx(hr,{className:"p-8 pb-4",children:o.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[o.jsx("div",{className:"w-12 h-12 rounded-2xl bg-primary/10 flex items-center justify-center",children:o.jsx(hu,{className:"h-6 w-6 text-primary"})}),o.jsxs("div",{children:[o.jsx(fr,{className:"text-2xl font-black tracking-tight",children:"Database Setup Required"}),o.jsxs(tl,{className:"text-xs font-bold uppercase tracking-[0.2em] opacity-60",children:["Foundational Registry Sync • ",s.appVersion]})]})]})}),o.jsxs("div",{className:"px-8 pb-8 space-y-6",children:[o.jsxs(jn,{className:"bg-muted/40 border-none rounded-2xl p-4",children:[o.jsx(Im,{className:"h-4 w-4 text-primary"}),o.jsxs(_n,{className:"text-xs font-medium leading-relaxed",children:["Your application requires a database schema update to enable new features like ",o.jsx("strong",{children:"Enhanced TTS Engine"})," and ",o.jsx("strong",{children:"Real-time Intelligence Streaming"}),". Existing data remains untouched."]})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[o.jsx("div",{className:"space-y-4",children:o.jsxs("div",{className:"rounded-2xl border bg-card/50 shadow-sm p-6 space-y-4",children:[o.jsx("h3",{className:"text-[10px] font-black uppercase tracking-[0.2em] text-muted-foreground",children:"Security Credentials"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"project-id",className:"text-[10px] uppercase tracking-widest font-black opacity-60",children:"Project Identity"}),o.jsx(je,{id:"project-id",value:S,disabled:!0,readOnly:!0,className:"h-10 bg-muted/50 border-none font-mono text-xs rounded-xl"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx(Je,{htmlFor:"access-token",className:"text-[10px] uppercase tracking-widest font-black opacity-60",children:"Personal Access Token"}),o.jsxs("a",{href:"https://supabase.com/dashboard/account/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] font-black tracking-widest text-primary hover:underline flex items-center gap-1",children:["GENERATE ",o.jsx(Uw,{className:"h-2.5 w-2.5"})]})]}),o.jsx(je,{id:"access-token",type:"password",placeholder:"sbp_...",value:y,onChange:j=>x(j.target.value),disabled:d,className:"h-10 bg-background border-border/40 focus:ring-primary/20 rounded-xl font-mono text-xs"})]}),o.jsx(ae,{onClick:E,disabled:d||!y,className:"w-full h-11 rounded-xl bg-primary text-primary-foreground font-black text-[10px] uppercase tracking-[0.2em] shadow-lg shadow-primary/20 hover:scale-[1.02] active:scale-[0.98] transition-all",children:d?o.jsxs(o.Fragment,{children:[o.jsx(rt,{className:"mr-2 h-4 w-4 animate-spin"}),"Deploying..."]}):o.jsxs(o.Fragment,{children:[o.jsx(ya,{className:"mr-2 h-4 w-4"}),"Initialize Protocol"]})})]})]})}),o.jsxs("div",{className:"flex flex-col rounded-2xl border bg-zinc-950/95 text-zinc-400 font-mono text-[11px] p-5 shadow-inner min-h-[300px] overflow-hidden",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-4 shrink-0",children:[o.jsxs("div",{className:"flex gap-1.5",children:[o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-500/20"}),o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-amber-500/20"}),o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-emerald-500/20"})]}),o.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest opacity-40 ml-2",children:"Foundation Terminal"})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:[m.length===0?o.jsxs("div",{className:"text-zinc-700 italic flex flex-col items-center justify-center h-full opacity-50",children:[o.jsx(Io,{className:"h-8 w-8 mb-2"}),o.jsx("span",{children:"Awaiting synchronization..."})]}):m.map((j,_)=>o.jsxs("div",{className:ge("mb-1.5 leading-relaxed break-words",j.includes("✅")||j.includes("success")?"text-emerald-400":j.includes("❌")||j.includes("Error")?"text-red-400 font-bold":j.includes("🚀")||j.includes("[System]")?"text-primary":""),children:[o.jsx("span",{className:"opacity-30 mr-2",children:_+1}),j]},_)),o.jsx("div",{ref:w})]})]})]})]}),o.jsx(tr,{className:"p-8 pt-0 flex-col sm:flex-row gap-3",children:o.jsxs("div",{className:"flex gap-3 w-full",children:[o.jsxs(ae,{type:"button",variant:"secondary",onClick:()=>u(1),disabled:d,className:"flex-1 h-11 rounded-xl font-black text-[10px] uppercase tracking-widest",children:[o.jsx(Qo,{className:"h-4 w-4 mr-2 opacity-60"}),"Snooze 1h"]}),o.jsxs(ae,{type:"button",variant:"secondary",onClick:()=>u(24),disabled:d,className:"flex-1 h-11 rounded-xl font-black text-[10px] uppercase tracking-widest",children:[o.jsx(zw,{className:"h-4 w-4 mr-2 opacity-60"}),"Tomorrow"]})]})})]})})})}const R6=[{id:"bay-area-utilities",name:"Bay Area Utilities",description:"PG&E, Recology, EBMUD, and SCE bill handling",policies:4,tags:["utilities","california"]},{id:"freelancer-tax",name:"Freelancer Tax Pack",description:"1099-NEC, W-9, invoices, and estimated taxes",policies:6,tags:["finance","tax"]},{id:"medical-records",name:"Medical Records",description:"EOB, lab results, prescription receipts",policies:5,tags:["health","insurance"]},{id:"legal-docs",name:"Legal Documents",description:"Contracts, notices, deeds, and court documents",policies:3,tags:["legal","priority"]}];function O6({initialCompose:t,onInitialConsumed:e}){const[s,i]=v.useState([]),[l,u]=v.useState(!0),[d,h]=v.useState(""),[m,g]=v.useState(!1),[y,x]=v.useState(null),[w,S]=v.useState(!1),[E,j]=v.useState(!1),[_,N]=v.useState(null),[k,C]=v.useState("policies"),[A,D]=v.useState([]),[z,V]=v.useState(""),[R,P]=v.useState(""),[Z,te]=v.useState(null),[me,Ee]=v.useState(null),[ye,_e]=v.useState(null),[$,Y]=v.useState(!1),[J,pe]=v.useState({name:"",description:"",keywords:"",matchStrategy:"ANY",actions:[{type:"copy",destination:"",filename:"",columns:[],spreadsheet_id:"",range:""}],tags:"",priority:100}),[se,M]=v.useState(!1),U=v.useCallback(async()=>{u(!0);const B=await Te.getPolicies?.(Z);B?.data?.policies&&i(B.data.policies),u(!1)},[Z]),W=v.useCallback(async()=>{try{const ie=(await Te.getSDKChatProviders?.())?.data?.providers??[];D(ie),ie.length>0&&!z&&(V(ie[0].provider),P(ie[0].models?.[0]?.id??""))}catch{}},[z]);v.useEffect(()=>{const B=un();B&&B.auth.getSession().then(({data:ie})=>{te(ie.session?.access_token??null)})},[]),v.useEffect(()=>{U(),W()},[U,W]),v.useEffect(()=>{t&&(h(t),e?.())},[t,e]);const ne=async()=>{if(d.trim()){g(!0),x(null);try{const B=await Te.synthesizePolicy?.({description:d,provider:z||void 0,model:R||void 0},Z);if(B?.data?.policy){x(B.data.policy),S(!1);const ie=B.data.warning;ie?ce.warning(ie):ce.success("Policy synthesized! Review and save below.")}else ce.error(B?.data?.error??"Synthesis failed.")}catch{ce.error("LLM synthesis failed.")}finally{g(!1)}}},oe=async B=>{j(!0);try{await Te.savePolicy?.(B,Z),ce.success(`Policy "${B.metadata.name}" saved.`),x(null),h(""),await U()}catch{ce.error("Failed to save policy.")}finally{j(!1)}},ue=async B=>{window.confirm(`Delete policy "${B}"?`)&&(await Te.deletePolicy?.(B,Z),ce.success("Policy deleted."),await U())},q=async B=>{i(ie=>ie.map(De=>De.metadata.id===B.metadata.id?{...De,metadata:{...De.metadata,enabled:!De.metadata.enabled}}:De));try{await Te.patchPolicy?.(B.metadata.id,{enabled:!B.metadata.enabled},Z)}catch{ce.error("Failed to toggle policy."),await U()}},fe=B=>{Ee(B.metadata.id),_e({name:B.metadata.name,description:B.metadata.description,tags:(B.metadata.tags??[]).join(", "),priority:B.metadata.priority})},re=()=>{Ee(null),_e(null)},ze=async B=>{if(ye)try{await Te.patchPolicy?.(B,{name:ye.name,description:ye.description,tags:ye.tags.split(",").map(ie=>ie.trim()).filter(Boolean),priority:ye.priority},Z),ce.success("Policy updated."),Ee(null),_e(null),await U()}catch{ce.error("Failed to save edits.")}},Be=B=>{h(B.metadata.description),C("policies"),ce.success("Description pre-filled — edit and click ✨ to re-synthesize.")},kt=async()=>{await Te.reloadPolicies?.(Z),await U(),ce.success("Policies reloaded.")},et=(B,ie,De)=>{pe(qe=>{const ft=qe.actions.map((Zt,Ve)=>Ve===B?{...Zt,[ie]:De}:Zt);return{...qe,actions:ft}})},le=()=>{pe(B=>({...B,actions:[...B.actions,{type:"copy",destination:"",filename:"",columns:[],spreadsheet_id:"",range:""}]}))},Fe=B=>{pe(ie=>({...ie,actions:ie.actions.filter((De,qe)=>qe!==B)}))},de=B=>B.type==="append_to_google_sheet"&&!B.spreadsheet_id?.trim(),Me=J.actions.some(de),at=async()=>{if(!J.name.trim())return;const B=J.actions.findIndex(de);if(B!==-1){ce.error(`Action #${B+1}: "Append to Google Sheet" requires Spreadsheet ID or Google Sheet URL.`);return}M(!0);try{const ie=J.name.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),De=J.keywords.split(",").map(Ve=>Ve.trim()).filter(Boolean),qe=J.tags.split(",").map(Ve=>Ve.trim()).filter(Boolean),ft=J.actions.filter(Ve=>Ve.type==="copy_to_gdrive"||Ve.type==="auto_rename"||Ve.type==="append_to_google_sheet"||Ve.destination.trim()).map(Ve=>{const en={type:Ve.type};if(Ve.type==="copy")en.destination=Ve.destination,Ve.filename&&(en.filename=Ve.filename);else if(Ve.type==="rename")en.destination=Ve.destination;else if(Ve.type!=="auto_rename"){if(Ve.type==="copy_to_gdrive")Ve.destination.trim()&&(en.destination=Ve.destination.trim()),Ve.filename&&(en.filename=Ve.filename);else if(Ve.type==="log_csv")en.path=Ve.destination;else if(Ve.type==="append_to_google_sheet"){const ll=Ve.spreadsheet_id?.trim();ll&&(en.spreadsheet_id=ll);const Ms=Ve.range?.trim();Ms&&(en.range=Ms);const Kt=(Ve.columns??[]).map(Wn=>Wn.trim()).filter(Boolean);Kt.length>0&&(en.columns=Kt)}}return en}),Zt={metadata:{id:ie,name:J.name.trim(),description:J.description.trim(),priority:J.priority,tags:qe,enabled:!0},spec:{match:{strategy:J.matchStrategy,conditions:De.length>0?[{type:"keyword",value:De}]:[{type:"keyword",value:[]}]},extract:[],actions:ft}};await Te.savePolicy?.(Zt,Z),ce.success(`Policy "${Zt.metadata.name}" created.`),Y(!1),pe({name:"",description:"",keywords:"",matchStrategy:"ANY",actions:[{type:"copy",destination:"",filename:"",columns:[],spreadsheet_id:"",range:""}],tags:"",priority:100}),await U()}catch{ce.error("Failed to create policy.")}finally{M(!1)}},Ut=B=>{if(B.type==="append_to_google_sheet"){const ie=B.spreadsheet_id?.trim()||B.spreadsheet_url?.trim()||"",De=B.range?.trim()||"";return ie&&De?`${ie} (${De})`:ie||De}return B.type==="log_csv"?B.path?.trim()||"":B.destination?.trim()||B.pattern?.trim()||""},Xn=(B,ie)=>{x(De=>{if(!De)return De;const qe=(De.spec.actions??[]).map((ft,Zt)=>Zt===B?{...ft,...ie}:ft);return{...De,spec:{...De.spec,actions:qe}}})},Sr=(B=>{if(!B)return[];const ie=[];B.metadata.name?.trim()||ie.push("Policy name is missing."),B.metadata.id?.trim()||ie.push("Policy id is missing.");const De=B.spec.actions??[];return De.length===0&&ie.push("At least one action is required."),De.forEach((qe,ft)=>{qe.type==="append_to_google_sheet"&&(qe.spreadsheet_id?.trim()||qe.spreadsheet_url?.trim()||ie.push(`Action #${ft+1} append_to_google_sheet is missing spreadsheet_id / URL.`)),qe.type==="copy"&&!qe.destination?.trim()&&ie.push(`Action #${ft+1} copy is missing destination.`),qe.type==="rename"&&!(qe.pattern?.trim()||qe.destination?.trim())&&ie.push(`Action #${ft+1} rename is missing pattern.`)}),ie})(y),Uu=!!y&&Sr.length===0&&!E;return o.jsxs("div",{className:"w-full mx-auto px-8 py-10 space-y-10 animate-in fade-in duration-500",children:[o.jsxs("div",{className:"flex items-end justify-between",children:[o.jsxs("div",{children:[o.jsxs("h1",{className:"text-3xl font-black tracking-tight flex items-center gap-3",children:[o.jsx(Hw,{className:"w-8 h-8 text-primary"}),"Policy Engine"]}),o.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Define automation rules that govern how Folio handles your documents."})]}),o.jsxs(ae,{variant:"outline",size:"sm",onClick:kt,className:"gap-2 rounded-xl",children:[o.jsx(ma,{className:"w-4 h-4"}),"Reload"]})]}),o.jsx("div",{className:"flex gap-1 p-1 rounded-2xl bg-muted/50 border w-fit",children:["policies","packs"].map(B=>o.jsx("button",{onClick:()=>C(B),className:ge("px-5 py-2 rounded-xl text-xs font-black uppercase tracking-widest transition-all",k===B?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:B==="policies"?"Active Policies":"Policy Packs"},B))}),k==="policies"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"rounded-2xl border bg-card/60 backdrop-blur-sm p-6 shadow-sm space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[o.jsx(Cs,{className:"w-4 h-4 text-primary"}),o.jsx("h2",{className:"text-sm font-black uppercase tracking-widest",children:"Magic Composer"})]}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Describe a rule in plain English. Click ✨ to generate the policy automatically."}),A.length>0&&o.jsxs("div",{className:"flex gap-2 items-center",children:[o.jsx(Bm,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"}),o.jsx("select",{value:`${z}::${R}`,onChange:B=>{const[ie,De]=B.target.value.split("::");V(ie),P(De)},className:"text-xs rounded-lg border border-border/40 bg-background px-2 py-1 text-foreground flex-1 max-w-xs",children:A.flatMap(B=>(B.models??[]).map(ie=>o.jsxs("option",{value:`${B.provider}::${ie.id}`,children:[B.provider," / ",ie.id]},`${B.provider}::${ie.id}`)))}),o.jsx("span",{className:"text-[10px] text-muted-foreground",children:"for synthesis"})]}),o.jsxs("div",{className:"flex gap-3 items-start",children:[o.jsx(Ym,{placeholder:"e.g. If I get a bill from Tesla, move it to /Car/ folder and log the amount to my CSV…",value:d,onChange:B=>h(B.target.value),className:"flex-1 min-h-[80px] resize-none rounded-xl border-border/40 bg-background text-sm",onKeyDown:B=>{B.key==="Enter"&&(B.metaKey||B.ctrlKey)&&ne()}}),o.jsx(ae,{onClick:ne,disabled:m||!d.trim(),className:ge("h-10 w-10 p-0 rounded-xl flex items-center justify-center transition-all","bg-primary text-primary-foreground shadow-lg shadow-primary/20","hover:scale-105 active:scale-95"),title:"Synthesize policy with AI",children:m?o.jsx(rt,{className:"w-4 h-4 animate-spin"}):o.jsx(Cs,{className:"w-4 h-4"})})]}),y&&o.jsxs("div",{className:"rounded-xl border border-primary/20 bg-primary/5 p-4 space-y-3 animate-in slide-in-from-bottom-2 duration-300",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"font-black text-sm",children:y.metadata.name}),o.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:y.metadata.description})]}),o.jsxs(Pt,{variant:"outline",className:"text-[10px] uppercase font-bold",children:["Priority ",y.metadata.priority]})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3 text-xs text-muted-foreground",children:[o.jsxs("div",{className:"rounded-lg bg-muted/60 p-2",children:[o.jsx("div",{className:"font-bold uppercase tracking-widest text-[9px] mb-1 text-foreground",children:"Match"}),o.jsxs("div",{className:"space-y-1",children:[y.spec.match.conditions.length===0&&o.jsx("div",{children:"—"}),y.spec.match.conditions.map((B,ie)=>o.jsxs("div",{children:[o.jsx("span",{className:"font-mono bg-muted px-1 rounded text-[10px]",children:B.type})," ",Array.isArray(B.value)?B.value.join(", "):B.value]},`${B.type}-${ie}`))]})]}),o.jsxs("div",{className:"rounded-lg bg-muted/60 p-2",children:[o.jsx("div",{className:"font-bold uppercase tracking-widest text-[9px] mb-1 text-foreground",children:"Extract"}),o.jsxs("div",{className:"space-y-1",children:[(y.spec.extract?.length??0)===0&&o.jsx("div",{children:"—"}),y.spec.extract?.map(B=>o.jsxs("div",{children:[o.jsx("span",{className:"font-mono bg-muted px-1 rounded text-[10px]",children:B.key})," ","(",B.type,")",B.required?" *":""]},B.key))]})]}),o.jsxs("div",{className:"rounded-lg bg-muted/60 p-2",children:[o.jsx("div",{className:"font-bold uppercase tracking-widest text-[9px] mb-1 text-foreground",children:"Actions"}),o.jsxs("div",{className:"space-y-2",children:[(y.spec.actions?.length??0)===0&&o.jsx("div",{children:"—"}),y.spec.actions?.map((B,ie)=>o.jsxs("div",{className:"rounded-md border border-border/50 bg-background/80 p-2 space-y-1.5",children:[o.jsxs("div",{children:[o.jsx("span",{className:"font-mono bg-muted px-1 rounded text-[10px]",children:B.type})," ",Ut(B)]}),B.type==="copy_to_gdrive"&&o.jsx(je,{value:B.destination??"",onChange:De=>Xn(ie,{destination:De.target.value}),placeholder:"Google Drive folder ID",className:"h-7 text-[11px] rounded-lg font-mono"}),B.type==="append_to_google_sheet"&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(je,{value:B.spreadsheet_id??B.spreadsheet_url??"",onChange:De=>Xn(ie,{spreadsheet_id:De.target.value,spreadsheet_url:void 0}),placeholder:"Spreadsheet ID or URL",className:"h-7 text-[11px] rounded-lg font-mono"}),o.jsx(je,{value:B.range??"",onChange:De=>Xn(ie,{range:De.target.value}),placeholder:"Optional range (e.g. Sheet1!A:Z)",className:"h-7 text-[11px] rounded-lg font-mono"})]})]},`${B.type}-${ie}`))]})]})]}),Sr.length>0?o.jsx(jn,{className:"rounded-xl border-red-200 bg-red-50",children:o.jsxs(_n,{className:"text-xs text-red-700",children:[o.jsx("div",{className:"font-semibold mb-1",children:"Fix before saving:"}),o.jsx("div",{className:"space-y-0.5",children:Sr.map((B,ie)=>o.jsx("div",{children:B},`synth-issue-${ie}`))})]})}):o.jsx("div",{className:"text-[11px] text-emerald-700 font-semibold",children:"Policy looks valid for save."}),o.jsx("div",{className:"flex gap-2",children:o.jsx(ae,{type:"button",size:"sm",variant:"outline",onClick:()=>S(B=>!B),className:"h-7 px-2 rounded-lg text-[10px] uppercase tracking-widest",children:w?"Hide JSON":"Show JSON"})}),w&&o.jsx("pre",{className:"rounded-lg border border-border/40 bg-background p-3 text-[11px] overflow-auto max-h-72 whitespace-pre-wrap font-mono",children:JSON.stringify(y,null,2)}),o.jsxs("div",{className:"flex gap-2 pt-1",children:[o.jsx(ae,{size:"sm",onClick:()=>oe(y),disabled:!Uu,className:"flex-1 h-8 rounded-xl font-black text-[10px] uppercase tracking-widest",children:E?o.jsx(rt,{className:"w-3 h-3 animate-spin"}):"Save Policy"}),o.jsx(ae,{size:"sm",variant:"outline",onClick:()=>{x(null),S(!1)},className:"h-8 px-3 rounded-xl",children:"Discard"})]})]})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("h2",{className:"text-xs font-black uppercase tracking-widest text-muted-foreground",children:["Active Policies (",s.length,")"]}),o.jsx(ae,{size:"sm",variant:$?"secondary":"outline",onClick:()=>Y(B=>!B),className:"h-7 px-3 rounded-xl gap-1.5 text-[10px] font-black uppercase tracking-widest",children:$?o.jsxs(o.Fragment,{children:[o.jsx(zn,{className:"w-3 h-3"}),"Cancel"]}):o.jsxs(o.Fragment,{children:[o.jsx(hu,{className:"w-3 h-3"}),"Quick Create"]})})]}),$&&o.jsxs("div",{className:"rounded-2xl border border-primary/20 bg-primary/5 p-5 space-y-4 animate-in slide-in-from-top-2 duration-200",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(hu,{className:"w-3.5 h-3.5 text-primary"}),o.jsx("span",{className:"text-xs font-black uppercase tracking-widest text-primary",children:"Quick Create Policy"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{className:"col-span-2 space-y-1",children:[o.jsx(Je,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Name *"}),o.jsx(je,{placeholder:"e.g. Tesla Invoice Handler",value:J.name,onChange:B=>pe({...J,name:B.target.value}),className:"h-8 text-sm rounded-xl border-border/40 bg-background"})]}),o.jsxs("div",{className:"col-span-2 space-y-1",children:[o.jsx(Je,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Description"}),o.jsx(je,{placeholder:"What does this policy do?",value:J.description,onChange:B=>pe({...J,description:B.target.value}),className:"h-8 text-xs rounded-xl border-border/40 bg-background"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(Je,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Match Keywords"}),o.jsx(je,{placeholder:"tesla, invoice, PG&E (comma-sep)",value:J.keywords,onChange:B=>pe({...J,keywords:B.target.value}),className:"h-8 text-xs rounded-xl border-border/40 bg-background"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(Je,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Match Strategy"}),o.jsxs("select",{value:J.matchStrategy,onChange:B=>pe({...J,matchStrategy:B.target.value}),className:"h-8 w-full text-xs rounded-xl border border-border/40 bg-background px-3 text-foreground",children:[o.jsx("option",{value:"ANY",children:"ANY keyword matches"}),o.jsx("option",{value:"ALL",children:"ALL keywords match"})]})]}),o.jsxs("div",{className:"col-span-2 space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(Je,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Actions"}),o.jsxs("button",{type:"button",onClick:le,className:"flex items-center gap-1 text-[10px] font-bold text-primary hover:text-primary/80 transition-colors",children:[o.jsx(Wa,{className:"w-3 h-3"}),"Add Action"]})]}),o.jsx("div",{className:"space-y-2",children:J.actions.map((B,ie)=>{const De=!B.filename||B.filename===""?"original":B.filename==="auto"?"auto":"custom";return o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"grid grid-cols-[9rem_minmax(0,1fr)] gap-2 items-start",children:[o.jsxs("select",{value:B.type,onChange:qe=>et(ie,"type",qe.target.value),className:"h-8 text-xs rounded-xl border border-border/40 bg-background px-2 text-foreground w-full",children:[o.jsx("option",{value:"copy",children:"Copy to folder"}),o.jsx("option",{value:"rename",children:"Rename file (Pattern)"}),o.jsx("option",{value:"log_csv",children:"Log to CSV"}),o.jsx("option",{value:"copy_to_gdrive",children:"Copy to Google Drive"}),o.jsx("option",{value:"append_to_google_sheet",children:"Append to Google Sheet"})]}),o.jsxs("div",{className:"flex gap-2 items-center min-w-0",children:[B.type!=="append_to_google_sheet"&&o.jsx(je,{placeholder:B.type==="copy"?"/Car/":B.type==="copy_to_gdrive"?"Folder ID (empty = My Drive root)":B.type==="rename"?"Tesla-{date}":"/logs/invoices.csv",value:B.destination,onChange:qe=>et(ie,"destination",qe.target.value),className:"h-8 text-xs rounded-xl border-border/40 bg-background font-mono flex-1 min-w-0"}),J.actions.length>1&&o.jsx("button",{type:"button",onClick:()=>Fe(ie),className:"text-muted-foreground hover:text-destructive transition-colors shrink-0 p-1",children:o.jsx(zn,{className:"w-3.5 h-3.5"})})]})]}),(B.type==="copy"||B.type==="copy_to_gdrive")&&o.jsxs("div",{className:"grid grid-cols-[9rem_minmax(0,1fr)] gap-2 items-center",children:[o.jsx("div",{"aria-hidden":"true"}),o.jsxs("div",{className:"flex gap-2 items-center min-w-0",children:[o.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:"Filename:"}),o.jsxs("select",{value:De,onChange:qe=>{const ft=qe.target.value;ft==="original"?et(ie,"filename",""):ft==="auto"?et(ie,"filename","auto"):et(ie,"filename","{date}_{issuer}_{document_type}")},className:"h-7 text-xs rounded-lg border border-border/40 bg-background px-2 text-foreground shrink-0",children:[o.jsx("option",{value:"original",children:"Keep original"}),o.jsx("option",{value:"auto",children:"Smart rename (AI)"}),o.jsx("option",{value:"custom",children:"Custom pattern"})]}),De==="custom"&&o.jsx(je,{value:B.filename,onChange:qe=>et(ie,"filename",qe.target.value),placeholder:"{date}_{issuer}_{document_type}",className:"h-7 text-xs rounded-lg border-border/40 bg-background font-mono flex-1 min-w-0"})]})]}),B.type==="append_to_google_sheet"&&o.jsxs("div",{className:"grid grid-cols-[9rem_minmax(0,1fr)] gap-2",children:[o.jsx("div",{"aria-hidden":"true"}),o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsxs("div",{className:"flex gap-2",children:[o.jsx(je,{placeholder:"Spreadsheet ID or Google Sheet URL",value:B.spreadsheet_id||"",onChange:qe=>et(ie,"spreadsheet_id",qe.target.value),className:"h-7 text-xs rounded-lg flex-1"}),o.jsx(je,{placeholder:"Optional tab/range (e.g. Sheet1!A:F)",value:B.range||"",onChange:qe=>et(ie,"range",qe.target.value),className:"h-7 text-xs rounded-lg w-32"})]}),o.jsxs("div",{className:"flex flex-col gap-1.5 p-2 rounded-lg border border-border/40 bg-muted/20",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(Je,{className:"text-[10px] uppercase font-bold text-muted-foreground",children:"Columns Mapping (A, B, C...)"}),o.jsxs(ae,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-[10px] px-2 py-0",onClick:()=>{const qe=[...B.columns||[],""];et(ie,"columns",qe)},children:[o.jsx(Wa,{className:"w-3 h-3 mr-1"})," Add Col"]})]}),(B.columns||[]).map((qe,ft)=>o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"text-[10px] font-mono text-muted-foreground w-4 flex-shrink-0 text-center",children:String.fromCharCode(65+ft)}),o.jsx(je,{placeholder:"e.g. {Date} or Static Text",value:qe,onChange:Zt=>{const Ve=[...B.columns||[]];Ve[ft]=Zt.target.value,et(ie,"columns",Ve)},className:"h-7 text-xs rounded-lg font-mono flex-1"}),o.jsx("button",{type:"button",onClick:()=>{const Zt=(B.columns||[]).filter((Ve,en)=>en!==ft);et(ie,"columns",Zt)},className:"text-muted-foreground hover:text-destructive p-1",children:o.jsx(zn,{className:"w-3 h-3"})})]},ft)),(!B.columns||B.columns.length===0)&&o.jsx("div",{className:"text-[10px] text-muted-foreground italic text-center py-1",children:"No explicit mapping provided. Folio will auto-map by reading header row from the sheet template."})]})]})]})]},ie)})})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(Je,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Tags"}),o.jsx(je,{placeholder:"finance, cars (comma-sep)",value:J.tags,onChange:B=>pe({...J,tags:B.target.value}),className:"h-8 text-xs rounded-xl border-border/40 bg-background"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(Je,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Priority"}),o.jsx(je,{type:"number",min:1,max:999,value:J.priority,onChange:B=>pe({...J,priority:Number(B.target.value)}),className:"h-8 text-xs rounded-xl border-border/40 bg-background"})]})]}),Me&&o.jsx("p",{className:"text-[10px] text-destructive",children:'"Append to Google Sheet" actions require a Spreadsheet ID or Google Sheet URL.'}),o.jsxs("div",{className:"flex gap-2 pt-1",children:[o.jsx(ae,{size:"sm",onClick:at,disabled:se||!J.name.trim()||Me,className:"flex-1 h-8 rounded-xl font-black text-[10px] uppercase tracking-widest gap-1.5",children:se?o.jsx(rt,{className:"w-3 h-3 animate-spin"}):o.jsxs(o.Fragment,{children:[o.jsx(Wa,{className:"w-3 h-3"}),"Create Policy"]})}),o.jsx(ae,{size:"sm",variant:"outline",onClick:()=>Y(!1),className:"h-8 px-3 rounded-xl",children:"Cancel"})]})]}),l?o.jsxs("div",{className:"flex items-center justify-center py-16 text-muted-foreground",children:[o.jsx(rt,{className:"w-6 h-6 animate-spin mr-3"}),"Loading policies..."]}):s.length===0?o.jsxs(jn,{className:"rounded-2xl border-dashed",children:[o.jsx(Im,{className:"h-4 w-4"}),o.jsx(_n,{className:"text-sm",children:"No policies yet. Use the Magic Composer above to create your first one."})]}):o.jsx("div",{className:"space-y-2",children:s.map(B=>o.jsxs("div",{className:ge("rounded-2xl border bg-card/50 shadow-sm overflow-hidden transition-all",B.metadata.enabled===!1&&"opacity-60"),children:[o.jsxs("div",{className:"flex items-center gap-3 px-5 py-4",children:[o.jsx("button",{title:B.metadata.enabled===!1?"Enable policy":"Disable policy",onClick:()=>q(B),className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:B.metadata.enabled===!1?o.jsx(lA,{className:"w-5 h-5 text-muted-foreground"}):o.jsx(uA,{className:"w-5 h-5 text-primary"})}),o.jsx("div",{className:"flex-1 min-w-0",children:me===B.metadata.id&&ye?o.jsxs("div",{className:"space-y-2",onClick:ie=>ie.stopPropagation(),children:[o.jsx(je,{value:ye.name,onChange:ie=>_e({...ye,name:ie.target.value}),placeholder:"Policy name",className:"h-7 text-sm font-semibold"}),o.jsx(je,{value:ye.description,onChange:ie=>_e({...ye,description:ie.target.value}),placeholder:"Description",className:"h-7 text-xs"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(je,{value:ye.tags,onChange:ie=>_e({...ye,tags:ie.target.value}),placeholder:"Tags (comma-separated)",className:"h-7 text-xs flex-1"}),o.jsx(je,{type:"number",value:ye.priority,onChange:ie=>_e({...ye,priority:Number(ie.target.value)}),placeholder:"Priority",className:"h-7 text-xs w-20",min:1,max:999})]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx("span",{className:"font-bold text-sm truncate",children:B.metadata.name}),o.jsxs(Pt,{variant:"outline",className:"text-[9px] shrink-0",children:["P",B.metadata.priority]}),(B.metadata.learning_examples??0)>0&&o.jsxs(Pt,{variant:"secondary",className:"text-[9px] shrink-0",children:["Learned ",B.metadata.learning_examples]}),B.metadata.tags?.map(ie=>o.jsxs(Pt,{variant:"secondary",className:"text-[9px] gap-1 shrink-0",children:[o.jsx(du,{className:"w-2.5 h-2.5"}),ie]},ie))]}),o.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:B.metadata.description})]})}),o.jsx("div",{className:"flex items-center gap-1 shrink-0",children:me===B.metadata.id?o.jsxs(o.Fragment,{children:[o.jsx(ae,{size:"sm",variant:"default",className:"h-7 px-2 text-xs",onClick:()=>ze(B.metadata.id),children:"Save"}),o.jsx(ae,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs",onClick:re,children:"Cancel"})]}):o.jsxs(o.Fragment,{children:[o.jsx("button",{title:"Edit metadata",onClick:()=>fe(B),className:"text-muted-foreground hover:text-foreground transition-colors p-1",children:o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-4 h-4",children:[o.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),o.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),o.jsx("button",{title:"Re-compose with AI",onClick:()=>Be(B),className:"text-muted-foreground hover:text-primary transition-colors p-1",children:o.jsx(Cs,{className:"w-4 h-4"})}),o.jsx("button",{className:"text-muted-foreground hover:text-foreground transition-colors p-1",onClick:()=>N(_===B.metadata.id?null:B.metadata.id),children:_===B.metadata.id?o.jsx(lu,{className:"w-4 h-4"}):o.jsx(Bo,{className:"w-4 h-4"})}),o.jsx("button",{onClick:()=>ue(B.metadata.id),className:"text-muted-foreground hover:text-destructive transition-colors p-1",children:o.jsx(el,{className:"w-4 h-4"})})]})})]}),_===B.metadata.id&&o.jsxs("div",{className:"border-t px-5 py-4 bg-muted/20 space-y-3 animate-in slide-in-from-top-2 duration-200",children:[o.jsxs("div",{className:"grid grid-cols-3 gap-3 text-xs",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"font-bold uppercase tracking-widest text-[9px] text-muted-foreground mb-1",children:["Match (",B.spec.match.strategy,")"]}),B.spec.match.conditions.map((ie,De)=>o.jsxs("div",{className:"text-muted-foreground",children:[o.jsx("span",{className:"font-mono bg-muted px-1 rounded text-[10px]",children:ie.type})," ",Array.isArray(ie.value)?ie.value.join(", "):ie.value]},De))]}),o.jsxs("div",{children:[o.jsx("div",{className:"font-bold uppercase tracking-widest text-[9px] text-muted-foreground mb-1",children:"Extract"}),B.spec.extract?.map(ie=>o.jsxs("div",{className:"text-muted-foreground",children:[o.jsx("span",{className:"font-mono bg-muted px-1 rounded text-[10px]",children:ie.key})," ","(",ie.type,")",ie.required?" *":""]},ie.key))??o.jsx("span",{className:"text-muted-foreground/60",children:"—"})]}),o.jsxs("div",{children:[o.jsx("div",{className:"font-bold uppercase tracking-widest text-[9px] text-muted-foreground mb-1",children:"Actions"}),B.spec.actions?.map((ie,De)=>o.jsxs("div",{className:"text-muted-foreground",children:[o.jsx("span",{className:"font-mono bg-muted px-1 rounded text-[10px]",children:ie.type})," ",Ut(ie)]},De))??o.jsx("span",{className:"text-muted-foreground/60",children:"—"})]})]}),(B.metadata.learning_examples??0)>0&&o.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Learned examples: ",B.metadata.learning_examples,B.metadata.learning_last_at?` · last on ${new Date(B.metadata.learning_last_at).toLocaleDateString()}`:""]})]})]},B.metadata.id))})]})]}),k==="packs"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Import curated policy bundles to instantly configure Folio for common use cases."}),o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:R6.map(B=>o.jsxs("div",{className:"rounded-2xl border bg-card/60 p-5 space-y-3 hover:border-primary/30 hover:shadow-md transition-all group",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsx("p",{className:"font-black text-sm",children:B.name}),o.jsxs(Pt,{variant:"outline",className:"text-[9px] shrink-0",children:[B.policies," policies"]})]}),o.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:B.description})]}),o.jsx("div",{className:"flex flex-wrap gap-1",children:B.tags.map(ie=>o.jsxs(Pt,{variant:"secondary",className:"text-[9px] gap-1",children:[o.jsx(du,{className:"w-2.5 h-2.5"}),ie]},ie))}),o.jsxs(ae,{size:"sm",variant:"outline",className:"w-full h-8 rounded-xl font-black text-[10px] uppercase tracking-widest group-hover:border-primary/40 transition-all",onClick:()=>ce.info(`"${B.name}" import coming soon!`),children:[o.jsx(RC,{className:"w-3 h-3 mr-2"}),"Import Pack"]})]},B.id))})]})]})}function Xa(t){return!t||typeof t!="object"||Array.isArray(t)?null:t}function Wb(t){const e=[];for(const s of t){const i=Xa(s);if(!i)continue;const l=Xa(i.metadata)??{},u=Xa(i.spec)??{},d=Array.isArray(u.actions)?u.actions:[],h=typeof l.id=="string"?l.id.trim():"";if(!h)continue;const m=d.map(g=>{const y=Xa(g);return typeof y?.type=="string"?y.type.trim():""}).filter(g=>g==="append_to_google_sheet"||g==="webhook"||g==="copy_to_gdrive"||g==="copy"||g==="log_csv"||g==="notify");e.push({id:h,name:typeof l.name=="string"?l.name:h,priority:typeof l.priority=="number"?l.priority:100,riskyActions:m,learningExamples:typeof l.learning_examples=="number"?l.learning_examples:0,learningLastAt:typeof l.learning_last_at=="string"?l.learning_last_at:null})}return e.sort((s,i)=>i.priority-s.priority),e}function M6(t){if(!Array.isArray(t)||t.length===0)return null;const s=[...t].reverse().find(h=>{const m=String(h?.step??"").toLowerCase();return m.includes("learned fallback")||m.includes("learned policy candidate selected")});if(!s)return null;const i=String(s.step??"").toLowerCase(),l=Xa(s.details);if(!l)return null;const u=typeof l.reason=="string"?l.reason:i.includes("candidate selected")?"accepted":void 0,d=Xa(l.bestCandidate)??(typeof l.policyId=="string"||typeof l.score=="number"||typeof l.support=="number"?{policyId:l.policyId,score:l.score,support:l.support}:void 0);return{reason:u,evaluatedPolicies:typeof l.evaluatedPolicies=="number"?l.evaluatedPolicies:void 0,evaluatedSamples:typeof l.evaluatedSamples=="number"?l.evaluatedSamples:void 0,bestCandidate:d,topCandidates:Array.isArray(l.topCandidates)?l.topCandidates.map(h=>Xa(h)).filter(h=>!!h):void 0}}function D6(t){if(!t)return"No learned candidate details available yet.";switch(t){case"accepted":return"Learned fallback selected a policy candidate.";case"no_policy_ids":return"No candidate policies available for learned fallback.";case"no_document_features":return"Document had insufficient signals for learned fallback scoring.";case"no_feedback_samples":return"No learned examples yet. Match at least one document with learning enabled.";case"no_valid_samples":return"Learned examples exist but were too sparse to score.";case"score_below_threshold":return"A candidate was found but confidence stayed below threshold.";case"read_error":return"Learned fallback could not read feedback history.";default:return t.replace(/_/g," ")}}function P6({status:t}){return{pending:o.jsx(Qo,{className:"w-4 h-4 text-muted-foreground"}),processing:o.jsx(rt,{className:"w-4 h-4 text-blue-500 animate-spin"}),matched:o.jsx(os,{className:"w-4 h-4 text-emerald-500"}),no_match:o.jsx(em,{className:"w-4 h-4 text-amber-500"}),duplicate:o.jsx(em,{className:"w-4 h-4 text-emerald-500"}),error:o.jsx(Lw,{className:"w-4 h-4 text-destructive"})}[t]??null}function ra({children:t}){return o.jsx("div",{className:"text-[9px] font-bold uppercase tracking-widest text-muted-foreground mb-1.5",children:t})}function z6(t){const e=[];t.status==="no_match"?e.push(`I have a document named "${t.filename}" that wasn't matched by any policy.`):e.push(`I have a document named "${t.filename}" that matched a policy, but I want to create a better, more specific policy for it.`),t.mime_type&&e.push(`It is a ${t.mime_type} file.`);const s=t.extracted?Object.entries(t.extracted).filter(([i,l])=>i!=="_enrichment"&&l!=null):[];if(s.length>0){const i=s.map(([l,u])=>`${l}: ${String(u)}`).join(", ");e.push(`Partial data already extracted: ${i}.`)}return e.push("Create a policy to handle this exact type of document — infer the document type, define strict match conditions, extract key fields, and route it to an appropriate folder."),e.join(" ")}function Jb(t){if(t==null)return"null";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}const L6=["issuer","vendor","sender","document_type","date","due_date","amount","total","currency"];function U6({extracted:t}){const e=L6.filter(s=>t[s]!=null&&String(t[s]).trim()!=="").map(s=>({key:s,value:String(t[s])}));return e.length===0?null:o.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.map(({key:s,value:i})=>o.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] px-2 py-0.5 rounded-full bg-muted border",children:[o.jsx("span",{className:"text-muted-foreground font-mono",children:s}),o.jsx("span",{className:"font-medium",children:i})]},s))})}function B6({tags:t,onChange:e}){const[s,i]=v.useState(""),l=v.useRef(null),u=m=>e(t.filter(g=>g!==m)),d=()=>{const m=s.toLowerCase().trim().replace(/\s+/g,"-");if(!m||t.includes(m)){i("");return}e([...t,m]),i("")},h=m=>{m.key==="Enter"||m.key===","?(m.preventDefault(),d()):m.key==="Backspace"&&!s&&t.length>0&&e(t.slice(0,-1))};return o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 rounded-xl border px-3 py-2 bg-background min-h-[36px] cursor-text",role:"button",tabIndex:0,onClick:()=>l.current?.focus(),onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),l.current?.focus())},children:[t.map(m=>o.jsxs("span",{className:ge("inline-flex items-center gap-1 text-[10px] px-2 py-0.5 rounded-full border",kp(m)),children:[m,o.jsx("button",{onClick:g=>{g.stopPropagation(),u(m)},className:"ml-0.5 opacity-60 hover:opacity-100 transition-opacity","aria-label":`Remove ${m}`,children:o.jsx(zn,{className:"w-2.5 h-2.5"})})]},m)),o.jsx("input",{ref:l,value:s,onChange:m=>i(m.target.value),onKeyDown:h,onBlur:d,placeholder:t.length?"":"Add tags…",className:"flex-1 min-w-[80px] bg-transparent text-xs outline-none placeholder:text-muted-foreground/50"}),s&&o.jsx("button",{onClick:d,className:"text-muted-foreground hover:text-foreground transition-colors",children:o.jsx(Wa,{className:"w-3 h-3"})})]})}function V6({ingestion:t,onClose:e,onRerun:s,onTagsChange:i,onComposePolicy:l,onManualMatch:u}){const d=t.extracted&&Object.keys(t.extracted).length>0?t.extracted:null,h=d&&typeof d._enrichment=="object"&&d._enrichment!==null?d._enrichment:null,m=t.actions_taken?.length?t.actions_taken:null,[g,y]=v.useState(t.summary??null),[x,w]=v.useState(!1),[S,E]=v.useState([]),[j,_]=v.useState(!1),[N,k]=v.useState(""),[C,A]=v.useState(!0),[D,z]=v.useState(!0),[V,R]=v.useState(!1),[P,Z]=v.useState(!1),[te,me]=v.useState(null),[Ee,ye]=v.useState(!1),[_e,$]=v.useState(!1),[Y,J]=v.useState(null),[pe,se]=v.useState([]),[M,U]=v.useState(null),[W,ne]=v.useState(!1),oe=t.status!=="pending"&&t.status!=="processing",ue=!!u&&!t.policy_name&&t.status!=="pending"&&t.status!=="processing",q=M6(t.trace);v.useEffect(()=>{if(!oe||g)return;let le=!1;return(async()=>{w(!0);try{const de=(await un()?.auth.getSession())?.data?.session?.access_token??null,Me=await Te.summarizeIngestion(t.id,de);if(le)return;Me.data?.summary&&y(Me.data.summary)}catch{}finally{le||w(!1)}})(),()=>{le=!0}},[t.id]),v.useEffect(()=>{if(!ue)return;let le=!1;return(async()=>{_(!0),me(null);try{const de=(await un()?.auth.getSession())?.data?.session?.access_token??null,Me=await Te.getPolicies(de);if(le)return;if(Me?.error){const Ut=typeof Me.error=="string"?Me.error:Me.error.message;throw new Error(Ut||"Failed to load policies.")}const at=Wb(Me?.data?.policies??[]);E(at),k(Ut=>Ut||at[0]?.id||"")}catch{le||(E([]),me("Failed to load policies."))}finally{le||_(!1)}})(),()=>{le=!0}},[ue,t.id]);const fe=v.useCallback(async()=>{if(!u||!N||P)return;const Fe=S.find(de=>de.id===N)?.riskyActions??[];if(D&&Fe.length>0&&!V){me(`Re-run may trigger side-effect actions: ${Fe.join(", ")}. Enable side-effect confirmation to continue.`);return}Z(!0),me(null);try{await u({policyId:N,learn:C,rerun:D,allowSideEffects:D?V:!1}),J(null),se([]),U(null)}catch(de){const Me=de instanceof Error?de.message:String(de);me(Me||"Failed to assign policy.")}finally{Z(!1)}},[V,P,C,u,S,D,N]),re=v.useCallback(async()=>{if(!(!N||Ee||_e)){ye(!0),U(null),J(null),se([]);try{const Fe=(await un()?.auth.getSession())?.data?.session?.access_token??null,de=await Te.suggestPolicyRefinement(t.id,{policyId:N},Fe);if(de?.error){const Ut=typeof de.error=="string"?de.error:de.error.message;throw new Error(Ut||"Unable to suggest refinement.")}const Me=de?.data?.suggestion?.policy;if(!Me)throw new Error("No policy refinement draft was returned.");const at=Array.isArray(de?.data?.suggestion?.rationale)?de.data.suggestion.rationale.map(Ut=>String(Ut).trim()).filter(Boolean):[];J(Me),se(at),ne(!1)}catch(le){const Fe=le instanceof Error?le.message:String(le);U(Fe||"Unable to suggest refinement.")}finally{ye(!1)}}},[t.id,_e,Ee,N]),ze=v.useCallback(async()=>{if(!(!Y||_e)){$(!0),U(null);try{const Fe=(await un()?.auth.getSession())?.data?.session?.access_token??null,de=await Te.savePolicy(Y,Fe);if(de?.error){const at=typeof de.error=="string"?de.error:de.error.message;throw new Error(at||"Failed to apply refinement.")}ce.success(`Applied refinement to policy "${Y.metadata.name}".`),J(null),se([]),U(null),ne(!1);const Me=await Te.getPolicies(Fe);if(!Me?.error){const at=Wb(Me?.data?.policies??[]);E(at)}}catch(le){const Fe=le instanceof Error?le.message:String(le);U(Fe||"Failed to apply refinement.")}finally{$(!1)}}},[_e,Y]),Be=S.find(le=>le.id===N),kt=Be?.riskyActions??[],et=v.useCallback(le=>{le.target===le.currentTarget&&e()},[e]);return o.jsx("div",{className:"fixed inset-0 z-50 bg-black/40 backdrop-blur-sm flex items-center justify-center p-4",role:"button",tabIndex:0,onClick:et,onKeyDown:le=>{le.key==="Escape"&&(le.preventDefault(),e()),(le.key==="Enter"||le.key===" ")&&le.target===le.currentTarget&&(le.preventDefault(),e())},children:o.jsxs("div",{className:"bg-background border rounded-2xl shadow-2xl w-full max-w-xl flex flex-col overflow-hidden animate-in zoom-in-95 duration-200",children:[o.jsxs("div",{className:"flex items-start gap-3 px-6 pt-5 pb-4 border-b",children:[o.jsx("div",{className:"w-8 h-8 rounded-lg bg-muted flex items-center justify-center shrink-0 mt-0.5",children:o.jsx(Vm,{className:"w-4 h-4 text-muted-foreground"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("h2",{className:"font-bold text-sm truncate",title:t.filename,children:t.filename}),o.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[t.source," · ",new Date(t.created_at).toLocaleString(),t.file_size&&` · ${(t.file_size/1024).toFixed(1)}KB`]})]}),o.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[o.jsx(P6,{status:t.status}),o.jsx("button",{onClick:e,className:"text-muted-foreground hover:text-foreground transition-colors",children:o.jsx(zn,{className:"w-4 h-4"})})]})]}),o.jsxs("div",{className:"px-6 py-5 space-y-5 overflow-y-auto max-h-[65vh]",children:[oe&&o.jsxs("div",{children:[o.jsx(ra,{children:o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx(Cs,{className:"w-2.5 h-2.5"}),"Summary"]})}),d&&o.jsx("div",{className:"mb-2",children:o.jsx(U6,{extracted:d})}),x?o.jsxs("div",{className:"space-y-2",children:[o.jsx("div",{className:"h-3 rounded bg-muted animate-pulse w-full"}),o.jsx("div",{className:"h-3 rounded bg-muted animate-pulse w-5/6"}),o.jsx("div",{className:"h-3 rounded bg-muted animate-pulse w-4/6"})]}):g?o.jsx("p",{className:"text-xs text-foreground/80 leading-relaxed",children:g}):o.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No summary available."})]}),!oe&&o.jsx("div",{className:"rounded-xl bg-muted/40 border px-4 py-3 text-xs text-muted-foreground text-center",children:"Summary will be available after processing completes."}),o.jsxs("div",{children:[o.jsx(ra,{children:o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx(du,{className:"w-2.5 h-2.5"}),"Tags"]})}),o.jsx(B6,{tags:t.tags??[],onChange:i}),o.jsx("p",{className:"text-[10px] text-muted-foreground mt-1.5",children:"Enter to add · Backspace to remove · spaces become hyphens"})]}),o.jsxs("div",{children:[o.jsx(ra,{children:"Policy Matched"}),t.policy_name?o.jsx(Pt,{variant:"secondary",children:t.policy_name}):o.jsxs("div",{className:"space-y-2",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"No policy matched"}),ue&&o.jsxs("div",{className:"rounded-xl border bg-muted/20 p-3 space-y-2",children:[o.jsx("p",{className:"text-[10px] uppercase tracking-wider font-semibold text-muted-foreground",children:"Assign To Existing Policy"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("select",{className:"flex-1 h-8 rounded-lg border bg-background px-2 text-xs outline-none focus:ring-2 focus:ring-primary/30",value:N,onChange:le=>{k(le.target.value),R(!1),me(null),J(null),se([]),U(null)},disabled:j||P||S.length===0,children:S.length===0?o.jsx("option",{value:"",children:j?"Loading policies…":"No active policies"}):S.map(le=>o.jsx("option",{value:le.id,children:le.learningExamples>0?`${le.name} (${le.learningExamples} learned)`:le.name},le.id))}),o.jsx(ae,{variant:"outline",size:"sm",className:"h-8 rounded-lg",disabled:P||j||!N,onClick:fe,children:P?o.jsx(rt,{className:"w-3.5 h-3.5 animate-spin"}):"Match To Policy"}),o.jsx(ae,{variant:"outline",size:"sm",className:"h-8 rounded-lg",disabled:Ee||_e||j||!N,onClick:re,children:Ee?o.jsx(rt,{className:"w-3.5 h-3.5 animate-spin"}):"Suggest Refinement"})]}),Be&&o.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Learned examples for this policy: ",Be.learningExamples,Be.learningLastAt?` · last on ${new Date(Be.learningLastAt).toLocaleDateString()}`:""]}),o.jsxs("label",{className:"inline-flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[o.jsx("input",{type:"checkbox",className:"rounded border-muted-foreground/40",checked:C,onChange:le=>A(le.target.checked),disabled:P}),"Learn from this match"]}),o.jsxs("label",{className:"inline-flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[o.jsx("input",{type:"checkbox",className:"rounded border-muted-foreground/40",checked:D,onChange:le=>{z(le.target.checked),R(!1),me(null)},disabled:P}),"Re-run ingestion now (recommended)"]}),D&&kt.length>0&&o.jsxs("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/10 p-2 text-[11px] text-amber-700 space-y-1",children:[o.jsxs("p",{children:["This policy has side-effect actions: ",kt.join(", ")]}),o.jsxs("label",{className:"inline-flex items-center gap-1.5 text-[11px]",children:[o.jsx("input",{type:"checkbox",className:"rounded border-amber-500/40",checked:V,onChange:le=>R(le.target.checked),disabled:P}),"I understand this may create external writes on re-run"]})]}),(Y||M)&&o.jsxs("div",{className:"rounded-lg border border-primary/20 bg-primary/5 p-2.5 space-y-2",children:[o.jsx("p",{className:"text-[10px] uppercase tracking-wider font-semibold text-primary",children:"Policy Refinement Preview"}),M&&o.jsx("p",{className:"text-[11px] text-destructive",children:M}),Y&&o.jsxs(o.Fragment,{children:[o.jsxs("p",{className:"text-[11px] text-foreground/90",children:[Y.metadata.name," · ",Y.spec.match.conditions.length," match conditions · ",(Y.spec.extract??[]).length," extract fields"]}),pe.length>0&&o.jsx("div",{className:"space-y-1",children:pe.map((le,Fe)=>o.jsx("p",{className:"text-[10px] text-muted-foreground",children:le},`refine-rationale-${Fe}`))}),o.jsxs("div",{className:"flex gap-1.5",children:[o.jsx(ae,{variant:"outline",size:"sm",className:"h-7 rounded-lg text-[10px]",onClick:()=>ne(le=>!le),children:W?"Hide JSON":"Show JSON"}),o.jsx(ae,{size:"sm",className:"h-7 rounded-lg text-[10px]",onClick:ze,disabled:_e,children:_e?o.jsx(rt,{className:"w-3.5 h-3.5 animate-spin"}):"Apply To Policy"}),o.jsx(ae,{variant:"ghost",size:"sm",className:"h-7 rounded-lg text-[10px]",onClick:()=>{J(null),se([]),U(null),ne(!1)},children:"Discard"})]}),W&&o.jsx("pre",{className:"rounded-md border border-border/40 bg-background p-2 text-[10px] overflow-auto max-h-48 whitespace-pre-wrap font-mono",children:JSON.stringify(Y,null,2)})]})]}),te&&o.jsx("p",{className:"text-[11px] text-destructive",children:te})]})]})]}),q&&o.jsxs("div",{children:[o.jsx(ra,{children:"Learning Diagnostics"}),o.jsxs("div",{className:"rounded-xl border bg-muted/20 px-4 py-3 space-y-1.5",children:[o.jsx("p",{className:"text-xs text-foreground/90",children:D6(q.reason)}),(q.evaluatedPolicies!==void 0||q.evaluatedSamples!==void 0)&&o.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Evaluated policies: ",q.evaluatedPolicies??0," · samples: ",q.evaluatedSamples??0]}),q.bestCandidate&&o.jsxs("p",{className:"text-[11px] text-muted-foreground font-mono",children:["Best: ",String(q.bestCandidate.policyId??"-")," · score ",String(q.bestCandidate.score??"-")," · support ",String(q.bestCandidate.support??"-"),q.bestCandidate.requiredScore!==void 0?` · needed ${String(q.bestCandidate.requiredScore)}`:""]})]})]}),d&&o.jsxs("div",{children:[o.jsx(ra,{children:"Extracted Data"}),o.jsx("div",{className:"rounded-xl border overflow-hidden",children:Object.entries(d).filter(([le])=>le!=="_enrichment").map(([le,Fe])=>o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 text-xs border-b last:border-0",children:[o.jsx("span",{className:"font-mono text-muted-foreground",children:le}),o.jsx("span",{className:"font-medium text-right max-w-[55%] truncate",children:Jb(Fe)})]},le))})]}),h&&Object.keys(h).length>0&&o.jsxs("div",{children:[o.jsx(ra,{children:"Enrichment Data"}),o.jsx("div",{className:"rounded-xl border overflow-hidden",children:Object.entries(h).map(([le,Fe])=>o.jsxs("div",{className:"px-4 py-2 text-xs border-b last:border-0",children:[o.jsx("div",{className:"font-mono text-muted-foreground mb-1",children:le}),o.jsx("pre",{className:"font-medium whitespace-pre-wrap break-all",children:Jb(Fe)})]},le))})]}),m&&o.jsxs("div",{children:[o.jsx(ra,{children:"Actions Taken"}),o.jsx("ul",{className:"space-y-1",children:m.map((le,Fe)=>o.jsxs("li",{className:"flex items-center gap-2 text-xs",children:[o.jsx(os,{className:"w-3 h-3 text-emerald-500 shrink-0"}),o.jsx("span",{className:"text-muted-foreground",children:String(le)})]},Fe))})]}),t.error_message&&o.jsxs("div",{children:[o.jsx(ra,{children:"Error"}),o.jsx("div",{className:"rounded-xl bg-destructive/5 border border-destructive/20 px-4 py-3",children:o.jsx("p",{className:"text-xs text-destructive font-mono break-all",children:t.error_message})})]}),!d&&!m&&!t.error_message&&oe&&!x&&!g&&o.jsx("p",{className:"text-xs text-muted-foreground text-center py-4",children:"No extracted data or actions recorded."})]}),o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t bg-muted/20",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(ae,{variant:"outline",size:"sm",onClick:s,className:"gap-2 rounded-xl",children:[o.jsx(ma,{className:"w-3.5 h-3.5"}),"Re-run"]}),l&&o.jsxs(ae,{variant:"outline",size:"sm",onClick:()=>l(z6(t)),className:"gap-2 rounded-xl border-primary/30 text-primary hover:bg-primary/5 hover:text-primary",children:[o.jsx(Cs,{className:"w-3.5 h-3.5"}),"Create Policy"]})]}),o.jsx(ae,{variant:"ghost",size:"sm",onClick:e,className:"rounded-xl",children:"Close"})]})]})})}function I6({children:t}){return o.jsx("h3",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-3",children:t})}function $6({ingestion:t,onClose:e}){return o.jsx("div",{className:"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm flex items-center justify-center p-4 animate-in fade-in duration-200",children:o.jsxs("div",{className:"bg-card w-full max-w-3xl rounded-2xl shadow-xl border overflow-hidden flex flex-col max-h-[90vh]",children:[o.jsxs("div",{className:"px-6 py-4 border-b flex items-center justify-between bg-muted/20",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-8 h-8 rounded-lg bg-emerald-500/10 flex items-center justify-center",children:o.jsx(Io,{className:"w-4 h-4 text-emerald-500"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"font-semibold",children:"AI Processing Trace"}),o.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[400px]",title:t.filename,children:t.filename})]})]}),o.jsx("button",{onClick:e,className:"p-2 -mr-2 text-muted-foreground hover:text-foreground hover:bg-muted rounded-xl transition-colors",children:o.jsx(zn,{className:"w-4 h-4"})})]}),o.jsx("div",{className:"p-6 overflow-y-auto space-y-6",children:t.trace&&t.trace.length>0?o.jsxs("div",{children:[o.jsx(I6,{children:"Execution Log"}),o.jsx("div",{className:"rounded-xl bg-zinc-950 text-emerald-400 p-4 font-mono text-[11px] space-y-3 overflow-x-auto border border-zinc-800 shadow-inner max-h-[60vh] overflow-y-auto",children:[...t.trace].reverse().map((s,i)=>o.jsxs("div",{className:`flex gap-3 leading-relaxed ${s.step.startsWith("---")?"text-zinc-500 my-4 text-center justify-center":""}`,children:[!s.step.startsWith("---")&&o.jsx("span",{className:"opacity-40 shrink-0",children:new Date(s.timestamp).toLocaleTimeString([],{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}),o.jsxs("div",{className:s.step.startsWith("---")?"font-bold uppercase tracking-widest":"",children:[o.jsx("span",{className:"font-semibold text-zinc-100",children:s.step}),s.details&&Object.keys(s.details).length>0&&o.jsxs("pre",{className:"mt-1 flex text-emerald-500/80 whitespace-pre-wrap text-[10px]",children:[o.jsx("span",{className:"select-none opacity-30 mr-2",children:"↳"}),JSON.stringify(s.details,null,2)]})]})]},i))})]}):o.jsx("p",{className:"text-sm text-muted-foreground text-center py-12 border-2 border-dashed rounded-xl",children:"No trace logs available for this ingestion."})})]})})}const Qb=["bg-blue-500/10 text-blue-600 border-blue-500/20","bg-emerald-500/10 text-emerald-600 border-emerald-500/20","bg-amber-500/10 text-amber-700 border-amber-500/20","bg-violet-500/10 text-violet-600 border-violet-500/20","bg-rose-500/10 text-rose-600 border-rose-500/20","bg-cyan-500/10 text-cyan-600 border-cyan-500/20","bg-orange-500/10 text-orange-600 border-orange-500/20"];function kp(t){let e=0;for(const s of t)e=e*31+s.charCodeAt(0)>>>0;return Qb[e%Qb.length]}function q6({status:t}){const e={pending:{label:"Pending",icon:o.jsx(Qo,{className:"w-3 h-3"}),cls:"bg-muted text-muted-foreground"},processing:{label:"Processing",icon:o.jsx(rt,{className:"w-3 h-3 animate-spin"}),cls:"bg-blue-500/10 text-blue-500"},matched:{label:"Matched",icon:o.jsx(os,{className:"w-3 h-3"}),cls:"bg-emerald-500/10 text-emerald-500"},no_match:{label:"No Match",icon:o.jsx(em,{className:"w-3 h-3"}),cls:"bg-amber-500/10 text-amber-600"},error:{label:"Error",icon:o.jsx(Lw,{className:"w-3 h-3"}),cls:"bg-destructive/10 text-destructive"},duplicate:{label:"Duplicate",icon:o.jsx(Qk,{className:"w-3 h-3"}),cls:"bg-violet-500/10 text-violet-500"}},s=e[t]??e.pending;return o.jsxs("span",{className:ge("inline-flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded-full",s.cls),children:[s.icon,s.label]})}function H6({source:t}){const e={upload:"📄",dropzone:"📂",email:"📧",url:"🔗"};return o.jsxs("span",{className:"text-xs text-muted-foreground",children:[e[t]??"📄"," ",t]})}function G6(t){return t?t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/(1024*1024)).toFixed(1)}MB`:""}function F6({tags:t,activeFilters:e,onToggle:s}){if(!t.length)return null;const i=t.slice(0,3),l=t.length-i.length;return o.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[i.map(u=>o.jsx("button",{onClick:d=>s(u,d),className:ge("inline-flex items-center text-[9px] px-1.5 py-0 rounded-full border transition-all",kp(u),e.has(u)&&"ring-1 ring-current font-semibold"),children:u},u)),l>0&&o.jsxs("span",{className:"text-[9px] text-muted-foreground",children:["+",l]})]})}function K6({allTags:t,activeFilters:e,onToggle:s,onClear:i}){return t.length?o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground shrink-0",children:[o.jsx(du,{className:"w-3 h-3"}),o.jsx("span",{children:"Filter by tag:"})]}),o.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:t.map(l=>o.jsx("button",{onClick:()=>s(l),className:ge("inline-flex items-center text-[10px] px-2 py-0.5 rounded-full border transition-all",kp(l),e.has(l)?"ring-1 ring-current font-semibold shadow-sm":"opacity-70 hover:opacity-100"),children:l},l))}),e.size>0&&o.jsxs("button",{onClick:i,className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors",children:[o.jsx(zn,{className:"w-3 h-3"}),"Clear"]})]}):null}const Vf=20;function Y6({page:t,total:e,pageSize:s,onPage:i}){const l=Math.max(1,Math.ceil(e/s));if(l<=1&&e<=s)return null;const u=e===0?0:(t-1)*s+1,d=Math.min(t*s,e);return o.jsxs("div",{className:"flex items-center justify-between px-1 pt-2",children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:e===0?"No results":`${u}–${d} of ${e}`}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(ae,{variant:"outline",size:"sm",className:"h-7 px-2 rounded-lg",onClick:()=>i(t-1),disabled:t<=1,children:o.jsx(Jo,{className:"w-3.5 h-3.5"})}),o.jsxs("span",{className:"text-xs text-muted-foreground px-2",children:["Page ",t," of ",l]}),o.jsx(ae,{variant:"outline",size:"sm",className:"h-7 px-2 rounded-lg",onClick:()=>i(t+1),disabled:t>=l,children:o.jsx(dr,{className:"w-3.5 h-3.5"})})]})]})}function X6({onComposePolicyForDoc:t}){const[e,s]=v.useState([]),[i,l]=v.useState(0),[u,d]=v.useState(1),[h,m]=v.useState(!0),[g,y]=v.useState(!1),[x,w]=v.useState(!1),[S,E]=v.useState(null),[j,_]=v.useState(null),[N,k]=v.useState(null),[C,A]=v.useState(new Set),[D,z]=v.useState([]),[V,R]=v.useState(""),[P,Z]=v.useState(""),te=v.useRef(null),me=v.useRef(null),Ee=U=>{R(U),te.current&&clearTimeout(te.current),te.current=setTimeout(()=>{Z(U),d(1)},300)},ye=v.useCallback(async(U=u)=>{if(S===null)return;m(!0);const W=await Te.getIngestions({page:U,pageSize:Vf,q:P||void 0},S),ne=W?.data?.ingestions??[];s(ne),l(W?.data?.total??0),m(!1),z(oe=>[...new Set([...oe,...ne.flatMap(q=>q.tags??[])])].sort())},[S,P,u]);v.useEffect(()=>{const U=un();U&&U.auth.getSession().then(({data:W})=>{E(W.session?.access_token??null)})},[]),v.useEffect(()=>{S!==null&&ye(u)},[S,P,u]);const _e=v.useMemo(()=>C.size?e.filter(U=>[...C].every(W=>U.tags?.includes(W))):e,[e,C]),$=U=>{A(W=>{const ne=new Set(W);return ne.has(U)?ne.delete(U):ne.add(U),ne}),d(1)},Y=async U=>{const W=Array.from(U);if(W.length){w(!0);try{for(const ne of W){ce.info(`Ingesting ${ne.name}…`);const oe=await Te.uploadDocument?.(ne,S);if(oe?.success)if(oe.ingestion?.status==="duplicate"){const ue=oe.ingestion.extracted?.original_filename??"a previous upload";ce.warning(`${ne.name} is a duplicate of "${ue}" — skipped.`)}else ce.success(`${ne.name} → ${oe.ingestion?.status}`);else ce.error(`Failed to ingest ${ne.name}`)}d(1),await ye(1)}finally{w(!1)}}},J=U=>{U.preventDefault(),y(!1),Y(U.dataTransfer.files)},pe=async(U,W)=>{W.stopPropagation(),await Te.rerunIngestion?.(U,S),ce.success("Re-running…"),await ye(u)},se=async(U,W)=>{if(W.stopPropagation(),!window.confirm("Delete this ingestion record?"))return;await Te.deleteIngestion?.(U,S),ce.success("Deleted.");const ne=i-1,oe=Math.max(1,Math.ceil(ne/Vf)),ue=Math.min(u,oe);d(ue),await ye(ue)},M=async(U,W)=>{s(ne=>ne.map(oe=>oe.id===U?{...oe,tags:W}:oe)),j?.id===U&&_(ne=>ne&&{...ne,tags:W}),await Te.updateIngestionTags(U,W,S),z(ne=>[...new Set([...ne,...W])].sort())};return o.jsxs("div",{className:"w-full mx-auto px-8 py-10 space-y-6 animate-in fade-in duration-500",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-9 h-9 rounded-xl bg-primary/10 flex items-center justify-center",children:o.jsx(Bw,{className:"w-5 h-5 text-primary"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-xl font-bold",children:"Funnel"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Document ingestion pipeline"})]})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(ae,{variant:"outline",size:"sm",onClick:()=>ye(u),className:"gap-2 rounded-xl",children:[o.jsx(ma,{className:"w-3.5 h-3.5"}),"Refresh"]}),o.jsxs(ae,{size:"sm",onClick:()=>me.current?.click(),disabled:x,className:"gap-2 rounded-xl",children:[x?o.jsx(rt,{className:"w-3.5 h-3.5 animate-spin"}):o.jsx(tm,{className:"w-3.5 h-3.5"}),"Upload"]}),o.jsx("input",{ref:me,type:"file",multiple:!0,hidden:!0,onChange:U=>U.target.files&&Y(U.target.files)})]})]}),o.jsxs("div",{onDragOver:U=>{U.preventDefault(),y(!0)},onDragLeave:()=>y(!1),onDrop:J,onClick:()=>me.current?.click(),className:ge("rounded-2xl border-2 border-dashed transition-all cursor-pointer flex flex-col items-center justify-center gap-2 py-8",g?"border-primary bg-primary/5 scale-[1.01]":"border-muted-foreground/20 hover:border-primary/50 hover:bg-muted/30"),children:[o.jsx(tm,{className:ge("w-8 h-8 transition-colors",g?"text-primary":"text-muted-foreground/50")}),o.jsx("p",{className:"text-sm text-muted-foreground",children:g?"Drop to ingest":"Drag & drop files here, or click to browse"}),o.jsx("p",{className:"text-xs text-muted-foreground/60",children:".txt, .md, .pdf, .docx — up to 20MB"})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"relative",children:[o.jsx(qC,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground pointer-events-none"}),o.jsx("input",{type:"text",value:V,onChange:U=>Ee(U.target.value),placeholder:"Search filename, policy, summary…",className:"w-full pl-9 pr-9 py-2 text-sm rounded-xl border bg-background placeholder:text-muted-foreground/50 outline-none focus:ring-2 focus:ring-primary/30 transition"}),V&&o.jsx("button",{onClick:()=>{R(""),Z(""),d(1)},className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",children:o.jsx(zn,{className:"w-3.5 h-3.5"})})]}),D.length>0&&o.jsx(K6,{allTags:D,activeFilters:C,onToggle:$,onClear:()=>A(new Set)})]}),o.jsx("div",{className:"rounded-2xl border overflow-hidden",children:o.jsxs("table",{className:"w-full text-sm",children:[o.jsx("thead",{className:"bg-muted/40 border-b",children:o.jsxs("tr",{children:[o.jsx("th",{className:"text-left px-5 py-3 text-xs font-semibold text-muted-foreground",children:"File"}),o.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-muted-foreground",children:"Status"}),o.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-muted-foreground",children:"Policy"}),o.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-muted-foreground",children:"Source"}),o.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-muted-foreground",children:"Date"}),o.jsx("th",{className:"px-4 py-3"})]})}),o.jsx("tbody",{className:"divide-y",children:h?o.jsx("tr",{children:o.jsxs("td",{colSpan:6,className:"text-center py-12 text-muted-foreground",children:[o.jsx(rt,{className:"w-5 h-5 animate-spin mx-auto mb-2"}),"Loading…"]})}):_e.length===0?o.jsx("tr",{children:o.jsxs("td",{colSpan:6,className:"text-center py-16 text-muted-foreground",children:[o.jsx(Vm,{className:"w-8 h-8 mx-auto mb-3 opacity-30"}),o.jsx("p",{className:"text-sm",children:P||C.size>0?"No documents match your search.":"No ingestions yet — upload a document above."}),(P||C.size>0)&&o.jsx("button",{className:"mt-2 text-xs text-primary hover:underline",onClick:()=>{R(""),Z(""),A(new Set),d(1)},children:"Clear filters"})]})}):_e.map(U=>o.jsxs("tr",{onClick:()=>_(U),className:ge("cursor-pointer transition-colors",U.status==="processing"?"animate-pulse bg-blue-500/5 hover:bg-blue-500/10":"hover:bg-muted/30"),children:[o.jsxs("td",{className:"px-5 py-3.5",children:[o.jsx("div",{className:"font-medium text-sm truncate max-w-[220px]",title:U.filename,children:U.filename}),U.status==="duplicate"?o.jsxs("div",{className:"text-xs text-violet-500/80 truncate max-w-[220px]",children:["↳ ",U.extracted?.original_filename??"previously processed"]}):U.file_size&&o.jsx("div",{className:"text-xs text-muted-foreground",children:G6(U.file_size)}),o.jsx(F6,{tags:U.tags??[],activeFilters:C,onToggle:(W,ne)=>{ne.stopPropagation(),$(W)}})]}),o.jsx("td",{className:"px-4 py-3.5",children:o.jsx(q6,{status:U.status})}),o.jsx("td",{className:"px-4 py-3.5",children:U.policy_name?o.jsx(Pt,{variant:"secondary",className:"text-[10px]",children:U.policy_name}):o.jsx("span",{className:"text-muted-foreground/50 text-xs",children:"—"})}),o.jsx("td",{className:"px-4 py-3.5",children:o.jsx(H6,{source:U.source})}),o.jsx("td",{className:"px-4 py-3.5 text-xs text-muted-foreground whitespace-nowrap",children:new Date(U.created_at).toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"})}),o.jsx("td",{className:"px-4 py-3.5",children:o.jsxs("div",{className:"flex items-center gap-1 justify-end",children:[o.jsx("button",{title:"View Processing Trace",onClick:W=>{W.stopPropagation(),k(U)},className:"text-muted-foreground hover:text-emerald-500 p-1 transition-colors",children:o.jsx(Io,{className:"w-3.5 h-3.5"})}),o.jsx("button",{title:"Re-run",onClick:W=>pe(U.id,W),className:"text-muted-foreground hover:text-foreground p-1 transition-colors",children:o.jsx(ma,{className:"w-3.5 h-3.5"})}),o.jsx("button",{title:"Delete",onClick:W=>se(U.id,W),className:"text-muted-foreground hover:text-destructive p-1 transition-colors",children:o.jsx(el,{className:"w-3.5 h-3.5"})}),o.jsx(dr,{className:"w-3.5 h-3.5 text-muted-foreground/40"})]})})]},U.id))})]})}),o.jsx(Y6,{page:u,total:i,pageSize:Vf,onPage:U=>d(U)}),j&&o.jsx(V6,{ingestion:j,onClose:()=>_(null),onTagsChange:U=>M(j.id,U),onRerun:async()=>{await Te.rerunIngestion?.(j.id,S),await ye(u),_(null),ce.success("Re-running ingestion…")},onComposePolicy:t?U=>{_(null),t(U)}:void 0,onManualMatch:async({policyId:U,learn:W,rerun:ne,allowSideEffects:oe})=>{const ue=await Te.matchIngestionToPolicy(j.id,{policyId:U,learn:W,rerun:ne,allowSideEffects:oe},S);if(ue?.error){const fe=typeof ue.error=="string"?ue.error:ue.error.message;throw new Error(fe||"Failed to match ingestion to policy.")}const q=ue?.data?.ingestion;if(!q)throw new Error("Match succeeded but updated ingestion payload is missing.");q&&(s(fe=>fe.map(re=>re.id===q.id?q:re)),_(q)),await ye(u),ne?ce.success(W?"Policy matched, learned, and re-run started.":"Policy matched and re-run started."):ce.success(W?"Policy match saved and learned.":"Policy match saved.")}}),N&&o.jsx($6,{ingestion:N,onClose:()=>k(null)})]})}function W6({activeSessionId:t,onSelectSession:e,refreshTrigger:s}){const[i,l]=v.useState([]),[u,d]=v.useState(!0),h=v.useCallback(async()=>{const y=un();if(!y)return null;const{data:x}=await y.auth.getSession();return x.session?.access_token??null},[]),m=v.useCallback(async()=>{try{const y=await h(),x=await Te.getChatSessions(y);x.data?.success&&l(x.data.sessions)}catch(y){console.error("Failed to fetch sessions",y)}finally{d(!1)}},[h]);v.useEffect(()=>{m()},[m,s]);const g=async(y,x)=>{y.stopPropagation();try{const w=await un();if(!w)return;const{error:S}=await w.from("chat_sessions").delete().eq("id",x);S||(l(E=>E.filter(j=>j.id!==x)),t===x&&e(null))}catch(w){console.error(w)}};return o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsx("div",{className:"p-3 border-b border-border bg-surface/15",children:o.jsxs("button",{onClick:()=>e(null),className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-primary/10 hover:bg-primary/20 text-primary rounded-xl transition-all font-semibold text-sm border border-primary/20 cursor-pointer",children:[o.jsx(Wa,{size:16}),"New Chat"]})}),o.jsx("div",{className:"flex-1 overflow-y-auto p-2 space-y-1 scrollbar-on-hover",children:u?o.jsx("div",{className:"p-4 text-center text-xs text-muted-foreground",children:"Loading..."}):i.length===0?o.jsxs("div",{className:"p-8 text-center text-muted-foreground",children:[o.jsx(cu,{size:24,className:"mx-auto opacity-20 mb-2"}),o.jsx("p",{className:"text-xs",children:"No chat history"})]}):i.map(y=>o.jsxs("div",{onClick:()=>e(y.id),className:`group flex items-center justify-between px-3 py-3 rounded-lg cursor-pointer transition-all text-sm ${t===y.id?"bg-primary/15 text-foreground ring-1 ring-primary/30 font-medium":"text-muted-foreground hover:bg-surface/50 hover:text-foreground"}`,children:[o.jsxs("div",{className:"flex items-center gap-2.5 overflow-hidden",children:[o.jsx(cu,{size:14,className:t===y.id?"text-primary":"opacity-50"}),o.jsx("span",{className:"truncate",children:y.title})]}),o.jsx("button",{onClick:x=>g(x,y.id),className:"opacity-0 group-hover:opacity-100 p-1.5 hover:bg-destructive/10 hover:text-destructive rounded transition-all",children:o.jsx(el,{size:12})})]},y.id))})]})}function J6({message:t}){const e=t.role==="user",s=i=>i.split(`
|
|
113
|
+
`).map((l,u)=>o.jsxs("span",{children:[l,o.jsx("br",{})]},u));return o.jsx("div",{className:`flex w-full ${e?"justify-end":"justify-start"}`,children:o.jsxs("div",{className:`flex gap-3 max-w-[85%] ${e?"flex-row-reverse":"flex-row"}`,children:[o.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center shrink-0 shadow-sm ${e?"bg-primary text-primary-foreground":"bg-surface border border-border shadow-inner text-foreground"}`,children:e?o.jsx(ku,{size:14,strokeWidth:2.5}):o.jsx(Zf,{size:14,className:"text-primary",strokeWidth:2.5})}),o.jsxs("div",{className:`flex flex-col ${e?"items-end":"items-start"}`,children:[o.jsx("div",{className:`px-4 py-3 rounded-2xl text-[13px] leading-relaxed shadow-sm ${e?"bg-primary text-primary-foreground rounded-tr-sm":"bg-surface border border-border/60 text-foreground rounded-tl-sm"}`,children:o.jsx("div",{className:"font-sans break-words whitespace-pre-wrap",children:s(t.content)})}),o.jsxs("div",{className:"flex items-center gap-2 mt-1.5 px-1",children:[o.jsx("span",{className:"text-[10px] text-muted-foreground/50 font-medium tracking-wide",children:new Date(t.created_at).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}),!e&&t.context_sources&&t.context_sources.length>0&&o.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-secondary/20 text-secondary border border-secondary/20 flex items-center gap-1 font-medium",children:[o.jsx(Zf,{size:10}),t.context_sources.length," sources"]})]})]})]})})}function Fc(t){return typeof t=="string"?t:t&&typeof t=="object"&&"message"in t&&typeof t.message=="string"?t.message:"Request failed"}function Q6({sessionId:t,onContextUpdate:e,onSessionCreated:s}){const[i,l]=v.useState([]),[u,d]=v.useState(""),[h,m]=v.useState(!1),[g,y]=v.useState(!1),[x,w]=v.useState(!1),S=v.useRef(null),E=v.useRef(null),j=v.useRef(!0),_=v.useRef(null),N=v.useRef(null),k=v.useRef(null),C=v.useCallback(async()=>{const P=un();if(!P)return null;const{data:Z}=await P.auth.getSession();return Z.session?.access_token??null},[]),A=v.useCallback(async P=>{try{const Z=await C();if(!Z)throw new Error("Authentication required");const te=await Te.getChatMessages(P,Z);if(te.error)throw new Error(Fc(te.error));if(te.data?.success&&N.current===P){l(te.data.messages);const me=te.data.messages.filter(Ee=>Ee.role==="assistant"&&Array.isArray(Ee.context_sources)).flatMap(Ee=>Ee.context_sources??[]);e(me)}}catch(Z){console.error("Failed to fetch messages",Z),ce.error("Failed to load chat history")}finally{N.current===P&&w(!1)}},[C,e]);v.useEffect(()=>{if(t){if(k.current===t){k.current=null,w(!1);return}l([]),w(!0),N.current=t,A(t)}else l([]),w(!1),e([]),N.current=null},[t,A,e]),v.useEffect(()=>{j.current&&S.current&&S.current.scrollIntoView({behavior:"smooth"})},[i,g]);const D=()=>{const P=E.current;if(!P)return;const Z=P.scrollHeight-P.scrollTop-P.clientHeight;j.current=Z<64},z=async P=>{if(P?.preventDefault(),!u.trim()||h)return;const Z=u.trim();d(""),_.current&&(_.current.style.height="auto"),m(!0),y(!0);try{const te=await C();if(!te)throw new Error("Authentication required");const me={id:"temp-"+Date.now(),role:"user",content:Z,created_at:new Date().toISOString()};l($=>[...$,me]);let Ee=t;if(!Ee){const $=await Te.createChatSession(te);if($.error)throw new Error(Fc($.error));if($.data?.success)Ee=$.data.session.id,k.current=Ee,s(Ee);else throw new Error("Failed to create session")}const ye=await Te.sendChatMessage({sessionId:Ee,content:Z},te);if(ye.error)throw new Error(Fc(ye.error));const _e=ye.data?.message;ye.data?.success&&_e&&(l($=>[...$,_e]),_e.context_sources&&_e.context_sources.length>0&&e(_e.context_sources))}catch(te){console.error("Message failed",te),ce.error(Fc(te)||"Failed to send message"),l(me=>[...me,{id:"err-"+Date.now(),role:"assistant",content:"I encountered an error trying to process that request.",created_at:new Date().toISOString()}])}finally{m(!1),y(!1)}},V=P=>{P.key==="Enter"&&!P.shiftKey&&(P.preventDefault(),z())},R=["Find me the latest invoice from AWS.","What is the late penalty on the ACME contract?","Show me receipts from last week.","Summarize my recent cloud hosting expenses."];return o.jsxs(o.Fragment,{children:[o.jsxs("div",{ref:E,onScroll:D,className:"flex-1 overflow-y-auto p-5 space-y-6 scrollbar-on-hover",children:[x?o.jsxs("div",{className:"flex-1 h-full flex items-center justify-center text-muted-foreground gap-2",children:[o.jsx(ma,{size:18,className:"animate-spin"}),o.jsx("span",{className:"text-sm",children:"Loading history..."})]}):i.length===0?o.jsxs("div",{className:"h-full flex flex-col items-center justify-center p-8 text-center text-muted-foreground/80",children:[o.jsx("div",{className:"w-16 h-16 bg-primary/10 rounded-2xl flex items-center justify-center mb-6 text-primary",children:o.jsx(Cs,{size:32})}),o.jsx("h3",{className:"text-2xl font-bold mb-3 text-foreground tracking-tight",children:"Chat with your Documents"}),o.jsx("p",{className:"text-sm max-w-sm mx-auto mb-10 leading-relaxed",children:"Folio has seamlessly read and memorized your files using Semantic Search. Ask any question to retrieve precise answers and exact page citations."}),o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 max-w-lg w-full",children:R.map((P,Z)=>o.jsx("button",{onClick:()=>d(P),className:"text-left p-3.5 text-xs font-medium bg-surface/30 hover:bg-surface border border-border/50 hover:border-border rounded-xl transition-all cursor-pointer shadow-sm hover:shadow",children:P},Z))})]}):o.jsxs(o.Fragment,{children:[i.map(P=>o.jsx(J6,{message:P},P.id)),o.jsx(_p,{children:g&&o.jsx(Ro.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:"flex justify-start w-full",children:o.jsx("div",{className:"bg-surface border border-border/50 rounded-2xl rounded-tl-none px-4 py-3.5 flex items-center gap-3 shadow-sm",children:o.jsxs("div",{className:"flex gap-1.5",children:[o.jsx("span",{className:"w-1.5 h-1.5 bg-primary/60 rounded-full animate-bounce",style:{animationDelay:"0s"}}),o.jsx("span",{className:"w-1.5 h-1.5 bg-primary/60 rounded-full animate-bounce",style:{animationDelay:"0.15s"}}),o.jsx("span",{className:"w-1.5 h-1.5 bg-primary/60 rounded-full animate-bounce",style:{animationDelay:"0.3s"}})]})})})})]}),o.jsx("div",{ref:S})]}),o.jsx("div",{className:"p-4 bg-surface/40 backdrop-blur-xl border-t border-border/50",children:o.jsx("form",{onSubmit:z,className:"relative max-w-4xl mx-auto",children:o.jsxs("div",{className:"relative flex items-end gap-2 bg-surface/80 border border-border/60 hover:border-border rounded-2xl px-3 py-2 shadow-sm transition-all focus-within:ring-2 focus-within:ring-primary/20 focus-within:border-primary/50",children:[o.jsx("textarea",{ref:_,value:u,onChange:P=>{d(P.target.value),P.target.style.height="auto",P.target.style.height=Math.min(P.target.scrollHeight,200)+"px"},onKeyDown:V,placeholder:"Message Folio AI...",rows:1,className:"w-full bg-transparent border-none focus:ring-0 focus:outline-none py-2.5 pl-1 text-sm text-foreground resize-none min-h-[44px] max-h-[200px] placeholder:text-muted-foreground/50",disabled:h}),o.jsx("button",{type:"submit",disabled:!u.trim()||h,className:"p-2.5 mb-1 bg-primary text-primary-foreground rounded-xl shadow-md hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed transition-all shrink-0 cursor-pointer",children:h?o.jsx(ma,{size:18,className:"animate-spin"}):o.jsx(GC,{size:18})})]})})})]})}function Z6({sources:t,onClose:e}){return!t||t.length===0?null:o.jsx(_p,{children:o.jsxs(Ro.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},className:"flex flex-col h-full",children:[o.jsxs("div",{className:"p-4 border-b border-border flex items-center justify-between bg-surface/15",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground/80",children:[o.jsx(Rk,{size:16,className:"text-secondary"}),o.jsx("span",{children:"Retrieved Context"})]}),o.jsx("button",{onClick:e,className:"p-1 hover:bg-surface rounded-md text-muted-foreground hover:text-foreground transition-colors cursor-pointer",children:o.jsx(zn,{size:14})})]}),o.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-3 scrollbar-on-hover",children:t.map((s,i)=>{const l=Math.round(s.similarity*100);return o.jsxs("div",{className:"p-3 bg-surface/20 hover:bg-surface/50 border border-border rounded-xl transition-all group",children:[o.jsxs("div",{className:"flex justify-between items-start mb-2",children:[o.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-bold",children:[o.jsx("span",{className:"flex items-center justify-center w-4 h-4 bg-primary/10 text-primary rounded",children:i+1}),o.jsxs("span",{className:`px-1.5 py-0.5 rounded border ${l>=80?"bg-amber-500/10 text-amber-600 border-amber-500/20":"bg-blue-500/10 text-blue-500 border-blue-500/20"}`,children:[l,"% Match"]})]}),o.jsx("button",{onClick:()=>{console.log("Open Ingestion ID:",s.ingestion_id)},className:"opacity-0 group-hover:opacity-100 focus-visible:opacity-100 text-muted-foreground hover:text-primary transition-opacity focus-visible:ring-2 focus-visible:ring-primary/40 rounded cursor-pointer",title:"View Source Document",children:o.jsx(Uw,{size:12})})]}),o.jsxs("div",{className:"text-[11px] text-muted-foreground leading-relaxed line-clamp-4 font-mono bg-black/5 p-2 rounded-lg border border-border/40",children:['"',s.content,'"']})]},i)})}),o.jsxs("div",{className:"p-3 border-t border-border bg-surface/20 text-[10px] text-center text-muted-foreground/50 font-medium",children:[t.length," document chunk",t.length!==1?"s":""," retrieved"]})]})})}function eP(){const[t,e]=v.useState(null),[s,i]=v.useState([]),[l,u]=v.useState(!1),[d,h]=v.useState(0),m=v.useCallback(y=>{e(y),h(x=>x+1)},[]),g=v.useCallback(y=>{i(y),y.length>0&&u(!0)},[]);return o.jsxs("div",{className:"flex w-full h-[calc(100vh-15rem)] min-h-[540px] gap-4 overflow-hidden animate-in fade-in duration-500",children:[o.jsx("div",{className:"w-64 shrink-0 flex flex-col h-full bg-surface/25 backdrop-blur-xl border border-border rounded-xl overflow-hidden shadow-sm",children:o.jsx(W6,{activeSessionId:t,onSelectSession:e,refreshTrigger:d})}),o.jsx("div",{className:"flex-1 min-w-0 flex flex-col h-full bg-surface/60 rounded-xl overflow-hidden border border-border relative shadow-sm",children:o.jsx(Q6,{sessionId:t,onContextUpdate:g,onSessionCreated:m})}),l&&o.jsx("div",{className:"w-80 shrink-0 flex flex-col h-full bg-surface/25 backdrop-blur-xl border border-border rounded-xl overflow-hidden shadow-sm",children:o.jsx(Z6,{sources:s,onClose:()=>u(!1)})})]})}const Aj=v.createContext(void 0);function tP({children:t}){const[e,s]=v.useState(!1),i=v.useCallback(()=>s(!0),[]),l=v.useCallback(()=>s(!1),[]),u=v.useMemo(()=>({isExpanded:e,setIsExpanded:s,openTerminal:i,closeTerminal:l}),[e,i,l]);return o.jsx(Aj.Provider,{value:u,children:t})}function nP(){const t=v.useContext(Aj);if(t===void 0)throw new Error("useTerminal must be used within a TerminalProvider");return t}const sP=/(https?:\/\/[^\s<>"'`]+)/g;function If(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Rj(t){if(typeof t!="string"||t.trim().length===0)return null;try{const e=new URL(t.trim());return e.protocol!=="http:"&&e.protocol!=="https:"?null:e.toString()}catch{return null}}function aP(t){if(!If(t)||!If(t.remediation))return null;const e=t.remediation,s=typeof e.title=="string"?e.title.trim():"",i=typeof e.summary=="string"?e.summary.trim():"",l=typeof e.code=="string"?e.code.trim():"",u=Array.isArray(e.steps)?e.steps.filter(h=>typeof h=="string").map(h=>h.trim()).filter(Boolean):[],d=Array.isArray(e.links)?e.links.filter(If).map(h=>{const m=Rj(h.url);return m?{label:typeof h.label=="string"&&h.label.trim().length>0?h.label.trim():"Open help link",url:m}:null}).filter(h=>h!==null):[];return!s&&!i&&!l&&u.length===0&&d.length===0?null:{...s?{title:s}:{},...i?{summary:i}:{},...l?{code:l}:{},steps:u,links:d}}function Kc(t){const e=[];let s=0;for(const i of t.matchAll(sP)){const l=i[0]??"",u=i.index??0,d=u+l.length;u>s&&e.push(o.jsx("span",{children:t.slice(s,u)},`txt-${s}-${u}`));const h=Rj(l);h?e.push(o.jsx("a",{href:h,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 decoration-current/50 hover:decoration-current",onClick:m=>m.stopPropagation(),children:h},`url-${u}-${h}`)):e.push(o.jsx("span",{children:l},`txt-${u}-${d}`)),s=d}return s<t.length&&e.push(o.jsx("span",{children:t.slice(s)},`txt-${s}-${t.length}`)),e.length>0?o.jsx(o.Fragment,{children:e}):t}function iP(){const t=un(),{isExpanded:e,openTerminal:s,closeTerminal:i}=nP(),[l,u]=v.useState([]),[d,h]=v.useState(new Set),[m,g]=v.useState(!1),y=v.useRef(null);v.useEffect(()=>{let _=!0;const N=async()=>{if(!t)return;const{data:{user:A}}=await t.auth.getUser();if(!A)return;const{data:D,error:z}=await t.from("processing_events").select("*").eq("user_id",A.id).order("created_at",{ascending:!1}).limit(50);if(D&&_){u(D);const V=new Set;D.forEach(R=>{R.event_type==="error"&&R.details?.error&&V.add(R.id)}),h(V)}},k=async()=>{if(!t)return null;const{data:{user:A}}=await t.auth.getUser();return A?t.channel("processing_events_realtime").on("postgres_changes",{event:"INSERT",schema:"public",table:"processing_events",filter:`user_id=eq.${A.id}`},D=>{const z=D.new;_&&(z.event_type==="error"&&z.details?.error&&h(V=>new Set(V).add(z.id)),z.details?.is_completion||(z.event_type==="error"||z.agent_state==="action"||z.agent_state==="extraction"||z.details?.is_high_intent===!0)&&s(),u(V=>{const R=[z,...V];return z.details?.is_completion&&setTimeout(()=>{_&&i()},3e3),R.length>100?R.slice(0,100):R}),g(!0),setTimeout(()=>g(!1),500))}).subscribe():null};N();const C=k();return()=>{_=!1,C.then(A=>{A&&t&&t.removeChannel(A)})}},[t,s,i]);const x=(_,N)=>{N.stopPropagation(),h(k=>{const C=new Set(k);return C.has(_)?C.delete(_):C.add(_),C})},w=_=>{switch(_.event_type){case"error":return"border-l-rose-500/50 bg-rose-500/5 text-rose-200";case"action":return"border-l-indigo-500/50 bg-indigo-500/5 text-indigo-200";case"analysis":return"border-l-amber-500/50 bg-amber-500/5 text-amber-200";default:return"border-l-emerald-500/30 text-emerald-100 hover:bg-white/5"}},S=_=>{if(!_)return o.jsx(ur,{className:"w-3.5 h-3.5"});const N=_.toLowerCase();return N.includes("triage")?o.jsx(oC,{className:"w-3.5 h-3.5"}):N.includes("extraction")?o.jsx(Pw,{className:"w-3.5 h-3.5"}):N.includes("matching")?o.jsx($m,{className:"w-3.5 h-3.5"}):N.includes("action")?o.jsx(qw,{className:"w-3.5 h-3.5"}):N.includes("completed")?o.jsx(os,{className:"w-3.5 h-3.5"}):N.includes("error")?o.jsx(uu,{className:"w-3.5 h-3.5"}):o.jsx(Bm,{className:"w-3.5 h-3.5"})},E=_=>_||"System",j=_=>{const N=_.details?.action||_.details?.error;if(typeof N=="string"&&N.trim().length>0)return N;const k=JSON.stringify(_.details);return typeof k=="string"&&k.trim().length>0?k:"Event received."};return e?o.jsxs("div",{className:"fixed bottom-4 right-4 z-50 w-[450px] bg-[#0A0D14] border border-white/10 rounded-xl shadow-2xl flex flex-col overflow-hidden transition-all duration-300 ease-out h-[600px] max-h-[85vh]",children:[o.jsxs("div",{className:"px-4 py-3 border-b border-white/10 bg-white/5 flex items-center justify-between shrink-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Io,{className:"w-4 h-4 text-emerald-400"}),o.jsx("h3",{className:"font-semibold text-sm text-zinc-100 uppercase tracking-widest",children:"Live Trace"}),o.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-emerald-500/10 border border-emerald-500/20 ml-2",children:[o.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${m?"bg-emerald-400 animate-pulse":"bg-emerald-500/50"}`}),o.jsx("span",{className:"text-[9px] font-medium text-emerald-400/80 uppercase tracking-widest",children:m?"Streaming":"Connected"})]})]}),o.jsx("button",{onClick:_=>{_.stopPropagation(),i()},className:"p-1.5 hover:bg-white/10 rounded-md text-zinc-400 hover:text-white transition-colors",children:o.jsx($w,{className:"w-4 h-4"})})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-2 font-mono text-xs flex flex-col gap-1.5 custom-scrollbar bg-[#05070A]",children:[l.length===0?o.jsxs("div",{className:"flex items-center justify-center h-full text-zinc-500 flex-col gap-2",children:[o.jsx(ur,{className:"w-6 h-6 opacity-20"}),o.jsx("span",{className:"text-sm",children:"Waiting for ingestion events..."})]}):l.map(_=>{const N=d.has(_.id),k=aP(_.details);return o.jsx("div",{className:`border-l-2 pl-3 py-2 pr-2 rounded-r-md transition-colors ${w(_)}`,children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"shrink-0 pt-0.5 opacity-60",children:S(_.agent_state)}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[o.jsx("span",{className:"text-[10px] opacity-50 shrink-0",children:new Date(_.created_at).toLocaleTimeString([],{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}),o.jsx("span",{className:"text-[10px] font-bold tracking-wider uppercase opacity-80 shrink-0",children:E(_.agent_state)}),_.ingestion_id&&o.jsx("span",{className:"text-[10px] text-zinc-500 truncate ml-auto uppercase",title:_.ingestion_id,children:_.ingestion_id.substring(0,8)})]}),o.jsx("div",{className:"leading-relaxed break-words whitespace-pre-wrap",children:Kc(j(_))}),_.event_type==="error"&&k&&o.jsxs("div",{className:"mt-2 rounded border border-amber-400/30 bg-amber-500/10 px-2.5 py-2 text-[10px] text-amber-100 space-y-1.5",children:[o.jsx("p",{className:"font-semibold uppercase tracking-wider text-[9px] text-amber-200",children:"Suggested Fix"}),k.title&&o.jsx("p",{className:"font-semibold text-amber-100",children:Kc(k.title)}),k.summary&&o.jsx("p",{className:"text-amber-100/90",children:Kc(k.summary)}),k.code&&o.jsxs("p",{className:"text-amber-200/90",children:["Code: ",k.code]}),k.steps.length>0&&o.jsx("ol",{className:"list-decimal pl-4 space-y-1 text-amber-100/90",children:k.steps.map(C=>o.jsx("li",{children:Kc(C)},`${_.id}-fix-step-${C}-${C.length}`))}),k.links.length>0&&o.jsx("div",{className:"flex flex-wrap gap-1.5 pt-0.5",children:k.links.map(C=>o.jsx("a",{href:C.url,target:"_blank",rel:"noreferrer",className:"inline-flex items-center rounded border border-amber-300/40 px-2 py-1 text-[9px] font-semibold uppercase tracking-wider text-amber-100 hover:bg-amber-300/10",onClick:A=>A.stopPropagation(),children:C.label},`${_.id}-fix-link-${C.url}`))})]}),_.event_type!=="info"&&_.details&&Object.keys(_.details).length>(_.details.action?1:0)&&o.jsx("div",{className:"mt-2 text-[10px]",children:_.event_type==="error"?o.jsxs("div",{className:"bg-rose-950/30 rounded border border-rose-500/20 overflow-hidden",children:[o.jsxs("button",{className:"w-full text-left px-2 py-1 flex justify-between items-center hover:bg-rose-500/10 text-rose-300 font-semibold uppercase tracking-wider text-[9px]",onClick:C=>x(_.id,C),children:[o.jsx("span",{children:"Error Details"}),o.jsx("span",{className:"opacity-50",children:N?"Hide":"Show"})]}),N&&o.jsx("pre",{className:"p-2 border-t border-rose-500/20 overflow-x-auto text-rose-200/80 custom-scrollbar",children:JSON.stringify(_.details,null,2)})]}):o.jsx("div",{className:"bg-black/20 rounded border border-white/5 p-2 overflow-x-auto text-white/50 custom-scrollbar",children:o.jsx("pre",{children:JSON.stringify(Object.fromEntries(Object.entries(_.details).filter(([C])=>C!=="action")),null,2)})})})]})]})},_.id)}),o.jsx("div",{ref:y,className:"h-4 shrink-0"})]}),o.jsxs("div",{className:"shrink-0 p-3 bg-white/5 border-t border-white/10 flex items-center gap-2 text-zinc-500 text-xs",children:[o.jsx("span",{className:"text-emerald-500/50 font-bold",children:"➜"}),o.jsx("span",{className:"animate-pulse",children:"_"})]})]}):o.jsxs("button",{type:"button",className:"fixed bottom-4 right-4 z-50 bg-[#0A0D14] border border-white/10 rounded-full py-2 px-4 shadow-xl flex items-center gap-3 cursor-pointer transition-all hover:bg-[#11141D] hover:border-white/20",onClick:s,children:[o.jsxs("div",{className:"relative",children:[o.jsx(Io,{className:`w-4 h-4 ${m?"text-emerald-400":"text-zinc-400"}`}),m&&o.jsx("div",{className:"absolute inset-0 bg-emerald-400/20 blur-sm rounded-full animate-pulse"})]}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-xs font-medium text-zinc-200",children:"Live Trace"}),o.jsx("span",{className:"text-[10px] text-zinc-500 leading-none mt-0.5",children:l.length>0?E(l[0].agent_state):"Idle"})]}),o.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500/50 shadow-[0_0_8px_rgba(16,185,129,0.5)] ml-1"})]})}function rP(){const t=v.useMemo(()=>$o(),[]),[e,s]=v.useState("dashboard"),[i,l]=v.useState(null),[u,d]=v.useState(!t),[h,m]=v.useState(!1),[g,y]=v.useState("not_checked"),[x,w]=v.useState("Folio ready. Run setup to configure runtime contracts."),[S,E]=v.useState(t),j=jA(),[_,N]=v.useState(!1),[k,C]=v.useState(0),[A,D]=v.useState("unknown"),[z,V]=v.useState("unknown"),[R,P]=v.useState(null),[Z,te]=v.useState(null),[me,Ee]=v.useState(!1),[ye,_e]=v.useState(()=>{const q=localStorage.getItem("folio_migration_snoozed_until");return q?new Date(q):null}),[$,Y]=v.useState(null),J=v.useMemo(()=>S?zm(S.url,S.anonKey,{auth:{autoRefreshToken:!0,persistSession:!0}}):null,[S]);v.useEffect(()=>{if(!J){V("unknown"),P(null);return}const{data:q}=J.auth.onAuthStateChange((fe,re)=>{V(re?.user?"authenticated":"anonymous"),P(re?.user?.email??null),C(ze=>ze+1)});return()=>{q.subscription.unsubscribe()}},[J]),v.useEffect(()=>{let q=!1;async function fe(ze,Be){const kt=Promise.resolve(ze);let et=null;const le=new Promise((Fe,de)=>{et=setTimeout(()=>{de(new Error(`Operation timed out after ${Be}ms`))},Be)});try{return await Promise.race([kt,le])}finally{et&&clearTimeout(et)}}async function re(){if(!J){D("unknown"),V("unknown"),P(null),te(null),Y(null);return}N(!0),Y(null);try{const{data:ze,error:Be}=await fe(J.from("init_state").select("is_initialized").single(),12e3);if(Be)if(Be.code==="42P01")D("missing_view");else throw D("error"),new Error(Be.message||"Failed to query init_state");else{const Fe=Number(ze.is_initialized??0)>0;D(Fe?"initialized":"empty")}const{data:kt,error:et}=await fe(J.auth.getSession(),12e3);if(et)V("error"),P(null);else{const Fe=kt.session?.user??null;V(Fe?"authenticated":"anonymous"),P(Fe?.email??null)}const le=await fe(Qw(J),12e3);te(le)}catch(ze){const Be=ze instanceof Error?ze.message:String(ze);q||(Y(Be),w(`Bootstrap check failed: ${Be}`))}finally{q||N(!1)}}return re(),()=>{q=!0}},[J,k]);function pe(){const q=$o();E(q),d(!1),w("Setup complete. Foundation runtime is configured."),y("not_checked"),C(fe=>fe+1)}function se(){wA(),E(null),D("unknown"),V("unknown"),P(null),te(null),Y(null),d(!0),w("Stored setup was cleared. Run setup wizard again."),y("not_checked"),C(q=>q+1)}function M(){C(q=>q+1)}const U=q=>{_e(q),localStorage.setItem("folio_migration_snoozed_until",q.toISOString())},W=v.useMemo(()=>!(!Z?.needsMigration||ye&&ye>new Date),[Z,ye]),ne=[{id:"dashboard",label:"Dashboard",icon:m0},{id:"chat",label:"Chat",icon:cu},{id:"funnel",label:"Funnel",icon:Bw},{id:"policies",label:"Policies",icon:Hw},{id:"config",label:"Configuration",icon:$m}];return u||!S?o.jsx("div",{className:"min-h-screen bg-background",children:o.jsx(m5,{open:u||!S,canClose:!!S,onComplete:pe})}):A==="empty"||A==="missing_view"||z!=="authenticated"?_&&A==="unknown"?o.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:o.jsxs("div",{className:"flex flex-col items-center gap-4",children:[o.jsx(rt,{className:"w-10 h-10 animate-spin text-primary opacity-50"}),o.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.3em] text-muted-foreground animate-pulse",children:"Initializing Engine..."})]})}):o.jsx(l6,{supabase:J,initStatus:A,onSuccess:M,onResetConfigs:se}):o.jsx(tP,{children:o.jsxs("div",{className:"min-h-screen bg-background text-foreground selection:bg-primary/10 flex flex-col font-sans animate-in fade-in duration-1000",children:[W&&Z&&o.jsx(C6,{status:Z,onSnooze:U,onOpenModal:()=>Ee(!0)}),Z&&o.jsx(A6,{open:me,onOpenChange:Ee,status:Z,onSnooze:U}),o.jsx("header",{className:ge("border-b bg-background/80 backdrop-blur-xl sticky top-0 z-50 transition-all duration-500",W&&"mt-24 sm:mt-20"),children:o.jsxs("div",{className:"container max-w-[1400px] mx-auto px-8 h-20 flex items-center",children:[o.jsxs("div",{className:"flex items-center gap-3 w-[280px]",children:[o.jsx("div",{className:"w-9 h-9 flex items-center justify-center",children:o.jsx(ou,{className:"w-8 h-8"})}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h1",{className:"text-xl font-bold tracking-tight text-foreground/90",children:"Folio"}),o.jsx("div",{className:"flex items-center",children:o.jsxs("span",{className:"relative flex h-2 w-2",children:[o.jsx("span",{className:ge("animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",g==="ok"?"bg-emerald-400":"bg-primary/40")}),o.jsx("span",{className:ge("relative inline-flex rounded-full h-2 w-2",g==="ok"?"bg-emerald-500":"bg-primary/60")})]})})]})]}),o.jsx("nav",{className:"flex-1 hidden md:flex items-center justify-center gap-2",children:ne.map(q=>o.jsxs("button",{onClick:()=>s(q.id),className:ge("flex items-center gap-2 px-4 py-2 rounded-xl text-sm font-semibold transition-all duration-300",e===q.id?"bg-primary/10 text-primary shadow-sm":"text-muted-foreground/80 hover:bg-muted/60 hover:text-foreground"),children:[o.jsx(q.icon,{className:ge("w-4.5 h-4.5",e===q.id?"text-primary":"text-muted-foreground/60")}),q.label]},q.id))}),o.jsxs("div",{className:"flex items-center justify-end gap-5 w-[280px]",children:[o.jsxs("div",{className:"hidden lg:flex items-center gap-2 px-3 py-1.5 bg-muted/40 rounded-full border border-border/40 cursor-pointer hover:bg-muted/60 transition-colors",children:[o.jsx("img",{src:"https://flagcdn.com/w40/us.png",className:"w-4 h-3 rounded-sm opacity-80",alt:"EN"}),o.jsx("span",{className:"text-[10px] font-extrabold tracking-widest text-muted-foreground",children:"EN"})]}),o.jsxs(ae,{variant:"ghost",size:"icon",className:ge("rounded-full h-9 w-9 transition-all relative group",Z?.needsMigration?"text-red-500 hover:bg-red-500/10":"text-muted-foreground hover:bg-muted/60"),onClick:()=>m(!0),children:[o.jsx(ur,{className:ge("w-5 h-5",Z?.needsMigration&&"animate-pulse")}),Z?.needsMigration&&o.jsx("span",{className:"absolute top-1 right-1 h-2 w-2 rounded-full bg-red-500 ring-4 ring-red-500/20 animate-ping"})]}),o.jsx(e1,{}),o.jsx("div",{className:"w-10 h-10 rounded-full overflow-hidden border-2 border-background shadow-lg cursor-pointer ring-1 ring-border/20",onClick:()=>s("account"),children:o.jsx("div",{className:"w-full h-full bg-primary flex items-center justify-center text-primary-foreground font-black text-xs",children:R?.charAt(0).toUpperCase()||"A"})})]})]})}),o.jsxs("main",{className:"flex-1 w-full px-6 py-12 mx-auto max-w-[1600px]",children:[$&&o.jsxs(jn,{variant:"destructive",className:"mb-10 animate-in fade-in slide-in-from-top-4 duration-500",children:[o.jsx(Sn,{className:"h-5 w-5"}),o.jsx(Hm,{className:"font-bold",children:"Protocol Connection Failure"}),o.jsx(_n,{className:"text-[13px] opacity-90",children:$})]}),e==="dashboard"&&o.jsx(AA,{configSnapshot:S,configSource:j,setActivePage:s}),e==="chat"&&o.jsx(eP,{}),e==="funnel"&&o.jsx(X6,{onComposePolicyForDoc:q=>{l(q),s("policies")}}),e==="policies"&&o.jsx(O6,{initialCompose:i,onInitialConsumed:()=>l(null)}),e==="config"&&o.jsx(k6,{}),e==="account"&&o.jsx(JA,{supabase:J,sessionEmail:R,sessionStatus:z,initStatus:A,configSnapshot:S,configSource:j,onRefresh:M,onLaunchSetup:()=>d(!0),onResetSetup:se})]}),o.jsx(iP,{}),o.jsx("div",{className:"fixed bottom-6 left-6 z-[60]",children:o.jsx(ae,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full shadow-xl bg-background border border-border/40 text-muted-foreground hover:text-primary hover:scale-110 transition-all",children:o.jsx(m0,{className:"w-6 h-6"})})}),o.jsx("footer",{className:"border-t bg-card/20 py-10 mt-auto",children:o.jsxs("div",{className:"container max-w-7xl mx-auto px-8 flex items-center justify-between text-[11px] text-muted-foreground font-bold uppercase tracking-[0.2em] opacity-40",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{children:"Core Foundation Protocol"}),o.jsx("div",{className:"w-1 h-1 rounded-full bg-muted-foreground"}),o.jsx("span",{children:"2026"})]}),o.jsxs("div",{className:"flex items-center gap-8",children:[o.jsx("a",{href:"#",className:"hover:text-foreground transition-colors",children:"Whitepaper"}),o.jsx("a",{href:"#",className:"hover:text-foreground transition-colors",children:"Foundation Registry"})]})]})}),o.jsx(WO,{open:h,onOpenChange:m,health:g,isBootstrapping:_,initStatus:A||"unknown",sessionStatus:z||"unknown",migrationStatus:Z,onRunMigration:()=>{m(!1),Ee(!0)}})]})})}s2.createRoot(document.getElementById("root")).render(o.jsx(ew.StrictMode,{children:o.jsx(nR,{defaultTheme:"dark",storageKey:"folio-theme",children:o.jsx(d6,{children:o.jsx(f6,{children:o.jsxs(y6,{children:[o.jsx(rP,{}),o.jsx(CA,{})]})})})})}));
|