1;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="2d4c41c2-441e-63d6-c35f-0fe7d196a9c3")}catch(e){}}(); 2(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,617029,e=>{"use strict";var t=e.i(368058),s=e.i(201234);let r=(0,s.createContext)(void 0);function i({children:e}){let[i,a]=(0,s.useState)(!1);return(0,t.jsx)(r.Provider,{value:{isCollapsed:i,setIsCollapsed:a},children:e})}function a(){let e=(0,s.useContext)(r);if(void 0===e)throw Error("useSidebar must be used within a SidebarProvider");return e}e.s(["SidebarProvider",()=>i,"useSidebar",()=>a])},460587,(e,t,s)=>{"use strict";Object.defineProperty(s,"__esModule",{value:!0}),s.default=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}}},6150,(e,t,s)=>{"use strict";var r=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0});let i=r(e.r(337692)),a=r(e.r(460587));s.default=class{constructor(e){this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=e.headers,this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=e.shouldThrowOnError,this.signal=e.signal,this.isMaybeSingle=e.isMaybeSingle,e.fetch?this.fetch=e.fetch:"u"<typeof fetch?this.fetch=i.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=Object.assign({},this.headers),this.headers[e]=t,this}then(e,t){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 s=(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,s,r;let i=null,n=null,o=null,l=e.status,c=e.statusText;if(e.ok){if("HEAD"!==this.method){let t=await e.text();""===t||(n="text/csv"===this.headers.Accept||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?t:JSON.parse(t))}let r=null==(t=this.headers.Prefer)?void 0:t.match(/count=(exact|planned|estimated)/),a=null==(s=e.headers.get("content-range"))?void 0:s.split("/");r&&a&&a.length>1&&(o=parseInt(a[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,o=null,l=406,c="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,l=200,c="OK")}catch(s){404===e.status&&""===t?(l=204,c="No Content"):i={message:t}}if(i&&this.isMaybeSingle&&(null==(r=null==i?void 0:i.details)?void 0:r.includes("0 rows"))&&(i=null,l=200,c="OK"),i&&this.shouldThrowOnError)throw new a.default(i)}return{error:i,data:n,count:o,status:l,statusText:c}});return this.shouldThrowOnError||(s=s.catch(e=>{var t,s,r;return{error:{message:`${null!=(t=null==e?void 0:e.name)?t:"FetchError"}: ${null==e?void 0:e.message}`,details:`${null!=(s=null==e?void 0:e.stack)?s:""}`,hint:"",code:`${null!=(r=null==e?void 0:e.code)?r:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}returns(){return this}overrideTypes(){return this}}},753243,(e,t,s)=>{"use strict";var r=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0});let i=r(e.r(6150));class a extends i.default{select(e){let t=!1,s=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!t?"":('"'===e&&(t=!t),e)).join("");return this.url.searchParams.set("select",s),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(e,{ascending:t=!0,nullsFirst:s,foreignTable:r,referencedTable:i=r}={}){let a=i?`${i}.order`:"order",n=this.url.searchParams.get(a);return this.url.searchParams.set(a,`${n?`${n},`:""}${e}.${t?"asc":"desc"}${void 0===s?"":s?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:s=t}={}){let r=void 0===s?"limit":`${s}.limit`;return this.url.searchParams.set(r,`${e}`),this}range(e,t,{foreignTable:s,referencedTable:r=s}={}){let i=void 0===r?"offset":`${r}.offset`,a=void 0===r?"limit":`${r}.limit`;return this.url.searchParams.set(i,`${e}`),this.url.searchParams.set(a,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return"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}
2explain({analyze:e=!1,verbose:t=!1,settings:s=!1,buffers:r=!1,wal:i=!1,format:a="text"}={}){var n;let o=[e?"analyze":null,t?"verbose":null,s?"settings":null,r?"buffers":null,i?"wal":null].filter(Boolean).join("|"),l=null!=(n=this.headers.Accept)?n:"application/json";return this.headers.Accept=`application/vnd.pgrst.plan+${a}; for="${l}"; options=${o};`,this}rollback(){var e;return(null!=(e=this.headers.Prefer)?e:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}}s.default=a},816803,(e,t,s)=>{"use strict";var r=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0});let i=r(e.r(753243));class a extends i.default{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){let s=Array.from(new Set(t)).map(e=>"string"==typeof e&&RegExp("[,()]").test(e)?`"${e}"`:`${e}`).join(",");return this.url.searchParams.append(e,`in.(${s})`),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:s,type:r}={}){let i="";"plain"===r?i="pl":"phrase"===r?i="ph":"websearch"===r&&(i="w");let a=void 0===s?"":`(${s})`;return this.url.searchParams.append(e,`${i}fts${a}.${t}`),this}match(e){return Object.entries(e).forEach(([e,t])=>{this.url.searchParams.append(e,`eq.${t}`)}),this}not(e,t,s){return this.url.searchParams.append(e,`not.${t}.${s}`),this}or(e,{foreignTable:t,referencedTable:s=t}={}){let r=s?`${s}.or`:"or";return this.url.searchParams.append(r,`(${e})`),this}filter(e,t,s){return this.url.searchParams.append(e,`${t}.${s}`),this}}s.default=a},828159,(e,t,s)=>{"use strict";var r=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0});let i=r(e.r(816803));s.default=class{constructor(e,{headers:t={},schema:s,fetch:r}){this.url=e,this.headers=t,this.schema=s,this.fetch=r}select(e,{head:t=!1,count:s}={}){let r=!1,a=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!r?"":('"'===e&&(r=!r),e)).join("");return this.url.searchParams.set("select",a),s&&(this.headers.Prefer=`count=${s}`),new i.default({method:t?"HEAD":"GET",url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e,{count:t,defaultToNull:s=!0}={}){let r=[];if(this.headers.Prefer&&r.push(this.headers.Prefer),t&&r.push(`count=${t}`),s||r.push("missing=default"),this.headers.Prefer=r.join(","),Array.isArray(e)){let t=e.reduce((e,t)=>
2e.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 i.default({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}upsert(e,{onConflict:t,ignoreDuplicates:s=!1,count:r,defaultToNull:a=!0}={}){let n=[`resolution=${s?"ignore":"merge"}-duplicates`];if(void 0!==t&&this.url.searchParams.set("on_conflict",t),this.headers.Prefer&&n.push(this.headers.Prefer),r&&n.push(`count=${r}`),a||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 i.default({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}update(e,{count:t}={}){let s=[];return this.headers.Prefer&&s.push(this.headers.Prefer),t&&s.push(`count=${t}`),this.headers.Prefer=s.join(","),new i.default({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 i.default({method:"DELETE",url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}}},871792,(e,t,s)=>{"use strict";Object.defineProperty(s,"__esModule",{value:!0}),s.version=void 0,s.version="0.0.0-automated"},201236,(e,t,s)=>{"use strict";Object.defineProperty(s,"__esModule",{value:!0}),s.DEFAULT_HEADERS=void 0;let r=e.r(871792);s.DEFAULT_HEADERS={"X-Client-Info":`postgrest-js/${r.version}`}},873436,(e,t,s)=>{"use strict";var r=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0});let i=r(e.r(828159)),a=r(e.r(816803)),n=e.r(201236);class o{constructor(e,{headers:t={},schema:s,fetch:r}={}){this.url=e,this.headers=Object.assign(Object.assign({},n.DEFAULT_HEADERS),t),this.schemaName=s,this.fetch=r}from(e){let t=new URL(`${this.url}/${e}`);return new i.default(t,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new o(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:s=!1,get:r=!1,count:i}={}){let n,o,l=new URL(`${this.url}/rpc/${e}`);s||r?(n=s?"HEAD":"GET",Object.entries(t).filter(([e,t])=>void 0!==t).map(([e,t])=>[e,Array.isArray(t)?`{${t.join(",")}}`:`${t}`]).forEach(([e,t])=>{l.searchParams.append(e,t)})):(n="POST",o=t);let c=Object.assign({},this.headers);return i&&(c.Prefer=`count=${i}`),new a.default({method:n,url:l,headers:c,schema:this.schemaName,body:o,fetch:this.fetch,allowEmpty:!1})}}s.default=o}
2,482820,(e,t,s)=>{"use strict";var r=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0}),s.PostgrestError=s.PostgrestBuilder=s.PostgrestTransformBuilder=s.PostgrestFilterBuilder=s.PostgrestQueryBuilder=s.PostgrestClient=void 0;let i=r(e.r(873436));s.PostgrestClient=i.default;let a=r(e.r(828159));s.PostgrestQueryBuilder=a.default;let n=r(e.r(816803));s.PostgrestFilterBuilder=n.default;let o=r(e.r(753243));s.PostgrestTransformBuilder=o.default;let l=r(e.r(6150));s.PostgrestBuilder=l.default;let c=r(e.r(460587));s.PostgrestError=c.default,s.default={PostgrestClient:i.default,PostgrestQueryBuilder:a.default,PostgrestFilterBuilder:n.default,PostgrestTransformBuilder:o.default,PostgrestBuilder:l.default,PostgrestError:c.default}},502627,(e,t,s)=>{"use strict";s.parse=function(e,t){if("string"!=typeof e)throw TypeError("argument str must be a string");for(var s={},r=(t||{}).decode||a,i=0;i<e.length;){var n=e.indexOf("=",i);if(-1===n)break;var o=e.indexOf(";",i);if(-1===o)o=e.length;else if(o<n){i=e.lastIndexOf(";",n-1)+1;continue}var l=e.slice(i,n).trim();if(void 0===s[l]){var c=e.slice(n+1,o).trim();34===c.charCodeAt(0)&&(c=c.slice(1,-1)),s[l]=function(e,t){try{return t(e)}catch(t){return e}}(c,r)}i=o+1}return s},s.serialize=function(e,t,s){var a=s||{},o=a.encode||n;if("function"!=typeof o)throw TypeError("option encode is invalid");if(!i.test(e))throw TypeError("argument name is invalid");var l=o(t);if(l&&!i.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(!i.test(a.domain))throw TypeError("option domain is invalid");c+="; Domain="+a.domain}if(a.path){if(!i.test(a.path))throw TypeError("option path is invalid");c+="; Path="+a.path}if(a.expires){var u,d=a.expires;if(u=d,"[object Date]"!==r.call(u)&&!(u instanceof Date)||isNaN(d.valueOf()))throw TypeError("option expires is invali
2d");c+="; Expires="+d.toUTCString()}if(a.httpOnly&&(c+="; HttpOnly"),a.secure&&(c+="; Secure"),a.partitioned&&(c+="; Partitioned"),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;default: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 r=Object.prototype.toString,i=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function a(e){return -1!==e.indexOf("%")?decodeURIComponent(e):e}function n(e){return encodeURIComponent(e)}},480874,(e,t,s)=>{},129014,e=>{"use strict";let t;var s,r,i,a,n,o,l,c,h,u,d,f,p,g,m,b,w,v,y,x,_,j=e.i(368058),k=e.i(975157),S=e.i(755600),N=e.i(621157),T=e.i(201234),E=e.i(317487),C=e.i(526214),A=e.i(664186),A=A,P=e.i(902806),O=e.i(937599),O=O,I=e.i(286470),$=e.i(797586),$=$,R=e.i(417417),U=e.i(959957),U=U,D=e.i(456647),L=e.i(660249),M=e.i(164430),B=e.i(476547),q=e.i(1491),q=q,F=e.i(355995),z=e.i(501371),K=e.i(768219),K=K,J=e.i(519455),H=e.i(617029),W=e.i(337822);e.i(63994);class V extends Error{constructor(e,t="FunctionsError",s){super(e),this.name=t,this.context=s}}class G extends V{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class Y extends V{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class X extends V{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}(s=d||(d={})).Any="any",s.ApNortheast1="ap-northeast-1",s.ApNortheast2="ap-northeast-2",s.ApSouth1="ap-south-1",s.ApSoutheast1="ap-southeast-1",s.ApSoutheast2="ap-southeast-2",s.CaCentral1="ca-central-1",s.EuCentral1="eu-central-1",s.EuWest1="eu-west-1",s.EuWest2="eu-west-2",s.EuWest3="eu-west-3",s.SaEast1="sa-east-1",s.UsEast1="us-east-1",s.UsWest1="us-west-1",s.UsWest2="us-west-2";class Z{constructor(t,{headers:s={},customFetch:r,region:i=d.Any}={}){this.url=t,this.headers=s,this.region=i,this.fetch=(t=>{let s;return s=t||("u"<typeof fetch?(...t)=>e.A(840267).then(({default:e})=>e(...t)):fetch),(...e)=>s(...e)})(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,t={}){var s,r,i,a,n;return r=this,i=void 0,a=void 0,n=function*(){try{let r,{headers:i,method:a,body:n}=t,o={},{region:l}=t;l||(l=this.region);let c=new URL(`${this.url}/${e}`);l&&"any"!==l&&(o["x-region"]=l,c.searchParams.set("forceFunctionRegion",l)),n&&(i&&!Object.prototype.hasOwnProperty.call(i,"Content-Type")||!i)&&("u">typeof Blob&&n instanceof Blob||n instanceof ArrayBuffer?(o["Content-Type"]="application/octet-stream",r=n):"string"==typeof n?(o["Content-Type"]="text/plain",r=n):"u">typeof FormData&&n instanceof FormData?r=n:(o["Content-Type"]="application/json",r=JSON.stringify(n)));let h=yield this.fetch(c.toString(),{method:a||"POST",headers:Object.assign(Object.assign(Object.assign({},o),this.headers),i),body:r}).catch(e=>{throw new G(e)}),u=h.headers.get("x-relay-error");if(u&&"true"===u)throw new Y(h);if(!h.ok)throw new X(h);let d=(null!=(s=h.headers.get("Content-Type"))?s:"text/plain").split(";")[0].trim();return{data:"application/json"===d?yield h.json():"application/octet-stream"===d?yield h.blob():"text/event-stream"===d?h:"multipart/form-data"===d?yield h.formData():yield h.text(),error:null,response:h}}catch(e){return{data:null,error:e,response:e instanceof X||e instanceof Y?e.context:void 0}}},new(a||(a=Promise))(function(e,t){function s(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 a?r:new a(function(e){e(r)})).then(s,o)}l((n=n.apply(r,i||[])).next())})}}let{PostgrestClient:Q,PostgrestQueryBuilder:ee,PostgrestFilterBuilder:et,PostgrestTransformBuilder:es,PostgrestBuilder:er,PostgrestError:ei}=e.i(482820).default,ea=function(){if("u">typeof WebSocket)return WebSocket;if(void 0!==e.g.WebSocket)return e.g.WebSocket;if(void 0!==window.WebSocket)return window.WebSocket;if(void 0!==self.WebSocket)return self.WebSocket;throw Error("`WebSocket` is not supported in this environment")}();(r=f||(f={}))[r.connecting=0]="connecting",r[r.open=1]="open",r[r.closing=2]="closing",r[r.closed=3]="closed",(i=p||(p={})).closed="closed",i.errored="errored",i.joined="joined",i.joining="joining",i.leaving="leaving",(a=g||(g={})).close="phx_close",a.error="phx_error",a.join="phx_join",a.reply="phx_reply",a.leave="phx_leave",a.access_token="access_token",(m||(m={})).websocket="websocket",(n=b||(b={})).Connecting="connecting",n.Open="open",n.Closing="closing",n.Closed="closed";class en{constructor(){this.HEADER_LENGTH=1}decode(e,t){return e.constructor===ArrayBuffer?t(this._binaryDecode(e)):"string"==typeof e?t(JSON.parse(e)):t({})}
2_binaryDecode(e){let t=new DataView(e),s=new TextDecoder;return this._decodeBroadcast(e,t,s)}_decodeBroadcast(e,t,s){let r=t.getUint8(1),i=t.getUint8(2),a=this.HEADER_LENGTH+2,n=s.decode(e.slice(a,a+r));a+=r;let o=s.decode(e.slice(a,a+i));return a+=i,{ref:null,topic:n,event:o,payload:JSON.parse(s.decode(e.slice(a,e.byteLength)))}}}class eo{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))}}(o=w||(w={})).abstime="abstime",o.bool="bool",o.date="date",o.daterange="daterange",o.float4="float4",o.float8="float8",o.int2="int2",o.int4="int4",o.int4range="int4range",o.int8="int8",o.int8range="int8range",o.json="json",o.jsonb="jsonb",o.money="money",o.numeric="numeric",o.oid="oid",o.reltime="reltime",o.text="text",o.time="time",o.timestamp="timestamp",o.timestamptz="timestamptz",o.timetz="timetz",o.tsrange="tsrange",o.tstzrange="tstzrange";let el=(e,t,s={})=>{var r;let i=null!=(r=s.skipTypes)?r:[];return Object.keys(t).reduce((s,r)=>(s[r]=ec(r,e,t,i),s),{})},ec=(e,t,s,r)=>{let i=t.find(t=>t.name===e),a=null==i?void 0:i.type,n=s[e];return a&&!r.includes(a)?eh(a,n):eu(n)},eh=(e,t)=>{if("_"===e.charAt(0))return eg(t,e.slice(1,e.length));switch(e){case w.bool:return ed(t);case w.float4:case w.float8:case w.int2:case w.int4:case w.int8:case w.numeric:case w.oid:return ef(t);case w.json:case w.jsonb:return ep(t);case w.timestamp:return em(t);case w.abstime:case w.date:case w.daterange:case w.int4range:case w.int8range:case w.money:case w.reltime:case w.text:case w.time:case w.timestamptz:case w.timetz:case w.tsrange:case w.tstzrange:default:return eu(t)}},eu=e=>e,ed=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},ef=e=>{if("string"==typeof e){let t=parseFloat(e);if(!Number.isNaN(t))return t}return e},ep=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){console.log(`JSON parse error: ${e}`)}return e},eg=(e,t)=>{if("string"!=typeof e)return e;let s=e.length-1,r=e[s];if("{"===e[0]&&"}"===r){let r,i=e.slice(1,s);try{r=JSON.parse("["+i+"]")}catch(e){r=i?i.split(","):[]}return r.map(e=>eh(t,e))}return e},em=e=>"string"==typeof e?e.replace(" ","T"):e,eb=e=>{let t=e;return(t=(t=t.replace(/^ws/i,"http")).replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,"")).replace(/\/+$/,"")};class ew{constructor(e,t,s={},r=1e4){this.channel=e,this.event=t,this.payload=s,this.timeout=r,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,t){var s;return this._hasReceived(e)&&t(null==(s=this.receivedResp)?void 0:s.response),this.recHooks.push({status:e,callback:t}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);let e=e=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=e,this._matchReceive(e)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,t){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:t})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:t}){this.recHooks.filter(t=>t.status===e).forEach(e=>e.callback(t))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}(l=v||(v={})).SYNC="sync",l.JOIN="join",l.LEAVE="leave";class ev{constructor(e,t){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const s=(null==t?void 0:t.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(s.state,{},e=>{let{onJoin:t,onLeave:s,onSync:r}=this.caller;this.joinRef=this.channel._joinRef(),this.state=ev.syncState(this.state,e,t,s),this.pendingDiffs.forEac
2h(e=>{this.state=ev.syncDiff(this.state,e,t,s)}),this.pendingDiffs=[],r()}),this.channel._on(s.diff,{},e=>{let{onJoin:t,onLeave:s,onSync:r}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(e):(this.state=ev.syncDiff(this.state,e,t,s),r())}),this.onJoin((e,t,s)=>{this.channel._trigger("presence",{event:"join",key:e,currentPresences:t,newPresences:s})}),this.onLeave((e,t,s)=>{this.channel._trigger("presence",{event:"leave",key:e,currentPresences:t,leftPresences:s})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,t,s,r){let i=this.cloneDeep(e),a=this.transformState(t),n={},o={};return this.map(i,(e,t)=>{a[e]||(o[e]=t)}),this.map(a,(e,t)=>{let s=i[e];if(s){let r=t.map(e=>e.presence_ref),i=s.map(e=>e.presence_ref),a=t.filter(e=>0>i.indexOf(e.presence_ref)),l=s.filter(e=>0>r.indexOf(e.presence_ref));a.length>0&&(n[e]=a),l.length>0&&(o[e]=l)}else n[e]=t}),this.syncDiff(i,{joins:n,leaves:o},s,r)}static syncDiff(e,t,s,r){let{joins:i,leaves:a}={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)};return s||(s=()=>{}),r||(r=()=>{}),this.map(i,(t,r)=>{var i;let a=null!=(i=e[t])?i:[];if(e[t]=this.cloneDeep(r),a.length>0){let s=e[t].map(e=>e.presence_ref),r=a.filter(e=>0>s.indexOf(e.presence_ref));e[t].unshift(...r)}s(t,a,r)}),this.map(a,(t,s)=>{let i=e[t];if(!i)return;let a=s.map(e=>e.presence_ref);i=i.filter(e=>0>a.indexOf(e.presence_ref)),e[t]=i,r(t,i,s),0===i.length&&delete e[t]}),e}static map(e,t){return Object.getOwnPropertyNames(e).map(s=>t(s,e[s]))}static transformState(e){return Object.getOwnPropertyNames(e=this.cloneDeep(e)).reduce((t,s)=>{let r=e[s];return"metas"in r?t[s]=r.metas.map(e=>(e.presence_ref=e.phx_ref,delete e.phx_ref,delete e.phx_ref_prev,e)):t[s]=r,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()}}(c=y||(y={})).ALL="*",c.INSERT="INSERT",c.UPDATE="UPDATE",c.DELETE="DELETE",(h=x||(x={})).BROADCAST="broadcast",h.PRESENCE="presence",h.POSTGRES_CHANGES="postgres_changes",h.SYSTEM="system",(u=_||(_={})).SUBSCRIBED="SUBSCRIBED",u.TIMED_OUT="TIMED_OUT",u.CLOSED="CLOSED",u.CHANNEL_ERROR="CHANNEL_ERROR";class ey{constructor(e,t={config:{}},s){this.topic=e,this.params=t,this.socket=s,this.bindings={},this.state=p.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""},private:!1},t.config),this.timeout=this.socket.timeout,this.joinPush=new ew(this,g.join,this.params,this.timeout),this.rejoinTimer=new eo(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=p.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=p.closed,this.socket._remove(this)}),this._onError(e=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,e),this.state=p.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=p.errored,this.rejoinTimer.scheduleTimeout())}),this._on(g.reply,{},(e,t)=>{this._trigger(this._replyEventName(t),e)}),this.presence=new ev(this),this.broadcastEndpointURL=eb(this.socket.endPoint)+"/api/broadcast",this.private=this.params.config.private||!1}subscribe(e,t=this.timeout){var s,r;if(this.socket.isConnected()||this.socket.connect(),this.state==p.closed){let{config:{broadcast:i,presence:a,private:n}}=this.params;this._onError(t=>null==e?void 0:e(_.CHANNEL_ERROR,t)),this._onClose(()=>null==e?void 0:e(_.CLOSED));let o={},l={broadcast:i,presence:a,postgres_changes:null!=(r=null==(s=this.bindings.postgres_changes)?void 0:s.map(e=>e.filter))?r:[],private:n};this.socket.accessTokenValue&&(o.access_token=this.socket.accessTokenValue),this.updateJoinPayload(Object.assign({config:l},o)),this.joinedOnce=!0,this._rejoin(t),this.joinPush.receive("ok",async({postgres_changes:t})=>{var s;if(this.socket.setAuth(),void 0===t){null==e||e(_.SUBSCRIBED);return}{let r=this.bindings.postgres_changes,i=null!=(s=null==r?void 0:r.length)?s:0,a=[];for(let s=0;s<i;s++){let i=r[s],{filter:{event:n,schema:o,table:l,filter:c}}=i,h=t&&t[s];if(h&&h.event===n&&h.schema===o&&h.table===l&&h.filter===c)a.push(Object.assign(Object.assign({},i),{id:h.id}));else{this.unsubscribe(),this.state=p.errored,null==e||e(_.CHANNEL_ERROR,Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=a,e&&e(_.SUBSCRIBED);return}}).receive("error",t=>{this.state=p.errored,null==e||e(_.CHANNEL_ERROR,Error(JSON.stringify(Object.values(t).join(", ")||"error")))}).receive("timeout",()=>{null==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,s){return this._on(e,t,s)}async send(e,t={}){var s,r;if(this._canPush()||"broadcast"!==e.type)return new Promise(s=>{var r,i,a;let n=this._push(e.type,e,t.timeout||this.timeout);"broadcast"!==e.type||(null==(a=null==(i=null==(r=this.params)?void 0:r.config)?void 0:i.broadcast)?void 0:a.ack)||s("ok"),n.receive("ok",()=>s("ok")),n.receive("error",()=>s("error")),n.receive("timeout",()=>s("timed out"))});{let{event:i,payload:a}=e,n={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:a,private:this.private}]})};try{let e=await this._fetchWithTimeout(this.broadcastEndpointURL,n,null!=(s=t.timeout)?s:this.timeout);return await (null==(r=e.body)?void 0:r.cancel()),e.ok?"ok":"error"}catch(e){if("AbortError"===e.name)return"timed out";return"error"}}}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=p.leaving;let t=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(g.close,"leave",this._joinRef())};this.joinPush.destroy();let s=null;return new Promise(r=>{(s=new ew(this,g.leave,{},e)).receive("ok",()=>{t(),r("ok")}).receive("timeout",()=>{t(),r("timed out")}).receive("error",()=>{r("error")}),s.send(),this._canPush()||s.trigger("ok",{})}).finally(()=>{null==s||s.destroy()})}
2teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.rejoinTimer&&clearTimeout(this.rejoinTimer.timer),this.joinPush.destroy()}async _fetchWithTimeout(e,t,s){let r=new AbortController,i=setTimeout(()=>r.abort(),s),a=await this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:r.signal}));return clearTimeout(i),a}_push(e,t,s=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let r=new ew(this,e,t,s);return this._canPush()?r.send():(r.startTimeout(),this.pushBuffer.push(r)),r}_onMessage(e,t,s){return t}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,t,s){var r,i;let a=e.toLocaleLowerCase(),{close:n,error:o,leave:l,join:c}=g;if(s&&[n,o,l,c].indexOf(a)>=0&&s!==this._joinRef())return;let h=this._onMessage(a,t,s);if(t&&!h)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(a)?null==(r=this.bindings.postgres_changes)||r.filter(e=>{var t,s,r;return(null==(t=e.filter)?void 0:t.event)==="*"||(null==(r=null==(s=e.filter)?void 0:s.event)?void 0:r.toLocaleLowerCase())===a}).map(e=>e.callback(h,s)):null==(i=this.bindings[a])||i.filter(e=>{var s,r,i,n,o,l;if(!["broadcast","presence","postgres_changes"].includes(a))return e.type.toLocaleLowerCase()===a;if("id"in e){let a=e.id,n=null==(s=e.filter)?void 0:s.event;return a&&(null==(r=t.ids)?void 0:r.includes(a))&&("*"===n||(null==n?void 0:n.toLocaleLowerCase())===(null==(i=t.data)?void 0:i.type.toLocaleLowerCase()))}{let s=null==(o=null==(n=null==e?void 0:e.filter)?void 0:n.event)?void 0:o.toLocaleLowerCase();return"*"===s||s===(null==(l=null==t?void 0:t.event)?void 0:l.toLocaleLowerCase())}}).map(e=>{if("object"==typeof h&&"ids"in h){let e=h.data,{schema:t,table:s,commit_timestamp:r,type:i,errors:a}=e;h=Object.assign(Object.assign({},{schema:t,table:s,commit_timestamp:r,eventType:i,new:{},old:{},errors:a}),this._getPayloadRecords(e))}e.callback(h,s)})}_isClosed(){return this.state===p.closed}_isJoined(){return this.state===p.joined}_isJoining(){return this.state===p.joining}_isLeaving(){return this.state===p.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,t,s){let r=e.toLocaleLowerCase(),i={type:r,filter:t,callback:s};return this.bindings[r]?this.bindings[r].push(i):this.bindings[r]=[i],this}_off(e,t){let s=e.toLocaleLowerCase();return this.bindings[s]=this.bindings[s].filter(e=>{var r;return!((null==(r=e.type)?void 0:r.toLocaleLowerCase())===s&&ey.isEqual(e.filter,t))}),this}static isEqual(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let s in e)if(e[s]!==t[s])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(g.close,{},e)}_onError(e){this._on(g.error,{},t=>e(t))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=p.joining,this.joinPush.resend(e))}_getPayloadRecords(e){let t={new:{},old:{}};return("INSERT"===e.type||"UPDATE"===e.type)&&(t.new=el(e.columns,e.record)),("UPDATE"===e.type||"DELETE"===e.type)&&(t.old=el(e.columns,e.old_record)),t}}let ex=()=>{},e_=` 3 addEventListener("message", (e) => { 4 if (e.data.event === "start") { 5 setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); 6 } 7 });`;class ej{constructor(t,s){var r;this.accessTokenValue=null,this.apiKey=null,this.channels=[],this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=1e4,this.heartbeatIntervalMs=25e3,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=ex,this.ref=0,this.logger=ex,this.conn=null,this.sendBuffer=[],this.serializer=new en,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._resolveFetch=t=>{let s;return s=t||("u"<typeof fetch?(...t)=>e.A(840267).then(({default:e})=>e(...t)):fetch),(...e)=>s(...e)},this.endPoint=`${t}/${m.websocket}`,this.httpEndpoint=eb(t),(null==s?void 0:s.transport)?this.transport=s.transport:this.transport=null,(null==s?void 0:s.params)&&(this.params=s.params),(null==s?void 0:s.timeout)&&(this.timeout=s.timeout),(null==s?void 0:s.logger)&&(this.logger=s.logger),((null==s?void 0:s.logLevel)||(null==s?void 0:s.log_level))&&(this.logLevel=s.logLevel||s.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),(null==s?void 0:s.heartbeatIntervalMs)&&(this.heartbeatIntervalMs=s.heartbeatIntervalMs);const i=null==(r=null==s?void 0:s.params)?void 0:r.apikey;if(i&&(this.accessTokenValue=i,this.apiKey=i),this.reconnectAfterMs=(null==s?void 0:s.reconnectAfterMs)?s.reconnectAfterMs:e=>[1e3,2e3,5e3,1e4][e-1]||1e4,this.encode=(null==s?void 0:s.encode)?s.encode:(e,t)=>t(JSON.stringify(e)),this.decode=(null==s?void 0:s.decode)?s.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new eo(async()=>{this.disconnect(),this.connect()},this.reconnectAfterMs),this.fetch=this._resolveFetch(null==s?void 0:s.fetch),null==s?void 0:s.worker){if("u">typeof window&&!window.Worker)throw Error("Web Worker is not supported");this.worker=(null==s?void 0:s.worker)||!1,this.workerUrl=null==s?void 0:s.workerUrl}this.accessToken=(null==s?void 0:s.accessToken)||null}connect(){if(!this.conn){if(this.transport||(this.transport=ea),!this.transport)throw Error("No transport provided");this.conn=new this.transport(this.endpointURL()),this.setupConnection()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:"1.0.0"}))}
7disconnect(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(),this.channels.forEach(e=>e.teardown()))}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.channels=[],this.disconnect(),e}log(e,t,s){this.logger(e,t,s)}connectionState(){switch(this.conn&&this.conn.readyState){case f.connecting:return b.Connecting;case f.open:return b.Open;case f.closing:return b.Closing;default:return b.Closed}}isConnected(){return this.connectionState()===b.Open}channel(e,t={config:{}}){let s=`realtime:${e}`,r=this.getChannels().find(e=>e.topic===s);if(r)return r;{let s=new ey(`realtime:${e}`,t,this);return this.channels.push(s),s}}push(e){let{topic:t,event:s,payload:r,ref:i}=e,a=()=>{this.encode(e,e=>{var t;null==(t=this.conn)||t.send(e)})};this.log("push",`${t} ${s} (${i})`,r),this.isConnected()?a():this.sendBuffer.push(a)}async setAuth(e=null){let t=e||this.accessToken&&await this.accessToken()||this.accessTokenValue;this.accessTokenValue!=t&&(this.accessTokenValue=t,this.channels.forEach(e=>{t&&e.updateJoinPayload({access_token:t,version:"realtime-js/2.11.15"}),e.joinedOnce&&e._isJoined()&&e._push(g.access_token,{access_token:t})}))}async sendHeartbeat(){var e;if(!this.isConnected())return void this.heartbeatCallback("disconnected");if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),this.heartbeatCallback("timeout"),null==(e=this.conn)||e.close(1e3,"hearbeat timeout");return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatCallback("sent"),await this.setAuth()}onHeartbeat(e){this.heartbeatCallback=e}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let 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.topic!==e.topic)}setupConnection(){this.conn&&(this.conn.binaryType="arraybuffer",this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e))}_onConnMessage(e){this.decode(e.data,e=>{let{topic:t,event:s,payload:r,ref:i}=e;"phoenix"===t&&"phx_reply"===s&&this.heartbeatCallback("ok"==e.payload.status?"ok":"error"),i&&i===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null),this.log("receive",`${r.status||""} ${t} ${s} ${i&&"("+i+")"||""}`,r),Array.from(this.channels).filter(e=>e._isMember(t)).forEach(e=>e._trigger(s,r,i)),this.stateChangeCallbacks.message.forEach(t=>t(e))})}_onConnOpen(){this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this.reconnectTimer.reset(),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this.stateChangeCallbacks.open.forEach(e=>e())}_startHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");let e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=e=>{this.log("worker","worker error",e.message),this.workerRef.terminate()},this.workerRef.onmessage=e=>{"keepAlive"===e.data.event&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_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}`),this._triggerChanError(),this.stateChangeCallbacks.error.forEach(t=>t(e))}
7_triggerChanError(){this.channels.forEach(e=>e._trigger(g.error))}_appendParams(e,t){if(0===Object.keys(t).length)return e;let s=e.match(/\?/)?"&":"?",r=new URLSearchParams(t);return`${e}${s}${r}`}_workerObjectUrl(e){let t;if(e)t=e;else{let e=new Blob([e_],{type:"application/javascript"});t=URL.createObjectURL(e)}return t}}var ek=e.i(29591);class eS extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function eN(e){return"object"==typeof e&&null!==e&&"__isStorageError"in e}class eT extends eS{constructor(e,t){super(e),this.name="StorageApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class eE extends eS{constructor(e,t){super(e),this.name="StorageUnknownError",this.originalError=t}}let eC=t=>{let s;return s=t||("u"<typeof fetch?(...t)=>e.A(840267).then(({default:e})=>e(...t)):fetch),(...e)=>s(...e)},eA=e=>{if(Array.isArray(e))return e.map(e=>eA(e));if("function"==typeof e||e!==Object(e))return e;let t={};return Object.entries(e).forEach(([e,s])=>{t[e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(/[-_]/g,""))]=eA(s)}),t};var eP=function(e,t,s,r){return new(s||(s=Promise))(function(i,a){function n(e){try{l(r.next(e))}catch(e){a(e)}}function o(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(n,o)}l((r=r.apply(e,t||[])).next())})};let eO=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e);function eI(t,s,r,i,a,n){return eP(this,void 0,void 0,function*(){return new Promise((o,l)=>{let c;t(r,(c={method:s,headers:(null==i?void 0:i.headers)||{}},"GET"===s?c:(c.headers=Object.assign({"Content-Type":"application/json"},null==i?void 0:i.headers),n&&(c.body=JSON.stringify(n)),Object.assign(Object.assign({},c),a)))).then(e=>{if(!e.ok)throw e;return(null==i?void 0:i.noResolveJson)?e:e.json()}).then(e=>o(e)).catch(t=>eP(void 0,void 0,void 0,function*(){var s,r,a,n;let o=yield(s=void 0,r=void 0,a=void 0,n=function*(){return"u"<typeof Response?(yield e.A(840267)).Response:Response},new(a||(a=Promise))(function(e,t){function i(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 s;t.done?e(t.value):((s=t.value)instanceof a?s:new a(function(e){e(s)})).then(i,o)}l((n=n.apply(s,r||[])).next())}));t instanceof o&&!(null==i?void 0:i.noResolveJson)?t.json().then(e=>{l(new eT(eO(e),t.status||500))}).catch(e=>{l(new eE(eO(e),e))}):l(new eE(eO(t),t))}))})})}function e$(e,t,s,r){return eP(this,void 0,void 0,function*(){return eI(e,"GET",t,s,r)})}function eR(e,t,s,r,i){return eP(this,void 0,void 0,function*(){return eI(e,"POST",t,r,i,s)})}function eU(e,t,s,r,i){return eP(this,void 0,void 0,function*(){return eI(e,"DELETE",t,r,i,s)})}var eD=function(e,t,s,r){return new(s||(s=Promise))(function(i,a){function n(e){try{l(r.next(e))}catch(e){a(e)}}function o(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(n,o)}l((r=r.apply(e,t||[])).next())})};let eL={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},eM={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class eB{constructor(e,t={},s,r){this.url=e,this.headers=t,this.bucketId=s,this.fetch=eC(r)}uploadOrUpdate(e,t,s,r){return eD(this,void 0,void 0,function*(){try{let i,a=Object.assign(Object.assign({},eM),r),n=Object.assign(Object.assign({},this.headers),"POST"===e&&{"x-upsert":String(a.upsert)}),o=a.metadata;"u">typeof Blob&&s instanceof Blob?((i=new FormData).append("cacheControl",a.cacheControl),o&&i.append("metadata",this.encodeMetadata(o)),i.append("",s)):"u">typeof FormData&&s instanceof FormData?((i=s).append("cacheControl",a.cacheControl),o&&i.append("metadata",this.encodeMetadata(o))):(i=s,n["cache-control"]=`max-age=${a.cacheControl}`,n["content-type"]=a.contentType,o&&(n["x-metadata"]=this.toBase64(this.encodeMetadata(o)))),(null==r?void 0:r.headers)&&(n=Object.assign(Object.assign({},n),r.headers));let l=this._removeEmptyFolders(t),c=this._getFinalPath(l),h=yield this.fetch(`${this.url}/object/${c}`,Object.assign({method:e,body:i,headers:n},(null==a?void 0:a.duplex)?{duplex:a.duplex}:{})),u=yield h.json();if(h.ok)return{data:{path:l,id:u.Id,fullPath:u.Key},error:null};return{data:null,error:u}}catch(e){if(eN(e))return{data:null,error:e};throw e}})}upload(e,t,s){return eD(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,t,s)})}uploadToSignedUrl(e,t,s,r){return eD(this,void 0,void 0,function*(){let i=this._removeEmptyFolders(e),a=this._getFinalPath(i),n=new URL(this.url+`/object/upload/sign/${a}`);n.searchParams.set("token",t);try{let e,t=Object.assign({upsert:eM.upsert},r),a=Object.assign(Object.assign({},this.headers),{"x-upsert":String(t.upsert)});"u">typeof Blob&&s instanceof Blob?((e=new FormData).append("cacheControl",t.cacheControl),e.append("",s)):"u">typeof FormData&&s instanceof FormData?(e=s).append("cacheControl",t.cacheControl):(e=s,a["cache-control"]=`max-age=${t.cacheControl}`,a["content-type"]=t.contentType);let o=yield this.fetch(n.toString(),{method:"PUT",body:e,headers:a}),l=yield o.json();if(o.ok)return{data:{path:i,fullPath:l.Key},error:null};return{data:null,error:l}}catch(e){if(eN(e))return{data:null,error:e};throw e}})}createSignedUploadUrl(e,t){return eD(this,void 0,void 0,function*(){try{let s=this._getFinalPath(e),r=Object.assign({},this.headers);(null==t?void 0:t.upsert)&&(r["x-upsert"]="true");let i=yield eR(this.fetch,`${this.url}/object/upload/sign/${s}`,{},{headers:r}),a=new URL(this.url+i.url),n=a.searchParams.get("token");if(!n)throw new eS("No token returned by API");return{data:{signedUrl:a.toString(),path:e,token:n},error:null}}catch(e){if(eN(e))return{data:null,error:e};throw e}})}
7update(e,t,s){return eD(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,t,s)})}move(e,t,s){return eD(this,void 0,void 0,function*(){try{return{data:yield eR(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,destinationBucket:null==s?void 0:s.destinationBucket},{headers:this.headers}),error:null}}catch(e){if(eN(e))return{data:null,error:e};throw e}})}copy(e,t,s){return eD(this,void 0,void 0,function*(){try{return{data:{path:(yield eR(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,destinationBucket:null==s?void 0:s.destinationBucket},{headers:this.headers})).Key},error:null}}catch(e){if(eN(e))return{data:null,error:e};throw e}})}createSignedUrl(e,t,s){return eD(this,void 0,void 0,function*(){try{let r=this._getFinalPath(e),i=yield eR(this.fetch,`${this.url}/object/sign/${r}`,Object.assign({expiresIn:t},(null==s?void 0:s.transform)?{transform:s.transform}:{}),{headers:this.headers}),a=(null==s?void 0:s.download)?`&download=${!0===s.download?"":s.download}`:"";return{data:i={signedUrl:encodeURI(`${this.url}${i.signedURL}${a}`)},error:null}}catch(e){if(eN(e))return{data:null,error:e};throw e}})}createSignedUrls(e,t,s){return eD(this,void 0,void 0,function*(){try{let r=yield eR(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:t,paths:e},{headers:this.headers}),i=(null==s?void 0:s.download)?`&download=${!0===s.download?"":s.download}`:"";return{data:r.map(e=>Object.assign(Object.assign({},e),{signedUrl:e.signedURL?encodeURI(`${this.url}${e.signedURL}${i}`):null})),error:null}}catch(e){if(eN(e))return{data:null,error:e};throw e}})}download(e,t){return eD(this,void 0,void 0,function*(){let s=void 0!==(null==t?void 0:t.transform),r=this.transformOptsToQueryString((null==t?void 0:t.transform)||{}),i=r?`?${r}`:"";try{let t=this._getFinalPath(e),r=yield e$(this.fetch,`${this.url}/${s?"render/image/authenticated":"object"}/${t}${i}`,{headers:this.headers,noResolveJson:!0});return{data:yield r.blob(),error:null}}catch(e){if(eN(e))return{data:null,error:e};throw e}})}info(e){return eD(this,void 0,void 0,function*(){let t=this._getFinalPath(e);try{let e=yield e$(this.fetch,`${this.url}/object/info/${t}`,{headers:this.headers});return{data:eA(e),error:null}}catch(e){if(eN(e))return{data:null,error:e};throw e}})}exists(e){return eD(this,void 0,void 0,function*(){let t=this._getFinalPath(e);try{return yield function(e,t,s,r){return eP(this,void 0,void 0,function*(){return eI(e,"HEAD",t,Object.assign(Object.assign({},s),{noResolveJson:!0}),void 0)})}(this.fetch,`${this.url}/object/${t}`,{headers:this.headers}),{data:!0,error:null}}catch(e){if(eN(e)&&e instanceof eE){let t=e.originalError;if([400,404].includes(null==t?void 0:t.status))return{data:!1,error:e}}throw e}})}getPublicUrl(e,t){let s=this._getFinalPath(e),r=[],i=(null==t?void 0:t.download)?`download=${!0===t.download?"":t.download}`:"";""!==i&&r.push(i);let a=void 0!==(null==t?void 0:t.transform),n=this.transformOptsToQueryString((null==t?void 0:t.transform)||{});""!==n&&r.push(n);let o=r.join("&");return""!==o&&(o=`?${o}`),{data:{publicUrl:encodeURI(`${this.url}/${a?"render/image":"object"}/public/${s}${o}`)}}}remove(e){return eD(this,void 0,void 0,function*(){try{return{data:yield eU(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(e){if(eN(e))return{data:null,error:e};throw e}})}list(e,t,s){return eD(this,void 0,void 0,function*(){try{let r=Object.assign(Object.assign(Object.assign({},eL),t),{prefix:e||""});return{data:yield eR(this.fetch,`${this.url}/object/list/${this.bucketId}`,r,{headers:this.headers},s),error:null}}catch(e){if(eN(e))return{data:null,error:e};throw e}})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return void 0!==ek.Buffer?ek.Buffer.from(e).toString("base64"):btoa(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 eq={"X-Client-Info":"storage-js/2.7.1"};
7var eF=function(e,t,s,r){return new(s||(s=Promise))(function(i,a){function n(e){try{l(r.next(e))}catch(e){a(e)}}function o(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(n,o)}l((r=r.apply(e,t||[])).next())})};class ez{constructor(e,t={},s){this.url=e,this.headers=Object.assign(Object.assign({},eq),t),this.fetch=eC(s)}listBuckets(){return eF(this,void 0,void 0,function*(){try{return{data:yield e$(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(eN(e))return{data:null,error:e};throw e}})}getBucket(e){return eF(this,void 0,void 0,function*(){try{return{data:yield e$(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(e){if(eN(e))return{data:null,error:e};throw e}})}createBucket(e,t={public:!1}){return eF(this,void 0,void 0,function*(){try{return{data:yield eR(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(eN(e))return{data:null,error:e};throw e}})}updateBucket(e,t){return eF(this,void 0,void 0,function*(){try{return{data:yield function(e,t,s,r,i){return eP(this,void 0,void 0,function*(){return eI(e,"PUT",t,r,void 0,s)})}(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(eN(e))return{data:null,error:e};throw e}})}emptyBucket(e){return eF(this,void 0,void 0,function*(){try{return{data:yield eR(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(e){if(eN(e))return{data:null,error:e};throw e}})}deleteBucket(e){return eF(this,void 0,void 0,function*(){try{return{data:yield eU(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(e){if(eN(e))return{data:null,error:e};throw e}})}}class eK extends ez{constructor(e,t={},s){super(e,t,s)}from(e){return new eB(this.url,this.headers,e,this.fetch)}}let eJ="";eJ="u">typeof Deno?"deno":"u">typeof document?"web":"u">typeof navigator&&"ReactNative"===navigator.product?"react-native":"node";let eH={headers:{"X-Client-Info":`supabase-js-${eJ}/2.52.0`}},eW={schema:"public"},eV={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},eG={};var eY=e.i(337692);let eX="2.71.1",eZ={"X-Client-Info":`gotrue-js/${eX}`},eQ="X-Supabase-Api-Version",e0={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},e1=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i;class e2 extends Error{constructor(e,t,s){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t,this.code=s}}function e5(e){return"object"==typeof e&&null!==e&&"__isAuthError"in e}class e4 extends e2{constructor(e,t,s){super(e,t,s),this.name="AuthApiError",this.status=t,this.code=s}}class e3 extends e2{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class e6 extends e2{constructor(e,t,s,r){super(e,s,r),this.name=t,this.status=s}}class e8 extends e6{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}class e9 extends e6{constructor(){super("Auth session or user missing","AuthInvalidToken
7ResponseError",500,void 0)}}class e7 extends e6{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class te extends e6{constructor(e,t=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class tt extends e6{constructor(e,t=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class ts extends e6{constructor(e,t){super(e,"AuthRetryableFetchError",t,void 0)}}function tr(e){return e5(e)&&"AuthRetryableFetchError"===e.name}class ti extends e6{constructor(e,t,s){super(e,"AuthWeakPasswordError",t,"weak_password"),this.reasons=s}}class ta extends e6{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}let tn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),to=" \n\r=".split(""),tl=(()=>{let e=Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<to.length;t+=1)e[to[t].charCodeAt(0)]=-2;for(let t=0;t<tn.length;t+=1)e[tn[t].charCodeAt(0)]=t;return e})();function tc(e,t,s){if(null!==e)for(t.queue=t.queue<<8|e,t.queuedBits+=8;t.queuedBits>=6;)s(tn[t.queue>>t.queuedBits-6&63]),t.queuedBits-=6;else if(t.queuedBits>0)for(t.queue=t.queue<<6-t.queuedBits,t.queuedBits=6;t.queuedBits>=6;)s(tn[t.queue>>t.queuedBits-6&63]),t.queuedBits-=6}function th(e,t,s){let r=tl[e];if(r>-1)for(t.queue=t.queue<<6|r,t.queuedBits+=6;t.queuedBits>=8;)s(t.queue>>t.queuedBits-8&255),t.queuedBits-=8;else if(-2===r)return;else throw Error(`Invalid Base64-URL character "${String.fromCharCode(e)}"`)}function tu(e){let t=[],s=e=>{t.push(String.fromCodePoint(e))},r={utf8seq:0,codepoint:0},i={queue:0,queuedBits:0},a=e=>{!function(e,t,s){if(0===t.utf8seq){if(e<=127)return s(e);for(let s=1;s<6;s+=1)if((e>>7-s&1)==0){t.utf8seq=s;break}if(2===t.utf8seq)t.codepoint=31&e;else if(3===t.utf8seq)t.codepoint=15&e;else if(4===t.utf8seq)t.codepoint=7&e;else throw Error("Invalid UTF-8 sequence");t.utf8seq-=1}else if(t.utf8seq>0){if(e<=127)throw Error("Invalid UTF-8 sequence");t.codepoint=t.codepoint<<6|63&e,t.utf8seq-=1,0===t.utf8seq&&s(t.codepoint)}}(e,r,s)};for(let t=0;t<e.length;t+=1)th(e.charCodeAt(t),i,a);return t.join("")}let td=()=>"u">typeof window&&"u">typeof document,tf={tested:!1,writable:!1},tp=()=>{if(!td())return!1;try{if("object"!=typeof globalThis.localStorage)return!1}catch(e){return!1}if(tf.tested)return tf.writable;let e=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),tf.tested=!0,tf.writable=!0}catch(e){tf.tested=!0,tf.writable=!1}return tf.writable},tg=t=>{let s;return s=t||("u"<typeof fetch?(...t)=>e.A(840267).then(({default:e})=>e(...t)):fetch),(...e)=>s(...e)},tm=async(e,t,s)=>{await e.setItem(t,JSON.stringify(s))},tb=async(e,t)=>{let s=await e.getItem(t);if(!s)return null;try{return JSON.parse(s)}catch(e){return s}},tw=async(e,t)=>{await e.removeItem(t)};class tv{constructor(){this.promise=new tv.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}}function ty(e){let t=e.split(".");if(3!==t.length)throw new ta("Invalid JWT structure");for(let e=0;e<t.length;e++)if(!e1.test(t[e]))throw new ta("JWT not in base64url format");return{header:JSON.parse(tu(t[0])),payload:JSON.parse(tu(t[1])),signature:function(e){let t=[],s={queue:0,queuedBits:0},r=e=>{t.push(e)};for(let t=0;t<e.length;t+=1)th(e.charCodeAt(t),s,r);return new Uint8Array(t)}(t[2]),raw:{header:t[0],payload:t[1]}}}async function tx(e){return await new Promise(t=>{setTimeout(()=>t(null),e)})}function t_(e){return("0"+e.toString(16)).substr(-2)}async function tj(e){let t=new TextEncoder().encode(e);return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",t))).map(e=>String.fromCharCode(e)).join("")}async function tk(e){return"u">typeof crypto&&void 0!==crypto.subtle&&"u">typeof TextEncoder?btoa(await tj(e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""):(console.warn("WebCrypto API is not supported. Code
7challenge method will default to use plain instead of sha256."),e)}async function tS(e,t,s=!1){let r=function(){let e=new Uint32Array(56);if("u"<typeof crypto){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=e.length,s="";for(let r=0;r<56;r++)s+=e.charAt(Math.floor(Math.random()*t));return s}return crypto.getRandomValues(e),Array.from(e,t_).join("")}(),i=r;s&&(i+="/PASSWORD_RECOVERY"),await tm(e,`${t}-code-verifier`,i);let a=await tk(r),n=r===a?"plain":"s256";return[a,n]}tv.promiseConstructor=Promise;let tN=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i,tT=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function tE(e){if(!tT.test(e))throw Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function tC(){return new Proxy({},{get:(e,t)=>{if("__isUserNotAvailableProxy"===t)return!0;if("symbol"==typeof t){let e=t.toString();if("Symbol(Symbol.toPrimitive)"===e||"Symbol(Symbol.toStringTag)"===e||"Symbol(util.inspect.custom)"===e)return}throw Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${t}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,t)=>{throw Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${t}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,t)=>{throw Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${t}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function tA(e){return JSON.parse(JSON.stringify(e))}var tP=function(e,t){var s={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(s[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)0>t.indexOf(r[i])&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(s[r[i]]=e[r[i]]);return s};let tO=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),tI=[502,503,504];async function t$(e){var t;let s,r;if(!("object"==typeof e&&null!==e&&"status"in e&&"ok"in e&&"json"in e&&"function"==typeof e.json))throw new ts(tO(e),0);if(tI.includes(e.status))throw new ts(tO(e),e.status);try{s=await e.json()}catch(e){throw new e3(tO(e),e)}let i=function(e){let t=e.headers.get(eQ);if(!t||!t.match(tN))return null;try{return new Date(`${t}T00:00:00.0Z`)}catch(e){return null}}(e);if(i&&i.getTime()>=e0["2024-01-01"].timestamp&&"object"==typeof s&&s&&"string"==typeof s.code?r=s.code:"object"==typeof s&&s&&"string"==typeof s.error_code&&(r=s.error_code),r){if("weak_password"===r)throw new ti(tO(s),e.status,(null==(t=s.weak_password)?void 0:t.reasons)||[]);else if("session_not_found"===r)throw new e8}else if("object"==typeof s&&s&&"object"==typeof s.weak_password&&s.weak_password&&Array.isArray(s.weak_password.reasons)&&s.weak_password.reasons.length&&s.weak_password.reasons.reduce((e,t)=>e&&"string"==typeof t,!0))throw new ti(tO(s),e.status,s.weak_password.reasons);throw new e4(tO(s),e.status||500,r)}async function tR(e,t,s,r){var i;let a=Object.assign({},null==r?void 0:r.headers);a[eQ]||(a[eQ]=e0["2024-01-01"].name),(null==r?void 0:r.jwt)&&(a.Authorization=`Bearer ${r.jwt}`);let n=null!=(i=null==r?void 0:r.query)?i:{};(null==r?void 0:r.redirectTo)&&(n.redirect_to=r.redirectTo);let o=Object.keys(n).length?"?"+new URLSearchParams(n).toString():"",l=await tU(e,t,s+o,{headers:a,noResolveJson:null==r?void 0:r.noResolveJson},{},null==r?void 0:r.body);return(null==r?void 0:r.xform)?null==r?void 0:r.xform(l):{data:Object.assign({},l),error:null}}async function tU(e,t,s,r,i,a){let n,o,l=(o={method:t,headers:(null==r?void 0:r.headers)||{}},"GET"===t?o:(o.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},null==r?void 0:r.headers),o.body=JSON.stringify(a),Object.assign(Object.assign({},o),i)));try{n=await e(s,Object.assign({},l))}catch(e){throw console.error(e),new ts(tO(e),0)}if(n.ok||await t$(n),null==r?void 0:r.noResolveJson)return n;try{return await n.json()}catch(e){await t$(e)}}function tD(e){var t,s,r;let i=null;(r=e).access_token&&r.refresh_token&&r.expires_in&&(i=Object.assign({},e),e.expires_at||(i.expires_at=(s=e.expires_in,Math.round(Date.now()/1e3)+s))
7);return{data:{session:i,user:null!=(t=e.user)?t:e},error:null}}function tL(e){let t=tD(e);return!t.error&&e.weak_password&&"object"==typeof e.weak_password&&Array.isArray(e.weak_password.reasons)&&e.weak_password.reasons.length&&e.weak_password.message&&"string"==typeof e.weak_password.message&&e.weak_password.reasons.reduce((e,t)=>e&&"string"==typeof t,!0)&&(t.data.weak_password=e.weak_password),t}function tM(e){var t;return{data:{user:null!=(t=e.user)?t:e},error:null}}function tB(e){return{data:e,error:null}}function tq(e){let{action_link:t,email_otp:s,hashed_token:r,redirect_to:i,verification_type:a}=e;return{data:{properties:{action_link:t,email_otp:s,hashed_token:r,redirect_to:i,verification_type:a},user:Object.assign({},tP(e,["action_link","email_otp","hashed_token","redirect_to","verification_type"]))},error:null}}function tF(e){return e}let tz=["global","local","others"];var tK=function(e,t){var s={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(s[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)0>t.indexOf(r[i])&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(s[r[i]]=e[r[i]]);return s};class tJ{constructor({url:e="",headers:t={},fetch:s}){this.url=e,this.headers=t,this.fetch=tg(s),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)}}async signOut(e,t=tz[0]){if(0>tz.indexOf(t))throw Error(`@supabase/auth-js: Parameter scope must be one of ${tz.join(", ")}`);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(e5(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:tM})}catch(e){if(e5(e))return{data:{user:null},error:e};throw e}}async generateLink(e){try{let{options:t}=e,s=tK(e,["options"]),r=Object.assign(Object.assign({},s),t);return"newEmail"in s&&(r.new_email=null==s?void 0:s.newEmail,delete r.newEmail),await tR(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:r,headers:this.headers,xform:tq,redirectTo:null==t?void 0:t.redirectTo})}catch(e){if(e5(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:tM})}catch(e){if(e5(e))return{data:{user:null},error:e};throw e}}async listUsers(e){var t,s,r,i,a,n,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!=(s=null==(t=null==e?void 0:e.page)?void 0:t.toString())?s:"",per_page:null!=(i=null==(r=null==e?void 0:e.perPage)?void 0:r.toString())?i:""},xform:tF});if(c.error)throw c.error;let h=await c.json(),u=null!=(a=c.headers.get("x-total-count"))?a:0,d=null!=(o=null==(n=c.headers.get("link"))?void 0:n.split(","))?o:[];return d.length>0&&(d.forEach(e=>{let t=parseInt(e.split(";")[0].split("=")[1].substring(0,1)),s=JSON.parse(e.split(";")[1].split("=")[1]);l[`${s}Page`]=t}),l.total=parseInt(u)),{data:Object.assign(Object.assign({},h),l),error:null}}catch(e){if(e5(e))return{data:{users:[]},error:e};throw e}}async getUserById(e){tE(e);try{return await tR(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:tM})}catch(e){if(e5(e))return{data:{user:null},error:e};throw e}}async updateUserById(e,t){tE(e);try{return await tR(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:tM})}catch(e){if(e5(e))return{data:{user:null},error:e};throw e}}async deleteUser(e,t=!1){tE(e);try{return await tR(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:tM})}catch(e){if(e5(e))return{data:{user:null},error:e};throw e}}async _listFactors(e){tE(e.userId);try{let{data:t,error:s}=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:s}}catch(e){if(e5(e))return{data:null,error:e};throw e}}async _deleteFactor(e){tE(e.userId),tE(e.id);
7try{return{data:await tR(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(e){if(e5(e))return{data:null,error:e};throw e}}}function tH(e={}){return{getItem:t=>e[t]||null,setItem:(t,s)=>{e[t]=s},removeItem:t=>{delete e[t]}}}let tW={debug:!!(globalThis&&tp()&&globalThis.localStorage&&"true"===globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug"))};class tV extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class tG extends tV{}async function tY(e,t,s){tW.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",e,t);let r=new globalThis.AbortController;return t>0&&setTimeout(()=>{r.abort(),tW.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",e)},t),await Promise.resolve().then(()=>globalThis.navigator.locks.request(e,0===t?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:r.signal},async r=>{if(r){tW.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",e,r.name);try{return await s()}finally{tW.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",e,r.name)}}if(0===t)throw tW.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",e),new tG(`Acquiring an exclusive Navigator LockManager lock "${e}" immediately failed`);if(tW.debug)try{let e=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(e,null," "))}catch(e){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",e)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await s()}))}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){"u">typeof self&&(self.globalThis=self)}let tX={url:"http://localhost:9999",storageKey:"supabase.auth.token",autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:eZ,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function tZ(e,t,s){return await s()}let tQ={};class t0{constructor(e){var t,s;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=t0.nextInstanceID,t0.nextInstanceID+=1,this.instanceID>0&&td()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");const r=Object.assign(Object.assign({},tX),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 tJ({url:r.url,headers:r.headers,fetch:r.fetch}),this.url=r.url,this.headers=r.headers,this.fetch=tg(r.fetch),this.lock=r.lock||tZ,this.detectSessionInUrl=r.detectSessionInUrl,this.flowType=r.flowType,this.hasCustomAuthorizationHeader=r.hasCustomAuthorizationHeader,r.lock?this.lock=r.lock:td()&&(null==(t=null==globalThis?void 0:globalThis.navigator)?void 0:t.locks)?this.lock=tY:this.lock=tZ,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},this.persistSession?(r.storage?this.storage=r.storage:tp()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=tH(this.memoryStorage)),r.userStorage&&(this.userStorage=r.userStorage)):(this.memoryStorage={},this.storage=tH(this.memoryStorage)),td()&&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==(s=this.broadcastChannel)||s.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()}get jwks(){var e,t;return null!=(t=null==(e=tQ[this.storageKey])?void 0:e.jwks)?t:{keys:[]}}set jwks(e){tQ[this.storageKey]=Object.assign(Object.assign({},tQ[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,t;return null!=(t=null==(e=tQ[this.storageKey])?void 0:e.cachedAt)?t:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){tQ[this.storageKey]=Object.assign(Object.assign({},tQ[this.storageKey]),{cachedAt:e})}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${eX}) ${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(){var e;try{let t=function(e){let t={},s=new URL(e);if(s.hash&&"#"===s.hash[0])try{new URLSearchParams(s.hash.substring(1)).forEac
7h((e,s)=>{t[s]=e})}catch(e){}return s.searchParams.forEach((e,s)=>{t[s]=e}),t}(window.location.href),s="none";if(this._isImplicitGrantCallback(t)?s="implicit":await this._isPKCECallback(t)&&(s="pkce"),td()&&this.detectSessionInUrl&&"none"!==s){let{data:r,error:i}=await this._getSessionFromURL(t,s);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),e5(i)&&"AuthImplicitGrantRedirectError"===i.name){let t=null==(e=i.details)?void 0:e.code;if("identity_already_exists"===t||"identity_not_found"===t||"single_identity_not_deletable"===t)return{error:i}}return await this._removeSession(),{error:i}}let{session:a,redirectType:n}=r;return this._debug("#_initialize()","detected session in URL",a,"redirect type",n),await this._saveSession(a),setTimeout(async()=>{"recovery"===n?await this._notifyAllSubscribers("PASSWORD_RECOVERY",a):await this._notifyAllSubscribers("SIGNED_IN",a)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(e){if(e5(e))return{error:e};return{error:new e3("Unexpected error during initialization",e)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var t,s,r;try{let{data:i,error:a}=await tR(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:null!=(s=null==(t=null==e?void 0:e.options)?void 0:t.data)?s:{},gotrue_meta_security:{captcha_token:null==(r=null==e?void 0:e.options)?void 0:r.captchaToken}},xform:tD});if(a||!i)return{data:{user:null,session:null},error:a};let n=i.session,o=i.user;return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",n)),{data:{user:o,session:n},error:null}}catch(e){if(e5(e))return{data:{user:null,session:null},error:e};throw e}}async signUp(e){var t,s,r;try{let i;if("email"in e){let{email:s,password:r,options:a}=e,n=null,o=null;"pkce"===this.flowType&&([n,o]=await tS(this.storage,this.storageKey)),i=await tR(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:null==a?void 0:a.emailRedirectTo,body:{email:s,password:r,data:null!=(t=null==a?void 0:a.data)?t:{},gotrue_meta_security:{captcha_token:null==a?void 0:a.captchaToken},code_challenge:n,code_challenge_method:o},xform:tD})}else if("phone"in e){let{phone:t,password:a,options:n}=e;i=await tR(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:t,password:a,data:null!=(s=null==n?void 0:n.data)?s:{},channel:null!=(r=null==n?void 0:n.channel)?r:"sms",gotrue_meta_security:{captcha_token:null==n?void 0:n.captchaToken}},xform:tD})}else throw new e7("You must provide either an email or phone number and a password");let{data:a,error:n}=i;if(n||!a)return{data:{user:null,session:null},error:n};let o=a.session,l=a.user;return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",o)),{data:{user:l,session:o},error:null}}catch(e){if(e5(e))return{data:{user:null,session:null},error:e};throw e}}async signInWithPassword(e){try{let t;if("email"in e){let{email:s,password:r,options:i}=e;t=await tR(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:s,password:r,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},xform:tL})}else if("phone"in e){let{phone:s,password:r,options:i}=e;t=await tR(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:s,password:r,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},xform:tL})}else throw new e7("You must provide either an email or phone number and a password");let{data:s,error:r}=t;if(r)return{data:{user:null,session:null},error:r};if(!s||!s.session||!s.user)return{data:{user:null,session:null},error:new e9};return s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",s.session)),{data:Object.assign({user:s.user,session:s.session},s.weak_password?{weakPassword:s.weak_password}:null),error:r}}catch(e){if(e5(e))return{data:{user:null,session:null},error:e};throw e}}async signInWithOAuth(e){var t,s,r,i;return await this._handleProviderSignIn(e.provider,{redirectTo:null==(t=e.options)?void 0:t.redirectTo,scopes:null==(s=e.options)?void 0:s.scopes,queryParams:null==(r=e.options)?void 0:r.queryParams,skipBrowserRedirect:null==(i=e.options)?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){let{chain:t}=e;if("solana"===t)return await this.signInWithSolana(e);throw Error(`@supabase/auth-js: Unsupported chain "${t}"`)}async signInWithSolana(e){var t,s,r,i,a,n,o,l,c,h,u,d,f;let p,g;if("message"in e)p=e.message,g=e.signature;else{let u,{chain:d,wallet:f,statement:m,options:b}=e;if(td())if("object"==typeof f)u=f;else{let e=window;if("solana"in e&&"object"==typeof e.solana&&("signIn"in e.solana&&"function"==typeof e.solana.signIn||"sign
7Message"in e.solana&&"function"==typeof e.solana.signMessage))u=e.solana;else throw Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if("object"!=typeof f||!(null==b?void 0:b.url))throw Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");u=f}let w=new URL(null!=(t=null==b?void 0:b.url)?t:window.location.href);if("signIn"in u&&u.signIn){let e,t=await u.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},null==b?void 0:b.signInWithSolana),{version:"1",domain:w.host,uri:w.href}),m?{statement:m}:null));if(Array.isArray(t)&&t[0]&&"object"==typeof t[0])e=t[0];else if(t&&"object"==typeof t&&"signedMessage"in t&&"signature"in t)e=t;else throw Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in e&&"signature"in e&&("string"==typeof e.signedMessage||e.signedMessage instanceof Uint8Array)&&e.signature instanceof Uint8Array)p="string"==typeof e.signedMessage?e.signedMessage:new TextDecoder().decode(e.signedMessage),g=e.signature;else throw Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in u)||"function"!=typeof u.signMessage||!("publicKey"in u)||"object"!=typeof u||!u.publicKey||!("toBase58"in u.publicKey)||"function"!=typeof u.publicKey.toBase58)throw Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");p=[`${w.host} wants you to sign in with your Solana account:`,u.publicKey.toBase58(),...m?["",m,""]:[""],"Version: 1",`URI: ${w.href}`,`Issued At: ${null!=(r=null==(s=null==b?void 0:b.signInWithSolana)?void 0:s.issuedAt)?r:new Date().toISOString()}`,...(null==(i=null==b?void 0:b.signInWithSolana)?void 0:i.notBefore)?[`Not Before: ${b.signInWithSolana.notBefore}`]:[],...(null==(a=null==b?void 0:b.signInWithSolana)?void 0:a.expirationTime)?[`Expiration Time: ${b.signInWithSolana.expirationTime}`]:[],...(null==(n=null==b?void 0:b.signInWithSolana)?void 0:n.chainId)?[`Chain ID: ${b.signInWithSolana.chainId}`]:[],...(null==(o=null==b?void 0:b.signInWithSolana)?void 0:o.nonce)?[`Nonce: ${b.signInWithSolana.nonce}`]:[],...(null==(l=null==b?void 0:b.signInWithSolana)?void 0:l.requestId)?[`Request ID: ${b.signInWithSolana.requestId}`]:[],...(null==(h=null==(c=null==b?void 0:b.signInWithSolana)?void 0:c.resources)?void 0:h.length)?["Resources",...b.signInWithSolana.resources.map(e=>`- ${e}`)]:[]].join("\n");let e=await u.signMessage(new TextEncoder().encode(p),"utf8");if(!e||!(e instanceof Uint8Array))throw Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");g=e}}try{let t,s,r,{data:i,error:a}=await tR(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:p,signature:(f=g,t=[],s={queue:0,queuedBits:0},r=e=>{t.push(e)},f.forEach(e=>tc(e,s,r)),tc(null,s,r),t.join(""))},(null==(u=e.options)?void 0:u.captchaToken)?{gotrue_meta_security:{captcha_token:null==(d=e.options)?void 0:d.captchaToken}}:null),xform:tD});if(a)throw a;if(!i||!i.session||!i.user)return{data:{user:null,session:null},error:new e9};return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",i.session)),{data:Object.assign({},i),error:a}}catch(e){if(e5(e))return{data:{user:null,session:null},error:e};throw e}}async _exchangeCodeForSession(e){let t=await tb(this.storage,`${this.storageKey}-code-verifier`),[s,r]=(null!=t?t:"").split("/");try{let{data:t,error:i}=await tR(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:s},xform:tD});if(await tw(this.storage,`${this.storageKey}-code-verifier`),i)throw i;if(!t||!t.session||!t.user)return{data:{user:null,session:null,redirectType:null},error:new e9};return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("SIGNED_IN",t.session)),{data:Object.assign(Object.assign({},t),{redirectType:null!=r?r:null}),error:i}}catch(e){if(e5(e))return{data:{user:null,session:null,redirectType:null},error:e};throw e}}async signInWithIdToken(e){try{let{options:t,provider:s,token:r,access_token:i,nonce:a}=e,{data:n,error:o}=await tR(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:s,id_token:r,access_token:i,nonce:a,gotrue_meta_security:{captcha_token:null==t?void 0:t.captchaToken}},xform:tD});if(o)return{data:{user:null,session:null},error:o};if(!n||!n.session||!n.user)return{data:{user:null,session:null},error:new e9};return n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),{data:n,error:o}}catch(e){if(e5(e))return{data:{user:null,session:null},error:e};throw e}}async signInWithOtp(e){var t,s,r,i,a;try{if("email"in e){let{email:r,options:i}=e,a=null,n=null;"pkce"===this.flowType&&([a,n]=await tS(this.storage,this.storageKey));let{error:o}=await tR(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:r,data:null!=(t=null==i?void 0:i.data)?t:{},create_user:null==(s=null==i?void 0:i.shouldCreateUser)||s,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken},code_challenge:a,code_challenge_method:n},redirectTo:null==i?void 0:i.emailRedirectTo});return{data:{user:null,session:null},error:o}}if("phone"in e){let{phone:t,options:s}=e,{data:n,error:o}=await tR(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:t,data:null!=(r=null==s?void 0:s.data)?r:{},create_user:null==(i=null==s?void 0:s.shouldCreateUser)||i,gotrue_meta_security:{captcha_token:null==s?void 0:s.captchaToken},channel:null!=(a=null==s?void 0:s.channel)?a:"sms"}});return{data:{user:null,session:null,messageId:null==n?void 0:n.message_id},error:o}}throw new e7("You must provide either an email or phone number.")}catch(e){if(e5(e))return{data:{user:null,session:null},error:e};throw e}}async verifyOtp(e){var t,s;try{let r,i;"options"in e&&(r=null==(t=e.options)?void 0:t.redirectTo,i=null==(s=e.options)?void 0:s.captchaToken);let{data:a,error:n}=await tR(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:r,xform:tD});if(n)throw n;if(!a)throw Error("An error occurred on token verification.");let o=a.session,l=a.user;return(null==o?void 0:o.access_token)&&(await this._saveSession(o),await this._notifyAllSubscribers("recovery"==e.type?"PASSWORD_RECOVERY":"SIGNED_IN",o)),{data:{user:l,session:o},error:null}}catch(e){if(e5(e))return{data:{user:null,session:null},error:e};throw e}}async signInWithSSO(e){var t,s,r;try{let i=null,a=null;return"pkce"===this.flowType&&([i,a]=await tS(this.storage,this.storageKey)),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!=(s=null==(t=e.options)?void 0:t.redirectTo)?s:void 0}),(null==(r=null==e?void 0:e.options)?void 0:r.captchaToken)?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:i,code_challenge_method:a}),headers:this.headers,xform:tB})}catch(e){if(e5(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:s}=e;if(s)throw s;if(!t)throw new e8;let{error:r}=await tR(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:t.access_token});return{data:{user:null,session:null},error:r}})}catch(e){if(e5(e))return{data:{user:null,session:null},error:e};throw e}}async resend(e){try{let t=`${this.url}/resend`;if("email"in e){let{email:s,type:r,options:i}=e,{error:a}=await tR(this.fetch,"POST",t,{headers:this.headers,body:{email:s,type:r,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:a}}if("phone"in e){let{phone:s,type:r,options:i}=e,{data:a,error:n}=await tR(this.fetch,"POST",t,{headers:this.headers,body:{phone:s,type:r,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}}});return{data:{user:null,session:null,messageId:null==a?void 0:a.message_id},error:n}}throw new e7("You must provide either an email or phone number and a type")}catch(e){if(e5(e))return{data:{user:null,session:null},error:e};throw e}}async getSession(){return await this.initializePromise,await 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(),s=(async()=>(await e,await t()))();return this.pendingInLock.push((async()=>{try{await s}catch(e){}})()),s}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 tb(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
7id"),await this._removeSession())),!e)return{data:{session:null},error:null};let s=!!e.expires_at&&1e3*e.expires_at-Date.now()<9e4;if(this._debug("#__loadSession()",`session has${s?"":" not"} expired`,"expires_at",e.expires_at),!s){if(this.userStorage){let t=await tb(this.userStorage,this.storageKey+"-user");(null==t?void 0:t.user)?e.user=t.user:e.user=tC()}if(this.storage.isServer&&e.user){let t=this.suppressGetSessionWarning;e=new Proxy(e,{get:(e,s,r)=>(t||"user"!==s||(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),t=!0,this.suppressGetSessionWarning=!0),Reflect.get(e,s,r))})}return{data:{session:e},error:null}}let{session:r,error:i}=await this._callRefreshToken(e.refresh_token);if(i)return{data:{session:null},error:i};return{data:{session:r},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(e){return e?await this._getUser(e):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(e){try{if(e)return await tR(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:tM});return await this._useSession(async e=>{var t,s,r;let{data:i,error:a}=e;if(a)throw a;return(null==(t=i.session)?void 0:t.access_token)||this.hasCustomAuthorizationHeader?await tR(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:null!=(r=null==(s=i.session)?void 0:s.access_token)?r:void 0,xform:tM}):{data:{user:null},error:new e8}})}catch(e){if(e5(e))return e5(e)&&"AuthSessionMissingError"===e.name&&(await this._removeSession(),await tw(this.storage,`${this.storageKey}-code-verifier`)),{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 s=>{let{data:r,error:i}=s;if(i)throw i;if(!r.session)throw new e8;let a=r.session,n=null,o=null;"pkce"===this.flowType&&null!=e.email&&([n,o]=await tS(this.storage,this.storageKey));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:n,code_challenge_method:o}),jwt:a.access_token,xform:tM});if(c)throw c;return a.user=l.user,await this._saveSession(a),await this._notifyAllSubscribers("USER_UPDATED",a),{data:{user:a.user},error:null}})}catch(e){if(e5(e))return{data:{user:null},error:e};throw 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 e8;let t=Date.now()/1e3,s=t,r=!0,i=null,{payload:a}=ty(e.access_token);if(a.exp&&(r=(s=a.exp)<=t),r){let{session:t,error:s}=await this._callRefreshToken(e.refresh_token);if(s)return{data:{user:null,session:null},error:s};if(!t)return{data:{user:null,session:null},error:null};i=t}else{let{data:r,error:a}=await this._getUser(e.access_token);if(a)throw a;i={access_token:e.access_token,refresh_token:e.refresh_token,user:r.user,token_type:"bearer",expires_in:s-t,expires_at:s},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return{data:{user:i.user,session:i},error:null}}catch(e){if(e5(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 s;if(!e){let{data:r,error:i}=t;if(i)throw i;e=null!=(s=r.session)?s:void 0}if(!(null==e?void 0:e.refresh_token))throw new e8;let{session:r,error:i}=await this._callRefreshToken(e.refresh_token);return i?{data:{user:null,session:null},error:i}:r?{data:{user:r.user,session:r},error:null}:{data:{user:null,session:null},error:null}})}catch(e){if(e5(e))return{data:{user:null,session:null},error:e};throw e}}async _getSessionFromURL(e,t){try{if(!td())throw new te("No browser detected.");
7if(e.error||e.error_description||e.error_code)throw new te(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(t){case"implicit":if("pkce"===this.flowType)throw new tt("Not a valid PKCE flow url.");break;case"pkce":if("implicit"===this.flowType)throw new te("Not a valid implicit grant flow url.")}if("pkce"===t){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new tt("No code detected.");let{data:t,error:s}=await this._exchangeCodeForSession(e.code);if(s)throw s;let r=new URL(window.location.href);return r.searchParams.delete("code"),window.history.replaceState(window.history.state,"",r.toString()),{data:{session:t.session,redirectType:null},error:null}}let{provider_token:s,provider_refresh_token:r,access_token:i,refresh_token:a,expires_in:n,expires_at:o,token_type:l}=e;if(!i||!n||!a||!l)throw new te("No session defined in URL");let c=Math.round(Date.now()/1e3),h=parseInt(n),u=c+h;o&&(u=parseInt(o));let d=u-c;1e3*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 clock for skew",f,u,c);let{data:p,error:g}=await this._getUser(i);if(g)throw g;let m={provider_token:s,provider_refresh_token:r,access_token:i,expires_in:h,expires_at:u,refresh_token:a,token_type:l,user:p.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:m,redirectType:e.type},error:null}}catch(e){if(e5(e))return{data:{session:null,redirectType:null},error:e};throw e}}_isImplicitGrantCallback(e){return!!(e.access_token||e.error_description)}async _isPKCECallback(e){let t=await tb(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 s;let{data:r,error:i}=t;if(i)return{error:i};let a=null==(s=r.session)?void 0:s.access_token;if(a){let{error:t}=await this.admin.signOut(a,e);if(t&&!(e5(t)&&"AuthApiError"===t.name&&(404===t.status||401===t.status||403===t.status)))return{error:t}}return"others"!==e&&(await this._removeSession(),await tw(this.storage,`${this.storageKey}-code-verifier`)),{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)}),s={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,s),(async()=>{await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(t)})})(),{data:{subscription:s}}}async _emitInitialSession(e){return await this._useSession(async t=>{var s,r;try{let{data:{session:r},error:i}=t;if(i)throw i;await (null==(s=this.stateChangeEmitters.get(e))?void 0:s.callback("INITIAL_SESSION",r)),this._debug("INITIAL_SESSION","callback id",e,"session",r)}catch(t){await (null==(r=this.stateChangeEmitters.get(e))?void 0:r.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",t),console.error(t)}})}async resetPasswordForEmail(e,t={}){let s=null,r=null;"pkce"===this.flowType&&([s,r]=await tS(this.storage,this.storageKey,!0));try{return await tR(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:s,code_challenge_method:r,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo})}catch(e){if(e5(e))return{data:null,error:e};throw e}}async getUserIdentities(){var e;try{let{data:t,error:s}=await this.getUser();if(s)throw s;return{data:{identities:null!=(e=t.user.identities)?e:[]},error:null}}catch(e){if(e5(e))return{data:null,error:e};throw e}}async linkIdentity(e){var t;try{let{data:s,error:r}=await this._useSession(async t=>{var s,r,i,a,n;let{data:o,error:l}=t;if(l)throw l;let c=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:null==(s=e.options)?void 0:s.redirectTo,scopes:null==(r=e.options)?void 0:r.scopes,queryParams:null==(i=e.options)?void 0:i.queryParams,skipBrowserRedirect:!0});return await tR(this.fetch,"GET",c,{headers:this.headers,jwt:null!=(n=null==(a=o.session)?void 0:a.access_token)?n:void 0})});if(r)throw r;return!td()||(null==(t=e.options)?void 0:t.skipBrowserRedirect)||window.location.assign(null==s?void 0:s.url),{data:{provider:e.provider,url:null==s?void 0:s.url},error:null}}catch(t){if(e5(t))return{data:{provider:e.provider,url:null},error:t};throw t}}async unlinkIdentity(e){try{return await this._useSession(async t=>{var s,r;let{data:i,error:a}=t;if(a)throw a;
7return await tR(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:null!=(r=null==(s=i.session)?void 0:s.access_token)?r:void 0})})}catch(e){if(e5(e))return{data:null,error:e};throw e}}async _refreshAccessToken(e){let t=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(t,"begin");try{var s,r;let i=Date.now();return await (s=async s=>(s>0&&await tx(200*Math.pow(2,s-1)),this._debug(t,"refreshing attempt",s),await tR(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:tD})),r=(e,t)=>{let s=200*Math.pow(2,e);return t&&tr(t)&&Date.now()+s-i<3e4},new Promise((e,t)=>{(async()=>{for(let i=0;i<1/0;i++)try{let t=await s(i);if(!r(i,null,t))return void e(t)}catch(e){if(!r(i,e))return void t(e)}})()}))}catch(e){if(this._debug(t,"error",e),e5(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 s=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:t.redirectTo,scopes:t.scopes,queryParams:t.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",t,"url",s),td()&&!t.skipBrowserRedirect&&window.location.assign(s),{data:{provider:e,url:s},error:null}}async _recoverAndRefresh(){var e,t;let s="#_recoverAndRefresh()";this._debug(s,"begin");try{let r=await tb(this.storage,this.storageKey);if(r&&this.userStorage){let t=await tb(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!t&&(t={user:r.user},await tm(this.userStorage,this.storageKey+"-user",t)),r.user=null!=(e=null==t?void 0:t.user)?e:tC()}else if(r&&!r.user&&!r.user){let e=await tb(this.storage,this.storageKey+"-user");e&&(null==e?void 0:e.user)?(r.user=e.user,await tw(this.storage,this.storageKey+"-user"),await tm(this.storage,this.storageKey,r)):r.user=tC()}if(this._debug(s,"session from storage",r),!this._isValidSession(r)){this._debug(s,"session is not valid"),null!==r&&await this._removeSession();return}let i=(null!=(t=r.expires_at)?t:1/0)*1e3-Date.now()<9e4;if(this._debug(s,`session has${i?"":" not"} expired with margin of 90000s`),i){if(this.autoRefreshToken&&r.refresh_token){let{error:e}=await this._callRefreshToken(r.refresh_token);e&&(console.error(e),tr(e)||(this._debug(s,"refresh failed with a non-retryable error, removing the session",e),await this._removeSession()))}}else if(r.user&&!0===r.user.__isUserNotAvailableProxy)try{let{data:e,error:t}=await this._getUser(r.access_token);!t&&(null==e?void 0:e.user)?(r.user=e.user,await this._saveSession(r),await this._notifyAllSubscribers("SIGNED_IN",r)):this._debug(s,"could not get user data, skipping SIGNED_IN notification")}catch(e){console.error("Error getting user data:",e),this._debug(s,"error getting user data, skipping SIGNED_IN notification",e)}else await this._notifyAllSubscribers("SIGNED_IN",r)}catch(e){this._debug(s,"error",e),console.error(e);return}finally{this._debug(s,"end")}}async _callRefreshToken(e){var t,s;if(!e)throw new e8;if(this.refreshingDeferred)return this.refreshingDeferred.promise;let r=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(r,"begin");try{this.refreshingDeferred=new tv;let{data:t,error:s}=await this._refreshAccessToken(e);if(s)throw s;if(!t.session)throw new e8;await this._saveSession(t.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",t.session);let r={session:t.session,error:null};return this.refreshingDeferred.resolve(r),r}catch(e){if(this._debug(r,"error",e),e5(e)){let s={session:null,error:e};return tr(e)||await this._removeSession(),null==(t=this.refreshingDeferred)||t.resolve(s),s}throw null==(s=this.refreshingDeferred)||s.reject(e),e}finally{this.refreshingDeferred=null,this._debug(r,"end")}}async _notifyAllSubscribers(e,t,s=!0){let r=`#_notifyAllSubscribers(${e})`;this._debug(r,"begin",t,`broadcast = ${s}`);try{this.broadcastChannel&&s&&this.broadcastChannel.postMessage({event:e,session:t});let r=[],i=Array.from(this.stateChangeEmitters.values()).map(async s=>{try{await s.callback(e,t)}catch(e){r.push(e)}});if(await Promise.all(i),r.length>0){for(let e=0;e<r.length;e+=1)console.error(r[e]);throw r[0]}}finally{this._debug(r,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0;let t=Object.assign({},e),s=t.user&&!0===t.user.__isUserNotAvailableProxy;if(this.userStorage){!s&&t.user&&await tm(this.userStorage,this.storageKey+"-user",{user:t.user});let e=Object.assign({},t);delete e.user;let r=tA(e);await tm(this.storage,this.storageKey,r)}else{let e=tA(t);await tm(this.storage,this.storageKey,e)}}async _removeSession(){this._debug("#_removeSession()"),await tw(this.storage,this.storageKey),await tw(this.storage,this.storageKey+"-code-verifier"),await tw(this.storage,this.storageKey+"-user"),this.userStorage&&await tw(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");let e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&td()&&(null==window?void 0:window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}
7catch(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():"u">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:s}}=t;if(!s||!s.refresh_token||!s.expires_at)return void this._debug("#_autoRefreshTokenTick()","no session");let r=Math.floor((1e3*s.expires_at-e)/3e4);this._debug("#_autoRefreshTokenTick()",`access token expires in ${r} ticks, a tick lasts 30000ms, refresh threshold is 3 ticks`),r<=3&&await this._callRefreshToken(s.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 tV)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!td()||!(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||(await this.initializePromise,await this._acquireLock(-1,async()=>{"visible"!==document.visibilityState?this._debug(t,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting"):await this._recoverAndRefresh()}))):"hidden"===document.visibilityState&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,t,s){let r=[`provider=${encodeURIComponent(t)}`];if((null==s?void 0:s.redirectTo)&&r.push(`redirect_to=${encodeURIComponent(s.redirectTo)}`),(null==s?void 0:s.scopes)&&r.push(`scopes=${encodeURIComponent(s.scopes)}`),"pkce"===this.flowType){let[e,t]=await tS(this.storage,this.storageKey),s=new URLSearchParams({code_challenge:`${encodeURIComponent(e)}`,code_challenge_method:`${encodeURIComponent(t)}`});r.push(s.toString())}if(null==s?void 0:s.queryParams){let e=new URLSearchParams(s.queryParams);r.push(e.toString())}return(null==s?void 0:s.skipBrowserRedirect)&&r.push(`skip_http_redirect=${s.skipBrowserRedirect}`),`${e}?${r.join("&")}`}async _unenroll(e){try{return await this._useSession(async t=>{var s;let{data:r,error:i}=t;return i?{data:null,error:i}:await tR(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:null==(s=null==r?void 0:r.session)?void 0:s.access_token})})}catch(e){if(e5(e))return{data:null,error:e};throw e}}async _enroll(e){try{return await this._useSession(async t=>{var s,r;let{data:i,error:a}=t;if(a)return{data:null,error:a};let n=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},"phone"===e.factorType?{phone:e.phone}:{issuer:e.issuer}),{data:o,error:l}=await tR(this.fetch,"POST",`${this.url}/factors`,{body:n,headers:this.headers,jwt:null==(s=null==i?void 0:i.session)?void 0:s.access_token});return l?{data:null,error:l}:("totp"===e.factorType&&(null==(r=null==o?void 0:o.totp)?void 0:r.qr_code)&&(o.totp.qr_code=`data:image/svg+xml;utf-8,${o.totp.qr_code}`),{data:o,error:null})})}catch(e){if(e5(e))return{data:null,error:e};throw e}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var s;let{data:r,error:i}=t;if(i)return{data:null,error:i};let{data:a,error:n}=await tR(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:null==(s=null==r?void 0:r.session)?void 0:s.access_token});return n?{data:null,error:n}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+a.expires_in},a)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",a),{data:a,error:n})})}catch(e){if(e5(e))return{data:null,error:e};throw e}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var s;let{data:r,error:i}=t;return i?{data:null,error:i}:await tR(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:{channel:e.channel},headers:this.headers,jwt:null==(s=null==r?void 0:r.session)?void 0:s.access_token})})}catch(e){if(e5(e))return{data:null,error:e};throw e}})}async _challengeAndVerify(e){let{data:t,error:s}=await this._challenge({factorId:e.factorId});return s?{data:null,error:s}: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 s=(null==e?void 0:e.factors)||[],r=s.filter(e=>"totp"===e.factor_type&&"verified"===e.status),i=s.filter(e=>"phone"===e.factor_type&&"verified"===e.status);return{data:{all:s,totp:r,phone:i},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async e=>{var t,s;let{data:{session:r},error:i}=e;if(i)return{data:null,error:i};if(!r)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};let{payload:a}=ty(r.access_token),n=null;a.aal&&(n=a.aal);let o=n;return(null!=(s=null==(t=r.user.factors)?void 0:t.filter(e=>"verified"===e.status))?s:[]).length>0&&(o="aal2"),{data:{currentLevel:n,nextLevel:o,currentAuthenticationMethods:a.amr||[]},error:null}}))}async fetchJwk(e,t={keys:[]}){let s=t.keys.find(t=>t.kid===e);if(s)return s;let r=Date.now();if((s=this.jwks.keys.find(t=>t.kid===e))&&this.jwks_cached_at+6e5>r)return s;let{data:i,error:a}=await tR(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(a)throw a;return i.keys&&0!==i.keys.length&&(this.jwks=i,this.jwks_cached_at=r,s=i.keys.find(t=>t.kid===e))?s:null}async getClaims(e,t={}){try{var s;let r,i=e;if(!i){let{data:e,error:t}
7=await this.getSession();if(t||!e.session)return{data:null,error:t};i=e.session.access_token}let{header:a,payload:n,signature:o,raw:{header:l,payload:c}}=ty(i);(null==t?void 0:t.allowExpired)||function(e){if(!e)throw Error("Missing exp claim");if(e<=Math.floor(Date.now()/1e3))throw Error("JWT has expired")}(n.exp);let h=!a.alg||a.alg.startsWith("HS")||!a.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(a.kid,(null==t?void 0:t.keys)?{keys:t.keys}:null==t?void 0:t.jwks);if(!h){let{error:e}=await this.getUser(i);if(e)throw e;return{data:{claims:n,header:a,signature:o},error:null}}let u=function(e){switch(e){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw Error("Invalid alg claim")}}(a.alg),d=await crypto.subtle.importKey("jwk",h,u,!0,["verify"]);if(!await crypto.subtle.verify(u,d,o,(s=`${l}.${c}`,r=[],!function(e,t){for(let s=0;s<e.length;s+=1){let r=e.charCodeAt(s);if(r>55295&&r<=56319){let t=(r-55296)*1024&65535;r=(e.charCodeAt(s+1)-56320&65535|t)+65536,s+=1}!function(e,t){if(e<=127)return t(e);if(e<=2047){t(192|e>>6),t(128|63&e);return}if(e<=65535){t(224|e>>12),t(128|e>>6&63),t(128|63&e);return}if(e<=1114111){t(240|e>>18),t(128|e>>12&63),t(128|e>>6&63),t(128|63&e);return}throw Error(`Unrecognized Unicode codepoint: ${e.toString(16)}`)}(r,t)}}(s,e=>r.push(e)),new Uint8Array(r))))throw new ta("Invalid JWT signature");return{data:{claims:n,header:a,signature:o},error:null}}catch(e){if(e5(e))return{data:null,error:e};throw e}}}t0.nextInstanceID=0;let t1=t0;class t2 extends t1{constructor(e){super(e)}}class t5{constructor(e,t,s){var r,i,a;if(this.supabaseUrl=e,this.supabaseKey=t,!e)throw Error("supabaseUrl is required.");if(!t)throw Error("supabaseKey is required.");const n=new URL(function(e){return e.endsWith("/")?e:e+"/"}(e));this.realtimeUrl=new URL("realtime/v1",n),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",n),this.storageUrl=new URL("storage/v1",n),this.functionsUrl=new URL("functions/v1",n);const o=`sb-${n.hostname.split(".")[0]}-auth-token`,l=function(e,t){var s,r;let{db:i,auth:a,realtime:n,global:o}=e,{db:l,auth:c,realtime:h,global:u}=t,d={db:Object.assign(Object.assign({},l),i),auth:Object.assign(Object.assign({},c),a),realtime:Object.assign(Object.assign({},h),n),global:Object.assign(Object.assign(Object.assign({},u),o),{headers:Object.assign(Object.assign({},null!=(s=null==u?void 0:u.headers)?s:{}),null!=(r=null==o?void 0:o.headers)?r:{})}),accessToken:()=>{var e,t,s,r;return e=this,t=void 0,r=function*(){return""},new(s=void 0,s=Promise)(function(i,a){function n(e){try{l(r.next(e))}catch(e){a(e)}}function o(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(n,o)}l((r=r.apply(e,t||[])).next())})}};return e.accessToken?d.accessToken=e.accessToken:delete d.accessToken,d}(null!=s?s:{},{db:eW,realtime:eG,auth:Object.assign(Object.assign({},eV),{storageKey:o}),global:eH});this.storageKey=null!=(r=l.auth.storageKey)?r:"",this.headers=null!=(i=l.global.headers)?i:{},l.accessToken?(this.accessToken=l.accessToken,this.auth=new Proxy({},{get:(e,t)=>{throw Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(t)} is not possible`)}})):this.auth=this._initSupabaseAuthClient(null!=(a=l.auth)?a:{},this.headers,l.global.fetch),this.fetch=((e,t,s)=>{let r,i=(r=s||("u"<typeof fetch?eY.default:fetch),(...e)=>r(...e)),a="u"<typeof Headers?eY.Headers:Headers;return(s,r)=>{var n,o,l,c;return n=void 0,o=void 0,l=void 0,c=function*(){var n;let o=null!=(n=yield t())?n:e,l=new a(null==r?void 0:r.headers);return l.has("apikey")||l.set("apikey",e),l.has("Authorization")||l.set("Authorization",`Bearer ${o}`),i(s,Object.assign(Object.assign({},r),{headers:l}))},new(l||(l=Promise))(function(e,t){function s(e){try{i(c.next(e))}catch(e){t(e)}}function r(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(s,r)}i((c=c.apply(n,o||[])).next())})}})(t,this._getAccessToken.bind(this),l.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},l.realtime)),this.rest=new Q(new URL("rest/v1",n).href,{headers:this.headers,schema:l.db.schema,fetch:this.fetch}),l.accessToken||this._listenForAuthEvents()}get functions(){return new Z(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}get storage(){return new eK(this.storageUrl.href,this.headers,this.fetch)}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,t={},s={}){return this.rest.rpc(e,t,s)}
7channel(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,s,r,i,a;return s=this,r=void 0,i=void 0,a=function*(){if(this.accessToken)return yield this.accessToken();let{data:s}=yield this.auth.getSession();return null!=(t=null==(e=s.session)?void 0:e.access_token)?t:null},new(i||(i=Promise))(function(e,t){function n(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 i?s:new i(function(e){e(s)})).then(n,o)}l((a=a.apply(s,r||[])).next())})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:s,storage:r,storageKey:i,flowType:a,lock:n,debug:o},l,c){let h={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new t2({url:this.authUrl.href,headers:Object.assign(Object.assign({},h),l),storageKey:i,autoRefreshToken:e,persistSession:t,detectSessionInUrl:s,storage:r,flowType:a,lock:n,debug:o,fetch:c,hasCustomAuthorizationHeader:"Authorization"in this.headers})}_initRealtimeClient(e){return new ej(this.realtimeUrl.href,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,s){("TOKEN_REFRESHED"===e||"SIGNED_IN"===e)&&this.changedAccessToken!==s?this.changedAccessToken=s:"SIGNED_OUT"===e&&(this.realtime.setAuth(),"STORAGE"==t&&this.auth.signOut(),this.changedAccessToken=void 0)}}var t4=e.i(502627);function t3(){return"u">typeof window&&void 0!==window.document}t4.parse,t4.serialize;let t6={path:"/",sameSite:"lax",httpOnly:!1,maxAge:31536e6},t8=/^(.*)[.](0|[1-9][0-9]*)$/;function t9(e,t){if(e===t)return!0;let s=e.match(t8);return!!s&&s[1]===t}function t7(e,t,s){let r=s??3180,i=encodeURIComponent(t);if(i.length<=r)return[{name:e,value:t}];let a=[];for(;i.length>0;){let e=i.slice(0,r),t=e.lastIndexOf("%");t>r-3&&(e=e.slice(0,t));let s="";for(;e.length>0;)try{s=decodeURIComponent(e);break}catch(t){if(t instanceof URIError&&"%"===e.at(-3)&&e.length>3)e=e.slice(0,e.length-3);else throw t}a.push(s),i=i.slice(e.length)}return a.map((t,s)=>({name:`${e}.${s}`,value:t}))}async function se(e,t){let s=await t(e);if(s)return s;let r=[];for(let s=0;;s++){let i=`${e}.${s}`,a=await t(i);if(!a)break;r.push(a)}return r.length>0?r.join(""):null}let st="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),ss=" \n\r=".split(""),sr=(()=>{let e=Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<ss.length;t+=1)e[ss[t].charCodeAt(0)]=-2;for(let t=0;t<st.length;t+=1)e[st[t].charCodeAt(0)]=t;return e})();function si(e){let t=[],s=0,r=0;if(function(e,t){for(let s=0;s<e.length;s+=1){let r=e.charCodeAt(s);if(r>55295&&r<=56319){let t=(r-55296)*1024&65535;r=(e.charCodeAt(s+1)-56320&65535|t)+65536,s+=1}!function(e,t){if(e<=127)return t(e);if(e<=2047){t(192|e>>6),t(128|63&e);return}if(e<=65535){t(224|e>>12),t(128|e>>6&63),t(128|63&e);return}if(e<=1114111){t(240|e>>18),t(128|e>>12&63),t(128|e>>6&63),t(128|63&e);return}throw Error(`Unrecognized Unicode codepoint: ${e.toString(16)}`)}(r,t)}}(e,e=>{for(s=s<<8|e,r+=8;r>=6;){let e=s>>r-6&63;t.push(st[e]),r-=6}}),r>0)for(s<<=6-r,r=6;r>=6;){let e=s>>r-6&63;t.push(st[e]),r-=6}return t.join("")}function sa(e){let t=[],s=e=>{t.push(String.fromCodePoint(e))},r={utf8seq:0,codepoint:0},i=0,a=0;for(let t=0;t<e.length;t+=1){let n=sr[e.charCodeAt(t)];if(n>-1)for(i=i<<6|n,a+=6;a>=8;)(function(e,t,s){if(0===t.utf8seq){if(e<=127)return s(e);for(let s=1;s<6;s+=1)if((e>>7-s&1)==0){t.utf8seq=s;break}if(2===t.utf8seq)t.codepoint=31&e;else if(3===t.utf8seq)t.codepoint=15&e;else if(4===t.utf8seq)t.codepoint=7&e;else throw Error("Invalid UTF-8 sequence");t.utf8seq-=1}else if(t.utf8seq>0){if(e<=127)throw Error("Invalid UTF-8 sequence");t.codepoint=t.codepoint<<6|63&e,t.utf8seq-=1,0===t.utf8seq&&s(t.codepoint)}})(i>>a-8&255,r,s),a-=8;else if(-2===n)continue;else throw Error(`Invalid Base64-URL character "${e.at(t)}" at position ${t}`)}return t.join("")}let sn="base64-";async function so({getAll:e,setAll:t,setItems:s,removedItems:r},i){let a=i.cookieEncoding,n=i.cookieOptions??null,o=await e([...s?Object.keys(s):[],...r?Object.keys(r):[]]),l=o?.map(({name:e})=>e)||[],c=Object.keys(r).flatMap(e=>l.filter(t=>t9(t,e))),h=Object.keys(s).flatMap(e=>{let t=new Set(l.filter(t=>
7t9(t,e))),r=s[e];"base64url"===a&&(r=sn+si(r));let i=t7(e,r);return i.forEach(e=>{t.delete(e.name)}),c.push(...t),i}),u={...t6,...n,maxAge:0},d={...t6,...n,maxAge:t6.maxAge};delete u.name,delete d.name,await t([...c.map(e=>({name:e,value:"",options:u})),...h.map(({name:e,value:t})=>({name:e,value:t,options:d}))])}e.i(480874);var sl=e.i(776639),sc=e.i(848961),sh=e.i(578938);function su({user:e}){let t=e?.name||e?.email?.split("@")[0]||"Account";return(0,j.jsxs)("div",{className:"flex justify-center items-center gap-2 min-w-0",children:[e?.avatar?(0,j.jsx)("img",{src:e?.avatar,alt:"Profile picture",className:"w-6 h-6 rounded-full bg-gray-50 shrink-0",referrerPolicy:"no-referrer",width:24,height:24}):(0,j.jsx)("span",{className:"w-6 h-6 bg-base-300 flex justify-center items-center rounded-full shrink-0 capitalize",children:t.charAt(0)}),(0,j.jsx)("span",{className:"truncate max-w-[160px] flex-1 min-w-0",children:t})]})}let sd=({user:e,onClose:t})=>{let s,r,i=!e?.payment_type||e?.payment_type==="Free";return(0,j.jsx)(j.Fragment,{children:(0,j.jsx)(sl.DialogContent,{className:"sm:max-w-md",children:(0,j.jsxs)(sc.motion.div,{className:"flex flex-col gap-6 py-4",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5},children:[(0,j.jsxs)("div",{children:[(0,j.jsx)("h2",{className:"text-lg font-semibold text-blue-300 mb-3",children:"Current Subscription"}),(0,j.jsxs)("div",{className:"bg-gradient-to-r from-cyan-500 to-blue-500 rounded-lg p-4",children:[(0,j.jsx)("h3",{className:"text-xl font-bold text-white mb-1",children:(s=e?.payment_type)&&"Free"!==s?s.includes("Basic")?"Basic Plan":s.includes("Standard")?"Standard Plan":s.includes("Pro")?"Pro Plan":s.includes("PayAsYouGo")||s.includes("OneTime")?"Pay As You Go":"Free Plan":"Free Plan"}),(0,j.jsx)("p",{className:"text-blue-100 text-sm mb-3",children:i?"Daily check-in credits available":`Credits: ${e?.left_credits||0}`}),(0,j.jsxs)("p",{className:"text-blue-100 text-sm",children:["Plan Type: ",(r=e?.payment_type)&&"Free"!==r?r.includes("Yearly")?"Yearly":r.includes("Monthly")?"Monthly":r.includes("PayAsYouGo")||r.includes("OneTime")?"One-time":"Free":"Free"]})]})]}),(0,j.jsx)(J.Button,{className:"w-full bg-white text-blue-900 hover:bg-blue-50 font-semibold",asChild:!0,children:(0,j.jsx)("a",{href:"/pricing",children:"View All Plans & Credits"})})]})})})},sf=({user:e,className:s})=>{!function(e,s,r){let i=t3();if(i&&t)return;if(!e||!s)throw Error(`@supabase/ssr: Your project's URL and API key are required to create a Supabase client! 8 9Check your Supabase project's API settings to find these values 10 11https://supabase.com/dashboard/project/_/settings/api`);let{storage:a}=function(e,t){let s,r,i=e.cookies??null,a=e.cookieEncoding,n={},o={};if(i)if("get"in i){let e=async e=>{let t=e.flatMap(e=>[e,...Array.from({length:5}).map((t,s)=>`${e}.${s}`)]),s=[];for(let e=0;e<t.length;e+=1){let r=await i.get(t[e]);(r||"string"==typeof r)&&s.push({name:t[e],value:r})}return s};if(s=async t=>await e(t),"set"in i&&"remove"in i)r=async e=>{for(let t=0;t<e.length;t+=1){let{name:s,value:r,options:a}=e[t];r?await i.set(s,r,a):await i.remove(s,a)}};else if(t)r=async()=>{console.warn("@supabase/ssr: createServerClient was configured without set and remove cookie methods, but the client needs to set cookies. This can lead to issues such as random logouts, early session termination or increased token refresh requests. If in NextJS, check your middleware.ts file, route handlers and server actions for correctness. Consider switching to the getAll and setAll cookie methods instead of get, set and remove which are deprecated and can be difficult to use correctly.")};else throw Error("@supabase/ssr: createBrowserClient requires configuring a getAll and setAll cookie method (deprecated: alternatively both get, set and remove can be used)")}else if("getAll"in i)if(s=async()=>await i.getAll(),"setAll"in i)r=i.setAll;else if(t)r=async()=>{console.warn("@supabase/ssr: createServerClient was configured without the setAll cookie method, but the client needs to set cookies. This can lead to issues such as random logouts, early session termination or increased token refresh requests. If in NextJS, check your middleware.ts file, route handlers and server actions for c
11orrectness.")};else throw Error("@supabase/ssr: createBrowserClient requires configuring both getAll and setAll cookie methods (deprecated: alternatively both get, set and remove can be used)");else throw Error(`@supabase/ssr: ${t?"createServerClient":"createBrowserClient"} requires configuring getAll and setAll cookie methods (deprecated: alternatively use get, set and remove).${t3()?" As this is called in a browser runtime, consider removing the cookies option object to use the document.cookie API automatically.":""}`);else if(!t&&t3())s=()=>{let e;return Object.keys(e=(0,t4.parse)(document.cookie)).map(t=>({name:t,value:e[t]}))},r=e=>{e.forEach(({name:e,value:t,options:s})=>{document.cookie=(0,t4.serialize)(e,t,s)})};else if(t)throw Error("@supabase/ssr: createServerClient must be initialized with cookie options that specify getAll and setAll functions (deprecated, not recommended: alternatively use get, set and remove)");else s=()=>[],r=()=>{throw Error("@supabase/ssr: createBrowserClient in non-browser runtimes (including Next.js pre-rendering mode) was not initialized cookie options that specify getAll and setAll functions (deprecated: alternatively use get, set and remove), but they were needed")};return t?{getAll:s,setAll:r,setItems:n,removedItems:o,storage:{isServer:!0,getItem:async e=>{if("string"==typeof n[e])return n[e];if(o[e])return null;let t=await s([e]),r=await se(e,async e=>{let s=t?.find(({name:t})=>t===e)||null;return s?s.value:null});if(!r)return null;let i=r;return r.startsWith(sn)&&(i=sa(r.substring(sn.length))),i},setItem:async(t,i)=>{t.endsWith("-code-verifier")&&await so({getAll:s,setAll:r,setItems:{[t]:i},removedItems:{}},{cookieOptions:e?.cookieOptions??null,cookieEncoding:a}),n[t]=i,delete o[t]},removeItem:async e=>{delete n[e],o[e]=!0}}}:{getAll:s,setAll:r,setItems:n,removedItems:o,storage:{isServer:!1,getItem:async e=>{let t=await s([e]),r=await se(e,async e=>{let s=t?.find(({name:t})=>t===e)||null;return s?s.value:null});if(!r)return null;let i=r;return r.startsWith(sn)&&(i=sa(r.substring(sn.length))),i},setItem:async(t,i)=>{let n=await s([t]),o=new Set((n?.map(({name:e})=>e)||[]).filter(e=>t9(e,t))),l=i;"base64url"===a&&(l=sn+si(i));let c=t7(t,l);c.forEach(({name:e})=>{o.delete(e)});let h={...t6,...e?.cookieOptions,maxAge:0},u={...t6,...e?.cookieOptions,maxAge:t6.maxAge};delete h.name,delete u.name;let d=[...[...o].map(e=>({name:e,value:"",options:h})),...c.map(({name:e,value:t})=>({name:e,value:t,options:u}))];d.length>0&&await r(d)},removeItem:async t=>{let i=await s([t]),a=(i?.map(({name:e})=>e)||[]).filter(e=>t9(e,t)),n={...t6,...e?.cookieOptions,maxAge:0};delete n.name,a.length>0&&await r(a.map(e=>({name:e,value:"",options:n})))}}}}({...void 0,cookieEncoding:(void 0)??"base64url"},!1),n=new t5(e,s,{...void 0,global:{...void 0,headers:{...void 0,"X-Client-Info":"supabase-ssr/0.4.1"}},auth:{...void 0,...null,flowType:"pkce",autoRefreshToken:t3(),detectSessionInUrl:t3(),persistSession:!0,storage:a}});i&&(t=n)}("https://jqgdbgxaoyefmtxqibey.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImpxZ2RiZ3hhb3llZm10eHFpYmV5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzE5MjczMjIsImV4cCI6MjA0NzUwMzMyMn0.tFTz99wlI6Cf2ppifdkG2VgtqY8SlF9mndNNGyjfSuA"),(0,S.useRouter)();let[r,i]=(0,T.useState)(!1),a=async()=>{await sh.authClient.signOut(),window.location.reload()};return(0,j.jsxs)(W.Popover,{children:[(0,j.jsx)(W.PopoverTrigger,{asChild:!0,children:(0,j.jsx)(J.Button,{variant:"outline",className:(0,k.cn)("gap-2 min-w-0",s),children:(0,j.jsx)(su,{user:e})})}),(0,j.jsx)(W.PopoverContent,{className:"w-64 p-0",children:(0,j.jsx)("div",{className:"overflow-hidden rounded-xl shadow-xl bg-base-100",children:(0,j.jsxs)("div",{className:"p-4 space-y-4",children:[(0,j.jsxs)("div",{className:"space-y-1",children:[(0,j.jsx)("div",{className:"text-sm font-medium truncate",children:e?.name||"User"}),(0,j.jsx)("div",{className:"text-xs text-gray-500 truncate",children:e?.email})]}),(0,j.jsxs)("div",{className:"space-y-2",children:[(0,j.jsxs)(sc.motion.a,{href:"/profiles",className:"flex items-center gap-2 w-full text-left py-2 px-0 rounded-lg font-medium text-sm hover:bg-gray-100 dark:hover:bg-white/10 cursor-pointer",whileHover:{scale:1.02},whileTap:{scale:.98},children:[(0,j.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"w-5 h-5",children:(0,j.jsx)("path",{d:"M10 8a3 3 0 100-6 3 3 0 000 6zM3.465 14.493a1.23 1.23 0 00.41 1.412A9.957 9.957 0 0010 18c2.31 0 4.438-.784 6.131-2.1.43-.333.604-.903.408-1.41a7.002 7.
11002 0 00-13.074.003z"})}),"Profile"]}),(0,j.jsxs)(sl.Dialog,{open:r,onOpenChange:i,children:[(0,j.jsx)(sl.DialogTrigger,{asChild:!0,children:(0,j.jsxs)(sc.motion.button,{className:"flex items-center justify-between w-full text-left py-2 px-0 rounded-lg font-medium text-sm hover:bg-gray-100 dark:hover:bg-white/10",whileHover:{scale:1.02},whileTap:{scale:.98},children:[(0,j.jsxs)("div",{className:"flex items-center gap-2",children:[(0,j.jsxs)("svg",{className:"w-5 h-5",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:[(0,j.jsx)("path",{d:"M508.416 509.44m-491.008 0a491.008 491.008 0 1 0 982.016 0 491.008 491.008 0 1 0-982.016 0Z",fill:"#FFDC00"}),(0,j.jsx)("path",{d:"M308.224 395.264c0 56.832 89.6 102.912 200.192 102.912s200.192-46.08 200.192-102.912-89.6-102.912-200.192-102.912-200.192 46.592-200.192 102.912z",fill:"#FFFFFF"}),(0,j.jsx)("path",{d:"M508.416 528.896c-81.92 0-152.064-25.088-182.784-61.44-10.752 12.8-16.896 26.624-16.896 41.472 0 56.832 89.6 102.912 200.192 102.912s200.192-46.08 200.192-102.912c0-14.848-6.144-28.672-16.896-41.472-32.256 36.352-102.4 61.44-183.808 61.44z",fill:"#FFFFFF"}),(0,j.jsx)("path",{d:"M508.416 646.144c-82.944 0-153.6-25.6-184.32-62.464-10.24 12.288-15.872 26.112-15.872 39.936 0 56.832 89.6 102.912 200.192 102.912s200.192-46.08 200.192-102.912c0-14.336-5.632-27.648-15.872-39.936-30.72 36.352-101.888 62.464-184.32 62.464z",fill:"#FFFFFF"})]}),"Credits"]}),(0,j.jsx)("span",{className:"text-blue-600 dark:text-blue-400",children:e?.left_credits})]})}),(0,j.jsx)(sd,{user:e,onClose:()=>i(!1)})]}),(0,j.jsxs)(sc.motion.a,{href:"/billing",className:"flex items-center gap-2 w-full text-left py-2 px-0 rounded-lg font-medium text-sm hover:bg-gray-100 dark:hover:bg-white/10 cursor-pointer",whileHover:{scale:1.02},whileTap:{scale:.98},children:[(0,j.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"w-5 h-5",children:(0,j.jsx)("path",{fillRule:"evenodd",d:"M2.5 4A1.5 1.5 0 001 5.5V6h18v-.5A1.5 1.5 0 0017.5 4h-15zM19 8.5H1v6A1.5 1.5 0 002.5 16h15a1.5 1.5 0 001.5-1.5v-6zM3 13.25a.75.75 0 01.75-.75h1.5a.75.75 0 010 1.5h-1.5a.75.75 0 01-.75-.75zm4.75-.75a.75.75 0 000 1.5h3.5a.75.75 0 000-1.5h-3.5z",clipRule:"evenodd"})}),"Billing"]}),(0,j.jsxs)("button",{className:"flex items-center gap-2 w-full text-left py-2 px-0 rounded-lg font-medium text-sm hover:bg-error/20 hover:text-error",onClick:a,children:[(0,j.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"w-5 h-5",children:[(0,j.jsx)("path",{fillRule:"evenodd",d:"M3 4.25A2.25 2.25 0 015.25 2h5.5A2.25 2.25 0 0113 4.25v2a.75.75 0 01-1.5 0v-2a.75.75 0 00-.75-.75h-5.5a.75.75 0 00-.75.75v11.5c0 .414.336.75.75.75h5.5a.75.75 0 00.75-.75v-2a.75.75 0 011.5 0v2A2.25 2.25 0 0110.75 18h-5.5A2.25 2.25 0 013 15.75V4.25z",clipRule:"evenodd"}),(0,j.jsx)("path",{fillRule:"evenodd",d:"M6 10a.75.75 0 01.75-.75h9.546l-1.048-.943a.75.75 0 111.004-1.114l2.5 2.25a.75.75 0 010 1.114l-2.5 2.25a.75.75 0 11-1.004-1.114l1.048-.943H6.75A.75.75 0 016 10z",clipRule:"evenodd"})]}),"Logout"]})]})]})})})]})};var sp=e.i(833277);let sg=({className:e,buttonClassName:t})=>{let{user:s}=(0,T.useContext)(sp.UserContext),r=(0,N.usePathname)(),i=(0,N.useSearchParams)();if(s)return(0,j.jsx)("div",{className:(0,k.cn)("flex items-center min-w-0",e),children:(0,j.jsx)(sf,{user:s,className:t})});let a=`${r}${i.toString()?`?${i.toString()}`:""}`,n=`/login?redirectTo=${encodeURIComponent(a)}`;return(0,j.jsx)(S.Link,{className:(0,k.cn)((0,J.buttonVariants)({variant:"secondary"}),"mr-6 text-sm",t,e),href:n,children:"Sign In"})};var sm=e.i(705301),sb=e.i(967489);function sw({className:e}){let t=(0,S.usePathname)(),s=(0,S.useRouter)(),r=(0,sm.useLocale)();return(0,j.jsxs)(sb.Select,{defaultValue:r,onValueChange:e=>{s.replace(t,{locale:e})},children:[(0,j.jsx)(sb.SelectTrigger,{className:(0,k.cn)("w-[100px]",e),children:(0,j.jsx)(sb.SelectValue,{placeholder:"ðºð¸ EN"})}),(0,j.jsx)(sb.SelectContent,{children:(0,j.jsxs)(sb.SelectGroup,{children:[(0,j.jsx)(sb.SelectItem,{value:"en",children:"ðºð¸ EN"}),(0,j.jsx)(sb.SelectItem,{value:"fr",children:"ð«ð· FR"}),(0,j.jsx)(sb.SelectItem,{value:"es",children:"ðªð¸ ES"}),(0,j.jsx)(sb.SelectItem,{value:"ko",children:"ð°ð· KO"}),(0,j.jsx)(sb.SelectItem,{value:"pt",children:"ðµð¹ PT"}),(0,j.jsx)(sb.SelectItem,{value:"ja",children:"ð¯ðµ JA"}),(0,j.jsx)(sb.SelectItem,{value:"zh",children:"ð¨ð³ ZH"}),(0,j.jsx)(sb.SelectItem,{value:"de",children:"ð©ðª DE"}),(0,j.jsx)(sb.SelectItem,{value:"ar",children:"ð¸ð¦ AR"}),(0,j.jsx)(sb.SelectItem,{value:"hi",children:"ð¨ð® HI"}),(0,j.jsx)(sb.SelectItem,{value:"nl",children:"ð³ð± NL"}),(0,j.jsx)(sb.SelectItem,{value:"tr",children:"ð¹ð· TR"}),(0,j.jsx)(sb.SelectItem,{value:"th",children:"ð¹ð TH"}),(0,j.jsx)(sb.SelectItem,{value:"ru",children:"ð·ðº RU"})]})})]})}var sv=e.i(710975),sy=e.i(665698),sx=e.i(90235);let s_="freeCredits:lastSeen",sj="2026-05-26-checkin";function sk({className:e,bellSlot:t}){let s=(0,N.usePathname)(),{isCollapsed:r,setIsCollapsed:i}=(0,H.useSidebar)(),[a,n]=(0,T.useState)(!1),[o,l]=(0,T.useState)(!1),[c,h]=(0,T.useState)(!1),[u,d]=(0,T.useState)(!1),[f,p]=(0,T.useState)(!1),g=(0,sv.useTranslations)("sidebar"),m="[email protected]",b=(0,T.useRef)(null);(0,T.useEffect)(()=>{p(function(){try{return localStorage.getItem(s_)}catch{return null}}()!==sj)},[]),(0,T.useEffect)(()=>{n(!1)},[s]),(0,T.useEffect)(()=>{let e=()=>{window.innerWidth>=1024&&n(!1)};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let w=[{name:g("mainNav.home"),href:"/",icon:E.Home},{name:g("mainNav.create"),href:"/create",icon:C.Music},{name:g("mainNav.library"),href:"/library",icon:A.default}],v=[{name:g("features.vocalRemover"),href:"/vocal-remover",icon:P.Mic2},{name:g("features.aiCover"),href:"/ai-song-cover-generator",icon:O.default},{name:g("features.aiMusicEditor"),href:"/ai-music-editor",icon:I.FileAudio},{name:g("features.voiceChanger"),href:"/ai-singing-voice-generator",icon:P.Mic2}],y=[{name:g("features.aiImageGenerator"),href:"/ai-image-generator",icon:$.default},{name:g("features.aiSingingVideo"),href:"/ai-singing-video-generator",icon:R.Video}],x=[{name:g("other.freeTools"),href:"#free-tools",icon:U.default,isDialog:!0,dialogType:"freeTools"},{name:g("other.pricing"),href:"/pricing",icon:D.DollarSign},{name:g("other.blog"),href:"/blog",icon:K.default},{name:g("other.refer"),href:"/refer",icon:L.Gift,isNew:!0},{name:g("other.contact"),href:"#contact",icon:z.Mail,isDialog:!0,dialogType:"contact"}],_=e=>"/"===e?"/"===s||"/en"===s||"/zh"===s:s.includes(e),W=async()=>{try{await navigator.clipboard.writeText(m),sx.toast.success(g("contactDialog.emailCopied"))}
11catch(e){sx.toast.error(g("contactDialog.emailCopyFailed"))}},V=()=>{try{localStorage.setItem(s_,sj)}catch{}p(!1)};return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)("button",{onClick:()=>n(!0),className:"fixed top-4 start-4 z-50 lg:hidden h-11 w-11 rounded-xl border border-white/15 bg-zinc-950/80 text-white backdrop-blur-md hover:bg-zinc-900 transition-all shadow-[0_12px_32px_rgba(0,0,0,0.35)] flex items-center justify-center",children:(0,j.jsx)(q.default,{className:"w-5 h-5"})}),a&&(0,j.jsx)("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-40 lg:hidden",onClick:()=>n(!1)}),(0,j.jsx)("aside",{className:(0,k.cn)("fixed start-0 top-0 z-50 h-screen bg-gradient-to-b from-[#0a0a0a] via-[#1a1a1a] to-[#0a0a0a] text-white transition-all duration-300 border-e border-gray-800/50 shadow-2xl","hidden lg:block",r?"lg:w-16":"lg:w-64",a&&"block w-64",e),children:(0,j.jsxs)("div",{ref:b,onWheel:e=>{let t=b.current;if(!t)return;let{scrollTop:s,scrollHeight:r,clientHeight:i}=t,a=e.deltaY>0;e.deltaY<0&&0===s||a&&s+i>=r||e.stopPropagation()},className:"flex h-full flex-col relative overflow-y-auto",children:[(0,j.jsx)("div",{className:"absolute inset-0 bg-gradient-to-br from-brand-start/5 via-transparent to-brand-end/5 pointer-events-none"}),(0,j.jsxs)("div",{className:"relative flex items-center justify-between p-5 bg-black/20 backdrop-blur-sm flex-shrink-0",children:[!r&&(0,j.jsxs)(S.Link,{href:"/",className:"flex items-center gap-3 group",children:[(0,j.jsx)("img",{src:"/logo.png",alt:"nafy.ai Logo",width:36,height:36,className:"w-9 h-9 flex-shrink-0"}),(0,j.jsx)("span",{className:"font-bold text-base bg-gradient-to-r from-white to-gray-300 bg-clip-text text-transparent",children:"nafy.ai"})]}),!r&&(0,j.jsx)("button",{onClick:()=>i(!r),className:"hidden lg:block p-2 rounded-lg hover:bg-white/10 transition-all hover:scale-110",children:(0,j.jsx)(M.ChevronLeft,{className:"w-4 h-4 text-gray-400 rtl:rotate-180"})}),r&&(0,j.jsx)("button",{onClick:()=>i(!r),className:"hidden lg:block mx-auto p-2 rounded-lg hover:bg-white/10 transition-all",children:(0,j.jsx)(M.ChevronLeft,{className:"w-4 h-4 text-gray-400 rotate-180 rtl:rotate-0"})}),(0,j.jsx)("button",{onClick:()=>n(!1),className:"lg:hidden p-2 rounded-lg hover:bg-white/10 transition-colors",children:(0,j.jsx)(F.X,{className:"w-5 h-5"})})]}),(0,j.jsxs)("nav",{className:"relative flex-1 px-4 py-4",children:[(0,j.jsx)("div",{className:"space-y-1",children:w.map(e=>{let t=e.icon,s=_(e.href);return(0,j.jsxs)(S.Link,{href:e.href,title:r?e.name:void 0,className:(0,k.cn)("group relative flex items-center gap-3 rounded-xl transition-all duration-200",r?"px-3 py-2.5 justify-center":"px-4 py-2.5",s?"bg-white/10 text-white font-medium border border-white/20":"text-gray-400 hover:bg-white/5 hover:text-gray-200"),children:[s&&!r&&(0,j.jsx)("div",{className:"absolute start-0 w-1 h-8 bg-gradient-to-b from-brand-start to-brand-end rounded-e-full"}),(0,j.jsx)(t,{className:(0,k.cn)("w-4 h-4 flex-shrink-0 transition-transform group-hover:scale-110",s&&"text-brand-start")}),!r&&(0,j.jsx)("span",{className:"text-sm font-medium",children:e.name})]},e.href)})}),(0,j.jsxs)("div",{className:"mt-5",children:[!r&&(0,j.jsxs)("div",{className:"px-4 mb-2 flex items-center gap-2",children:[(0,j.jsx)("div",{className:"h-px flex-1 bg-gradient-to-r from-transparent via-gray-700 to-transparent"}),(0,j.jsx)("span",{className:"text-xs font-bold text-gray-400 uppercase tracking-wider",children:g("features.musicTitle")}),(0,j.jsx)("div",{className:"h-px flex-1 bg-gradient-to-r from-transparent via-gray-700 to-transparent"})]}),(0,j.jsx)("div",{className:(0,k.cn)("space-y-1",r&&"flex flex-col items-center gap-3 space-y-0"),children:v.map(e=>{let t=e.icon,s=_(e.href),i="disabled"in e&&e.disabled;return r?i?(0,j.jsx)("div",{title:e.name,className:"w-10 h-10 flex items-center justify-center rounded-xl text-gray-600 opacity-40 cursor-not-allowed border border-white/5",children:(0,j.jsx)(t,{className:"w-4 h-4"})},e.href):(0,j.jsx)(S.Link,{href:e.href,title:e.name,className:(0,k.cn)("w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-200 border border-transparent text-gray-400 hover:bg-white/5 hover:text-white",s&&"bg-white/10 text-white border-white/20"),children:(0,j.jsx)(t,{className:"w-4 h-4"})},e.href):i?(0,j.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 rounded-lg text-gray-600 cursor-not-allowed opacity-40 relative",children:[(0,j.jsx)(t,{className:"w-4 h-4 flex-shrink-0"}),(0,j.jsx)("span",{className:"text-sm",children:e.name}),(0,j.jsx)("span",{className:"ms-auto text-xs bg-gray-800 px-1.5 py-0.5 rounded-full",children:g("freeToolsDialog.comingSoon")})]},e.href):(0,j.jsxs)(S.Link,{href:e.href,className:(0,k.cn)("group relative flex items-center gap-3 px-4 py-2.5 rounded-xl transition-all duration-200",s?"bg-white/10 text-white font-medium border border-white/20":"text-gray-400 hover:bg-white/5 hover:text-gray-200"),children:[s&&(0,j.jsx)("div",{className:"absolute start-0 w-1 h-8 bg-gradient-to-b from-brand-start to-brand-end rounded-e-full"}),(0,j.jsx)(t,{className:(0,k.cn)("w-4 h-4 flex-shrink-0 transition-transform group-hover:scale-110",s&&"text-brand-start")}),(0,j.jsx)("span",{className:"text-sm font-medium",children:e.name})]},e.href)})})]}),(0,j.jsxs)("div",{className:"mt-5",children:[!r&&(0,j.jsxs)("div",{className:"px-4 mb-2 flex items-center gap-2",children:[(0,j.jsx)("div",{className:"h-px flex-1 bg-gradient-to-r from-transparent via-gray-700 to-transparent"}),(0,j.jsx)("span",{className:"text-xs font-bold text-gray-400 uppercase tracking-wider",children:g("features.imageVideoTitle")}),(0,j.jsx)("div",{className:"h-px flex-1 bg-gradient-to-r from-transparent via-gray-700 to-transparent"})]}),(0,j.jsx)("div",{className:(0,k.cn)("space-y-1",r&&"flex flex-col items-center gap-3 space-y-0"),children:y.map(e=>{let t=e.icon,s=_(e.href);return r?(0,j.jsx)(S.Link,{href:e.href,title:e.name,className:(0,k.cn)("w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-200 border border-transparent text-gray-400 hover:bg-white/5 hover:text-white",s&&"bg-white/10 text-white border-white/20"),children:(0,j.jsx)(t,{className:"w-4 h-4"})},e.href):(0,j.jsxs)(S.Link,{href:e.href,className:(0,k.cn)("group relative flex items-center gap-3 px-4 py-2.5 rounded-xl transition-all duration-200",s?"bg-white/10 text-white font-medium border border-white/20":"text-gray-400 hover:bg-white/5 hover:text-gray-200"),children:[s&&(0,j.jsx)("div",{className:"absolute start-0 w-1 h-8 bg-gradient-to-b from-brand-start to-brand-end rounded-e-full"}),(0,j.jsx)(t,{className:(0,k.cn)("w-4 h-4 flex-shrink-0 transition-transform group-hover:scale-110",s&&"text-brand-start")}),(0,j.jsx)("span",{className:"text-sm font-medium",children:e.name})]},e.href)})})]}),(0,j.jsxs)("div",{className:"mt-5 mb-2",children:[!r&&(0,j.jsxs)("div",{className:"px-4 mb-2 flex items-center gap-2",children:[(0,j.jsx)("div",{className:"h-px flex-1 bg-gradient-to-r from-transparent via-gray-700 to-transparent"}),(0,j.jsx)("span",{className:"text-xs font-bold text-gray-400 uppercase tracking-wider",children:g("other.title")}),(0,j.jsx)("div",{className:"h-px flex-1 bg-gradient-to-r from-transparent via-gray-700 to-transparent"})]}),(0,j.jsxs)("div",{className:(0,k.cn)("space-y-1",r&&"flex flex-col items-center gap-3 space-y-0"),children:[x.map(e=>{let t=e.icon,s=_(e.href),i="disabled"in e&&e.disabled,a="isDialog"in e&&e.
11isDialog,n="isNew"in e&&e.isNew&&f;if(r){if(i)return(0,j.jsx)("div",{title:e.name,className:"w-10 h-10 flex items-center justify-center rounded-xl text-gray-600 opacity-40 cursor-not-allowed border border-white/5",children:(0,j.jsx)(t,{className:"w-4 h-4"})},e.href);if(a){let s="dialogType"in e?e.dialogType:"freeTools";return(0,j.jsx)("button",{title:e.name,onClick:()=>{"freeTools"===s?l(!0):"contact"===s&&d(!0)},className:"w-10 h-10 flex items-center justify-center rounded-xl transition-all text-gray-400 hover:bg-white/5 hover:text-white border border-transparent",children:(0,j.jsx)(t,{className:"w-4 h-4"})},e.href)}return(0,j.jsx)(S.Link,{href:e.href,title:e.name,onClick:n?V:void 0,className:(0,k.cn)("relative w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-200 border border-transparent text-gray-400 hover:bg-white/5 hover:text-white",s&&"bg-white/10 text-white border-white/20"),children:(0,j.jsxs)("span",{className:"relative",children:[(0,j.jsx)(t,{className:"w-4 h-4"}),n&&(0,j.jsx)("span",{className:"absolute -end-1.5 -top-1.5 h-2 w-2 rounded-full bg-red-500 ring-2 ring-[#141414]"})]})},e.href)}if(i)return(0,j.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 rounded-lg text-gray-600 cursor-not-allowed opacity-40",children:[(0,j.jsx)(t,{className:"w-4 h-4 flex-shrink-0"}),(0,j.jsx)("span",{className:"text-sm",children:e.name}),(0,j.jsx)("span",{className:"ms-auto text-xs bg-gray-800 px-1.5 py-0.5 rounded-full",children:g("freeToolsDialog.comingSoon")})]},e.href);if(a){let s="dialogType"in e?e.dialogType:"freeTools";return(0,j.jsxs)("button",{onClick:()=>{"freeTools"===s?l(!0):"contact"===s&&d(!0)},className:(0,k.cn)("group flex items-center gap-3 px-4 py-2 rounded-lg transition-all duration-200 w-full text-left","text-gray-400 hover:bg-white/5 hover:text-white"),children:[(0,j.jsx)(t,{className:"w-4 h-4 flex-shrink-0 group-hover:scale-110 transition-transform"}),(0,j.jsx)("span",{className:"text-sm",children:e.name})]},e.href)}return(0,j.jsxs)(S.Link,{href:e.href,onClick:n?V:void 0,className:(0,k.cn)("group relative flex items-center gap-3 px-4 py-2.5 rounded-xl transition-all duration-200",s?"bg-white/10 text-white font-medium border border-white/20":"text-gray-400 hover:bg-white/5 hover:text-gray-200"),children:[s&&(0,j.jsx)("div",{className:"absolute start-0 w-1 h-8 bg-gradient-to-b from-brand-start to-brand-end rounded-e-full"}),(0,j.jsxs)("span",{className:"relative flex-shrink-0",children:[(0,j.jsx)(t,{className:(0,k.cn)("w-4 h-4 transition-transform group-hover:scale-110",s&&"text-brand-start")}),n&&(0,j.jsx)("span",{className:"absolute -end-1.5 -top-1.5 h-2 w-2 rounded-full bg-red-500 ring-2 ring-[#191919]"})]}),(0,j.jsx)("span",{className:"text-sm font-medium",children:e.name})]},e.href)}),t]})]})]}),(0,j.jsxs)("div",{className:"relative bg-black/20 backdrop-blur-sm flex-shrink-0",children:[!r&&(0,j.jsx)("div",{className:"p-4 space-y-3",children:(0,j.jsxs)("div",{className:"grid grid-cols-2 items-center gap-3",children:[(0,j.jsx)("div",{className:"min-w-0",children:(0,j.jsx)(sw,{className:"w-full"})}),(0,j.jsx)("div",{className:"min-w-0",children:(0,j.jsx)(sg,{className:"w-full",buttonClassName:"w-full justify-start min-w-0 mr-0"})})]})}),(0,j.jsx)("div",{className:"p-4 pt-0 pb-5",children:r?(0,j.jsx)(J.Button,{onClick:()=>h(!0),size:"icon",className:"w-full aspect-square bg-gradient-to-br from-brand-start to-brand-end hover:opacity-90 text-white shadow-lg shadow-brand-start/30 hover:shadow-brand-start/50 transition-all hover:scale-105",title:g("upgrade"),children:(0,j.jsx)(B.Crown,{className:"w-5 h-5"})}):(0,j.jsxs)(J.Button,{onClick:()=>h(!0),className:"relative w-full bg-gradient-to-r from-brand-start to-brand-end hover:opacity-90 text-white font-bold py-6 rounded-xl shadow-lg shadow-brand-start/40 hover:shadow-brand-start/60 transition-all overflow-hidden group",children:[(0,j.jsx)("div",{className:"absolute inset-0 bg-gradient-to-r from-white/0 via-white/20 to-white/0 translate-x-[-100%] group-hover:translate-x-[100%] transition-transform duration-1000"}),(0,j.jsx)(B.Crown,{className:"w-5 h-5 me-2 relative z-10"}),(0,j.jsx)("span",{className:"relative z-10",children:g("upgrade")})]})})]})]})}),(0,j.jsx)(sl.Dialog,{open:o,onOpenChange:l,children:(0,j.jsxs)(sl.DialogContent,{className:"sm:max-w-3xl max-h-[80vh] overflow-y-auto",children:[(0,j.jsxs)(sl.DialogHeader,{className:"pb-1",children:[(0,j.jsx)(sl.DialogTitle,{children:g("freeToolsDialog.title")}),(0,j.jsx)(sl.DialogDescription,{children:g("freeToolsDialog.description")})]}),(0,j.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 py-4",children:[(0,j.jsxs)(S.Link,{href:"/lyrics-generator",onClick:()=>l(!1),className:"group relative p-6 rounded-xl bg-gradient-to-br from-white/5 to-white/[0.02] border border-white/10 hover:border-brand-start/50 transition-all duration-300 hover:shadow-lg hover:shadow-brand-start/20 flex flex-col",children:[(0,j.jsxs)("div",{className:"flex items-center gap-3 mb-3",children:[(0,j.jsx)("div",{className:"p-2.5 rounded-lg bg-gradient-to-br from-brand-start/20 to-brand-end/20 group-hover:from-brand-start/30 group-hover:to-brand-end/30 transition-all",children:(0,j.jsx)(C.Music,{className:"w-5 h-5 text-brand-start"})}),(0,j.jsx)("h3",{className:"font-semibold text-white group-hover:text-brand-start transition-colors",children:g("freeToolsDialog.tools.lyricsGenerator.title")})]}),(0,j.jsx)("p",{className:"text-sm text-gray-400 leading-relaxed",children:g("freeToolsDialog.tools.lyricsGenerator.description")})]}),(0,j.jsxs)(S.Link,{href:"/midi-editor",onClick:()=>l(!1),className:"group relative p-6 rounded-xl bg-gradient-to-br from-white/5 to-white/[0.02] border border-white/10 hover:border-brand-start/50 transition-all duration-300 hover:shadow-lg hover:shadow-brand-start/20 flex flex-col",children:[(0,j.jsxs)("div",{className:"flex items-center gap-3 mb-3",children:[(0,j.jsx)("div",{className:"p-2.5 rounded-lg bg-gradient-to-br from-brand-start/20 to-brand-end/20 group-hover:from-brand-start/30 group-hover:to-brand-end/30 transition-all",children:(0,j.jsx)(I.FileAudio,{className:"w-5 h-5 text-brand-start"})}),(0,j.jsx)("h3",{className:"font-semibold text-white group-hover:text-brand-start transition-colors",children:g("freeToolsDialog.tools.midiEditor.title")})]}),(0,j.jsx)("p",{className:"text-sm text-gray-400 leading-relaxed",children:g("freeToolsDialog.tools.midiEditor.description")})]}),(0,j.jsxs)(S.Link,{href:"/audio-to-midi",onClick:()=>l(!1),className:"group relative p-6 rounded-xl bg-gradient-to-br from-white/5 to-white/[0.02] border border-white/10 hover:border-brand-start/50 transition-all duration-300 hover:shadow-lg hover:shadow-brand-start/20 flex flex-col",children:[(0,j.jsxs)("div",{className:"flex items-center gap-3 mb-3",children:[(0,j.jsx)("div",{className:"p-2.5 rounded-lg bg-gradient-to-br from-brand-start/20 to-brand-end/20 group-hover:from-brand-start/30 group-hover:to-brand-end/30 transition-all",children:(0,j.jsx)(I.FileAudio,{className:"w-5 h-5 text-brand-start"})}),(0,j.jsx)("h3",{className:"font-semibold text-white group-hover:text-brand-start transition-colors",children:g("freeToolsDialog.tools.audioToMidi.title")})]}),(0,j.jsx)("p",{className:"text-sm text-gray-400 leading-relaxed",children:g("freeToolsDialog.tools.audioToMidi.description")})]})]})]})}),(0,j.jsx)(sy.PricingDialog,{isOpen:c,onClose:()=>h(!1)}),(0,j.jsx)(sl.Dialog,{open:u,onOpenChange:d,children:(0,j.jsxs)(sl.DialogContent,{className:"sm:max-w-md bg-gradient-to-b from-[#0a0a0a] to-[#1a1a1a] border-gray-800",children:[(0,j.jsxs)(sl.DialogHeader,{children:[(0,j.jsx)(sl.DialogTitle,{className:"text-2xl font-bold bg-gradient-to-r from-brand-start to-brand-end bg-clip-text text-transparent",children:g("contactDialog.title")}),(0,j.jsx)(sl.DialogDescription,{className:"text-gray-400",children:g("contactDialog.description")})]}),(0,j.jsxs)("div",{className:"space-y-6 py-4",children:[(0,j.jsxs)("div",{className:"p-4 rounded-xl bg-gradient-to-br from-green-500/10 to-emerald-500/10 border border-green-500/20",children:[(0,j.jsxs)("h3",{className:"font-semibold text-white mb-2 flex items-center gap-2",children:[(0,j.jsx)("span",{className:"text-green-400",children:"â¨"}),g("contactDialog.likeIt.title")]}),(0,j.jsx)("p",{className:"text-sm text-gray-400 mb-3",children:g("contactDialog.likeIt.description")}),(0,j.jsx)("div",{className:"space-y-2",children:(0,j.jsxs)("a",{href:"https://www.trustpilot.com/review/nafy.ai",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-white/5 hover:bg-white/10 border border-white/10 hover:border-green-500/30 transition-all text-sm text-white group",children:[(0,j.jsx)("span",{className:"group-hover:scale-110 transition-transform",children:"â"}),(0,j.jsx)("span",{children:g("contactDialog.likeIt.trustpilot")})]})})]}),(0,j.jsxs)("div",{className:"p-4 rounded-xl bg-gradient-to-br from-blue-500/10 to-cyan-500/10 border border-blue-500/20",children:[(0,j.jsxs)("h3",{className:"font-semibold text-white mb-2 flex items-center gap-2",children:[(0,j.jsx)(z.Mail,{className:"w-4 h-4 text-blue-400"}),g("contactDialog.needHelp.title")]}),(0,j.jsx)("p",{className:"text-sm text-gray-400 mb-3",children:g("contactDialog.needHelp.description")}),(0,j.jsxs)("button",{type:"button",onClick:W,className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-gradient-to-r from-brand-start to-brand-end hover:opacity-90 text-white font-medium transition-all shadow-lg shadow-brand-start/20 hover:shadow-brand-start/40",children:[(0,j.jsx)(z.Mail,{className:"w-4 h-4"}),m]})]})]})]})})]})}e.s(["Sidebar",()=>
11sk],129014)},300823,e=>{"use strict";var t=e.i(368058),s=e.i(201234),r=e.i(121779),i=e.i(978237),a=e.i(477722),a=a,n=e.i(570785),n=n,o=e.i(119959),o=o,l=e.i(638009),c=e.i(471677),h=e.i(943492),u=e.i(377464),u=u,d=e.i(946318),d=d,f=e.i(278834),f=f,p=e.i(166075),g=e.i(283713),m=e.i(595644),b=e.i(15034),w=e.i(986842),v=e.i(355995),y=e.i(710975),x=e.i(784329),_=e.i(519455),j=e.i(776639),k=e.i(759684),S=e.i(367692),N=e.i(617029),T=e.i(228271),E=e.i(975157),C=e.i(419546),A=e.i(129911);let P=["sequence","shuffle","repeat-one"];function O(e){if(!Number.isFinite(e))return"0:00";let t=Math.floor(e/60),s=Math.floor(e%60);return`${t}:${s.toString().padStart(2,"0")}`}function I(e,t=0){return e?.title||`Track ${t+1}`}function $(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function R({className:e,player:s}){let r="sequence"===s.playbackMode?"Sequential play":"shuffle"===s.playbackMode?"Shuffle play":"Repeat one",i="sequence"===s.playbackMode?u.default:"shuffle"===s.playbackMode?f.default:d.default;return(0,t.jsx)(_.Button,{variant:"ghost",size:"icon",className:(0,E.cn)("text-white/55 hover:bg-white/8 hover:text-white",e),onClick:function(){let e=P.indexOf(s.playbackMode);s.setPlaybackMode(P[(e+1)%P.length])},"aria-label":r,title:r,children:(0,t.jsx)(i,{className:"h-3.5 w-3.5"})})}function U({isLarge:e=!1,onOpenQueue:s,pauseLabel:r,playLabel:i,queueLabel:n,player:o}){return(0,t.jsxs)("div",{className:"flex items-center justify-center gap-1.5",children:[(0,t.jsx)(R,{player:o,className:e?"h-9 w-9":"h-6 w-6"}),(0,t.jsx)(_.Button,{variant:"ghost",size:"icon",className:(0,E.cn)("rounded-full text-white/75 hover:bg-white/8 hover:text-white",e?"h-10 w-10":"h-6 w-6"),onClick:o.playPrevious,"aria-label":"Previous track",children:(0,t.jsx)(p.SkipBack,{className:e?"h-5 w-5 fill-current":"h-3.5 w-3.5 fill-current"})}),(0,t.jsx)(_.Button,{size:"icon",className:(0,E.cn)("rounded-full bg-white text-zinc-950 shadow-[0_8px_30px_rgba(0,0,0,.28)] hover:scale-[1.04] hover:bg-zinc-100",e?"h-12 w-12":"h-8 w-8"),onClick:o.togglePlay,"aria-label":o.isPlaying?r:i,children:o.isPlaying?(0,t.jsx)(c.Pause,{className:(0,E.cn)("fill-current",e?"h-5 w-5":"h-3.5 w-3.5")}):(0,t.jsx)(h.Play,{className:(0,E.cn)("ml-0.5 fill-current",e?"h-5 w-5":"h-3.5 w-3.5")})}),(0,t.jsx)(_.Button,{variant:"ghost",size:"icon",className:(0,E.cn)("rounded-full text-white/75 hover:bg-white/8 hover:text-white",e?"h-10 w-10":"h-6 w-6"),onClick:o.playNext,"aria-label":"Next track",children:(0,t.jsx)(g.SkipForward,{className:e?"h-5 w-5 fill-current":"h-3.5 w-3.5 fill-current"})}),(0,t.jsxs)(_.Button,{variant:"ghost",size:"icon",className:(0,E.cn)("text-white/55 hover:bg-white/8 hover:text-white",e?"h-9 w-9":"h-6 w-6"),onClick:s,"aria-label":n,title:n,children:[(0,t.jsx)(a.default,{className:"h-3.5 w-3.5"}),o.playlist.length>1&&(0,t.jsx)("span",{className:"absolute ml-5 -mt-5 min-w-4 rounded-full bg-violet-500 px-1 text-[9px] font-semibold text-white",children:o.playlist.length})]})]})}function D({isLarge:e=!1,seekTo:s}){let{currentTime:r,duration:i}=(0,T.usePlayerProgress)();return(0,t.jsxs)("div",{className:(0,E.cn)("flex w-full items-center gap-3",e&&"gap-4"),children:[(0,t.jsx)("span",{className:"w-10 text-right text-[11px] tabular-nums text-white/55",children:O(r)}),(0,t.jsx)(S.Slider,{className:(0,E.cn)("group flex-1 [&_[role=slider]]:h-3 [&_[role=slider]]:w-3 [&_[role=slider]]:border-0 [&_[role=slider]]:bg-white",e&&"[&_[role=slider]]:h-4 [&_[role=slider]]:w-4"),value:[Math.min(r,i||0)],max:i||1,step:.1,onValueChange:e=>s(e[0]),"aria-label":"Track progress"}),(0,t.jsx)("span",{className:"w-10 text-[11px] tabular-nums text-white/55",children:O(i)})]})}function L(){let e=(0,y.useTranslations)("player"),{isCollapsed:a}=(0,N.useSidebar)(),[c,u]=(0,s.useState)(!1),[d,f]=(0,s.useState)(!1),[p,g]=(0,s.useState)(!1),P=(0,s.useRef)(null),R=(0,s.useRef)(null),L=(0,s.useRef)(null),M=(0,T.useMusicPlayer)();if((0,s.useEffect)(()=>{if(!M.isVisible||c)return void document.documentElement.style.setProperty("--music-player-inset","0px");let e=L.current;if(!e)return;function t(){let t=Math.ceil(e.getBoundingClientRect().height);document.documentElement.style.setProperty("--music-player-inset",`${t}px`)}t();let s=new ResizeObserver(t);return s.observe(e),()=>{s.disconnect(),document.documentElement.style.setProperty("--music-player-inset","0px")}},[c,M.isVisible]),(0,s.useEffect)(()=>
11{if(!d)return;let e=requestAnimationFrame(()=>{let e=P.current?.querySelector("[data-radix-scroll-area-viewport]"),t=R.current;if(!e||!t)return;let s=e.getBoundingClientRect(),r=t.getBoundingClientRect();e.scrollTop+=r.top-s.top-(e.clientHeight-r.height)/2});return()=>cancelAnimationFrame(e)},[d,M.currentTrackIndex]),!M.isVisible||!M.audioUrl)return null;let B=M.playlist[M.currentTrackIndex];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:(0,E.cn)("fixed bottom-0 start-0 end-0 z-40 transition-[inset-inline-start] duration-300",a?"lg:start-16":"lg:start-64",c&&"pointer-events-none"),children:[(0,t.jsx)(_.Button,{variant:"ghost",size:"icon",className:(0,E.cn)("pointer-events-auto fixed bottom-3 end-3 h-10 w-10 rounded-full border border-white/10 bg-zinc-900 p-0 text-white shadow-2xl transition-all duration-300 hover:bg-zinc-800",c?"translate-y-0 opacity-100":"translate-y-8 opacity-0 pointer-events-none"),onClick:()=>u(!1),"aria-label":e("expand"),children:(0,t.jsx)(i.ChevronUp,{className:"h-4 w-4"})}),(0,t.jsx)("div",{ref:L,className:(0,E.cn)("relative border-t border-white/10 bg-[#292929] px-4 pb-[max(6px,env(safe-area-inset-bottom))] pt-1.5 text-white shadow-[0_-18px_50px_rgba(0,0,0,.35)] transition-all duration-300 ease-out",c?"translate-y-full opacity-0":"translate-y-0 opacity-100"),children:(0,t.jsxs)("div",{className:"mx-auto grid max-w-[1500px] items-center gap-x-6 gap-y-2 md:grid-cols-[minmax(190px,1fr)_minmax(320px,2fr)_minmax(190px,1fr)]",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,t.jsx)("img",{src:B?.coverUrl||x.DEFAULT_MUSIC_COVER,alt:"",className:"h-9 w-9 shrink-0 rounded-lg object-cover ring-1 ring-white/10"}),(0,t.jsx)("div",{className:"min-w-0",children:(0,t.jsx)("p",{className:"truncate text-sm font-semibold text-white",children:I(B,M.currentTrackIndex)})})]}),(0,t.jsxs)("div",{className:"order-3 flex min-w-0 flex-col gap-1.5 md:order-none",children:[(0,t.jsx)(U,{player:M,playLabel:e("play"),pauseLabel:e("pause"),queueLabel:e("openQueue"),onOpenQueue:()=>f(!0)}),(0,t.jsx)(D,{seekTo:M.seekTo})]}),(0,t.jsxs)("div",{className:"absolute right-3 top-3 flex items-center gap-1 md:static md:justify-end",children:[(0,t.jsx)(_.Button,{variant:"ghost",size:"icon",className:"hidden h-9 w-9 text-white/55 hover:bg-white/8 hover:text-white sm:inline-flex",onClick:()=>M.setVolume(+(0===M.volume)),"aria-label":0===M.volume?e("unmute"):e("mute"),children:0===M.volume?(0,t.jsx)(w.VolumeX,{className:"h-4 w-4"}):(0,t.jsx)(b.Volume2,{className:"h-4 w-4"})}),(0,t.jsx)(S.Slider,{className:"hidden w-20 sm:flex lg:w-28 [&_[role=slider]]:h-3 [&_[role=slider]]:w-3",value:[M.volume],max:1,step:.01,onValueChange:e=>M.setVolume(e[0]),"aria-label":e("volume")}),(0,t.jsx)(_.Button,{variant:"ghost",size:"icon",className:"h-9 w-9 text-white/55 hover:bg-white/8 hover:text-white",onClick:()=>g(!0),"aria-label":"Open fullscreen player",children:(0,t.jsx)(n.default,{className:"h-4 w-4"})}),(0,t.jsx)(_.Button,{variant:"ghost",size:"icon",className:"h-9 w-9 text-white/40 hover:bg-white/8 hover:text-white",onClick:()=>u(!0),"aria-label":e("collapse"),children:(0,t.jsx)(r.ChevronDown,{className:"h-4 w-4"})}),(0,t.jsx)(_.Button,{variant:"ghost",size:"icon",className:"h-9 w-9 text-white/40 hover:bg-white/8 hover:text-white",onClick:M.hidePlayer,"aria-label":e("close"),children:(0,t.jsx)(v.X,{className:"h-4 w-4"})})]})]})})]}),(0,t.jsx)(j.Dialog,{open:d,onOpenChange:f,children:(0,t.jsxs)(j.DialogContent,{className:"flex h-[min(80dvh,720px)] max-w-xl flex-col gap-0 overflow-hidden p-0",children:[(0,t.jsxs)(j.DialogHeader,{className:"border-b border-white/8 px-6 pb-5 pt-6",children:[(0,t.jsx)(j.DialogTitle,{className:"pr-8 text-xl",children:e("queueTitle")}),(0,t.jsx)(j.DialogDescription,{className:"mt-1",children:e("queueDescription",{count:M.playlist.length})})]}),(0,t.jsx)(k.ScrollArea,{ref:P,className:"min-h-0 flex-1",children:(0,t.jsx)("div",{className:"space-y-1 p-3",children:M.playlist.map((s,r)=>{var i,a;let n=r===M.currentTrackIndex;return(0,t.jsxs)("div",{ref:n?R:void 0,className:(0,E.cn)("group flex items-center gap-3 rounded-2xl px-3 py-2.5 transition-colors",n?"bg-violet-500/12":"hover:bg-white/5"),children:[(0,t.jsxs)("button",{className:"relative shrink-0 overflow-hidden rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-400",onClick:()=>M.playAudio(s),"aria-label":`Play ${I(s,r)}`,children:[(0,t.jsx)("img",{src:s.coverUrl||x.DEFAULT_MUSIC_COVER,alt:"",className:"h-11 w-11 object-cover"}),(0,t.jsx)("span",{className:(0,E.cn)("absolute inset-0 grid place-items-center bg-black/45 transition-opacity",n?"opacity-100":"opacity-0 group-hover:opacity-100"),children:n&&M.isPlaying?(0,t.jsx)(l.Music2,{className:"h-4 w-4 text-violet-300"}):(0,t.jsx)(h.Play,{className:"h-4 w-4 fill-white text-white"})}),(0,t.jsx)("span",{className:"absolute bottom-0.5 right-1 z-10 text-[10px] font-medium tabular-nums text-white drop-shadow-[0_1px_2px_rgba(0,0,0,.9)]",children:"number"==typeof s.duration?O(s.duration):"--:--"})]}),(0,t.jsxs)("button",{className:"min-w-0 flex-1 text-left",onClick:()=>M.playAudio(s),children:[(0,t.jsx)("p",{className:(0,E.cn)("truncate text-sm font-medium",n?"text-violet-200":"text-white"),children:I(s,r)}),(0,t.jsx)("p",{className:"mt-0.5 truncate text-xs text-white/40",children:(i=s.createdAt,a=e("unknownDate"),i?i.replace("T"," ").replace(/\.\d{3}Z?$/,"").replace(/Z$/,"").slice(0,19):a)})]}),(0,t.jsx)(_.Button,{variant:"ghost",size:"icon",className:"h-9 w-9 text-white/30 opacity-100 hover:bg-red-500/10 hover:text-red-300 sm:opacity-0 sm:group-hover:opacity-100",onClick:()=>M.removeFromPlaylist(r),"aria-label":e("removeTrack",{title:I(s,r)}),children:(0,t.jsx)(v.X,{className:"h-4 w-4"})})]},`${s.id}-${r}`)})})}),(0,t.jsx)("div",{className:"shrink-0 border-t border-white/8 p-3",children:(0,t.jsxs)(_.Button,{variant:"ghost",className:"h-12 w-full rounded-xl bg-white/[0.04] text-red-300/80 hover:bg-red-500/10 hover:text-red-200",onClick:()=>{M.clearPlaylist(),f(!1)},children:[(0,t.jsx)(m.Trash2,{className:"mr-2 h-4 w-4"}),e("clearAll")]})})]})}),(0,t.jsx)(j.Dialog,{open:p,onOpenChange:g,children:(0,t.jsxs)(j.DialogContent,{className:"h-dvh max-h-none w-screen max-w-none overflow-hidden rounded-none border-0 bg-[oklch(0.105_0.012_260)] p-0 [&>button:last-child]:hidden",children:[(0,t.jsx)("img",{src:B?.coverUrl||x.DEFAULT_MUSIC_COVER,alt:"",decoding:"async",className:"absolute inset-0 h-full w-full scale-110 transform-gpu object-cover opacity-45 blur-[32px] saturate-125"}),(0,t.jsx)("div",{className:"absolute inset-0 bg-[linear-gradient(90deg,oklch(0.08_0.01_260/.72)_0%,oklch(0.1_0.012_260/.54)_45%,oklch(0.08_0.01_260/.72)_100%)]"}),(0,t.jsx)("div",{className:"absolute inset-0 bg-[linear-gradient(180deg,transparent_0%,oklch(0.07_0.008_260/.12)_58%,oklch(0.06_0.008_260/.78)_100%)]"}),(0,t.jsx)(_.Button,{variant:"ghost",size:"icon",className:"absolute right-5 top-5 z-30 h-10 w-10 rounded-full border border-white/10 bg-black/55 text-white/70 hover:bg-black/70 hover:text-white",onClick:()=>g(!1),"aria-label":"Exit fullscreen player",children:(0,t.jsx)(o.default,{className:"h-5 w-5"})}),(0,t.jsxs)("div",{className:"relative z-10 h-[calc(100dvh-82px)] px-5 pt-12 sm:px-10 sm:pt-14 lg:px-16",children:[(0,t.jsxs)("div",{className:"mx-auto grid h-full w-full max-w-[1500px] min-h-0 gap-8 lg:grid-cols-[minmax(300px,.8fr)_minmax(520px,1.3fr)] lg:gap-20",children:[(0,t.jsx)("div",{className:"hidden min-h-0 items-center justify-center pt-16 lg:flex",children:(0,t.jsx)(A.VinylPlayer,{isPlaying:M.isPlaying,onTogglePlay:M.togglePlay,coverUrl:B?.coverUrl,playLabel:e("play"),pauseL
11abel:e("pause"),variant:"fullscreen"})}),(0,t.jsxs)("section",{className:"flex h-full min-h-0 flex-col overflow-hidden pt-3 lg:pt-0","aria-label":"Lyrics",children:[(0,t.jsxs)("div",{className:"mb-5 shrink-0 pr-14",children:[(0,t.jsx)(j.DialogTitle,{className:"truncate text-3xl font-bold tracking-tight text-white sm:text-4xl lg:text-5xl",children:I(B,M.currentTrackIndex)}),$(B?.createdAt)&&(0,t.jsx)(j.DialogDescription,{className:"mt-2 text-sm text-white/45",children:$(B?.createdAt)}),B?.tags&&(0,t.jsx)("div",{className:"mt-4 flex flex-wrap gap-2",children:B.tags.split(",").map(e=>e.trim()).filter(Boolean).slice(0,8).map(e=>(0,t.jsx)("span",{className:"rounded-full bg-white/10 px-3 py-1 text-xs font-medium text-white/65",children:e},e))})]}),(0,t.jsx)(k.ScrollArea,{className:"h-[calc(100dvh-245px)] min-h-0 rounded-2xl border border-white/10 bg-black/20 px-6 py-5 shadow-[0_26px_90px_rgba(0,0,0,.24)] sm:px-8 sm:py-7 lg:px-9",children:B?.lyrics?(0,t.jsx)(C.TimestampedLyrics,{lyrics:B.lyrics,timestamps:B.extra?.lyrics_timestamps,track:B,variant:"fullscreen"}):(0,t.jsxs)("div",{className:"flex h-52 flex-col items-center justify-center text-center",children:[(0,t.jsx)(l.Music2,{className:"h-8 w-8 text-white/15"}),(0,t.jsx)("p",{className:"mt-4 text-sm font-medium text-white/40",children:"No lyrics available for this track"})]})})]})]}),(0,t.jsx)("div",{className:"fixed inset-x-0 bottom-0 z-20 border-t border-white/10 bg-[#292929] px-5 pb-[max(4px,env(safe-area-inset-bottom))] pt-1 sm:px-8",children:(0,t.jsxs)("div",{className:"mx-auto grid max-w-[1500px] items-center gap-3 md:grid-cols-[minmax(180px,1fr)_minmax(360px,2fr)_minmax(180px,1fr)] md:gap-8",children:[(0,t.jsxs)("div",{className:"hidden min-w-0 items-center gap-3 md:flex",children:[(0,t.jsx)("img",{src:B?.coverUrl||x.DEFAULT_MUSIC_COVER,alt:"",className:"h-9 w-9 rounded-md object-cover ring-1 ring-white/10"}),(0,t.jsx)("div",{className:"min-w-0",children:(0,t.jsx)("p",{className:"truncate text-sm font-semibold text-white",children:I(B,M.currentTrackIndex)})})]}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-col",children:[(0,t.jsx)(U,{player:M,playLabel:e("play"),pauseLabel:e("pause"),queueLabel:e("openQueue"),onOpenQueue:()=>f(!0)}),(0,t.jsx)(D,{seekTo:M.seekTo})]}),(0,t.jsxs)("div",{className:"hidden items-center justify-end gap-3 md:flex",children:[(0,t.jsx)(_.Button,{variant:"ghost",size:"icon",className:"h-8 w-8 text-white/55 hover:bg-white/8 hover:text-white",onClick:()=>M.setVolume(+(0===M.volume)),"aria-label":0===M.volume?e("unmute"):e("mute"),children:0===M.volume?(0,t.jsx)(w.VolumeX,{className:"h-4 w-4"}):(0,t.jsx)(b.Volume2,{className:"h-4 w-4"})}),(0,t.jsx)(S.Slider,{className:"w-24 [&_[role=slider]]:h-3 [&_[role=slider]]:w-3",value:[M.volume],max:1,step:.01,onValueChange:e=>M.setVolume(e[0]),"aria-label":e("volume")})]})]})})]})]})})]})}e.s(["MusicPlayer",()=>L,"default",0,L],300823)},136502,e=>{"use strict";var t=e.i(368058),s=e.i(201234),r=e.i(297060),r=r,i=e.i(776639),a=e.i(759684),n=e.i(519455),o=e.i(975157),l=e.i(617029),c=e.i(246377),h=e.i(687386);let u=["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"];function d({entry:e,isLast:r}){let i=function(e){let[t,s,r]=e.split("-").map(Number);return{year:t||"",monthName:s?u[s-1]??"":"",day:r?String(r).padStart(2,"0"):""}}(e.date),[a,n]=(0,s.useState)(null),l=!!e.image,d=!!e.video;return(0,t.jsxs)("div",{className:"relative grid grid-cols-12 gap-4 sm:gap-6 pb-12 last:pb-4",children:[(0,t.jsxs)("div",{className:"sm:hidden absolute left-1 top-2 bottom-0 flex flex-col items-center",children:[(0,t.jsx)("span",{className:"w-2.5 h-2.5 rounded-full bg-brand-start ring-4 ring-brand-start/20"}),!r&&(0,t.jsx)("span",{className:"flex-1 w-px mt-1 bg-gradient-to-b from-brand-start/40 to-brand-start/0"})]}),(0,t.jsxs)("div",{className:"col-span-12 sm:col-span-4 pl-6 sm:pl-0",children:[(0,t.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,t.jsx)("span",{className:"text-sm font-semibold tracking-[0.2em] text-gray-400",children:i.monthName}),(0,t.jsx)("span",{className:"text-4xl sm:text-5xl font-extrabold leading-none text-white",children:i.day})]}),(0,t.jsx)("h3",{className:"mt-4 text-base sm:text-lg font-semibold text-white border-l-2 border-brand-start pl-3 leading-snug",children:e.title}),(0,t.jsx)("div",{className:"mt-3 text-xs font-bold tracking-[0.35em] text-brand-start/90",children:i.year})]}),(0,t.jsxs)("div",{className:"hidden sm:flex sm:col-span-1 relative justify-center",children:[(0,t.jsx)("span",{className:"absolute top-2 w-3 h-3 rounded-full bg-brand-start ring-4 ring-brand-start/20"}),(0,t.jsx)("span",{className:(0,o.cn)("absolute top-5 w-px bg-gradient-to-b from-brand-start/50 via-brand-start/20 to-transparent",r?"h-10":"h-full")})]}),(0,t.jsx)("div",{className:"col-span-12 sm:col-span-7 pl-6 sm:pl-0",children:(0,t.jsxs)("div",{className:"rounded-2xl border border-white/10 bg-white/[0.04] overflow-hidden shadow-lg",children:[l&&d?(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-px bg-white/5",children:[(0,t.jsx)(f,{src:e.image,alt:e.title,onClick:()=>n({type:"image",src:e.image})}),(0,t.jsx)(p,{src:e.video,poster:e.image,alt:e.title,onClick:()=>n({type:"video",src:e.video,poster:e.image})})]}):d?(0,t.jsx)(p,{src:e.video,poster:e.image,alt:e.title,wide:!0,onClick:()=>n({type:"video",src:e.video,poster:e.image})}):l?(0,t.jsx)(f,{src:e.image,alt:e.title,wide:!0,onClick:()=>n({type:"image",src:e.image})}):null,(0,t.jsx)("div",{className:"px-4 sm:px-5 py-4 bg-black/40 backdrop-blur-sm border-t border-white/5 prose prose-invert prose-sm max-w-none text-gray-300/90 leading-relaxed [&_p]:mb-2 [&_p:last-child]:mb-0 [&_a]:text-brand-start [&_a]:font-medium [&_a]:no-underline hover:[&_a]:opacity-80",children:(0,t.jsx)(c.MDXContent,{code:e.body,components:h.mdxComponents})})]})}),(0,t.jsx)(g,{state:a,onClose:()=>n(null)})]})}function f({src:e,alt:s,onClick:r,wide:i}){return(0,t.jsxs)("button",{type:"button",onClick:r,className:(0,o.cn)("group relative block overflow-hidden bg-black",i?"w-full":"w-full aspect-square"),children:[(0,t.jsx)("img",{src:e,alt:s,loading:"lazy",className:(0,o.cn)("w-full block transition-transform duration-500 group-hover:scale-105",i?"h-auto":"h-full object-cover")}),(0,t.jsx)("span",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/15 transition-colors"})]})}function p({src:e,poster:s,alt:r,onClick:i,wide:a}){return(0,t.jsxs)("button",{type:"button",onClick:i,"aria-label":r,className:(0,o.cn)("group relative block overflow-hidden bg-black",a?"w-full aspect-video":"w-full aspect-square"),children:[(0,t.jsx)("video",{src:e,poster:s,autoPlay:!0,muted:!0,loop:!0,playsInl
11ine:!0,preload:"metadata",className:"w-full h-full object-cover block transition-transform duration-500 group-hover:scale-105"}),(0,t.jsx)("span",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/15 transition-colors"})]})}function g({state:e,onClose:s}){return(0,t.jsx)(i.Dialog,{open:!!e,onOpenChange:e=>!e&&s(),children:(0,t.jsxs)(i.DialogContent,{className:"sm:max-w-5xl p-0 overflow-hidden bg-black border-white/10",children:[e?.type==="image"&&(0,t.jsx)("img",{src:e.src,alt:"",className:"w-full h-auto max-h-[85vh] object-contain block mx-auto"}),e?.type==="video"&&(0,t.jsx)("video",{src:e.src,poster:e.poster,controls:!0,autoPlay:!0,playsInline:!0,className:"w-full max-h-[85vh] block mx-auto bg-black"})]})})}let m="changelog:lastSeen";function b({entries:e,latestDate:r,label:l,dialogTitle:c,dialogSubtitle:h,emptyText:u,gotItText:f,operationalText:p}){let[g,b]=(0,s.useState)(!1),[v,y]=(0,s.useState)(!1);function x(e){if(b(e),e&&r){try{localStorage.setItem(m,r)}catch{}y(!1)}}return(0,s.useEffect)(()=>{if(!r)return;let e=function(){try{return localStorage.getItem(m)}catch{return null}}();(!e||e<r)&&y(!0)},[r]),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(w,{label:l,hasUnread:v,onClick:()=>x(!0)}),(0,t.jsx)(i.Dialog,{open:g,onOpenChange:x,children:(0,t.jsxs)(i.DialogContent,{className:(0,o.cn)("sm:max-w-6xl max-h-[90vh] p-0 overflow-hidden border-gray-800/50","bg-gradient-to-b from-[#0a0a0a] via-[#1a1a1a] to-[#0a0a0a]"),children:[(0,t.jsx)("div",{className:"pointer-events-none absolute inset-0 bg-gradient-to-br from-brand-start/5 via-transparent to-brand-end/5"}),(0,t.jsxs)(i.DialogHeader,{className:"relative px-6 sm:px-10 pt-8 pb-4 text-left",children:[(0,t.jsx)(i.DialogTitle,{className:"text-2xl sm:text-3xl font-extrabold tracking-wider uppercase bg-gradient-to-r from-white to-gray-300 bg-clip-text text-transparent",children:c}),(0,t.jsx)("p",{className:"mt-2 text-sm text-gray-400",children:h})]}),(0,t.jsx)(a.ScrollArea,{className:"relative max-h-[68vh] px-6 sm:px-10 py-6",onClickCapture:function(e){e.target instanceof Element&&e.target.closest("a[href]")&&x(!1)},children:0===e.length?(0,t.jsx)("p",{className:"py-12 text-center text-sm text-gray-400",children:u}):(0,t.jsx)("div",{children:e.map((s,r)=>(0,t.jsx)(d,{entry:s,isLast:r===e.length-1},s.date+s.title))})}),(0,t.jsxs)("div",{className:"relative flex items-center justify-between gap-4 px-6 sm:px-10 py-4 border-t border-gray-800/50 bg-black/40 backdrop-blur-sm",children:[(0,t.jsxs)("span",{className:"flex items-center gap-2 text-xs text-gray-500",children:[(0,t.jsxs)("span",{className:"relative inline-flex w-2 h-2",children:[(0,t.jsx)("span",{className:"absolute inset-0 rounded-full bg-emerald-500 animate-ping opacity-60"}),(0,t.jsx)("span",{className:"relative rounded-full w-2 h-2 bg-emerald-500"})]}),(0,t.jsxs)("span",{className:"hidden sm:inline",children:["© ",new Date().getFullYear()," nafy.ai · ",p]}),(0,t.jsx)("span",{className:"sm:hidden",children:p})]}),(0,t.jsx)(n.Button,{onClick:()=>x(!1),className:"bg-gradient-to-r from-brand-start to-brand-end hover:opacity-90 text-white rounded-full px-5 py-2 text-sm font-medium shadow-lg shadow-brand-start/30 transition-all",children:f})]})]})})]})}function w({label:e,hasUnread:s,onClick:r}){return(0,t.jsx)(v,{label:e,hasUnread:s,onClick:r})}function v({label:e,hasUnread:s,onClick:i}){let{isCollapsed:a}=(0,l.useSidebar)();return a?(0,t.jsx)("button",{onClick:i,title:e,className:"w-10 h-10 flex items-center justify-center rounded-xl transition-all text-gray-400 hover:bg-white/5 hover:text-white border border-transparent",children:(0,t.jsxs)("span",{className:"relative inline-flex",children:[(0,t.jsx)(r.default,{className:"w-4 h-4"}),s&&(0,t.jsx)(y,{})]})}):(0,t.jsxs)("button",{onClick:i,className:(0,o.cn)("group flex items-center gap-3 px-4 py-2 rounded-lg transition-all duration-200 w-full text-left","text-gray-400 hover:bg-white/5 hover:text-white"),children:[(0,t.jsxs)("span",{className:"relative inline-flex",children:[(0,t.jsx)(r.default,{className:"w-4 h-4 flex-shrink-0 group-hover:scale-110 transition-transform"}),s&&(0,t.jsx)(y,{})]}),(0,t.jsx)("span",{className:"text-sm",children:e})]})}function y(){return(0,t.jsx)("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-red-500 ring-2 ring-zinc-950"})}e.s(["ChangelogBell",()=>b],136502)}]); 12 13//# debugId=2d4c41c2-441e-63d6-c35f-0fe7d196a9c3
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.