const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-w-119-DEalYQv-.js","assets/content-rendering-8LECY7UC.js","assets/vendor-d-100-DUwYIYiB.js","assets/react-core-lkHtAB4F.js","assets/vendor-b-98-FqpXQuLt.js","assets/vendor-e-101-D7dDjsNb.js","assets/vendor-i-105-DLPNJOh-.js","assets/vendor-t-116-CEUFdAEd.js","assets/vendor-v-118-B42bNtZ1.js","assets/vendor-u-117-DC4Cwaa0.js","assets/vendor-m-109-Du2052Hq.js","assets/vendor-misc-bJru-SXh.js","assets/monitoring-ujEZdQJ7.js","assets/vendor-c-99-Gw4UEZta.js","assets/utilities-DzfkJJIA.js","assets/vendor-l-108-biR2a0RG.js","assets/vendor-h-104-DCFH7znV.js","assets/vendor-p-112-kISQk9cd.js","assets/vendor-s-115-HsCUIFCF.js","assets/vendor-k-107-l3izQsJJ.js","assets/vendor-z-122-C2o2j-tx.js"])))=>i.map(i=>d[i]); import{a as nr,c as I}from"./content-rendering-8LECY7UC.js";import{X as ir,q as ar,_ as q}from"./vendor-misc-bJru-SXh.js";import{r as k,R as h}from"./react-core-lkHtAB4F.js";const or="modulepreload",lr=function(s){return"/"+s},ut={},he=function(e,t,r){let n=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=a?.nonce||a?.getAttribute("nonce");n=Promise.allSettled(t.map(l=>{if(l=lr(l),l in ut)return;ut[l]=!0;const u=l.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${c}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":or,u||(d.as="script"),d.crossOrigin="",d.href=l,o&&d.setAttribute("nonce",o),document.head.appendChild(d),u)return new Promise((f,p)=>{d.addEventListener("load",f),d.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${l}`)))})}))}function i(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return n.then(a=>{for(const o of a||[])o.status==="rejected"&&i(o.reason);return e().catch(i)})},cr=s=>{let e;return s?e=s:typeof fetch>"u"?e=(...t)=>he(async()=>{const{default:r}=await Promise.resolve().then(()=>fe);return{default:r}},void 0).then(({default:r})=>r(...t)):e=fetch,(...t)=>e(...t)};class et extends Error{constructor(e,t="FunctionsError",r){super(e),this.name=t,this.context=r}}class ur extends et{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class hr extends et{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class dr extends et{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var Ve;(function(s){s.Any="any",s.ApNortheast1="ap-northeast-1",s.ApNortheast2="ap-northeast-2",s.ApSouth1="ap-south-1",s.ApSoutheast1="ap-southeast-1",s.ApSoutheast2="ap-southeast-2",s.CaCentral1="ca-central-1",s.EuCentral1="eu-central-1",s.EuWest1="eu-west-1",s.EuWest2="eu-west-2",s.EuWest3="eu-west-3",s.SaEast1="sa-east-1",s.UsEast1="us-east-1",s.UsWest1="us-west-1",s.UsWest2="us-west-2"})(Ve||(Ve={}));var fr=function(s,e,t,r){function n(i){return i instanceof t?i:new t(function(a){a(i)})}return new(t||(t=Promise))(function(i,a){function o(c){try{u(r.next(c))}catch(d){a(d)}}function l(c){try{u(r.throw(c))}catch(d){a(d)}}function u(c){c.done?i(c.value):n(c.value).then(o,l)}u((r=r.apply(s,e||[])).next())})};class pr{constructor(e,{headers:t={},customFetch:r,region:n=Ve.Any}={}){this.url=e,this.headers=t,this.region=n,this.fetch=cr(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,t={}){var r;return fr(this,void 0,void 0,function*(){try{const{headers:n,method:i,body:a}=t;let o={},{region:l}=t;l||(l=this.region),l&&l!=="any"&&(o["x-region"]=l);let u;a&&(n&&!Object.prototype.hasOwnProperty.call(n,"Content-Type")||!n)&&(typeof Blob<"u"&&a instanceof Blob||a instanceof ArrayBuffer?(o["Content-Type"]="application/octet-stream",u=a):typeof a=="string"?(o["Content-Type"]="text/plain",u=a):typeof FormData<"u"&&a instanceof FormData?u=a:(o["Content-Type"]="application/json",u=JSON.stringify(a)));const c=yield this.fetch(`${this.url}/${e}`,{method:i||"POST",headers:Object.assign(Object.assign(Object.assign({},o),this.headers),n),body:u}).catch(v=>{throw new ur(v)}),d=c.headers.get("x-relay-error");if(d&&d==="true")throw new hr(c);if(!c.ok)throw new dr(c);let f=((r=c.headers.get("Content-Type"))!==null&&r!==void 0?r:"text/plain").split(";")[0].trim(),p;return f==="application/json"?p=yield c.json():f==="application/octet-stream"?p=yield c.blob():f==="text/event-stream"?p=c:f==="multipart/form-data"?p=yield c.formData():p=yield c.text(),{data:p,error:null}}catch(n){return{data:null,error:n}}})}}var j={},tt={},Oe={},ke={},je={},Re={},gr=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")},de=gr();const vr=de.fetch,Tt=de.fetch.bind(de),xt=de.Headers,mr=de.Request,_r=de.Response,fe=Object.freeze(Object.defineProperty({__proto__:null,Headers:xt,Request:mr,Response:_r,default:Tt,fetch:vr},Symbol.toStringTag,{value:"Module"})),wr=nr(fe);var Le={};Object.defineProperty(Le,"__esModule",{value:!0});let yr=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};Le.default=yr;var Pt=I&&I.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Re,"__esModule",{value:!0});const br=Pt(wr),kr=Pt(Le);let Er=class{constructor(e){this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=e.headers,this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=e.shouldThrowOnError,this.signal=e.signal,this.isMaybeSingle=e.isMaybeSingle,e.fetch?this.fetch=e.fetch:typeof fetch>"u"?this.fetch=br.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=Object.assign({},this.headers),this.headers[e]=t,this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),this.method!=="GET"&&this.method!=="HEAD"&&(this.headers["Content-Type"]="application/json");const r=this.fetch;let n=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{var a,o,l;let u=null,c=null,d=null,f=i.status,p=i.statusText;if(i.ok){if(this.method!=="HEAD"){const y=await i.text();y===""||(this.headers.Accept==="text/csv"||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?c=y:c=JSON.parse(y))}const m=(a=this.headers.Prefer)===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),g=(o=i.headers.get("content-range"))===null||o===void 0?void 0:o.split("/");m&&g&&g.length>1&&(d=parseInt(g[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(c)&&(c.length>1?(u={code:"PGRST116",details:`Results contain ${c.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},c=null,d=null,f=406,p="Not Acceptable"):c.length===1?c=c[0]:c=null)}else{const m=await i.text();try{u=JSON.parse(m),Array.isArray(u)&&i.status===404&&(c=[],u=null,f=200,p="OK")}catch{i.status===404&&m===""?(f=204,p="No Content"):u={message:m}}if(u&&this.isMaybeSingle&&(!((l=u?.details)===null||l===void 0)&&l.includes("0 rows"))&&(u=null,f=200,p="OK"),u&&this.shouldThrowOnError)throw new kr.default(u)}return{error:u,data:c,count:d,status:f,statusText:p}});return this.shouldThrowOnError||(n=n.catch(i=>{var a,o,l;return{error:{message:`${(a=i?.name)!==null&&a!==void 0?a:"FetchError"}: ${i?.message}`,details:`${(o=i?.stack)!==null&&o!==void 0?o:""}`,hint:"",code:`${(l=i?.code)!==null&&l!==void 0?l:""}`},data:null,count:null,status:0,statusText:""}})),n.then(e,t)}returns(){return this}overrideTypes(){return this}};Re.default=Er;var Sr=I&&I.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(je,"__esModule",{value:!0});const Cr=Sr(Re);let Tr=class extends Cr.default{select(e){let t=!1;const r=(e??"*").split("").map(n=>/\s/.test(n)&&!t?"":(n==='"'&&(t=!t),n)).join("");return this.url.searchParams.set("select",r),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:n,referencedTable:i=n}={}){const a=i?`${i}.order`:"order",o=this.url.searchParams.get(a);return this.url.searchParams.set(a,`${o?`${o},`:""}${e}.${t?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:r=t}={}){const n=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(n,`${e}`),this}range(e,t,{foreignTable:r,referencedTable:n=r}={}){const i=typeof n>"u"?"offset":`${n}.offset`,a=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(i,`${e}`),this.url.searchParams.set(a,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return this.method==="GET"?this.headers.Accept="application/json":this.headers.Accept="application/vnd.pgrst.object+json",this.isMaybeSingle=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:n=!1,wal:i=!1,format:a="text"}={}){var o;const l=[e?"analyze":null,t?"verbose":null,r?"settings":null,n?"buffers":null,i?"wal":null].filter(Boolean).join("|"),u=(o=this.headers.Accept)!==null&&o!==void 0?o:"application/json";return this.headers.Accept=`application/vnd.pgrst.plan+${a}; for="${u}"; options=${l};`,a==="json"?this:this}rollback(){var e;return((e=this.headers.Prefer)!==null&&e!==void 0?e:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}};je.default=Tr;var xr=I&&I.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(ke,"__esModule",{value:!0});const Pr=xr(je);let Ar=class extends Pr.default{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){const r=Array.from(new Set(t)).map(n=>typeof n=="string"&&new RegExp("[,()]").test(n)?`"${n}"`:`${n}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:n}={}){let i="";n==="plain"?i="pl":n==="phrase"?i="ph":n==="websearch"&&(i="w");const a=r===void 0?"":`(${r})`;return this.url.searchParams.append(e,`${i}fts${a}.${t}`),this}match(e){return Object.entries(e).forEach(([t,r])=>{this.url.searchParams.append(t,`eq.${r}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t,referencedTable:r=t}={}){const n=r?`${r}.or`:"or";return this.url.searchParams.append(n,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}};ke.default=Ar;var $r=I&&I.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Oe,"__esModule",{value:!0});const ve=$r(ke);let Or=class{constructor(e,{headers:t={},schema:r,fetch:n}){this.url=e,this.headers=t,this.schema=r,this.fetch=n}select(e,{head:t=!1,count:r}={}){const n=t?"HEAD":"GET";let i=!1;const a=(e??"*").split("").map(o=>/\s/.test(o)&&!i?"":(o==='"'&&(i=!i),o)).join("");return this.url.searchParams.set("select",a),r&&(this.headers.Prefer=`count=${r}`),new ve.default({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e,{count:t,defaultToNull:r=!0}={}){const n="POST",i=[];if(this.headers.Prefer&&i.push(this.headers.Prefer),t&&i.push(`count=${t}`),r||i.push("missing=default"),this.headers.Prefer=i.join(","),Array.isArray(e)){const a=e.reduce((o,l)=>o.concat(Object.keys(l)),[]);if(a.length>0){const o=[...new Set(a)].map(l=>`"${l}"`);this.url.searchParams.set("columns",o.join(","))}}return new ve.default({method:n,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:n,defaultToNull:i=!0}={}){const a="POST",o=[`resolution=${r?"ignore":"merge"}-duplicates`];if(t!==void 0&&this.url.searchParams.set("on_conflict",t),this.headers.Prefer&&o.push(this.headers.Prefer),n&&o.push(`count=${n}`),i||o.push("missing=default"),this.headers.Prefer=o.join(","),Array.isArray(e)){const l=e.reduce((u,c)=>u.concat(Object.keys(c)),[]);if(l.length>0){const u=[...new Set(l)].map(c=>`"${c}"`);this.url.searchParams.set("columns",u.join(","))}}return new ve.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}update(e,{count:t}={}){const r="PATCH",n=[];return this.headers.Prefer&&n.push(this.headers.Prefer),t&&n.push(`count=${t}`),this.headers.Prefer=n.join(","),new ve.default({method:r,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}delete({count:e}={}){const t="DELETE",r=[];return e&&r.push(`count=${e}`),this.headers.Prefer&&r.unshift(this.headers.Prefer),this.headers.Prefer=r.join(","),new ve.default({method:t,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}};Oe.default=Or;var Ie={},De={};Object.defineProperty(De,"__esModule",{value:!0});De.version=void 0;De.version="0.0.0-automated";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.DEFAULT_HEADERS=void 0;const jr=De;Ie.DEFAULT_HEADERS={"X-Client-Info":`postgrest-js/${jr.version}`};var At=I&&I.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(tt,"__esModule",{value:!0});const Rr=At(Oe),Lr=At(ke),Ir=Ie;let Dr=class $t{constructor(e,{headers:t={},schema:r,fetch:n}={}){this.url=e,this.headers=Object.assign(Object.assign({},Ir.DEFAULT_HEADERS),t),this.schemaName=r,this.fetch=n}from(e){const t=new URL(`${this.url}/${e}`);return new Rr.default(t,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new $t(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:r=!1,get:n=!1,count:i}={}){let a;const o=new URL(`${this.url}/rpc/${e}`);let l;r||n?(a=r?"HEAD":"GET",Object.entries(t).filter(([c,d])=>d!==void 0).map(([c,d])=>[c,Array.isArray(d)?`{${d.join(",")}}`:`${d}`]).forEach(([c,d])=>{o.searchParams.append(c,d)})):(a="POST",l=t);const u=Object.assign({},this.headers);return i&&(u.Prefer=`count=${i}`),new Lr.default({method:a,url:o,headers:u,schema:this.schemaName,body:l,fetch:this.fetch,allowEmpty:!1})}};tt.default=Dr;var pe=I&&I.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(j,"__esModule",{value:!0});j.PostgrestError=j.PostgrestBuilder=j.PostgrestTransformBuilder=j.PostgrestFilterBuilder=j.PostgrestQueryBuilder=j.PostgrestClient=void 0;const Ot=pe(tt);j.PostgrestClient=Ot.default;const jt=pe(Oe);j.PostgrestQueryBuilder=jt.default;const Rt=pe(ke);j.PostgrestFilterBuilder=Rt.default;const Lt=pe(je);j.PostgrestTransformBuilder=Lt.default;const It=pe(Re);j.PostgrestBuilder=It.default;const Dt=pe(Le);j.PostgrestError=Dt.default;var Ur=j.default={PostgrestClient:Ot.default,PostgrestQueryBuilder:jt.default,PostgrestFilterBuilder:Rt.default,PostgrestTransformBuilder:Lt.default,PostgrestBuilder:It.default,PostgrestError:Dt.default};const{PostgrestClient:Br,PostgrestQueryBuilder:ui,PostgrestFilterBuilder:hi,PostgrestTransformBuilder:di,PostgrestBuilder:fi,PostgrestError:pi}=Ur,Nr="2.11.2",Fr={"X-Client-Info":`realtime-js/${Nr}`},Mr="1.0.0",Ut=1e4,zr=1e3;var ue;(function(s){s[s.connecting=0]="connecting",s[s.open=1]="open",s[s.closing=2]="closing",s[s.closed=3]="closed"})(ue||(ue={}));var R;(function(s){s.closed="closed",s.errored="errored",s.joined="joined",s.joining="joining",s.leaving="leaving"})(R||(R={}));var U;(function(s){s.close="phx_close",s.error="phx_error",s.join="phx_join",s.reply="phx_reply",s.leave="phx_leave",s.access_token="access_token"})(U||(U={}));var Ge;(function(s){s.websocket="websocket"})(Ge||(Ge={}));var re;(function(s){s.Connecting="connecting",s.Open="open",s.Closing="closing",s.Closed="closed"})(re||(re={}));class qr{constructor(){this.HEADER_LENGTH=1}decode(e,t){return e.constructor===ArrayBuffer?t(this._binaryDecode(e)):t(typeof e=="string"?JSON.parse(e):{})}_binaryDecode(e){const t=new DataView(e),r=new TextDecoder;return this._decodeBroadcast(e,t,r)}_decodeBroadcast(e,t,r){const n=t.getUint8(1),i=t.getUint8(2);let a=this.HEADER_LENGTH+2;const o=r.decode(e.slice(a,a+n));a=a+n;const l=r.decode(e.slice(a,a+i));a=a+i;const u=JSON.parse(r.decode(e.slice(a,e.byteLength)));return{ref:null,topic:o,event:l,payload:u}}}class Bt{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=t}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}var T;(function(s){s.abstime="abstime",s.bool="bool",s.date="date",s.daterange="daterange",s.float4="float4",s.float8="float8",s.int2="int2",s.int4="int4",s.int4range="int4range",s.int8="int8",s.int8range="int8range",s.json="json",s.jsonb="jsonb",s.money="money",s.numeric="numeric",s.oid="oid",s.reltime="reltime",s.text="text",s.time="time",s.timestamp="timestamp",s.timestamptz="timestamptz",s.timetz="timetz",s.tsrange="tsrange",s.tstzrange="tstzrange"})(T||(T={}));const ht=(s,e,t={})=>{var r;const n=(r=t.skipTypes)!==null&&r!==void 0?r:[];return Object.keys(e).reduce((i,a)=>(i[a]=Hr(a,s,e,n),i),{})},Hr=(s,e,t,r)=>{const n=e.find(o=>o.name===s),i=n?.type,a=t[s];return i&&!r.includes(i)?Nt(i,a):We(a)},Nt=(s,e)=>{if(s.charAt(0)==="_"){const t=s.slice(1,s.length);return Jr(e,t)}switch(s){case T.bool:return Vr(e);case T.float4:case T.float8:case T.int2:case T.int4:case T.int8:case T.numeric:case T.oid:return Gr(e);case T.json:case T.jsonb:return Wr(e);case T.timestamp:return Kr(e);case T.abstime:case T.date:case T.daterange:case T.int4range:case T.int8range:case T.money:case T.reltime:case T.text:case T.time:case T.timestamptz:case T.timetz:case T.tsrange:case T.tstzrange:return We(e);default:return We(e)}},We=s=>s,Vr=s=>{switch(s){case"t":return!0;case"f":return!1;default:return s}},Gr=s=>{if(typeof s=="string"){const e=parseFloat(s);if(!Number.isNaN(e))return e}return s},Wr=s=>{if(typeof s=="string")try{return JSON.parse(s)}catch(e){return console.log(`JSON parse error: ${e}`),s}return s},Jr=(s,e)=>{if(typeof s!="string")return s;const t=s.length-1,r=s[t];if(s[0]==="{"&&r==="}"){let i;const a=s.slice(1,t);try{i=JSON.parse("["+a+"]")}catch{i=a?a.split(","):[]}return i.map(o=>Nt(e,o))}return s},Kr=s=>typeof s=="string"?s.replace(" ","T"):s,Ft=s=>{let e=s;return e=e.replace(/^ws/i,"http"),e=e.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),e.replace(/\/+$/,"")};class Be{constructor(e,t,r={},n=Ut){this.channel=e,this.event=t,this.payload=r,this.timeout=n,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,t){var r;return this._hasReceived(e)&&t((r=this.receivedResp)===null||r===void 0?void 0:r.response),this.recHooks.push({status:e,callback:t}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const e=t=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=t,this._matchReceive(t)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,t){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:t})}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:t}){this.recHooks.filter(r=>r.status===e).forEach(r=>r.callback(t))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}var dt;(function(s){s.SYNC="sync",s.JOIN="join",s.LEAVE="leave"})(dt||(dt={}));class _e{constructor(e,t){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const r=t?.events||{state:"presence_state",diff:"presence_diff"};this.channel._on(r.state,{},n=>{const{onJoin:i,onLeave:a,onSync:o}=this.caller;this.joinRef=this.channel._joinRef(),this.state=_e.syncState(this.state,n,i,a),this.pendingDiffs.forEach(l=>{this.state=_e.syncDiff(this.state,l,i,a)}),this.pendingDiffs=[],o()}),this.channel._on(r.diff,{},n=>{const{onJoin:i,onLeave:a,onSync:o}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(n):(this.state=_e.syncDiff(this.state,n,i,a),o())}),this.onJoin((n,i,a)=>{this.channel._trigger("presence",{event:"join",key:n,currentPresences:i,newPresences:a})}),this.onLeave((n,i,a)=>{this.channel._trigger("presence",{event:"leave",key:n,currentPresences:i,leftPresences:a})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,t,r,n){const i=this.cloneDeep(e),a=this.transformState(t),o={},l={};return this.map(i,(u,c)=>{a[u]||(l[u]=c)}),this.map(a,(u,c)=>{const d=i[u];if(d){const f=c.map(g=>g.presence_ref),p=d.map(g=>g.presence_ref),v=c.filter(g=>p.indexOf(g.presence_ref)<0),m=d.filter(g=>f.indexOf(g.presence_ref)<0);v.length>0&&(o[u]=v),m.length>0&&(l[u]=m)}else o[u]=c}),this.syncDiff(i,{joins:o,leaves:l},r,n)}static syncDiff(e,t,r,n){const{joins:i,leaves:a}={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)};return r||(r=()=>{}),n||(n=()=>{}),this.map(i,(o,l)=>{var u;const c=(u=e[o])!==null&&u!==void 0?u:[];if(e[o]=this.cloneDeep(l),c.length>0){const d=e[o].map(p=>p.presence_ref),f=c.filter(p=>d.indexOf(p.presence_ref)<0);e[o].unshift(...f)}r(o,c,l)}),this.map(a,(o,l)=>{let u=e[o];if(!u)return;const c=l.map(d=>d.presence_ref);u=u.filter(d=>c.indexOf(d.presence_ref)<0),e[o]=u,n(o,u,l),u.length===0&&delete e[o]}),e}static map(e,t){return Object.getOwnPropertyNames(e).map(r=>t(r,e[r]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((t,r)=>{const n=e[r];return"metas"in n?t[r]=n.metas.map(i=>(i.presence_ref=i.phx_ref,delete i.phx_ref,delete i.phx_ref_prev,i)):t[r]=n,t},{})}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 ft;(function(s){s.ALL="*",s.INSERT="INSERT",s.UPDATE="UPDATE",s.DELETE="DELETE"})(ft||(ft={}));var pt;(function(s){s.BROADCAST="broadcast",s.PRESENCE="presence",s.POSTGRES_CHANGES="postgres_changes",s.SYSTEM="system"})(pt||(pt={}));var z;(function(s){s.SUBSCRIBED="SUBSCRIBED",s.TIMED_OUT="TIMED_OUT",s.CLOSED="CLOSED",s.CHANNEL_ERROR="CHANNEL_ERROR"})(z||(z={}));class rt{constructor(e,t={config:{}},r){this.topic=e,this.params=t,this.socket=r,this.bindings={},this.state=R.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""},private:!1},t.config),this.timeout=this.socket.timeout,this.joinPush=new Be(this,U.join,this.params,this.timeout),this.rejoinTimer=new Bt(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=R.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(n=>n.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=R.closed,this.socket._remove(this)}),this._onError(n=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,n),this.state=R.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=R.errored,this.rejoinTimer.scheduleTimeout())}),this._on(U.reply,{},(n,i)=>{this._trigger(this._replyEventName(i),n)}),this.presence=new _e(this),this.broadcastEndpointURL=Ft(this.socket.endPoint)+"/api/broadcast",this.private=this.params.config.private||!1}subscribe(e,t=this.timeout){var r,n;if(this.socket.isConnected()||this.socket.connect(),this.joinedOnce)throw"tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance";{const{config:{broadcast:i,presence:a,private:o}}=this.params;this._onError(c=>e?.(z.CHANNEL_ERROR,c)),this._onClose(()=>e?.(z.CLOSED));const l={},u={broadcast:i,presence:a,postgres_changes:(n=(r=this.bindings.postgres_changes)===null||r===void 0?void 0:r.map(c=>c.filter))!==null&&n!==void 0?n:[],private:o};this.socket.accessTokenValue&&(l.access_token=this.socket.accessTokenValue),this.updateJoinPayload(Object.assign({config:u},l)),this.joinedOnce=!0,this._rejoin(t),this.joinPush.receive("ok",async({postgres_changes:c})=>{var d;if(this.socket.setAuth(),c===void 0){e?.(z.SUBSCRIBED);return}else{const f=this.bindings.postgres_changes,p=(d=f?.length)!==null&&d!==void 0?d:0,v=[];for(let m=0;m{e?.(z.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(c).join(", ")||"error")))}).receive("timeout",()=>{e?.(z.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(e,t={}){return await this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,t,r){return this._on(e,t,r)}async send(e,t={}){var r,n;if(!this._canPush()&&e.type==="broadcast"){const{event:i,payload:a}=e,l={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:a,private:this.private}]})};try{const u=await this._fetchWithTimeout(this.broadcastEndpointURL,l,(r=t.timeout)!==null&&r!==void 0?r:this.timeout);return await((n=u.body)===null||n===void 0?void 0:n.cancel()),u.ok?"ok":"error"}catch(u){return u.name==="AbortError"?"timed out":"error"}}else return new Promise(i=>{var a,o,l;const u=this._push(e.type,e,t.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"),u.receive("ok",()=>i("ok")),u.receive("error",()=>i("error")),u.receive("timeout",()=>i("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=R.leaving;const t=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(U.close,"leave",this._joinRef())};return this.rejoinTimer.reset(),this.joinPush.destroy(),new Promise(r=>{const n=new Be(this,U.leave,{},e);n.receive("ok",()=>{t(),r("ok")}).receive("timeout",()=>{t(),r("timed out")}).receive("error",()=>{r("error")}),n.send(),this._canPush()||n.trigger("ok",{})})}async _fetchWithTimeout(e,t,r){const n=new AbortController,i=setTimeout(()=>n.abort(),r),a=await this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:n.signal}));return clearTimeout(i),a}_push(e,t,r=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let n=new Be(this,e,t,r);return this._canPush()?n.send():(n.startTimeout(),this.pushBuffer.push(n)),n}_onMessage(e,t,r){return t}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,t,r){var n,i;const a=e.toLocaleLowerCase(),{close:o,error:l,leave:u,join:c}=U;if(r&&[o,l,u,c].indexOf(a)>=0&&r!==this._joinRef())return;let f=this._onMessage(a,t,r);if(t&&!f)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(a)?(n=this.bindings.postgres_changes)===null||n===void 0||n.filter(p=>{var v,m,g;return((v=p.filter)===null||v===void 0?void 0:v.event)==="*"||((g=(m=p.filter)===null||m===void 0?void 0:m.event)===null||g===void 0?void 0:g.toLocaleLowerCase())===a}).map(p=>p.callback(f,r)):(i=this.bindings[a])===null||i===void 0||i.filter(p=>{var v,m,g,y,_,S;if(["broadcast","presence","postgres_changes"].includes(a))if("id"in p){const b=p.id,C=(v=p.filter)===null||v===void 0?void 0:v.event;return b&&((m=t.ids)===null||m===void 0?void 0:m.includes(b))&&(C==="*"||C?.toLocaleLowerCase()===((g=t.data)===null||g===void 0?void 0:g.type.toLocaleLowerCase()))}else{const b=(_=(y=p?.filter)===null||y===void 0?void 0:y.event)===null||_===void 0?void 0:_.toLocaleLowerCase();return b==="*"||b===((S=t?.event)===null||S===void 0?void 0:S.toLocaleLowerCase())}else return p.type.toLocaleLowerCase()===a}).map(p=>{if(typeof f=="object"&&"ids"in f){const v=f.data,{schema:m,table:g,commit_timestamp:y,type:_,errors:S}=v;f=Object.assign(Object.assign({},{schema:m,table:g,commit_timestamp:y,eventType:_,new:{},old:{},errors:S}),this._getPayloadRecords(v))}p.callback(f,r)})}_isClosed(){return this.state===R.closed}_isJoined(){return this.state===R.joined}_isJoining(){return this.state===R.joining}_isLeaving(){return this.state===R.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,t,r){const n=e.toLocaleLowerCase(),i={type:n,filter:t,callback:r};return this.bindings[n]?this.bindings[n].push(i):this.bindings[n]=[i],this}_off(e,t){const r=e.toLocaleLowerCase();return this.bindings[r]=this.bindings[r].filter(n=>{var i;return!(((i=n.type)===null||i===void 0?void 0:i.toLocaleLowerCase())===r&&rt.isEqual(n.filter,t))}),this}static isEqual(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(U.close,{},e)}_onError(e){this._on(U.error,{},t=>e(t))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=R.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const t={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(t.new=ht(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(t.old=ht(e.columns,e.old_record)),t}}const Yr=()=>{},Zr=typeof WebSocket<"u",Qr=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class Xr{constructor(e,t){var r;this.accessTokenValue=null,this.apiKey=null,this.channels=[],this.endPoint="",this.httpEndpoint="",this.headers=Fr,this.params={},this.timeout=Ut,this.heartbeatIntervalMs=3e4,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.ref=0,this.logger=Yr,this.conn=null,this.sendBuffer=[],this.serializer=new qr,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._resolveFetch=i=>{let a;return i?a=i:typeof fetch>"u"?a=(...o)=>he(async()=>{const{default:l}=await Promise.resolve().then(()=>fe);return{default:l}},void 0).then(({default:l})=>l(...o)):a=fetch,(...o)=>a(...o)},this.endPoint=`${e}/${Ge.websocket}`,this.httpEndpoint=Ft(e),t?.transport?this.transport=t.transport:this.transport=null,t?.params&&(this.params=t.params),t?.headers&&(this.headers=Object.assign(Object.assign({},this.headers),t.headers)),t?.timeout&&(this.timeout=t.timeout),t?.logger&&(this.logger=t.logger),t?.heartbeatIntervalMs&&(this.heartbeatIntervalMs=t.heartbeatIntervalMs);const n=(r=t?.params)===null||r===void 0?void 0:r.apikey;if(n&&(this.accessTokenValue=n,this.apiKey=n),this.reconnectAfterMs=t?.reconnectAfterMs?t.reconnectAfterMs:i=>[1e3,2e3,5e3,1e4][i-1]||1e4,this.encode=t?.encode?t.encode:(i,a)=>a(JSON.stringify(i)),this.decode=t?.decode?t.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new Bt(async()=>{this.disconnect(),this.connect()},this.reconnectAfterMs),this.fetch=this._resolveFetch(t?.fetch),t?.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.worker=t?.worker||!1,this.workerUrl=t?.workerUrl}this.accessToken=t?.accessToken||null}connect(){if(!this.conn){if(this.transport){this.conn=new this.transport(this.endpointURL(),void 0,{headers:this.headers});return}if(Zr){this.conn=new WebSocket(this.endpointURL()),this.setupConnection();return}this.conn=new es(this.endpointURL(),void 0,{close:()=>{this.conn=null}}),he(async()=>{const{default:e}=await import("./vendor-w-119-DEalYQv-.js").then(t=>t.b);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])).then(({default:e})=>{this.conn=new e(this.endpointURL(),void 0,{headers:this.headers}),this.setupConnection()})}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:Mr}))}disconnect(e,t){this.conn&&(this.conn.onclose=function(){},e?this.conn.close(e,t??""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset())}getChannels(){return this.channels}async removeChannel(e){const t=await e.unsubscribe();return this.channels.length===0&&this.disconnect(),t}async removeAllChannels(){const e=await Promise.all(this.channels.map(t=>t.unsubscribe()));return this.disconnect(),e}log(e,t,r){this.logger(e,t,r)}connectionState(){switch(this.conn&&this.conn.readyState){case ue.connecting:return re.Connecting;case ue.open:return re.Open;case ue.closing:return re.Closing;default:return re.Closed}}isConnected(){return this.connectionState()===re.Open}channel(e,t={config:{}}){const r=new rt(`realtime:${e}`,t,this);return this.channels.push(r),r}push(e){const{topic:t,event:r,payload:n,ref:i}=e,a=()=>{this.encode(e,o=>{var l;(l=this.conn)===null||l===void 0||l.send(o)})};this.log("push",`${t} ${r} (${i})`,n),this.isConnected()?a():this.sendBuffer.push(a)}async setAuth(e=null){let t=e||this.accessToken&&await this.accessToken()||this.accessTokenValue;if(t){let r=null;try{r=JSON.parse(atob(t.split(".")[1]))}catch{}if(r&&r.exp&&!(Math.floor(Date.now()/1e3)-r.exp<0))return this.log("auth",`InvalidJWTToken: Invalid value for JWT claim "exp" with value ${r.exp}`),Promise.reject(`InvalidJWTToken: Invalid value for JWT claim "exp" with value ${r.exp}`);this.accessTokenValue=t,this.channels.forEach(n=>{t&&n.updateJoinPayload({access_token:t}),n.joinedOnce&&n._isJoined()&&n._push(U.access_token,{access_token:t})})}}async sendHeartbeat(){var e;if(this.isConnected()){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),(e=this.conn)===null||e===void 0||e.close(zr,"hearbeat timeout");return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.setAuth()}}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 t=this.channels.find(r=>r.topic===e&&(r._isJoined()||r._isJoining()));t&&(this.log("transport",`leaving duplicate topic "${e}"`),t.unsubscribe())}_remove(e){this.channels=this.channels.filter(t=>t._joinRef()!==e._joinRef())}setupConnection(){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))}_onConnMessage(e){this.decode(e.data,t=>{let{topic:r,event:n,payload:i,ref:a}=t;a&&a===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null),this.log("receive",`${i.status||""} ${r} ${n} ${a&&"("+a+")"||""}`,i),this.channels.filter(o=>o._isMember(r)).forEach(o=>o._trigger(n,i,a)),this.stateChangeCallbacks.message.forEach(o=>o(t))})}async _onConnOpen(){if(this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this.reconnectTimer.reset(),!this.worker)this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs);else{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=t=>{this.log("worker","worker error",t.message),this.workerRef.terminate()},this.workerRef.onmessage=t=>{t.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}this.stateChangeCallbacks.open.forEach(e=>e())}_onConnClose(e){this.log("transport","close",e),this._triggerChanError(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(t=>t(e))}_onConnError(e){this.log("transport",e.message),this._triggerChanError(),this.stateChangeCallbacks.error.forEach(t=>t(e))}_triggerChanError(){this.channels.forEach(e=>e._trigger(U.error))}_appendParams(e,t){if(Object.keys(t).length===0)return e;const r=e.match(/\?/)?"&":"?",n=new URLSearchParams(t);return`${e}${r}${n}`}_workerObjectUrl(e){let t;if(e)t=e;else{const r=new Blob([Qr],{type:"application/javascript"});t=URL.createObjectURL(r)}return t}}class es{constructor(e,t,r){this.binaryType="arraybuffer",this.onclose=()=>{},this.onerror=()=>{},this.onmessage=()=>{},this.onopen=()=>{},this.readyState=ue.connecting,this.send=()=>{},this.url=null,this.url=e,this.close=r.close}}class st extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function P(s){return typeof s=="object"&&s!==null&&"__isStorageError"in s}class ts extends st{constructor(e,t){super(e),this.name="StorageApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class Je extends st{constructor(e,t){super(e),this.name="StorageUnknownError",this.originalError=t}}var rs=function(s,e,t,r){function n(i){return i instanceof t?i:new t(function(a){a(i)})}return new(t||(t=Promise))(function(i,a){function o(c){try{u(r.next(c))}catch(d){a(d)}}function l(c){try{u(r.throw(c))}catch(d){a(d)}}function u(c){c.done?i(c.value):n(c.value).then(o,l)}u((r=r.apply(s,e||[])).next())})};const Mt=s=>{let e;return s?e=s:typeof fetch>"u"?e=(...t)=>he(async()=>{const{default:r}=await Promise.resolve().then(()=>fe);return{default:r}},void 0).then(({default:r})=>r(...t)):e=fetch,(...t)=>e(...t)},ss=()=>rs(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield he(()=>Promise.resolve().then(()=>fe),void 0)).Response:Response}),Ke=s=>{if(Array.isArray(s))return s.map(t=>Ke(t));if(typeof s=="function"||s!==Object(s))return s;const e={};return Object.entries(s).forEach(([t,r])=>{const n=t.replace(/([-_][a-z])/gi,i=>i.toUpperCase().replace(/[-_]/g,""));e[n]=Ke(r)}),e};var ne=function(s,e,t,r){function n(i){return i instanceof t?i:new t(function(a){a(i)})}return new(t||(t=Promise))(function(i,a){function o(c){try{u(r.next(c))}catch(d){a(d)}}function l(c){try{u(r.throw(c))}catch(d){a(d)}}function u(c){c.done?i(c.value):n(c.value).then(o,l)}u((r=r.apply(s,e||[])).next())})};const Ne=s=>s.msg||s.message||s.error_description||s.error||JSON.stringify(s),ns=(s,e,t)=>ne(void 0,void 0,void 0,function*(){const r=yield ss();s instanceof r&&!t?.noResolveJson?s.json().then(n=>{e(new ts(Ne(n),s.status||500))}).catch(n=>{e(new Je(Ne(n),n))}):e(new Je(Ne(s),s))}),is=(s,e,t,r)=>{const n={method:s,headers:e?.headers||{}};return s==="GET"?n:(n.headers=Object.assign({"Content-Type":"application/json"},e?.headers),r&&(n.body=JSON.stringify(r)),Object.assign(Object.assign({},n),t))};function Ee(s,e,t,r,n,i){return ne(this,void 0,void 0,function*(){return new Promise((a,o)=>{s(t,is(e,r,n,i)).then(l=>{if(!l.ok)throw l;return r?.noResolveJson?l:l.json()}).then(l=>a(l)).catch(l=>ns(l,o,r))})})}function $e(s,e,t,r){return ne(this,void 0,void 0,function*(){return Ee(s,"GET",e,t,r)})}function J(s,e,t,r,n){return ne(this,void 0,void 0,function*(){return Ee(s,"POST",e,r,n,t)})}function as(s,e,t,r,n){return ne(this,void 0,void 0,function*(){return Ee(s,"PUT",e,r,n,t)})}function os(s,e,t,r){return ne(this,void 0,void 0,function*(){return Ee(s,"HEAD",e,Object.assign(Object.assign({},t),{noResolveJson:!0}),r)})}function zt(s,e,t,r,n){return ne(this,void 0,void 0,function*(){return Ee(s,"DELETE",e,r,n,t)})}var O=function(s,e,t,r){function n(i){return i instanceof t?i:new t(function(a){a(i)})}return new(t||(t=Promise))(function(i,a){function o(c){try{u(r.next(c))}catch(d){a(d)}}function l(c){try{u(r.throw(c))}catch(d){a(d)}}function u(c){c.done?i(c.value):n(c.value).then(o,l)}u((r=r.apply(s,e||[])).next())})};const ls={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},gt={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class cs{constructor(e,t={},r,n){this.url=e,this.headers=t,this.bucketId=r,this.fetch=Mt(n)}uploadOrUpdate(e,t,r,n){return O(this,void 0,void 0,function*(){try{let i;const a=Object.assign(Object.assign({},gt),n);let o=Object.assign(Object.assign({},this.headers),e==="POST"&&{"x-upsert":String(a.upsert)});const l=a.metadata;typeof Blob<"u"&&r instanceof Blob?(i=new FormData,i.append("cacheControl",a.cacheControl),l&&i.append("metadata",this.encodeMetadata(l)),i.append("",r)):typeof FormData<"u"&&r instanceof FormData?(i=r,i.append("cacheControl",a.cacheControl),l&&i.append("metadata",this.encodeMetadata(l))):(i=r,o["cache-control"]=`max-age=${a.cacheControl}`,o["content-type"]=a.contentType,l&&(o["x-metadata"]=this.toBase64(this.encodeMetadata(l)))),n?.headers&&(o=Object.assign(Object.assign({},o),n.headers));const u=this._removeEmptyFolders(t),c=this._getFinalPath(u),d=yield this.fetch(`${this.url}/object/${c}`,Object.assign({method:e,body:i,headers:o},a?.duplex?{duplex:a.duplex}:{})),f=yield d.json();return d.ok?{data:{path:u,id:f.Id,fullPath:f.Key},error:null}:{data:null,error:f}}catch(i){if(P(i))return{data:null,error:i};throw i}})}upload(e,t,r){return O(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,t,r)})}uploadToSignedUrl(e,t,r,n){return O(this,void 0,void 0,function*(){const i=this._removeEmptyFolders(e),a=this._getFinalPath(i),o=new URL(this.url+`/object/upload/sign/${a}`);o.searchParams.set("token",t);try{let l;const u=Object.assign({upsert:gt.upsert},n),c=Object.assign(Object.assign({},this.headers),{"x-upsert":String(u.upsert)});typeof Blob<"u"&&r instanceof Blob?(l=new FormData,l.append("cacheControl",u.cacheControl),l.append("",r)):typeof FormData<"u"&&r instanceof FormData?(l=r,l.append("cacheControl",u.cacheControl)):(l=r,c["cache-control"]=`max-age=${u.cacheControl}`,c["content-type"]=u.contentType);const d=yield this.fetch(o.toString(),{method:"PUT",body:l,headers:c}),f=yield d.json();return d.ok?{data:{path:i,fullPath:f.Key},error:null}:{data:null,error:f}}catch(l){if(P(l))return{data:null,error:l};throw l}})}createSignedUploadUrl(e,t){return O(this,void 0,void 0,function*(){try{let r=this._getFinalPath(e);const n=Object.assign({},this.headers);t?.upsert&&(n["x-upsert"]="true");const i=yield J(this.fetch,`${this.url}/object/upload/sign/${r}`,{},{headers:n}),a=new URL(this.url+i.url),o=a.searchParams.get("token");if(!o)throw new st("No token returned by API");return{data:{signedUrl:a.toString(),path:e,token:o},error:null}}catch(r){if(P(r))return{data:null,error:r};throw r}})}update(e,t,r){return O(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,t,r)})}move(e,t,r){return O(this,void 0,void 0,function*(){try{return{data:yield J(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,destinationBucket:r?.destinationBucket},{headers:this.headers}),error:null}}catch(n){if(P(n))return{data:null,error:n};throw n}})}copy(e,t,r){return O(this,void 0,void 0,function*(){try{return{data:{path:(yield J(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,destinationBucket:r?.destinationBucket},{headers:this.headers})).Key},error:null}}catch(n){if(P(n))return{data:null,error:n};throw n}})}createSignedUrl(e,t,r){return O(this,void 0,void 0,function*(){try{let n=this._getFinalPath(e),i=yield J(this.fetch,`${this.url}/object/sign/${n}`,Object.assign({expiresIn:t},r?.transform?{transform:r.transform}:{}),{headers:this.headers});const a=r?.download?`&download=${r.download===!0?"":r.download}`:"";return i={signedUrl:encodeURI(`${this.url}${i.signedURL}${a}`)},{data:i,error:null}}catch(n){if(P(n))return{data:null,error:n};throw n}})}createSignedUrls(e,t,r){return O(this,void 0,void 0,function*(){try{const n=yield J(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:t,paths:e},{headers:this.headers}),i=r?.download?`&download=${r.download===!0?"":r.download}`:"";return{data:n.map(a=>Object.assign(Object.assign({},a),{signedUrl:a.signedURL?encodeURI(`${this.url}${a.signedURL}${i}`):null})),error:null}}catch(n){if(P(n))return{data:null,error:n};throw n}})}download(e,t){return O(this,void 0,void 0,function*(){const n=typeof t?.transform<"u"?"render/image/authenticated":"object",i=this.transformOptsToQueryString(t?.transform||{}),a=i?`?${i}`:"";try{const o=this._getFinalPath(e);return{data:yield(yield $e(this.fetch,`${this.url}/${n}/${o}${a}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(o){if(P(o))return{data:null,error:o};throw o}})}info(e){return O(this,void 0,void 0,function*(){const t=this._getFinalPath(e);try{const r=yield $e(this.fetch,`${this.url}/object/info/${t}`,{headers:this.headers});return{data:Ke(r),error:null}}catch(r){if(P(r))return{data:null,error:r};throw r}})}exists(e){return O(this,void 0,void 0,function*(){const t=this._getFinalPath(e);try{return yield os(this.fetch,`${this.url}/object/${t}`,{headers:this.headers}),{data:!0,error:null}}catch(r){if(P(r)&&r instanceof Je){const n=r.originalError;if([400,404].includes(n?.status))return{data:!1,error:r}}throw r}})}getPublicUrl(e,t){const r=this._getFinalPath(e),n=[],i=t?.download?`download=${t.download===!0?"":t.download}`:"";i!==""&&n.push(i);const o=typeof t?.transform<"u"?"render/image":"object",l=this.transformOptsToQueryString(t?.transform||{});l!==""&&n.push(l);let u=n.join("&");return u!==""&&(u=`?${u}`),{data:{publicUrl:encodeURI(`${this.url}/${o}/public/${r}${u}`)}}}remove(e){return O(this,void 0,void 0,function*(){try{return{data:yield zt(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(t){if(P(t))return{data:null,error:t};throw t}})}list(e,t,r){return O(this,void 0,void 0,function*(){try{const n=Object.assign(Object.assign(Object.assign({},ls),t),{prefix:e||""});return{data:yield J(this.fetch,`${this.url}/object/list/${this.bucketId}`,n,{headers:this.headers},r),error:null}}catch(n){if(P(n))return{data:null,error:n};throw n}})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return typeof Buffer<"u"?Buffer.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){const t=[];return e.width&&t.push(`width=${e.width}`),e.height&&t.push(`height=${e.height}`),e.resize&&t.push(`resize=${e.resize}`),e.format&&t.push(`format=${e.format}`),e.quality&&t.push(`quality=${e.quality}`),t.join("&")}}const us="2.7.1",hs={"X-Client-Info":`storage-js/${us}`};var ae=function(s,e,t,r){function n(i){return i instanceof t?i:new t(function(a){a(i)})}return new(t||(t=Promise))(function(i,a){function o(c){try{u(r.next(c))}catch(d){a(d)}}function l(c){try{u(r.throw(c))}catch(d){a(d)}}function u(c){c.done?i(c.value):n(c.value).then(o,l)}u((r=r.apply(s,e||[])).next())})};class ds{constructor(e,t={},r){this.url=e,this.headers=Object.assign(Object.assign({},hs),t),this.fetch=Mt(r)}listBuckets(){return ae(this,void 0,void 0,function*(){try{return{data:yield $e(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(P(e))return{data:null,error:e};throw e}})}getBucket(e){return ae(this,void 0,void 0,function*(){try{return{data:yield $e(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(t){if(P(t))return{data:null,error:t};throw t}})}createBucket(e,t={public:!1}){return ae(this,void 0,void 0,function*(){try{return{data:yield J(this.fetch,`${this.url}/bucket`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}),error:null}}catch(r){if(P(r))return{data:null,error:r};throw r}})}updateBucket(e,t){return ae(this,void 0,void 0,function*(){try{return{data:yield as(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}),error:null}}catch(r){if(P(r))return{data:null,error:r};throw r}})}emptyBucket(e){return ae(this,void 0,void 0,function*(){try{return{data:yield J(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(t){if(P(t))return{data:null,error:t};throw t}})}deleteBucket(e){return ae(this,void 0,void 0,function*(){try{return{data:yield zt(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(t){if(P(t))return{data:null,error:t};throw t}})}}class fs extends ds{constructor(e,t={},r){super(e,t,r)}from(e){return new cs(this.url,this.headers,e,this.fetch)}}const ps="2.49.4";let me="";typeof Deno<"u"?me="deno":typeof document<"u"?me="web":typeof navigator<"u"&&navigator.product==="ReactNative"?me="react-native":me="node";const gs={"X-Client-Info":`supabase-js-${me}/${ps}`},vs={headers:gs},ms={schema:"public"},_s={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},ws={};var ys=function(s,e,t,r){function n(i){return i instanceof t?i:new t(function(a){a(i)})}return new(t||(t=Promise))(function(i,a){function o(c){try{u(r.next(c))}catch(d){a(d)}}function l(c){try{u(r.throw(c))}catch(d){a(d)}}function u(c){c.done?i(c.value):n(c.value).then(o,l)}u((r=r.apply(s,e||[])).next())})};const bs=s=>{let e;return s?e=s:typeof fetch>"u"?e=Tt:e=fetch,(...t)=>e(...t)},ks=()=>typeof Headers>"u"?xt:Headers,Es=(s,e,t)=>{const r=bs(t),n=ks();return(i,a)=>ys(void 0,void 0,void 0,function*(){var o;const l=(o=yield e())!==null&&o!==void 0?o:s;let u=new n(a?.headers);return u.has("apikey")||u.set("apikey",s),u.has("Authorization")||u.set("Authorization",`Bearer ${l}`),r(i,Object.assign(Object.assign({},a),{headers:u}))})};var Ss=function(s,e,t,r){function n(i){return i instanceof t?i:new t(function(a){a(i)})}return new(t||(t=Promise))(function(i,a){function o(c){try{u(r.next(c))}catch(d){a(d)}}function l(c){try{u(r.throw(c))}catch(d){a(d)}}function u(c){c.done?i(c.value):n(c.value).then(o,l)}u((r=r.apply(s,e||[])).next())})};function Cs(s){return s.replace(/\/$/,"")}function Ts(s,e){const{db:t,auth:r,realtime:n,global:i}=s,{db:a,auth:o,realtime:l,global:u}=e,c={db:Object.assign(Object.assign({},a),t),auth:Object.assign(Object.assign({},o),r),realtime:Object.assign(Object.assign({},l),n),global:Object.assign(Object.assign({},u),i),accessToken:()=>Ss(this,void 0,void 0,function*(){return""})};return s.accessToken?c.accessToken=s.accessToken:delete c.accessToken,c}const qt="2.69.1",ce=30*1e3,Ye=3,Fe=Ye*ce,xs="http://localhost:9999",Ps="supabase.auth.token",As={"X-Client-Info":`gotrue-js/${qt}`},Ze="X-Supabase-Api-Version",Ht={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},$s=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,Os=6e5;class nt extends Error{constructor(e,t,r){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t,this.code=r}}function w(s){return typeof s=="object"&&s!==null&&"__isAuthError"in s}class js extends nt{constructor(e,t,r){super(e,t,r),this.name="AuthApiError",this.status=t,this.code=r}}function Rs(s){return w(s)&&s.name==="AuthApiError"}class Vt extends nt{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class Q extends nt{constructor(e,t,r,n){super(e,r,n),this.name=t,this.status=r}}class G extends Q{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function Ls(s){return w(s)&&s.name==="AuthSessionMissingError"}class Me extends Q{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class Te extends Q{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class xe extends Q{constructor(e,t=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function Is(s){return w(s)&&s.name==="AuthImplicitGrantRedirectError"}class vt extends Q{constructor(e,t=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class Qe extends Q{constructor(e,t){super(e,"AuthRetryableFetchError",t,void 0)}}function ze(s){return w(s)&&s.name==="AuthRetryableFetchError"}class mt extends Q{constructor(e,t,r){super(e,"AuthWeakPasswordError",t,"weak_password"),this.reasons=r}}class we extends Q{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const _t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),wt=` \r=`.split(""),Ds=(()=>{const s=new Array(128);for(let e=0;e-1)for(e.queue=e.queue<<6|r,e.queuedBits+=6;e.queuedBits>=8;)t(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(r===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(s)}"`)}}function yt(s){const e=[],t=a=>{e.push(String.fromCodePoint(a))},r={utf8seq:0,codepoint:0},n={queue:0,queuedBits:0},i=a=>{Ns(a,r,t)};for(let a=0;a>6),e(128|s&63);return}else if(s<=65535){e(224|s>>12),e(128|s>>6&63),e(128|s&63);return}else if(s<=1114111){e(240|s>>18),e(128|s>>12&63),e(128|s>>6&63),e(128|s&63);return}throw new Error(`Unrecognized Unicode codepoint: ${s.toString(16)}`)}function Bs(s,e){for(let t=0;t55295&&r<=56319){const n=(r-55296)*1024&65535;r=(s.charCodeAt(t+1)-56320&65535|n)+65536,t+=1}Us(r,e)}}function Ns(s,e,t){if(e.utf8seq===0){if(s<=127){t(s);return}for(let r=1;r<6;r+=1)if(!(s>>7-r&1)){e.utf8seq=r;break}if(e.utf8seq===2)e.codepoint=s&31;else if(e.utf8seq===3)e.codepoint=s&15;else if(e.utf8seq===4)e.codepoint=s&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(s<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|s&63,e.utf8seq-=1,e.utf8seq===0&&t(e.codepoint)}}function Fs(s){const e=[],t={queue:0,queuedBits:0},r=n=>{e.push(n)};for(let n=0;ne.push(t)),new Uint8Array(e)}function zs(s){return Math.round(Date.now()/1e3)+s}function qs(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(s){const e=Math.random()*16|0;return(s=="x"?e:e&3|8).toString(16)})}const B=()=>typeof window<"u"&&typeof document<"u",ee={tested:!1,writable:!1},ye=()=>{if(!B())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(ee.tested)return ee.writable;const s=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(s,s),globalThis.localStorage.removeItem(s),ee.tested=!0,ee.writable=!0}catch{ee.tested=!0,ee.writable=!1}return ee.writable};function Hs(s){const e={},t=new URL(s);if(t.hash&&t.hash[0]==="#")try{new URLSearchParams(t.hash.substring(1)).forEach((n,i)=>{e[i]=n})}catch{}return t.searchParams.forEach((r,n)=>{e[n]=r}),e}const Wt=s=>{let e;return s?e=s:typeof fetch>"u"?e=(...t)=>he(async()=>{const{default:r}=await Promise.resolve().then(()=>fe);return{default:r}},void 0).then(({default:r})=>r(...t)):e=fetch,(...t)=>e(...t)},Vs=s=>typeof s=="object"&&s!==null&&"status"in s&&"ok"in s&&"json"in s&&typeof s.json=="function",Jt=async(s,e,t)=>{await s.setItem(e,JSON.stringify(t))},Pe=async(s,e)=>{const t=await s.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch{return t}},Ae=async(s,e)=>{await s.removeItem(e)};class Ue{constructor(){this.promise=new Ue.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}}Ue.promiseConstructor=Promise;function qe(s){const e=s.split(".");if(e.length!==3)throw new we("Invalid JWT structure");for(let r=0;r{setTimeout(()=>e(null),s)})}function Ws(s,e){return new Promise((r,n)=>{(async()=>{for(let i=0;i<1/0;i++)try{const a=await s(i);if(!e(i,null,a)){r(a);return}}catch(a){if(!e(i,a)){n(a);return}}})()})}function Js(s){return("0"+s.toString(16)).substr(-2)}function Ks(){const e=new Uint32Array(56);if(typeof crypto>"u"){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",r=t.length;let n="";for(let i=0;i<56;i++)n+=t.charAt(Math.floor(Math.random()*r));return n}return crypto.getRandomValues(e),Array.from(e,Js).join("")}async function Ys(s){const t=new TextEncoder().encode(s),r=await crypto.subtle.digest("SHA-256",t),n=new Uint8Array(r);return Array.from(n).map(i=>String.fromCharCode(i)).join("")}async function Zs(s){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."),s;const t=await Ys(s);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function oe(s,e,t=!1){const r=Ks();let n=r;t&&(n+="/PASSWORD_RECOVERY"),await Jt(s,`${e}-code-verifier`,n);const i=await Zs(r);return[i,r===i?"plain":"s256"]}const Qs=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function Xs(s){const e=s.headers.get(Ze);if(!e||!e.match(Qs))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function en(s){if(!s)throw new Error("Missing exp claim");const e=Math.floor(Date.now()/1e3);if(s<=e)throw new Error("JWT has expired")}function tn(s){switch(s){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")}}var rn=function(s,e){var t={};for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&e.indexOf(r)<0&&(t[r]=s[r]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(s);ns.msg||s.message||s.error_description||s.error||JSON.stringify(s),sn=[502,503,504];async function bt(s){var e;if(!Vs(s))throw new Qe(te(s),0);if(sn.includes(s.status))throw new Qe(te(s),s.status);let t;try{t=await s.json()}catch(i){throw new Vt(te(i),i)}let r;const n=Xs(s);if(n&&n.getTime()>=Ht["2024-01-01"].timestamp&&typeof t=="object"&&t&&typeof t.code=="string"?r=t.code:typeof t=="object"&&t&&typeof t.error_code=="string"&&(r=t.error_code),r){if(r==="weak_password")throw new mt(te(t),s.status,((e=t.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(r==="session_not_found")throw new G}else if(typeof t=="object"&&t&&typeof t.weak_password=="object"&&t.weak_password&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.reasons.reduce((i,a)=>i&&typeof a=="string",!0))throw new mt(te(t),s.status,t.weak_password.reasons);throw new js(te(t),s.status||500,r)}const nn=(s,e,t,r)=>{const n={method:s,headers:e?.headers||{}};return s==="GET"?n:(n.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e?.headers),n.body=JSON.stringify(r),Object.assign(Object.assign({},n),t))};async function E(s,e,t,r){var n;const i=Object.assign({},r?.headers);i[Ze]||(i[Ze]=Ht["2024-01-01"].name),r?.jwt&&(i.Authorization=`Bearer ${r.jwt}`);const a=(n=r?.query)!==null&&n!==void 0?n:{};r?.redirectTo&&(a.redirect_to=r.redirectTo);const o=Object.keys(a).length?"?"+new URLSearchParams(a).toString():"",l=await an(s,e,t+o,{headers:i,noResolveJson:r?.noResolveJson},{},r?.body);return r?.xform?r?.xform(l):{data:Object.assign({},l),error:null}}async function an(s,e,t,r,n,i){const a=nn(e,r,n,i);let o;try{o=await s(t,Object.assign({},a))}catch(l){throw console.error(l),new Qe(te(l),0)}if(o.ok||await bt(o),r?.noResolveJson)return o;try{return await o.json()}catch(l){await bt(l)}}function W(s){var e;let t=null;un(s)&&(t=Object.assign({},s),s.expires_at||(t.expires_at=zs(s.expires_in)));const r=(e=s.user)!==null&&e!==void 0?e:s;return{data:{session:t,user:r},error:null}}function kt(s){const e=W(s);return!e.error&&s.weak_password&&typeof s.weak_password=="object"&&Array.isArray(s.weak_password.reasons)&&s.weak_password.reasons.length&&s.weak_password.message&&typeof s.weak_password.message=="string"&&s.weak_password.reasons.reduce((t,r)=>t&&typeof r=="string",!0)&&(e.data.weak_password=s.weak_password),e}function K(s){var e;return{data:{user:(e=s.user)!==null&&e!==void 0?e:s},error:null}}function on(s){return{data:s,error:null}}function ln(s){const{action_link:e,email_otp:t,hashed_token:r,redirect_to:n,verification_type:i}=s,a=rn(s,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),o={action_link:e,email_otp:t,hashed_token:r,redirect_to:n,verification_type:i},l=Object.assign({},a);return{data:{properties:o,user:l},error:null}}function cn(s){return s}function un(s){return s.access_token&&s.refresh_token&&s.expires_in}var hn=function(s,e){var t={};for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&e.indexOf(r)<0&&(t[r]=s[r]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(s);n0&&(p.forEach(v=>{const m=parseInt(v.split(";")[0].split("=")[1].substring(0,1)),g=JSON.parse(v.split(";")[1].split("=")[1]);u[`${g}Page`]=m}),u.total=parseInt(f)),{data:Object.assign(Object.assign({},d),u),error:null}}catch(u){if(w(u))return{data:{users:[]},error:u};throw u}}async getUserById(e){try{return await E(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:K})}catch(t){if(w(t))return{data:{user:null},error:t};throw t}}async updateUserById(e,t){try{return await E(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:K})}catch(r){if(w(r))return{data:{user:null},error:r};throw r}}async deleteUser(e,t=!1){try{return await E(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:K})}catch(r){if(w(r))return{data:{user:null},error:r};throw r}}async _listFactors(e){try{const{data:t,error:r}=await E(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:n=>({data:{factors:n},error:null})});return{data:t,error:r}}catch(t){if(w(t))return{data:null,error:t};throw t}}async _deleteFactor(e){try{return{data:await E(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(t){if(w(t))return{data:null,error:t};throw t}}}const fn={getItem:s=>ye()?globalThis.localStorage.getItem(s):null,setItem:(s,e)=>{ye()&&globalThis.localStorage.setItem(s,e)},removeItem:s=>{ye()&&globalThis.localStorage.removeItem(s)}};function Et(s={}){return{getItem:e=>s[e]||null,setItem:(e,t)=>{s[e]=t},removeItem:e=>{delete s[e]}}}function pn(){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)}}const le={debug:!!(globalThis&&ye()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class Kt extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class gn extends Kt{}async function vn(s,e,t){le.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",s,e);const r=new globalThis.AbortController;return e>0&&setTimeout(()=>{r.abort(),le.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",s)},e),await Promise.resolve().then(()=>globalThis.navigator.locks.request(s,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:r.signal},async n=>{if(n){le.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",s,n.name);try{return await t()}finally{le.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",s,n.name)}}else{if(e===0)throw le.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",s),new gn(`Acquiring an exclusive Navigator LockManager lock "${s}" immediately failed`);if(le.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 t()}}))}pn();const mn={url:xs,storageKey:Ps,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:As,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function St(s,e,t){return await t()}class be{constructor(e){var t,r;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,this.instanceID=be.nextInstanceID,be.nextInstanceID+=1,this.instanceID>0&&B()&&console.warn("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.");const n=Object.assign(Object.assign({},mn),e);if(this.logDebugMessages=!!n.debug,typeof n.debug=="function"&&(this.logger=n.debug),this.persistSession=n.persistSession,this.storageKey=n.storageKey,this.autoRefreshToken=n.autoRefreshToken,this.admin=new dn({url:n.url,headers:n.headers,fetch:n.fetch}),this.url=n.url,this.headers=n.headers,this.fetch=Wt(n.fetch),this.lock=n.lock||St,this.detectSessionInUrl=n.detectSessionInUrl,this.flowType=n.flowType,this.hasCustomAuthorizationHeader=n.hasCustomAuthorizationHeader,n.lock?this.lock=n.lock:B()&&(!((t=globalThis?.navigator)===null||t===void 0)&&t.locks)?this.lock=vn:this.lock=St,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)},this.persistSession?n.storage?this.storage=n.storage:ye()?this.storage=fn:(this.memoryStorage={},this.storage=Et(this.memoryStorage)):(this.memoryStorage={},this.storage=Et(this.memoryStorage)),B()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(i){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",i)}(r=this.broadcastChannel)===null||r===void 0||r.addEventListener("message",async i=>{this._debug("received broadcast notification from other tab or client",i),await this._notifyAllSubscribers(i.data.event,i.data.session,!1)})}this.initialize()}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${qt}) ${new Date().toISOString()}`,...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{const t=Hs(window.location.href);let r="none";if(this._isImplicitGrantCallback(t)?r="implicit":await this._isPKCECallback(t)&&(r="pkce"),B()&&this.detectSessionInUrl&&r!=="none"){const{data:n,error:i}=await this._getSessionFromURL(t,r);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),Is(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}=n;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(t){return w(t)?{error:t}:{error:new Vt("Unexpected error during initialization",t)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var t,r,n;try{const i=await E(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(r=(t=e?.options)===null||t===void 0?void 0:t.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:(n=e?.options)===null||n===void 0?void 0:n.captchaToken}},xform:W}),{data:a,error:o}=i;if(o||!a)return{data:{user:null,session:null},error:o};const l=a.session,u=a.user;return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",l)),{data:{user:u,session:l},error:null}}catch(i){if(w(i))return{data:{user:null,session:null},error:i};throw i}}async signUp(e){var t,r,n;try{let i;if("email"in e){const{email:c,password:d,options:f}=e;let p=null,v=null;this.flowType==="pkce"&&([p,v]=await oe(this.storage,this.storageKey)),i=await E(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:f?.emailRedirectTo,body:{email:c,password:d,data:(t=f?.data)!==null&&t!==void 0?t:{},gotrue_meta_security:{captcha_token:f?.captchaToken},code_challenge:p,code_challenge_method:v},xform:W})}else if("phone"in e){const{phone:c,password:d,options:f}=e;i=await E(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:c,password:d,data:(r=f?.data)!==null&&r!==void 0?r:{},channel:(n=f?.channel)!==null&&n!==void 0?n:"sms",gotrue_meta_security:{captcha_token:f?.captchaToken}},xform:W})}else throw new Te("You must provide either an email or phone number and a password");const{data:a,error:o}=i;if(o||!a)return{data:{user:null,session:null},error:o};const l=a.session,u=a.user;return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",l)),{data:{user:u,session:l},error:null}}catch(i){if(w(i))return{data:{user:null,session:null},error:i};throw i}}async signInWithPassword(e){try{let t;if("email"in e){const{email:i,password:a,options:o}=e;t=await E(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:i,password:a,gotrue_meta_security:{captcha_token:o?.captchaToken}},xform:kt})}else if("phone"in e){const{phone:i,password:a,options:o}=e;t=await E(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:i,password:a,gotrue_meta_security:{captcha_token:o?.captchaToken}},xform:kt})}else throw new Te("You must provide either an email or phone number and a password");const{data:r,error:n}=t;return n?{data:{user:null,session:null},error:n}:!r||!r.session||!r.user?{data:{user:null,session:null},error:new Me}:(r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),{data:Object.assign({user:r.user,session:r.session},r.weak_password?{weakPassword:r.weak_password}:null),error:n})}catch(t){if(w(t))return{data:{user:null,session:null},error:t};throw t}}async signInWithOAuth(e){var t,r,n,i;return await this._handleProviderSignIn(e.provider,{redirectTo:(t=e.options)===null||t===void 0?void 0:t.redirectTo,scopes:(r=e.options)===null||r===void 0?void 0:r.scopes,queryParams:(n=e.options)===null||n===void 0?void 0:n.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 _exchangeCodeForSession(e){const t=await Pe(this.storage,`${this.storageKey}-code-verifier`),[r,n]=(t??"").split("/");try{const{data:i,error:a}=await E(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:r},xform:W});if(await Ae(this.storage,`${this.storageKey}-code-verifier`),a)throw a;return!i||!i.session||!i.user?{data:{user:null,session:null,redirectType:null},error:new Me}:(i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",i.session)),{data:Object.assign(Object.assign({},i),{redirectType:n??null}),error:a})}catch(i){if(w(i))return{data:{user:null,session:null,redirectType:null},error:i};throw i}}async signInWithIdToken(e){try{const{options:t,provider:r,token:n,access_token:i,nonce:a}=e,o=await E(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:n,access_token:i,nonce:a,gotrue_meta_security:{captcha_token:t?.captchaToken}},xform:W}),{data:l,error:u}=o;return u?{data:{user:null,session:null},error:u}:!l||!l.session||!l.user?{data:{user:null,session:null},error:new Me}:(l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",l.session)),{data:l,error:u})}catch(t){if(w(t))return{data:{user:null,session:null},error:t};throw t}}async signInWithOtp(e){var t,r,n,i,a;try{if("email"in e){const{email:o,options:l}=e;let u=null,c=null;this.flowType==="pkce"&&([u,c]=await oe(this.storage,this.storageKey));const{error:d}=await E(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:o,data:(t=l?.data)!==null&&t!==void 0?t:{},create_user:(r=l?.shouldCreateUser)!==null&&r!==void 0?r:!0,gotrue_meta_security:{captcha_token:l?.captchaToken},code_challenge:u,code_challenge_method:c},redirectTo:l?.emailRedirectTo});return{data:{user:null,session:null},error:d}}if("phone"in e){const{phone:o,options:l}=e,{data:u,error:c}=await E(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:o,data:(n=l?.data)!==null&&n!==void 0?n:{},create_user:(i=l?.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:l?.captchaToken},channel:(a=l?.channel)!==null&&a!==void 0?a:"sms"}});return{data:{user:null,session:null,messageId:u?.message_id},error:c}}throw new Te("You must provide either an email or phone number.")}catch(o){if(w(o))return{data:{user:null,session:null},error:o};throw o}}async verifyOtp(e){var t,r;try{let n,i;"options"in e&&(n=(t=e.options)===null||t===void 0?void 0:t.redirectTo,i=(r=e.options)===null||r===void 0?void 0:r.captchaToken);const{data:a,error:o}=await E(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:n,xform:W});if(o)throw o;if(!a)throw new Error("An error occurred on token verification.");const l=a.session,u=a.user;return l?.access_token&&(await this._saveSession(l),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l)),{data:{user:u,session:l},error:null}}catch(n){if(w(n))return{data:{user:null,session:null},error:n};throw n}}async signInWithSSO(e){var t,r,n;try{let i=null,a=null;return this.flowType==="pkce"&&([i,a]=await oe(this.storage,this.storageKey)),await E(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(r=(t=e.options)===null||t===void 0?void 0:t.redirectTo)!==null&&r!==void 0?r:void 0}),!((n=e?.options)===null||n===void 0)&&n.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:i,code_challenge_method:a}),headers:this.headers,xform:on})}catch(i){if(w(i))return{data:null,error:i};throw i}}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:t},error:r}=e;if(r)throw r;if(!t)throw new G;const{error:n}=await E(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:t.access_token});return{data:{user:null,session:null},error:n}})}catch(e){if(w(e))return{data:{user:null,session:null},error:e};throw e}}async resend(e){try{const t=`${this.url}/resend`;if("email"in e){const{email:r,type:n,options:i}=e,{error:a}=await E(this.fetch,"POST",t,{headers:this.headers,body:{email:r,type:n,gotrue_meta_security:{captcha_token:i?.captchaToken}},redirectTo:i?.emailRedirectTo});return{data:{user:null,session:null},error:a}}else if("phone"in e){const{phone:r,type:n,options:i}=e,{data:a,error:o}=await E(this.fetch,"POST",t,{headers:this.headers,body:{phone:r,type:n,gotrue_meta_security:{captcha_token:i?.captchaToken}}});return{data:{user:null,session:null,messageId:a?.message_id},error:o}}throw new Te("You must provide either an email or phone number and a type")}catch(t){if(w(t))return{data:{user:null,session:null},error:t};throw t}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async t=>t))}async _acquireLock(e,t){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),n=(async()=>(await r,await t()))();return this.pendingInLock.push((async()=>{try{await n}catch{}})()),n}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const r=t();for(this.pendingInLock.push((async()=>{try{await r}catch{}})()),await r;this.pendingInLock.length;){const n=[...this.pendingInLock];await Promise.all(n),this.pendingInLock.splice(0,n.length)}return await r}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const t=await this.__loadSession();return await e(t)}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 t=await Pe(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",t),t!==null&&(this._isValidSession(t)?e=t:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const r=e.expires_at?e.expires_at*1e3-Date.now()(!a&&u==="user"&&(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."),a=!0,this.suppressGetSessionWarning=!0),Reflect.get(l,u,c))})}return{data:{session:e},error:null}}const{session:n,error:i}=await this._callRefreshToken(e.refresh_token);return i?{data:{session:null},error:i}:{data:{session:n},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(e){return e?await this._getUser(e):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(e){try{return e?await E(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:K}):await this._useSession(async t=>{var r,n,i;const{data:a,error:o}=t;if(o)throw o;return!(!((r=a.session)===null||r===void 0)&&r.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new G}:await E(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(i=(n=a.session)===null||n===void 0?void 0:n.access_token)!==null&&i!==void 0?i:void 0,xform:K})})}catch(t){if(w(t))return Ls(t)&&(await this._removeSession(),await Ae(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:t};throw t}}async updateUser(e,t={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(e,t))}async _updateUser(e,t={}){try{return await this._useSession(async r=>{const{data:n,error:i}=r;if(i)throw i;if(!n.session)throw new G;const a=n.session;let o=null,l=null;this.flowType==="pkce"&&e.email!=null&&([o,l]=await oe(this.storage,this.storageKey));const{data:u,error:c}=await E(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:t?.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:o,code_challenge_method:l}),jwt:a.access_token,xform:K});if(c)throw c;return a.user=u.user,await this._saveSession(a),await this._notifyAllSubscribers("USER_UPDATED",a),{data:{user:a.user},error:null}})}catch(r){if(w(r))return{data:{user:null},error:r};throw r}}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 G;const t=Date.now()/1e3;let r=t,n=!0,i=null;const{payload:a}=qe(e.access_token);if(a.exp&&(r=a.exp,n=r<=t),n){const{session:o,error:l}=await this._callRefreshToken(e.refresh_token);if(l)return{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:r-t,expires_at:r},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return{data:{user:i.user,session:i},error:null}}catch(t){if(w(t))return{data:{session:null,user:null},error:t};throw t}}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 t=>{var r;if(!e){const{data:a,error:o}=t;if(o)throw o;e=(r=a.session)!==null&&r!==void 0?r:void 0}if(!e?.refresh_token)throw new G;const{session:n,error:i}=await this._callRefreshToken(e.refresh_token);return i?{data:{user:null,session:null},error:i}:n?{data:{user:n.user,session:n},error:null}:{data:{user:null,session:null},error:null}})}catch(t){if(w(t))return{data:{user:null,session:null},error:t};throw t}}async _getSessionFromURL(e,t){try{if(!B())throw new xe("No browser detected.");if(e.error||e.error_description||e.error_code)throw new xe(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(t){case"implicit":if(this.flowType==="pkce")throw new vt("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new xe("Not a valid implicit grant flow url.");break;default:}if(t==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new vt("No code detected.");const{data:_,error:S}=await this._exchangeCodeForSession(e.code);if(S)throw S;const b=new URL(window.location.href);return b.searchParams.delete("code"),window.history.replaceState(window.history.state,"",b.toString()),{data:{session:_.session,redirectType:null},error:null}}const{provider_token:r,provider_refresh_token:n,access_token:i,refresh_token:a,expires_in:o,expires_at:l,token_type:u}=e;if(!i||!o||!a||!u)throw new xe("No session defined in URL");const c=Math.round(Date.now()/1e3),d=parseInt(o);let f=c+d;l&&(f=parseInt(l));const p=f-c;p*1e3<=ce&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${p}s, should have been closer to ${d}s`);const v=f-d;c-v>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",v,f,c):c-v<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",v,f,c);const{data:m,error:g}=await this._getUser(i);if(g)throw g;const y={provider_token:r,provider_refresh_token:n,access_token:i,expires_in:d,expires_at:f,refresh_token:a,token_type:u,user:m.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:y,redirectType:e.type},error:null}}catch(r){if(w(r))return{data:{session:null,redirectType:null},error:r};throw r}}_isImplicitGrantCallback(e){return!!(e.access_token||e.error_description)}async _isPKCECallback(e){const t=await Pe(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&t)}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 t=>{var r;const{data:n,error:i}=t;if(i)return{error:i};const a=(r=n.session)===null||r===void 0?void 0:r.access_token;if(a){const{error:o}=await this.admin.signOut(a,e);if(o&&!(Rs(o)&&(o.status===404||o.status===401||o.status===403)))return{error:o}}return e!=="others"&&(await this._removeSession(),await Ae(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(e){const t=qs(),r={id:t,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",t),this.stateChangeEmitters.delete(t)}};return this._debug("#onAuthStateChange()","registered callback with id",t),this.stateChangeEmitters.set(t,r),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(t)})))(),{data:{subscription:r}}}async _emitInitialSession(e){return await this._useSession(async t=>{var r,n;try{const{data:{session:i},error:a}=t;if(a)throw a;await((r=this.stateChangeEmitters.get(e))===null||r===void 0?void 0:r.callback("INITIAL_SESSION",i)),this._debug("INITIAL_SESSION","callback id",e,"session",i)}catch(i){await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",i),console.error(i)}})}async resetPasswordForEmail(e,t={}){let r=null,n=null;this.flowType==="pkce"&&([r,n]=await oe(this.storage,this.storageKey,!0));try{return await E(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:r,code_challenge_method:n,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo})}catch(i){if(w(i))return{data:null,error:i};throw i}}async getUserIdentities(){var e;try{const{data:t,error:r}=await this.getUser();if(r)throw r;return{data:{identities:(e=t.user.identities)!==null&&e!==void 0?e:[]},error:null}}catch(t){if(w(t))return{data:null,error:t};throw t}}async linkIdentity(e){var t;try{const{data:r,error:n}=await this._useSession(async i=>{var a,o,l,u,c;const{data:d,error:f}=i;if(f)throw f;const p=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 E(this.fetch,"GET",p,{headers:this.headers,jwt:(c=(u=d.session)===null||u===void 0?void 0:u.access_token)!==null&&c!==void 0?c:void 0})});if(n)throw n;return B()&&!(!((t=e.options)===null||t===void 0)&&t.skipBrowserRedirect)&&window.location.assign(r?.url),{data:{provider:e.provider,url:r?.url},error:null}}catch(r){if(w(r))return{data:{provider:e.provider,url:null},error:r};throw r}}async unlinkIdentity(e){try{return await this._useSession(async t=>{var r,n;const{data:i,error:a}=t;if(a)throw a;return await E(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(n=(r=i.session)===null||r===void 0?void 0:r.access_token)!==null&&n!==void 0?n:void 0})})}catch(t){if(w(t))return{data:null,error:t};throw t}}async _refreshAccessToken(e){const t=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(t,"begin");try{const r=Date.now();return await Ws(async n=>(n>0&&await Gs(200*Math.pow(2,n-1)),this._debug(t,"refreshing attempt",n),await E(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:W})),(n,i)=>{const a=200*Math.pow(2,n);return i&&ze(i)&&Date.now()+a-r{try{await o.callback(e,t)}catch(l){i.push(l)}});if(await Promise.all(a),i.length>0){for(let o=0;othis._autoRefreshTokenTick(),ce);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 t=>{const{data:{session:r}}=t;if(!r||!r.refresh_token||!r.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const n=Math.floor((r.expires_at*1e3-e)/ce);this._debug("#_autoRefreshTokenTick()",`access token expires in ${n} ticks, a tick lasts ${ce}ms, refresh threshold is ${Ye} ticks`),n<=Ye&&await this._callRefreshToken(r.refresh_token)})}catch(t){console.error("Auto refresh tick failed with error. This is likely a transient error.",t)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof Kt)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!B()||!window?.addEventListener)return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window?.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const t=`#_onVisibilityChanged(${e})`;this._debug(t,"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(t,"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,t,r){const n=[`provider=${encodeURIComponent(t)}`];if(r?.redirectTo&&n.push(`redirect_to=${encodeURIComponent(r.redirectTo)}`),r?.scopes&&n.push(`scopes=${encodeURIComponent(r.scopes)}`),this.flowType==="pkce"){const[i,a]=await oe(this.storage,this.storageKey),o=new URLSearchParams({code_challenge:`${encodeURIComponent(i)}`,code_challenge_method:`${encodeURIComponent(a)}`});n.push(o.toString())}if(r?.queryParams){const i=new URLSearchParams(r.queryParams);n.push(i.toString())}return r?.skipBrowserRedirect&&n.push(`skip_http_redirect=${r.skipBrowserRedirect}`),`${e}?${n.join("&")}`}async _unenroll(e){try{return await this._useSession(async t=>{var r;const{data:n,error:i}=t;return i?{data:null,error:i}:await E(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(r=n?.session)===null||r===void 0?void 0:r.access_token})})}catch(t){if(w(t))return{data:null,error:t};throw t}}async _enroll(e){try{return await this._useSession(async t=>{var r,n;const{data:i,error:a}=t;if(a)return{data:null,error:a};const o=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:{issuer:e.issuer}),{data:l,error:u}=await E(this.fetch,"POST",`${this.url}/factors`,{body:o,headers:this.headers,jwt:(r=i?.session)===null||r===void 0?void 0:r.access_token});return u?{data:null,error:u}:(e.factorType==="totp"&&(!((n=l?.totp)===null||n===void 0)&&n.qr_code)&&(l.totp.qr_code=`data:image/svg+xml;utf-8,${l.totp.qr_code}`),{data:l,error:null})})}catch(t){if(w(t))return{data:null,error:t};throw t}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var r;const{data:n,error:i}=t;if(i)return{data:null,error:i};const{data:a,error:o}=await E(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:(r=n?.session)===null||r===void 0?void 0:r.access_token});return o?{data:null,error:o}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+a.expires_in},a)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",a),{data:a,error:o})})}catch(t){if(w(t))return{data:null,error:t};throw t}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var r;const{data:n,error:i}=t;return i?{data:null,error:i}:await E(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:{channel:e.channel},headers:this.headers,jwt:(r=n?.session)===null||r===void 0?void 0:r.access_token})})}catch(t){if(w(t))return{data:null,error:t};throw t}})}async _challengeAndVerify(e){const{data:t,error:r}=await this._challenge({factorId:e.factorId});return r?{data:null,error:r}:await this._verify({factorId:e.factorId,challengeId:t.id,code:e.code})}async _listFactors(){const{data:{user:e},error:t}=await this.getUser();if(t)return{data:null,error:t};const r=e?.factors||[],n=r.filter(a=>a.factor_type==="totp"&&a.status==="verified"),i=r.filter(a=>a.factor_type==="phone"&&a.status==="verified");return{data:{all:r,totp:n,phone:i},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async e=>{var t,r;const{data:{session:n},error:i}=e;if(i)return{data:null,error:i};if(!n)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:a}=qe(n.access_token);let o=null;a.aal&&(o=a.aal);let l=o;((r=(t=n.user.factors)===null||t===void 0?void 0:t.filter(d=>d.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(l="aal2");const c=a.amr||[];return{data:{currentLevel:o,nextLevel:l,currentAuthenticationMethods:c},error:null}}))}async fetchJwk(e,t={keys:[]}){let r=t.keys.find(a=>a.kid===e);if(r||(r=this.jwks.keys.find(a=>a.kid===e),r&&this.jwks_cached_at+Os>Date.now()))return r;const{data:n,error:i}=await E(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(i)throw i;if(!n.keys||n.keys.length===0)throw new we("JWKS is empty");if(this.jwks=n,this.jwks_cached_at=Date.now(),r=n.keys.find(a=>a.kid===e),!r)throw new we("No matching signing key found in JWKS");return r}async getClaims(e,t={keys:[]}){try{let r=e;if(!r){const{data:p,error:v}=await this.getSession();if(v||!p.session)return{data:null,error:v};r=p.session.access_token}const{header:n,payload:i,signature:a,raw:{header:o,payload:l}}=qe(r);if(en(i.exp),!n.kid||n.alg==="HS256"||!("crypto"in globalThis&&"subtle"in globalThis.crypto)){const{error:p}=await this.getUser(r);if(p)throw p;return{data:{claims:i,header:n,signature:a},error:null}}const u=tn(n.alg),c=await this.fetchJwk(n.kid,t),d=await crypto.subtle.importKey("jwk",c,u,!0,["verify"]);if(!await crypto.subtle.verify(u,d,a,Ms(`${o}.${l}`)))throw new we("Invalid JWT signature");return{data:{claims:i,header:n,signature:a},error:null}}catch(r){if(w(r))return{data:null,error:r};throw r}}}be.nextInstanceID=0;const _n=be;class wn extends _n{constructor(e){super(e)}}var yn=function(s,e,t,r){function n(i){return i instanceof t?i:new t(function(a){a(i)})}return new(t||(t=Promise))(function(i,a){function o(c){try{u(r.next(c))}catch(d){a(d)}}function l(c){try{u(r.throw(c))}catch(d){a(d)}}function u(c){c.done?i(c.value):n(c.value).then(o,l)}u((r=r.apply(s,e||[])).next())})};class bn{constructor(e,t,r){var n,i,a;if(this.supabaseUrl=e,this.supabaseKey=t,!e)throw new Error("supabaseUrl is required.");if(!t)throw new Error("supabaseKey is required.");const o=Cs(e);this.realtimeUrl=`${o}/realtime/v1`.replace(/^http/i,"ws"),this.authUrl=`${o}/auth/v1`,this.storageUrl=`${o}/storage/v1`,this.functionsUrl=`${o}/functions/v1`;const l=`sb-${new URL(this.authUrl).hostname.split(".")[0]}-auth-token`,u={db:ms,realtime:ws,auth:Object.assign(Object.assign({},_s),{storageKey:l}),global:vs},c=Ts(r??{},u);this.storageKey=(n=c.auth.storageKey)!==null&&n!==void 0?n:"",this.headers=(i=c.global.headers)!==null&&i!==void 0?i:{},c.accessToken?(this.accessToken=c.accessToken,this.auth=new Proxy({},{get:(d,f)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(f)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((a=c.auth)!==null&&a!==void 0?a:{},this.headers,c.global.fetch),this.fetch=Es(t,this._getAccessToken.bind(this),c.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},c.realtime)),this.rest=new Br(`${o}/rest/v1`,{headers:this.headers,schema:c.db.schema,fetch:this.fetch}),c.accessToken||this._listenForAuthEvents()}get functions(){return new pr(this.functionsUrl,{headers:this.headers,customFetch:this.fetch})}get storage(){return new fs(this.storageUrl,this.headers,this.fetch)}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,t={},r={}){return this.rest.rpc(e,t,r)}channel(e,t={config:{}}){return this.realtime.channel(e,t)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var e,t;return yn(this,void 0,void 0,function*(){if(this.accessToken)return yield this.accessToken();const{data:r}=yield this.auth.getSession();return(t=(e=r.session)===null||e===void 0?void 0:e.access_token)!==null&&t!==void 0?t:null})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:n,storageKey:i,flowType:a,lock:o,debug:l},u,c){const d={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new wn({url:this.authUrl,headers:Object.assign(Object.assign({},d),u),storageKey:i,autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:n,flowType:a,lock:o,debug:l,fetch:c,hasCustomAuthorizationHeader:"Authorization"in this.headers})}_initRealtimeClient(e){return new Xr(this.realtimeUrl,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e?.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,r)=>{this._handleTokenChanged(t,"CLIENT",r?.access_token)})}_handleTokenChanged(e,t,r){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==r?this.changedAccessToken=r:e==="SIGNED_OUT"&&(this.realtime.setAuth(),t=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const gi=(s,e,t)=>new bn(s,e,t);var vi={default:{colors:{brand:"hsl(153 60.0% 53.0%)",brandAccent:"hsl(154 54.8% 45.1%)",brandButtonText:"white",defaultButtonBackground:"white",defaultButtonBackgroundHover:"#eaeaea",defaultButtonBorder:"lightgray",defaultButtonText:"gray",dividerBackground:"#eaeaea",inputBackground:"transparent",inputBorder:"lightgray",inputBorderHover:"gray",inputBorderFocus:"gray",inputText:"black",inputLabelText:"gray",inputPlaceholder:"darkgray",messageText:"#2b805a",messageBackground:"#e7fcf1",messageBorder:"#d0f3e1",messageTextDanger:"#ff6369",messageBackgroundDanger:"#fff8f8",messageBorderDanger:"#822025",anchorTextColor:"gray",anchorTextHoverColor:"darkgray"},space:{spaceSmall:"4px",spaceMedium:"8px",spaceLarge:"16px",labelBottomMargin:"8px",anchorBottomMargin:"4px",emailInputSpacing:"4px",socialAuthSpacing:"4px",buttonPadding:"10px 15px",inputPadding:"10px 15px"},fontSizes:{baseBodySize:"13px",baseInputSize:"14px",baseLabelSize:"14px",baseButtonSize:"14px"},fonts:{bodyFontFamily:"ui-sans-serif, sans-serif",buttonFontFamily:"ui-sans-serif, sans-serif",inputFontFamily:"ui-sans-serif, sans-serif",labelFontFamily:"ui-sans-serif, sans-serif"},borderWidths:{buttonBorderWidth:"1px",inputBorderWidth:"1px"},radii:{borderRadiusButton:"4px",buttonBorderRadius:"4px",inputBorderRadius:"4px"}},dark:{colors:{brandButtonText:"white",defaultButtonBackground:"#2e2e2e",defaultButtonBackgroundHover:"#3e3e3e",defaultButtonBorder:"#3e3e3e",defaultButtonText:"white",dividerBackground:"#2e2e2e",inputBackground:"#1e1e1e",inputBorder:"#3e3e3e",inputBorderHover:"gray",inputBorderFocus:"gray",inputText:"white",inputPlaceholder:"darkgray",messageText:"#85e0b7",messageBackground:"#072719",messageBorder:"#2b805a",messageBackgroundDanger:"#1f1315"}}},x={SIGN_IN:"sign_in",SIGN_UP:"sign_up",FORGOTTEN_PASSWORD:"forgotten_password",MAGIC_LINK:"magic_link",UPDATE_PASSWORD:"update_password",VERIFY_OTP:"verify_otp"},kn="supabase-auth-ui",En={ROOT:"root",SIGN_IN:x.SIGN_IN,SIGN_UP:x.SIGN_UP,FORGOTTEN_PASSWORD:x.FORGOTTEN_PASSWORD,MAGIC_LINK:x.MAGIC_LINK,UPDATE_PASSWORD:x.UPDATE_PASSWORD,anchor:"ui-anchor",button:"ui-button",container:"ui-container",divider:"ui-divider",input:"ui-input",label:"ui-label",loader:"ui-loader",message:"ui-message"};function ie(s,e,t){var r,n;const i=[],a=En[s];return i.push(t?.prependedClassName?t?.prependedClassName+"_"+a:kn+"_"+a),(r=t?.className)!=null&&r[s]&&i.push((n=t?.className)==null?void 0:n[s]),(t?.extend===void 0||t?.extend===!0)&&i.push(e),i}function Xe(s,e){let t;if(s&&e&&typeof s=="object"&&typeof e=="object"){if(Array.isArray(e))for(t=0;te.hasOwnProperty(r)?e[r]:t)}var Cn={sign_up:{email_label:"Email address",password_label:"Create a Password",email_input_placeholder:"Your email address",password_input_placeholder:"Your password",button_label:"Sign up",loading_button_label:"Signing up ...",social_provider_text:"Sign in with {{provider}}",link_text:"Don't have an account? Sign up",confirmation_text:"Check your email for the confirmation link"},sign_in:{email_label:"Email address",password_label:"Your Password",email_input_placeholder:"Your email address",password_input_placeholder:"Your password",button_label:"Sign in",loading_button_label:"Signing in ...",social_provider_text:"Sign in with {{provider}}",link_text:"Already have an account? Sign in"},magic_link:{email_input_label:"Email address",email_input_placeholder:"Your email address",button_label:"Send Magic Link",loading_button_label:"Sending Magic Link ...",link_text:"Send a magic link email",confirmation_text:"Check your email for the magic link"},forgotten_password:{email_label:"Email address",password_label:"Your Password",email_input_placeholder:"Your email address",button_label:"Send reset password instructions",loading_button_label:"Sending reset instructions ...",link_text:"Forgot your password?",confirmation_text:"Check your email for the password reset link"},update_password:{password_label:"New password",password_input_placeholder:"Your new password",button_label:"Update password",loading_button_label:"Updating password ...",confirmation_text:"Your password has been updated"},verify_otp:{email_input_label:"Email address",email_input_placeholder:"Your email address",phone_input_label:"Phone number",phone_input_placeholder:"Your phone number",token_input_label:"Token",token_input_placeholder:"Your Otp token",button_label:"Verify token",loading_button_label:"Signing in ..."}};const Tn=q({fontFamily:"$bodyFontFamily",fontSize:"$baseBodySize",marginBottom:"$anchorBottomMargin",color:"$anchorTextColor",display:"block",textAlign:"center",textDecoration:"underline","&:hover":{color:"$anchorTextHoverColor"}}),se=({children:s,appearance:e,...t})=>{var r;const n=ie("anchor",Tn(),e);return h.createElement("a",{...t,style:(r=e?.style)==null?void 0:r.anchor,className:n.join(" ")},s)},xn=q({fontFamily:"$buttonFontFamily",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",borderRadius:"$borderRadiusButton",fontSize:"$baseButtonSize",padding:"$buttonPadding",cursor:"pointer",borderWidth:"$buttonBorderWidth",borderStyle:"solid",width:"100%",transitionProperty:"background-color",transitionTimingFunction:"cubic-bezier(0.4, 0, 0.2, 1)",transitionDuration:"100ms","&:disabled":{opacity:.7,cursor:"unset"},variants:{color:{default:{backgroundColor:"$defaultButtonBackground",color:"$defaultButtonText",borderColor:"$defaultButtonBorder","&:hover:not(:disabled)":{backgroundColor:"$defaultButtonBackgroundHover"}},primary:{backgroundColor:"$brand",color:"$brandButtonText",borderColor:"$brandAccent","&:hover:not(:disabled)":{backgroundColor:"$brandAccent"}}}}}),ge=({children:s,color:e="default",appearance:t,icon:r,loading:n=!1,...i})=>{var a;const o=ie("button",xn({color:e}),t);return h.createElement("button",{...i,style:(a=t?.style)==null?void 0:a.button,className:o.join(" "),disabled:n},r,s)},Pn=q({display:"flex",gap:"4px",variants:{direction:{horizontal:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(48px, 1fr))"},vertical:{flexDirection:"column",margin:"8px 0"}},gap:{small:{gap:"4px"},medium:{gap:"8px"},large:{gap:"16px"}}}}),N=({children:s,appearance:e,...t})=>{var r;const n=ie("container",Pn({direction:t.direction,gap:t.gap}),e);return h.createElement("div",{...t,style:(r=e?.style)==null?void 0:r.container,className:n.join(" ")},s)},An=q({background:"$dividerBackground",display:"block",margin:"16px 0",height:"1px",width:"100%"}),$n=({children:s,appearance:e,...t})=>{var r;const n=ie("divider",An(),e);return h.createElement("div",{...t,style:(r=e?.style)==null?void 0:r.divider,className:n.join(" ")})},On=q({fontFamily:"$inputFontFamily",background:"$inputBackground",borderRadius:"$inputBorderRadius",padding:"$inputPadding",cursor:"text",borderWidth:"$inputBorderWidth",borderColor:"$inputBorder",borderStyle:"solid",fontSize:"$baseInputSize",width:"100%",color:"$inputText",boxSizing:"border-box","&:hover":{borderColor:"$inputBorderHover",outline:"none"},"&:focus":{borderColor:"$inputBorderFocus",outline:"none"},"&::placeholder":{color:"$inputPlaceholder",letterSpacing:"initial"},transitionProperty:"background-color, border",transitionTimingFunction:"cubic-bezier(0.4, 0, 0.2, 1)",transitionDuration:"100ms",variants:{type:{default:{letterSpacing:"0px"},password:{letterSpacing:"0px"}}}}),Y=({children:s,appearance:e,...t})=>{var r;const n=ie("input",On({type:t.type==="password"?"password":"default"}),e);return h.createElement("input",{...t,style:(r=e?.style)==null?void 0:r.input,className:n.join(" ")},s)},jn=q({fontFamily:"$labelFontFamily",fontSize:"$baseLabelSize",marginBottom:"$labelBottomMargin",color:"$inputLabelText",display:"block"}),Z=({children:s,appearance:e,...t})=>{var r;const n=ie("label",jn(),e);return h.createElement("label",{...t,style:(r=e?.style)==null?void 0:r.label,className:n.join(" ")},s)},Rn=q({fontFamily:"$bodyFontFamily",fontSize:"$baseInputSize",marginBottom:"$labelBottomMargin",display:"block",textAlign:"center",borderRadius:"0.375rem",padding:"1.5rem 1rem",lineHeight:"1rem",color:"$messageText",backgroundColor:"$messageBackground",border:"1px solid $messageBorder",variants:{color:{danger:{color:"$messageTextDanger",backgroundColor:"$messageBackgroundDanger",border:"1px solid $messageBorderDanger"}}}}),F=({children:s,appearance:e,...t})=>{var r;const n=ie("message",Rn({color:t.color}),e);return h.createElement("span",{...t,style:(r=e?.style)==null?void 0:r.message,className:n.join(" ")},s)};function Yt({setAuthView:s=()=>{},supabaseClient:e,redirectTo:t,i18n:r,appearance:n,showLinks:i=!1}){var a;const[o,l]=k.useState(""),[u,c]=k.useState(""),[d,f]=k.useState(""),[p,v]=k.useState(!1),m=async y=>{var _,S;if(y.preventDefault(),c(""),f(""),v(!0),o.length===0){c((_=r?.magic_link)==null?void 0:_.empty_email_address),v(!1);return}const{error:b}=await e.auth.signInWithOtp({email:o,options:{emailRedirectTo:t}});b?c(b.message):f((S=r?.magic_link)==null?void 0:S.confirmation_text),v(!1)},g=r?.magic_link;return h.createElement("form",{id:"auth-magic-link",onSubmit:m},h.createElement(N,{gap:"large",direction:"vertical",appearance:n},h.createElement("div",null,h.createElement(Z,{htmlFor:"email",appearance:n},g?.email_input_label),h.createElement(Y,{id:"email",name:"email",type:"email",autoFocus:!0,placeholder:g?.email_input_placeholder,onChange:y=>{c&&c(""),l(y.target.value)},appearance:n})),h.createElement(ge,{color:"primary",type:"submit",loading:p,appearance:n},p?g?.loading_button_label:g?.button_label),i&&h.createElement(se,{href:"#auth-sign-in",onClick:y=>{y.preventDefault(),s(x.SIGN_IN)},appearance:n},(a=r?.sign_in)==null?void 0:a.link_text),d&&h.createElement(F,{appearance:n},d),u&&h.createElement(F,{color:"danger",appearance:n},u)))}const A=q({width:"21px",height:"21px"}),Ln=({provider:s})=>s=="google"?In():s=="facebook"?Dn():s=="twitter"?Un():s=="apple"?Bn():s=="github"?Nn():s=="gitlab"?Fn():s=="bitbucket"?Mn():s=="discord"?zn():s=="azure"?qn():s=="keycloak"?Hn():s=="linkedin"?Vn():s=="notion"?Gn():s=="slack"?Wn():s=="spotify"?Jn():s=="twitch"?Kn():s=="workos"?Yn():s=="kakao"?Zn():null,In=()=>h.createElement("svg",{className:A(),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",width:"21px",height:"21px"},h.createElement("path",{fill:"#FFC107",d:"M43.611,20.083H42V20H24v8h11.303c-1.649,4.657-6.08,8-11.303,8c-6.627,0-12-5.373-12-12c0-6.627,5.373-12,12-12c3.059,0,5.842,1.154,7.961,3.039l5.657-5.657C34.046,6.053,29.268,4,24,4C12.955,4,4,12.955,4,24c0,11.045,8.955,20,20,20c11.045,0,20-8.955,20-20C44,22.659,43.862,21.35,43.611,20.083z"}),h.createElement("path",{fill:"#FF3D00",d:"M6.306,14.691l6.571,4.819C14.655,15.108,18.961,12,24,12c3.059,0,5.842,1.154,7.961,3.039l5.657-5.657C34.046,6.053,29.268,4,24,4C16.318,4,9.656,8.337,6.306,14.691z"}),h.createElement("path",{fill:"#4CAF50",d:"M24,44c5.166,0,9.86-1.977,13.409-5.192l-6.19-5.238C29.211,35.091,26.715,36,24,36c-5.202,0-9.619-3.317-11.283-7.946l-6.522,5.025C9.505,39.556,16.227,44,24,44z"}),h.createElement("path",{fill:"#1976D2",d:"M43.611,20.083H42V20H24v8h11.303c-0.792,2.237-2.231,4.166-4.087,5.571c0.001-0.001,0.002-0.001,0.003-0.002l6.19,5.238C36.971,39.205,44,34,44,24C44,22.659,43.862,21.35,43.611,20.083z"})),Dn=()=>h.createElement("svg",{className:A(),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",width:"21px",height:"21px"},h.createElement("path",{fill:"#039be5",d:"M24 5A19 19 0 1 0 24 43A19 19 0 1 0 24 5Z"}),h.createElement("path",{fill:"#fff",d:"M26.572,29.036h4.917l0.772-4.995h-5.69v-2.73c0-2.075,0.678-3.915,2.619-3.915h3.119v-4.359c-0.548-0.074-1.707-0.236-3.897-0.236c-4.573,0-7.254,2.415-7.254,7.917v3.323h-4.701v4.995h4.701v13.729C22.089,42.905,23.032,43,24,43c0.875,0,1.729-0.08,2.572-0.194V29.036z"})),Un=()=>h.createElement("svg",{className:A(),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",width:"21px",height:"21px"},h.createElement("path",{fill:"#03A9F4",d:"M42,12.429c-1.323,0.586-2.746,0.977-4.247,1.162c1.526-0.906,2.7-2.351,3.251-4.058c-1.428,0.837-3.01,1.452-4.693,1.776C34.967,9.884,33.05,9,30.926,9c-4.08,0-7.387,3.278-7.387,7.32c0,0.572,0.067,1.129,0.193,1.67c-6.138-0.308-11.582-3.226-15.224-7.654c-0.64,1.082-1,2.349-1,3.686c0,2.541,1.301,4.778,3.285,6.096c-1.211-0.037-2.351-0.374-3.349-0.914c0,0.022,0,0.055,0,0.086c0,3.551,2.547,6.508,5.923,7.181c-0.617,0.169-1.269,0.263-1.941,0.263c-0.477,0-0.942-0.054-1.392-0.135c0.94,2.902,3.667,5.023,6.898,5.086c-2.528,1.96-5.712,3.134-9.174,3.134c-0.598,0-1.183-0.034-1.761-0.104C9.268,36.786,13.152,38,17.321,38c13.585,0,21.017-11.156,21.017-20.834c0-0.317-0.01-0.633-0.025-0.945C39.763,15.197,41.013,13.905,42,12.429"})),Bn=()=>h.createElement("svg",{className:A(),fill:"gray",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"21px",height:"21px"}," ",h.createElement("path",{d:"M 15.904297 1.078125 C 15.843359 1.06875 15.774219 1.0746094 15.699219 1.0996094 C 14.699219 1.2996094 13.600391 1.8996094 12.900391 2.5996094 C 12.300391 3.1996094 11.800781 4.1996094 11.800781 5.0996094 C 11.800781 5.2996094 11.999219 5.5 12.199219 5.5 C 13.299219 5.4 14.399609 4.7996094 15.099609 4.0996094 C 15.699609 3.2996094 16.199219 2.4 16.199219 1.5 C 16.199219 1.275 16.087109 1.10625 15.904297 1.078125 z M 16.199219 5.4003906 C 14.399219 5.4003906 13.600391 6.5 12.400391 6.5 C 11.100391 6.5 9.9003906 5.5 8.4003906 5.5 C 6.3003906 5.5 3.0996094 7.4996094 3.0996094 12.099609 C 2.9996094 16.299609 6.8 21 9 21 C 10.3 21 10.600391 20.199219 12.400391 20.199219 C 14.200391 20.199219 14.600391 21 15.900391 21 C 17.400391 21 18.500391 19.399609 19.400391 18.099609 C 19.800391 17.399609 20.100391 17.000391 20.400391 16.400391 C 20.600391 16.000391 20.4 15.600391 20 15.400391 C 17.4 14.100391 16.900781 9.9003906 19.800781 8.4003906 C 20.300781 8.1003906 20.4 7.4992188 20 7.1992188 C 18.9 6.1992187 17.299219 5.4003906 16.199219 5.4003906 z"})),Nn=()=>h.createElement("svg",{className:A(),fill:"gray",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 30 30",width:"21px",height:"21px"}," ",h.createElement("path",{d:"M15,3C8.373,3,3,8.373,3,15c0,5.623,3.872,10.328,9.092,11.63C12.036,26.468,12,26.28,12,26.047v-2.051 c-0.487,0-1.303,0-1.508,0c-0.821,0-1.551-0.353-1.905-1.009c-0.393-0.729-0.461-1.844-1.435-2.526 c-0.289-0.227-0.069-0.486,0.264-0.451c0.615,0.174,1.125,0.596,1.605,1.222c0.478,0.627,0.703,0.769,1.596,0.769 c0.433,0,1.081-0.025,1.691-0.121c0.328-0.833,0.895-1.6,1.588-1.962c-3.996-0.411-5.903-2.399-5.903-5.098 c0-1.162,0.495-2.286,1.336-3.233C9.053,10.647,8.706,8.73,9.435,8c1.798,0,2.885,1.166,3.146,1.481C13.477,9.174,14.461,9,15.495,9 c1.036,0,2.024,0.174,2.922,0.483C18.675,9.17,19.763,8,21.565,8c0.732,0.731,0.381,2.656,0.102,3.594 c0.836,0.945,1.328,2.066,1.328,3.226c0,2.697-1.904,4.684-5.894,5.097C18.199,20.49,19,22.1,19,23.313v2.734 c0,0.104-0.023,0.179-0.035,0.268C23.641,24.676,27,20.236,27,15C27,8.373,21.627,3,15,3z"})),Fn=()=>h.createElement("svg",{className:A(),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",width:"21px",height:"21px"},h.createElement("path",{fill:"#e53935",d:"M24 43L16 20 32 20z"}),h.createElement("path",{fill:"#ff7043",d:"M24 43L42 20 32 20z"}),h.createElement("path",{fill:"#e53935",d:"M37 5L42 20 32 20z"}),h.createElement("path",{fill:"#ffa726",d:"M24 43L42 20 45 28z"}),h.createElement("path",{fill:"#ff7043",d:"M24 43L6 20 16 20z"}),h.createElement("path",{fill:"#e53935",d:"M11 5L6 20 16 20z"}),h.createElement("path",{fill:"#ffa726",d:"M24 43L6 20 3 28z"})),Mn=()=>h.createElement("svg",{className:A(),xmlns:"http://www.w3.org/2000/svg",width:"512",height:"512",viewBox:"0 0 62.42 62.42"},h.createElement("defs",null,h.createElement("linearGradient",{id:"New_Gradient_Swatch_1",x1:"64.01",y1:"30.27",x2:"32.99",y2:"54.48",gradientUnits:"userSpaceOnUse"},h.createElement("stop",{offset:"0.18",stopColor:"#0052cc"}),h.createElement("stop",{offset:"1",stopColor:"#2684ff"}))),h.createElement("title",null,"Bitbucket-blue"),h.createElement("g",{id:"Layer_2","data-name":"Layer 2"},h.createElement("g",{id:"Blue",transform:"translate(0 -3.13)"},h.createElement("path",{d:"M2,6.26A2,2,0,0,0,0,8.58L8.49,60.12a2.72,2.72,0,0,0,2.66,2.27H51.88a2,2,0,0,0,2-1.68L62.37,8.59a2,2,0,0,0-2-2.32ZM37.75,43.51h-13L21.23,25.12H40.9Z",fill:"#2684ff"}),h.createElement("path",{d:"M59.67,25.12H40.9L37.75,43.51h-13L9.4,61.73a2.71,2.71,0,0,0,1.75.66H51.89a2,2,0,0,0,2-1.68Z",fill:"url(#New_Gradient_Swatch_1)"})))),zn=()=>h.createElement("svg",{className:A(),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",width:"21px",height:"21px"},h.createElement("path",{fill:"#536dfe",d:"M39.248,10.177c-2.804-1.287-5.812-2.235-8.956-2.778c-0.057-0.01-0.114,0.016-0.144,0.068 c-0.387,0.688-0.815,1.585-1.115,2.291c-3.382-0.506-6.747-0.506-10.059,0c-0.3-0.721-0.744-1.603-1.133-2.291 c-0.03-0.051-0.087-0.077-0.144-0.068c-3.143,0.541-6.15,1.489-8.956,2.778c-0.024,0.01-0.045,0.028-0.059,0.051 c-5.704,8.522-7.267,16.835-6.5,25.044c0.003,0.04,0.026,0.079,0.057,0.103c3.763,2.764,7.409,4.442,10.987,5.554 c0.057,0.017,0.118-0.003,0.154-0.051c0.846-1.156,1.601-2.374,2.248-3.656c0.038-0.075,0.002-0.164-0.076-0.194 c-1.197-0.454-2.336-1.007-3.432-1.636c-0.087-0.051-0.094-0.175-0.014-0.234c0.231-0.173,0.461-0.353,0.682-0.534 c0.04-0.033,0.095-0.04,0.142-0.019c7.201,3.288,14.997,3.288,22.113,0c0.047-0.023,0.102-0.016,0.144,0.017 c0.22,0.182,0.451,0.363,0.683,0.536c0.08,0.059,0.075,0.183-0.012,0.234c-1.096,0.641-2.236,1.182-3.434,1.634 c-0.078,0.03-0.113,0.12-0.075,0.196c0.661,1.28,1.415,2.498,2.246,3.654c0.035,0.049,0.097,0.07,0.154,0.052 c3.595-1.112,7.241-2.79,11.004-5.554c0.033-0.024,0.054-0.061,0.057-0.101c0.917-9.491-1.537-17.735-6.505-25.044 C39.293,10.205,39.272,10.187,39.248,10.177z M16.703,30.273c-2.168,0-3.954-1.99-3.954-4.435s1.752-4.435,3.954-4.435 c2.22,0,3.989,2.008,3.954,4.435C20.658,28.282,18.906,30.273,16.703,30.273z M31.324,30.273c-2.168,0-3.954-1.99-3.954-4.435 s1.752-4.435,3.954-4.435c2.22,0,3.989,2.008,3.954,4.435C35.278,28.282,33.544,30.273,31.324,30.273z"})),qn=()=>h.createElement("svg",{className:A(),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",width:"21px",height:"21px"},h.createElement("linearGradient",{id:"k8yl7~hDat~FaoWq8WjN6a",x1:"-1254.397",x2:"-1261.911",y1:"877.268",y2:"899.466",gradientTransform:"translate(1981.75 -1362.063) scale(1.5625)",gradientUnits:"userSpaceOnUse"},h.createElement("stop",{offset:"0",stopColor:"#114a8b"}),h.createElement("stop",{offset:"1",stopColor:"#0669bc"})),h.createElement("path",{fill:"url(#k8yl7~hDat~FaoWq8WjN6a)",d:"M17.634,6h11.305L17.203,40.773c-0.247,0.733-0.934,1.226-1.708,1.226H6.697 c-0.994,0-1.8-0.806-1.8-1.8c0-0.196,0.032-0.39,0.094-0.576L15.926,7.227C16.173,6.494,16.86,6,17.634,6L17.634,6z"}),h.createElement("path",{fill:"#0078d4",d:"M34.062,29.324H16.135c-0.458-0.001-0.83,0.371-0.831,0.829c0,0.231,0.095,0.451,0.264,0.608 l11.52,10.752C27.423,41.826,27.865,42,28.324,42h10.151L34.062,29.324z"}),h.createElement("linearGradient",{id:"k8yl7~hDat~FaoWq8WjN6b",x1:"-1252.05",x2:"-1253.788",y1:"887.612",y2:"888.2",gradientTransform:"translate(1981.75 -1362.063) scale(1.5625)",gradientUnits:"userSpaceOnUse"},h.createElement("stop",{offset:"0",stopOpacity:".3"}),h.createElement("stop",{offset:".071",stopOpacity:".2"}),h.createElement("stop",{offset:".321",stopOpacity:".1"}),h.createElement("stop",{offset:".623",stopOpacity:".05"}),h.createElement("stop",{offset:"1",stopOpacity:"0"})),h.createElement("path",{fill:"url(#k8yl7~hDat~FaoWq8WjN6b)",d:"M17.634,6c-0.783-0.003-1.476,0.504-1.712,1.25L5.005,39.595 c-0.335,0.934,0.151,1.964,1.085,2.299C6.286,41.964,6.493,42,6.702,42h9.026c0.684-0.122,1.25-0.603,1.481-1.259l2.177-6.416 l7.776,7.253c0.326,0.27,0.735,0.419,1.158,0.422h10.114l-4.436-12.676l-12.931,0.003L28.98,6H17.634z"}),h.createElement("linearGradient",{id:"k8yl7~hDat~FaoWq8WjN6c",x1:"-1252.952",x2:"-1244.704",y1:"876.6",y2:"898.575",gradientTransform:"translate(1981.75 -1362.063) scale(1.5625)",gradientUnits:"userSpaceOnUse"},h.createElement("stop",{offset:"0",stopColor:"#3ccbf4"}),h.createElement("stop",{offset:"1",stopColor:"#2892df"})),h.createElement("path",{fill:"url(#k8yl7~hDat~FaoWq8WjN6c)",d:"M32.074,7.225C31.827,6.493,31.141,6,30.368,6h-12.6c0.772,0,1.459,0.493,1.705,1.224 l10.935,32.399c0.318,0.942-0.188,1.963-1.13,2.281C29.093,41.968,28.899,42,28.703,42h12.6c0.994,0,1.8-0.806,1.8-1.801 c0-0.196-0.032-0.39-0.095-0.575L32.074,7.225z"})),Hn=()=>h.createElement("svg",{className:A(),width:"512",height:"512",viewBox:"0 0 512 512",fill:"none",xmlns:"http://www.w3.org/2000/svg"},h.createElement("path",{d:"M472.136 163.959H408.584C407.401 163.959 406.218 163.327 405.666 162.3L354.651 73.6591C354.02 72.632 352.916 72 351.654 72H143.492C142.309 72 141.126 72.632 140.574 73.6591L87.5084 165.618L36.414 254.259C35.862 255.286 35.862 256.55 36.414 257.656L87.5084 346.297L140.495 438.335C141.047 439.362 142.23 440.073 143.413 439.994H351.654C352.837 439.994 354.02 439.362 354.651 438.335L405.745 349.694C406.297 348.667 407.48 347.956 408.663 348.035H472.215C474.344 348.035 476 346.297 476 344.243V167.83C475.921 165.697 474.186 163.959 472.136 163.959ZM228.728 349.694L212.721 377.345C212.485 377.74 212.091 378.135 211.696 378.372C211.223 378.609 210.75 378.767 210.198 378.767H178.422C177.318 378.767 176.293 378.214 175.82 377.187L128.431 294.787L123.779 286.65L106.748 257.498C106.511 257.103 106.353 256.629 106.432 256.076C106.432 255.602 106.59 255.049 106.827 254.654L123.937 224.949L175.899 134.886C176.451 133.938 177.476 133.306 178.501 133.306H210.198C210.75 133.306 211.302 133.464 211.854 133.701C212.248 133.938 212.643 134.254 212.879 134.728L228.886 162.537C229.359 163.485 229.28 164.67 228.728 165.539L177.397 254.654C177.16 255.049 177.081 255.523 177.081 255.918C177.081 256.392 177.239 256.787 177.397 257.182L228.728 346.218C229.438 347.403 229.359 348.667 228.728 349.694V349.694ZM388.083 257.498L371.051 286.65L366.399 294.787L319.011 377.187C318.459 378.135 317.512 378.767 316.409 378.767H284.632C284.08 378.767 283.607 378.609 283.134 378.372C282.74 378.135 282.346 377.819 282.109 377.345L266.103 349.694C265.393 348.667 265.393 347.403 266.024 346.376L317.355 257.34C317.591 256.945 317.67 256.471 317.67 256.076C317.67 255.602 317.513 255.207 317.355 254.812L266.024 165.697C265.472 164.749 265.393 163.643 265.866 162.695L281.873 134.886C282.109 134.491 282.503 134.096 282.898 133.859C283.371 133.543 283.923 133.464 284.553 133.464H316.409C317.512 133.464 318.538 134.017 319.011 135.044L370.972 225.107L388.083 254.812C388.319 255.286 388.477 255.76 388.477 256.234C388.477 256.55 388.319 257.024 388.083 257.498V257.498Z",fill:"#008AAA"})),Vn=()=>h.createElement("svg",{className:A(),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",width:"21px",height:"21px"},h.createElement("path",{fill:"#0288D1",d:"M42,37c0,2.762-2.238,5-5,5H11c-2.761,0-5-2.238-5-5V11c0-2.762,2.239-5,5-5h26c2.762,0,5,2.238,5,5V37z"}),h.createElement("path",{fill:"#FFF",d:"M12 19H17V36H12zM14.485 17h-.028C12.965 17 12 15.888 12 14.499 12 13.08 12.995 12 14.514 12c1.521 0 2.458 1.08 2.486 2.499C17 15.887 16.035 17 14.485 17zM36 36h-5v-9.099c0-2.198-1.225-3.698-3.192-3.698-1.501 0-2.313 1.012-2.707 1.99C24.957 25.543 25 26.511 25 27v9h-5V19h5v2.616C25.721 20.5 26.85 19 29.738 19c3.578 0 6.261 2.25 6.261 7.274L36 36 36 36z"})),Gn=()=>h.createElement("svg",{className:A(),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",width:"21px",height:"21px",fillRule:"evenodd",clipRule:"evenodd"},h.createElement("path",{fill:"#fff",fillRule:"evenodd",d:"M11.553,11.099c1.232,1.001,1.694,0.925,4.008,0.77 l21.812-1.31c0.463,0,0.078-0.461-0.076-0.538l-3.622-2.619c-0.694-0.539-1.619-1.156-3.391-1.002l-21.12,1.54 c-0.77,0.076-0.924,0.461-0.617,0.77L11.553,11.099z",clipRule:"evenodd"}),h.createElement("path",{fill:"#fff",fillRule:"evenodd",d:"M12.862,16.182v22.95c0,1.233,0.616,1.695,2.004,1.619 l23.971-1.387c1.388-0.076,1.543-0.925,1.543-1.927V14.641c0-1-0.385-1.54-1.234-1.463l-25.05,1.463 C13.171,14.718,12.862,15.181,12.862,16.182L12.862,16.182z",clipRule:"evenodd"}),h.createElement("path",{fill:"#424242",fillRule:"evenodd",d:"M11.553,11.099c1.232,1.001,1.694,0.925,4.008,0.77 l21.812-1.31c0.463,0,0.078-0.461-0.076-0.538l-3.622-2.619c-0.694-0.539-1.619-1.156-3.391-1.002l-21.12,1.54 c-0.77,0.076-0.924,0.461-0.617,0.77L11.553,11.099z M12.862,16.182v22.95c0,1.233,0.616,1.695,2.004,1.619l23.971-1.387 c1.388-0.076,1.543-0.925,1.543-1.927V14.641c0-1-0.385-1.54-1.234-1.463l-25.05,1.463C13.171,14.718,12.862,15.181,12.862,16.182 L12.862,16.182z M36.526,17.413c0.154,0.694,0,1.387-0.695,1.465l-1.155,0.23v16.943c-1.003,0.539-1.928,0.847-2.698,0.847 c-1.234,0-1.543-0.385-2.467-1.54l-7.555-11.86v11.475l2.391,0.539c0,0,0,1.386-1.929,1.386l-5.317,0.308 c-0.154-0.308,0-1.078,0.539-1.232l1.388-0.385V20.418l-1.927-0.154c-0.155-0.694,0.23-1.694,1.31-1.772l5.704-0.385l7.862,12.015 V19.493l-2.005-0.23c-0.154-0.848,0.462-1.464,1.233-1.54L36.526,17.413z M7.389,5.862l21.968-1.618 c2.698-0.231,3.392-0.076,5.087,1.155l7.013,4.929C42.614,11.176,43,11.407,43,12.33v27.032c0,1.694-0.617,2.696-2.775,2.849 l-25.512,1.541c-1.62,0.077-2.391-0.154-3.239-1.232l-5.164-6.7C5.385,34.587,5,33.664,5,32.585V8.556 C5,7.171,5.617,6.015,7.389,5.862z",clipRule:"evenodd"})),Wn=()=>h.createElement("svg",{className:A(),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",width:"21px",height:"21px"},h.createElement("path",{fill:"#33d375",d:"M33,8c0-2.209-1.791-4-4-4s-4,1.791-4,4c0,1.254,0,9.741,0,11c0,2.209,1.791,4,4,4s4-1.791,4-4 C33,17.741,33,9.254,33,8z"}),h.createElement("path",{fill:"#33d375",d:"M43,19c0,2.209-1.791,4-4,4c-1.195,0-4,0-4,0s0-2.986,0-4c0-2.209,1.791-4,4-4S43,16.791,43,19z"}),h.createElement("path",{fill:"#40c4ff",d:"M8,14c-2.209,0-4,1.791-4,4s1.791,4,4,4c1.254,0,9.741,0,11,0c2.209,0,4-1.791,4-4s-1.791-4-4-4 C17.741,14,9.254,14,8,14z"}),h.createElement("path",{fill:"#40c4ff",d:"M19,4c2.209,0,4,1.791,4,4c0,1.195,0,4,0,4s-2.986,0-4,0c-2.209,0-4-1.791-4-4S16.791,4,19,4z"}),h.createElement("path",{fill:"#e91e63",d:"M14,39.006C14,41.212,15.791,43,18,43s4-1.788,4-3.994c0-1.252,0-9.727,0-10.984 c0-2.206-1.791-3.994-4-3.994s-4,1.788-4,3.994C14,29.279,14,37.754,14,39.006z"}),h.createElement("path",{fill:"#e91e63",d:"M4,28.022c0-2.206,1.791-3.994,4-3.994c1.195,0,4,0,4,0s0,2.981,0,3.994c0,2.206-1.791,3.994-4,3.994 S4,30.228,4,28.022z"}),h.createElement("path",{fill:"#ffc107",d:"M39,33c2.209,0,4-1.791,4-4s-1.791-4-4-4c-1.254,0-9.741,0-11,0c-2.209,0-4,1.791-4,4s1.791,4,4,4 C29.258,33,37.746,33,39,33z"}),h.createElement("path",{fill:"#ffc107",d:"M28,43c-2.209,0-4-1.791-4-4c0-1.195,0-4,0-4s2.986,0,4,0c2.209,0,4,1.791,4,4S30.209,43,28,43z"})),Jn=()=>h.createElement("svg",{className:A(),width:"512",height:"512",viewBox:"0 0 512 512",fill:"none",xmlns:"http://www.w3.org/2000/svg"},h.createElement("path",{d:"M255.498 31.0034C131.513 31.0034 31 131.515 31 255.502C31 379.492 131.513 480 255.498 480C379.497 480 480 379.495 480 255.502C480 131.522 379.497 31.0135 255.495 31.0135L255.498 31V31.0034ZM358.453 354.798C354.432 361.391 345.801 363.486 339.204 359.435C286.496 327.237 220.139 319.947 141.993 337.801C134.463 339.516 126.957 334.798 125.24 327.264C123.516 319.731 128.217 312.225 135.767 310.511C221.284 290.972 294.639 299.384 353.816 335.549C360.413 339.596 362.504 348.2 358.453 354.798ZM385.932 293.67C380.864 301.903 370.088 304.503 361.858 299.438C301.512 262.345 209.528 251.602 138.151 273.272C128.893 276.067 119.118 270.851 116.309 261.61C113.521 252.353 118.74 242.597 127.981 239.782C209.512 215.044 310.87 227.026 380.17 269.612C388.4 274.68 391 285.456 385.935 293.676V293.673L385.932 293.67ZM388.293 230.016C315.935 187.039 196.56 183.089 127.479 204.055C116.387 207.42 104.654 201.159 101.293 190.063C97.9326 178.964 104.189 167.241 115.289 163.87C194.59 139.796 326.418 144.446 409.723 193.902C419.722 199.826 422.995 212.71 417.068 222.675C411.168 232.653 398.247 235.943 388.303 230.016H388.293V230.016Z",fill:"#1ED760"})),Kn=()=>h.createElement("svg",{className:A(),width:"512",height:"512",viewBox:"0 0 512 512",fill:"none",xmlns:"http://www.w3.org/2000/svg"},h.createElement("path",{d:"M416 240L352 304H288L232 360V304H160V64H416V240Z",fill:"white"}),h.createElement("path",{d:"M144 32L64 112V400H160V480L240 400H304L448 256V32H144ZM416 240L352 304H288L232 360V304H160V64H416V240Z",fill:"#9146FF"}),h.createElement("path",{d:"M368 120H336V216H368V120Z",fill:"#9146FF"}),h.createElement("path",{d:"M280 120H248V216H280V120Z",fill:"#9146FF"})),Yn=()=>h.createElement("svg",{className:A(),width:"512",height:"512",viewBox:"0 0 512 512",fill:"none",xmlns:"http://www.w3.org/2000/svg"},h.createElement("path",{d:"M33 256.043C33 264.556 35.3159 273.069 39.4845 280.202L117.993 415.493C126.098 429.298 138.373 440.572 153.657 445.634C183.764 455.528 214.797 442.873 229.618 417.333L248.609 384.661L173.806 256.043L252.777 119.831L271.768 87.1591C277.557 77.2654 284.968 69.4424 294 63H285.894H172.185C150.878 63 131.193 74.2742 120.54 92.6812L39.7161 231.884C35.3159 239.016 33 247.53 33 256.043Z",fill:"#6363F1"}),h.createElement("path",{d:"M480 256.058C480 247.539 477.684 239.021 473.516 231.883L393.849 94.6596C379.028 69.3331 347.995 56.4396 317.888 66.34C302.603 71.4053 290.329 82.6871 282.224 96.5015L264.391 127.354L339.194 256.058L260.223 392.131L241.232 424.825C235.443 434.495 228.032 442.553 219 449H227.106H340.815C362.122 449 381.807 437.718 392.46 419.299L473.284 280.003C477.684 272.866 480 264.577 480 256.058Z",fill:"#6363F1"})),Zn=()=>h.createElement("svg",{className:A(),xmlns:"http://www.w3.org/2000/svg",width:"2500",height:"2500",viewBox:"0 0 256 256"},h.createElement("path",{fill:"#FFE812",d:"M256 236c0 11.046-8.954 20-20 20H20c-11.046 0-20-8.954-20-20V20C0 8.954 8.954 0 20 0h216c11.046 0 20 8.954 20 20v216z"}),h.createElement("path",{d:"M128 36C70.562 36 24 72.713 24 118c0 29.279 19.466 54.97 48.748 69.477-1.593 5.494-10.237 35.344-10.581 37.689 0 0-.207 1.762.934 2.434s2.483.15 2.483.15c3.272-.457 37.943-24.811 43.944-29.04 5.995.849 12.168 1.29 18.472 1.29 57.438 0 104-36.712 104-82 0-45.287-46.562-82-104-82z"}),h.createElement("path",{fill:"#FFE812",d:"M70.5 146.625c-3.309 0-6-2.57-6-5.73V105.25h-9.362c-3.247 0-5.888-2.636-5.888-5.875s2.642-5.875 5.888-5.875h30.724c3.247 0 5.888 2.636 5.888 5.875s-2.642 5.875-5.888 5.875H76.5v35.645c0 3.16-2.691 5.73-6 5.73zM123.112 146.547c-2.502 0-4.416-1.016-4.993-2.65l-2.971-7.778-18.296-.001-2.973 7.783c-.575 1.631-2.488 2.646-4.99 2.646a9.155 9.155 0 0 1-3.814-.828c-1.654-.763-3.244-2.861-1.422-8.52l14.352-37.776c1.011-2.873 4.082-5.833 7.99-5.922 3.919.088 6.99 3.049 8.003 5.928l14.346 37.759c1.826 5.672.236 7.771-1.418 8.532a9.176 9.176 0 0 1-3.814.827c-.001 0 0 0 0 0zm-11.119-21.056L106 108.466l-5.993 17.025h11.986zM138 145.75c-3.171 0-5.75-2.468-5.75-5.5V99.5c0-3.309 2.748-6 6.125-6s6.125 2.691 6.125 6v35.25h12.75c3.171 0 5.75 2.468 5.75 5.5s-2.579 5.5-5.75 5.5H138zM171.334 146.547c-3.309 0-6-2.691-6-6V99.5c0-3.309 2.691-6 6-6s6 2.691 6 6v12.896l16.74-16.74c.861-.861 2.044-1.335 3.328-1.335 1.498 0 3.002.646 4.129 1.772 1.051 1.05 1.678 2.401 1.764 3.804.087 1.415-.384 2.712-1.324 3.653l-13.673 13.671 14.769 19.566a5.951 5.951 0 0 1 1.152 4.445 5.956 5.956 0 0 1-2.328 3.957 5.94 5.94 0 0 1-3.609 1.211 5.953 5.953 0 0 1-4.793-2.385l-14.071-18.644-2.082 2.082v13.091a6.01 6.01 0 0 1-6.002 6.003z"}));function Qn({supabaseClient:s,socialLayout:e="vertical",providers:t=["github","google","azure"],providerScopes:r,queryParams:n,redirectTo:i,onlyThirdPartyProviders:a=!0,view:o="sign_in",i18n:l,appearance:u}){const[c,d]=k.useState(!1),[f,p]=k.useState(""),v=e==="vertical",m=o==="magic_link"?"sign_in":o,g=async _=>{d(!0);const{error:S}=await s.auth.signInWithOAuth({provider:_,options:{redirectTo:i,scopes:r?.[_],queryParams:n}});S&&p(S.message),d(!1)};function y(_){const S=_.toLowerCase();return _.charAt(0).toUpperCase()+S.slice(1)}return h.createElement(h.Fragment,null,t&&t.length>0&&h.createElement(h.Fragment,null,h.createElement(N,{gap:"large",direction:"vertical",appearance:u},h.createElement(N,{direction:v?"vertical":"horizontal",gap:v?"small":"medium",appearance:u},t.map(_=>{var S;return h.createElement(ge,{key:_,color:"default",loading:c,onClick:()=>g(_),appearance:u},h.createElement(Ln,{provider:_}),v&&Sn((S=l?.[m])==null?void 0:S.social_provider_text,{provider:y(_)}))}))),!a&&h.createElement($n,{appearance:u})))}function Ct({authView:s="sign_in",defaultEmail:e="",defaultPassword:t="",setAuthView:r=()=>{},setDefaultEmail:n=v=>{},setDefaultPassword:i=v=>{},supabaseClient:a,showLinks:o=!1,redirectTo:l,additionalData:u,magicLink:c,i18n:d,appearance:f,children:p}){var v,m,g,y;const _=k.useRef(!0),[S,b]=k.useState(e),[C,H]=k.useState(t),[X,V]=k.useState(""),[Ce,M]=k.useState(!1),[D,er]=k.useState("");k.useEffect(()=>(_.current=!0,b(e),H(t),()=>{_.current=!1}),[s]);const tr=async $=>{var at;switch($.preventDefault(),V(""),M(!0),s){case"sign_in":const{error:ot}=await a.auth.signInWithPassword({email:S,password:C});ot&&V(ot.message);break;case"sign_up":let lt={emailRedirectTo:l};u&&(lt.data=u);const{data:{user:rr,session:sr},error:ct}=await a.auth.signUp({email:S,password:C,options:lt});ct?V(ct.message):rr&&!sr&&er((at=d?.sign_up)==null?void 0:at.confirmation_text);break}_.current&&M(!1)},it=$=>{n(S),i(C),r($)},L=d?.[s];return h.createElement("form",{id:s==="sign_in"?"auth-sign-in":"auth-sign-up",onSubmit:tr,autoComplete:"on",style:{width:"100%"}},h.createElement(N,{direction:"vertical",gap:"large",appearance:f},h.createElement(N,{direction:"vertical",gap:"large",appearance:f},h.createElement("div",null,h.createElement(Z,{htmlFor:"email",appearance:f},L?.email_label),h.createElement(Y,{id:"email",type:"email",name:"email",placeholder:L?.email_input_placeholder,defaultValue:S,onChange:$=>b($.target.value),autoComplete:"email",appearance:f})),h.createElement("div",null,h.createElement(Z,{htmlFor:"password",appearance:f},L?.password_label),h.createElement(Y,{id:"password",type:"password",name:"password",placeholder:L?.password_input_placeholder,defaultValue:C,onChange:$=>H($.target.value),autoComplete:s==="sign_in"?"current-password":"new-password",appearance:f})),p),h.createElement(ge,{type:"submit",color:"primary",loading:Ce,appearance:f},Ce?L?.loading_button_label:L?.button_label),o&&h.createElement(N,{direction:"vertical",gap:"small",appearance:f},s===x.SIGN_IN&&c&&h.createElement(se,{href:"#auth-magic-link",onClick:$=>{$.preventDefault(),r(x.MAGIC_LINK)},appearance:f},(v=d?.magic_link)==null?void 0:v.link_text),s===x.SIGN_IN&&h.createElement(se,{href:"#auth-forgot-password",onClick:$=>{$.preventDefault(),r(x.FORGOTTEN_PASSWORD)},appearance:f},(m=d?.forgotten_password)==null?void 0:m.link_text),s===x.SIGN_IN?h.createElement(se,{href:"#auth-sign-up",onClick:$=>{$.preventDefault(),it(x.SIGN_UP)},appearance:f},(g=d?.sign_up)==null?void 0:g.link_text):h.createElement(se,{href:"#auth-sign-in",onClick:$=>{$.preventDefault(),it(x.SIGN_IN)},appearance:f},(y=d?.sign_in)==null?void 0:y.link_text))),D&&h.createElement(F,{appearance:f},D),X&&h.createElement(F,{color:"danger",appearance:f},X))}function Zt({setAuthView:s=()=>{},supabaseClient:e,redirectTo:t,i18n:r,appearance:n,showLinks:i=!1}){var a;const[o,l]=k.useState(""),[u,c]=k.useState(""),[d,f]=k.useState(""),[p,v]=k.useState(!1),m=async y=>{var _;y.preventDefault(),c(""),f(""),v(!0);const{error:S}=await e.auth.resetPasswordForEmail(o,{redirectTo:t});S?c(S.message):f((_=r?.forgotten_password)==null?void 0:_.confirmation_text),v(!1)},g=r?.forgotten_password;return h.createElement("form",{id:"auth-forgot-password",onSubmit:m},h.createElement(N,{direction:"vertical",gap:"large",appearance:n},h.createElement(N,{gap:"large",direction:"vertical",appearance:n},h.createElement("div",null,h.createElement(Z,{htmlFor:"email",appearance:n},g?.email_label),h.createElement(Y,{id:"email",name:"email",type:"email",autoFocus:!0,placeholder:g?.email_input_placeholder,onChange:y=>l(y.target.value),appearance:n})),h.createElement(ge,{type:"submit",color:"primary",loading:p,appearance:n},p?g?.loading_button_label:g?.button_label),i&&h.createElement(se,{href:"#auth-sign-in",onClick:y=>{y.preventDefault(),s(x.SIGN_IN)},appearance:n},(a=r?.sign_in)==null?void 0:a.link_text),d&&h.createElement(F,{appearance:n},d),u&&h.createElement(F,{color:"danger",appearance:n},u))))}function Qt({supabaseClient:s,i18n:e,appearance:t}){const[r,n]=k.useState(""),[i,a]=k.useState(""),[o,l]=k.useState(""),[u,c]=k.useState(!1),d=async p=>{var v;p.preventDefault(),a(""),l(""),c(!0);const{error:m}=await s.auth.updateUser({password:r});m?a(m.message):l((v=e?.update_password)==null?void 0:v.confirmation_text),c(!1)},f=e?.update_password;return h.createElement("form",{id:"auth-update-password",onSubmit:d},h.createElement(N,{gap:"large",direction:"vertical",appearance:t},h.createElement("div",null,h.createElement(Z,{htmlFor:"password",appearance:t},f?.password_label),h.createElement(Y,{id:"password",name:"password",placeholder:f?.password_input_placeholder,type:"password",autoFocus:!0,onChange:p=>n(p.target.value),appearance:t})),h.createElement(ge,{type:"submit",color:"primary",loading:u,appearance:t},u?f?.loading_button_label:f?.button_label),o&&h.createElement(F,{appearance:t},o),i&&h.createElement(F,{color:"danger",appearance:t},i)))}function Xn({setAuthView:s=()=>{},supabaseClient:e,otpType:t="email",i18n:r,appearance:n,showLinks:i=!1}){var a;const[o,l]=k.useState(""),[u,c]=k.useState(""),[d,f]=k.useState(""),[p,v]=k.useState(""),[m,g]=k.useState(""),[y,_]=k.useState(!1),S=async C=>{C.preventDefault(),v(""),g(""),_(!0);let H={email:o,token:d,type:t};["sms","phone_change"].includes(t)&&(H={phone:u,token:d,type:t});const{error:X}=await e.auth.verifyOtp(H);X&&v(X.message),_(!1)},b=r?.verify_otp;return h.createElement("form",{id:"auth-magic-link",onSubmit:S},h.createElement(N,{gap:"large",direction:"vertical",appearance:n},["sms","phone_change"].includes(t)?h.createElement("div",null,h.createElement(Z,{htmlFor:"phone",appearance:n},b?.phone_input_label),h.createElement(Y,{id:"phone",name:"phone",type:"text",autoFocus:!0,placeholder:b?.phone_input_placeholder,onChange:C=>c(C.target.value),appearance:n})):h.createElement("div",null,h.createElement(Z,{htmlFor:"email",appearance:n},b?.email_input_label),h.createElement(Y,{id:"email",name:"email",type:"email",autoFocus:!0,placeholder:b?.email_input_placeholder,onChange:C=>l(C.target.value),appearance:n})),h.createElement("div",null,h.createElement(Z,{htmlFor:"token",appearance:n},b?.token_input_label),h.createElement(Y,{id:"token",name:"token",type:"text",placeholder:b?.token_input_placeholder,onChange:C=>f(C.target.value),appearance:n})),h.createElement(ge,{color:"primary",type:"submit",loading:y,appearance:n},y?b?.loading_button_label:b?.button_label),i&&h.createElement(se,{href:"#auth-sign-in",onClick:C=>{C.preventDefault(),s(x.SIGN_IN)},appearance:n},(a=r?.sign_in)==null?void 0:a.link_text),m&&h.createElement(F,{appearance:n},m),p&&h.createElement(F,{color:"danger",appearance:n},p)))}const Xt=k.createContext({user:null,session:null}),ei=s=>{const{supabaseClient:e}=s,[t,r]=k.useState(null),[n,i]=k.useState(t?.user??null);k.useEffect(()=>{(async()=>{var l;const{data:u}=await e.auth.getSession();r(u.session),i(((l=u.session)==null?void 0:l.user)??null)})();const{data:o}=e.auth.onAuthStateChange(async(l,u)=>{r(u),i(u?.user??null)});return()=>{o?.subscription.unsubscribe()}},[]);const a={session:t,user:n};return h.createElement(Xt.Provider,{value:a,...s})},ti=()=>{const s=k.useContext(Xt);if(s===void 0)throw new Error("useUser must be used within a UserContextProvider.");return s};function Se({supabaseClient:s,socialLayout:e="vertical",providers:t,providerScopes:r,queryParams:n,view:i="sign_in",redirectTo:a,onlyThirdPartyProviders:o=!1,magicLink:l=!1,showLinks:u=!0,appearance:c,theme:d="default",localization:f={variables:{}},otpType:p="email",additionalData:v,children:m}){const g=He(Cn,f.variables??{}),[y,_]=k.useState(i),[S,b]=k.useState(""),[C,H]=k.useState(""),X=y==="sign_in"||y==="sign_up"||y==="magic_link";k.useEffect(()=>{var M,D;ir({theme:He(((M=c?.theme)==null?void 0:M.default)??{},((D=c?.variables)==null?void 0:D.default)??{})})},[c]);const V=({children:M})=>{var D;return h.createElement("div",{className:d!=="default"?ar(He(c?.theme[d],((D=c?.variables)==null?void 0:D[d])??{})):""},X&&h.createElement(Qn,{appearance:c,supabaseClient:s,providers:t,providerScopes:r,queryParams:n,socialLayout:e,redirectTo:a,onlyThirdPartyProviders:o,i18n:g,view:y}),!o&&M)};k.useEffect(()=>{const{data:M}=s.auth.onAuthStateChange(D=>{D==="PASSWORD_RECOVERY"?_("update_password"):D==="USER_UPDATED"&&_("sign_in")});return _(i),()=>M.subscription.unsubscribe()},[i]);const Ce={supabaseClient:s,setAuthView:_,defaultEmail:S,defaultPassword:C,setDefaultEmail:b,setDefaultPassword:H,redirectTo:a,magicLink:l,showLinks:u,i18n:g,appearance:c};switch(y){case x.SIGN_IN:return h.createElement(V,null,h.createElement(Ct,{...Ce,authView:"sign_in"}));case x.SIGN_UP:return h.createElement(V,null,h.createElement(Ct,{appearance:c,supabaseClient:s,authView:"sign_up",setAuthView:_,defaultEmail:S,defaultPassword:C,setDefaultEmail:b,setDefaultPassword:H,redirectTo:a,magicLink:l,showLinks:u,i18n:g,additionalData:v,children:m}));case x.FORGOTTEN_PASSWORD:return h.createElement(V,null,h.createElement(Zt,{appearance:c,supabaseClient:s,setAuthView:_,redirectTo:a,showLinks:u,i18n:g}));case x.MAGIC_LINK:return h.createElement(V,null,h.createElement(Yt,{appearance:c,supabaseClient:s,setAuthView:_,redirectTo:a,showLinks:u,i18n:g}));case x.UPDATE_PASSWORD:return h.createElement(Qt,{appearance:c,supabaseClient:s,i18n:g});case x.VERIFY_OTP:return h.createElement(Xn,{appearance:c,supabaseClient:s,otpType:p,i18n:g});default:return null}}Se.ForgottenPassword=Zt;Se.UpdatePassword=Qt;Se.MagicLink=Yt;Se.UserContextProvider=ei;Se.useUser=ti;q({borderRadius:"12px",boxShadow:"rgba(100, 100, 111, 0.2) 0px 7px 29px 0px",width:"360px",padding:"28px 32px"});export{nt as A,Se as S,vi as T,he as _,gi as c};