import{j as m}from"./vendor-query-DxCcOIl8.js";import{r as _,a as Fl}from"./vendor-react-DO-R8FnS.js";import{b as Wl,u as ql,L as ne}from"./vendor-router-DakTd-wc.js";import{c as ae,u as Kn,X as hs,b as Hl,P as Gn,d as Kl,e as on,a as Ge,f as Gl,S as zl}from"./index-CnGg_HSs.js";/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Jl=ae("BookOpen",[["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"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Pr=ae("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Yl=ae("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Xl=ae("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Cr=ae("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Zl=ae("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ql=ae("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ec=ae("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Kt=ae("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Rr=ae("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const tc=ae("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const sc=ae("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),zn=_.createContext({});function Jn(t){const e=_.useRef(null);return e.current===null&&(e.current=t()),e.current}const nc=typeof window<"u",Ta=nc?_.useLayoutEffect:_.useEffect,Ts=_.createContext(null);function Yn(t,e){t.indexOf(e)===-1&&t.push(e)}function ds(t,e){const s=t.indexOf(e);s>-1&&t.splice(s,1)}const be=(t,e,s)=>s>e?e:s<t?t:s;let ks=()=>{},ft=()=>{};const De={},ka=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function Aa(t){return typeof t=="object"&&t!==null}const Ea=t=>/^0[^.\s]+$/u.test(t);function Pa(t){let e;return()=>(e===void 0&&(e=t()),e)}const ie=t=>t,rc=(t,e)=>s=>e(t(s)),Ut=(...t)=>t.reduce(rc),jt=(t,e,s)=>{const n=e-t;return n===0?1:(s-t)/n};class Xn{constructor(){this.subscriptions=[]}add(e){return Yn(this.subscriptions,e),()=>ds(this.subscriptions,e)}notify(e,s,n){const r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,s,n);else for(let i=0;i<r;i++){const a=this.subscriptions[i];a&&a(e,s,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Z=t=>t*1e3,re=t=>t/1e3;function Ca(t,e){return e?t*(1e3/e):0}const Ra=(t,e,s)=>(((1-3*s+3*e)*t+(3*s-6*e))*t+3*e)*t,ic=1e-7,ac=12;function oc(t,e,s,n,r){let i,a,o=0;do a=e+(s-e)/2,i=Ra(a,n,r)-t,i>0?s=a:e=a;while(Math.abs(i)>ic&&++o<ac);return a}function Ft(t,e,s,n){if(t===e&&s===n)return ie;const r=i=>oc(i,0,1,t,s);return i=>i===0||i===1?i:Ra(r(i),e,n)}const ja=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Oa=t=>e=>1-t(1-e),Da=Ft(.33,1.53,.69,.99),Zn=Oa(Da),Ia=ja(Zn),Na=t=>t>=1?1:(t*=2)<1?.5*Zn(t):.5*(2-Math.pow(2,-10*(t-1))),Qn=t=>1-Math.sin(Math.acos(t)),Ma=Oa(Qn),$a=ja(Qn),lc=Ft(.42,0,1,1),cc=Ft(0,0,.58,1),La=Ft(.42,0,.58,1),uc=t=>Array.isArray(t)&&typeof t[0]!="number",Ba=t=>Array.isArray(t)&&typeof t[0]=="number",jr={linear:ie,easeIn:lc,easeInOut:La,easeOut:cc,circIn:Qn,circInOut:$a,circOut:Ma,backIn:Zn,backInOut:Ia,backOut:Da,anticipate:Na},hc=t=>typeof t=="string",Or=t=>{if(Ba(t)){ft(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,s,n,r]=t;return Ft(e,s,n,r)}else if(hc(t))return ft(jr[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),jr[t];return t},Gt=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"],Dr={value:null,addProjectionMetrics:null};function dc(t,e){let s=new Set,n=new Set,r=!1,i=!1;const a=new WeakSet;let o={delta:0,timestamp:0,isProcessing:!1},l=0;function c(h){a.has(h)&&(u.schedule(h),t()),l++,h(o)}const u={schedule:(h,d=!1,f=!1)=>{const y=f&&r?s:n;return d&&a.add(h),y.add(h),h},cancel:h=>{n.delete(h),a.delete(h)},process:h=>{if(o=h,r){i=!0;return}r=!0;const d=s;s=n,n=d,s.forEach(c),e&&Dr.value&&Dr.value.frameloop[e].push(l),l=0,s.clear(),r=!1,i&&(i=!1,u.process(h))}};return u}const fc=40;function Va(t,e){let s=!1,n=!0;const r={delta:0,timestamp:0,isProcessing:!1},i=()=>s=!0,a=Gt.reduce((v,x)=>(v[x]=dc(i,e?x:void 0),v),{}),{setup:o,read:l,resolveKeyframes:c,preUpdate:u,update:h,preRender:d,render:f,postRender:p}=a,y=()=>{const v=De.useManualTiming,x=v?r.timestamp:performance.now();s=!1,v||(r.delta=n?1e3/60:Math.max(Math.min(x-r.timestamp,fc),1)),r.timestamp=x,r.isProcessing=!0,o.process(r),l.process(r),c.process(r),u.process(r),h.process(r),d.process(r),f.process(r),p.process(r),r.isProcessing=!1,s&&e&&(n=!1,t(y))},g=()=>{s=!0,n=!0,r.isProcessing||t(y)};return{schedule:Gt.reduce((v,x)=>{const S=a[x];return v[x]=(k,j=!1,E=!1)=>(s||g(),S.schedule(k,j,E)),v},{}),cancel:v=>{for(let x=0;x<Gt.length;x++)a[Gt[x]].cancel(v)},state:r,steps:a}}const{schedule:D,cancel:Ie,state:z,steps:Ds}=Va(typeof requestAnimationFrame<"u"?requestAnimationFrame:ie,!0);let ns;function pc(){ns=void 0}const Y={now:()=>(ns===void 0&&Y.set(z.isProcessing||De.useManualTiming?z.timestamp:performance.now()),ns),set:t=>{ns=t,queueMicrotask(pc)}},Ua=t=>e=>typeof e=="string"&&e.startsWith(t),Fa=Ua("--"),mc=Ua("var(--"),er=t=>mc(t)?gc.test(t.split("/*")[0].trim()):!1,gc=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Ir(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const yt={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Ot={...yt,transform:t=>be(0,1,t)},zt={...yt,default:1},St=t=>Math.round(t*1e5)/1e5,tr=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function yc(t){return t==null}const vc=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,sr=(t,e)=>s=>!!(typeof s=="string"&&vc.test(s)&&s.startsWith(t)||e&&!yc(s)&&Object.prototype.hasOwnProperty.call(s,e)),Wa=(t,e,s)=>n=>{if(typeof n!="string")return n;const[r,i,a,o]=n.match(tr);return{[t]:parseFloat(r),[e]:parseFloat(i),[s]:parseFloat(a),alpha:o!==void 0?parseFloat(o):1}},wc=t=>be(0,255,t),Is={...yt,transform:t=>Math.round(wc(t))},qe={test:sr("rgb","red"),parse:Wa("red","green","blue"),transform:({red:t,green:e,blue:s,alpha:n=1})=>"rgba("+Is.transform(t)+", "+Is.transform(e)+", "+Is.transform(s)+", "+St(Ot.transform(n))+")"};function bc(t){let e="",s="",n="",r="";return t.length>5?(e=t.substring(1,3),s=t.substring(3,5),n=t.substring(5,7),r=t.substring(7,9)):(e=t.substring(1,2),s=t.substring(2,3),n=t.substring(3,4),r=t.substring(4,5),e+=e,s+=s,n+=n,r+=r),{red:parseInt(e,16),green:parseInt(s,16),blue:parseInt(n,16),alpha:r?parseInt(r,16)/255:1}}const ln={test:sr("#"),parse:bc,transform:qe.transform},Wt=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Ee=Wt("deg"),we=Wt("%"),T=Wt("px"),xc=Wt("vh"),_c=Wt("vw"),Nr={...we,parse:t=>we.parse(t)/100,transform:t=>we.transform(t*100)},ot={test:sr("hsl","hue"),parse:Wa("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:s,alpha:n=1})=>"hsla("+Math.round(t)+", "+we.transform(St(e))+", "+we.transform(St(s))+", "+St(Ot.transform(n))+")"},U={test:t=>qe.test(t)||ln.test(t)||ot.test(t),parse:t=>qe.test(t)?qe.parse(t):ot.test(t)?ot.parse(t):ln.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?qe.transform(t):ot.transform(t),getAnimatableNone:t=>{const e=U.parse(t);return e.alpha=0,U.transform(e)}},Sc=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Tc(t){var e,s;return isNaN(t)&&typeof t=="string"&&(((e=t.match(tr))==null?void 0:e.length)||0)+(((s=t.match(Sc))==null?void 0:s.length)||0)>0}const qa="number",Ha="color",kc="var",Ac="var(",Mr="${}",Ec=/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 pt(t){const e=t.toString(),s=[],n={color:[],number:[],var:[]},r=[];let i=0;const o=e.replace(Ec,l=>(U.test(l)?(n.color.push(i),r.push(Ha),s.push(U.parse(l))):l.startsWith(Ac)?(n.var.push(i),r.push(kc),s.push(l)):(n.number.push(i),r.push(qa),s.push(parseFloat(l))),++i,Mr)).split(Mr);return{values:s,split:o,indexes:n,types:r}}function Pc(t){return pt(t).values}function Ka({split:t,types:e}){const s=t.length;return n=>{let r="";for(let i=0;i<s;i++)if(r+=t[i],n[i]!==void 0){const a=e[i];a===qa?r+=St(n[i]):a===Ha?r+=U.transform(n[i]):r+=n[i]}return r}}function Cc(t){return Ka(pt(t))}const Rc=t=>typeof t=="number"?0:U.test(t)?U.getAnimatableNone(t):t,jc=(t,e)=>typeof t=="number"?e!=null&&e.trim().endsWith("/")?t:0:Rc(t);function Oc(t){const e=pt(t);return Ka(e)(e.values.map((n,r)=>jc(n,e.split[r])))}const fe={test:Tc,parse:Pc,createTransformer:Cc,getAnimatableNone:Oc};function Ns(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 Dc({hue:t,saturation:e,lightness:s,alpha:n}){t/=360,e/=100,s/=100;let r=0,i=0,a=0;if(!e)r=i=a=s;else{const o=s<.5?s*(1+e):s+e-s*e,l=2*s-o;r=Ns(l,o,t+1/3),i=Ns(l,o,t),a=Ns(l,o,t-1/3)}return{red:Math.round(r*255),green:Math.round(i*255),blue:Math.round(a*255),alpha:n}}function fs(t,e){return s=>s>0?e:t}const N=(t,e,s)=>t+(e-t)*s,Ms=(t,e,s)=>{const n=t*t,r=s*(e*e-n)+n;return r<0?0:Math.sqrt(r)},Ic=[ln,qe,ot],Nc=t=>Ic.find(e=>e.test(t));function $r(t){const e=Nc(t);if(ks(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!e)return!1;let s=e.parse(t);return e===ot&&(s=Dc(s)),s}const Lr=(t,e)=>{const s=$r(t),n=$r(e);if(!s||!n)return fs(t,e);const r={...s};return i=>(r.red=Ms(s.red,n.red,i),r.green=Ms(s.green,n.green,i),r.blue=Ms(s.blue,n.blue,i),r.alpha=N(s.alpha,n.alpha,i),qe.transform(r))},cn=new Set(["none","hidden"]);function Mc(t,e){return cn.has(t)?s=>s<=0?t:e:s=>s>=1?e:t}function $c(t,e){return s=>N(t,e,s)}function nr(t){return typeof t=="number"?$c:typeof t=="string"?er(t)?fs:U.test(t)?Lr:Vc:Array.isArray(t)?Ga:typeof t=="object"?U.test(t)?Lr:Lc:fs}function Ga(t,e){const s=[...t],n=s.length,r=t.map((i,a)=>nr(i)(i,e[a]));return i=>{for(let a=0;a<n;a++)s[a]=r[a](i);return s}}function Lc(t,e){const s={...t,...e},n={};for(const r in s)t[r]!==void 0&&e[r]!==void 0&&(n[r]=nr(t[r])(t[r],e[r]));return r=>{for(const i in n)s[i]=n[i](r);return s}}function Bc(t,e){const s=[],n={color:0,var:0,number:0};for(let r=0;r<e.values.length;r++){const i=e.types[r],a=t.indexes[i][n[i]],o=t.values[a]??0;s[r]=o,n[i]++}return s}const Vc=(t,e)=>{const s=fe.createTransformer(e),n=pt(t),r=pt(e);return n.indexes.var.length===r.indexes.var.length&&n.indexes.color.length===r.indexes.color.length&&n.indexes.number.length>=r.indexes.number.length?cn.has(t)&&!r.values.length||cn.has(e)&&!n.values.length?Mc(t,e):Ut(Ga(Bc(n,r),r.values),s):(ks(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),fs(t,e))};function za(t,e,s){return typeof t=="number"&&typeof e=="number"&&typeof s=="number"?N(t,e,s):nr(t)(t,e)}const Uc=t=>{const e=({timestamp:s})=>t(s);return{start:(s=!0)=>D.update(e,s),stop:()=>Ie(e),now:()=>z.isProcessing?z.timestamp:Y.now()}},Ja=(t,e,s=10)=>{let n="";const r=Math.max(Math.round(e/s),2);for(let i=0;i<r;i++)n+=Math.round(t(i/(r-1))*1e4)/1e4+", ";return`linear(${n.substring(0,n.length-2)})`},ps=2e4;function rr(t){let e=0;const s=50;let n=t.next(e);for(;!n.done&&e<ps;)e+=s,n=t.next(e);return e>=ps?1/0:e}function Fc(t,e=100,s){const n=s({...t,keyframes:[0,e]}),r=Math.min(rr(n),ps);return{type:"keyframes",ease:i=>n.next(r*i).value/e,duration:re(r)}}const L={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};function un(t,e){return t*Math.sqrt(1-e*e)}const Wc=12;function qc(t,e,s){let n=s;for(let r=1;r<Wc;r++)n=n-t(n)/e(n);return n}const $s=.001;function Hc({duration:t=L.duration,bounce:e=L.bounce,velocity:s=L.velocity,mass:n=L.mass}){let r,i;ks(t<=Z(L.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let a=1-e;a=be(L.minDamping,L.maxDamping,a),t=be(L.minDuration,L.maxDuration,re(t)),a<1?(r=c=>{const u=c*a,h=u*t,d=u-s,f=un(c,a),p=Math.exp(-h);return $s-d/f*p},i=c=>{const h=c*a*t,d=h*s+s,f=Math.pow(a,2)*Math.pow(c,2)*t,p=Math.exp(-h),y=un(Math.pow(c,2),a);return(-r(c)+$s>0?-1:1)*((d-f)*p)/y}):(r=c=>{const u=Math.exp(-c*t),h=(c-s)*t+1;return-$s+u*h},i=c=>{const u=Math.exp(-c*t),h=(s-c)*(t*t);return u*h});const o=5/t,l=qc(r,i,o);if(t=Z(t),isNaN(l))return{stiffness:L.stiffness,damping:L.damping,duration:t};{const c=Math.pow(l,2)*n;return{stiffness:c,damping:a*2*Math.sqrt(n*c),duration:t}}}const Kc=["duration","bounce"],Gc=["stiffness","damping","mass"];function Br(t,e){return e.some(s=>t[s]!==void 0)}function zc(t){let e={velocity:L.velocity,stiffness:L.stiffness,damping:L.damping,mass:L.mass,isResolvedFromDuration:!1,...t};if(!Br(t,Gc)&&Br(t,Kc))if(e.velocity=0,t.visualDuration){const s=t.visualDuration,n=2*Math.PI/(s*1.2),r=n*n,i=2*be(.05,1,1-(t.bounce||0))*Math.sqrt(r);e={...e,mass:L.mass,stiffness:r,damping:i}}else{const s=Hc({...t,velocity:0});e={...e,...s,mass:L.mass},e.isResolvedFromDuration=!0}return e}function ms(t=L.visualDuration,e=L.bounce){const s=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:n,restDelta:r}=s;const i=s.keyframes[0],a=s.keyframes[s.keyframes.length-1],o={done:!1,value:i},{stiffness:l,damping:c,mass:u,duration:h,velocity:d,isResolvedFromDuration:f}=zc({...s,velocity:-re(s.velocity||0)}),p=d||0,y=c/(2*Math.sqrt(l*u)),g=a-i,b=re(Math.sqrt(l/u)),w=Math.abs(g)<5;n||(n=w?L.restSpeed.granular:L.restSpeed.default),r||(r=w?L.restDelta.granular:L.restDelta.default);let v,x,S,k,j,E;if(y<1)S=un(b,y),k=(p+y*b*g)/S,v=P=>{const M=Math.exp(-y*b*P);return a-M*(k*Math.sin(S*P)+g*Math.cos(S*P))},j=y*b*k+g*S,E=y*b*g-k*S,x=P=>Math.exp(-y*b*P)*(j*Math.sin(S*P)+E*Math.cos(S*P));else if(y===1){v=M=>a-Math.exp(-b*M)*(g+(p+b*g)*M);const P=p+b*g;x=M=>Math.exp(-b*M)*(b*P*M-p)}else{const P=b*Math.sqrt(y*y-1);v=pe=>{const _e=Math.exp(-y*b*pe),me=Math.min(P*pe,300);return a-_e*((p+y*b*g)*Math.sinh(me)+P*g*Math.cosh(me))/P};const M=(p+y*b*g)/P,q=y*b*M-g*P,xe=y*b*g-M*P;x=pe=>{const _e=Math.exp(-y*b*pe),me=Math.min(P*pe,300);return _e*(q*Math.sinh(me)+xe*Math.cosh(me))}}const O={calculatedDuration:f&&h||null,velocity:P=>Z(x(P)),next:P=>{if(!f&&y<1){const q=Math.exp(-y*b*P),xe=Math.sin(S*P),pe=Math.cos(S*P),_e=a-q*(k*xe+g*pe),me=Z(q*(j*xe+E*pe));return o.done=Math.abs(me)<=n&&Math.abs(a-_e)<=r,o.value=o.done?a:_e,o}const M=v(P);if(f)o.done=P>=h;else{const q=Z(x(P));o.done=Math.abs(q)<=n&&Math.abs(a-M)<=r}return o.value=o.done?a:M,o},toString:()=>{const P=Math.min(rr(O),ps),M=Ja(q=>O.next(P*q).value,P,30);return P+"ms "+M},toTransition:()=>{}};return O}ms.applyToOptions=t=>{const e=Fc(t,100,ms);return t.ease=e.ease,t.duration=Z(e.duration),t.type="keyframes",t};const Jc=5;function Ya(t,e,s){const n=Math.max(e-Jc,0);return Ca(s-t(n),e-n)}function hn({keyframes:t,velocity:e=0,power:s=.8,timeConstant:n=325,bounceDamping:r=10,bounceStiffness:i=500,modifyTarget:a,min:o,max:l,restDelta:c=.5,restSpeed:u}){const h=t[0],d={done:!1,value:h},f=E=>o!==void 0&&E<o||l!==void 0&&E>l,p=E=>o===void 0?l:l===void 0||Math.abs(o-E)<Math.abs(l-E)?o:l;let y=s*e;const g=h+y,b=a===void 0?g:a(g);b!==g&&(y=b-h);const w=E=>-y*Math.exp(-E/n),v=E=>b+w(E),x=E=>{const O=w(E),P=v(E);d.done=Math.abs(O)<=c,d.value=d.done?b:P};let S,k;const j=E=>{f(d.value)&&(S=E,k=ms({keyframes:[d.value,p(d.value)],velocity:Ya(v,E,d.value),damping:r,stiffness:i,restDelta:c,restSpeed:u}))};return j(0),{calculatedDuration:null,next:E=>{let O=!1;return!k&&S===void 0&&(O=!0,x(E),j(E)),S!==void 0&&E>=S?k.next(E-S):(!O&&x(E),d)}}}function Yc(t,e,s){const n=[],r=s||De.mix||za,i=t.length-1;for(let a=0;a<i;a++){let o=r(t[a],t[a+1]);if(e){const l=Array.isArray(e)?e[a]||ie:e;o=Ut(l,o)}n.push(o)}return n}function Xc(t,e,{clamp:s=!0,ease:n,mixer:r}={}){const i=t.length;if(ft(i===e.length,"Both input and output ranges must be the same length","range-length"),i===1)return()=>e[0];if(i===2&&e[0]===e[1])return()=>e[1];const a=t[0]===t[1];t[0]>t[i-1]&&(t=[...t].reverse(),e=[...e].reverse());const o=Yc(e,n,r),l=o.length,c=u=>{if(a&&u<t[0])return e[0];let h=0;if(l>1)for(;h<t.length-2&&!(u<t[h+1]);h++);const d=jt(t[h],t[h+1],u);return o[h](d)};return s?u=>c(be(t[0],t[i-1],u)):c}function Zc(t,e){const s=t[t.length-1];for(let n=1;n<=e;n++){const r=jt(0,e,n);t.push(N(s,1,r))}}function Qc(t){const e=[0];return Zc(e,t.length-1),e}function eu(t,e){return t.map(s=>s*e)}function tu(t,e){return t.map(()=>e||La).splice(0,t.length-1)}function Tt({duration:t=300,keyframes:e,times:s,ease:n="easeInOut"}){const r=uc(n)?n.map(Or):Or(n),i={done:!1,value:e[0]},a=eu(s&&s.length===e.length?s:Qc(e),t),o=Xc(a,e,{ease:Array.isArray(r)?r:tu(e,r)});return{calculatedDuration:t,next:l=>(i.value=o(l),i.done=l>=t,i)}}const su=t=>t!==null;function As(t,{repeat:e,repeatType:s="loop"},n,r=1){const i=t.filter(su),o=r<0||e&&s!=="loop"&&e%2===1?0:i.length-1;return!o||n===void 0?i[o]:n}const nu={decay:hn,inertia:hn,tween:Tt,keyframes:Tt,spring:ms};function Xa(t){typeof t.type=="string"&&(t.type=nu[t.type])}class ir{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 ru=t=>t/100;class gs extends ir{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{var n,r;const{motionValue:s}=this.options;s&&s.updatedAt!==Y.now()&&this.tick(Y.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(r=(n=this.options).onStop)==null||r.call(n))},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;Xa(e);const{type:s=Tt,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e;let{keyframes:o}=e;const l=s||Tt;l!==Tt&&typeof o[0]!="number"&&(this.mixKeyframes=Ut(ru,za(o[0],o[1])),o=[0,100]);const c=l({...e,keyframes:o});i==="mirror"&&(this.mirroredGenerator=l({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=rr(c));const{calculatedDuration:u}=c;this.calculatedDuration=u,this.resolvedDuration=u+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}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:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:l}=this;if(this.startTime===null)return n.next(0);const{delay:c=0,keyframes:u,repeat:h,repeatType:d,repeatDelay:f,type:p,onUpdate:y,finalKeyframe:g}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),s?this.currentTime=e:this.updateTime(e);const b=this.currentTime-c*(this.playbackSpeed>=0?1:-1),w=this.playbackSpeed>=0?b<0:b>r;this.currentTime=Math.max(b,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=r);let v=this.currentTime,x=n;if(h){const E=Math.min(this.currentTime,r)/o;let O=Math.floor(E),P=E%1;!P&&E>=1&&(P=1),P===1&&O--,O=Math.min(O,h+1),!!(O%2)&&(d==="reverse"?(P=1-P,f&&(P-=f/o)):d==="mirror"&&(x=a)),v=be(0,1,P)*o}let S;w?(this.delayState.value=u[0],S=this.delayState):S=x.next(v),i&&!w&&(S.value=i(S.value));let{done:k}=S;!w&&l!==null&&(k=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);const j=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&k);return j&&p!==hn&&(S.value=As(u,this.options,g,this.speed)),y&&y(S.value),j&&this.finish(),S}then(e,s){return this.finished.then(e,s)}get duration(){return re(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+re(e)}get time(){return re(this.currentTime)}set time(e){e=Z(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?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=e,this.tick(e))}getGeneratorVelocity(){const e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);const s=this.generator.next(e).value;return Ya(n=>this.generator.next(n).value,e,s)}get speed(){return this.playbackSpeed}set speed(e){const s=this.playbackSpeed!==e;s&&this.driver&&this.updateTime(Y.now()),this.playbackSpeed=e,s&&this.driver&&(this.time=re(this.currentTime))}play(){var r,i;if(this.isStopped)return;const{driver:e=Uc,startTime:s}=this.options;this.driver||(this.driver=e(a=>this.tick(a))),(i=(r=this.options).onPlay)==null||i.call(r);const n=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=n):this.holdTime!==null?this.startTime=n-this.holdTime:this.startTime||(this.startTime=s??n),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(Y.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var e,s;this.notifyFinished(),this.teardown(),this.state="finished",(s=(e=this.options).onComplete)==null||s.call(e)}cancel(){var e,s;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(s=(e=this.options).onCancel)==null||s.call(e)}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){var s;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(s=this.driver)==null||s.stop(),e.observe(this)}}function iu(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const He=t=>t*180/Math.PI,dn=t=>{const e=He(Math.atan2(t[1],t[0]));return fn(e)},au={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:dn,rotateZ:dn,skewX:t=>He(Math.atan(t[1])),skewY:t=>He(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},fn=t=>(t=t%360,t<0&&(t+=360),t),Vr=dn,Ur=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),Fr=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),ou={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Ur,scaleY:Fr,scale:t=>(Ur(t)+Fr(t))/2,rotateX:t=>fn(He(Math.atan2(t[6],t[5]))),rotateY:t=>fn(He(Math.atan2(-t[2],t[0]))),rotateZ:Vr,rotate:Vr,skewX:t=>He(Math.atan(t[4])),skewY:t=>He(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function pn(t){return t.includes("scale")?1:0}function mn(t,e){if(!t||t==="none")return pn(e);const s=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,r;if(s)n=ou,r=s;else{const o=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=au,r=o}if(!r)return pn(e);const i=n[e],a=r[1].split(",").map(cu);return typeof i=="function"?i(a):a[i]}const lu=(t,e)=>{const{transform:s="none"}=getComputedStyle(t);return mn(s,e)};function cu(t){return parseFloat(t.trim())}const vt=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],wt=new Set(vt),Wr=t=>t===yt||t===T,uu=new Set(["x","y","z"]),hu=vt.filter(t=>!uu.has(t));function du(t){const e=[];return hu.forEach(s=>{const n=t.getValue(s);n!==void 0&&(e.push([s,n.get()]),n.set(s.startsWith("scale")?1:0))}),e}const Oe={width:({x:t},{paddingLeft:e="0",paddingRight:s="0",boxSizing:n})=>{const r=t.max-t.min;return n==="border-box"?r:r-parseFloat(e)-parseFloat(s)},height:({y:t},{paddingTop:e="0",paddingBottom:s="0",boxSizing:n})=>{const r=t.max-t.min;return n==="border-box"?r:r-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})=>mn(e,"x"),y:(t,{transform:e})=>mn(e,"y")};Oe.translateX=Oe.x;Oe.translateY=Oe.y;const ze=new Set;let gn=!1,yn=!1,vn=!1;function Za(){if(yn){const t=Array.from(ze).filter(n=>n.needsMeasurement),e=new Set(t.map(n=>n.element)),s=new Map;e.forEach(n=>{const r=du(n);r.length&&(s.set(n,r),n.render())}),t.forEach(n=>n.measureInitialState()),e.forEach(n=>{n.render();const r=s.get(n);r&&r.forEach(([i,a])=>{var o;(o=n.getValue(i))==null||o.set(a)})}),t.forEach(n=>n.measureEndState()),t.forEach(n=>{n.suspendedScrollY!==void 0&&window.scrollTo(0,n.suspendedScrollY)})}yn=!1,gn=!1,ze.forEach(t=>t.complete(vn)),ze.clear()}function Qa(){ze.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(yn=!0)})}function fu(){vn=!0,Qa(),Za(),vn=!1}class ar{constructor(e,s,n,r,i,a=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=s,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state="scheduled",this.isAsync?(ze.add(this),gn||(gn=!0,D.read(Qa),D.resolveKeyframes(Za))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:s,element:n,motionValue:r}=this;if(e[0]===null){const i=r==null?void 0:r.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&s){const o=n.readValue(s,a);o!=null&&(e[0]=o)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}iu(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),ze.delete(this)}cancel(){this.state==="scheduled"&&(ze.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const pu=t=>t.startsWith("--");function eo(t,e,s){pu(e)?t.style.setProperty(e,s):t.style[e]=s}const mu={};function to(t,e){const s=Pa(t);return()=>mu[e]??s()}const gu=to(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),so=to(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),xt=([t,e,s,n])=>`cubic-bezier(${t}, ${e}, ${s}, ${n})`,qr={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:xt([0,.65,.55,1]),circOut:xt([.55,0,1,.45]),backIn:xt([.31,.01,.66,-.59]),backOut:xt([.33,1.53,.69,.99])};function no(t,e){if(t)return typeof t=="function"?so()?Ja(t,e):"ease-out":Ba(t)?xt(t):Array.isArray(t)?t.map(s=>no(s,e)||qr.easeOut):qr[t]}function yu(t,e,s,{delay:n=0,duration:r=300,repeat:i=0,repeatType:a="loop",ease:o="easeOut",times:l}={},c=void 0){const u={[e]:s};l&&(u.offset=l);const h=no(o,r);Array.isArray(h)&&(u.easing=h);const d={delay:n,duration:r,easing:Array.isArray(h)?"linear":h,fill:"both",iterations:i+1,direction:a==="reverse"?"alternate":"normal"};return c&&(d.pseudoElement=c),t.animate(u,d)}function ro(t){return typeof t=="function"&&"applyToOptions"in t}function vu({type:t,...e}){return ro(t)&&so()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class io extends ir{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;const{element:s,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:l}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,ft(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const c=vu(e);this.animation=yu(s,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){const u=As(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(u),eo(s,n,u),this.animation.cancel()}l==null||l(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var e,s;(s=(e=this.animation).finish)==null||s.call(e)}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(){var s,n,r;const e=(s=this.options)==null?void 0:s.element;!this.isPseudoElement&&(e!=null&&e.isConnected)&&((r=(n=this.animation).commitStyles)==null||r.call(n))}get duration(){var s,n;const e=((n=(s=this.animation.effect)==null?void 0:s.getComputedTiming)==null?void 0:n.call(s).duration)||0;return re(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+re(e)}get time(){return re(Number(this.animation.currentTime)||0)}set time(e){const s=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Z(e),s&&this.animation.pause()}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,rangeStart:s,rangeEnd:n,observe:r}){var i;return this.allowFlatten&&((i=this.animation.effect)==null||i.updateTiming({easing:"linear"})),this.animation.onfinish=null,e&&gu()?(this.animation.timeline=e,s&&(this.animation.rangeStart=s),n&&(this.animation.rangeEnd=n),ie):r(this)}}const ao={anticipate:Na,backInOut:Ia,circInOut:$a};function wu(t){return t in ao}function bu(t){typeof t.ease=="string"&&wu(t.ease)&&(t.ease=ao[t.ease])}const Ls=10;class xu extends io{constructor(e){bu(e),Xa(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:s,onUpdate:n,onComplete:r,element:i,...a}=this.options;if(!s)return;if(e!==void 0){s.set(e);return}const o=new gs({...a,autoplay:!1}),l=Math.max(Ls,Y.now()-this.startTime),c=be(0,Ls,l-Ls),u=o.sample(l).value,{name:h}=this.options;i&&h&&eo(i,h,u),s.setWithVelocity(o.sample(Math.max(0,l-c)).value,u,c),o.stop()}}const Hr=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(fe.test(t)||t==="0")&&!t.startsWith("url("));function _u(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 Su(t,e,s,n){const r=t[0];if(r===null)return!1;if(e==="display"||e==="visibility")return!0;const i=t[t.length-1],a=Hr(r,e),o=Hr(i,e);return ks(a===o,`You are trying to animate ${e} from "${r}" to "${i}". "${a?i:r}" is not an animatable value.`,"value-not-animatable"),!a||!o?!1:_u(t)||(s==="spring"||ro(s))&&n}function wn(t){t.duration=0,t.type="keyframes"}const oo=new Set(["opacity","clipPath","filter","transform"]),Tu=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function ku(t){for(let e=0;e<t.length;e++)if(typeof t[e]=="string"&&Tu.test(t[e]))return!0;return!1}const Au=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),Eu=Pa(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Pu(t){var h;const{motionValue:e,name:s,repeatDelay:n,repeatType:r,damping:i,type:a,keyframes:o}=t;if(!(((h=e==null?void 0:e.owner)==null?void 0:h.current)instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:u}=e.owner.getProps();return Eu()&&s&&(oo.has(s)||Au.has(s)&&ku(o))&&(s!=="transform"||!u)&&!c&&!n&&r!=="mirror"&&i!==0&&a!=="inertia"}const Cu=40;class Ru extends ir{constructor({autoplay:e=!0,delay:s=0,type:n="keyframes",repeat:r=0,repeatDelay:i=0,repeatType:a="loop",keyframes:o,name:l,motionValue:c,element:u,...h}){var p;super(),this.stop=()=>{var y,g;this._animation&&(this._animation.stop(),(y=this.stopTimeline)==null||y.call(this)),(g=this.keyframeResolver)==null||g.cancel()},this.createdAt=Y.now();const d={autoplay:e,delay:s,type:n,repeat:r,repeatDelay:i,repeatType:a,name:l,motionValue:c,element:u,...h},f=(u==null?void 0:u.KeyframeResolver)||ar;this.keyframeResolver=new f(o,(y,g,b)=>this.onKeyframesResolved(y,g,d,!b),l,c,u),(p=this.keyframeResolver)==null||p.scheduleResolve()}onKeyframesResolved(e,s,n,r){var b,w;this.keyframeResolver=void 0;const{name:i,type:a,velocity:o,delay:l,isHandoff:c,onUpdate:u}=n;this.resolvedAt=Y.now();let h=!0;Su(e,i,a,o)||(h=!1,(De.instantAnimations||!l)&&(u==null||u(As(e,n,s))),e[0]=e[e.length-1],wn(n),n.repeat=0);const f={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>Cu?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:s,...n,keyframes:e},p=h&&!c&&Pu(f),y=(w=(b=f.motionValue)==null?void 0:b.owner)==null?void 0:w.current;let g;if(p)try{g=new xu({...f,element:y})}catch{g=new gs(f)}else g=new gs(f);g.finished.then(()=>{this.notifyFinished()}).catch(ie),this.pendingTimeline&&(this.stopTimeline=g.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=g}get finished(){return this._animation?this.animation.finished:this._finished}then(e,s){return this.finished.finally(e).then(()=>{})}get animation(){var e;return this._animation||((e=this.keyframeResolver)==null||e.resume(),fu()),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(){var e;this._animation&&this.animation.cancel(),(e=this.keyframeResolver)==null||e.cancel()}}function lo(t,e,s,n=0,r=1){const i=Array.from(t).sort((c,u)=>c.sortNodePosition(u)).indexOf(e),a=t.size,o=(a-1)*n;return typeof s=="function"?s(i,a):r===1?i*n:o-i*n}const ju=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Ou(t){const e=ju.exec(t);if(!e)return[,];const[,s,n,r]=e;return[`--${s??n}`,r]}const Du=4;function co(t,e,s=1){ft(s<=Du,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[n,r]=Ou(t);if(!n)return;const i=window.getComputedStyle(e).getPropertyValue(n);if(i){const a=i.trim();return ka(a)?parseFloat(a):a}return er(r)?co(r,e,s+1):r}const Iu={type:"spring",stiffness:500,damping:25,restSpeed:10},Nu=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),Mu={type:"keyframes",duration:.8},$u={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Lu=(t,{keyframes:e})=>e.length>2?Mu:wt.has(t)?t.startsWith("scale")?Nu(e[1]):Iu:$u;function uo(t,e){if(t!=null&&t.inherit&&e){const{inherit:s,...n}=t;return{...e,...n}}return t}function or(t,e){const s=(t==null?void 0:t[e])??(t==null?void 0:t.default)??t;return s!==t?uo(s,t):s}const Bu=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function Vu(t){for(const e in t)if(!Bu.has(e))return!0;return!1}const lr=(t,e,s,n={},r,i)=>a=>{const o=or(n,t)||{},l=o.delay||n.delay||0;let{elapsed:c=0}=n;c=c-Z(l);const u={keyframes:Array.isArray(s)?s:[null,s],ease:"easeOut",velocity:e.getVelocity(),...o,delay:-c,onUpdate:d=>{e.set(d),o.onUpdate&&o.onUpdate(d)},onComplete:()=>{a(),o.onComplete&&o.onComplete()},name:t,motionValue:e,element:i?void 0:r};Vu(o)||Object.assign(u,Lu(t,u)),u.duration&&(u.duration=Z(u.duration)),u.repeatDelay&&(u.repeatDelay=Z(u.repeatDelay)),u.from!==void 0&&(u.keyframes[0]=u.from);let h=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(wn(u),u.delay===0&&(h=!0)),(De.instantAnimations||De.skipAnimations||r!=null&&r.shouldSkipAnimations)&&(h=!0,wn(u),u.delay=0),u.allowFlatten=!o.type&&!o.ease,h&&!i&&e.get()!==void 0){const d=As(u.keyframes,o);if(d!==void 0){D.update(()=>{u.onUpdate(d),u.onComplete()});return}}return o.isSync?new gs(u):new Ru(u)};function Kr(t){const e=[{},{}];return t==null||t.values.forEach((s,n)=>{e[0][n]=s.get(),e[1][n]=s.getVelocity()}),e}function cr(t,e,s,n){if(typeof e=="function"){const[r,i]=Kr(n);e=e(s!==void 0?s:t.custom,r,i)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[r,i]=Kr(n);e=e(s!==void 0?s:t.custom,r,i)}return e}function Je(t,e,s){const n=t.getProps();return cr(n,e,s!==void 0?s:n.custom,t)}const ho=new Set(["width","height","top","left","right","bottom",...vt]),Gr=30,Uu=t=>!isNaN(parseFloat(t));class Fu{constructor(e,s={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{var i;const r=Y.now();if(this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(n),this.current!==this.prev&&((i=this.events.change)==null||i.notify(this.current),this.dependents))for(const a of this.dependents)a.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=s.owner}setCurrent(e){this.current=e,this.updatedAt=Y.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Uu(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 Xn);const n=this.events[e].add(s);return e==="change"?()=>{n(),D.read(()=>{this.events.change.getSize()||this.stop()})}:n}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,n){this.set(s),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,s=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,s&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var e;(e=this.events.change)==null||e.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=Y.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Gr)return 0;const s=Math.min(this.updatedAt-this.prevUpdatedAt,Gr);return Ca(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(){var e,s;(e=this.dependents)==null||e.clear(),(s=this.events.destroy)==null||s.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function mt(t,e){return new Fu(t,e)}const bn=t=>Array.isArray(t);function Wu(t,e,s){t.hasValue(e)?t.getValue(e).set(s):t.addValue(e,mt(s))}function qu(t){return bn(t)?t[t.length-1]||0:t}function Hu(t,e){const s=Je(t,e);let{transitionEnd:n={},transition:r={},...i}=s||{};i={...i,...n};for(const a in i){const o=qu(i[a]);Wu(t,a,o)}}const J=t=>!!(t&&t.getVelocity);function Ku(t){return!!(J(t)&&t.add)}function xn(t,e){const s=t.getValue("willChange");if(Ku(s))return s.add(e);if(!s&&De.WillChange){const n=new De.WillChange("auto");t.addValue("willChange",n),n.add(e)}}function ur(t){return t.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}const Gu="framerAppearId",fo="data-"+ur(Gu);function po(t){return t.props[fo]}function zu({protectedKeys:t,needsAnimating:e},s){const n=t.hasOwnProperty(s)&&e[s]!==!0;return e[s]=!1,n}function mo(t,e,{delay:s=0,transitionOverride:n,type:r}={}){let{transition:i,transitionEnd:a,...o}=e;const l=t.getDefaultTransition();i=i?uo(i,l):l;const c=i==null?void 0:i.reduceMotion;n&&(i=n);const u=[],h=r&&t.animationState&&t.animationState.getState()[r];for(const d in o){const f=t.getValue(d,t.latestValues[d]??null),p=o[d];if(p===void 0||h&&zu(h,d))continue;const y={delay:s,...or(i||{},d)},g=f.get();if(g!==void 0&&!f.isAnimating()&&!Array.isArray(p)&&p===g&&!y.velocity){D.update(()=>f.set(p));continue}let b=!1;if(window.MotionHandoffAnimation){const x=po(t);if(x){const S=window.MotionHandoffAnimation(x,d,D);S!==null&&(y.startTime=S,b=!0)}}xn(t,d);const w=c??t.shouldReduceMotion;f.start(lr(d,f,p,w&&ho.has(d)?{type:!1}:y,t,b));const v=f.animation;v&&u.push(v)}if(a){const d=()=>D.update(()=>{a&&Hu(t,a)});u.length?Promise.all(u).then(d):d()}return u}function _n(t,e,s={}){var l;const n=Je(t,e,s.type==="exit"?(l=t.presenceContext)==null?void 0:l.custom:void 0);let{transition:r=t.getDefaultTransition()||{}}=n||{};s.transitionOverride&&(r=s.transitionOverride);const i=n?()=>Promise.all(mo(t,n,s)):()=>Promise.resolve(),a=t.variantChildren&&t.variantChildren.size?(c=0)=>{const{delayChildren:u=0,staggerChildren:h,staggerDirection:d}=r;return Ju(t,e,c,u,h,d,s)}:()=>Promise.resolve(),{when:o}=r;if(o){const[c,u]=o==="beforeChildren"?[i,a]:[a,i];return c().then(()=>u())}else return Promise.all([i(),a(s.delay)])}function Ju(t,e,s=0,n=0,r=0,i=1,a){const o=[];for(const l of t.variantChildren)l.notify("AnimationStart",e),o.push(_n(l,e,{...a,delay:s+(typeof n=="function"?0:n)+lo(t.variantChildren,l,n,r,i)}).then(()=>l.notify("AnimationComplete",e)));return Promise.all(o)}function Yu(t,e,s={}){t.notify("AnimationStart",e);let n;if(Array.isArray(e)){const r=e.map(i=>_n(t,i,s));n=Promise.all(r)}else if(typeof e=="string")n=_n(t,e,s);else{const r=typeof e=="function"?Je(t,e,s.custom):e;n=Promise.all(mo(t,r,s))}return n.then(()=>{t.notify("AnimationComplete",e)})}const Xu={test:t=>t==="auto",parse:t=>t},go=t=>e=>e.test(t),yo=[yt,T,we,Ee,_c,xc,Xu],zr=t=>yo.find(go(t));function Zu(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||Ea(t):!0}const Qu=new Set(["brightness","contrast","saturate","opacity"]);function eh(t){const[e,s]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[n]=s.match(tr)||[];if(!n)return t;const r=s.replace(n,"");let i=Qu.has(e)?1:0;return n!==s&&(i*=100),e+"("+i+r+")"}const th=/\b([a-z-]*)\(.*?\)/gu,Sn={...fe,getAnimatableNone:t=>{const e=t.match(th);return e?e.map(eh).join(" "):t}},Tn={...fe,getAnimatableNone:t=>{const e=fe.parse(t);return fe.createTransformer(t)(e.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},Jr={...yt,transform:Math.round},sh={rotate:Ee,rotateX:Ee,rotateY:Ee,rotateZ:Ee,scale:zt,scaleX:zt,scaleY:zt,scaleZ:zt,skew:Ee,skewX:Ee,skewY:Ee,distance:T,translateX:T,translateY:T,translateZ:T,x:T,y:T,z:T,perspective:T,transformPerspective:T,opacity:Ot,originX:Nr,originY:Nr,originZ:T},hr={borderWidth:T,borderTopWidth:T,borderRightWidth:T,borderBottomWidth:T,borderLeftWidth:T,borderRadius:T,borderTopLeftRadius:T,borderTopRightRadius:T,borderBottomRightRadius:T,borderBottomLeftRadius:T,width:T,maxWidth:T,height:T,maxHeight:T,top:T,right:T,bottom:T,left:T,inset:T,insetBlock:T,insetBlockStart:T,insetBlockEnd:T,insetInline:T,insetInlineStart:T,insetInlineEnd:T,padding:T,paddingTop:T,paddingRight:T,paddingBottom:T,paddingLeft:T,paddingBlock:T,paddingBlockStart:T,paddingBlockEnd:T,paddingInline:T,paddingInlineStart:T,paddingInlineEnd:T,margin:T,marginTop:T,marginRight:T,marginBottom:T,marginLeft:T,marginBlock:T,marginBlockStart:T,marginBlockEnd:T,marginInline:T,marginInlineStart:T,marginInlineEnd:T,fontSize:T,backgroundPositionX:T,backgroundPositionY:T,...sh,zIndex:Jr,fillOpacity:Ot,strokeOpacity:Ot,numOctaves:Jr},nh={...hr,color:U,backgroundColor:U,outlineColor:U,fill:U,stroke:U,borderColor:U,borderTopColor:U,borderRightColor:U,borderBottomColor:U,borderLeftColor:U,filter:Sn,WebkitFilter:Sn,mask:Tn,WebkitMask:Tn},vo=t=>nh[t],rh=new Set([Sn,Tn]);function wo(t,e){let s=vo(t);return rh.has(s)||(s=fe),s.getAnimatableNone?s.getAnimatableNone(e):void 0}const ih=new Set(["auto","none","0"]);function ah(t,e,s){let n=0,r;for(;n<t.length&&!r;){const i=t[n];typeof i=="string"&&!ih.has(i)&&pt(i).values.length&&(r=t[n]),n++}if(r&&s)for(const i of e)t[i]=wo(s,r)}class oh extends ar{constructor(e,s,n,r,i){super(e,s,n,r,i,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:s,name:n}=this;if(!s||!s.current)return;super.readKeyframes();for(let u=0;u<e.length;u++){let h=e[u];if(typeof h=="string"&&(h=h.trim(),er(h))){const d=co(h,s.current);d!==void 0&&(e[u]=d),u===e.length-1&&(this.finalKeyframe=h)}}if(this.resolveNoneKeyframes(),!ho.has(n)||e.length!==2)return;const[r,i]=e,a=zr(r),o=zr(i),l=Ir(r),c=Ir(i);if(l!==c&&Oe[n]){this.needsMeasurement=!0;return}if(a!==o)if(Wr(a)&&Wr(o))for(let u=0;u<e.length;u++){const h=e[u];typeof h=="string"&&(e[u]=parseFloat(h))}else Oe[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:s}=this,n=[];for(let r=0;r<e.length;r++)(e[r]===null||Zu(e[r]))&&n.push(r);n.length&&ah(e,n,s)}measureInitialState(){const{element:e,unresolvedKeyframes:s,name:n}=this;if(!e||!e.current)return;n==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Oe[n](e.measureViewportBox(),window.getComputedStyle(e.current)),s[0]=this.measuredOrigin;const r=s[s.length-1];r!==void 0&&e.getValue(n,r).jump(r,!1)}measureEndState(){var o;const{element:e,name:s,unresolvedKeyframes:n}=this;if(!e||!e.current)return;const r=e.getValue(s);r&&r.jump(this.measuredOrigin,!1);const i=n.length-1,a=n[i];n[i]=Oe[s](e.measureViewportBox(),window.getComputedStyle(e.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),(o=this.removedTransforms)!=null&&o.length&&this.removedTransforms.forEach(([l,c])=>{e.getValue(l).set(c)}),this.resolveNoneKeyframes()}}function bo(t,e,s){if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){const r=document.querySelectorAll(t);return r?Array.from(r):[]}return Array.from(t).filter(n=>n!=null)}const xo=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function rs(t){return Aa(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:dr,cancel:Cy}=Va(queueMicrotask,!1),ue={x:!1,y:!1};function _o(){return ue.x||ue.y}function lh(t){return t==="x"||t==="y"?ue[t]?null:(ue[t]=!0,()=>{ue[t]=!1}):ue.x||ue.y?null:(ue.x=ue.y=!0,()=>{ue.x=ue.y=!1})}function So(t,e){const s=bo(t),n=new AbortController,r={passive:!0,...e,signal:n.signal};return[s,r,()=>n.abort()]}function ch(t){return!(t.pointerType==="touch"||_o())}function uh(t,e,s={}){const[n,r,i]=So(t,s);return n.forEach(a=>{let o=!1,l=!1,c;const u=()=>{a.removeEventListener("pointerleave",p)},h=g=>{c&&(c(g),c=void 0),u()},d=g=>{o=!1,window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",d),l&&(l=!1,h(g))},f=()=>{o=!0,window.addEventListener("pointerup",d,r),window.addEventListener("pointercancel",d,r)},p=g=>{if(g.pointerType!=="touch"){if(o){l=!0;return}h(g)}},y=g=>{if(!ch(g))return;l=!1;const b=e(a,g);typeof b=="function"&&(c=b,a.addEventListener("pointerleave",p,r))};a.addEventListener("pointerenter",y,r),a.addEventListener("pointerdown",f,r)}),i}const To=(t,e)=>e?t===e?!0:To(t,e.parentElement):!1,fr=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,hh=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function dh(t){return hh.has(t.tagName)||t.isContentEditable===!0}const fh=new Set(["INPUT","SELECT","TEXTAREA"]);function ph(t){return fh.has(t.tagName)||t.isContentEditable===!0}const is=new WeakSet;function Yr(t){return e=>{e.key==="Enter"&&t(e)}}function Bs(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const mh=(t,e)=>{const s=t.currentTarget;if(!s)return;const n=Yr(()=>{if(is.has(s))return;Bs(s,"down");const r=Yr(()=>{Bs(s,"up")}),i=()=>Bs(s,"cancel");s.addEventListener("keyup",r,e),s.addEventListener("blur",i,e)});s.addEventListener("keydown",n,e),s.addEventListener("blur",()=>s.removeEventListener("keydown",n),e)};function Xr(t){return fr(t)&&!_o()}const Zr=new WeakSet;function gh(t,e,s={}){const[n,r,i]=So(t,s),a=o=>{const l=o.currentTarget;if(!Xr(o)||Zr.has(o))return;is.add(l),s.stopPropagation&&Zr.add(o);const c=e(l,o),u=(f,p)=>{window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",d),is.has(l)&&is.delete(l),Xr(f)&&typeof c=="function"&&c(f,{success:p})},h=f=>{u(f,l===window||l===document||s.useGlobalTarget||To(l,f.target))},d=f=>{u(f,!1)};window.addEventListener("pointerup",h,r),window.addEventListener("pointercancel",d,r)};return n.forEach(o=>{(s.useGlobalTarget?window:o).addEventListener("pointerdown",a,r),rs(o)&&(o.addEventListener("focus",c=>mh(c,r)),!dh(o)&&!o.hasAttribute("tabindex")&&(o.tabIndex=0))}),i}function pr(t){return Aa(t)&&"ownerSVGElement"in t}const as=new WeakMap;let Pe;const ko=(t,e,s)=>(n,r)=>r&&r[0]?r[0][t+"Size"]:pr(n)&&"getBBox"in n?n.getBBox()[e]:n[s],yh=ko("inline","width","offsetWidth"),vh=ko("block","height","offsetHeight");function wh({target:t,borderBoxSize:e}){var s;(s=as.get(t))==null||s.forEach(n=>{n(t,{get width(){return yh(t,e)},get height(){return vh(t,e)}})})}function bh(t){t.forEach(wh)}function xh(){typeof ResizeObserver>"u"||(Pe=new ResizeObserver(bh))}function _h(t,e){Pe||xh();const s=bo(t);return s.forEach(n=>{let r=as.get(n);r||(r=new Set,as.set(n,r)),r.add(e),Pe==null||Pe.observe(n)}),()=>{s.forEach(n=>{const r=as.get(n);r==null||r.delete(e),r!=null&&r.size||Pe==null||Pe.unobserve(n)})}}const os=new Set;let lt;function Sh(){lt=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};os.forEach(e=>e(t))},window.addEventListener("resize",lt)}function Th(t){return os.add(t),lt||Sh(),()=>{os.delete(t),!os.size&&typeof lt=="function"&&(window.removeEventListener("resize",lt),lt=void 0)}}function Qr(t,e){return typeof t=="function"?Th(t):_h(t,e)}function kh(t){return pr(t)&&t.tagName==="svg"}const Ah=[...yo,U,fe],Eh=t=>Ah.find(go(t)),ei=()=>({translate:0,scale:1,origin:0,originPoint:0}),ct=()=>({x:ei(),y:ei()}),ti=()=>({min:0,max:0}),W=()=>({x:ti(),y:ti()}),Ph=new WeakMap;function Es(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Dt(t){return typeof t=="string"||Array.isArray(t)}const mr=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],gr=["initial",...mr];function Ps(t){return Es(t.animate)||gr.some(e=>Dt(t[e]))}function Ao(t){return!!(Ps(t)||t.variants)}function Ch(t,e,s){for(const n in e){const r=e[n],i=s[n];if(J(r))t.addValue(n,r);else if(J(i))t.addValue(n,mt(r,{owner:t}));else if(i!==r)if(t.hasValue(n)){const a=t.getValue(n);a.liveStyle===!0?a.jump(r):a.hasAnimated||a.set(r)}else{const a=t.getStaticValue(n);t.addValue(n,mt(a!==void 0?a:r,{owner:t}))}}for(const n in s)e[n]===void 0&&t.removeValue(n);return e}const kn={current:null},Eo={current:!1},Rh=typeof window<"u";function jh(){if(Eo.current=!0,!!Rh)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>kn.current=t.matches;t.addEventListener("change",e),e()}else kn.current=!1}const si=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let ys={};function Po(t){ys=t}function Oh(){return ys}class Dh{scrapeMotionValuesFromProps(e,s,n){return{}}constructor({parent:e,props:s,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},l={}){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=ar,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 f=Y.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,D.render(this.render,!1,!0))};const{latestValues:c,renderState:u}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=s.initial?{...c}:{},this.renderState=u,this.parent=e,this.props=s,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=l,this.blockInitialAnimation=!!a,this.isControllingVariants=Ps(s),this.isVariantNode=Ao(s),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:h,...d}=this.scrapeMotionValuesFromProps(s,{},this);for(const f in d){const p=d[f];c[f]!==void 0&&J(p)&&p.set(c[f])}}mount(e){var s,n;if(this.hasBeenMounted)for(const r in this.initialValues)(s=this.values.get(r))==null||s.jump(this.initialValues[r]),this.latestValues[r]=this.initialValues[r];this.current=e,Ph.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((r,i)=>this.bindToMotionValue(i,r)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(Eo.current||jh(),this.shouldReduceMotion=kn.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,(n=this.parent)==null||n.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){var e;this.projection&&this.projection.unmount(),Ie(this.notifyUpdate),Ie(this.render),this.valueSubscriptions.forEach(s=>s()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(e=this.parent)==null||e.removeChild(this);for(const s in this.events)this.events[s].clear();for(const s in this.features){const n=this.features[s];n&&(n.unmount(),n.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&&oo.has(e)&&this.current instanceof HTMLElement){const{factory:a,keyframes:o,times:l,ease:c,duration:u}=s.accelerate,h=new io({element:this.current,name:e,keyframes:o,times:l,ease:c,duration:Z(u)}),d=a(h);this.valueSubscriptions.set(e,()=>{d(),h.cancel()});return}const n=wt.has(e);n&&this.onBindTransform&&this.onBindTransform();const r=s.on("change",a=>{this.latestValues[e]=a,this.props.onUpdate&&D.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let i;typeof window<"u"&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,s)),this.valueSubscriptions.set(e,()=>{r(),i&&i(),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 ys){const s=ys[e];if(!s)continue;const{isEnabled:n,Feature:r}=s;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){const i=this.features[e];i.isMounted?i.update():(i.mount(),i.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):W()}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 n=0;n<si.length;n++){const r=si[n];this.propEventSubscriptions[r]&&(this.propEventSubscriptions[r](),delete this.propEventSubscriptions[r]);const i="on"+r,a=e[i];a&&(this.propEventSubscriptions[r]=this.on(r,a))}this.prevMotionValues=Ch(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 n=this.values.get(e);s!==n&&(n&&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 n=this.values.get(e);return n===void 0&&s!==void 0&&(n=mt(s===null?void 0:s,{owner:this}),this.addValue(e,n)),n}readValue(e,s){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n=="string"&&(ka(n)||Ea(n))?n=parseFloat(n):!Eh(n)&&fe.test(s)&&(n=wo(e,s)),this.setBaseTarget(e,J(n)?n.get():n)),J(n)?n.get():n}setBaseTarget(e,s){this.baseTarget[e]=s}getBaseTarget(e){var i;const{initial:s}=this.props;let n;if(typeof s=="string"||typeof s=="object"){const a=cr(this.props,s,(i=this.presenceContext)==null?void 0:i.custom);a&&(n=a[e])}if(s&&n!==void 0)return n;const r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!J(r)?r:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,s){return this.events[e]||(this.events[e]=new Xn),this.events[e].add(s)}notify(e,...s){this.events[e]&&this.events[e].notify(...s)}scheduleRenderMicrotask(){dr.render(this.render)}}class Co extends Dh{constructor(){super(...arguments),this.KeyframeResolver=oh}sortInstanceNodePosition(e,s){return e.compareDocumentPosition(s)&2?1:-1}getBaseTargetFromProps(e,s){const n=e.style;return n?n[s]:void 0}removeValueFromRenderState(e,{vars:s,style:n}){delete s[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;J(e)&&(this.childSubscription=e.on("change",s=>{this.current&&(this.current.textContent=`${s}`)}))}}class Ne{constructor(e){this.isMounted=!1,this.node=e}update(){}}function Ro({top:t,left:e,right:s,bottom:n}){return{x:{min:e,max:s},y:{min:t,max:n}}}function Ih({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function Nh(t,e){if(!e)return t;const s=e({x:t.left,y:t.top}),n=e({x:t.right,y:t.bottom});return{top:s.y,left:s.x,bottom:n.y,right:n.x}}function Vs(t){return t===void 0||t===1}function An({scale:t,scaleX:e,scaleY:s}){return!Vs(t)||!Vs(e)||!Vs(s)}function Ve(t){return An(t)||jo(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function jo(t){return ni(t.x)||ni(t.y)}function ni(t){return t&&t!=="0%"}function vs(t,e,s){const n=t-s,r=e*n;return s+r}function ri(t,e,s,n,r){return r!==void 0&&(t=vs(t,r,n)),vs(t,s,n)+e}function En(t,e=0,s=1,n,r){t.min=ri(t.min,e,s,n,r),t.max=ri(t.max,e,s,n,r)}function Oo(t,{x:e,y:s}){En(t.x,e.translate,e.scale,e.originPoint),En(t.y,s.translate,s.scale,s.originPoint)}const ii=.999999999999,ai=1.0000000000001;function Mh(t,e,s,n=!1){var o;const r=s.length;if(!r)return;e.x=e.y=1;let i,a;for(let l=0;l<r;l++){i=s[l],a=i.projectionDelta;const{visualElement:c}=i.options;c&&c.props.style&&c.props.style.display==="contents"||(n&&i.options.layoutScroll&&i.scroll&&i!==i.root&&(ve(t.x,-i.scroll.offset.x),ve(t.y,-i.scroll.offset.y)),a&&(e.x*=a.x.scale,e.y*=a.y.scale,Oo(t,a)),n&&Ve(i.latestValues)&&ls(t,i.latestValues,(o=i.layout)==null?void 0:o.layoutBox))}e.x<ai&&e.x>ii&&(e.x=1),e.y<ai&&e.y>ii&&(e.y=1)}function ve(t,e){t.min+=e,t.max+=e}function oi(t,e,s,n,r=.5){const i=N(t.min,t.max,r);En(t,e,s,i,n)}function li(t,e){return typeof t=="string"?parseFloat(t)/100*(e.max-e.min):t}function ls(t,e,s){const n=s??t;oi(t.x,li(e.x,n.x),e.scaleX,e.scale,e.originX),oi(t.y,li(e.y,n.y),e.scaleY,e.scale,e.originY)}function Do(t,e){return Ro(Nh(t.getBoundingClientRect(),e))}function $h(t,e,s){const n=Do(t,s),{scroll:r}=e;return r&&(ve(n.x,r.offset.x),ve(n.y,r.offset.y)),n}const Lh={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Bh=vt.length;function Vh(t,e,s){let n="",r=!0;for(let i=0;i<Bh;i++){const a=vt[i],o=t[a];if(o===void 0)continue;let l=!0;if(typeof o=="number")l=o===(a.startsWith("scale")?1:0);else{const c=parseFloat(o);l=a.startsWith("scale")?c===1:c===0}if(!l||s){const c=xo(o,hr[a]);if(!l){r=!1;const u=Lh[a]||a;n+=`${u}(${c}) `}s&&(e[a]=c)}}return n=n.trim(),s?n=s(e,r?"":n):r&&(n="none"),n}function yr(t,e,s){const{style:n,vars:r,transformOrigin:i}=t;let a=!1,o=!1;for(const l in e){const c=e[l];if(wt.has(l)){a=!0;continue}else if(Fa(l)){r[l]=c;continue}else{const u=xo(c,hr[l]);l.startsWith("origin")?(o=!0,i[l]=u):n[l]=u}}if(e.transform||(a||s?n.transform=Vh(e,t.transform,s):n.transform&&(n.transform="none")),o){const{originX:l="50%",originY:c="50%",originZ:u=0}=i;n.transformOrigin=`${l} ${c} ${u}`}}function Io(t,{style:e,vars:s},n,r){const i=t.style;let a;for(a in e)i[a]=e[a];r==null||r.applyProjectionStyles(i,n);for(a in s)i.setProperty(a,s[a])}function ci(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const bt={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(T.test(t))t=parseFloat(t);else return t;const s=ci(t,e.target.x),n=ci(t,e.target.y);return`${s}% ${n}%`}},Uh={correct:(t,{treeScale:e,projectionDelta:s})=>{const n=t,r=fe.parse(t);if(r.length>5)return n;const i=fe.createTransformer(t),a=typeof r[0]!="number"?1:0,o=s.x.scale*e.x,l=s.y.scale*e.y;r[0+a]/=o,r[1+a]/=l;const c=N(o,l,.5);return typeof r[2+a]=="number"&&(r[2+a]/=c),typeof r[3+a]=="number"&&(r[3+a]/=c),i(r)}},Pn={borderRadius:{...bt,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:bt,borderTopRightRadius:bt,borderBottomLeftRadius:bt,borderBottomRightRadius:bt,boxShadow:Uh};function No(t,{layout:e,layoutId:s}){return wt.has(t)||t.startsWith("origin")||(e||s!==void 0)&&(!!Pn[t]||t==="opacity")}function vr(t,e,s){var a;const n=t.style,r=e==null?void 0:e.style,i={};if(!n)return i;for(const o in n)(J(n[o])||r&&J(r[o])||No(o,t)||((a=s==null?void 0:s.getValue(o))==null?void 0:a.liveStyle)!==void 0)&&(i[o]=n[o]);return i}function Fh(t){return window.getComputedStyle(t)}class Wh extends Co{constructor(){super(...arguments),this.type="html",this.renderInstance=Io}readValueFromInstance(e,s){var n;if(wt.has(s))return(n=this.projection)!=null&&n.isProjecting?pn(s):lu(e,s);{const r=Fh(e),i=(Fa(s)?r.getPropertyValue(s):r[s])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:s}){return Do(e,s)}build(e,s,n){yr(e,s,n.transformTemplate)}scrapeMotionValuesFromProps(e,s,n){return vr(e,s,n)}}const qh={offset:"stroke-dashoffset",array:"stroke-dasharray"},Hh={offset:"strokeDashoffset",array:"strokeDasharray"};function Kh(t,e,s=1,n=0,r=!0){t.pathLength=1;const i=r?qh:Hh;t[i.offset]=`${-n}`,t[i.array]=`${e} ${s}`}const Gh=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function Mo(t,{attrX:e,attrY:s,attrScale:n,pathLength:r,pathSpacing:i=1,pathOffset:a=0,...o},l,c,u){if(yr(t,o,c),l){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:h,style:d}=t;h.transform&&(d.transform=h.transform,delete h.transform),(d.transform||h.transformOrigin)&&(d.transformOrigin=h.transformOrigin??"50% 50%",delete h.transformOrigin),d.transform&&(d.transformBox=(u==null?void 0:u.transformBox)??"fill-box",delete h.transformBox);for(const f of Gh)h[f]!==void 0&&(d[f]=h[f],delete h[f]);e!==void 0&&(h.x=e),s!==void 0&&(h.y=s),n!==void 0&&(h.scale=n),r!==void 0&&Kh(h,r,i,a,!1)}const $o=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"]),Lo=t=>typeof t=="string"&&t.toLowerCase()==="svg";function zh(t,e,s,n){Io(t,e,void 0,n);for(const r in e.attrs)t.setAttribute($o.has(r)?r:ur(r),e.attrs[r])}function Bo(t,e,s){const n=vr(t,e,s);for(const r in t)if(J(t[r])||J(e[r])){const i=vt.indexOf(r)!==-1?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r;n[i]=t[r]}return n}class Jh extends Co{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=W}getBaseTargetFromProps(e,s){return e[s]}readValueFromInstance(e,s){if(wt.has(s)){const n=vo(s);return n&&n.default||0}return s=$o.has(s)?s:ur(s),e.getAttribute(s)}scrapeMotionValuesFromProps(e,s,n){return Bo(e,s,n)}build(e,s,n){Mo(e,s,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,s,n,r){zh(e,s,n,r)}mount(e){this.isSVGTag=Lo(e.tagName),super.mount(e)}}const Yh=gr.length;function Vo(t){if(!t)return;if(!t.isControllingVariants){const s=t.parent?Vo(t.parent)||{}:{};return t.props.initial!==void 0&&(s.initial=t.props.initial),s}const e={};for(let s=0;s<Yh;s++){const n=gr[s],r=t.props[n];(Dt(r)||r===!1)&&(e[n]=r)}return e}function Uo(t,e){if(!Array.isArray(e))return!1;const s=e.length;if(s!==t.length)return!1;for(let n=0;n<s;n++)if(e[n]!==t[n])return!1;return!0}const Xh=[...mr].reverse(),Zh=mr.length;function Qh(t){return e=>Promise.all(e.map(({animation:s,options:n})=>Yu(t,s,n)))}function ed(t){let e=Qh(t),s=ui(),n=!0,r=!1;const i=c=>(u,h)=>{var f;const d=Je(t,h,c==="exit"?(f=t.presenceContext)==null?void 0:f.custom:void 0);if(d){const{transition:p,transitionEnd:y,...g}=d;u={...u,...g,...y}}return u};function a(c){e=c(t)}function o(c){const{props:u}=t,h=Vo(t.parent)||{},d=[],f=new Set;let p={},y=1/0;for(let b=0;b<Zh;b++){const w=Xh[b],v=s[w],x=u[w]!==void 0?u[w]:h[w],S=Dt(x),k=w===c?v.isActive:null;k===!1&&(y=b);let j=x===h[w]&&x!==u[w]&&S;if(j&&(n||r)&&t.manuallyAnimateOnMount&&(j=!1),v.protectedKeys={...p},!v.isActive&&k===null||!x&&!v.prevProp||Es(x)||typeof x=="boolean")continue;if(w==="exit"&&v.isActive&&k!==!0){v.prevResolvedValues&&(p={...p,...v.prevResolvedValues});continue}const E=td(v.prevProp,x);let O=E||w===c&&v.isActive&&!j&&S||b>y&&S,P=!1;const M=Array.isArray(x)?x:[x];let q=M.reduce(i(w),{});k===!1&&(q={});const{prevResolvedValues:xe={}}=v,pe={...xe,...q},_e=H=>{O=!0,f.has(H)&&(P=!0,f.delete(H)),v.needsAnimating[H]=!0;const se=t.getValue(H);se&&(se.liveStyle=!1)};for(const H in pe){const se=q[H],Me=xe[H];if(p.hasOwnProperty(H))continue;let Ye=!1;bn(se)&&bn(Me)?Ye=!Uo(se,Me):Ye=se!==Me,Ye?se!=null?_e(H):f.add(H):se!==void 0&&f.has(H)?_e(H):v.protectedKeys[H]=!0}v.prevProp=x,v.prevResolvedValues=q,v.isActive&&(p={...p,...q}),(n||r)&&t.blockInitialAnimation&&(O=!1);const me=j&&E;O&&(!me||P)&&d.push(...M.map(H=>{const se={type:w};if(typeof H=="string"&&(n||r)&&!me&&t.manuallyAnimateOnMount&&t.parent){const{parent:Me}=t,Ye=Je(Me,H);if(Me.enteringChildren&&Ye){const{delayChildren:Ul}=Ye.transition||{};se.delay=lo(Me.enteringChildren,t,Ul)}}return{animation:H,options:se}}))}if(f.size){const b={};if(typeof u.initial!="boolean"){const w=Je(t,Array.isArray(u.initial)?u.initial[0]:u.initial);w&&w.transition&&(b.transition=w.transition)}f.forEach(w=>{const v=t.getBaseTarget(w),x=t.getValue(w);x&&(x.liveStyle=!0),b[w]=v??null}),d.push({animation:b})}let g=!!d.length;return n&&(u.initial===!1||u.initial===u.animate)&&!t.manuallyAnimateOnMount&&(g=!1),n=!1,r=!1,g?e(d):Promise.resolve()}function l(c,u){var d;if(s[c].isActive===u)return Promise.resolve();(d=t.variantChildren)==null||d.forEach(f=>{var p;return(p=f.animationState)==null?void 0:p.setActive(c,u)}),s[c].isActive=u;const h=o(c);for(const f in s)s[f].protectedKeys={};return h}return{animateChanges:o,setActive:l,setAnimateFunction:a,getState:()=>s,reset:()=>{s=ui(),r=!0}}}function td(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!Uo(e,t):!1}function $e(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function ui(){return{animate:$e(!0),whileInView:$e(),whileHover:$e(),whileTap:$e(),whileDrag:$e(),whileFocus:$e(),exit:$e()}}function Cn(t,e){t.min=e.min,t.max=e.max}function oe(t,e){Cn(t.x,e.x),Cn(t.y,e.y)}function hi(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}const Fo=1e-4,sd=1-Fo,nd=1+Fo,Wo=.01,rd=0-Wo,id=0+Wo;function X(t){return t.max-t.min}function ad(t,e,s){return Math.abs(t-e)<=s}function di(t,e,s,n=.5){t.origin=n,t.originPoint=N(e.min,e.max,t.origin),t.scale=X(s)/X(e),t.translate=N(s.min,s.max,t.origin)-t.originPoint,(t.scale>=sd&&t.scale<=nd||isNaN(t.scale))&&(t.scale=1),(t.translate>=rd&&t.translate<=id||isNaN(t.translate))&&(t.translate=0)}function kt(t,e,s,n){di(t.x,e.x,s.x,n?n.originX:void 0),di(t.y,e.y,s.y,n?n.originY:void 0)}function fi(t,e,s,n=0){const r=n?N(s.min,s.max,n):s.min;t.min=r+e.min,t.max=t.min+X(e)}function od(t,e,s,n){fi(t.x,e.x,s.x,n==null?void 0:n.x),fi(t.y,e.y,s.y,n==null?void 0:n.y)}function pi(t,e,s,n=0){const r=n?N(s.min,s.max,n):s.min;t.min=e.min-r,t.max=t.min+X(e)}function ws(t,e,s,n){pi(t.x,e.x,s.x,n==null?void 0:n.x),pi(t.y,e.y,s.y,n==null?void 0:n.y)}function mi(t,e,s,n,r){return t-=e,t=vs(t,1/s,n),r!==void 0&&(t=vs(t,1/r,n)),t}function ld(t,e=0,s=1,n=.5,r,i=t,a=t){if(we.test(e)&&(e=parseFloat(e),e=N(a.min,a.max,e/100)-a.min),typeof e!="number")return;let o=N(i.min,i.max,n);t===i&&(o-=e),t.min=mi(t.min,e,s,o,r),t.max=mi(t.max,e,s,o,r)}function gi(t,e,[s,n,r],i,a){ld(t,e[s],e[n],e[r],e.scale,i,a)}const cd=["x","scaleX","originX"],ud=["y","scaleY","originY"];function yi(t,e,s,n){gi(t.x,e,cd,s?s.x:void 0,n?n.x:void 0),gi(t.y,e,ud,s?s.y:void 0,n?n.y:void 0)}function vi(t){return t.translate===0&&t.scale===1}function qo(t){return vi(t.x)&&vi(t.y)}function wi(t,e){return t.min===e.min&&t.max===e.max}function hd(t,e){return wi(t.x,e.x)&&wi(t.y,e.y)}function bi(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function Ho(t,e){return bi(t.x,e.x)&&bi(t.y,e.y)}function xi(t){return X(t.x)/X(t.y)}function _i(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}function ye(t){return[t("x"),t("y")]}function dd(t,e,s){let n="";const r=t.x.translate/e.x,i=t.y.translate/e.y,a=(s==null?void 0:s.z)||0;if((r||i||a)&&(n=`translate3d(${r}px, ${i}px, ${a}px) `),(e.x!==1||e.y!==1)&&(n+=`scale(${1/e.x}, ${1/e.y}) `),s){const{transformPerspective:c,rotate:u,rotateX:h,rotateY:d,skewX:f,skewY:p}=s;c&&(n=`perspective(${c}px) ${n}`),u&&(n+=`rotate(${u}deg) `),h&&(n+=`rotateX(${h}deg) `),d&&(n+=`rotateY(${d}deg) `),f&&(n+=`skewX(${f}deg) `),p&&(n+=`skewY(${p}deg) `)}const o=t.x.scale*e.x,l=t.y.scale*e.y;return(o!==1||l!==1)&&(n+=`scale(${o}, ${l})`),n||"none"}const Ko=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],fd=Ko.length,Si=t=>typeof t=="string"?parseFloat(t):t,Ti=t=>typeof t=="number"||T.test(t);function pd(t,e,s,n,r,i){r?(t.opacity=N(0,s.opacity??1,md(n)),t.opacityExit=N(e.opacity??1,0,gd(n))):i&&(t.opacity=N(e.opacity??1,s.opacity??1,n));for(let a=0;a<fd;a++){const o=Ko[a];let l=ki(e,o),c=ki(s,o);if(l===void 0&&c===void 0)continue;l||(l=0),c||(c=0),l===0||c===0||Ti(l)===Ti(c)?(t[o]=Math.max(N(Si(l),Si(c),n),0),(we.test(c)||we.test(l))&&(t[o]+="%")):t[o]=c}(e.rotate||s.rotate)&&(t.rotate=N(e.rotate||0,s.rotate||0,n))}function ki(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const md=Go(0,.5,Ma),gd=Go(.5,.95,ie);function Go(t,e,s){return n=>n<t?0:n>e?1:s(jt(t,e,n))}function yd(t,e,s){const n=J(t)?t:mt(t);return n.start(lr("",n,e,s)),n.animation}function It(t,e,s,n={passive:!0}){return t.addEventListener(e,s,n),()=>t.removeEventListener(e,s)}const vd=(t,e)=>t.depth-e.depth;class wd{constructor(){this.children=[],this.isDirty=!1}add(e){Yn(this.children,e),this.isDirty=!0}remove(e){ds(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(vd),this.isDirty=!1,this.children.forEach(e)}}function bd(t,e){const s=Y.now(),n=({timestamp:r})=>{const i=r-s;i>=e&&(Ie(n),t(i-e))};return D.setup(n,!0),()=>Ie(n)}function cs(t){return J(t)?t.get():t}class xd{constructor(){this.members=[]}add(e){Yn(this.members,e);for(let s=this.members.length-1;s>=0;s--){const n=this.members[s];if(n===e||n===this.lead||n===this.prevLead)continue;const r=n.instance;(!r||r.isConnected===!1)&&!n.snapshot&&(ds(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(ds(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){var s;for(let n=this.members.indexOf(e)-1;n>=0;n--){const r=this.members[n];if(r.isPresent!==!1&&((s=r.instance)==null?void 0:s.isConnected)!==!1)return this.promote(r),!0}return!1}promote(e,s){var r;const n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();const{layoutDependency:i}=n.options,{layoutDependency:a}=e.options;(i===void 0||i!==a)&&(e.resumeFrom=n,s&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),(r=e.root)!=null&&r.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{var s,n,r,i,a;(n=(s=e.options).onExitComplete)==null||n.call(s),(a=(r=e.resumingFrom)==null?void 0:(i=r.options).onExitComplete)==null||a.call(i)})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){var e;(e=this.lead)!=null&&e.snapshot&&(this.lead.snapshot=void 0)}}const us={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Us=["","X","Y","Z"],_d=1e3;let Sd=0;function Fs(t,e,s,n){const{latestValues:r}=e;r[t]&&(s[t]=r[t],e.setStaticValue(t,0),n&&(n[t]=0))}function zo(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const s=po(e);if(window.MotionHasOptimisedAnimation(s,"transform")){const{layout:r,layoutId:i}=t.options;window.MotionCancelOptimisedAnimation(s,"transform",D,!(r||i))}const{parent:n}=t;n&&!n.hasCheckedOptimisedAppear&&zo(n)}function Jo({attachResizeListener:t,defaultParent:e,measureScroll:s,checkIsScrollRoot:n,resetTransform:r}){return class{constructor(a={},o=e==null?void 0:e()){this.id=Sd++,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(Ad),this.nodes.forEach(Od),this.nodes.forEach(Dd),this.nodes.forEach(Ed)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=a,this.root=o?o.root||o:this,this.path=o?[...o.path,o]:[],this.parent=o,this.depth=o?o.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new wd)}addEventListener(a,o){return this.eventHandlers.has(a)||this.eventHandlers.set(a,new Xn),this.eventHandlers.get(a).add(o)}notifyListeners(a,...o){const l=this.eventHandlers.get(a);l&&l.notify(...o)}hasListeners(a){return this.eventHandlers.has(a)}mount(a){if(this.instance)return;this.isSVG=pr(a)&&!kh(a),this.instance=a;const{layoutId:o,layout:l,visualElement:c}=this.options;if(c&&!c.current&&c.mount(a),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||o)&&(this.isLayoutDirty=!0),t){let u,h=0;const d=()=>this.root.updateBlockedByResize=!1;D.read(()=>{h=window.innerWidth}),t(a,()=>{const f=window.innerWidth;f!==h&&(h=f,this.root.updateBlockedByResize=!0,u&&u(),u=bd(d,250),us.hasAnimatedSinceResize&&(us.hasAnimatedSinceResize=!1,this.nodes.forEach(Pi)))})}o&&this.root.registerSharedNode(o,this),this.options.animate!==!1&&c&&(o||l)&&this.addEventListener("didUpdate",({delta:u,hasLayoutChanged:h,hasRelativeLayoutChanged:d,layout:f})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const p=this.options.transition||c.getDefaultTransition()||Ld,{onLayoutAnimationStart:y,onLayoutAnimationComplete:g}=c.getProps(),b=!this.targetLayout||!Ho(this.targetLayout,f),w=!h&&d;if(this.options.layoutRoot||this.resumeFrom||w||h&&(b||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const v={...or(p,"layout"),onPlay:y,onComplete:g};(c.shouldReduceMotion||this.options.layoutRoot)&&(v.delay=0,v.type=!1),this.startAnimation(v),this.setAnimationOrigin(u,w)}else h||Pi(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=f})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const a=this.getStack();a&&a.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Ie(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:a}=this.options;return a&&a.getProps().transformTemplate}willUpdate(a=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&zo(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let u=0;u<this.path.length;u++){const h=this.path[u];h.shouldResetTransform=!0,(typeof h.latestValues.x=="string"||typeof h.latestValues.y=="string")&&(h.isLayoutDirty=!0),h.updateScroll("snapshot"),h.options.layoutRoot&&h.willUpdate(!1)}const{layoutId:o,layout:l}=this.options;if(o===void 0&&!l)return;const c=this.getTransformTemplate();this.prevTransformTemplateValue=c?c(this.latestValues,""):void 0,this.updateSnapshot(),a&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){const l=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),l&&this.nodes.forEach(Cd),this.nodes.forEach(Ai);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Ei);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Rd),this.nodes.forEach(jd),this.nodes.forEach(Td),this.nodes.forEach(kd)):this.nodes.forEach(Ei),this.clearAllSnapshots();const o=Y.now();z.delta=be(0,1e3/60,o-z.timestamp),z.timestamp=o,z.isProcessing=!0,Ds.update.process(z),Ds.preRender.process(z),Ds.render.process(z),z.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,dr.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Pd),this.sharedNodes.forEach(Nd)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,D.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){D.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!X(this.snapshot.measuredBox.x)&&!X(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 l=0;l<this.path.length;l++)this.path[l].updateScroll();const a=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||(this.layoutCorrected=W()),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:o}=this.options;o&&o.notify("LayoutMeasure",this.layout.layoutBox,a?a.layoutBox:void 0)}updateScroll(a="measure"){let o=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===a&&(o=!1),o&&this.instance){const l=n(this.instance);this.scroll={animationId:this.root.animationId,phase:a,isRoot:l,offset:s(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!r)return;const a=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,o=this.projectionDelta&&!qo(this.projectionDelta),l=this.getTransformTemplate(),c=l?l(this.latestValues,""):void 0,u=c!==this.prevTransformTemplateValue;a&&this.instance&&(o||Ve(this.latestValues)||u)&&(r(this.instance,c),this.shouldResetTransform=!1,this.scheduleRender())}measure(a=!0){const o=this.measurePageBox();let l=this.removeElementScroll(o);return a&&(l=this.removeTransform(l)),Bd(l),{animationId:this.root.animationId,measuredBox:o,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){var c;const{visualElement:a}=this.options;if(!a)return W();const o=a.measureViewportBox();if(!(((c=this.scroll)==null?void 0:c.wasRoot)||this.path.some(Vd))){const{scroll:u}=this.root;u&&(ve(o.x,u.offset.x),ve(o.y,u.offset.y))}return o}removeElementScroll(a){var l;const o=W();if(oe(o,a),(l=this.scroll)!=null&&l.wasRoot)return o;for(let c=0;c<this.path.length;c++){const u=this.path[c],{scroll:h,options:d}=u;u!==this.root&&h&&d.layoutScroll&&(h.wasRoot&&oe(o,a),ve(o.x,h.offset.x),ve(o.y,h.offset.y))}return o}applyTransform(a,o=!1,l){var u,h;const c=l||W();oe(c,a);for(let d=0;d<this.path.length;d++){const f=this.path[d];!o&&f.options.layoutScroll&&f.scroll&&f!==f.root&&(ve(c.x,-f.scroll.offset.x),ve(c.y,-f.scroll.offset.y)),Ve(f.latestValues)&&ls(c,f.latestValues,(u=f.layout)==null?void 0:u.layoutBox)}return Ve(this.latestValues)&&ls(c,this.latestValues,(h=this.layout)==null?void 0:h.layoutBox),c}removeTransform(a){var l;const o=W();oe(o,a);for(let c=0;c<this.path.length;c++){const u=this.path[c];if(!Ve(u.latestValues))continue;let h;u.instance&&(An(u.latestValues)&&u.updateSnapshot(),h=W(),oe(h,u.measurePageBox())),yi(o,u.latestValues,(l=u.snapshot)==null?void 0:l.layoutBox,h)}return Ve(this.latestValues)&&yi(o,this.latestValues),o}setTargetDelta(a){this.targetDelta=a,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(a){this.options={...this.options,...a,crossfade:a.crossfade!==void 0?a.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!==z.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(a=!1){var f;const o=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=o.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=o.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=o.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==o;if(!(a||l&&this.isSharedProjectionDirty||this.isProjectionDirty||(f=this.parent)!=null&&f.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:u,layoutId:h}=this.options;if(!this.layout||!(u||h))return;this.resolvedRelativeTargetAt=z.timestamp;const d=this.getClosestProjectingParent();d&&this.linkedParentVersion!==d.layoutVersion&&!d.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&d&&d.layout?this.createRelativeTarget(d,this.layout.layoutBox,d.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=W(),this.targetWithTransforms=W()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),od(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):oe(this.target,this.layout.layoutBox),Oo(this.target,this.targetDelta)):oe(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&d&&!!d.resumingFrom==!!this.resumingFrom&&!d.options.layoutScroll&&d.target&&this.animationProgress!==1?this.createRelativeTarget(d,this.target,d.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||An(this.parent.latestValues)||jo(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(a,o,l){this.relativeParent=a,this.linkedParentVersion=a.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=W(),this.relativeTargetOrigin=W(),ws(this.relativeTargetOrigin,o,l,this.options.layoutAnchor||void 0),oe(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){var p;const a=this.getLead(),o=!!this.resumingFrom||this!==a;let l=!0;if((this.isProjectionDirty||(p=this.parent)!=null&&p.isProjectionDirty)&&(l=!1),o&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===z.timestamp&&(l=!1),l)return;const{layout:c,layoutId:u}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(c||u))return;oe(this.layoutCorrected,this.layout.layoutBox);const h=this.treeScale.x,d=this.treeScale.y;Mh(this.layoutCorrected,this.treeScale,this.path,o),a.layout&&!a.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(a.target=a.layout.layoutBox,a.targetWithTransforms=W());const{target:f}=a;if(!f){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(hi(this.prevProjectionDelta.x,this.projectionDelta.x),hi(this.prevProjectionDelta.y,this.projectionDelta.y)),kt(this.projectionDelta,this.layoutCorrected,f,this.latestValues),(this.treeScale.x!==h||this.treeScale.y!==d||!_i(this.projectionDelta.x,this.prevProjectionDelta.x)||!_i(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",f))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(a=!0){var o;if((o=this.options.visualElement)==null||o.scheduleRender(),a){const l=this.getStack();l&&l.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=ct(),this.projectionDelta=ct(),this.projectionDeltaWithTransform=ct()}setAnimationOrigin(a,o=!1){const l=this.snapshot,c=l?l.latestValues:{},u={...this.latestValues},h=ct();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!o;const d=W(),f=l?l.source:void 0,p=this.layout?this.layout.source:void 0,y=f!==p,g=this.getStack(),b=!g||g.members.length<=1,w=!!(y&&!b&&this.options.crossfade===!0&&!this.path.some($d));this.animationProgress=0;let v;this.mixTargetDelta=x=>{const S=x/1e3;Ci(h.x,a.x,S),Ci(h.y,a.y,S),this.setTargetDelta(h),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(ws(d,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),Md(this.relativeTarget,this.relativeTargetOrigin,d,S),v&&hd(this.relativeTarget,v)&&(this.isProjectionDirty=!1),v||(v=W()),oe(v,this.relativeTarget)),y&&(this.animationValues=u,pd(u,c,this.latestValues,S,w,b)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=S},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(a){var o,l,c;this.notifyListeners("animationStart"),(o=this.currentAnimation)==null||o.stop(),(c=(l=this.resumingFrom)==null?void 0:l.currentAnimation)==null||c.stop(),this.pendingAnimation&&(Ie(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=D.update(()=>{us.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=mt(0)),this.motionValue.jump(0,!1),this.currentAnimation=yd(this.motionValue,[0,1e3],{...a,velocity:0,isSync:!0,onUpdate:u=>{this.mixTargetDelta(u),a.onUpdate&&a.onUpdate(u)},onStop:()=>{},onComplete:()=>{a.onComplete&&a.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 a=this.getStack();a&&a.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(_d),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const a=this.getLead();let{targetWithTransforms:o,target:l,layout:c,latestValues:u}=a;if(!(!o||!l||!c)){if(this!==a&&this.layout&&c&&Yo(this.options.animationType,this.layout.layoutBox,c.layoutBox)){l=this.target||W();const h=X(this.layout.layoutBox.x);l.x.min=a.target.x.min,l.x.max=l.x.min+h;const d=X(this.layout.layoutBox.y);l.y.min=a.target.y.min,l.y.max=l.y.min+d}oe(o,l),ls(o,u),kt(this.projectionDeltaWithTransform,this.layoutCorrected,o,u)}}registerSharedNode(a,o){this.sharedNodes.has(a)||this.sharedNodes.set(a,new xd),this.sharedNodes.get(a).add(o);const c=o.options.initialPromotionConfig;o.promote({transition:c?c.transition:void 0,preserveFollowOpacity:c&&c.shouldPreserveFollowOpacity?c.shouldPreserveFollowOpacity(o):void 0})}isLead(){const a=this.getStack();return a?a.lead===this:!0}getLead(){var o;const{layoutId:a}=this.options;return a?((o=this.getStack())==null?void 0:o.lead)||this:this}getPrevLead(){var o;const{layoutId:a}=this.options;return a?(o=this.getStack())==null?void 0:o.prevLead:void 0}getStack(){const{layoutId:a}=this.options;if(a)return this.root.sharedNodes.get(a)}promote({needsReset:a,transition:o,preserveFollowOpacity:l}={}){const c=this.getStack();c&&c.promote(this,l),a&&(this.projectionDelta=void 0,this.needsReset=!0),o&&this.setOptions({transition:o})}relegate(){const a=this.getStack();return a?a.relegate(this):!1}resetSkewAndRotation(){const{visualElement:a}=this.options;if(!a)return;let o=!1;const{latestValues:l}=a;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(o=!0),!o)return;const c={};l.z&&Fs("z",a,c,this.animationValues);for(let u=0;u<Us.length;u++)Fs(`rotate${Us[u]}`,a,c,this.animationValues),Fs(`skew${Us[u]}`,a,c,this.animationValues);a.render();for(const u in c)a.setStaticValue(u,c[u]),this.animationValues&&(this.animationValues[u]=c[u]);a.scheduleRender()}applyProjectionStyles(a,o){if(!this.instance||this.isSVG)return;if(!this.isVisible){a.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,a.visibility="",a.opacity="",a.pointerEvents=cs(o==null?void 0:o.pointerEvents)||"",a.transform=l?l(this.latestValues,""):"none";return}const c=this.getLead();if(!this.projectionDelta||!this.layout||!c.target){this.options.layoutId&&(a.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,a.pointerEvents=cs(o==null?void 0:o.pointerEvents)||""),this.hasProjected&&!Ve(this.latestValues)&&(a.transform=l?l({},""):"none",this.hasProjected=!1);return}a.visibility="";const u=c.animationValues||c.latestValues;this.applyTransformsToTarget();let h=dd(this.projectionDeltaWithTransform,this.treeScale,u);l&&(h=l(u,h)),a.transform=h;const{x:d,y:f}=this.projectionDelta;a.transformOrigin=`${d.origin*100}% ${f.origin*100}% 0`,c.animationValues?a.opacity=c===this?u.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:u.opacityExit:a.opacity=c===this?u.opacity!==void 0?u.opacity:"":u.opacityExit!==void 0?u.opacityExit:0;for(const p in Pn){if(u[p]===void 0)continue;const{correct:y,applyTo:g,isCSSVariable:b}=Pn[p],w=h==="none"?u[p]:y(u[p],c);if(g){const v=g.length;for(let x=0;x<v;x++)a[g[x]]=w}else b?this.options.visualElement.renderState.vars[p]=w:a[p]=w}this.options.layoutId&&(a.pointerEvents=c===this?cs(o==null?void 0:o.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(a=>{var o;return(o=a.currentAnimation)==null?void 0:o.stop()}),this.root.nodes.forEach(Ai),this.root.sharedNodes.clear()}}}function Td(t){t.updateLayout()}function kd(t){var s;const e=((s=t.resumeFrom)==null?void 0:s.snapshot)||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:r}=t.layout,{animationType:i}=t.options,a=e.source!==t.layout.source;if(i==="size")ye(h=>{const d=a?e.measuredBox[h]:e.layoutBox[h],f=X(d);d.min=n[h].min,d.max=d.min+f});else if(i==="x"||i==="y"){const h=i==="x"?"y":"x";Cn(a?e.measuredBox[h]:e.layoutBox[h],n[h])}else Yo(i,e.layoutBox,n)&&ye(h=>{const d=a?e.measuredBox[h]:e.layoutBox[h],f=X(n[h]);d.max=d.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[h].max=t.relativeTarget[h].min+f)});const o=ct();kt(o,n,e.layoutBox);const l=ct();a?kt(l,t.applyTransform(r,!0),e.measuredBox):kt(l,n,e.layoutBox);const c=!qo(o);let u=!1;if(!t.resumeFrom){const h=t.getClosestProjectingParent();if(h&&!h.resumeFrom){const{snapshot:d,layout:f}=h;if(d&&f){const p=t.options.layoutAnchor||void 0,y=W();ws(y,e.layoutBox,d.layoutBox,p);const g=W();ws(g,n,f.layoutBox,p),Ho(y,g)||(u=!0),h.options.layoutRoot&&(t.relativeTarget=g,t.relativeTargetOrigin=y,t.relativeParent=h)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:l,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:u})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function Ad(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 Ed(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function Pd(t){t.clearSnapshot()}function Ai(t){t.clearMeasurements()}function Cd(t){t.isLayoutDirty=!0,t.updateLayout()}function Ei(t){t.isLayoutDirty=!1}function Rd(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function jd(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function Pi(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function Od(t){t.resolveTargetDelta()}function Dd(t){t.calcProjection()}function Id(t){t.resetSkewAndRotation()}function Nd(t){t.removeLeadSnapshot()}function Ci(t,e,s){t.translate=N(e.translate,0,s),t.scale=N(e.scale,1,s),t.origin=e.origin,t.originPoint=e.originPoint}function Ri(t,e,s,n){t.min=N(e.min,s.min,n),t.max=N(e.max,s.max,n)}function Md(t,e,s,n){Ri(t.x,e.x,s.x,n),Ri(t.y,e.y,s.y,n)}function $d(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const Ld={duration:.45,ease:[.4,0,.1,1]},ji=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),Oi=ji("applewebkit/")&&!ji("chrome/")?Math.round:ie;function Di(t){t.min=Oi(t.min),t.max=Oi(t.max)}function Bd(t){Di(t.x),Di(t.y)}function Yo(t,e,s){return t==="position"||t==="preserve-aspect"&&!ad(xi(e),xi(s),.2)}function Vd(t){var e;return t!==t.root&&((e=t.scroll)==null?void 0:e.wasRoot)}const Ud=Jo({attachResizeListener:(t,e)=>It(t,"resize",e),measureScroll:()=>{var t,e;return{x:document.documentElement.scrollLeft||((t=document.body)==null?void 0:t.scrollLeft)||0,y:document.documentElement.scrollTop||((e=document.body)==null?void 0:e.scrollTop)||0}},checkIsScrollRoot:()=>!0}),Ws={current:void 0},Xo=Jo({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Ws.current){const t=new Ud({});t.mount(window),t.setOptions({layoutScroll:!0}),Ws.current=t}return Ws.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),wr=_.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function Ii(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Fd(...t){return e=>{let s=!1;const n=t.map(r=>{const i=Ii(r,e);return!s&&typeof i=="function"&&(s=!0),i});if(s)return()=>{for(let r=0;r<n.length;r++){const i=n[r];typeof i=="function"?i():Ii(t[r],null)}}}}function Wd(...t){return _.useCallback(Fd(...t),t)}class qd extends _.Component{getSnapshotBeforeUpdate(e){const s=this.props.childRef.current;if(rs(s)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const n=s.offsetParent,r=rs(n)&&n.offsetWidth||0,i=rs(n)&&n.offsetHeight||0,a=getComputedStyle(s),o=this.props.sizeRef.current;o.height=parseFloat(a.height),o.width=parseFloat(a.width),o.top=s.offsetTop,o.left=s.offsetLeft,o.right=r-o.width-o.left,o.bottom=i-o.height-o.top}return null}componentDidUpdate(){}render(){return this.props.children}}function Hd({children:t,isPresent:e,anchorX:s,anchorY:n,root:r,pop:i}){var d;const a=_.useId(),o=_.useRef(null),l=_.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0}),{nonce:c}=_.useContext(wr),u=((d=t.props)==null?void 0:d.ref)??(t==null?void 0:t.ref),h=Wd(o,u);return _.useInsertionEffect(()=>{const{width:f,height:p,top:y,left:g,right:b,bottom:w}=l.current;if(e||i===!1||!o.current||!f||!p)return;const v=s==="left"?`left: ${g}`:`right: ${b}`,x=n==="bottom"?`bottom: ${w}`:`top: ${y}`;o.current.dataset.motionPopId=a;const S=document.createElement("style");c&&(S.nonce=c);const k=r??document.head;return k.appendChild(S),S.sheet&&S.sheet.insertRule(`
[data-motion-pop-id="${a}"] {
position: absolute !important;
width: ${f}px !important;
height: ${p}px !important;
${v}px !important;
${x}px !important;
}
`),()=>{var j;(j=o.current)==null||j.removeAttribute("data-motion-pop-id"),k.contains(S)&&k.removeChild(S)}},[e]),m.jsx(qd,{isPresent:e,childRef:o,sizeRef:l,pop:i,children:i===!1?t:_.cloneElement(t,{ref:h})})}const Kd=({children:t,initial:e,isPresent:s,onExitComplete:n,custom:r,presenceAffectsLayout:i,mode:a,anchorX:o,anchorY:l,root:c})=>{const u=Jn(Gd),h=_.useId();let d=!0,f=_.useMemo(()=>(d=!1,{id:h,initial:e,isPresent:s,custom:r,onExitComplete:p=>{u.set(p,!0);for(const y of u.values())if(!y)return;n&&n()},register:p=>(u.set(p,!1),()=>u.delete(p))}),[s,u,n]);return i&&d&&(f={...f}),_.useMemo(()=>{u.forEach((p,y)=>u.set(y,!1))},[s]),_.useEffect(()=>{!s&&!u.size&&n&&n()},[s]),t=m.jsx(Hd,{pop:a==="popLayout",isPresent:s,anchorX:o,anchorY:l,root:c,children:t}),m.jsx(Ts.Provider,{value:f,children:t})};function Gd(){return new Map}function Zo(t=!0){const e=_.useContext(Ts);if(e===null)return[!0,null];const{isPresent:s,onExitComplete:n,register:r}=e,i=_.useId();_.useEffect(()=>{if(t)return r(i)},[t]);const a=_.useCallback(()=>t&&n&&n(i),[i,n,t]);return!s&&n?[!1,a]:[!0]}const Jt=t=>t.key||"";function Ni(t){const e=[];return _.Children.forEach(t,s=>{_.isValidElement(s)&&e.push(s)}),e}const Rn=({children:t,custom:e,initial:s=!0,onExitComplete:n,presenceAffectsLayout:r=!0,mode:i="sync",propagate:a=!1,anchorX:o="left",anchorY:l="top",root:c})=>{const[u,h]=Zo(a),d=_.useMemo(()=>Ni(t),[t]),f=a&&!u?[]:d.map(Jt),p=_.useRef(!0),y=_.useRef(d),g=Jn(()=>new Map),b=_.useRef(new Set),[w,v]=_.useState(d),[x,S]=_.useState(d);Ta(()=>{p.current=!1,y.current=d;for(let E=0;E<x.length;E++){const O=Jt(x[E]);f.includes(O)?(g.delete(O),b.current.delete(O)):g.get(O)!==!0&&g.set(O,!1)}},[x,f.length,f.join("-")]);const k=[];if(d!==w){let E=[...d];for(let O=0;O<x.length;O++){const P=x[O],M=Jt(P);f.includes(M)||(E.splice(O,0,P),k.push(P))}return i==="wait"&&k.length&&(E=k),S(Ni(E)),v(d),null}const{forceRender:j}=_.useContext(zn);return m.jsx(m.Fragment,{children:x.map(E=>{const O=Jt(E),P=a&&!u?!1:d===x||f.includes(O),M=()=>{if(b.current.has(O))return;if(g.has(O))b.current.add(O),g.set(O,!0);else return;let q=!0;g.forEach(xe=>{xe||(q=!1)}),q&&(j==null||j(),S(y.current),a&&(h==null||h()),n&&n())};return m.jsx(Kd,{isPresent:P,initial:!p.current||s?void 0:!1,custom:e,presenceAffectsLayout:r,mode:i,root:c,onExitComplete:P?void 0:M,anchorX:o,anchorY:l,children:E},O)})})},Qo=_.createContext({strict:!1}),Mi={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 $i=!1;function zd(){if($i)return;const t={};for(const e in Mi)t[e]={isEnabled:s=>Mi[e].some(n=>!!s[n])};Po(t),$i=!0}function el(){return zd(),Oh()}function Jd(t){const e=el();for(const s in t)e[s]={...e[s],...t[s]};Po(e)}const Yd=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 bs(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||Yd.has(t)}let tl=t=>!bs(t);function Xd(t){typeof t=="function"&&(tl=e=>e.startsWith("on")?!bs(e):t(e))}try{Xd(require("@emotion/is-prop-valid").default)}catch{}function Zd(t,e,s){const n={};for(const r in t)r==="values"&&typeof t.values=="object"||J(t[r])||(tl(r)||s===!0&&bs(r)||!e&&!bs(r)||t.draggable&&r.startsWith("onDrag"))&&(n[r]=t[r]);return n}const Cs=_.createContext({});function Qd(t,e){if(Ps(t)){const{initial:s,animate:n}=t;return{initial:s===!1||Dt(s)?s:void 0,animate:Dt(n)?n:void 0}}return t.inherit!==!1?e:{}}function ef(t){const{initial:e,animate:s}=Qd(t,_.useContext(Cs));return _.useMemo(()=>({initial:e,animate:s}),[Li(e),Li(s)])}function Li(t){return Array.isArray(t)?t.join(" "):t}const br=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function sl(t,e,s){for(const n in e)!J(e[n])&&!No(n,s)&&(t[n]=e[n])}function tf({transformTemplate:t},e){return _.useMemo(()=>{const s=br();return yr(s,e,t),Object.assign({},s.vars,s.style)},[e])}function sf(t,e){const s=t.style||{},n={};return sl(n,s,t),Object.assign(n,tf(t,e)),n}function nf(t,e){const s={},n=sf(t,e);return t.drag&&t.dragListener!==!1&&(s.draggable=!1,n.userSelect=n.WebkitUserSelect=n.WebkitTouchCallout="none",n.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=n,s}const nl=()=>({...br(),attrs:{}});function rf(t,e,s,n){const r=_.useMemo(()=>{const i=nl();return Mo(i,e,Lo(n),t.transformTemplate,t.style),{...i.attrs,style:{...i.style}}},[e]);if(t.style){const i={};sl(i,t.style,t),r.style={...i,...r.style}}return r}const af=["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 xr(t){return typeof t!="string"||t.includes("-")?!1:!!(af.indexOf(t)>-1||/[A-Z]/u.test(t))}function of(t,e,s,{latestValues:n},r,i=!1,a){const l=(a??xr(t)?rf:nf)(e,n,r,t),c=Zd(e,typeof t=="string",i),u=t!==_.Fragment?{...c,...l,ref:s}:{},{children:h}=e,d=_.useMemo(()=>J(h)?h.get():h,[h]);return _.createElement(t,{...u,children:d})}function lf({scrapeMotionValuesFromProps:t,createRenderState:e},s,n,r){return{latestValues:cf(s,n,r,t),renderState:e()}}function cf(t,e,s,n){const r={},i=n(t,{});for(const d in i)r[d]=cs(i[d]);let{initial:a,animate:o}=t;const l=Ps(t),c=Ao(t);e&&c&&!l&&t.inherit!==!1&&(a===void 0&&(a=e.initial),o===void 0&&(o=e.animate));let u=s?s.initial===!1:!1;u=u||a===!1;const h=u?o:a;if(h&&typeof h!="boolean"&&!Es(h)){const d=Array.isArray(h)?h:[h];for(let f=0;f<d.length;f++){const p=cr(t,d[f]);if(p){const{transitionEnd:y,transition:g,...b}=p;for(const w in b){let v=b[w];if(Array.isArray(v)){const x=u?v.length-1:0;v=v[x]}v!==null&&(r[w]=v)}for(const w in y)r[w]=y[w]}}}return r}const rl=t=>(e,s)=>{const n=_.useContext(Cs),r=_.useContext(Ts),i=()=>lf(t,e,n,r);return s?i():Jn(i)},uf=rl({scrapeMotionValuesFromProps:vr,createRenderState:br}),hf=rl({scrapeMotionValuesFromProps:Bo,createRenderState:nl}),df=Symbol.for("motionComponentSymbol");function ff(t,e,s){const n=_.useRef(s);_.useInsertionEffect(()=>{n.current=s});const r=_.useRef(null);return _.useCallback(i=>{var o;i&&((o=t.onMount)==null||o.call(t,i));const a=n.current;if(typeof a=="function")if(i){const l=a(i);typeof l=="function"&&(r.current=l)}else r.current?(r.current(),r.current=null):a(i);else a&&(a.current=i);e&&(i?e.mount(i):e.unmount())},[e])}const il=_.createContext({});function nt(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function pf(t,e,s,n,r,i){var v,x;const{visualElement:a}=_.useContext(Cs),o=_.useContext(Qo),l=_.useContext(Ts),c=_.useContext(wr),u=c.reducedMotion,h=c.skipAnimations,d=_.useRef(null),f=_.useRef(!1);n=n||o.renderer,!d.current&&n&&(d.current=n(t,{visualState:e,parent:a,props:s,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:u,skipAnimations:h,isSVG:i}),f.current&&d.current&&(d.current.manuallyAnimateOnMount=!0));const p=d.current,y=_.useContext(il);p&&!p.projection&&r&&(p.type==="html"||p.type==="svg")&&mf(d.current,s,r,y);const g=_.useRef(!1);_.useInsertionEffect(()=>{p&&g.current&&p.update(s,l)});const b=s[fo],w=_.useRef(!!b&&typeof window<"u"&&!((v=window.MotionHandoffIsComplete)!=null&&v.call(window,b))&&((x=window.MotionHasOptimisedAnimation)==null?void 0:x.call(window,b)));return Ta(()=>{f.current=!0,p&&(g.current=!0,window.MotionIsMounted=!0,p.updateFeatures(),p.scheduleRenderMicrotask(),w.current&&p.animationState&&p.animationState.animateChanges())}),_.useEffect(()=>{p&&(!w.current&&p.animationState&&p.animationState.animateChanges(),w.current&&(queueMicrotask(()=>{var S;(S=window.MotionHandoffMarkAsComplete)==null||S.call(window,b)}),w.current=!1),p.enteringChildren=void 0)}),p}function mf(t,e,s,n){const{layoutId:r,layout:i,drag:a,dragConstraints:o,layoutScroll:l,layoutRoot:c,layoutAnchor:u,layoutCrossfade:h}=e;t.projection=new s(t.latestValues,e["data-framer-portal-id"]?void 0:al(t.parent)),t.projection.setOptions({layoutId:r,layout:i,alwaysMeasureLayout:!!a||o&&nt(o),visualElement:t,animationType:typeof i=="string"?i:"both",initialPromotionConfig:n,crossfade:h,layoutScroll:l,layoutRoot:c,layoutAnchor:u})}function al(t){if(t)return t.options.allowProjection!==!1?t.projection:al(t.parent)}function qs(t,{forwardMotionProps:e=!1,type:s}={},n,r){n&&Jd(n);const i=s?s==="svg":xr(t),a=i?hf:uf;function o(c,u){let h;const d={..._.useContext(wr),...c,layoutId:gf(c)},{isStatic:f}=d,p=ef(c),y=a(c,f);if(!f&&typeof window<"u"){yf();const g=vf(d);h=g.MeasureLayout,p.visualElement=pf(t,y,d,r,g.ProjectionNode,i)}return m.jsxs(Cs.Provider,{value:p,children:[h&&p.visualElement?m.jsx(h,{visualElement:p.visualElement,...d}):null,of(t,c,ff(y,p.visualElement,u),y,f,e,i)]})}o.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const l=_.forwardRef(o);return l[df]=t,l}function gf({layoutId:t}){const e=_.useContext(zn).id;return e&&t!==void 0?e+"-"+t:t}function yf(t,e){_.useContext(Qo).strict}function vf(t){const e=el(),{drag:s,layout:n}=e;if(!s&&!n)return{};const r={...s,...n};return{MeasureLayout:s!=null&&s.isEnabled(t)||n!=null&&n.isEnabled(t)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function wf(t,e){if(typeof Proxy>"u")return qs;const s=new Map,n=(i,a)=>qs(i,a,t,e),r=(i,a)=>n(i,a);return new Proxy(r,{get:(i,a)=>a==="create"?n:(s.has(a)||s.set(a,qs(a,void 0,t,e)),s.get(a))})}const bf=(t,e)=>e.isSVG??xr(t)?new Jh(e):new Wh(e,{allowProjection:t!==_.Fragment});class xf extends Ne{constructor(e){super(e),e.animationState||(e.animationState=ed(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();Es(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(){var e;this.node.animationState.reset(),(e=this.unmountControls)==null||e.call(this)}}let _f=0;class Sf extends Ne{constructor(){super(...arguments),this.id=_f++,this.isExitComplete=!1}update(){var i;if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:s}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){const{initial:a,custom:o}=this.node.getProps();if(typeof a=="string"){const l=Je(this.node,a,o);if(l){const{transition:c,transitionEnd:u,...h}=l;for(const d in h)(i=this.node.getValue(d))==null||i.jump(h[d])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const r=this.node.animationState.setActive("exit",!e);s&&!e&&r.then(()=>{this.isExitComplete=!0,s(this.id)})}mount(){const{register:e,onExitComplete:s}=this.node.presenceContext||{};s&&s(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const Tf={animation:{Feature:xf},exit:{Feature:Sf}};function qt(t){return{point:{x:t.pageX,y:t.pageY}}}const kf=t=>e=>fr(e)&&t(e,qt(e));function At(t,e,s,n){return It(t,e,kf(s),n)}const ol=({current:t})=>t?t.ownerDocument.defaultView:null,Bi=(t,e)=>Math.abs(t-e);function Af(t,e){const s=Bi(t.x,e.x),n=Bi(t.y,e.y);return Math.sqrt(s**2+n**2)}const Vi=new Set(["auto","scroll"]);class ll{constructor(e,s,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=f=>{this.handleScroll(f.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Yt(this.lastRawMoveEventInfo,this.transformPagePoint));const f=Hs(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,y=Af(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!y)return;const{point:g}=f,{timestamp:b}=z;this.history.push({...g,timestamp:b});const{onStart:w,onMove:v}=this.handlers;p||(w&&w(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),v&&v(this.lastMoveEvent,f)},this.handlePointerMove=(f,p)=>{this.lastMoveEvent=f,this.lastRawMoveEventInfo=p,this.lastMoveEventInfo=Yt(p,this.transformPagePoint),D.update(this.updatePoint,!0)},this.handlePointerUp=(f,p)=>{this.end();const{onEnd:y,onSessionEnd:g,resumeAnimation:b}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&b&&b(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const w=Hs(f.type==="pointercancel"?this.lastMoveEventInfo:Yt(p,this.transformPagePoint),this.history);this.startEvent&&y&&y(f,w),g&&g(f,w)},!fr(e))return;this.dragSnapToOrigin=i,this.handlers=s,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;const l=qt(e),c=Yt(l,this.transformPagePoint),{point:u}=c,{timestamp:h}=z;this.history=[{...u,timestamp:h}];const{onSessionStart:d}=s;d&&d(e,Hs(c,this.history)),this.removeListeners=Ut(At(this.contextWindow,"pointermove",this.handlePointerMove),At(this.contextWindow,"pointerup",this.handlePointerUp),At(this.contextWindow,"pointercancel",this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let s=e.parentElement;for(;s;){const n=getComputedStyle(s);(Vi.has(n.overflowX)||Vi.has(n.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 n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-s.x,y:r.y-s.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),D.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Ie(this.updatePoint)}}function Yt(t,e){return e?{point:e(t.point)}:t}function Ui(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Hs({point:t},e){return{point:t,delta:Ui(t,cl(e)),offset:Ui(t,Ef(e)),velocity:Pf(e,.1)}}function Ef(t){return t[0]}function cl(t){return t[t.length-1]}function Pf(t,e){if(t.length<2)return{x:0,y:0};let s=t.length-1,n=null;const r=cl(t);for(;s>=0&&(n=t[s],!(r.timestamp-n.timestamp>Z(e)));)s--;if(!n)return{x:0,y:0};n===t[0]&&t.length>2&&r.timestamp-n.timestamp>Z(e)*2&&(n=t[1]);const i=re(r.timestamp-n.timestamp);if(i===0)return{x:0,y:0};const a={x:(r.x-n.x)/i,y:(r.y-n.y)/i};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}function Cf(t,{min:e,max:s},n){return e!==void 0&&t<e?t=n?N(e,t,n.min):Math.max(t,e):s!==void 0&&t>s&&(t=n?N(s,t,n.max):Math.min(t,s)),t}function Fi(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 Rf(t,{top:e,left:s,bottom:n,right:r}){return{x:Fi(t.x,s,r),y:Fi(t.y,e,n)}}function Wi(t,e){let s=e.min-t.min,n=e.max-t.max;return e.max-e.min<t.max-t.min&&([s,n]=[n,s]),{min:s,max:n}}function jf(t,e){return{x:Wi(t.x,e.x),y:Wi(t.y,e.y)}}function Of(t,e){let s=.5;const n=X(t),r=X(e);return r>n?s=jt(e.min,e.max-n,t.min):n>r&&(s=jt(t.min,t.max-r,e.min)),be(0,1,s)}function Df(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 jn=.35;function If(t=jn){return t===!1?t=0:t===!0&&(t=jn),{x:qi(t,"left","right"),y:qi(t,"top","bottom")}}function qi(t,e,s){return{min:Hi(t,e),max:Hi(t,s)}}function Hi(t,e){return typeof t=="number"?t:t[e]||0}const Nf=new WeakMap;class Mf{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=W(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:s=!1,distanceThreshold:n}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const i=h=>{s&&this.snapToCursor(qt(h).point),this.stopAnimation()},a=(h,d)=>{const{drag:f,dragPropagation:p,onDragStart:y}=this.getProps();if(f&&!p&&(this.openDragLock&&this.openDragLock(),this.openDragLock=lh(f),!this.openDragLock))return;this.latestPointerEvent=h,this.latestPanInfo=d,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),ye(b=>{let w=this.getAxisMotionValue(b).get()||0;if(we.test(w)){const{projection:v}=this.visualElement;if(v&&v.layout){const x=v.layout.layoutBox[b];x&&(w=X(x)*(parseFloat(w)/100))}}this.originPoint[b]=w}),y&&D.update(()=>y(h,d),!1,!0),xn(this.visualElement,"transform");const{animationState:g}=this.visualElement;g&&g.setActive("whileDrag",!0)},o=(h,d)=>{this.latestPointerEvent=h,this.latestPanInfo=d;const{dragPropagation:f,dragDirectionLock:p,onDirectionLock:y,onDrag:g}=this.getProps();if(!f&&!this.openDragLock)return;const{offset:b}=d;if(p&&this.currentDirection===null){this.currentDirection=Lf(b),this.currentDirection!==null&&y&&y(this.currentDirection);return}this.updateAxis("x",d.point,b),this.updateAxis("y",d.point,b),this.visualElement.render(),g&&D.update(()=>g(h,d),!1,!0)},l=(h,d)=>{this.latestPointerEvent=h,this.latestPanInfo=d,this.stop(h,d),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{const{dragSnapToOrigin:h}=this.getProps();(h||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:u}=this.getProps();this.panSession=new ll(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:u,distanceThreshold:n,contextWindow:ol(this.visualElement),element:this.visualElement.current})}stop(e,s){const n=e||this.latestPointerEvent,r=s||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;const{velocity:a}=r;this.startAnimation(a);const{onDragEnd:o}=this.getProps();o&&D.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;const{projection:e,animationState:s}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:n}=this.getProps();!n&&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,n){const{drag:r}=this.getProps();if(!n||!Xt(e,r,this.currentDirection))return;const i=this.getAxisMotionValue(e);let a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=Cf(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){var i;const{dragConstraints:e,dragElastic:s}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(i=this.visualElement.projection)==null?void 0:i.layout,r=this.constraints;e&&nt(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&n?this.constraints=Rf(n.layoutBox,e):this.constraints=!1,this.elastic=If(s),r!==this.constraints&&!nt(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&ye(a=>{this.constraints!==!1&&this.getAxisMotionValue(a)&&(this.constraints[a]=Df(n.layoutBox[a],this.constraints[a]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:s}=this.getProps();if(!e||!nt(e))return!1;const n=e.current;ft(n!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const i=$h(n,r.root,this.visualElement.getTransformPagePoint());let a=jf(r.layout.layoutBox,i);if(s){const o=s(Ih(a));this.hasMutatedConstraints=!!o,o&&(a=Ro(o))}return a}startAnimation(e){const{drag:s,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),l=this.constraints||{},c=ye(u=>{if(!Xt(u,s,this.currentDirection))return;let h=l&&l[u]||{};(a===!0||a===u)&&(h={min:0,max:0});const d=r?200:1e6,f=r?40:1e7,p={type:"inertia",velocity:n?e[u]:0,bounceStiffness:d,bounceDamping:f,timeConstant:750,restDelta:1,restSpeed:10,...i,...h};return this.startAxisValueAnimation(u,p)});return Promise.all(c).then(o)}startAxisValueAnimation(e,s){const n=this.getAxisMotionValue(e);return xn(this.visualElement,e),n.start(lr(e,n,0,s,this.visualElement,!1))}stopAnimation(){ye(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){const s=`_drag${e.toUpperCase()}`,n=this.visualElement.getProps(),r=n[s];return r||this.visualElement.getValue(e,(n.initial?n.initial[e]:void 0)||0)}snapToCursor(e){ye(s=>{const{drag:n}=this.getProps();if(!Xt(s,n,this.currentDirection))return;const{projection:r}=this.visualElement,i=this.getAxisMotionValue(s);if(r&&r.layout){const{min:a,max:o}=r.layout.layoutBox[s],l=i.get()||0;i.set(e[s]-N(a,o,.5)+l)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:s}=this.getProps(),{projection:n}=this.visualElement;if(!nt(s)||!n||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};ye(a=>{const o=this.getAxisMotionValue(a);if(o&&this.constraints!==!1){const l=o.get();r[a]=Of({min:l,max:l},this.constraints[a])}});const{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),ye(a=>{if(!Xt(a,e,null))return;const o=this.getAxisMotionValue(a),{min:l,max:c}=this.constraints[a];o.set(N(l,c,r[a]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Nf.set(this.visualElement,this);const e=this.visualElement.current,s=At(e,"pointerdown",c=>{const{drag:u,dragListener:h=!0}=this.getProps(),d=c.target,f=d!==e&&ph(d);u&&h&&!f&&this.start(c)});let n;const r=()=>{const{dragConstraints:c}=this.getProps();nt(c)&&c.current&&(this.constraints=this.resolveRefConstraints(),n||(n=$f(e,c.current,()=>this.scalePositionWithinConstraints())))},{projection:i}=this.visualElement,a=i.addEventListener("measure",r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),D.read(r);const o=It(window,"resize",()=>this.scalePositionWithinConstraints()),l=i.addEventListener("didUpdate",({delta:c,hasLayoutChanged:u})=>{this.isDragging&&u&&(ye(h=>{const d=this.getAxisMotionValue(h);d&&(this.originPoint[h]+=c[h].translate,d.set(d.get()+c[h].translate))}),this.visualElement.render())});return()=>{o(),s(),a(),l&&l(),n&&n()}}getProps(){const e=this.visualElement.getProps(),{drag:s=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=jn,dragMomentum:o=!0}=e;return{...e,drag:s,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}}function Ki(t){let e=!0;return()=>{if(e){e=!1;return}t()}}function $f(t,e,s){const n=Qr(t,Ki(s)),r=Qr(e,Ki(s));return()=>{n(),r()}}function Xt(t,e,s){return(e===!0||e===t)&&(s===null||s===t)}function Lf(t,e=10){let s=null;return Math.abs(t.y)>e?s="y":Math.abs(t.x)>e&&(s="x"),s}class Bf extends Ne{constructor(e){super(e),this.removeGroupControls=ie,this.removeListeners=ie,this.controls=new Mf(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||ie}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 Ks=t=>(e,s)=>{t&&D.update(()=>t(e,s),!1,!0)};class Vf extends Ne{constructor(){super(...arguments),this.removePointerDownListener=ie}onPointerDown(e){this.session=new ll(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:ol(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:s,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:Ks(e),onStart:Ks(s),onMove:Ks(n),onEnd:(i,a)=>{delete this.session,r&&D.postRender(()=>r(i,a))}}}mount(){this.removePointerDownListener=At(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 Gs=!1;class Uf extends _.Component{componentDidMount(){const{visualElement:e,layoutGroup:s,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(s.group&&s.group.add(i),n&&n.register&&r&&n.register(i),Gs&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),us.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:s,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a&&(a.isPresent=i,e.layoutDependency!==s&&a.setOptions({...a.options,layoutDependency:s}),Gs=!0,r||e.layoutDependency!==s||s===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||D.postRender(()=>{const o=a.getStack();(!o||!o.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:e,layoutAnchor:s}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=s,n.root.didUpdate(),dr.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:s,switchLayoutGroup:n}=this.props,{projection:r}=e;Gs=!0,r&&(r.scheduleCheckAfterUnmount(),s&&s.group&&s.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function ul(t){const[e,s]=Zo(),n=_.useContext(zn);return m.jsx(Uf,{...t,layoutGroup:n,switchLayoutGroup:_.useContext(il),isPresent:e,safeToRemove:s})}const Ff={pan:{Feature:Vf},drag:{Feature:Bf,ProjectionNode:Xo,MeasureLayout:ul}};function Gi(t,e,s){const{props:n}=t;t.animationState&&n.whileHover&&t.animationState.setActive("whileHover",s==="Start");const r="onHover"+s,i=n[r];i&&D.postRender(()=>i(e,qt(e)))}class Wf extends Ne{mount(){const{current:e}=this.node;e&&(this.unmount=uh(e,(s,n)=>(Gi(this.node,n,"Start"),r=>Gi(this.node,r,"End"))))}unmount(){}}class qf extends Ne{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=Ut(It(this.node.current,"focus",()=>this.onFocus()),It(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function zi(t,e,s){const{props:n}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&n.whileTap&&t.animationState.setActive("whileTap",s==="Start");const r="onTap"+(s==="End"?"":s),i=n[r];i&&D.postRender(()=>i(e,qt(e)))}class Hf extends Ne{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:s,propagate:n}=this.node.props;this.unmount=gh(e,(r,i)=>(zi(this.node,i,"Start"),(a,{success:o})=>zi(this.node,a,o?"End":"Cancel")),{useGlobalTarget:s,stopPropagation:(n==null?void 0:n.tap)===!1})}unmount(){}}const On=new WeakMap,zs=new WeakMap,Kf=t=>{const e=On.get(t.target);e&&e(t)},Gf=t=>{t.forEach(Kf)};function zf({root:t,...e}){const s=t||document;zs.has(s)||zs.set(s,{});const n=zs.get(s),r=JSON.stringify(e);return n[r]||(n[r]=new IntersectionObserver(Gf,{root:t,...e})),n[r]}function Jf(t,e,s){const n=zf(e);return On.set(t,s),n.observe(t),()=>{On.delete(t),n.unobserve(t)}}const Yf={some:0,all:1};class Xf extends Ne{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var l;(l=this.stopObserver)==null||l.call(this);const{viewport:e={}}=this.node.getProps(),{root:s,margin:n,amount:r="some",once:i}=e,a={root:s?s.current:void 0,rootMargin:n,threshold:typeof r=="number"?r:Yf[r]},o=c=>{const{isIntersecting:u}=c;if(this.isInView===u||(this.isInView=u,i&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:h,onViewportLeave:d}=this.node.getProps(),f=u?h:d;f&&f(c)};this.stopObserver=Jf(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:s}=this.node;["amount","margin","root"].some(Zf(e,s))&&this.startObserver()}unmount(){var e;(e=this.stopObserver)==null||e.call(this),this.hasEnteredView=!1,this.isInView=!1}}function Zf({viewport:t={}},{viewport:e={}}={}){return s=>t[s]!==e[s]}const Qf={inView:{Feature:Xf},tap:{Feature:Hf},focus:{Feature:qf},hover:{Feature:Wf}},ep={layout:{ProjectionNode:Xo,MeasureLayout:ul}},tp={...Tf,...Qf,...Ff,...ep},Ce=wf(tp,bf),sp=[{slug:"claudia-hounslow",name:"Claudia Hounslow",title:"Director & Psychologist",ahpraNumber:"PSY0001527849",photo:"/images/team/claudia.png",inPerson:["Tuesday","Wednesday"],online:["Tuesday","Wednesday"],areas:["Individual","Coaching"],tags:["Executive Coaching","Neuropsychology","Women in Leadership","Anxiety","High Performers"],bio:`Claudia is a psychologist and the director of Contemporary Psychology. Her lifelong passion of delivering mental health education with a neuropsychological lens led to the creation of our amazing clinic. Claudia has worked as a psychologist for over 18 years and has studied extensively in human behaviour, personality, attachment, coaching, neuropsychology, business development and management. In addition to her training in psychology, Claudia has also obtained a master's degree in management and can provide further insight into organisational leadership, workplace dynamics, personality profiling, your interpersonal style, and provide leadership coaching.
Claudia is committed to the pursuit of knowledge and is energised by the complexity of the human mind. She believes individuals are shaped through experience, and uses the latest insights in to neuroplasticity to encourage her clients to create lasting behavioural change. Whether you are seeking a formal assessment, coaching or psychotherapy, you will benefit from her experienced and compassionate approach.
`,areasOfInterest:["Health Professionals Wellbeing","Coaching high performers","Neuropsychology","Women in leadership","Self sacrificing beliefs and schemas","Generalised Anxiety","Business owners & leaders training in mental health","Performance Anxiety","Executive Coaching","Relationship Conflict","Anger Management"],qualifications:[{degree:"Master of Management"}],isPsychologist:!0},{slug:"rivkah-bendet",name:"Rivkah Bendet",title:"Psychologist",ahpraNumber:"PSY0002616011",sameAs:["https://www.psychologytoday.com/au/counselling/rivkah-bendet-saint-kilda-vic/1698545","https://healthengine.com.au/psychologist/vic/st-kilda-east/ms-rivkah-bendet/p125162"],photo:"/images/team/rivkah.jpg",inPerson:["Tuesday","Wednesday","Thursday","Friday"],online:["Monday","Tuesday","Wednesday","Thursday","Friday"],areas:["Individual","Trauma","Assessment","TAC"],tags:["Anxiety","Trauma","Body Image","ADHD/ASD","Neuroaffirming"],bio:`Rivkah understands that mental health is a crucial aspect of a person's quality of life and day-to-day functioning. She is therefore passionate about providing her clients with the necessary support and guidance to help them achieve and maintain psychological well-being.
Through her Master's in Educational and Developmental Psychology at Monash University, Rivkah gained skills in counselling, administering assessments, and delivering relaxation exercises for clients. She has worked with people of all ages and with various presentations including anxiety, anger management, ADHD, ASD and more.
Rivkah's experience in working with many different people from diverse backgrounds has made her a well-rounded and compassionate psychologist, capable of understanding and addressing the unique needs of a wide range of individuals.
Rivkah employs a client-centred approach and utilises a variety of evidence-based therapies, including cognitive-behavioural therapy, acceptance and commitment therapy, schema therapy and motivational interviewing to assist clients in overcoming their challenges.
Rivkah believes that building a strong rapport with her clients is essential for achieving positive and powerful outcomes. Her clients describe her as warm, empathetic, dedicated, and easy to work with.`,areasOfInterest:["Relational conflict","Anxiety","Social anxiety & shyness","Self-esteem & confidence","Grief","Trauma","Life transitions","Body image and eating concerns","Assessments for Learning Disorders, ADHD & ASD","Neuroaffirming practice"],qualifications:[{degree:"Master of Educational and Developmental Psychology",institution:"Monash University"}],neurodivergenceSpecialist:!0,isPsychologist:!0},{slug:"lucy-adlard",name:"Lucy Adlard",title:"Psychologist",ahpraNumber:"PSY0002698522",sameAs:["https://www.psychologytoday.com/au/counselling/lucy-adlard-melbourne-vic/1461825","https://healthengine.com.au/psychologist/vic/st-kilda-east/ms-lucy-adlard/p128660"],photo:"/images/team/lucy.jpg",inPerson:["Tuesday","Wednesday","Thursday","Friday"],online:["Monday","Tuesday","Wednesday","Thursday","Friday"],areas:["Individual","Coaching","Workcover","TAC","Trauma","Couples"],tags:["Anxiety","Couples Therapy","Life Transitions","Emotional Regulation","Mood Disorders"],bio:`Clients often describe Lucy as warm and grounded, with a natural ability to bring energy and insight into each session. She's known for her respectful yet direct style, gently challenging stuck patterns and helping clients move toward meaningful change beyond the therapy room.
Her clinical interests include behaviour change and addictions, emotional regulation, anxiety (in all its forms), sleep, and mood and personality disorders. She also has further training in the Gottman Method (Level 2) and has a particular interest supporting clients working through relationship and attachment concerns, as well as working with couples.
Lucy adapts her therapeutic style to suit each individual, drawing from a range of evidence-based approaches including Cognitive Behavioural Therapy (CBT), Acceptance and Commitment Therapy (ACT), Schema Therapy, and Dialectical Behaviour Therapy (DBT).
Lucy takes a holistic, client-led approach to mental health and believes that therapy works best when clients feel genuinely safe, heard, and comfortable being themselves. She's passionate about creating the kind of space that feels supportive and relaxed, yet still fosters honesty, curiosity, and self-compassion.`,areasOfInterest:["Anxiety","Relationships and romantic attachments","Couples","Trauma","Life Transitions","Emotional Regulation / Anger Management","Social anxiety and self-esteem","Sleep","Interpersonal challenges","LGBTQIA+","Mood and personality disorders"],isPsychologist:!0},{slug:"avi-winner",name:"Avi Winner",title:"Psychologist",ahpraNumber:"PSY0002588644",sameAs:["https://www.psychologytoday.com/au/counselling/avrohom-winner-saint-kilda-vic/1693608","https://healthengine.com.au/psychologist/vic/st-kilda-east/mr-avi-winner/p140216"],photo:"/images/team/avi.jpg",inPerson:["Thursday","Friday"],online:["Thursday","Friday"],areas:["Individual","Assessment","TAC","Workcover","Trauma"],tags:["Neurodivergence","Executive Function","Anxiety & Depression","Life Transitions","Assessments"],bio:`Avi understands that every individual has unique goals and challenges, and he views supporting people on their journey toward well-being and personal fulfilment as both a calling and a privilege. He takes a client-led, strengths-based approach, helping clients pursue their goals, navigate challenges, gain self-understanding, and maximise their well-being and achievement.
Avi believes that the foundation of effective therapy lies in the relationship between client and psychologist. With warmth, empathy, and respect, he strives to create a safe and supportive environment where clients feel seen, valued, and understood.
With his diverse experience and easy ability to connect, Avi is well-suited to address a broad range of goals and challenges. (Some of) Avi's therapeutic interests include supporting neurodivergent individuals in professional and social settings, and life transitions such as parenthood, ageing, and grief. He also brings experience in psychological and diagnostic assessments, delivering thorough, accessible reports that aim to truly 'get' the individual and respond clearly to their questions.
Avi's journey into psychology followed a bachelor's degree in philosophy, where he explored questions around living a meaningful and fulfilling life. He then went on to complete a Master of Educational and Developmental Psychology at Monash University, and has conducted research in areas including ADHD and fatherhood.`,areasOfInterest:["Being neurodivergent in a neurotypical world","Executive functioning","Assertiveness and self-advocacy","Confidence and self-efficacy","Anxiety and depression","Life transitions","Ageing","Grief","Assessments and psychoeducational reports"],qualifications:[{degree:"Master of Educational and Developmental Psychology",institution:"Monash University"}],neurodivergenceSpecialist:!0,isPsychologist:!0},{slug:"david-bokan",name:"David Bokan",title:"Psychologist",ahpraNumber:"PSY0002821425",photo:"/images/team/david.png",inPerson:["Wednesday","Thursday","Friday"],online:["Wednesday","Thursday","Friday"],areas:["Individual","Assessment"],tags:["Anxiety","Emotional Regulation","Neurodivergence","Trauma-Informed","Men's Mental Health","Youth Mental Health"],bio:`David is committed to supporting and working collaboratively with clients through their unique mental health journey and offers a warm, empathetic, and non-judgemental space where individuals feel heard and respected, with approaches centred to each individual's own experiences and needs.
His clinical interests include anxiety, emotional regulation, neurodivergence, trauma-informed practice, men's mental health, and many more. He has worked with clients from diverse backgrounds, ages, and presentations in providing therapy as well as psychological assessments. David utilises a variety of best practice evidence-based treatments. These include Cognitive Behavioural Therapy (CBT), Dialectical Behavioural Therapy (DBT), Acceptance and Commitment Therapy (ACT) and mindfulness based interventions.
David is passionate about working with clients from diverse backgrounds and ensuring a safe and empowering therapeutic environment. He completed his Master's in Clinical Psychology at RMIT and is currently working toward his clinical endorsement.`,areasOfInterest:["Anxiety","Depression","Emotional Regulation","Neurodivergence and neuroaffirming practice","Trauma-informed practice","ADHD assessments","Men's mental health","Youth mental health","Life transitions","Grief and loss","CBT, DBT and ACT","Work and performance stress"],qualifications:[{degree:"Master of Clinical Psychology",institution:"RMIT University"}],neurodivergenceSpecialist:!0,personalInterests:"Outside of work, David enjoys sport (all kinds), reading and writing poetry, and watching movies with friends.",isPsychologist:!0},{slug:"bridget-kosmas",name:"Bridget Kosmas",title:"Provisional Psychologist",ahpraNumber:"PSY0002687048",sameAs:["https://healthengine.com.au/psychologist/vic/st-kilda-east/ms-bridget-kosmas/p156858"],photo:"/images/team/bridget.png",inPerson:["Tuesday","Wednesday"],online:["Tuesday","Wednesday"],areas:["Individual","Assessment"],tags:["Anxiety","Depression","Life Transitions","Trauma","Emotion Regulation"],bio:`Bridget is a Provisional Psychologist with a Master of Professional Psychology from La Trobe University. She is passionate about creating a safe, supportive and welcoming environment, where clients can explore their experiences and challenges without judgment. Bridget takes a collaborative approach to therapy, supporting clients to develop insight, clarify their goals, and move toward meaningful and lasting change.
Bridget's clinical interests include but are not limited to; anxiety, depression, workplace difficulties, life transitions, trauma and adjustment disorders, emotion regulation, stress management and self-esteem and identity concerns.
She takes a flexible and integrative approach to therapy sessions, tailoring interventions to each client's individual needs, whilst drawing from evidence-based frameworks including Cognitive Behavioural Therapy (CBT), Acceptance and Commitment Therapy (ACT) and Mindfulness-based approaches.
Using a warm and empathetic style, Bridget seeks to build a strong therapeutic relationship where clients feel heard, understood, and empowered. She is committed to providing an inclusive and affirming space, welcoming individuals from diverse backgrounds.`,areasOfInterest:["Anxiety and depression","Work-related concerns","Life transitions","Adjustment disorders","Trauma and attachment difficulties","Emotion regulation","Stress management","Self-esteem and resilience"],qualifications:[{degree:"Master of Professional Psychology",institution:"La Trobe University"}],personalInterests:"In her spare time, Bridget enjoys travelling, taking her dog out on new walks, eating out with friends, baking and watching crime shows.",isPsychologist:!0},{slug:"adam-boyle",name:"Adam Boyle",title:"Operations Manager",photo:"/images/team/adam.jpg",inPerson:[],online:[],areas:["Booking & Client Care"],tags:[],bio:`Adam is our Operations Manager and the backbone of our front of house. After completing a double degree in Criminology and Psychology and a Postgraduate Diploma in Psychology, Adam is currently pursuing his Master's in Forensic Psychology, driven by a deep interest in criminal processes and behaviour.
In his role, Adam oversees the day-to-day operations of the clinic, ensuring everything runs smoothly and efficiently behind the scenes so our psychologists can focus on what they do best.
Outside of work and study, he enjoys catching up with friends over a good meal or watching the footy.`,isPsychologist:!1},{slug:"nick-van-der-linden",name:"Nick van der Linden",title:"Business Development Manager",photo:"/images/team/nick.png",inPerson:[],online:[],areas:["Booking & Client Care"],tags:[],bio:`Nick is our Business Development Manager, bringing a strong commercial and scientific background to the team. After completing a double degree in Commerce and Science, Nick is currently completing his Honours year at Monash University, with plans to pursue a Master of Professional Psychology.
Nick is passionate about mental health and wellbeing, with a particular focus on supporting and advocating for young men's mental health, a cause he carries into both his academic and professional work.
Outside of the clinic, Nick is an avid sports fan who enjoys running, cooking, and a good movie.`,isPsychologist:!1},{slug:"jacqui-williams",name:"Jacqui Williams",title:"Client & Administrative Support",photo:"/images/team/jacqui.jpg",inPerson:[],online:[],areas:["Booking & Client Care"],tags:[],bio:"Jacqui is part of our client support team, assisting with bookings and client care.",isPsychologist:!1},{slug:"apryl-hamall",name:"Apryl Hamall",title:"Client & Administrative Support",photo:"/images/team/apryl.jpg",inPerson:[],online:[],areas:["Booking & Client Care"],tags:[],bio:"Apryl is part of our client support team, assisting with bookings and client care.",isPsychologist:!1},{slug:"maryann",name:"Maryann Scrivener",title:"Client & Administrative Support",photo:"/images/team/maryann.jpg",inPerson:[],online:[],areas:["Booking & Client Care"],tags:[],bio:"Maryann is a dedicated professional working full-time in psychology administration, bringing both experience and compassion to her role. She is passionate about helping clients connect with the most suitable support tailored to their individual needs, ensuring a seamless and positive experience throughout their journey. With strong organisational skills, attention to detail, and a client-focused approach, Maryann plays a key role in maintaining efficient processes while fostering a welcoming and supportive environment.",isPsychologist:!1},{slug:"joey-summers",name:"Joey Summers",title:"Client & Administrative Support",photo:"/images/team/joey.jpg",inPerson:[],online:[],areas:["Booking & Client Care"],tags:[],bio:"Joey is part of our client support team, assisting with bookings and client care.",isPsychologist:!1}],np=[{slug:"what-to-expect-first-psychology-session",title:"What to Expect from Your First Psychology Session",excerpt:"Many people feel uncertain or anxious before their first appointment. Here is what a first psychology session typically involves, and how to make the most of it.",date:"2025-03-12",category:"Getting Started",readTime:"4 min read",body:["It is completely normal to feel nervous before your first session with a psychologist. You may not know what to say, worry about being judged, or wonder whether therapy will be useful for you. These feelings are understandable, and most psychologists are very familiar with them.","A first session is primarily about your psychologist getting to know you. They will ask about what has brought you in, your history, your current circumstances, and what you are hoping to get from the process. It tends to feel more like a structured conversation than anything clinical or confronting.","You do not need to prepare anything in advance. It can help to have thought about what you most want your psychologist to understand about your situation, but there is no script and no wrong answers. The first session is also a chance to assess whether you feel comfortable with your psychologist. Fit matters, and it is okay to raise concerns or request a different clinician."]},{slug:"understanding-adhd-in-adults",title:"Understanding ADHD in Adults: Beyond the Stereotypes",excerpt:"ADHD in adulthood often looks very different from the hyperactive child stereotype. We explore what adult ADHD can look like, and why so many people are identified later in life.",date:"2025-02-28",category:"ADHD",readTime:"6 min read",body:["When most people think of ADHD, they picture a hyperactive young boy who can't sit still in class. But this stereotype misses the majority of adults who live with ADHD, many of whom were never identified as children, and many of whom are women.","In adults, ADHD often presents as chronic disorganisation, difficulty completing tasks, time blindness, emotional dysregulation, and a persistent sense of underachievement despite significant effort. Hyperactivity may be internalised as mental restlessness or racing thoughts rather than physical movement.","The reasons for late identification are complex. Higher intelligence, strong coping strategies, and supportive environments can mask ADHD symptoms until demands increase, particularly in tertiary education, early career, or parenthood. For many women, ADHD presents primarily through inattention rather than hyperactivity, which is more easily overlooked.","A formal assessment can provide clarity and open access to strategies, support services, and where relevant, medical treatment. It can also be a significant source of self-understanding for people who have long felt something was different about the way their brain works."]},{slug:"the-science-of-anxiety",title:"The Science of Anxiety: Why Your Brain Works the Way It Does",excerpt:"Anxiety is not a character flaw or a sign of weakness. It is your nervous system doing exactly what it was designed to do. Understanding the neuroscience can help.",date:"2025-02-10",category:"Anxiety",readTime:"5 min read",body:["Anxiety is one of the most fundamental responses in the human nervous system. It evolved to protect us from danger, triggering a cascade of physiological changes that prepare the body to fight, flee, or freeze when threat is perceived. In short bursts, anxiety is adaptive. It sharpens attention, increases physical readiness, and motivates action.","The problem is that the brain's threat detection system does not reliably distinguish between a predator and a presentation at work. The amygdala, a structure deep in the brain involved in processing emotional responses, can be activated by social or psychological threats in much the same way it would respond to physical danger.","When anxiety becomes chronic or disproportionate, this suggests that the threat detection system is calibrated too sensitively, often due to past learning experiences, trauma, or biological predisposition. Understanding this does not eliminate anxiety, but it can fundamentally change how you relate to it, shifting from 'there is something wrong with me' to 'my nervous system learned this, and it can be retrained'."]},{slug:"autism-assessment-in-adulthood",title:"Autism Assessment in Adulthood: What the Process Looks Like",excerpt:"More adults are seeking autism assessments than ever before. Here is what the assessment process typically involves, what you might receive at the end, and who can benefit.",date:"2025-01-22",category:"Autism",readTime:"5 min read",body:["In recent years, there has been a significant increase in adults seeking autism assessment, particularly women, older adults, and people who were missed or dismissed during childhood. Many describe a lifelong sense of being different, of struggling in social situations that others seem to navigate effortlessly, or of exhaustion from years of masking.","A comprehensive autism assessment typically involves a detailed clinical interview covering your developmental history, current presentation, strengths and challenges; standardised psychometric tools; and sometimes collateral information from a person who knows you well. The process may take place over multiple sessions.","At the end of the assessment, you receive a written report summarising the findings. This report can support workplace adjustments, academic accommodations, and other forms of support. Importantly, it can also provide a framework for understanding your own experience, something many adults describe as profoundly validating.","An assessment does not change who you are. For many people, it provides language for experiences they have always had, and opens doors to community, support, and self-compassion."]},{slug:"mental-health-treatment-plan-guide",title:"How to Talk to Your GP About Getting a Mental Health Treatment Plan",excerpt:"A Mental Health Treatment Plan from your GP can give you access to Medicare rebates for psychology. Here is how to have that conversation.",date:"2025-01-08",category:"Practical Guides",readTime:"4 min read",body:["If you are considering seeing a psychologist, you may be eligible for a Medicare rebate, but to access it, you need a Mental Health Care Plan (MHCP) from your GP. Many people are unsure how to raise this in a GP appointment. Here is a straightforward guide.","Book a longer appointment with your GP, specifically for a mental health review. When you arrive, be honest about what you have been experiencing. You do not need to have a formal diagnosis or use clinical language. Describing how you have been feeling, how long it has been going on, and how it is affecting your daily life is enough.","Your GP will assess whether you meet criteria for a mental health condition and, if so, complete the MHCP. This plan entitles you to up to 10 rebatable psychology sessions per calendar year. The current Medicare rebate is $101.55 per session. You can bring the plan to your appointment with us and we will process the rebate on the spot.","Note: You do not need an MHCP to see a psychologist at Contemporary Psychology. You can book and attend without one, paying the full fee. The MHCP is only relevant if you want to access the Medicare rebate."]},{slug:"what-is-evidence-based-therapy",title:"What Does Evidence-Based Therapy Actually Mean?",excerpt:"You will often hear psychology practices describe themselves as 'evidence-based'. But what does this actually mean, and why does it matter for you as a client?",date:"2024-12-15",category:"About Psychology",readTime:"5 min read",body:["'Evidence-based' is a term used widely in psychology, but it can mean different things depending on context. At its core, evidence-based practice means drawing on the best available scientific research to inform clinical decisions, rather than relying solely on tradition, personal preference, or anecdote.","In practice, this means that the therapeutic approaches your psychologist uses have been tested in rigorous clinical research, typically randomised controlled trials, and found to produce meaningful outcomes for people with similar presentations to yours. Cognitive-behavioural therapy (CBT), for example, has an extensive evidence base for anxiety and depression. EMDR has strong evidence for PTSD. CBT-I has strong evidence for insomnia.","Evidence-based practice is not the same as applying a rigid protocol. Effective therapy requires the psychologist to integrate research evidence with their clinical expertise and your individual circumstances, preferences, and values. The best outcome is typically achieved when these three elements are in dialogue.","When you choose a psychologist, asking about their approach and the evidence that supports it is entirely reasonable. A good clinician will welcome this question."]}],rp=[{question:"Do I need a GP referral to book?",answer:"No. You can book directly with us without a referral for any service, including ADHD and ASD assessments. If you want to access a Medicare rebate on therapy sessions, you will need a valid Mental Health Care Plan from your GP, but you can begin seeing a psychologist before you have one and arrange it at your next GP appointment. Our admin team can walk you through the options before you book so you know exactly what to expect."},{question:"Do you offer bulk billing?",answer:"We do not offer bulk billing. Session fees range from $165 to $300 depending on the clinician and appointment time. Registered psychologists charge $260.30 before 4pm and $270.45 at or after 4pm. Provisional psychologist Bridget Kosmas charges $165 before 4pm and $175 after. If you hold a valid Mental Health Care Plan from your GP, a Medicare rebate of $101.55 applies per therapy session, up to 10 sessions per calendar year. We process the rebate on the spot so you pay the gap only. ADHD and ASD assessment fees are self-funded and are not covered by Medicare."},{question:"What is a Mental Health Care Plan and how does it work?",answer:"A Mental Health Care Plan (MHCP) is a document prepared by your GP that enables Medicare rebates for psychology sessions. With a valid MHCP you receive a rebate of $101.55 per session for up to 10 sessions per calendar year. You book a longer GP appointment, your GP assesses your mental health needs and writes the plan, and then you bring it to your psychology appointment. We process the rebate directly, meaning you pay the gap on the day. A MHCP is not required to book and is not applicable to ADHD or ASD assessments."},{question:"What can I expect in my first session?",answer:"Your first session is largely about your psychologist understanding you. They will ask about what has brought you in, your background and history, your current circumstances, and what you are hoping to get from the process. It is also a chance for you to ask questions and get a sense of how your psychologist works. You do not need to prepare anything in advance. Most clients find that the first session feels more like a conversation than anything clinical. At the end of the session your psychologist will share their initial thoughts and discuss how they suggest you work together."},{question:"How do I find the right psychologist for me?",answer:"When you contact us, our admin team will speak with you to understand your needs, preferences, and goals before suggesting a match. We consider your presenting concerns, preferred appointment times, whether you want in-person or telehealth, and any preferences around the psychologist's experience or approach. After your first session we check in to make sure the match felt right. If it did not, we can arrange a different clinician within the team at no extra cost. Getting the fit right matters more than getting started quickly."},{question:"What is the difference between a psychologist and a psychiatrist?",answer:"Psychiatrists are medical doctors with specialist training in psychiatry. They can prescribe medication and manage complex or treatment-resistant presentations. Psychologists hold postgraduate qualifications, typically a master's or doctoral degree, in psychological assessment and therapy. They do not prescribe medication but provide evidence-based psychological treatment. Many clients work with both: a psychiatrist for medication management and a psychologist for therapy. If medication is appropriate following an ADHD assessment, we can refer you to a prescriber and continue to provide psychological support alongside that."},{question:"Do you offer telehealth sessions?",answer:"Yes. All of our psychologists offer telehealth appointments via a secure video platform. Telehealth sessions are available to clients anywhere in Australia. In-person appointments are available at our St Kilda clinic at G06-G07/22 St Kilda Road. Many clients use a combination of in-person and telehealth depending on the week. ADHD and ASD assessments require at least one in-person session for psychometric testing, though parts of the process can be completed online."},{question:"How long does a course of therapy typically take?",answer:"There is no fixed length. Some people come for a focused short-term piece of work, six to twelve sessions, while others engage in longer-term therapy over many months. It depends on what you are working on, how long the difficulty has been present, and what you want to achieve. Your psychologist will discuss this with you in the early sessions and revisit it as you progress. Under a Mental Health Care Plan you can access up to 10 rebated sessions per calendar year, after which you can continue at the standard fee or return to your GP to discuss your options."},{question:"What therapies do your psychologists use?",answer:"Our psychologists draw from a range of evidence-based approaches, tailoring the method to the person rather than applying a single framework to everyone. Approaches used across the team include Cognitive Behavioural Therapy (CBT), Acceptance and Commitment Therapy (ACT), Schema Therapy, Dialectical Behaviour Therapy (DBT), mindfulness-based approaches, and trauma-informed frameworks. For couples work, Lucy Adlard is Gottman Level 2 certified. For ADHD and ASD presentations, our psychologists take a neuroaffirming approach alongside structured psychometric assessment."},{question:"How do I know if I need an assessment?",answer:"An assessment may be worth considering if you are seeking clarity about whether you have ADHD or autism, have been told by a GP or psychiatrist that an assessment would be useful, or want a formal diagnostic report to access support at work, university, or through the NDIS. Assessment is not required before accessing therapy. If you are unsure whether an assessment is the right starting point, our admin team can help you think through this before you book. We can often guide you toward the most useful first step."},{question:"Why should I go to therapy?",answer:"You do not need to be in crisis to benefit from psychology. People seek support for many reasons: a specific episode of anxiety or low mood, longer-standing patterns they want to understand and change, relationship difficulties, a significant life transition, or simply a desire for more self-awareness. Therapy provides a structured, confidential space to work through what is getting in the way and build skills you can use outside of sessions. While we cannot guarantee specific outcomes, many clients find that it meaningfully improves their day-to-day functioning and quality of life."},{question:"I have tried therapy before and it did not help. Should I try again?",answer:"Previous unhelpful therapy experience is common and does not mean that psychological support cannot work for you. The most frequent reasons therapy does not help include a poor fit with the therapist, an approach that was not well-matched to the presenting concern, or timing that was not right. When you contact us, we encourage you to share what did and did not work previously. This helps us match you more carefully and approach the work in a way more likely to be useful. A different psychologist and a different approach can produce a very different result."},{question:"What does 'contemporary psychology' mean?",answer:"The name reflects our approach: grounded in current scientific evidence, responsive to the way people actually live, and open to integrating across different therapeutic frameworks rather than taking a rigid or dogmatic approach. Contemporary psychology as a discipline draws on neuroscience, cognitive science, social science, and clinical research to understand and support human wellbeing. We believe that effective psychological care should keep pace with that evidence and remain connected to the real circumstances of each client's life."}],ip=[{title:"Home",desc:"Contemporary Psychology — Melbourne psychologists",href:"/"},{title:"Book Online",desc:"Request an appointment or enquire",href:"/book-online"},{title:"Contact",desc:"Get in touch with our team",href:"/contact"},{title:"Our Team",desc:"Meet our psychologists",href:"/our-team"},{title:"Services",desc:"What we offer",href:"/services"},{title:"What We Help With",desc:"Presentations and conditions we support",href:"/what-we-help-with"},{title:"Pricing & Fees",desc:"Session costs and Medicare rebates",href:"/book-online#pricing"},{title:"FAQs",desc:"Common questions about getting started",href:"/faq"},{title:"Resources",desc:"Articles, guides and tools",href:"/resources"},{title:"Individual Therapy",desc:"One-on-one psychological support",href:"/services/psychology"},{title:"Couples Counselling",desc:"Gottman Method couples therapy",href:"/services/couples-counselling"},{title:"ADHD Assessment",desc:"Comprehensive ADHD assessment for adults",href:"/services/adhd-assessment"},{title:"ASD Assessment",desc:"Autism spectrum assessment for adults",href:"/services/autism-assessment"},{title:"Mental Health Assessment",desc:"Psychological and neuropsychological assessment",href:"/services/mental-health-assessment"},{title:"Coaching",desc:"Psychology-informed coaching for professionals",href:"/services/coaching"},{title:"WorkCover & TAC",desc:"Funded psychology for workplace and transport injuries",href:"/services/workcover-tac"},{title:"Online Counselling",desc:"Telehealth psychology across Australia",href:"/services/online-counselling"},{title:"Adolescent Psychology",desc:"Support for young people aged 13–17",href:"/services/adolescent-psychology"},{title:"Anxiety",desc:"Help with anxiety, worry, panic and phobias",href:"/what-we-help-with/anxiety"},{title:"Depression",desc:"Support for depression and low mood",href:"/what-we-help-with/depression"},{title:"Trauma & PTSD",desc:"Trauma-informed treatment",href:"/what-we-help-with/trauma-and-acute-stress"},{title:"ADHD & Impulsivity",desc:"Understanding and managing ADHD",href:"/what-we-help-with/adhd"},{title:"Addictions",desc:"Support for substance use and behavioural addictions",href:"/what-we-help-with/addictions"},{title:"Sleep Disturbance",desc:"CBT-I and sleep therapy",href:"/what-we-help-with/sleep-disturbance"},{title:"Work Issues & Burnout",desc:"Burnout, workplace stress and career challenges",href:"/what-we-help-with/work-issues-burnout"},{title:"LGBTIQA+ Counselling",desc:"Affirming psychological support",href:"/what-we-help-with/lgbtiqa-counselling"},{title:"Relationships & Attachment",desc:"Relationship difficulties and attachment patterns",href:"/what-we-help-with/relationships-and-attachment"},{title:"Disordered Eating",desc:"Support for eating and body image concerns",href:"/what-we-help-with/disordered-eating"},{title:"Autism Support",desc:"Neuroaffirming support for autistic adults",href:"/what-we-help-with/autism"}];function ap(){const t=[];return ip.forEach(e=>t.push({type:"page",title:e.title,subtitle:e.desc,href:e.href})),sp.filter(e=>e.isPsychologist).forEach(e=>{var s;return t.push({type:"team",title:e.name,subtitle:e.title+((s=e.tags)!=null&&s.length?" · "+e.tags.slice(0,3).join(", "):""),href:`/our-team/${e.slug}`})}),np.forEach(e=>{var s;return t.push({type:"blog",title:e.title,subtitle:((s=e.excerpt)==null?void 0:s.slice(0,80))+"…",href:`/blog/${e.slug}`})}),rp.forEach(e=>{var s;return t.push({type:"faq",title:e.question,subtitle:((s=e.answer)==null?void 0:s.slice(0,80))+"…",href:"/faq"})}),t}const op=ap(),lp={page:"Page",team:"Team",blog:"Article",faq:"FAQ"},cp={page:Xl,team:sc,blog:Jl,faq:Yl},Js=["page","team","blog","faq"],up=[{id:"all",label:"All"},{id:"page",label:"Pages"},{id:"team",label:"Team"},{id:"blog",label:"Articles"},{id:"faq",label:"FAQs"}];function hp(t,e){if(!t.trim())return[];const s=t.toLowerCase();return op.filter(n=>e!=="all"&&n.type!==e?!1:n.title.toLowerCase().includes(s)||n.subtitle.toLowerCase().includes(s)).slice(0,20)}function dp(){const t=Kn(),[e,s]=_.useState(!1),[n,r]=_.useState(""),[i,a]=_.useState("all"),[o,l]=_.useState(0),c=_.useRef(null),u=Wl(),h=hp(n,i),d=Js.reduce((w,v)=>{const x=h.filter(S=>S.type===v);return x.length&&(w[v]=x),w},{}),f=Js.flatMap(w=>d[w]??[]),p=_.useCallback(()=>{s(!1),r(""),a("all"),l(0)},[]),y=_.useCallback((w,v)=>{n.trim()&&(t==null||t.capture("site_search_performed",{query:n.trim(),result_count:h.length,selected_result_type:v==null?void 0:v.type})),p(),u(w)},[p,u,t,n,h.length]);_.useEffect(()=>{const w=v=>{(v.metaKey||v.ctrlKey)&&v.key==="k"&&(v.preventDefault(),s(x=>!x)),v.key==="Escape"&&p()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[p]),_.useEffect(()=>{e&&setTimeout(()=>{var w;return(w=c.current)==null?void 0:w.focus()},50)},[e]),_.useEffect(()=>{l(0)},[n,i]);function g(w){w.key==="ArrowDown"?(w.preventDefault(),l(v=>Math.min(v+1,f.length-1))):w.key==="ArrowUp"?(w.preventDefault(),l(v=>Math.max(v-1,0))):w.key==="Enter"&&f[o]&&y(f[o].href,f[o])}let b=0;return m.jsxs(m.Fragment,{children:[m.jsx("button",{onClick:()=>s(!0),"aria-label":"Search",className:"hidden md:flex items-center justify-center w-9 h-9 rounded-full text-[#3D3D5C] hover:text-brand-pink hover:bg-surface-pink transition-colors",children:m.jsx(Rr,{className:"h-4 w-4"})}),Fl.createPortal(m.jsx(Rn,{children:e&&m.jsxs(Ce.div,{className:"fixed inset-0 z-[200] flex items-center justify-center px-4",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[m.jsx("div",{className:"absolute inset-0 bg-[#071B27]/50 backdrop-blur-sm",onClick:p}),m.jsxs(Ce.div,{className:"relative w-full max-w-xl bg-white rounded-2xl shadow-2xl overflow-hidden border border-cp-rule",initial:{opacity:0,scale:.95,y:-12},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-12},transition:{type:"spring",damping:28,stiffness:350},children:[m.jsxs("div",{className:"flex items-center gap-3 px-4 py-3.5 border-b border-cp-rule",children:[m.jsx(Rr,{className:"h-4 w-4 text-cp-muted flex-shrink-0"}),m.jsx("input",{ref:c,value:n,onChange:w=>r(w.target.value),onKeyDown:g,placeholder:"Search pages, team, articles, FAQs…",className:"flex-1 text-sm font-poppins text-[#071B27] placeholder:text-cp-muted outline-none bg-transparent"}),n&&m.jsx("button",{onClick:()=>r(""),className:"text-cp-muted hover:text-cp-body transition-colors",children:m.jsx(hs,{className:"h-4 w-4"})}),m.jsx("kbd",{className:"hidden sm:inline-flex items-center text-[10px] font-poppins text-cp-muted border border-cp-rule rounded px-1.5 py-0.5",children:"ESC"})]}),m.jsx("div",{className:"flex items-center gap-1.5 px-4 py-2.5 border-b border-cp-rule overflow-x-auto",children:up.map(w=>m.jsx("button",{onClick:()=>a(w.id),className:`flex-shrink-0 rounded-full px-3 py-1 text-xs font-medium font-poppins transition-colors ${i===w.id?"bg-brand-pink text-white":"bg-surface-warm text-cp-muted hover:text-cp-body hover:bg-surface-pink"}`,children:w.label},w.id))}),m.jsxs("div",{className:"max-h-[55vh] overflow-y-auto",children:[!n&&m.jsx("p",{className:"text-xs text-cp-muted font-poppins text-center py-8",children:"Start typing to search…"}),n&&h.length===0&&m.jsxs("p",{className:"text-xs text-cp-muted font-poppins text-center py-8",children:['No results for "',n,'"']}),Js.map(w=>{const v=d[w];return v?m.jsxs("div",{children:[m.jsx("p",{className:"text-[10px] font-bold font-poppins tracking-widest text-cp-muted uppercase px-4 pt-4 pb-1.5",children:lp[w]}),v.map(x=>{const S=cp[x.type],k=f[o]===x,j=b++;return m.jsxs("button",{onClick:()=>y(x.href,x),onMouseEnter:()=>l(j),className:`w-full flex items-center gap-3 px-4 py-2.5 text-left transition-colors ${k?"bg-surface-pink":"hover:bg-surface-warm"}`,children:[m.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center flex-shrink-0 transition-colors border ${k?"bg-brand-pink border-brand-pink":"bg-surface-warm border-cp-rule"}`,children:m.jsx(S,{className:`h-3.5 w-3.5 transition-colors ${k?"text-white":"text-cp-muted"}`})}),m.jsxs("div",{className:"min-w-0",children:[m.jsx("p",{className:`text-sm font-semibold font-poppins truncate transition-colors ${k?"text-brand-pink":"text-[#071B27]"}`,children:x.title}),m.jsx("p",{className:"text-xs text-cp-muted font-poppins leading-snug line-clamp-1",children:x.subtitle})]})]},x.href+x.title)})]},w):null})]}),h.length>0&&m.jsxs("div",{className:"flex items-center justify-between border-t border-cp-rule px-4 py-2.5",children:[m.jsxs("span",{className:"text-[10px] text-cp-muted font-poppins",children:[h.length," result",h.length!==1?"s":""]}),m.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-cp-muted font-poppins",children:[m.jsxs("span",{className:"flex items-center gap-1",children:[m.jsx("kbd",{className:"border border-cp-rule rounded px-1 py-0.5 text-[9px]",children:"↑"}),m.jsx("kbd",{className:"border border-cp-rule rounded px-1 py-0.5 text-[9px]",children:"↓"}),"navigate"]}),m.jsxs("span",{className:"flex items-center gap-1",children:[m.jsx("kbd",{className:"border border-cp-rule rounded px-1 py-0.5 text-[9px]",children:"↵"}),"open"]})]})]})]})]})}),document.body)]})}const ht="/assets/logo-C1kM2SaN.png";var hl={exports:{}},dl={};/**
* @license React
* use-sync-external-store-shim.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var gt=_;function fp(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var pp=typeof Object.is=="function"?Object.is:fp,mp=gt.useState,gp=gt.useEffect,yp=gt.useLayoutEffect,vp=gt.useDebugValue;function wp(t,e){var s=e(),n=mp({inst:{value:s,getSnapshot:e}}),r=n[0].inst,i=n[1];return yp(function(){r.value=s,r.getSnapshot=e,Ys(r)&&i({inst:r})},[t,s,e]),gp(function(){return Ys(r)&&i({inst:r}),t(function(){Ys(r)&&i({inst:r})})},[t]),vp(s),s}function Ys(t){var e=t.getSnapshot;t=t.value;try{var s=e();return!pp(t,s)}catch{return!0}}function bp(t,e){return e()}var xp=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?bp:wp;dl.useSyncExternalStore=gt.useSyncExternalStore!==void 0?gt.useSyncExternalStore:xp;hl.exports=dl;var _p=hl.exports;function Sp(){return _p.useSyncExternalStore(Tp,()=>!0,()=>!1)}function Tp(){return()=>{}}var _r="Avatar",[kp,jy]=Hl(_r),[Ap,fl]=kp(_r),pl=_.forwardRef((t,e)=>{const{__scopeAvatar:s,...n}=t,[r,i]=_.useState("idle");return m.jsx(Ap,{scope:s,imageLoadingStatus:r,onImageLoadingStatusChange:i,children:m.jsx(Gn.span,{...n,ref:e})})});pl.displayName=_r;var ml="AvatarImage",gl=_.forwardRef((t,e)=>{const{__scopeAvatar:s,src:n,onLoadingStatusChange:r=()=>{},...i}=t,a=fl(ml,s),o=Ep(n,i),l=Kl(c=>{r(c),a.onImageLoadingStatusChange(c)});return on(()=>{o!=="idle"&&l(o)},[o,l]),o==="loaded"?m.jsx(Gn.img,{...i,ref:e,src:n}):null});gl.displayName=ml;var yl="AvatarFallback",vl=_.forwardRef((t,e)=>{const{__scopeAvatar:s,delayMs:n,...r}=t,i=fl(yl,s),[a,o]=_.useState(n===void 0);return _.useEffect(()=>{if(n!==void 0){const l=window.setTimeout(()=>o(!0),n);return()=>window.clearTimeout(l)}},[n]),a&&i.imageLoadingStatus!=="loaded"?m.jsx(Gn.span,{...r,ref:e}):null});vl.displayName=yl;function Ji(t,e){return t?e?(t.src!==e&&(t.src=e),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function Ep(t,{referrerPolicy:e,crossOrigin:s}){const n=Sp(),r=_.useRef(null),i=n?(r.current||(r.current=new window.Image),r.current):null,[a,o]=_.useState(()=>Ji(i,t));return on(()=>{o(Ji(i,t))},[i,t]),on(()=>{const l=h=>()=>{o(h)};if(!i)return;const c=l("loaded"),u=l("error");return i.addEventListener("load",c),i.addEventListener("error",u),e&&(i.referrerPolicy=e),typeof s=="string"&&(i.crossOrigin=s),()=>{i.removeEventListener("load",c),i.removeEventListener("error",u)}},[i,s,e]),a}var wl=pl,bl=gl,xl=vl;const Et=_.forwardRef(({className:t,...e},s)=>m.jsx(wl,{ref:s,className:Ge("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...e}));Et.displayName=wl.displayName;const Pp=_.forwardRef(({className:t,...e},s)=>m.jsx(bl,{ref:s,className:Ge("aspect-square h-full w-full",t),...e}));Pp.displayName=bl.displayName;const Pt=_.forwardRef(({className:t,...e},s)=>m.jsx(xl,{ref:s,className:Ge("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...e}));Pt.displayName=xl.displayName;const Cp=Gl("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Dn=_.forwardRef(({className:t,variant:e,size:s,asChild:n=!1,...r},i)=>{const a=n?zl:"button";return m.jsx(a,{className:Ge(Cp({variant:e,size:s,className:t})),ref:i,...r})});Dn.displayName="Button";var Yi=function(){return Yi=Object.assign||function(e){for(var s,n=1,r=arguments.length;n<r;n++){s=arguments[n];for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(e[i]=s[i])}return e},Yi.apply(this,arguments)};function Rs(t,e){var s={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(s[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(t);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(t,n[r])&&(s[n[r]]=t[n[r]]);return s}function Rp(t,e,s,n){function r(i){return i instanceof s?i:new s(function(a){a(i)})}return new(s||(s=Promise))(function(i,a){function o(u){try{c(n.next(u))}catch(h){a(h)}}function l(u){try{c(n.throw(u))}catch(h){a(h)}}function c(u){u.done?i(u.value):r(u.value).then(o,l)}c((n=n.apply(t,e||[])).next())})}function Oy(t,e,s){if(s||arguments.length===2)for(var n=0,r=e.length,i;n<r;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))}const jp=t=>t?(...e)=>t(...e):(...e)=>fetch(...e);class Sr extends Error{constructor(e,s="FunctionsError",n){super(e),this.name=s,this.context=n}}class Op extends Sr{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class Xi extends Sr{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class Zi extends Sr{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var In;(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"})(In||(In={}));class Dp{constructor(e,{headers:s={},customFetch:n,region:r=In.Any}={}){this.url=e,this.headers=s,this.region=r,this.fetch=jp(n)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){return Rp(this,arguments,void 0,function*(s,n={}){var r;let i,a;try{const{headers:o,method:l,body:c,signal:u,timeout:h}=n;let d={},{region:f}=n;f||(f=this.region);const p=new URL(`${this.url}/${s}`);f&&f!=="any"&&(d["x-region"]=f,p.searchParams.set("forceFunctionRegion",f));let y;c&&(o&&!Object.prototype.hasOwnProperty.call(o,"Content-Type")||!o)?typeof Blob<"u"&&c instanceof Blob||c instanceof ArrayBuffer?(d["Content-Type"]="application/octet-stream",y=c):typeof c=="string"?(d["Content-Type"]="text/plain",y=c):typeof FormData<"u"&&c instanceof FormData?y=c:(d["Content-Type"]="application/json",y=JSON.stringify(c)):y=c;let g=u;h&&(a=new AbortController,i=setTimeout(()=>a.abort(),h),u?(g=a.signal,u.addEventListener("abort",()=>a.abort())):g=a.signal);const b=yield this.fetch(p.toString(),{method:l||"POST",headers:Object.assign(Object.assign(Object.assign({},d),this.headers),o),body:y,signal:g}).catch(S=>{throw new Op(S)}),w=b.headers.get("x-relay-error");if(w&&w==="true")throw new Xi(b);if(!b.ok)throw new Zi(b);let v=((r=b.headers.get("Content-Type"))!==null&&r!==void 0?r:"text/plain").split(";")[0].trim(),x;return v==="application/json"?x=yield b.json():v==="application/octet-stream"||v==="application/pdf"?x=yield b.blob():v==="text/event-stream"?x=b:v==="multipart/form-data"?x=yield b.formData():x=yield b.text(),{data:x,error:null,response:b}}catch(o){return{data:null,error:o,response:o instanceof Zi||o instanceof Xi?o.context:void 0}}finally{i&&clearTimeout(i)}})}}var Ip=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.code=t.code}},Np=class{constructor(t){var e,s;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,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 n=this.fetch;let r=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{let a=null,o=null,l=null,c=i.status,u=i.statusText;if(i.ok){var h,d;if(s.method!=="HEAD"){var f;const b=await i.text();b===""||(s.headers.get("Accept")==="text/csv"||s.headers.get("Accept")&&(!((f=s.headers.get("Accept"))===null||f===void 0)&&f.includes("application/vnd.pgrst.plan+text"))?o=b:o=JSON.parse(b))}const y=(h=s.headers.get("Prefer"))===null||h===void 0?void 0:h.match(/count=(exact|planned|estimated)/),g=(d=i.headers.get("content-range"))===null||d===void 0?void 0:d.split("/");y&&g&&g.length>1&&(l=parseInt(g[1])),s.isMaybeSingle&&s.method==="GET"&&Array.isArray(o)&&(o.length>1?(a={code:"PGRST116",details:`Results contain ${o.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},o=null,l=null,c=406,u="Not Acceptable"):o.length===1?o=o[0]:o=null)}else{var p;const y=await i.text();try{a=JSON.parse(y),Array.isArray(a)&&i.status===404&&(o=[],a=null,c=200,u="OK")}catch{i.status===404&&y===""?(c=204,u="No Content"):a={message:y}}if(a&&s.isMaybeSingle&&(!(a==null||(p=a.details)===null||p===void 0)&&p.includes("0 rows"))&&(a=null,c=200,u="OK"),a&&s.shouldThrowOnError)throw new Ip(a)}return{error:a,data:o,count:l,status:c,statusText:u}});return this.shouldThrowOnError||(r=r.catch(i=>{var a;let o="";const l=i==null?void 0:i.cause;if(l){var c,u,h,d;const p=(c=l==null?void 0:l.message)!==null&&c!==void 0?c:"",y=(u=l==null?void 0:l.code)!==null&&u!==void 0?u:"";o=`${(h=i==null?void 0:i.name)!==null&&h!==void 0?h:"FetchError"}: ${i==null?void 0:i.message}`,o+=`
Caused by: ${(d=l==null?void 0:l.name)!==null&&d!==void 0?d:"Error"}: ${p}`,y&&(o+=` (${y})`),l!=null&&l.stack&&(o+=`
${l.stack}`)}else{var f;o=(f=i==null?void 0:i.stack)!==null&&f!==void 0?f:""}return{error:{message:`${(a=i==null?void 0:i.name)!==null&&a!==void 0?a:"FetchError"}: ${i==null?void 0:i.message}`,details:o,hint:"",code:""},data:null,count:null,status:0,statusText:""}})),r.then(t,e)}returns(){return this}overrideTypes(){return this}},Mp=class extends Np{select(t){let e=!1;const s=(t??"*").split("").map(n=>/\s/.test(n)&&!e?"":(n==='"'&&(e=!e),n)).join("");return this.url.searchParams.set("select",s),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:e=!0,nullsFirst:s,foreignTable:n,referencedTable:r=n}={}){const i=r?`${r}.order`:"order",a=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${a?`${a},`:""}${t}.${e?"asc":"desc"}${s===void 0?"":s?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:e,referencedTable:s=e}={}){const n=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(n,`${t}`),this}range(t,e,{foreignTable:s,referencedTable:n=s}={}){const r=typeof n>"u"?"offset":`${n}.offset`,i=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(r,`${t}`),this.url.searchParams.set(i,`${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:n=!1,wal:r=!1,format:i="text"}={}){var a;const o=[t?"analyze":null,e?"verbose":null,s?"settings":null,n?"buffers":null,r?"wal":null].filter(Boolean).join("|"),l=(a=this.headers.get("Accept"))!==null&&a!==void 0?a:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${l}"; options=${o};`),i==="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 Qi=new RegExp("[,()]");var rt=class extends Mp{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(n=>typeof n=="string"&&Qi.test(n)?`"${n}"`:`${n}`).join(",");return this.url.searchParams.append(t,`in.(${s})`),this}notIn(t,e){const s=Array.from(new Set(e)).map(n=>typeof n=="string"&&Qi.test(n)?`"${n}"`:`${n}`).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:n}={}){let r="";n==="plain"?r="pl":n==="phrase"?r="ph":n==="websearch"&&(r="w");const i=s===void 0?"":`(${s})`;return this.url.searchParams.append(t,`${r}fts${i}.${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 n=s?`${s}.or`:"or";return this.url.searchParams.append(n,`(${t})`),this}filter(t,e,s){return this.url.searchParams.append(t,`${e}.${s}`),this}},$p=class{constructor(t,{headers:e={},schema:s,fetch:n}){this.url=t,this.headers=new Headers(e),this.schema=s,this.fetch=n}select(t,e){const{head:s=!1,count:n}=e??{},r=s?"HEAD":"GET";let i=!1;const a=(t??"*").split("").map(o=>/\s/.test(o)&&!i?"":(o==='"'&&(i=!i),o)).join("");return this.url.searchParams.set("select",a),n&&this.headers.append("Prefer",`count=${n}`),new rt({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(t,{count:e,defaultToNull:s=!0}={}){var n;const r="POST";if(e&&this.headers.append("Prefer",`count=${e}`),s||this.headers.append("Prefer","missing=default"),Array.isArray(t)){const i=t.reduce((a,o)=>a.concat(Object.keys(o)),[]);if(i.length>0){const a=[...new Set(i)].map(o=>`"${o}"`);this.url.searchParams.set("columns",a.join(","))}}return new rt({method:r,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}upsert(t,{onConflict:e,ignoreDuplicates:s=!1,count:n,defaultToNull:r=!0}={}){var i;const a="POST";if(this.headers.append("Prefer",`resolution=${s?"ignore":"merge"}-duplicates`),e!==void 0&&this.url.searchParams.set("on_conflict",e),n&&this.headers.append("Prefer",`count=${n}`),r||this.headers.append("Prefer","missing=default"),Array.isArray(t)){const o=t.reduce((l,c)=>l.concat(Object.keys(c)),[]);if(o.length>0){const l=[...new Set(o)].map(c=>`"${c}"`);this.url.searchParams.set("columns",l.join(","))}}return new rt({method:a,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(t,{count:e}={}){var s;const n="PATCH";return e&&this.headers.append("Prefer",`count=${e}`),new rt({method:n,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}delete({count:t}={}){var e;const s="DELETE";return t&&this.headers.append("Prefer",`count=${t}`),new rt({method:s,url:this.url,headers:this.headers,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch})}},Lp=class _l{constructor(e,{headers:s={},schema:n,fetch:r}={}){this.url=e,this.headers=new Headers(s),this.schemaName=n,this.fetch=r}from(e){if(!e||typeof e!="string"||e.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new $p(new URL(`${this.url}/${e}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new _l(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,s={},{head:n=!1,get:r=!1,count:i}={}){var a;let o;const l=new URL(`${this.url}/rpc/${e}`);let c;n||r?(o=n?"HEAD":"GET",Object.entries(s).filter(([h,d])=>d!==void 0).map(([h,d])=>[h,Array.isArray(d)?`{${d.join(",")}}`:`${d}`]).forEach(([h,d])=>{l.searchParams.append(h,d)})):(o="POST",c=s);const u=new Headers(this.headers);return i&&u.set("Prefer",`count=${i}`),new rt({method:o,url:l,headers:u,schema:this.schemaName,body:c,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}};class Bp{constructor(){}static detectEnvironment(){var e;if(typeof WebSocket<"u")return{type:"native",constructor:WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocket<"u")return{type:"native",constructor:globalThis.WebSocket};if(typeof global<"u"&&typeof global.WebSocket<"u")return{type:"native",constructor:global.WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&globalThis.EdgeRuntime||typeof navigator<"u"&&(!((e=navigator.userAgent)===null||e===void 0)&&e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};if(typeof process<"u"){const s=process.versions;if(s&&s.node){const n=s.node,r=parseInt(n.replace(/^v/,"").split(".")[0]);return r>=22?typeof globalThis.WebSocket<"u"?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${r} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${r} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option:
import ws from "ws"
new RealtimeClient(url, { transport: ws })`}}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const e=this.detectEnvironment();if(e.constructor)return e.constructor;let s=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(s+=`
Suggested solution: ${e.workaround}`),new Error(s)}static createWebSocket(e,s){const n=this.getWebSocketConstructor();return new n(e,s)}static isWebSocketSupported(){try{const e=this.detectEnvironment();return e.type==="native"||e.type==="ws"}catch{return!1}}}const Vp="2.88.0",Up=`realtime-js/${Vp}`,Sl="1.0.0",Fp="2.0.0",ea=Sl,Nn=1e4,Wp=1e3,qp=100;var Re;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(Re||(Re={}));var F;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(F||(F={}));var de;(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"})(de||(de={}));var Mn;(function(t){t.websocket="websocket"})(Mn||(Mn={}));var Fe;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(Fe||(Fe={}));class Hp{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 n=[e.join_ref,e.ref,e.topic,e.event,e.payload];return s(JSON.stringify(n))}_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,n;const r=(n=(s=e.payload)===null||s===void 0?void 0:s.payload)!==null&&n!==void 0?n:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,r)}_encodeJsonUserBroadcastPush(e){var s,n;const r=(n=(s=e.payload)===null||s===void 0?void 0:s.payload)!==null&&n!==void 0?n:{},a=new TextEncoder().encode(JSON.stringify(r)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,a)}_encodeUserBroadcastPush(e,s,n){var r,i;const a=e.topic,o=(r=e.ref)!==null&&r!==void 0?r:"",l=(i=e.join_ref)!==null&&i!==void 0?i:"",c=e.payload.event,u=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},h=Object.keys(u).length===0?"":JSON.stringify(u);if(l.length>255)throw new Error(`joinRef length ${l.length} exceeds maximum of 255`);if(o.length>255)throw new Error(`ref length ${o.length} exceeds maximum of 255`);if(a.length>255)throw new Error(`topic length ${a.length} exceeds maximum of 255`);if(c.length>255)throw new Error(`userEvent length ${c.length} exceeds maximum of 255`);if(h.length>255)throw new Error(`metadata length ${h.length} exceeds maximum of 255`);const d=this.USER_BROADCAST_PUSH_META_LENGTH+l.length+o.length+a.length+c.length+h.length,f=new ArrayBuffer(this.HEADER_LENGTH+d);let p=new DataView(f),y=0;p.setUint8(y++,this.KINDS.userBroadcastPush),p.setUint8(y++,l.length),p.setUint8(y++,o.length),p.setUint8(y++,a.length),p.setUint8(y++,c.length),p.setUint8(y++,h.length),p.setUint8(y++,s),Array.from(l,b=>p.setUint8(y++,b.charCodeAt(0))),Array.from(o,b=>p.setUint8(y++,b.charCodeAt(0))),Array.from(a,b=>p.setUint8(y++,b.charCodeAt(0))),Array.from(c,b=>p.setUint8(y++,b.charCodeAt(0))),Array.from(h,b=>p.setUint8(y++,b.charCodeAt(0)));var g=new Uint8Array(f.byteLength+n.byteLength);return g.set(new Uint8Array(f),0),g.set(new Uint8Array(n),f.byteLength),g.buffer}decode(e,s){if(this._isArrayBuffer(e)){let n=this._binaryDecode(e);return s(n)}if(typeof e=="string"){const n=JSON.parse(e),[r,i,a,o,l]=n;return s({join_ref:r,ref:i,topic:a,event:o,payload:l})}return s({})}_binaryDecode(e){const s=new DataView(e),n=s.getUint8(0),r=new TextDecoder;switch(n){case this.KINDS.userBroadcast:return this._decodeUserBroadcast(e,s,r)}}_decodeUserBroadcast(e,s,n){const r=s.getUint8(1),i=s.getUint8(2),a=s.getUint8(3),o=s.getUint8(4);let l=this.HEADER_LENGTH+4;const c=n.decode(e.slice(l,l+r));l=l+r;const u=n.decode(e.slice(l,l+i));l=l+i;const h=n.decode(e.slice(l,l+a));l=l+a;const d=e.slice(l,e.byteLength),f=o===this.JSON_ENCODING?JSON.parse(n.decode(d)):d,p={type:this.BROADCAST_EVENT,event:u,payload:f};return a>0&&(p.meta=JSON.parse(h)),{join_ref:null,ref:null,topic:c,event:this.BROADCAST_EVENT,payload:p}}_isArrayBuffer(e){var s;return e instanceof ArrayBuffer||((s=e==null?void 0: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(([n])=>s.includes(n)))}}class Tl{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 I;(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"})(I||(I={}));const ta=(t,e,s={})=>{var n;const r=(n=s.skipTypes)!==null&&n!==void 0?n:[];return e?Object.keys(e).reduce((i,a)=>(i[a]=Kp(a,t,e,r),i),{}):{}},Kp=(t,e,s,n)=>{const r=e.find(o=>o.name===t),i=r==null?void 0:r.type,a=s[t];return i&&!n.includes(i)?kl(i,a):$n(a)},kl=(t,e)=>{if(t.charAt(0)==="_"){const s=t.slice(1,t.length);return Yp(e,s)}switch(t){case I.bool:return Gp(e);case I.float4:case I.float8:case I.int2:case I.int4:case I.int8:case I.numeric:case I.oid:return zp(e);case I.json:case I.jsonb:return Jp(e);case I.timestamp:return Xp(e);case I.abstime:case I.date:case I.daterange:case I.int4range:case I.int8range:case I.money:case I.reltime:case I.text:case I.time:case I.timestamptz:case I.timetz:case I.tsrange:case I.tstzrange:return $n(e);default:return $n(e)}},$n=t=>t,Gp=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},zp=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},Jp=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t},Yp=(t,e)=>{if(typeof t!="string")return t;const s=t.length-1,n=t[s];if(t[0]==="{"&&n==="}"){let i;const a=t.slice(1,s);try{i=JSON.parse("["+a+"]")}catch{i=a?a.split(","):[]}return i.map(o=>kl(e,o))}return t},Xp=t=>typeof t=="string"?t.replace(" ","T"):t,Al=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 Xs{constructor(e,s,n={},r=Nn){this.channel=e,this.event=s,this.payload=n,this.timeout=r,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 n;return this._hasReceived(e)&&s((n=this.receivedResp)===null||n===void 0?void 0:n.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(n=>n.status===e).forEach(n=>n.callback(s))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}var sa;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(sa||(sa={}));class Ct{constructor(e,s){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const n=(s==null?void 0:s.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(n.state,{},r=>{const{onJoin:i,onLeave:a,onSync:o}=this.caller;this.joinRef=this.channel._joinRef(),this.state=Ct.syncState(this.state,r,i,a),this.pendingDiffs.forEach(l=>{this.state=Ct.syncDiff(this.state,l,i,a)}),this.pendingDiffs=[],o()}),this.channel._on(n.diff,{},r=>{const{onJoin:i,onLeave:a,onSync:o}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(r):(this.state=Ct.syncDiff(this.state,r,i,a),o())}),this.onJoin((r,i,a)=>{this.channel._trigger("presence",{event:"join",key:r,currentPresences:i,newPresences:a})}),this.onLeave((r,i,a)=>{this.channel._trigger("presence",{event:"leave",key:r,currentPresences:i,leftPresences:a})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,s,n,r){const i=this.cloneDeep(e),a=this.transformState(s),o={},l={};return this.map(i,(c,u)=>{a[c]||(l[c]=u)}),this.map(a,(c,u)=>{const h=i[c];if(h){const d=u.map(g=>g.presence_ref),f=h.map(g=>g.presence_ref),p=u.filter(g=>f.indexOf(g.presence_ref)<0),y=h.filter(g=>d.indexOf(g.presence_ref)<0);p.length>0&&(o[c]=p),y.length>0&&(l[c]=y)}else o[c]=u}),this.syncDiff(i,{joins:o,leaves:l},n,r)}static syncDiff(e,s,n,r){const{joins:i,leaves:a}={joins:this.transformState(s.joins),leaves:this.transformState(s.leaves)};return n||(n=()=>{}),r||(r=()=>{}),this.map(i,(o,l)=>{var c;const u=(c=e[o])!==null&&c!==void 0?c:[];if(e[o]=this.cloneDeep(l),u.length>0){const h=e[o].map(f=>f.presence_ref),d=u.filter(f=>h.indexOf(f.presence_ref)<0);e[o].unshift(...d)}n(o,u,l)}),this.map(a,(o,l)=>{let c=e[o];if(!c)return;const u=l.map(h=>h.presence_ref);c=c.filter(h=>u.indexOf(h.presence_ref)<0),e[o]=c,r(o,c,l),c.length===0&&delete e[o]}),e}static map(e,s){return Object.getOwnPropertyNames(e).map(n=>s(n,e[n]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((s,n)=>{const r=e[n];return"metas"in r?s[n]=r.metas.map(i=>(i.presence_ref=i.phx_ref,delete i.phx_ref,delete i.phx_ref_prev,i)):s[n]=r,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 na;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(na||(na={}));var Rt;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(Rt||(Rt={}));var Te;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(Te||(Te={}));class ut{constructor(e,s={config:{}},n){var r,i;if(this.topic=e,this.params=s,this.socket=n,this.bindings={},this.state=F.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 Xs(this,de.join,this.params,this.timeout),this.rejoinTimer=new Tl(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=F.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(a=>a.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=F.closed,this.socket._remove(this)}),this._onError(a=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,a),this.state=F.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=F.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",a=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,a),this.state=F.errored,this.rejoinTimer.scheduleTimeout())}),this._on(de.reply,{},(a,o)=>{this._trigger(this._replyEventName(o),a)}),this.presence=new Ct(this),this.broadcastEndpointURL=Al(this.socket.endPoint),this.private=this.params.config.private||!1,!this.private&&(!((i=(r=this.params.config)===null||r===void 0?void 0:r.broadcast)===null||i===void 0)&&i.replay))throw`tried to use replay on public channel '${this.topic}'. It must be a private channel.`}subscribe(e,s=this.timeout){var n,r,i;if(this.socket.isConnected()||this.socket.connect(),this.state==F.closed){const{config:{broadcast:a,presence:o,private:l}}=this.params,c=(r=(n=this.bindings.postgres_changes)===null||n===void 0?void 0:n.map(f=>f.filter))!==null&&r!==void 0?r:[],u=!!this.bindings[Rt.PRESENCE]&&this.bindings[Rt.PRESENCE].length>0||((i=this.params.config.presence)===null||i===void 0?void 0:i.enabled)===!0,h={},d={broadcast:a,presence:Object.assign(Object.assign({},o),{enabled:u}),postgres_changes:c,private:l};this.socket.accessTokenValue&&(h.access_token=this.socket.accessTokenValue),this._onError(f=>e==null?void 0:e(Te.CHANNEL_ERROR,f)),this._onClose(()=>e==null?void 0:e(Te.CLOSED)),this.updateJoinPayload(Object.assign({config:d},h)),this.joinedOnce=!0,this._rejoin(s),this.joinPush.receive("ok",async({postgres_changes:f})=>{var p;if(this.socket._isManualToken()||this.socket.setAuth(),f===void 0){e==null||e(Te.SUBSCRIBED);return}else{const y=this.bindings.postgres_changes,g=(p=y==null?void 0:y.length)!==null&&p!==void 0?p:0,b=[];for(let w=0;w<g;w++){const v=y[w],{filter:{event:x,schema:S,table:k,filter:j}}=v,E=f&&f[w];if(E&&E.event===x&&ut.isFilterValueEqual(E.schema,S)&&ut.isFilterValueEqual(E.table,k)&&ut.isFilterValueEqual(E.filter,j))b.push(Object.assign(Object.assign({},v),{id:E.id}));else{this.unsubscribe(),this.state=F.errored,e==null||e(Te.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=b,e&&e(Te.SUBSCRIBED);return}}).receive("error",f=>{this.state=F.errored,e==null||e(Te.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(f).join(", ")||"error")))}).receive("timeout",()=>{e==null||e(Te.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,n){return this.state===F.joined&&e===Rt.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,n)}async httpSend(e,s,n={}){var r;if(s==null)return Promise.reject("Payload is required for httpSend()");const i={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(i.Authorization=`Bearer ${this.socket.accessTokenValue}`);const a={method:"POST",headers:i,body:JSON.stringify({messages:[{topic:this.subTopic,event:e,payload:s,private:this.private}]})},o=await this._fetchWithTimeout(this.broadcastEndpointURL,a,(r=n.timeout)!==null&&r!==void 0?r:this.timeout);if(o.status===202)return{success:!0};let l=o.statusText;try{const c=await o.json();l=c.error||c.message||l}catch{}return Promise.reject(new Error(l))}async send(e,s={}){var n,r;if(!this._canPush()&&e.type==="broadcast"){console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");const{event:i,payload:a}=e,o={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(o.Authorization=`Bearer ${this.socket.accessTokenValue}`);const l={method:"POST",headers:o,body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:a,private:this.private}]})};try{const c=await this._fetchWithTimeout(this.broadcastEndpointURL,l,(n=s.timeout)!==null&&n!==void 0?n:this.timeout);return await((r=c.body)===null||r===void 0?void 0:r.cancel()),c.ok?"ok":"error"}catch(c){return c.name==="AbortError"?"timed out":"error"}}else return new Promise(i=>{var a,o,l;const c=this._push(e.type,e,s.timeout||this.timeout);e.type==="broadcast"&&!(!((l=(o=(a=this.params)===null||a===void 0?void 0:a.config)===null||o===void 0?void 0:o.broadcast)===null||l===void 0)&&l.ack)&&i("ok"),c.receive("ok",()=>i("ok")),c.receive("error",()=>i("error")),c.receive("timeout",()=>i("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=F.leaving;const s=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(de.close,"leave",this._joinRef())};this.joinPush.destroy();let n=null;return new Promise(r=>{n=new Xs(this,de.leave,{},e),n.receive("ok",()=>{s(),r("ok")}).receive("timeout",()=>{s(),r("timed out")}).receive("error",()=>{r("error")}),n.send(),this._canPush()||n.trigger("ok",{})}).finally(()=>{n==null||n.destroy()})}teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=F.closed,this.bindings={}}async _fetchWithTimeout(e,s,n){const r=new AbortController,i=setTimeout(()=>r.abort(),n),a=await this.socket.fetch(e,Object.assign(Object.assign({},s),{signal:r.signal}));return clearTimeout(i),a}_push(e,s,n=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let r=new Xs(this,e,s,n);return this._canPush()?r.send():this._addToPushBuffer(r),r}_addToPushBuffer(e){if(e.startTimeout(),this.pushBuffer.push(e),this.pushBuffer.length>qp){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,n){return s}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,s,n){var r,i;const a=e.toLocaleLowerCase(),{close:o,error:l,leave:c,join:u}=de;if(n&&[o,l,c,u].indexOf(a)>=0&&n!==this._joinRef())return;let d=this._onMessage(a,s,n);if(s&&!d)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(a)?(r=this.bindings.postgres_changes)===null||r===void 0||r.filter(f=>{var p,y,g;return((p=f.filter)===null||p===void 0?void 0:p.event)==="*"||((g=(y=f.filter)===null||y===void 0?void 0:y.event)===null||g===void 0?void 0:g.toLocaleLowerCase())===a}).map(f=>f.callback(d,n)):(i=this.bindings[a])===null||i===void 0||i.filter(f=>{var p,y,g,b,w,v;if(["broadcast","presence","postgres_changes"].includes(a))if("id"in f){const x=f.id,S=(p=f.filter)===null||p===void 0?void 0:p.event;return x&&((y=s.ids)===null||y===void 0?void 0:y.includes(x))&&(S==="*"||(S==null?void 0:S.toLocaleLowerCase())===((g=s.data)===null||g===void 0?void 0:g.type.toLocaleLowerCase()))}else{const x=(w=(b=f==null?void 0:f.filter)===null||b===void 0?void 0:b.event)===null||w===void 0?void 0:w.toLocaleLowerCase();return x==="*"||x===((v=s==null?void 0:s.event)===null||v===void 0?void 0:v.toLocaleLowerCase())}else return f.type.toLocaleLowerCase()===a}).map(f=>{if(typeof d=="object"&&"ids"in d){const p=d.data,{schema:y,table:g,commit_timestamp:b,type:w,errors:v}=p;d=Object.assign(Object.assign({},{schema:y,table:g,commit_timestamp:b,eventType:w,new:{},old:{},errors:v}),this._getPayloadRecords(p))}f.callback(d,n)})}_isClosed(){return this.state===F.closed}_isJoined(){return this.state===F.joined}_isJoining(){return this.state===F.joining}_isLeaving(){return this.state===F.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,s,n){const r=e.toLocaleLowerCase(),i={type:r,filter:s,callback:n};return this.bindings[r]?this.bindings[r].push(i):this.bindings[r]=[i],this}_off(e,s){const n=e.toLocaleLowerCase();return this.bindings[n]&&(this.bindings[n]=this.bindings[n].filter(r=>{var i;return!(((i=r.type)===null||i===void 0?void 0:i.toLocaleLowerCase())===n&&ut.isEqual(r.filter,s))})),this}static isEqual(e,s){if(Object.keys(e).length!==Object.keys(s).length)return!1;for(const n in e)if(e[n]!==s[n])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(de.close,{},e)}_onError(e){this._on(de.error,{},s=>e(s))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=F.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const s={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(s.new=ta(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(s.old=ta(e.columns,e.old_record)),s}}const Zs=()=>{},Zt={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},Zp=[1e3,2e3,5e3,1e4],Qp=1e4,em=`
addEventListener("message", (e) => {
if (e.data.event === "start") {
setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
}
});`;class tm{constructor(e,s){var n;if(this.accessTokenValue=null,this.apiKey=null,this._manuallySetToken=!1,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=Nn,this.transport=null,this.heartbeatIntervalMs=Zt.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=Zs,this.ref=0,this.reconnectTimer=null,this.vsn=ea,this.logger=Zs,this.conn=null,this.sendBuffer=[],this.serializer=new Hp,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._connectionState="disconnected",this._wasManualDisconnect=!1,this._authPromise=null,this._resolveFetch=r=>r?(...i)=>r(...i):(...i)=>fetch(...i),!(!((n=s==null?void 0:s.params)===null||n===void 0)&&n.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=s.params.apikey,this.endPoint=`${e}/${Mn.websocket}`,this.httpEndpoint=Al(e),this._initializeOptions(s),this._setupReconnectionTimer(),this.fetch=this._resolveFetch(s==null?void 0: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=Bp.createWebSocket(this.endpointURL())}catch(e){this._setConnectionState("disconnected");const s=e.message;throw s.includes("Node.js")?new Error(`${s}
To use Realtime in Node.js, you need to provide a WebSocket implementation:
Option 1: Use Node.js 22+ which has native WebSocket support
Option 2: Install and provide the "ws" package:
npm install ws
import ws from "ws"
const client = new RealtimeClient(url, {
...options,
transport: ws
})`):new Error(`WebSocket not available: ${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 n=setTimeout(()=>{this._setConnectionState("disconnected")},100);this.conn.onclose=()=>{clearTimeout(n),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,n){this.logger(e,s,n)}connectionState(){switch(this.conn&&this.conn.readyState){case Re.connecting:return Fe.Connecting;case Re.open:return Fe.Open;case Re.closing:return Fe.Closing;default:return Fe.Closed}}isConnected(){return this.connectionState()===Fe.Open}isConnecting(){return this._connectionState==="connecting"}isDisconnecting(){return this._connectionState==="disconnecting"}channel(e,s={config:{}}){const n=`realtime:${e}`,r=this.getChannels().find(i=>i.topic===n);if(r)return r;{const i=new ut(`realtime:${e}`,s,this);return this.channels.push(i),i}}push(e){const{topic:s,event:n,payload:r,ref:i}=e,a=()=>{this.encode(e,o=>{var l;(l=this.conn)===null||l===void 0||l.send(o)})};this.log("push",`${s} ${n} (${i})`,r),this.isConnected()?a():this.sendBuffer.push(a)}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.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(Wp,"heartbeat timeout"),setTimeout(()=>{var s;this.isConnected()||(s=this.reconnectTimer)===null||s===void 0||s.scheduleTimeout()},Zt.HEARTBEAT_TIMEOUT_FALLBACK);return}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(n=>n.topic===e&&(n._isJoined()||n._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")try{this.heartbeatCallback(s.payload.status==="ok"?"ok":"error")}catch(c){this.log("error","error in heartbeat callback",c)}s.ref&&s.ref===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null);const{topic:n,event:r,payload:i,ref:a}=s,o=a?`(${a})`:"",l=i.status||"";this.log("receive",`${l} ${n} ${r} ${o}`.trim(),i),this.channels.filter(c=>c._isMember(n)).forEach(c=>c._trigger(r,i,a)),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===Re.open&&this._onConnOpen())}_teardownConnection(){if(this.conn){if(this.conn.readyState===Re.open||this.conn.readyState===Re.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)}_triggerChanError(){this.channels.forEach(e=>e._trigger(de.error))}_appendParams(e,s){if(Object.keys(s).length===0)return e;const n=e.match(/\?/)?"&":"?",r=new URLSearchParams(s);return`${e}${n}${r}`}_workerObjectUrl(e){let s;if(e)s=e;else{const n=new Blob([em],{type:"application/javascript"});s=URL.createObjectURL(n)}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,n=!1;if(e)s=e,n=!0;else if(this.accessToken)try{s=await this.accessToken()}catch(r){this.log("error","Error fetching access token from callback",r),s=this.accessTokenValue}else s=this.accessTokenValue;n?this._manuallySetToken=!0:this.accessToken&&(this._manuallySetToken=!1),this.accessTokenValue!=s&&(this.accessTokenValue=s,this.channels.forEach(r=>{const i={access_token:s,version:Up};s&&r.updateJoinPayload(i),r.joinedOnce&&r._isJoined()&&r._push(de.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(n=>{try{n(s)}catch(r){this.log("error",`error in ${e} callback`,r)}})}catch(n){this.log("error",`error triggering ${e} callbacks`,n)}}_setupReconnectionTimer(){this.reconnectTimer=new Tl(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},Zt.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(e){var s,n,r,i,a,o,l,c,u,h,d,f;switch(this.transport=(s=e==null?void 0:e.transport)!==null&&s!==void 0?s:null,this.timeout=(n=e==null?void 0:e.timeout)!==null&&n!==void 0?n:Nn,this.heartbeatIntervalMs=(r=e==null?void 0:e.heartbeatIntervalMs)!==null&&r!==void 0?r:Zt.HEARTBEAT_INTERVAL,this.worker=(i=e==null?void 0:e.worker)!==null&&i!==void 0?i:!1,this.accessToken=(a=e==null?void 0:e.accessToken)!==null&&a!==void 0?a:null,this.heartbeatCallback=(o=e==null?void 0:e.heartbeatCallback)!==null&&o!==void 0?o:Zs,this.vsn=(l=e==null?void 0:e.vsn)!==null&&l!==void 0?l:ea,e!=null&&e.params&&(this.params=e.params),e!=null&&e.logger&&(this.logger=e.logger),(e!=null&&e.logLevel||e!=null&&e.log_level)&&(this.logLevel=e.logLevel||e.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=(c=e==null?void 0:e.reconnectAfterMs)!==null&&c!==void 0?c:p=>Zp[p-1]||Qp,this.vsn){case Sl:this.encode=(u=e==null?void 0:e.encode)!==null&&u!==void 0?u:(p,y)=>y(JSON.stringify(p)),this.decode=(h=e==null?void 0:e.decode)!==null&&h!==void 0?h:(p,y)=>y(JSON.parse(p));break;case Fp:this.encode=(d=e==null?void 0:e.encode)!==null&&d!==void 0?d:this.serializer.encode.bind(this.serializer),this.decode=(f=e==null?void 0:e.decode)!==null&&f!==void 0?f:this.serializer.decode.bind(this.serializer);break;default:throw new Error(`Unsupported serializer version: ${this.vsn}`)}if(this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=e==null?void 0:e.workerUrl}}}var Nt=class extends Error{constructor(t,e){var s;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)&&((s=e.icebergType)==null?void 0:s.includes("CommitState"))===!0}isNotFound(){return this.status===404}isConflict(){return this.status===409}isAuthenticationTimeout(){return this.status===419}};function sm(t,e,s){const n=new URL(e,t);if(s)for(const[r,i]of Object.entries(s))i!==void 0&&n.searchParams.set(r,i);return n.toString()}async function nm(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 rm(t){const e=t.fetchImpl??globalThis.fetch;return{async request({method:s,path:n,query:r,body:i,headers:a}){const o=sm(t.baseUrl,n,r),l=await nm(t.auth),c=await e(o,{method:s,headers:{...i?{"Content-Type":"application/json"}:{},...l,...a},body:i?JSON.stringify(i):void 0}),u=await c.text(),h=(c.headers.get("content-type")||"").includes("application/json"),d=h&&u?JSON.parse(u):u;if(!c.ok){const f=h?d:void 0,p=f==null?void 0:f.error;throw new Nt((p==null?void 0:p.message)??`Request failed with status ${c.status}`,{status:c.status,icebergType:p==null?void 0:p.type,icebergCode:p==null?void 0:p.code,details:f})}return{status:c.status,headers:c.headers,data:d}}}}function Qt(t){return t.join("")}var im=class{constructor(t,e=""){this.client=t,this.prefix=e}async listNamespaces(t){const e=t?{parent:Qt(t.namespace)}:void 0;return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces`,query:e})).data.namespaces.map(n=>({namespace:n}))}async createNamespace(t,e){const s={namespace:t.namespace,properties:e==null?void 0: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/${Qt(t.namespace)}`})}async loadNamespaceMetadata(t){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Qt(t.namespace)}`})).data.properties}}async namespaceExists(t){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${Qt(t.namespace)}`}),!0}catch(e){if(e instanceof Nt&&e.status===404)return!1;throw e}}async createNamespaceIfNotExists(t,e){try{return await this.createNamespace(t,e)}catch(s){if(s instanceof Nt&&s.status===409)return;throw s}}};function Xe(t){return t.join("")}var am=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/${Xe(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/${Xe(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/${Xe(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/${Xe(t.namespace)}/tables/${t.name}`,query:{purgeRequested:String((e==null?void 0:e.purge)??!1)}})}async loadTable(t){const e={};return this.accessDelegation&&(e["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Xe(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/${Xe(t.namespace)}/tables/${t.name}`,headers:e}),!0}catch(s){if(s instanceof Nt&&s.status===404)return!1;throw s}}async createTableIfNotExists(t,e){try{return await this.createTable(t,e)}catch(s){if(s instanceof Nt&&s.status===409)return await this.loadTable({namespace:t.namespace,name:e.name});throw s}}},om=class{constructor(t){var n;let e="v1";t.catalogName&&(e+=`/${t.catalogName}`);const s=t.baseUrl.endsWith("/")?t.baseUrl:`${t.baseUrl}/`;this.client=rm({baseUrl:s,auth:t.auth,fetchImpl:t.fetch}),this.accessDelegation=(n=t.accessDelegation)==null?void 0:n.join(","),this.namespaceOps=new im(this.client,e),this.tableOps=new am(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)}},js=class extends Error{constructor(t){super(t),this.__isStorageError=!0,this.name="StorageError"}};function $(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}var lm=class extends js{constructor(t,e,s){super(t),this.name="StorageApiError",this.status=e,this.statusCode=s}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}},Ln=class extends js{constructor(t,e){super(t),this.name="StorageUnknownError",this.originalError=e}};const Tr=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),cm=()=>Response,Bn=t=>{if(Array.isArray(t))return t.map(s=>Bn(s));if(typeof t=="function"||t!==Object(t))return t;const e={};return Object.entries(t).forEach(([s,n])=>{const r=s.replace(/([-_][a-z])/gi,i=>i.toUpperCase().replace(/[-_]/g,""));e[r]=Bn(n)}),e},um=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)},hm=t=>!t||typeof t!="string"||t.length===0||t.length>100||t.trim()!==t||t.includes("/")||t.includes("\\")?!1:/^[\w!.\*'() &$@=;:+,?-]+$/.test(t);function Mt(t){"@babel/helpers - typeof";return Mt=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},Mt(t)}function dm(t,e){if(Mt(t)!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var n=s.call(t,e||"default");if(Mt(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function fm(t){var e=dm(t,"string");return Mt(e)=="symbol"?e:e+""}function pm(t,e,s){return(e=fm(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function ra(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),s.push.apply(s,n)}return s}function R(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?ra(Object(s),!0).forEach(function(n){pm(t,n,s[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):ra(Object(s)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(s,n))})}return t}const Qs=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)},mm=async(t,e,s)=>{t instanceof await cm()&&!(s!=null&&s.noResolveJson)?t.json().then(n=>{const r=t.status||500,i=(n==null?void 0:n.statusCode)||r+"";e(new lm(Qs(n),r,i))}).catch(n=>{e(new Ln(Qs(n),n))}):e(new Ln(Qs(t),t))},gm=(t,e,s,n)=>{const r={method:t,headers:(e==null?void 0:e.headers)||{}};return t==="GET"||!n?r:(um(n)?(r.headers=R({"Content-Type":"application/json"},e==null?void 0:e.headers),r.body=JSON.stringify(n)):r.body=n,e!=null&&e.duplex&&(r.duplex=e.duplex),R(R({},r),s))};async function Ht(t,e,s,n,r,i){return new Promise((a,o)=>{t(s,gm(e,n,r,i)).then(l=>{if(!l.ok)throw l;return n!=null&&n.noResolveJson?l:l.json()}).then(l=>a(l)).catch(l=>mm(l,o,n))})}async function $t(t,e,s,n){return Ht(t,"GET",e,s,n)}async function he(t,e,s,n,r){return Ht(t,"POST",e,n,r,s)}async function Vn(t,e,s,n,r){return Ht(t,"PUT",e,n,r,s)}async function ym(t,e,s,n){return Ht(t,"HEAD",e,R(R({},s),{},{noResolveJson:!0}),n)}async function kr(t,e,s,n,r){return Ht(t,"DELETE",e,n,r,s)}var vm=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($(e))return{data:null,error:e};throw e}}};let El;El=Symbol.toStringTag;var wm=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e,this[El]="BlobDownloadBuilder",this.promise=null}asStream(){return new vm(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($(e))return{data:null,error:e};throw e}}};const bm={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},ia={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var xm=class{constructor(t,e={},s,n){this.shouldThrowOnError=!1,this.url=t,this.headers=e,this.bucketId=s,this.fetch=Tr(n)}throwOnError(){return this.shouldThrowOnError=!0,this}async uploadOrUpdate(t,e,s,n){var r=this;try{let i;const a=R(R({},ia),n);let o=R(R({},r.headers),t==="POST"&&{"x-upsert":String(a.upsert)});const l=a.metadata;typeof Blob<"u"&&s instanceof Blob?(i=new FormData,i.append("cacheControl",a.cacheControl),l&&i.append("metadata",r.encodeMetadata(l)),i.append("",s)):typeof FormData<"u"&&s instanceof FormData?(i=s,i.has("cacheControl")||i.append("cacheControl",a.cacheControl),l&&!i.has("metadata")&&i.append("metadata",r.encodeMetadata(l))):(i=s,o["cache-control"]=`max-age=${a.cacheControl}`,o["content-type"]=a.contentType,l&&(o["x-metadata"]=r.toBase64(r.encodeMetadata(l))),(typeof ReadableStream<"u"&&i instanceof ReadableStream||i&&typeof i=="object"&&"pipe"in i&&typeof i.pipe=="function")&&!a.duplex&&(a.duplex="half")),n!=null&&n.headers&&(o=R(R({},o),n.headers));const c=r._removeEmptyFolders(e),u=r._getFinalPath(c),h=await(t=="PUT"?Vn:he)(r.fetch,`${r.url}/object/${u}`,i,R({headers:o},a!=null&&a.duplex?{duplex:a.duplex}:{}));return{data:{path:c,id:h.Id,fullPath:h.Key},error:null}}catch(i){if(r.shouldThrowOnError)throw i;if($(i))return{data:null,error:i};throw i}}async upload(t,e,s){return this.uploadOrUpdate("POST",t,e,s)}async uploadToSignedUrl(t,e,s,n){var r=this;const i=r._removeEmptyFolders(t),a=r._getFinalPath(i),o=new URL(r.url+`/object/upload/sign/${a}`);o.searchParams.set("token",e);try{let l;const c=R({upsert:ia.upsert},n),u=R(R({},r.headers),{"x-upsert":String(c.upsert)});return typeof Blob<"u"&&s instanceof Blob?(l=new FormData,l.append("cacheControl",c.cacheControl),l.append("",s)):typeof FormData<"u"&&s instanceof FormData?(l=s,l.append("cacheControl",c.cacheControl)):(l=s,u["cache-control"]=`max-age=${c.cacheControl}`,u["content-type"]=c.contentType),{data:{path:i,fullPath:(await Vn(r.fetch,o.toString(),l,{headers:u})).Key},error:null}}catch(l){if(r.shouldThrowOnError)throw l;if($(l))return{data:null,error:l};throw l}}async createSignedUploadUrl(t,e){var s=this;try{let n=s._getFinalPath(t);const r=R({},s.headers);e!=null&&e.upsert&&(r["x-upsert"]="true");const i=await he(s.fetch,`${s.url}/object/upload/sign/${n}`,{},{headers:r}),a=new URL(s.url+i.url),o=a.searchParams.get("token");if(!o)throw new js("No token returned by API");return{data:{signedUrl:a.toString(),path:t,token:o},error:null}}catch(n){if(s.shouldThrowOnError)throw n;if($(n))return{data:null,error:n};throw n}}async update(t,e,s){return this.uploadOrUpdate("PUT",t,e,s)}async move(t,e,s){var n=this;try{return{data:await he(n.fetch,`${n.url}/object/move`,{bucketId:n.bucketId,sourceKey:t,destinationKey:e,destinationBucket:s==null?void 0:s.destinationBucket},{headers:n.headers}),error:null}}catch(r){if(n.shouldThrowOnError)throw r;if($(r))return{data:null,error:r};throw r}}async copy(t,e,s){var n=this;try{return{data:{path:(await he(n.fetch,`${n.url}/object/copy`,{bucketId:n.bucketId,sourceKey:t,destinationKey:e,destinationBucket:s==null?void 0:s.destinationBucket},{headers:n.headers})).Key},error:null}}catch(r){if(n.shouldThrowOnError)throw r;if($(r))return{data:null,error:r};throw r}}async createSignedUrl(t,e,s){var n=this;try{let r=n._getFinalPath(t),i=await he(n.fetch,`${n.url}/object/sign/${r}`,R({expiresIn:e},s!=null&&s.transform?{transform:s.transform}:{}),{headers:n.headers});const a=s!=null&&s.download?`&download=${s.download===!0?"":s.download}`:"";return i={signedUrl:encodeURI(`${n.url}${i.signedURL}${a}`)},{data:i,error:null}}catch(r){if(n.shouldThrowOnError)throw r;if($(r))return{data:null,error:r};throw r}}async createSignedUrls(t,e,s){var n=this;try{const r=await he(n.fetch,`${n.url}/object/sign/${n.bucketId}`,{expiresIn:e,paths:t},{headers:n.headers}),i=s!=null&&s.download?`&download=${s.download===!0?"":s.download}`:"";return{data:r.map(a=>R(R({},a),{},{signedUrl:a.signedURL?encodeURI(`${n.url}${a.signedURL}${i}`):null})),error:null}}catch(r){if(n.shouldThrowOnError)throw r;if($(r))return{data:null,error:r};throw r}}download(t,e){const s=typeof(e==null?void 0:e.transform)<"u"?"render/image/authenticated":"object",n=this.transformOptsToQueryString((e==null?void 0:e.transform)||{}),r=n?`?${n}`:"",i=this._getFinalPath(t),a=()=>$t(this.fetch,`${this.url}/${s}/${i}${r}`,{headers:this.headers,noResolveJson:!0});return new wm(a,this.shouldThrowOnError)}async info(t){var e=this;const s=e._getFinalPath(t);try{return{data:Bn(await $t(e.fetch,`${e.url}/object/info/${s}`,{headers:e.headers})),error:null}}catch(n){if(e.shouldThrowOnError)throw n;if($(n))return{data:null,error:n};throw n}}async exists(t){var e=this;const s=e._getFinalPath(t);try{return await ym(e.fetch,`${e.url}/object/${s}`,{headers:e.headers}),{data:!0,error:null}}catch(n){if(e.shouldThrowOnError)throw n;if($(n)&&n instanceof Ln){const r=n.originalError;if([400,404].includes(r==null?void 0:r.status))return{data:!1,error:n}}throw n}}getPublicUrl(t,e){const s=this._getFinalPath(t),n=[],r=e!=null&&e.download?`download=${e.download===!0?"":e.download}`:"";r!==""&&n.push(r);const i=typeof(e==null?void 0:e.transform)<"u"?"render/image":"object",a=this.transformOptsToQueryString((e==null?void 0:e.transform)||{});a!==""&&n.push(a);let o=n.join("&");return o!==""&&(o=`?${o}`),{data:{publicUrl:encodeURI(`${this.url}/${i}/public/${s}${o}`)}}}async remove(t){var e=this;try{return{data:await kr(e.fetch,`${e.url}/object/${e.bucketId}`,{prefixes:t},{headers:e.headers}),error:null}}catch(s){if(e.shouldThrowOnError)throw s;if($(s))return{data:null,error:s};throw s}}async list(t,e,s){var n=this;try{const r=R(R(R({},bm),e),{},{prefix:t||""});return{data:await he(n.fetch,`${n.url}/object/list/${n.bucketId}`,r,{headers:n.headers},s),error:null}}catch(r){if(n.shouldThrowOnError)throw r;if($(r))return{data:null,error:r};throw r}}async listV2(t,e){var s=this;try{const n=R({},t);return{data:await he(s.fetch,`${s.url}/object/list-v2/${s.bucketId}`,n,{headers:s.headers},e),error:null}}catch(n){if(s.shouldThrowOnError)throw n;if($(n))return{data:null,error:n};throw n}}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 Pl="2.88.0",Cl={"X-Client-Info":`storage-js/${Pl}`};var _m=class{constructor(t,e={},s,n){this.shouldThrowOnError=!1;const r=new URL(t);n!=null&&n.useNewHostname&&/supabase\.(co|in|red)$/.test(r.hostname)&&!r.hostname.includes("storage.supabase.")&&(r.hostname=r.hostname.replace("supabase.","storage.supabase.")),this.url=r.href.replace(/\/$/,""),this.headers=R(R({},Cl),e),this.fetch=Tr(s)}throwOnError(){return this.shouldThrowOnError=!0,this}async listBuckets(t){var e=this;try{const s=e.listBucketOptionsToQueryString(t);return{data:await $t(e.fetch,`${e.url}/bucket${s}`,{headers:e.headers}),error:null}}catch(s){if(e.shouldThrowOnError)throw s;if($(s))return{data:null,error:s};throw s}}async getBucket(t){var e=this;try{return{data:await $t(e.fetch,`${e.url}/bucket/${t}`,{headers:e.headers}),error:null}}catch(s){if(e.shouldThrowOnError)throw s;if($(s))return{data:null,error:s};throw s}}async createBucket(t,e={public:!1}){var s=this;try{return{data:await he(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}),error:null}}catch(n){if(s.shouldThrowOnError)throw n;if($(n))return{data:null,error:n};throw n}}async updateBucket(t,e){var s=this;try{return{data:await Vn(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}),error:null}}catch(n){if(s.shouldThrowOnError)throw n;if($(n))return{data:null,error:n};throw n}}async emptyBucket(t){var e=this;try{return{data:await he(e.fetch,`${e.url}/bucket/${t}/empty`,{},{headers:e.headers}),error:null}}catch(s){if(e.shouldThrowOnError)throw s;if($(s))return{data:null,error:s};throw s}}async deleteBucket(t){var e=this;try{return{data:await kr(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}),error:null}}catch(s){if(e.shouldThrowOnError)throw s;if($(s))return{data:null,error:s};throw s}}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():""}},Sm=class{constructor(t,e={},s){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=R(R({},Cl),e),this.fetch=Tr(s)}throwOnError(){return this.shouldThrowOnError=!0,this}async createBucket(t){var e=this;try{return{data:await he(e.fetch,`${e.url}/bucket`,{name:t},{headers:e.headers}),error:null}}catch(s){if(e.shouldThrowOnError)throw s;if($(s))return{data:null,error:s};throw s}}async listBuckets(t){var e=this;try{const s=new URLSearchParams;(t==null?void 0:t.limit)!==void 0&&s.set("limit",t.limit.toString()),(t==null?void 0:t.offset)!==void 0&&s.set("offset",t.offset.toString()),t!=null&&t.sortColumn&&s.set("sortColumn",t.sortColumn),t!=null&&t.sortOrder&&s.set("sortOrder",t.sortOrder),t!=null&&t.search&&s.set("search",t.search);const n=s.toString(),r=n?`${e.url}/bucket?${n}`:`${e.url}/bucket`;return{data:await $t(e.fetch,r,{headers:e.headers}),error:null}}catch(s){if(e.shouldThrowOnError)throw s;if($(s))return{data:null,error:s};throw s}}async deleteBucket(t){var e=this;try{return{data:await kr(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}),error:null}}catch(s){if(e.shouldThrowOnError)throw s;if($(s))return{data:null,error:s};throw s}}from(t){var e=this;if(!hm(t))throw new js("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 om({baseUrl:this.url,catalogName:t,auth:{type:"custom",getHeaders:async()=>e.headers},fetch:this.fetch}),n=this.shouldThrowOnError;return new Proxy(s,{get(r,i){const a=r[i];return typeof a!="function"?a:async(...o)=>{try{return{data:await a.apply(r,o),error:null}}catch(l){if(n)throw l;return{data:null,error:l}}}}})}};const Ar={"X-Client-Info":`storage-js/${Pl}`,"Content-Type":"application/json"};var Rl=class extends Error{constructor(t){super(t),this.__isStorageVectorsError=!0,this.name="StorageVectorsError"}};function ee(t){return typeof t=="object"&&t!==null&&"__isStorageVectorsError"in t}var en=class extends Rl{constructor(t,e,s){super(t),this.name="StorageVectorsApiError",this.status=e,this.statusCode=s}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}},Tm=class extends Rl{constructor(t,e){super(t),this.name="StorageVectorsUnknownError",this.originalError=e}};const Er=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),km=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)},aa=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),Am=async(t,e,s)=>{if(t&&typeof t=="object"&&"status"in t&&"ok"in t&&typeof t.status=="number"&&!(s!=null&&s.noResolveJson)){const n=t.status||500,r=t;if(typeof r.json=="function")r.json().then(i=>{const a=(i==null?void 0:i.statusCode)||(i==null?void 0:i.code)||n+"";e(new en(aa(i),n,a))}).catch(()=>{const i=n+"";e(new en(r.statusText||`HTTP ${n} error`,n,i))});else{const i=n+"";e(new en(r.statusText||`HTTP ${n} error`,n,i))}}else e(new Tm(aa(t),t))},Em=(t,e,s,n)=>{const r={method:t,headers:(e==null?void 0:e.headers)||{}};return n?(km(n)?(r.headers=R({"Content-Type":"application/json"},e==null?void 0:e.headers),r.body=JSON.stringify(n)):r.body=n,R(R({},r),s)):r};async function Pm(t,e,s,n,r,i){return new Promise((a,o)=>{t(s,Em(e,n,r,i)).then(l=>{if(!l.ok)throw l;if(n!=null&&n.noResolveJson)return l;const c=l.headers.get("content-type");return!c||!c.includes("application/json")?{}:l.json()}).then(l=>a(l)).catch(l=>Am(l,o,n))})}async function te(t,e,s,n,r){return Pm(t,"POST",e,n,r,s)}var Cm=class{constructor(t,e={},s){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=R(R({},Ar),e),this.fetch=Er(s)}throwOnError(){return this.shouldThrowOnError=!0,this}async createIndex(t){var e=this;try{return{data:await te(e.fetch,`${e.url}/CreateIndex`,t,{headers:e.headers})||{},error:null}}catch(s){if(e.shouldThrowOnError)throw s;if(ee(s))return{data:null,error:s};throw s}}async getIndex(t,e){var s=this;try{return{data:await te(s.fetch,`${s.url}/GetIndex`,{vectorBucketName:t,indexName:e},{headers:s.headers}),error:null}}catch(n){if(s.shouldThrowOnError)throw n;if(ee(n))return{data:null,error:n};throw n}}async listIndexes(t){var e=this;try{return{data:await te(e.fetch,`${e.url}/ListIndexes`,t,{headers:e.headers}),error:null}}catch(s){if(e.shouldThrowOnError)throw s;if(ee(s))return{data:null,error:s};throw s}}async deleteIndex(t,e){var s=this;try{return{data:await te(s.fetch,`${s.url}/DeleteIndex`,{vectorBucketName:t,indexName:e},{headers:s.headers})||{},error:null}}catch(n){if(s.shouldThrowOnError)throw n;if(ee(n))return{data:null,error:n};throw n}}},Rm=class{constructor(t,e={},s){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=R(R({},Ar),e),this.fetch=Er(s)}throwOnError(){return this.shouldThrowOnError=!0,this}async putVectors(t){var e=this;try{if(t.vectors.length<1||t.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return{data:await te(e.fetch,`${e.url}/PutVectors`,t,{headers:e.headers})||{},error:null}}catch(s){if(e.shouldThrowOnError)throw s;if(ee(s))return{data:null,error:s};throw s}}async getVectors(t){var e=this;try{return{data:await te(e.fetch,`${e.url}/GetVectors`,t,{headers:e.headers}),error:null}}catch(s){if(e.shouldThrowOnError)throw s;if(ee(s))return{data:null,error:s};throw s}}async listVectors(t){var e=this;try{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{data:await te(e.fetch,`${e.url}/ListVectors`,t,{headers:e.headers}),error:null}}catch(s){if(e.shouldThrowOnError)throw s;if(ee(s))return{data:null,error:s};throw s}}async queryVectors(t){var e=this;try{return{data:await te(e.fetch,`${e.url}/QueryVectors`,t,{headers:e.headers}),error:null}}catch(s){if(e.shouldThrowOnError)throw s;if(ee(s))return{data:null,error:s};throw s}}async deleteVectors(t){var e=this;try{if(t.keys.length<1||t.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return{data:await te(e.fetch,`${e.url}/DeleteVectors`,t,{headers:e.headers})||{},error:null}}catch(s){if(e.shouldThrowOnError)throw s;if(ee(s))return{data:null,error:s};throw s}}},jm=class{constructor(t,e={},s){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=R(R({},Ar),e),this.fetch=Er(s)}throwOnError(){return this.shouldThrowOnError=!0,this}async createBucket(t){var e=this;try{return{data:await te(e.fetch,`${e.url}/CreateVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{},error:null}}catch(s){if(e.shouldThrowOnError)throw s;if(ee(s))return{data:null,error:s};throw s}}async getBucket(t){var e=this;try{return{data:await te(e.fetch,`${e.url}/GetVectorBucket`,{vectorBucketName:t},{headers:e.headers}),error:null}}catch(s){if(e.shouldThrowOnError)throw s;if(ee(s))return{data:null,error:s};throw s}}async listBuckets(t={}){var e=this;try{return{data:await te(e.fetch,`${e.url}/ListVectorBuckets`,t,{headers:e.headers}),error:null}}catch(s){if(e.shouldThrowOnError)throw s;if(ee(s))return{data:null,error:s};throw s}}async deleteBucket(t){var e=this;try{return{data:await te(e.fetch,`${e.url}/DeleteVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{},error:null}}catch(s){if(e.shouldThrowOnError)throw s;if(ee(s))return{data:null,error:s};throw s}}},Om=class extends jm{constructor(t,e={}){super(t,e.headers||{},e.fetch)}from(t){return new Dm(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)}},Dm=class extends Cm{constructor(t,e,s,n){super(t,e,n),this.vectorBucketName=s}async createIndex(t){var e=()=>super.createIndex,s=this;return e().call(s,R(R({},t),{},{vectorBucketName:s.vectorBucketName}))}async listIndexes(t={}){var e=()=>super.listIndexes,s=this;return e().call(s,R(R({},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 Im(this.url,this.headers,this.vectorBucketName,t,this.fetch)}},Im=class extends Rm{constructor(t,e,s,n,r){super(t,e,r),this.vectorBucketName=s,this.indexName=n}async putVectors(t){var e=()=>super.putVectors,s=this;return e().call(s,R(R({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}async getVectors(t){var e=()=>super.getVectors,s=this;return e().call(s,R(R({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}async listVectors(t={}){var e=()=>super.listVectors,s=this;return e().call(s,R(R({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}async queryVectors(t){var e=()=>super.queryVectors,s=this;return e().call(s,R(R({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}async deleteVectors(t){var e=()=>super.deleteVectors,s=this;return e().call(s,R(R({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}},Nm=class extends _m{constructor(t,e={},s,n){super(t,e,s,n)}from(t){return new xm(this.url,this.headers,t,this.fetch)}get vectors(){return new Om(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new Sm(this.url+"/iceberg",this.headers,this.fetch)}};const jl="2.88.0",it=30*1e3,Un=3,tn=Un*it,Mm="http://localhost:9999",$m="supabase.auth.token",Lm={"X-Client-Info":`gotrue-js/${jl}`},Fn="X-Supabase-Api-Version",Ol={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},Bm=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,Vm=10*60*1e3;class Lt extends Error{constructor(e,s,n){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=s,this.code=n}}function A(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class Um extends Lt{constructor(e,s,n){super(e,s,n),this.name="AuthApiError",this.status=s,this.code=n}}function Fm(t){return A(t)&&t.name==="AuthApiError"}class We extends Lt{constructor(e,s){super(e),this.name="AuthUnknownError",this.originalError=s}}class ke extends Lt{constructor(e,s,n,r){super(e,n,r),this.name=s,this.status=n}}class Q extends ke{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function Wm(t){return A(t)&&t.name==="AuthSessionMissingError"}class Ze extends ke{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class es extends ke{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class ts extends ke{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 qm(t){return A(t)&&t.name==="AuthImplicitGrantRedirectError"}class oa extends ke{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 Hm extends ke{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 Wn extends ke{constructor(e,s){super(e,"AuthRetryableFetchError",s,void 0)}}function sn(t){return A(t)&&t.name==="AuthRetryableFetchError"}class la extends ke{constructor(e,s,n){super(e,"AuthWeakPasswordError",s,"weak_password"),this.reasons=n}}class qn extends ke{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const xs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),ca=`
\r=`.split(""),Km=(()=>{const t=new Array(128);for(let e=0;e<t.length;e+=1)t[e]=-1;for(let e=0;e<ca.length;e+=1)t[ca[e].charCodeAt(0)]=-2;for(let e=0;e<xs.length;e+=1)t[xs[e].charCodeAt(0)]=e;return t})();function ua(t,e,s){if(t!==null)for(e.queue=e.queue<<8|t,e.queuedBits+=8;e.queuedBits>=6;){const n=e.queue>>e.queuedBits-6&63;s(xs[n]),e.queuedBits-=6}else if(e.queuedBits>0)for(e.queue=e.queue<<6-e.queuedBits,e.queuedBits=6;e.queuedBits>=6;){const n=e.queue>>e.queuedBits-6&63;s(xs[n]),e.queuedBits-=6}}function Dl(t,e,s){const n=Km[t];if(n>-1)for(e.queue=e.queue<<6|n,e.queuedBits+=6;e.queuedBits>=8;)s(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(n===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function ha(t){const e=[],s=a=>{e.push(String.fromCodePoint(a))},n={utf8seq:0,codepoint:0},r={queue:0,queuedBits:0},i=a=>{Jm(a,n,s)};for(let a=0;a<t.length;a+=1)Dl(t.charCodeAt(a),r,i);return e.join("")}function Gm(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 zm(t,e){for(let s=0;s<t.length;s+=1){let n=t.charCodeAt(s);if(n>55295&&n<=56319){const r=(n-55296)*1024&65535;n=(t.charCodeAt(s+1)-56320&65535|r)+65536,s+=1}Gm(n,e)}}function Jm(t,e,s){if(e.utf8seq===0){if(t<=127){s(t);return}for(let n=1;n<6;n+=1)if(!(t>>7-n&1)){e.utf8seq=n;break}if(e.utf8seq===2)e.codepoint=t&31;else if(e.utf8seq===3)e.codepoint=t&15;else if(e.utf8seq===4)e.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|t&63,e.utf8seq-=1,e.utf8seq===0&&s(e.codepoint)}}function dt(t){const e=[],s={queue:0,queuedBits:0},n=r=>{e.push(r)};for(let r=0;r<t.length;r+=1)Dl(t.charCodeAt(r),s,n);return new Uint8Array(e)}function Ym(t){const e=[];return zm(t,s=>e.push(s)),new Uint8Array(e)}function Ke(t){const e=[],s={queue:0,queuedBits:0},n=r=>{e.push(r)};return t.forEach(r=>ua(r,s,n)),ua(null,s,n),e.join("")}function Xm(t){return Math.round(Date.now()/1e3)+t}function Zm(){return Symbol("auth-callback")}const G=()=>typeof window<"u"&&typeof document<"u",Le={tested:!1,writable:!1},Il=()=>{if(!G())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Le.tested)return Le.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),Le.tested=!0,Le.writable=!0}catch{Le.tested=!0,Le.writable=!1}return Le.writable};function Qm(t){const e={},s=new URL(t);if(s.hash&&s.hash[0]==="#")try{new URLSearchParams(s.hash.substring(1)).forEach((r,i)=>{e[i]=r})}catch{}return s.searchParams.forEach((n,r)=>{e[r]=n}),e}const Nl=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),eg=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",at=async(t,e,s)=>{await t.setItem(e,JSON.stringify(s))},Be=async(t,e)=>{const s=await t.getItem(e);if(!s)return null;try{return JSON.parse(s)}catch{return s}},K=async(t,e)=>{await t.removeItem(e)};class Os{constructor(){this.promise=new Os.promiseConstructor((e,s)=>{this.resolve=e,this.reject=s})}}Os.promiseConstructor=Promise;function nn(t){const e=t.split(".");if(e.length!==3)throw new qn("Invalid JWT structure");for(let n=0;n<e.length;n++)if(!Bm.test(e[n]))throw new qn("JWT not in base64url format");return{header:JSON.parse(ha(e[0])),payload:JSON.parse(ha(e[1])),signature:dt(e[2]),raw:{header:e[0],payload:e[1]}}}async function tg(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}function sg(t,e){return new Promise((n,r)=>{(async()=>{for(let i=0;i<1/0;i++)try{const a=await t(i);if(!e(i,null,a)){n(a);return}}catch(a){if(!e(i,a)){r(a);return}}})()})}function ng(t){return("0"+t.toString(16)).substr(-2)}function rg(){const e=new Uint32Array(56);if(typeof crypto>"u"){const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",n=s.length;let r="";for(let i=0;i<56;i++)r+=s.charAt(Math.floor(Math.random()*n));return r}return crypto.getRandomValues(e),Array.from(e,ng).join("")}async function ig(t){const s=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",s),r=new Uint8Array(n);return Array.from(r).map(i=>String.fromCharCode(i)).join("")}async function ag(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 ig(t);return btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Qe(t,e,s=!1){const n=rg();let r=n;s&&(r+="/PASSWORD_RECOVERY"),await at(t,`${e}-code-verifier`,r);const i=await ag(n);return[i,n===i?"plain":"s256"]}const og=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function lg(t){const e=t.headers.get(Fn);if(!e||!e.match(og))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function cg(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 ug(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 hg=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function et(t){if(!hg.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function rn(){const t={};return new Proxy(t,{get:(e,s)=>{if(s==="__isUserNotAvailableProxy")return!0;if(typeof s=="symbol"){const n=s.toString();if(n==="Symbol(Symbol.toPrimitive)"||n==="Symbol(Symbol.toStringTag)"||n==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${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 dg(t,e){return new Proxy(t,{get:(s,n,r)=>{if(n==="__isInsecureUserWarningProxy")return!0;if(typeof n=="symbol"){const i=n.toString();if(i==="Symbol(Symbol.toPrimitive)"||i==="Symbol(Symbol.toStringTag)"||i==="Symbol(util.inspect.custom)"||i==="Symbol(nodejs.util.inspect.custom)")return Reflect.get(s,n,r)}return!e.value&&typeof n=="string"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),e.value=!0),Reflect.get(s,n,r)}})}function da(t){return JSON.parse(JSON.stringify(t))}const Ue=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),fg=[502,503,504];async function fa(t){var e;if(!eg(t))throw new Wn(Ue(t),0);if(fg.includes(t.status))throw new Wn(Ue(t),t.status);let s;try{s=await t.json()}catch(i){throw new We(Ue(i),i)}let n;const r=lg(t);if(r&&r.getTime()>=Ol["2024-01-01"].timestamp&&typeof s=="object"&&s&&typeof s.code=="string"?n=s.code:typeof s=="object"&&s&&typeof s.error_code=="string"&&(n=s.error_code),n){if(n==="weak_password")throw new la(Ue(s),t.status,((e=s.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(n==="session_not_found")throw new Q}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((i,a)=>i&&typeof a=="string",!0))throw new la(Ue(s),t.status,s.weak_password.reasons);throw new Um(Ue(s),t.status||500,n)}const pg=(t,e,s,n)=>{const r={method:t,headers:(e==null?void 0:e.headers)||{}};return t==="GET"?r:(r.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e==null?void 0:e.headers),r.body=JSON.stringify(n),Object.assign(Object.assign({},r),s))};async function C(t,e,s,n){var r;const i=Object.assign({},n==null?void 0:n.headers);i[Fn]||(i[Fn]=Ol["2024-01-01"].name),n!=null&&n.jwt&&(i.Authorization=`Bearer ${n.jwt}`);const a=(r=n==null?void 0:n.query)!==null&&r!==void 0?r:{};n!=null&&n.redirectTo&&(a.redirect_to=n.redirectTo);const o=Object.keys(a).length?"?"+new URLSearchParams(a).toString():"",l=await mg(t,e,s+o,{headers:i,noResolveJson:n==null?void 0:n.noResolveJson},{},n==null?void 0:n.body);return n!=null&&n.xform?n==null?void 0:n.xform(l):{data:Object.assign({},l),error:null}}async function mg(t,e,s,n,r,i){const a=pg(e,n,r,i);let o;try{o=await t(s,Object.assign({},a))}catch(l){throw console.error(l),new Wn(Ue(l),0)}if(o.ok||await fa(o),n!=null&&n.noResolveJson)return o;try{return await o.json()}catch(l){await fa(l)}}function le(t){var e;let s=null;vg(t)&&(s=Object.assign({},t),t.expires_at||(s.expires_at=Xm(t.expires_in)));const n=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:s,user:n},error:null}}function pa(t){const e=le(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,n)=>s&&typeof n=="string",!0)&&(e.data.weak_password=t.weak_password),e}function je(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function gg(t){return{data:t,error:null}}function yg(t){const{action_link:e,email_otp:s,hashed_token:n,redirect_to:r,verification_type:i}=t,a=Rs(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),o={action_link:e,email_otp:s,hashed_token:n,redirect_to:r,verification_type:i},l=Object.assign({},a);return{data:{properties:o,user:l},error:null}}function ma(t){return t}function vg(t){return t.access_token&&t.refresh_token&&t.expires_in}const an=["global","local","others"];class wg{constructor({url:e="",headers:s={},fetch:n}){this.url=e,this.headers=s,this.fetch=Nl(n),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),updateClient:this._updateOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)}}async signOut(e,s=an[0]){if(an.indexOf(s)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${an.join(", ")}`);try{return await C(this.fetch,"POST",`${this.url}/logout?scope=${s}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(n){if(A(n))return{data:null,error:n};throw n}}async inviteUserByEmail(e,s={}){try{return await C(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:s.data},headers:this.headers,redirectTo:s.redirectTo,xform:je})}catch(n){if(A(n))return{data:{user:null},error:n};throw n}}async generateLink(e){try{const{options:s}=e,n=Rs(e,["options"]),r=Object.assign(Object.assign({},n),s);return"newEmail"in n&&(r.new_email=n==null?void 0:n.newEmail,delete r.newEmail),await C(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:r,headers:this.headers,xform:yg,redirectTo:s==null?void 0:s.redirectTo})}catch(s){if(A(s))return{data:{properties:null,user:null},error:s};throw s}}async createUser(e){try{return await C(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:je})}catch(s){if(A(s))return{data:{user:null},error:s};throw s}}async listUsers(e){var s,n,r,i,a,o,l;try{const c={nextPage:null,lastPage:0,total:0},u=await C(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(s=e==null?void 0:e.page)===null||s===void 0?void 0:s.toString())!==null&&n!==void 0?n:"",per_page:(i=(r=e==null?void 0:e.perPage)===null||r===void 0?void 0:r.toString())!==null&&i!==void 0?i:""},xform:ma});if(u.error)throw u.error;const h=await u.json(),d=(a=u.headers.get("x-total-count"))!==null&&a!==void 0?a:0,f=(l=(o=u.headers.get("link"))===null||o===void 0?void 0:o.split(","))!==null&&l!==void 0?l:[];return f.length>0&&(f.forEach(p=>{const y=parseInt(p.split(";")[0].split("=")[1].substring(0,1)),g=JSON.parse(p.split(";")[1].split("=")[1]);c[`${g}Page`]=y}),c.total=parseInt(d)),{data:Object.assign(Object.assign({},h),c),error:null}}catch(c){if(A(c))return{data:{users:[]},error:c};throw c}}async getUserById(e){et(e);try{return await C(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:je})}catch(s){if(A(s))return{data:{user:null},error:s};throw s}}async updateUserById(e,s){et(e);try{return await C(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:s,headers:this.headers,xform:je})}catch(n){if(A(n))return{data:{user:null},error:n};throw n}}async deleteUser(e,s=!1){et(e);try{return await C(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:s},xform:je})}catch(n){if(A(n))return{data:{user:null},error:n};throw n}}async _listFactors(e){et(e.userId);try{const{data:s,error:n}=await C(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:r=>({data:{factors:r},error:null})});return{data:s,error:n}}catch(s){if(A(s))return{data:null,error:s};throw s}}async _deleteFactor(e){et(e.userId),et(e.id);try{return{data:await C(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(s){if(A(s))return{data:null,error:s};throw s}}async _listOAuthClients(e){var s,n,r,i,a,o,l;try{const c={nextPage:null,lastPage:0,total:0},u=await C(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(s=e==null?void 0:e.page)===null||s===void 0?void 0:s.toString())!==null&&n!==void 0?n:"",per_page:(i=(r=e==null?void 0:e.perPage)===null||r===void 0?void 0:r.toString())!==null&&i!==void 0?i:""},xform:ma});if(u.error)throw u.error;const h=await u.json(),d=(a=u.headers.get("x-total-count"))!==null&&a!==void 0?a:0,f=(l=(o=u.headers.get("link"))===null||o===void 0?void 0:o.split(","))!==null&&l!==void 0?l:[];return f.length>0&&(f.forEach(p=>{const y=parseInt(p.split(";")[0].split("=")[1].substring(0,1)),g=JSON.parse(p.split(";")[1].split("=")[1]);c[`${g}Page`]=y}),c.total=parseInt(d)),{data:Object.assign(Object.assign({},h),c),error:null}}catch(c){if(A(c))return{data:{clients:[]},error:c};throw c}}async _createOAuthClient(e){try{return await C(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(A(s))return{data:null,error:s};throw s}}async _getOAuthClient(e){try{return await C(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(A(s))return{data:null,error:s};throw s}}async _updateOAuthClient(e,s){try{return await C(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${e}`,{body:s,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(A(n))return{data:null,error:n};throw n}}async _deleteOAuthClient(e){try{return await C(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(s){if(A(s))return{data:null,error:s};throw s}}async _regenerateOAuthClientSecret(e){try{return await C(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(A(s))return{data:null,error:s};throw s}}}function ga(t={}){return{getItem:e=>t[e]||null,setItem:(e,s)=>{t[e]=s},removeItem:e=>{delete t[e]}}}const tt={debug:!!(globalThis&&Il()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class Ml extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class bg extends Ml{}async function xg(t,e,s){tt.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const n=new globalThis.AbortController;return e>0&&setTimeout(()=>{n.abort(),tt.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},e),await Promise.resolve().then(()=>globalThis.navigator.locks.request(t,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:n.signal},async r=>{if(r){tt.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,r.name);try{return await s()}finally{tt.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,r.name)}}else{if(e===0)throw tt.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new bg(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(tt.debug)try{const i=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(i,null," "))}catch(i){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",i)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await s()}}))}function _g(){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 $l(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function Sg(t){return parseInt(t,16)}function Tg(t){const e=new TextEncoder().encode(t);return"0x"+Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}function kg(t){var e;const{chainId:s,domain:n,expirationTime:r,issuedAt:i=new Date,nonce:a,notBefore:o,requestId:l,resources:c,scheme:u,uri:h,version:d}=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(!n)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(a&&a.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${a}`);if(!h)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(d!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${d}`);if(!((e=t.statement)===null||e===void 0)&&e.includes(`
`))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${t.statement}`)}const f=$l(t.address),p=u?`${u}://${n}`:n,y=t.statement?`${t.statement}
`:"",g=`${p} wants you to sign in with your Ethereum account:
${f}
${y}`;let b=`URI: ${h}
Version: ${d}
Chain ID: ${s}${a?`
Nonce: ${a}`:""}
Issued At: ${i.toISOString()}`;if(r&&(b+=`
Expiration Time: ${r.toISOString()}`),o&&(b+=`
Not Before: ${o.toISOString()}`),l&&(b+=`
Request ID: ${l}`),c){let w=`
Resources:`;for(const v of c){if(!v||typeof v!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${v}`);w+=`
- ${v}`}b+=w}return`${g}
${b}`}class V extends Error{constructor({message:e,code:s,cause:n,name:r}){var i;super(e,{cause:n}),this.__isWebAuthnError=!0,this.name=(i=r??(n instanceof Error?n.name:void 0))!==null&&i!==void 0?i:"Unknown Error",this.code=s}}class _s extends V{constructor(e,s){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:s,message:e}),this.name="WebAuthnUnknownError",this.originalError=s}}function Ag({error:t,options:e}){var s,n,r;const{publicKey:i}=e;if(!i)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new V({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((s=i.authenticatorSelection)===null||s===void 0?void 0:s.requireResidentKey)===!0)return new V({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(e.mediation==="conditional"&&((n=i.authenticatorSelection)===null||n===void 0?void 0:n.userVerification)==="required")return new V({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((r=i.authenticatorSelection)===null||r===void 0?void 0:r.userVerification)==="required")return new V({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 V({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new V({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return i.pubKeyCredParams.filter(o=>o.type==="public-key").length===0?new V({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new V({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if(t.name==="SecurityError"){const a=window.location.hostname;if(Ll(a)){if(i.rp.id!==a)return new V({message:`The RP ID "${i.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new V({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(i.user.id.byteLength<1||i.user.id.byteLength>64)return new V({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 V({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 V({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function Eg({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 V({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new V({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const n=window.location.hostname;if(Ll(n)){if(s.rpId!==n)return new V({message:`The RP ID "${s.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new V({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new V({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 V({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class Pg{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 Cg=new Pg;function Rg(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:n}=t,r=Rs(t,["challenge","user","excludeCredentials"]),i=dt(e).buffer,a=Object.assign(Object.assign({},s),{id:dt(s.id).buffer}),o=Object.assign(Object.assign({},r),{challenge:i,user:a});if(n&&n.length>0){o.excludeCredentials=new Array(n.length);for(let l=0;l<n.length;l++){const c=n[l];o.excludeCredentials[l]=Object.assign(Object.assign({},c),{id:dt(c.id).buffer,type:c.type||"public-key",transports:c.transports})}}return o}function jg(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,n=Rs(t,["challenge","allowCredentials"]),r=dt(e).buffer,i=Object.assign(Object.assign({},n),{challenge:r});if(s&&s.length>0){i.allowCredentials=new Array(s.length);for(let a=0;a<s.length;a++){const o=s[a];i.allowCredentials[a]=Object.assign(Object.assign({},o),{id:dt(o.id).buffer,type:o.type||"public-key",transports:o.transports})}}return i}function Og(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:Ke(new Uint8Array(t.response.attestationObject)),clientDataJSON:Ke(new Uint8Array(t.response.clientDataJSON))},type:"public-key",clientExtensionResults:t.getClientExtensionResults(),authenticatorAttachment:(e=s.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function Dg(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const s=t,n=t.getClientExtensionResults(),r=t.response;return{id:t.id,rawId:t.id,response:{authenticatorData:Ke(new Uint8Array(r.authenticatorData)),clientDataJSON:Ke(new Uint8Array(r.clientDataJSON)),signature:Ke(new Uint8Array(r.signature)),userHandle:r.userHandle?Ke(new Uint8Array(r.userHandle)):void 0},type:"public-key",clientExtensionResults:n,authenticatorAttachment:(e=s.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function Ll(t){return t==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(t)}function ya(){var t,e;return!!(G()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&typeof((t=navigator==null?void 0:navigator.credentials)===null||t===void 0?void 0:t.create)=="function"&&typeof((e=navigator==null?void 0:navigator.credentials)===null||e===void 0?void 0:e.get)=="function")}async function Ig(t){try{const e=await navigator.credentials.create(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new _s("Browser returned unexpected credential type",e)}:{data:null,error:new _s("Empty credential response",e)}}catch(e){return{data:null,error:Ag({error:e,options:t})}}}async function Ng(t){try{const e=await navigator.credentials.get(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new _s("Browser returned unexpected credential type",e)}:{data:null,error:new _s("Empty credential response",e)}}catch(e){return{data:null,error:Eg({error:e,options:t})}}}const Mg={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},$g={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function Ss(...t){const e=r=>r!==null&&typeof r=="object"&&!Array.isArray(r),s=r=>r instanceof ArrayBuffer||ArrayBuffer.isView(r),n={};for(const r of t)if(r)for(const i in r){const a=r[i];if(a!==void 0)if(Array.isArray(a))n[i]=a;else if(s(a))n[i]=a;else if(e(a)){const o=n[i];e(o)?n[i]=Ss(o,a):n[i]=Ss(a)}else n[i]=a}return n}function Lg(t,e){return Ss(Mg,t,e||{})}function Bg(t,e){return Ss($g,t,e||{})}class Vg{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:n,signal:r},i){try{const{data:a,error:o}=await this.client.mfa.challenge({factorId:e,webauthn:s});if(!a)return{data:null,error:o};const l=r??Cg.createNewAbortSignal();if(a.webauthn.type==="create"){const{user:c}=a.webauthn.credential_options.publicKey;c.name||(c.name=`${c.id}:${n}`),c.displayName||(c.displayName=c.name)}switch(a.webauthn.type){case"create":{const c=Lg(a.webauthn.credential_options.publicKey,i==null?void 0:i.create),{data:u,error:h}=await Ig({publicKey:c,signal:l});return u?{data:{factorId:e,challengeId:a.id,webauthn:{type:a.webauthn.type,credential_response:u}},error:null}:{data:null,error:h}}case"request":{const c=Bg(a.webauthn.credential_options.publicKey,i==null?void 0:i.request),{data:u,error:h}=await Ng(Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:c,signal:l}));return u?{data:{factorId:e,challengeId:a.id,webauthn:{type:a.webauthn.type,credential_response:u}},error:null}:{data:null,error:h}}}}catch(a){return A(a)?{data:null,error:a}:{data:null,error:new We("Unexpected error in challenge",a)}}}async _verify({challengeId:e,factorId:s,webauthn:n}){return this.client.mfa.verify({factorId:s,challengeId:e,webauthn:n})}async _authenticate({factorId:e,webauthn:{rpId:s=typeof window<"u"?window.location.hostname:void 0,rpOrigins:n=typeof window<"u"?[window.location.origin]:void 0,signal:r}={}},i){if(!s)return{data:null,error:new Lt("rpId is required for WebAuthn authentication")};try{if(!ya())return{data:null,error:new We("Browser does not support WebAuthn",null)};const{data:a,error:o}=await this.challenge({factorId:e,webauthn:{rpId:s,rpOrigins:n},signal:r},{request:i});if(!a)return{data:null,error:o};const{webauthn:l}=a;return this._verify({factorId:e,challengeId:a.challengeId,webauthn:{type:l.type,rpId:s,rpOrigins:n,credential_response:l.credential_response}})}catch(a){return A(a)?{data:null,error:a}:{data:null,error:new We("Unexpected error in authenticate",a)}}}async _register({friendlyName:e,webauthn:{rpId:s=typeof window<"u"?window.location.hostname:void 0,rpOrigins:n=typeof window<"u"?[window.location.origin]:void 0,signal:r}={}},i){if(!s)return{data:null,error:new Lt("rpId is required for WebAuthn registration")};try{if(!ya())return{data:null,error:new We("Browser does not support WebAuthn",null)};const{data:a,error:o}=await this._enroll({friendlyName:e});if(!a)return await this.client.mfa.listFactors().then(u=>{var h;return(h=u.data)===null||h===void 0?void 0:h.all.find(d=>d.factor_type==="webauthn"&&d.friendly_name===e&&d.status!=="unverified")}).then(u=>u?this.client.mfa.unenroll({factorId:u==null?void 0:u.id}):void 0),{data:null,error:o};const{data:l,error:c}=await this._challenge({factorId:a.id,friendlyName:a.friendly_name,webauthn:{rpId:s,rpOrigins:n},signal:r},{create:i});return l?this._verify({factorId:a.id,challengeId:l.challengeId,webauthn:{rpId:s,rpOrigins:n,type:l.webauthn.type,credential_response:l.webauthn.credential_response}}):{data:null,error:c}}catch(a){return A(a)?{data:null,error:a}:{data:null,error:new We("Unexpected error in register",a)}}}}_g();const Ug={url:Mm,storageKey:$m,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:Lm,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1};async function va(t,e,s){return await s()}const st={};class Bt{get jwks(){var e,s;return(s=(e=st[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&s!==void 0?s:{keys:[]}}set jwks(e){st[this.storageKey]=Object.assign(Object.assign({},st[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,s;return(s=(e=st[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&s!==void 0?s:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){st[this.storageKey]=Object.assign(Object.assign({},st[this.storageKey]),{cachedAt:e})}constructor(e){var s,n,r;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;const i=Object.assign(Object.assign({},Ug),e);if(this.storageKey=i.storageKey,this.instanceID=(s=Bt.nextInstanceID[this.storageKey])!==null&&s!==void 0?s:0,Bt.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!i.debug,typeof i.debug=="function"&&(this.logger=i.debug),this.instanceID>0&&G()){const a=`${this._logPrefix()} Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.`;console.warn(a),this.logDebugMessages&&console.trace(a)}if(this.persistSession=i.persistSession,this.autoRefreshToken=i.autoRefreshToken,this.admin=new wg({url:i.url,headers:i.headers,fetch:i.fetch}),this.url=i.url,this.headers=i.headers,this.fetch=Nl(i.fetch),this.lock=i.lock||va,this.detectSessionInUrl=i.detectSessionInUrl,this.flowType=i.flowType,this.hasCustomAuthorizationHeader=i.hasCustomAuthorizationHeader,this.throwOnError=i.throwOnError,i.lock?this.lock=i.lock:this.persistSession&&G()&&(!((n=globalThis==null?void 0:globalThis.navigator)===null||n===void 0)&&n.locks)?this.lock=xg:this.lock=va,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 Vg(this)},this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this),listGrants:this._listOAuthGrants.bind(this),revokeGrant:this._revokeOAuthGrant.bind(this)},this.persistSession?(i.storage?this.storage=i.storage:Il()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=ga(this.memoryStorage)),i.userStorage&&(this.userStorage=i.userStorage)):(this.memoryStorage={},this.storage=ga(this.memoryStorage)),G()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(a){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",a)}(r=this.broadcastChannel)===null||r===void 0||r.addEventListener("message",async a=>{this._debug("received broadcast notification from other tab or client",a),await this._notifyAllSubscribers(a.data.event,a.data.session,!1)})}this.initialize()}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${jl}) ${new Date().toISOString()}`}_debug(...e){return this.logDebugMessages&&this.logger(this._logPrefix(),...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var e;try{let s={},n="none";if(G()&&(s=Qm(window.location.href),this._isImplicitGrantCallback(s)?n="implicit":await this._isPKCECallback(s)&&(n="pkce")),G()&&this.detectSessionInUrl&&n!=="none"){const{data:r,error:i}=await this._getSessionFromURL(s,n);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),qm(i)){const l=(e=i.details)===null||e===void 0?void 0:e.code;if(l==="identity_already_exists"||l==="identity_not_found"||l==="single_identity_not_deletable")return{error:i}}return await this._removeSession(),{error:i}}const{session:a,redirectType:o}=r;return this._debug("#_initialize()","detected session in URL",a,"redirect type",o),await this._saveSession(a),setTimeout(async()=>{o==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",a):await this._notifyAllSubscribers("SIGNED_IN",a)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(s){return A(s)?this._returnResult({error:s}):this._returnResult({error:new We("Unexpected error during initialization",s)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var s,n,r;try{const i=await C(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(n=(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.captchaToken}},xform:le}),{data:a,error:o}=i;if(o||!a)return this._returnResult({data:{user:null,session:null},error:o});const l=a.session,c=a.user;return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(i){if(A(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signUp(e){var s,n,r;try{let i;if("email"in e){const{email:u,password:h,options:d}=e;let f=null,p=null;this.flowType==="pkce"&&([f,p]=await Qe(this.storage,this.storageKey)),i=await C(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:d==null?void 0:d.emailRedirectTo,body:{email:u,password:h,data:(s=d==null?void 0:d.data)!==null&&s!==void 0?s:{},gotrue_meta_security:{captcha_token:d==null?void 0:d.captchaToken},code_challenge:f,code_challenge_method:p},xform:le})}else if("phone"in e){const{phone:u,password:h,options:d}=e;i=await C(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:u,password:h,data:(n=d==null?void 0:d.data)!==null&&n!==void 0?n:{},channel:(r=d==null?void 0:d.channel)!==null&&r!==void 0?r:"sms",gotrue_meta_security:{captcha_token:d==null?void 0:d.captchaToken}},xform:le})}else throw new es("You must provide either an email or phone number and a password");const{data:a,error:o}=i;if(o||!a)return await K(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:o});const l=a.session,c=a.user;return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(i){if(await K(this.storage,`${this.storageKey}-code-verifier`),A(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signInWithPassword(e){try{let s;if("email"in e){const{email:i,password:a,options:o}=e;s=await C(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:i,password:a,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},xform:pa})}else if("phone"in e){const{phone:i,password:a,options:o}=e;s=await C(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:i,password:a,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},xform:pa})}else throw new es("You must provide either an email or phone number and a password");const{data:n,error:r}=s;if(r)return this._returnResult({data:{user:null,session:null},error:r});if(!n||!n.session||!n.user){const i=new Ze;return this._returnResult({data:{user:null,session:null},error:i})}return n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),this._returnResult({data:Object.assign({user:n.user,session:n.session},n.weak_password?{weakPassword:n.weak_password}:null),error:r})}catch(s){if(A(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async signInWithOAuth(e){var s,n,r,i;return await this._handleProviderSignIn(e.provider,{redirectTo:(s=e.options)===null||s===void 0?void 0:s.redirectTo,scopes:(n=e.options)===null||n===void 0?void 0:n.scopes,queryParams:(r=e.options)===null||r===void 0?void 0:r.queryParams,skipBrowserRedirect:(i=e.options)===null||i===void 0?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){const{chain: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,n,r,i,a,o,l,c,u,h,d;let f,p;if("message"in e)f=e.message,p=e.signature;else{const{chain:y,wallet:g,statement:b,options:w}=e;let v;if(G())if(typeof g=="object")v=g;else{const O=window;if("ethereum"in O&&typeof O.ethereum=="object"&&"request"in O.ethereum&&typeof O.ethereum.request=="function")v=O.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 g!="object"||!(w!=null&&w.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");v=g}const x=new URL((s=w==null?void 0:w.url)!==null&&s!==void 0?s:window.location.href),S=await v.request({method:"eth_requestAccounts"}).then(O=>O).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!S||S.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const k=$l(S[0]);let j=(n=w==null?void 0:w.signInWithEthereum)===null||n===void 0?void 0:n.chainId;if(!j){const O=await v.request({method:"eth_chainId"});j=Sg(O)}const E={domain:x.host,address:k,statement:b,uri:x.href,version:"1",chainId:j,nonce:(r=w==null?void 0:w.signInWithEthereum)===null||r===void 0?void 0:r.nonce,issuedAt:(a=(i=w==null?void 0:w.signInWithEthereum)===null||i===void 0?void 0:i.issuedAt)!==null&&a!==void 0?a:new Date,expirationTime:(o=w==null?void 0:w.signInWithEthereum)===null||o===void 0?void 0:o.expirationTime,notBefore:(l=w==null?void 0:w.signInWithEthereum)===null||l===void 0?void 0:l.notBefore,requestId:(c=w==null?void 0:w.signInWithEthereum)===null||c===void 0?void 0:c.requestId,resources:(u=w==null?void 0:w.signInWithEthereum)===null||u===void 0?void 0:u.resources};f=kg(E),p=await v.request({method:"personal_sign",params:[Tg(f),k]})}try{const{data:y,error:g}=await C(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:f,signature:p},!((h=e.options)===null||h===void 0)&&h.captchaToken?{gotrue_meta_security:{captcha_token:(d=e.options)===null||d===void 0?void 0:d.captchaToken}}:null),xform:le});if(g)throw g;if(!y||!y.session||!y.user){const b=new Ze;return this._returnResult({data:{user:null,session:null},error:b})}return y.session&&(await this._saveSession(y.session),await this._notifyAllSubscribers("SIGNED_IN",y.session)),this._returnResult({data:Object.assign({},y),error:g})}catch(y){if(A(y))return this._returnResult({data:{user:null,session:null},error:y});throw y}}async signInWithSolana(e){var s,n,r,i,a,o,l,c,u,h,d,f;let p,y;if("message"in e)p=e.message,y=e.signature;else{const{chain:g,wallet:b,statement:w,options:v}=e;let x;if(G())if(typeof b=="object")x=b;else{const k=window;if("solana"in k&&typeof k.solana=="object"&&("signIn"in k.solana&&typeof k.solana.signIn=="function"||"signMessage"in k.solana&&typeof k.solana.signMessage=="function"))x=k.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 b!="object"||!(v!=null&&v.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");x=b}const S=new URL((s=v==null?void 0:v.url)!==null&&s!==void 0?s:window.location.href);if("signIn"in x&&x.signIn){const k=await x.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},v==null?void 0:v.signInWithSolana),{version:"1",domain:S.host,uri:S.href}),w?{statement:w}:null));let j;if(Array.isArray(k)&&k[0]&&typeof k[0]=="object")j=k[0];else if(k&&typeof k=="object"&&"signedMessage"in k&&"signature"in k)j=k;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in j&&"signature"in j&&(typeof j.signedMessage=="string"||j.signedMessage instanceof Uint8Array)&&j.signature instanceof Uint8Array)p=typeof j.signedMessage=="string"?j.signedMessage:new TextDecoder().decode(j.signedMessage),y=j.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in x)||typeof x.signMessage!="function"||!("publicKey"in x)||typeof x!="object"||!x.publicKey||!("toBase58"in x.publicKey)||typeof x.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");p=[`${S.host} wants you to sign in with your Solana account:`,x.publicKey.toBase58(),...w?["",w,""]:[""],"Version: 1",`URI: ${S.href}`,`Issued At: ${(r=(n=v==null?void 0:v.signInWithSolana)===null||n===void 0?void 0:n.issuedAt)!==null&&r!==void 0?r:new Date().toISOString()}`,...!((i=v==null?void 0:v.signInWithSolana)===null||i===void 0)&&i.notBefore?[`Not Before: ${v.signInWithSolana.notBefore}`]:[],...!((a=v==null?void 0:v.signInWithSolana)===null||a===void 0)&&a.expirationTime?[`Expiration Time: ${v.signInWithSolana.expirationTime}`]:[],...!((o=v==null?void 0:v.signInWithSolana)===null||o===void 0)&&o.chainId?[`Chain ID: ${v.signInWithSolana.chainId}`]:[],...!((l=v==null?void 0:v.signInWithSolana)===null||l===void 0)&&l.nonce?[`Nonce: ${v.signInWithSolana.nonce}`]:[],...!((c=v==null?void 0:v.signInWithSolana)===null||c===void 0)&&c.requestId?[`Request ID: ${v.signInWithSolana.requestId}`]:[],...!((h=(u=v==null?void 0:v.signInWithSolana)===null||u===void 0?void 0:u.resources)===null||h===void 0)&&h.length?["Resources",...v.signInWithSolana.resources.map(j=>`- ${j}`)]:[]].join(`
`);const k=await x.signMessage(new TextEncoder().encode(p),"utf8");if(!k||!(k instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");y=k}}try{const{data:g,error:b}=await C(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:p,signature:Ke(y)},!((d=e.options)===null||d===void 0)&&d.captchaToken?{gotrue_meta_security:{captcha_token:(f=e.options)===null||f===void 0?void 0:f.captchaToken}}:null),xform:le});if(b)throw b;if(!g||!g.session||!g.user){const w=new Ze;return this._returnResult({data:{user:null,session:null},error:w})}return g.session&&(await this._saveSession(g.session),await this._notifyAllSubscribers("SIGNED_IN",g.session)),this._returnResult({data:Object.assign({},g),error:b})}catch(g){if(A(g))return this._returnResult({data:{user:null,session:null},error:g});throw g}}async _exchangeCodeForSession(e){const s=await Be(this.storage,`${this.storageKey}-code-verifier`),[n,r]=(s??"").split("/");try{if(!n&&this.flowType==="pkce")throw new Hm;const{data:i,error:a}=await C(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:n},xform:le});if(await K(this.storage,`${this.storageKey}-code-verifier`),a)throw a;if(!i||!i.session||!i.user){const o=new Ze;return this._returnResult({data:{user:null,session:null,redirectType:null},error:o})}return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",i.session)),this._returnResult({data:Object.assign(Object.assign({},i),{redirectType:r??null}),error:a})}catch(i){if(await K(this.storage,`${this.storageKey}-code-verifier`),A(i))return this._returnResult({data:{user:null,session:null,redirectType:null},error:i});throw i}}async signInWithIdToken(e){try{const{options:s,provider:n,token:r,access_token:i,nonce:a}=e,o=await C(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:n,id_token:r,access_token:i,nonce:a,gotrue_meta_security:{captcha_token:s==null?void 0:s.captchaToken}},xform:le}),{data:l,error:c}=o;if(c)return this._returnResult({data:{user:null,session:null},error:c});if(!l||!l.session||!l.user){const u=new Ze;return this._returnResult({data:{user:null,session:null},error:u})}return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",l.session)),this._returnResult({data:l,error:c})}catch(s){if(A(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async signInWithOtp(e){var s,n,r,i,a;try{if("email"in e){const{email:o,options:l}=e;let c=null,u=null;this.flowType==="pkce"&&([c,u]=await Qe(this.storage,this.storageKey));const{error:h}=await C(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:o,data:(s=l==null?void 0:l.data)!==null&&s!==void 0?s:{},create_user:(n=l==null?void 0:l.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},code_challenge:c,code_challenge_method:u},redirectTo:l==null?void 0:l.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:h})}if("phone"in e){const{phone:o,options:l}=e,{data:c,error:u}=await C(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:o,data:(r=l==null?void 0:l.data)!==null&&r!==void 0?r:{},create_user:(i=l==null?void 0:l.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},channel:(a=l==null?void 0:l.channel)!==null&&a!==void 0?a:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:c==null?void 0:c.message_id},error:u})}throw new es("You must provide either an email or phone number.")}catch(o){if(await K(this.storage,`${this.storageKey}-code-verifier`),A(o))return this._returnResult({data:{user:null,session:null},error:o});throw o}}async verifyOtp(e){var s,n;try{let r,i;"options"in e&&(r=(s=e.options)===null||s===void 0?void 0:s.redirectTo,i=(n=e.options)===null||n===void 0?void 0:n.captchaToken);const{data:a,error:o}=await C(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:r,xform:le});if(o)throw o;if(!a)throw new Error("An error occurred on token verification.");const l=a.session,c=a.user;return l!=null&&l.access_token&&(await this._saveSession(l),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(r){if(A(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signInWithSSO(e){var s,n,r,i,a;try{let o=null,l=null;this.flowType==="pkce"&&([o,l]=await Qe(this.storage,this.storageKey));const c=await C(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(n=(s=e.options)===null||s===void 0?void 0:s.redirectTo)!==null&&n!==void 0?n:void 0}),!((r=e==null?void 0:e.options)===null||r===void 0)&&r.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:o,code_challenge_method:l}),headers:this.headers,xform:gg});return!((i=c.data)===null||i===void 0)&&i.url&&G()&&!(!((a=e.options)===null||a===void 0)&&a.skipBrowserRedirect)&&window.location.assign(c.data.url),this._returnResult(c)}catch(o){if(await K(this.storage,`${this.storageKey}-code-verifier`),A(o))return this._returnResult({data:null,error:o});throw o}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:s},error:n}=e;if(n)throw n;if(!s)throw new Q;const{error:r}=await C(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:s.access_token});return this._returnResult({data:{user:null,session:null},error:r})})}catch(e){if(A(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:n,type:r,options:i}=e,{error:a}=await C(this.fetch,"POST",s,{headers:this.headers,body:{email:n,type:r,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}},redirectTo:i==null?void 0:i.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:a})}else if("phone"in e){const{phone:n,type:r,options:i}=e,{data:a,error:o}=await C(this.fetch,"POST",s,{headers:this.headers,body:{phone:n,type:r,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:a==null?void 0:a.message_id},error:o})}throw new es("You must provide either an email or phone number and a type")}catch(s){if(A(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async s=>s))}async _acquireLock(e,s){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),r=(async()=>(await n,await s()))();return this.pendingInLock.push((async()=>{try{await r}catch{}})()),r}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const n=s();for(this.pendingInLock.push((async()=>{try{await n}catch{}})()),await n;this.pendingInLock.length;){const r=[...this.pendingInLock];await Promise.all(r),this.pendingInLock.splice(0,r.length)}return await n}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const 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 Be(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 n=e.expires_at?e.expires_at*1e3-Date.now()<tn:!1;if(this._debug("#__loadSession()",`session has${n?"":" not"} expired`,"expires_at",e.expires_at),!n){if(this.userStorage){const a=await Be(this.userStorage,this.storageKey+"-user");a!=null&&a.user?e.user=a.user:e.user=rn()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){const a={value:this.suppressGetSessionWarning};e.user=dg(e.user,a),a.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:e},error:null}}const{data:r,error:i}=await this._callRefreshToken(e.refresh_token);return i?this._returnResult({data:{session:null},error:i}):this._returnResult({data:{session:r},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(-1,async()=>await this._getUser());return s.data.user&&(this.suppressGetSessionWarning=!0),s}async _getUser(e){try{return e?await C(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:je}):await this._useSession(async s=>{var n,r,i;const{data:a,error:o}=s;if(o)throw o;return!(!((n=a.session)===null||n===void 0)&&n.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new Q}:await C(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(i=(r=a.session)===null||r===void 0?void 0:r.access_token)!==null&&i!==void 0?i:void 0,xform:je})})}catch(s){if(A(s))return Wm(s)&&(await this._removeSession(),await K(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(-1,async()=>await this._updateUser(e,s))}async _updateUser(e,s={}){try{return await this._useSession(async n=>{const{data:r,error:i}=n;if(i)throw i;if(!r.session)throw new Q;const a=r.session;let o=null,l=null;this.flowType==="pkce"&&e.email!=null&&([o,l]=await Qe(this.storage,this.storageKey));const{data:c,error:u}=await C(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:s==null?void 0:s.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:o,code_challenge_method:l}),jwt:a.access_token,xform:je});if(u)throw u;return a.user=c.user,await this._saveSession(a),await this._notifyAllSubscribers("USER_UPDATED",a),this._returnResult({data:{user:a.user},error:null})})}catch(n){if(await K(this.storage,`${this.storageKey}-code-verifier`),A(n))return this._returnResult({data:{user:null},error:n});throw n}}async setSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new Q;const s=Date.now()/1e3;let n=s,r=!0,i=null;const{payload:a}=nn(e.access_token);if(a.exp&&(n=a.exp,r=n<=s),r){const{data:o,error:l}=await this._callRefreshToken(e.refresh_token);if(l)return this._returnResult({data:{user:null,session:null},error:l});if(!o)return{data:{user:null,session:null},error:null};i=o}else{const{data:o,error:l}=await this._getUser(e.access_token);if(l)throw l;i={access_token:e.access_token,refresh_token:e.refresh_token,user:o.user,token_type:"bearer",expires_in:n-s,expires_at:n},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return this._returnResult({data:{user:i.user,session:i},error:null})}catch(s){if(A(s))return this._returnResult({data:{session:null,user:null},error:s});throw s}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async s=>{var n;if(!e){const{data:a,error:o}=s;if(o)throw o;e=(n=a.session)!==null&&n!==void 0?n:void 0}if(!(e!=null&&e.refresh_token))throw new Q;const{data:r,error:i}=await this._callRefreshToken(e.refresh_token);return i?this._returnResult({data:{user:null,session:null},error:i}):r?this._returnResult({data:{user:r.user,session:r},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(s){if(A(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async _getSessionFromURL(e,s){try{if(!G())throw new ts("No browser detected.");if(e.error||e.error_description||e.error_code)throw new ts(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 oa("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new ts("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 oa("No code detected.");const{data:w,error:v}=await this._exchangeCodeForSession(e.code);if(v)throw v;const x=new URL(window.location.href);return x.searchParams.delete("code"),window.history.replaceState(window.history.state,"",x.toString()),{data:{session:w.session,redirectType:null},error:null}}const{provider_token:n,provider_refresh_token:r,access_token:i,refresh_token:a,expires_in:o,expires_at:l,token_type:c}=e;if(!i||!o||!a||!c)throw new ts("No session defined in URL");const u=Math.round(Date.now()/1e3),h=parseInt(o);let d=u+h;l&&(d=parseInt(l));const f=d-u;f*1e3<=it&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${f}s, should have been closer to ${h}s`);const p=d-h;u-p>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",p,d,u):u-p<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",p,d,u);const{data:y,error:g}=await this._getUser(i);if(g)throw g;const b={provider_token:n,provider_refresh_token:r,access_token:i,expires_in:h,expires_at:d,refresh_token:a,token_type:c,user:y.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:b,redirectType:e.type},error:null})}catch(n){if(A(n))return this._returnResult({data:{session:null,redirectType:null},error:n});throw n}}_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 Be(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&s)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async s=>{var n;const{data:r,error:i}=s;if(i)return this._returnResult({error:i});const a=(n=r.session)===null||n===void 0?void 0:n.access_token;if(a){const{error:o}=await this.admin.signOut(a,e);if(o&&!(Fm(o)&&(o.status===404||o.status===401||o.status===403)))return this._returnResult({error:o})}return e!=="others"&&(await this._removeSession(),await K(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(e){const s=Zm(),n={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,n),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(s)})))(),{data:{subscription:n}}}async _emitInitialSession(e){return await this._useSession(async s=>{var n,r;try{const{data:{session:i},error:a}=s;if(a)throw a;await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",i)),this._debug("INITIAL_SESSION","callback id",e,"session",i)}catch(i){await((r=this.stateChangeEmitters.get(e))===null||r===void 0?void 0:r.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",i),console.error(i)}})}async resetPasswordForEmail(e,s={}){let n=null,r=null;this.flowType==="pkce"&&([n,r]=await Qe(this.storage,this.storageKey,!0));try{return await C(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:n,code_challenge_method:r,gotrue_meta_security:{captcha_token:s.captchaToken}},headers:this.headers,redirectTo:s.redirectTo})}catch(i){if(await K(this.storage,`${this.storageKey}-code-verifier`),A(i))return this._returnResult({data:null,error:i});throw i}}async getUserIdentities(){var e;try{const{data:s,error:n}=await this.getUser();if(n)throw n;return this._returnResult({data:{identities:(e=s.user.identities)!==null&&e!==void 0?e:[]},error:null})}catch(s){if(A(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:n,error:r}=await this._useSession(async i=>{var a,o,l,c,u;const{data:h,error:d}=i;if(d)throw d;const f=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(a=e.options)===null||a===void 0?void 0:a.redirectTo,scopes:(o=e.options)===null||o===void 0?void 0:o.scopes,queryParams:(l=e.options)===null||l===void 0?void 0:l.queryParams,skipBrowserRedirect:!0});return await C(this.fetch,"GET",f,{headers:this.headers,jwt:(u=(c=h.session)===null||c===void 0?void 0:c.access_token)!==null&&u!==void 0?u:void 0})});if(r)throw r;return G()&&!(!((s=e.options)===null||s===void 0)&&s.skipBrowserRedirect)&&window.location.assign(n==null?void 0:n.url),this._returnResult({data:{provider:e.provider,url:n==null?void 0:n.url},error:null})}catch(n){if(A(n))return this._returnResult({data:{provider:e.provider,url:null},error:n});throw n}}async linkIdentityIdToken(e){return await this._useSession(async s=>{var n;try{const{error:r,data:{session:i}}=s;if(r)throw r;const{options:a,provider:o,token:l,access_token:c,nonce:u}=e,h=await C(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(n=i==null?void 0:i.access_token)!==null&&n!==void 0?n:void 0,body:{provider:o,id_token:l,access_token:c,nonce:u,link_identity:!0,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:le}),{data:d,error:f}=h;return f?this._returnResult({data:{user:null,session:null},error:f}):!d||!d.session||!d.user?this._returnResult({data:{user:null,session:null},error:new Ze}):(d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("USER_UPDATED",d.session)),this._returnResult({data:d,error:f}))}catch(r){if(await K(this.storage,`${this.storageKey}-code-verifier`),A(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}})}async unlinkIdentity(e){try{return await this._useSession(async s=>{var n,r;const{data:i,error:a}=s;if(a)throw a;return await C(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(r=(n=i.session)===null||n===void 0?void 0:n.access_token)!==null&&r!==void 0?r:void 0})})}catch(s){if(A(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 n=Date.now();return await sg(async r=>(r>0&&await tg(200*Math.pow(2,r-1)),this._debug(s,"refreshing attempt",r),await C(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:le})),(r,i)=>{const a=200*Math.pow(2,r);return i&&sn(i)&&Date.now()+a-n<it})}catch(n){if(this._debug(s,"error",n),A(n))return this._returnResult({data:{session:null,user:null},error:n});throw n}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 n=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",n),G()&&!s.skipBrowserRedirect&&window.location.assign(n),{data:{provider:e,url:n},error:null}}async _recoverAndRefresh(){var e,s;const n="#_recoverAndRefresh()";this._debug(n,"begin");try{const r=await Be(this.storage,this.storageKey);if(r&&this.userStorage){let a=await Be(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!a&&(a={user:r.user},await at(this.userStorage,this.storageKey+"-user",a)),r.user=(e=a==null?void 0:a.user)!==null&&e!==void 0?e:rn()}else if(r&&!r.user&&!r.user){const a=await Be(this.storage,this.storageKey+"-user");a&&(a!=null&&a.user)?(r.user=a.user,await K(this.storage,this.storageKey+"-user"),await at(this.storage,this.storageKey,r)):r.user=rn()}if(this._debug(n,"session from storage",r),!this._isValidSession(r)){this._debug(n,"session is not valid"),r!==null&&await this._removeSession();return}const i=((s=r.expires_at)!==null&&s!==void 0?s:1/0)*1e3-Date.now()<tn;if(this._debug(n,`session has${i?"":" not"} expired with margin of ${tn}s`),i){if(this.autoRefreshToken&&r.refresh_token){const{error:a}=await this._callRefreshToken(r.refresh_token);a&&(console.error(a),sn(a)||(this._debug(n,"refresh failed with a non-retryable error, removing the session",a),await this._removeSession()))}}else if(r.user&&r.user.__isUserNotAvailableProxy===!0)try{const{data:a,error:o}=await this._getUser(r.access_token);!o&&(a!=null&&a.user)?(r.user=a.user,await this._saveSession(r),await this._notifyAllSubscribers("SIGNED_IN",r)):this._debug(n,"could not get user data, skipping SIGNED_IN notification")}catch(a){console.error("Error getting user data:",a),this._debug(n,"error getting user data, skipping SIGNED_IN notification",a)}else await this._notifyAllSubscribers("SIGNED_IN",r)}catch(r){this._debug(n,"error",r),console.error(r);return}finally{this._debug(n,"end")}}async _callRefreshToken(e){var s,n;if(!e)throw new Q;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const r=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(r,"begin");try{this.refreshingDeferred=new Os;const{data:i,error:a}=await this._refreshAccessToken(e);if(a)throw a;if(!i.session)throw new Q;await this._saveSession(i.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",i.session);const o={data:i.session,error:null};return this.refreshingDeferred.resolve(o),o}catch(i){if(this._debug(r,"error",i),A(i)){const a={data:null,error:i};return sn(i)||await this._removeSession(),(s=this.refreshingDeferred)===null||s===void 0||s.resolve(a),a}throw(n=this.refreshingDeferred)===null||n===void 0||n.reject(i),i}finally{this.refreshingDeferred=null,this._debug(r,"end")}}async _notifyAllSubscribers(e,s,n=!0){const r=`#_notifyAllSubscribers(${e})`;this._debug(r,"begin",s,`broadcast = ${n}`);try{this.broadcastChannel&&n&&this.broadcastChannel.postMessage({event:e,session:s});const i=[],a=Array.from(this.stateChangeEmitters.values()).map(async o=>{try{await o.callback(e,s)}catch(l){i.push(l)}});if(await Promise.all(a),i.length>0){for(let o=0;o<i.length;o+=1)console.error(i[o]);throw i[0]}}finally{this._debug(r,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await K(this.storage,`${this.storageKey}-code-verifier`);const s=Object.assign({},e),n=s.user&&s.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!n&&s.user&&await at(this.userStorage,this.storageKey+"-user",{user:s.user});const r=Object.assign({},s);delete r.user;const i=da(r);await at(this.storage,this.storageKey,i)}else{const r=da(s);await at(this.storage,this.storageKey,r)}}async _removeSession(){this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await K(this.storage,this.storageKey),await K(this.storage,this.storageKey+"-code-verifier"),await K(this.storage,this.storageKey+"-user"),this.userStorage&&await K(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&G()&&(window!=null&&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(),it);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async s=>{const{data:{session:n}}=s;if(!n||!n.refresh_token||!n.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const r=Math.floor((n.expires_at*1e3-e)/it);this._debug("#_autoRefreshTokenTick()",`access token expires in ${r} ticks, a tick lasts ${it}ms, refresh threshold is ${Un} ticks`),r<=Un&&await this._callRefreshToken(n.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 Ml)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!G()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const s=`#_onVisibilityChanged(${e})`;this._debug(s,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(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,n){const r=[`provider=${encodeURIComponent(s)}`];if(n!=null&&n.redirectTo&&r.push(`redirect_to=${encodeURIComponent(n.redirectTo)}`),n!=null&&n.scopes&&r.push(`scopes=${encodeURIComponent(n.scopes)}`),this.flowType==="pkce"){const[i,a]=await Qe(this.storage,this.storageKey),o=new URLSearchParams({code_challenge:`${encodeURIComponent(i)}`,code_challenge_method:`${encodeURIComponent(a)}`});r.push(o.toString())}if(n!=null&&n.queryParams){const i=new URLSearchParams(n.queryParams);r.push(i.toString())}return n!=null&&n.skipBrowserRedirect&&r.push(`skip_http_redirect=${n.skipBrowserRedirect}`),`${e}?${r.join("&")}`}async _unenroll(e){try{return await this._useSession(async s=>{var n;const{data:r,error:i}=s;return i?this._returnResult({data:null,error:i}):await C(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(n=r==null?void 0:r.session)===null||n===void 0?void 0:n.access_token})})}catch(s){if(A(s))return this._returnResult({data:null,error:s});throw s}}async _enroll(e){try{return await this._useSession(async s=>{var n,r;const{data:i,error:a}=s;if(a)return this._returnResult({data:null,error:a});const o=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:e.factorType==="totp"?{issuer:e.issuer}:{}),{data:l,error:c}=await C(this.fetch,"POST",`${this.url}/factors`,{body:o,headers:this.headers,jwt:(n=i==null?void 0:i.session)===null||n===void 0?void 0:n.access_token});return c?this._returnResult({data:null,error:c}):(e.factorType==="totp"&&l.type==="totp"&&(!((r=l==null?void 0:l.totp)===null||r===void 0)&&r.qr_code)&&(l.totp.qr_code=`data:image/svg+xml;utf-8,${l.totp.qr_code}`),this._returnResult({data:l,error:null}))})}catch(s){if(A(s))return this._returnResult({data:null,error:s});throw s}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async s=>{var n;const{data:r,error:i}=s;if(i)return this._returnResult({data:null,error:i});const a=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:e.webauthn.type==="create"?Og(e.webauthn.credential_response):Dg(e.webauthn.credential_response)})}:{code:e.code}),{data:o,error:l}=await C(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:a,headers:this.headers,jwt:(n=r==null?void 0:r.session)===null||n===void 0?void 0:n.access_token});return l?this._returnResult({data:null,error:l}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+o.expires_in},o)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",o),this._returnResult({data:o,error:l}))})}catch(s){if(A(s))return this._returnResult({data:null,error:s});throw s}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async s=>{var n;const{data:r,error:i}=s;if(i)return this._returnResult({data:null,error:i});const a=await C(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(n=r==null?void 0:r.session)===null||n===void 0?void 0:n.access_token});if(a.error)return a;const{data:o}=a;if(o.type!=="webauthn")return{data:o,error:null};switch(o.webauthn.type){case"create":return{data:Object.assign(Object.assign({},o),{webauthn:Object.assign(Object.assign({},o.webauthn),{credential_options:Object.assign(Object.assign({},o.webauthn.credential_options),{publicKey:Rg(o.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},o),{webauthn:Object.assign(Object.assign({},o.webauthn),{credential_options:Object.assign(Object.assign({},o.webauthn.credential_options),{publicKey:jg(o.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(s){if(A(s))return this._returnResult({data:null,error:s});throw s}})}async _challengeAndVerify(e){const{data:s,error:n}=await this._challenge({factorId:e.factorId});return n?this._returnResult({data:null,error:n}):await this._verify({factorId:e.factorId,challengeId:s.id,code:e.code})}async _listFactors(){var e;const{data:{user:s},error:n}=await this.getUser();if(n)return{data:null,error:n};const r={all:[],phone:[],totp:[],webauthn:[]};for(const i of(e=s==null?void 0:s.factors)!==null&&e!==void 0?e:[])r.all.push(i),i.status==="verified"&&r[i.factor_type].push(i);return{data:r,error:null}}async _getAuthenticatorAssuranceLevel(){var e,s;const{data:{session:n},error:r}=await this.getSession();if(r)return this._returnResult({data:null,error:r});if(!n)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:i}=nn(n.access_token);let a=null;i.aal&&(a=i.aal);let o=a;((s=(e=n.user.factors)===null||e===void 0?void 0:e.filter(u=>u.status==="verified"))!==null&&s!==void 0?s:[]).length>0&&(o="aal2");const c=i.amr||[];return{data:{currentLevel:a,nextLevel:o,currentAuthenticationMethods:c},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async s=>{const{data:{session:n},error:r}=s;return r?this._returnResult({data:null,error:r}):n?await C(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:n.access_token,xform:i=>({data:i,error:null})}):this._returnResult({data:null,error:new Q})})}catch(s){if(A(s))return this._returnResult({data:null,error:s});throw s}}async _approveAuthorization(e,s){try{return await this._useSession(async n=>{const{data:{session:r},error:i}=n;if(i)return this._returnResult({data:null,error:i});if(!r)return this._returnResult({data:null,error:new Q});const a=await C(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:r.access_token,body:{action:"approve"},xform:o=>({data:o,error:null})});return a.data&&a.data.redirect_url&&G()&&!(s!=null&&s.skipBrowserRedirect)&&window.location.assign(a.data.redirect_url),a})}catch(n){if(A(n))return this._returnResult({data:null,error:n});throw n}}async _denyAuthorization(e,s){try{return await this._useSession(async n=>{const{data:{session:r},error:i}=n;if(i)return this._returnResult({data:null,error:i});if(!r)return this._returnResult({data:null,error:new Q});const a=await C(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:r.access_token,body:{action:"deny"},xform:o=>({data:o,error:null})});return a.data&&a.data.redirect_url&&G()&&!(s!=null&&s.skipBrowserRedirect)&&window.location.assign(a.data.redirect_url),a})}catch(n){if(A(n))return this._returnResult({data:null,error:n});throw n}}async _listOAuthGrants(){try{return await this._useSession(async e=>{const{data:{session:s},error:n}=e;return n?this._returnResult({data:null,error:n}):s?await C(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:s.access_token,xform:r=>({data:r,error:null})}):this._returnResult({data:null,error:new Q})})}catch(e){if(A(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async s=>{const{data:{session:n},error:r}=s;return r?this._returnResult({data:null,error:r}):n?(await C(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:n.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new Q})})}catch(s){if(A(s))return this._returnResult({data:null,error:s});throw s}}async fetchJwk(e,s={keys:[]}){let n=s.keys.find(o=>o.kid===e);if(n)return n;const r=Date.now();if(n=this.jwks.keys.find(o=>o.kid===e),n&&this.jwks_cached_at+Vm>r)return n;const{data:i,error:a}=await C(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(a)throw a;return!i.keys||i.keys.length===0||(this.jwks=i,this.jwks_cached_at=r,n=i.keys.find(o=>o.kid===e),!n)?null:n}async getClaims(e,s={}){try{let n=e;if(!n){const{data:f,error:p}=await this.getSession();if(p||!f.session)return this._returnResult({data:null,error:p});n=f.session.access_token}const{header:r,payload:i,signature:a,raw:{header:o,payload:l}}=nn(n);s!=null&&s.allowExpired||cg(i.exp);const c=!r.alg||r.alg.startsWith("HS")||!r.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(r.kid,s!=null&&s.keys?{keys:s.keys}:s==null?void 0:s.jwks);if(!c){const{error:f}=await this.getUser(n);if(f)throw f;return{data:{claims:i,header:r,signature:a},error:null}}const u=ug(r.alg),h=await crypto.subtle.importKey("jwk",c,u,!0,["verify"]);if(!await crypto.subtle.verify(u,h,a,Ym(`${o}.${l}`)))throw new qn("Invalid JWT signature");return{data:{claims:i,header:r,signature:a},error:null}}catch(n){if(A(n))return this._returnResult({data:null,error:n});throw n}}}Bt.nextInstanceID={};const Fg=Bt,Wg="2.88.0";let _t="";typeof Deno<"u"?_t="deno":typeof document<"u"?_t="web":typeof navigator<"u"&&navigator.product==="ReactNative"?_t="react-native":_t="node";const qg={"X-Client-Info":`supabase-js-${_t}/${Wg}`},Hg={headers:qg},Kg={schema:"public"},Gg={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},zg={};function Vt(t){"@babel/helpers - typeof";return Vt=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},Vt(t)}function Jg(t,e){if(Vt(t)!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var n=s.call(t,e||"default");if(Vt(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Yg(t){var e=Jg(t,"string");return Vt(e)=="symbol"?e:e+""}function Xg(t,e,s){return(e=Yg(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function wa(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),s.push.apply(s,n)}return s}function B(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?wa(Object(s),!0).forEach(function(n){Xg(t,n,s[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):wa(Object(s)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(s,n))})}return t}const Zg=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),Qg=()=>Headers,ey=(t,e,s)=>{const n=Zg(s),r=Qg();return async(i,a)=>{var o;const l=(o=await e())!==null&&o!==void 0?o:t;let c=new r(a==null?void 0:a.headers);return c.has("apikey")||c.set("apikey",t),c.has("Authorization")||c.set("Authorization",`Bearer ${l}`),n(i,B(B({},a),{},{headers:c}))}};function ty(t){return t.endsWith("/")?t:t+"/"}function sy(t,e){var s,n;const{db:r,auth:i,realtime:a,global:o}=t,{db:l,auth:c,realtime:u,global:h}=e,d={db:B(B({},l),r),auth:B(B({},c),i),realtime:B(B({},u),a),storage:{},global:B(B(B({},h),o),{},{headers:B(B({},(s=h==null?void 0:h.headers)!==null&&s!==void 0?s:{}),(n=o==null?void 0:o.headers)!==null&&n!==void 0?n:{})}),accessToken:async()=>""};return t.accessToken?d.accessToken=t.accessToken:delete d.accessToken,d}function ny(t){const e=t==null?void 0:t.trim();if(!e)throw new Error("supabaseUrl is required.");if(!e.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(ty(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var ry=class extends Fg{constructor(t){super(t)}},iy=class{constructor(t,e,s){var n,r;this.supabaseUrl=t,this.supabaseKey=e;const i=ny(t);if(!e)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",i),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",i),this.storageUrl=new URL("storage/v1",i),this.functionsUrl=new URL("functions/v1",i);const a=`sb-${i.hostname.split(".")[0]}-auth-token`,o={db:Kg,realtime:zg,auth:B(B({},Gg),{},{storageKey:a}),global:Hg},l=sy(s??{},o);if(this.storageKey=(n=l.auth.storageKey)!==null&&n!==void 0?n:"",this.headers=(r=l.global.headers)!==null&&r!==void 0?r:{},l.accessToken)this.accessToken=l.accessToken,this.auth=new Proxy({},{get:(u,h)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(h)} is not possible`)}});else{var c;this.auth=this._initSupabaseAuthClient((c=l.auth)!==null&&c!==void 0?c:{},this.headers,l.global.fetch)}this.fetch=ey(e,this._getAccessToken.bind(this),l.global.fetch),this.realtime=this._initRealtimeClient(B({headers:this.headers,accessToken:this._getAccessToken.bind(this)},l.realtime)),this.accessToken&&this.accessToken().then(u=>this.realtime.setAuth(u)).catch(u=>console.warn("Failed to set initial Realtime auth token:",u)),this.rest=new Lp(new URL("rest/v1",i).href,{headers:this.headers,schema:l.db.schema,fetch:this.fetch}),this.storage=new Nm(this.storageUrl.href,this.headers,this.fetch,s==null?void 0:s.storage),l.accessToken||this._listenForAuthEvents()}get functions(){return new Dp(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:n}=await t.auth.getSession();return(e=(s=n.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:n,userStorage:r,storageKey:i,flowType:a,lock:o,debug:l,throwOnError:c},u,h){const d={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new ry({url:this.authUrl.href,headers:B(B({},d),u),storageKey:i,autoRefreshToken:t,persistSession:e,detectSessionInUrl:s,storage:n,userStorage:r,flowType:a,lock:o,debug:l,throwOnError:c,fetch:h,hasCustomAuthorizationHeader:Object.keys(this.headers).some(f=>f.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new tm(this.realtimeUrl.href,B(B({},t),{},{params:B(B({},{apikey:this.supabaseKey}),t==null?void 0:t.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,e)=>{this._handleTokenChanged(t,"CLIENT",e==null?void 0: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 ay=(t,e,s)=>new iy(t,e,s);function oy(){if(typeof window<"u"||typeof process>"u")return!1;const t=process.version;if(t==null)return!1;const e=t.match(/^v(\d+)\./);return e?parseInt(e[1],10)<=18:!1}oy()&&console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");const ly="https://woqsriglllgyushlflxh.supabase.co",cy="sb_publishable_HDPOzEpyVotVL_y52W_6XA_lmgomhSu",uy=ay(ly,cy,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),Se="#F2506A",ge="#B67AEC",ba="#27BBE9",hy={hidden:{opacity:0,y:20,scale:.95,transformOrigin:"bottom right"},visible:{opacity:1,y:0,scale:1,transition:{type:"spring",damping:25,stiffness:300}},exit:{opacity:0,y:20,scale:.95,transition:{duration:.18}}},xa={hidden:{opacity:0,y:8},visible:{opacity:1,y:0,transition:{type:"spring",stiffness:500,damping:30}}};function dy(){return m.jsxs("div",{className:"flex gap-3",children:[m.jsx(Et,{className:"h-7 w-7 flex-shrink-0",children:m.jsx(Pt,{style:{background:`linear-gradient(135deg, ${Se}, ${ge})`},children:m.jsx("img",{src:ht,alt:"CP",className:"h-4 w-4 object-contain"})})}),m.jsx("div",{className:"rounded-2xl rounded-tl-none bg-white/10 border border-white/10 px-4 py-3 flex items-center gap-1",children:["-0.3s","-0.15s","0s"].map((t,e)=>m.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-white/50 animate-bounce",style:{animationDelay:t}},e))})]})}const fy=/(https?:\/\/[^\s]+|[\w.+-]+@[\w-]+\.[a-z]{2,}|(?:(?:\+61|0)[0-9][\s0-9]{7,10}))/gi;function py(t){return t.split(fy).map((s,n)=>{if(/^https?:\/\//i.test(s)){const r=s.replace(/^https?:\/\/(www\.)?/,"").replace(/\/$/,"");return m.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2 opacity-80 hover:opacity-100 break-all",children:r},n)}return/^[\w.+-]+@[\w-]+\.[a-z]{2,}$/i.test(s)?m.jsx("a",{href:`mailto:${s}`,className:"underline underline-offset-2 opacity-80 hover:opacity-100",children:s},n):/^(?:\+61|0)[0-9][\s0-9]{7,10}$/.test(s.trim())?m.jsx("a",{href:`tel:${s.replace(/\s/g,"")}`,className:"underline underline-offset-2 opacity-80 hover:opacity-100",children:s},n):s})}function my(){const t=Kn(),e=_.useRef(!1),[s,n]=_.useState(!1),[r,i]=_.useState([]),[a,o]=_.useState(""),[l,c]=_.useState(!1),[u,h]=_.useState(null),d=_.useRef(null),f=_.useRef(null);_.useEffect(()=>{d.current&&(d.current.scrollTop=d.current.scrollHeight)},[r,l]),_.useEffect(()=>{s&&setTimeout(()=>{var g;return(g=f.current)==null?void 0:g.focus()},300)},[s]);const p=_.useCallback(()=>{n(g=>{const b=!g;return b&&!e.current&&(e.current=!0,t==null||t.capture("chat_widget_opened")),b})},[t]),y=async g=>{g.preventDefault();const b=a.trim();if(!b||l)return;const w={role:"user",content:b},v=[...r,w];i(v),o(""),c(!0),h(null);try{const{data:x,error:S}=await uy.functions.invoke("chat-bot",{body:{messages:v}});if(S)throw console.error("[chat-bot] function error:",S),S;if(!(x!=null&&x.reply))throw console.error("[chat-bot] unexpected response:",x),new Error("No reply in response");i(k=>[...k,{role:"assistant",content:x.reply}])}catch(x){console.error("[chat-bot] catch:",x),h("Sorry, I couldn't connect right now. Please call us on 03 9081 4270.")}finally{c(!1)}};return m.jsxs("div",{className:"fixed bottom-6 right-6 z-50 flex flex-col items-end gap-4",children:[m.jsx(Rn,{children:s&&m.jsxs(Ce.div,{variants:hy,initial:"hidden",animate:"visible",exit:"exit",className:"w-[360px] sm:w-[400px] overflow-hidden rounded-2xl shadow-2xl",style:{background:"rgba(26,26,46,0.96)",border:"1px solid rgba(255,255,255,0.10)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)"},children:[m.jsxs("div",{className:"relative p-4 flex items-center justify-between overflow-hidden",style:{borderBottom:"1px solid rgba(255,255,255,0.08)"},children:[m.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-[4px]",style:{background:`linear-gradient(to bottom, ${Se}, ${ge}, ${ba})`}}),m.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{background:"radial-gradient(ellipse at 30% 50%, rgba(242,80,106,0.08) 0%, transparent 60%)"}}),m.jsxs("div",{className:"flex items-center gap-3 pl-3 relative z-10",children:[m.jsxs("div",{className:"relative",children:[m.jsx("div",{className:"h-10 w-10 rounded-xl flex items-center justify-center overflow-hidden",style:{background:`linear-gradient(135deg, ${Se}, ${ge})`},children:m.jsx("img",{src:ht,alt:"CP",className:"h-7 w-7 object-contain"})}),m.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full bg-emerald-500 border-2 border-[#1A1A2E]"})]}),m.jsxs("div",{children:[m.jsx("p",{className:"text-sm font-semibold text-white leading-tight",children:"Contemporary Psychology"}),m.jsx("p",{className:"text-[11px] text-white/50",children:"Ask me anything about our services"})]})]}),m.jsx(Dn,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full relative z-10 hover:bg-white/10 text-white/60 hover:text-white",onClick:()=>n(!1),children:m.jsx(hs,{className:"h-4 w-4"})})]}),m.jsxs("div",{ref:d,className:"flex flex-col gap-4 overflow-y-auto p-4",style:{height:340},children:[m.jsxs(Ce.div,{variants:xa,initial:"hidden",animate:"visible",className:"flex gap-3",children:[m.jsx(Et,{className:"h-7 w-7 flex-shrink-0",children:m.jsx(Pt,{style:{background:`linear-gradient(135deg, ${Se}, ${ge})`},children:m.jsx("img",{src:ht,alt:"CP",className:"h-4 w-4 object-contain"})})}),m.jsxs("div",{className:"flex flex-col gap-1 max-w-[85%]",children:[m.jsx("span",{className:"text-[11px] font-medium text-white/40",children:"CP Assistant"}),m.jsx("div",{className:"rounded-2xl rounded-tl-none px-4 py-2.5 text-sm text-white/90 leading-relaxed",style:{background:"rgba(255,255,255,0.07)",border:"1px solid rgba(255,255,255,0.08)"},children:"Hi! I'm here to help with questions about our services, fees, team, and how to get started. What can I help you with?"})]})]}),r.map((g,b)=>m.jsxs(Ce.div,{variants:xa,initial:"hidden",animate:"visible",className:Ge("flex gap-3",g.role==="user"&&"flex-row-reverse"),children:[g.role==="assistant"?m.jsx(Et,{className:"h-7 w-7 flex-shrink-0",children:m.jsx(Pt,{style:{background:`linear-gradient(135deg, ${Se}, ${ge})`},children:m.jsx("img",{src:ht,alt:"CP",className:"h-4 w-4 object-contain"})})}):m.jsx(Et,{className:"h-7 w-7 flex-shrink-0",children:m.jsx(Pt,{style:{background:`linear-gradient(135deg, ${ba}, ${ge})`},children:m.jsx("span",{className:"text-[10px] font-bold text-white",children:"You"})})}),m.jsxs("div",{className:Ge("flex flex-col gap-1 max-w-[85%]",g.role==="user"&&"items-end"),children:[g.role==="assistant"&&m.jsx("span",{className:"text-[11px] font-medium text-white/40",children:"CP Assistant"}),m.jsx("div",{className:Ge("px-4 py-2.5 text-sm leading-relaxed break-words",g.role==="assistant"?"rounded-2xl rounded-tl-none text-white/90":"rounded-2xl rounded-tr-none text-white"),style:g.role==="assistant"?{background:"rgba(255,255,255,0.07)",border:"1px solid rgba(255,255,255,0.08)",whiteSpace:"pre-wrap"}:{background:`linear-gradient(135deg, ${Se}, ${ge})`,whiteSpace:"pre-wrap"},children:py(g.content)})]})]},b)),l&&m.jsx(dy,{}),u&&m.jsx("div",{className:"text-xs text-red-400/80 text-center px-4",children:u})]}),m.jsxs("form",{onSubmit:y,className:"flex items-center gap-2 p-3",style:{borderTop:"1px solid rgba(255,255,255,0.08)",background:"rgba(255,255,255,0.03)"},children:[m.jsx("input",{ref:f,type:"text",value:a,onChange:g=>o(g.target.value),placeholder:"Ask about services, fees, booking…",disabled:l,className:"flex-1 rounded-full px-4 py-2.5 text-sm text-white placeholder:text-white/30 outline-none transition-all disabled:opacity-50",style:{background:"rgba(255,255,255,0.06)",border:"1px solid rgba(255,255,255,0.10)"},onFocus:g=>g.currentTarget.style.borderColor="rgba(242,80,106,0.5)",onBlur:g=>g.currentTarget.style.borderColor="rgba(255,255,255,0.10)"}),m.jsx(Dn,{type:"submit",size:"icon",disabled:!a.trim()||l,className:"h-10 w-10 rounded-full flex-shrink-0 disabled:opacity-40 transition-transform hover:scale-105",style:{background:`linear-gradient(135deg, ${Se}, ${ge})`},children:m.jsx(tc,{className:"h-4 w-4 text-white"})})]}),m.jsxs("p",{className:"text-center text-[10px] text-white/20 pb-2.5 px-4",children:["Not medical advice · For clinical support, please"," ",m.jsx("a",{href:"tel:0390814270",className:"underline hover:text-white/40 transition-colors",children:"call us"})]})]},"chat-window")}),m.jsxs(Ce.button,{whileHover:{scale:1.06},whileTap:{scale:.94},onClick:p,className:"relative group flex h-14 w-14 items-center justify-center rounded-full shadow-2xl cursor-pointer transition-all duration-300",style:{background:s?"#6B7280":`linear-gradient(135deg, ${Se}, ${ge})`},"aria-label":s?"Close chat":"Open chat",children:[m.jsx("span",{className:"absolute inset-0 -z-10 rounded-full opacity-30 blur-xl transition-opacity group-hover:opacity-50",style:{background:`linear-gradient(135deg, ${Se}, ${ge})`}}),m.jsx(Rn,{mode:"wait",children:s?m.jsx(Ce.span,{initial:{rotate:-90,opacity:0},animate:{rotate:0,opacity:1},exit:{rotate:90,opacity:0},transition:{duration:.18},children:m.jsx(hs,{className:"h-6 w-6 text-white"})},"close"):m.jsx(Ce.span,{initial:{rotate:90,opacity:0},animate:{rotate:0,opacity:1},exit:{rotate:-90,opacity:0},transition:{duration:.18},children:m.jsx(ec,{className:"h-6 w-6 text-white"})},"open")})]})]})}const Hn="/book-online",gy="https://clientportal.zandahealth.com/clientportal/contemporarypsychology",Ae="03 9081 4270",ss="reception@contemporarypsychology.com.au",yy="G06-G07/22 St Kilda Road, St Kilda VIC 3182",_a=[{label:"LinkedIn",href:"https://www.linkedin.com/company/contemporary-psychology/posts/?feedView=all",icon:m.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"h-4 w-4","aria-hidden":"true",children:m.jsx("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 0 1-2.063-2.065 2.064 2.064 0 1 1 2.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"})})},{label:"Instagram",href:"https://www.instagram.com/contemporarypsychology/",icon:m.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"h-4 w-4","aria-hidden":"true",children:m.jsx("path",{d:"M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zm0-2.163c-3.259 0-3.667.014-4.947.072-4.358.2-6.78 2.618-6.98 6.98-.059 1.281-.073 1.689-.073 4.948 0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98 1.281.058 1.689.072 4.948.072 3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98-1.281-.059-1.69-.073-4.949-.073zm0 5.838a6.162 6.162 0 1 0 0 12.324 6.162 6.162 0 0 0 0-12.324zM12 16a4 4 0 1 1 0-8 4 4 0 0 1 0 8zm6.406-11.845a1.44 1.44 0 1 0 0 2.881 1.44 1.44 0 0 0 0-2.881z"})})},{label:"Facebook",href:"https://www.facebook.com/contemporarypsychology.com.au",icon:m.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"h-4 w-4","aria-hidden":"true",children:m.jsx("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})})}],Sa=[{label:"About Us",href:"/about-us",children:[{label:"Meet the Team",href:"/our-team"},{label:"Join Our Team",href:"/our-team/join-our-team"}]},{label:"What We Help With",href:"/what-we-help-with",wide:!0,children:[{label:"ADHD & Impulsivity",href:"/what-we-help-with/adhd"},{label:"Addictions",href:"/what-we-help-with/addictions"},{label:"Anxiety Disorders",href:"/what-we-help-with/anxiety-disorders"},{label:"Attachment & Relationships",href:"/what-we-help-with/attachment-relationships"},{label:"Autism",href:"/what-we-help-with/autism"},{label:"Depression",href:"/what-we-help-with/depression"},{label:"Disordered Eating & Body Image",href:"/what-we-help-with/disordered-eating-body-image"},{label:"LGBTIQA+ Counselling",href:"/what-we-help-with/lgbtiqa-counselling"},{label:"PMDD, PCOS & Menopause",href:"/what-we-help-with/pmdd-pcos-menopause"},{label:"Postnatal Depression & Anxiety",href:"/what-we-help-with/postnatal-depression-and-anxiety"},{label:"Sleep Disturbance",href:"/what-we-help-with/sleep-disturbance"},{label:"Trauma & Acute Stress",href:"/what-we-help-with/trauma-and-acute-stress"},{label:"Work Issues & Burnout",href:"/what-we-help-with/work-issues-burnout"}]},{label:"Services",href:"/services",children:[{label:"Psychological Counselling",href:"/services/psychology"},{label:"Online Counselling",href:"/services/online-counselling"},{label:"Mental Health Assessment",href:"/services/mental-health-assessment"},{label:"ADHD Assessment & Coaching",href:"/services/adhd-assessment-and-coaching-program"},{label:"ASD Assessments",href:"/services/asd-assessments"},{label:"Autism Support & Growth Program",href:"/services/autism-support-program"},{label:"Adolescent Psychology",href:"/services/adolescent-psychology"},{label:"Couples Counselling",href:"/services/couples-counselling"},{label:"WorkCover & TAC",href:"/services/workcover-tac"},{label:"For GPs & Referrers",href:"/for-gps"}]},{label:"Pricing & Rebates",href:"/pricing-rebates"},{label:"Contact",href:"/contact"},{label:"More",href:"#",children:[{label:"Blog",href:"/blog"},{label:"FAQ",href:"/faq"},{label:"Resources",href:"/resources"},{label:"For GPs",href:"/for-gps"}]}],vy=[{label:"ADHD Assessment & Coaching",href:"/services/adhd-assessment-and-coaching-program"},{label:"ASD Assessments",href:"/services/asd-assessments"},{label:"Individual Therapy",href:"/services/psychology"},{label:"Couples Counselling",href:"/services/couples-counselling"},{label:"WorkCover & TAC",href:"/services/workcover-tac"}],wy=[{label:"About Us",href:"/about-us"},{label:"Our Team",href:"/our-team"},{label:"Join Our Team",href:"/our-team/join-our-team"},{label:"Resources",href:"/resources"},{label:"Blog",href:"/blog"},{label:"FAQ",href:"/faq"}],by=[{label:"Book Online",href:Hn},{label:"Pricing & Rebates",href:"/pricing-rebates"},{label:"For GPs & Referring Practitioners",href:"/for-gps"},{label:"Contact Us",href:"/contact"},{label:"Privacy Policy",href:"/privacy-policy"}],xy=[[5,28],[12,18],[8,42],[18,32],[15,50],[22,24],[25,42],[10,60],[20,65],[28,55],[35,35],[40,50],[45,28],[42,65],[48,42],[50,20],[55,58],[62,30],[68,20],[72,42],[65,52],[75,35],[80,52],[78,22],[85,40],[88,28],[90,52],[82,62],[5,75],[15,80],[28,80],[38,75],[50,80],[62,75],[75,78],[88,70],[95,46],[95,22],[5,10],[20,8],[40,10],[60,10],[80,8],[93,12]],Bl=1400,Vl=600,ce=xy.map(([t,e])=>[t/100*Bl,e/100*Vl]),_y=(()=>{const e=[];for(let s=0;s<ce.length;s++)for(let n=s+1;n<ce.length;n++){const r=ce[s][0]-ce[n][0],i=ce[s][1]-ce[n][1];r*r+i*i<21025&&e.push([ce[s][0],ce[s][1],ce[n][0],ce[n][1]])}return e})();function Sy(){return m.jsxs("svg",{"aria-hidden":"true",className:"absolute inset-0 w-full h-full pointer-events-none select-none",viewBox:`0 0 ${Bl} ${Vl}`,preserveAspectRatio:"xMidYMid slice",xmlns:"http://www.w3.org/2000/svg",children:[_y.map(([t,e,s,n],r)=>m.jsx("line",{x1:t,y1:e,x2:s,y2:n,stroke:"#1a7aad",strokeWidth:"0.9",opacity:"0.18"},r)),ce.map(([t,e],s)=>m.jsx("circle",{cx:t,cy:e,r:s%6===0?4:2.2,fill:"#1a7aad",opacity:s%6===0?.38:.25},s))]})}function Dy({children:t}){const[e,s]=_.useState(!1),[n,r]=_.useState(null),[i,a]=_.useState(null),o=_.useRef(null),l=ql(),c=Kn();function u(f){c==null||c.capture("phone_number_clicked",{placement:f})}const h=f=>{o.current&&clearTimeout(o.current),r(f)},d=()=>{o.current=setTimeout(()=>r(null),120)};return m.jsxs("div",{className:"min-h-screen flex flex-col font-poppins bg-[#FAFAF8] text-[#3D3D5C]",children:[m.jsx("div",{className:"bg-[#b2defd] text-[#071B27] text-xs py-2.5 px-4",children:m.jsxs("div",{className:"max-w-7xl mx-auto flex flex-col sm:flex-row items-center justify-between gap-1.5",children:[m.jsx("span",{className:"text-[#071B27]/70 text-center sm:text-left",children:"Celebrating 11 Years of Clinical Practice in Melbourne"}),m.jsxs("div",{className:"flex items-center gap-4 text-[#071B27]/80",children:[m.jsxs("a",{href:`tel:${Ae.replace(/\s/g,"")}`,onClick:()=>u("meta-bar"),className:"hover:text-[#071B27] transition-colors flex items-center gap-1.5",children:[m.jsx(Kt,{className:"h-3 w-3"}),Ae]}),m.jsx("span",{className:"hidden sm:block text-[#071B27]/30",children:"·"}),m.jsxs("a",{href:`mailto:${ss}`,className:"hover:text-[#071B27] transition-colors hidden sm:flex items-center gap-1.5",children:[m.jsx(Cr,{className:"h-3 w-3"}),ss]}),m.jsx("span",{className:"hidden sm:block text-[#071B27]/30",children:"·"}),m.jsx("div",{className:"hidden sm:flex items-center gap-2.5",children:_a.map(f=>m.jsx("a",{href:f.href,target:"_blank",rel:"noopener noreferrer","aria-label":`Follow us on ${f.label}`,className:"text-[#071B27]/50 hover:text-[#071B27] transition-colors",children:f.icon},f.label))})]})]})}),m.jsxs("header",{className:"sticky top-0 z-50 bg-white/97 backdrop-blur-md border-b border-[#E2DCEF] shadow-sm",children:[m.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:m.jsxs("div",{className:"flex items-center justify-between h-16",children:[m.jsxs(ne,{to:"/",className:"flex items-center gap-3 flex-shrink-0",children:[m.jsx("img",{src:ht,alt:"Contemporary Psychology",className:"h-10 w-auto"}),m.jsxs("span",{className:"hidden sm:block font-bold text-[#1A1A2E] text-sm leading-tight font-lora",children:["Contemporary",m.jsx("br",{}),"Psychology"]})]}),m.jsx("nav",{className:"hidden lg:flex items-center gap-0.5",children:Sa.map(f=>m.jsxs("div",{className:"relative",onMouseEnter:()=>f.children&&h(f.label),onMouseLeave:()=>f.children&&d(),children:[m.jsxs(ne,{to:f.href,className:`flex items-center gap-1 px-3.5 py-2 rounded-md text-sm font-medium transition-colors font-poppins ${l.pathname.startsWith(f.href)&&f.href!=="/"?"text-[#F2506A] bg-[#FDF0F4]":"text-[#3D3D5C] hover:text-[#1A1A2E] hover:bg-[#F8F7FD]"}`,children:[f.label,f.children&&m.jsx(Pr,{className:`h-3.5 w-3.5 transition-transform duration-200 ${n===f.label?"rotate-180":""}`})]}),f.children&&m.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 pt-1 z-50",style:{visibility:n===f.label?"visible":"hidden",pointerEvents:n===f.label?"auto":"none"},children:m.jsx("div",{className:`bg-white border border-[#E2DCEF] rounded-xl shadow-lg py-1.5 ${f.wide?"w-[min(580px,calc(100vw-2rem))] grid grid-cols-2":"min-w-[200px]"}`,children:f.children.map(p=>m.jsx(ne,{to:p.href,onClick:()=>r(null),className:`block px-4 py-2 text-sm font-poppins text-left transition-colors whitespace-nowrap ${l.pathname===p.href?"text-[#F2506A] bg-[#FDF0F4]":"text-[#3D3D5C] hover:text-[#1A1A2E] hover:bg-[#F8F7FD]"}`,children:p.label},p.label))})})]},f.label))}),m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx(dp,{}),m.jsx("a",{href:gy,target:"_blank",rel:"noopener noreferrer",className:"hidden md:inline-flex items-center rounded-full text-sm font-semibold px-4 py-2 border border-cp-rule text-[#3D3D5C] hover:border-brand-pink hover:text-brand-pink transition-colors font-poppins",children:"Client Login"}),m.jsx(ne,{to:Hn,className:"hidden md:inline-flex items-center rounded-full text-white text-sm font-semibold px-5 py-2 transition-opacity hover:opacity-90 cp-gradient-bg",children:"Book Online"}),m.jsx("button",{className:"lg:hidden p-2 rounded-md text-[#3D3D5C] hover:text-[#1A1A2E] hover:bg-[#F8F7FD] transition-colors",onClick:()=>s(!e),"aria-label":"Toggle menu",children:e?m.jsx(hs,{className:"h-5 w-5"}):m.jsx(Ql,{className:"h-5 w-5"})})]})]})}),e&&m.jsxs("div",{className:"lg:hidden border-t border-[#E2DCEF] bg-white px-4 py-3 space-y-1",children:[Sa.map(f=>m.jsx("div",{children:f.children?m.jsxs(m.Fragment,{children:[m.jsxs("button",{onClick:()=>a(i===f.label?null:f.label),className:"w-full flex items-center justify-between px-3 py-2.5 rounded-md text-sm font-medium text-[#3D3D5C] hover:text-[#1A1A2E] hover:bg-[#F8F7FD] transition-colors",children:[f.label,m.jsx(Pr,{className:`h-4 w-4 transition-transform duration-200 ${i===f.label?"rotate-180":""}`})]}),i===f.label&&m.jsxs("div",{className:"ml-3 border-l border-[#E2DCEF] pl-3 space-y-1 mt-1 mb-1",children:[m.jsx(ne,{to:f.href,onClick:()=>{s(!1),a(null)},className:"block px-3 py-2 rounded-md text-sm text-[#3D3D5C] hover:text-[#1A1A2E] hover:bg-[#F8F7FD] transition-colors",children:"Overview"}),f.children.map(p=>m.jsx(ne,{to:p.href,onClick:()=>{s(!1),a(null)},className:"block px-3 py-2 rounded-md text-sm text-[#3D3D5C] hover:text-[#1A1A2E] hover:bg-[#F8F7FD] transition-colors",children:p.label},p.label))]})]}):m.jsx(ne,{to:f.href,onClick:()=>s(!1),className:"block px-3 py-2.5 rounded-md text-sm font-medium text-[#3D3D5C] hover:text-[#1A1A2E] hover:bg-[#F8F7FD] transition-colors",children:f.label})},f.label)),m.jsxs("div",{className:"pt-3 border-t border-[#E2DCEF] flex flex-col gap-2",children:[m.jsxs("a",{href:`tel:${Ae.replace(/\s/g,"")}`,onClick:()=>{u("mobile-nav"),s(!1)},className:"flex items-center justify-center gap-2 rounded-full text-white text-sm font-semibold px-5 py-2.5 cp-gradient-bg",children:[m.jsx(Kt,{className:"h-4 w-4"}),"Call ",Ae]}),m.jsx(ne,{to:Hn,onClick:()=>s(!1),className:"block text-center rounded-full text-sm font-semibold px-5 py-2.5 border-2 border-[#1A1A2E] text-[#1A1A2E]",children:"Book Online"})]})]})]}),m.jsx("main",{className:"flex-1",children:t}),m.jsx(my,{}),m.jsxs("footer",{className:"text-[#071B27]/70",style:{backgroundColor:"#b2defd"},children:[m.jsx("div",{className:"h-[3px] w-full",style:{background:"linear-gradient(to right, #F2506A, #B67AEC, #27BBE9)"}}),m.jsx("div",{className:"border-b border-[#071B27]/10 bg-[#071B27]/05",children:m.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-5 flex flex-col sm:flex-row items-center justify-between gap-4",children:[m.jsxs("div",{children:[m.jsx("p",{className:"font-lora font-bold text-[#071B27] text-base",children:"The easiest way to book is to call us."}),m.jsx("p",{className:"text-xs text-[#071B27]/60 font-poppins mt-0.5",children:"Our admin team will match you with the right psychologist and get you booked in."})]}),m.jsxs("a",{href:`tel:${Ae.replace(/\s/g,"")}`,onClick:()=>u("footer-cta-strip"),className:"flex-shrink-0 inline-flex items-center gap-2 rounded-full text-white font-semibold font-poppins px-6 py-2.5 text-sm transition-opacity hover:opacity-90 cp-gradient-bg",children:[m.jsx(Kt,{className:"h-4 w-4"}),Ae]})]})}),m.jsxs("div",{className:"relative overflow-hidden",children:[m.jsx(Sy,{}),m.jsxs("div",{className:"relative z-10 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-14",children:[m.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-5 gap-10",children:[m.jsxs("div",{className:"md:col-span-3 lg:col-span-2 space-y-4",children:[m.jsx("img",{src:ht,alt:"Contemporary Psychology",className:"h-10 w-auto brightness-0 opacity-70"}),m.jsx("p",{className:"text-[#071B27] font-semibold text-sm leading-snug font-lora italic",children:"Leading Psychologists. Grounded in Neuroscience. Built for Your Story."}),m.jsx("p",{className:"text-xs text-[#071B27]/60 leading-relaxed",children:"Evidence-based psychological support for individuals, couples, and families across Melbourne."}),m.jsxs("div",{className:"space-y-2 text-xs",children:[m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx(Zl,{className:"h-3.5 w-3.5 mt-0.5 text-[#F2506A] flex-shrink-0"}),m.jsx("a",{href:"https://maps.google.com/?q=G06-G07/22+St+Kilda+Road+St+Kilda+VIC+3182",target:"_blank",rel:"noopener noreferrer",className:"hover:text-[#071B27] transition-colors",children:yy})]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(Kt,{className:"h-3.5 w-3.5 text-[#F2506A] flex-shrink-0"}),m.jsx("a",{href:`tel:${Ae.replace(/\s/g,"")}`,onClick:()=>u("footer"),className:"hover:text-[#071B27] transition-colors",children:Ae})]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(Cr,{className:"h-3.5 w-3.5 text-[#F2506A] flex-shrink-0"}),m.jsx("a",{href:`mailto:${ss}`,className:"hover:text-[#071B27] transition-colors text-xs whitespace-nowrap",children:ss})]})]}),m.jsx("div",{className:"flex items-center gap-3 pt-1",children:_a.map(f=>m.jsx("a",{href:f.href,target:"_blank",rel:"noopener noreferrer","aria-label":`Follow us on ${f.label}`,className:"w-8 h-8 rounded-full bg-[#071B27]/10 hover:bg-[#F2506A] flex items-center justify-center text-[#071B27]/60 hover:text-white transition-all duration-200",children:f.icon},f.label))})]}),m.jsxs("div",{className:"space-y-3",children:[m.jsx("h3",{className:"text-[#071B27] font-semibold text-xs uppercase tracking-widest",children:"About"}),m.jsx("ul",{className:"space-y-2",children:wy.map(f=>m.jsx("li",{children:m.jsx(ne,{to:f.href,className:"text-sm text-[#071B27]/65 hover:text-[#071B27] transition-colors",children:f.label})},f.label))})]}),m.jsxs("div",{className:"space-y-3",children:[m.jsx("h3",{className:"text-[#071B27] font-semibold text-xs uppercase tracking-widest",children:"Services"}),m.jsx("ul",{className:"space-y-2",children:vy.map(f=>m.jsx("li",{children:m.jsx(ne,{to:f.href,className:"text-sm text-[#071B27]/65 hover:text-[#071B27] transition-colors",children:f.label})},f.label))})]}),m.jsxs("div",{className:"space-y-3 flex flex-col",children:[m.jsx("h3",{className:"text-[#071B27] font-semibold text-xs uppercase tracking-widest",children:"Support"}),m.jsx("ul",{className:"space-y-2",children:by.map(f=>m.jsx("li",{children:f.external?m.jsx("a",{href:f.href,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#071B27]/65 hover:text-[#071B27] transition-colors",children:f.label}):m.jsx(ne,{to:f.href,className:"text-sm text-[#071B27]/65 hover:text-[#071B27] transition-colors",children:f.label})},f.label))}),m.jsx("div",{className:"mt-auto pt-6",children:m.jsx("a",{href:"https://www.psychologytoday.com/profile/918210",target:"_blank",rel:"noopener noreferrer",children:m.jsx("img",{src:"/images/psychtoday.png",alt:"Contemporary Psychology on Psychology Today",className:"h-14 w-auto"})})})]})]}),m.jsxs("div",{className:"border-t border-[#071B27]/15 mt-12 pt-6",children:[m.jsx("p",{className:"text-xs text-[#071B27]/50 leading-relaxed max-w-3xl mb-4",children:"All psychological services are provided by AHPRA-registered psychologists. Medicare rebates are available for eligible clients with a valid Mental Health Treatment Plan or equivalent referral."}),m.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-3 text-xs text-[#071B27]/40",children:[m.jsxs("p",{children:["© ",new Date().getFullYear()," Contemporary Psychology · All rights reserved."]}),m.jsx(ne,{to:"/privacy-policy",className:"hover:text-[#071B27]/60 transition-colors",children:"Privacy Policy"})]})]})]})]})]})]})}export{Dn as B,Pr as C,Xl as F,Zl as M,Dy as P,tc as S,sc as U,Yi as _,Kt as a,ec as b,Cr as c,Rs as d,Oy as e,Jl as f,Rr as g,rp as h,Yl as i,Ce as m,uy as s,sp as t};