@nvwa-app/sdk-core 0.7.7 → 0.9.0
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 +49 -1
- package/dist/index.d.ts +49 -1
- package/dist/index.js +33 -1
- package/dist/index.mjs +33 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -212,6 +212,54 @@ declare class NvwaSkill {
|
|
|
212
212
|
declare const ENTITIES_BASE_PATH = "/entities";
|
|
213
213
|
declare const createPostgrestClient: (baseUrl: string, httpClient: NvwaHttpClient) => PostgrestClient<any, {} | _nvwa_app_postgrest_js.PostgrestClientOptions, "public", any>;
|
|
214
214
|
|
|
215
|
+
/**
|
|
216
|
+
* 公共的 Inspector 消息类型定义
|
|
217
|
+
*/
|
|
218
|
+
interface HoverInspectorMessage {
|
|
219
|
+
type: 'HOVER_INSPECTOR_ENABLE' | 'HOVER_INSPECTOR_DISABLE' | 'HOVER_INSPECTOR_ELEMENT_HOVER' | 'HOVER_INSPECTOR_ELEMENT_LEAVE' | 'HOVER_INSPECTOR_ELEMENT_SELECT';
|
|
220
|
+
sourceLocation?: string | null;
|
|
221
|
+
elementInfo?: {
|
|
222
|
+
tagName: string;
|
|
223
|
+
className: string;
|
|
224
|
+
id: string;
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
interface IframeSourceLocationMessage {
|
|
228
|
+
type: 'GET_SOURCE_LOCATION_REQUEST' | 'GET_SOURCE_LOCATION_RESPONSE';
|
|
229
|
+
sourceLocation?: string | null;
|
|
230
|
+
error?: string;
|
|
231
|
+
requestId?: string;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* 公共的 Overlay 工具函数
|
|
235
|
+
*/
|
|
236
|
+
declare class OverlayManager {
|
|
237
|
+
private hoverOverlay;
|
|
238
|
+
private selectedOverlay;
|
|
239
|
+
private tooltip;
|
|
240
|
+
private hoverElement;
|
|
241
|
+
private selectedElement;
|
|
242
|
+
private hoverUpdateHandler;
|
|
243
|
+
private selectedUpdateHandler;
|
|
244
|
+
constructor();
|
|
245
|
+
private createStyles;
|
|
246
|
+
private createTooltip;
|
|
247
|
+
private createOverlay;
|
|
248
|
+
private updateOverlayPosition;
|
|
249
|
+
private removeOverlay;
|
|
250
|
+
highlightElement(el: HTMLElement, sourceLocation: string | null): void;
|
|
251
|
+
selectElement(el: HTMLElement, sourceLocation: string | null): void;
|
|
252
|
+
removeHighlight(): void;
|
|
253
|
+
clearSelection(): void;
|
|
254
|
+
cleanup(): void;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* 从 DOM 获取 source location
|
|
258
|
+
* @param rootSelector 根元素的选择器 ID,默认为 'root'
|
|
259
|
+
* @returns source location 字符串,格式如 "pages/index.tsx:3"
|
|
260
|
+
*/
|
|
261
|
+
declare function getSourceLocationFromDOM(rootSelector?: string): string | null;
|
|
262
|
+
|
|
215
263
|
interface INvwa {
|
|
216
264
|
entities: PostgrestClient;
|
|
217
265
|
auth: NvwaAuthClient;
|
|
@@ -220,4 +268,4 @@ interface INvwa {
|
|
|
220
268
|
skill: NvwaSkill;
|
|
221
269
|
}
|
|
222
270
|
|
|
223
|
-
export { AUTH_BASE_PATH, AbortController, AbortSignal, type AuthClient, CURRENT_JWT_KEY, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, Headers, type HttpMethod, type HttpUploadFileResponse, type INvwa, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, type NvwaAppUser, NvwaAuthClient, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, NvwaSkill, type RegisterUser, Request, type RequestInfo, type RequestInit, Response, type ResponseInit, type SkillExecuteResponse, URL$1 as URL, URLSearchParams, createPostgrestClient, polyfill };
|
|
271
|
+
export { AUTH_BASE_PATH, AbortController, AbortSignal, type AuthClient, CURRENT_JWT_KEY, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, Headers, type HoverInspectorMessage, type HttpMethod, type HttpUploadFileResponse, type INvwa, type IframeSourceLocationMessage, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, type NvwaAppUser, NvwaAuthClient, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, NvwaSkill, OverlayManager, type RegisterUser, Request, type RequestInfo, type RequestInit, Response, type ResponseInit, type SkillExecuteResponse, URL$1 as URL, URLSearchParams, createPostgrestClient, getSourceLocationFromDOM, polyfill };
|
package/dist/index.d.ts
CHANGED
|
@@ -212,6 +212,54 @@ declare class NvwaSkill {
|
|
|
212
212
|
declare const ENTITIES_BASE_PATH = "/entities";
|
|
213
213
|
declare const createPostgrestClient: (baseUrl: string, httpClient: NvwaHttpClient) => PostgrestClient<any, {} | _nvwa_app_postgrest_js.PostgrestClientOptions, "public", any>;
|
|
214
214
|
|
|
215
|
+
/**
|
|
216
|
+
* 公共的 Inspector 消息类型定义
|
|
217
|
+
*/
|
|
218
|
+
interface HoverInspectorMessage {
|
|
219
|
+
type: 'HOVER_INSPECTOR_ENABLE' | 'HOVER_INSPECTOR_DISABLE' | 'HOVER_INSPECTOR_ELEMENT_HOVER' | 'HOVER_INSPECTOR_ELEMENT_LEAVE' | 'HOVER_INSPECTOR_ELEMENT_SELECT';
|
|
220
|
+
sourceLocation?: string | null;
|
|
221
|
+
elementInfo?: {
|
|
222
|
+
tagName: string;
|
|
223
|
+
className: string;
|
|
224
|
+
id: string;
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
interface IframeSourceLocationMessage {
|
|
228
|
+
type: 'GET_SOURCE_LOCATION_REQUEST' | 'GET_SOURCE_LOCATION_RESPONSE';
|
|
229
|
+
sourceLocation?: string | null;
|
|
230
|
+
error?: string;
|
|
231
|
+
requestId?: string;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* 公共的 Overlay 工具函数
|
|
235
|
+
*/
|
|
236
|
+
declare class OverlayManager {
|
|
237
|
+
private hoverOverlay;
|
|
238
|
+
private selectedOverlay;
|
|
239
|
+
private tooltip;
|
|
240
|
+
private hoverElement;
|
|
241
|
+
private selectedElement;
|
|
242
|
+
private hoverUpdateHandler;
|
|
243
|
+
private selectedUpdateHandler;
|
|
244
|
+
constructor();
|
|
245
|
+
private createStyles;
|
|
246
|
+
private createTooltip;
|
|
247
|
+
private createOverlay;
|
|
248
|
+
private updateOverlayPosition;
|
|
249
|
+
private removeOverlay;
|
|
250
|
+
highlightElement(el: HTMLElement, sourceLocation: string | null): void;
|
|
251
|
+
selectElement(el: HTMLElement, sourceLocation: string | null): void;
|
|
252
|
+
removeHighlight(): void;
|
|
253
|
+
clearSelection(): void;
|
|
254
|
+
cleanup(): void;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* 从 DOM 获取 source location
|
|
258
|
+
* @param rootSelector 根元素的选择器 ID,默认为 'root'
|
|
259
|
+
* @returns source location 字符串,格式如 "pages/index.tsx:3"
|
|
260
|
+
*/
|
|
261
|
+
declare function getSourceLocationFromDOM(rootSelector?: string): string | null;
|
|
262
|
+
|
|
215
263
|
interface INvwa {
|
|
216
264
|
entities: PostgrestClient;
|
|
217
265
|
auth: NvwaAuthClient;
|
|
@@ -220,4 +268,4 @@ interface INvwa {
|
|
|
220
268
|
skill: NvwaSkill;
|
|
221
269
|
}
|
|
222
270
|
|
|
223
|
-
export { AUTH_BASE_PATH, AbortController, AbortSignal, type AuthClient, CURRENT_JWT_KEY, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, Headers, type HttpMethod, type HttpUploadFileResponse, type INvwa, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, type NvwaAppUser, NvwaAuthClient, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, NvwaSkill, type RegisterUser, Request, type RequestInfo, type RequestInit, Response, type ResponseInit, type SkillExecuteResponse, URL$1 as URL, URLSearchParams, createPostgrestClient, polyfill };
|
|
271
|
+
export { AUTH_BASE_PATH, AbortController, AbortSignal, type AuthClient, CURRENT_JWT_KEY, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, Headers, type HoverInspectorMessage, type HttpMethod, type HttpUploadFileResponse, type INvwa, type IframeSourceLocationMessage, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, type NvwaAppUser, NvwaAuthClient, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, NvwaSkill, OverlayManager, type RegisterUser, Request, type RequestInfo, type RequestInit, Response, type ResponseInit, type SkillExecuteResponse, URL$1 as URL, URLSearchParams, createPostgrestClient, getSourceLocationFromDOM, polyfill };
|
package/dist/index.js
CHANGED
|
@@ -1 +1,33 @@
|
|
|
1
|
-
"use strict";var _r=Object.create;var ce=Object.defineProperty;var vr=Object.getOwnPropertyDescriptor;var Er=Object.getOwnPropertyNames;var Rr=Object.getPrototypeOf,Pr=Object.prototype.hasOwnProperty;var nt=(r,e)=>()=>(r&&(e=r(r=0)),e);var H=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),st=(r,e)=>{for(var t in e)ce(r,t,{get:e[t],enumerable:!0})},ot=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Er(e))!Pr.call(r,s)&&s!==t&&ce(r,s,{get:()=>e[s],enumerable:!(n=vr(e,s))||n.enumerable});return r};var Sr=(r,e,t)=>(t=r!=null?_r(Rr(r)):{},ot(e||!r||!r.__esModule?ce(t,"default",{value:r,enumerable:!0}):t,r)),q=r=>ot(ce({},"__esModule",{value:!0}),r);var a=nt(()=>{"use strict"});var G={};st(G,{__addDisposableResource:()=>nr,__assign:()=>be,__asyncDelegator:()=>Jt,__asyncGenerator:()=>Kt,__asyncValues:()=>Yt,__await:()=>Y,__awaiter:()=>qt,__classPrivateFieldGet:()=>er,__classPrivateFieldIn:()=>rr,__classPrivateFieldSet:()=>tr,__createBinding:()=>_e,__decorate:()=>Dt,__disposeResources:()=>sr,__esDecorate:()=>kt,__exportStar:()=>Gt,__extends:()=>Nt,__generator:()=>Ft,__importDefault:()=>Zt,__importStar:()=>Xt,__makeTemplateObject:()=>Qt,__metadata:()=>Ht,__param:()=>$t,__propKey:()=>Mt,__read:()=>$e,__rest:()=>Lt,__rewriteRelativeImportExtension:()=>or,__runInitializers:()=>jt,__setFunctionName:()=>Bt,__spread:()=>Wt,__spreadArray:()=>zt,__spreadArrays:()=>Vt,__values:()=>we,default:()=>Ln});function Nt(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Le(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Lt(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 Dt(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 $t(r,e){return function(t,n){e(t,n,r)}}function kt(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",l=!e&&r?n.static?r:r.prototype:null,u=e||(l?Object.getOwnPropertyDescriptor(l,n.name):{}),d,p=!1,g=t.length-1;g>=0;g--){var b={};for(var v in n)b[v]=v==="access"?{}:n[v];for(var v in n.access)b.access[v]=n.access[v];b.addInitializer=function(E){if(p)throw new TypeError("Cannot add initializers after decoration has completed");o.push(i(E||null))};var y=(0,t[g])(c==="accessor"?{get:u.get,set:u.set}:u[f],b);if(c==="accessor"){if(y===void 0)continue;if(y===null||typeof y!="object")throw new TypeError("Object expected");(d=i(y.get))&&(u.get=d),(d=i(y.set))&&(u.set=d),(d=i(y.init))&&s.unshift(d)}else(d=i(y))&&(c==="field"?s.unshift(d):u[f]=d)}l&&Object.defineProperty(l,n.name,u),p=!0}function jt(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 Mt(r){return typeof r=="symbol"?r:"".concat(r)}function Bt(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 Ht(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function qt(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{l(n.next(u))}catch(d){i(d)}}function f(u){try{l(n.throw(u))}catch(d){i(d)}}function l(u){u.done?o(u.value):s(u.value).then(c,f)}l((n=n.apply(r,e||[])).next())})}function Ft(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(l){return function(u){return f([l,u])}}function f(l){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(t=0)),t;)try{if(n=1,s&&(o=l[0]&2?s.return:l[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,l[1])).done)return o;switch(s=0,o&&(l=[l[0]&2,o.value]),l[0]){case 0:case 1:o=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,s=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!o||l[1]>o[0]&&l[1]<o[3])){t.label=l[1];break}if(l[0]===6&&t.label<o[1]){t.label=o[1],o=l;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(l);break}o[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(r,t)}catch(u){l=[6,u],s=0}finally{n=o=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Gt(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&_e(e,r,t)}function we(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 $e(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 Wt(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat($e(arguments[e]));return r}function Vt(){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 zt(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 Y(r){return this instanceof Y?(this.v=r,this):new Y(r)}function Kt(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(b){return Promise.resolve(b).then(g,d)}}function c(g,b){n[g]&&(s[g]=function(v){return new Promise(function(y,E){o.push([g,v,y,E])>1||f(g,v)})},b&&(s[g]=b(s[g])))}function f(g,b){try{l(n[g](b))}catch(v){p(o[0][3],v)}}function l(g){g.value instanceof Y?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,b){g(b),o.shift(),o.length&&f(o[0][0],o[0][1])}}function Jt(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:Y(r[s](i)),done:!1}:o?o(i):i}:o}}function Yt(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 we=="function"?we(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(l){o({value:l,done:c})},i)}}function Qt(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function Xt(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t=De(r),n=0;n<t.length;n++)t[n]!=="default"&&_e(e,r,t[n]);return Cn(e,r),e}function Zt(r){return r&&r.__esModule?r:{default:r}}function er(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 tr(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 rr(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 nr(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 sr(r){function e(o){r.error=r.hasError?new Nn(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 or(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 Le,be,_e,Cn,De,Nn,Ln,W=nt(()=>{"use strict";a();Le=function(r,e){return Le=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])},Le(r,e)};be=function(){return be=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},be.apply(this,arguments)};_e=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]});Cn=Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e},De=function(r){return De=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},De(r)};Nn=typeof SuppressedError=="function"?SuppressedError:function(r,e,t){var n=new Error(t);return n.name="SuppressedError",n.error=r,n.suppressed=e,n};Ln={__extends:Nt,__assign:be,__rest:Lt,__decorate:Dt,__param:$t,__esDecorate:kt,__runInitializers:jt,__propKey:Mt,__setFunctionName:Bt,__metadata:Ht,__awaiter:qt,__generator:Ft,__createBinding:_e,__exportStar:Gt,__values:we,__read:$e,__spread:Wt,__spreadArrays:Vt,__spreadArray:zt,__await:Y,__asyncGenerator:Kt,__asyncDelegator:Jt,__asyncValues:Yt,__makeTemplateObject:Qt,__importStar:Xt,__importDefault:Zt,__classPrivateFieldGet:er,__classPrivateFieldSet:tr,__classPrivateFieldIn:rr,__addDisposableResource:nr,__disposeResources:sr,__rewriteRelativeImportExtension:or}});var Me=H(je=>{"use strict";a();Object.defineProperty(je,"__esModule",{value:!0});var ke=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=ke});var qe=H(He=>{"use strict";a();Object.defineProperty(He,"__esModule",{value:!0});var Dn=(W(),q(G)),$n=Dn.__importDefault(Me()),Be=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,l;let u=null,d=null,p=null,g=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 y=(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("/");y&&E&&E.length>1&&(p=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,p=null,g=406,b="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let y=await o.text();try{u=JSON.parse(y),Array.isArray(u)&&o.status===404&&(d=[],u=null,g=200,b="OK")}catch{o.status===404&&y===""?(g=204,b="No Content"):u={message:y}}if(u&&this.isMaybeSingle&&(!((l=u?.details)===null||l===void 0)&&l.includes("0 rows"))&&(u=null,g=200,b="OK"),u&&this.shouldThrowOnError)throw new $n.default(u)}return{error:u,data:d,count:p,status:g,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}};He.default=Be});var We=H(Ge=>{"use strict";a();Object.defineProperty(Ge,"__esModule",{value:!0});var kn=(W(),q(G)),jn=kn.__importDefault(qe()),Fe=class extends jn.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("|"),l=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${l}"; 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}};Ge.default=Fe});var ve=H(ze=>{"use strict";a();Object.defineProperty(ze,"__esModule",{value:!0});var Mn=(W(),q(G)),Bn=Mn.__importDefault(We()),Hn=new RegExp("[,()]"),Ve=class extends Bn.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"&&Hn.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}};ze.default=Ve});var Ye=H(Je=>{"use strict";a();Object.defineProperty(Je,"__esModule",{value:!0});var qn=(W(),q(G)),ae=qn.__importDefault(ve()),Ke=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 ae.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 ae.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((l,u)=>l.concat(Object.keys(u)),[]);if(f.length>0){let l=[...new Set(f)].map(u=>`"${u}"`);this.url.searchParams.set("columns",l.join(","))}}return new ae.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 ae.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 ae.default({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};Je.default=Ke});var ar=H(Xe=>{"use strict";a();Object.defineProperty(Xe,"__esModule",{value:!0});var ir=(W(),q(G)),Fn=ir.__importDefault(Ye()),Gn=ir.__importDefault(ve()),Qe=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 Fn.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}`),l;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",l=t);let u=new Headers(this.headers);return o&&u.set("Prefer",`count=${o}`),new Gn.default({method:c,url:f,headers:u,schema:this.schemaName,body:l,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}};Xe.default=Qe});var pr=H(T=>{"use strict";a();Object.defineProperty(T,"__esModule",{value:!0});T.PostgrestError=T.PostgrestBuilder=T.PostgrestTransformBuilder=T.PostgrestFilterBuilder=T.PostgrestQueryBuilder=T.PostgrestClient=void 0;var Q=(W(),q(G)),lr=Q.__importDefault(ar());T.PostgrestClient=lr.default;var cr=Q.__importDefault(Ye());T.PostgrestQueryBuilder=cr.default;var ur=Q.__importDefault(ve());T.PostgrestFilterBuilder=ur.default;var fr=Q.__importDefault(We());T.PostgrestTransformBuilder=fr.default;var dr=Q.__importDefault(qe());T.PostgrestBuilder=dr.default;var hr=Q.__importDefault(Me());T.PostgrestError=hr.default;T.default={PostgrestClient:lr.default,PostgrestQueryBuilder:cr.default,PostgrestFilterBuilder:ur.default,PostgrestTransformBuilder:fr.default,PostgrestBuilder:dr.default,PostgrestError:hr.default}});var Vn={};st(Vn,{AUTH_BASE_PATH:()=>It,AbortController:()=>ie,AbortSignal:()=>J,CURRENT_JWT_KEY:()=>z,ENTITIES_BASE_PATH:()=>gr,FILE_STORAGE_BASE_PATH:()=>Ut,GENERATE_UPLOAD_URL_PATH:()=>Ct,Headers:()=>S,LOGIN_TOKEN_KEY:()=>ge,LOGIN_USER_PROFILE_KEY:()=>ye,NvwaAuthClient:()=>Ie,NvwaEdgeFunctions:()=>Ue,NvwaFileStorage:()=>Ne,NvwaHttpClient:()=>Ce,NvwaSkill:()=>et,Request:()=>se,Response:()=>oe,URL:()=>ne,URLSearchParams:()=>K,createPostgrestClient:()=>Wn,polyfill:()=>Un});module.exports=q(Vn);a();a();a();a();a();a();var Tr=Object.defineProperty,Or=Object.defineProperties,Ar=Object.getOwnPropertyDescriptors,it=Object.getOwnPropertySymbols,xr=Object.prototype.hasOwnProperty,Ir=Object.prototype.propertyIsEnumerable,at=(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={}))xr.call(e,t)&&at(r,t,e[t]);if(it)for(var t of it(e))Ir.call(e,t)&&at(r,t,e[t]);return r},N=(r,e)=>Or(r,Ar(e)),Ur=class extends Error{constructor(r,e,t){super(e||r.toString(),{cause:t}),this.status=r,this.statusText=e,this.error=t}},Cr=async(r,e)=>{var t,n,s,o,i,c;let f=e||{},l={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:l};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}l.onRequest.push((n=u.hooks)==null?void 0:n.onRequest),l.onResponse.push((s=u.hooks)==null?void 0:s.onResponse),l.onSuccess.push((o=u.hooks)==null?void 0:o.onSuccess),l.onError.push((i=u.hooks)==null?void 0:i.onError),l.onRetry.push((c=u.hooks)==null?void 0:c.onRetry)}return{url:r,options:f,hooks:l}},lt=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}},Nr=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 Lr(r){if(typeof r=="number")return new lt({type:"linear",attempts:r,delay:1e3});switch(r.type){case"linear":return new lt(r);case"exponential":return new Nr(r);default:throw new Error("Invalid retry strategy")}}var Dr=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},$r=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function kr(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 $r.test(n)?"json":t.has(n)||n.startsWith("text/")?"text":"blob"}function jr(r){try{return JSON.parse(r),!0}catch{return!1}}function ft(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 ct(r){try{return JSON.parse(r)}catch{return r}}function ut(r){return typeof r=="function"}function Mr(r){if(r?.customFetchImpl)return r.customFetchImpl;if(typeof globalThis<"u"&&ut(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&ut(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function Br(r){let e=new Headers(r?.headers),t=await Dr(r);for(let[n,s]of Object.entries(t||{}))e.set(n,s);if(!e.has("content-type")){let n=Hr(r?.body);n&&e.set("content-type",n)}return e}function Hr(r){return ft(r)?"application/json":null}function qr(r){if(!r?.body)return null;let e=new Headers(r?.headers);if(ft(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 Fr(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 ht.includes(n)?n.toUpperCase():e?.body?"POST":"GET"}return e?.body?"POST":"GET"}function Gr(r,e){let t;return!r?.signal&&r?.timeout&&(t=setTimeout(()=>e?.abort(),r?.timeout)),{abortTimeout:t,clearTimeout:()=>{t&&clearTimeout(t)}}}var Wr=class dt extends Error{constructor(e,t){super(t||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,dt.prototype)}};async function ue(r,e){let t=await r["~standard"].validate(e);if(t.issues)throw new Wr(t.issues);return t.value}var ht=["get","post","put","patch","delete"];var Vr=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 l;return(l=f.schema)!=null&&l.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 l=c.schema[f];if(l){let u=N(U({},t),{method:l.method,output:l.output});return t?.disableValidation||(u=N(U({},u),{body:l.input?await ue(l.input,t?.body):t?.body,params:l.params?await ue(l.params,t?.params):t?.params,query:l.query?await ue(l.query,t?.query):t?.query})),{url:e,options:u}}}return{url:e,options:t}}}),pt=r=>{async function e(t,n){let s=N(U(U({},r),n),{plugins:[...r?.plugins||[],Vr(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 zr(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];ht.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 b=n[p];i=i.replace(g,b)}}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 l=f.toString();return l=l.length>0?`?${l}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${i}${l}`,o):`${o}${i}${l}`}var Re=async(r,e)=>{var t,n,s,o,i,c,f,l;let{hooks:u,url:d,options:p}=await Cr(r,e),g=Mr(p),b=new AbortController,v=(t=p.signal)!=null?t:b.signal,y=zr(d,p),E=qr(p),O=await Br(p),$=Fr(d,p),m=N(U({},p),{url:y,headers:O,body:E,method:$,signal:v});for(let I of u.onRequest)if(I){let P=await I(m);P instanceof Object&&(m=P)}("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:B}=Gr(p,b),_=await g(m.url,m);B();let tt={response:_,request:m};for(let I of u.onResponse)if(I){let P=await I(N(U({},tt),{response:(s=e?.hookOptions)!=null&&s.cloneResponse?_.clone():_}));P instanceof Response?_=P:P instanceof Object&&(_=P.response)}if(_.ok){if(!(m.method!=="HEAD"))return{data:"",error:null};let P=kr(_),k={data:"",response:_,request:m};if(P==="json"||P==="text"){let j=await _.text(),wr=await((o=m.jsonParser)!=null?o:ct)(j);k.data=wr}else k.data=await _[P]();m?.output&&m.output&&!m.disableValidation&&(k.data=await ue(m.output,k.data));for(let j of u.onSuccess)j&&await j(N(U({},k),{response:(i=e?.hookOptions)!=null&&i.cloneResponse?_.clone():_}));return e?.throw?k.data:{data:k.data,error:null}}let yr=(c=e?.jsonParser)!=null?c:ct,le=await _.text(),rt=jr(le),Ee=rt?await yr(le):null,br={response:_,responseText:le,request:m,error:N(U({},Ee),{status:_.status,statusText:_.statusText})};for(let I of u.onError)I&&await I(N(U({},br),{response:(f=e?.hookOptions)!=null&&f.cloneResponse?_.clone():_}));if(e?.retry){let I=Lr(e.retry),P=(l=e.retryAttempt)!=null?l:0;if(await I.shouldAttemptRetry(P,_)){for(let j of u.onRetry)j&&await j(tt);let k=I.getDelay(P);return await new Promise(j=>setTimeout(j,k)),await Re(r,N(U({},e),{retryAttempt:P+1}))}}if(e?.throw)throw new Ur(_.status,_.statusText,rt?Ee:le);return{data:null,error:N(U({},Ee),{status:_.status,statusText:_.statusText})}};a();a();var fe=Object.create(null),X=r=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(r?fe:globalThis),x=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 ts=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 rs=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,R=4,L=8,A=24,mt={eterm:R,cons25:R,console:R,cygwin:R,dtterm:R,gnome:R,hurd:R,jfbterm:R,konsole:R,kterm:R,mlterm:R,mosh:A,putty:R,st:R,"rxvt-unicode-24bit":A,terminator:A,"xterm-kitty":A},Kr=new Map(Object.entries({APPVEYOR:L,BUILDKITE:L,CIRCLECI:A,DRONE:L,GITEA_ACTIONS:A,GITHUB_ACTIONS:A,GITLAB_CI:L,TRAVIS:L})),Jr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Yr(){if(w("FORCE_COLOR")!==void 0)switch(w("FORCE_COLOR")){case"":case"1":case"true":return R;case"2":return L;case"3":return A;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 A;if("TF_BUILD"in x&&"AGENT_NAME"in x)return R;if("CI"in x){for(let{0:r,1:e}of Kr)if(r in x)return e;return w("CI_NAME")==="codeship"?L:Z}if("TEAMCITY_VERSION"in x)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(w("TEAMCITY_VERSION"))!==null?R:Z;switch(w("TERM_PROGRAM")){case"iTerm.app":return!w("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(w("TERM_PROGRAM_VERSION"))!==null?L:A;case"HyperTerm":case"MacTerm":return A;case"Apple_Terminal":return L}if(w("COLORTERM")==="truecolor"||w("COLORTERM")==="24bit")return A;if(w("TERM")){if(/truecolor/.exec(w("TERM"))!==null)return A;if(/^xterm-256/.exec(w("TERM"))!==null)return L;let r=w("TERM").toLowerCase();if(mt[r])return mt[r];if(Jr.some(e=>e.exec(r)!==null))return R}return w("COLORTERM")?R: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"}},Pe=["info","success","warn","error","debug"];function Qr(r,e){return Pe.indexOf(e)<=Pe.indexOf(r)}var Xr={info:D.fg.blue,success:D.fg.green,warn:D.fg.yellow,error:D.fg.red,debug:D.fg.magenta},Zr=(r,e,t)=>{let n=new Date().toISOString();return t?`${D.dim}${n}${D.reset} ${Xr[r]}${r.toUpperCase()}${D.reset} ${D.bright}[Better Auth]:${D.reset} ${e}`:`${n} ${r.toUpperCase()} [Better Auth]: ${e}`},en=r=>{let e=r?.disabled!==!0,t=r?.level??"error",s=r?.disableColors!==void 0?!r.disableColors:Yr()!==1,o=(c,f,l=[])=>{if(!e||!Qr(t,c))return;let u=Zr(c,f,s);if(!r||typeof r.log!="function"){c==="error"?console.error(u,...l):c==="warn"?console.warn(u,...l):console.log(u,...l);return}r.log(c==="success"?"info":c,f,...l)};return{...Object.fromEntries(Pe.map(c=>[c,(...[f,...l])=>o(c,f,l)])),get level(){return t}}},ns=en();a();a();var us={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 tn(r){try{return(new URL(r).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new F(`Invalid base URL: ${r}. Please provide a valid base URL.`)}}function ee(r,e="/api/auth"){if(tn(r))return r;let n=r.replace(/\/+$/,"");return!e||e==="/"?n:(e=e.startsWith("/")?e:`/${e}`,`${n}${e}`)}function gt(r,e,t,n){if(r)return ee(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 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=rn(t.url);if(!i)throw new F("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 rn(r){try{return new URL(r).origin}catch{return null}}a();a();a();var te=Symbol("clean");var C=[],M=0,de=4,nn=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){nn++;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};a();var sn=5,V=6,he=10,on=(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 yt=1e3,Se=(r,e)=>on(r,n=>{let s=e(n);s&&r.events[V].push(s)},sn,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[V]=[],r.off=()=>{o(),setTimeout(()=>{if(r.active&&!r.lc){r.active=!1;for(let i of r.events[V])i();r.events[V]=[]}},yt)},process.env.NODE_ENV!=="production"){let i=r[te];r[te]=()=>{for(let c of r.events[V])c();r.events[V]=[],r.active=!1,i()}}return()=>{r.listen=s,r.off=o}});a();var an=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(l){s.set({data:l.data,error:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await f?.onSuccess?.(l)},async onError(l){let{request:u}=l,d=typeof u.retry=="number"?u.retry:u.retry?.attempts,p=u.retryAttempt||0;d&&p<d||(s.set({error:l.error,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await f?.onError?.(l))},async onRequest(l){let u=s.get();s.set({isPending:u.data===null,data:u.data,error:null,isRefetching:!0,refetch:s.value.refetch}),await f?.onRequest?.(l)}}).catch(l=>{s.set({error:l,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(()=>{an||(i?o():Se(s,()=>{let f=setTimeout(()=>{i||(o(),i=!0)},0);return()=>{s.off(),c.off(),clearTimeout(f)}}))});return s};a();var ln={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*:/},cn=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,bt={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},un=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function fn(r){return r instanceof Date&&!isNaN(r.getTime())}function dn(r){let e=un.exec(r);if(!e)return null;let[,t,n,s,o,i,c,f,l,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(l){let g=(parseInt(u,10)*60+parseInt(d,10))*(l==="+"?-1:1);p.setUTCMinutes(p.getUTCMinutes()+g)}return fn(p)?p:null}function hn(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 bt)return bt[c];if(!cn.test(i)){if(t)throw new SyntaxError("[better-json] Invalid JSON");return r}if(Object.entries(ln).some(([l,u])=>{let d=u.test(i);return d&&n&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${l} 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=dn(d);if(p)return p}return s?s(u,d):d})}catch(l){if(t)throw l;return r}}function wt(r,e={strict:!0}){return hn(r,e)}var pn={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 mn(r){let e=re(!1);return{session:pe(e,"/get-session",r,{method:"GET"}),$sessionSignal:e}}var _t=(r,e)=>{let t="credentials"in Request.prototype,n=gt(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:l,...u}=r?.fetchOptions||{},d=pt({baseURL:n,...t?{credentials:"include"}:{},method:"GET",jsonParser(m){return m?wt(m,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[o,...u.plugins||[],...r?.disableDefaultFetchPlugins?[]:[pn],...s]}),{$sessionSignal:p,session:g}=mn(d),b=r?.plugins||[],v={},y={$sessionSignal:p,session:g},E={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},O=[{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 b)m.getAtoms&&Object.assign(y,m.getAtoms?.(d)),m.pathMethods&&Object.assign(E,m.pathMethods),m.atomListeners&&O.push(...m.atomListeners);let $={notify:m=>{y[m].set(!y[m].get())},listen:(m,B)=>{y[m].subscribe(B)},atoms:y};for(let m of b)m.getActions&&Object.assign(v,m.getActions?.(d,$,r));return{get baseURL(){return n},pluginsActions:v,pluginsAtoms:y,pluginPathMethods:E,atomListeners:O,$fetch:d,$store:$}};function gn(r){return typeof r=="object"&&r!==null&&"get"in r&&typeof r.get=="function"&&"lc"in r&&typeof r.lc=="number"}function yn(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 vt(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 l=[...i,f],u=r;for(let d of l)if(u&&typeof u=="object"&&d in u)u=u[d];else{u=void 0;break}return typeof u=="function"||gn(u)?u:o(l)},apply:async(c,f,l)=>{let u="/"+i.map(O=>O.replace(/[A-Z]/g,$=>`-${$.toLowerCase()}`)).join("/"),d=l[0]||{},p=l[1]||{},{query:g,fetchOptions:b,...v}=d,y={...p,...b},E=yn(u,t,d);return await e(u,{...y,body:E==="GET"?void 0:{...v,...y?.body||{}},query:g||y?.query,method:E,async onSuccess(O){if(await y?.onSuccess?.(O),!s)return;let $=s.filter(m=>m.matcher(u));if($.length)for(let m of $){let B=n[m.signal];if(!B)return;let _=B.get();setTimeout(()=>{B.set(!_)},10)}}})}})}return o()}a();function Et(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Te(r){let{pluginPathMethods:e,pluginsActions:t,pluginsAtoms:n,$fetch:s,atomListeners:o,$store:i}=_t(r),c={};for(let[u,d]of Object.entries(n))c[`use${Et(u)}`]=d;let f={...t,...c,$fetch:s,$store:i};return vt(f,s,e,n,o)}a();a();a();function bn(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 me(r){return{newRole(e){return bn(e)},statements:r}}var wn={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},Oe=me(wn),_n=Oe.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),vn=Oe.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),En=Oe.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});a();a();a();a();a();a();a();a();a();a();a();var Ae=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}}},St=new Ae;a();a();a();a();a();a();a();a();var On={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},Tt=me(On),An=Tt.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),xn=Tt.newRole({user:[],session:[]});a();a();var Ot=()=>({id:"username",$InferServerPlugin:{}});var At=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(r){return r==="/phone-number/update"||r==="/phone-number/verify"},signal:"$sessionSignal"}]});var xt=()=>({id:"better-auth-client",$InferServerPlugin:{}});var It="/auth",ge="nvwa_login_token",z="nvwa_current_jwt",ye="nvwa_user_profile",Ie=class{constructor(e,t,n){this.storage=n;let s=Te({baseURL:e,basePath:It,plugins:[Ot(),At(),xt()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:async()=>{let o=await this.storage.get(z);if(console.log("jwt",o),o)return o;let i=await this.storage.get(ge);return console.log("loginToken",i),i}}}});this.authClient=s}async currentUser(){return await this.storage.get(ye)}async getCurrentJwt(){return await this.storage.get(z)}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.handleLogin(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.handleLogin(n)}async signInWithPhoneNumber(e,t,n=!1){let s=await this.authClient.signIn.phoneNumber({phoneNumber:e,password:t,rememberMe:n});this.handleLogin(s)}async signInWithUsername(e,t){let n=await this.authClient.signIn.username({username:e,password:t});this.handleLogin(n)}async handleLogin(e){if(e.error)throw new Error(e.error.message);await this.storage.set(ge,e.data?.token),await this.storage.set(ye,e.data?.user);let{data:t,error:n}=await this.authClient.token();if(n)throw new Error(n.message);await this.storage.set(z,t.token)}async signOut(){await this.storage.remove(ge),await this.storage.remove(ye)}async updateUserPassword(e,t,n=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:n});this.handleLogin(s)}};a();var Ue=class{constructor(e){this.http=e}async invoke(e,t){return await(await this.http.fetch("/functions/"+e,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};a();a();a();var S=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()}},K=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}},ne=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 K(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(/^([^@]*)@(.+)$/),l="",u="",d=s;if(f){let v=f[1];d=f[2];let y=v.match(/^([^:]*):?(.*)$/);y&&(l=y[1]||"",u=y[2]||"")}let p=d.match(/^([^:]+):?(\d*)$/),g=p?p[1]:d,b=p&&p[2]?p[2]:"";return{protocol:n?`${n}:`:"",username:l,password:u,host:d,hostname:g,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()}};a();var se=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 S?t.headers:new S(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}};a();var oe=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=In(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 In(r){return r?new S(r):new S}a();var J=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]"}},ie=class{constructor(){this._signal=new J}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};a();function Un(r){r.URL=ne,r.URLSearchParams=K,r.Headers=S,r.Request=se,r.Response=oe,r.AbortController=ie,r.AbortSignal=J}var Ce=class{constructor(e,t,n){console.log("NvwaHttpClient constructor",e,t,n),this.storage=e,this.customFetch=t,this.handleUnauthorized=n}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let n=await this.storage.get(z),s=new S(t?.headers);n&&s.set("Authorization",`Bearer ${n}`);let o=await this.customFetch(e,{...t,headers:s});if(o.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return o}};a();var Ut="/storage",Ct=Ut+"/generateUploadUrl",Ne=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+Ct,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:n}=await t.json();if(!n)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(n,{method:"PUT",body:e,headers:new S({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:o}=await s.json();return{url:o.split("?")[0]}}};a();a();a();var Ze=Sr(pr(),1),{PostgrestClient:mr,PostgrestQueryBuilder:dl,PostgrestFilterBuilder:hl,PostgrestTransformBuilder:pl,PostgrestBuilder:ml,PostgrestError:gl}=Ze.default||Ze;var gr="/entities",Wn=(r,e)=>new mr(r+gr,{fetch:e.fetchWithAuth.bind(e)});a();var et=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let n=`${this.baseUrl}/skill/${e}/execute`,o=await(await this.http.fetchWithAuth(n,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(o.status!==200)throw new Error(o.message);return o.data}};0&&(module.exports={AUTH_BASE_PATH,AbortController,AbortSignal,CURRENT_JWT_KEY,ENTITIES_BASE_PATH,FILE_STORAGE_BASE_PATH,GENERATE_UPLOAD_URL_PATH,Headers,LOGIN_TOKEN_KEY,LOGIN_USER_PROFILE_KEY,NvwaAuthClient,NvwaEdgeFunctions,NvwaFileStorage,NvwaHttpClient,NvwaSkill,Request,Response,URL,URLSearchParams,createPostgrestClient,polyfill});
|
|
1
|
+
"use strict";var Er=Object.create;var ce=Object.defineProperty;var _r=Object.getOwnPropertyDescriptor;var Rr=Object.getOwnPropertyNames;var Or=Object.getPrototypeOf,Tr=Object.prototype.hasOwnProperty;var st=(r,e)=>()=>(r&&(e=r(r=0)),e);var B=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ot=(r,e)=>{for(var t in e)ce(r,t,{get:e[t],enumerable:!0})},it=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Rr(e))!Tr.call(r,s)&&s!==t&&ce(r,s,{get:()=>e[s],enumerable:!(n=_r(e,s))||n.enumerable});return r};var Pr=(r,e,t)=>(t=r!=null?Er(Or(r)):{},it(e||!r||!r.__esModule?ce(t,"default",{value:r,enumerable:!0}):t,r)),q=r=>it(ce({},"__esModule",{value:!0}),r);var a=st(()=>{"use strict"});var z={};ot(z,{__addDisposableResource:()=>sr,__assign:()=>we,__asyncDelegator:()=>Yt,__asyncGenerator:()=>Jt,__asyncValues:()=>Qt,__await:()=>Y,__awaiter:()=>Ft,__classPrivateFieldGet:()=>tr,__classPrivateFieldIn:()=>nr,__classPrivateFieldSet:()=>rr,__createBinding:()=>be,__decorate:()=>Dt,__disposeResources:()=>or,__esDecorate:()=>kt,__exportStar:()=>Gt,__extends:()=>Lt,__generator:()=>zt,__importDefault:()=>er,__importStar:()=>Zt,__makeTemplateObject:()=>Xt,__metadata:()=>qt,__param:()=>Mt,__propKey:()=>Ht,__read:()=>De,__rest:()=>$t,__rewriteRelativeImportExtension:()=>ir,__runInitializers:()=>jt,__setFunctionName:()=>Bt,__spread:()=>Vt,__spreadArray:()=>Kt,__spreadArrays:()=>Wt,__values:()=>ve,default:()=>$n});function Lt(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Le(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function $t(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 Dt(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 l=r.length-1;l>=0;l--)(i=r[l])&&(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 Mt(r,e){return function(t,n){e(t,n,r)}}function kt(r,e,t,n,s,o){function i(_){if(_!==void 0&&typeof _!="function")throw new TypeError("Function expected");return _}for(var l=n.kind,d=l==="getter"?"get":l==="setter"?"set":"value",c=!e&&r?n.static?r:r.prototype:null,u=e||(c?Object.getOwnPropertyDescriptor(c,n.name):{}),f,p=!1,g=t.length-1;g>=0;g--){var w={};for(var E in n)w[E]=E==="access"?{}:n[E];for(var E in n.access)w.access[E]=n.access[E];w.addInitializer=function(_){if(p)throw new TypeError("Cannot add initializers after decoration has completed");o.push(i(_||null))};var y=(0,t[g])(l==="accessor"?{get:u.get,set:u.set}:u[d],w);if(l==="accessor"){if(y===void 0)continue;if(y===null||typeof y!="object")throw new TypeError("Object expected");(f=i(y.get))&&(u.get=f),(f=i(y.set))&&(u.set=f),(f=i(y.init))&&s.unshift(f)}else(f=i(y))&&(l==="field"?s.unshift(f):u[d]=f)}c&&Object.defineProperty(c,n.name,u),p=!0}function jt(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 Ht(r){return typeof r=="symbol"?r:"".concat(r)}function Bt(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 qt(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function Ft(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 l(u){try{c(n.next(u))}catch(f){i(f)}}function d(u){try{c(n.throw(u))}catch(f){i(f)}}function c(u){u.done?o(u.value):s(u.value).then(l,d)}c((n=n.apply(r,e||[])).next())})}function zt(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=l(0),i.throw=l(1),i.return=l(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function l(c){return function(u){return d([c,u])}}function d(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(t=0)),t;)try{if(n=1,s&&(o=c[0]&2?s.return:c[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,c[1])).done)return o;switch(s=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,s=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){t.label=c[1];break}if(c[0]===6&&t.label<o[1]){t.label=o[1],o=c;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(c);break}o[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(r,t)}catch(u){c=[6,u],s=0}finally{n=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function Gt(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&be(e,r,t)}function ve(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(l){i={error:l}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o}function Vt(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(De(arguments[e]));return r}function Wt(){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,l=o.length;i<l;i++,s++)n[s]=o[i];return n}function Kt(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 Y(r){return this instanceof Y?(this.v=r,this):new Y(r)}function Jt(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),l("next"),l("throw"),l("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(g){return function(w){return Promise.resolve(w).then(g,f)}}function l(g,w){n[g]&&(s[g]=function(E){return new Promise(function(y,_){o.push([g,E,y,_])>1||d(g,E)})},w&&(s[g]=w(s[g])))}function d(g,w){try{c(n[g](w))}catch(E){p(o[0][3],E)}}function c(g){g.value instanceof Y?Promise.resolve(g.value.v).then(u,f):p(o[0][2],g)}function u(g){d("next",g)}function f(g){d("throw",g)}function p(g,w){g(w),o.shift(),o.length&&d(o[0][0],o[0][1])}}function Yt(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:Y(r[s](i)),done:!1}:o?o(i):i}:o}}function Qt(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 ve=="function"?ve(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(l,d){i=r[o](i),s(l,d,i.done,i.value)})}}function s(o,i,l,d){Promise.resolve(d).then(function(c){o({value:c,done:l})},i)}}function Xt(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=$e(r),n=0;n<t.length;n++)t[n]!=="default"&&be(e,r,t[n]);return Nn(e,r),e}function er(r){return r&&r.__esModule?r:{default:r}}function tr(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 rr(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 nr(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 sr(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 or(r){function e(o){r.error=r.hasError?new Ln(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 ir(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 Le,we,be,Nn,$e,Ln,$n,G=st(()=>{"use strict";a();Le=function(r,e){return Le=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])},Le(r,e)};we=function(){return we=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},we.apply(this,arguments)};be=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]});Nn=Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e},$e=function(r){return $e=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},$e(r)};Ln=typeof SuppressedError=="function"?SuppressedError:function(r,e,t){var n=new Error(t);return n.name="SuppressedError",n.error=r,n.suppressed=e,n};$n={__extends:Lt,__assign:we,__rest:$t,__decorate:Dt,__param:Mt,__esDecorate:kt,__runInitializers:jt,__propKey:Ht,__setFunctionName:Bt,__metadata:qt,__awaiter:Ft,__generator:zt,__createBinding:be,__exportStar:Gt,__values:ve,__read:De,__spread:Vt,__spreadArrays:Wt,__spreadArray:Kt,__await:Y,__asyncGenerator:Jt,__asyncDelegator:Yt,__asyncValues:Qt,__makeTemplateObject:Xt,__importStar:Zt,__importDefault:er,__classPrivateFieldGet:tr,__classPrivateFieldSet:rr,__classPrivateFieldIn:nr,__addDisposableResource:sr,__disposeResources:or,__rewriteRelativeImportExtension:ir}});var je=B(ke=>{"use strict";a();Object.defineProperty(ke,"__esModule",{value:!0});var Me=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};ke.default=Me});var qe=B(Be=>{"use strict";a();Object.defineProperty(Be,"__esModule",{value:!0});var Dn=(G(),q(z)),Mn=Dn.__importDefault(je()),He=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,l,d,c;let u=null,f=null,p=null,g=o.status,w=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"))?f=S:f=JSON.parse(S))}let y=(l=this.headers.get("Prefer"))===null||l===void 0?void 0:l.match(/count=(exact|planned|estimated)/),_=(d=o.headers.get("content-range"))===null||d===void 0?void 0:d.split("/");y&&_&&_.length>1&&(p=parseInt(_[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(f)&&(f.length>1?(u={code:"PGRST116",details:`Results contain ${f.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},f=null,p=null,g=406,w="Not Acceptable"):f.length===1?f=f[0]:f=null)}else{let y=await o.text();try{u=JSON.parse(y),Array.isArray(u)&&o.status===404&&(f=[],u=null,g=200,w="OK")}catch{o.status===404&&y===""?(g=204,w="No Content"):u={message:y}}if(u&&this.isMaybeSingle&&(!((c=u?.details)===null||c===void 0)&&c.includes("0 rows"))&&(u=null,g=200,w="OK"),u&&this.shouldThrowOnError)throw new Mn.default(u)}return{error:u,data:f,count:p,status:g,statusText:w}});return this.shouldThrowOnError||(s=s.catch(o=>{var i,l,d;return{error:{message:`${(i=o?.name)!==null&&i!==void 0?i:"FetchError"}: ${o?.message}`,details:`${(l=o?.stack)!==null&&l!==void 0?l:""}`,hint:"",code:`${(d=o?.code)!==null&&d!==void 0?d:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}returns(){return this}overrideTypes(){return this}};Be.default=He});var Ge=B(ze=>{"use strict";a();Object.defineProperty(ze,"__esModule",{value:!0});var kn=(G(),q(z)),jn=kn.__importDefault(qe()),Fe=class extends jn.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",l=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${l?`${l},`:""}${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 l;let d=[e?"analyze":null,t?"verbose":null,n?"settings":null,s?"buffers":null,o?"wal":null].filter(Boolean).join("|"),c=(l=this.headers.get("Accept"))!==null&&l!==void 0?l:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${c}"; options=${d};`),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}};ze.default=Fe});var Ee=B(We=>{"use strict";a();Object.defineProperty(We,"__esModule",{value:!0});var Hn=(G(),q(z)),Bn=Hn.__importDefault(Ge()),qn=new RegExp("[,()]"),Ve=class extends Bn.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"&&qn.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}};We.default=Ve});var Ye=B(Je=>{"use strict";a();Object.defineProperty(Je,"__esModule",{value:!0});var Fn=(G(),q(z)),ae=Fn.__importDefault(Ee()),Ke=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,l=(e??"*").split("").map(d=>/\s/.test(d)&&!i?"":(d==='"'&&(i=!i),d)).join("");return this.url.searchParams.set("select",l),s&&this.headers.append("Prefer",`count=${s}`),new ae.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((l,d)=>l.concat(Object.keys(d)),[]);if(i.length>0){let l=[...new Set(i)].map(d=>`"${d}"`);this.url.searchParams.set("columns",l.join(","))}}return new ae.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 l="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 d=e.reduce((c,u)=>c.concat(Object.keys(u)),[]);if(d.length>0){let c=[...new Set(d)].map(u=>`"${u}"`);this.url.searchParams.set("columns",c.join(","))}}return new ae.default({method:l,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 ae.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 ae.default({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};Je.default=Ke});var lr=B(Xe=>{"use strict";a();Object.defineProperty(Xe,"__esModule",{value:!0});var ar=(G(),q(z)),zn=ar.__importDefault(Ye()),Gn=ar.__importDefault(Ee()),Qe=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 zn.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 l,d=new URL(`${this.url}/rpc/${e}`),c;n||s?(l=n?"HEAD":"GET",Object.entries(t).filter(([f,p])=>p!==void 0).map(([f,p])=>[f,Array.isArray(p)?`{${p.join(",")}}`:`${p}`]).forEach(([f,p])=>{d.searchParams.append(f,p)})):(l="POST",c=t);let u=new Headers(this.headers);return o&&u.set("Prefer",`count=${o}`),new Gn.default({method:l,url:d,headers:u,schema:this.schemaName,body:c,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}};Xe.default=Qe});var mr=B(P=>{"use strict";a();Object.defineProperty(P,"__esModule",{value:!0});P.PostgrestError=P.PostgrestBuilder=P.PostgrestTransformBuilder=P.PostgrestFilterBuilder=P.PostgrestQueryBuilder=P.PostgrestClient=void 0;var Q=(G(),q(z)),cr=Q.__importDefault(lr());P.PostgrestClient=cr.default;var ur=Q.__importDefault(Ye());P.PostgrestQueryBuilder=ur.default;var dr=Q.__importDefault(Ee());P.PostgrestFilterBuilder=dr.default;var fr=Q.__importDefault(Ge());P.PostgrestTransformBuilder=fr.default;var hr=Q.__importDefault(qe());P.PostgrestBuilder=hr.default;var pr=Q.__importDefault(je());P.PostgrestError=pr.default;P.default={PostgrestClient:cr.default,PostgrestQueryBuilder:ur.default,PostgrestFilterBuilder:dr.default,PostgrestTransformBuilder:fr.default,PostgrestBuilder:hr.default,PostgrestError:pr.default}});var Kn={};ot(Kn,{AUTH_BASE_PATH:()=>Ct,AbortController:()=>ie,AbortSignal:()=>J,CURRENT_JWT_KEY:()=>W,ENTITIES_BASE_PATH:()=>yr,FILE_STORAGE_BASE_PATH:()=>Ut,GENERATE_UPLOAD_URL_PATH:()=>Nt,Headers:()=>T,LOGIN_TOKEN_KEY:()=>ge,LOGIN_USER_PROFILE_KEY:()=>ye,NvwaAuthClient:()=>Ie,NvwaEdgeFunctions:()=>Ce,NvwaFileStorage:()=>Ne,NvwaHttpClient:()=>Ue,NvwaSkill:()=>et,OverlayManager:()=>tt,Request:()=>se,Response:()=>oe,URL:()=>ne,URLSearchParams:()=>K,createPostgrestClient:()=>Vn,getSourceLocationFromDOM:()=>Wn,polyfill:()=>Un});module.exports=q(Kn);a();a();a();a();a();a();var Sr=Object.defineProperty,Ar=Object.defineProperties,xr=Object.getOwnPropertyDescriptors,at=Object.getOwnPropertySymbols,Ir=Object.prototype.hasOwnProperty,Cr=Object.prototype.propertyIsEnumerable,lt=(r,e,t)=>e in r?Sr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,C=(r,e)=>{for(var t in e||(e={}))Ir.call(e,t)&<(r,t,e[t]);if(at)for(var t of at(e))Cr.call(e,t)&<(r,t,e[t]);return r},N=(r,e)=>Ar(r,xr(e)),Ur=class extends Error{constructor(r,e,t){super(e||r.toString(),{cause:t}),this.status=r,this.statusText=e,this.error=t}},Nr=async(r,e)=>{var t,n,s,o,i,l;let d=e||{},c={onRequest:[e?.onRequest],onResponse:[e?.onResponse],onSuccess:[e?.onSuccess],onError:[e?.onError],onRetry:[e?.onRetry]};if(!e||!e?.plugins)return{url:r,options:d,hooks:c};for(let u of e?.plugins||[]){if(u.init){let f=await((t=u.init)==null?void 0:t.call(u,r.toString(),e));d=f.options||d,r=f.url}c.onRequest.push((n=u.hooks)==null?void 0:n.onRequest),c.onResponse.push((s=u.hooks)==null?void 0:s.onResponse),c.onSuccess.push((o=u.hooks)==null?void 0:o.onSuccess),c.onError.push((i=u.hooks)==null?void 0:i.onError),c.onRetry.push((l=u.hooks)==null?void 0:l.onRetry)}return{url:r,options:d,hooks:c}},ct=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}},Lr=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 $r(r){if(typeof r=="number")return new ct({type:"linear",attempts:r,delay:1e3});switch(r.type){case"linear":return new ct(r);case"exponential":return new Lr(r);default:throw new Error("Invalid retry strategy")}}var Dr=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},Mr=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function kr(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 Mr.test(n)?"json":t.has(n)||n.startsWith("text/")?"text":"blob"}function jr(r){try{return JSON.parse(r),!0}catch{return!1}}function ft(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 ut(r){try{return JSON.parse(r)}catch{return r}}function dt(r){return typeof r=="function"}function Hr(r){if(r?.customFetchImpl)return r.customFetchImpl;if(typeof globalThis<"u"&&dt(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&dt(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function Br(r){let e=new Headers(r?.headers),t=await Dr(r);for(let[n,s]of Object.entries(t||{}))e.set(n,s);if(!e.has("content-type")){let n=qr(r?.body);n&&e.set("content-type",n)}return e}function qr(r){return ft(r)?"application/json":null}function Fr(r){if(!r?.body)return null;let e=new Headers(r?.headers);if(ft(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 zr(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 pt.includes(n)?n.toUpperCase():e?.body?"POST":"GET"}return e?.body?"POST":"GET"}function Gr(r,e){let t;return!r?.signal&&r?.timeout&&(t=setTimeout(()=>e?.abort(),r?.timeout)),{abortTimeout:t,clearTimeout:()=>{t&&clearTimeout(t)}}}var Vr=class ht extends Error{constructor(e,t){super(t||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,ht.prototype)}};async function ue(r,e){let t=await r["~standard"].validate(e);if(t.issues)throw new Vr(t.issues);return t.value}var pt=["get","post","put","patch","delete"];var Wr=r=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(e,t){var n,s,o,i;let l=((s=(n=r.plugins)==null?void 0:n.find(d=>{var c;return(c=d.schema)!=null&&c.config?e.startsWith(d.schema.config.baseURL||"")||e.startsWith(d.schema.config.prefix||""):!1}))==null?void 0:s.schema)||r.schema;if(l){let d=e;(o=l.config)!=null&&o.prefix&&d.startsWith(l.config.prefix)&&(d=d.replace(l.config.prefix,""),l.config.baseURL&&(e=e.replace(l.config.prefix,l.config.baseURL))),(i=l.config)!=null&&i.baseURL&&d.startsWith(l.config.baseURL)&&(d=d.replace(l.config.baseURL,""));let c=l.schema[d];if(c){let u=N(C({},t),{method:c.method,output:c.output});return t?.disableValidation||(u=N(C({},u),{body:c.input?await ue(c.input,t?.body):t?.body,params:c.params?await ue(c.params,t?.params):t?.params,query:c.query?await ue(c.query,t?.query):t?.query})),{url:e,options:u}}}return{url:e,options:t}}}),mt=r=>{async function e(t,n){let s=N(C(C({},r),n),{plugins:[...r?.plugins||[],Wr(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 Kr(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 f=r.toString().split("@")[1].split("/")[0];pt.includes(f)&&(r=r.replace(`@${f}/`,"/"))}o.endsWith("/")||(o+="/");let[i,l]=r.replace(o,"").split("?"),d=new URLSearchParams(l);for(let[f,p]of Object.entries(s||{}))p!=null&&d.set(f,String(p));if(n)if(Array.isArray(n)){let f=i.split("/").filter(p=>p.startsWith(":"));for(let[p,g]of f.entries()){let w=n[p];i=i.replace(g,w)}}else for(let[f,p]of Object.entries(n))i=i.replace(`:${f}`,String(p));i=i.split("/").map(encodeURIComponent).join("/"),i.startsWith("/")&&(i=i.slice(1));let c=d.toString();return c=c.length>0?`?${c}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${i}${c}`,o):`${o}${i}${c}`}var Re=async(r,e)=>{var t,n,s,o,i,l,d,c;let{hooks:u,url:f,options:p}=await Nr(r,e),g=Hr(p),w=new AbortController,E=(t=p.signal)!=null?t:w.signal,y=Kr(f,p),_=Fr(p),S=await Br(p),D=zr(f,p),m=N(C({},p),{url:y,headers:S,body:_,method:D,signal:E});for(let I of u.onRequest)if(I){let O=await I(m);O instanceof Object&&(m=O)}("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:H}=Gr(p,w),b=await g(m.url,m);H();let rt={response:b,request:m};for(let I of u.onResponse)if(I){let O=await I(N(C({},rt),{response:(s=e?.hookOptions)!=null&&s.cloneResponse?b.clone():b}));O instanceof Response?b=O:O instanceof Object&&(b=O.response)}if(b.ok){if(!(m.method!=="HEAD"))return{data:"",error:null};let O=kr(b),M={data:"",response:b,request:m};if(O==="json"||O==="text"){let k=await b.text(),br=await((o=m.jsonParser)!=null?o:ut)(k);M.data=br}else M.data=await b[O]();m?.output&&m.output&&!m.disableValidation&&(M.data=await ue(m.output,M.data));for(let k of u.onSuccess)k&&await k(N(C({},M),{response:(i=e?.hookOptions)!=null&&i.cloneResponse?b.clone():b}));return e?.throw?M.data:{data:M.data,error:null}}let wr=(l=e?.jsonParser)!=null?l:ut,le=await b.text(),nt=jr(le),_e=nt?await wr(le):null,vr={response:b,responseText:le,request:m,error:N(C({},_e),{status:b.status,statusText:b.statusText})};for(let I of u.onError)I&&await I(N(C({},vr),{response:(d=e?.hookOptions)!=null&&d.cloneResponse?b.clone():b}));if(e?.retry){let I=$r(e.retry),O=(c=e.retryAttempt)!=null?c:0;if(await I.shouldAttemptRetry(O,b)){for(let k of u.onRetry)k&&await k(rt);let M=I.getDelay(O);return await new Promise(k=>setTimeout(k,M)),await Re(r,N(C({},e),{retryAttempt:O+1}))}}if(e?.throw)throw new Ur(b.status,b.statusText,nt?_e:le);return{data:null,error:N(C({},_e),{status:b.status,statusText:b.statusText})}};a();a();var de=Object.create(null),X=r=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(r?de:globalThis),x=new Proxy(de,{get(r,e){return X()[e]??de[e]},has(r,e){let t=X();return e in t||e in de},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 ns=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function v(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 ss=Object.freeze({get BETTER_AUTH_SECRET(){return v("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return v("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return v("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return v("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return v("NODE_ENV","development")},get PACKAGE_VERSION(){return v("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return v("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),Z=1,R=4,L=8,A=24,gt={eterm:R,cons25:R,console:R,cygwin:R,dtterm:R,gnome:R,hurd:R,jfbterm:R,konsole:R,kterm:R,mlterm:R,mosh:A,putty:R,st:R,"rxvt-unicode-24bit":A,terminator:A,"xterm-kitty":A},Jr=new Map(Object.entries({APPVEYOR:L,BUILDKITE:L,CIRCLECI:A,DRONE:L,GITEA_ACTIONS:A,GITHUB_ACTIONS:A,GITLAB_CI:L,TRAVIS:L})),Yr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Qr(){if(v("FORCE_COLOR")!==void 0)switch(v("FORCE_COLOR")){case"":case"1":case"true":return R;case"2":return L;case"3":return A;default:return Z}if(v("NODE_DISABLE_COLORS")!==void 0&&v("NODE_DISABLE_COLORS")!==""||v("NO_COLOR")!==void 0&&v("NO_COLOR")!==""||v("TERM")==="dumb")return Z;if(v("TMUX"))return A;if("TF_BUILD"in x&&"AGENT_NAME"in x)return R;if("CI"in x){for(let{0:r,1:e}of Jr)if(r in x)return e;return v("CI_NAME")==="codeship"?L:Z}if("TEAMCITY_VERSION"in x)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(v("TEAMCITY_VERSION"))!==null?R:Z;switch(v("TERM_PROGRAM")){case"iTerm.app":return!v("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(v("TERM_PROGRAM_VERSION"))!==null?L:A;case"HyperTerm":case"MacTerm":return A;case"Apple_Terminal":return L}if(v("COLORTERM")==="truecolor"||v("COLORTERM")==="24bit")return A;if(v("TERM")){if(/truecolor/.exec(v("TERM"))!==null)return A;if(/^xterm-256/.exec(v("TERM"))!==null)return L;let r=v("TERM").toLowerCase();if(gt[r])return gt[r];if(Yr.some(e=>e.exec(r)!==null))return R}return v("COLORTERM")?R:Z}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"}},Oe=["info","success","warn","error","debug"];function Xr(r,e){return Oe.indexOf(e)<=Oe.indexOf(r)}var Zr={info:$.fg.blue,success:$.fg.green,warn:$.fg.yellow,error:$.fg.red,debug:$.fg.magenta},en=(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}`},tn=r=>{let e=r?.disabled!==!0,t=r?.level??"error",s=r?.disableColors!==void 0?!r.disableColors:Qr()!==1,o=(l,d,c=[])=>{if(!e||!Xr(t,l))return;let u=en(l,d,s);if(!r||typeof r.log!="function"){l==="error"?console.error(u,...c):l==="warn"?console.warn(u,...c):console.log(u,...c);return}r.log(l==="success"?"info":l,d,...c)};return{...Object.fromEntries(Oe.map(l=>[l,(...[d,...c])=>o(l,d,c)])),get level(){return t}}},os=tn();a();a();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 rn(r){try{return(new URL(r).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new F(`Invalid base URL: ${r}. Please provide a valid base URL.`)}}function ee(r,e="/api/auth"){if(rn(r))return r;let n=r.replace(/\/+$/,"");return!e||e==="/"?n:(e=e.startsWith("/")?e:`/${e}`,`${n}${e}`)}function yt(r,e,t,n){if(r)return ee(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 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=nn(t.url);if(!i)throw new F("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 nn(r){try{return new URL(r).origin}catch{return null}}a();a();a();var te=Symbol("clean");var U=[],j=0,fe=4,sn=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=j+fe;o<U.length;)U[o]===n?U.splice(o,fe):o+=fe;let s=e.indexOf(n);~s&&(e.splice(s,1),--t.lc||t.off())}},notify(n,s){sn++;let o=!U.length;for(let i of e)U.push(i,t.value,n,s);if(o){for(j=0;j<U.length;j+=fe)U[j](U[j+1],U[j+2],U[j+3]);U.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};a();var on=5,V=6,he=10,an=(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 wt=1e3,Te=(r,e)=>an(r,n=>{let s=e(n);s&&r.events[V].push(s)},on,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[V]=[],r.off=()=>{o(),setTimeout(()=>{if(r.active&&!r.lc){r.active=!1;for(let i of r.events[V])i();r.events[V]=[]}},wt)},process.env.NODE_ENV!=="production"){let i=r[te];r[te]=()=>{for(let l of r.events[V])l();r.events[V]=[],r.active=!1,i()}}return()=>{r.listen=s,r.off=o}});a();var ln=typeof window>"u",pe=(r,e,t,n)=>{let s=re({data:null,error:null,isPending:!0,isRefetching:!1,refetch:l=>o(l)}),o=l=>{let d=typeof n=="function"?n({data:s.get().data,error:s.get().error,isPending:s.get().isPending}):n;t(e,{...d,query:{...d?.query,...l?.query},async onSuccess(c){s.set({data:c.data,error:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await d?.onSuccess?.(c)},async onError(c){let{request:u}=c,f=typeof u.retry=="number"?u.retry:u.retry?.attempts,p=u.retryAttempt||0;f&&p<f||(s.set({error:c.error,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await d?.onError?.(c))},async onRequest(c){let u=s.get();s.set({isPending:u.data===null,data:u.data,error:null,isRefetching:!0,refetch:s.value.refetch}),await d?.onRequest?.(c)}}).catch(c=>{s.set({error:c,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch})})};r=Array.isArray(r)?r:[r];let i=!1;for(let l of r)l.subscribe(()=>{ln||(i?o():Te(s,()=>{let d=setTimeout(()=>{i||(o(),i=!0)},0);return()=>{s.off(),l.off(),clearTimeout(d)}}))});return s};a();var cn={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*:/},un=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,vt={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},dn=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function fn(r){return r instanceof Date&&!isNaN(r.getTime())}function hn(r){let e=dn.exec(r);if(!e)return null;let[,t,n,s,o,i,l,d,c,u,f]=e,p=new Date(Date.UTC(parseInt(t,10),parseInt(n,10)-1,parseInt(s,10),parseInt(o,10),parseInt(i,10),parseInt(l,10),d?parseInt(d.padEnd(3,"0"),10):0));if(c){let g=(parseInt(u,10)*60+parseInt(f,10))*(c==="+"?-1:1);p.setUTCMinutes(p.getUTCMinutes()+g)}return fn(p)?p:null}function pn(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 l=i.toLowerCase();if(l.length<=9&&l in vt)return vt[l];if(!un.test(i)){if(t)throw new SyntaxError("[better-json] Invalid JSON");return r}if(Object.entries(cn).some(([c,u])=>{let f=u.test(i);return f&&n&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${c} pattern`),f})&&t)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(i,(u,f)=>{if(u==="__proto__"||u==="constructor"&&f&&typeof f=="object"&&"prototype"in f){n&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof f=="string"){let p=hn(f);if(p)return p}return s?s(u,f):f})}catch(c){if(t)throw c;return r}}function bt(r,e={strict:!0}){return pn(r,e)}var mn={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 gn(r){let e=re(!1);return{session:pe(e,"/get-session",r,{method:"GET"}),$sessionSignal:e}}var Et=(r,e)=>{let t="credentials"in Request.prototype,n=yt(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:l,onRequest:d,onResponse:c,...u}=r?.fetchOptions||{},f=mt({baseURL:n,...t?{credentials:"include"}:{},method:"GET",jsonParser(m){return m?bt(m,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[o,...u.plugins||[],...r?.disableDefaultFetchPlugins?[]:[mn],...s]}),{$sessionSignal:p,session:g}=gn(f),w=r?.plugins||[],E={},y={$sessionSignal:p,session:g},_={"/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 w)m.getAtoms&&Object.assign(y,m.getAtoms?.(f)),m.pathMethods&&Object.assign(_,m.pathMethods),m.atomListeners&&S.push(...m.atomListeners);let D={notify:m=>{y[m].set(!y[m].get())},listen:(m,H)=>{y[m].subscribe(H)},atoms:y};for(let m of w)m.getActions&&Object.assign(E,m.getActions?.(f,D,r));return{get baseURL(){return n},pluginsActions:E,pluginsAtoms:y,pluginPathMethods:_,atomListeners:S,$fetch:f,$store:D}};function yn(r){return typeof r=="object"&&r!==null&&"get"in r&&typeof r.get=="function"&&"lc"in r&&typeof r.lc=="number"}function wn(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 _t(r,e,t,n,s){function o(i=[]){return new Proxy(function(){},{get(l,d){if(typeof d!="string"||d==="then"||d==="catch"||d==="finally")return;let c=[...i,d],u=r;for(let f of c)if(u&&typeof u=="object"&&f in u)u=u[f];else{u=void 0;break}return typeof u=="function"||yn(u)?u:o(c)},apply:async(l,d,c)=>{let u="/"+i.map(S=>S.replace(/[A-Z]/g,D=>`-${D.toLowerCase()}`)).join("/"),f=c[0]||{},p=c[1]||{},{query:g,fetchOptions:w,...E}=f,y={...p,...w},_=wn(u,t,f);return await e(u,{...y,body:_==="GET"?void 0:{...E,...y?.body||{}},query:g||y?.query,method:_,async onSuccess(S){if(await y?.onSuccess?.(S),!s)return;let D=s.filter(m=>m.matcher(u));if(D.length)for(let m of D){let H=n[m.signal];if(!H)return;let b=H.get();setTimeout(()=>{H.set(!b)},10)}}})}})}return o()}a();function Rt(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}=Et(r),l={};for(let[u,f]of Object.entries(n))l[`use${Rt(u)}`]=f;let d={...t,...l,$fetch:s,$store:i};return _t(d,s,e,n,o)}a();a();a();function vn(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(l=>i.includes(l));else if(typeof o=="object"){let l=o;l.connector==="OR"?n=l.actions.some(d=>i.includes(d)):n=l.actions.every(d=>i.includes(d))}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 me(r){return{newRole(e){return vn(e)},statements:r}}var bn={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},Se=me(bn),En=Se.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),_n=Se.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),Rn=Se.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});a();a();a();a();a();a();a();a();a();a();a();var Ae=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}}},Pt=new Ae;a();a();a();a();a();a();a();a();var An={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},St=me(An),xn=St.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),In=St.newRole({user:[],session:[]});a();a();var At=()=>({id:"username",$InferServerPlugin:{}});var xt=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(r){return r==="/phone-number/update"||r==="/phone-number/verify"},signal:"$sessionSignal"}]});var It=()=>({id:"better-auth-client",$InferServerPlugin:{}});var Ct="/auth",ge="nvwa_login_token",W="nvwa_current_jwt",ye="nvwa_user_profile",Ie=class{constructor(e,t,n){this.storage=n;let s=Pe({baseURL:e,basePath:Ct,plugins:[At(),xt(),It()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:async()=>{let o=await this.storage.get(W);if(console.log("jwt",o),o)return o;let i=await this.storage.get(ge);return console.log("loginToken",i),i}}}});this.authClient=s}async currentUser(){return await this.storage.get(ye)}async getCurrentJwt(){return await this.storage.get(W)}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.handleLogin(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.handleLogin(n)}async signInWithPhoneNumber(e,t,n=!1){let s=await this.authClient.signIn.phoneNumber({phoneNumber:e,password:t,rememberMe:n});this.handleLogin(s)}async signInWithUsername(e,t){let n=await this.authClient.signIn.username({username:e,password:t});this.handleLogin(n)}async handleLogin(e){if(e.error)throw new Error(e.error.message);await this.storage.set(ge,e.data?.token),await this.storage.set(ye,e.data?.user);let{data:t,error:n}=await this.authClient.token();if(n)throw new Error(n.message);await this.storage.set(W,t.token)}async signOut(){await this.storage.remove(ge),await this.storage.remove(ye)}async updateUserPassword(e,t,n=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:n});this.handleLogin(s)}};a();var Ce=class{constructor(e){this.http=e}async invoke(e,t){return await(await this.http.fetch("/functions/"+e,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};a();a();a();var T=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()}},K=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}},ne=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 K(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]}`:"",l=t[9]?`#${t[9]}`:"";if(!n&&!s&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let d=s.match(/^([^@]*)@(.+)$/),c="",u="",f=s;if(d){let E=d[1];f=d[2];let y=E.match(/^([^:]*):?(.*)$/);y&&(c=y[1]||"",u=y[2]||"")}let p=f.match(/^([^:]+):?(\d*)$/),g=p?p[1]:f,w=p&&p[2]?p[2]:"";return{protocol:n?`${n}:`:"",username:c,password:u,host:f,hostname:g,port:w,pathname:o,search:i,hash:l}}toString(){let e=this.searchParams.toString(),t=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${t}${this.hash}`}toJSON(){return this.toString()}};a();var se=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 T?t.headers:new T(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}};a();var oe=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=Cn(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 Cn(r){return r?new T(r):new T}a();var J=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]"}},ie=class{constructor(){this._signal=new J}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};a();function Un(r){r.URL=ne,r.URLSearchParams=K,r.Headers=T,r.Request=se,r.Response=oe,r.AbortController=ie,r.AbortSignal=J}var Ue=class{constructor(e,t,n){console.log("NvwaHttpClient constructor",e,t,n),this.storage=e,this.customFetch=t,this.handleUnauthorized=n}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let n=await this.storage.get(W),s=new T(t?.headers);n&&s.set("Authorization",`Bearer ${n}`);let o=await this.customFetch(e,{...t,headers:s});if(o.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return o}};a();var Ut="/storage",Nt=Ut+"/generateUploadUrl",Ne=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+Nt,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:n}=await t.json();if(!n)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(n,{method:"PUT",body:e,headers:new T({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:o}=await s.json();return{url:o.split("?")[0]}}};a();a();a();var Ze=Pr(mr(),1),{PostgrestClient:gr,PostgrestQueryBuilder:pl,PostgrestFilterBuilder:ml,PostgrestTransformBuilder:gl,PostgrestBuilder:yl,PostgrestError:wl}=Ze.default||Ze;var yr="/entities",Vn=(r,e)=>new gr(r+yr,{fetch:e.fetchWithAuth.bind(e)});a();var et=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let n=`${this.baseUrl}/skill/${e}/execute`,o=await(await this.http.fetchWithAuth(n,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(o.status!==200)throw new Error(o.message);return o.data}};a();var tt=class{constructor(){this.hoverOverlay=null;this.selectedOverlay=null;this.tooltip=null;this.hoverElement=null;this.selectedElement=null;this.hoverUpdateHandler=null;this.selectedUpdateHandler=null;this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let e=document.createElement("style");e.id="__nvwa-inspector-overlay-style",e.textContent=`
|
|
2
|
+
.__nvwa-inspector-overlay {
|
|
3
|
+
position: absolute;
|
|
4
|
+
pointer-events: none;
|
|
5
|
+
z-index: 999998;
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
}
|
|
8
|
+
.__nvwa-inspector-overlay-hover {
|
|
9
|
+
border: 2px solid #3b82f6;
|
|
10
|
+
background-color: rgba(59, 130, 246, 0.1);
|
|
11
|
+
z-index: 999998;
|
|
12
|
+
}
|
|
13
|
+
.__nvwa-inspector-overlay-selected {
|
|
14
|
+
border: 3px solid #10b981;
|
|
15
|
+
background-color: rgba(16, 185, 129, 0.15);
|
|
16
|
+
z-index: 999997;
|
|
17
|
+
}
|
|
18
|
+
#__nvwa-inspector-tooltip {
|
|
19
|
+
position: fixed;
|
|
20
|
+
background: rgba(0, 0, 0, 0.9);
|
|
21
|
+
color: white;
|
|
22
|
+
padding: 6px 10px;
|
|
23
|
+
border-radius: 4px;
|
|
24
|
+
font-size: 12px;
|
|
25
|
+
font-family: monospace;
|
|
26
|
+
pointer-events: none;
|
|
27
|
+
z-index: 999999;
|
|
28
|
+
display: none;
|
|
29
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
|
|
30
|
+
max-width: 400px;
|
|
31
|
+
word-break: break-all;
|
|
32
|
+
}
|
|
33
|
+
`,document.head.appendChild(e)}createTooltip(){return this.tooltip?this.tooltip:(this.tooltip=document.createElement("div"),this.tooltip.id="__nvwa-inspector-tooltip",document.body.appendChild(this.tooltip),this.tooltip)}createOverlay(e){let t=document.createElement("div");return t.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${e}`,document.body.appendChild(t),t}updateOverlayPosition(e,t){if(!t.isConnected)return;let n=t.getBoundingClientRect(),s=window.scrollX||window.pageXOffset,o=window.scrollY||window.pageYOffset;n.width>0&&n.height>0?(e.style.left=`${n.left+s}px`,e.style.top=`${n.top+o}px`,e.style.width=`${n.width}px`,e.style.height=`${n.height}px`,e.style.display="block"):e.style.display="none"}removeOverlay(e){e&&e.parentNode&&e.parentNode.removeChild(e)}highlightElement(e,t){if(!e.isConnected)return;if(this.hoverElement===e&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,e);let l=this.createTooltip();t?l.textContent=t:l.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,l.style.display="block";let d=e.getBoundingClientRect();l.style.left=`${d.left+window.scrollX}px`,l.style.top=`${d.top+window.scrollY-l.offsetHeight-8}px`,d.top<l.offsetHeight+8&&(l.style.top=`${d.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let n=this.createOverlay("hover");this.updateOverlayPosition(n,e),this.hoverOverlay=n,this.hoverElement=e;let s=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s);let o=this.createTooltip();t?o.textContent=t:o.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let i=e.getBoundingClientRect();o.style.left=`${i.left+window.scrollX}px`,o.style.top=`${i.top+window.scrollY-o.offsetHeight-8}px`,i.top<o.offsetHeight+8&&(o.style.top=`${i.bottom+window.scrollY+8}px`)}selectElement(e,t){if(!e.isConnected)return;if(this.selectedElement===e&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,e);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let n=this.createOverlay("selected");this.updateOverlayPosition(n,e),this.selectedOverlay=n,this.selectedElement=e;let s=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let e=document.getElementById("__nvwa-inspector-overlay-style");e&&e.parentNode&&e.parentNode.removeChild(e)}};function Wn(r="root"){if(typeof document>"u")return null;let e=document.getElementById(r)||document.body;if(!e)return null;let t=e.querySelector("[data-source-location]");if(t){let n=t.getAttribute("data-source-location");if(n)return n}if(e.firstElementChild){let s=e.firstElementChild.getAttribute("data-source-location");if(s)return s}return null}0&&(module.exports={AUTH_BASE_PATH,AbortController,AbortSignal,CURRENT_JWT_KEY,ENTITIES_BASE_PATH,FILE_STORAGE_BASE_PATH,GENERATE_UPLOAD_URL_PATH,Headers,LOGIN_TOKEN_KEY,LOGIN_USER_PROFILE_KEY,NvwaAuthClient,NvwaEdgeFunctions,NvwaFileStorage,NvwaHttpClient,NvwaSkill,OverlayManager,Request,Response,URL,URLSearchParams,createPostgrestClient,getSourceLocationFromDOM,polyfill});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,33 @@
|
|
|
1
|
-
var gr=Object.create;var ie=Object.defineProperty;var yr=Object.getOwnPropertyDescriptor;var br=Object.getOwnPropertyNames;var wr=Object.getPrototypeOf,_r=Object.prototype.hasOwnProperty;var Ze=(r,e)=>()=>(r&&(e=r(r=0)),e);var q=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),vr=(r,e)=>{for(var t in e)ie(r,t,{get:e[t],enumerable:!0})},et=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of br(e))!_r.call(r,s)&&s!==t&&ie(r,s,{get:()=>e[s],enumerable:!(n=yr(e,s))||n.enumerable});return r};var Er=(r,e,t)=>(t=r!=null?gr(wr(r)):{},et(e||!r||!r.__esModule?ie(t,"default",{value:r,enumerable:!0}):t,r)),V=r=>et(ie({},"__esModule",{value:!0}),r);import Kn from"path";import{fileURLToPath as Yn}from"url";var a=Ze(()=>{"use strict"});var G={};vr(G,{__addDisposableResource:()=>Zt,__assign:()=>ye,__asyncDelegator:()=>Wt,__asyncGenerator:()=>Gt,__asyncValues:()=>Vt,__await:()=>K,__awaiter:()=>jt,__classPrivateFieldGet:()=>Yt,__classPrivateFieldIn:()=>Xt,__classPrivateFieldSet:()=>Qt,__createBinding:()=>we,__decorate:()=>Ct,__disposeResources:()=>er,__esDecorate:()=>Ut,__exportStar:()=>Bt,__extends:()=>xt,__generator:()=>Mt,__importDefault:()=>Jt,__importStar:()=>Kt,__makeTemplateObject:()=>zt,__metadata:()=>kt,__param:()=>Nt,__propKey:()=>Dt,__read:()=>Ue,__rest:()=>It,__rewriteRelativeImportExtension:()=>tr,__runInitializers:()=>Lt,__setFunctionName:()=>$t,__spread:()=>Ht,__spreadArray:()=>Ft,__spreadArrays:()=>qt,__values:()=>be,default:()=>Un});function xt(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Ce(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 Ct(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 Nt(r,e){return function(t,n){e(t,n,r)}}function Ut(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",l=!e&&r?n.static?r:r.prototype:null,u=e||(l?Object.getOwnPropertyDescriptor(l,n.name):{}),d,m=!1,y=t.length-1;y>=0;y--){var w={};for(var E in n)w[E]=E==="access"?{}:n[E];for(var E in n.access)w.access[E]=n.access[E];w.addInitializer=function(R){if(m)throw new TypeError("Cannot add initializers after decoration has completed");o.push(i(R||null))};var b=(0,t[y])(c==="accessor"?{get:u.get,set:u.set}:u[f],w);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)}l&&Object.defineProperty(l,n.name,u),m=!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 kt(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function jt(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{l(n.next(u))}catch(d){i(d)}}function f(u){try{l(n.throw(u))}catch(d){i(d)}}function l(u){u.done?o(u.value):s(u.value).then(c,f)}l((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(l){return function(u){return f([l,u])}}function f(l){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(t=0)),t;)try{if(n=1,s&&(o=l[0]&2?s.return:l[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,l[1])).done)return o;switch(s=0,o&&(l=[l[0]&2,o.value]),l[0]){case 0:case 1:o=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,s=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!o||l[1]>o[0]&&l[1]<o[3])){t.label=l[1];break}if(l[0]===6&&t.label<o[1]){t.label=o[1],o=l;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(l);break}o[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(r,t)}catch(u){l=[6,u],s=0}finally{n=o=0}if(l[0]&5)throw l[1];return{value:l[0]?l[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 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 Ht(){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 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(y){return function(w){return Promise.resolve(w).then(y,d)}}function c(y,w){n[y]&&(s[y]=function(E){return new Promise(function(b,R){o.push([y,E,b,R])>1||f(y,E)})},w&&(s[y]=w(s[y])))}function f(y,w){try{l(n[y](w))}catch(E){m(o[0][3],E)}}function l(y){y.value instanceof K?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,w){y(w),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(l){o({value:l,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=Ne(r),n=0;n<t.length;n++)t[n]!=="default"&&we(e,r,t[n]);return Cn(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 Nn(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 Ce,ye,we,Cn,Ne,Nn,Un,W=Ze(()=>{"use strict";a();Ce=function(r,e){return Ce=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])},Ce(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]});Cn=Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e},Ne=function(r){return Ne=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},Ne(r)};Nn=typeof SuppressedError=="function"?SuppressedError:function(r,e,t){var n=new Error(t);return n.name="SuppressedError",n.error=r,n.suppressed=e,n};Un={__extends:xt,__assign:ye,__rest:It,__decorate:Ct,__param:Nt,__esDecorate:Ut,__runInitializers:Lt,__propKey:Dt,__setFunctionName:$t,__metadata:kt,__awaiter:jt,__generator:Mt,__createBinding:we,__exportStar:Bt,__values:be,__read:Ue,__spread:Ht,__spreadArrays:qt,__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 $e=q(De=>{"use strict";a();Object.defineProperty(De,"__esModule",{value:!0});var Le=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};De.default=Le});var Me=q(je=>{"use strict";a();Object.defineProperty(je,"__esModule",{value:!0});var Ln=(W(),V(G)),Dn=Ln.__importDefault($e()),ke=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,l;let u=null,d=null,m=null,y=o.status,w=o.statusText;if(o.ok){if(this.method!=="HEAD"){let A=await o.text();A===""||(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=A:d=JSON.parse(A))}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&&(m=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,m=null,y=406,w="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,y=200,w="OK")}catch{o.status===404&&b===""?(y=204,w="No Content"):u={message:b}}if(u&&this.isMaybeSingle&&(!((l=u?.details)===null||l===void 0)&&l.includes("0 rows"))&&(u=null,y=200,w="OK"),u&&this.shouldThrowOnError)throw new Dn.default(u)}return{error:u,data:d,count:m,status:y,statusText:w}});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}};je.default=ke});var qe=q(He=>{"use strict";a();Object.defineProperty(He,"__esModule",{value:!0});var $n=(W(),V(G)),kn=$n.__importDefault(Me()),Be=class extends kn.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("|"),l=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${l}"; 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}};He.default=Be});var _e=q(Ge=>{"use strict";a();Object.defineProperty(Ge,"__esModule",{value:!0});var jn=(W(),V(G)),Mn=jn.__importDefault(qe()),Bn=new RegExp("[,()]"),Fe=class extends Mn.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"&&Bn.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}};Ge.default=Fe});var ze=q(Ve=>{"use strict";a();Object.defineProperty(Ve,"__esModule",{value:!0});var Hn=(W(),V(G)),se=Hn.__importDefault(_e()),We=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((l,u)=>l.concat(Object.keys(u)),[]);if(f.length>0){let l=[...new Set(f)].map(u=>`"${u}"`);this.url.searchParams.set("columns",l.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})}};Ve.default=We});var nr=q(Je=>{"use strict";a();Object.defineProperty(Je,"__esModule",{value:!0});var rr=(W(),V(G)),qn=rr.__importDefault(ze()),Fn=rr.__importDefault(_e()),Ke=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 qn.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}`),l;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",l=t);let u=new Headers(this.headers);return o&&u.set("Prefer",`count=${o}`),new Fn.default({method:c,url:f,headers:u,schema:this.schemaName,body:l,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}};Je.default=Ke});var ur=q(T=>{"use strict";a();Object.defineProperty(T,"__esModule",{value:!0});T.PostgrestError=T.PostgrestBuilder=T.PostgrestTransformBuilder=T.PostgrestFilterBuilder=T.PostgrestQueryBuilder=T.PostgrestClient=void 0;var J=(W(),V(G)),sr=J.__importDefault(nr());T.PostgrestClient=sr.default;var or=J.__importDefault(ze());T.PostgrestQueryBuilder=or.default;var ir=J.__importDefault(_e());T.PostgrestFilterBuilder=ir.default;var ar=J.__importDefault(qe());T.PostgrestTransformBuilder=ar.default;var lr=J.__importDefault(Me());T.PostgrestBuilder=lr.default;var cr=J.__importDefault($e());T.PostgrestError=cr.default;T.default={PostgrestClient:sr.default,PostgrestQueryBuilder:or.default,PostgrestFilterBuilder:ir.default,PostgrestTransformBuilder:ar.default,PostgrestBuilder:lr.default,PostgrestError:cr.default}});a();a();a();a();a();a();var Rr=Object.defineProperty,Pr=Object.defineProperties,Sr=Object.getOwnPropertyDescriptors,tt=Object.getOwnPropertySymbols,Tr=Object.prototype.hasOwnProperty,Or=Object.prototype.propertyIsEnumerable,rt=(r,e,t)=>e in r?Rr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,N=(r,e)=>{for(var t in e||(e={}))Tr.call(e,t)&&rt(r,t,e[t]);if(tt)for(var t of tt(e))Or.call(e,t)&&rt(r,t,e[t]);return r},L=(r,e)=>Pr(r,Sr(e)),Ar=class extends Error{constructor(r,e,t){super(e||r.toString(),{cause:t}),this.status=r,this.statusText=e,this.error=t}},xr=async(r,e)=>{var t,n,s,o,i,c;let f=e||{},l={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:l};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}l.onRequest.push((n=u.hooks)==null?void 0:n.onRequest),l.onResponse.push((s=u.hooks)==null?void 0:s.onResponse),l.onSuccess.push((o=u.hooks)==null?void 0:o.onSuccess),l.onError.push((i=u.hooks)==null?void 0:i.onError),l.onRetry.push((c=u.hooks)==null?void 0:c.onRetry)}return{url:r,options:f,hooks:l}},nt=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}},Ir=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 nt({type:"linear",attempts:r,delay:1e3});switch(r.type){case"linear":return new nt(r);case"exponential":return new Ir(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},Ur=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Lr(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 Ur.test(n)?"json":t.has(n)||n.startsWith("text/")?"text":"blob"}function Dr(r){try{return JSON.parse(r),!0}catch{return!1}}function it(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 ot(r){return typeof r=="function"}function $r(r){if(r?.customFetchImpl)return r.customFetchImpl;if(typeof globalThis<"u"&&ot(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&ot(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=jr(r?.body);n&&e.set("content-type",n)}return e}function jr(r){return it(r)?"application/json":null}function Mr(r){if(!r?.body)return null;let e=new Headers(r?.headers);if(it(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 Br(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 lt.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 qr=class at extends Error{constructor(e,t){super(t||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,at.prototype)}};async function ae(r,e){let t=await r["~standard"].validate(e);if(t.issues)throw new qr(t.issues);return t.value}var lt=["get","post","put","patch","delete"];var Fr=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 l;return(l=f.schema)!=null&&l.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 l=c.schema[f];if(l){let u=L(N({},t),{method:l.method,output:l.output});return t?.disableValidation||(u=L(N({},u),{body:l.input?await ae(l.input,t?.body):t?.body,params:l.params?await ae(l.params,t?.params):t?.params,query:l.query?await ae(l.query,t?.query):t?.query})),{url:e,options:u}}}return{url:e,options:t}}}),ct=r=>{async function e(t,n){let s=L(N(N({},r),n),{plugins:[...r?.plugins||[],Fr(r||{})]});if(r?.catchAllError)try{return await Ee(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 Ee(t,s)}return e};function Gr(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];lt.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 w=n[m];i=i.replace(y,w)}}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 l=f.toString();return l=l.length>0?`?${l}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${i}${l}`,o):`${o}${i}${l}`}var Ee=async(r,e)=>{var t,n,s,o,i,c,f,l;let{hooks:u,url:d,options:m}=await xr(r,e),y=$r(m),w=new AbortController,E=(t=m.signal)!=null?t:w.signal,b=Gr(d,m),R=Mr(m),A=await kr(m),k=Br(d,m),g=L(N({},m),{url:b,headers:A,body:R,method:k,signal:E});for(let C of u.onRequest)if(C){let S=await C(g);S instanceof Object&&(g=S)}("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:H}=Hr(m,w),v=await y(g.url,g);H();let Qe={response:v,request:g};for(let C of u.onResponse)if(C){let S=await C(L(N({},Qe),{response:(s=e?.hookOptions)!=null&&s.cloneResponse?v.clone():v}));S instanceof Response?v=S:S instanceof Object&&(v=S.response)}if(v.ok){if(!(g.method!=="HEAD"))return{data:"",error:null};let S=Lr(v),j={data:"",response:v,request:g};if(S==="json"||S==="text"){let M=await v.text(),mr=await((o=g.jsonParser)!=null?o:st)(M);j.data=mr}else j.data=await v[S]();g?.output&&g.output&&!g.disableValidation&&(j.data=await ae(g.output,j.data));for(let M of u.onSuccess)M&&await M(L(N({},j),{response:(i=e?.hookOptions)!=null&&i.cloneResponse?v.clone():v}));return e?.throw?j.data:{data:j.data,error:null}}let hr=(c=e?.jsonParser)!=null?c:st,oe=await v.text(),Xe=Dr(oe),ve=Xe?await hr(oe):null,pr={response:v,responseText:oe,request:g,error:L(N({},ve),{status:v.status,statusText:v.statusText})};for(let C of u.onError)C&&await C(L(N({},pr),{response:(f=e?.hookOptions)!=null&&f.cloneResponse?v.clone():v}));if(e?.retry){let C=Cr(e.retry),S=(l=e.retryAttempt)!=null?l:0;if(await C.shouldAttemptRetry(S,v)){for(let M of u.onRetry)M&&await M(Qe);let j=C.getDelay(S);return await new Promise(M=>setTimeout(M,j)),await Ee(r,L(N({},e),{retryAttempt:S+1}))}}if(e?.throw)throw new Ar(v.status,v.statusText,Xe?ve:oe);return{data:null,error:L(N({},ve),{status:v.status,statusText:v.statusText})}};a();a();var le=Object.create(null),Y=r=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(r?le:globalThis),I=new Proxy(le,{get(r,e){return Y()[e]??le[e]},has(r,e){let t=Y();return e in t||e in le},set(r,e,t){let n=Y(!0);return n[e]=t,!0},deleteProperty(r,e){if(!e)return!1;let t=Y(!0);return delete t[e],!0},ownKeys(){let r=Y(!0);return Object.keys(r)}});var ns=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 ss=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")}}),Q=1,P=4,D=8,x=24,ut={eterm:P,cons25:P,console:P,cygwin:P,dtterm:P,gnome:P,hurd:P,jfbterm:P,konsole:P,kterm:P,mlterm:P,mosh:x,putty:P,st:P,"rxvt-unicode-24bit":x,terminator:x,"xterm-kitty":x},Wr=new Map(Object.entries({APPVEYOR:D,BUILDKITE:D,CIRCLECI:x,DRONE:D,GITEA_ACTIONS:x,GITHUB_ACTIONS:x,GITLAB_CI:D,TRAVIS:D})),Vr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function zr(){if(_("FORCE_COLOR")!==void 0)switch(_("FORCE_COLOR")){case"":case"1":case"true":return P;case"2":return D;case"3":return x;default:return Q}if(_("NODE_DISABLE_COLORS")!==void 0&&_("NODE_DISABLE_COLORS")!==""||_("NO_COLOR")!==void 0&&_("NO_COLOR")!==""||_("TERM")==="dumb")return Q;if(_("TMUX"))return x;if("TF_BUILD"in I&&"AGENT_NAME"in I)return P;if("CI"in I){for(let{0:r,1:e}of Wr)if(r in I)return e;return _("CI_NAME")==="codeship"?D:Q}if("TEAMCITY_VERSION"in I)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(_("TEAMCITY_VERSION"))!==null?P:Q;switch(_("TERM_PROGRAM")){case"iTerm.app":return!_("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(_("TERM_PROGRAM_VERSION"))!==null?D:x;case"HyperTerm":case"MacTerm":return x;case"Apple_Terminal":return D}if(_("COLORTERM")==="truecolor"||_("COLORTERM")==="24bit")return x;if(_("TERM")){if(/truecolor/.exec(_("TERM"))!==null)return x;if(/^xterm-256/.exec(_("TERM"))!==null)return D;let r=_("TERM").toLowerCase();if(ut[r])return ut[r];if(Vr.some(e=>e.exec(r)!==null))return P}return _("COLORTERM")?P:Q}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"}},Re=["info","success","warn","error","debug"];function Kr(r,e){return Re.indexOf(e)<=Re.indexOf(r)}var Jr={info:$.fg.blue,success:$.fg.green,warn:$.fg.yellow,error:$.fg.red,debug:$.fg.magenta},Yr=(r,e,t)=>{let n=new Date().toISOString();return t?`${$.dim}${n}${$.reset} ${Jr[r]}${r.toUpperCase()}${$.reset} ${$.bright}[Better Auth]:${$.reset} ${e}`:`${n} ${r.toUpperCase()} [Better Auth]: ${e}`},Qr=r=>{let e=r?.disabled!==!0,t=r?.level??"error",s=r?.disableColors!==void 0?!r.disableColors:zr()!==1,o=(c,f,l=[])=>{if(!e||!Kr(t,c))return;let u=Yr(c,f,s);if(!r||typeof r.log!="function"){c==="error"?console.error(u,...l):c==="warn"?console.warn(u,...l):console.log(u,...l);return}r.log(c==="success"?"info":c,f,...l)};return{...Object.fromEntries(Re.map(c=>[c,(...[f,...l])=>o(c,f,l)])),get level(){return t}}},os=Qr();a();a();var ds={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 Xr(r){try{return(new URL(r).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new F(`Invalid base URL: ${r}. Please provide a valid base URL.`)}}function X(r,e="/api/auth"){if(Xr(r))return r;let n=r.replace(/\/+$/,"");return!e||e==="/"?n:(e=e.startsWith("/")?e:`/${e}`,`${n}${e}`)}function ft(r,e,t,n){if(r)return X(r,e);if(n!==!1){let i=I.BETTER_AUTH_URL||I.NEXT_PUBLIC_BETTER_AUTH_URL||I.PUBLIC_BETTER_AUTH_URL||I.NUXT_PUBLIC_BETTER_AUTH_URL||I.NUXT_PUBLIC_AUTH_URL||(I.BASE_URL!=="/"?I.BASE_URL:void 0);if(i)return X(i,e)}let s=t?.headers.get("x-forwarded-host"),o=t?.headers.get("x-forwarded-proto");if(s&&o)return X(`${o}://${s}`,e);if(t){let i=Zr(t.url);if(!i)throw new F("Could not get origin from request. Please provide a valid base URL.");return X(i,e)}if(typeof window<"u"&&window.location)return X(window.location.origin,e)}function Zr(r){try{return new URL(r).origin}catch{return null}}a();a();a();var Z=Symbol("clean");var U=[],B=0,ce=4,en=0,ee=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<U.length;)U[o]===n?U.splice(o,ce):o+=ce;let s=e.indexOf(n);~s&&(e.splice(s,1),--t.lc||t.off())}},notify(n,s){en++;let o=!U.length;for(let i of e)U.push(i,t.value,n,s);if(o){for(B=0;B<U.length;B+=ce)U[B](U[B+1],U[B+2],U[B+3]);U.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[Z]=()=>{e=[],t.lc=0,t.off()}),t};a();var tn=5,z=6,ue=10,rn=(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 dt=1e3,Pe=(r,e)=>rn(r,n=>{let s=e(n);s&&r.events[z].push(s)},tn,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]=[]}},dt)},process.env.NODE_ENV!=="production"){let i=r[Z];r[Z]=()=>{for(let c of r.events[z])c();r.events[z]=[],r.active=!1,i()}}return()=>{r.listen=s,r.off=o}});a();var nn=typeof window>"u",fe=(r,e,t,n)=>{let s=ee({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(l){s.set({data:l.data,error:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await f?.onSuccess?.(l)},async onError(l){let{request:u}=l,d=typeof u.retry=="number"?u.retry:u.retry?.attempts,m=u.retryAttempt||0;d&&m<d||(s.set({error:l.error,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await f?.onError?.(l))},async onRequest(l){let u=s.get();s.set({isPending:u.data===null,data:u.data,error:null,isRefetching:!0,refetch:s.value.refetch}),await f?.onRequest?.(l)}}).catch(l=>{s.set({error:l,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(()=>{nn||(i?o():Pe(s,()=>{let f=setTimeout(()=>{i||(o(),i=!0)},0);return()=>{s.off(),c.off(),clearTimeout(f)}}))});return s};a();var sn={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*:/},on=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,ht={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},an=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function ln(r){return r instanceof Date&&!isNaN(r.getTime())}function cn(r){let e=an.exec(r);if(!e)return null;let[,t,n,s,o,i,c,f,l,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(l){let y=(parseInt(u,10)*60+parseInt(d,10))*(l==="+"?-1:1);m.setUTCMinutes(m.getUTCMinutes()+y)}return ln(m)?m:null}function un(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 ht)return ht[c];if(!on.test(i)){if(t)throw new SyntaxError("[better-json] Invalid JSON");return r}if(Object.entries(sn).some(([l,u])=>{let d=u.test(i);return d&&n&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${l} 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=cn(d);if(m)return m}return s?s(u,d):d})}catch(l){if(t)throw l;return r}}function pt(r,e={strict:!0}){return un(r,e)}var fn={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 dn(r){let e=ee(!1);return{session:fe(e,"/get-session",r,{method:"GET"}),$sessionSignal:e}}var mt=(r,e)=>{let t="credentials"in Request.prototype,n=ft(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:l,...u}=r?.fetchOptions||{},d=ct({baseURL:n,...t?{credentials:"include"}:{},method:"GET",jsonParser(g){return g?pt(g,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[o,...u.plugins||[],...r?.disableDefaultFetchPlugins?[]:[fn],...s]}),{$sessionSignal:m,session:y}=dn(d),w=r?.plugins||[],E={},b={$sessionSignal:m,session:y},R={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},A=[{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 w)g.getAtoms&&Object.assign(b,g.getAtoms?.(d)),g.pathMethods&&Object.assign(R,g.pathMethods),g.atomListeners&&A.push(...g.atomListeners);let k={notify:g=>{b[g].set(!b[g].get())},listen:(g,H)=>{b[g].subscribe(H)},atoms:b};for(let g of w)g.getActions&&Object.assign(E,g.getActions?.(d,k,r));return{get baseURL(){return n},pluginsActions:E,pluginsAtoms:b,pluginPathMethods:R,atomListeners:A,$fetch:d,$store:k}};function hn(r){return typeof r=="object"&&r!==null&&"get"in r&&typeof r.get=="function"&&"lc"in r&&typeof r.lc=="number"}function pn(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 gt(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 l=[...i,f],u=r;for(let d of l)if(u&&typeof u=="object"&&d in u)u=u[d];else{u=void 0;break}return typeof u=="function"||hn(u)?u:o(l)},apply:async(c,f,l)=>{let u="/"+i.map(A=>A.replace(/[A-Z]/g,k=>`-${k.toLowerCase()}`)).join("/"),d=l[0]||{},m=l[1]||{},{query:y,fetchOptions:w,...E}=d,b={...m,...w},R=pn(u,t,d);return await e(u,{...b,body:R==="GET"?void 0:{...E,...b?.body||{}},query:y||b?.query,method:R,async onSuccess(A){if(await b?.onSuccess?.(A),!s)return;let k=s.filter(g=>g.matcher(u));if(k.length)for(let g of k){let H=n[g.signal];if(!H)return;let v=H.get();setTimeout(()=>{H.set(!v)},10)}}})}})}return o()}a();function yt(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}=mt(r),c={};for(let[u,d]of Object.entries(n))c[`use${yt(u)}`]=d;let f={...t,...c,$fetch:s,$store:i};return gt(f,s,e,n,o)}a();a();a();function mn(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 mn(e)},statements:r}}var gn={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},Te=de(gn),yn=Te.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),bn=Te.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),wn=Te.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});a();a();a();a();a();a();a();a();a();a();a();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}}},_t=new Oe;a();a();a();a();a();a();a();a();var Pn={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},vt=de(Pn),Sn=vt.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),Tn=vt.newRole({user:[],session:[]});a();a();var Et=()=>({id:"username",$InferServerPlugin:{}});var Rt=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(r){return r==="/phone-number/update"||r==="/phone-number/verify"},signal:"$sessionSignal"}]});var Pt=()=>({id:"better-auth-client",$InferServerPlugin:{}});var On="/auth",xe="nvwa_login_token",te="nvwa_current_jwt",Ie="nvwa_user_profile",St=class{constructor(e,t,n){this.storage=n;let s=Se({baseURL:e,basePath:On,plugins:[Et(),Rt(),Pt()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:async()=>{let o=await this.storage.get(te);if(console.log("jwt",o),o)return o;let i=await this.storage.get(xe);return console.log("loginToken",i),i}}}});this.authClient=s}async currentUser(){return await this.storage.get(Ie)}async getCurrentJwt(){return await this.storage.get(te)}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.handleLogin(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.handleLogin(n)}async signInWithPhoneNumber(e,t,n=!1){let s=await this.authClient.signIn.phoneNumber({phoneNumber:e,password:t,rememberMe:n});this.handleLogin(s)}async signInWithUsername(e,t){let n=await this.authClient.signIn.username({username:e,password:t});this.handleLogin(n)}async handleLogin(e){if(e.error)throw new Error(e.error.message);await this.storage.set(xe,e.data?.token),await this.storage.set(Ie,e.data?.user);let{data:t,error:n}=await this.authClient.token();if(n)throw new Error(n.message);await this.storage.set(te,t.token)}async signOut(){await this.storage.remove(xe),await this.storage.remove(Ie)}async updateUserPassword(e,t,n=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:n});this.handleLogin(s)}};a();var Tt=class{constructor(e){this.http=e}async invoke(e,t){return await(await this.http.fetch("/functions/"+e,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};a();a();a();var O=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()}},re=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}},he=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 re(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(/^([^@]*)@(.+)$/),l="",u="",d=s;if(f){let E=f[1];d=f[2];let b=E.match(/^([^:]*):?(.*)$/);b&&(l=b[1]||"",u=b[2]||"")}let m=d.match(/^([^:]+):?(\d*)$/),y=m?m[1]:d,w=m&&m[2]?m[2]:"";return{protocol:n?`${n}:`:"",username:l,password:u,host:d,hostname:y,port:w,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()}};a();var pe=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 O?t.headers:new O(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}};a();var me=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=An(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 An(r){return r?new O(r):new O}a();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]"}},ge=class{constructor(){this._signal=new ne}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};a();function Ia(r){r.URL=he,r.URLSearchParams=re,r.Headers=O,r.Request=pe,r.Response=me,r.AbortController=ge,r.AbortSignal=ne}var Ot=class{constructor(e,t,n){console.log("NvwaHttpClient constructor",e,t,n),this.storage=e,this.customFetch=t,this.handleUnauthorized=n}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let n=await this.storage.get(te),s=new O(t?.headers);n&&s.set("Authorization",`Bearer ${n}`);let o=await this.customFetch(e,{...t,headers:s});if(o.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return o}};a();var xn="/storage",In=xn+"/generateUploadUrl",At=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+In,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:n}=await t.json();if(!n)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(n,{method:"PUT",body:e,headers:new O({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:o}=await s.json();return{url:o.split("?")[0]}}};a();a();a();var Ye=Er(ur(),1),{PostgrestClient:fr,PostgrestQueryBuilder:ml,PostgrestFilterBuilder:gl,PostgrestTransformBuilder:yl,PostgrestBuilder:bl,PostgrestError:wl}=Ye.default||Ye;var Gn="/entities",Rl=(r,e)=>new fr(r+Gn,{fetch:e.fetchWithAuth.bind(e)});a();var dr=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let n=`${this.baseUrl}/skill/${e}/execute`,o=await(await this.http.fetchWithAuth(n,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(o.status!==200)throw new Error(o.message);return o.data}};export{On as AUTH_BASE_PATH,ge as AbortController,ne as AbortSignal,te as CURRENT_JWT_KEY,Gn as ENTITIES_BASE_PATH,xn as FILE_STORAGE_BASE_PATH,In as GENERATE_UPLOAD_URL_PATH,O as Headers,xe as LOGIN_TOKEN_KEY,Ie as LOGIN_USER_PROFILE_KEY,St as NvwaAuthClient,Tt as NvwaEdgeFunctions,At as NvwaFileStorage,Ot as NvwaHttpClient,dr as NvwaSkill,pe as Request,me as Response,he as URL,re as URLSearchParams,Rl as createPostgrestClient,Ia as polyfill};
|
|
1
|
+
var yr=Object.create;var ie=Object.defineProperty;var wr=Object.getOwnPropertyDescriptor;var vr=Object.getOwnPropertyNames;var br=Object.getPrototypeOf,Er=Object.prototype.hasOwnProperty;var Ze=(r,e)=>()=>(r&&(e=r(r=0)),e);var q=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),_r=(r,e)=>{for(var t in e)ie(r,t,{get:e[t],enumerable:!0})},et=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of vr(e))!Er.call(r,s)&&s!==t&&ie(r,s,{get:()=>e[s],enumerable:!(n=wr(e,s))||n.enumerable});return r};var Rr=(r,e,t)=>(t=r!=null?yr(br(r)):{},et(e||!r||!r.__esModule?ie(t,"default",{value:r,enumerable:!0}):t,r)),V=r=>et(ie({},"__esModule",{value:!0}),r);import Jn from"path";import{fileURLToPath as Qn}from"url";var a=Ze(()=>{"use strict"});var z={};_r(z,{__addDisposableResource:()=>Zt,__assign:()=>ye,__asyncDelegator:()=>Gt,__asyncGenerator:()=>zt,__asyncValues:()=>Vt,__await:()=>K,__awaiter:()=>Mt,__classPrivateFieldGet:()=>Yt,__classPrivateFieldIn:()=>Xt,__classPrivateFieldSet:()=>Qt,__createBinding:()=>ve,__decorate:()=>Ct,__disposeResources:()=>er,__esDecorate:()=>Ut,__exportStar:()=>Ht,__extends:()=>xt,__generator:()=>jt,__importDefault:()=>Jt,__importStar:()=>Kt,__makeTemplateObject:()=>Wt,__metadata:()=>kt,__param:()=>Nt,__propKey:()=>Dt,__read:()=>Ue,__rest:()=>It,__rewriteRelativeImportExtension:()=>tr,__runInitializers:()=>Lt,__setFunctionName:()=>$t,__spread:()=>Bt,__spreadArray:()=>Ft,__spreadArrays:()=>qt,__values:()=>we,default:()=>Ln});function xt(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Ce(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 Ct(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 l=r.length-1;l>=0;l--)(i=r[l])&&(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 Nt(r,e){return function(t,n){e(t,n,r)}}function Ut(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 l=n.kind,d=l==="getter"?"get":l==="setter"?"set":"value",c=!e&&r?n.static?r:r.prototype:null,u=e||(c?Object.getOwnPropertyDescriptor(c,n.name):{}),f,m=!1,y=t.length-1;y>=0;y--){var v={};for(var _ in n)v[_]=_==="access"?{}:n[_];for(var _ in n.access)v.access[_]=n.access[_];v.addInitializer=function(R){if(m)throw new TypeError("Cannot add initializers after decoration has completed");o.push(i(R||null))};var w=(0,t[y])(l==="accessor"?{get:u.get,set:u.set}:u[d],v);if(l==="accessor"){if(w===void 0)continue;if(w===null||typeof w!="object")throw new TypeError("Object expected");(f=i(w.get))&&(u.get=f),(f=i(w.set))&&(u.set=f),(f=i(w.init))&&s.unshift(f)}else(f=i(w))&&(l==="field"?s.unshift(f):u[d]=f)}c&&Object.defineProperty(c,n.name,u),m=!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 kt(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function Mt(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 l(u){try{c(n.next(u))}catch(f){i(f)}}function d(u){try{c(n.throw(u))}catch(f){i(f)}}function c(u){u.done?o(u.value):s(u.value).then(l,d)}c((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=l(0),i.throw=l(1),i.return=l(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function l(c){return function(u){return d([c,u])}}function d(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(t=0)),t;)try{if(n=1,s&&(o=c[0]&2?s.return:c[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,c[1])).done)return o;switch(s=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,s=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){t.label=c[1];break}if(c[0]===6&&t.label<o[1]){t.label=o[1],o=c;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(c);break}o[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(r,t)}catch(u){c=[6,u],s=0}finally{n=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function Ht(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&ve(e,r,t)}function we(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(l){i={error:l}}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,l=o.length;i<l;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 zt(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),l("next"),l("throw"),l("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(y){return function(v){return Promise.resolve(v).then(y,f)}}function l(y,v){n[y]&&(s[y]=function(_){return new Promise(function(w,R){o.push([y,_,w,R])>1||d(y,_)})},v&&(s[y]=v(s[y])))}function d(y,v){try{c(n[y](v))}catch(_){m(o[0][3],_)}}function c(y){y.value instanceof K?Promise.resolve(y.value.v).then(u,f):m(o[0][2],y)}function u(y){d("next",y)}function f(y){d("throw",y)}function m(y,v){y(v),o.shift(),o.length&&d(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: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 we=="function"?we(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(l,d){i=r[o](i),s(l,d,i.done,i.value)})}}function s(o,i,l,d){Promise.resolve(d).then(function(c){o({value:c,done:l})},i)}}function Wt(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=Ne(r),n=0;n<t.length;n++)t[n]!=="default"&&ve(e,r,t[n]);return Nn(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 Un(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 Ce,ye,ve,Nn,Ne,Un,Ln,G=Ze(()=>{"use strict";a();Ce=function(r,e){return Ce=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])},Ce(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)};ve=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]});Nn=Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e},Ne=function(r){return Ne=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},Ne(r)};Un=typeof SuppressedError=="function"?SuppressedError:function(r,e,t){var n=new Error(t);return n.name="SuppressedError",n.error=r,n.suppressed=e,n};Ln={__extends:xt,__assign:ye,__rest:It,__decorate:Ct,__param:Nt,__esDecorate:Ut,__runInitializers:Lt,__propKey:Dt,__setFunctionName:$t,__metadata:kt,__awaiter:Mt,__generator:jt,__createBinding:ve,__exportStar:Ht,__values:we,__read:Ue,__spread:Bt,__spreadArrays:qt,__spreadArray:Ft,__await:K,__asyncGenerator:zt,__asyncDelegator:Gt,__asyncValues:Vt,__makeTemplateObject:Wt,__importStar:Kt,__importDefault:Jt,__classPrivateFieldGet:Yt,__classPrivateFieldSet:Qt,__classPrivateFieldIn:Xt,__addDisposableResource:Zt,__disposeResources:er,__rewriteRelativeImportExtension:tr}});var $e=q(De=>{"use strict";a();Object.defineProperty(De,"__esModule",{value:!0});var Le=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};De.default=Le});var je=q(Me=>{"use strict";a();Object.defineProperty(Me,"__esModule",{value:!0});var Dn=(G(),V(z)),$n=Dn.__importDefault($e()),ke=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,l,d,c;let u=null,f=null,m=null,y=o.status,v=o.statusText;if(o.ok){if(this.method!=="HEAD"){let A=await o.text();A===""||(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"))?f=A:f=JSON.parse(A))}let w=(l=this.headers.get("Prefer"))===null||l===void 0?void 0:l.match(/count=(exact|planned|estimated)/),R=(d=o.headers.get("content-range"))===null||d===void 0?void 0:d.split("/");w&&R&&R.length>1&&(m=parseInt(R[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(f)&&(f.length>1?(u={code:"PGRST116",details:`Results contain ${f.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},f=null,m=null,y=406,v="Not Acceptable"):f.length===1?f=f[0]:f=null)}else{let w=await o.text();try{u=JSON.parse(w),Array.isArray(u)&&o.status===404&&(f=[],u=null,y=200,v="OK")}catch{o.status===404&&w===""?(y=204,v="No Content"):u={message:w}}if(u&&this.isMaybeSingle&&(!((c=u?.details)===null||c===void 0)&&c.includes("0 rows"))&&(u=null,y=200,v="OK"),u&&this.shouldThrowOnError)throw new $n.default(u)}return{error:u,data:f,count:m,status:y,statusText:v}});return this.shouldThrowOnError||(s=s.catch(o=>{var i,l,d;return{error:{message:`${(i=o?.name)!==null&&i!==void 0?i:"FetchError"}: ${o?.message}`,details:`${(l=o?.stack)!==null&&l!==void 0?l:""}`,hint:"",code:`${(d=o?.code)!==null&&d!==void 0?d:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}returns(){return this}overrideTypes(){return this}};Me.default=ke});var qe=q(Be=>{"use strict";a();Object.defineProperty(Be,"__esModule",{value:!0});var kn=(G(),V(z)),Mn=kn.__importDefault(je()),He=class extends Mn.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",l=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${l?`${l},`:""}${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 l;let d=[e?"analyze":null,t?"verbose":null,n?"settings":null,s?"buffers":null,o?"wal":null].filter(Boolean).join("|"),c=(l=this.headers.get("Accept"))!==null&&l!==void 0?l:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${c}"; options=${d};`),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=He});var be=q(ze=>{"use strict";a();Object.defineProperty(ze,"__esModule",{value:!0});var jn=(G(),V(z)),Hn=jn.__importDefault(qe()),Bn=new RegExp("[,()]"),Fe=class extends Hn.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"&&Bn.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}};ze.default=Fe});var We=q(Ve=>{"use strict";a();Object.defineProperty(Ve,"__esModule",{value:!0});var qn=(G(),V(z)),se=qn.__importDefault(be()),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,l=(e??"*").split("").map(d=>/\s/.test(d)&&!i?"":(d==='"'&&(i=!i),d)).join("");return this.url.searchParams.set("select",l),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((l,d)=>l.concat(Object.keys(d)),[]);if(i.length>0){let l=[...new Set(i)].map(d=>`"${d}"`);this.url.searchParams.set("columns",l.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 l="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 d=e.reduce((c,u)=>c.concat(Object.keys(u)),[]);if(d.length>0){let c=[...new Set(d)].map(u=>`"${u}"`);this.url.searchParams.set("columns",c.join(","))}}return new se.default({method:l,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})}};Ve.default=Ge});var nr=q(Je=>{"use strict";a();Object.defineProperty(Je,"__esModule",{value:!0});var rr=(G(),V(z)),Fn=rr.__importDefault(We()),zn=rr.__importDefault(be()),Ke=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 Fn.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 l,d=new URL(`${this.url}/rpc/${e}`),c;n||s?(l=n?"HEAD":"GET",Object.entries(t).filter(([f,m])=>m!==void 0).map(([f,m])=>[f,Array.isArray(m)?`{${m.join(",")}}`:`${m}`]).forEach(([f,m])=>{d.searchParams.append(f,m)})):(l="POST",c=t);let u=new Headers(this.headers);return o&&u.set("Prefer",`count=${o}`),new zn.default({method:l,url:d,headers:u,schema:this.schemaName,body:c,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}};Je.default=Ke});var ur=q(P=>{"use strict";a();Object.defineProperty(P,"__esModule",{value:!0});P.PostgrestError=P.PostgrestBuilder=P.PostgrestTransformBuilder=P.PostgrestFilterBuilder=P.PostgrestQueryBuilder=P.PostgrestClient=void 0;var J=(G(),V(z)),sr=J.__importDefault(nr());P.PostgrestClient=sr.default;var or=J.__importDefault(We());P.PostgrestQueryBuilder=or.default;var ir=J.__importDefault(be());P.PostgrestFilterBuilder=ir.default;var ar=J.__importDefault(qe());P.PostgrestTransformBuilder=ar.default;var lr=J.__importDefault(je());P.PostgrestBuilder=lr.default;var cr=J.__importDefault($e());P.PostgrestError=cr.default;P.default={PostgrestClient:sr.default,PostgrestQueryBuilder:or.default,PostgrestFilterBuilder:ir.default,PostgrestTransformBuilder:ar.default,PostgrestBuilder:lr.default,PostgrestError:cr.default}});a();a();a();a();a();a();var Or=Object.defineProperty,Tr=Object.defineProperties,Pr=Object.getOwnPropertyDescriptors,tt=Object.getOwnPropertySymbols,Sr=Object.prototype.hasOwnProperty,Ar=Object.prototype.propertyIsEnumerable,rt=(r,e,t)=>e in r?Or(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,N=(r,e)=>{for(var t in e||(e={}))Sr.call(e,t)&&rt(r,t,e[t]);if(tt)for(var t of tt(e))Ar.call(e,t)&&rt(r,t,e[t]);return r},L=(r,e)=>Tr(r,Pr(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,l;let d=e||{},c={onRequest:[e?.onRequest],onResponse:[e?.onResponse],onSuccess:[e?.onSuccess],onError:[e?.onError],onRetry:[e?.onRetry]};if(!e||!e?.plugins)return{url:r,options:d,hooks:c};for(let u of e?.plugins||[]){if(u.init){let f=await((t=u.init)==null?void 0:t.call(u,r.toString(),e));d=f.options||d,r=f.url}c.onRequest.push((n=u.hooks)==null?void 0:n.onRequest),c.onResponse.push((s=u.hooks)==null?void 0:s.onResponse),c.onSuccess.push((o=u.hooks)==null?void 0:o.onSuccess),c.onError.push((i=u.hooks)==null?void 0:i.onError),c.onRetry.push((l=u.hooks)==null?void 0:l.onRetry)}return{url:r,options:d,hooks:c}},nt=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}},Cr=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 Nr(r){if(typeof r=="number")return new nt({type:"linear",attempts:r,delay:1e3});switch(r.type){case"linear":return new nt(r);case"exponential":return new Cr(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},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 it(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 ot(r){return typeof r=="function"}function kr(r){if(r?.customFetchImpl)return r.customFetchImpl;if(typeof globalThis<"u"&&ot(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&ot(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function Mr(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 it(r)?"application/json":null}function Hr(r){if(!r?.body)return null;let e=new Headers(r?.headers);if(it(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 Br(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 lt.includes(n)?n.toUpperCase():e?.body?"POST":"GET"}return e?.body?"POST":"GET"}function qr(r,e){let t;return!r?.signal&&r?.timeout&&(t=setTimeout(()=>e?.abort(),r?.timeout)),{abortTimeout:t,clearTimeout:()=>{t&&clearTimeout(t)}}}var Fr=class at extends Error{constructor(e,t){super(t||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,at.prototype)}};async function ae(r,e){let t=await r["~standard"].validate(e);if(t.issues)throw new Fr(t.issues);return t.value}var lt=["get","post","put","patch","delete"];var zr=r=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(e,t){var n,s,o,i;let l=((s=(n=r.plugins)==null?void 0:n.find(d=>{var c;return(c=d.schema)!=null&&c.config?e.startsWith(d.schema.config.baseURL||"")||e.startsWith(d.schema.config.prefix||""):!1}))==null?void 0:s.schema)||r.schema;if(l){let d=e;(o=l.config)!=null&&o.prefix&&d.startsWith(l.config.prefix)&&(d=d.replace(l.config.prefix,""),l.config.baseURL&&(e=e.replace(l.config.prefix,l.config.baseURL))),(i=l.config)!=null&&i.baseURL&&d.startsWith(l.config.baseURL)&&(d=d.replace(l.config.baseURL,""));let c=l.schema[d];if(c){let u=L(N({},t),{method:c.method,output:c.output});return t?.disableValidation||(u=L(N({},u),{body:c.input?await ae(c.input,t?.body):t?.body,params:c.params?await ae(c.params,t?.params):t?.params,query:c.query?await ae(c.query,t?.query):t?.query})),{url:e,options:u}}}return{url:e,options:t}}}),ct=r=>{async function e(t,n){let s=L(N(N({},r),n),{plugins:[...r?.plugins||[],zr(r||{})]});if(r?.catchAllError)try{return await _e(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 _e(t,s)}return e};function Gr(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 f=r.toString().split("@")[1].split("/")[0];lt.includes(f)&&(r=r.replace(`@${f}/`,"/"))}o.endsWith("/")||(o+="/");let[i,l]=r.replace(o,"").split("?"),d=new URLSearchParams(l);for(let[f,m]of Object.entries(s||{}))m!=null&&d.set(f,String(m));if(n)if(Array.isArray(n)){let f=i.split("/").filter(m=>m.startsWith(":"));for(let[m,y]of f.entries()){let v=n[m];i=i.replace(y,v)}}else for(let[f,m]of Object.entries(n))i=i.replace(`:${f}`,String(m));i=i.split("/").map(encodeURIComponent).join("/"),i.startsWith("/")&&(i=i.slice(1));let c=d.toString();return c=c.length>0?`?${c}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${i}${c}`,o):`${o}${i}${c}`}var _e=async(r,e)=>{var t,n,s,o,i,l,d,c;let{hooks:u,url:f,options:m}=await Ir(r,e),y=kr(m),v=new AbortController,_=(t=m.signal)!=null?t:v.signal,w=Gr(f,m),R=Hr(m),A=await Mr(m),k=Br(f,m),g=L(N({},m),{url:w,headers:A,body:R,method:k,signal:_});for(let C of u.onRequest)if(C){let T=await C(g);T instanceof Object&&(g=T)}("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:B}=qr(m,v),E=await y(g.url,g);B();let Qe={response:E,request:g};for(let C of u.onResponse)if(C){let T=await C(L(N({},Qe),{response:(s=e?.hookOptions)!=null&&s.cloneResponse?E.clone():E}));T instanceof Response?E=T:T instanceof Object&&(E=T.response)}if(E.ok){if(!(g.method!=="HEAD"))return{data:"",error:null};let T=Dr(E),M={data:"",response:E,request:g};if(T==="json"||T==="text"){let j=await E.text(),gr=await((o=g.jsonParser)!=null?o:st)(j);M.data=gr}else M.data=await E[T]();g?.output&&g.output&&!g.disableValidation&&(M.data=await ae(g.output,M.data));for(let j of u.onSuccess)j&&await j(L(N({},M),{response:(i=e?.hookOptions)!=null&&i.cloneResponse?E.clone():E}));return e?.throw?M.data:{data:M.data,error:null}}let pr=(l=e?.jsonParser)!=null?l:st,oe=await E.text(),Xe=$r(oe),Ee=Xe?await pr(oe):null,mr={response:E,responseText:oe,request:g,error:L(N({},Ee),{status:E.status,statusText:E.statusText})};for(let C of u.onError)C&&await C(L(N({},mr),{response:(d=e?.hookOptions)!=null&&d.cloneResponse?E.clone():E}));if(e?.retry){let C=Nr(e.retry),T=(c=e.retryAttempt)!=null?c:0;if(await C.shouldAttemptRetry(T,E)){for(let j of u.onRetry)j&&await j(Qe);let M=C.getDelay(T);return await new Promise(j=>setTimeout(j,M)),await _e(r,L(N({},e),{retryAttempt:T+1}))}}if(e?.throw)throw new xr(E.status,E.statusText,Xe?Ee:oe);return{data:null,error:L(N({},Ee),{status:E.status,statusText:E.statusText})}};a();a();var le=Object.create(null),Y=r=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(r?le:globalThis),I=new Proxy(le,{get(r,e){return Y()[e]??le[e]},has(r,e){let t=Y();return e in t||e in le},set(r,e,t){let n=Y(!0);return n[e]=t,!0},deleteProperty(r,e){if(!e)return!1;let t=Y(!0);return delete t[e],!0},ownKeys(){let r=Y(!0);return Object.keys(r)}});var ss=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function b(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 os=Object.freeze({get BETTER_AUTH_SECRET(){return b("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return b("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return b("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return b("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return b("NODE_ENV","development")},get PACKAGE_VERSION(){return b("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return b("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),Q=1,O=4,D=8,x=24,ut={eterm:O,cons25:O,console:O,cygwin:O,dtterm:O,gnome:O,hurd:O,jfbterm:O,konsole:O,kterm:O,mlterm:O,mosh:x,putty:O,st:O,"rxvt-unicode-24bit":x,terminator:x,"xterm-kitty":x},Vr=new Map(Object.entries({APPVEYOR:D,BUILDKITE:D,CIRCLECI:x,DRONE:D,GITEA_ACTIONS:x,GITHUB_ACTIONS:x,GITLAB_CI:D,TRAVIS:D})),Wr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Kr(){if(b("FORCE_COLOR")!==void 0)switch(b("FORCE_COLOR")){case"":case"1":case"true":return O;case"2":return D;case"3":return x;default:return Q}if(b("NODE_DISABLE_COLORS")!==void 0&&b("NODE_DISABLE_COLORS")!==""||b("NO_COLOR")!==void 0&&b("NO_COLOR")!==""||b("TERM")==="dumb")return Q;if(b("TMUX"))return x;if("TF_BUILD"in I&&"AGENT_NAME"in I)return O;if("CI"in I){for(let{0:r,1:e}of Vr)if(r in I)return e;return b("CI_NAME")==="codeship"?D:Q}if("TEAMCITY_VERSION"in I)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(b("TEAMCITY_VERSION"))!==null?O:Q;switch(b("TERM_PROGRAM")){case"iTerm.app":return!b("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(b("TERM_PROGRAM_VERSION"))!==null?D:x;case"HyperTerm":case"MacTerm":return x;case"Apple_Terminal":return D}if(b("COLORTERM")==="truecolor"||b("COLORTERM")==="24bit")return x;if(b("TERM")){if(/truecolor/.exec(b("TERM"))!==null)return x;if(/^xterm-256/.exec(b("TERM"))!==null)return D;let r=b("TERM").toLowerCase();if(ut[r])return ut[r];if(Wr.some(e=>e.exec(r)!==null))return O}return b("COLORTERM")?O:Q}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"}},Re=["info","success","warn","error","debug"];function Jr(r,e){return Re.indexOf(e)<=Re.indexOf(r)}var Yr={info:$.fg.blue,success:$.fg.green,warn:$.fg.yellow,error:$.fg.red,debug:$.fg.magenta},Qr=(r,e,t)=>{let n=new Date().toISOString();return t?`${$.dim}${n}${$.reset} ${Yr[r]}${r.toUpperCase()}${$.reset} ${$.bright}[Better Auth]:${$.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=(l,d,c=[])=>{if(!e||!Jr(t,l))return;let u=Qr(l,d,s);if(!r||typeof r.log!="function"){l==="error"?console.error(u,...c):l==="warn"?console.warn(u,...c):console.log(u,...c);return}r.log(l==="success"?"info":l,d,...c)};return{...Object.fromEntries(Re.map(l=>[l,(...[d,...c])=>o(l,d,c)])),get level(){return t}}},is=Xr();a();a();var hs={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 Zr(r){try{return(new URL(r).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new F(`Invalid base URL: ${r}. Please provide a valid base URL.`)}}function X(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 dt(r,e,t,n){if(r)return X(r,e);if(n!==!1){let i=I.BETTER_AUTH_URL||I.NEXT_PUBLIC_BETTER_AUTH_URL||I.PUBLIC_BETTER_AUTH_URL||I.NUXT_PUBLIC_BETTER_AUTH_URL||I.NUXT_PUBLIC_AUTH_URL||(I.BASE_URL!=="/"?I.BASE_URL:void 0);if(i)return X(i,e)}let s=t?.headers.get("x-forwarded-host"),o=t?.headers.get("x-forwarded-proto");if(s&&o)return X(`${o}://${s}`,e);if(t){let i=en(t.url);if(!i)throw new F("Could not get origin from request. Please provide a valid base URL.");return X(i,e)}if(typeof window<"u"&&window.location)return X(window.location.origin,e)}function en(r){try{return new URL(r).origin}catch{return null}}a();a();a();var Z=Symbol("clean");var U=[],H=0,ce=4,tn=0,ee=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=H+ce;o<U.length;)U[o]===n?U.splice(o,ce):o+=ce;let s=e.indexOf(n);~s&&(e.splice(s,1),--t.lc||t.off())}},notify(n,s){tn++;let o=!U.length;for(let i of e)U.push(i,t.value,n,s);if(o){for(H=0;H<U.length;H+=ce)U[H](U[H+1],U[H+2],U[H+3]);U.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[Z]=()=>{e=[],t.lc=0,t.off()}),t};a();var rn=5,W=6,ue=10,nn=(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,Oe=(r,e)=>nn(r,n=>{let s=e(n);s&&r.events[W].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[W]=[],r.off=()=>{o(),setTimeout(()=>{if(r.active&&!r.lc){r.active=!1;for(let i of r.events[W])i();r.events[W]=[]}},ft)},process.env.NODE_ENV!=="production"){let i=r[Z];r[Z]=()=>{for(let l of r.events[W])l();r.events[W]=[],r.active=!1,i()}}return()=>{r.listen=s,r.off=o}});a();var sn=typeof window>"u",de=(r,e,t,n)=>{let s=ee({data:null,error:null,isPending:!0,isRefetching:!1,refetch:l=>o(l)}),o=l=>{let d=typeof n=="function"?n({data:s.get().data,error:s.get().error,isPending:s.get().isPending}):n;t(e,{...d,query:{...d?.query,...l?.query},async onSuccess(c){s.set({data:c.data,error:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await d?.onSuccess?.(c)},async onError(c){let{request:u}=c,f=typeof u.retry=="number"?u.retry:u.retry?.attempts,m=u.retryAttempt||0;f&&m<f||(s.set({error:c.error,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await d?.onError?.(c))},async onRequest(c){let u=s.get();s.set({isPending:u.data===null,data:u.data,error:null,isRefetching:!0,refetch:s.value.refetch}),await d?.onRequest?.(c)}}).catch(c=>{s.set({error:c,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch})})};r=Array.isArray(r)?r:[r];let i=!1;for(let l of r)l.subscribe(()=>{sn||(i?o():Oe(s,()=>{let d=setTimeout(()=>{i||(o(),i=!0)},0);return()=>{s.off(),l.off(),clearTimeout(d)}}))});return s};a();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*$/,ht={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,l,d,c,u,f]=e,m=new Date(Date.UTC(parseInt(t,10),parseInt(n,10)-1,parseInt(s,10),parseInt(o,10),parseInt(i,10),parseInt(l,10),d?parseInt(d.padEnd(3,"0"),10):0));if(c){let y=(parseInt(u,10)*60+parseInt(f,10))*(c==="+"?-1:1);m.setUTCMinutes(m.getUTCMinutes()+y)}return cn(m)?m:null}function dn(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 l=i.toLowerCase();if(l.length<=9&&l in ht)return ht[l];if(!an.test(i)){if(t)throw new SyntaxError("[better-json] Invalid JSON");return r}if(Object.entries(on).some(([c,u])=>{let f=u.test(i);return f&&n&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${c} pattern`),f})&&t)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(i,(u,f)=>{if(u==="__proto__"||u==="constructor"&&f&&typeof f=="object"&&"prototype"in f){n&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof f=="string"){let m=un(f);if(m)return m}return s?s(u,f):f})}catch(c){if(t)throw c;return r}}function pt(r,e={strict:!0}){return dn(r,e)}var fn={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=ee(!1);return{session:de(e,"/get-session",r,{method:"GET"}),$sessionSignal:e}}var mt=(r,e)=>{let t="credentials"in Request.prototype,n=dt(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:l,onRequest:d,onResponse:c,...u}=r?.fetchOptions||{},f=ct({baseURL:n,...t?{credentials:"include"}:{},method:"GET",jsonParser(g){return g?pt(g,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[o,...u.plugins||[],...r?.disableDefaultFetchPlugins?[]:[fn],...s]}),{$sessionSignal:m,session:y}=hn(f),v=r?.plugins||[],_={},w={$sessionSignal:m,session:y},R={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},A=[{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 v)g.getAtoms&&Object.assign(w,g.getAtoms?.(f)),g.pathMethods&&Object.assign(R,g.pathMethods),g.atomListeners&&A.push(...g.atomListeners);let k={notify:g=>{w[g].set(!w[g].get())},listen:(g,B)=>{w[g].subscribe(B)},atoms:w};for(let g of v)g.getActions&&Object.assign(_,g.getActions?.(f,k,r));return{get baseURL(){return n},pluginsActions:_,pluginsAtoms:w,pluginPathMethods:R,atomListeners:A,$fetch:f,$store:k}};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 gt(r,e,t,n,s){function o(i=[]){return new Proxy(function(){},{get(l,d){if(typeof d!="string"||d==="then"||d==="catch"||d==="finally")return;let c=[...i,d],u=r;for(let f of c)if(u&&typeof u=="object"&&f in u)u=u[f];else{u=void 0;break}return typeof u=="function"||pn(u)?u:o(c)},apply:async(l,d,c)=>{let u="/"+i.map(A=>A.replace(/[A-Z]/g,k=>`-${k.toLowerCase()}`)).join("/"),f=c[0]||{},m=c[1]||{},{query:y,fetchOptions:v,..._}=f,w={...m,...v},R=mn(u,t,f);return await e(u,{...w,body:R==="GET"?void 0:{..._,...w?.body||{}},query:y||w?.query,method:R,async onSuccess(A){if(await w?.onSuccess?.(A),!s)return;let k=s.filter(g=>g.matcher(u));if(k.length)for(let g of k){let B=n[g.signal];if(!B)return;let E=B.get();setTimeout(()=>{B.set(!E)},10)}}})}})}return o()}a();function yt(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Te(r){let{pluginPathMethods:e,pluginsActions:t,pluginsAtoms:n,$fetch:s,atomListeners:o,$store:i}=mt(r),l={};for(let[u,f]of Object.entries(n))l[`use${yt(u)}`]=f;let d={...t,...l,$fetch:s,$store:i};return gt(d,s,e,n,o)}a();a();a();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(l=>i.includes(l));else if(typeof o=="object"){let l=o;l.connector==="OR"?n=l.actions.some(d=>i.includes(d)):n=l.actions.every(d=>i.includes(d))}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 fe(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"]},Pe=fe(yn),wn=Pe.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),vn=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"]});a();a();a();a();a();a();a();a();a();a();a();var Se=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}}},bt=new Se;a();a();a();a();a();a();a();a();var Tn={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},Et=fe(Tn),Pn=Et.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),Sn=Et.newRole({user:[],session:[]});a();a();var _t=()=>({id:"username",$InferServerPlugin:{}});var Rt=()=>({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 An="/auth",xe="nvwa_login_token",te="nvwa_current_jwt",Ie="nvwa_user_profile",Tt=class{constructor(e,t,n){this.storage=n;let s=Te({baseURL:e,basePath:An,plugins:[_t(),Rt(),Ot()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:async()=>{let o=await this.storage.get(te);if(console.log("jwt",o),o)return o;let i=await this.storage.get(xe);return console.log("loginToken",i),i}}}});this.authClient=s}async currentUser(){return await this.storage.get(Ie)}async getCurrentJwt(){return await this.storage.get(te)}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.handleLogin(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.handleLogin(n)}async signInWithPhoneNumber(e,t,n=!1){let s=await this.authClient.signIn.phoneNumber({phoneNumber:e,password:t,rememberMe:n});this.handleLogin(s)}async signInWithUsername(e,t){let n=await this.authClient.signIn.username({username:e,password:t});this.handleLogin(n)}async handleLogin(e){if(e.error)throw new Error(e.error.message);await this.storage.set(xe,e.data?.token),await this.storage.set(Ie,e.data?.user);let{data:t,error:n}=await this.authClient.token();if(n)throw new Error(n.message);await this.storage.set(te,t.token)}async signOut(){await this.storage.remove(xe),await this.storage.remove(Ie)}async updateUserPassword(e,t,n=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:n});this.handleLogin(s)}};a();var Pt=class{constructor(e){this.http=e}async invoke(e,t){return await(await this.http.fetch("/functions/"+e,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};a();a();a();var S=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()}},re=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}},he=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 re(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]}`:"",l=t[9]?`#${t[9]}`:"";if(!n&&!s&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let d=s.match(/^([^@]*)@(.+)$/),c="",u="",f=s;if(d){let _=d[1];f=d[2];let w=_.match(/^([^:]*):?(.*)$/);w&&(c=w[1]||"",u=w[2]||"")}let m=f.match(/^([^:]+):?(\d*)$/),y=m?m[1]:f,v=m&&m[2]?m[2]:"";return{protocol:n?`${n}:`:"",username:c,password:u,host:f,hostname:y,port:v,pathname:o,search:i,hash:l}}toString(){let e=this.searchParams.toString(),t=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${t}${this.hash}`}toJSON(){return this.toString()}};a();var pe=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 S?t.headers:new S(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}};a();var me=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=xn(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 xn(r){return r?new S(r):new S}a();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]"}},ge=class{constructor(){this._signal=new ne}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};a();function Ca(r){r.URL=he,r.URLSearchParams=re,r.Headers=S,r.Request=pe,r.Response=me,r.AbortController=ge,r.AbortSignal=ne}var St=class{constructor(e,t,n){console.log("NvwaHttpClient constructor",e,t,n),this.storage=e,this.customFetch=t,this.handleUnauthorized=n}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let n=await this.storage.get(te),s=new S(t?.headers);n&&s.set("Authorization",`Bearer ${n}`);let o=await this.customFetch(e,{...t,headers:s});if(o.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return o}};a();var In="/storage",Cn=In+"/generateUploadUrl",At=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+Cn,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:n}=await t.json();if(!n)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(n,{method:"PUT",body:e,headers:new S({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:o}=await s.json();return{url:o.split("?")[0]}}};a();a();a();var Ye=Rr(ur(),1),{PostgrestClient:dr,PostgrestQueryBuilder:gl,PostgrestFilterBuilder:yl,PostgrestTransformBuilder:wl,PostgrestBuilder:vl,PostgrestError:bl}=Ye.default||Ye;var Gn="/entities",Ol=(r,e)=>new dr(r+Gn,{fetch:e.fetchWithAuth.bind(e)});a();var fr=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let n=`${this.baseUrl}/skill/${e}/execute`,o=await(await this.http.fetchWithAuth(n,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(o.status!==200)throw new Error(o.message);return o.data}};a();var hr=class{constructor(){this.hoverOverlay=null;this.selectedOverlay=null;this.tooltip=null;this.hoverElement=null;this.selectedElement=null;this.hoverUpdateHandler=null;this.selectedUpdateHandler=null;this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let e=document.createElement("style");e.id="__nvwa-inspector-overlay-style",e.textContent=`
|
|
2
|
+
.__nvwa-inspector-overlay {
|
|
3
|
+
position: absolute;
|
|
4
|
+
pointer-events: none;
|
|
5
|
+
z-index: 999998;
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
}
|
|
8
|
+
.__nvwa-inspector-overlay-hover {
|
|
9
|
+
border: 2px solid #3b82f6;
|
|
10
|
+
background-color: rgba(59, 130, 246, 0.1);
|
|
11
|
+
z-index: 999998;
|
|
12
|
+
}
|
|
13
|
+
.__nvwa-inspector-overlay-selected {
|
|
14
|
+
border: 3px solid #10b981;
|
|
15
|
+
background-color: rgba(16, 185, 129, 0.15);
|
|
16
|
+
z-index: 999997;
|
|
17
|
+
}
|
|
18
|
+
#__nvwa-inspector-tooltip {
|
|
19
|
+
position: fixed;
|
|
20
|
+
background: rgba(0, 0, 0, 0.9);
|
|
21
|
+
color: white;
|
|
22
|
+
padding: 6px 10px;
|
|
23
|
+
border-radius: 4px;
|
|
24
|
+
font-size: 12px;
|
|
25
|
+
font-family: monospace;
|
|
26
|
+
pointer-events: none;
|
|
27
|
+
z-index: 999999;
|
|
28
|
+
display: none;
|
|
29
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
|
|
30
|
+
max-width: 400px;
|
|
31
|
+
word-break: break-all;
|
|
32
|
+
}
|
|
33
|
+
`,document.head.appendChild(e)}createTooltip(){return this.tooltip?this.tooltip:(this.tooltip=document.createElement("div"),this.tooltip.id="__nvwa-inspector-tooltip",document.body.appendChild(this.tooltip),this.tooltip)}createOverlay(e){let t=document.createElement("div");return t.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${e}`,document.body.appendChild(t),t}updateOverlayPosition(e,t){if(!t.isConnected)return;let n=t.getBoundingClientRect(),s=window.scrollX||window.pageXOffset,o=window.scrollY||window.pageYOffset;n.width>0&&n.height>0?(e.style.left=`${n.left+s}px`,e.style.top=`${n.top+o}px`,e.style.width=`${n.width}px`,e.style.height=`${n.height}px`,e.style.display="block"):e.style.display="none"}removeOverlay(e){e&&e.parentNode&&e.parentNode.removeChild(e)}highlightElement(e,t){if(!e.isConnected)return;if(this.hoverElement===e&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,e);let l=this.createTooltip();t?l.textContent=t:l.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,l.style.display="block";let d=e.getBoundingClientRect();l.style.left=`${d.left+window.scrollX}px`,l.style.top=`${d.top+window.scrollY-l.offsetHeight-8}px`,d.top<l.offsetHeight+8&&(l.style.top=`${d.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let n=this.createOverlay("hover");this.updateOverlayPosition(n,e),this.hoverOverlay=n,this.hoverElement=e;let s=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s);let o=this.createTooltip();t?o.textContent=t:o.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let i=e.getBoundingClientRect();o.style.left=`${i.left+window.scrollX}px`,o.style.top=`${i.top+window.scrollY-o.offsetHeight-8}px`,i.top<o.offsetHeight+8&&(o.style.top=`${i.bottom+window.scrollY+8}px`)}selectElement(e,t){if(!e.isConnected)return;if(this.selectedElement===e&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,e);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let n=this.createOverlay("selected");this.updateOverlayPosition(n,e),this.selectedOverlay=n,this.selectedElement=e;let s=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let e=document.getElementById("__nvwa-inspector-overlay-style");e&&e.parentNode&&e.parentNode.removeChild(e)}};function xl(r="root"){if(typeof document>"u")return null;let e=document.getElementById(r)||document.body;if(!e)return null;let t=e.querySelector("[data-source-location]");if(t){let n=t.getAttribute("data-source-location");if(n)return n}if(e.firstElementChild){let s=e.firstElementChild.getAttribute("data-source-location");if(s)return s}return null}export{An as AUTH_BASE_PATH,ge as AbortController,ne as AbortSignal,te as CURRENT_JWT_KEY,Gn as ENTITIES_BASE_PATH,In as FILE_STORAGE_BASE_PATH,Cn as GENERATE_UPLOAD_URL_PATH,S as Headers,xe as LOGIN_TOKEN_KEY,Ie as LOGIN_USER_PROFILE_KEY,Tt as NvwaAuthClient,Pt as NvwaEdgeFunctions,At as NvwaFileStorage,St as NvwaHttpClient,fr as NvwaSkill,hr as OverlayManager,pe as Request,me as Response,he as URL,re as URLSearchParams,Ol as createPostgrestClient,xl as getSourceLocationFromDOM,Ca as polyfill};
|