1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[479],{8714:function(e,t,r){"use strict";var s,i=Object.defineProperty,n=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,l={};((e,t)=>{for(var r in t)i(e,r,{get:t[r],enumerable:!0})})(l,{createBrowserSupabaseClient:()=>O,createClientComponentClient:()=>h,createMiddlewareClient:()=>v,createMiddlewareSupabaseClient:()=>I,createPagesBrowserClient:()=>u,createPagesServerClient:()=>g,createRouteHandlerClient:()=>C,createServerActionClient:()=>T,createServerComponentClient:()=>k,createServerSupabaseClient:()=>j}),e.exports=((e,t,r,s)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of a(t))o.call(e,r)||void 0===r||i(e,r,{get:()=>t[r],enumerable:!(s=n(t,r))||s.enumerable});return e})(i({},"__esModule",{value:!0}),l);var c=r(5874);function h({supabaseUrl:e="https://fjwxzsnwmlfuawioozpe.supabase.co",supabaseKey:t="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZqd3h6c253bWxmdWF3aW9venBlIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDUzMjYwNTUsImV4cCI6MjAyMDkwMjA1NX0.JGzqVoDpQrf7xByLGeGYIoWKKBZsdQ6E-J0Rxoo6rfw",options:r,cookieOptions:i,isSingleton:n=!0}={}){if(!e||!t)throw Error("either NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY env variables or supabaseUrl and supabaseKey are required!");let a=()=>{var s;return(0,c.createSupabaseClient)(e,t,{...r,global:{...null==r?void 0:r.global,headers:{...null==(s=null==r?void 0:r.global)?void 0:s.headers,"X-Client-Info":"@supabase/[email protected]"}},auth:{storage:new c.BrowserCookieAuthStorageAdapter(i)}})};if(n){let e=s??a();return"undefined"==typeof window?e:(s||(s=e),s)}return a()}var u=h,d=r(5874),f=r(7),p=class extends d.CookieAuthStorageAdapter{constructor(e,t){super(t),this.context=e}getCookie(e){var t,r,s;return(0,f.splitCookiesString)((null==(r=null==(t=this.context.res)?void 0:t.getHeader("set-cookie"))?void 0:r.toString())??"").map(t=>(0,d.parseCookies)(t)[e]).find(e=>!!e)??(null==(s=this.context.req)?void 0:s.cookies[e])}setCookie(e,t){this._setCookie(e,t)}deleteCookie(e){this._setCookie(e,"",{maxAge:0})}_setCookie(e,t,r){var s;let i=(0,f.splitCookiesString)((null==(s=this.context.res.getHeader("set-cookie"))?void 0:s.toString())??"").filter(t=>!(e in(0,d.parseCookies)(t))),n=(0,d.serializeCookie)(e,t,{...this.cookieOptions,...r,httpOnly:!1});this.context.res.setHeader("set-cookie",[...i,n])}};function g(e,{supabaseUrl:t="https://fjwxzsnwmlfuawioozpe.supabase.co",supabaseKey:r="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZqd3h6c253bWxmdWF3aW9venBlIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDUzMjYwNTUsImV4cCI6MjAyMDkwMjA1NX0.JGzqVoDpQrf7xByLGeGYIoWKKBZsdQ6E-J0Rxoo6rfw",options:s,cookieOptions:i}={}){var n;if(!t||!r)throw Error("either NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY env variables or supabaseUrl and supabaseKey are required!");return(0,d.createSupabaseClient)(t,r,{...s,global:{...null==s?void 0:s.global,headers:{...null==(n=null==s?void 0:s.global)?void 0:n.headers,"X-Client-Info":"@supabase/[email protected]"}},auth:{storage:new p(e,i)}})}var m=r(5874),b=r(7),y=class extends m.CookieAuthStorageAdapter{constructor(e,t){super(t),this.context=e}getCookie(e){var t;return(0,b.splitCookiesString)((null==(t=this.context.res.headers.get("set-cookie"))?void 0:t.toString())??"").map(t=>(0,m.parseCookies)(t)[e]).find(e=>!!e)||(0,m.parseCookies)(this.context.req.headers.get("cookie")??"")[e]}setCookie(e,t){this._setCookie(e,t)}deleteCookie(e){this._setCookie(e,"",{maxAge:0})}_setCookie(e,t,r){let s=(0,m.serializeCookie)(e,t,{...this.cookieOptions,...r,httpOnly:!1});this.context.res.headers&&this.context.res.headers.append("set-cookie",s)}};function v(e,{supabaseUrl:t="https://fjwxzsnwmlfuawioozpe.supabase.co",supabaseKey:r="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZqd3h6c253bWxmdWF3aW9venBlIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDUzMjYwNTUsImV4cCI6MjAyMDkwMjA1NX0.JGzqVoDpQrf7xByLGeGYIoWKKBZsdQ6E-J0Rxoo6rfw",options:s,cookieOptions:i}={}){var n;if(!t||!r)throw Error("either NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY env variables or supabaseUrl and supabaseKey are required!");return(0,m.createSupabaseClient)(t,r,{...s,global:{...null==s?void 0:s.global,headers:{...null==(n=null==s?void 0:s.global)?void 0:n.headers,"X-Client-Info":"@supabase/[email protected]"}},auth:{storage:new y(e,i)}})}var w=r(5874),_=class extends w.CookieAuthStorageAdapter{constructor(e,t){super(t),this.context=e}getCookie(e){var t;return null==(t=this.context.cookies().get(e))?void 0:t.value}setCookie(e,t){}deleteCookie(e){}};function k(e,{supabaseUrl:t="https://fjwxzsnwmlfuawioozpe.supabase.co",supabaseKey:r="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZqd3h6c253bWxmdWF3aW9venBlIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDUzMjYwNTUsImV4cCI6MjAyMDkwMjA1NX0.JGzqVoDpQrf7xByLGeGYIoWKKBZsdQ6E-J0Rxoo6rfw",options:s,cookieOptions:i}={}){var n;if(!t||!r)throw Error("either NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY env variables or supabaseUrl and supabaseKey are required!");return(0,w.createSupabaseClient)(t,r,{...s,global:{...null==s?void 0:s.global,headers:{...null==(n=null==s?void 0:s.global)?void 0:n.headers,"X-Client-Info":"@supabase/[email protected]"}},auth:{storage:new _(e,i)}})}var S=r(5874),E=class extends S.CookieAuthStorageAdapter{constructor(e,t){super(t),this.context=e}getCookie(e){var t;return null==(t=this.context.cookies().get(e))?void 0:t.value}setCookie(e,t){this.context.cookies().set(e,t,this.cookieOptions)}deleteCookie(e){this.context.cookies().set(e,"",{...this.cookieOptions,maxAge:0}
1)}};function C(e,{supabaseUrl:t="https://fjwxzsnwmlfuawioozpe.supabase.co",supabaseKey:r="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZqd3h6c253bWxmdWF3aW9venBlIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDUzMjYwNTUsImV4cCI6MjAyMDkwMjA1NX0.JGzqVoDpQrf7xByLGeGYIoWKKBZsdQ6E-J0Rxoo6rfw",options:s,cookieOptions:i}={}){var n;if(!t||!r)throw Error("either NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY env variables or supabaseUrl and supabaseKey are required!");return(0,S.createSupabaseClient)(t,r,{...s,global:{...null==s?void 0:s.global,headers:{...null==(n=null==s?void 0:s.global)?void 0:n.headers,"X-Client-Info":"@supabase/[email protected]"}},auth:{storage:new E(e,i)}})}var T=C;function O({supabaseUrl:e="https://fjwxzsnwmlfuawioozpe.supabase.co",supabaseKey:t="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZqd3h6c253bWxmdWF3aW9venBlIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDUzMjYwNTUsImV4cCI6MjAyMDkwMjA1NX0.JGzqVoDpQrf7xByLGeGYIoWKKBZsdQ6E-J0Rxoo6rfw",options:r,cookieOptions:s}={}){return console.warn("Please utilize the `createPagesBrowserClient` function instead of the deprecated `createBrowserSupabaseClient` function. Learn more: https://supabase.com/docs/guides/auth/auth-helpers/nextjs-pages"),u({supabaseUrl:e,supabaseKey:t,options:r,cookieOptions:s})}function j(e,{supabaseUrl:t="https://fjwxzsnwmlfuawioozpe.supabase.co",supabaseKey:r="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZqd3h6c253bWxmdWF3aW9venBlIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDUzMjYwNTUsImV4cCI6MjAyMDkwMjA1NX0.JGzqVoDpQrf7xByLGeGYIoWKKBZsdQ6E-J0Rxoo6rfw",options:s,cookieOptions:i}={}){return console.warn("Please utilize the `createPagesServerClient` function instead of the deprecated `createServerSupabaseClient` function. Learn more: https://supabase.com/docs/guides/auth/auth-helpers/nextjs-pages"),g(e,{supabaseUrl:t,supabaseKey:r,options:s,cookieOptions:i})}function I(e,{supabaseUrl:t="https://fjwxzsnwmlfuawioozpe.supabase.co",supabaseKey:r="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZqd3h6c253bWxmdWF3aW9venBlIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDUzMjYwNTUsImV4cCI6MjAyMDkwMjA1NX0.JGzqVoDpQrf7xByLGeGYIoWKKBZsdQ6E-J0Rxoo6rfw",options:s,cookieOptions:i}={}){return console.warn("Please utilize the `createMiddlewareClient` function instead of the deprecated `createMiddlewareSupabaseClient` function. Learn more: https://supabase.com/docs/guides/auth/auth-helpers/nextjs#middleware"),v(e,{supabaseUrl:t,supabaseKey:r,options:s,cookieOptions:i})}},5973:function(e,t,r){"use strict";var s=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==r.g)return r.g;throw Error("unable to locate global object")}();e.exports=t=s.fetch,s.fetch&&(t.default=s.fetch.bind(s)),t.Headers=s.Headers,t.Request=s.Request,t.Response=s.Response},6244:function(e){e.exports={"[data-theme=aqua]":{"color-scheme":"dark",primary:"#09ecf3","primary-content":"#005355",secondary:"#966fb3",accent:"#ffe999",neutral:"#3b8ac4","base-100":"#345da7",info:"#2563eb",success:"#16a34a",warning:"#d97706",error:"#dc2626"},"[data-theme=black]":{"color-scheme":"dark",primary:"#343232",secondary:"#343232",accent:"#343232","base-100":"#000000","base-200":"#0D0D0D","base-300":"#1A1919",neutral:"#272626","neutral-focus":"#343232",info:"#0000ff",success:"#008000",warning:"#ffff00",error:"#ff0000","--rounded-box":"0","--rounded-btn":"0","--rounded-badge":"0","--animation-btn":"0","--animation-input":"0","--btn-text-case":"lowercase","--btn-focus-scale":"1","--tab-radius":"0"},"[data-theme=bumblebee]":{"color-scheme":"light",primary:"#f9d72f","primary-content":"#181830",secondary:"#e0a82e","secondary-content":"#181830",accent:"#DC8850",neutral:"#181830","base-100":"#ffffff"},"[data-theme=cmyk]":{"color-scheme":"light",primary:"#45AEEE",secondary:"#E8488A",accent:"#FFF232",neutral:"#1a1a1a","base-100":"#ffffff",info:"#4AA8C0",success:"#823290",warning:"#EE8133",error:"#E93F33"},"[data-theme=corporate]":{"color-scheme":"light",primary:"#4b6bfb",secondary:"#7b92b2",accent:"#67cba0",neutral:"#181a2a","neutral-content":"#edf2f7","base-100":"#ffffff","base-content":"#181a2a","--rounded-box":"0.25rem","--rounded-btn":".125rem","--rounded-badge":".125rem","--animation-btn":"0","--animation-input":"0","--btn-focus-scale":"1"},"[data-theme=cupcake]":{"color-scheme":"light",primary:"#65c3c8",secondary:"#ef9fbc",accent:"#eeaf3a",neutral:"#291334","base-100":"#faf7f5","base-200":"#efeae6","base-300":"#e7e2df","base-content":"#291334","--rounded-btn":"1.9rem","--tab-border":"2px","--tab-radius":".5rem"},"[data-theme=cyberpunk]":{"color-scheme":"light",fontFamily:"ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace",primary:"#ff7598",secondary:"#75d1f0",accent:"#c07eec",neutral:"#423f00","neutral-content":"#ffee00","base-100":"#ffee00","--rounded-box":"0","--rounded-btn":"0","--rounded-badge":"0","--tab-radius":"0"},"[data-theme=dark]":{"color-scheme":"dark",primary:"#661AE6","primary-content":"#ffffff",secondary:"#D926AA","secondary-content":"#ffffff",accent:"#1FB2A5","accent-content":"#ffffff",neutral:"#2a323c","neutral-focus":"#242b33","neutral-content":"#A6ADBB","base-100":"#1d232a","base-200":"#191e24","base-300":"#15191e","base-content":"#A6ADBB"},"[data-theme=dracula]":{"color-scheme":"dark",primary:"#ff79c6",secondary:"#bd93f9",accent:"#ffb86c",neutral:"#414558","base-100":"#282a36","base-content":"#f8f8f2",info:"#8be9fd",success:"#50fa7b",warning:"#f1fa8c",error:"#ff5555"},"[data-theme=emerald]":{"color-scheme":"light",primary:"#66cc8a","primary-content":"#223D30",secondary:"#377cfb","secondary-content":"#f9fafb",accent:"#ea5234","accent-content":"#f9fafb",neutral:"#333c4d","neutral-content":"#f9fafb","base-100":"#ffffff","base-content":"#333c4d","--animation-btn":"0","--animation-input":"0","--btn-focus-scale":"1"},"[data-theme=fantasy]":{"color-scheme":"light",primary:"#6e0b75",secondary:"#007ebd",accent:"#f8860d",neutral:"#1f2937","base-100":"#ffffff","base-content":"#1f2937"},"[data-theme=forest]":{"color-scheme":"dark",primary:"#1eb854","primary-content":"#000000",secondary:"#1DB88E",accent:"#1DB8AB",neutral:"#19362D","base-100":"#171212","--rounded-btn":"1.9rem"},"[data-theme=garden]":{"color-scheme":"light",primary:"#F40076",secondary:"#8E4162",accent:"#5c7f67",neutral:"#291E00","neutral-content":"#e9e7e7","base-100":"#e9e7e7","base-content":"#100f0f"},"[data-theme=halloween]":{"color-scheme":"dark",primary:"#f28c18","primary-content":"#131616",secondary:"#6d3a9c",accent:"#51a800","accent-content":"#000000",neutral:"#2F1B05","base-100":"#212121",info:"#2563eb",success:"#16a34a",warning:"#d97706",error:"#dc2626"},"[data-theme=light]":{"color-scheme":"light",primary:"#570df8","primary-content":"#E0D2FE",secondary:"#f000b8","secondary-content":"#FFD1F4",accent:"#1ECEBC","accent-content":"#07312D",neutral:"#2B3440","neutral-content":"#D7DDE4","base-100":"#ffffff","base-200":"#F2F2F2","base-300":"#E5E6E6","base-content":"#1f2937"},"[data-theme=lofi]":{"color-scheme":"light",primary:"#0D0D0D","primary-content":"#ffffff",secondary:"#1A1919","secondary-content":"#ffffff",accent:"#262626","accent-content":"#ffffff",neutral:"#000000","neutral-content":"#ffffff","base-100":"#ffffff","base-200":"#F2F2F2","base-300":"#E6E5E5","base-content":"#000000",info:"#0070F3","info-content":"#ffffff",success:"#21CC51","success-content":"#000000",warning:"#FF6154","warning-content":"#ffffff",error:"#DE1C8D","error-content":"#ffffff","--rounded-box":"0.25rem","--rounded-btn":"0.125rem","--rounded-badge":"0.125rem","--animation-btn":"0","--animation-input":"0","--btn-focus-scale":"1","--tab-radius":"0"},"[data-theme=luxury]":{"color-scheme":"dark",primary:"#ffffff",secondary:"#152747",accent:"#513448",neutral:"#331800","neutral-content":"#FFE7A3","base-100":"#09090b","base-200":"#171618","base-300":"#2e2d2f","base-content":"#dca54c",info:"#66c6ff",success:"#87d039",warning:"#e2d562",error:"#ff6f6f"},"[data-theme=pastel]":{"color-scheme":"light",primary:"#d1c1d7",secondary:"#f6cbd1",accent:"#b4e9d6",neutral:"#70acc7","base-100":"#ffffff","base-200":"#f9fafb","base-300":"#d1d5db","--rounded-btn":"1.9rem"},"[data-theme=retro]":{"color-scheme":"light",primary:"#ef9995","primary-content":"#282425",secondary:"#a4cbb4","secondary-content":"#282425",accent:"#DC8850","accent-content":"#282425",neutral:"#2
1E282A","neutral-content":"#EDE6D4","base-100":"#e4d8b4","base-200":"#DBCA9A","base-300":"#D4BF87","base-content":"#282425",info:"#2563eb",success:"#16a34a",warning:"#d97706",error:"#dc2626","--rounded-box":"0.4rem","--rounded-btn":"0.4rem","--rounded-badge":"0.4rem"},"[data-theme=synthwave]":{"color-scheme":"dark",primary:"#e779c1",secondary:"#58c7f3",accent:"#f3cc30",neutral:"#221551","neutral-content":"#f9f7fd","base-100":"#1a103d","base-content":"#f9f7fd",info:"#53c0f3","info-content":"#201047",success:"#71ead2","success-content":"#201047",warning:"#f3cc30","warning-content":"#201047",error:"#e24056","error-content":"#f9f7fd"},"[data-theme=valentine]":{"color-scheme":"light",primary:"#e96d7b",secondary:"#a991f7",accent:"#88dbdd",neutral:"#af4670","neutral-content":"#f0d6e8","base-100":"#f0d6e8","base-content":"#632c3b",info:"#2563eb",success:"#16a34a",warning:"#d97706",error:"#dc2626","--rounded-btn":"1.9rem"},"[data-theme=wireframe]":{"color-scheme":"light",fontFamily:'Chalkboard,comic sans ms,"sanssecondaryerif"',primary:"#b8b8b8",secondary:"#b8b8b8",accent:"#b8b8b8",neutral:"#ebebeb","base-100":"#ffffff","base-200":"#eeeeee","base-300":"#dddddd",info:"#0000ff",success:"#008000",warning:"#a6a659",error:"#ff0000","--rounded-box":"0.2rem","--rounded-btn":"0.2rem","--rounded-badge":"0.2rem","--tab-radius":"0.2rem"},"[data-theme=autumn]":{"color-scheme":"light",primary:"#8C0327",secondary:"#D85251",accent:"#D59B6A",neutral:"#826A5C","base-100":"#f1f1f1",info:"#42ADBB",success:"#499380",warning:"#E97F14",error:"#DF1A2F"},"[data-theme=business]":{"color-scheme":"dark",primary:"#1C4E80",secondary:"#7C909A",accent:"#EA6947",neutral:"#23282E","base-100":"#202020",info:"#0091D5",success:"#6BB187",warning:"#DBAE59",error:"#AC3E31","--rounded-box":"0.25rem","--rounded-btn":".125rem","--rounded-badge":".125rem"},"[data-theme=acid]":{"color-scheme":"light",primary:"#FF00F4",secondary:"#FF7400",accent:"#CBFD03",neutral:"#191A3F","base-100":"#fafafa",info:"#3194F6",success:"#5FC992",warning:"#F7DE2D",error:"#E60300","--rounded-box":"1.25rem","--rounded-btn":"1rem","--rounded-badge":"1rem"},"[data-theme=lemonade]":{"color-scheme":"light",primary:"#519903",secondary:"#E9E92E",accent:"#F7F9CA",neutral:"#191A3F","base-100":"#ffffff",info:"#C8E1E7",success:"#DEF29F",warning:"#F7E589",error:"#F2B6B5"},"[data-theme=night]":{"color-scheme":"dark",primary:"#38bdf8",secondary:"#818CF8",accent:"#F471B5",neutral:"#1E293B","neutral-focus":"#273449","base-100":"#0F172A",info:"#0CA5E9","info-content":"#000000",success:"#2DD4BF",warning:"#F4BF50",error:"#FB7085"},"[data-theme=coffee]":{"color-scheme":"dark",primary:"#DB924B",secondary:"#263E3F",accent:"#10576D",neutral:"#120C12","base-100":"#20161F","base-content":"#756E63",info:"#8DCAC1",success:"#9DB787",warning:"#FFD25F",error:"#FC9581"},"[data-theme=winter]":{"color-scheme":"light",primary:"#047AFF",secondary:"#463AA2",accent:"#C148AC",neutral:"#021431","base-100":"#ffffff","base-200":"#F2F7FF","base-300":"#E3E9F4","base-content":"#394E6A",info:"#93E7FB",success:"#81CFD1",warning:"#EFD7BB",error:"#E58B8B"}}},1833:function(e){var t=function(){if("object"==typeof self&&self)return self;if("object"==typeof window&&window)return window;throw Error("Unable to resolve global `this`")};e.exports=function(){if(this)return this;if("object"==typeof globalThis&&globalThis)return globalThis;try{Object.defineProperty(Object.prototype,"__global__",{get:function(){return this},configurable:!0})}catch(e){return t()}try{if(!__global__)return t();return __global__}finally{delete Object.prototype.__global__}}()},7:function(e){"use strict";var t={decodeValues:!0,map:!1,silent:!1};function r(e){return"string"==typeof e&&!!e.trim()}function s(e,s){var i,n,a,o,l=e.split(";").filter(r),c=(i=l.shift(),n="",a="",(o=i.split("=")).length>1?(n=o.shift(),a=o.join("=")):a=i,{name:n,value:a}),h=c.name,u=c.value;s=s?Object.assign({},t,s):t;try{u=s.decodeValues?decodeURIComponent(u):u}catch(e){console.error("set-cookie-parser encountered an error while decoding a cookie with value '"+u+"'. Set options.decodeValues to false to disable this feature.",e)}var d={name:h,value:u};return l.forEach(function(e){var t=e.split("="),r=t.shift().trimLeft().toLowerCase(),s=t.join("=");"expires"===r?d.expires=new Date(s):"max-age"===r?d.maxAge=parseInt(s,10):"secure"===r?d.secure=!0:"httponly"===r?d.httpOnly=!0:"samesite"===r?d.sameSite=s:d[r]=s}),d}function i(e,i){if(i=i?Object.assign({},t,i):t,!e)return i.map?{}:[];if(e.headers){if("function"==typeof e.headers.getSetCookie)e=e.headers.getSetCookie();else if(e.headers["set-cookie"])e=e.headers["set-cookie"];else{var n=e.headers[Object.keys(e.headers).find(function(e){return"set-cookie"===e.toLowerCase()})];n||!e.headers.cookie||i.silent||console.warn("Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."),e=n}}return(Array.isArray(e)||(e=[e]),(i=i?Object.assign({},t,i):t).map)?e.filter(r).reduce(function(e,t){var r=s(t,i);return e[r.name]=r,e},{}):e.filter(r).map(function(e){return s(e,i)})}
1e.exports=i,e.exports.parse=i,e.exports.parseString=s,e.exports.splitCookiesString=function(e){if(Array.isArray(e))return e;if("string"!=typeof e)return[];var t,r,s,i,n,a=[],o=0;function l(){for(;o<e.length&&/\s/.test(e.charAt(o));)o+=1;return o<e.length}for(;o<e.length;){for(t=o,n=!1;l();)if(","===(r=e.charAt(o))){for(s=o,o+=1,l(),i=o;o<e.length&&"="!==(r=e.charAt(o))&&";"!==r&&","!==r;)o+=1;o<e.length&&"="===e.charAt(o)?(n=!0,o=i,a.push(e.substring(t,s)),t=o):o=s+1}else o+=1;(!n||o>=e.length)&&a.push(e.substring(t,e.length))}return a}},4731:function(e,t,r){if("object"==typeof globalThis)s=globalThis;else try{s=r(1833)}catch(e){}finally{if(s||"undefined"==typeof window||(s=window),!s)throw Error("Could not determine global this")}var s,i=s.WebSocket||s.MozWebSocket,n=r(4167);function a(e,t){return t?new i(e,t):new i(e)}i&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach(function(e){Object.defineProperty(a,e,{get:function(){return i[e]}})}),e.exports={w3cwebsocket:i?a:null,version:n}},4167:function(e,t,r){e.exports=r(2151).version},5874:function(e,t,r){"use strict";r.r(t),r.d(t,{BrowserCookieAuthStorageAdapter:function(){return tq},CookieAuthStorageAdapter:function(){return tM},DEFAULT_COOKIE_OPTIONS:function(){return tB},createSupabaseClient:function(){return tK},isBrowser:function(){return tF},parseCookies:function(){return tG},parseSupabaseCookie:function(){return tL},serializeCookie:function(){return tX},stringifySupabaseSession:function(){return tN}}),new TextEncoder;let s=new TextDecoder,i=e=>{let t=atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r};var n,a,o,l,c,h,u,d,f,p,g,m,b,y,v,w,_,k,S,E,C,T=crypto;T.getRandomValues.bind(T),Symbol();let O=e=>{let t=e;t instanceof Uint8Array&&(t=s.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return i(t)}catch(e){throw TypeError("The input to be decoded is not correctly encoded.")}},j=e=>{let t;return t=e||("undefined"==typeof fetch?(...e)=>Promise.resolve().then(r.t.bind(r,5973,23)).then(({default:t})=>t(...e)):fetch),(...e)=>t(...e)};class I extends Error{constructor(e,t="FunctionsError",r){super(e),this.name=t,this.context=r}}class x extends I{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class A extends I{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class P extends I{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}class ${constructor(e,{headers:t={},customFetch:r}={}){this.url=e,this.headers=t,this.fetch=j(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,t={}){var r,s,i,n,a;return s=this,i=void 0,n=void 0,a=function*(){try{let s;let{headers:i,method:n,body:a}=t,o={};a&&(i&&!Object.prototype.hasOwnProperty.call(i,"Content-Type")||!i)&&("undefined"!=typeof Blob&&a instanceof Blob||a instanceof ArrayBuffer?(o["Content-Type"]="application/octet-stream",s=a):"string"==typeof a?(o["Content-Type"]="text/plain",s=a):"undefined"!=typeof FormData&&a instanceof FormData?s=a:(o["Content-Type"]="application/json",s=JSON.stringify(a)));let l=yield this.fetch(`${this.url}/${e}`,{method:n||"POST",headers:Object.assign(Object.assign(Object.assign({},o),this.headers),i),body:s}).catch(e=>{throw new x(e)}),c=l.headers.get("x-relay-error");if(c&&"true"===c)throw new A(l);if(!l.ok)throw new P(l);let h=(null!==(r=l.headers.get("Content-Type"))&&void 0!==r?r:"text/plain").split(";")[0].trim();return{data:"application/json"===h?yield l.json():"application/octet-stream"===h?yield l.blob():"multipart/form-data"===h?yield l.formData():yield l.text(),error:null}}catch(e){return{data:null,error:e}}},new(n||(n=Promise))(function(e,t){function r(e){try{l(a.next(e))}catch(e){t(e)}}function o(e){try{l(a.throw(e))}catch(e){t(e)}}function l(t){var s;t.done?e(t.value):((s=t.value)instanceof n?s:new n(function(e){e(s)})).then(r,o)}l((a=a.apply(s,i||[])).next())})}}var R=r(5973),U=r.n(R);class D{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:"undefined"==typeof fetch?this.fetch=U():this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}then(e,t){void 0===this.schema||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),"GET"!==this.method&&"HEAD"!==this.method&&(this.headers["Content-Type"]="application/json");let r=(0,this.fetch)(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async e=>{var t,r,s;let i=null,n=null,a=null,o=e.status,l=e.statusText;if(e.ok){if("HEAD"!==this.method){let t=await e.text();""===t||(n="text/csv"===this.headers.Accept?t:this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?t:JSON.parse(t))}let s=null===(t=this.headers.Prefer)||void 0===t?void 0:t.match(/count=(exact|planned|estimated)/),c=null===(r=e.headers.get("content-range"))||void 0===r?void 0:r.split("/");s&&c&&c.length>1&&(a=parseInt(c[1])),this.isMaybeSingle&&"GET"===this.method&&Array.isArray(n)&&(n.length>1?(i={code:"PGRST116",details:`Results contain ${n.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},n=null,a=null,o=406,l="Not Acceptable"):n=1===n.length?n[0]:null)}else{let t=await e.text();try{i=JSON.parse(t),Array.isArray(i)&&404===e.status&&(n=[],i=null,o=200,l="OK")}catch(r){404===e.status&&""===t?(o=204,l="No Content"):i={message:t}}if(i&&this.isMaybeSingle&&(null===(s=null==i?void 0:i.details)||void 0===s?void 0:s.includes("0 rows"))&&(i=null,o=200,l="OK"),i&&this.shouldThrowOnError)throw i}return{error:i,data:n,count:a,status:o,statusText:l}});return this.shouldThrowOnError||(r=r.catch(e=>{var t,r,s;return{error:{message:`${null!==(t=null==e?void 0:e.name)&&void 0!==t?t:"FetchError"}: ${null==e?void 0:e.message}`,details:`${null!==(r=null==e?void 0:e.stack)&&void 0!==r?r:""}`,hint:"",code:`${null!==(s=null==e?void 0:e.code)&&void 0!==s?s:""}`},data:null,count:null,status:0,statusText:""}}
1)),r.then(e,t)}}class L extends D{select(e){let t=!1,r=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!t?"":('"'===e&&(t=!t),e)).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:s}={}){let i=s?`${s}.order`:"order",n=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${n?`${n},`:""}${e}.${t?"asc":"desc"}${void 0===r?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t}={}){let r=void 0===t?"limit":`${t}.limit`;return this.url.searchParams.set(r,`${e}`),this}range(e,t,{foreignTable:r}={}){let s=void 0===r?"offset":`${r}.offset`,i=void 0===r?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${e}`),this.url.searchParams.set(i,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return"GET"===this.method?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:s=!1,wal:i=!1,format:n="text"}={}){let a=[e?"analyze":null,t?"verbose":null,r?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),o=this.headers.Accept;return this.headers.Accept=`application/vnd.pgrst.plan+${n}; for="${o}"; options=${a};`,this}rollback(){var e;return(null!==(e=this.headers.Prefer)&&void 0!==e?e:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}}class N extends L{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){let r=t.map(e=>"string"==typeof e&&RegExp("[,()]").test(e)?`"${e}"`:`${e}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}contains(e,t){return"string"==typeof t?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"string"==typeof t?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"string"==typeof t?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:s}={}){let i="";"plain"===s?i="pl":"phrase"===s?i="ph":"websearch"===s&&(i="w");let n=void 0===r?"":`(${r})`;return this.url.searchParams.append(e,`${i}fts${n}.${t}`),this}match(e){return Object.entries(e).forEach(([e,t])=>{this.url.searchParams.append(e,`eq.${t}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t}={}){let r=t?`${t}.or`:"or";return this.url.searchParams.append(r,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}}class F{constructor(e,{headers:t={},schema:r,fetch:s}){this.url=e,this.headers=t,this.schema=r,this.fetch=s}
1select(e,{head:t=!1,count:r}={}){let s=!1,i=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!s?"":('"'===e&&(s=!s),e)).join("");return this.url.searchParams.set("select",i),r&&(this.headers.Prefer=`count=${r}`),new N({method:t?"HEAD":"GET",url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e,{count:t,defaultToNull:r=!0}={}){let s=[];if(this.headers.Prefer&&s.push(this.headers.Prefer),t&&s.push(`count=${t}`),r||s.push("missing=default"),this.headers.Prefer=s.join(","),Array.isArray(e)){let t=e.reduce((e,t)=>e.concat(Object.keys(t)),[]);if(t.length>0){let e=[...new Set(t)].map(e=>`"${e}"`);this.url.searchParams.set("columns",e.join(","))}}return new N({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:s,defaultToNull:i=!0}={}){let n=[`resolution=${r?"ignore":"merge"}-duplicates`];if(void 0!==t&&this.url.searchParams.set("on_conflict",t),this.headers.Prefer&&n.push(this.headers.Prefer),s&&n.push(`count=${s}`),i||n.push("missing=default"),this.headers.Prefer=n.join(","),Array.isArray(e)){let t=e.reduce((e,t)=>e.concat(Object.keys(t)),[]);if(t.length>0){let e=[...new Set(t)].map(e=>`"${e}"`);this.url.searchParams.set("columns",e.join(","))}}return new N({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}update(e,{count:t}={}){let r=[];return this.headers.Prefer&&r.push(this.headers.Prefer),t&&r.push(`count=${t}`),this.headers.Prefer=r.join(","),new N({method:"PATCH",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}delete({count:e}={}){let t=[];return e&&t.push(`count=${e}`),this.headers.Prefer&&t.unshift(this.headers.Prefer),this.headers.Prefer=t.join(","),new N({method:"DELETE",url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}}let B={"X-Client-Info":"postgrest-js/1.8.5"};class J{constructor(e,{headers:t={},schema:r,fetch:s}={}){this.url=e,this.headers=Object.assign(Object.assign({},B),t),this.schemaName=r,this.fetch=s}from(e){return new F(new URL(`${this.url}/${e}`),{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new J(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:r=!1,count:s}={}){let i,n;let a=new URL(`${this.url}/rpc/${e}`);r?(i="HEAD",Object.entries(t).forEach(([e,t])=>{a.searchParams.append(e,`${t}`)})):(i="POST",n=t);let o=Object.assign({},this.headers);return s&&(o.Prefer=`count=${s}`),new N({method:i,url:a,headers:o,schema:this.schemaName,body:n,fetch:this.fetch,allowEmpty:!1})}}var z=r(4731);let M={"X-Client-Info":"realtime-js/2.8.3"};(n=m||(m={}))[n.connecting=0]="connecting",n[n.open=1]="open",n[n.closing=2]="closing",n[n.closed=3]="closed",(a=b||(b={})).closed="closed",a.errored="errored",a.joined="joined",a.joining="joining",a.leaving="leaving",(o=y||(y={})).close="phx_close",o.error="phx_error",o.join="phx_join",o.reply="phx_reply",o.leave="phx_leave",o.access_token="access_token",(v||(v={})).websocket="websocket",(l=w||(w={})).Connecting="connecting",l.Open="open",l.Closing="closing",l.Closed="closed";class q{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))}}class K{constructor(){this.HEADER_LENGTH=1}decode(e,t){return e.constructor===ArrayBuffer?t(this._binaryDecode(e)):"string"==typeof e?t(JSON.parse(e)):t({})}_binaryDecode(e){let t=new DataView(e),r=new TextDecoder;return this._decodeBroadcast(e,t,r)}_decodeBroadcast(e,t,r){let s=t.getUint8(1),i=t.getUint8(2),n=this.HEADER_LENGTH+2,a=r.decode(e.slice(n,n+s));n+=s;let o=r.decode(e.slice(n,n+i));return n+=i,{ref:null,topic:a,event:o,payload:JSON.parse(r.decode(e.slice(n,e.byteLength)))}}}class G{constructor(e,t,r={},s=1e4){this.channel=e,this.event=t,this.payload=r,this.timeout=s,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHo
1oks=[],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(null===(r=this.receivedResp)||void 0===r?void 0:r.response),this.recHooks.push({status:e,callback:t}),this}startTimeout(){this.timeoutTimer||(this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref),this.channel._on(this.refEvent,{},e=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=e,this._matchReceive(e)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout))}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(t=>t.status===e).forEach(e=>e.callback(t))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}(c=_||(_={})).SYNC="sync",c.JOIN="join",c.LEAVE="leave";class X{constructor(e,t){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};let r=(null==t?void 0:t.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(r.state,{},e=>{let{onJoin:t,onLeave:r,onSync:s}=this.caller;this.joinRef=this.channel._joinRef(),this.state=X.syncState(this.state,e,t,r),this.pendingDiffs.forEach(e=>{this.state=X.syncDiff(this.state,e,t,r)}),this.pendingDiffs=[],s()}),this.channel._on(r.diff,{},e=>{let{onJoin:t,onLeave:r,onSync:s}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(e):(this.state=X.syncDiff(this.state,e,t,r),s())}),this.onJoin((e,t,r)=>{this.channel._trigger("presence",{event:"join",key:e,currentPresences:t,newPresences:r})}),this.onLeave((e,t,r)=>{this.channel._trigger("presence",{event:"leave",key:e,currentPresences:t,leftPresences:r})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,t,r,s){let i=this.cloneDeep(e),n=this.transformState(t),a={},o={};return this.map(i,(e,t)=>{n[e]||(o[e]=t)}),this.map(n,(e,t)=>{let r=i[e];if(r){let s=t.map(e=>e.presence_ref),i=r.map(e=>e.presence_ref),n=t.filter(e=>0>i.indexOf(e.presence_ref)),l=r.filter(e=>0>s.indexOf(e.presence_ref));n.length>0&&(a[e]=n),l.length>0&&(o[e]=l)}else a[e]=t}),this.syncDiff(i,{joins:a,leaves:o},r,s)}static syncDiff(e,t,r,s){let{joins:i,leaves:n}={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)};return r||(r=()=>{}),s||(s=()=>{}),this.map(i,(t,s)=>{var i;let n=null!==(i=e[t])&&void 0!==i?i:[];if(e[t]=this.cloneDeep(s),n.length>0){let r=e[t].map(e=>e.presence_ref),s=n.filter(e=>0>r.indexOf(e.presence_ref));e[t].unshift(...s)}r(t,n,s)}),this.map(n,(t,r)=>{let i=e[t];if(!i)return;let n=r.map(e=>e.presence_ref);i=i.filter(e=>0>n.indexOf(e.presence_ref)),e[t]=i,s(t,i,r),0===i.length&&delete e[t]}),e}static map(e,t){return Object.getOwnPropertyNames(e).map(r=>t(r,e[r]))}static transformState(e){return Object.getOwnPropertyNames(e=this.cloneDeep(e)).reduce((t,r)=>{let s=e[r];return"metas"in s?t[r]=s.metas.map(e=>(e.presence_ref=e.phx_ref,delete e.phx_ref,delete e.phx_ref_prev,e)):t[r]=s,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()}}(h=k||(k={})).abstime="abstime",h.bool="bool",h.date="date",h.daterange="daterange",h.float4="float4",h.float8="float8",h.int2="int2",h.int4="int4",h.int4range="int4range",h.int8="int8",h.int8range="int8range",h.json="json",h.jsonb="jsonb",h.money="money",h.numeric="numeric",h.oid="oid",h.reltime="reltime",h.text="text",h.time="time",h.timestamp="timestamp",h.timestamptz="timestamptz",h.timetz="timetz",h.tsrange="tsrange",h.tstzrange="tstzrange";let V=(e,t,r={})=>{var s;let i=null!==(s=r.skipTypes)&&void 0!==s?s:[];return Object.keys(t).reduce((r,s)=>(r[s]=W(s,e,t,i),r),{})},W=(e,t,r,s)=>{let i=t.find(t=>t.name===e),n=null==i?void 0:i.type,a=r[e];return n&&!s.includes(n)?H(n,a):Y(a)},H=(e,t)=>
1{if("_"===e.charAt(0))return et(t,e.slice(1,e.length));switch(e){case k.bool:return Z(t);case k.float4:case k.float8:case k.int2:case k.int4:case k.int8:case k.numeric:case k.oid:return Q(t);case k.json:case k.jsonb:return ee(t);case k.timestamp:return er(t);case k.abstime:case k.date:case k.daterange:case k.int4range:case k.int8range:case k.money:case k.reltime:case k.text:case k.time:case k.timestamptz:case k.timetz:case k.tsrange:case k.tstzrange:default:return Y(t)}},Y=e=>e,Z=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},Q=e=>{if("string"==typeof e){let t=parseFloat(e);if(!Number.isNaN(t))return t}return e},ee=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){console.log(`JSON parse error: ${e}`)}return e},et=(e,t)=>{if("string"!=typeof e)return e;let r=e.length-1,s=e[r];if("{"===e[0]&&"}"===s){let s;let i=e.slice(1,r);try{s=JSON.parse("["+i+"]")}catch(e){s=i?i.split(","):[]}return s.map(e=>H(t,e))}return e},er=e=>"string"==typeof e?e.replace(" ","T"):e;(u=S||(S={})).ALL="*",u.INSERT="INSERT",u.UPDATE="UPDATE",u.DELETE="DELETE",(d=E||(E={})).BROADCAST="broadcast",d.PRESENCE="presence",d.POSTGRES_CHANGES="postgres_changes",(f=C||(C={})).SUBSCRIBED="SUBSCRIBED",f.TIMED_OUT="TIMED_OUT",f.CLOSED="CLOSED",f.CHANNEL_ERROR="CHANNEL_ERROR";class es{constructor(e,t={config:{}},r){this.topic=e,this.params=t,this.socket=r,this.bindings={},this.state=b.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""}},t.config),this.timeout=this.socket.timeout,this.joinPush=new G(this,y.join,this.params,this.timeout),this.rejoinTimer=new q(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=b.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(e=>e.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=b.closed,this.socket._remove(this)}),this._onError(e=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,e),this.state=b.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=b.errored,this.rejoinTimer.scheduleTimeout())}),this._on(y.reply,{},(e,t)=>{this._trigger(this._replyEventName(t),e)}),this.presence=new X(this),this.broadcastEndpointURL=this._broadcastEndpointURL()}subscribe(e,t=this.timeout){var r,s;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";{let{config:{broadcast:i,presence:n}}=this.params;this._onError(t=>e&&e("CHANNEL_ERROR",t)),this._onClose(()=>e&&e("CLOSED"));let a={},o={broadcast:i,presence:n,postgres_changes:null!==(s=null===(r=this.bindings.postgres_changes)||void 0===r?void 0:r.map(e=>e.filter))&&void 0!==s?s:[]};this.socket.accessToken&&(a.access_token=this.socket.accessToken),this.updateJoinPayload(Object.assign({config:o},a)),this.joinedOnce=!0,this._rejoin(t),this.joinPush.receive("ok",({postgres_changes:t})=>{var r;if(this.socket.accessToken&&this.socket.setAuth(this.socket.accessToken),void 0===t){e&&e("SUBSCRIBED");return}{let s=this.bindings.postgres_changes,i=null!==(r=null==s?void 0:s.length)&&void 0!==r?r:0,n=[];for(let r=0;r<i;r++){let i=s[r],{filter:{event:a,schema:o,table:l,filter:c}}=i,h=t&&t[r];if(h&&h.event===a&&h.schema===o&&h.table===l&&h.filter===c)n.push(Object.assign(Object.assign({},i),{id:h.id}));else{this.unsubscribe(),e&&e("CHANNEL_ERROR",Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=n,e&&e("SUBSCRIBED");return}}).receive("error",t=>{e&&e("CHANNEL_ERROR",Error(JSON.stringify(Object.values(t).join(", ")||"error")))}).receive("timeout",()=>{e&&e("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,s;if(this._canPush()||"broadcast"!==e.type)return new Promise(r=>{var s,i,n;let a=this._push(e.type,e,t.timeout||this.timeout);"broadcast"!==e.type||(null===(n=null===(i=null===(s=this.params)||void 0===s?void 0:s.config)||void 0===i?void 0:i.broadcast)||void 0===n?void 0:n.ack)||r("ok"),a.receive("ok",()=>r("ok")),a.receive("timeout",()=>r("timed out"))});{let{event:i,payload:n}=e,a={method:"POST",headers:{apikey:null!==(r=this.socket.accessToken)&&void 0!==r?r:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:n}]})};try{if((await this._fetchWithTimeout(this.broadcastEndpointURL,a,null!==(s=t.timeout)&&void 0!==s?s:this.timeout)).ok)return"ok";return"error"}catch(e){if("AbortError"===e.name)return"timed out";return"error"}}}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=b.leaving;let t=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(y.close,"leave",this._joinRef())};return this.rejoinTimer.reset(),this.joinPush.destroy(),new Promise(r=>{let s=new G(this,y.leave,{},e);s.receive("ok",()=>{t(),r("ok")}).receive("timeout",()=>{t(),r("timed out")}).receive("error",()=>{r("error")}),s.send(),this._canPush()||s.trigger("ok",{})})}_broadcastEndpointURL(){let e=this.socket.endPoint;
1return(e=(e=e.replace(/^ws/i,"http")).replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,"")).replace(/\/+$/,"")+"/api/broadcast"}async _fetchWithTimeout(e,t,r){let s=new AbortController,i=setTimeout(()=>s.abort(),r),n=await this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:s.signal}));return clearTimeout(i),n}_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 s=new G(this,e,t,r);return this._canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}_onMessage(e,t,r){return t}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,t,r){var s,i;let n=e.toLocaleLowerCase(),{close:a,error:o,leave:l,join:c}=y;if(r&&[a,o,l,c].indexOf(n)>=0&&r!==this._joinRef())return;let h=this._onMessage(n,t,r);if(t&&!h)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(n)?null===(s=this.bindings.postgres_changes)||void 0===s||s.filter(e=>{var t,r,s;return(null===(t=e.filter)||void 0===t?void 0:t.event)==="*"||(null===(s=null===(r=e.filter)||void 0===r?void 0:r.event)||void 0===s?void 0:s.toLocaleLowerCase())===n}).map(e=>e.callback(h,r)):null===(i=this.bindings[n])||void 0===i||i.filter(e=>{var r,s,i,a,o,l;if(!["broadcast","presence","postgres_changes"].includes(n))return e.type.toLocaleLowerCase()===n;if("id"in e){let n=e.id,a=null===(r=e.filter)||void 0===r?void 0:r.event;return n&&(null===(s=t.ids)||void 0===s?void 0:s.includes(n))&&("*"===a||(null==a?void 0:a.toLocaleLowerCase())===(null===(i=t.data)||void 0===i?void 0:i.type.toLocaleLowerCase()))}{let r=null===(o=null===(a=null==e?void 0:e.filter)||void 0===a?void 0:a.event)||void 0===o?void 0:o.toLocaleLowerCase();return"*"===r||r===(null===(l=null==t?void 0:t.event)||void 0===l?void 0:l.toLocaleLowerCase())}}).map(e=>{if("object"==typeof h&&"ids"in h){let e=h.data,{schema:t,table:r,commit_timestamp:s,type:i,errors:n}=e;h=Object.assign(Object.assign({},{schema:t,table:r,commit_timestamp:s,eventType:i,new:{},old:{},errors:n}),this._getPayloadRecords(e))}e.callback(h,r)})}_isClosed(){return this.state===b.closed}_isJoined(){return this.state===b.joined}_isJoining(){return this.state===b.joining}_isLeaving(){return this.state===b.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,t,r){let s=e.toLocaleLowerCase(),i={type:s,filter:t,callback:r};return this.bindings[s]?this.bindings[s].push(i):this.bindings[s]=[i],this}_off(e,t){let r=e.toLocaleLowerCase();return this.bindings[r]=this.bindings[r].filter(e=>{var s;return!((null===(s=e.type)||void 0===s?void 0:s.toLocaleLowerCase())===r&&es.isEqual(e.filter,t))}),this}static isEqual(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let 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(y.close,{},e)}_onError(e){this._on(y.error,{},t=>e(t))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=b.joining,this.joinPush.resend(e))}_getPayloadRecords(e){let t={new:{},old:{}};return("INSERT"===e.type||"UPDATE"===e.type)&&(t.new=V(e.columns,e.record)),("UPDATE"===e.type||"DELETE"===e.type)&&(t.old=V(e.columns,e.old_record)),t}}let ei=()=>{};class en{constructor(e,t){var s;this.accessToken=null,this.channels=[],this.endPoint="",this.headers=M,this.params={},this.timeout=1e4,this.transport=z.w3cwebsocket,this.heartbeatIntervalMs=3e4,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.ref=0,this.logger=ei,this.conn=null,this.sendBuffer=[],this.serializer=new K,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this._resolveFetch=e=>{let t;return t=e||("undefined"==typeof fetch?(...e)=>Promise.resolve().then(r.t.bind(r,5973,23)).then(({default:t})=>t(...e)):fetch),(...e)=>t(...e)},this.endPoint=`${e}/${v.websocket}`,(null==t?void 0:t.params)&&(this.params=t.params),(null==t?void 0:t.headers)&&(this.headers=Object.assign(Object.assign({}
1,this.headers),t.headers)),(null==t?void 0:t.timeout)&&(this.timeout=t.timeout),(null==t?void 0:t.logger)&&(this.logger=t.logger),(null==t?void 0:t.transport)&&(this.transport=t.transport),(null==t?void 0:t.heartbeatIntervalMs)&&(this.heartbeatIntervalMs=t.heartbeatIntervalMs);let i=null===(s=null==t?void 0:t.params)||void 0===s?void 0:s.apikey;i&&(this.accessToken=i),this.reconnectAfterMs=(null==t?void 0:t.reconnectAfterMs)?t.reconnectAfterMs:e=>[1e3,2e3,5e3,1e4][e-1]||1e4,this.encode=(null==t?void 0:t.encode)?t.encode:(e,t)=>t(JSON.stringify(e)),this.decode=(null==t?void 0:t.decode)?t.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new q(async()=>{this.disconnect(),this.connect()},this.reconnectAfterMs),this.fetch=this._resolveFetch(null==t?void 0:t.fetch)}connect(){!this.conn&&(this.conn=new this.transport(this._endPointURL(),[],null,this.headers),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)))}disconnect(e,t){this.conn&&(this.conn.onclose=function(){},e?this.conn.close(e,null!=t?t:""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset())}getChannels(){return this.channels}async removeChannel(e){let t=await e.unsubscribe();return 0===this.channels.length&&this.disconnect(),t}async removeAllChannels(){let e=await Promise.all(this.channels.map(e=>e.unsubscribe()));return this.disconnect(),e}log(e,t,r){this.logger(e,t,r)}connectionState(){switch(this.conn&&this.conn.readyState){case m.connecting:return w.Connecting;
1case m.open:return w.Open;case m.closing:return w.Closing;default:return w.Closed}}isConnected(){return this.connectionState()===w.Open}channel(e,t={config:{}}){let r=new es(`realtime:${e}`,t,this);return this.channels.push(r),r}push(e){let{topic:t,event:r,payload:s,ref:i}=e,n=()=>{this.encode(e,e=>{var t;null===(t=this.conn)||void 0===t||t.send(e)})};this.log("push",`${t} ${r} (${i})`,s),this.isConnected()?n():this.sendBuffer.push(n)}setAuth(e){this.accessToken=e,this.channels.forEach(t=>{e&&t.updateJoinPayload({access_token:e}),t.joinedOnce&&t._isJoined()&&t._push(y.access_token,{access_token:e})})}_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(t=>t.topic===e&&(t._isJoined()||t._isJoining()));t&&(this.log("transport",`leaving duplicate topic "${e}"`),t.unsubscribe())}_remove(e){this.channels=this.channels.filter(t=>t._joinRef()!==e._joinRef())}_endPointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:"1.0.0"}))}_onConnMessage(e){this.decode(e.data,e=>{let{topic:t,event:r,payload:s,ref:i}=e;(i&&i===this.pendingHeartbeatRef||r===(null==s?void 0:s.type))&&(this.pendingHeartbeatRef=null),this.log("receive",`${s.status||""} ${t} ${r} ${i&&"("+i+")"||""}`,s),this.channels.filter(e=>e._isMember(t)).forEach(e=>e._trigger(r,s,i)),this.stateChangeCallbacks.message.forEach(t=>t(e))})}_onConnOpen(){this.log("transport",`connected to ${this._endPointURL()}`),this._flushSendBuffer(),this.reconnectTimer.reset(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this._sendHeartbeat(),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(y.error))}_appendParams(e,t){if(0===Object.keys(t).length)return e;let r=e.match(/\?/)?"&":"?",s=new URLSearchParams(t);return`${e}${r}${s}`}_flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_sendHeartbeat(){var e;if(this.isConnected()){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),null===(e=this.conn)||void 0===e||e.close(1e3,"hearbeat timeout");return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.setAuth(this.accessToken)}}}
1class ea extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function eo(e){return"object"==typeof e&&null!==e&&"__isStorageError"in e}class el extends ea{constructor(e,t){super(e),this.name="StorageApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class ec extends ea{constructor(e,t){super(e),this.name="StorageUnknownError",this.originalError=t}}let eh=e=>{let t;return t=e||("undefined"==typeof fetch?(...e)=>Promise.resolve().then(r.t.bind(r,5973,23)).then(({default:t})=>t(...e)):fetch),(...e)=>t(...e)},eu=()=>{var e,t,s,i;return e=void 0,t=void 0,s=void 0,i=function*(){return"undefined"==typeof Response?(yield Promise.resolve().then(r.t.bind(r,5973,23))).Response:Response},new(s||(s=Promise))(function(r,n){function a(e){try{l(i.next(e))}catch(e){n(e)}}function o(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?r(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(a,o)}l((i=i.apply(e,t||[])).next())})};var ed=function(e,t,r,s){return new(r||(r=Promise))(function(i,n){function a(e){try{l(s.next(e))}catch(e){n(e)}}function o(e){try{l(s.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(a,o)}l((s=s.apply(e,t||[])).next())})};let ef=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),ep=(e,t)=>ed(void 0,void 0,void 0,function*(){e instanceof(yield eu())?e.json().then(r=>{t(new el(ef(r),e.status||500))}).catch(e=>{t(new ec(ef(e),e))}):t(new ec(ef(e),e))}),eg=(e,t,r,s)=>{let i={method:e,headers:(null==t?void 0:t.headers)||{}};return"GET"===e?i:(i.headers=Object.assign({"Content-Type":"application/json"},null==t?void 0:t.headers),i.body=JSON.stringify(s),Object.assign(Object.assign({},i),r))};function em(e,t,r,s,i,n){return ed(this,void 0,void 0,function*(){return new Promise((a,o)=>{e(r,eg(t,s,i,n)).then(e=>{if(!e.ok)throw e;return(null==s?void 0:s.noResolveJson)?e:e.json()}).then(e=>a(e)).catch(e=>ep(e,o))})})}function eb(e,t,r,s){return ed(this,void 0,void 0,function*(){return em(e,"GET",t,r,s)})}function ey(e,t,r,s,i){return ed(this,void 0,void 0,function*(){return em(e,"POST",t,s,i,r)})}function ev(e,t,r,s,i){return ed(this,void 0,void 0,function*(){return em(e,"DELETE",t,s,i,r)})}var ew=function(e,t,r,s){return new(r||(r=Promise))(function(i,n){function a(e){try{l(s.next(e))}catch(e){n(e)}}function o(e){try{l(s.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(a,o)}l((s=s.apply(e,t||[])).next())})};let e_={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},ek={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class eS{constructor(e,t={},r,s){this.url=e,this.headers=t,this.bucketId=r,this.fetch=eh(s)}uploadOrUpdate(e,t,r,s){return ew(this,void 0,void 0,function*(){try{let i;let n=Object.assign(Object.assign({},ek),s),a=Object.assign(Object.assign({},this.headers),"POST"===e&&{"x-upsert":String(n.upsert)});"undefined"!=typeof Blob&&r instanceof Blob?((i=new FormData).append("cacheControl",n.cacheControl),i.append("",r)):"undefined"!=typeof FormData&&r instanceof FormData?(i=r).append("cacheControl",n.cacheControl):(i=r,a["cache-control"]=`max-age=${n.cacheControl}`,a["content-type"]=n.contentType);let o=this._removeEmptyFolders(t),l=this._getFinalPath(o),c=yield this.fetch(`${this.url}/object/${l}`,Object.assign({method:e,body:i,headers:a},(null==n?void 0:n.duplex)?{duplex:n.duplex}:{}));if(c.ok)return{data:{path:o},error:null};{let e=yield c.json();return{data:null,error:e}}}catch(e){if(eo(e))return{data:null,error:e};throw e}})}upload(e,t,r){return ew(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,t,r)})}uploadToSignedUrl(e,t,r,s){return ew(this,void 0,void 0,function*(){let i=this._removeEmptyFolders(e),n=this._getFinalPath(i),a=new URL(this.url+`/object/upload/sign/${n}`);a.searchParams.set("token",t);try{let e;let t=Object.assign({upsert:ek.upsert},s),n=Object.assign(Object.assign({},this.headers),{"x-upsert":String(t.upsert)});"undefined"!=typeof Blob&&r instanceof Blob?((e=new FormData).append("cacheControl",t.cacheControl),e.append("",r)):"undefined"!=typeof FormData&&r instanceof FormData?(e=r).append("cacheControl",t.cacheControl):(e=r,n["cache-control"]=`max-age=${t.cacheControl}`,n["content-type"]=t.contentType);let o=yield this.fetch(a.toString(),{method:"PUT",body:e,headers:n});if(o.ok)return{data:{path:i},error:null};{let e=yield o.json();return{data:null,error:e}}}catch(e){if(eo(e))return{data:null,error:e};throw e}})}createSignedUploadUrl(e){return ew(this,void 0,void 0,function*(){try{let t=this._getFinalPath(e),r=yield ey(this.fetch,`${this.url}/object/upload/sign/${t}`,{},{headers:this.headers}),s=new URL(this.url+r.url),i=s.searchParams.get("token");if(!i)throw new ea("No token returned by API");return{data:{signedUrl:s.toString(),path:e,token:i},error:null}}catch(e){if(eo(e))return{data:null,error:e};throw e}})}update(e,t,r){return ew(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,t,r)})}move(e,t){return ew(this,void 0,void 0,function*(){try{return{data:yield ey(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t},{headers:this.headers}),error:null}}catch(e){if(eo(e))return{data:null,error:e};throw e}})}copy(e,t){return ew(this,void 0,void 0,function*(){try{return{data:{path:(yield ey(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t},{headers:this.headers})).Key},error:null}}catch(e){if(eo(e))return{data:null,error:e};throw e}})}createSignedUrl(e,t,r){return ew(this,void 0,void 0,function*(){try{let s=this._getFinalPath(e),i=yield ey(this.fetch,`${this.url}/object/sign/${s}
1`,Object.assign({expiresIn:t},(null==r?void 0:r.transform)?{transform:r.transform}:{}),{headers:this.headers}),n=(null==r?void 0:r.download)?`&download=${!0===r.download?"":r.download}`:"";return{data:i={signedUrl:encodeURI(`${this.url}${i.signedURL}${n}`)},error:null}}catch(e){if(eo(e))return{data:null,error:e};throw e}})}createSignedUrls(e,t,r){return ew(this,void 0,void 0,function*(){try{let s=yield ey(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:t,paths:e},{headers:this.headers}),i=(null==r?void 0:r.download)?`&download=${!0===r.download?"":r.download}`:"";return{data:s.map(e=>Object.assign(Object.assign({},e),{signedUrl:e.signedURL?encodeURI(`${this.url}${e.signedURL}${i}`):null})),error:null}}catch(e){if(eo(e))return{data:null,error:e};throw e}})}download(e,t){return ew(this,void 0,void 0,function*(){let r=void 0!==(null==t?void 0:t.transform),s=this.transformOptsToQueryString((null==t?void 0:t.transform)||{}),i=s?`?${s}`:"";try{let t=this._getFinalPath(e),s=yield eb(this.fetch,`${this.url}/${r?"render/image/authenticated":"object"}/${t}${i}`,{headers:this.headers,noResolveJson:!0});return{data:yield s.blob(),error:null}}catch(e){if(eo(e))return{data:null,error:e};throw e}})}getPublicUrl(e,t){let r=this._getFinalPath(e),s=[],i=(null==t?void 0:t.download)?`download=${!0===t.download?"":t.download}`:"";""!==i&&s.push(i);let n=void 0!==(null==t?void 0:t.transform),a=this.transformOptsToQueryString((null==t?void 0:t.transform)||{});""!==a&&s.push(a);let o=s.join("&");return""!==o&&(o=`?${o}`),{data:{publicUrl:encodeURI(`${this.url}/${n?"render/image":"object"}/public/${r}${o}`)}}}remove(e){return ew(this,void 0,void 0,function*(){try{return{data:yield ev(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(e){if(eo(e))return{data:null,error:e};throw e}})}list(e,t,r){return ew(this,void 0,void 0,function*(){try{let s=Object.assign(Object.assign(Object.assign({},e_),t),{prefix:e||""});return{data:yield ey(this.fetch,`${this.url}/object/list/${this.bucketId}`,s,{headers:this.headers},r),error:null}}catch(e){if(eo(e))return{data:null,error:e};throw e}})}_getFinalPath(e){return`${this.bucketId}/${e}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){let 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("&")}}let eE={"X-Client-Info":"storage-js/2.5.4"};var eC=function(e,t,r,s){return new(r||(r=Promise))(function(i,n){function a(e){try{l(s.next(e))}catch(e){n(e)}}function o(e){try{l(s.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(a,o)}l((s=s.apply(e,t||[])).next())})};class eT{constructor(e,t={},r){this.url=e,this.headers=Object.assign(Object.assign({},eE),t),this.fetch=eh(r)}listBuckets(){return eC(this,void 0,void 0,function*(){try{return{data:yield eb(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(eo(e))return{data:null,error:e};throw e}})}getBucket(e){return eC(this,void 0,void 0,function*(){try{return{data:yield eb(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(e){if(eo(e))return{data:null,error:e};throw e}})}createBucket(e,t={public:!1}){return eC(this,void 0,void 0,function*(){try{return{data:yield ey(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(e){if(eo(e))return{data:null,error:e};throw e}})}updateBucket(e,t){return eC(this,void 0,void 0,function*(){try{return{data:yield function(e,t,r,s,i){return ed(this,void 0,void 0,function*(){return em(e,"PUT",t,s,void 0,r)})}(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(e){if(eo(e))return{data:null,error:e};throw e}})}emptyBucket(e){return eC(this,void 0,void 0,function*(){try{return{data:yield ey(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(e){if(eo(e))return{data:null,error:e};throw e}})}deleteBucket(e){return eC(this,void 0,void 0,function*(){try{return{data:yield ev(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(e){if(eo(e))return{data:null,error:e};throw e}})}}class eO extends eT{constructor(e,t={},r){super(e,t,r)}from(e){return new eS(this.url,this.headers,e,this.fetch)}}let ej="";ej="undefined"!=typeof Deno?"deno":"undefined"!=typeof document?"web":"undefined"!=typeof navigator&&"ReactNative"===navigator.product?"react-native":"node";let eI={"X-Client-Info":`supabase-js-${ej}/2.38.3`},ex=e=>{let t;return t=e||("undefined"==typeof fetch?U():fetch),(...e)=>t(...e)},eA=()=>"undefined"==typeof Headers?R.Headers:Headers,eP=(e,t,r)=>{let s=ex(r),i=eA();return(r,n)=>{var a,o,l,c;return a=void 0,o=void 0,l=void 0,c=function*(){var a;let o=null!==(a=yield t())&&void 0!==a?a:e,l=new i(null==n?void 0:n.headers);return l.has("apikey")||l.set("apikey",e),l.has("Authorization")||l.set("Authorization",`Bearer ${o}`),s(r,Object.assign(Object.assign({},n),{headers:l}))},new(l||(l=Promise))(function(e,t){function r(e){try{i(c.next(e))}catch(e){t(e)}}function s(e){try{i(c.throw(e))}catch(e){t(e)}}function i(t){var i;t.done?e(t.value):((i=t.value)instanceof l?i:new l(function(e){e(i)})).then(r,s)}i((c=c.apply(a,o||[])).next())})}},e$=()=>"undefined"!=typeof document,eR={tested:!1,writable:!1},eU=()=>
1{if(!e$())return!1;try{if("object"!=typeof globalThis.localStorage)return!1}catch(e){return!1}if(eR.tested)return eR.writable;let e=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),eR.tested=!0,eR.writable=!0}catch(e){eR.tested=!0,eR.writable=!1}return eR.writable};function eD(e){let t={},r=new URL(e);if(r.hash&&"#"===r.hash[0])try{new URLSearchParams(r.hash.substring(1)).forEach((e,r)=>{t[r]=e})}catch(e){}return r.searchParams.forEach((e,r)=>{t[r]=e}),t}let eL=e=>{let t;return t=e||("undefined"==typeof fetch?(...e)=>Promise.resolve().then(r.t.bind(r,5973,23)).then(({default:t})=>t(...e)):fetch),(...e)=>t(...e)},eN=e=>"object"==typeof e&&null!==e&&"status"in e&&"ok"in e&&"json"in e&&"function"==typeof e.json,eF=async(e,t,r)=>{await e.setItem(t,JSON.stringify(r))},eB=async(e,t)=>{let r=await e.getItem(t);if(!r)return null;try{return JSON.parse(r)}catch(e){return r}},eJ=async(e,t)=>{await e.removeItem(t)};class ez{constructor(){this.promise=new ez.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}}function eM(e){let t=e.split(".");if(3!==t.length)throw Error("JWT is not valid: not a JWT structure");if(!/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}=?$|[a-z0-9_-]{2}(==)?$)$/i.test(t[1]))throw Error("JWT is not valid: payload is not in base64url format");return JSON.parse(function(e){let t,r,s,i,n,a,o;let l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",c="",h=0;for(e=e.replace("-","+").replace("_","/");h<e.length;)i=l.indexOf(e.charAt(h++)),n=l.indexOf(e.charAt(h++)),a=l.indexOf(e.charAt(h++)),o=l.indexOf(e.charAt(h++)),t=i<<2|n>>4,r=(15&n)<<4|a>>2,s=(3&a)<<6|o,c+=String.fromCharCode(t),64!=a&&0!=r&&(c+=String.fromCharCode(r)),64!=o&&0!=s&&(c+=String.fromCharCode(s));return c}(t[1]))}async function eq(e){return await new Promise(t=>{setTimeout(()=>t(null),e)})}function eK(e){return("0"+e.toString(16)).substr(-2)}function eG(){let e=new Uint32Array(56);if("undefined"==typeof crypto){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=e.length,r="";for(let s=0;s<56;s++)r+=e.charAt(Math.floor(Math.random()*t));return r}return crypto.getRandomValues(e),Array.from(e,eK).join("")}async function eX(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(r)).map(e=>String.fromCharCode(e)).join("")}async function eV(e){return"undefined"!=typeof crypto&&void 0!==crypto.subtle&&"undefined"!=typeof TextEncoder?btoa(await eX(e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""):(console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),e)}ez.promiseConstructor=Promise;class eW extends Error{constructor(e,t){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t}}function eH(e){return"object"==typeof e&&null!==e&&"__isAuthError"in e}class eY extends eW{constructor(e,t){super(e,t),this.name="AuthApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class eZ extends eW{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class eQ extends eW{constructor(e,t,r){super(e),this.name=t,this.status=r}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class e0 extends eQ{constructor(){super("Auth session missing!","AuthSessionMissingError",400)}}class e1 extends eQ{constructor(){super("Auth session or user missing","AuthInvalidToken
1ResponseError",500)}}class e2 extends eQ{constructor(e){super(e,"AuthInvalidCredentialsError",400)}}class e3 extends eQ{constructor(e,t=null){super(e,"AuthImplicitGrantRedirectError",500),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class e6 extends eQ{constructor(e,t=null){super(e,"AuthPKCEGrantCodeExchangeError",500),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class e4 extends eQ{constructor(e,t){super(e,"AuthRetryableFetchError",t)}}function e5(e){return eH(e)&&"AuthRetryableFetchError"===e.name}var e8=function(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&0>t.indexOf(s)&&(r[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,s=Object.getOwnPropertySymbols(e);i<s.length;i++)0>t.indexOf(s[i])&&Object.prototype.propertyIsEnumerable.call(e,s[i])&&(r[s[i]]=e[s[i]]);return r};let e9=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),e7=[502,503,504];async function te(e){let t;if(!eN(e))throw new e4(e9(e),0);if(e7.includes(e.status))throw new e4(e9(e),e.status);try{t=await e.json()}catch(e){throw new eZ(e9(e),e)}throw new eY(e9(t),e.status||500)}let tt=(e,t,r,s)=>{let i={method:e,headers:(null==t?void 0:t.headers)||{}};return"GET"===e?i:(i.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},null==t?void 0:t.headers),i.body=JSON.stringify(s),Object.assign(Object.assign({},i),r))};async function tr(e,t,r,s){var i;let n=Object.assign({},null==s?void 0:s.headers);(null==s?void 0:s.jwt)&&(n.Authorization=`Bearer ${s.jwt}`);let a=null!==(i=null==s?void 0:s.query)&&void 0!==i?i:{};(null==s?void 0:s.redirectTo)&&(a.redirect_to=s.redirectTo);let o=Object.keys(a).length?"?"+new URLSearchParams(a).toString():"",l=await ts(e,t,r+o,{headers:n,noResolveJson:null==s?void 0:s.noResolveJson},{},null==s?void 0:s.body);return(null==s?void 0:s.xform)?null==s?void 0:s.xform(l):{data:Object.assign({},l),error:null}}async function ts(e,t,r,s,i,n){let a;let o=tt(t,s,i,n);try{a=await e(r,o)}catch(e){throw console.error(e),new e4(e9(e),0)}if(a.ok||await te(a),null==s?void 0:s.noResolveJson)return a;try{return await a.json()}catch(e){await te(e)}}function ti(e){var t,r;let s=null;return e.access_token&&e.refresh_token&&e.expires_in&&(s=Object.assign({},e),!e.expires_at)&&(s.expires_at=(r=e.expires_in,Math.round(Date.now()/1e3)+r)),{data:{session:s,user:null!==(t=e.user)&&void 0!==t?t:e},error:null}}function tn(e){var t;return{data:{user:null!==(t=e.user)&&void 0!==t?t:e},error:null}}function ta(e){return{data:e,error:null}}function to(e){let{action_link:t,email_otp:r,hashed_token:s,redirect_to:i,verification_type:n}=e;return{data:{properties:{action_link:t,email_otp:r,hashed_token:s,redirect_to:i,verification_type:n},user:Object.assign({},e8(e,["action_link","email_otp","hashed_token","redirect_to","verification_type"]))},error:null}}function tl(e){return e}var tc=function(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&0>t.indexOf(s)&&(r[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,s=Object.getOwnPropertySymbols(e);i<s.length;i++)0>t.indexOf(s[i])&&Object.prototype.propertyIsEnumerable.call(e,s[i])&&(r[s[i]]=e[s[i]]);return r};class th{constructor({url:e="",headers:t={},fetch:r}){this.url=e,this.headers=t,this.fetch=eL(r),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)}}async signOut(e,t="global"){try{return await tr(this.fetch,"POST",`${this.url}/logout?scope=${t}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(e){if(eH(e))return{data:null,error:e};throw e}}async inviteUserByEmail(e,t={}){try{return await tr(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:tn})}catch(e){if(eH(e))return{data:{user:null},error:e};throw e}}async generateLink(e){try{let{options:t}=e,r=tc(e,["options"]),s=Object.assign(Object.assign({},r),t);return"newEmail"in r&&(s.new_email=null==r?void 0:r.newEmail,delete s.newEmail),await tr(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:to,redirectTo:null==t?void 0:t.redirectTo})}catch(e){if(eH(e))return{data:{properties:null,user:null},error:e};throw e}}async createUser(e){try{return await tr(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:tn})}catch(e){if(eH(e))return{data:{user:null},error:e};throw e}}async listUsers(e){var t,r,s,i,n,a,o;try{let l={nextPage:null,lastPage:0,total:0},c=await tr(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:null!==(r=null===(t=null==e?void 0:e.page)||void 0===t?void 0:t.toString())&&void 0!==r?r:"",per_page:null!==(i=null===(s=null==e?void 0:e.perPage)||void 0===s?void 0:s.toString())&&void 0!==i?i:""},xform:tl});if(c.error)throw c.error;let h=await c.json(),u=null!==(n=c.headers.get("x-total-count"))&&void 0!==n?n:0,d=null!==(o=null===(a=c.headers.get("link"))||void 0===a?void 0:a.split(","))&&void 0!==o?o:[];return d.length>
10&&(d.forEach(e=>{let t=parseInt(e.split(";")[0].split("=")[1].substring(0,1)),r=JSON.parse(e.split(";")[1].split("=")[1]);l[`${r}Page`]=t}),l.total=parseInt(u)),{data:Object.assign(Object.assign({},h),l),error:null}}catch(e){if(eH(e))return{data:{users:[]},error:e};throw e}}async getUserById(e){try{return await tr(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:tn})}catch(e){if(eH(e))return{data:{user:null},error:e};throw e}}async updateUserById(e,t){try{return await tr(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:tn})}catch(e){if(eH(e))return{data:{user:null},error:e};throw e}}async deleteUser(e,t=!1){try{return await tr(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:tn})}catch(e){if(eH(e))return{data:{user:null},error:e};throw e}}async _listFactors(e){try{let{data:t,error:r}=await tr(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:e=>({data:{factors:e},error:null})});return{data:t,error:r}}catch(e){if(eH(e))return{data:null,error:e};throw e}}async _deleteFactor(e){try{return{data:await tr(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(e){if(eH(e))return{data:null,error:e};throw e}}}let tu="2.57.0",td={"X-Client-Info":`gotrue-js/${tu}`},tf={getItem:e=>eU()?globalThis.localStorage.getItem(e):null,setItem:(e,t)=>{eU()&&globalThis.localStorage.setItem(e,t)},removeItem:e=>{eU()&&globalThis.localStorage.removeItem(e)}};function tp(e={}){return{getItem:t=>e[t]||null,setItem:(t,r)=>{e[t]=r},removeItem:t=>{delete e[t]}}}globalThis&&eU()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug");class tg extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}!function(){if("object"!=typeof globalThis)try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch(e){"undefined"!=typeof self&&(self.globalThis=self)}}();let tm={url:"http://localhost:9999",storageKey:"supabase.auth.token",autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:td,flowType:"implicit",debug:!1};async function tb(e,t,r){return await r()}class ty{constructor(e){var t;this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=ty.nextInstanceID,ty.nextInstanceID+=1,this.instanceID>0&&e$()&&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.");let r=Object.assign(Object.assign({},tm),e);if(this.logDebugMessages=!!r.debug,"function"==typeof r.debug&&(this.logger=r.debug),this.persistSession=r.persistSession,this.storageKey=r.storageKey,this.autoRefreshToken=r.autoRefreshToken,this.admin=new th({url:r.url,headers:r.headers,fetch:r.fetch}),this.url=r.url,this.headers=r.headers,this.fetch=eL(r.fetch),this.lock=r.lock||tb,this.detectSessionInUrl=r.detectSessionInUrl,this.flowType=r.flowType,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?r.storage?this.storage=r.storage:eU()?this.storage=tf:(this.memoryStorage={},this.storage=tp(this.memoryStorage)):(this.memoryStorage={},this.storage=tp(this.memoryStorage)),e$()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(e){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",e)}null===(t=this.broadcastChannel)||void 0===t||t.addEventListener("message",async e=>{this._debug("received broadcast notification from other tab or client",e),await this._notifyAllSubscribers(e.data.event,e.data.session,!1)})}this.initialize()}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${tu}) ${new Date().toISOString()}`,...e),this}async initialize(){return this.initializePromise||(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))()),await this.initializePromise}async _initialize(){try{let e=!!e$()&&await this._isPKCEFlow();if(this._debug("#_initialize()","begin","is PKCE flow",e),e||this.detectSessionInUrl&&this._isImplicitGrantFlow()){let{data:t,error:r}=await this._getSessionFromURL(e);if(r)return this._debug("#_initialize()","error detecting session from URL",r),await this._removeSession(),{error:r};let{session:s,redirectType:i}=t;return this._debug("#_initialize()","detected session in URL",s,"redirect type",i),await this._saveSession(s),setTimeout(async()=>{"recovery"===i?await this._notifyAllSubscribers("PASSWORD_RECOVERY",s):await this._notifyAllSubscribers("SIGNED_IN",s)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(e){if(eH(e))return{error:e};return{error:new eZ("Unexpected error during initialization",e)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signUp(e){var t,r,s;try{let i;if(await this._removeSession(),"email"in e){let{email:r,password:s,options:n}=e,a=null,o=null;if("pkce"===this.flowType){let e=eG();await eF(this.storage,`${this.storageKey}-code-verifier`,e),a=await eV(e),o=e===a?"plain":"s256"}i=await tr(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:null==n?void 0:n.emailRedirectTo,body:{email:r,password:s,data:null!==(t=null==n?void 0:n.data)&&void 0!==t?t:{},gotrue_meta_security:{captcha_token:null==n?void 0:n.captchaToken},code_challenge:a,code_challenge_method:o},xform:ti})}else if("phone"in e){let{phone:t,password:n,options:a}=e;i=await tr(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:t,password:n,data:null!==(r=null==a?void 0:a.data)&&void 0!==r?r:{},channel:null!==(s=null==a?void 0:a.channel)&&void 0!==s?s:"sms",gotrue_meta_security:{captcha_token:null==a?void 0:a.captchaToken}},xform:ti})}else throw new e2("You must provide either an email or phone number and a password");let{data:n,error:a}=i;if(a||!n)return{data:{user:null,session:null},error:a};let o=n.session,l=n.user;return n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",o)),{data:{user:l,session:o},error:null}}catch(e){if(eH(e))return{data:{user:null,session:null},error:e};throw e}}async signInWithPassword(e){try{let t;if(await this._removeSession(),"email"in e){let{email:r,password:s,options:i}=e;t=await tr(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:r,password:s,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},xform:ti})}else if("phone"in e){let{phone:r,password:s,options:i}=e;t=await tr(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:r,password:s,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},xform:ti})}else throw new e2("You must provide either an email or phone number and a password");let{data:r,error:s}=t;if(s)return{data:{user:null,session:null},error:s};if(!r||!r.session||!r.user)return{data:{user:null,session:null},error:new e1};return r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),{data:{user:r.user,session:r.session},error:s}}catch(e){if(eH(e))return{data:{user:null,session:null},error:e};throw e}}async signInWithOAuth(e){var t,r,s,i;return await this._removeSession(),await this._handleProviderSignIn(e.provider,{redirectTo:null===(t=e.options)||void 0===t?void 0:t.redirectTo,scopes:null===(r=e.options)||void 0===r?void 0:r.scopes,queryParams:null===(s=e.options)||void 0===s?void 0:s.queryParams,skipBrowserRedirect:null===(i=e.options)||void 0===i?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async _exchangeCodeForSession(e){let t=await eB(this.storage,`${this.storageKey}-code-verifier`),{data:r,error:s}=await tr(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:t},xform:ti});return(await eJ(this.storage,`${this.storageKey}-code-verifier`),s)?{data:{user:null,session:null},error:s}:r&&r.session&&r.user?(r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),{data:r,error:s}):{data:{user:null,session:null},error:new e1}}async signInWithIdToken(e){await this._removeSession();try{let{options:t,provider:r,token:s,access_token:i,nonce:n}=e,{data:a,error:o}=await tr(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:s,access_token:i,nonce:n,gotrue_meta_security:{captcha_token:null==t?void 0:t.captchaToken}},xform:ti});if(o)return{data:{user:null,session:null},error:o};if(!a||!a.session||!a.user)return{data:{user:null,session:null},error:new e1};return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",a.session)),{data:a,error:o}}catch(e){if(eH(e))return{data:{user:null,session:null},error:e};throw e}}async signInWithOtp(e){var t,r,s,i,n;try{if(await this._removeSession(),"email"in e){let{email:s,options:i}=e,n=null,a=null;if("pkce"===this.flowType){let e=eG();await eF(this.storage,`${this.storageKey}-code-verifier`,e),n=await eV(e),a=e===n?"plain":"s256"}let{error:o}=await tr(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:s,data:null!==(t=null==i?void 0:i.data)&&void 0!==t?t:{}
1,create_user:null===(r=null==i?void 0:i.shouldCreateUser)||void 0===r||r,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken},code_challenge:n,code_challenge_method:a},redirectTo:null==i?void 0:i.emailRedirectTo});return{data:{user:null,session:null},error:o}}if("phone"in e){let{phone:t,options:r}=e,{data:a,error:o}=await tr(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:t,data:null!==(s=null==r?void 0:r.data)&&void 0!==s?s:{},create_user:null===(i=null==r?void 0:r.shouldCreateUser)||void 0===i||i,gotrue_meta_security:{captcha_token:null==r?void 0:r.captchaToken},channel:null!==(n=null==r?void 0:r.channel)&&void 0!==n?n:"sms"}});return{data:{user:null,session:null,messageId:null==a?void 0:a.message_id},error:o}}throw new e2("You must provide either an email or phone number.")}catch(e){if(eH(e))return{data:{user:null,session:null},error:e};throw e}}async verifyOtp(e){var t,r;try{let s,i;"email_change"!==e.type&&"phone_change"!==e.type&&await this._removeSession(),"options"in e&&(s=null===(t=e.options)||void 0===t?void 0:t.redirectTo,i=null===(r=e.options)||void 0===r?void 0:r.captchaToken);let{data:n,error:a}=await tr(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:s,xform:ti});if(a)throw a;if(!n)throw Error("An error occurred on token verification.");let o=n.session,l=n.user;return(null==o?void 0:o.access_token)&&(await this._saveSession(o),await this._notifyAllSubscribers("SIGNED_IN",o)),{data:{user:l,session:o},error:null}}catch(e){if(eH(e))return{data:{user:null,session:null},error:e};throw e}}async signInWithSSO(e){var t,r,s;try{await this._removeSession();let i=null,n=null;if("pkce"===this.flowType){let e=eG();await eF(this.storage,`${this.storageKey}-code-verifier`,e),i=await eV(e),n=e===i?"plain":"s256"}return await tr(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:null!==(r=null===(t=e.options)||void 0===t?void 0:t.redirectTo)&&void 0!==r?r:void 0}),(null===(s=null==e?void 0:e.options)||void 0===s?void 0:s.captchaToken)?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:i,code_challenge_method:n}),headers:this.headers,xform:ta})}catch(e){if(eH(e))return{data:null,error:e};throw e}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{let{data:{session:t},error:r}=e;if(r)throw r;if(!t)throw new e0;let{error:s}=await tr(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:t.access_token});return{data:{user:null,session:null},error:s}})}catch(e){if(eH(e))return{data:{user:null,session:null},error:e};throw e}}async resend(e){try{"email_change"!=e.type&&"phone_change"!=e.type&&await this._removeSession();let t=`${this.url}/resend`;if("email"in e){let{email:r,type:s,options:i}=e,{error:n}=await tr(this.fetch,"POST",t,{headers:this.headers,body:{email:r,type:s,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},redirectTo:null==i?void 0:i.emailRedirectTo});return{data:{user:null,session:null},error:n}}if("phone"in e){let{phone:r,type:s,options:i}=e,{data:n,error:a}=await tr(this.fetch,"POST",t,{headers:this.headers,body:{phone:r,type:s,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}}});return{data:{user:null,session:null,messageId:null==n?void 0:n.message_id},error:a}}throw new e2("You must provide either an email or phone number and a type")}catch(e){if(eH(e))return{data:{user:null,session:null},error:e};throw e}}async getSession(){return await this.initializePromise,this._acquireLock(-1,async()=>this._useSession(async e=>e))}async _acquireLock(e,t){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){let e=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),r=(async()=>(await e,await t()))();return this.pendingInLock.push((async()=>{try{await r}catch(e){}})()),r}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;let e=t();for(this.pendingInLock.push((async()=>{try{await e}catch(e){}})()),await e;this.pendingInLock.length;){let e=[...this.pendingInLock];await Promise.all(e),this.pendingInLock.splice(0,e.length)}return await e}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{let 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!",Error().stack);try{let e=null,t=await eB(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",t),null!==t&&(this._isValidSession(t)?e=t:(this._debug("#getSession()","session from storage is not val
1id"),await this._removeSession())),!e)return{data:{session:null},error:null};let r=!!e.expires_at&&e.expires_at<=Date.now()/1e3;if(this._debug("#__loadSession()",`session has${r?"":" not"} expired`,"expires_at",e.expires_at),!r)return{data:{session:e},error:null};let{session:s,error:i}=await this._callRefreshToken(e.refresh_token);if(i)return{data:{session:null},error:i};return{data:{session:s},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(e){return e?await this._getUser(e):(await this.initializePromise,this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(e){try{if(e)return await tr(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:tn});return await this._useSession(async e=>{var t,r;let{data:s,error:i}=e;if(i)throw i;return await tr(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:null!==(r=null===(t=s.session)||void 0===t?void 0:t.access_token)&&void 0!==r?r:void 0,xform:tn})})}catch(e){if(eH(e))return{data:{user:null},error:e};throw e}}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=>{let{data:s,error:i}=r;if(i)throw i;if(!s.session)throw new e0;let n=s.session,a=null,o=null;if("pkce"===this.flowType&&null!=e.email){let e=eG();await eF(this.storage,`${this.storageKey}-code-verifier`,e),a=await eV(e),o=e===a?"plain":"s256"}let{data:l,error:c}=await tr(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:null==t?void 0:t.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:o}),jwt:n.access_token,xform:tn});if(c)throw c;return n.user=l.user,await this._saveSession(n),await this._notifyAllSubscribers("USER_UPDATED",n),{data:{user:n.user},error:null}})}catch(e){if(eH(e))return{data:{user:null},error:e};throw e}}_decodeJWT(e){return eM(e)}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 e0;let t=Date.now()/1e3,r=t,s=!0,i=null,n=eM(e.access_token);if(n.exp&&(s=(r=n.exp)<=t),s){let{session:t,error:r}=await this._callRefreshToken(e.refresh_token);if(r)return{data:{user:null,session:null},error:r};if(!t)return{data:{user:null,session:null},error:null};i=t}else{let{data:s,error:n}=await this._getUser(e.access_token);if(n)throw n;i={access_token:e.access_token,refresh_token:e.refresh_token,user:s.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(e){if(eH(e))return{data:{session:null,user:null},error:e};throw e}}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){let{data:s,error:i}=t;if(i)throw i;e=null!==(r=s.session)&&void 0!==r?r:void 0}if(!(null==e?void 0:e.refresh_token))throw new e0;let{session:s,error:i}=await this._callRefreshToken(e.refresh_token);return i?{data:{user:null,session:null},error:i}:s?{data:{user:s.user,session:s},error:null}:{data:{user:null,session:null},error:null}})}catch(e){if(eH(e))return{data:{user:null,session:null},error:e};throw e}}async _getSessionFromURL(e){try{if(!e$())throw new e3("No browser detected.");if("implicit"!==this.flowType||this._isImplicitGrantFlow()){if("pkce"==this.flowType&&!e)throw new e6("Not a valid PKCE flow url.")}else throw new e3("Not a valid implicit grant flow url.");let t=eD(window.location.href);if(e){if(!t.code)throw new e6("No code detected.");let{data:e,error:r}=await this._exchangeCodeForSession(t.code);if(r)throw r;let s=new URL(window.location.href);return s.searchParams.delete("code"),window.history.replaceState(window.history.state,"",s.toString()),{data:{session:e.session,redirectType:null},error:null}}if(t.error||t.error_description||t.error_code)throw new e3(t.error_description||"Error in URL with unspecified error_description",{error:t.error||"unspecified_error",code:t.error_code||"unspecified_code"});let{provider_token:r,provider_refresh_token:s,access_token:i,refresh_token:n,expires_in:a,expires_at:o,token_type:l}=t;if(!i||!a||!n||!l)throw new e3("No session defined in URL");let c=Math.round(Date.now()/1e3),h=parseInt(a),u=c+h;o&&(u=parseInt(o));let d=u-c;
11e3*d<=3e4&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${d}s, should have been closer to ${h}s`);let f=u-h;c-f>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",f,u,c):c-f<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clok for skew",f,u,c);let{data:p,error:g}=await this._getUser(i);if(g)throw g;let m={provider_token:r,provider_refresh_token:s,access_token:i,expires_in:h,expires_at:u,refresh_token:n,token_type:l,user:p.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:m,redirectType:t.type},error:null}}catch(e){if(eH(e))return{data:{session:null,redirectType:null},error:e};throw e}}_isImplicitGrantFlow(){let e=eD(window.location.href);return!!(e$()&&(e.access_token||e.error_description))}async _isPKCEFlow(){let e=eD(window.location.href),t=await eB(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;let{data:s,error:i}=t;if(i)return{error:i};let n=null===(r=s.session)||void 0===r?void 0:r.access_token;if(n){let{error:t}=await this.admin.signOut(n,e);if(t&&!(eH(t)&&"AuthApiError"===t.name&&(404===t.status||401===t.status)))return{error:t}}return"others"!==e&&(await this._removeSession(),await eJ(this.storage,`${this.storageKey}-code-verifier`),await this._notifyAllSubscribers("SIGNED_OUT",null)),{error:null}})}onAuthStateChange(e){let t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){let t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}),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,s;try{let{data:{session:s},error:i}=t;if(i)throw i;await (null===(r=this.stateChangeEmitters.get(e))||void 0===r?void 0:r.callback("INITIAL_SESSION",s)),this._debug("INITIAL_SESSION","callback id",e,"session",s)}catch(t){await (null===(s=this.stateChangeEmitters.get(e))||void 0===s?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",t),console.error(t)}})}async resetPasswordForEmail(e,t={}){let r=null,s=null;if("pkce"===this.flowType){let e=eG();await eF(this.storage,`${this.storageKey}-code-verifier`,e),r=await eV(e),s=e===r?"plain":"s256"}try{return await tr(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:r,code_challenge_method:s,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo})}catch(e){if(eH(e))return{data:null,error:e};throw e}}async _refreshAccessToken(e){let t=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(t,"begin");try{var r,s;let i=Date.now();return await (r=async r=>(await eq(200*r),this._debug(t,"refreshing attempt",r),await tr(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:ti})),s=(e,t,r)=>r&&r.error&&e5(r.error)&&Date.now()+(e+1)*200-i<3e4,new Promise((e,t)=>{(async()=>{for(let i=0;i<1/0;i++)try{let t=await r(i);if(!s(i,null,t)){e(t);return}}catch(e){if(!s(i,e)){t(e);return}}})()}))}catch(e){if(this._debug(t,"error",e),eH(e))return{data:{session:null,user:null},error:e};throw e}finally{this._debug(t,"end")}}_isValidSession(e){return"object"==typeof e&&null!==e&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,t){let r=await this._getUrlForProvider(e,{redirectTo:t.redirectTo,scopes:t.scopes,queryParams:t.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",t,"url",r),e$()&&!t.skipBrowserRedirect&&window.location.assign(r),{data:{provider:e,url:r},error:null}}async _recoverAndRefresh(){var e;let t="#_recoverAndRefresh()";this._debug(t,"begin");try{let r=await eB(this.storage,this.storageKey);if(this._debug(t,"session from storage",r),!this._isValidSession(r)){this._debug(t,"session is not val
1id"),null!==r&&await this._removeSession();return}let s=Math.round(Date.now()/1e3),i=(null!==(e=r.expires_at)&&void 0!==e?e:1/0)<s+10;if(this._debug(t,`session has${i?"":" not"} expired with margin of 10s`),i){if(this.autoRefreshToken&&r.refresh_token){let{error:e}=await this._callRefreshToken(r.refresh_token);e&&(console.error(e),e5(e)||(this._debug(t,"refresh failed with a non-retryable error, removing the session",e),await this._removeSession()))}}else await this._notifyAllSubscribers("SIGNED_IN",r)}catch(e){this._debug(t,"error",e),console.error(e);return}finally{this._debug(t,"end")}}async _callRefreshToken(e){var t,r;if(!e)throw new e0;if(this.refreshingDeferred)return this.refreshingDeferred.promise;let s=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{this.refreshingDeferred=new ez;let{data:t,error:r}=await this._refreshAccessToken(e);if(r)throw r;if(!t.session)throw new e0;await this._saveSession(t.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",t.session);let s={session:t.session,error:null};return this.refreshingDeferred.resolve(s),s}catch(e){if(this._debug(s,"error",e),eH(e)){let r={session:null,error:e};return null===(t=this.refreshingDeferred)||void 0===t||t.resolve(r),r}throw null===(r=this.refreshingDeferred)||void 0===r||r.reject(e),e}finally{this.refreshingDeferred=null,this._debug(s,"end")}}async _notifyAllSubscribers(e,t,r=!0){let s=`#_notifyAllSubscribers(${e})`;this._debug(s,"begin",t,`broadcast = ${r}`);try{this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:e,session:t});let s=[],i=Array.from(this.stateChangeEmitters.values()).map(async r=>{try{await r.callback(e,t)}catch(e){s.push(e)}});if(await Promise.all(i),s.length>0){for(let e=0;e<s.length;e+=1)console.error(s[e]);throw s[0]}}finally{this._debug(s,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),await this._persistSession(e)}_persistSession(e){return this._debug("#_persistSession()",e),eF(this.storage,this.storageKey,e)}async _removeSession(){this._debug("#_removeSession()"),await eJ(this.storage,this.storageKey)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");let e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&e$()&&(null==window?void 0:window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}catch(e){console.error("removing visibilitychange callback failed",e)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");let e=setInterval(()=>this._autoRefreshTokenTick(),3e4);this.autoRefreshTicker=e,e&&"object"==typeof e&&"function"==typeof e.unref?e.unref():"undefined"!=typeof Deno&&"function"==typeof Deno.unrefTimer&&Deno.unrefTimer(e),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");let 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{let e=Date.now();try{return await this._useSession(async t=>{let{data:{session:r}}=t;if(!r||!r.refresh_token||!r.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}let s=Math.floor((1e3*r.expires_at-e)/3e4);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts 30000ms, refresh threshold is 3 ticks`),s<=3&&await this._callRefreshToken(r.refresh_token)})}catch(e){console.error("Auto refresh tick failed with error. This is likely a transient error.",e)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof tg)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!e$()||!(null==window?void 0:window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),null==window||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){let t=`#_onVisibilityChanged(${e})`;this._debug(t,"visibilityState",document.visibilityState),"visible"===document.visibilityState?(this.autoRefreshToken&&this._startAutoRefresh(),e||(
1await this.initializePromise,await this._acquireLock(-1,async()=>{if("visible"!==document.visibilityState){this._debug(t,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):"hidden"===document.visibilityState&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,t){let r=[`provider=${encodeURIComponent(e)}`];if((null==t?void 0:t.redirectTo)&&r.push(`redirect_to=${encodeURIComponent(t.redirectTo)}`),(null==t?void 0:t.scopes)&&r.push(`scopes=${encodeURIComponent(t.scopes)}`),"pkce"===this.flowType){let e=eG();await eF(this.storage,`${this.storageKey}-code-verifier`,e);let t=await eV(e),s=e===t?"plain":"s256";this._debug("PKCE","code verifier",`${e.substring(0,5)}...`,"code challenge",t,"method",s);let i=new URLSearchParams({code_challenge:`${encodeURIComponent(t)}`,code_challenge_method:`${encodeURIComponent(s)}`});r.push(i.toString())}if(null==t?void 0:t.queryParams){let e=new URLSearchParams(t.queryParams);r.push(e.toString())}return`${this.url}/authorize?${r.join("&")}`}async _unenroll(e){try{return await this._useSession(async t=>{var r;let{data:s,error:i}=t;return i?{data:null,error:i}:await tr(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:null===(r=null==s?void 0:s.session)||void 0===r?void 0:r.access_token})})}catch(e){if(eH(e))return{data:null,error:e};throw e}}async _enroll(e){try{return await this._useSession(async t=>{var r,s;let{data:i,error:n}=t;if(n)return{data:null,error:n};let{data:a,error:o}=await tr(this.fetch,"POST",`${this.url}/factors`,{body:{friendly_name:e.friendlyName,factor_type:e.factorType,issuer:e.issuer},headers:this.headers,jwt:null===(r=null==i?void 0:i.session)||void 0===r?void 0:r.access_token});return o?{data:null,error:o}:((null===(s=null==a?void 0:a.totp)||void 0===s?void 0:s.qr_code)&&(a.totp.qr_code=`data:image/svg+xml;utf-8,${a.totp.qr_code}`),{data:a,error:null})})}catch(e){if(eH(e))return{data:null,error:e};throw e}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var r;let{data:s,error:i}=t;if(i)return{data:null,error:i};let{data:n,error:a}=await tr(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:null===(r=null==s?void 0:s.session)||void 0===r?void 0:r.access_token});return a?{data:null,error:a}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+n.expires_in},n)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",n),{data:n,error:a})})}catch(e){if(eH(e))return{data:null,error:e};throw e}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var r;let{data:s,error:i}=t;return i?{data:null,error:i}:await tr(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{headers:this.headers,jwt:null===(r=null==s?void 0:s.session)||void 0===r?void 0:r.access_token})})}catch(e){if(eH(e))return{data:null,error:e};throw e}})}async _challengeAndVerify(e){let{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(){let{data:{user:e},error:t}=await this.getUser();if(t)return{data:null,error:t};let r=(null==e?void 0:e.factors)||[],s=r.filter(e=>"totp"===e.factor_type&&"verified"===e.status);return{data:{all:r,totp:s},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async e=>{var t,r;let{data:{session:s},error:i}=e;if(i)return{data:null,error:i};if(!s)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};let n=this._decodeJWT(s.access_token),a=null;n.aal&&(a=n.aal);let o=a;return(null!==(r=null===(t=s.user.factors)||void 0===t?void 0:t.filter(e=>"verified"===e.status))&&void 0!==r?r:[]).length>0&&(o="aal2"),{data:{currentLevel:a,nextLevel:o,currentAuthenticationMethods:n.amr||[]},error:null}}))}}ty.nextInstanceID=0;class tv extends ty{constructor(e){super(e)}}let tw={headers:eI},t_={schema:"public"},tk={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},tS={};class tE{constructor(e,t,r){var s,i,n,a,o,l,c,h;if(this.supabaseUrl=e,this.supabaseKey=t,!e)throw Error("supabaseUrl is required.");
1if(!t)throw Error("supabaseKey is required.");let u=e.replace(/\/$/,"");this.realtimeUrl=`${u}/realtime/v1`.replace(/^http/i,"ws"),this.authUrl=`${u}/auth/v1`,this.storageUrl=`${u}/storage/v1`,this.functionsUrl=`${u}/functions/v1`;let d=`sb-${new URL(this.authUrl).hostname.split(".")[0]}-auth-token`,f=function(e,t){let{db:r,auth:s,realtime:i,global:n}=e,{db:a,auth:o,realtime:l,global:c}=t;return{db:Object.assign(Object.assign({},a),r),auth:Object.assign(Object.assign({},o),s),realtime:Object.assign(Object.assign({},l),i),global:Object.assign(Object.assign({},c),n)}}(null!=r?r:{},{db:t_,realtime:tS,auth:Object.assign(Object.assign({},tk),{storageKey:d}),global:tw});this.storageKey=null!==(i=null===(s=f.auth)||void 0===s?void 0:s.storageKey)&&void 0!==i?i:"",this.headers=null!==(a=null===(n=f.global)||void 0===n?void 0:n.headers)&&void 0!==a?a:{},this.auth=this._initSupabaseAuthClient(null!==(o=f.auth)&&void 0!==o?o:{},this.headers,null===(l=f.global)||void 0===l?void 0:l.fetch),this.fetch=eP(t,this._getAccessToken.bind(this),null===(c=f.global)||void 0===c?void 0:c.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers},f.realtime)),this.rest=new J(`${u}/rest/v1`,{headers:this.headers,schema:null===(h=f.db)||void 0===h?void 0:h.schema,fetch:this.fetch}),this._listenForAuthEvents()}get functions(){return new $(this.functionsUrl,{headers:this.headers,customFetch:this.fetch})}get storage(){return new eO(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,r,s,i,n;return r=this,s=void 0,i=void 0,n=function*(){let{data:r}=yield this.auth.getSession();return null!==(t=null===(e=r.session)||void 0===e?void 0:e.access_token)&&void 0!==t?t:null},new(i||(i=Promise))(function(e,t){function a(e){try{l(n.next(e))}catch(e){t(e)}}function o(e){try{l(n.throw(e))}catch(e){t(e)}}function l(t){var r;t.done?e(t.value):((r=t.value)instanceof i?r:new i(function(e){e(r)})).then(a,o)}l((n=n.apply(r,s||[])).next())})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:s,storageKey:i,flowType:n,debug:a},o,l){let c={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new tv({url:this.authUrl,headers:Object.assign(Object.assign({},c),o),storageKey:i,autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:s,flowType:n,debug:a,fetch:l})}_initRealtimeClient(e){return new en(this.realtimeUrl,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},null==e?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((e,t)=>{this._handleTokenChanged(e,"CLIENT",null==t?void 0:t.access_token)})}_handleTokenChanged(e,t,r){("TOKEN_REFRESHED"===e||"SIGNED_IN"===e)&&this.changedAccessToken!==r?(this.realtime.setAuth(null!=r?r:null),this.changedAccessToken=r):"SIGNED_OUT"===e&&(this.realtime.setAuth(this.supabaseKey),"STORAGE"==t&&this.auth.signOut(),this.changedAccessToken=void 0)}}let tC=(e,t,r)=>new tE(e,t,r);var tT=Object.create,tO=Object.defineProperty,tj=Object.getOwnPropertyDescriptor,tI=Object.getOwnPropertyNames,tx=Object.getPrototypeOf,tA=Object.prototype.hasOwnProperty,tP=(e,t,r,s)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let i of tI(t))tA.call(e,i)||i===r||tO(e,i,{get:()=>t[i],enumerable:!(s=tj(t,i))||s.enumerable});return e},t$=(e,t,r)=>(r=null!=e?tT(tx(e)):{},tP(!t&&e&&e.__esModule?r:tO(r,"default",{value:e,enumerable:!0}),e)),tR=(p={"../../node_modules/.pnpm/[email protected]/node_modules/cookie/index.js"(e){e.parse=function(e,t){if("string"!=typeof e)throw TypeError("argument str must be a string");for(var r={},i=(t||{}).decode||s,n=0;n<e.length;){var a=e.indexOf("=",n);if(-1===a)break;var o=e.indexOf(";",n);if(-1===o)o=e.length;else if(o<a){n=e.lastIndexOf(";",a-1)+1;continue}var l=e.slice(n,a).trim();if(void 0===r[l]){var c=e.slice(a+1,o).trim();
134===c.charCodeAt(0)&&(c=c.slice(1,-1)),r[l]=function(e,t){try{return t(e)}catch(t){return e}}(c,i)}n=o+1}return r},e.serialize=function(e,s,n){var a=n||{},o=a.encode||i;if("function"!=typeof o)throw TypeError("option encode is invalid");if(!r.test(e))throw TypeError("argument name is invalid");var l=o(s);if(l&&!r.test(l))throw TypeError("argument val is invalid");var c=e+"="+l;if(null!=a.maxAge){var h=a.maxAge-0;if(isNaN(h)||!isFinite(h))throw TypeError("option maxAge is invalid");c+="; Max-Age="+Math.floor(h)}if(a.domain){if(!r.test(a.domain))throw TypeError("option domain is invalid");c+="; Domain="+a.domain}if(a.path){if(!r.test(a.path))throw TypeError("option path is invalid");c+="; Path="+a.path}if(a.expires){var u=a.expires;if("[object Date]"!==t.call(u)&&!(u instanceof Date)||isNaN(u.valueOf()))throw TypeError("option expires is invalid");c+="; Expires="+u.toUTCString()}if(a.httpOnly&&(c+="; HttpOnly"),a.secure&&(c+="; Secure"),a.priority)switch("string"==typeof a.priority?a.priority.toLowerCase():a.priority){case"low":c+="; Priority=Low";break;case"medium":c+="; Priority=Medium";break;case"high":c+="; Priority=High";break;
1default:throw TypeError("option priority is invalid")}if(a.sameSite)switch("string"==typeof a.sameSite?a.sameSite.toLowerCase():a.sameSite){case!0:case"strict":c+="; SameSite=Strict";break;case"lax":c+="; SameSite=Lax";break;case"none":c+="; SameSite=None";break;default:throw TypeError("option sameSite is invalid")}return c};var t=Object.prototype.toString,r=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function s(e){return -1!==e.indexOf("%")?decodeURIComponent(e):e}function i(e){return encodeURIComponent(e)}}},function(){return g||(0,p[tI(p)[0]])((g={exports:{}}).exports,g),g.exports}),tU=t$(tR()),tD=t$(tR());function tL(e){if(!e)return null;try{let t=JSON.parse(e);if(!t)return null;if("Object"===t.constructor.name)return t;if("Array"!==t.constructor.name)throw Error(`Unexpected format: ${t.constructor.name}`);let[r,s,i]=t[0].split("."),n=O(s),a=new TextDecoder,{exp:o,sub:l,...c}=JSON.parse(a.decode(n));return{expires_at:o,expires_in:o-Math.round(Date.now()/1e3),token_type:"bearer",access_token:t[0],refresh_token:t[1],provider_token:t[2],provider_refresh_token:t[3],user:{id:l,factors:t[4],...c}}}catch(e){return console.warn("Failed to parse cookie string:",e),null}}function tN(e){var t;return JSON.stringify([e.access_token,e.refresh_token,e.provider_token,e.provider_refresh_token,(null==(t=e.user)?void 0:t.factors)??null])}function tF(){return"undefined"!=typeof window&&void 0!==window.document}var tB={path:"/",sameSite:"lax",maxAge:31536e6};function tJ(e){return RegExp(".{1,"+e+"}","g")}var tz=tJ(3180),tM=class{constructor(e){this.cookieOptions={...tB,...e,maxAge:tB.maxAge}}getItem(e){let t=this.getCookie(e);if(e.endsWith("-code-verifier")&&t)return t;if(t)return JSON.stringify(tL(t));let r=function(e,t=()=>null){let r=[];for(let s=0;;s++){let i=t(`${e}.${s}`);if(!i)break;r.push(i)}return r.length?r.join(""):null}(e,e=>this.getCookie(e));return null!==r?JSON.stringify(tL(r)):null}setItem(e,t){if(e.endsWith("-code-verifier")){this.setCookie(e,t);return}(function(e,t,r){let s=void 0!==r?tJ(r):tz;if(1===Math.ceil(t.length/(r??3180)))return[{name:e,value:t}];let i=[],n=t.match(s);return null==n||n.forEach((t,r)=>{let s=`${e}.${r}`;i.push({name:s,value:t})}),i})(e,tN(JSON.parse(t))).forEach(e=>{this.setCookie(e.name,e.value)})}removeItem(e){this._deleteSingleCookie(e),this._deleteChunkedCookies(e)}_deleteSingleCookie(e){this.getCookie(e)&&this.deleteCookie(e)}_deleteChunkedCookies(e,t=0){for(let r=t;;r++){let t=`${e}.${r}`;if(void 0===this.getCookie(t))break;this.deleteCookie(t)}}},tq=class extends tM{constructor(e){super(e)}getCookie(e){return tF()?(0,tU.parse)(document.cookie)[e]:null}setCookie(e,t){if(!tF())return null;document.cookie=(0,tU.serialize)(e,t,{...this.cookieOptions,httpOnly:!1})}deleteCookie(e){if(!tF())return null;document.cookie=(0,tU.serialize)(e,"",{...this.cookieOptions,maxAge:0,httpOnly:!1})}};function tK(e,t,r){var s;let i=tF();return tC(e,t,{...r,auth:{flowType:"pkce",autoRefreshToken:i,detectSessionInUrl:i,persistSession:!0,storage:r.auth.storage,...(null==(s=r.auth)?void 0:s.storageKey)?{storageKey:r.auth.storageKey}:{}}})}var tG=tD.parse,tX=tD.serialize;/*! Bundled license information: 2 3cookie/index.js: 4 (*! 5 * cookie 6 * Copyright(c) 2012-2014 Roman Shtylman 7 * Copyright(c) 2015 Douglas Christopher Wilson 8 * MIT Licensed 9 *) 10*/},2151:function(e){"use strict";e.exports={version:"1.0.34"}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.