@nvwa-app/sdk-core 0.4.14 → 0.4.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -153,6 +153,9 @@ declare class NvwaAuthClient {
|
|
|
153
153
|
constructor(baseUrl: string, fetch: NvwaFetch, storage: NvwaLocalStorage);
|
|
154
154
|
currentUser(): Promise<User | null>;
|
|
155
155
|
signUp(user: RegisterUser): Promise<void>;
|
|
156
|
+
sendPhoneNumberCode(phoneNumber: string): Promise<void>;
|
|
157
|
+
signInWithPhoneNumberCode(phoneNumber: string, code: string): Promise<void>;
|
|
158
|
+
signInWithPhoneNumber(phoneNumber: string, password: string, rememberMe?: boolean): Promise<void>;
|
|
156
159
|
signInWithUsername(username: string, password: string): Promise<void>;
|
|
157
160
|
saveSession(result: SignInResult): void;
|
|
158
161
|
signOut(): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -153,6 +153,9 @@ declare class NvwaAuthClient {
|
|
|
153
153
|
constructor(baseUrl: string, fetch: NvwaFetch, storage: NvwaLocalStorage);
|
|
154
154
|
currentUser(): Promise<User | null>;
|
|
155
155
|
signUp(user: RegisterUser): Promise<void>;
|
|
156
|
+
sendPhoneNumberCode(phoneNumber: string): Promise<void>;
|
|
157
|
+
signInWithPhoneNumberCode(phoneNumber: string, code: string): Promise<void>;
|
|
158
|
+
signInWithPhoneNumber(phoneNumber: string, password: string, rememberMe?: boolean): Promise<void>;
|
|
156
159
|
signInWithUsername(username: string, password: string): Promise<void>;
|
|
157
160
|
saveSession(result: SignInResult): void;
|
|
158
161
|
signOut(): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var gr=Object.create;var ce=Object.defineProperty;var yr=Object.getOwnPropertyDescriptor;var br=Object.getOwnPropertyNames;var wr=Object.getPrototypeOf,_r=Object.prototype.hasOwnProperty;var tt=(r,e)=>()=>(r&&(e=r(r=0)),e);var H=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),rt=(r,e)=>{for(var t in e)ce(r,t,{get:e[t],enumerable:!0})},nt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of br(e))!_r.call(r,s)&&s!==t&&ce(r,s,{get:()=>e[s],enumerable:!(n=yr(e,s))||n.enumerable});return r};var Rr=(r,e,t)=>(t=r!=null?gr(wr(r)):{},nt(e||!r||!r.__esModule?ce(t,"default",{value:r,enumerable:!0}):t,r)),F=r=>nt(ce({},"__esModule",{value:!0}),r);var l=tt(()=>{"use strict"});var W={};rt(W,{__addDisposableResource:()=>Zt,__assign:()=>ye,__asyncDelegator:()=>Wt,__asyncGenerator:()=>Gt,__asyncValues:()=>Vt,__await:()=>K,__awaiter:()=>kt,__classPrivateFieldGet:()=>Yt,__classPrivateFieldIn:()=>Xt,__classPrivateFieldSet:()=>Qt,__createBinding:()=>we,__decorate:()=>Ut,__disposeResources:()=>er,__esDecorate:()=>Nt,__exportStar:()=>Bt,__extends:()=>xt,__generator:()=>Mt,__importDefault:()=>Jt,__importStar:()=>Kt,__makeTemplateObject:()=>zt,__metadata:()=>jt,__param:()=>Ct,__propKey:()=>Dt,__read:()=>De,__rest:()=>It,__rewriteRelativeImportExtension:()=>tr,__runInitializers:()=>Lt,__setFunctionName:()=>$t,__spread:()=>qt,__spreadArray:()=>Ft,__spreadArrays:()=>Ht,__values:()=>be,default:()=>An});function xt(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Ne(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function It(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}function Ut(r,e,t,n){var s=arguments.length,o=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(i=r[c])&&(o=(s<3?i(o):s>3?i(e,t,o):i(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o}function Ct(r,e){return function(t,n){e(t,n,r)}}function Nt(r,e,t,n,s,o){function i(v){if(v!==void 0&&typeof v!="function")throw new TypeError("Function expected");return v}for(var c=n.kind,f=c==="getter"?"get":c==="setter"?"set":"value",a=!e&&r?n.static?r:r.prototype:null,u=e||(a?Object.getOwnPropertyDescriptor(a,n.name):{}),d,p=!1,g=t.length-1;g>=0;g--){var y={};for(var R in n)y[R]=R==="access"?{}:n[R];for(var R in n.access)y.access[R]=n.access[R];y.addInitializer=function(v){if(p)throw new TypeError("Cannot add initializers after decoration has completed");o.push(i(v||null))};var b=(0,t[g])(c==="accessor"?{get:u.get,set:u.set}:u[f],y);if(c==="accessor"){if(b===void 0)continue;if(b===null||typeof b!="object")throw new TypeError("Object expected");(d=i(b.get))&&(u.get=d),(d=i(b.set))&&(u.set=d),(d=i(b.init))&&s.unshift(d)}else(d=i(b))&&(c==="field"?s.unshift(d):u[f]=d)}a&&Object.defineProperty(a,n.name,u),p=!0}function Lt(r,e,t){for(var n=arguments.length>2,s=0;s<e.length;s++)t=n?e[s].call(r,t):e[s].call(r);return n?t:void 0}function Dt(r){return typeof r=="symbol"?r:"".concat(r)}function $t(r,e,t){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(r,"name",{configurable:!0,value:t?"".concat(t," ",e):e})}function jt(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function kt(r,e,t,n){function s(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function c(u){try{a(n.next(u))}catch(d){i(d)}}function f(u){try{a(n.throw(u))}catch(d){i(d)}}function a(u){u.done?o(u.value):s(u.value).then(c,f)}a((n=n.apply(r,e||[])).next())})}function Mt(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,s,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(a){return function(u){return f([a,u])}}function f(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(t=0)),t;)try{if(n=1,s&&(o=a[0]&2?s.return:a[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,a[1])).done)return o;switch(s=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return t.label++,{value:a[1],done:!1};case 5:t.label++,s=a[1],a=[0];continue;case 7:a=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){t.label=a[1];break}if(a[0]===6&&t.label<o[1]){t.label=o[1],o=a;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(a);break}o[2]&&t.ops.pop(),t.trys.pop();continue}a=e.call(r,t)}catch(u){a=[6,u],s=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function Bt(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&we(e,r,t)}function be(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function De(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(c){i={error:c}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o}function qt(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(De(arguments[e]));return r}function Ht(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var o=arguments[e],i=0,c=o.length;i<c;i++,s++)n[s]=o[i];return n}function Ft(r,e,t){if(t||arguments.length===2)for(var n=0,s=e.length,o;n<s;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))}function K(r){return this instanceof K?(this.v=r,this):new K(r)}function Gt(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(r,e||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(g){return function(y){return Promise.resolve(y).then(g,d)}}function c(g,y){n[g]&&(s[g]=function(R){return new Promise(function(b,v){o.push([g,R,b,v])>1||f(g,R)})},y&&(s[g]=y(s[g])))}function f(g,y){try{a(n[g](y))}catch(R){p(o[0][3],R)}}function a(g){g.value instanceof K?Promise.resolve(g.value.v).then(u,d):p(o[0][2],g)}function u(g){f("next",g)}function d(g){f("throw",g)}function p(g,y){g(y),o.shift(),o.length&&f(o[0][0],o[0][1])}}function Wt(r){var e,t;return e={},n("next"),n("throw",function(s){throw s}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(s,o){e[s]=r[s]?function(i){return(t=!t)?{value:K(r[s](i)),done:!1}:o?o(i):i}:o}}function Vt(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof be=="function"?be(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(o){t[o]=r[o]&&function(i){return new Promise(function(c,f){i=r[o](i),s(c,f,i.done,i.value)})}}function s(o,i,c,f){Promise.resolve(f).then(function(a){o({value:a,done:c})},i)}}function zt(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function Kt(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t=Le(r),n=0;n<t.length;n++)t[n]!=="default"&&we(e,r,t[n]);return Pn(e,r),e}function Jt(r){return r&&r.__esModule?r:{default:r}}function Yt(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}function Qt(r,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(r,t):s?s.value=t:e.set(r,t),t}function Xt(r,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof r=="function"?e===r:r.has(e)}function Zt(r,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var n,s;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=e[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=e[Symbol.dispose],t&&(s=n)}if(typeof n!="function")throw new TypeError("Object not disposable.");s&&(n=function(){try{s.call(this)}catch(o){return Promise.reject(o)}}),r.stack.push({value:e,dispose:n,async:t})}else t&&r.stack.push({async:!0});return e}function er(r){function e(o){r.error=r.hasError?new On(o,r.error,"An error was suppressed during disposal."):o,r.hasError=!0}var t,n=0;function s(){for(;t=r.stack.pop();)try{if(!t.async&&n===1)return n=0,r.stack.push(t),Promise.resolve().then(s);if(t.dispose){var o=t.dispose.call(t.value);if(t.async)return n|=2,Promise.resolve(o).then(s,function(i){return e(i),s()})}else n|=1}catch(i){e(i)}if(n===1)return r.hasError?Promise.reject(r.error):Promise.resolve();if(r.hasError)throw r.error}return s()}function tr(r,e){return typeof r=="string"&&/^\.\.?\//.test(r)?r.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,n,s,o,i){return n?e?".jsx":".js":s&&(!o||!i)?t:s+o+"."+i.toLowerCase()+"js"}):r}var Ne,ye,we,Pn,Le,On,An,V=tt(()=>{"use strict";l();Ne=function(r,e){return Ne=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])},Ne(r,e)};ye=function(){return ye=Object.assign||function(e){for(var t,n=1,s=arguments.length;n<s;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},ye.apply(this,arguments)};we=Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]});Pn=Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e},Le=function(r){return Le=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},Le(r)};On=typeof SuppressedError=="function"?SuppressedError:function(r,e,t){var n=new Error(t);return n.name="SuppressedError",n.error=r,n.suppressed=e,n};An={__extends:xt,__assign:ye,__rest:It,__decorate:Ut,__param:Ct,__esDecorate:Nt,__runInitializers:Lt,__propKey:Dt,__setFunctionName:$t,__metadata:jt,__awaiter:kt,__generator:Mt,__createBinding:we,__exportStar:Bt,__values:be,__read:De,__spread:qt,__spreadArrays:Ht,__spreadArray:Ft,__await:K,__asyncGenerator:Gt,__asyncDelegator:Wt,__asyncValues:Vt,__makeTemplateObject:zt,__importStar:Kt,__importDefault:Jt,__classPrivateFieldGet:Yt,__classPrivateFieldSet:Qt,__classPrivateFieldIn:Xt,__addDisposableResource:Zt,__disposeResources:er,__rewriteRelativeImportExtension:tr}});var ke=H(je=>{"use strict";l();Object.defineProperty(je,"__esModule",{value:!0});var $e=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};je.default=$e});var qe=H(Be=>{"use strict";l();Object.defineProperty(Be,"__esModule",{value:!0});var xn=(V(),F(W)),In=xn.__importDefault(ke()),Me=class{constructor(e){var t,n;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(n=e.isMaybeSingle)!==null&&n!==void 0?n:!1,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let n=this.fetch,s=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async o=>{var i,c,f,a;let u=null,d=null,p=null,g=o.status,y=o.statusText;if(o.ok){if(this.method!=="HEAD"){let P=await o.text();P===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((i=this.headers.get("Accept"))===null||i===void 0)&&i.includes("application/vnd.pgrst.plan+text"))?d=P:d=JSON.parse(P))}let b=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),v=(f=o.headers.get("content-range"))===null||f===void 0?void 0:f.split("/");b&&v&&v.length>1&&(p=parseInt(v[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(u={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,p=null,g=406,y="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let b=await o.text();try{u=JSON.parse(b),Array.isArray(u)&&o.status===404&&(d=[],u=null,g=200,y="OK")}catch{o.status===404&&b===""?(g=204,y="No Content"):u={message:b}}if(u&&this.isMaybeSingle&&(!((a=u?.details)===null||a===void 0)&&a.includes("0 rows"))&&(u=null,g=200,y="OK"),u&&this.shouldThrowOnError)throw new In.default(u)}return{error:u,data:d,count:p,status:g,statusText:y}});return this.shouldThrowOnError||(s=s.catch(o=>{var i,c,f;return{error:{message:`${(i=o?.name)!==null&&i!==void 0?i:"FetchError"}: ${o?.message}`,details:`${(c=o?.stack)!==null&&c!==void 0?c:""}`,hint:"",code:`${(f=o?.code)!==null&&f!==void 0?f:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}returns(){return this}overrideTypes(){return this}};Be.default=Me});var Ge=H(Fe=>{"use strict";l();Object.defineProperty(Fe,"__esModule",{value:!0});var Un=(V(),F(W)),Cn=Un.__importDefault(qe()),He=class extends Cn.default{select(e){let t=!1,n=(e??"*").split("").map(s=>/\s/.test(s)&&!t?"":(s==='"'&&(t=!t),s)).join("");return this.url.searchParams.set("select",n),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:n,foreignTable:s,referencedTable:o=s}={}){let i=o?`${o}.order`:"order",c=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${c?`${c},`:""}${e}.${t?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:n=t}={}){let s=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:n,referencedTable:s=n}={}){let o=typeof s>"u"?"offset":`${s}.offset`,i=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(o,`${e}`),this.url.searchParams.set(i,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:n=!1,buffers:s=!1,wal:o=!1,format:i="text"}={}){var c;let f=[e?"analyze":null,t?"verbose":null,n?"settings":null,s?"buffers":null,o?"wal":null].filter(Boolean).join("|"),a=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${a}"; options=${f};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};Fe.default=He});var _e=H(Ve=>{"use strict";l();Object.defineProperty(Ve,"__esModule",{value:!0});var Nn=(V(),F(W)),Ln=Nn.__importDefault(Ge()),Dn=new RegExp("[,()]"),We=class extends Ln.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 n=Array.from(new Set(t)).map(s=>typeof s=="string"&&Dn.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${n})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:n,type:s}={}){let o="";s==="plain"?o="pl":s==="phrase"?o="ph":s==="websearch"&&(o="w");let i=n===void 0?"":`(${n})`;return this.url.searchParams.append(e,`${o}fts${i}.${t}`),this}match(e){return Object.entries(e).forEach(([t,n])=>{this.url.searchParams.append(t,`eq.${n}`)}),this}not(e,t,n){return this.url.searchParams.append(e,`not.${t}.${n}`),this}or(e,{foreignTable:t,referencedTable:n=t}={}){let s=n?`${n}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,n){return this.url.searchParams.append(e,`${t}.${n}`),this}};Ve.default=We});var Je=H(Ke=>{"use strict";l();Object.defineProperty(Ke,"__esModule",{value:!0});var $n=(V(),F(W)),se=$n.__importDefault(_e()),ze=class{constructor(e,{headers:t={},schema:n,fetch:s}){this.url=e,this.headers=new Headers(t),this.schema=n,this.fetch=s}select(e,t){let{head:n=!1,count:s}=t??{},o=n?"HEAD":"GET",i=!1,c=(e??"*").split("").map(f=>/\s/.test(f)&&!i?"":(f==='"'&&(i=!i),f)).join("");return this.url.searchParams.set("select",c),s&&this.headers.append("Prefer",`count=${s}`),new se.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:n=!0}={}){var s;let o="POST";if(t&&this.headers.append("Prefer",`count=${t}`),n||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let i=e.reduce((c,f)=>c.concat(Object.keys(f)),[]);if(i.length>0){let c=[...new Set(i)].map(f=>`"${f}"`);this.url.searchParams.set("columns",c.join(","))}}return new se.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:n=!1,count:s,defaultToNull:o=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${n?"ignore":"merge"}-duplicates`),t!==void 0&&this.url.searchParams.set("on_conflict",t),s&&this.headers.append("Prefer",`count=${s}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let f=e.reduce((a,u)=>a.concat(Object.keys(u)),[]);if(f.length>0){let a=[...new Set(f)].map(u=>`"${u}"`);this.url.searchParams.set("columns",a.join(","))}}return new se.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(e,{count:t}={}){var n;let s="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new se.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}delete({count:e}={}){var t;let n="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new se.default({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};Ke.default=ze});var nr=H(Qe=>{"use strict";l();Object.defineProperty(Qe,"__esModule",{value:!0});var rr=(V(),F(W)),jn=rr.__importDefault(Je()),kn=rr.__importDefault(_e()),Ye=class r{constructor(e,{headers:t={},schema:n,fetch:s}={}){this.url=e,this.headers=new Headers(t),this.schemaName=n,this.fetch=s}from(e){let t=new URL(`${this.url}/${e}`);return new jn.default(t,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new r(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:n=!1,get:s=!1,count:o}={}){var i;let c,f=new URL(`${this.url}/rpc/${e}`),a;n||s?(c=n?"HEAD":"GET",Object.entries(t).filter(([d,p])=>p!==void 0).map(([d,p])=>[d,Array.isArray(p)?`{${p.join(",")}}`:`${p}`]).forEach(([d,p])=>{f.searchParams.append(d,p)})):(c="POST",a=t);let u=new Headers(this.headers);return o&&u.set("Prefer",`count=${o}`),new kn.default({method:c,url:f,headers:u,schema:this.schemaName,body:a,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}};Qe.default=Ye});var ur=H(S=>{"use strict";l();Object.defineProperty(S,"__esModule",{value:!0});S.PostgrestError=S.PostgrestBuilder=S.PostgrestTransformBuilder=S.PostgrestFilterBuilder=S.PostgrestQueryBuilder=S.PostgrestClient=void 0;var J=(V(),F(W)),sr=J.__importDefault(nr());S.PostgrestClient=sr.default;var or=J.__importDefault(Je());S.PostgrestQueryBuilder=or.default;var ir=J.__importDefault(_e());S.PostgrestFilterBuilder=ir.default;var ar=J.__importDefault(Ge());S.PostgrestTransformBuilder=ar.default;var lr=J.__importDefault(qe());S.PostgrestBuilder=lr.default;var cr=J.__importDefault(ke());S.PostgrestError=cr.default;S.default={PostgrestClient:sr.default,PostgrestQueryBuilder:or.default,PostgrestFilterBuilder:ir.default,PostgrestTransformBuilder:ar.default,PostgrestBuilder:lr.default,PostgrestError:cr.default}});var Fn={};rt(Fn,{AUTH_BASE_PATH:()=>Pt,AbortController:()=>ae,AbortSignal:()=>Q,ENTITIES_BASE_PATH:()=>dr,FILE_STORAGE_BASE_PATH:()=>Ot,GENERATE_UPLOAD_URL_PATH:()=>At,Headers:()=>x,LOGIN_TOKEN_KEY:()=>ne,LOGIN_USER_PROFILE_KEY:()=>ge,NvwaAuthClient:()=>xe,NvwaEdgeFunctions:()=>Ie,NvwaFileStorage:()=>Ce,NvwaHttpClient:()=>Ue,Request:()=>ie,Response:()=>B,URL:()=>oe,URLSearchParams:()=>Y,createPostgrestClient:()=>Hn,polyfill:()=>Bn});module.exports=F(Fn);l();l();l();l();l();l();var vr=Object.defineProperty,Er=Object.defineProperties,Tr=Object.getOwnPropertyDescriptors,st=Object.getOwnPropertySymbols,Sr=Object.prototype.hasOwnProperty,Pr=Object.prototype.propertyIsEnumerable,ot=(r,e,t)=>e in r?vr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,U=(r,e)=>{for(var t in e||(e={}))Sr.call(e,t)&&ot(r,t,e[t]);if(st)for(var t of st(e))Pr.call(e,t)&&ot(r,t,e[t]);return r},N=(r,e)=>Er(r,Tr(e)),Or=class extends Error{constructor(r,e,t){super(e||r.toString(),{cause:t}),this.status=r,this.statusText=e,this.error=t}},Ar=async(r,e)=>{var t,n,s,o,i,c;let f=e||{},a={onRequest:[e?.onRequest],onResponse:[e?.onResponse],onSuccess:[e?.onSuccess],onError:[e?.onError],onRetry:[e?.onRetry]};if(!e||!e?.plugins)return{url:r,options:f,hooks:a};for(let u of e?.plugins||[]){if(u.init){let d=await((t=u.init)==null?void 0:t.call(u,r.toString(),e));f=d.options||f,r=d.url}a.onRequest.push((n=u.hooks)==null?void 0:n.onRequest),a.onResponse.push((s=u.hooks)==null?void 0:s.onResponse),a.onSuccess.push((o=u.hooks)==null?void 0:o.onSuccess),a.onError.push((i=u.hooks)==null?void 0:i.onError),a.onRetry.push((c=u.hooks)==null?void 0:c.onRetry)}return{url:r,options:f,hooks:a}},it=class{constructor(r){this.options=r}shouldAttemptRetry(r,e){return this.options.shouldRetry?Promise.resolve(r<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(r<this.options.attempts)}getDelay(){return this.options.delay}},xr=class{constructor(r){this.options=r}shouldAttemptRetry(r,e){return this.options.shouldRetry?Promise.resolve(r<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(r<this.options.attempts)}getDelay(r){return Math.min(this.options.maxDelay,this.options.baseDelay*2**r)}};function Ir(r){if(typeof r=="number")return new it({type:"linear",attempts:r,delay:1e3});switch(r.type){case"linear":return new it(r);case"exponential":return new xr(r);default:throw new Error("Invalid retry strategy")}}var Ur=async r=>{let e={},t=async n=>typeof n=="function"?await n():n;if(r?.auth){if(r.auth.type==="Bearer"){let n=await t(r.auth.token);if(!n)return e;e.authorization=`Bearer ${n}`}else if(r.auth.type==="Basic"){let n=t(r.auth.username),s=t(r.auth.password);if(!n||!s)return e;e.authorization=`Basic ${btoa(`${n}:${s}`)}`}else if(r.auth.type==="Custom"){let n=t(r.auth.value);if(!n)return e;e.authorization=`${t(r.auth.prefix)} ${n}`}}return e},Cr=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Nr(r){let e=r.headers.get("content-type"),t=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!e)return"json";let n=e.split(";").shift()||"";return Cr.test(n)?"json":t.has(n)||n.startsWith("text/")?"text":"blob"}function Lr(r){try{return JSON.parse(r),!0}catch{return!1}}function ct(r){if(r===void 0)return!1;let e=typeof r;return e==="string"||e==="number"||e==="boolean"||e===null?!0:e!=="object"?!1:Array.isArray(r)?!0:r.buffer?!1:r.constructor&&r.constructor.name==="Object"||typeof r.toJSON=="function"}function at(r){try{return JSON.parse(r)}catch{return r}}function lt(r){return typeof r=="function"}function Dr(r){if(r?.customFetchImpl)return r.customFetchImpl;if(typeof globalThis<"u"&<(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&<(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function $r(r){let e=new Headers(r?.headers),t=await Ur(r);for(let[n,s]of Object.entries(t||{}))e.set(n,s);if(!e.has("content-type")){let n=jr(r?.body);n&&e.set("content-type",n)}return e}function jr(r){return ct(r)?"application/json":null}function kr(r){if(!r?.body)return null;let e=new Headers(r?.headers);if(ct(r.body)&&!e.has("content-type")){for(let[t,n]of Object.entries(r?.body))n instanceof Date&&(r.body[t]=n.toISOString());return JSON.stringify(r.body)}return r.body}function Mr(r,e){var t;if(e?.method)return e.method.toUpperCase();if(r.startsWith("@")){let n=(t=r.split("@")[1])==null?void 0:t.split("/")[0];return ft.includes(n)?n.toUpperCase():e?.body?"POST":"GET"}return e?.body?"POST":"GET"}function Br(r,e){let t;return!r?.signal&&r?.timeout&&(t=setTimeout(()=>e?.abort(),r?.timeout)),{abortTimeout:t,clearTimeout:()=>{t&&clearTimeout(t)}}}var qr=class ut extends Error{constructor(e,t){super(t||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,ut.prototype)}};async function ue(r,e){let t=await r["~standard"].validate(e);if(t.issues)throw new qr(t.issues);return t.value}var ft=["get","post","put","patch","delete"];var Hr=r=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(e,t){var n,s,o,i;let c=((s=(n=r.plugins)==null?void 0:n.find(f=>{var a;return(a=f.schema)!=null&&a.config?e.startsWith(f.schema.config.baseURL||"")||e.startsWith(f.schema.config.prefix||""):!1}))==null?void 0:s.schema)||r.schema;if(c){let f=e;(o=c.config)!=null&&o.prefix&&f.startsWith(c.config.prefix)&&(f=f.replace(c.config.prefix,""),c.config.baseURL&&(e=e.replace(c.config.prefix,c.config.baseURL))),(i=c.config)!=null&&i.baseURL&&f.startsWith(c.config.baseURL)&&(f=f.replace(c.config.baseURL,""));let a=c.schema[f];if(a){let u=N(U({},t),{method:a.method,output:a.output});return t?.disableValidation||(u=N(U({},u),{body:a.input?await ue(a.input,t?.body):t?.body,params:a.params?await ue(a.params,t?.params):t?.params,query:a.query?await ue(a.query,t?.query):t?.query})),{url:e,options:u}}}return{url:e,options:t}}}),dt=r=>{async function e(t,n){let s=N(U(U({},r),n),{plugins:[...r?.plugins||[],Hr(r||{})]});if(r?.catchAllError)try{return await ve(t,s)}catch(o){return{data:null,error:{status:500,statusText:"Fetch Error",message:"Fetch related error. Captured by catchAllError option. See error property for more details.",error:o}}}return await ve(t,s)}return e};function Fr(r,e){let{baseURL:t,params:n,query:s}=e||{query:{},params:{},baseURL:""},o=r.startsWith("http")?r.split("/").slice(0,3).join("/"):t||"";if(r.startsWith("@")){let d=r.toString().split("@")[1].split("/")[0];ft.includes(d)&&(r=r.replace(`@${d}/`,"/"))}o.endsWith("/")||(o+="/");let[i,c]=r.replace(o,"").split("?"),f=new URLSearchParams(c);for(let[d,p]of Object.entries(s||{}))p!=null&&f.set(d,String(p));if(n)if(Array.isArray(n)){let d=i.split("/").filter(p=>p.startsWith(":"));for(let[p,g]of d.entries()){let y=n[p];i=i.replace(g,y)}}else for(let[d,p]of Object.entries(n))i=i.replace(`:${d}`,String(p));i=i.split("/").map(encodeURIComponent).join("/"),i.startsWith("/")&&(i=i.slice(1));let a=f.toString();return a=a.length>0?`?${a}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${i}${a}`,o):`${o}${i}${a}`}var ve=async(r,e)=>{var t,n,s,o,i,c,f,a;let{hooks:u,url:d,options:p}=await Ar(r,e),g=Dr(p),y=new AbortController,R=(t=p.signal)!=null?t:y.signal,b=Fr(d,p),v=kr(p),P=await $r(p),$=Mr(d,p),m=N(U({},p),{url:b,headers:P,body:v,method:$,signal:R});for(let I of u.onRequest)if(I){let T=await I(m);T instanceof Object&&(m=T)}("pipeTo"in m&&typeof m.pipeTo=="function"||typeof((n=e?.body)==null?void 0:n.pipe)=="function")&&("duplex"in m||(m.duplex="half"));let{clearTimeout:q}=Br(p,y),_=await g(m.url,m);q();let Ze={response:_,request:m};for(let I of u.onResponse)if(I){let T=await I(N(U({},Ze),{response:(s=e?.hookOptions)!=null&&s.cloneResponse?_.clone():_}));T instanceof Response?_=T:T instanceof Object&&(_=T.response)}if(_.ok){if(!(m.method!=="HEAD"))return{data:"",error:null};let T=Nr(_),j={data:"",response:_,request:m};if(T==="json"||T==="text"){let k=await _.text(),mr=await((o=m.jsonParser)!=null?o:at)(k);j.data=mr}else j.data=await _[T]();m?.output&&m.output&&!m.disableValidation&&(j.data=await ue(m.output,j.data));for(let k of u.onSuccess)k&&await k(N(U({},j),{response:(i=e?.hookOptions)!=null&&i.cloneResponse?_.clone():_}));return e?.throw?j.data:{data:j.data,error:null}}let hr=(c=e?.jsonParser)!=null?c:at,le=await _.text(),et=Lr(le),Re=et?await hr(le):null,pr={response:_,responseText:le,request:m,error:N(U({},Re),{status:_.status,statusText:_.statusText})};for(let I of u.onError)I&&await I(N(U({},pr),{response:(f=e?.hookOptions)!=null&&f.cloneResponse?_.clone():_}));if(e?.retry){let I=Ir(e.retry),T=(a=e.retryAttempt)!=null?a:0;if(await I.shouldAttemptRetry(T,_)){for(let k of u.onRetry)k&&await k(Ze);let j=I.getDelay(T);return await new Promise(k=>setTimeout(k,j)),await ve(r,N(U({},e),{retryAttempt:T+1}))}}if(e?.throw)throw new Or(_.status,_.statusText,et?Re:le);return{data:null,error:N(U({},Re),{status:_.status,statusText:_.statusText})}};l();l();var fe=Object.create(null),X=r=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(r?fe:globalThis),A=new Proxy(fe,{get(r,e){return X()[e]??fe[e]},has(r,e){let t=X();return e in t||e in fe},set(r,e,t){let n=X(!0);return n[e]=t,!0},deleteProperty(r,e){if(!e)return!1;let t=X(!0);return delete t[e],!0},ownKeys(){let r=X(!0);return Object.keys(r)}});var Xn=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function w(r,e){return typeof process<"u"&&process.env?process.env[r]??e:typeof Deno<"u"?Deno.env.get(r)??e:typeof Bun<"u"?Bun.env[r]??e:e}var Zn=Object.freeze({get BETTER_AUTH_SECRET(){return w("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return w("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return w("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return w("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return w("NODE_ENV","development")},get PACKAGE_VERSION(){return w("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return w("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),Z=1,E=4,L=8,O=24,ht={eterm:E,cons25:E,console:E,cygwin:E,dtterm:E,gnome:E,hurd:E,jfbterm:E,konsole:E,kterm:E,mlterm:E,mosh:O,putty:E,st:E,"rxvt-unicode-24bit":O,terminator:O,"xterm-kitty":O},Gr=new Map(Object.entries({APPVEYOR:L,BUILDKITE:L,CIRCLECI:O,DRONE:L,GITEA_ACTIONS:O,GITHUB_ACTIONS:O,GITLAB_CI:L,TRAVIS:L})),Wr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Vr(){if(w("FORCE_COLOR")!==void 0)switch(w("FORCE_COLOR")){case"":case"1":case"true":return E;case"2":return L;case"3":return O;default:return Z}if(w("NODE_DISABLE_COLORS")!==void 0&&w("NODE_DISABLE_COLORS")!==""||w("NO_COLOR")!==void 0&&w("NO_COLOR")!==""||w("TERM")==="dumb")return Z;if(w("TMUX"))return O;if("TF_BUILD"in A&&"AGENT_NAME"in A)return E;if("CI"in A){for(let{0:r,1:e}of Gr)if(r in A)return e;return w("CI_NAME")==="codeship"?L:Z}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(w("TEAMCITY_VERSION"))!==null?E:Z;switch(w("TERM_PROGRAM")){case"iTerm.app":return!w("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(w("TERM_PROGRAM_VERSION"))!==null?L:O;case"HyperTerm":case"MacTerm":return O;case"Apple_Terminal":return L}if(w("COLORTERM")==="truecolor"||w("COLORTERM")==="24bit")return O;if(w("TERM")){if(/truecolor/.exec(w("TERM"))!==null)return O;if(/^xterm-256/.exec(w("TERM"))!==null)return L;let r=w("TERM").toLowerCase();if(ht[r])return ht[r];if(Wr.some(e=>e.exec(r)!==null))return E}return w("COLORTERM")?E:Z}var D={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",undim:"\x1B[22m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",fg:{black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m"},bg:{black:"\x1B[40m",red:"\x1B[41m",green:"\x1B[42m",yellow:"\x1B[43m",blue:"\x1B[44m",magenta:"\x1B[45m",cyan:"\x1B[46m",white:"\x1B[47m"}},Ee=["info","success","warn","error","debug"];function zr(r,e){return Ee.indexOf(e)<=Ee.indexOf(r)}var Kr={info:D.fg.blue,success:D.fg.green,warn:D.fg.yellow,error:D.fg.red,debug:D.fg.magenta},Jr=(r,e,t)=>{let n=new Date().toISOString();return t?`${D.dim}${n}${D.reset} ${Kr[r]}${r.toUpperCase()}${D.reset} ${D.bright}[Better Auth]:${D.reset} ${e}`:`${n} ${r.toUpperCase()} [Better Auth]: ${e}`},Yr=r=>{let e=r?.disabled!==!0,t=r?.level??"error",s=r?.disableColors!==void 0?!r.disableColors:Vr()!==1,o=(c,f,a=[])=>{if(!e||!zr(t,c))return;let u=Jr(c,f,s);if(!r||typeof r.log!="function"){c==="error"?console.error(u,...a):c==="warn"?console.warn(u,...a):console.log(u,...a);return}r.log(c==="success"?"info":c,f,...a)};return{...Object.fromEntries(Ee.map(c=>[c,(...[f,...a])=>o(c,f,a)])),get level(){return t}}},es=Yr();l();l();var as={USER_NOT_FOUND:"User not found",FAILED_TO_CREATE_USER:"Failed to create user",FAILED_TO_CREATE_SESSION:"Failed to create session",FAILED_TO_UPDATE_USER:"Failed to update user",FAILED_TO_GET_SESSION:"Failed to get session",INVALID_PASSWORD:"Invalid password",INVALID_EMAIL:"Invalid email",INVALID_EMAIL_OR_PASSWORD:"Invalid email or password",SOCIAL_ACCOUNT_ALREADY_LINKED:"Social account already linked",PROVIDER_NOT_FOUND:"Provider not found",INVALID_TOKEN:"Invalid token",ID_TOKEN_NOT_SUPPORTED:"id_token not supported",FAILED_TO_GET_USER_INFO:"Failed to get user info",USER_EMAIL_NOT_FOUND:"User email not found",EMAIL_NOT_VERIFIED:"Email not verified",PASSWORD_TOO_SHORT:"Password too short",PASSWORD_TOO_LONG:"Password too long",USER_ALREADY_EXISTS:"User already exists.",USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL:"User already exists. Use another email.",EMAIL_CAN_NOT_BE_UPDATED:"Email can not be updated",CREDENTIAL_ACCOUNT_NOT_FOUND:"Credential account not found",SESSION_EXPIRED:"Session expired. Re-authenticate to perform this action.",FAILED_TO_UNLINK_LAST_ACCOUNT:"You can't unlink your last account",ACCOUNT_NOT_FOUND:"Account not found",USER_ALREADY_HAS_PASSWORD:"User already has a password. Provide that to delete the account."},G=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function Qr(r){try{return(new URL(r).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new G(`Invalid base URL: ${r}. Please provide a valid base URL.`)}}function ee(r,e="/api/auth"){if(Qr(r))return r;let n=r.replace(/\/+$/,"");return!e||e==="/"?n:(e=e.startsWith("/")?e:`/${e}`,`${n}${e}`)}function pt(r,e,t,n){if(r)return ee(r,e);if(n!==!1){let i=A.BETTER_AUTH_URL||A.NEXT_PUBLIC_BETTER_AUTH_URL||A.PUBLIC_BETTER_AUTH_URL||A.NUXT_PUBLIC_BETTER_AUTH_URL||A.NUXT_PUBLIC_AUTH_URL||(A.BASE_URL!=="/"?A.BASE_URL:void 0);if(i)return ee(i,e)}let s=t?.headers.get("x-forwarded-host"),o=t?.headers.get("x-forwarded-proto");if(s&&o)return ee(`${o}://${s}`,e);if(t){let i=Xr(t.url);if(!i)throw new G("Could not get origin from request. Please provide a valid base URL.");return ee(i,e)}if(typeof window<"u"&&window.location)return ee(window.location.origin,e)}function Xr(r){try{return new URL(r).origin}catch{return null}}l();l();l();var te=Symbol("clean");var C=[],M=0,de=4,Zr=0,re=r=>{let e=[],t={get(){return t.lc||t.listen(()=>{})(),t.value},lc:0,listen(n){return t.lc=e.push(n),()=>{for(let o=M+de;o<C.length;)C[o]===n?C.splice(o,de):o+=de;let s=e.indexOf(n);~s&&(e.splice(s,1),--t.lc||t.off())}},notify(n,s){Zr++;let o=!C.length;for(let i of e)C.push(i,t.value,n,s);if(o){for(M=0;M<C.length;M+=de)C[M](C[M+1],C[M+2],C[M+3]);C.length=0}},off(){},set(n){let s=t.value;s!==n&&(t.value=n,t.notify(s))},subscribe(n){let s=t.listen(n);return n(t.value),s},value:r};return process.env.NODE_ENV!=="production"&&(t[te]=()=>{e=[],t.lc=0,t.off()}),t};l();var en=5,z=6,he=10,tn=(r,e,t,n)=>(r.events=r.events||{},r.events[t+he]||(r.events[t+he]=n(s=>{r.events[t].reduceRight((o,i)=>(i(o),o),{shared:{},...s})})),r.events[t]=r.events[t]||[],r.events[t].push(e),()=>{let s=r.events[t],o=s.indexOf(e);s.splice(o,1),s.length||(delete r.events[t],r.events[t+he](),delete r.events[t+he])});var mt=1e3,Te=(r,e)=>tn(r,n=>{let s=e(n);s&&r.events[z].push(s)},en,n=>{let s=r.listen;r.listen=(...i)=>(!r.lc&&!r.active&&(r.active=!0,n()),s(...i));let o=r.off;if(r.events[z]=[],r.off=()=>{o(),setTimeout(()=>{if(r.active&&!r.lc){r.active=!1;for(let i of r.events[z])i();r.events[z]=[]}},mt)},process.env.NODE_ENV!=="production"){let i=r[te];r[te]=()=>{for(let c of r.events[z])c();r.events[z]=[],r.active=!1,i()}}return()=>{r.listen=s,r.off=o}});l();var rn=typeof window>"u",pe=(r,e,t,n)=>{let s=re({data:null,error:null,isPending:!0,isRefetching:!1,refetch:c=>o(c)}),o=c=>{let f=typeof n=="function"?n({data:s.get().data,error:s.get().error,isPending:s.get().isPending}):n;t(e,{...f,query:{...f?.query,...c?.query},async onSuccess(a){s.set({data:a.data,error:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await f?.onSuccess?.(a)},async onError(a){let{request:u}=a,d=typeof u.retry=="number"?u.retry:u.retry?.attempts,p=u.retryAttempt||0;d&&p<d||(s.set({error:a.error,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await f?.onError?.(a))},async onRequest(a){let u=s.get();s.set({isPending:u.data===null,data:u.data,error:null,isRefetching:!0,refetch:s.value.refetch}),await f?.onRequest?.(a)}}).catch(a=>{s.set({error:a,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch})})};r=Array.isArray(r)?r:[r];let i=!1;for(let c of r)c.subscribe(()=>{rn||(i?o():Te(s,()=>{let f=setTimeout(()=>{i||(o(),i=!0)},0);return()=>{s.off(),c.off(),clearTimeout(f)}}))});return s};l();var nn={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},sn=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,gt={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},on=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function an(r){return r instanceof Date&&!isNaN(r.getTime())}function ln(r){let e=on.exec(r);if(!e)return null;let[,t,n,s,o,i,c,f,a,u,d]=e,p=new Date(Date.UTC(parseInt(t,10),parseInt(n,10)-1,parseInt(s,10),parseInt(o,10),parseInt(i,10),parseInt(c,10),f?parseInt(f.padEnd(3,"0"),10):0));if(a){let g=(parseInt(u,10)*60+parseInt(d,10))*(a==="+"?-1:1);p.setUTCMinutes(p.getUTCMinutes()+g)}return an(p)?p:null}function cn(r,e={}){let{strict:t=!1,warnings:n=!1,reviver:s,parseDates:o=!0}=e;if(typeof r!="string")return r;let i=r.trim();if(i.length>0&&i[0]==='"'&&i.endsWith('"')&&!i.slice(1,-1).includes('"'))return i.slice(1,-1);let c=i.toLowerCase();if(c.length<=9&&c in gt)return gt[c];if(!sn.test(i)){if(t)throw new SyntaxError("[better-json] Invalid JSON");return r}if(Object.entries(nn).some(([a,u])=>{let d=u.test(i);return d&&n&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${a} pattern`),d})&&t)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(i,(u,d)=>{if(u==="__proto__"||u==="constructor"&&d&&typeof d=="object"&&"prototype"in d){n&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof d=="string"){let p=ln(d);if(p)return p}return s?s(u,d):d})}catch(a){if(t)throw a;return r}}function yt(r,e={strict:!0}){return cn(r,e)}var un={id:"redirect",name:"Redirect",hooks:{onSuccess(r){if(r.data?.url&&r.data?.redirect&&typeof window<"u"&&window.location&&window.location)try{window.location.href=r.data.url}catch{}}}};function fn(r){let e=re(!1);return{session:pe(e,"/get-session",r,{method:"GET"}),$sessionSignal:e}}var bt=(r,e)=>{let t="credentials"in Request.prototype,n=pt(r?.baseURL,r?.basePath,void 0,e)??"/api/auth",s=r?.plugins?.flatMap(m=>m.fetchPlugins).filter(m=>m!==void 0)||[],o={id:"lifecycle-hooks",name:"lifecycle-hooks",hooks:{onSuccess:r?.fetchOptions?.onSuccess,onError:r?.fetchOptions?.onError,onRequest:r?.fetchOptions?.onRequest,onResponse:r?.fetchOptions?.onResponse}},{onSuccess:i,onError:c,onRequest:f,onResponse:a,...u}=r?.fetchOptions||{},d=dt({baseURL:n,...t?{credentials:"include"}:{},method:"GET",jsonParser(m){return m?yt(m,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[o,...u.plugins||[],...r?.disableDefaultFetchPlugins?[]:[un],...s]}),{$sessionSignal:p,session:g}=fn(d),y=r?.plugins||[],R={},b={$sessionSignal:p,session:g},v={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},P=[{signal:"$sessionSignal",matcher(m){return m==="/sign-out"||m==="/update-user"||m.startsWith("/sign-in")||m.startsWith("/sign-up")||m==="/delete-user"||m==="/verify-email"}}];for(let m of y)m.getAtoms&&Object.assign(b,m.getAtoms?.(d)),m.pathMethods&&Object.assign(v,m.pathMethods),m.atomListeners&&P.push(...m.atomListeners);let $={notify:m=>{b[m].set(!b[m].get())},listen:(m,q)=>{b[m].subscribe(q)},atoms:b};for(let m of y)m.getActions&&Object.assign(R,m.getActions?.(d,$,r));return{get baseURL(){return n},pluginsActions:R,pluginsAtoms:b,pluginPathMethods:v,atomListeners:P,$fetch:d,$store:$}};function dn(r){return typeof r=="object"&&r!==null&&"get"in r&&typeof r.get=="function"&&"lc"in r&&typeof r.lc=="number"}function hn(r,e,t){let n=e[r],{fetchOptions:s,query:o,...i}=t||{};return n||(s?.method?s.method:i&&Object.keys(i).length>0?"POST":"GET")}function wt(r,e,t,n,s){function o(i=[]){return new Proxy(function(){},{get(c,f){if(typeof f!="string"||f==="then"||f==="catch"||f==="finally")return;let a=[...i,f],u=r;for(let d of a)if(u&&typeof u=="object"&&d in u)u=u[d];else{u=void 0;break}return typeof u=="function"||dn(u)?u:o(a)},apply:async(c,f,a)=>{let u="/"+i.map(P=>P.replace(/[A-Z]/g,$=>`-${$.toLowerCase()}`)).join("/"),d=a[0]||{},p=a[1]||{},{query:g,fetchOptions:y,...R}=d,b={...p,...y},v=hn(u,t,d);return await e(u,{...b,body:v==="GET"?void 0:{...R,...b?.body||{}},query:g||b?.query,method:v,async onSuccess(P){if(await b?.onSuccess?.(P),!s)return;let $=s.filter(m=>m.matcher(u));if($.length)for(let m of $){let q=n[m.signal];if(!q)return;let _=q.get();setTimeout(()=>{q.set(!_)},10)}}})}})}return o()}l();function _t(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Se(r){let{pluginPathMethods:e,pluginsActions:t,pluginsAtoms:n,$fetch:s,atomListeners:o,$store:i}=bt(r),c={};for(let[u,d]of Object.entries(n))c[`use${_t(u)}`]=d;let f={...t,...c,$fetch:s,$store:i};return wt(f,s,e,n,o)}l();l();l();function pn(r){return{authorize(e,t="AND"){let n=!1;for(let[s,o]of Object.entries(e)){let i=r[s];if(!i)return{success:!1,error:`You are not allowed to access resource: ${s}`};if(Array.isArray(o))n=o.every(c=>i.includes(c));else if(typeof o=="object"){let c=o;c.connector==="OR"?n=c.actions.some(f=>i.includes(f)):n=c.actions.every(f=>i.includes(f))}else throw new G("Invalid access control request");if(n&&t==="OR")return{success:n};if(!n&&t==="AND")return{success:!1,error:`unauthorized to access resource "${s}"`}}return n?{success:n}:{success:!1,error:"Not authorized"}},statements:r}}function me(r){return{newRole(e){return pn(e)},statements:r}}var mn={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},Pe=me(mn),gn=Pe.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),yn=Pe.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),bn=Pe.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});l();l();l();l();l();l();l();l();l();l();l();var Oe=class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let t=new Error("Cancelling existing WebAuthn API call for new one");t.name="AbortError",this.controller.abort(t)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}},Et=new Oe;l();l();l();l();l();l();l();l();var En={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},Tt=me(En),Tn=Tt.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),Sn=Tt.newRole({user:[],session:[]});l();l();var St=()=>({id:"username",$InferServerPlugin:{}});var Pt="/auth",ne="nvwa_login_token",ge="nvwa_user_profile",xe=class{constructor(e,t,n){this.storage=n,this.authClient=Se({baseURL:e,basePath:Pt,fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:()=>n.get(ne)},onSuccess:s=>{let o=s.response.headers.get("set-auth-token");o&&n.set(ne,o)}},plugins:[St()]})}async currentUser(){return await this.storage.get(ge)}async signUp(e){let t=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:e.password});this.saveSession(t)}async signInWithUsername(e,t){let n=await this.authClient.signIn.username({username:e,password:t});this.saveSession(n)}saveSession(e){if(e.error)throw new Error(e.error.message);this.storage.set(ne,e.data?.token),this.storage.set(ge,e.data?.user)}async signOut(){await this.storage.remove(ne),await this.storage.remove(ge)}async updateUserPassword(e,t,n=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:n});this.saveSession(s)}};l();var Ie=class{constructor(e){this.http=e}async invoke(e,t){return(await this.http.request("/functions/"+e,{method:t.method||"POST",data:t.body,headers:t.headers})).body}};l();var Ue=class{async jsonRequest(e,t){let n={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.request(e,n)}async jsonRequestWithAuth(e,t,n){let s={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.requestWithAuth(e,s,n)}};l();var Ot="/storage",At=Ot+"/generateUploadUrl",Ce=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.request(this.baseUrl+At,{method:"POST",data:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:n}=t.body;if(!n)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");return{url:(await this.http.request(n,{method:"PUT",data:e,headers:{"Content-Type":e.type||e.fileType||"application/octet-stream"}})).body.url.split("?")[0]}}};l();l();l();var Xe=Rr(ur(),1),{PostgrestClient:fr,PostgrestQueryBuilder:Ua,PostgrestFilterBuilder:Ca,PostgrestTransformBuilder:Na,PostgrestBuilder:La,PostgrestError:Da}=Xe.default||Xe;l();l();var x=class r{constructor(e){this.headerMap=new Map;if(e){if(e instanceof r)e.forEach((t,n)=>this.set(n,t));else if(Array.isArray(e))for(let[t,n]of e)this.set(t,String(n));else if(typeof e=="object")for(let t of Object.keys(e))this.set(t,String(e[t]))}}append(e,t){let n=e.toLowerCase(),s=this.headerMap.get(n);this.headerMap.set(n,s?`${s}, ${t}`:t)}set(e,t){this.headerMap.set(e.toLowerCase(),String(t))}get(e){let t=this.headerMap.get(e.toLowerCase());return t??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[t,n]of this.headerMap.entries())e(n,t,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},Y=class r{constructor(e){this.params=new Map;if(e){if(typeof e=="string")this.parseString(e);else if(e instanceof r)this.params=new Map(e.params);else if(Array.isArray(e))for(let[t,n]of e)this.append(t,n);else if(e&&typeof e=="object")for(let[t,n]of Object.entries(e))this.set(t,n)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let t=e.split("&");for(let n of t)if(n){let[s,o]=n.split("=");s&&this.append(decodeURIComponent(s),o?decodeURIComponent(o):"")}}append(e,t){let n=this.params.get(e)||[];n.push(t),this.params.set(e,n)}delete(e){this.params.delete(e)}get(e){let t=this.params.get(e);return t?t[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,t){this.params.set(e,[t])}sort(){let e=Array.from(this.params.entries()).sort(([t],[n])=>t.localeCompare(n));this.params=new Map(e)}toString(){let e=[];for(let[t,n]of this.params.entries())for(let s of n)e.push(`${encodeURIComponent(t)}=${encodeURIComponent(s)}`);return e.join("&")}forEach(e){for(let[t,n]of this.params.entries())for(let s of n)e(s,t,this)}keys(){return this.params.keys()}values(){let e=[];for(let t of this.params.values())e.push(...t);return e[Symbol.iterator]()}entries(){let e=[];for(let[t,n]of this.params.entries())for(let s of n)e.push([t,s]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},oe=class r{constructor(e,t){let n;if(e instanceof r)n=e.href;else if(t){let o=t instanceof r?t.href:t;n=this.resolve(o,e)}else n=e;let s=this.parseUrl(n);this.href=n,this.origin=`${s.protocol}//${s.host}`,this.protocol=s.protocol,this.username=s.username,this.password=s.password,this.host=s.host,this.hostname=s.hostname,this.port=s.port,this.pathname=s.pathname,this.search=s.search,this.searchParams=new Y(s.search),this.hash=s.hash}resolve(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(t.startsWith("//"))return`${this.parseUrl(e).protocol}${t}`;if(t.startsWith("/")){let o=this.parseUrl(e);return`${o.protocol}//${o.host}${t}`}let n=this.parseUrl(e),s=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return`${n.protocol}//${n.host}${s}${t}`}parseUrl(e){let t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)throw new TypeError("Invalid URL");let n=t[2]||"",s=t[4]||"",o=t[5]||"/",i=t[7]?`?${t[7]}`:"",c=t[9]?`#${t[9]}`:"";if(!n&&!s&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let f=s.match(/^([^@]*)@(.+)$/),a="",u="",d=s;if(f){let R=f[1];d=f[2];let b=R.match(/^([^:]*):?(.*)$/);b&&(a=b[1]||"",u=b[2]||"")}let p=d.match(/^([^:]+):?(\d*)$/),g=p?p[1]:d,y=p&&p[2]?p[2]:"";return{protocol:n?`${n}:`:"",username:a,password:u,host:d,hostname:g,port:y,pathname:o,search:i,hash:c}}toString(){let e=this.searchParams.toString(),t=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${t}${this.hash}`}toJSON(){return this.toString()}};l();var ie=class r{constructor(e,t){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(t?.method||"GET").toUpperCase(),this.headers=t?.headers instanceof x?t.headers:new x(t?.headers),this.body=t?.body,this.timeout=t?.timeout,this.signal=t?.signal||void 0}clone(){return new r(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};l();var B=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=Mn(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function Mn(r){return r?new x(r):new x}l();var Q=class{constructor(){this._aborted=!1;this.listeners=new Set;this.onabort=null}get aborted(){return this._aborted}_trigger(){if(!this._aborted){if(this._aborted=!0,typeof this.onabort=="function")try{this.onabort()}catch{}for(let e of Array.from(this.listeners))try{e()}catch{}this.listeners.clear()}}addEventListener(e,t){if(this._aborted){try{t()}catch{}return}this.listeners.add(t)}removeEventListener(e,t){this.listeners.delete(t)}toString(){return"[object AbortSignal]"}},ae=class{constructor(){this._signal=new Q}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};l();function Bn(r){r.URL=oe,r.URLSearchParams=Y,r.Headers=x,r.Request=ie,r.Response=B,r.AbortController=ae,r.AbortSignal=Q}var dr="/entities",qn=(r,e)=>async(n,s)=>{console.log("customFetch",n,s);let o;if(typeof n=="string")o=n;else if(n&&typeof n=="object")if(typeof n.toString=="function"&&!n.url)o=n.toString();else if(n.url)o=n.url,s||(s={}),s.method=n.method,s.headers=n.headers,s.body=n.body;else throw new Error("Unsupported input type for fetch");else throw new Error("Unsupported input type for fetch");let i=(s?.method||"GET").toUpperCase(),c={};if(s?.headers)if(s.headers&&typeof s.headers.forEach=="function")s.headers.forEach((g,y)=>{c[y]=g});else if(Array.isArray(s.headers))for(let[g,y]of s.headers)c[g]=y;else Object.assign(c,s.headers);let f=s?.body,a;try{a=await r.requestWithAuth(o,{method:i,data:f,headers:c},e)}catch(g){return new B(g?.message||"Internal Error",{status:500,statusText:"Internal Error"})}let u=a.body,d=null;return(a.headers["content-type"]||a.headers["Content-Type"]||"").startsWith("application/json")&&typeof u!="string"?d=JSON.stringify(u):typeof u=="string"||u&&(u.constructor===Blob||u.constructor===ArrayBuffer||typeof u.getReader=="function")?d=u:d=JSON.stringify(u),new B(d,{status:a.status,headers:new x(a.headers)})},Hn=(r,e,t)=>new fr(r+dr,{fetch:qn(e,t)});0&&(module.exports={AUTH_BASE_PATH,AbortController,AbortSignal,ENTITIES_BASE_PATH,FILE_STORAGE_BASE_PATH,GENERATE_UPLOAD_URL_PATH,Headers,LOGIN_TOKEN_KEY,LOGIN_USER_PROFILE_KEY,NvwaAuthClient,NvwaEdgeFunctions,NvwaFileStorage,NvwaHttpClient,Request,Response,URL,URLSearchParams,createPostgrestClient,polyfill});
|
|
1
|
+
"use strict";var br=Object.create;var ce=Object.defineProperty;var wr=Object.getOwnPropertyDescriptor;var _r=Object.getOwnPropertyNames;var vr=Object.getPrototypeOf,Rr=Object.prototype.hasOwnProperty;var tt=(r,e)=>()=>(r&&(e=r(r=0)),e);var H=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),rt=(r,e)=>{for(var t in e)ce(r,t,{get:e[t],enumerable:!0})},nt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of _r(e))!Rr.call(r,s)&&s!==t&&ce(r,s,{get:()=>e[s],enumerable:!(n=wr(e,s))||n.enumerable});return r};var Er=(r,e,t)=>(t=r!=null?br(vr(r)):{},nt(e||!r||!r.__esModule?ce(t,"default",{value:r,enumerable:!0}):t,r)),F=r=>nt(ce({},"__esModule",{value:!0}),r);var l=tt(()=>{"use strict"});var W={};rt(W,{__addDisposableResource:()=>tr,__assign:()=>ye,__asyncDelegator:()=>zt,__asyncGenerator:()=>Vt,__asyncValues:()=>Kt,__await:()=>K,__awaiter:()=>Bt,__classPrivateFieldGet:()=>Xt,__classPrivateFieldIn:()=>er,__classPrivateFieldSet:()=>Zt,__createBinding:()=>we,__decorate:()=>Nt,__disposeResources:()=>rr,__esDecorate:()=>Dt,__exportStar:()=>Ht,__extends:()=>Ut,__generator:()=>qt,__importDefault:()=>Qt,__importStar:()=>Yt,__makeTemplateObject:()=>Jt,__metadata:()=>Mt,__param:()=>Lt,__propKey:()=>jt,__read:()=>De,__rest:()=>Ct,__rewriteRelativeImportExtension:()=>nr,__runInitializers:()=>$t,__setFunctionName:()=>kt,__spread:()=>Ft,__spreadArray:()=>Wt,__spreadArrays:()=>Gt,__values:()=>be,default:()=>In});function Ut(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Ne(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Ct(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}function Nt(r,e,t,n){var s=arguments.length,o=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(i=r[c])&&(o=(s<3?i(o):s>3?i(e,t,o):i(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o}function Lt(r,e){return function(t,n){e(t,n,r)}}function Dt(r,e,t,n,s,o){function i(R){if(R!==void 0&&typeof R!="function")throw new TypeError("Function expected");return R}for(var c=n.kind,f=c==="getter"?"get":c==="setter"?"set":"value",a=!e&&r?n.static?r:r.prototype:null,u=e||(a?Object.getOwnPropertyDescriptor(a,n.name):{}),d,p=!1,g=t.length-1;g>=0;g--){var y={};for(var v in n)y[v]=v==="access"?{}:n[v];for(var v in n.access)y.access[v]=n.access[v];y.addInitializer=function(R){if(p)throw new TypeError("Cannot add initializers after decoration has completed");o.push(i(R||null))};var b=(0,t[g])(c==="accessor"?{get:u.get,set:u.set}:u[f],y);if(c==="accessor"){if(b===void 0)continue;if(b===null||typeof b!="object")throw new TypeError("Object expected");(d=i(b.get))&&(u.get=d),(d=i(b.set))&&(u.set=d),(d=i(b.init))&&s.unshift(d)}else(d=i(b))&&(c==="field"?s.unshift(d):u[f]=d)}a&&Object.defineProperty(a,n.name,u),p=!0}function $t(r,e,t){for(var n=arguments.length>2,s=0;s<e.length;s++)t=n?e[s].call(r,t):e[s].call(r);return n?t:void 0}function jt(r){return typeof r=="symbol"?r:"".concat(r)}function kt(r,e,t){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(r,"name",{configurable:!0,value:t?"".concat(t," ",e):e})}function Mt(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function Bt(r,e,t,n){function s(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function c(u){try{a(n.next(u))}catch(d){i(d)}}function f(u){try{a(n.throw(u))}catch(d){i(d)}}function a(u){u.done?o(u.value):s(u.value).then(c,f)}a((n=n.apply(r,e||[])).next())})}function qt(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,s,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(a){return function(u){return f([a,u])}}function f(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(t=0)),t;)try{if(n=1,s&&(o=a[0]&2?s.return:a[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,a[1])).done)return o;switch(s=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return t.label++,{value:a[1],done:!1};case 5:t.label++,s=a[1],a=[0];continue;case 7:a=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){t.label=a[1];break}if(a[0]===6&&t.label<o[1]){t.label=o[1],o=a;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(a);break}o[2]&&t.ops.pop(),t.trys.pop();continue}a=e.call(r,t)}catch(u){a=[6,u],s=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function Ht(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&we(e,r,t)}function be(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function De(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(c){i={error:c}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o}function Ft(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(De(arguments[e]));return r}function Gt(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var o=arguments[e],i=0,c=o.length;i<c;i++,s++)n[s]=o[i];return n}function Wt(r,e,t){if(t||arguments.length===2)for(var n=0,s=e.length,o;n<s;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))}function K(r){return this instanceof K?(this.v=r,this):new K(r)}function Vt(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(r,e||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(g){return function(y){return Promise.resolve(y).then(g,d)}}function c(g,y){n[g]&&(s[g]=function(v){return new Promise(function(b,R){o.push([g,v,b,R])>1||f(g,v)})},y&&(s[g]=y(s[g])))}function f(g,y){try{a(n[g](y))}catch(v){p(o[0][3],v)}}function a(g){g.value instanceof K?Promise.resolve(g.value.v).then(u,d):p(o[0][2],g)}function u(g){f("next",g)}function d(g){f("throw",g)}function p(g,y){g(y),o.shift(),o.length&&f(o[0][0],o[0][1])}}function zt(r){var e,t;return e={},n("next"),n("throw",function(s){throw s}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(s,o){e[s]=r[s]?function(i){return(t=!t)?{value:K(r[s](i)),done:!1}:o?o(i):i}:o}}function Kt(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof be=="function"?be(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(o){t[o]=r[o]&&function(i){return new Promise(function(c,f){i=r[o](i),s(c,f,i.done,i.value)})}}function s(o,i,c,f){Promise.resolve(f).then(function(a){o({value:a,done:c})},i)}}function Jt(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function Yt(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t=Le(r),n=0;n<t.length;n++)t[n]!=="default"&&we(e,r,t[n]);return An(e,r),e}function Qt(r){return r&&r.__esModule?r:{default:r}}function Xt(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}function Zt(r,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(r,t):s?s.value=t:e.set(r,t),t}function er(r,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof r=="function"?e===r:r.has(e)}function tr(r,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var n,s;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=e[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=e[Symbol.dispose],t&&(s=n)}if(typeof n!="function")throw new TypeError("Object not disposable.");s&&(n=function(){try{s.call(this)}catch(o){return Promise.reject(o)}}),r.stack.push({value:e,dispose:n,async:t})}else t&&r.stack.push({async:!0});return e}function rr(r){function e(o){r.error=r.hasError?new xn(o,r.error,"An error was suppressed during disposal."):o,r.hasError=!0}var t,n=0;function s(){for(;t=r.stack.pop();)try{if(!t.async&&n===1)return n=0,r.stack.push(t),Promise.resolve().then(s);if(t.dispose){var o=t.dispose.call(t.value);if(t.async)return n|=2,Promise.resolve(o).then(s,function(i){return e(i),s()})}else n|=1}catch(i){e(i)}if(n===1)return r.hasError?Promise.reject(r.error):Promise.resolve();if(r.hasError)throw r.error}return s()}function nr(r,e){return typeof r=="string"&&/^\.\.?\//.test(r)?r.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,n,s,o,i){return n?e?".jsx":".js":s&&(!o||!i)?t:s+o+"."+i.toLowerCase()+"js"}):r}var Ne,ye,we,An,Le,xn,In,V=tt(()=>{"use strict";l();Ne=function(r,e){return Ne=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])},Ne(r,e)};ye=function(){return ye=Object.assign||function(e){for(var t,n=1,s=arguments.length;n<s;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},ye.apply(this,arguments)};we=Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]});An=Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e},Le=function(r){return Le=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},Le(r)};xn=typeof SuppressedError=="function"?SuppressedError:function(r,e,t){var n=new Error(t);return n.name="SuppressedError",n.error=r,n.suppressed=e,n};In={__extends:Ut,__assign:ye,__rest:Ct,__decorate:Nt,__param:Lt,__esDecorate:Dt,__runInitializers:$t,__propKey:jt,__setFunctionName:kt,__metadata:Mt,__awaiter:Bt,__generator:qt,__createBinding:we,__exportStar:Ht,__values:be,__read:De,__spread:Ft,__spreadArrays:Gt,__spreadArray:Wt,__await:K,__asyncGenerator:Vt,__asyncDelegator:zt,__asyncValues:Kt,__makeTemplateObject:Jt,__importStar:Yt,__importDefault:Qt,__classPrivateFieldGet:Xt,__classPrivateFieldSet:Zt,__classPrivateFieldIn:er,__addDisposableResource:tr,__disposeResources:rr,__rewriteRelativeImportExtension:nr}});var ke=H(je=>{"use strict";l();Object.defineProperty(je,"__esModule",{value:!0});var $e=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};je.default=$e});var qe=H(Be=>{"use strict";l();Object.defineProperty(Be,"__esModule",{value:!0});var Un=(V(),F(W)),Cn=Un.__importDefault(ke()),Me=class{constructor(e){var t,n;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(n=e.isMaybeSingle)!==null&&n!==void 0?n:!1,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let n=this.fetch,s=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async o=>{var i,c,f,a;let u=null,d=null,p=null,g=o.status,y=o.statusText;if(o.ok){if(this.method!=="HEAD"){let S=await o.text();S===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((i=this.headers.get("Accept"))===null||i===void 0)&&i.includes("application/vnd.pgrst.plan+text"))?d=S:d=JSON.parse(S))}let b=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),R=(f=o.headers.get("content-range"))===null||f===void 0?void 0:f.split("/");b&&R&&R.length>1&&(p=parseInt(R[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(u={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,p=null,g=406,y="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let b=await o.text();try{u=JSON.parse(b),Array.isArray(u)&&o.status===404&&(d=[],u=null,g=200,y="OK")}catch{o.status===404&&b===""?(g=204,y="No Content"):u={message:b}}if(u&&this.isMaybeSingle&&(!((a=u?.details)===null||a===void 0)&&a.includes("0 rows"))&&(u=null,g=200,y="OK"),u&&this.shouldThrowOnError)throw new Cn.default(u)}return{error:u,data:d,count:p,status:g,statusText:y}});return this.shouldThrowOnError||(s=s.catch(o=>{var i,c,f;return{error:{message:`${(i=o?.name)!==null&&i!==void 0?i:"FetchError"}: ${o?.message}`,details:`${(c=o?.stack)!==null&&c!==void 0?c:""}`,hint:"",code:`${(f=o?.code)!==null&&f!==void 0?f:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}returns(){return this}overrideTypes(){return this}};Be.default=Me});var Ge=H(Fe=>{"use strict";l();Object.defineProperty(Fe,"__esModule",{value:!0});var Nn=(V(),F(W)),Ln=Nn.__importDefault(qe()),He=class extends Ln.default{select(e){let t=!1,n=(e??"*").split("").map(s=>/\s/.test(s)&&!t?"":(s==='"'&&(t=!t),s)).join("");return this.url.searchParams.set("select",n),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:n,foreignTable:s,referencedTable:o=s}={}){let i=o?`${o}.order`:"order",c=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${c?`${c},`:""}${e}.${t?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:n=t}={}){let s=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:n,referencedTable:s=n}={}){let o=typeof s>"u"?"offset":`${s}.offset`,i=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(o,`${e}`),this.url.searchParams.set(i,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:n=!1,buffers:s=!1,wal:o=!1,format:i="text"}={}){var c;let f=[e?"analyze":null,t?"verbose":null,n?"settings":null,s?"buffers":null,o?"wal":null].filter(Boolean).join("|"),a=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${a}"; options=${f};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};Fe.default=He});var _e=H(Ve=>{"use strict";l();Object.defineProperty(Ve,"__esModule",{value:!0});var Dn=(V(),F(W)),$n=Dn.__importDefault(Ge()),jn=new RegExp("[,()]"),We=class extends $n.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 n=Array.from(new Set(t)).map(s=>typeof s=="string"&&jn.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${n})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:n,type:s}={}){let o="";s==="plain"?o="pl":s==="phrase"?o="ph":s==="websearch"&&(o="w");let i=n===void 0?"":`(${n})`;return this.url.searchParams.append(e,`${o}fts${i}.${t}`),this}match(e){return Object.entries(e).forEach(([t,n])=>{this.url.searchParams.append(t,`eq.${n}`)}),this}not(e,t,n){return this.url.searchParams.append(e,`not.${t}.${n}`),this}or(e,{foreignTable:t,referencedTable:n=t}={}){let s=n?`${n}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,n){return this.url.searchParams.append(e,`${t}.${n}`),this}};Ve.default=We});var Je=H(Ke=>{"use strict";l();Object.defineProperty(Ke,"__esModule",{value:!0});var kn=(V(),F(W)),se=kn.__importDefault(_e()),ze=class{constructor(e,{headers:t={},schema:n,fetch:s}){this.url=e,this.headers=new Headers(t),this.schema=n,this.fetch=s}select(e,t){let{head:n=!1,count:s}=t??{},o=n?"HEAD":"GET",i=!1,c=(e??"*").split("").map(f=>/\s/.test(f)&&!i?"":(f==='"'&&(i=!i),f)).join("");return this.url.searchParams.set("select",c),s&&this.headers.append("Prefer",`count=${s}`),new se.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:n=!0}={}){var s;let o="POST";if(t&&this.headers.append("Prefer",`count=${t}`),n||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let i=e.reduce((c,f)=>c.concat(Object.keys(f)),[]);if(i.length>0){let c=[...new Set(i)].map(f=>`"${f}"`);this.url.searchParams.set("columns",c.join(","))}}return new se.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:n=!1,count:s,defaultToNull:o=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${n?"ignore":"merge"}-duplicates`),t!==void 0&&this.url.searchParams.set("on_conflict",t),s&&this.headers.append("Prefer",`count=${s}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let f=e.reduce((a,u)=>a.concat(Object.keys(u)),[]);if(f.length>0){let a=[...new Set(f)].map(u=>`"${u}"`);this.url.searchParams.set("columns",a.join(","))}}return new se.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(e,{count:t}={}){var n;let s="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new se.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}delete({count:e}={}){var t;let n="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new se.default({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};Ke.default=ze});var or=H(Qe=>{"use strict";l();Object.defineProperty(Qe,"__esModule",{value:!0});var sr=(V(),F(W)),Mn=sr.__importDefault(Je()),Bn=sr.__importDefault(_e()),Ye=class r{constructor(e,{headers:t={},schema:n,fetch:s}={}){this.url=e,this.headers=new Headers(t),this.schemaName=n,this.fetch=s}from(e){let t=new URL(`${this.url}/${e}`);return new Mn.default(t,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new r(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:n=!1,get:s=!1,count:o}={}){var i;let c,f=new URL(`${this.url}/rpc/${e}`),a;n||s?(c=n?"HEAD":"GET",Object.entries(t).filter(([d,p])=>p!==void 0).map(([d,p])=>[d,Array.isArray(p)?`{${p.join(",")}}`:`${p}`]).forEach(([d,p])=>{f.searchParams.append(d,p)})):(c="POST",a=t);let u=new Headers(this.headers);return o&&u.set("Prefer",`count=${o}`),new Bn.default({method:c,url:f,headers:u,schema:this.schemaName,body:a,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}};Qe.default=Ye});var dr=H(P=>{"use strict";l();Object.defineProperty(P,"__esModule",{value:!0});P.PostgrestError=P.PostgrestBuilder=P.PostgrestTransformBuilder=P.PostgrestFilterBuilder=P.PostgrestQueryBuilder=P.PostgrestClient=void 0;var J=(V(),F(W)),ir=J.__importDefault(or());P.PostgrestClient=ir.default;var ar=J.__importDefault(Je());P.PostgrestQueryBuilder=ar.default;var lr=J.__importDefault(_e());P.PostgrestFilterBuilder=lr.default;var cr=J.__importDefault(Ge());P.PostgrestTransformBuilder=cr.default;var ur=J.__importDefault(qe());P.PostgrestBuilder=ur.default;var fr=J.__importDefault(ke());P.PostgrestError=fr.default;P.default={PostgrestClient:ir.default,PostgrestQueryBuilder:ar.default,PostgrestFilterBuilder:lr.default,PostgrestTransformBuilder:cr.default,PostgrestBuilder:ur.default,PostgrestError:fr.default}});var Wn={};rt(Wn,{AUTH_BASE_PATH:()=>At,AbortController:()=>ae,AbortSignal:()=>Q,ENTITIES_BASE_PATH:()=>pr,FILE_STORAGE_BASE_PATH:()=>xt,GENERATE_UPLOAD_URL_PATH:()=>It,Headers:()=>x,LOGIN_TOKEN_KEY:()=>ne,LOGIN_USER_PROFILE_KEY:()=>ge,NvwaAuthClient:()=>xe,NvwaEdgeFunctions:()=>Ie,NvwaFileStorage:()=>Ce,NvwaHttpClient:()=>Ue,Request:()=>ie,Response:()=>B,URL:()=>oe,URLSearchParams:()=>Y,createPostgrestClient:()=>Gn,polyfill:()=>Hn});module.exports=F(Wn);l();l();l();l();l();l();var Tr=Object.defineProperty,Pr=Object.defineProperties,Sr=Object.getOwnPropertyDescriptors,st=Object.getOwnPropertySymbols,Or=Object.prototype.hasOwnProperty,Ar=Object.prototype.propertyIsEnumerable,ot=(r,e,t)=>e in r?Tr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,U=(r,e)=>{for(var t in e||(e={}))Or.call(e,t)&&ot(r,t,e[t]);if(st)for(var t of st(e))Ar.call(e,t)&&ot(r,t,e[t]);return r},N=(r,e)=>Pr(r,Sr(e)),xr=class extends Error{constructor(r,e,t){super(e||r.toString(),{cause:t}),this.status=r,this.statusText=e,this.error=t}},Ir=async(r,e)=>{var t,n,s,o,i,c;let f=e||{},a={onRequest:[e?.onRequest],onResponse:[e?.onResponse],onSuccess:[e?.onSuccess],onError:[e?.onError],onRetry:[e?.onRetry]};if(!e||!e?.plugins)return{url:r,options:f,hooks:a};for(let u of e?.plugins||[]){if(u.init){let d=await((t=u.init)==null?void 0:t.call(u,r.toString(),e));f=d.options||f,r=d.url}a.onRequest.push((n=u.hooks)==null?void 0:n.onRequest),a.onResponse.push((s=u.hooks)==null?void 0:s.onResponse),a.onSuccess.push((o=u.hooks)==null?void 0:o.onSuccess),a.onError.push((i=u.hooks)==null?void 0:i.onError),a.onRetry.push((c=u.hooks)==null?void 0:c.onRetry)}return{url:r,options:f,hooks:a}},it=class{constructor(r){this.options=r}shouldAttemptRetry(r,e){return this.options.shouldRetry?Promise.resolve(r<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(r<this.options.attempts)}getDelay(){return this.options.delay}},Ur=class{constructor(r){this.options=r}shouldAttemptRetry(r,e){return this.options.shouldRetry?Promise.resolve(r<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(r<this.options.attempts)}getDelay(r){return Math.min(this.options.maxDelay,this.options.baseDelay*2**r)}};function Cr(r){if(typeof r=="number")return new it({type:"linear",attempts:r,delay:1e3});switch(r.type){case"linear":return new it(r);case"exponential":return new Ur(r);default:throw new Error("Invalid retry strategy")}}var Nr=async r=>{let e={},t=async n=>typeof n=="function"?await n():n;if(r?.auth){if(r.auth.type==="Bearer"){let n=await t(r.auth.token);if(!n)return e;e.authorization=`Bearer ${n}`}else if(r.auth.type==="Basic"){let n=t(r.auth.username),s=t(r.auth.password);if(!n||!s)return e;e.authorization=`Basic ${btoa(`${n}:${s}`)}`}else if(r.auth.type==="Custom"){let n=t(r.auth.value);if(!n)return e;e.authorization=`${t(r.auth.prefix)} ${n}`}}return e},Lr=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Dr(r){let e=r.headers.get("content-type"),t=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!e)return"json";let n=e.split(";").shift()||"";return Lr.test(n)?"json":t.has(n)||n.startsWith("text/")?"text":"blob"}function $r(r){try{return JSON.parse(r),!0}catch{return!1}}function ct(r){if(r===void 0)return!1;let e=typeof r;return e==="string"||e==="number"||e==="boolean"||e===null?!0:e!=="object"?!1:Array.isArray(r)?!0:r.buffer?!1:r.constructor&&r.constructor.name==="Object"||typeof r.toJSON=="function"}function at(r){try{return JSON.parse(r)}catch{return r}}function lt(r){return typeof r=="function"}function jr(r){if(r?.customFetchImpl)return r.customFetchImpl;if(typeof globalThis<"u"&<(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&<(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function kr(r){let e=new Headers(r?.headers),t=await Nr(r);for(let[n,s]of Object.entries(t||{}))e.set(n,s);if(!e.has("content-type")){let n=Mr(r?.body);n&&e.set("content-type",n)}return e}function Mr(r){return ct(r)?"application/json":null}function Br(r){if(!r?.body)return null;let e=new Headers(r?.headers);if(ct(r.body)&&!e.has("content-type")){for(let[t,n]of Object.entries(r?.body))n instanceof Date&&(r.body[t]=n.toISOString());return JSON.stringify(r.body)}return r.body}function qr(r,e){var t;if(e?.method)return e.method.toUpperCase();if(r.startsWith("@")){let n=(t=r.split("@")[1])==null?void 0:t.split("/")[0];return ft.includes(n)?n.toUpperCase():e?.body?"POST":"GET"}return e?.body?"POST":"GET"}function Hr(r,e){let t;return!r?.signal&&r?.timeout&&(t=setTimeout(()=>e?.abort(),r?.timeout)),{abortTimeout:t,clearTimeout:()=>{t&&clearTimeout(t)}}}var Fr=class ut extends Error{constructor(e,t){super(t||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,ut.prototype)}};async function ue(r,e){let t=await r["~standard"].validate(e);if(t.issues)throw new Fr(t.issues);return t.value}var ft=["get","post","put","patch","delete"];var Gr=r=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(e,t){var n,s,o,i;let c=((s=(n=r.plugins)==null?void 0:n.find(f=>{var a;return(a=f.schema)!=null&&a.config?e.startsWith(f.schema.config.baseURL||"")||e.startsWith(f.schema.config.prefix||""):!1}))==null?void 0:s.schema)||r.schema;if(c){let f=e;(o=c.config)!=null&&o.prefix&&f.startsWith(c.config.prefix)&&(f=f.replace(c.config.prefix,""),c.config.baseURL&&(e=e.replace(c.config.prefix,c.config.baseURL))),(i=c.config)!=null&&i.baseURL&&f.startsWith(c.config.baseURL)&&(f=f.replace(c.config.baseURL,""));let a=c.schema[f];if(a){let u=N(U({},t),{method:a.method,output:a.output});return t?.disableValidation||(u=N(U({},u),{body:a.input?await ue(a.input,t?.body):t?.body,params:a.params?await ue(a.params,t?.params):t?.params,query:a.query?await ue(a.query,t?.query):t?.query})),{url:e,options:u}}}return{url:e,options:t}}}),dt=r=>{async function e(t,n){let s=N(U(U({},r),n),{plugins:[...r?.plugins||[],Gr(r||{})]});if(r?.catchAllError)try{return await Re(t,s)}catch(o){return{data:null,error:{status:500,statusText:"Fetch Error",message:"Fetch related error. Captured by catchAllError option. See error property for more details.",error:o}}}return await Re(t,s)}return e};function Wr(r,e){let{baseURL:t,params:n,query:s}=e||{query:{},params:{},baseURL:""},o=r.startsWith("http")?r.split("/").slice(0,3).join("/"):t||"";if(r.startsWith("@")){let d=r.toString().split("@")[1].split("/")[0];ft.includes(d)&&(r=r.replace(`@${d}/`,"/"))}o.endsWith("/")||(o+="/");let[i,c]=r.replace(o,"").split("?"),f=new URLSearchParams(c);for(let[d,p]of Object.entries(s||{}))p!=null&&f.set(d,String(p));if(n)if(Array.isArray(n)){let d=i.split("/").filter(p=>p.startsWith(":"));for(let[p,g]of d.entries()){let y=n[p];i=i.replace(g,y)}}else for(let[d,p]of Object.entries(n))i=i.replace(`:${d}`,String(p));i=i.split("/").map(encodeURIComponent).join("/"),i.startsWith("/")&&(i=i.slice(1));let a=f.toString();return a=a.length>0?`?${a}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${i}${a}`,o):`${o}${i}${a}`}var Re=async(r,e)=>{var t,n,s,o,i,c,f,a;let{hooks:u,url:d,options:p}=await Ir(r,e),g=jr(p),y=new AbortController,v=(t=p.signal)!=null?t:y.signal,b=Wr(d,p),R=Br(p),S=await kr(p),$=qr(d,p),m=N(U({},p),{url:b,headers:S,body:R,method:$,signal:v});for(let I of u.onRequest)if(I){let T=await I(m);T instanceof Object&&(m=T)}("pipeTo"in m&&typeof m.pipeTo=="function"||typeof((n=e?.body)==null?void 0:n.pipe)=="function")&&("duplex"in m||(m.duplex="half"));let{clearTimeout:q}=Hr(p,y),_=await g(m.url,m);q();let Ze={response:_,request:m};for(let I of u.onResponse)if(I){let T=await I(N(U({},Ze),{response:(s=e?.hookOptions)!=null&&s.cloneResponse?_.clone():_}));T instanceof Response?_=T:T instanceof Object&&(_=T.response)}if(_.ok){if(!(m.method!=="HEAD"))return{data:"",error:null};let T=Dr(_),j={data:"",response:_,request:m};if(T==="json"||T==="text"){let k=await _.text(),yr=await((o=m.jsonParser)!=null?o:at)(k);j.data=yr}else j.data=await _[T]();m?.output&&m.output&&!m.disableValidation&&(j.data=await ue(m.output,j.data));for(let k of u.onSuccess)k&&await k(N(U({},j),{response:(i=e?.hookOptions)!=null&&i.cloneResponse?_.clone():_}));return e?.throw?j.data:{data:j.data,error:null}}let mr=(c=e?.jsonParser)!=null?c:at,le=await _.text(),et=$r(le),ve=et?await mr(le):null,gr={response:_,responseText:le,request:m,error:N(U({},ve),{status:_.status,statusText:_.statusText})};for(let I of u.onError)I&&await I(N(U({},gr),{response:(f=e?.hookOptions)!=null&&f.cloneResponse?_.clone():_}));if(e?.retry){let I=Cr(e.retry),T=(a=e.retryAttempt)!=null?a:0;if(await I.shouldAttemptRetry(T,_)){for(let k of u.onRetry)k&&await k(Ze);let j=I.getDelay(T);return await new Promise(k=>setTimeout(k,j)),await Re(r,N(U({},e),{retryAttempt:T+1}))}}if(e?.throw)throw new xr(_.status,_.statusText,et?ve:le);return{data:null,error:N(U({},ve),{status:_.status,statusText:_.statusText})}};l();l();var fe=Object.create(null),X=r=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(r?fe:globalThis),A=new Proxy(fe,{get(r,e){return X()[e]??fe[e]},has(r,e){let t=X();return e in t||e in fe},set(r,e,t){let n=X(!0);return n[e]=t,!0},deleteProperty(r,e){if(!e)return!1;let t=X(!0);return delete t[e],!0},ownKeys(){let r=X(!0);return Object.keys(r)}});var es=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function w(r,e){return typeof process<"u"&&process.env?process.env[r]??e:typeof Deno<"u"?Deno.env.get(r)??e:typeof Bun<"u"?Bun.env[r]??e:e}var ts=Object.freeze({get BETTER_AUTH_SECRET(){return w("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return w("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return w("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return w("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return w("NODE_ENV","development")},get PACKAGE_VERSION(){return w("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return w("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),Z=1,E=4,L=8,O=24,ht={eterm:E,cons25:E,console:E,cygwin:E,dtterm:E,gnome:E,hurd:E,jfbterm:E,konsole:E,kterm:E,mlterm:E,mosh:O,putty:E,st:E,"rxvt-unicode-24bit":O,terminator:O,"xterm-kitty":O},Vr=new Map(Object.entries({APPVEYOR:L,BUILDKITE:L,CIRCLECI:O,DRONE:L,GITEA_ACTIONS:O,GITHUB_ACTIONS:O,GITLAB_CI:L,TRAVIS:L})),zr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Kr(){if(w("FORCE_COLOR")!==void 0)switch(w("FORCE_COLOR")){case"":case"1":case"true":return E;case"2":return L;case"3":return O;default:return Z}if(w("NODE_DISABLE_COLORS")!==void 0&&w("NODE_DISABLE_COLORS")!==""||w("NO_COLOR")!==void 0&&w("NO_COLOR")!==""||w("TERM")==="dumb")return Z;if(w("TMUX"))return O;if("TF_BUILD"in A&&"AGENT_NAME"in A)return E;if("CI"in A){for(let{0:r,1:e}of Vr)if(r in A)return e;return w("CI_NAME")==="codeship"?L:Z}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(w("TEAMCITY_VERSION"))!==null?E:Z;switch(w("TERM_PROGRAM")){case"iTerm.app":return!w("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(w("TERM_PROGRAM_VERSION"))!==null?L:O;case"HyperTerm":case"MacTerm":return O;case"Apple_Terminal":return L}if(w("COLORTERM")==="truecolor"||w("COLORTERM")==="24bit")return O;if(w("TERM")){if(/truecolor/.exec(w("TERM"))!==null)return O;if(/^xterm-256/.exec(w("TERM"))!==null)return L;let r=w("TERM").toLowerCase();if(ht[r])return ht[r];if(zr.some(e=>e.exec(r)!==null))return E}return w("COLORTERM")?E:Z}var D={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",undim:"\x1B[22m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",fg:{black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m"},bg:{black:"\x1B[40m",red:"\x1B[41m",green:"\x1B[42m",yellow:"\x1B[43m",blue:"\x1B[44m",magenta:"\x1B[45m",cyan:"\x1B[46m",white:"\x1B[47m"}},Ee=["info","success","warn","error","debug"];function Jr(r,e){return Ee.indexOf(e)<=Ee.indexOf(r)}var Yr={info:D.fg.blue,success:D.fg.green,warn:D.fg.yellow,error:D.fg.red,debug:D.fg.magenta},Qr=(r,e,t)=>{let n=new Date().toISOString();return t?`${D.dim}${n}${D.reset} ${Yr[r]}${r.toUpperCase()}${D.reset} ${D.bright}[Better Auth]:${D.reset} ${e}`:`${n} ${r.toUpperCase()} [Better Auth]: ${e}`},Xr=r=>{let e=r?.disabled!==!0,t=r?.level??"error",s=r?.disableColors!==void 0?!r.disableColors:Kr()!==1,o=(c,f,a=[])=>{if(!e||!Jr(t,c))return;let u=Qr(c,f,s);if(!r||typeof r.log!="function"){c==="error"?console.error(u,...a):c==="warn"?console.warn(u,...a):console.log(u,...a);return}r.log(c==="success"?"info":c,f,...a)};return{...Object.fromEntries(Ee.map(c=>[c,(...[f,...a])=>o(c,f,a)])),get level(){return t}}},rs=Xr();l();l();var cs={USER_NOT_FOUND:"User not found",FAILED_TO_CREATE_USER:"Failed to create user",FAILED_TO_CREATE_SESSION:"Failed to create session",FAILED_TO_UPDATE_USER:"Failed to update user",FAILED_TO_GET_SESSION:"Failed to get session",INVALID_PASSWORD:"Invalid password",INVALID_EMAIL:"Invalid email",INVALID_EMAIL_OR_PASSWORD:"Invalid email or password",SOCIAL_ACCOUNT_ALREADY_LINKED:"Social account already linked",PROVIDER_NOT_FOUND:"Provider not found",INVALID_TOKEN:"Invalid token",ID_TOKEN_NOT_SUPPORTED:"id_token not supported",FAILED_TO_GET_USER_INFO:"Failed to get user info",USER_EMAIL_NOT_FOUND:"User email not found",EMAIL_NOT_VERIFIED:"Email not verified",PASSWORD_TOO_SHORT:"Password too short",PASSWORD_TOO_LONG:"Password too long",USER_ALREADY_EXISTS:"User already exists.",USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL:"User already exists. Use another email.",EMAIL_CAN_NOT_BE_UPDATED:"Email can not be updated",CREDENTIAL_ACCOUNT_NOT_FOUND:"Credential account not found",SESSION_EXPIRED:"Session expired. Re-authenticate to perform this action.",FAILED_TO_UNLINK_LAST_ACCOUNT:"You can't unlink your last account",ACCOUNT_NOT_FOUND:"Account not found",USER_ALREADY_HAS_PASSWORD:"User already has a password. Provide that to delete the account."},G=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function Zr(r){try{return(new URL(r).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new G(`Invalid base URL: ${r}. Please provide a valid base URL.`)}}function ee(r,e="/api/auth"){if(Zr(r))return r;let n=r.replace(/\/+$/,"");return!e||e==="/"?n:(e=e.startsWith("/")?e:`/${e}`,`${n}${e}`)}function pt(r,e,t,n){if(r)return ee(r,e);if(n!==!1){let i=A.BETTER_AUTH_URL||A.NEXT_PUBLIC_BETTER_AUTH_URL||A.PUBLIC_BETTER_AUTH_URL||A.NUXT_PUBLIC_BETTER_AUTH_URL||A.NUXT_PUBLIC_AUTH_URL||(A.BASE_URL!=="/"?A.BASE_URL:void 0);if(i)return ee(i,e)}let s=t?.headers.get("x-forwarded-host"),o=t?.headers.get("x-forwarded-proto");if(s&&o)return ee(`${o}://${s}`,e);if(t){let i=en(t.url);if(!i)throw new G("Could not get origin from request. Please provide a valid base URL.");return ee(i,e)}if(typeof window<"u"&&window.location)return ee(window.location.origin,e)}function en(r){try{return new URL(r).origin}catch{return null}}l();l();l();var te=Symbol("clean");var C=[],M=0,de=4,tn=0,re=r=>{let e=[],t={get(){return t.lc||t.listen(()=>{})(),t.value},lc:0,listen(n){return t.lc=e.push(n),()=>{for(let o=M+de;o<C.length;)C[o]===n?C.splice(o,de):o+=de;let s=e.indexOf(n);~s&&(e.splice(s,1),--t.lc||t.off())}},notify(n,s){tn++;let o=!C.length;for(let i of e)C.push(i,t.value,n,s);if(o){for(M=0;M<C.length;M+=de)C[M](C[M+1],C[M+2],C[M+3]);C.length=0}},off(){},set(n){let s=t.value;s!==n&&(t.value=n,t.notify(s))},subscribe(n){let s=t.listen(n);return n(t.value),s},value:r};return process.env.NODE_ENV!=="production"&&(t[te]=()=>{e=[],t.lc=0,t.off()}),t};l();var rn=5,z=6,he=10,nn=(r,e,t,n)=>(r.events=r.events||{},r.events[t+he]||(r.events[t+he]=n(s=>{r.events[t].reduceRight((o,i)=>(i(o),o),{shared:{},...s})})),r.events[t]=r.events[t]||[],r.events[t].push(e),()=>{let s=r.events[t],o=s.indexOf(e);s.splice(o,1),s.length||(delete r.events[t],r.events[t+he](),delete r.events[t+he])});var mt=1e3,Te=(r,e)=>nn(r,n=>{let s=e(n);s&&r.events[z].push(s)},rn,n=>{let s=r.listen;r.listen=(...i)=>(!r.lc&&!r.active&&(r.active=!0,n()),s(...i));let o=r.off;if(r.events[z]=[],r.off=()=>{o(),setTimeout(()=>{if(r.active&&!r.lc){r.active=!1;for(let i of r.events[z])i();r.events[z]=[]}},mt)},process.env.NODE_ENV!=="production"){let i=r[te];r[te]=()=>{for(let c of r.events[z])c();r.events[z]=[],r.active=!1,i()}}return()=>{r.listen=s,r.off=o}});l();var sn=typeof window>"u",pe=(r,e,t,n)=>{let s=re({data:null,error:null,isPending:!0,isRefetching:!1,refetch:c=>o(c)}),o=c=>{let f=typeof n=="function"?n({data:s.get().data,error:s.get().error,isPending:s.get().isPending}):n;t(e,{...f,query:{...f?.query,...c?.query},async onSuccess(a){s.set({data:a.data,error:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await f?.onSuccess?.(a)},async onError(a){let{request:u}=a,d=typeof u.retry=="number"?u.retry:u.retry?.attempts,p=u.retryAttempt||0;d&&p<d||(s.set({error:a.error,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await f?.onError?.(a))},async onRequest(a){let u=s.get();s.set({isPending:u.data===null,data:u.data,error:null,isRefetching:!0,refetch:s.value.refetch}),await f?.onRequest?.(a)}}).catch(a=>{s.set({error:a,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch})})};r=Array.isArray(r)?r:[r];let i=!1;for(let c of r)c.subscribe(()=>{sn||(i?o():Te(s,()=>{let f=setTimeout(()=>{i||(o(),i=!0)},0);return()=>{s.off(),c.off(),clearTimeout(f)}}))});return s};l();var on={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},an=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,gt={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},ln=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function cn(r){return r instanceof Date&&!isNaN(r.getTime())}function un(r){let e=ln.exec(r);if(!e)return null;let[,t,n,s,o,i,c,f,a,u,d]=e,p=new Date(Date.UTC(parseInt(t,10),parseInt(n,10)-1,parseInt(s,10),parseInt(o,10),parseInt(i,10),parseInt(c,10),f?parseInt(f.padEnd(3,"0"),10):0));if(a){let g=(parseInt(u,10)*60+parseInt(d,10))*(a==="+"?-1:1);p.setUTCMinutes(p.getUTCMinutes()+g)}return cn(p)?p:null}function fn(r,e={}){let{strict:t=!1,warnings:n=!1,reviver:s,parseDates:o=!0}=e;if(typeof r!="string")return r;let i=r.trim();if(i.length>0&&i[0]==='"'&&i.endsWith('"')&&!i.slice(1,-1).includes('"'))return i.slice(1,-1);let c=i.toLowerCase();if(c.length<=9&&c in gt)return gt[c];if(!an.test(i)){if(t)throw new SyntaxError("[better-json] Invalid JSON");return r}if(Object.entries(on).some(([a,u])=>{let d=u.test(i);return d&&n&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${a} pattern`),d})&&t)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(i,(u,d)=>{if(u==="__proto__"||u==="constructor"&&d&&typeof d=="object"&&"prototype"in d){n&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof d=="string"){let p=un(d);if(p)return p}return s?s(u,d):d})}catch(a){if(t)throw a;return r}}function yt(r,e={strict:!0}){return fn(r,e)}var dn={id:"redirect",name:"Redirect",hooks:{onSuccess(r){if(r.data?.url&&r.data?.redirect&&typeof window<"u"&&window.location&&window.location)try{window.location.href=r.data.url}catch{}}}};function hn(r){let e=re(!1);return{session:pe(e,"/get-session",r,{method:"GET"}),$sessionSignal:e}}var bt=(r,e)=>{let t="credentials"in Request.prototype,n=pt(r?.baseURL,r?.basePath,void 0,e)??"/api/auth",s=r?.plugins?.flatMap(m=>m.fetchPlugins).filter(m=>m!==void 0)||[],o={id:"lifecycle-hooks",name:"lifecycle-hooks",hooks:{onSuccess:r?.fetchOptions?.onSuccess,onError:r?.fetchOptions?.onError,onRequest:r?.fetchOptions?.onRequest,onResponse:r?.fetchOptions?.onResponse}},{onSuccess:i,onError:c,onRequest:f,onResponse:a,...u}=r?.fetchOptions||{},d=dt({baseURL:n,...t?{credentials:"include"}:{},method:"GET",jsonParser(m){return m?yt(m,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[o,...u.plugins||[],...r?.disableDefaultFetchPlugins?[]:[dn],...s]}),{$sessionSignal:p,session:g}=hn(d),y=r?.plugins||[],v={},b={$sessionSignal:p,session:g},R={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},S=[{signal:"$sessionSignal",matcher(m){return m==="/sign-out"||m==="/update-user"||m.startsWith("/sign-in")||m.startsWith("/sign-up")||m==="/delete-user"||m==="/verify-email"}}];for(let m of y)m.getAtoms&&Object.assign(b,m.getAtoms?.(d)),m.pathMethods&&Object.assign(R,m.pathMethods),m.atomListeners&&S.push(...m.atomListeners);let $={notify:m=>{b[m].set(!b[m].get())},listen:(m,q)=>{b[m].subscribe(q)},atoms:b};for(let m of y)m.getActions&&Object.assign(v,m.getActions?.(d,$,r));return{get baseURL(){return n},pluginsActions:v,pluginsAtoms:b,pluginPathMethods:R,atomListeners:S,$fetch:d,$store:$}};function pn(r){return typeof r=="object"&&r!==null&&"get"in r&&typeof r.get=="function"&&"lc"in r&&typeof r.lc=="number"}function mn(r,e,t){let n=e[r],{fetchOptions:s,query:o,...i}=t||{};return n||(s?.method?s.method:i&&Object.keys(i).length>0?"POST":"GET")}function wt(r,e,t,n,s){function o(i=[]){return new Proxy(function(){},{get(c,f){if(typeof f!="string"||f==="then"||f==="catch"||f==="finally")return;let a=[...i,f],u=r;for(let d of a)if(u&&typeof u=="object"&&d in u)u=u[d];else{u=void 0;break}return typeof u=="function"||pn(u)?u:o(a)},apply:async(c,f,a)=>{let u="/"+i.map(S=>S.replace(/[A-Z]/g,$=>`-${$.toLowerCase()}`)).join("/"),d=a[0]||{},p=a[1]||{},{query:g,fetchOptions:y,...v}=d,b={...p,...y},R=mn(u,t,d);return await e(u,{...b,body:R==="GET"?void 0:{...v,...b?.body||{}},query:g||b?.query,method:R,async onSuccess(S){if(await b?.onSuccess?.(S),!s)return;let $=s.filter(m=>m.matcher(u));if($.length)for(let m of $){let q=n[m.signal];if(!q)return;let _=q.get();setTimeout(()=>{q.set(!_)},10)}}})}})}return o()}l();function _t(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Pe(r){let{pluginPathMethods:e,pluginsActions:t,pluginsAtoms:n,$fetch:s,atomListeners:o,$store:i}=bt(r),c={};for(let[u,d]of Object.entries(n))c[`use${_t(u)}`]=d;let f={...t,...c,$fetch:s,$store:i};return wt(f,s,e,n,o)}l();l();l();function gn(r){return{authorize(e,t="AND"){let n=!1;for(let[s,o]of Object.entries(e)){let i=r[s];if(!i)return{success:!1,error:`You are not allowed to access resource: ${s}`};if(Array.isArray(o))n=o.every(c=>i.includes(c));else if(typeof o=="object"){let c=o;c.connector==="OR"?n=c.actions.some(f=>i.includes(f)):n=c.actions.every(f=>i.includes(f))}else throw new G("Invalid access control request");if(n&&t==="OR")return{success:n};if(!n&&t==="AND")return{success:!1,error:`unauthorized to access resource "${s}"`}}return n?{success:n}:{success:!1,error:"Not authorized"}},statements:r}}function me(r){return{newRole(e){return gn(e)},statements:r}}var yn={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},Se=me(yn),bn=Se.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),wn=Se.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),_n=Se.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});l();l();l();l();l();l();l();l();l();l();l();var Oe=class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let t=new Error("Cancelling existing WebAuthn API call for new one");t.name="AbortError",this.controller.abort(t)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}},Et=new Oe;l();l();l();l();l();l();l();l();var Pn={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},Tt=me(Pn),Sn=Tt.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),On=Tt.newRole({user:[],session:[]});l();l();var Pt=()=>({id:"username",$InferServerPlugin:{}});var St=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(r){return r==="/phone-number/update"||r==="/phone-number/verify"},signal:"$sessionSignal"}]});var Ot=()=>({id:"better-auth-client",$InferServerPlugin:{}});var At="/auth",ne="nvwa_login_token",ge="nvwa_user_profile",xe=class{constructor(e,t,n){this.storage=n;let s=Pe({baseURL:e,basePath:At,plugins:[Pt(),St(),Ot()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:()=>n.get(ne)},onSuccess:o=>{let i=o.response.headers.get("set-auth-token");console.log("success",o.data,o.request),i&&n.set(ne,i)}}});this.authClient=s}async currentUser(){return await this.storage.get(ge)}async signUp(e){let t=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:e.password});this.saveSession(t)}async sendPhoneNumberCode(e){await this.authClient.phoneNumber.sendOtp({phoneNumber:e})}async signInWithPhoneNumberCode(e,t){let n=await this.authClient.phoneNumber.verify({phoneNumber:e,code:t});this.saveSession(n)}async signInWithPhoneNumber(e,t,n=!1){let s=await this.authClient.signIn.phoneNumber({phoneNumber:e,password:t,rememberMe:n});this.saveSession(s)}async signInWithUsername(e,t){let n=await this.authClient.signIn.username({username:e,password:t});this.saveSession(n)}saveSession(e){if(e.error)throw new Error(e.error.message);this.storage.set(ne,e.data?.token),this.storage.set(ge,e.data?.user)}async signOut(){await this.storage.remove(ne),await this.storage.remove(ge)}async updateUserPassword(e,t,n=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:n});this.saveSession(s)}};l();var Ie=class{constructor(e){this.http=e}async invoke(e,t){return(await this.http.request("/functions/"+e,{method:t.method||"POST",data:t.body,headers:t.headers})).body}};l();var Ue=class{async jsonRequest(e,t){let n={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.request(e,n)}async jsonRequestWithAuth(e,t,n){let s={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.requestWithAuth(e,s,n)}};l();var xt="/storage",It=xt+"/generateUploadUrl",Ce=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.request(this.baseUrl+It,{method:"POST",data:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:n}=t.body;if(!n)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");return{url:(await this.http.request(n,{method:"PUT",data:e,headers:{"Content-Type":e.type||e.fileType||"application/octet-stream"}})).body.url.split("?")[0]}}};l();l();l();var Xe=Er(dr(),1),{PostgrestClient:hr,PostgrestQueryBuilder:Na,PostgrestFilterBuilder:La,PostgrestTransformBuilder:Da,PostgrestBuilder:$a,PostgrestError:ja}=Xe.default||Xe;l();l();var x=class r{constructor(e){this.headerMap=new Map;if(e){if(e instanceof r)e.forEach((t,n)=>this.set(n,t));else if(Array.isArray(e))for(let[t,n]of e)this.set(t,String(n));else if(typeof e=="object")for(let t of Object.keys(e))this.set(t,String(e[t]))}}append(e,t){let n=e.toLowerCase(),s=this.headerMap.get(n);this.headerMap.set(n,s?`${s}, ${t}`:t)}set(e,t){this.headerMap.set(e.toLowerCase(),String(t))}get(e){let t=this.headerMap.get(e.toLowerCase());return t??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[t,n]of this.headerMap.entries())e(n,t,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},Y=class r{constructor(e){this.params=new Map;if(e){if(typeof e=="string")this.parseString(e);else if(e instanceof r)this.params=new Map(e.params);else if(Array.isArray(e))for(let[t,n]of e)this.append(t,n);else if(e&&typeof e=="object")for(let[t,n]of Object.entries(e))this.set(t,n)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let t=e.split("&");for(let n of t)if(n){let[s,o]=n.split("=");s&&this.append(decodeURIComponent(s),o?decodeURIComponent(o):"")}}append(e,t){let n=this.params.get(e)||[];n.push(t),this.params.set(e,n)}delete(e){this.params.delete(e)}get(e){let t=this.params.get(e);return t?t[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,t){this.params.set(e,[t])}sort(){let e=Array.from(this.params.entries()).sort(([t],[n])=>t.localeCompare(n));this.params=new Map(e)}toString(){let e=[];for(let[t,n]of this.params.entries())for(let s of n)e.push(`${encodeURIComponent(t)}=${encodeURIComponent(s)}`);return e.join("&")}forEach(e){for(let[t,n]of this.params.entries())for(let s of n)e(s,t,this)}keys(){return this.params.keys()}values(){let e=[];for(let t of this.params.values())e.push(...t);return e[Symbol.iterator]()}entries(){let e=[];for(let[t,n]of this.params.entries())for(let s of n)e.push([t,s]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},oe=class r{constructor(e,t){let n;if(e instanceof r)n=e.href;else if(t){let o=t instanceof r?t.href:t;n=this.resolve(o,e)}else n=e;let s=this.parseUrl(n);this.href=n,this.origin=`${s.protocol}//${s.host}`,this.protocol=s.protocol,this.username=s.username,this.password=s.password,this.host=s.host,this.hostname=s.hostname,this.port=s.port,this.pathname=s.pathname,this.search=s.search,this.searchParams=new Y(s.search),this.hash=s.hash}resolve(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(t.startsWith("//"))return`${this.parseUrl(e).protocol}${t}`;if(t.startsWith("/")){let o=this.parseUrl(e);return`${o.protocol}//${o.host}${t}`}let n=this.parseUrl(e),s=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return`${n.protocol}//${n.host}${s}${t}`}parseUrl(e){let t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)throw new TypeError("Invalid URL");let n=t[2]||"",s=t[4]||"",o=t[5]||"/",i=t[7]?`?${t[7]}`:"",c=t[9]?`#${t[9]}`:"";if(!n&&!s&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let f=s.match(/^([^@]*)@(.+)$/),a="",u="",d=s;if(f){let v=f[1];d=f[2];let b=v.match(/^([^:]*):?(.*)$/);b&&(a=b[1]||"",u=b[2]||"")}let p=d.match(/^([^:]+):?(\d*)$/),g=p?p[1]:d,y=p&&p[2]?p[2]:"";return{protocol:n?`${n}:`:"",username:a,password:u,host:d,hostname:g,port:y,pathname:o,search:i,hash:c}}toString(){let e=this.searchParams.toString(),t=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${t}${this.hash}`}toJSON(){return this.toString()}};l();var ie=class r{constructor(e,t){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(t?.method||"GET").toUpperCase(),this.headers=t?.headers instanceof x?t.headers:new x(t?.headers),this.body=t?.body,this.timeout=t?.timeout,this.signal=t?.signal||void 0}clone(){return new r(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};l();var B=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=qn(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function qn(r){return r?new x(r):new x}l();var Q=class{constructor(){this._aborted=!1;this.listeners=new Set;this.onabort=null}get aborted(){return this._aborted}_trigger(){if(!this._aborted){if(this._aborted=!0,typeof this.onabort=="function")try{this.onabort()}catch{}for(let e of Array.from(this.listeners))try{e()}catch{}this.listeners.clear()}}addEventListener(e,t){if(this._aborted){try{t()}catch{}return}this.listeners.add(t)}removeEventListener(e,t){this.listeners.delete(t)}toString(){return"[object AbortSignal]"}},ae=class{constructor(){this._signal=new Q}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};l();function Hn(r){r.URL=oe,r.URLSearchParams=Y,r.Headers=x,r.Request=ie,r.Response=B,r.AbortController=ae,r.AbortSignal=Q}var pr="/entities",Fn=(r,e)=>async(n,s)=>{console.log("customFetch",n,s);let o;if(typeof n=="string")o=n;else if(n&&typeof n=="object")if(typeof n.toString=="function"&&!n.url)o=n.toString();else if(n.url)o=n.url,s||(s={}),s.method=n.method,s.headers=n.headers,s.body=n.body;else throw new Error("Unsupported input type for fetch");else throw new Error("Unsupported input type for fetch");let i=(s?.method||"GET").toUpperCase(),c={};if(s?.headers)if(s.headers&&typeof s.headers.forEach=="function")s.headers.forEach((g,y)=>{c[y]=g});else if(Array.isArray(s.headers))for(let[g,y]of s.headers)c[g]=y;else Object.assign(c,s.headers);let f=s?.body,a;try{a=await r.requestWithAuth(o,{method:i,data:f,headers:c},e)}catch(g){return new B(g?.message||"Internal Error",{status:500,statusText:"Internal Error"})}let u=a.body,d=null;return(a.headers["content-type"]||a.headers["Content-Type"]||"").startsWith("application/json")&&typeof u!="string"?d=JSON.stringify(u):typeof u=="string"||u&&(u.constructor===Blob||u.constructor===ArrayBuffer||typeof u.getReader=="function")?d=u:d=JSON.stringify(u),new B(d,{status:a.status,headers:new x(a.headers)})},Gn=(r,e,t)=>new hr(r+pr,{fetch:Fn(e,t)});0&&(module.exports={AUTH_BASE_PATH,AbortController,AbortSignal,ENTITIES_BASE_PATH,FILE_STORAGE_BASE_PATH,GENERATE_UPLOAD_URL_PATH,Headers,LOGIN_TOKEN_KEY,LOGIN_USER_PROFILE_KEY,NvwaAuthClient,NvwaEdgeFunctions,NvwaFileStorage,NvwaHttpClient,Request,Response,URL,URLSearchParams,createPostgrestClient,polyfill});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var dr=Object.create;var ie=Object.defineProperty;var hr=Object.getOwnPropertyDescriptor;var pr=Object.getOwnPropertyNames;var mr=Object.getPrototypeOf,gr=Object.prototype.hasOwnProperty;var Xe=(r,e)=>()=>(r&&(e=r(r=0)),e);var H=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),yr=(r,e)=>{for(var t in e)ie(r,t,{get:e[t],enumerable:!0})},Ze=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of pr(e))!gr.call(r,n)&&n!==t&&ie(r,n,{get:()=>e[n],enumerable:!(s=hr(e,n))||s.enumerable});return r};var br=(r,e,t)=>(t=r!=null?dr(mr(r)):{},Ze(e||!r||!r.__esModule?ie(t,"default",{value:r,enumerable:!0}):t,r)),z=r=>Ze(ie({},"__esModule",{value:!0}),r);import Gs from"path";import{fileURLToPath as Vs}from"url";var l=Xe(()=>{"use strict"});var G={};yr(G,{__addDisposableResource:()=>Yt,__assign:()=>pe,__asyncDelegator:()=>Ht,__asyncGenerator:()=>qt,__asyncValues:()=>Ft,__await:()=>J,__awaiter:()=>Dt,__classPrivateFieldGet:()=>zt,__classPrivateFieldIn:()=>Jt,__classPrivateFieldSet:()=>Kt,__createBinding:()=>ge,__decorate:()=>At,__disposeResources:()=>Qt,__esDecorate:()=>It,__exportStar:()=>jt,__extends:()=>Pt,__generator:()=>$t,__importDefault:()=>Vt,__importStar:()=>Wt,__makeTemplateObject:()=>Gt,__metadata:()=>Lt,__param:()=>xt,__propKey:()=>Ct,__read:()=>Ce,__rest:()=>Ot,__rewriteRelativeImportExtension:()=>Xt,__runInitializers:()=>Ut,__setFunctionName:()=>Nt,__spread:()=>kt,__spreadArray:()=>Bt,__spreadArrays:()=>Mt,__values:()=>me,default:()=>Os});function Pt(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Ie(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Ot(r,e){var t={};for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&e.indexOf(s)<0&&(t[s]=r[s]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(r);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(r,s[n])&&(t[s[n]]=r[s[n]]);return t}function At(r,e,t,s){var n=arguments.length,o=n<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(r,e,t,s);else for(var c=r.length-1;c>=0;c--)(i=r[c])&&(o=(n<3?i(o):n>3?i(e,t,o):i(e,t))||o);return n>3&&o&&Object.defineProperty(e,t,o),o}function xt(r,e){return function(t,s){e(t,s,r)}}function It(r,e,t,s,n,o){function i(E){if(E!==void 0&&typeof E!="function")throw new TypeError("Function expected");return E}for(var c=s.kind,f=c==="getter"?"get":c==="setter"?"set":"value",a=!e&&r?s.static?r:r.prototype:null,u=e||(a?Object.getOwnPropertyDescriptor(a,s.name):{}),d,m=!1,y=t.length-1;y>=0;y--){var b={};for(var v in s)b[v]=v==="access"?{}:s[v];for(var v in s.access)b.access[v]=s.access[v];b.addInitializer=function(E){if(m)throw new TypeError("Cannot add initializers after decoration has completed");o.push(i(E||null))};var w=(0,t[y])(c==="accessor"?{get:u.get,set:u.set}:u[f],b);if(c==="accessor"){if(w===void 0)continue;if(w===null||typeof w!="object")throw new TypeError("Object expected");(d=i(w.get))&&(u.get=d),(d=i(w.set))&&(u.set=d),(d=i(w.init))&&n.unshift(d)}else(d=i(w))&&(c==="field"?n.unshift(d):u[f]=d)}a&&Object.defineProperty(a,s.name,u),m=!0}function Ut(r,e,t){for(var s=arguments.length>2,n=0;n<e.length;n++)t=s?e[n].call(r,t):e[n].call(r);return s?t:void 0}function Ct(r){return typeof r=="symbol"?r:"".concat(r)}function Nt(r,e,t){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(r,"name",{configurable:!0,value:t?"".concat(t," ",e):e})}function Lt(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function Dt(r,e,t,s){function n(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function c(u){try{a(s.next(u))}catch(d){i(d)}}function f(u){try{a(s.throw(u))}catch(d){i(d)}}function a(u){u.done?o(u.value):n(u.value).then(c,f)}a((s=s.apply(r,e||[])).next())})}function $t(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},s,n,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(a){return function(u){return f([a,u])}}function f(a){if(s)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(t=0)),t;)try{if(s=1,n&&(o=a[0]&2?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return t.label++,{value:a[1],done:!1};case 5:t.label++,n=a[1],a=[0];continue;case 7:a=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){t.label=a[1];break}if(a[0]===6&&t.label<o[1]){t.label=o[1],o=a;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(a);break}o[2]&&t.ops.pop(),t.trys.pop();continue}a=e.call(r,t)}catch(u){a=[6,u],n=0}finally{s=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function jt(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&ge(e,r,t)}function me(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],s=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&s>=r.length&&(r=void 0),{value:r&&r[s++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ce(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var s=t.call(r),n,o=[],i;try{for(;(e===void 0||e-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(c){i={error:c}}finally{try{n&&!n.done&&(t=s.return)&&t.call(s)}finally{if(i)throw i.error}}return o}function kt(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(Ce(arguments[e]));return r}function Mt(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var o=arguments[e],i=0,c=o.length;i<c;i++,n++)s[n]=o[i];return s}function Bt(r,e,t){if(t||arguments.length===2)for(var s=0,n=e.length,o;s<n;s++)(o||!(s in e))&&(o||(o=Array.prototype.slice.call(e,0,s)),o[s]=e[s]);return r.concat(o||Array.prototype.slice.call(e))}function J(r){return this instanceof J?(this.v=r,this):new J(r)}function qt(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=t.apply(r,e||[]),n,o=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",i),n[Symbol.asyncIterator]=function(){return this},n;function i(y){return function(b){return Promise.resolve(b).then(y,d)}}function c(y,b){s[y]&&(n[y]=function(v){return new Promise(function(w,E){o.push([y,v,w,E])>1||f(y,v)})},b&&(n[y]=b(n[y])))}function f(y,b){try{a(s[y](b))}catch(v){m(o[0][3],v)}}function a(y){y.value instanceof J?Promise.resolve(y.value.v).then(u,d):m(o[0][2],y)}function u(y){f("next",y)}function d(y){f("throw",y)}function m(y,b){y(b),o.shift(),o.length&&f(o[0][0],o[0][1])}}function Ht(r){var e,t;return e={},s("next"),s("throw",function(n){throw n}),s("return"),e[Symbol.iterator]=function(){return this},e;function s(n,o){e[n]=r[n]?function(i){return(t=!t)?{value:J(r[n](i)),done:!1}:o?o(i):i}:o}}function Ft(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof me=="function"?me(r):r[Symbol.iterator](),t={},s("next"),s("throw"),s("return"),t[Symbol.asyncIterator]=function(){return this},t);function s(o){t[o]=r[o]&&function(i){return new Promise(function(c,f){i=r[o](i),n(c,f,i.done,i.value)})}}function n(o,i,c,f){Promise.resolve(f).then(function(a){o({value:a,done:c})},i)}}function Gt(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function Wt(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t=Ue(r),s=0;s<t.length;s++)t[s]!=="default"&&ge(e,r,t[s]);return Ss(e,r),e}function Vt(r){return r&&r.__esModule?r:{default:r}}function zt(r,e,t,s){if(t==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?s:t==="a"?s.call(r):s?s.value:e.get(r)}function Kt(r,e,t,s,n){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t}function Jt(r,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof r=="function"?e===r:r.has(e)}function Yt(r,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var s,n;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=e[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=e[Symbol.dispose],t&&(n=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");n&&(s=function(){try{n.call(this)}catch(o){return Promise.reject(o)}}),r.stack.push({value:e,dispose:s,async:t})}else t&&r.stack.push({async:!0});return e}function Qt(r){function e(o){r.error=r.hasError?new Ps(o,r.error,"An error was suppressed during disposal."):o,r.hasError=!0}var t,s=0;function n(){for(;t=r.stack.pop();)try{if(!t.async&&s===1)return s=0,r.stack.push(t),Promise.resolve().then(n);if(t.dispose){var o=t.dispose.call(t.value);if(t.async)return s|=2,Promise.resolve(o).then(n,function(i){return e(i),n()})}else s|=1}catch(i){e(i)}if(s===1)return r.hasError?Promise.reject(r.error):Promise.resolve();if(r.hasError)throw r.error}return n()}function Xt(r,e){return typeof r=="string"&&/^\.\.?\//.test(r)?r.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,s,n,o,i){return s?e?".jsx":".js":n&&(!o||!i)?t:n+o+"."+i.toLowerCase()+"js"}):r}var Ie,pe,ge,Ss,Ue,Ps,Os,W=Xe(()=>{"use strict";l();Ie=function(r,e){return Ie=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,s){t.__proto__=s}||function(t,s){for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(t[n]=s[n])},Ie(r,e)};pe=function(){return pe=Object.assign||function(e){for(var t,s=1,n=arguments.length;s<n;s++){t=arguments[s];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},pe.apply(this,arguments)};ge=Object.create?(function(r,e,t,s){s===void 0&&(s=t);var n=Object.getOwnPropertyDescriptor(e,t);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,s,n)}):(function(r,e,t,s){s===void 0&&(s=t),r[s]=e[t]});Ss=Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e},Ue=function(r){return Ue=Object.getOwnPropertyNames||function(e){var t=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[t.length]=s);return t},Ue(r)};Ps=typeof SuppressedError=="function"?SuppressedError:function(r,e,t){var s=new Error(t);return s.name="SuppressedError",s.error=r,s.suppressed=e,s};Os={__extends:Pt,__assign:pe,__rest:Ot,__decorate:At,__param:xt,__esDecorate:It,__runInitializers:Ut,__propKey:Ct,__setFunctionName:Nt,__metadata:Lt,__awaiter:Dt,__generator:$t,__createBinding:ge,__exportStar:jt,__values:me,__read:Ce,__spread:kt,__spreadArrays:Mt,__spreadArray:Bt,__await:J,__asyncGenerator:qt,__asyncDelegator:Ht,__asyncValues:Ft,__makeTemplateObject:Gt,__importStar:Wt,__importDefault:Vt,__classPrivateFieldGet:zt,__classPrivateFieldSet:Kt,__classPrivateFieldIn:Jt,__addDisposableResource:Yt,__disposeResources:Qt,__rewriteRelativeImportExtension:Xt}});var De=H(Le=>{"use strict";l();Object.defineProperty(Le,"__esModule",{value:!0});var Ne=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};Le.default=Ne});var ke=H(je=>{"use strict";l();Object.defineProperty(je,"__esModule",{value:!0});var As=(W(),z(G)),xs=As.__importDefault(De()),$e=class{constructor(e){var t,s;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(s=e.isMaybeSingle)!==null&&s!==void 0?s:!1,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let s=this.fetch,n=s(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async o=>{var i,c,f,a;let u=null,d=null,m=null,y=o.status,b=o.statusText;if(o.ok){if(this.method!=="HEAD"){let O=await o.text();O===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((i=this.headers.get("Accept"))===null||i===void 0)&&i.includes("application/vnd.pgrst.plan+text"))?d=O:d=JSON.parse(O))}let w=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),E=(f=o.headers.get("content-range"))===null||f===void 0?void 0:f.split("/");w&&E&&E.length>1&&(m=parseInt(E[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(u={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,m=null,y=406,b="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let w=await o.text();try{u=JSON.parse(w),Array.isArray(u)&&o.status===404&&(d=[],u=null,y=200,b="OK")}catch{o.status===404&&w===""?(y=204,b="No Content"):u={message:w}}if(u&&this.isMaybeSingle&&(!((a=u?.details)===null||a===void 0)&&a.includes("0 rows"))&&(u=null,y=200,b="OK"),u&&this.shouldThrowOnError)throw new xs.default(u)}return{error:u,data:d,count:m,status:y,statusText:b}});return this.shouldThrowOnError||(n=n.catch(o=>{var i,c,f;return{error:{message:`${(i=o?.name)!==null&&i!==void 0?i:"FetchError"}: ${o?.message}`,details:`${(c=o?.stack)!==null&&c!==void 0?c:""}`,hint:"",code:`${(f=o?.code)!==null&&f!==void 0?f:""}`},data:null,count:null,status:0,statusText:""}})),n.then(e,t)}returns(){return this}overrideTypes(){return this}};je.default=$e});var qe=H(Be=>{"use strict";l();Object.defineProperty(Be,"__esModule",{value:!0});var Is=(W(),z(G)),Us=Is.__importDefault(ke()),Me=class extends Us.default{select(e){let t=!1,s=(e??"*").split("").map(n=>/\s/.test(n)&&!t?"":(n==='"'&&(t=!t),n)).join("");return this.url.searchParams.set("select",s),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:s,foreignTable:n,referencedTable:o=n}={}){let i=o?`${o}.order`:"order",c=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${c?`${c},`:""}${e}.${t?"asc":"desc"}${s===void 0?"":s?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:s=t}={}){let n=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(n,`${e}`),this}range(e,t,{foreignTable:s,referencedTable:n=s}={}){let o=typeof n>"u"?"offset":`${n}.offset`,i=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(o,`${e}`),this.url.searchParams.set(i,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:s=!1,buffers:n=!1,wal:o=!1,format:i="text"}={}){var c;let f=[e?"analyze":null,t?"verbose":null,s?"settings":null,n?"buffers":null,o?"wal":null].filter(Boolean).join("|"),a=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${a}"; options=${f};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};Be.default=Me});var ye=H(Fe=>{"use strict";l();Object.defineProperty(Fe,"__esModule",{value:!0});var Cs=(W(),z(G)),Ns=Cs.__importDefault(qe()),Ls=new RegExp("[,()]"),He=class extends Ns.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(n=>typeof n=="string"&&Ls.test(n)?`"${n}"`:`${n}`).join(",");return this.url.searchParams.append(e,`in.(${s})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:s,type:n}={}){let o="";n==="plain"?o="pl":n==="phrase"?o="ph":n==="websearch"&&(o="w");let i=s===void 0?"":`(${s})`;return this.url.searchParams.append(e,`${o}fts${i}.${t}`),this}match(e){return Object.entries(e).forEach(([t,s])=>{this.url.searchParams.append(t,`eq.${s}`)}),this}not(e,t,s){return this.url.searchParams.append(e,`not.${t}.${s}`),this}or(e,{foreignTable:t,referencedTable:s=t}={}){let n=s?`${s}.or`:"or";return this.url.searchParams.append(n,`(${e})`),this}filter(e,t,s){return this.url.searchParams.append(e,`${t}.${s}`),this}};Fe.default=He});var Ve=H(We=>{"use strict";l();Object.defineProperty(We,"__esModule",{value:!0});var Ds=(W(),z(G)),re=Ds.__importDefault(ye()),Ge=class{constructor(e,{headers:t={},schema:s,fetch:n}){this.url=e,this.headers=new Headers(t),this.schema=s,this.fetch=n}select(e,t){let{head:s=!1,count:n}=t??{},o=s?"HEAD":"GET",i=!1,c=(e??"*").split("").map(f=>/\s/.test(f)&&!i?"":(f==='"'&&(i=!i),f)).join("");return this.url.searchParams.set("select",c),n&&this.headers.append("Prefer",`count=${n}`),new re.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:s=!0}={}){var n;let o="POST";if(t&&this.headers.append("Prefer",`count=${t}`),s||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let i=e.reduce((c,f)=>c.concat(Object.keys(f)),[]);if(i.length>0){let c=[...new Set(i)].map(f=>`"${f}"`);this.url.searchParams.set("columns",c.join(","))}}return new re.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:s=!1,count:n,defaultToNull:o=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${s?"ignore":"merge"}-duplicates`),t!==void 0&&this.url.searchParams.set("on_conflict",t),n&&this.headers.append("Prefer",`count=${n}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let f=e.reduce((a,u)=>a.concat(Object.keys(u)),[]);if(f.length>0){let a=[...new Set(f)].map(u=>`"${u}"`);this.url.searchParams.set("columns",a.join(","))}}return new re.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(e,{count:t}={}){var s;let n="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new re.default({method:n,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}delete({count:e}={}){var t;let s="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new re.default({method:s,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};We.default=Ge});var er=H(Ke=>{"use strict";l();Object.defineProperty(Ke,"__esModule",{value:!0});var Zt=(W(),z(G)),$s=Zt.__importDefault(Ve()),js=Zt.__importDefault(ye()),ze=class r{constructor(e,{headers:t={},schema:s,fetch:n}={}){this.url=e,this.headers=new Headers(t),this.schemaName=s,this.fetch=n}from(e){let t=new URL(`${this.url}/${e}`);return new $s.default(t,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new r(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:s=!1,get:n=!1,count:o}={}){var i;let c,f=new URL(`${this.url}/rpc/${e}`),a;s||n?(c=s?"HEAD":"GET",Object.entries(t).filter(([d,m])=>m!==void 0).map(([d,m])=>[d,Array.isArray(m)?`{${m.join(",")}}`:`${m}`]).forEach(([d,m])=>{f.searchParams.append(d,m)})):(c="POST",a=t);let u=new Headers(this.headers);return o&&u.set("Prefer",`count=${o}`),new js.default({method:c,url:f,headers:u,schema:this.schemaName,body:a,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}};Ke.default=ze});var ar=H(P=>{"use strict";l();Object.defineProperty(P,"__esModule",{value:!0});P.PostgrestError=P.PostgrestBuilder=P.PostgrestTransformBuilder=P.PostgrestFilterBuilder=P.PostgrestQueryBuilder=P.PostgrestClient=void 0;var Y=(W(),z(G)),tr=Y.__importDefault(er());P.PostgrestClient=tr.default;var rr=Y.__importDefault(Ve());P.PostgrestQueryBuilder=rr.default;var sr=Y.__importDefault(ye());P.PostgrestFilterBuilder=sr.default;var nr=Y.__importDefault(qe());P.PostgrestTransformBuilder=nr.default;var or=Y.__importDefault(ke());P.PostgrestBuilder=or.default;var ir=Y.__importDefault(De());P.PostgrestError=ir.default;P.default={PostgrestClient:tr.default,PostgrestQueryBuilder:rr.default,PostgrestFilterBuilder:sr.default,PostgrestTransformBuilder:nr.default,PostgrestBuilder:or.default,PostgrestError:ir.default}});l();l();l();l();l();l();var wr=Object.defineProperty,_r=Object.defineProperties,Rr=Object.getOwnPropertyDescriptors,et=Object.getOwnPropertySymbols,vr=Object.prototype.hasOwnProperty,Er=Object.prototype.propertyIsEnumerable,tt=(r,e,t)=>e in r?wr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,C=(r,e)=>{for(var t in e||(e={}))vr.call(e,t)&&tt(r,t,e[t]);if(et)for(var t of et(e))Er.call(e,t)&&tt(r,t,e[t]);return r},L=(r,e)=>_r(r,Rr(e)),Tr=class extends Error{constructor(r,e,t){super(e||r.toString(),{cause:t}),this.status=r,this.statusText=e,this.error=t}},Sr=async(r,e)=>{var t,s,n,o,i,c;let f=e||{},a={onRequest:[e?.onRequest],onResponse:[e?.onResponse],onSuccess:[e?.onSuccess],onError:[e?.onError],onRetry:[e?.onRetry]};if(!e||!e?.plugins)return{url:r,options:f,hooks:a};for(let u of e?.plugins||[]){if(u.init){let d=await((t=u.init)==null?void 0:t.call(u,r.toString(),e));f=d.options||f,r=d.url}a.onRequest.push((s=u.hooks)==null?void 0:s.onRequest),a.onResponse.push((n=u.hooks)==null?void 0:n.onResponse),a.onSuccess.push((o=u.hooks)==null?void 0:o.onSuccess),a.onError.push((i=u.hooks)==null?void 0:i.onError),a.onRetry.push((c=u.hooks)==null?void 0:c.onRetry)}return{url:r,options:f,hooks:a}},rt=class{constructor(r){this.options=r}shouldAttemptRetry(r,e){return this.options.shouldRetry?Promise.resolve(r<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(r<this.options.attempts)}getDelay(){return this.options.delay}},Pr=class{constructor(r){this.options=r}shouldAttemptRetry(r,e){return this.options.shouldRetry?Promise.resolve(r<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(r<this.options.attempts)}getDelay(r){return Math.min(this.options.maxDelay,this.options.baseDelay*2**r)}};function Or(r){if(typeof r=="number")return new rt({type:"linear",attempts:r,delay:1e3});switch(r.type){case"linear":return new rt(r);case"exponential":return new Pr(r);default:throw new Error("Invalid retry strategy")}}var Ar=async r=>{let e={},t=async s=>typeof s=="function"?await s():s;if(r?.auth){if(r.auth.type==="Bearer"){let s=await t(r.auth.token);if(!s)return e;e.authorization=`Bearer ${s}`}else if(r.auth.type==="Basic"){let s=t(r.auth.username),n=t(r.auth.password);if(!s||!n)return e;e.authorization=`Basic ${btoa(`${s}:${n}`)}`}else if(r.auth.type==="Custom"){let s=t(r.auth.value);if(!s)return e;e.authorization=`${t(r.auth.prefix)} ${s}`}}return e},xr=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Ir(r){let e=r.headers.get("content-type"),t=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!e)return"json";let s=e.split(";").shift()||"";return xr.test(s)?"json":t.has(s)||s.startsWith("text/")?"text":"blob"}function Ur(r){try{return JSON.parse(r),!0}catch{return!1}}function ot(r){if(r===void 0)return!1;let e=typeof r;return e==="string"||e==="number"||e==="boolean"||e===null?!0:e!=="object"?!1:Array.isArray(r)?!0:r.buffer?!1:r.constructor&&r.constructor.name==="Object"||typeof r.toJSON=="function"}function st(r){try{return JSON.parse(r)}catch{return r}}function nt(r){return typeof r=="function"}function Cr(r){if(r?.customFetchImpl)return r.customFetchImpl;if(typeof globalThis<"u"&&nt(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&nt(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function Nr(r){let e=new Headers(r?.headers),t=await Ar(r);for(let[s,n]of Object.entries(t||{}))e.set(s,n);if(!e.has("content-type")){let s=Lr(r?.body);s&&e.set("content-type",s)}return e}function Lr(r){return ot(r)?"application/json":null}function Dr(r){if(!r?.body)return null;let e=new Headers(r?.headers);if(ot(r.body)&&!e.has("content-type")){for(let[t,s]of Object.entries(r?.body))s instanceof Date&&(r.body[t]=s.toISOString());return JSON.stringify(r.body)}return r.body}function $r(r,e){var t;if(e?.method)return e.method.toUpperCase();if(r.startsWith("@")){let s=(t=r.split("@")[1])==null?void 0:t.split("/")[0];return at.includes(s)?s.toUpperCase():e?.body?"POST":"GET"}return e?.body?"POST":"GET"}function jr(r,e){let t;return!r?.signal&&r?.timeout&&(t=setTimeout(()=>e?.abort(),r?.timeout)),{abortTimeout:t,clearTimeout:()=>{t&&clearTimeout(t)}}}var kr=class it extends Error{constructor(e,t){super(t||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,it.prototype)}};async function ae(r,e){let t=await r["~standard"].validate(e);if(t.issues)throw new kr(t.issues);return t.value}var at=["get","post","put","patch","delete"];var Mr=r=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(e,t){var s,n,o,i;let c=((n=(s=r.plugins)==null?void 0:s.find(f=>{var a;return(a=f.schema)!=null&&a.config?e.startsWith(f.schema.config.baseURL||"")||e.startsWith(f.schema.config.prefix||""):!1}))==null?void 0:n.schema)||r.schema;if(c){let f=e;(o=c.config)!=null&&o.prefix&&f.startsWith(c.config.prefix)&&(f=f.replace(c.config.prefix,""),c.config.baseURL&&(e=e.replace(c.config.prefix,c.config.baseURL))),(i=c.config)!=null&&i.baseURL&&f.startsWith(c.config.baseURL)&&(f=f.replace(c.config.baseURL,""));let a=c.schema[f];if(a){let u=L(C({},t),{method:a.method,output:a.output});return t?.disableValidation||(u=L(C({},u),{body:a.input?await ae(a.input,t?.body):t?.body,params:a.params?await ae(a.params,t?.params):t?.params,query:a.query?await ae(a.query,t?.query):t?.query})),{url:e,options:u}}}return{url:e,options:t}}}),lt=r=>{async function e(t,s){let n=L(C(C({},r),s),{plugins:[...r?.plugins||[],Mr(r||{})]});if(r?.catchAllError)try{return await ve(t,n)}catch(o){return{data:null,error:{status:500,statusText:"Fetch Error",message:"Fetch related error. Captured by catchAllError option. See error property for more details.",error:o}}}return await ve(t,n)}return e};function Br(r,e){let{baseURL:t,params:s,query:n}=e||{query:{},params:{},baseURL:""},o=r.startsWith("http")?r.split("/").slice(0,3).join("/"):t||"";if(r.startsWith("@")){let d=r.toString().split("@")[1].split("/")[0];at.includes(d)&&(r=r.replace(`@${d}/`,"/"))}o.endsWith("/")||(o+="/");let[i,c]=r.replace(o,"").split("?"),f=new URLSearchParams(c);for(let[d,m]of Object.entries(n||{}))m!=null&&f.set(d,String(m));if(s)if(Array.isArray(s)){let d=i.split("/").filter(m=>m.startsWith(":"));for(let[m,y]of d.entries()){let b=s[m];i=i.replace(y,b)}}else for(let[d,m]of Object.entries(s))i=i.replace(`:${d}`,String(m));i=i.split("/").map(encodeURIComponent).join("/"),i.startsWith("/")&&(i=i.slice(1));let a=f.toString();return a=a.length>0?`?${a}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${i}${a}`,o):`${o}${i}${a}`}var ve=async(r,e)=>{var t,s,n,o,i,c,f,a;let{hooks:u,url:d,options:m}=await Sr(r,e),y=Cr(m),b=new AbortController,v=(t=m.signal)!=null?t:b.signal,w=Br(d,m),E=Dr(m),O=await Nr(m),j=$r(d,m),g=L(C({},m),{url:w,headers:O,body:E,method:j,signal:v});for(let I of u.onRequest)if(I){let S=await I(g);S instanceof Object&&(g=S)}("pipeTo"in g&&typeof g.pipeTo=="function"||typeof((s=e?.body)==null?void 0:s.pipe)=="function")&&("duplex"in g||(g.duplex="half"));let{clearTimeout:q}=jr(m,b),R=await y(g.url,g);q();let Ye={response:R,request:g};for(let I of u.onResponse)if(I){let S=await I(L(C({},Ye),{response:(n=e?.hookOptions)!=null&&n.cloneResponse?R.clone():R}));S instanceof Response?R=S:S instanceof Object&&(R=S.response)}if(R.ok){if(!(g.method!=="HEAD"))return{data:"",error:null};let S=Ir(R),k={data:"",response:R,request:g};if(S==="json"||S==="text"){let M=await R.text(),fr=await((o=g.jsonParser)!=null?o:st)(M);k.data=fr}else k.data=await R[S]();g?.output&&g.output&&!g.disableValidation&&(k.data=await ae(g.output,k.data));for(let M of u.onSuccess)M&&await M(L(C({},k),{response:(i=e?.hookOptions)!=null&&i.cloneResponse?R.clone():R}));return e?.throw?k.data:{data:k.data,error:null}}let cr=(c=e?.jsonParser)!=null?c:st,oe=await R.text(),Qe=Ur(oe),Re=Qe?await cr(oe):null,ur={response:R,responseText:oe,request:g,error:L(C({},Re),{status:R.status,statusText:R.statusText})};for(let I of u.onError)I&&await I(L(C({},ur),{response:(f=e?.hookOptions)!=null&&f.cloneResponse?R.clone():R}));if(e?.retry){let I=Or(e.retry),S=(a=e.retryAttempt)!=null?a:0;if(await I.shouldAttemptRetry(S,R)){for(let M of u.onRetry)M&&await M(Ye);let k=I.getDelay(S);return await new Promise(M=>setTimeout(M,k)),await ve(r,L(C({},e),{retryAttempt:S+1}))}}if(e?.throw)throw new Tr(R.status,R.statusText,Qe?Re:oe);return{data:null,error:L(C({},Re),{status:R.status,statusText:R.statusText})}};l();l();var le=Object.create(null),Q=r=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(r?le:globalThis),x=new Proxy(le,{get(r,e){return Q()[e]??le[e]},has(r,e){let t=Q();return e in t||e in le},set(r,e,t){let s=Q(!0);return s[e]=t,!0},deleteProperty(r,e){if(!e)return!1;let t=Q(!0);return delete t[e],!0},ownKeys(){let r=Q(!0);return Object.keys(r)}});var Zs=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function _(r,e){return typeof process<"u"&&process.env?process.env[r]??e:typeof Deno<"u"?Deno.env.get(r)??e:typeof Bun<"u"?Bun.env[r]??e:e}var en=Object.freeze({get BETTER_AUTH_SECRET(){return _("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return _("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return _("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return _("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return _("NODE_ENV","development")},get PACKAGE_VERSION(){return _("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return _("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),X=1,T=4,D=8,A=24,ct={eterm:T,cons25:T,console:T,cygwin:T,dtterm:T,gnome:T,hurd:T,jfbterm:T,konsole:T,kterm:T,mlterm:T,mosh:A,putty:T,st:T,"rxvt-unicode-24bit":A,terminator:A,"xterm-kitty":A},qr=new Map(Object.entries({APPVEYOR:D,BUILDKITE:D,CIRCLECI:A,DRONE:D,GITEA_ACTIONS:A,GITHUB_ACTIONS:A,GITLAB_CI:D,TRAVIS:D})),Hr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Fr(){if(_("FORCE_COLOR")!==void 0)switch(_("FORCE_COLOR")){case"":case"1":case"true":return T;case"2":return D;case"3":return A;default:return X}if(_("NODE_DISABLE_COLORS")!==void 0&&_("NODE_DISABLE_COLORS")!==""||_("NO_COLOR")!==void 0&&_("NO_COLOR")!==""||_("TERM")==="dumb")return X;if(_("TMUX"))return A;if("TF_BUILD"in x&&"AGENT_NAME"in x)return T;if("CI"in x){for(let{0:r,1:e}of qr)if(r in x)return e;return _("CI_NAME")==="codeship"?D:X}if("TEAMCITY_VERSION"in x)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(_("TEAMCITY_VERSION"))!==null?T:X;switch(_("TERM_PROGRAM")){case"iTerm.app":return!_("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(_("TERM_PROGRAM_VERSION"))!==null?D:A;case"HyperTerm":case"MacTerm":return A;case"Apple_Terminal":return D}if(_("COLORTERM")==="truecolor"||_("COLORTERM")==="24bit")return A;if(_("TERM")){if(/truecolor/.exec(_("TERM"))!==null)return A;if(/^xterm-256/.exec(_("TERM"))!==null)return D;let r=_("TERM").toLowerCase();if(ct[r])return ct[r];if(Hr.some(e=>e.exec(r)!==null))return T}return _("COLORTERM")?T:X}var $={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",undim:"\x1B[22m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",fg:{black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m"},bg:{black:"\x1B[40m",red:"\x1B[41m",green:"\x1B[42m",yellow:"\x1B[43m",blue:"\x1B[44m",magenta:"\x1B[45m",cyan:"\x1B[46m",white:"\x1B[47m"}},Ee=["info","success","warn","error","debug"];function Gr(r,e){return Ee.indexOf(e)<=Ee.indexOf(r)}var Wr={info:$.fg.blue,success:$.fg.green,warn:$.fg.yellow,error:$.fg.red,debug:$.fg.magenta},Vr=(r,e,t)=>{let s=new Date().toISOString();return t?`${$.dim}${s}${$.reset} ${Wr[r]}${r.toUpperCase()}${$.reset} ${$.bright}[Better Auth]:${$.reset} ${e}`:`${s} ${r.toUpperCase()} [Better Auth]: ${e}`},zr=r=>{let e=r?.disabled!==!0,t=r?.level??"error",n=r?.disableColors!==void 0?!r.disableColors:Fr()!==1,o=(c,f,a=[])=>{if(!e||!Gr(t,c))return;let u=Vr(c,f,n);if(!r||typeof r.log!="function"){c==="error"?console.error(u,...a):c==="warn"?console.warn(u,...a):console.log(u,...a);return}r.log(c==="success"?"info":c,f,...a)};return{...Object.fromEntries(Ee.map(c=>[c,(...[f,...a])=>o(c,f,a)])),get level(){return t}}},tn=zr();l();l();var cn={USER_NOT_FOUND:"User not found",FAILED_TO_CREATE_USER:"Failed to create user",FAILED_TO_CREATE_SESSION:"Failed to create session",FAILED_TO_UPDATE_USER:"Failed to update user",FAILED_TO_GET_SESSION:"Failed to get session",INVALID_PASSWORD:"Invalid password",INVALID_EMAIL:"Invalid email",INVALID_EMAIL_OR_PASSWORD:"Invalid email or password",SOCIAL_ACCOUNT_ALREADY_LINKED:"Social account already linked",PROVIDER_NOT_FOUND:"Provider not found",INVALID_TOKEN:"Invalid token",ID_TOKEN_NOT_SUPPORTED:"id_token not supported",FAILED_TO_GET_USER_INFO:"Failed to get user info",USER_EMAIL_NOT_FOUND:"User email not found",EMAIL_NOT_VERIFIED:"Email not verified",PASSWORD_TOO_SHORT:"Password too short",PASSWORD_TOO_LONG:"Password too long",USER_ALREADY_EXISTS:"User already exists.",USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL:"User already exists. Use another email.",EMAIL_CAN_NOT_BE_UPDATED:"Email can not be updated",CREDENTIAL_ACCOUNT_NOT_FOUND:"Credential account not found",SESSION_EXPIRED:"Session expired. Re-authenticate to perform this action.",FAILED_TO_UNLINK_LAST_ACCOUNT:"You can't unlink your last account",ACCOUNT_NOT_FOUND:"Account not found",USER_ALREADY_HAS_PASSWORD:"User already has a password. Provide that to delete the account."},F=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function Kr(r){try{return(new URL(r).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new F(`Invalid base URL: ${r}. Please provide a valid base URL.`)}}function Z(r,e="/api/auth"){if(Kr(r))return r;let s=r.replace(/\/+$/,"");return!e||e==="/"?s:(e=e.startsWith("/")?e:`/${e}`,`${s}${e}`)}function ut(r,e,t,s){if(r)return Z(r,e);if(s!==!1){let i=x.BETTER_AUTH_URL||x.NEXT_PUBLIC_BETTER_AUTH_URL||x.PUBLIC_BETTER_AUTH_URL||x.NUXT_PUBLIC_BETTER_AUTH_URL||x.NUXT_PUBLIC_AUTH_URL||(x.BASE_URL!=="/"?x.BASE_URL:void 0);if(i)return Z(i,e)}let n=t?.headers.get("x-forwarded-host"),o=t?.headers.get("x-forwarded-proto");if(n&&o)return Z(`${o}://${n}`,e);if(t){let i=Jr(t.url);if(!i)throw new F("Could not get origin from request. Please provide a valid base URL.");return Z(i,e)}if(typeof window<"u"&&window.location)return Z(window.location.origin,e)}function Jr(r){try{return new URL(r).origin}catch{return null}}l();l();l();var ee=Symbol("clean");var N=[],B=0,ce=4,Yr=0,te=r=>{let e=[],t={get(){return t.lc||t.listen(()=>{})(),t.value},lc:0,listen(s){return t.lc=e.push(s),()=>{for(let o=B+ce;o<N.length;)N[o]===s?N.splice(o,ce):o+=ce;let n=e.indexOf(s);~n&&(e.splice(n,1),--t.lc||t.off())}},notify(s,n){Yr++;let o=!N.length;for(let i of e)N.push(i,t.value,s,n);if(o){for(B=0;B<N.length;B+=ce)N[B](N[B+1],N[B+2],N[B+3]);N.length=0}},off(){},set(s){let n=t.value;n!==s&&(t.value=s,t.notify(n))},subscribe(s){let n=t.listen(s);return s(t.value),n},value:r};return process.env.NODE_ENV!=="production"&&(t[ee]=()=>{e=[],t.lc=0,t.off()}),t};l();var Qr=5,K=6,ue=10,Xr=(r,e,t,s)=>(r.events=r.events||{},r.events[t+ue]||(r.events[t+ue]=s(n=>{r.events[t].reduceRight((o,i)=>(i(o),o),{shared:{},...n})})),r.events[t]=r.events[t]||[],r.events[t].push(e),()=>{let n=r.events[t],o=n.indexOf(e);n.splice(o,1),n.length||(delete r.events[t],r.events[t+ue](),delete r.events[t+ue])});var ft=1e3,Te=(r,e)=>Xr(r,s=>{let n=e(s);n&&r.events[K].push(n)},Qr,s=>{let n=r.listen;r.listen=(...i)=>(!r.lc&&!r.active&&(r.active=!0,s()),n(...i));let o=r.off;if(r.events[K]=[],r.off=()=>{o(),setTimeout(()=>{if(r.active&&!r.lc){r.active=!1;for(let i of r.events[K])i();r.events[K]=[]}},ft)},process.env.NODE_ENV!=="production"){let i=r[ee];r[ee]=()=>{for(let c of r.events[K])c();r.events[K]=[],r.active=!1,i()}}return()=>{r.listen=n,r.off=o}});l();var Zr=typeof window>"u",fe=(r,e,t,s)=>{let n=te({data:null,error:null,isPending:!0,isRefetching:!1,refetch:c=>o(c)}),o=c=>{let f=typeof s=="function"?s({data:n.get().data,error:n.get().error,isPending:n.get().isPending}):s;t(e,{...f,query:{...f?.query,...c?.query},async onSuccess(a){n.set({data:a.data,error:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch}),await f?.onSuccess?.(a)},async onError(a){let{request:u}=a,d=typeof u.retry=="number"?u.retry:u.retry?.attempts,m=u.retryAttempt||0;d&&m<d||(n.set({error:a.error,data:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch}),await f?.onError?.(a))},async onRequest(a){let u=n.get();n.set({isPending:u.data===null,data:u.data,error:null,isRefetching:!0,refetch:n.value.refetch}),await f?.onRequest?.(a)}}).catch(a=>{n.set({error:a,data:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch})})};r=Array.isArray(r)?r:[r];let i=!1;for(let c of r)c.subscribe(()=>{Zr||(i?o():Te(n,()=>{let f=setTimeout(()=>{i||(o(),i=!0)},0);return()=>{n.off(),c.off(),clearTimeout(f)}}))});return n};l();var es={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},ts=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,dt={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},rs=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function ss(r){return r instanceof Date&&!isNaN(r.getTime())}function ns(r){let e=rs.exec(r);if(!e)return null;let[,t,s,n,o,i,c,f,a,u,d]=e,m=new Date(Date.UTC(parseInt(t,10),parseInt(s,10)-1,parseInt(n,10),parseInt(o,10),parseInt(i,10),parseInt(c,10),f?parseInt(f.padEnd(3,"0"),10):0));if(a){let y=(parseInt(u,10)*60+parseInt(d,10))*(a==="+"?-1:1);m.setUTCMinutes(m.getUTCMinutes()+y)}return ss(m)?m:null}function os(r,e={}){let{strict:t=!1,warnings:s=!1,reviver:n,parseDates:o=!0}=e;if(typeof r!="string")return r;let i=r.trim();if(i.length>0&&i[0]==='"'&&i.endsWith('"')&&!i.slice(1,-1).includes('"'))return i.slice(1,-1);let c=i.toLowerCase();if(c.length<=9&&c in dt)return dt[c];if(!ts.test(i)){if(t)throw new SyntaxError("[better-json] Invalid JSON");return r}if(Object.entries(es).some(([a,u])=>{let d=u.test(i);return d&&s&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${a} pattern`),d})&&t)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(i,(u,d)=>{if(u==="__proto__"||u==="constructor"&&d&&typeof d=="object"&&"prototype"in d){s&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof d=="string"){let m=ns(d);if(m)return m}return n?n(u,d):d})}catch(a){if(t)throw a;return r}}function ht(r,e={strict:!0}){return os(r,e)}var is={id:"redirect",name:"Redirect",hooks:{onSuccess(r){if(r.data?.url&&r.data?.redirect&&typeof window<"u"&&window.location&&window.location)try{window.location.href=r.data.url}catch{}}}};function as(r){let e=te(!1);return{session:fe(e,"/get-session",r,{method:"GET"}),$sessionSignal:e}}var pt=(r,e)=>{let t="credentials"in Request.prototype,s=ut(r?.baseURL,r?.basePath,void 0,e)??"/api/auth",n=r?.plugins?.flatMap(g=>g.fetchPlugins).filter(g=>g!==void 0)||[],o={id:"lifecycle-hooks",name:"lifecycle-hooks",hooks:{onSuccess:r?.fetchOptions?.onSuccess,onError:r?.fetchOptions?.onError,onRequest:r?.fetchOptions?.onRequest,onResponse:r?.fetchOptions?.onResponse}},{onSuccess:i,onError:c,onRequest:f,onResponse:a,...u}=r?.fetchOptions||{},d=lt({baseURL:s,...t?{credentials:"include"}:{},method:"GET",jsonParser(g){return g?ht(g,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[o,...u.plugins||[],...r?.disableDefaultFetchPlugins?[]:[is],...n]}),{$sessionSignal:m,session:y}=as(d),b=r?.plugins||[],v={},w={$sessionSignal:m,session:y},E={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},O=[{signal:"$sessionSignal",matcher(g){return g==="/sign-out"||g==="/update-user"||g.startsWith("/sign-in")||g.startsWith("/sign-up")||g==="/delete-user"||g==="/verify-email"}}];for(let g of b)g.getAtoms&&Object.assign(w,g.getAtoms?.(d)),g.pathMethods&&Object.assign(E,g.pathMethods),g.atomListeners&&O.push(...g.atomListeners);let j={notify:g=>{w[g].set(!w[g].get())},listen:(g,q)=>{w[g].subscribe(q)},atoms:w};for(let g of b)g.getActions&&Object.assign(v,g.getActions?.(d,j,r));return{get baseURL(){return s},pluginsActions:v,pluginsAtoms:w,pluginPathMethods:E,atomListeners:O,$fetch:d,$store:j}};function ls(r){return typeof r=="object"&&r!==null&&"get"in r&&typeof r.get=="function"&&"lc"in r&&typeof r.lc=="number"}function cs(r,e,t){let s=e[r],{fetchOptions:n,query:o,...i}=t||{};return s||(n?.method?n.method:i&&Object.keys(i).length>0?"POST":"GET")}function mt(r,e,t,s,n){function o(i=[]){return new Proxy(function(){},{get(c,f){if(typeof f!="string"||f==="then"||f==="catch"||f==="finally")return;let a=[...i,f],u=r;for(let d of a)if(u&&typeof u=="object"&&d in u)u=u[d];else{u=void 0;break}return typeof u=="function"||ls(u)?u:o(a)},apply:async(c,f,a)=>{let u="/"+i.map(O=>O.replace(/[A-Z]/g,j=>`-${j.toLowerCase()}`)).join("/"),d=a[0]||{},m=a[1]||{},{query:y,fetchOptions:b,...v}=d,w={...m,...b},E=cs(u,t,d);return await e(u,{...w,body:E==="GET"?void 0:{...v,...w?.body||{}},query:y||w?.query,method:E,async onSuccess(O){if(await w?.onSuccess?.(O),!n)return;let j=n.filter(g=>g.matcher(u));if(j.length)for(let g of j){let q=s[g.signal];if(!q)return;let R=q.get();setTimeout(()=>{q.set(!R)},10)}}})}})}return o()}l();function gt(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Se(r){let{pluginPathMethods:e,pluginsActions:t,pluginsAtoms:s,$fetch:n,atomListeners:o,$store:i}=pt(r),c={};for(let[u,d]of Object.entries(s))c[`use${gt(u)}`]=d;let f={...t,...c,$fetch:n,$store:i};return mt(f,n,e,s,o)}l();l();l();function us(r){return{authorize(e,t="AND"){let s=!1;for(let[n,o]of Object.entries(e)){let i=r[n];if(!i)return{success:!1,error:`You are not allowed to access resource: ${n}`};if(Array.isArray(o))s=o.every(c=>i.includes(c));else if(typeof o=="object"){let c=o;c.connector==="OR"?s=c.actions.some(f=>i.includes(f)):s=c.actions.every(f=>i.includes(f))}else throw new F("Invalid access control request");if(s&&t==="OR")return{success:s};if(!s&&t==="AND")return{success:!1,error:`unauthorized to access resource "${n}"`}}return s?{success:s}:{success:!1,error:"Not authorized"}},statements:r}}function de(r){return{newRole(e){return us(e)},statements:r}}var fs={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},Pe=de(fs),ds=Pe.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),hs=Pe.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),ps=Pe.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});l();l();l();l();l();l();l();l();l();l();l();var Oe=class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let t=new Error("Cancelling existing WebAuthn API call for new one");t.name="AbortError",this.controller.abort(t)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}},wt=new Oe;l();l();l();l();l();l();l();l();var ws={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},_t=de(ws),_s=_t.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),Rs=_t.newRole({user:[],session:[]});l();l();var Rt=()=>({id:"username",$InferServerPlugin:{}});var vs="/auth",he="nvwa_login_token",xe="nvwa_user_profile",vt=class{constructor(e,t,s){this.storage=s,this.authClient=Se({baseURL:e,basePath:vs,fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:()=>s.get(he)},onSuccess:n=>{let o=n.response.headers.get("set-auth-token");o&&s.set(he,o)}},plugins:[Rt()]})}async currentUser(){return await this.storage.get(xe)}async signUp(e){let t=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:e.password});this.saveSession(t)}async signInWithUsername(e,t){let s=await this.authClient.signIn.username({username:e,password:t});this.saveSession(s)}saveSession(e){if(e.error)throw new Error(e.error.message);this.storage.set(he,e.data?.token),this.storage.set(xe,e.data?.user)}async signOut(){await this.storage.remove(he),await this.storage.remove(xe)}async updateUserPassword(e,t,s=!1){let n=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:s});this.saveSession(n)}};l();var Et=class{constructor(e){this.http=e}async invoke(e,t){return(await this.http.request("/functions/"+e,{method:t.method||"POST",data:t.body,headers:t.headers})).body}};l();var Tt=class{async jsonRequest(e,t){let s={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.request(e,s)}async jsonRequestWithAuth(e,t,s){let n={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.requestWithAuth(e,n,s)}};l();var Es="/storage",Ts=Es+"/generateUploadUrl",St=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.request(this.baseUrl+Ts,{method:"POST",data:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:s}=t.body;if(!s)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");return{url:(await this.http.request(s,{method:"PUT",data:e,headers:{"Content-Type":e.type||e.fileType||"application/octet-stream"}})).body.url.split("?")[0]}}};l();l();l();var Je=br(ar(),1),{PostgrestClient:lr,PostgrestQueryBuilder:Na,PostgrestFilterBuilder:La,PostgrestTransformBuilder:Da,PostgrestBuilder:$a,PostgrestError:ja}=Je.default||Je;l();l();var U=class r{constructor(e){this.headerMap=new Map;if(e){if(e instanceof r)e.forEach((t,s)=>this.set(s,t));else if(Array.isArray(e))for(let[t,s]of e)this.set(t,String(s));else if(typeof e=="object")for(let t of Object.keys(e))this.set(t,String(e[t]))}}append(e,t){let s=e.toLowerCase(),n=this.headerMap.get(s);this.headerMap.set(s,n?`${n}, ${t}`:t)}set(e,t){this.headerMap.set(e.toLowerCase(),String(t))}get(e){let t=this.headerMap.get(e.toLowerCase());return t??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[t,s]of this.headerMap.entries())e(s,t,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},se=class r{constructor(e){this.params=new Map;if(e){if(typeof e=="string")this.parseString(e);else if(e instanceof r)this.params=new Map(e.params);else if(Array.isArray(e))for(let[t,s]of e)this.append(t,s);else if(e&&typeof e=="object")for(let[t,s]of Object.entries(e))this.set(t,s)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let t=e.split("&");for(let s of t)if(s){let[n,o]=s.split("=");n&&this.append(decodeURIComponent(n),o?decodeURIComponent(o):"")}}append(e,t){let s=this.params.get(e)||[];s.push(t),this.params.set(e,s)}delete(e){this.params.delete(e)}get(e){let t=this.params.get(e);return t?t[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,t){this.params.set(e,[t])}sort(){let e=Array.from(this.params.entries()).sort(([t],[s])=>t.localeCompare(s));this.params=new Map(e)}toString(){let e=[];for(let[t,s]of this.params.entries())for(let n of s)e.push(`${encodeURIComponent(t)}=${encodeURIComponent(n)}`);return e.join("&")}forEach(e){for(let[t,s]of this.params.entries())for(let n of s)e(n,t,this)}keys(){return this.params.keys()}values(){let e=[];for(let t of this.params.values())e.push(...t);return e[Symbol.iterator]()}entries(){let e=[];for(let[t,s]of this.params.entries())for(let n of s)e.push([t,n]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},be=class r{constructor(e,t){let s;if(e instanceof r)s=e.href;else if(t){let o=t instanceof r?t.href:t;s=this.resolve(o,e)}else s=e;let n=this.parseUrl(s);this.href=s,this.origin=`${n.protocol}//${n.host}`,this.protocol=n.protocol,this.username=n.username,this.password=n.password,this.host=n.host,this.hostname=n.hostname,this.port=n.port,this.pathname=n.pathname,this.search=n.search,this.searchParams=new se(n.search),this.hash=n.hash}resolve(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(t.startsWith("//"))return`${this.parseUrl(e).protocol}${t}`;if(t.startsWith("/")){let o=this.parseUrl(e);return`${o.protocol}//${o.host}${t}`}let s=this.parseUrl(e),n=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return`${s.protocol}//${s.host}${n}${t}`}parseUrl(e){let t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)throw new TypeError("Invalid URL");let s=t[2]||"",n=t[4]||"",o=t[5]||"/",i=t[7]?`?${t[7]}`:"",c=t[9]?`#${t[9]}`:"";if(!s&&!n&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let f=n.match(/^([^@]*)@(.+)$/),a="",u="",d=n;if(f){let v=f[1];d=f[2];let w=v.match(/^([^:]*):?(.*)$/);w&&(a=w[1]||"",u=w[2]||"")}let m=d.match(/^([^:]+):?(\d*)$/),y=m?m[1]:d,b=m&&m[2]?m[2]:"";return{protocol:s?`${s}:`:"",username:a,password:u,host:d,hostname:y,port:b,pathname:o,search:i,hash:c}}toString(){let e=this.searchParams.toString(),t=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${t}${this.hash}`}toJSON(){return this.toString()}};l();var we=class r{constructor(e,t){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(t?.method||"GET").toUpperCase(),this.headers=t?.headers instanceof U?t.headers:new U(t?.headers),this.body=t?.body,this.timeout=t?.timeout,this.signal=t?.signal||void 0}clone(){return new r(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};l();var V=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=ks(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function ks(r){return r?new U(r):new U}l();var ne=class{constructor(){this._aborted=!1;this.listeners=new Set;this.onabort=null}get aborted(){return this._aborted}_trigger(){if(!this._aborted){if(this._aborted=!0,typeof this.onabort=="function")try{this.onabort()}catch{}for(let e of Array.from(this.listeners))try{e()}catch{}this.listeners.clear()}}addEventListener(e,t){if(this._aborted){try{t()}catch{}return}this.listeners.add(t)}removeEventListener(e,t){this.listeners.delete(t)}toString(){return"[object AbortSignal]"}},_e=class{constructor(){this._signal=new ne}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};l();function el(r){r.URL=be,r.URLSearchParams=se,r.Headers=U,r.Request=we,r.Response=V,r.AbortController=_e,r.AbortSignal=ne}var Ms="/entities",Bs=(r,e)=>async(s,n)=>{console.log("customFetch",s,n);let o;if(typeof s=="string")o=s;else if(s&&typeof s=="object")if(typeof s.toString=="function"&&!s.url)o=s.toString();else if(s.url)o=s.url,n||(n={}),n.method=s.method,n.headers=s.headers,n.body=s.body;else throw new Error("Unsupported input type for fetch");else throw new Error("Unsupported input type for fetch");let i=(n?.method||"GET").toUpperCase(),c={};if(n?.headers)if(n.headers&&typeof n.headers.forEach=="function")n.headers.forEach((y,b)=>{c[b]=y});else if(Array.isArray(n.headers))for(let[y,b]of n.headers)c[y]=b;else Object.assign(c,n.headers);let f=n?.body,a;try{a=await r.requestWithAuth(o,{method:i,data:f,headers:c},e)}catch(y){return new V(y?.message||"Internal Error",{status:500,statusText:"Internal Error"})}let u=a.body,d=null;return(a.headers["content-type"]||a.headers["Content-Type"]||"").startsWith("application/json")&&typeof u!="string"?d=JSON.stringify(u):typeof u=="string"||u&&(u.constructor===Blob||u.constructor===ArrayBuffer||typeof u.getReader=="function")?d=u:d=JSON.stringify(u),new V(d,{status:a.status,headers:new U(a.headers)})},gl=(r,e,t)=>new lr(r+Ms,{fetch:Bs(e,t)});export{vs as AUTH_BASE_PATH,_e as AbortController,ne as AbortSignal,Ms as ENTITIES_BASE_PATH,Es as FILE_STORAGE_BASE_PATH,Ts as GENERATE_UPLOAD_URL_PATH,U as Headers,he as LOGIN_TOKEN_KEY,xe as LOGIN_USER_PROFILE_KEY,vt as NvwaAuthClient,Et as NvwaEdgeFunctions,St as NvwaFileStorage,Tt as NvwaHttpClient,we as Request,V as Response,be as URL,se as URLSearchParams,gl as createPostgrestClient,el as polyfill};
|
|
1
|
+
var pr=Object.create;var ie=Object.defineProperty;var mr=Object.getOwnPropertyDescriptor;var gr=Object.getOwnPropertyNames;var yr=Object.getPrototypeOf,br=Object.prototype.hasOwnProperty;var Xe=(r,e)=>()=>(r&&(e=r(r=0)),e);var H=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),wr=(r,e)=>{for(var t in e)ie(r,t,{get:e[t],enumerable:!0})},Ze=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of gr(e))!br.call(r,s)&&s!==t&&ie(r,s,{get:()=>e[s],enumerable:!(n=mr(e,s))||n.enumerable});return r};var _r=(r,e,t)=>(t=r!=null?pr(yr(r)):{},Ze(e||!r||!r.__esModule?ie(t,"default",{value:r,enumerable:!0}):t,r)),z=r=>Ze(ie({},"__esModule",{value:!0}),r);import zn from"path";import{fileURLToPath as Jn}from"url";var l=Xe(()=>{"use strict"});var G={};wr(G,{__addDisposableResource:()=>Xt,__assign:()=>pe,__asyncDelegator:()=>Gt,__asyncGenerator:()=>Ft,__asyncValues:()=>Wt,__await:()=>J,__awaiter:()=>kt,__classPrivateFieldGet:()=>Jt,__classPrivateFieldIn:()=>Qt,__classPrivateFieldSet:()=>Yt,__createBinding:()=>ge,__decorate:()=>It,__disposeResources:()=>Zt,__esDecorate:()=>Ut,__exportStar:()=>Mt,__extends:()=>At,__generator:()=>jt,__importDefault:()=>Kt,__importStar:()=>zt,__makeTemplateObject:()=>Vt,__metadata:()=>$t,__param:()=>Ct,__propKey:()=>Lt,__read:()=>Ue,__rest:()=>xt,__rewriteRelativeImportExtension:()=>er,__runInitializers:()=>Nt,__setFunctionName:()=>Dt,__spread:()=>Bt,__spreadArray:()=>Ht,__spreadArrays:()=>qt,__values:()=>me,default:()=>In});function At(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Ie(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function xt(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}function It(r,e,t,n){var s=arguments.length,o=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(i=r[c])&&(o=(s<3?i(o):s>3?i(e,t,o):i(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o}function Ct(r,e){return function(t,n){e(t,n,r)}}function Ut(r,e,t,n,s,o){function i(E){if(E!==void 0&&typeof E!="function")throw new TypeError("Function expected");return E}for(var c=n.kind,f=c==="getter"?"get":c==="setter"?"set":"value",a=!e&&r?n.static?r:r.prototype:null,u=e||(a?Object.getOwnPropertyDescriptor(a,n.name):{}),d,m=!1,y=t.length-1;y>=0;y--){var b={};for(var R in n)b[R]=R==="access"?{}:n[R];for(var R in n.access)b.access[R]=n.access[R];b.addInitializer=function(E){if(m)throw new TypeError("Cannot add initializers after decoration has completed");o.push(i(E||null))};var w=(0,t[y])(c==="accessor"?{get:u.get,set:u.set}:u[f],b);if(c==="accessor"){if(w===void 0)continue;if(w===null||typeof w!="object")throw new TypeError("Object expected");(d=i(w.get))&&(u.get=d),(d=i(w.set))&&(u.set=d),(d=i(w.init))&&s.unshift(d)}else(d=i(w))&&(c==="field"?s.unshift(d):u[f]=d)}a&&Object.defineProperty(a,n.name,u),m=!0}function Nt(r,e,t){for(var n=arguments.length>2,s=0;s<e.length;s++)t=n?e[s].call(r,t):e[s].call(r);return n?t:void 0}function Lt(r){return typeof r=="symbol"?r:"".concat(r)}function Dt(r,e,t){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(r,"name",{configurable:!0,value:t?"".concat(t," ",e):e})}function $t(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function kt(r,e,t,n){function s(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function c(u){try{a(n.next(u))}catch(d){i(d)}}function f(u){try{a(n.throw(u))}catch(d){i(d)}}function a(u){u.done?o(u.value):s(u.value).then(c,f)}a((n=n.apply(r,e||[])).next())})}function jt(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,s,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(a){return function(u){return f([a,u])}}function f(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(t=0)),t;)try{if(n=1,s&&(o=a[0]&2?s.return:a[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,a[1])).done)return o;switch(s=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return t.label++,{value:a[1],done:!1};case 5:t.label++,s=a[1],a=[0];continue;case 7:a=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){t.label=a[1];break}if(a[0]===6&&t.label<o[1]){t.label=o[1],o=a;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(a);break}o[2]&&t.ops.pop(),t.trys.pop();continue}a=e.call(r,t)}catch(u){a=[6,u],s=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function Mt(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&ge(e,r,t)}function me(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ue(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(c){i={error:c}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o}function Bt(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(Ue(arguments[e]));return r}function qt(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var o=arguments[e],i=0,c=o.length;i<c;i++,s++)n[s]=o[i];return n}function Ht(r,e,t){if(t||arguments.length===2)for(var n=0,s=e.length,o;n<s;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))}function J(r){return this instanceof J?(this.v=r,this):new J(r)}function Ft(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(r,e||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(y){return function(b){return Promise.resolve(b).then(y,d)}}function c(y,b){n[y]&&(s[y]=function(R){return new Promise(function(w,E){o.push([y,R,w,E])>1||f(y,R)})},b&&(s[y]=b(s[y])))}function f(y,b){try{a(n[y](b))}catch(R){m(o[0][3],R)}}function a(y){y.value instanceof J?Promise.resolve(y.value.v).then(u,d):m(o[0][2],y)}function u(y){f("next",y)}function d(y){f("throw",y)}function m(y,b){y(b),o.shift(),o.length&&f(o[0][0],o[0][1])}}function Gt(r){var e,t;return e={},n("next"),n("throw",function(s){throw s}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(s,o){e[s]=r[s]?function(i){return(t=!t)?{value:J(r[s](i)),done:!1}:o?o(i):i}:o}}function Wt(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof me=="function"?me(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(o){t[o]=r[o]&&function(i){return new Promise(function(c,f){i=r[o](i),s(c,f,i.done,i.value)})}}function s(o,i,c,f){Promise.resolve(f).then(function(a){o({value:a,done:c})},i)}}function Vt(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function zt(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t=Ce(r),n=0;n<t.length;n++)t[n]!=="default"&&ge(e,r,t[n]);return An(e,r),e}function Kt(r){return r&&r.__esModule?r:{default:r}}function Jt(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}function Yt(r,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(r,t):s?s.value=t:e.set(r,t),t}function Qt(r,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof r=="function"?e===r:r.has(e)}function Xt(r,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var n,s;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=e[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=e[Symbol.dispose],t&&(s=n)}if(typeof n!="function")throw new TypeError("Object not disposable.");s&&(n=function(){try{s.call(this)}catch(o){return Promise.reject(o)}}),r.stack.push({value:e,dispose:n,async:t})}else t&&r.stack.push({async:!0});return e}function Zt(r){function e(o){r.error=r.hasError?new xn(o,r.error,"An error was suppressed during disposal."):o,r.hasError=!0}var t,n=0;function s(){for(;t=r.stack.pop();)try{if(!t.async&&n===1)return n=0,r.stack.push(t),Promise.resolve().then(s);if(t.dispose){var o=t.dispose.call(t.value);if(t.async)return n|=2,Promise.resolve(o).then(s,function(i){return e(i),s()})}else n|=1}catch(i){e(i)}if(n===1)return r.hasError?Promise.reject(r.error):Promise.resolve();if(r.hasError)throw r.error}return s()}function er(r,e){return typeof r=="string"&&/^\.\.?\//.test(r)?r.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,n,s,o,i){return n?e?".jsx":".js":s&&(!o||!i)?t:s+o+"."+i.toLowerCase()+"js"}):r}var Ie,pe,ge,An,Ce,xn,In,W=Xe(()=>{"use strict";l();Ie=function(r,e){return Ie=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])},Ie(r,e)};pe=function(){return pe=Object.assign||function(e){for(var t,n=1,s=arguments.length;n<s;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},pe.apply(this,arguments)};ge=Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]});An=Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e},Ce=function(r){return Ce=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},Ce(r)};xn=typeof SuppressedError=="function"?SuppressedError:function(r,e,t){var n=new Error(t);return n.name="SuppressedError",n.error=r,n.suppressed=e,n};In={__extends:At,__assign:pe,__rest:xt,__decorate:It,__param:Ct,__esDecorate:Ut,__runInitializers:Nt,__propKey:Lt,__setFunctionName:Dt,__metadata:$t,__awaiter:kt,__generator:jt,__createBinding:ge,__exportStar:Mt,__values:me,__read:Ue,__spread:Bt,__spreadArrays:qt,__spreadArray:Ht,__await:J,__asyncGenerator:Ft,__asyncDelegator:Gt,__asyncValues:Wt,__makeTemplateObject:Vt,__importStar:zt,__importDefault:Kt,__classPrivateFieldGet:Jt,__classPrivateFieldSet:Yt,__classPrivateFieldIn:Qt,__addDisposableResource:Xt,__disposeResources:Zt,__rewriteRelativeImportExtension:er}});var De=H(Le=>{"use strict";l();Object.defineProperty(Le,"__esModule",{value:!0});var Ne=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};Le.default=Ne});var je=H(ke=>{"use strict";l();Object.defineProperty(ke,"__esModule",{value:!0});var Cn=(W(),z(G)),Un=Cn.__importDefault(De()),$e=class{constructor(e){var t,n;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(n=e.isMaybeSingle)!==null&&n!==void 0?n:!1,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let n=this.fetch,s=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async o=>{var i,c,f,a;let u=null,d=null,m=null,y=o.status,b=o.statusText;if(o.ok){if(this.method!=="HEAD"){let O=await o.text();O===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((i=this.headers.get("Accept"))===null||i===void 0)&&i.includes("application/vnd.pgrst.plan+text"))?d=O:d=JSON.parse(O))}let w=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),E=(f=o.headers.get("content-range"))===null||f===void 0?void 0:f.split("/");w&&E&&E.length>1&&(m=parseInt(E[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(u={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,m=null,y=406,b="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let w=await o.text();try{u=JSON.parse(w),Array.isArray(u)&&o.status===404&&(d=[],u=null,y=200,b="OK")}catch{o.status===404&&w===""?(y=204,b="No Content"):u={message:w}}if(u&&this.isMaybeSingle&&(!((a=u?.details)===null||a===void 0)&&a.includes("0 rows"))&&(u=null,y=200,b="OK"),u&&this.shouldThrowOnError)throw new Un.default(u)}return{error:u,data:d,count:m,status:y,statusText:b}});return this.shouldThrowOnError||(s=s.catch(o=>{var i,c,f;return{error:{message:`${(i=o?.name)!==null&&i!==void 0?i:"FetchError"}: ${o?.message}`,details:`${(c=o?.stack)!==null&&c!==void 0?c:""}`,hint:"",code:`${(f=o?.code)!==null&&f!==void 0?f:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}returns(){return this}overrideTypes(){return this}};ke.default=$e});var qe=H(Be=>{"use strict";l();Object.defineProperty(Be,"__esModule",{value:!0});var Nn=(W(),z(G)),Ln=Nn.__importDefault(je()),Me=class extends Ln.default{select(e){let t=!1,n=(e??"*").split("").map(s=>/\s/.test(s)&&!t?"":(s==='"'&&(t=!t),s)).join("");return this.url.searchParams.set("select",n),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:n,foreignTable:s,referencedTable:o=s}={}){let i=o?`${o}.order`:"order",c=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${c?`${c},`:""}${e}.${t?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:n=t}={}){let s=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:n,referencedTable:s=n}={}){let o=typeof s>"u"?"offset":`${s}.offset`,i=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(o,`${e}`),this.url.searchParams.set(i,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:n=!1,buffers:s=!1,wal:o=!1,format:i="text"}={}){var c;let f=[e?"analyze":null,t?"verbose":null,n?"settings":null,s?"buffers":null,o?"wal":null].filter(Boolean).join("|"),a=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${a}"; options=${f};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};Be.default=Me});var ye=H(Fe=>{"use strict";l();Object.defineProperty(Fe,"__esModule",{value:!0});var Dn=(W(),z(G)),$n=Dn.__importDefault(qe()),kn=new RegExp("[,()]"),He=class extends $n.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 n=Array.from(new Set(t)).map(s=>typeof s=="string"&&kn.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${n})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:n,type:s}={}){let o="";s==="plain"?o="pl":s==="phrase"?o="ph":s==="websearch"&&(o="w");let i=n===void 0?"":`(${n})`;return this.url.searchParams.append(e,`${o}fts${i}.${t}`),this}match(e){return Object.entries(e).forEach(([t,n])=>{this.url.searchParams.append(t,`eq.${n}`)}),this}not(e,t,n){return this.url.searchParams.append(e,`not.${t}.${n}`),this}or(e,{foreignTable:t,referencedTable:n=t}={}){let s=n?`${n}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,n){return this.url.searchParams.append(e,`${t}.${n}`),this}};Fe.default=He});var Ve=H(We=>{"use strict";l();Object.defineProperty(We,"__esModule",{value:!0});var jn=(W(),z(G)),re=jn.__importDefault(ye()),Ge=class{constructor(e,{headers:t={},schema:n,fetch:s}){this.url=e,this.headers=new Headers(t),this.schema=n,this.fetch=s}select(e,t){let{head:n=!1,count:s}=t??{},o=n?"HEAD":"GET",i=!1,c=(e??"*").split("").map(f=>/\s/.test(f)&&!i?"":(f==='"'&&(i=!i),f)).join("");return this.url.searchParams.set("select",c),s&&this.headers.append("Prefer",`count=${s}`),new re.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:n=!0}={}){var s;let o="POST";if(t&&this.headers.append("Prefer",`count=${t}`),n||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let i=e.reduce((c,f)=>c.concat(Object.keys(f)),[]);if(i.length>0){let c=[...new Set(i)].map(f=>`"${f}"`);this.url.searchParams.set("columns",c.join(","))}}return new re.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:n=!1,count:s,defaultToNull:o=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${n?"ignore":"merge"}-duplicates`),t!==void 0&&this.url.searchParams.set("on_conflict",t),s&&this.headers.append("Prefer",`count=${s}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let f=e.reduce((a,u)=>a.concat(Object.keys(u)),[]);if(f.length>0){let a=[...new Set(f)].map(u=>`"${u}"`);this.url.searchParams.set("columns",a.join(","))}}return new re.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(e,{count:t}={}){var n;let s="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new re.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}delete({count:e}={}){var t;let n="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new re.default({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};We.default=Ge});var rr=H(Ke=>{"use strict";l();Object.defineProperty(Ke,"__esModule",{value:!0});var tr=(W(),z(G)),Mn=tr.__importDefault(Ve()),Bn=tr.__importDefault(ye()),ze=class r{constructor(e,{headers:t={},schema:n,fetch:s}={}){this.url=e,this.headers=new Headers(t),this.schemaName=n,this.fetch=s}from(e){let t=new URL(`${this.url}/${e}`);return new Mn.default(t,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new r(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:n=!1,get:s=!1,count:o}={}){var i;let c,f=new URL(`${this.url}/rpc/${e}`),a;n||s?(c=n?"HEAD":"GET",Object.entries(t).filter(([d,m])=>m!==void 0).map(([d,m])=>[d,Array.isArray(m)?`{${m.join(",")}}`:`${m}`]).forEach(([d,m])=>{f.searchParams.append(d,m)})):(c="POST",a=t);let u=new Headers(this.headers);return o&&u.set("Prefer",`count=${o}`),new Bn.default({method:c,url:f,headers:u,schema:this.schemaName,body:a,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}};Ke.default=ze});var cr=H(S=>{"use strict";l();Object.defineProperty(S,"__esModule",{value:!0});S.PostgrestError=S.PostgrestBuilder=S.PostgrestTransformBuilder=S.PostgrestFilterBuilder=S.PostgrestQueryBuilder=S.PostgrestClient=void 0;var Y=(W(),z(G)),nr=Y.__importDefault(rr());S.PostgrestClient=nr.default;var sr=Y.__importDefault(Ve());S.PostgrestQueryBuilder=sr.default;var or=Y.__importDefault(ye());S.PostgrestFilterBuilder=or.default;var ir=Y.__importDefault(qe());S.PostgrestTransformBuilder=ir.default;var ar=Y.__importDefault(je());S.PostgrestBuilder=ar.default;var lr=Y.__importDefault(De());S.PostgrestError=lr.default;S.default={PostgrestClient:nr.default,PostgrestQueryBuilder:sr.default,PostgrestFilterBuilder:or.default,PostgrestTransformBuilder:ir.default,PostgrestBuilder:ar.default,PostgrestError:lr.default}});l();l();l();l();l();l();var vr=Object.defineProperty,Rr=Object.defineProperties,Er=Object.getOwnPropertyDescriptors,et=Object.getOwnPropertySymbols,Tr=Object.prototype.hasOwnProperty,Pr=Object.prototype.propertyIsEnumerable,tt=(r,e,t)=>e in r?vr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,U=(r,e)=>{for(var t in e||(e={}))Tr.call(e,t)&&tt(r,t,e[t]);if(et)for(var t of et(e))Pr.call(e,t)&&tt(r,t,e[t]);return r},L=(r,e)=>Rr(r,Er(e)),Sr=class extends Error{constructor(r,e,t){super(e||r.toString(),{cause:t}),this.status=r,this.statusText=e,this.error=t}},Or=async(r,e)=>{var t,n,s,o,i,c;let f=e||{},a={onRequest:[e?.onRequest],onResponse:[e?.onResponse],onSuccess:[e?.onSuccess],onError:[e?.onError],onRetry:[e?.onRetry]};if(!e||!e?.plugins)return{url:r,options:f,hooks:a};for(let u of e?.plugins||[]){if(u.init){let d=await((t=u.init)==null?void 0:t.call(u,r.toString(),e));f=d.options||f,r=d.url}a.onRequest.push((n=u.hooks)==null?void 0:n.onRequest),a.onResponse.push((s=u.hooks)==null?void 0:s.onResponse),a.onSuccess.push((o=u.hooks)==null?void 0:o.onSuccess),a.onError.push((i=u.hooks)==null?void 0:i.onError),a.onRetry.push((c=u.hooks)==null?void 0:c.onRetry)}return{url:r,options:f,hooks:a}},rt=class{constructor(r){this.options=r}shouldAttemptRetry(r,e){return this.options.shouldRetry?Promise.resolve(r<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(r<this.options.attempts)}getDelay(){return this.options.delay}},Ar=class{constructor(r){this.options=r}shouldAttemptRetry(r,e){return this.options.shouldRetry?Promise.resolve(r<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(r<this.options.attempts)}getDelay(r){return Math.min(this.options.maxDelay,this.options.baseDelay*2**r)}};function xr(r){if(typeof r=="number")return new rt({type:"linear",attempts:r,delay:1e3});switch(r.type){case"linear":return new rt(r);case"exponential":return new Ar(r);default:throw new Error("Invalid retry strategy")}}var Ir=async r=>{let e={},t=async n=>typeof n=="function"?await n():n;if(r?.auth){if(r.auth.type==="Bearer"){let n=await t(r.auth.token);if(!n)return e;e.authorization=`Bearer ${n}`}else if(r.auth.type==="Basic"){let n=t(r.auth.username),s=t(r.auth.password);if(!n||!s)return e;e.authorization=`Basic ${btoa(`${n}:${s}`)}`}else if(r.auth.type==="Custom"){let n=t(r.auth.value);if(!n)return e;e.authorization=`${t(r.auth.prefix)} ${n}`}}return e},Cr=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Ur(r){let e=r.headers.get("content-type"),t=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!e)return"json";let n=e.split(";").shift()||"";return Cr.test(n)?"json":t.has(n)||n.startsWith("text/")?"text":"blob"}function Nr(r){try{return JSON.parse(r),!0}catch{return!1}}function ot(r){if(r===void 0)return!1;let e=typeof r;return e==="string"||e==="number"||e==="boolean"||e===null?!0:e!=="object"?!1:Array.isArray(r)?!0:r.buffer?!1:r.constructor&&r.constructor.name==="Object"||typeof r.toJSON=="function"}function nt(r){try{return JSON.parse(r)}catch{return r}}function st(r){return typeof r=="function"}function Lr(r){if(r?.customFetchImpl)return r.customFetchImpl;if(typeof globalThis<"u"&&st(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&st(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function Dr(r){let e=new Headers(r?.headers),t=await Ir(r);for(let[n,s]of Object.entries(t||{}))e.set(n,s);if(!e.has("content-type")){let n=$r(r?.body);n&&e.set("content-type",n)}return e}function $r(r){return ot(r)?"application/json":null}function kr(r){if(!r?.body)return null;let e=new Headers(r?.headers);if(ot(r.body)&&!e.has("content-type")){for(let[t,n]of Object.entries(r?.body))n instanceof Date&&(r.body[t]=n.toISOString());return JSON.stringify(r.body)}return r.body}function jr(r,e){var t;if(e?.method)return e.method.toUpperCase();if(r.startsWith("@")){let n=(t=r.split("@")[1])==null?void 0:t.split("/")[0];return at.includes(n)?n.toUpperCase():e?.body?"POST":"GET"}return e?.body?"POST":"GET"}function Mr(r,e){let t;return!r?.signal&&r?.timeout&&(t=setTimeout(()=>e?.abort(),r?.timeout)),{abortTimeout:t,clearTimeout:()=>{t&&clearTimeout(t)}}}var Br=class it extends Error{constructor(e,t){super(t||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,it.prototype)}};async function ae(r,e){let t=await r["~standard"].validate(e);if(t.issues)throw new Br(t.issues);return t.value}var at=["get","post","put","patch","delete"];var qr=r=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(e,t){var n,s,o,i;let c=((s=(n=r.plugins)==null?void 0:n.find(f=>{var a;return(a=f.schema)!=null&&a.config?e.startsWith(f.schema.config.baseURL||"")||e.startsWith(f.schema.config.prefix||""):!1}))==null?void 0:s.schema)||r.schema;if(c){let f=e;(o=c.config)!=null&&o.prefix&&f.startsWith(c.config.prefix)&&(f=f.replace(c.config.prefix,""),c.config.baseURL&&(e=e.replace(c.config.prefix,c.config.baseURL))),(i=c.config)!=null&&i.baseURL&&f.startsWith(c.config.baseURL)&&(f=f.replace(c.config.baseURL,""));let a=c.schema[f];if(a){let u=L(U({},t),{method:a.method,output:a.output});return t?.disableValidation||(u=L(U({},u),{body:a.input?await ae(a.input,t?.body):t?.body,params:a.params?await ae(a.params,t?.params):t?.params,query:a.query?await ae(a.query,t?.query):t?.query})),{url:e,options:u}}}return{url:e,options:t}}}),lt=r=>{async function e(t,n){let s=L(U(U({},r),n),{plugins:[...r?.plugins||[],qr(r||{})]});if(r?.catchAllError)try{return await Re(t,s)}catch(o){return{data:null,error:{status:500,statusText:"Fetch Error",message:"Fetch related error. Captured by catchAllError option. See error property for more details.",error:o}}}return await Re(t,s)}return e};function Hr(r,e){let{baseURL:t,params:n,query:s}=e||{query:{},params:{},baseURL:""},o=r.startsWith("http")?r.split("/").slice(0,3).join("/"):t||"";if(r.startsWith("@")){let d=r.toString().split("@")[1].split("/")[0];at.includes(d)&&(r=r.replace(`@${d}/`,"/"))}o.endsWith("/")||(o+="/");let[i,c]=r.replace(o,"").split("?"),f=new URLSearchParams(c);for(let[d,m]of Object.entries(s||{}))m!=null&&f.set(d,String(m));if(n)if(Array.isArray(n)){let d=i.split("/").filter(m=>m.startsWith(":"));for(let[m,y]of d.entries()){let b=n[m];i=i.replace(y,b)}}else for(let[d,m]of Object.entries(n))i=i.replace(`:${d}`,String(m));i=i.split("/").map(encodeURIComponent).join("/"),i.startsWith("/")&&(i=i.slice(1));let a=f.toString();return a=a.length>0?`?${a}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${i}${a}`,o):`${o}${i}${a}`}var Re=async(r,e)=>{var t,n,s,o,i,c,f,a;let{hooks:u,url:d,options:m}=await Or(r,e),y=Lr(m),b=new AbortController,R=(t=m.signal)!=null?t:b.signal,w=Hr(d,m),E=kr(m),O=await Dr(m),k=jr(d,m),g=L(U({},m),{url:w,headers:O,body:E,method:k,signal:R});for(let I of u.onRequest)if(I){let P=await I(g);P instanceof Object&&(g=P)}("pipeTo"in g&&typeof g.pipeTo=="function"||typeof((n=e?.body)==null?void 0:n.pipe)=="function")&&("duplex"in g||(g.duplex="half"));let{clearTimeout:q}=Mr(m,b),v=await y(g.url,g);q();let Ye={response:v,request:g};for(let I of u.onResponse)if(I){let P=await I(L(U({},Ye),{response:(s=e?.hookOptions)!=null&&s.cloneResponse?v.clone():v}));P instanceof Response?v=P:P instanceof Object&&(v=P.response)}if(v.ok){if(!(g.method!=="HEAD"))return{data:"",error:null};let P=Ur(v),j={data:"",response:v,request:g};if(P==="json"||P==="text"){let M=await v.text(),hr=await((o=g.jsonParser)!=null?o:nt)(M);j.data=hr}else j.data=await v[P]();g?.output&&g.output&&!g.disableValidation&&(j.data=await ae(g.output,j.data));for(let M of u.onSuccess)M&&await M(L(U({},j),{response:(i=e?.hookOptions)!=null&&i.cloneResponse?v.clone():v}));return e?.throw?j.data:{data:j.data,error:null}}let fr=(c=e?.jsonParser)!=null?c:nt,oe=await v.text(),Qe=Nr(oe),ve=Qe?await fr(oe):null,dr={response:v,responseText:oe,request:g,error:L(U({},ve),{status:v.status,statusText:v.statusText})};for(let I of u.onError)I&&await I(L(U({},dr),{response:(f=e?.hookOptions)!=null&&f.cloneResponse?v.clone():v}));if(e?.retry){let I=xr(e.retry),P=(a=e.retryAttempt)!=null?a:0;if(await I.shouldAttemptRetry(P,v)){for(let M of u.onRetry)M&&await M(Ye);let j=I.getDelay(P);return await new Promise(M=>setTimeout(M,j)),await Re(r,L(U({},e),{retryAttempt:P+1}))}}if(e?.throw)throw new Sr(v.status,v.statusText,Qe?ve:oe);return{data:null,error:L(U({},ve),{status:v.status,statusText:v.statusText})}};l();l();var le=Object.create(null),Q=r=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(r?le:globalThis),x=new Proxy(le,{get(r,e){return Q()[e]??le[e]},has(r,e){let t=Q();return e in t||e in le},set(r,e,t){let n=Q(!0);return n[e]=t,!0},deleteProperty(r,e){if(!e)return!1;let t=Q(!0);return delete t[e],!0},ownKeys(){let r=Q(!0);return Object.keys(r)}});var rs=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function _(r,e){return typeof process<"u"&&process.env?process.env[r]??e:typeof Deno<"u"?Deno.env.get(r)??e:typeof Bun<"u"?Bun.env[r]??e:e}var ns=Object.freeze({get BETTER_AUTH_SECRET(){return _("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return _("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return _("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return _("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return _("NODE_ENV","development")},get PACKAGE_VERSION(){return _("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return _("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),X=1,T=4,D=8,A=24,ct={eterm:T,cons25:T,console:T,cygwin:T,dtterm:T,gnome:T,hurd:T,jfbterm:T,konsole:T,kterm:T,mlterm:T,mosh:A,putty:T,st:T,"rxvt-unicode-24bit":A,terminator:A,"xterm-kitty":A},Fr=new Map(Object.entries({APPVEYOR:D,BUILDKITE:D,CIRCLECI:A,DRONE:D,GITEA_ACTIONS:A,GITHUB_ACTIONS:A,GITLAB_CI:D,TRAVIS:D})),Gr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Wr(){if(_("FORCE_COLOR")!==void 0)switch(_("FORCE_COLOR")){case"":case"1":case"true":return T;case"2":return D;case"3":return A;default:return X}if(_("NODE_DISABLE_COLORS")!==void 0&&_("NODE_DISABLE_COLORS")!==""||_("NO_COLOR")!==void 0&&_("NO_COLOR")!==""||_("TERM")==="dumb")return X;if(_("TMUX"))return A;if("TF_BUILD"in x&&"AGENT_NAME"in x)return T;if("CI"in x){for(let{0:r,1:e}of Fr)if(r in x)return e;return _("CI_NAME")==="codeship"?D:X}if("TEAMCITY_VERSION"in x)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(_("TEAMCITY_VERSION"))!==null?T:X;switch(_("TERM_PROGRAM")){case"iTerm.app":return!_("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(_("TERM_PROGRAM_VERSION"))!==null?D:A;case"HyperTerm":case"MacTerm":return A;case"Apple_Terminal":return D}if(_("COLORTERM")==="truecolor"||_("COLORTERM")==="24bit")return A;if(_("TERM")){if(/truecolor/.exec(_("TERM"))!==null)return A;if(/^xterm-256/.exec(_("TERM"))!==null)return D;let r=_("TERM").toLowerCase();if(ct[r])return ct[r];if(Gr.some(e=>e.exec(r)!==null))return T}return _("COLORTERM")?T:X}var $={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",undim:"\x1B[22m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",fg:{black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m"},bg:{black:"\x1B[40m",red:"\x1B[41m",green:"\x1B[42m",yellow:"\x1B[43m",blue:"\x1B[44m",magenta:"\x1B[45m",cyan:"\x1B[46m",white:"\x1B[47m"}},Ee=["info","success","warn","error","debug"];function Vr(r,e){return Ee.indexOf(e)<=Ee.indexOf(r)}var zr={info:$.fg.blue,success:$.fg.green,warn:$.fg.yellow,error:$.fg.red,debug:$.fg.magenta},Kr=(r,e,t)=>{let n=new Date().toISOString();return t?`${$.dim}${n}${$.reset} ${zr[r]}${r.toUpperCase()}${$.reset} ${$.bright}[Better Auth]:${$.reset} ${e}`:`${n} ${r.toUpperCase()} [Better Auth]: ${e}`},Jr=r=>{let e=r?.disabled!==!0,t=r?.level??"error",s=r?.disableColors!==void 0?!r.disableColors:Wr()!==1,o=(c,f,a=[])=>{if(!e||!Vr(t,c))return;let u=Kr(c,f,s);if(!r||typeof r.log!="function"){c==="error"?console.error(u,...a):c==="warn"?console.warn(u,...a):console.log(u,...a);return}r.log(c==="success"?"info":c,f,...a)};return{...Object.fromEntries(Ee.map(c=>[c,(...[f,...a])=>o(c,f,a)])),get level(){return t}}},ss=Jr();l();l();var fs={USER_NOT_FOUND:"User not found",FAILED_TO_CREATE_USER:"Failed to create user",FAILED_TO_CREATE_SESSION:"Failed to create session",FAILED_TO_UPDATE_USER:"Failed to update user",FAILED_TO_GET_SESSION:"Failed to get session",INVALID_PASSWORD:"Invalid password",INVALID_EMAIL:"Invalid email",INVALID_EMAIL_OR_PASSWORD:"Invalid email or password",SOCIAL_ACCOUNT_ALREADY_LINKED:"Social account already linked",PROVIDER_NOT_FOUND:"Provider not found",INVALID_TOKEN:"Invalid token",ID_TOKEN_NOT_SUPPORTED:"id_token not supported",FAILED_TO_GET_USER_INFO:"Failed to get user info",USER_EMAIL_NOT_FOUND:"User email not found",EMAIL_NOT_VERIFIED:"Email not verified",PASSWORD_TOO_SHORT:"Password too short",PASSWORD_TOO_LONG:"Password too long",USER_ALREADY_EXISTS:"User already exists.",USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL:"User already exists. Use another email.",EMAIL_CAN_NOT_BE_UPDATED:"Email can not be updated",CREDENTIAL_ACCOUNT_NOT_FOUND:"Credential account not found",SESSION_EXPIRED:"Session expired. Re-authenticate to perform this action.",FAILED_TO_UNLINK_LAST_ACCOUNT:"You can't unlink your last account",ACCOUNT_NOT_FOUND:"Account not found",USER_ALREADY_HAS_PASSWORD:"User already has a password. Provide that to delete the account."},F=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function Yr(r){try{return(new URL(r).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new F(`Invalid base URL: ${r}. Please provide a valid base URL.`)}}function Z(r,e="/api/auth"){if(Yr(r))return r;let n=r.replace(/\/+$/,"");return!e||e==="/"?n:(e=e.startsWith("/")?e:`/${e}`,`${n}${e}`)}function ut(r,e,t,n){if(r)return Z(r,e);if(n!==!1){let i=x.BETTER_AUTH_URL||x.NEXT_PUBLIC_BETTER_AUTH_URL||x.PUBLIC_BETTER_AUTH_URL||x.NUXT_PUBLIC_BETTER_AUTH_URL||x.NUXT_PUBLIC_AUTH_URL||(x.BASE_URL!=="/"?x.BASE_URL:void 0);if(i)return Z(i,e)}let s=t?.headers.get("x-forwarded-host"),o=t?.headers.get("x-forwarded-proto");if(s&&o)return Z(`${o}://${s}`,e);if(t){let i=Qr(t.url);if(!i)throw new F("Could not get origin from request. Please provide a valid base URL.");return Z(i,e)}if(typeof window<"u"&&window.location)return Z(window.location.origin,e)}function Qr(r){try{return new URL(r).origin}catch{return null}}l();l();l();var ee=Symbol("clean");var N=[],B=0,ce=4,Xr=0,te=r=>{let e=[],t={get(){return t.lc||t.listen(()=>{})(),t.value},lc:0,listen(n){return t.lc=e.push(n),()=>{for(let o=B+ce;o<N.length;)N[o]===n?N.splice(o,ce):o+=ce;let s=e.indexOf(n);~s&&(e.splice(s,1),--t.lc||t.off())}},notify(n,s){Xr++;let o=!N.length;for(let i of e)N.push(i,t.value,n,s);if(o){for(B=0;B<N.length;B+=ce)N[B](N[B+1],N[B+2],N[B+3]);N.length=0}},off(){},set(n){let s=t.value;s!==n&&(t.value=n,t.notify(s))},subscribe(n){let s=t.listen(n);return n(t.value),s},value:r};return process.env.NODE_ENV!=="production"&&(t[ee]=()=>{e=[],t.lc=0,t.off()}),t};l();var Zr=5,K=6,ue=10,en=(r,e,t,n)=>(r.events=r.events||{},r.events[t+ue]||(r.events[t+ue]=n(s=>{r.events[t].reduceRight((o,i)=>(i(o),o),{shared:{},...s})})),r.events[t]=r.events[t]||[],r.events[t].push(e),()=>{let s=r.events[t],o=s.indexOf(e);s.splice(o,1),s.length||(delete r.events[t],r.events[t+ue](),delete r.events[t+ue])});var ft=1e3,Te=(r,e)=>en(r,n=>{let s=e(n);s&&r.events[K].push(s)},Zr,n=>{let s=r.listen;r.listen=(...i)=>(!r.lc&&!r.active&&(r.active=!0,n()),s(...i));let o=r.off;if(r.events[K]=[],r.off=()=>{o(),setTimeout(()=>{if(r.active&&!r.lc){r.active=!1;for(let i of r.events[K])i();r.events[K]=[]}},ft)},process.env.NODE_ENV!=="production"){let i=r[ee];r[ee]=()=>{for(let c of r.events[K])c();r.events[K]=[],r.active=!1,i()}}return()=>{r.listen=s,r.off=o}});l();var tn=typeof window>"u",fe=(r,e,t,n)=>{let s=te({data:null,error:null,isPending:!0,isRefetching:!1,refetch:c=>o(c)}),o=c=>{let f=typeof n=="function"?n({data:s.get().data,error:s.get().error,isPending:s.get().isPending}):n;t(e,{...f,query:{...f?.query,...c?.query},async onSuccess(a){s.set({data:a.data,error:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await f?.onSuccess?.(a)},async onError(a){let{request:u}=a,d=typeof u.retry=="number"?u.retry:u.retry?.attempts,m=u.retryAttempt||0;d&&m<d||(s.set({error:a.error,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await f?.onError?.(a))},async onRequest(a){let u=s.get();s.set({isPending:u.data===null,data:u.data,error:null,isRefetching:!0,refetch:s.value.refetch}),await f?.onRequest?.(a)}}).catch(a=>{s.set({error:a,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch})})};r=Array.isArray(r)?r:[r];let i=!1;for(let c of r)c.subscribe(()=>{tn||(i?o():Te(s,()=>{let f=setTimeout(()=>{i||(o(),i=!0)},0);return()=>{s.off(),c.off(),clearTimeout(f)}}))});return s};l();var rn={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},nn=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,dt={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},sn=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function on(r){return r instanceof Date&&!isNaN(r.getTime())}function an(r){let e=sn.exec(r);if(!e)return null;let[,t,n,s,o,i,c,f,a,u,d]=e,m=new Date(Date.UTC(parseInt(t,10),parseInt(n,10)-1,parseInt(s,10),parseInt(o,10),parseInt(i,10),parseInt(c,10),f?parseInt(f.padEnd(3,"0"),10):0));if(a){let y=(parseInt(u,10)*60+parseInt(d,10))*(a==="+"?-1:1);m.setUTCMinutes(m.getUTCMinutes()+y)}return on(m)?m:null}function ln(r,e={}){let{strict:t=!1,warnings:n=!1,reviver:s,parseDates:o=!0}=e;if(typeof r!="string")return r;let i=r.trim();if(i.length>0&&i[0]==='"'&&i.endsWith('"')&&!i.slice(1,-1).includes('"'))return i.slice(1,-1);let c=i.toLowerCase();if(c.length<=9&&c in dt)return dt[c];if(!nn.test(i)){if(t)throw new SyntaxError("[better-json] Invalid JSON");return r}if(Object.entries(rn).some(([a,u])=>{let d=u.test(i);return d&&n&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${a} pattern`),d})&&t)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(i,(u,d)=>{if(u==="__proto__"||u==="constructor"&&d&&typeof d=="object"&&"prototype"in d){n&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof d=="string"){let m=an(d);if(m)return m}return s?s(u,d):d})}catch(a){if(t)throw a;return r}}function ht(r,e={strict:!0}){return ln(r,e)}var cn={id:"redirect",name:"Redirect",hooks:{onSuccess(r){if(r.data?.url&&r.data?.redirect&&typeof window<"u"&&window.location&&window.location)try{window.location.href=r.data.url}catch{}}}};function un(r){let e=te(!1);return{session:fe(e,"/get-session",r,{method:"GET"}),$sessionSignal:e}}var pt=(r,e)=>{let t="credentials"in Request.prototype,n=ut(r?.baseURL,r?.basePath,void 0,e)??"/api/auth",s=r?.plugins?.flatMap(g=>g.fetchPlugins).filter(g=>g!==void 0)||[],o={id:"lifecycle-hooks",name:"lifecycle-hooks",hooks:{onSuccess:r?.fetchOptions?.onSuccess,onError:r?.fetchOptions?.onError,onRequest:r?.fetchOptions?.onRequest,onResponse:r?.fetchOptions?.onResponse}},{onSuccess:i,onError:c,onRequest:f,onResponse:a,...u}=r?.fetchOptions||{},d=lt({baseURL:n,...t?{credentials:"include"}:{},method:"GET",jsonParser(g){return g?ht(g,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[o,...u.plugins||[],...r?.disableDefaultFetchPlugins?[]:[cn],...s]}),{$sessionSignal:m,session:y}=un(d),b=r?.plugins||[],R={},w={$sessionSignal:m,session:y},E={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},O=[{signal:"$sessionSignal",matcher(g){return g==="/sign-out"||g==="/update-user"||g.startsWith("/sign-in")||g.startsWith("/sign-up")||g==="/delete-user"||g==="/verify-email"}}];for(let g of b)g.getAtoms&&Object.assign(w,g.getAtoms?.(d)),g.pathMethods&&Object.assign(E,g.pathMethods),g.atomListeners&&O.push(...g.atomListeners);let k={notify:g=>{w[g].set(!w[g].get())},listen:(g,q)=>{w[g].subscribe(q)},atoms:w};for(let g of b)g.getActions&&Object.assign(R,g.getActions?.(d,k,r));return{get baseURL(){return n},pluginsActions:R,pluginsAtoms:w,pluginPathMethods:E,atomListeners:O,$fetch:d,$store:k}};function fn(r){return typeof r=="object"&&r!==null&&"get"in r&&typeof r.get=="function"&&"lc"in r&&typeof r.lc=="number"}function dn(r,e,t){let n=e[r],{fetchOptions:s,query:o,...i}=t||{};return n||(s?.method?s.method:i&&Object.keys(i).length>0?"POST":"GET")}function mt(r,e,t,n,s){function o(i=[]){return new Proxy(function(){},{get(c,f){if(typeof f!="string"||f==="then"||f==="catch"||f==="finally")return;let a=[...i,f],u=r;for(let d of a)if(u&&typeof u=="object"&&d in u)u=u[d];else{u=void 0;break}return typeof u=="function"||fn(u)?u:o(a)},apply:async(c,f,a)=>{let u="/"+i.map(O=>O.replace(/[A-Z]/g,k=>`-${k.toLowerCase()}`)).join("/"),d=a[0]||{},m=a[1]||{},{query:y,fetchOptions:b,...R}=d,w={...m,...b},E=dn(u,t,d);return await e(u,{...w,body:E==="GET"?void 0:{...R,...w?.body||{}},query:y||w?.query,method:E,async onSuccess(O){if(await w?.onSuccess?.(O),!s)return;let k=s.filter(g=>g.matcher(u));if(k.length)for(let g of k){let q=n[g.signal];if(!q)return;let v=q.get();setTimeout(()=>{q.set(!v)},10)}}})}})}return o()}l();function gt(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Pe(r){let{pluginPathMethods:e,pluginsActions:t,pluginsAtoms:n,$fetch:s,atomListeners:o,$store:i}=pt(r),c={};for(let[u,d]of Object.entries(n))c[`use${gt(u)}`]=d;let f={...t,...c,$fetch:s,$store:i};return mt(f,s,e,n,o)}l();l();l();function hn(r){return{authorize(e,t="AND"){let n=!1;for(let[s,o]of Object.entries(e)){let i=r[s];if(!i)return{success:!1,error:`You are not allowed to access resource: ${s}`};if(Array.isArray(o))n=o.every(c=>i.includes(c));else if(typeof o=="object"){let c=o;c.connector==="OR"?n=c.actions.some(f=>i.includes(f)):n=c.actions.every(f=>i.includes(f))}else throw new F("Invalid access control request");if(n&&t==="OR")return{success:n};if(!n&&t==="AND")return{success:!1,error:`unauthorized to access resource "${s}"`}}return n?{success:n}:{success:!1,error:"Not authorized"}},statements:r}}function de(r){return{newRole(e){return hn(e)},statements:r}}var pn={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},Se=de(pn),mn=Se.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),gn=Se.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),yn=Se.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});l();l();l();l();l();l();l();l();l();l();l();var Oe=class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let t=new Error("Cancelling existing WebAuthn API call for new one");t.name="AbortError",this.controller.abort(t)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}},wt=new Oe;l();l();l();l();l();l();l();l();var Rn={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},_t=de(Rn),En=_t.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),Tn=_t.newRole({user:[],session:[]});l();l();var vt=()=>({id:"username",$InferServerPlugin:{}});var Rt=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(r){return r==="/phone-number/update"||r==="/phone-number/verify"},signal:"$sessionSignal"}]});var Et=()=>({id:"better-auth-client",$InferServerPlugin:{}});var Pn="/auth",he="nvwa_login_token",xe="nvwa_user_profile",Tt=class{constructor(e,t,n){this.storage=n;let s=Pe({baseURL:e,basePath:Pn,plugins:[vt(),Rt(),Et()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:()=>n.get(he)},onSuccess:o=>{let i=o.response.headers.get("set-auth-token");console.log("success",o.data,o.request),i&&n.set(he,i)}}});this.authClient=s}async currentUser(){return await this.storage.get(xe)}async signUp(e){let t=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:e.password});this.saveSession(t)}async sendPhoneNumberCode(e){await this.authClient.phoneNumber.sendOtp({phoneNumber:e})}async signInWithPhoneNumberCode(e,t){let n=await this.authClient.phoneNumber.verify({phoneNumber:e,code:t});this.saveSession(n)}async signInWithPhoneNumber(e,t,n=!1){let s=await this.authClient.signIn.phoneNumber({phoneNumber:e,password:t,rememberMe:n});this.saveSession(s)}async signInWithUsername(e,t){let n=await this.authClient.signIn.username({username:e,password:t});this.saveSession(n)}saveSession(e){if(e.error)throw new Error(e.error.message);this.storage.set(he,e.data?.token),this.storage.set(xe,e.data?.user)}async signOut(){await this.storage.remove(he),await this.storage.remove(xe)}async updateUserPassword(e,t,n=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:n});this.saveSession(s)}};l();var Pt=class{constructor(e){this.http=e}async invoke(e,t){return(await this.http.request("/functions/"+e,{method:t.method||"POST",data:t.body,headers:t.headers})).body}};l();var St=class{async jsonRequest(e,t){let n={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.request(e,n)}async jsonRequestWithAuth(e,t,n){let s={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.requestWithAuth(e,s,n)}};l();var Sn="/storage",On=Sn+"/generateUploadUrl",Ot=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.request(this.baseUrl+On,{method:"POST",data:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:n}=t.body;if(!n)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");return{url:(await this.http.request(n,{method:"PUT",data:e,headers:{"Content-Type":e.type||e.fileType||"application/octet-stream"}})).body.url.split("?")[0]}}};l();l();l();var Je=_r(cr(),1),{PostgrestClient:ur,PostgrestQueryBuilder:Da,PostgrestFilterBuilder:$a,PostgrestTransformBuilder:ka,PostgrestBuilder:ja,PostgrestError:Ma}=Je.default||Je;l();l();var C=class r{constructor(e){this.headerMap=new Map;if(e){if(e instanceof r)e.forEach((t,n)=>this.set(n,t));else if(Array.isArray(e))for(let[t,n]of e)this.set(t,String(n));else if(typeof e=="object")for(let t of Object.keys(e))this.set(t,String(e[t]))}}append(e,t){let n=e.toLowerCase(),s=this.headerMap.get(n);this.headerMap.set(n,s?`${s}, ${t}`:t)}set(e,t){this.headerMap.set(e.toLowerCase(),String(t))}get(e){let t=this.headerMap.get(e.toLowerCase());return t??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[t,n]of this.headerMap.entries())e(n,t,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},ne=class r{constructor(e){this.params=new Map;if(e){if(typeof e=="string")this.parseString(e);else if(e instanceof r)this.params=new Map(e.params);else if(Array.isArray(e))for(let[t,n]of e)this.append(t,n);else if(e&&typeof e=="object")for(let[t,n]of Object.entries(e))this.set(t,n)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let t=e.split("&");for(let n of t)if(n){let[s,o]=n.split("=");s&&this.append(decodeURIComponent(s),o?decodeURIComponent(o):"")}}append(e,t){let n=this.params.get(e)||[];n.push(t),this.params.set(e,n)}delete(e){this.params.delete(e)}get(e){let t=this.params.get(e);return t?t[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,t){this.params.set(e,[t])}sort(){let e=Array.from(this.params.entries()).sort(([t],[n])=>t.localeCompare(n));this.params=new Map(e)}toString(){let e=[];for(let[t,n]of this.params.entries())for(let s of n)e.push(`${encodeURIComponent(t)}=${encodeURIComponent(s)}`);return e.join("&")}forEach(e){for(let[t,n]of this.params.entries())for(let s of n)e(s,t,this)}keys(){return this.params.keys()}values(){let e=[];for(let t of this.params.values())e.push(...t);return e[Symbol.iterator]()}entries(){let e=[];for(let[t,n]of this.params.entries())for(let s of n)e.push([t,s]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},be=class r{constructor(e,t){let n;if(e instanceof r)n=e.href;else if(t){let o=t instanceof r?t.href:t;n=this.resolve(o,e)}else n=e;let s=this.parseUrl(n);this.href=n,this.origin=`${s.protocol}//${s.host}`,this.protocol=s.protocol,this.username=s.username,this.password=s.password,this.host=s.host,this.hostname=s.hostname,this.port=s.port,this.pathname=s.pathname,this.search=s.search,this.searchParams=new ne(s.search),this.hash=s.hash}resolve(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(t.startsWith("//"))return`${this.parseUrl(e).protocol}${t}`;if(t.startsWith("/")){let o=this.parseUrl(e);return`${o.protocol}//${o.host}${t}`}let n=this.parseUrl(e),s=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return`${n.protocol}//${n.host}${s}${t}`}parseUrl(e){let t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)throw new TypeError("Invalid URL");let n=t[2]||"",s=t[4]||"",o=t[5]||"/",i=t[7]?`?${t[7]}`:"",c=t[9]?`#${t[9]}`:"";if(!n&&!s&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let f=s.match(/^([^@]*)@(.+)$/),a="",u="",d=s;if(f){let R=f[1];d=f[2];let w=R.match(/^([^:]*):?(.*)$/);w&&(a=w[1]||"",u=w[2]||"")}let m=d.match(/^([^:]+):?(\d*)$/),y=m?m[1]:d,b=m&&m[2]?m[2]:"";return{protocol:n?`${n}:`:"",username:a,password:u,host:d,hostname:y,port:b,pathname:o,search:i,hash:c}}toString(){let e=this.searchParams.toString(),t=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${t}${this.hash}`}toJSON(){return this.toString()}};l();var we=class r{constructor(e,t){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(t?.method||"GET").toUpperCase(),this.headers=t?.headers instanceof C?t.headers:new C(t?.headers),this.body=t?.body,this.timeout=t?.timeout,this.signal=t?.signal||void 0}clone(){return new r(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};l();var V=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=qn(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function qn(r){return r?new C(r):new C}l();var se=class{constructor(){this._aborted=!1;this.listeners=new Set;this.onabort=null}get aborted(){return this._aborted}_trigger(){if(!this._aborted){if(this._aborted=!0,typeof this.onabort=="function")try{this.onabort()}catch{}for(let e of Array.from(this.listeners))try{e()}catch{}this.listeners.clear()}}addEventListener(e,t){if(this._aborted){try{t()}catch{}return}this.listeners.add(t)}removeEventListener(e,t){this.listeners.delete(t)}toString(){return"[object AbortSignal]"}},_e=class{constructor(){this._signal=new se}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};l();function rl(r){r.URL=be,r.URLSearchParams=ne,r.Headers=C,r.Request=we,r.Response=V,r.AbortController=_e,r.AbortSignal=se}var Hn="/entities",Fn=(r,e)=>async(n,s)=>{console.log("customFetch",n,s);let o;if(typeof n=="string")o=n;else if(n&&typeof n=="object")if(typeof n.toString=="function"&&!n.url)o=n.toString();else if(n.url)o=n.url,s||(s={}),s.method=n.method,s.headers=n.headers,s.body=n.body;else throw new Error("Unsupported input type for fetch");else throw new Error("Unsupported input type for fetch");let i=(s?.method||"GET").toUpperCase(),c={};if(s?.headers)if(s.headers&&typeof s.headers.forEach=="function")s.headers.forEach((y,b)=>{c[b]=y});else if(Array.isArray(s.headers))for(let[y,b]of s.headers)c[y]=b;else Object.assign(c,s.headers);let f=s?.body,a;try{a=await r.requestWithAuth(o,{method:i,data:f,headers:c},e)}catch(y){return new V(y?.message||"Internal Error",{status:500,statusText:"Internal Error"})}let u=a.body,d=null;return(a.headers["content-type"]||a.headers["Content-Type"]||"").startsWith("application/json")&&typeof u!="string"?d=JSON.stringify(u):typeof u=="string"||u&&(u.constructor===Blob||u.constructor===ArrayBuffer||typeof u.getReader=="function")?d=u:d=JSON.stringify(u),new V(d,{status:a.status,headers:new C(a.headers)})},bl=(r,e,t)=>new ur(r+Hn,{fetch:Fn(e,t)});export{Pn as AUTH_BASE_PATH,_e as AbortController,se as AbortSignal,Hn as ENTITIES_BASE_PATH,Sn as FILE_STORAGE_BASE_PATH,On as GENERATE_UPLOAD_URL_PATH,C as Headers,he as LOGIN_TOKEN_KEY,xe as LOGIN_USER_PROFILE_KEY,Tt as NvwaAuthClient,Pt as NvwaEdgeFunctions,Ot as NvwaFileStorage,St as NvwaHttpClient,we as Request,V as Response,be as URL,ne as URLSearchParams,bl as createPostgrestClient,rl as polyfill};
|