@nvwa-app/sdk-core 6.8.1 → 6.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 CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as _nvwa_app_postgrest_js from '@nvwa-app/postgrest-js';
2
2
  import { PostgrestClient } from '@nvwa-app/postgrest-js';
3
+ import { NvwaFetch, URL, RequestInfo, RequestInit, Response, Headers } from '@nvwa-app/nvwa-http-polyfill';
3
4
 
4
5
  /**
5
6
  * Payment 纯前端能力:仅「发起支付」。
@@ -96,128 +97,6 @@ type CreatePaymentResponse = PaymentOrderResult;
96
97
  */
97
98
  declare function requestPaymentFromOrderResult(result: PaymentOrderResult, launcher: IPaymentLauncher, callbacks?: PaymentRequestCallbacks): Promise<void>;
98
99
 
99
- declare class Headers {
100
- private readonly headerMap;
101
- constructor(init?: Headers | Record<string, string> | [string, string][]);
102
- append(name: string, value: string): void;
103
- set(name: string, value: string): void;
104
- get(name: string): string | null;
105
- has(name: string): boolean;
106
- delete(name: string): void;
107
- forEach(callback: (value: string, key: string, parent: Headers) => void): void;
108
- entries(): IterableIterator<[string, string]>;
109
- keys(): IterableIterator<string>;
110
- values(): IterableIterator<string>;
111
- [Symbol.iterator](): IterableIterator<[string, string]>;
112
- }
113
- declare class URLSearchParams {
114
- private params;
115
- constructor(init?: string | URLSearchParams | Record<string, string> | [string, string][] | Iterable<[string, string]>);
116
- private parseString;
117
- append(name: string, value: string): void;
118
- delete(name: string): void;
119
- get(name: string): string | null;
120
- getAll(name: string): string[];
121
- has(name: string): boolean;
122
- set(name: string, value: string): void;
123
- sort(): void;
124
- toString(): string;
125
- forEach(callback: (value: string, key: string, parent: URLSearchParams) => void): void;
126
- keys(): IterableIterator<string>;
127
- values(): IterableIterator<string>;
128
- entries(): IterableIterator<[string, string]>;
129
- [Symbol.iterator](): IterableIterator<[string, string]>;
130
- get size(): number;
131
- }
132
- declare class URL$1 {
133
- readonly href: string;
134
- readonly origin: string;
135
- readonly protocol: string;
136
- readonly username: string;
137
- readonly password: string;
138
- readonly host: string;
139
- readonly hostname: string;
140
- readonly port: string;
141
- readonly pathname: string;
142
- readonly search: string;
143
- readonly searchParams: URLSearchParams;
144
- readonly hash: string;
145
- constructor(url: string | URL$1, base?: string | URL$1);
146
- private resolve;
147
- private parseUrl;
148
- toString(): string;
149
- toJSON(): string;
150
- }
151
-
152
- /** 与标准 fetch 的 RequestInit 对齐,便于 AuthClient 等传入 credentials / headers 对象 */
153
- interface RequestInit {
154
- method?: string;
155
- /** Headers 实例或可被 Headers 构造器接受的格式 */
156
- headers?: Headers | Record<string, string> | [string, string][];
157
- body?: any;
158
- /** 与标准 fetch 一致,AuthClient 传 "omit" 等 */
159
- credentials?: "omit" | "same-origin" | "include";
160
- timeout?: number;
161
- signal?: {
162
- aborted: boolean;
163
- addEventListener: Function;
164
- } | null;
165
- }
166
- type RequestInfo = string | {
167
- url?: string;
168
- } | URL;
169
- declare class Request {
170
- readonly url: string;
171
- readonly method: string;
172
- readonly headers: Headers;
173
- readonly body?: any;
174
- readonly timeout?: number;
175
- readonly signal?: any;
176
- constructor(input: RequestInfo, init?: RequestInit);
177
- clone(): Request;
178
- toString(): string;
179
- }
180
-
181
- interface ResponseInit {
182
- status?: number;
183
- statusText?: string;
184
- headers?: Headers;
185
- }
186
- declare class Response {
187
- private readonly bodyData;
188
- readonly status: number;
189
- readonly statusText: string;
190
- readonly headers: Headers;
191
- readonly ok: boolean;
192
- constructor(body?: any, init?: ResponseInit);
193
- text(): Promise<string>;
194
- json<T = unknown>(): Promise<T>;
195
- arrayBuffer(): Promise<ArrayBuffer>;
196
- }
197
-
198
- type AbortListener = () => void;
199
- declare class AbortSignal {
200
- private _aborted;
201
- private listeners;
202
- onabort: AbortListener | null;
203
- get aborted(): boolean;
204
- _trigger(): void;
205
- addEventListener(_: "abort", listener: AbortListener): void;
206
- removeEventListener(_: "abort", listener: AbortListener): void;
207
- toString(): string;
208
- }
209
- declare class AbortController {
210
- private _signal;
211
- constructor();
212
- get signal(): AbortSignal;
213
- abort(): void;
214
- toString(): string;
215
- }
216
-
217
- declare function polyfill(_global: any): void;
218
-
219
- type NvwaFetch = (input: string | URL$1 | RequestInfo, init?: RequestInit) => Promise<Response>;
220
-
221
100
  interface NvwaLocalStorage {
222
101
  get(key: string): Promise<any | null>;
223
102
  /**
@@ -234,8 +113,8 @@ declare class NvwaHttpClient {
234
113
  protected customFetch: NvwaFetch;
235
114
  protected handleUnauthorized: () => void;
236
115
  constructor(storage: NvwaLocalStorage, customFetch: NvwaFetch, handleUnauthorized: () => void);
237
- fetch(url: string | URL$1 | RequestInfo, request?: RequestInit): Promise<Response>;
238
- fetchWithAuth(url: string | URL$1 | RequestInfo, request?: RequestInit): Promise<Response>;
116
+ fetch(url: string | URL | RequestInfo, request?: RequestInit): Promise<Response>;
117
+ fetchWithAuth(url: string | URL | RequestInfo, request?: RequestInit): Promise<Response>;
239
118
  }
240
119
 
241
120
  type HttpUploadFileResponse = {
@@ -687,4 +566,4 @@ interface INvwa {
687
566
  endpointType: string;
688
567
  }
689
568
 
690
- export { AbortController, AbortSignal, type AlipayCodeLoginResult, type AlipayOpenPlatformIdentity, AuthClient, type AuthClientOptions, type AuthResult, type AuthSession, type AuthUser, CURRENT_JWT_KEY, type CreatePaymentResponse, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, type GithubOpenPlatformIdentity, type GithubOpenPlatformLoginResult, type GoogleOpenPlatformIdentity, type GoogleOpenPlatformLoginResult, Headers, type HoverInspectorMessage, type HttpMethod, type HttpUploadFileResponse, type INvwa, type IPaymentLauncher, type IframeSourceLocationMessage, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, type LegacyPayParams, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, OverlayManager, type PayParams, type PaymentOrderResult, type PaymentRequestCallbacks, Request, type RequestInfo, type RequestInit, Response, type ResponseInit, SET_AUTH_TOKEN_HEADER, type SignUpBody, type TypedPayParams, URL$1 as URL, URLSearchParams, type WeChatCodeLoginResult, type WeChatOpenPlatformIdentity, type WechatJsapiPayParams, type WechatWebsiteOpenPlatformIdentity, type WechatWebsiteOpenPlatformLoginResult, createPostgrestClient, getSourceLocationFromDOM, normalizePayParams, polyfill, requestPaymentFromOrderResult };
569
+ export { type AlipayCodeLoginResult, type AlipayOpenPlatformIdentity, AuthClient, type AuthClientOptions, type AuthResult, type AuthSession, type AuthUser, CURRENT_JWT_KEY, type CreatePaymentResponse, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, type GithubOpenPlatformIdentity, type GithubOpenPlatformLoginResult, type GoogleOpenPlatformIdentity, type GoogleOpenPlatformLoginResult, type HoverInspectorMessage, type HttpMethod, type HttpUploadFileResponse, type INvwa, type IPaymentLauncher, type IframeSourceLocationMessage, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, type LegacyPayParams, NvwaEdgeFunctions, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, OverlayManager, type PayParams, type PaymentOrderResult, type PaymentRequestCallbacks, SET_AUTH_TOKEN_HEADER, type SignUpBody, type TypedPayParams, type WeChatCodeLoginResult, type WeChatOpenPlatformIdentity, type WechatJsapiPayParams, type WechatWebsiteOpenPlatformIdentity, type WechatWebsiteOpenPlatformLoginResult, createPostgrestClient, getSourceLocationFromDOM, normalizePayParams, requestPaymentFromOrderResult };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as _nvwa_app_postgrest_js from '@nvwa-app/postgrest-js';
2
2
  import { PostgrestClient } from '@nvwa-app/postgrest-js';
3
+ import { NvwaFetch, URL, RequestInfo, RequestInit, Response, Headers } from '@nvwa-app/nvwa-http-polyfill';
3
4
 
4
5
  /**
5
6
  * Payment 纯前端能力:仅「发起支付」。
@@ -96,128 +97,6 @@ type CreatePaymentResponse = PaymentOrderResult;
96
97
  */
97
98
  declare function requestPaymentFromOrderResult(result: PaymentOrderResult, launcher: IPaymentLauncher, callbacks?: PaymentRequestCallbacks): Promise<void>;
98
99
 
99
- declare class Headers {
100
- private readonly headerMap;
101
- constructor(init?: Headers | Record<string, string> | [string, string][]);
102
- append(name: string, value: string): void;
103
- set(name: string, value: string): void;
104
- get(name: string): string | null;
105
- has(name: string): boolean;
106
- delete(name: string): void;
107
- forEach(callback: (value: string, key: string, parent: Headers) => void): void;
108
- entries(): IterableIterator<[string, string]>;
109
- keys(): IterableIterator<string>;
110
- values(): IterableIterator<string>;
111
- [Symbol.iterator](): IterableIterator<[string, string]>;
112
- }
113
- declare class URLSearchParams {
114
- private params;
115
- constructor(init?: string | URLSearchParams | Record<string, string> | [string, string][] | Iterable<[string, string]>);
116
- private parseString;
117
- append(name: string, value: string): void;
118
- delete(name: string): void;
119
- get(name: string): string | null;
120
- getAll(name: string): string[];
121
- has(name: string): boolean;
122
- set(name: string, value: string): void;
123
- sort(): void;
124
- toString(): string;
125
- forEach(callback: (value: string, key: string, parent: URLSearchParams) => void): void;
126
- keys(): IterableIterator<string>;
127
- values(): IterableIterator<string>;
128
- entries(): IterableIterator<[string, string]>;
129
- [Symbol.iterator](): IterableIterator<[string, string]>;
130
- get size(): number;
131
- }
132
- declare class URL$1 {
133
- readonly href: string;
134
- readonly origin: string;
135
- readonly protocol: string;
136
- readonly username: string;
137
- readonly password: string;
138
- readonly host: string;
139
- readonly hostname: string;
140
- readonly port: string;
141
- readonly pathname: string;
142
- readonly search: string;
143
- readonly searchParams: URLSearchParams;
144
- readonly hash: string;
145
- constructor(url: string | URL$1, base?: string | URL$1);
146
- private resolve;
147
- private parseUrl;
148
- toString(): string;
149
- toJSON(): string;
150
- }
151
-
152
- /** 与标准 fetch 的 RequestInit 对齐,便于 AuthClient 等传入 credentials / headers 对象 */
153
- interface RequestInit {
154
- method?: string;
155
- /** Headers 实例或可被 Headers 构造器接受的格式 */
156
- headers?: Headers | Record<string, string> | [string, string][];
157
- body?: any;
158
- /** 与标准 fetch 一致,AuthClient 传 "omit" 等 */
159
- credentials?: "omit" | "same-origin" | "include";
160
- timeout?: number;
161
- signal?: {
162
- aborted: boolean;
163
- addEventListener: Function;
164
- } | null;
165
- }
166
- type RequestInfo = string | {
167
- url?: string;
168
- } | URL;
169
- declare class Request {
170
- readonly url: string;
171
- readonly method: string;
172
- readonly headers: Headers;
173
- readonly body?: any;
174
- readonly timeout?: number;
175
- readonly signal?: any;
176
- constructor(input: RequestInfo, init?: RequestInit);
177
- clone(): Request;
178
- toString(): string;
179
- }
180
-
181
- interface ResponseInit {
182
- status?: number;
183
- statusText?: string;
184
- headers?: Headers;
185
- }
186
- declare class Response {
187
- private readonly bodyData;
188
- readonly status: number;
189
- readonly statusText: string;
190
- readonly headers: Headers;
191
- readonly ok: boolean;
192
- constructor(body?: any, init?: ResponseInit);
193
- text(): Promise<string>;
194
- json<T = unknown>(): Promise<T>;
195
- arrayBuffer(): Promise<ArrayBuffer>;
196
- }
197
-
198
- type AbortListener = () => void;
199
- declare class AbortSignal {
200
- private _aborted;
201
- private listeners;
202
- onabort: AbortListener | null;
203
- get aborted(): boolean;
204
- _trigger(): void;
205
- addEventListener(_: "abort", listener: AbortListener): void;
206
- removeEventListener(_: "abort", listener: AbortListener): void;
207
- toString(): string;
208
- }
209
- declare class AbortController {
210
- private _signal;
211
- constructor();
212
- get signal(): AbortSignal;
213
- abort(): void;
214
- toString(): string;
215
- }
216
-
217
- declare function polyfill(_global: any): void;
218
-
219
- type NvwaFetch = (input: string | URL$1 | RequestInfo, init?: RequestInit) => Promise<Response>;
220
-
221
100
  interface NvwaLocalStorage {
222
101
  get(key: string): Promise<any | null>;
223
102
  /**
@@ -234,8 +113,8 @@ declare class NvwaHttpClient {
234
113
  protected customFetch: NvwaFetch;
235
114
  protected handleUnauthorized: () => void;
236
115
  constructor(storage: NvwaLocalStorage, customFetch: NvwaFetch, handleUnauthorized: () => void);
237
- fetch(url: string | URL$1 | RequestInfo, request?: RequestInit): Promise<Response>;
238
- fetchWithAuth(url: string | URL$1 | RequestInfo, request?: RequestInit): Promise<Response>;
116
+ fetch(url: string | URL | RequestInfo, request?: RequestInit): Promise<Response>;
117
+ fetchWithAuth(url: string | URL | RequestInfo, request?: RequestInit): Promise<Response>;
239
118
  }
240
119
 
241
120
  type HttpUploadFileResponse = {
@@ -687,4 +566,4 @@ interface INvwa {
687
566
  endpointType: string;
688
567
  }
689
568
 
690
- export { AbortController, AbortSignal, type AlipayCodeLoginResult, type AlipayOpenPlatformIdentity, AuthClient, type AuthClientOptions, type AuthResult, type AuthSession, type AuthUser, CURRENT_JWT_KEY, type CreatePaymentResponse, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, type GithubOpenPlatformIdentity, type GithubOpenPlatformLoginResult, type GoogleOpenPlatformIdentity, type GoogleOpenPlatformLoginResult, Headers, type HoverInspectorMessage, type HttpMethod, type HttpUploadFileResponse, type INvwa, type IPaymentLauncher, type IframeSourceLocationMessage, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, type LegacyPayParams, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, OverlayManager, type PayParams, type PaymentOrderResult, type PaymentRequestCallbacks, Request, type RequestInfo, type RequestInit, Response, type ResponseInit, SET_AUTH_TOKEN_HEADER, type SignUpBody, type TypedPayParams, URL$1 as URL, URLSearchParams, type WeChatCodeLoginResult, type WeChatOpenPlatformIdentity, type WechatJsapiPayParams, type WechatWebsiteOpenPlatformIdentity, type WechatWebsiteOpenPlatformLoginResult, createPostgrestClient, getSourceLocationFromDOM, normalizePayParams, polyfill, requestPaymentFromOrderResult };
569
+ export { type AlipayCodeLoginResult, type AlipayOpenPlatformIdentity, AuthClient, type AuthClientOptions, type AuthResult, type AuthSession, type AuthUser, CURRENT_JWT_KEY, type CreatePaymentResponse, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, type GithubOpenPlatformIdentity, type GithubOpenPlatformLoginResult, type GoogleOpenPlatformIdentity, type GoogleOpenPlatformLoginResult, type HoverInspectorMessage, type HttpMethod, type HttpUploadFileResponse, type INvwa, type IPaymentLauncher, type IframeSourceLocationMessage, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, type LegacyPayParams, NvwaEdgeFunctions, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, OverlayManager, type PayParams, type PaymentOrderResult, type PaymentRequestCallbacks, SET_AUTH_TOKEN_HEADER, type SignUpBody, type TypedPayParams, type WeChatCodeLoginResult, type WeChatOpenPlatformIdentity, type WechatJsapiPayParams, type WechatWebsiteOpenPlatformIdentity, type WechatWebsiteOpenPlatformLoginResult, createPostgrestClient, getSourceLocationFromDOM, normalizePayParams, requestPaymentFromOrderResult };
package/dist/index.js CHANGED
@@ -1,4 +1,7 @@
1
- "use strict";var ie=Object.create;var W=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var le=Object.getPrototypeOf,ue=Object.prototype.hasOwnProperty;var mt=(i,t)=>()=>(i&&(t=i(i=0)),t);var E=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),yt=(i,t)=>{for(var e in t)W(i,e,{get:t[e],enumerable:!0})},wt=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of oe(t))!ue.call(i,s)&&s!==e&&W(i,s,{get:()=>t[s],enumerable:!(r=ae(t,s))||r.enumerable});return i};var ce=(i,t,e)=>(e=i!=null?ie(le(i)):{},wt(t||!i||!i.__esModule?W(e,"default",{value:i,enumerable:!0}):e,i)),S=i=>wt(W({},"__esModule",{value:!0}),i);var u=mt(()=>{"use strict"});var T={};yt(T,{__addDisposableResource:()=>Ft,__assign:()=>G,__asyncDelegator:()=>Nt,__asyncGenerator:()=>jt,__asyncValues:()=>Ht,__await:()=>k,__awaiter:()=>At,__classPrivateFieldGet:()=>Mt,__classPrivateFieldIn:()=>Dt,__classPrivateFieldSet:()=>Bt,__createBinding:()=>B,__decorate:()=>Ot,__disposeResources:()=>Jt,__esDecorate:()=>Et,__exportStar:()=>$t,__extends:()=>Pt,__generator:()=>kt,__importDefault:()=>Gt,__importStar:()=>qt,__makeTemplateObject:()=>Wt,__metadata:()=>Lt,__param:()=>xt,__propKey:()=>Tt,__read:()=>Q,__rest:()=>_t,__rewriteRelativeImportExtension:()=>zt,__runInitializers:()=>St,__setFunctionName:()=>Rt,__spread:()=>Ut,__spreadArray:()=>Ct,__spreadArrays:()=>It,__values:()=>M,default:()=>me});function Pt(i,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Y(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function _t(i,t){var e={};for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&t.indexOf(r)<0&&(e[r]=i[r]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(i);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(i,r[s])&&(e[r[s]]=i[r[s]]);return e}function Ot(i,t,e,r){var s=arguments.length,n=s<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(i,t,e,r);else for(var o=i.length-1;o>=0;o--)(a=i[o])&&(n=(s<3?a(n):s>3?a(t,e,n):a(t,e))||n);return s>3&&n&&Object.defineProperty(t,e,n),n}function xt(i,t){return function(e,r){t(e,r,i)}}function Et(i,t,e,r,s,n){function a(O){if(O!==void 0&&typeof O!="function")throw new TypeError("Function expected");return O}for(var o=r.kind,c=o==="getter"?"get":o==="setter"?"set":"value",l=!t&&i?r.static?i:i.prototype:null,h=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),p,g=!1,d=e.length-1;d>=0;d--){var y={};for(var P in r)y[P]=P==="access"?{}:r[P];for(var P in r.access)y.access[P]=r.access[P];y.addInitializer=function(O){if(g)throw new TypeError("Cannot add initializers after decoration has completed");n.push(a(O||null))};var w=(0,e[d])(o==="accessor"?{get:h.get,set:h.set}:h[c],y);if(o==="accessor"){if(w===void 0)continue;if(w===null||typeof w!="object")throw new TypeError("Object expected");(p=a(w.get))&&(h.get=p),(p=a(w.set))&&(h.set=p),(p=a(w.init))&&s.unshift(p)}else(p=a(w))&&(o==="field"?s.unshift(p):h[c]=p)}l&&Object.defineProperty(l,r.name,h),g=!0}function St(i,t,e){for(var r=arguments.length>2,s=0;s<t.length;s++)e=r?t[s].call(i,e):t[s].call(i);return r?e:void 0}function Tt(i){return typeof i=="symbol"?i:"".concat(i)}function Rt(i,t,e){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(i,"name",{configurable:!0,value:e?"".concat(e," ",t):t})}function Lt(i,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,t)}function At(i,t,e,r){function s(n){return n instanceof e?n:new e(function(a){a(n)})}return new(e||(e=Promise))(function(n,a){function o(h){try{l(r.next(h))}catch(p){a(p)}}function c(h){try{l(r.throw(h))}catch(p){a(p)}}function l(h){h.done?n(h.value):s(h.value).then(o,c)}l((r=r.apply(i,t||[])).next())})}function kt(i,t){var e={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},r,s,n,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=o(0),a.throw=o(1),a.return=o(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(h){return c([l,h])}}function c(l){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(e=0)),e;)try{if(r=1,s&&(n=l[0]&2?s.return:l[0]?s.throw||((n=s.return)&&n.call(s),0):s.next)&&!(n=n.call(s,l[1])).done)return n;switch(s=0,n&&(l=[l[0]&2,n.value]),l[0]){case 0:case 1:n=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,s=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(n=e.trys,!(n=n.length>0&&n[n.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!n||l[1]>n[0]&&l[1]<n[3])){e.label=l[1];break}if(l[0]===6&&e.label<n[1]){e.label=n[1],n=l;break}if(n&&e.label<n[2]){e.label=n[2],e.ops.push(l);break}n[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(i,e)}catch(h){l=[6,h],s=0}finally{r=n=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function $t(i,t){for(var e in i)e!=="default"&&!Object.prototype.hasOwnProperty.call(t,e)&&B(t,i,e)}function M(i){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&i[t],r=0;if(e)return e.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&r>=i.length&&(i=void 0),{value:i&&i[r++],done:!i}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Q(i,t){var e=typeof Symbol=="function"&&i[Symbol.iterator];if(!e)return i;var r=e.call(i),s,n=[],a;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)n.push(s.value)}catch(o){a={error:o}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(a)throw a.error}}return n}function Ut(){for(var i=[],t=0;t<arguments.length;t++)i=i.concat(Q(arguments[t]));return i}function It(){for(var i=0,t=0,e=arguments.length;t<e;t++)i+=arguments[t].length;for(var r=Array(i),s=0,t=0;t<e;t++)for(var n=arguments[t],a=0,o=n.length;a<o;a++,s++)r[s]=n[a];return r}function Ct(i,t,e){if(e||arguments.length===2)for(var r=0,s=t.length,n;r<s;r++)(n||!(r in t))&&(n||(n=Array.prototype.slice.call(t,0,r)),n[r]=t[r]);return i.concat(n||Array.prototype.slice.call(t))}function k(i){return this instanceof k?(this.v=i,this):new k(i)}function jt(i,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(i,t||[]),s,n=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",a),s[Symbol.asyncIterator]=function(){return this},s;function a(d){return function(y){return Promise.resolve(y).then(d,p)}}function o(d,y){r[d]&&(s[d]=function(P){return new Promise(function(w,O){n.push([d,P,w,O])>1||c(d,P)})},y&&(s[d]=y(s[d])))}function c(d,y){try{l(r[d](y))}catch(P){g(n[0][3],P)}}function l(d){d.value instanceof k?Promise.resolve(d.value.v).then(h,p):g(n[0][2],d)}function h(d){c("next",d)}function p(d){c("throw",d)}function g(d,y){d(y),n.shift(),n.length&&c(n[0][0],n[0][1])}}function Nt(i){var t,e;return t={},r("next"),r("throw",function(s){throw s}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(s,n){t[s]=i[s]?function(a){return(e=!e)?{value:k(i[s](a)),done:!1}:n?n(a):a}:n}}function Ht(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=i[Symbol.asyncIterator],e;return t?t.call(i):(i=typeof M=="function"?M(i):i[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(n){e[n]=i[n]&&function(a){return new Promise(function(o,c){a=i[n](a),s(o,c,a.done,a.value)})}}function s(n,a,o,c){Promise.resolve(c).then(function(l){n({value:l,done:o})},a)}}function Wt(i,t){return Object.defineProperty?Object.defineProperty(i,"raw",{value:t}):i.raw=t,i}function qt(i){if(i&&i.__esModule)return i;var t={};if(i!=null)for(var e=V(i),r=0;r<e.length;r++)e[r]!=="default"&&B(t,i,e[r]);return fe(t,i),t}function Gt(i){return i&&i.__esModule?i:{default:i}}function Mt(i,t,e,r){if(e==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?r:e==="a"?r.call(i):r?r.value:t.get(i)}function Bt(i,t,e,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!s:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(i,e):s?s.value=e:t.set(i,e),e}function Dt(i,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof i=="function"?t===i:i.has(t)}function Ft(i,t,e){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var r,s;if(e){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=t[Symbol.dispose],e&&(s=r)}if(typeof r!="function")throw new TypeError("Object not disposable.");s&&(r=function(){try{s.call(this)}catch(n){return Promise.reject(n)}}),i.stack.push({value:t,dispose:r,async:e})}else e&&i.stack.push({async:!0});return t}function Jt(i){function t(n){i.error=i.hasError?new ge(n,i.error,"An error was suppressed during disposal."):n,i.hasError=!0}var e,r=0;function s(){for(;e=i.stack.pop();)try{if(!e.async&&r===1)return r=0,i.stack.push(e),Promise.resolve().then(s);if(e.dispose){var n=e.dispose.call(e.value);if(e.async)return r|=2,Promise.resolve(n).then(s,function(a){return t(a),s()})}else r|=1}catch(a){t(a)}if(r===1)return i.hasError?Promise.reject(i.error):Promise.resolve();if(i.hasError)throw i.error}return s()}function zt(i,t){return typeof i=="string"&&/^\.\.?\//.test(i)?i.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,r,s,n,a){return r?t?".jsx":".js":s&&(!n||!a)?e:s+n+"."+a.toLowerCase()+"js"}):i}var Y,G,B,fe,V,ge,me,R=mt(()=>{"use strict";u();Y=function(i,t){return Y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])},Y(i,t)};G=function(){return G=Object.assign||function(t){for(var e,r=1,s=arguments.length;r<s;r++){e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},G.apply(this,arguments)};B=Object.create?(function(i,t,e,r){r===void 0&&(r=e);var s=Object.getOwnPropertyDescriptor(t,e);(!s||("get"in s?!t.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(i,r,s)}):(function(i,t,e,r){r===void 0&&(r=e),i[r]=t[e]});fe=Object.create?(function(i,t){Object.defineProperty(i,"default",{enumerable:!0,value:t})}):function(i,t){i.default=t},V=function(i){return V=Object.getOwnPropertyNames||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[e.length]=r);return e},V(i)};ge=typeof SuppressedError=="function"?SuppressedError:function(i,t,e){var r=new Error(e);return r.name="SuppressedError",r.error=i,r.suppressed=t,r};me={__extends:Pt,__assign:G,__rest:_t,__decorate:Ot,__param:xt,__esDecorate:Et,__runInitializers:St,__propKey:Tt,__setFunctionName:Rt,__metadata:Lt,__awaiter:At,__generator:kt,__createBinding:B,__exportStar:$t,__values:M,__read:Q,__spread:Ut,__spreadArrays:It,__spreadArray:Ct,__await:k,__asyncGenerator:jt,__asyncDelegator:Nt,__asyncValues:Ht,__makeTemplateObject:Wt,__importStar:qt,__importDefault:Gt,__classPrivateFieldGet:Mt,__classPrivateFieldSet:Bt,__classPrivateFieldIn:Dt,__addDisposableResource:Ft,__disposeResources:Jt,__rewriteRelativeImportExtension:zt}});var tt=E(Z=>{"use strict";u();Object.defineProperty(Z,"__esModule",{value:!0});var X=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.code=t.code}};Z.default=X});var st=E(rt=>{"use strict";u();Object.defineProperty(rt,"__esModule",{value:!0});var ye=(R(),S(T)),we=ye.__importDefault(tt()),et=class{constructor(t){var e,r;this.shouldThrowOnError=!1,this.method=t.method,this.url=t.url,this.headers=new Headers(t.headers),this.schema=t.schema,this.body=t.body,this.shouldThrowOnError=(e=t.shouldThrowOnError)!==null&&e!==void 0?e:!1,this.signal=t.signal,this.isMaybeSingle=(r=t.isMaybeSingle)!==null&&r!==void 0?r:!1,t.fetch?this.fetch=t.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,e){return this.headers=new Headers(this.headers),this.headers.set(t,e),this}then(t,e){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 r=this.fetch,s=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async n=>{var a,o,c,l;let h=null,p=null,g=null,d=n.status,y=n.statusText;if(n.ok){if(this.method!=="HEAD"){let H=await n.text();H===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((a=this.headers.get("Accept"))===null||a===void 0)&&a.includes("application/vnd.pgrst.plan+text"))?p=H:p=JSON.parse(H))}let w=(o=this.headers.get("Prefer"))===null||o===void 0?void 0:o.match(/count=(exact|planned|estimated)/),O=(c=n.headers.get("content-range"))===null||c===void 0?void 0:c.split("/");w&&O&&O.length>1&&(g=parseInt(O[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(p)&&(p.length>1?(h={code:"PGRST116",details:`Results contain ${p.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},p=null,g=null,d=406,y="Not Acceptable"):p.length===1?p=p[0]:p=null)}else{let w=await n.text();try{h=JSON.parse(w),Array.isArray(h)&&n.status===404&&(p=[],h=null,d=200,y="OK")}catch{n.status===404&&w===""?(d=204,y="No Content"):h={message:w}}if(h&&this.isMaybeSingle&&(!((l=h?.details)===null||l===void 0)&&l.includes("0 rows"))&&(h=null,d=200,y="OK"),h&&this.shouldThrowOnError)throw new we.default(h)}return{error:h,data:p,count:g,status:d,statusText:y}});return this.shouldThrowOnError||(s=s.catch(n=>{var a,o,c;return{error:{message:`${(a=n?.name)!==null&&a!==void 0?a:"FetchError"}: ${n?.message}`,details:`${(o=n?.stack)!==null&&o!==void 0?o:""}`,hint:"",code:`${(c=n?.code)!==null&&c!==void 0?c:""}`},data:null,count:null,status:0,statusText:""}})),s.then(t,e)}returns(){return this}overrideTypes(){return this}};rt.default=et});var at=E(it=>{"use strict";u();Object.defineProperty(it,"__esModule",{value:!0});var be=(R(),S(T)),ve=be.__importDefault(st()),nt=class extends ve.default{select(t){let e=!1,r=(t??"*").split("").map(s=>/\s/.test(s)&&!e?"":(s==='"'&&(e=!e),s)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:e=!0,nullsFirst:r,foreignTable:s,referencedTable:n=s}={}){let a=n?`${n}.order`:"order",o=this.url.searchParams.get(a);return this.url.searchParams.set(a,`${o?`${o},`:""}${t}.${e?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:e,referencedTable:r=e}={}){let s=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${t}`),this}range(t,e,{foreignTable:r,referencedTable:s=r}={}){let n=typeof s>"u"?"offset":`${s}.offset`,a=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(n,`${t}`),this.url.searchParams.set(a,`${e-t+1}`),this}abortSignal(t){return this.signal=t,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:t=!1,verbose:e=!1,settings:r=!1,buffers:s=!1,wal:n=!1,format:a="text"}={}){var o;let c=[t?"analyze":null,e?"verbose":null,r?"settings":null,s?"buffers":null,n?"wal":null].filter(Boolean).join("|"),l=(o=this.headers.get("Accept"))!==null&&o!==void 0?o:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${a}; for="${l}"; options=${c};`),a==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(t){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${t}`),this}};it.default=nt});var D=E(lt=>{"use strict";u();Object.defineProperty(lt,"__esModule",{value:!0});var Pe=(R(),S(T)),_e=Pe.__importDefault(at()),Oe=new RegExp("[,()]"),ot=class extends _e.default{eq(t,e){return this.url.searchParams.append(t,`eq.${e}`),this}neq(t,e){return this.url.searchParams.append(t,`neq.${e}`),this}gt(t,e){return this.url.searchParams.append(t,`gt.${e}`),this}gte(t,e){return this.url.searchParams.append(t,`gte.${e}`),this}lt(t,e){return this.url.searchParams.append(t,`lt.${e}`),this}lte(t,e){return this.url.searchParams.append(t,`lte.${e}`),this}like(t,e){return this.url.searchParams.append(t,`like.${e}`),this}likeAllOf(t,e){return this.url.searchParams.append(t,`like(all).{${e.join(",")}}`),this}likeAnyOf(t,e){return this.url.searchParams.append(t,`like(any).{${e.join(",")}}`),this}ilike(t,e){return this.url.searchParams.append(t,`ilike.${e}`),this}ilikeAllOf(t,e){return this.url.searchParams.append(t,`ilike(all).{${e.join(",")}}`),this}ilikeAnyOf(t,e){return this.url.searchParams.append(t,`ilike(any).{${e.join(",")}}`),this}is(t,e){return this.url.searchParams.append(t,`is.${e}`),this}in(t,e){let r=Array.from(new Set(e)).map(s=>typeof s=="string"&&Oe.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(t,`in.(${r})`),this}contains(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cs.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cs.{${e.join(",")}}`):this.url.searchParams.append(t,`cs.${JSON.stringify(e)}`),this}containedBy(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cd.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cd.{${e.join(",")}}`):this.url.searchParams.append(t,`cd.${JSON.stringify(e)}`),this}rangeGt(t,e){return this.url.searchParams.append(t,`sr.${e}`),this}rangeGte(t,e){return this.url.searchParams.append(t,`nxl.${e}`),this}rangeLt(t,e){return this.url.searchParams.append(t,`sl.${e}`),this}rangeLte(t,e){return this.url.searchParams.append(t,`nxr.${e}`),this}rangeAdjacent(t,e){return this.url.searchParams.append(t,`adj.${e}`),this}overlaps(t,e){return typeof e=="string"?this.url.searchParams.append(t,`ov.${e}`):this.url.searchParams.append(t,`ov.{${e.join(",")}}`),this}textSearch(t,e,{config:r,type:s}={}){let n="";s==="plain"?n="pl":s==="phrase"?n="ph":s==="websearch"&&(n="w");let a=r===void 0?"":`(${r})`;return this.url.searchParams.append(t,`${n}fts${a}.${e}`),this}match(t){return Object.entries(t).forEach(([e,r])=>{this.url.searchParams.append(e,`eq.${r}`)}),this}not(t,e,r){return this.url.searchParams.append(t,`not.${e}.${r}`),this}or(t,{foreignTable:e,referencedTable:r=e}={}){let s=r?`${r}.or`:"or";return this.url.searchParams.append(s,`(${t})`),this}filter(t,e,r){return this.url.searchParams.append(t,`${e}.${r}`),this}};lt.default=ot});var ht=E(ct=>{"use strict";u();Object.defineProperty(ct,"__esModule",{value:!0});var xe=(R(),S(T)),N=xe.__importDefault(D()),ut=class{constructor(t,{headers:e={},schema:r,fetch:s}){this.url=t,this.headers=new Headers(e),this.schema=r,this.fetch=s}select(t,e){let{head:r=!1,count:s}=e??{},n=r?"HEAD":"GET",a=!1,o=(t??"*").split("").map(c=>/\s/.test(c)&&!a?"":(c==='"'&&(a=!a),c)).join("");return this.url.searchParams.set("select",o),s&&this.headers.append("Prefer",`count=${s}`),new N.default({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(t,{count:e,defaultToNull:r=!0}={}){var s;let n="POST";if(e&&this.headers.append("Prefer",`count=${e}`),r||this.headers.append("Prefer","missing=default"),Array.isArray(t)){let a=t.reduce((o,c)=>o.concat(Object.keys(c)),[]);if(a.length>0){let o=[...new Set(a)].map(c=>`"${c}"`);this.url.searchParams.set("columns",o.join(","))}}return new N.default({method:n,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}upsert(t,{onConflict:e,ignoreDuplicates:r=!1,count:s,defaultToNull:n=!0}={}){var a;let o="POST";if(this.headers.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),e!==void 0&&this.url.searchParams.set("on_conflict",e),s&&this.headers.append("Prefer",`count=${s}`),n||this.headers.append("Prefer","missing=default"),Array.isArray(t)){let c=t.reduce((l,h)=>l.concat(Object.keys(h)),[]);if(c.length>0){let l=[...new Set(c)].map(h=>`"${h}"`);this.url.searchParams.set("columns",l.join(","))}}return new N.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}update(t,{count:e}={}){var r;let s="PATCH";return e&&this.headers.append("Prefer",`count=${e}`),new N.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch})}delete({count:t}={}){var e;let r="DELETE";return t&&this.headers.append("Prefer",`count=${t}`),new N.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch})}};ct.default=ut});var Yt=E(dt=>{"use strict";u();Object.defineProperty(dt,"__esModule",{value:!0});var Kt=(R(),S(T)),Ee=Kt.__importDefault(ht()),Se=Kt.__importDefault(D()),pt=class i{constructor(t,{headers:e={},schema:r,fetch:s}={}){this.url=t,this.headers=new Headers(e),this.schemaName=r,this.fetch=s}from(t){let e=new URL(`${this.url}/${t}`);return new Ee.default(e,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(t){return new i(this.url,{headers:this.headers,schema:t,fetch:this.fetch})}rpc(t,e={},{head:r=!1,get:s=!1,count:n}={}){var a;let o,c=new URL(`${this.url}/rpc/${t}`),l;r||s?(o=r?"HEAD":"GET",Object.entries(e).filter(([p,g])=>g!==void 0).map(([p,g])=>[p,Array.isArray(g)?`{${g.join(",")}}`:`${g}`]).forEach(([p,g])=>{c.searchParams.append(p,g)})):(o="POST",l=e);let h=new Headers(this.headers);return n&&h.set("Prefer",`count=${n}`),new Se.default({method:o,url:c,headers:h,schema:this.schemaName,body:l,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}};dt.default=pt});var re=E(v=>{"use strict";u();Object.defineProperty(v,"__esModule",{value:!0});v.PostgrestError=v.PostgrestBuilder=v.PostgrestTransformBuilder=v.PostgrestFilterBuilder=v.PostgrestQueryBuilder=v.PostgrestClient=void 0;var $=(R(),S(T)),Vt=$.__importDefault(Yt());v.PostgrestClient=Vt.default;var Qt=$.__importDefault(ht());v.PostgrestQueryBuilder=Qt.default;var Xt=$.__importDefault(D());v.PostgrestFilterBuilder=Xt.default;var Zt=$.__importDefault(at());v.PostgrestTransformBuilder=Zt.default;var te=$.__importDefault(st());v.PostgrestBuilder=te.default;var ee=$.__importDefault(tt());v.PostgrestError=ee.default;v.default={PostgrestClient:Vt.default,PostgrestQueryBuilder:Qt.default,PostgrestFilterBuilder:Xt.default,PostgrestTransformBuilder:Zt.default,PostgrestBuilder:te.default,PostgrestError:ee.default}});var ke={};yt(ke,{AbortController:()=>j,AbortSignal:()=>A,AuthClient:()=>q,CURRENT_JWT_KEY:()=>f,ENTITIES_BASE_PATH:()=>ne,FILE_STORAGE_BASE_PATH:()=>bt,GENERATE_UPLOAD_URL_PATH:()=>vt,Headers:()=>b,LOGIN_TOKEN_KEY:()=>_,LOGIN_USER_PROFILE_KEY:()=>x,NvwaEdgeFunctions:()=>F,NvwaFileStorage:()=>K,NvwaHttpClient:()=>z,OverlayManager:()=>gt,Request:()=>I,Response:()=>C,SET_AUTH_TOKEN_HEADER:()=>J,URL:()=>U,URLSearchParams:()=>L,createPostgrestClient:()=>Te,getSourceLocationFromDOM:()=>Re,normalizePayParams:()=>Le,polyfill:()=>de,requestPaymentFromOrderResult:()=>Ae});module.exports=S(ke);u();u();var F=class{constructor(t,e=""){this.http=t,this.baseUrl=e.replace(/\/$/,"")}async invoke(t,e){let r=this.baseUrl?`${this.baseUrl}/functions/${t}`:`/functions/${t}`;return await(await this.http.fetch(r,{method:e.method||"POST",body:e.body,headers:e.headers})).json()}};u();u();var f="nvwa_current_jwt",_="nvwa_login_token",x="nvwa_user_profile",J="set-auth-token",he=typeof fetch<"u"?(i,t)=>fetch(i,t):()=>{throw new Error("AuthClient requires fetch")},q=class{constructor(t,e={}){this.baseUrl=t.replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??he,this.storage=e.storage??null,this.credentials=e.credentials??"omit",typeof console<"u"&&(console.warn("[NvwaAuth] init baseUrl:",this.baseUrl||"(empty)"),(!this.baseUrl||!this.baseUrl.startsWith("http://")&&!this.baseUrl.startsWith("https://"))&&console.warn("[NvwaAuth] baseUrl \u5E94\u4E3A\u5B8C\u6574\u5730\u5740\uFF08\u5982 https://xxx.nvwa.app\uFF09\uFF0C\u5426\u5219\u5C0F\u7A0B\u5E8F request \u4F1A\u62A5 invalid url"))}async currentUser(){if(this.storage){let r=await this.storage.get(x);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(x,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(f);if(e!=null)return e;let r=await this.storage.get(_),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(f,s.token),s.token):null}let{data:t}=await this.getToken();return t?.token??null}async persistLogin(t,e){if(!this.storage)return;let s=e?.headers.get(J)?.trim()||t.token||t.session?.token;s&&await this.storage.set(_,s),t.user&&await this.storage.set(x,t.user);let n=s??await this.storage.get(_),{data:a}=await this.getToken(n??void 0);a?.token&&await this.storage.set(f,a.token)}async clearLogin(){this.storage&&(await this.storage.remove(_),await this.storage.remove(x),await this.storage.remove(f))}getGoogleOpenPlatformLoginUrl(t){let e=new URLSearchParams({return_url:t});return`${this.url("google/openplatform/login")}?${e.toString()}`}startGoogleOpenPlatformLogin(t){let e=this.getGoogleOpenPlatformLoginUrl(t);if(typeof globalThis<"u"&&"location"in globalThis){globalThis.location.href=e;return}throw new Error("startGoogleOpenPlatformLogin requires a browser environment with location")}async completeGoogleOpenPlatformLoginFromCurrentUrl(t){let e;if(t!=null&&t!=="")e=t;else if(typeof globalThis<"u"&&"location"in globalThis)e=globalThis.location.href;else return{error:{message:"completeGoogleOpenPlatformLoginFromCurrentUrl requires url or browser location",status:0}};let r;try{r=new URL(e).searchParams.get("exchange_code")}catch{return{error:{message:"invalid_callback_url",status:400}}}return r?.trim()?await this.loginWithGoogleExchangeCode(r.trim()):{error:{message:"missing_exchange_code",status:400}}}async loginWithGoogleExchangeCode(t){try{let e={"Content-Type":"application/json"};if(this.storage){let a=await this.storage.get(f);a!=null&&(e.Authorization=`Bearer ${a}`)}let r=await this.fetchImpl(this.url("google/openplatform/sign-in"),{method:"POST",headers:e,credentials:this.credentials,body:JSON.stringify({exchangeCode:t})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let n=s?JSON.parse(s):null;return!n?.token||!n.user?{error:{message:"invalid_google_login_response",status:502}}:(this.storage&&(await this.storage.set(f,n.token),await this.storage.set(_,n.token),await this.storage.set(x,n.user)),{data:n})}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getGoogleOpenPlatformIdentity(){try{let t={};if(this.storage){let n=await this.storage.get(f);n!=null&&(t.Authorization=`Bearer ${n}`)}let e=await this.fetchImpl(this.url("google/openplatform/identity"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}}),r=await e.text();if(!e.ok)return{error:{message:r||e.statusText,status:e.status}};let s=r?JSON.parse(r):null;return s?.sub?{data:s}:{error:{message:"invalid_google_identity_response",status:502}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}getGithubOpenPlatformLoginUrl(t){let e=new URLSearchParams({return_url:t});return`${this.url("github/openplatform/login")}?${e.toString()}`}startGithubOpenPlatformLogin(t){let e=this.getGithubOpenPlatformLoginUrl(t);if(typeof globalThis<"u"&&"location"in globalThis){globalThis.location.href=e;return}throw new Error("startGithubOpenPlatformLogin requires a browser environment with location")}async completeGithubOpenPlatformLoginFromCurrentUrl(t){let e;if(t!=null&&t!=="")e=t;else if(typeof globalThis<"u"&&"location"in globalThis)e=globalThis.location.href;else return{error:{message:"completeGithubOpenPlatformLoginFromCurrentUrl requires url or browser location",status:0}};let r;try{r=new URL(e).searchParams.get("exchange_code")}catch{return{error:{message:"invalid_callback_url",status:400}}}return r?.trim()?await this.loginWithGithubExchangeCode(r.trim()):{error:{message:"missing_exchange_code",status:400}}}async loginWithGithubExchangeCode(t){try{let e={"Content-Type":"application/json"};if(this.storage){let a=await this.storage.get(f);a!=null&&(e.Authorization=`Bearer ${a}`)}let r=await this.fetchImpl(this.url("github/openplatform/sign-in"),{method:"POST",headers:e,credentials:this.credentials,body:JSON.stringify({exchangeCode:t})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let n=s?JSON.parse(s):null;return!n?.token||!n.user?{error:{message:"invalid_github_login_response",status:502}}:(this.storage&&(await this.storage.set(f,n.token),await this.storage.set(_,n.token),await this.storage.set(x,n.user)),{data:n})}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getGithubOpenPlatformIdentity(){try{let t={};if(this.storage){let n=await this.storage.get(f);n!=null&&(t.Authorization=`Bearer ${n}`)}let e=await this.fetchImpl(this.url("github/openplatform/identity"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}}),r=await e.text();if(!e.ok)return{error:{message:r||e.statusText,status:e.status}};let s=r?JSON.parse(r):null;return s?.sub?{data:s}:{error:{message:"invalid_github_identity_response",status:502}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}getWechatWebsiteOpenPlatformLoginUrl(t){let e=new URLSearchParams({return_url:t});return`${this.url("wechat-website/openplatform/login")}?${e.toString()}`}startWechatWebsiteOpenPlatformLogin(t){let e=this.getWechatWebsiteOpenPlatformLoginUrl(t);if(typeof globalThis<"u"&&"location"in globalThis){globalThis.location.href=e;return}throw new Error("startWechatWebsiteOpenPlatformLogin requires a browser environment with location")}async completeWechatWebsiteOpenPlatformLoginFromCurrentUrl(t){let e;if(t!=null&&t!=="")e=t;else if(typeof globalThis<"u"&&"location"in globalThis)e=globalThis.location.href;else return{error:{message:"completeWechatWebsiteOpenPlatformLoginFromCurrentUrl requires url or browser location",status:0}};let r;try{r=new URL(e).searchParams.get("exchange_code")}catch{return{error:{message:"invalid_callback_url",status:400}}}return r?.trim()?await this.loginWithWechatWebsiteExchangeCode(r.trim()):{error:{message:"missing_exchange_code",status:400}}}async loginWithWechatWebsiteExchangeCode(t){try{let e={"Content-Type":"application/json"};if(this.storage){let a=await this.storage.get(f);a!=null&&(e.Authorization=`Bearer ${a}`)}let r=await this.fetchImpl(this.url("wechat-website/openplatform/sign-in"),{method:"POST",headers:e,credentials:this.credentials,body:JSON.stringify({exchangeCode:t})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let n=s?JSON.parse(s):null;return!n?.token||!n.user?{error:{message:"invalid_wechat_website_login_response",status:502}}:(this.storage&&(await this.storage.set(f,n.token),await this.storage.set(_,n.token),await this.storage.set(x,n.user)),{data:n})}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getWechatWebsiteOpenPlatformIdentity(){try{let t={};if(this.storage){let n=await this.storage.get(f);n!=null&&(t.Authorization=`Bearer ${n}`)}let e=await this.fetchImpl(this.url("wechat-website/openplatform/identity"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}}),r=await e.text();if(!e.ok)return{error:{message:r||e.statusText,status:e.status}};let s=r?JSON.parse(r):null;return s?.sub?{data:s}:{error:{message:"invalid_wechat_website_identity_response",status:502}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}url(t){let r=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${t.replace(/^\/+/,"")}`;return typeof console<"u"&&(console.warn("[NvwaAuth] request URL:",r),!r.startsWith("http://")&&!r.startsWith("https://")&&console.warn("[NvwaAuth] URL \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F\u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 Nvwa \u6784\u9020\u65F6\u4F20\u5165\u7684 baseUrl")),r}async getSession(){try{let t={};if(this.storage){let s=await this.storage.get(_)??await this.storage.get(f);s!=null&&(t.Authorization=`Bearer ${s}`)}let e=await this.fetchImpl(this.url("session"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return e.ok?{data:await e.json()}:{data:null,error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{data:null,error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signInWithEmail(t,e){try{let r=await this.fetchImpl(this.url("sign-in/email"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify({email:t,password:e})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let n=s?JSON.parse(s):void 0;return n&&await this.persistLogin({user:n.user,session:n.session},r),{data:n}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let t={};if(this.storage){let r=await this.storage.get(_)??await this.storage.get(f);r!=null&&(t.Authorization=`Bearer ${r}`)}let e=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return await this.clearLogin(),e.ok?{}:{error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signUp(t){let e=await this.postJson("sign-up/email",t);return e.data&&await this.persistLogin(e.data,e.response),e}async getToken(t){try{let e={};if(t)e.Authorization=`Bearer ${t}`;else if(this.storage){let a=await this.storage.get(_)??await this.storage.get(f);a!=null&&(e.Authorization=`Bearer ${a}`)}let r=await this.fetchImpl(this.url("token"),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let n=s?JSON.parse(s):void 0;return{data:n?.token!=null?{token:n.token}:void 0}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithUsername(t,e){let r=await this.postJson("sign-in/username",{username:t,password:e});return r.data&&await this.persistLogin(r.data,r.response),r}async signInWithPhoneNumber(t,e,r){let s=await this.postJson("sign-in/phone-number",{phoneNumber:t,password:e,rememberMe:r});return s.data&&await this.persistLogin(s.data,s.response),s}async sendPhoneNumberOtp(t){let e=await this.postJson("phone-number/send-otp",{phoneNumber:t});return e.error?{error:e.error}:{}}async verifyPhoneNumber(t,e){let r=await this.postJson("phone-number/verify",{phoneNumber:t,code:e});return r.data&&await this.persistLogin(r.data,r.response),r}async loginWithWeChatCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(f);o!=null&&(r.Authorization=`Bearer ${o}`)}let s=await this.fetchImpl(this.url("wechat/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let a=n?JSON.parse(n):null;return!a?.token||!a.user?{error:{message:"invalid_wechat_login_response",status:502}}:(this.storage&&(await this.storage.set(f,a.token),await this.storage.set(_,a.token),await this.storage.set(x,a.user)),{data:a})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async loginWithAlipayCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(f);o!=null&&(r.Authorization=`Bearer ${o}`)}let s=await this.fetchImpl(this.url("alipay/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let a=n?JSON.parse(n):null;return!a?.token||!a.user?{error:{message:"invalid_alipay_login_response",status:502}}:(this.storage&&(await this.storage.set(f,a.token),await this.storage.set(_,a.token),await this.storage.set(x,a.user)),{data:a})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async getWeChatOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(f);o!=null&&(e.Authorization=`Bearer ${o}`)}let r=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",s=await this.fetchImpl(this.url(`wechat/openplatform/identity${r}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let a=n?JSON.parse(n):null;return!a?.openid||!a.appId?{error:{message:"invalid_wechat_identity_response",status:502}}:{data:a}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getAlipayOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(f);o!=null&&(e.Authorization=`Bearer ${o}`)}let r=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",s=await this.fetchImpl(this.url(`alipay/openplatform/identity${r}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let a=n?JSON.parse(n):null;return!a?.openid||!a.appId?{error:{message:"invalid_alipay_identity_response",status:502}}:{data:a}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async postJson(t,e){try{let r=await this.fetchImpl(this.url(t),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify(e)}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let n=s?JSON.parse(s):void 0;return{data:n?.data??n??void 0,response:r}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}};u();u();var b=class i{constructor(t){this.headerMap=new Map;if(t){if(t instanceof i)t.forEach((e,r)=>this.set(r,e));else if(Array.isArray(t))for(let[e,r]of t)this.set(e,String(r));else if(typeof t=="object")for(let e of Object.keys(t))this.set(e,String(t[e]))}}append(t,e){let r=t.toLowerCase(),s=this.headerMap.get(r);this.headerMap.set(r,s?`${s}, ${e}`:e)}set(t,e){this.headerMap.set(t.toLowerCase(),String(e))}get(t){let e=this.headerMap.get(t.toLowerCase());return e??null}has(t){return this.headerMap.has(t.toLowerCase())}delete(t){this.headerMap.delete(t.toLowerCase())}forEach(t){for(let[e,r]of this.headerMap.entries())t(r,e,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},L=class i{constructor(t){this.params=new Map;if(t){if(typeof t=="string")this.parseString(t);else if(t instanceof i)this.params=new Map(t.params);else if(Array.isArray(t))for(let[e,r]of t)this.append(e,r);else if(t&&typeof t=="object")for(let[e,r]of Object.entries(t))this.set(e,r)}}parseString(t){t.startsWith("?")&&(t=t.slice(1));let e=t.split("&");for(let r of e)if(r){let[s,n]=r.split("=");s&&this.append(decodeURIComponent(s),n?decodeURIComponent(n):"")}}append(t,e){let r=this.params.get(t)||[];r.push(e),this.params.set(t,r)}delete(t){this.params.delete(t)}get(t){let e=this.params.get(t);return e?e[0]:null}getAll(t){return this.params.get(t)||[]}has(t){return this.params.has(t)}set(t,e){this.params.set(t,[e])}sort(){let t=Array.from(this.params.entries()).sort(([e],[r])=>e.localeCompare(r));this.params=new Map(t)}toString(){let t=[];for(let[e,r]of this.params.entries())for(let s of r)t.push(`${encodeURIComponent(e)}=${encodeURIComponent(s)}`);return t.join("&")}forEach(t){for(let[e,r]of this.params.entries())for(let s of r)t(s,e,this)}keys(){return this.params.keys()}values(){let t=[];for(let e of this.params.values())t.push(...e);return t[Symbol.iterator]()}entries(){let t=[];for(let[e,r]of this.params.entries())for(let s of r)t.push([e,s]);return t[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},U=class i{constructor(t,e){let r;if(t instanceof i)r=t.href;else if(e){let n=e instanceof i?e.href:e;r=this.resolve(n,t)}else r=t;let s=this.parseUrl(r);this.href=r,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 L(s.search),this.hash=s.hash}resolve(t,e){if(e.startsWith("http://")||e.startsWith("https://"))return e;if(e.startsWith("//"))return`${this.parseUrl(t).protocol}${e}`;if(e.startsWith("/")){let n=this.parseUrl(t);return`${n.protocol}//${n.host}${e}`}let r=this.parseUrl(t),s=r.pathname.endsWith("/")?r.pathname:r.pathname+"/";return`${r.protocol}//${r.host}${s}${e}`}parseUrl(t){let e=t.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!e)throw new TypeError("Invalid URL");let r=e[2]||"",s=e[4]||"",n=e[5]||"/",a=e[7]?`?${e[7]}`:"",o=e[9]?`#${e[9]}`:"";if(!r&&!s&&!n.startsWith("/")&&!n.includes("/")&&!n.includes("."))throw new TypeError("Invalid URL");let c=s.match(/^([^@]*)@(.+)$/),l="",h="",p=s;if(c){let P=c[1];p=c[2];let w=P.match(/^([^:]*):?(.*)$/);w&&(l=w[1]||"",h=w[2]||"")}let g=p.match(/^([^:]+):?(\d*)$/),d=g?g[1]:p,y=g&&g[2]?g[2]:"";return{protocol:r?`${r}:`:"",username:l,password:h,host:p,hostname:d,port:y,pathname:n,search:a,hash:o}}toString(){let t=this.searchParams.toString(),e=t?`?${t}`:"";return`${this.protocol}//${this.host}${this.pathname}${e}${this.hash}`}toJSON(){return this.toString()}};u();var I=class i{constructor(t,e){if(typeof t=="string")this.url=t;else if(t?.url)this.url=String(t.url);else if(typeof t?.toString=="function")this.url=String(t.toString());else throw new Error("Invalid input for Request");this.method=(e?.method||"GET").toUpperCase(),this.headers=e?.headers instanceof b?e.headers:new b(e?.headers),this.body=e?.body,this.timeout=e?.timeout,this.signal=e?.signal||void 0}clone(){return new i(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};u();var C=class{constructor(t,e){this.bodyData=t,this.status=e?.status??200,this.statusText=e?.statusText??"",this.headers=pe(e?.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 t=await this.text();return new TextEncoder().encode(t).buffer}};function pe(i){return i?new b(i):new b}u();var A=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 t of Array.from(this.listeners))try{t()}catch{}this.listeners.clear()}}addEventListener(t,e){if(this._aborted){try{e()}catch{}return}this.listeners.add(e)}removeEventListener(t,e){this.listeners.delete(e)}toString(){return"[object AbortSignal]"}},j=class{constructor(){this._signal=new A}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};u();function de(i){let t=i;i===void 0&&(t=(0,eval)("this")),t.URL=U,t.URLSearchParams=L,t.Headers=b,t.Request=I,t.Response=C,t.AbortController=j,t.AbortSignal=A}var z=class{constructor(t,e,r){this.storage=t,this.customFetch=e,this.handleUnauthorized=r}async fetch(t,e){return await this.customFetch(t,e)}async fetchWithAuth(t,e){let r=await this.storage.get(f),s=new b(e?.headers);r&&s.set("Authorization",`Bearer ${r}`);let n=e?.method||"GET";if((n==="POST"||n==="PUT"||n==="PATCH")&&e?.body){let o=s.get("Content-Type");(!o||o.includes("text/plain"))&&s.set("Content-Type","application/json")}let a=await this.customFetch(t,{...e,headers:s});if(a.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return a}};u();var bt="/storage",vt=bt+"/generateUploadUrl",K=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+vt,{method:"POST",body:{fileName:t.name||t.fileName,fileSize:t.size||t.fileSize,fileType:t.type||t.fileType}}),{url:r}=await e.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:t,headers:new b({"Content-Type":t.type||t.fileType||"application/octet-stream"})}),{url:n}=await s.json();return{url:n.split("?")[0]}}};u();u();u();var ft=ce(re(),1),{PostgrestClient:se,PostgrestQueryBuilder:jr,PostgrestFilterBuilder:Nr,PostgrestTransformBuilder:Hr,PostgrestBuilder:Wr,PostgrestError:qr}=ft.default||ft;var ne="/entities",Te=(i,t)=>new se(i+ne,{fetch:t.fetchWithAuth.bind(t)});u();var gt=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 t=document.createElement("style");t.id="__nvwa-inspector-overlay-style",t.textContent=`
1
+ "use strict";var T=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var M=(r,t)=>{for(var e in t)T(r,e,{get:t[e],enumerable:!0})},D=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of J(t))!z.call(r,n)&&n!==e&&T(r,n,{get:()=>t[n],enumerable:!(s=B(t,n))||s.enumerable});return r};var Y=r=>D(T({},"__esModule",{value:!0}),r);var ot={};M(ot,{AuthClient:()=>E,CURRENT_JWT_KEY:()=>c,ENTITIES_BASE_PATH:()=>q,FILE_STORAGE_BASE_PATH:()=>$,GENERATE_UPLOAD_URL_PATH:()=>I,LOGIN_TOKEN_KEY:()=>f,LOGIN_USER_PROFILE_KEY:()=>w,NvwaEdgeFunctions:()=>S,NvwaFileStorage:()=>k,NvwaHttpClient:()=>_,OverlayManager:()=>A,SET_AUTH_TOKEN_HEADER:()=>R,createPostgrestClient:()=>rt,getSourceLocationFromDOM:()=>it,normalizePayParams:()=>nt,requestPaymentFromOrderResult:()=>at});module.exports=Y(ot);var S=class{constructor(t,e=""){this.http=t,this.baseUrl=e.replace(/\/$/,"")}async invoke(t,e){let s=this.baseUrl?`${this.baseUrl}/functions/${t}`:`/functions/${t}`;return await(await this.http.fetch(s,{method:e.method||"POST",body:e.body,headers:e.headers})).json()}};var c="nvwa_current_jwt",f="nvwa_login_token",w="nvwa_user_profile",R="set-auth-token",K=typeof fetch<"u"?(r,t)=>fetch(r,t):()=>{throw new Error("AuthClient requires fetch")},E=class{constructor(t,e={}){this.baseUrl=t.replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??K,this.storage=e.storage??null,this.credentials=e.credentials??"omit",typeof console<"u"&&(console.warn("[NvwaAuth] init baseUrl:",this.baseUrl||"(empty)"),(!this.baseUrl||!this.baseUrl.startsWith("http://")&&!this.baseUrl.startsWith("https://"))&&console.warn("[NvwaAuth] baseUrl \u5E94\u4E3A\u5B8C\u6574\u5730\u5740\uFF08\u5982 https://xxx.nvwa.app\uFF09\uFF0C\u5426\u5219\u5C0F\u7A0B\u5E8F request \u4F1A\u62A5 invalid url"))}async currentUser(){if(this.storage){let s=await this.storage.get(w);if(s!=null)return s}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(w,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(c);if(e!=null)return e;let s=await this.storage.get(f),{data:n}=await this.getToken(s??void 0);return n?.token?(await this.storage.set(c,n.token),n.token):null}let{data:t}=await this.getToken();return t?.token??null}async persistLogin(t,e){if(!this.storage)return;let n=e?.headers.get(R)?.trim()||t.token||t.session?.token;n&&await this.storage.set(f,n),t.user&&await this.storage.set(w,t.user);let i=n??await this.storage.get(f),{data:a}=await this.getToken(i??void 0);a?.token&&await this.storage.set(c,a.token)}async clearLogin(){this.storage&&(await this.storage.remove(f),await this.storage.remove(w),await this.storage.remove(c))}getGoogleOpenPlatformLoginUrl(t){let e=new URLSearchParams({return_url:t});return`${this.url("google/openplatform/login")}?${e.toString()}`}startGoogleOpenPlatformLogin(t){let e=this.getGoogleOpenPlatformLoginUrl(t);if(typeof globalThis<"u"&&"location"in globalThis){globalThis.location.href=e;return}throw new Error("startGoogleOpenPlatformLogin requires a browser environment with location")}async completeGoogleOpenPlatformLoginFromCurrentUrl(t){let e;if(t!=null&&t!=="")e=t;else if(typeof globalThis<"u"&&"location"in globalThis)e=globalThis.location.href;else return{error:{message:"completeGoogleOpenPlatformLoginFromCurrentUrl requires url or browser location",status:0}};let s;try{s=new URL(e).searchParams.get("exchange_code")}catch{return{error:{message:"invalid_callback_url",status:400}}}return s?.trim()?await this.loginWithGoogleExchangeCode(s.trim()):{error:{message:"missing_exchange_code",status:400}}}async loginWithGoogleExchangeCode(t){try{let e={"Content-Type":"application/json"};if(this.storage){let a=await this.storage.get(c);a!=null&&(e.Authorization=`Bearer ${a}`)}let s=await this.fetchImpl(this.url("google/openplatform/sign-in"),{method:"POST",headers:e,credentials:this.credentials,body:JSON.stringify({exchangeCode:t})}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let i=n?JSON.parse(n):null;return!i?.token||!i.user?{error:{message:"invalid_google_login_response",status:502}}:(this.storage&&(await this.storage.set(c,i.token),await this.storage.set(f,i.token),await this.storage.set(w,i.user)),{data:i})}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getGoogleOpenPlatformIdentity(){try{let t={};if(this.storage){let i=await this.storage.get(c);i!=null&&(t.Authorization=`Bearer ${i}`)}let e=await this.fetchImpl(this.url("google/openplatform/identity"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}}),s=await e.text();if(!e.ok)return{error:{message:s||e.statusText,status:e.status}};let n=s?JSON.parse(s):null;return n?.sub?{data:n}:{error:{message:"invalid_google_identity_response",status:502}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}getGithubOpenPlatformLoginUrl(t){let e=new URLSearchParams({return_url:t});return`${this.url("github/openplatform/login")}?${e.toString()}`}startGithubOpenPlatformLogin(t){let e=this.getGithubOpenPlatformLoginUrl(t);if(typeof globalThis<"u"&&"location"in globalThis){globalThis.location.href=e;return}throw new Error("startGithubOpenPlatformLogin requires a browser environment with location")}async completeGithubOpenPlatformLoginFromCurrentUrl(t){let e;if(t!=null&&t!=="")e=t;else if(typeof globalThis<"u"&&"location"in globalThis)e=globalThis.location.href;else return{error:{message:"completeGithubOpenPlatformLoginFromCurrentUrl requires url or browser location",status:0}};let s;try{s=new URL(e).searchParams.get("exchange_code")}catch{return{error:{message:"invalid_callback_url",status:400}}}return s?.trim()?await this.loginWithGithubExchangeCode(s.trim()):{error:{message:"missing_exchange_code",status:400}}}async loginWithGithubExchangeCode(t){try{let e={"Content-Type":"application/json"};if(this.storage){let a=await this.storage.get(c);a!=null&&(e.Authorization=`Bearer ${a}`)}let s=await this.fetchImpl(this.url("github/openplatform/sign-in"),{method:"POST",headers:e,credentials:this.credentials,body:JSON.stringify({exchangeCode:t})}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let i=n?JSON.parse(n):null;return!i?.token||!i.user?{error:{message:"invalid_github_login_response",status:502}}:(this.storage&&(await this.storage.set(c,i.token),await this.storage.set(f,i.token),await this.storage.set(w,i.user)),{data:i})}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getGithubOpenPlatformIdentity(){try{let t={};if(this.storage){let i=await this.storage.get(c);i!=null&&(t.Authorization=`Bearer ${i}`)}let e=await this.fetchImpl(this.url("github/openplatform/identity"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}}),s=await e.text();if(!e.ok)return{error:{message:s||e.statusText,status:e.status}};let n=s?JSON.parse(s):null;return n?.sub?{data:n}:{error:{message:"invalid_github_identity_response",status:502}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}getWechatWebsiteOpenPlatformLoginUrl(t){let e=new URLSearchParams({return_url:t});return`${this.url("wechat-website/openplatform/login")}?${e.toString()}`}startWechatWebsiteOpenPlatformLogin(t){let e=this.getWechatWebsiteOpenPlatformLoginUrl(t);if(typeof globalThis<"u"&&"location"in globalThis){globalThis.location.href=e;return}throw new Error("startWechatWebsiteOpenPlatformLogin requires a browser environment with location")}async completeWechatWebsiteOpenPlatformLoginFromCurrentUrl(t){let e;if(t!=null&&t!=="")e=t;else if(typeof globalThis<"u"&&"location"in globalThis)e=globalThis.location.href;else return{error:{message:"completeWechatWebsiteOpenPlatformLoginFromCurrentUrl requires url or browser location",status:0}};let s;try{s=new URL(e).searchParams.get("exchange_code")}catch{return{error:{message:"invalid_callback_url",status:400}}}return s?.trim()?await this.loginWithWechatWebsiteExchangeCode(s.trim()):{error:{message:"missing_exchange_code",status:400}}}async loginWithWechatWebsiteExchangeCode(t){try{let e={"Content-Type":"application/json"};if(this.storage){let a=await this.storage.get(c);a!=null&&(e.Authorization=`Bearer ${a}`)}let s=await this.fetchImpl(this.url("wechat-website/openplatform/sign-in"),{method:"POST",headers:e,credentials:this.credentials,body:JSON.stringify({exchangeCode:t})}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let i=n?JSON.parse(n):null;return!i?.token||!i.user?{error:{message:"invalid_wechat_website_login_response",status:502}}:(this.storage&&(await this.storage.set(c,i.token),await this.storage.set(f,i.token),await this.storage.set(w,i.user)),{data:i})}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getWechatWebsiteOpenPlatformIdentity(){try{let t={};if(this.storage){let i=await this.storage.get(c);i!=null&&(t.Authorization=`Bearer ${i}`)}let e=await this.fetchImpl(this.url("wechat-website/openplatform/identity"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}}),s=await e.text();if(!e.ok)return{error:{message:s||e.statusText,status:e.status}};let n=s?JSON.parse(s):null;return n?.sub?{data:n}:{error:{message:"invalid_wechat_website_identity_response",status:502}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}url(t){let s=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${t.replace(/^\/+/,"")}`;return typeof console<"u"&&(console.warn("[NvwaAuth] request URL:",s),!s.startsWith("http://")&&!s.startsWith("https://")&&console.warn("[NvwaAuth] URL \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F\u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 Nvwa \u6784\u9020\u65F6\u4F20\u5165\u7684 baseUrl")),s}async getSession(){try{let t={};if(this.storage){let n=await this.storage.get(f)??await this.storage.get(c);n!=null&&(t.Authorization=`Bearer ${n}`)}let e=await this.fetchImpl(this.url("session"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return e.ok?{data:await e.json()}:{data:null,error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{data:null,error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signInWithEmail(t,e){try{let s=await this.fetchImpl(this.url("sign-in/email"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify({email:t,password:e})}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let i=n?JSON.parse(n):void 0;return i&&await this.persistLogin({user:i.user,session:i.session},s),{data:i}}catch(s){return{error:{message:s instanceof Error?s.message:String(s),status:0}}}}async signOut(){try{let t={};if(this.storage){let s=await this.storage.get(f)??await this.storage.get(c);s!=null&&(t.Authorization=`Bearer ${s}`)}let e=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return await this.clearLogin(),e.ok?{}:{error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signUp(t){let e=await this.postJson("sign-up/email",t);return e.data&&await this.persistLogin(e.data,e.response),e}async getToken(t){try{let e={};if(t)e.Authorization=`Bearer ${t}`;else if(this.storage){let a=await this.storage.get(f)??await this.storage.get(c);a!=null&&(e.Authorization=`Bearer ${a}`)}let s=await this.fetchImpl(this.url("token"),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let i=n?JSON.parse(n):void 0;return{data:i?.token!=null?{token:i.token}:void 0}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithUsername(t,e){let s=await this.postJson("sign-in/username",{username:t,password:e});return s.data&&await this.persistLogin(s.data,s.response),s}async signInWithPhoneNumber(t,e,s){let n=await this.postJson("sign-in/phone-number",{phoneNumber:t,password:e,rememberMe:s});return n.data&&await this.persistLogin(n.data,n.response),n}async sendPhoneNumberOtp(t){let e=await this.postJson("phone-number/send-otp",{phoneNumber:t});return e.error?{error:e.error}:{}}async verifyPhoneNumber(t,e){let s=await this.postJson("phone-number/verify",{phoneNumber:t,code:e});return s.data&&await this.persistLogin(s.data,s.response),s}async loginWithWeChatCode(t,e){try{let s={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(c);o!=null&&(s.Authorization=`Bearer ${o}`)}let n=await this.fetchImpl(this.url("wechat/openplatform/sign-in"),{method:"POST",headers:s,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),i=await n.text();if(!n.ok)return{error:{message:i||n.statusText,status:n.status}};let a=i?JSON.parse(i):null;return!a?.token||!a.user?{error:{message:"invalid_wechat_login_response",status:502}}:(this.storage&&(await this.storage.set(c,a.token),await this.storage.set(f,a.token),await this.storage.set(w,a.user)),{data:a})}catch(s){return{error:{message:s instanceof Error?s.message:String(s),status:0}}}}async loginWithAlipayCode(t,e){try{let s={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(c);o!=null&&(s.Authorization=`Bearer ${o}`)}let n=await this.fetchImpl(this.url("alipay/openplatform/sign-in"),{method:"POST",headers:s,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),i=await n.text();if(!n.ok)return{error:{message:i||n.statusText,status:n.status}};let a=i?JSON.parse(i):null;return!a?.token||!a.user?{error:{message:"invalid_alipay_login_response",status:502}}:(this.storage&&(await this.storage.set(c,a.token),await this.storage.set(f,a.token),await this.storage.set(w,a.user)),{data:a})}catch(s){return{error:{message:s instanceof Error?s.message:String(s),status:0}}}}async getWeChatOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(c);o!=null&&(e.Authorization=`Bearer ${o}`)}let s=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",n=await this.fetchImpl(this.url(`wechat/openplatform/identity${s}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),i=await n.text();if(!n.ok)return{error:{message:i||n.statusText,status:n.status}};let a=i?JSON.parse(i):null;return!a?.openid||!a.appId?{error:{message:"invalid_wechat_identity_response",status:502}}:{data:a}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getAlipayOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(c);o!=null&&(e.Authorization=`Bearer ${o}`)}let s=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",n=await this.fetchImpl(this.url(`alipay/openplatform/identity${s}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),i=await n.text();if(!n.ok)return{error:{message:i||n.statusText,status:n.status}};let a=i?JSON.parse(i):null;return!a?.openid||!a.appId?{error:{message:"invalid_alipay_identity_response",status:502}}:{data:a}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async postJson(t,e){try{let s=await this.fetchImpl(this.url(t),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify(e)}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let i=n?JSON.parse(n):void 0;return{data:i?.data??i??void 0,response:s}}catch(s){return{error:{message:s instanceof Error?s.message:String(s),status:0}}}}};var U=require("@nvwa-app/nvwa-http-polyfill"),_=class{constructor(t,e,s){this.storage=t,this.customFetch=e,this.handleUnauthorized=s}async fetch(t,e){return await this.customFetch(t,e)}async fetchWithAuth(t,e){let s=await this.storage.get(c),n=new U.Headers(e?.headers);s&&n.set("Authorization",`Bearer ${s}`);let i=e?.method||"GET";if((i==="POST"||i==="PUT"||i==="PATCH")&&e?.body){let o=n.get("Content-Type");(!o||o.includes("text/plain"))&&n.set("Content-Type","application/json")}let a=await this.customFetch(t,{...e,headers:n});if(a.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return a}};var N=require("@nvwa-app/nvwa-http-polyfill"),$="/storage",I=$+"/generateUploadUrl",k=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+I,{method:"POST",body:{fileName:t.name||t.fileName,fileSize:t.size||t.fileSize,fileType:t.type||t.fileType}}),{url:s}=await e.json();if(!s)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let n=await this.http.fetch(s,{method:"PUT",body:t,headers:new N.Headers({"Content-Type":t.type||t.fileType||"application/octet-stream"})}),{url:i}=await n.json();return{url:i.split("?")[0]}}};var y=require("@nvwa-app/nvwa-http-polyfill"),V=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}},X=class{constructor(r){var t,e,s;this.shouldThrowOnError=!1,this.method=r.method,this.url=r.url,this.headers=new y.Headers(r.headers),this.schema=r.schema,this.body=r.body,this.shouldThrowOnError=(t=r.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=r.signal,this.isMaybeSingle=(e=r.isMaybeSingle)!==null&&e!==void 0?e:!1,this.urlLengthLimit=(s=r.urlLengthLimit)!==null&&s!==void 0?s:8e3,r.fetch?this.fetch=r.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(r,t){return this.headers=new y.Headers(this.headers),this.headers.set(r,t),this}then(r,t){var e=this;this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let s=this.fetch,n=s(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{let a=null,o=null,h=null,u=i.status,l=i.statusText;if(i.ok){var p,m;if(e.method!=="HEAD"){var d;let v=await i.text();v===""||(e.headers.get("Accept")==="text/csv"||e.headers.get("Accept")&&(!((d=e.headers.get("Accept"))===null||d===void 0)&&d.includes("application/vnd.pgrst.plan+text"))?o=v:o=JSON.parse(v))}let g=(p=e.headers.get("Prefer"))===null||p===void 0?void 0:p.match(/count=(exact|planned|estimated)/),b=(m=i.headers.get("content-range"))===null||m===void 0?void 0:m.split("/");g&&b&&b.length>1&&(h=parseInt(b[1])),e.isMaybeSingle&&Array.isArray(o)&&(o.length>1?(a={code:"PGRST116",details:`Results contain ${o.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},o=null,h=null,u=406,l="Not Acceptable"):o.length===1?o=o[0]:o=null)}else{let g=await i.text();try{a=JSON.parse(g),Array.isArray(a)&&i.status===404&&(o=[],a=null,u=200,l="OK")}catch{i.status===404&&g===""?(u=204,l="No Content"):a={message:g}}if(a&&e.shouldThrowOnError)throw new V(a)}return{error:a,data:o,count:h,status:u,statusText:l}});return this.shouldThrowOnError||(n=n.catch(i=>{var a;let o="",h="",u="",l=i?.cause;if(l){var p,m,d,g;let F=(p=l?.message)!==null&&p!==void 0?p:"",C=(m=l?.code)!==null&&m!==void 0?m:"";o=`${(d=i?.name)!==null&&d!==void 0?d:"FetchError"}: ${i?.message}`,o+=`
2
+
3
+ Caused by: ${(g=l?.name)!==null&&g!==void 0?g:"Error"}: ${F}`,C&&(o+=` (${C})`),l?.stack&&(o+=`
4
+ ${l.stack}`)}else{var b;o=(b=i?.stack)!==null&&b!==void 0?b:""}let v=this.url.toString().length;return i?.name==="AbortError"||i?.code==="ABORT_ERR"?(u="",h="Request was aborted (timeout or manual cancellation)",v>this.urlLengthLimit&&(h+=`. Note: Your request URL is ${v} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`)):(l?.name==="HeadersOverflowError"||l?.code==="UND_ERR_HEADERS_OVERFLOW")&&(u="",h="HTTP headers exceeded server limits (typically 16KB)",v>this.urlLengthLimit&&(h+=`. Your request URL is ${v} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{error:{message:`${(a=i?.name)!==null&&a!==void 0?a:"FetchError"}: ${i?.message}`,details:o,hint:h,code:u},data:null,count:null,status:0,statusText:""}})),n.then(r,t)}returns(){return this}overrideTypes(){return this}},Q=class extends X{select(r){let t=!1,e=(r??"*").split("").map(s=>/\s/.test(s)&&!t?"":(s==='"'&&(t=!t),s)).join("");return this.url.searchParams.set("select",e),this.headers.append("Prefer","return=representation"),this}order(r,{ascending:t=!0,nullsFirst:e,foreignTable:s,referencedTable:n=s}={}){let i=n?`${n}.order`:"order",a=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${a?`${a},`:""}${r}.${t?"asc":"desc"}${e===void 0?"":e?".nullsfirst":".nullslast"}`),this}limit(r,{foreignTable:t,referencedTable:e=t}={}){let s=typeof e>"u"?"limit":`${e}.limit`;return this.url.searchParams.set(s,`${r}`),this}range(r,t,{foreignTable:e,referencedTable:s=e}={}){let n=typeof s>"u"?"offset":`${s}.offset`,i=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(n,`${r}`),this.url.searchParams.set(i,`${t-r+1}`),this}abortSignal(r){return this.signal=r,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return 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:r=!1,verbose:t=!1,settings:e=!1,buffers:s=!1,wal:n=!1,format:i="text"}={}){var a;let o=[r?"analyze":null,t?"verbose":null,e?"settings":null,s?"buffers":null,n?"wal":null].filter(Boolean).join("|"),h=(a=this.headers.get("Accept"))!==null&&a!==void 0?a:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${h}"; options=${o};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(r){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${r}`),this}},j=new RegExp("[,()]"),O=class extends Q{eq(r,t){return this.url.searchParams.append(r,`eq.${t}`),this}neq(r,t){return this.url.searchParams.append(r,`neq.${t}`),this}gt(r,t){return this.url.searchParams.append(r,`gt.${t}`),this}gte(r,t){return this.url.searchParams.append(r,`gte.${t}`),this}lt(r,t){return this.url.searchParams.append(r,`lt.${t}`),this}lte(r,t){return this.url.searchParams.append(r,`lte.${t}`),this}like(r,t){return this.url.searchParams.append(r,`like.${t}`),this}likeAllOf(r,t){return this.url.searchParams.append(r,`like(all).{${t.join(",")}}`),this}likeAnyOf(r,t){return this.url.searchParams.append(r,`like(any).{${t.join(",")}}`),this}ilike(r,t){return this.url.searchParams.append(r,`ilike.${t}`),this}ilikeAllOf(r,t){return this.url.searchParams.append(r,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(r,t){return this.url.searchParams.append(r,`ilike(any).{${t.join(",")}}`),this}regexMatch(r,t){return this.url.searchParams.append(r,`match.${t}`),this}regexIMatch(r,t){return this.url.searchParams.append(r,`imatch.${t}`),this}is(r,t){return this.url.searchParams.append(r,`is.${t}`),this}isDistinct(r,t){return this.url.searchParams.append(r,`isdistinct.${t}`),this}in(r,t){let e=Array.from(new Set(t)).map(s=>typeof s=="string"&&j.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(r,`in.(${e})`),this}notIn(r,t){let e=Array.from(new Set(t)).map(s=>typeof s=="string"&&j.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(r,`not.in.(${e})`),this}contains(r,t){return typeof t=="string"?this.url.searchParams.append(r,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(r,`cs.{${t.join(",")}}`):this.url.searchParams.append(r,`cs.${JSON.stringify(t)}`),this}containedBy(r,t){return typeof t=="string"?this.url.searchParams.append(r,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(r,`cd.{${t.join(",")}}`):this.url.searchParams.append(r,`cd.${JSON.stringify(t)}`),this}rangeGt(r,t){return this.url.searchParams.append(r,`sr.${t}`),this}rangeGte(r,t){return this.url.searchParams.append(r,`nxl.${t}`),this}rangeLt(r,t){return this.url.searchParams.append(r,`sl.${t}`),this}rangeLte(r,t){return this.url.searchParams.append(r,`nxr.${t}`),this}rangeAdjacent(r,t){return this.url.searchParams.append(r,`adj.${t}`),this}overlaps(r,t){return typeof t=="string"?this.url.searchParams.append(r,`ov.${t}`):this.url.searchParams.append(r,`ov.{${t.join(",")}}`),this}textSearch(r,t,{config:e,type:s}={}){let n="";s==="plain"?n="pl":s==="phrase"?n="ph":s==="websearch"&&(n="w");let i=e===void 0?"":`(${e})`;return this.url.searchParams.append(r,`${n}fts${i}.${t}`),this}match(r){return Object.entries(r).filter(([t,e])=>e!==void 0).forEach(([t,e])=>{this.url.searchParams.append(t,`eq.${e}`)}),this}not(r,t,e){return this.url.searchParams.append(r,`not.${t}.${e}`),this}or(r,{foreignTable:t,referencedTable:e=t}={}){let s=e?`${e}.or`:"or";return this.url.searchParams.append(s,`(${r})`),this}filter(r,t,e){return this.url.searchParams.append(r,`${t}.${e}`),this}},Z=class{constructor(r,{headers:t={},schema:e,fetch:s,urlLengthLimit:n=8e3}){this.url=r,this.headers=new y.Headers(t),this.schema=e,this.fetch=s,this.urlLengthLimit=n}cloneRequestState(){return{url:new y.URL(this.url.toString()),headers:new y.Headers(this.headers)}}select(r,t){let{head:e=!1,count:s}=t??{},n=e?"HEAD":"GET",i=!1,a=(r??"*").split("").map(u=>/\s/.test(u)&&!i?"":(u==='"'&&(i=!i),u)).join(""),{url:o,headers:h}=this.cloneRequestState();return o.searchParams.set("select",a),s&&h.append("Prefer",`count=${s}`),new O({method:n,url:o,headers:h,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}insert(r,{count:t,defaultToNull:e=!0}={}){var s;let n="POST",{url:i,headers:a}=this.cloneRequestState();if(t&&a.append("Prefer",`count=${t}`),e||a.append("Prefer","missing=default"),Array.isArray(r)){let o=r.reduce((h,u)=>h.concat(Object.keys(u)),[]);if(o.length>0){let h=[...new Set(o)].map(u=>`"${u}"`);i.searchParams.set("columns",h.join(","))}}return new O({method:n,url:i,headers:a,schema:this.schema,body:r,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch,urlLengthLimit:this.urlLengthLimit})}upsert(r,{onConflict:t,ignoreDuplicates:e=!1,count:s,defaultToNull:n=!0}={}){var i;let a="POST",{url:o,headers:h}=this.cloneRequestState();if(h.append("Prefer",`resolution=${e?"ignore":"merge"}-duplicates`),t!==void 0&&o.searchParams.set("on_conflict",t),s&&h.append("Prefer",`count=${s}`),n||h.append("Prefer","missing=default"),Array.isArray(r)){let u=r.reduce((l,p)=>l.concat(Object.keys(p)),[]);if(u.length>0){let l=[...new Set(u)].map(p=>`"${p}"`);o.searchParams.set("columns",l.join(","))}}return new O({method:a,url:o,headers:h,schema:this.schema,body:r,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch,urlLengthLimit:this.urlLengthLimit})}update(r,{count:t}={}){var e;let s="PATCH",{url:n,headers:i}=this.cloneRequestState();return t&&i.append("Prefer",`count=${t}`),new O({method:s,url:n,headers:i,schema:this.schema,body:r,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch,urlLengthLimit:this.urlLengthLimit})}delete({count:r}={}){var t;let e="DELETE",{url:s,headers:n}=this.cloneRequestState();return r&&n.append("Prefer",`count=${r}`),new O({method:e,url:s,headers:n,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch,urlLengthLimit:this.urlLengthLimit})}};function L(r){"@babel/helpers - typeof";return L=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},L(r)}function tt(r,t){if(L(r)!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var s=e.call(r,t||"default");if(L(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function et(r){var t=tt(r,"string");return L(t)=="symbol"?t:t+""}function st(r,t,e){return(t=et(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function H(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(r);t&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),e.push.apply(e,s)}return e}function x(r){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?H(Object(e),!0).forEach(function(s){st(r,s,e[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):H(Object(e)).forEach(function(s){Object.defineProperty(r,s,Object.getOwnPropertyDescriptor(e,s))})}return r}var W=class G{constructor(t,{headers:e={},schema:s,fetch:n,timeout:i,urlLengthLimit:a=8e3}={}){this.url=t,this.headers=new y.Headers(e),this.schemaName=s,this.urlLengthLimit=a;let o=n??globalThis.fetch;i!==void 0&&i>0?this.fetch=(h,u)=>{let l=new y.AbortController,p=setTimeout(()=>l.abort(),i),m=u?.signal;if(m){if(m.aborted)return clearTimeout(p),o(h,u);let d=()=>{clearTimeout(p),l.abort()};return m.addEventListener("abort",d,{once:!0}),o(h,x(x({},u),{},{signal:l.signal})).finally(()=>{clearTimeout(p),m.removeEventListener("abort",d)})}return o(h,x(x({},u),{},{signal:l.signal})).finally(()=>clearTimeout(p))}:this.fetch=o}from(t){if(!t||typeof t!="string"||t.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new Z(new y.URL(`${this.url}/${t}`),{headers:new y.Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}schema(t){return new G(this.url,{headers:this.headers,schema:t,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}rpc(t,e={},{head:s=!1,get:n=!1,count:i}={}){var a;let o,h=new y.URL(`${this.url}/rpc/${t}`),u,l=d=>d!==null&&typeof d=="object"&&(!Array.isArray(d)||d.some(l)),p=s&&Object.values(e).some(l);p?(o="POST",u=e):s||n?(o=s?"HEAD":"GET",Object.entries(e).filter(([d,g])=>g!==void 0).map(([d,g])=>[d,Array.isArray(g)?`{${g.join(",")}}`:`${g}`]).forEach(([d,g])=>{h.searchParams.append(d,g)})):(o="POST",u=e);let m=new y.Headers(this.headers);return p?m.set("Prefer",i?`count=${i},return=minimal`:"return=minimal"):i&&m.set("Prefer",`count=${i}`),new O({method:o,url:h,headers:m,schema:this.schemaName,body:u,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch,urlLengthLimit:this.urlLengthLimit})}};var q="/entities",rt=(r,t)=>new W(r+q,{fetch:t.fetchWithAuth.bind(t)});var A=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 t=document.createElement("style");t.id="__nvwa-inspector-overlay-style",t.textContent=`
2
5
  .__nvwa-inspector-overlay {
3
6
  position: absolute;
4
7
  pointer-events: none;
@@ -30,4 +33,4 @@
30
33
  max-width: 400px;
31
34
  word-break: break-all;
32
35
  }
33
- `,document.head.appendChild(t)}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(t){let e=document.createElement("div");return e.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${t}`,document.body.appendChild(e),e}updateOverlayPosition(t,e){if(!e.isConnected)return;let r=e.getBoundingClientRect(),s=window.scrollX||window.pageXOffset,n=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(t.style.left=`${r.left+s}px`,t.style.top=`${r.top+n}px`,t.style.width=`${r.width}px`,t.style.height=`${r.height}px`,t.style.display="block"):t.style.display="none"}removeOverlay(t){t&&t.parentNode&&t.parentNode.removeChild(t)}highlightElement(t,e){if(!t.isConnected)return;if(this.hoverElement===t&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,t);let o=this.createTooltip();e?o.textContent=e:o.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let c=t.getBoundingClientRect();o.style.left=`${c.left+window.scrollX}px`,o.style.top=`${c.top+window.scrollY-o.offsetHeight-8}px`,c.top<o.offsetHeight+8&&(o.style.top=`${c.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let r=this.createOverlay("hover");this.updateOverlayPosition(r,t),this.hoverOverlay=r,this.hoverElement=t;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 n=this.createTooltip();e?n.textContent=e:n.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,n.style.display="block";let a=t.getBoundingClientRect();n.style.left=`${a.left+window.scrollX}px`,n.style.top=`${a.top+window.scrollY-n.offsetHeight-8}px`,a.top<n.offsetHeight+8&&(n.style.top=`${a.bottom+window.scrollY+8}px`)}selectElement(t,e){if(!t.isConnected)return;if(this.selectedElement===t&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,t);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,t),this.selectedOverlay=r,this.selectedElement=t;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 t=document.getElementById("__nvwa-inspector-overlay-style");t&&t.parentNode&&t.parentNode.removeChild(t)}};function Re(i="root"){if(typeof document>"u")return null;let t=document.getElementById(i)||document.body;if(!t)return null;let e=t.querySelector("[data-source-location]");if(e){let r=e.getAttribute("data-source-location");if(r)return r}if(t.firstElementChild){let s=t.firstElementChild.getAttribute("data-source-location");if(s)return s}return null}u();function Le(i){let t=i;if(typeof t.kind=="string")return t;if(typeof t.tradeNO=="string")return{kind:"alipay_miniprogram",tradeNO:t.tradeNO};if(typeof t.clientSecret=="string")return{kind:"stripe_client_secret",clientSecret:t.clientSecret};if(typeof t.redirectUrl=="string")return{kind:"redirect_url",redirectUrl:t.redirectUrl};if(typeof t.formHtml=="string")return{kind:"alipay_page",formHtml:t.formHtml};if(typeof t.codeUrl=="string")return{kind:"wechat_native_qr",codeUrl:t.codeUrl};let e=t.jsapiPayParams??t;return typeof e.timeStamp=="string"&&typeof e.nonceStr=="string"&&typeof e.package=="string"&&typeof e.paySign=="string"&&typeof e.appId=="string"?{kind:"wechat_jsapi",mode:"jsapi",jsapiPayParams:{appId:e.appId,timeStamp:e.timeStamp,nonceStr:e.nonceStr,package:e.package,signType:e.signType??"RSA",paySign:e.paySign}}:null}function Ae(i,t,e){return t.requestPayment(i.payParams,e)}0&&(module.exports={AbortController,AbortSignal,AuthClient,CURRENT_JWT_KEY,ENTITIES_BASE_PATH,FILE_STORAGE_BASE_PATH,GENERATE_UPLOAD_URL_PATH,Headers,LOGIN_TOKEN_KEY,LOGIN_USER_PROFILE_KEY,NvwaEdgeFunctions,NvwaFileStorage,NvwaHttpClient,OverlayManager,Request,Response,SET_AUTH_TOKEN_HEADER,URL,URLSearchParams,createPostgrestClient,getSourceLocationFromDOM,normalizePayParams,polyfill,requestPaymentFromOrderResult});
36
+ `,document.head.appendChild(t)}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(t){let e=document.createElement("div");return e.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${t}`,document.body.appendChild(e),e}updateOverlayPosition(t,e){if(!e.isConnected)return;let s=e.getBoundingClientRect(),n=window.scrollX||window.pageXOffset,i=window.scrollY||window.pageYOffset;s.width>0&&s.height>0?(t.style.left=`${s.left+n}px`,t.style.top=`${s.top+i}px`,t.style.width=`${s.width}px`,t.style.height=`${s.height}px`,t.style.display="block"):t.style.display="none"}removeOverlay(t){t&&t.parentNode&&t.parentNode.removeChild(t)}highlightElement(t,e){if(!t.isConnected)return;if(this.hoverElement===t&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,t);let o=this.createTooltip();e?o.textContent=e:o.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let h=t.getBoundingClientRect();o.style.left=`${h.left+window.scrollX}px`,o.style.top=`${h.top+window.scrollY-o.offsetHeight-8}px`,h.top<o.offsetHeight+8&&(o.style.top=`${h.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let s=this.createOverlay("hover");this.updateOverlayPosition(s,t),this.hoverOverlay=s,this.hoverElement=t;let n=()=>{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=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n);let i=this.createTooltip();e?i.textContent=e:i.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,i.style.display="block";let a=t.getBoundingClientRect();i.style.left=`${a.left+window.scrollX}px`,i.style.top=`${a.top+window.scrollY-i.offsetHeight-8}px`,a.top<i.offsetHeight+8&&(i.style.top=`${a.bottom+window.scrollY+8}px`)}selectElement(t,e){if(!t.isConnected)return;if(this.selectedElement===t&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,t);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let s=this.createOverlay("selected");this.updateOverlayPosition(s,t),this.selectedOverlay=s,this.selectedElement=t;let n=()=>{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=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n)}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 t=document.getElementById("__nvwa-inspector-overlay-style");t&&t.parentNode&&t.parentNode.removeChild(t)}};function it(r="root"){if(typeof document>"u")return null;let t=document.getElementById(r)||document.body;if(!t)return null;let e=t.querySelector("[data-source-location]");if(e){let s=e.getAttribute("data-source-location");if(s)return s}if(t.firstElementChild){let n=t.firstElementChild.getAttribute("data-source-location");if(n)return n}return null}function nt(r){let t=r;if(typeof t.kind=="string")return t;if(typeof t.tradeNO=="string")return{kind:"alipay_miniprogram",tradeNO:t.tradeNO};if(typeof t.clientSecret=="string")return{kind:"stripe_client_secret",clientSecret:t.clientSecret};if(typeof t.redirectUrl=="string")return{kind:"redirect_url",redirectUrl:t.redirectUrl};if(typeof t.formHtml=="string")return{kind:"alipay_page",formHtml:t.formHtml};if(typeof t.codeUrl=="string")return{kind:"wechat_native_qr",codeUrl:t.codeUrl};let e=t.jsapiPayParams??t;return typeof e.timeStamp=="string"&&typeof e.nonceStr=="string"&&typeof e.package=="string"&&typeof e.paySign=="string"&&typeof e.appId=="string"?{kind:"wechat_jsapi",mode:"jsapi",jsapiPayParams:{appId:e.appId,timeStamp:e.timeStamp,nonceStr:e.nonceStr,package:e.package,signType:e.signType??"RSA",paySign:e.paySign}}:null}function at(r,t,e){return t.requestPayment(r.payParams,e)}0&&(module.exports={AuthClient,CURRENT_JWT_KEY,ENTITIES_BASE_PATH,FILE_STORAGE_BASE_PATH,GENERATE_UPLOAD_URL_PATH,LOGIN_TOKEN_KEY,LOGIN_USER_PROFILE_KEY,NvwaEdgeFunctions,NvwaFileStorage,NvwaHttpClient,OverlayManager,SET_AUTH_TOKEN_HEADER,createPostgrestClient,getSourceLocationFromDOM,normalizePayParams,requestPaymentFromOrderResult});
package/dist/index.mjs CHANGED
@@ -1,4 +1,7 @@
1
- var re=Object.create;var j=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var ie=Object.getPrototypeOf,ae=Object.prototype.hasOwnProperty;var pt=(i,t)=>()=>(i&&(t=i(i=0)),t);var S=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),oe=(i,t)=>{for(var e in t)j(i,e,{get:t[e],enumerable:!0})},dt=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ne(t))!ae.call(i,s)&&s!==e&&j(i,s,{get:()=>t[s],enumerable:!(r=se(t,s))||r.enumerable});return i};var le=(i,t,e)=>(e=i!=null?re(ie(i)):{},dt(t||!i||!i.__esModule?j(e,"default",{value:i,enumerable:!0}):e,i)),L=i=>dt(j({},"__esModule",{value:!0}),i);import Le from"path";import{fileURLToPath as ke}from"url";var u=pt(()=>{"use strict"});var T={};oe(T,{__addDisposableResource:()=>Mt,__assign:()=>G,__asyncDelegator:()=>It,__asyncGenerator:()=>Ut,__asyncValues:()=>Ct,__await:()=>A,__awaiter:()=>Tt,__classPrivateFieldGet:()=>Wt,__classPrivateFieldIn:()=>Gt,__classPrivateFieldSet:()=>qt,__createBinding:()=>B,__decorate:()=>vt,__disposeResources:()=>Bt,__esDecorate:()=>_t,__exportStar:()=>Lt,__extends:()=>wt,__generator:()=>Rt,__importDefault:()=>Ht,__importStar:()=>Nt,__makeTemplateObject:()=>jt,__metadata:()=>St,__param:()=>Pt,__propKey:()=>xt,__read:()=>K,__rest:()=>bt,__rewriteRelativeImportExtension:()=>Dt,__runInitializers:()=>Ot,__setFunctionName:()=>Et,__spread:()=>At,__spreadArray:()=>$t,__spreadArrays:()=>kt,__values:()=>M,default:()=>fe});function wt(i,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");J(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function bt(i,t){var e={};for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&t.indexOf(r)<0&&(e[r]=i[r]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(i);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(i,r[s])&&(e[r[s]]=i[r[s]]);return e}function vt(i,t,e,r){var s=arguments.length,n=s<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(i,t,e,r);else for(var o=i.length-1;o>=0;o--)(a=i[o])&&(n=(s<3?a(n):s>3?a(t,e,n):a(t,e))||n);return s>3&&n&&Object.defineProperty(t,e,n),n}function Pt(i,t){return function(e,r){t(e,r,i)}}function _t(i,t,e,r,s,n){function a(x){if(x!==void 0&&typeof x!="function")throw new TypeError("Function expected");return x}for(var o=r.kind,h=o==="getter"?"get":o==="setter"?"set":"value",l=!t&&i?r.static?i:i.prototype:null,c=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),p,f=!1,d=e.length-1;d>=0;d--){var w={};for(var P in r)w[P]=P==="access"?{}:r[P];for(var P in r.access)w.access[P]=r.access[P];w.addInitializer=function(x){if(f)throw new TypeError("Cannot add initializers after decoration has completed");n.push(a(x||null))};var b=(0,e[d])(o==="accessor"?{get:c.get,set:c.set}:c[h],w);if(o==="accessor"){if(b===void 0)continue;if(b===null||typeof b!="object")throw new TypeError("Object expected");(p=a(b.get))&&(c.get=p),(p=a(b.set))&&(c.set=p),(p=a(b.init))&&s.unshift(p)}else(p=a(b))&&(o==="field"?s.unshift(p):c[h]=p)}l&&Object.defineProperty(l,r.name,c),f=!0}function Ot(i,t,e){for(var r=arguments.length>2,s=0;s<t.length;s++)e=r?t[s].call(i,e):t[s].call(i);return r?e:void 0}function xt(i){return typeof i=="symbol"?i:"".concat(i)}function Et(i,t,e){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(i,"name",{configurable:!0,value:e?"".concat(e," ",t):t})}function St(i,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,t)}function Tt(i,t,e,r){function s(n){return n instanceof e?n:new e(function(a){a(n)})}return new(e||(e=Promise))(function(n,a){function o(c){try{l(r.next(c))}catch(p){a(p)}}function h(c){try{l(r.throw(c))}catch(p){a(p)}}function l(c){c.done?n(c.value):s(c.value).then(o,h)}l((r=r.apply(i,t||[])).next())})}function Rt(i,t){var e={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},r,s,n,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=o(0),a.throw=o(1),a.return=o(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(c){return h([l,c])}}function h(l){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(e=0)),e;)try{if(r=1,s&&(n=l[0]&2?s.return:l[0]?s.throw||((n=s.return)&&n.call(s),0):s.next)&&!(n=n.call(s,l[1])).done)return n;switch(s=0,n&&(l=[l[0]&2,n.value]),l[0]){case 0:case 1:n=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,s=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(n=e.trys,!(n=n.length>0&&n[n.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!n||l[1]>n[0]&&l[1]<n[3])){e.label=l[1];break}if(l[0]===6&&e.label<n[1]){e.label=n[1],n=l;break}if(n&&e.label<n[2]){e.label=n[2],e.ops.push(l);break}n[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(i,e)}catch(c){l=[6,c],s=0}finally{r=n=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Lt(i,t){for(var e in i)e!=="default"&&!Object.prototype.hasOwnProperty.call(t,e)&&B(t,i,e)}function M(i){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&i[t],r=0;if(e)return e.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&r>=i.length&&(i=void 0),{value:i&&i[r++],done:!i}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function K(i,t){var e=typeof Symbol=="function"&&i[Symbol.iterator];if(!e)return i;var r=e.call(i),s,n=[],a;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)n.push(s.value)}catch(o){a={error:o}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(a)throw a.error}}return n}function At(){for(var i=[],t=0;t<arguments.length;t++)i=i.concat(K(arguments[t]));return i}function kt(){for(var i=0,t=0,e=arguments.length;t<e;t++)i+=arguments[t].length;for(var r=Array(i),s=0,t=0;t<e;t++)for(var n=arguments[t],a=0,o=n.length;a<o;a++,s++)r[s]=n[a];return r}function $t(i,t,e){if(e||arguments.length===2)for(var r=0,s=t.length,n;r<s;r++)(n||!(r in t))&&(n||(n=Array.prototype.slice.call(t,0,r)),n[r]=t[r]);return i.concat(n||Array.prototype.slice.call(t))}function A(i){return this instanceof A?(this.v=i,this):new A(i)}function Ut(i,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(i,t||[]),s,n=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",a),s[Symbol.asyncIterator]=function(){return this},s;function a(d){return function(w){return Promise.resolve(w).then(d,p)}}function o(d,w){r[d]&&(s[d]=function(P){return new Promise(function(b,x){n.push([d,P,b,x])>1||h(d,P)})},w&&(s[d]=w(s[d])))}function h(d,w){try{l(r[d](w))}catch(P){f(n[0][3],P)}}function l(d){d.value instanceof A?Promise.resolve(d.value.v).then(c,p):f(n[0][2],d)}function c(d){h("next",d)}function p(d){h("throw",d)}function f(d,w){d(w),n.shift(),n.length&&h(n[0][0],n[0][1])}}function It(i){var t,e;return t={},r("next"),r("throw",function(s){throw s}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(s,n){t[s]=i[s]?function(a){return(e=!e)?{value:A(i[s](a)),done:!1}:n?n(a):a}:n}}function Ct(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=i[Symbol.asyncIterator],e;return t?t.call(i):(i=typeof M=="function"?M(i):i[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(n){e[n]=i[n]&&function(a){return new Promise(function(o,h){a=i[n](a),s(o,h,a.done,a.value)})}}function s(n,a,o,h){Promise.resolve(h).then(function(l){n({value:l,done:o})},a)}}function jt(i,t){return Object.defineProperty?Object.defineProperty(i,"raw",{value:t}):i.raw=t,i}function Nt(i){if(i&&i.__esModule)return i;var t={};if(i!=null)for(var e=z(i),r=0;r<e.length;r++)e[r]!=="default"&&B(t,i,e[r]);return de(t,i),t}function Ht(i){return i&&i.__esModule?i:{default:i}}function Wt(i,t,e,r){if(e==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?r:e==="a"?r.call(i):r?r.value:t.get(i)}function qt(i,t,e,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!s:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(i,e):s?s.value=e:t.set(i,e),e}function Gt(i,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof i=="function"?t===i:i.has(t)}function Mt(i,t,e){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var r,s;if(e){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=t[Symbol.dispose],e&&(s=r)}if(typeof r!="function")throw new TypeError("Object not disposable.");s&&(r=function(){try{s.call(this)}catch(n){return Promise.reject(n)}}),i.stack.push({value:t,dispose:r,async:e})}else e&&i.stack.push({async:!0});return t}function Bt(i){function t(n){i.error=i.hasError?new ge(n,i.error,"An error was suppressed during disposal."):n,i.hasError=!0}var e,r=0;function s(){for(;e=i.stack.pop();)try{if(!e.async&&r===1)return r=0,i.stack.push(e),Promise.resolve().then(s);if(e.dispose){var n=e.dispose.call(e.value);if(e.async)return r|=2,Promise.resolve(n).then(s,function(a){return t(a),s()})}else r|=1}catch(a){t(a)}if(r===1)return i.hasError?Promise.reject(i.error):Promise.resolve();if(i.hasError)throw i.error}return s()}function Dt(i,t){return typeof i=="string"&&/^\.\.?\//.test(i)?i.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,r,s,n,a){return r?t?".jsx":".js":s&&(!n||!a)?e:s+n+"."+a.toLowerCase()+"js"}):i}var J,G,B,de,z,ge,fe,R=pt(()=>{"use strict";u();J=function(i,t){return J=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])},J(i,t)};G=function(){return G=Object.assign||function(t){for(var e,r=1,s=arguments.length;r<s;r++){e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},G.apply(this,arguments)};B=Object.create?(function(i,t,e,r){r===void 0&&(r=e);var s=Object.getOwnPropertyDescriptor(t,e);(!s||("get"in s?!t.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(i,r,s)}):(function(i,t,e,r){r===void 0&&(r=e),i[r]=t[e]});de=Object.create?(function(i,t){Object.defineProperty(i,"default",{enumerable:!0,value:t})}):function(i,t){i.default=t},z=function(i){return z=Object.getOwnPropertyNames||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[e.length]=r);return e},z(i)};ge=typeof SuppressedError=="function"?SuppressedError:function(i,t,e){var r=new Error(e);return r.name="SuppressedError",r.error=i,r.suppressed=t,r};fe={__extends:wt,__assign:G,__rest:bt,__decorate:vt,__param:Pt,__esDecorate:_t,__runInitializers:Ot,__propKey:xt,__setFunctionName:Et,__metadata:St,__awaiter:Tt,__generator:Rt,__createBinding:B,__exportStar:Lt,__values:M,__read:K,__spread:At,__spreadArrays:kt,__spreadArray:$t,__await:A,__asyncGenerator:Ut,__asyncDelegator:It,__asyncValues:Ct,__makeTemplateObject:jt,__importStar:Nt,__importDefault:Ht,__classPrivateFieldGet:Wt,__classPrivateFieldSet:qt,__classPrivateFieldIn:Gt,__addDisposableResource:Mt,__disposeResources:Bt,__rewriteRelativeImportExtension:Dt}});var Q=S(V=>{"use strict";u();Object.defineProperty(V,"__esModule",{value:!0});var Y=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.code=t.code}};V.default=Y});var tt=S(Z=>{"use strict";u();Object.defineProperty(Z,"__esModule",{value:!0});var me=(R(),L(T)),ye=me.__importDefault(Q()),X=class{constructor(t){var e,r;this.shouldThrowOnError=!1,this.method=t.method,this.url=t.url,this.headers=new Headers(t.headers),this.schema=t.schema,this.body=t.body,this.shouldThrowOnError=(e=t.shouldThrowOnError)!==null&&e!==void 0?e:!1,this.signal=t.signal,this.isMaybeSingle=(r=t.isMaybeSingle)!==null&&r!==void 0?r:!1,t.fetch?this.fetch=t.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,e){return this.headers=new Headers(this.headers),this.headers.set(t,e),this}then(t,e){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 r=this.fetch,s=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async n=>{var a,o,h,l;let c=null,p=null,f=null,d=n.status,w=n.statusText;if(n.ok){if(this.method!=="HEAD"){let C=await n.text();C===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((a=this.headers.get("Accept"))===null||a===void 0)&&a.includes("application/vnd.pgrst.plan+text"))?p=C:p=JSON.parse(C))}let b=(o=this.headers.get("Prefer"))===null||o===void 0?void 0:o.match(/count=(exact|planned|estimated)/),x=(h=n.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");b&&x&&x.length>1&&(f=parseInt(x[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(p)&&(p.length>1?(c={code:"PGRST116",details:`Results contain ${p.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},p=null,f=null,d=406,w="Not Acceptable"):p.length===1?p=p[0]:p=null)}else{let b=await n.text();try{c=JSON.parse(b),Array.isArray(c)&&n.status===404&&(p=[],c=null,d=200,w="OK")}catch{n.status===404&&b===""?(d=204,w="No Content"):c={message:b}}if(c&&this.isMaybeSingle&&(!((l=c?.details)===null||l===void 0)&&l.includes("0 rows"))&&(c=null,d=200,w="OK"),c&&this.shouldThrowOnError)throw new ye.default(c)}return{error:c,data:p,count:f,status:d,statusText:w}});return this.shouldThrowOnError||(s=s.catch(n=>{var a,o,h;return{error:{message:`${(a=n?.name)!==null&&a!==void 0?a:"FetchError"}: ${n?.message}`,details:`${(o=n?.stack)!==null&&o!==void 0?o:""}`,hint:"",code:`${(h=n?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),s.then(t,e)}returns(){return this}overrideTypes(){return this}};Z.default=X});var st=S(rt=>{"use strict";u();Object.defineProperty(rt,"__esModule",{value:!0});var we=(R(),L(T)),be=we.__importDefault(tt()),et=class extends be.default{select(t){let e=!1,r=(t??"*").split("").map(s=>/\s/.test(s)&&!e?"":(s==='"'&&(e=!e),s)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:e=!0,nullsFirst:r,foreignTable:s,referencedTable:n=s}={}){let a=n?`${n}.order`:"order",o=this.url.searchParams.get(a);return this.url.searchParams.set(a,`${o?`${o},`:""}${t}.${e?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:e,referencedTable:r=e}={}){let s=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${t}`),this}range(t,e,{foreignTable:r,referencedTable:s=r}={}){let n=typeof s>"u"?"offset":`${s}.offset`,a=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(n,`${t}`),this.url.searchParams.set(a,`${e-t+1}`),this}abortSignal(t){return this.signal=t,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:t=!1,verbose:e=!1,settings:r=!1,buffers:s=!1,wal:n=!1,format:a="text"}={}){var o;let h=[t?"analyze":null,e?"verbose":null,r?"settings":null,s?"buffers":null,n?"wal":null].filter(Boolean).join("|"),l=(o=this.headers.get("Accept"))!==null&&o!==void 0?o:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${a}; for="${l}"; options=${h};`),a==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(t){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${t}`),this}};rt.default=et});var D=S(it=>{"use strict";u();Object.defineProperty(it,"__esModule",{value:!0});var ve=(R(),L(T)),Pe=ve.__importDefault(st()),_e=new RegExp("[,()]"),nt=class extends Pe.default{eq(t,e){return this.url.searchParams.append(t,`eq.${e}`),this}neq(t,e){return this.url.searchParams.append(t,`neq.${e}`),this}gt(t,e){return this.url.searchParams.append(t,`gt.${e}`),this}gte(t,e){return this.url.searchParams.append(t,`gte.${e}`),this}lt(t,e){return this.url.searchParams.append(t,`lt.${e}`),this}lte(t,e){return this.url.searchParams.append(t,`lte.${e}`),this}like(t,e){return this.url.searchParams.append(t,`like.${e}`),this}likeAllOf(t,e){return this.url.searchParams.append(t,`like(all).{${e.join(",")}}`),this}likeAnyOf(t,e){return this.url.searchParams.append(t,`like(any).{${e.join(",")}}`),this}ilike(t,e){return this.url.searchParams.append(t,`ilike.${e}`),this}ilikeAllOf(t,e){return this.url.searchParams.append(t,`ilike(all).{${e.join(",")}}`),this}ilikeAnyOf(t,e){return this.url.searchParams.append(t,`ilike(any).{${e.join(",")}}`),this}is(t,e){return this.url.searchParams.append(t,`is.${e}`),this}in(t,e){let r=Array.from(new Set(e)).map(s=>typeof s=="string"&&_e.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(t,`in.(${r})`),this}contains(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cs.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cs.{${e.join(",")}}`):this.url.searchParams.append(t,`cs.${JSON.stringify(e)}`),this}containedBy(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cd.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cd.{${e.join(",")}}`):this.url.searchParams.append(t,`cd.${JSON.stringify(e)}`),this}rangeGt(t,e){return this.url.searchParams.append(t,`sr.${e}`),this}rangeGte(t,e){return this.url.searchParams.append(t,`nxl.${e}`),this}rangeLt(t,e){return this.url.searchParams.append(t,`sl.${e}`),this}rangeLte(t,e){return this.url.searchParams.append(t,`nxr.${e}`),this}rangeAdjacent(t,e){return this.url.searchParams.append(t,`adj.${e}`),this}overlaps(t,e){return typeof e=="string"?this.url.searchParams.append(t,`ov.${e}`):this.url.searchParams.append(t,`ov.{${e.join(",")}}`),this}textSearch(t,e,{config:r,type:s}={}){let n="";s==="plain"?n="pl":s==="phrase"?n="ph":s==="websearch"&&(n="w");let a=r===void 0?"":`(${r})`;return this.url.searchParams.append(t,`${n}fts${a}.${e}`),this}match(t){return Object.entries(t).forEach(([e,r])=>{this.url.searchParams.append(e,`eq.${r}`)}),this}not(t,e,r){return this.url.searchParams.append(t,`not.${e}.${r}`),this}or(t,{foreignTable:e,referencedTable:r=e}={}){let s=r?`${r}.or`:"or";return this.url.searchParams.append(s,`(${t})`),this}filter(t,e,r){return this.url.searchParams.append(t,`${e}.${r}`),this}};it.default=nt});var lt=S(ot=>{"use strict";u();Object.defineProperty(ot,"__esModule",{value:!0});var Oe=(R(),L(T)),I=Oe.__importDefault(D()),at=class{constructor(t,{headers:e={},schema:r,fetch:s}){this.url=t,this.headers=new Headers(e),this.schema=r,this.fetch=s}select(t,e){let{head:r=!1,count:s}=e??{},n=r?"HEAD":"GET",a=!1,o=(t??"*").split("").map(h=>/\s/.test(h)&&!a?"":(h==='"'&&(a=!a),h)).join("");return this.url.searchParams.set("select",o),s&&this.headers.append("Prefer",`count=${s}`),new I.default({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(t,{count:e,defaultToNull:r=!0}={}){var s;let n="POST";if(e&&this.headers.append("Prefer",`count=${e}`),r||this.headers.append("Prefer","missing=default"),Array.isArray(t)){let a=t.reduce((o,h)=>o.concat(Object.keys(h)),[]);if(a.length>0){let o=[...new Set(a)].map(h=>`"${h}"`);this.url.searchParams.set("columns",o.join(","))}}return new I.default({method:n,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}upsert(t,{onConflict:e,ignoreDuplicates:r=!1,count:s,defaultToNull:n=!0}={}){var a;let o="POST";if(this.headers.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),e!==void 0&&this.url.searchParams.set("on_conflict",e),s&&this.headers.append("Prefer",`count=${s}`),n||this.headers.append("Prefer","missing=default"),Array.isArray(t)){let h=t.reduce((l,c)=>l.concat(Object.keys(c)),[]);if(h.length>0){let l=[...new Set(h)].map(c=>`"${c}"`);this.url.searchParams.set("columns",l.join(","))}}return new I.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}update(t,{count:e}={}){var r;let s="PATCH";return e&&this.headers.append("Prefer",`count=${e}`),new I.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch})}delete({count:t}={}){var e;let r="DELETE";return t&&this.headers.append("Prefer",`count=${t}`),new I.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch})}};ot.default=at});var Jt=S(ht=>{"use strict";u();Object.defineProperty(ht,"__esModule",{value:!0});var Ft=(R(),L(T)),xe=Ft.__importDefault(lt()),Ee=Ft.__importDefault(D()),ut=class i{constructor(t,{headers:e={},schema:r,fetch:s}={}){this.url=t,this.headers=new Headers(e),this.schemaName=r,this.fetch=s}from(t){let e=new URL(`${this.url}/${t}`);return new xe.default(e,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(t){return new i(this.url,{headers:this.headers,schema:t,fetch:this.fetch})}rpc(t,e={},{head:r=!1,get:s=!1,count:n}={}){var a;let o,h=new URL(`${this.url}/rpc/${t}`),l;r||s?(o=r?"HEAD":"GET",Object.entries(e).filter(([p,f])=>f!==void 0).map(([p,f])=>[p,Array.isArray(f)?`{${f.join(",")}}`:`${f}`]).forEach(([p,f])=>{h.searchParams.append(p,f)})):(o="POST",l=e);let c=new Headers(this.headers);return n&&c.set("Prefer",`count=${n}`),new Ee.default({method:o,url:h,headers:c,schema:this.schemaName,body:l,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}};ht.default=ut});var Zt=S(v=>{"use strict";u();Object.defineProperty(v,"__esModule",{value:!0});v.PostgrestError=v.PostgrestBuilder=v.PostgrestTransformBuilder=v.PostgrestFilterBuilder=v.PostgrestQueryBuilder=v.PostgrestClient=void 0;var k=(R(),L(T)),zt=k.__importDefault(Jt());v.PostgrestClient=zt.default;var Kt=k.__importDefault(lt());v.PostgrestQueryBuilder=Kt.default;var Yt=k.__importDefault(D());v.PostgrestFilterBuilder=Yt.default;var Vt=k.__importDefault(st());v.PostgrestTransformBuilder=Vt.default;var Qt=k.__importDefault(tt());v.PostgrestBuilder=Qt.default;var Xt=k.__importDefault(Q());v.PostgrestError=Xt.default;v.default={PostgrestClient:zt.default,PostgrestQueryBuilder:Kt.default,PostgrestFilterBuilder:Yt.default,PostgrestTransformBuilder:Vt.default,PostgrestBuilder:Qt.default,PostgrestError:Xt.default}});u();u();var gt=class{constructor(t,e=""){this.http=t,this.baseUrl=e.replace(/\/$/,"")}async invoke(t,e){let r=this.baseUrl?`${this.baseUrl}/functions/${t}`:`/functions/${t}`;return await(await this.http.fetch(r,{method:e.method||"POST",body:e.body,headers:e.headers})).json()}};u();u();var g="nvwa_current_jwt",O="nvwa_login_token",E="nvwa_user_profile",ft="set-auth-token",ue=typeof fetch<"u"?(i,t)=>fetch(i,t):()=>{throw new Error("AuthClient requires fetch")},F=class{constructor(t,e={}){this.baseUrl=t.replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??ue,this.storage=e.storage??null,this.credentials=e.credentials??"omit",typeof console<"u"&&(console.warn("[NvwaAuth] init baseUrl:",this.baseUrl||"(empty)"),(!this.baseUrl||!this.baseUrl.startsWith("http://")&&!this.baseUrl.startsWith("https://"))&&console.warn("[NvwaAuth] baseUrl \u5E94\u4E3A\u5B8C\u6574\u5730\u5740\uFF08\u5982 https://xxx.nvwa.app\uFF09\uFF0C\u5426\u5219\u5C0F\u7A0B\u5E8F request \u4F1A\u62A5 invalid url"))}async currentUser(){if(this.storage){let r=await this.storage.get(E);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(E,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(g);if(e!=null)return e;let r=await this.storage.get(O),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(g,s.token),s.token):null}let{data:t}=await this.getToken();return t?.token??null}async persistLogin(t,e){if(!this.storage)return;let s=e?.headers.get(ft)?.trim()||t.token||t.session?.token;s&&await this.storage.set(O,s),t.user&&await this.storage.set(E,t.user);let n=s??await this.storage.get(O),{data:a}=await this.getToken(n??void 0);a?.token&&await this.storage.set(g,a.token)}async clearLogin(){this.storage&&(await this.storage.remove(O),await this.storage.remove(E),await this.storage.remove(g))}getGoogleOpenPlatformLoginUrl(t){let e=new URLSearchParams({return_url:t});return`${this.url("google/openplatform/login")}?${e.toString()}`}startGoogleOpenPlatformLogin(t){let e=this.getGoogleOpenPlatformLoginUrl(t);if(typeof globalThis<"u"&&"location"in globalThis){globalThis.location.href=e;return}throw new Error("startGoogleOpenPlatformLogin requires a browser environment with location")}async completeGoogleOpenPlatformLoginFromCurrentUrl(t){let e;if(t!=null&&t!=="")e=t;else if(typeof globalThis<"u"&&"location"in globalThis)e=globalThis.location.href;else return{error:{message:"completeGoogleOpenPlatformLoginFromCurrentUrl requires url or browser location",status:0}};let r;try{r=new URL(e).searchParams.get("exchange_code")}catch{return{error:{message:"invalid_callback_url",status:400}}}return r?.trim()?await this.loginWithGoogleExchangeCode(r.trim()):{error:{message:"missing_exchange_code",status:400}}}async loginWithGoogleExchangeCode(t){try{let e={"Content-Type":"application/json"};if(this.storage){let a=await this.storage.get(g);a!=null&&(e.Authorization=`Bearer ${a}`)}let r=await this.fetchImpl(this.url("google/openplatform/sign-in"),{method:"POST",headers:e,credentials:this.credentials,body:JSON.stringify({exchangeCode:t})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let n=s?JSON.parse(s):null;return!n?.token||!n.user?{error:{message:"invalid_google_login_response",status:502}}:(this.storage&&(await this.storage.set(g,n.token),await this.storage.set(O,n.token),await this.storage.set(E,n.user)),{data:n})}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getGoogleOpenPlatformIdentity(){try{let t={};if(this.storage){let n=await this.storage.get(g);n!=null&&(t.Authorization=`Bearer ${n}`)}let e=await this.fetchImpl(this.url("google/openplatform/identity"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}}),r=await e.text();if(!e.ok)return{error:{message:r||e.statusText,status:e.status}};let s=r?JSON.parse(r):null;return s?.sub?{data:s}:{error:{message:"invalid_google_identity_response",status:502}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}getGithubOpenPlatformLoginUrl(t){let e=new URLSearchParams({return_url:t});return`${this.url("github/openplatform/login")}?${e.toString()}`}startGithubOpenPlatformLogin(t){let e=this.getGithubOpenPlatformLoginUrl(t);if(typeof globalThis<"u"&&"location"in globalThis){globalThis.location.href=e;return}throw new Error("startGithubOpenPlatformLogin requires a browser environment with location")}async completeGithubOpenPlatformLoginFromCurrentUrl(t){let e;if(t!=null&&t!=="")e=t;else if(typeof globalThis<"u"&&"location"in globalThis)e=globalThis.location.href;else return{error:{message:"completeGithubOpenPlatformLoginFromCurrentUrl requires url or browser location",status:0}};let r;try{r=new URL(e).searchParams.get("exchange_code")}catch{return{error:{message:"invalid_callback_url",status:400}}}return r?.trim()?await this.loginWithGithubExchangeCode(r.trim()):{error:{message:"missing_exchange_code",status:400}}}async loginWithGithubExchangeCode(t){try{let e={"Content-Type":"application/json"};if(this.storage){let a=await this.storage.get(g);a!=null&&(e.Authorization=`Bearer ${a}`)}let r=await this.fetchImpl(this.url("github/openplatform/sign-in"),{method:"POST",headers:e,credentials:this.credentials,body:JSON.stringify({exchangeCode:t})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let n=s?JSON.parse(s):null;return!n?.token||!n.user?{error:{message:"invalid_github_login_response",status:502}}:(this.storage&&(await this.storage.set(g,n.token),await this.storage.set(O,n.token),await this.storage.set(E,n.user)),{data:n})}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getGithubOpenPlatformIdentity(){try{let t={};if(this.storage){let n=await this.storage.get(g);n!=null&&(t.Authorization=`Bearer ${n}`)}let e=await this.fetchImpl(this.url("github/openplatform/identity"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}}),r=await e.text();if(!e.ok)return{error:{message:r||e.statusText,status:e.status}};let s=r?JSON.parse(r):null;return s?.sub?{data:s}:{error:{message:"invalid_github_identity_response",status:502}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}getWechatWebsiteOpenPlatformLoginUrl(t){let e=new URLSearchParams({return_url:t});return`${this.url("wechat-website/openplatform/login")}?${e.toString()}`}startWechatWebsiteOpenPlatformLogin(t){let e=this.getWechatWebsiteOpenPlatformLoginUrl(t);if(typeof globalThis<"u"&&"location"in globalThis){globalThis.location.href=e;return}throw new Error("startWechatWebsiteOpenPlatformLogin requires a browser environment with location")}async completeWechatWebsiteOpenPlatformLoginFromCurrentUrl(t){let e;if(t!=null&&t!=="")e=t;else if(typeof globalThis<"u"&&"location"in globalThis)e=globalThis.location.href;else return{error:{message:"completeWechatWebsiteOpenPlatformLoginFromCurrentUrl requires url or browser location",status:0}};let r;try{r=new URL(e).searchParams.get("exchange_code")}catch{return{error:{message:"invalid_callback_url",status:400}}}return r?.trim()?await this.loginWithWechatWebsiteExchangeCode(r.trim()):{error:{message:"missing_exchange_code",status:400}}}async loginWithWechatWebsiteExchangeCode(t){try{let e={"Content-Type":"application/json"};if(this.storage){let a=await this.storage.get(g);a!=null&&(e.Authorization=`Bearer ${a}`)}let r=await this.fetchImpl(this.url("wechat-website/openplatform/sign-in"),{method:"POST",headers:e,credentials:this.credentials,body:JSON.stringify({exchangeCode:t})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let n=s?JSON.parse(s):null;return!n?.token||!n.user?{error:{message:"invalid_wechat_website_login_response",status:502}}:(this.storage&&(await this.storage.set(g,n.token),await this.storage.set(O,n.token),await this.storage.set(E,n.user)),{data:n})}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getWechatWebsiteOpenPlatformIdentity(){try{let t={};if(this.storage){let n=await this.storage.get(g);n!=null&&(t.Authorization=`Bearer ${n}`)}let e=await this.fetchImpl(this.url("wechat-website/openplatform/identity"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}}),r=await e.text();if(!e.ok)return{error:{message:r||e.statusText,status:e.status}};let s=r?JSON.parse(r):null;return s?.sub?{data:s}:{error:{message:"invalid_wechat_website_identity_response",status:502}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}url(t){let r=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${t.replace(/^\/+/,"")}`;return typeof console<"u"&&(console.warn("[NvwaAuth] request URL:",r),!r.startsWith("http://")&&!r.startsWith("https://")&&console.warn("[NvwaAuth] URL \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F\u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 Nvwa \u6784\u9020\u65F6\u4F20\u5165\u7684 baseUrl")),r}async getSession(){try{let t={};if(this.storage){let s=await this.storage.get(O)??await this.storage.get(g);s!=null&&(t.Authorization=`Bearer ${s}`)}let e=await this.fetchImpl(this.url("session"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return e.ok?{data:await e.json()}:{data:null,error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{data:null,error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signInWithEmail(t,e){try{let r=await this.fetchImpl(this.url("sign-in/email"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify({email:t,password:e})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let n=s?JSON.parse(s):void 0;return n&&await this.persistLogin({user:n.user,session:n.session},r),{data:n}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let t={};if(this.storage){let r=await this.storage.get(O)??await this.storage.get(g);r!=null&&(t.Authorization=`Bearer ${r}`)}let e=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return await this.clearLogin(),e.ok?{}:{error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signUp(t){let e=await this.postJson("sign-up/email",t);return e.data&&await this.persistLogin(e.data,e.response),e}async getToken(t){try{let e={};if(t)e.Authorization=`Bearer ${t}`;else if(this.storage){let a=await this.storage.get(O)??await this.storage.get(g);a!=null&&(e.Authorization=`Bearer ${a}`)}let r=await this.fetchImpl(this.url("token"),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let n=s?JSON.parse(s):void 0;return{data:n?.token!=null?{token:n.token}:void 0}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithUsername(t,e){let r=await this.postJson("sign-in/username",{username:t,password:e});return r.data&&await this.persistLogin(r.data,r.response),r}async signInWithPhoneNumber(t,e,r){let s=await this.postJson("sign-in/phone-number",{phoneNumber:t,password:e,rememberMe:r});return s.data&&await this.persistLogin(s.data,s.response),s}async sendPhoneNumberOtp(t){let e=await this.postJson("phone-number/send-otp",{phoneNumber:t});return e.error?{error:e.error}:{}}async verifyPhoneNumber(t,e){let r=await this.postJson("phone-number/verify",{phoneNumber:t,code:e});return r.data&&await this.persistLogin(r.data,r.response),r}async loginWithWeChatCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(g);o!=null&&(r.Authorization=`Bearer ${o}`)}let s=await this.fetchImpl(this.url("wechat/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let a=n?JSON.parse(n):null;return!a?.token||!a.user?{error:{message:"invalid_wechat_login_response",status:502}}:(this.storage&&(await this.storage.set(g,a.token),await this.storage.set(O,a.token),await this.storage.set(E,a.user)),{data:a})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async loginWithAlipayCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(g);o!=null&&(r.Authorization=`Bearer ${o}`)}let s=await this.fetchImpl(this.url("alipay/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let a=n?JSON.parse(n):null;return!a?.token||!a.user?{error:{message:"invalid_alipay_login_response",status:502}}:(this.storage&&(await this.storage.set(g,a.token),await this.storage.set(O,a.token),await this.storage.set(E,a.user)),{data:a})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async getWeChatOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(g);o!=null&&(e.Authorization=`Bearer ${o}`)}let r=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",s=await this.fetchImpl(this.url(`wechat/openplatform/identity${r}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let a=n?JSON.parse(n):null;return!a?.openid||!a.appId?{error:{message:"invalid_wechat_identity_response",status:502}}:{data:a}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getAlipayOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(g);o!=null&&(e.Authorization=`Bearer ${o}`)}let r=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",s=await this.fetchImpl(this.url(`alipay/openplatform/identity${r}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let a=n?JSON.parse(n):null;return!a?.openid||!a.appId?{error:{message:"invalid_alipay_identity_response",status:502}}:{data:a}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async postJson(t,e){try{let r=await this.fetchImpl(this.url(t),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify(e)}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let n=s?JSON.parse(s):void 0;return{data:n?.data??n??void 0,response:r}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}};u();u();var _=class i{constructor(t){this.headerMap=new Map;if(t){if(t instanceof i)t.forEach((e,r)=>this.set(r,e));else if(Array.isArray(t))for(let[e,r]of t)this.set(e,String(r));else if(typeof t=="object")for(let e of Object.keys(t))this.set(e,String(t[e]))}}append(t,e){let r=t.toLowerCase(),s=this.headerMap.get(r);this.headerMap.set(r,s?`${s}, ${e}`:e)}set(t,e){this.headerMap.set(t.toLowerCase(),String(e))}get(t){let e=this.headerMap.get(t.toLowerCase());return e??null}has(t){return this.headerMap.has(t.toLowerCase())}delete(t){this.headerMap.delete(t.toLowerCase())}forEach(t){for(let[e,r]of this.headerMap.entries())t(r,e,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},$=class i{constructor(t){this.params=new Map;if(t){if(typeof t=="string")this.parseString(t);else if(t instanceof i)this.params=new Map(t.params);else if(Array.isArray(t))for(let[e,r]of t)this.append(e,r);else if(t&&typeof t=="object")for(let[e,r]of Object.entries(t))this.set(e,r)}}parseString(t){t.startsWith("?")&&(t=t.slice(1));let e=t.split("&");for(let r of e)if(r){let[s,n]=r.split("=");s&&this.append(decodeURIComponent(s),n?decodeURIComponent(n):"")}}append(t,e){let r=this.params.get(t)||[];r.push(e),this.params.set(t,r)}delete(t){this.params.delete(t)}get(t){let e=this.params.get(t);return e?e[0]:null}getAll(t){return this.params.get(t)||[]}has(t){return this.params.has(t)}set(t,e){this.params.set(t,[e])}sort(){let t=Array.from(this.params.entries()).sort(([e],[r])=>e.localeCompare(r));this.params=new Map(t)}toString(){let t=[];for(let[e,r]of this.params.entries())for(let s of r)t.push(`${encodeURIComponent(e)}=${encodeURIComponent(s)}`);return t.join("&")}forEach(t){for(let[e,r]of this.params.entries())for(let s of r)t(s,e,this)}keys(){return this.params.keys()}values(){let t=[];for(let e of this.params.values())t.push(...e);return t[Symbol.iterator]()}entries(){let t=[];for(let[e,r]of this.params.entries())for(let s of r)t.push([e,s]);return t[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},N=class i{constructor(t,e){let r;if(t instanceof i)r=t.href;else if(e){let n=e instanceof i?e.href:e;r=this.resolve(n,t)}else r=t;let s=this.parseUrl(r);this.href=r,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 $(s.search),this.hash=s.hash}resolve(t,e){if(e.startsWith("http://")||e.startsWith("https://"))return e;if(e.startsWith("//"))return`${this.parseUrl(t).protocol}${e}`;if(e.startsWith("/")){let n=this.parseUrl(t);return`${n.protocol}//${n.host}${e}`}let r=this.parseUrl(t),s=r.pathname.endsWith("/")?r.pathname:r.pathname+"/";return`${r.protocol}//${r.host}${s}${e}`}parseUrl(t){let e=t.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!e)throw new TypeError("Invalid URL");let r=e[2]||"",s=e[4]||"",n=e[5]||"/",a=e[7]?`?${e[7]}`:"",o=e[9]?`#${e[9]}`:"";if(!r&&!s&&!n.startsWith("/")&&!n.includes("/")&&!n.includes("."))throw new TypeError("Invalid URL");let h=s.match(/^([^@]*)@(.+)$/),l="",c="",p=s;if(h){let P=h[1];p=h[2];let b=P.match(/^([^:]*):?(.*)$/);b&&(l=b[1]||"",c=b[2]||"")}let f=p.match(/^([^:]+):?(\d*)$/),d=f?f[1]:p,w=f&&f[2]?f[2]:"";return{protocol:r?`${r}:`:"",username:l,password:c,host:p,hostname:d,port:w,pathname:n,search:a,hash:o}}toString(){let t=this.searchParams.toString(),e=t?`?${t}`:"";return`${this.protocol}//${this.host}${this.pathname}${e}${this.hash}`}toJSON(){return this.toString()}};u();var H=class i{constructor(t,e){if(typeof t=="string")this.url=t;else if(t?.url)this.url=String(t.url);else if(typeof t?.toString=="function")this.url=String(t.toString());else throw new Error("Invalid input for Request");this.method=(e?.method||"GET").toUpperCase(),this.headers=e?.headers instanceof _?e.headers:new _(e?.headers),this.body=e?.body,this.timeout=e?.timeout,this.signal=e?.signal||void 0}clone(){return new i(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};u();var W=class{constructor(t,e){this.bodyData=t,this.status=e?.status??200,this.statusText=e?.statusText??"",this.headers=he(e?.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 t=await this.text();return new TextEncoder().encode(t).buffer}};function he(i){return i?new _(i):new _}u();var U=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 t of Array.from(this.listeners))try{t()}catch{}this.listeners.clear()}}addEventListener(t,e){if(this._aborted){try{e()}catch{}return}this.listeners.add(e)}removeEventListener(t,e){this.listeners.delete(e)}toString(){return"[object AbortSignal]"}},q=class{constructor(){this._signal=new U}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};u();function Qe(i){let t=i;i===void 0&&(t=(0,eval)("this")),t.URL=N,t.URLSearchParams=$,t.Headers=_,t.Request=H,t.Response=W,t.AbortController=q,t.AbortSignal=U}var mt=class{constructor(t,e,r){this.storage=t,this.customFetch=e,this.handleUnauthorized=r}async fetch(t,e){return await this.customFetch(t,e)}async fetchWithAuth(t,e){let r=await this.storage.get(g),s=new _(e?.headers);r&&s.set("Authorization",`Bearer ${r}`);let n=e?.method||"GET";if((n==="POST"||n==="PUT"||n==="PATCH")&&e?.body){let o=s.get("Content-Type");(!o||o.includes("text/plain"))&&s.set("Content-Type","application/json")}let a=await this.customFetch(t,{...e,headers:s});if(a.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return a}};u();var ce="/storage",pe=ce+"/generateUploadUrl",yt=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+pe,{method:"POST",body:{fileName:t.name||t.fileName,fileSize:t.size||t.fileSize,fileType:t.type||t.fileType}}),{url:r}=await e.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:t,headers:new _({"Content-Type":t.type||t.fileType||"application/octet-stream"})}),{url:n}=await s.json();return{url:n.split("?")[0]}}};u();u();u();var ct=le(Zt(),1),{PostgrestClient:te,PostgrestQueryBuilder:jr,PostgrestFilterBuilder:Nr,PostgrestTransformBuilder:Hr,PostgrestBuilder:Wr,PostgrestError:qr}=ct.default||ct;var Se="/entities",Dr=(i,t)=>new te(i+Se,{fetch:t.fetchWithAuth.bind(t)});u();var ee=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 t=document.createElement("style");t.id="__nvwa-inspector-overlay-style",t.textContent=`
1
+ var _=class{constructor(t,e=""){this.http=t,this.baseUrl=e.replace(/\/$/,"")}async invoke(t,e){let s=this.baseUrl?`${this.baseUrl}/functions/${t}`:`/functions/${t}`;return await(await this.http.fetch(s,{method:e.method||"POST",body:e.body,headers:e.headers})).json()}};var c="nvwa_current_jwt",f="nvwa_login_token",y="nvwa_user_profile",k="set-auth-token",W=typeof fetch<"u"?(r,t)=>fetch(r,t):()=>{throw new Error("AuthClient requires fetch")},T=class{constructor(t,e={}){this.baseUrl=t.replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??W,this.storage=e.storage??null,this.credentials=e.credentials??"omit",typeof console<"u"&&(console.warn("[NvwaAuth] init baseUrl:",this.baseUrl||"(empty)"),(!this.baseUrl||!this.baseUrl.startsWith("http://")&&!this.baseUrl.startsWith("https://"))&&console.warn("[NvwaAuth] baseUrl \u5E94\u4E3A\u5B8C\u6574\u5730\u5740\uFF08\u5982 https://xxx.nvwa.app\uFF09\uFF0C\u5426\u5219\u5C0F\u7A0B\u5E8F request \u4F1A\u62A5 invalid url"))}async currentUser(){if(this.storage){let s=await this.storage.get(y);if(s!=null)return s}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(y,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(c);if(e!=null)return e;let s=await this.storage.get(f),{data:n}=await this.getToken(s??void 0);return n?.token?(await this.storage.set(c,n.token),n.token):null}let{data:t}=await this.getToken();return t?.token??null}async persistLogin(t,e){if(!this.storage)return;let n=e?.headers.get(k)?.trim()||t.token||t.session?.token;n&&await this.storage.set(f,n),t.user&&await this.storage.set(y,t.user);let i=n??await this.storage.get(f),{data:a}=await this.getToken(i??void 0);a?.token&&await this.storage.set(c,a.token)}async clearLogin(){this.storage&&(await this.storage.remove(f),await this.storage.remove(y),await this.storage.remove(c))}getGoogleOpenPlatformLoginUrl(t){let e=new URLSearchParams({return_url:t});return`${this.url("google/openplatform/login")}?${e.toString()}`}startGoogleOpenPlatformLogin(t){let e=this.getGoogleOpenPlatformLoginUrl(t);if(typeof globalThis<"u"&&"location"in globalThis){globalThis.location.href=e;return}throw new Error("startGoogleOpenPlatformLogin requires a browser environment with location")}async completeGoogleOpenPlatformLoginFromCurrentUrl(t){let e;if(t!=null&&t!=="")e=t;else if(typeof globalThis<"u"&&"location"in globalThis)e=globalThis.location.href;else return{error:{message:"completeGoogleOpenPlatformLoginFromCurrentUrl requires url or browser location",status:0}};let s;try{s=new URL(e).searchParams.get("exchange_code")}catch{return{error:{message:"invalid_callback_url",status:400}}}return s?.trim()?await this.loginWithGoogleExchangeCode(s.trim()):{error:{message:"missing_exchange_code",status:400}}}async loginWithGoogleExchangeCode(t){try{let e={"Content-Type":"application/json"};if(this.storage){let a=await this.storage.get(c);a!=null&&(e.Authorization=`Bearer ${a}`)}let s=await this.fetchImpl(this.url("google/openplatform/sign-in"),{method:"POST",headers:e,credentials:this.credentials,body:JSON.stringify({exchangeCode:t})}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let i=n?JSON.parse(n):null;return!i?.token||!i.user?{error:{message:"invalid_google_login_response",status:502}}:(this.storage&&(await this.storage.set(c,i.token),await this.storage.set(f,i.token),await this.storage.set(y,i.user)),{data:i})}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getGoogleOpenPlatformIdentity(){try{let t={};if(this.storage){let i=await this.storage.get(c);i!=null&&(t.Authorization=`Bearer ${i}`)}let e=await this.fetchImpl(this.url("google/openplatform/identity"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}}),s=await e.text();if(!e.ok)return{error:{message:s||e.statusText,status:e.status}};let n=s?JSON.parse(s):null;return n?.sub?{data:n}:{error:{message:"invalid_google_identity_response",status:502}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}getGithubOpenPlatformLoginUrl(t){let e=new URLSearchParams({return_url:t});return`${this.url("github/openplatform/login")}?${e.toString()}`}startGithubOpenPlatformLogin(t){let e=this.getGithubOpenPlatformLoginUrl(t);if(typeof globalThis<"u"&&"location"in globalThis){globalThis.location.href=e;return}throw new Error("startGithubOpenPlatformLogin requires a browser environment with location")}async completeGithubOpenPlatformLoginFromCurrentUrl(t){let e;if(t!=null&&t!=="")e=t;else if(typeof globalThis<"u"&&"location"in globalThis)e=globalThis.location.href;else return{error:{message:"completeGithubOpenPlatformLoginFromCurrentUrl requires url or browser location",status:0}};let s;try{s=new URL(e).searchParams.get("exchange_code")}catch{return{error:{message:"invalid_callback_url",status:400}}}return s?.trim()?await this.loginWithGithubExchangeCode(s.trim()):{error:{message:"missing_exchange_code",status:400}}}async loginWithGithubExchangeCode(t){try{let e={"Content-Type":"application/json"};if(this.storage){let a=await this.storage.get(c);a!=null&&(e.Authorization=`Bearer ${a}`)}let s=await this.fetchImpl(this.url("github/openplatform/sign-in"),{method:"POST",headers:e,credentials:this.credentials,body:JSON.stringify({exchangeCode:t})}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let i=n?JSON.parse(n):null;return!i?.token||!i.user?{error:{message:"invalid_github_login_response",status:502}}:(this.storage&&(await this.storage.set(c,i.token),await this.storage.set(f,i.token),await this.storage.set(y,i.user)),{data:i})}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getGithubOpenPlatformIdentity(){try{let t={};if(this.storage){let i=await this.storage.get(c);i!=null&&(t.Authorization=`Bearer ${i}`)}let e=await this.fetchImpl(this.url("github/openplatform/identity"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}}),s=await e.text();if(!e.ok)return{error:{message:s||e.statusText,status:e.status}};let n=s?JSON.parse(s):null;return n?.sub?{data:n}:{error:{message:"invalid_github_identity_response",status:502}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}getWechatWebsiteOpenPlatformLoginUrl(t){let e=new URLSearchParams({return_url:t});return`${this.url("wechat-website/openplatform/login")}?${e.toString()}`}startWechatWebsiteOpenPlatformLogin(t){let e=this.getWechatWebsiteOpenPlatformLoginUrl(t);if(typeof globalThis<"u"&&"location"in globalThis){globalThis.location.href=e;return}throw new Error("startWechatWebsiteOpenPlatformLogin requires a browser environment with location")}async completeWechatWebsiteOpenPlatformLoginFromCurrentUrl(t){let e;if(t!=null&&t!=="")e=t;else if(typeof globalThis<"u"&&"location"in globalThis)e=globalThis.location.href;else return{error:{message:"completeWechatWebsiteOpenPlatformLoginFromCurrentUrl requires url or browser location",status:0}};let s;try{s=new URL(e).searchParams.get("exchange_code")}catch{return{error:{message:"invalid_callback_url",status:400}}}return s?.trim()?await this.loginWithWechatWebsiteExchangeCode(s.trim()):{error:{message:"missing_exchange_code",status:400}}}async loginWithWechatWebsiteExchangeCode(t){try{let e={"Content-Type":"application/json"};if(this.storage){let a=await this.storage.get(c);a!=null&&(e.Authorization=`Bearer ${a}`)}let s=await this.fetchImpl(this.url("wechat-website/openplatform/sign-in"),{method:"POST",headers:e,credentials:this.credentials,body:JSON.stringify({exchangeCode:t})}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let i=n?JSON.parse(n):null;return!i?.token||!i.user?{error:{message:"invalid_wechat_website_login_response",status:502}}:(this.storage&&(await this.storage.set(c,i.token),await this.storage.set(f,i.token),await this.storage.set(y,i.user)),{data:i})}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getWechatWebsiteOpenPlatformIdentity(){try{let t={};if(this.storage){let i=await this.storage.get(c);i!=null&&(t.Authorization=`Bearer ${i}`)}let e=await this.fetchImpl(this.url("wechat-website/openplatform/identity"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}}),s=await e.text();if(!e.ok)return{error:{message:s||e.statusText,status:e.status}};let n=s?JSON.parse(s):null;return n?.sub?{data:n}:{error:{message:"invalid_wechat_website_identity_response",status:502}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}url(t){let s=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${t.replace(/^\/+/,"")}`;return typeof console<"u"&&(console.warn("[NvwaAuth] request URL:",s),!s.startsWith("http://")&&!s.startsWith("https://")&&console.warn("[NvwaAuth] URL \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F\u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 Nvwa \u6784\u9020\u65F6\u4F20\u5165\u7684 baseUrl")),s}async getSession(){try{let t={};if(this.storage){let n=await this.storage.get(f)??await this.storage.get(c);n!=null&&(t.Authorization=`Bearer ${n}`)}let e=await this.fetchImpl(this.url("session"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return e.ok?{data:await e.json()}:{data:null,error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{data:null,error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signInWithEmail(t,e){try{let s=await this.fetchImpl(this.url("sign-in/email"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify({email:t,password:e})}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let i=n?JSON.parse(n):void 0;return i&&await this.persistLogin({user:i.user,session:i.session},s),{data:i}}catch(s){return{error:{message:s instanceof Error?s.message:String(s),status:0}}}}async signOut(){try{let t={};if(this.storage){let s=await this.storage.get(f)??await this.storage.get(c);s!=null&&(t.Authorization=`Bearer ${s}`)}let e=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return await this.clearLogin(),e.ok?{}:{error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signUp(t){let e=await this.postJson("sign-up/email",t);return e.data&&await this.persistLogin(e.data,e.response),e}async getToken(t){try{let e={};if(t)e.Authorization=`Bearer ${t}`;else if(this.storage){let a=await this.storage.get(f)??await this.storage.get(c);a!=null&&(e.Authorization=`Bearer ${a}`)}let s=await this.fetchImpl(this.url("token"),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let i=n?JSON.parse(n):void 0;return{data:i?.token!=null?{token:i.token}:void 0}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithUsername(t,e){let s=await this.postJson("sign-in/username",{username:t,password:e});return s.data&&await this.persistLogin(s.data,s.response),s}async signInWithPhoneNumber(t,e,s){let n=await this.postJson("sign-in/phone-number",{phoneNumber:t,password:e,rememberMe:s});return n.data&&await this.persistLogin(n.data,n.response),n}async sendPhoneNumberOtp(t){let e=await this.postJson("phone-number/send-otp",{phoneNumber:t});return e.error?{error:e.error}:{}}async verifyPhoneNumber(t,e){let s=await this.postJson("phone-number/verify",{phoneNumber:t,code:e});return s.data&&await this.persistLogin(s.data,s.response),s}async loginWithWeChatCode(t,e){try{let s={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(c);o!=null&&(s.Authorization=`Bearer ${o}`)}let n=await this.fetchImpl(this.url("wechat/openplatform/sign-in"),{method:"POST",headers:s,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),i=await n.text();if(!n.ok)return{error:{message:i||n.statusText,status:n.status}};let a=i?JSON.parse(i):null;return!a?.token||!a.user?{error:{message:"invalid_wechat_login_response",status:502}}:(this.storage&&(await this.storage.set(c,a.token),await this.storage.set(f,a.token),await this.storage.set(y,a.user)),{data:a})}catch(s){return{error:{message:s instanceof Error?s.message:String(s),status:0}}}}async loginWithAlipayCode(t,e){try{let s={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(c);o!=null&&(s.Authorization=`Bearer ${o}`)}let n=await this.fetchImpl(this.url("alipay/openplatform/sign-in"),{method:"POST",headers:s,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),i=await n.text();if(!n.ok)return{error:{message:i||n.statusText,status:n.status}};let a=i?JSON.parse(i):null;return!a?.token||!a.user?{error:{message:"invalid_alipay_login_response",status:502}}:(this.storage&&(await this.storage.set(c,a.token),await this.storage.set(f,a.token),await this.storage.set(y,a.user)),{data:a})}catch(s){return{error:{message:s instanceof Error?s.message:String(s),status:0}}}}async getWeChatOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(c);o!=null&&(e.Authorization=`Bearer ${o}`)}let s=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",n=await this.fetchImpl(this.url(`wechat/openplatform/identity${s}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),i=await n.text();if(!n.ok)return{error:{message:i||n.statusText,status:n.status}};let a=i?JSON.parse(i):null;return!a?.openid||!a.appId?{error:{message:"invalid_wechat_identity_response",status:502}}:{data:a}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getAlipayOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(c);o!=null&&(e.Authorization=`Bearer ${o}`)}let s=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",n=await this.fetchImpl(this.url(`alipay/openplatform/identity${s}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),i=await n.text();if(!n.ok)return{error:{message:i||n.statusText,status:n.status}};let a=i?JSON.parse(i):null;return!a?.openid||!a.appId?{error:{message:"invalid_alipay_identity_response",status:502}}:{data:a}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async postJson(t,e){try{let s=await this.fetchImpl(this.url(t),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify(e)}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let i=n?JSON.parse(n):void 0;return{data:i?.data??i??void 0,response:s}}catch(s){return{error:{message:s instanceof Error?s.message:String(s),status:0}}}}};import{Headers as G}from"@nvwa-app/nvwa-http-polyfill";var A=class{constructor(t,e,s){this.storage=t,this.customFetch=e,this.handleUnauthorized=s}async fetch(t,e){return await this.customFetch(t,e)}async fetchWithAuth(t,e){let s=await this.storage.get(c),n=new G(e?.headers);s&&n.set("Authorization",`Bearer ${s}`);let i=e?.method||"GET";if((i==="POST"||i==="PUT"||i==="PATCH")&&e?.body){let o=n.get("Content-Type");(!o||o.includes("text/plain"))&&n.set("Content-Type","application/json")}let a=await this.customFetch(t,{...e,headers:n});if(a.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return a}};import{Headers as q}from"@nvwa-app/nvwa-http-polyfill";var F="/storage",B=F+"/generateUploadUrl",C=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+B,{method:"POST",body:{fileName:t.name||t.fileName,fileSize:t.size||t.fileSize,fileType:t.type||t.fileType}}),{url:s}=await e.json();if(!s)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let n=await this.http.fetch(s,{method:"PUT",body:t,headers:new q({"Content-Type":t.type||t.fileType||"application/octet-stream"})}),{url:i}=await n.json();return{url:i.split("?")[0]}}};import{AbortController as J,Headers as O,URL as S}from"@nvwa-app/nvwa-http-polyfill";var z=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}},M=class{constructor(r){var t,e,s;this.shouldThrowOnError=!1,this.method=r.method,this.url=r.url,this.headers=new O(r.headers),this.schema=r.schema,this.body=r.body,this.shouldThrowOnError=(t=r.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=r.signal,this.isMaybeSingle=(e=r.isMaybeSingle)!==null&&e!==void 0?e:!1,this.urlLengthLimit=(s=r.urlLengthLimit)!==null&&s!==void 0?s:8e3,r.fetch?this.fetch=r.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(r,t){return this.headers=new O(this.headers),this.headers.set(r,t),this}then(r,t){var e=this;this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let s=this.fetch,n=s(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{let a=null,o=null,h=null,u=i.status,l=i.statusText;if(i.ok){var p,m;if(e.method!=="HEAD"){var d;let w=await i.text();w===""||(e.headers.get("Accept")==="text/csv"||e.headers.get("Accept")&&(!((d=e.headers.get("Accept"))===null||d===void 0)&&d.includes("application/vnd.pgrst.plan+text"))?o=w:o=JSON.parse(w))}let g=(p=e.headers.get("Prefer"))===null||p===void 0?void 0:p.match(/count=(exact|planned|estimated)/),b=(m=i.headers.get("content-range"))===null||m===void 0?void 0:m.split("/");g&&b&&b.length>1&&(h=parseInt(b[1])),e.isMaybeSingle&&Array.isArray(o)&&(o.length>1?(a={code:"PGRST116",details:`Results contain ${o.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},o=null,h=null,u=406,l="Not Acceptable"):o.length===1?o=o[0]:o=null)}else{let g=await i.text();try{a=JSON.parse(g),Array.isArray(a)&&i.status===404&&(o=[],a=null,u=200,l="OK")}catch{i.status===404&&g===""?(u=204,l="No Content"):a={message:g}}if(a&&e.shouldThrowOnError)throw new z(a)}return{error:a,data:o,count:h,status:u,statusText:l}});return this.shouldThrowOnError||(n=n.catch(i=>{var a;let o="",h="",u="",l=i?.cause;if(l){var p,m,d,g;let H=(p=l?.message)!==null&&p!==void 0?p:"",R=(m=l?.code)!==null&&m!==void 0?m:"";o=`${(d=i?.name)!==null&&d!==void 0?d:"FetchError"}: ${i?.message}`,o+=`
2
+
3
+ Caused by: ${(g=l?.name)!==null&&g!==void 0?g:"Error"}: ${H}`,R&&(o+=` (${R})`),l?.stack&&(o+=`
4
+ ${l.stack}`)}else{var b;o=(b=i?.stack)!==null&&b!==void 0?b:""}let w=this.url.toString().length;return i?.name==="AbortError"||i?.code==="ABORT_ERR"?(u="",h="Request was aborted (timeout or manual cancellation)",w>this.urlLengthLimit&&(h+=`. Note: Your request URL is ${w} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`)):(l?.name==="HeadersOverflowError"||l?.code==="UND_ERR_HEADERS_OVERFLOW")&&(u="",h="HTTP headers exceeded server limits (typically 16KB)",w>this.urlLengthLimit&&(h+=`. Your request URL is ${w} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{error:{message:`${(a=i?.name)!==null&&a!==void 0?a:"FetchError"}: ${i?.message}`,details:o,hint:h,code:u},data:null,count:null,status:0,statusText:""}})),n.then(r,t)}returns(){return this}overrideTypes(){return this}},D=class extends M{select(r){let t=!1,e=(r??"*").split("").map(s=>/\s/.test(s)&&!t?"":(s==='"'&&(t=!t),s)).join("");return this.url.searchParams.set("select",e),this.headers.append("Prefer","return=representation"),this}order(r,{ascending:t=!0,nullsFirst:e,foreignTable:s,referencedTable:n=s}={}){let i=n?`${n}.order`:"order",a=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${a?`${a},`:""}${r}.${t?"asc":"desc"}${e===void 0?"":e?".nullsfirst":".nullslast"}`),this}limit(r,{foreignTable:t,referencedTable:e=t}={}){let s=typeof e>"u"?"limit":`${e}.limit`;return this.url.searchParams.set(s,`${r}`),this}range(r,t,{foreignTable:e,referencedTable:s=e}={}){let n=typeof s>"u"?"offset":`${s}.offset`,i=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(n,`${r}`),this.url.searchParams.set(i,`${t-r+1}`),this}abortSignal(r){return this.signal=r,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return 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:r=!1,verbose:t=!1,settings:e=!1,buffers:s=!1,wal:n=!1,format:i="text"}={}){var a;let o=[r?"analyze":null,t?"verbose":null,e?"settings":null,s?"buffers":null,n?"wal":null].filter(Boolean).join("|"),h=(a=this.headers.get("Accept"))!==null&&a!==void 0?a:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${h}"; options=${o};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(r){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${r}`),this}},U=new RegExp("[,()]"),L=class extends D{eq(r,t){return this.url.searchParams.append(r,`eq.${t}`),this}neq(r,t){return this.url.searchParams.append(r,`neq.${t}`),this}gt(r,t){return this.url.searchParams.append(r,`gt.${t}`),this}gte(r,t){return this.url.searchParams.append(r,`gte.${t}`),this}lt(r,t){return this.url.searchParams.append(r,`lt.${t}`),this}lte(r,t){return this.url.searchParams.append(r,`lte.${t}`),this}like(r,t){return this.url.searchParams.append(r,`like.${t}`),this}likeAllOf(r,t){return this.url.searchParams.append(r,`like(all).{${t.join(",")}}`),this}likeAnyOf(r,t){return this.url.searchParams.append(r,`like(any).{${t.join(",")}}`),this}ilike(r,t){return this.url.searchParams.append(r,`ilike.${t}`),this}ilikeAllOf(r,t){return this.url.searchParams.append(r,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(r,t){return this.url.searchParams.append(r,`ilike(any).{${t.join(",")}}`),this}regexMatch(r,t){return this.url.searchParams.append(r,`match.${t}`),this}regexIMatch(r,t){return this.url.searchParams.append(r,`imatch.${t}`),this}is(r,t){return this.url.searchParams.append(r,`is.${t}`),this}isDistinct(r,t){return this.url.searchParams.append(r,`isdistinct.${t}`),this}in(r,t){let e=Array.from(new Set(t)).map(s=>typeof s=="string"&&U.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(r,`in.(${e})`),this}notIn(r,t){let e=Array.from(new Set(t)).map(s=>typeof s=="string"&&U.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(r,`not.in.(${e})`),this}contains(r,t){return typeof t=="string"?this.url.searchParams.append(r,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(r,`cs.{${t.join(",")}}`):this.url.searchParams.append(r,`cs.${JSON.stringify(t)}`),this}containedBy(r,t){return typeof t=="string"?this.url.searchParams.append(r,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(r,`cd.{${t.join(",")}}`):this.url.searchParams.append(r,`cd.${JSON.stringify(t)}`),this}rangeGt(r,t){return this.url.searchParams.append(r,`sr.${t}`),this}rangeGte(r,t){return this.url.searchParams.append(r,`nxl.${t}`),this}rangeLt(r,t){return this.url.searchParams.append(r,`sl.${t}`),this}rangeLte(r,t){return this.url.searchParams.append(r,`nxr.${t}`),this}rangeAdjacent(r,t){return this.url.searchParams.append(r,`adj.${t}`),this}overlaps(r,t){return typeof t=="string"?this.url.searchParams.append(r,`ov.${t}`):this.url.searchParams.append(r,`ov.{${t.join(",")}}`),this}textSearch(r,t,{config:e,type:s}={}){let n="";s==="plain"?n="pl":s==="phrase"?n="ph":s==="websearch"&&(n="w");let i=e===void 0?"":`(${e})`;return this.url.searchParams.append(r,`${n}fts${i}.${t}`),this}match(r){return Object.entries(r).filter(([t,e])=>e!==void 0).forEach(([t,e])=>{this.url.searchParams.append(t,`eq.${e}`)}),this}not(r,t,e){return this.url.searchParams.append(r,`not.${t}.${e}`),this}or(r,{foreignTable:t,referencedTable:e=t}={}){let s=e?`${e}.or`:"or";return this.url.searchParams.append(s,`(${r})`),this}filter(r,t,e){return this.url.searchParams.append(r,`${t}.${e}`),this}},Y=class{constructor(r,{headers:t={},schema:e,fetch:s,urlLengthLimit:n=8e3}){this.url=r,this.headers=new O(t),this.schema=e,this.fetch=s,this.urlLengthLimit=n}cloneRequestState(){return{url:new S(this.url.toString()),headers:new O(this.headers)}}select(r,t){let{head:e=!1,count:s}=t??{},n=e?"HEAD":"GET",i=!1,a=(r??"*").split("").map(u=>/\s/.test(u)&&!i?"":(u==='"'&&(i=!i),u)).join(""),{url:o,headers:h}=this.cloneRequestState();return o.searchParams.set("select",a),s&&h.append("Prefer",`count=${s}`),new L({method:n,url:o,headers:h,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}insert(r,{count:t,defaultToNull:e=!0}={}){var s;let n="POST",{url:i,headers:a}=this.cloneRequestState();if(t&&a.append("Prefer",`count=${t}`),e||a.append("Prefer","missing=default"),Array.isArray(r)){let o=r.reduce((h,u)=>h.concat(Object.keys(u)),[]);if(o.length>0){let h=[...new Set(o)].map(u=>`"${u}"`);i.searchParams.set("columns",h.join(","))}}return new L({method:n,url:i,headers:a,schema:this.schema,body:r,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch,urlLengthLimit:this.urlLengthLimit})}upsert(r,{onConflict:t,ignoreDuplicates:e=!1,count:s,defaultToNull:n=!0}={}){var i;let a="POST",{url:o,headers:h}=this.cloneRequestState();if(h.append("Prefer",`resolution=${e?"ignore":"merge"}-duplicates`),t!==void 0&&o.searchParams.set("on_conflict",t),s&&h.append("Prefer",`count=${s}`),n||h.append("Prefer","missing=default"),Array.isArray(r)){let u=r.reduce((l,p)=>l.concat(Object.keys(p)),[]);if(u.length>0){let l=[...new Set(u)].map(p=>`"${p}"`);o.searchParams.set("columns",l.join(","))}}return new L({method:a,url:o,headers:h,schema:this.schema,body:r,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch,urlLengthLimit:this.urlLengthLimit})}update(r,{count:t}={}){var e;let s="PATCH",{url:n,headers:i}=this.cloneRequestState();return t&&i.append("Prefer",`count=${t}`),new L({method:s,url:n,headers:i,schema:this.schema,body:r,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch,urlLengthLimit:this.urlLengthLimit})}delete({count:r}={}){var t;let e="DELETE",{url:s,headers:n}=this.cloneRequestState();return r&&n.append("Prefer",`count=${r}`),new L({method:e,url:s,headers:n,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch,urlLengthLimit:this.urlLengthLimit})}};function E(r){"@babel/helpers - typeof";return E=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},E(r)}function K(r,t){if(E(r)!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var s=e.call(r,t||"default");if(E(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function V(r){var t=K(r,"string");return E(t)=="symbol"?t:t+""}function X(r,t,e){return(t=V(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function N(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(r);t&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),e.push.apply(e,s)}return e}function x(r){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?N(Object(e),!0).forEach(function(s){X(r,s,e[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):N(Object(e)).forEach(function(s){Object.defineProperty(r,s,Object.getOwnPropertyDescriptor(e,s))})}return r}var $=class I{constructor(t,{headers:e={},schema:s,fetch:n,timeout:i,urlLengthLimit:a=8e3}={}){this.url=t,this.headers=new O(e),this.schemaName=s,this.urlLengthLimit=a;let o=n??globalThis.fetch;i!==void 0&&i>0?this.fetch=(h,u)=>{let l=new J,p=setTimeout(()=>l.abort(),i),m=u?.signal;if(m){if(m.aborted)return clearTimeout(p),o(h,u);let d=()=>{clearTimeout(p),l.abort()};return m.addEventListener("abort",d,{once:!0}),o(h,x(x({},u),{},{signal:l.signal})).finally(()=>{clearTimeout(p),m.removeEventListener("abort",d)})}return o(h,x(x({},u),{},{signal:l.signal})).finally(()=>clearTimeout(p))}:this.fetch=o}from(t){if(!t||typeof t!="string"||t.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new Y(new S(`${this.url}/${t}`),{headers:new O(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}schema(t){return new I(this.url,{headers:this.headers,schema:t,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}rpc(t,e={},{head:s=!1,get:n=!1,count:i}={}){var a;let o,h=new S(`${this.url}/rpc/${t}`),u,l=d=>d!==null&&typeof d=="object"&&(!Array.isArray(d)||d.some(l)),p=s&&Object.values(e).some(l);p?(o="POST",u=e):s||n?(o=s?"HEAD":"GET",Object.entries(e).filter(([d,g])=>g!==void 0).map(([d,g])=>[d,Array.isArray(g)?`{${g.join(",")}}`:`${g}`]).forEach(([d,g])=>{h.searchParams.append(d,g)})):(o="POST",u=e);let m=new O(this.headers);return p?m.set("Prefer",i?`count=${i},return=minimal`:"return=minimal"):i&&m.set("Prefer",`count=${i}`),new L({method:o,url:h,headers:m,schema:this.schemaName,body:u,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch,urlLengthLimit:this.urlLengthLimit})}};var Q="/entities",Tt=(r,t)=>new $(r+Q,{fetch:t.fetchWithAuth.bind(t)});var j=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 t=document.createElement("style");t.id="__nvwa-inspector-overlay-style",t.textContent=`
2
5
  .__nvwa-inspector-overlay {
3
6
  position: absolute;
4
7
  pointer-events: none;
@@ -30,4 +33,4 @@ var re=Object.create;var j=Object.defineProperty;var se=Object.getOwnPropertyDes
30
33
  max-width: 400px;
31
34
  word-break: break-all;
32
35
  }
33
- `,document.head.appendChild(t)}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(t){let e=document.createElement("div");return e.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${t}`,document.body.appendChild(e),e}updateOverlayPosition(t,e){if(!e.isConnected)return;let r=e.getBoundingClientRect(),s=window.scrollX||window.pageXOffset,n=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(t.style.left=`${r.left+s}px`,t.style.top=`${r.top+n}px`,t.style.width=`${r.width}px`,t.style.height=`${r.height}px`,t.style.display="block"):t.style.display="none"}removeOverlay(t){t&&t.parentNode&&t.parentNode.removeChild(t)}highlightElement(t,e){if(!t.isConnected)return;if(this.hoverElement===t&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,t);let o=this.createTooltip();e?o.textContent=e:o.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let h=t.getBoundingClientRect();o.style.left=`${h.left+window.scrollX}px`,o.style.top=`${h.top+window.scrollY-o.offsetHeight-8}px`,h.top<o.offsetHeight+8&&(o.style.top=`${h.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let r=this.createOverlay("hover");this.updateOverlayPosition(r,t),this.hoverOverlay=r,this.hoverElement=t;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 n=this.createTooltip();e?n.textContent=e:n.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,n.style.display="block";let a=t.getBoundingClientRect();n.style.left=`${a.left+window.scrollX}px`,n.style.top=`${a.top+window.scrollY-n.offsetHeight-8}px`,a.top<n.offsetHeight+8&&(n.style.top=`${a.bottom+window.scrollY+8}px`)}selectElement(t,e){if(!t.isConnected)return;if(this.selectedElement===t&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,t);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,t),this.selectedOverlay=r,this.selectedElement=t;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 t=document.getElementById("__nvwa-inspector-overlay-style");t&&t.parentNode&&t.parentNode.removeChild(t)}};function zr(i="root"){if(typeof document>"u")return null;let t=document.getElementById(i)||document.body;if(!t)return null;let e=t.querySelector("[data-source-location]");if(e){let r=e.getAttribute("data-source-location");if(r)return r}if(t.firstElementChild){let s=t.firstElementChild.getAttribute("data-source-location");if(s)return s}return null}u();function Vr(i){let t=i;if(typeof t.kind=="string")return t;if(typeof t.tradeNO=="string")return{kind:"alipay_miniprogram",tradeNO:t.tradeNO};if(typeof t.clientSecret=="string")return{kind:"stripe_client_secret",clientSecret:t.clientSecret};if(typeof t.redirectUrl=="string")return{kind:"redirect_url",redirectUrl:t.redirectUrl};if(typeof t.formHtml=="string")return{kind:"alipay_page",formHtml:t.formHtml};if(typeof t.codeUrl=="string")return{kind:"wechat_native_qr",codeUrl:t.codeUrl};let e=t.jsapiPayParams??t;return typeof e.timeStamp=="string"&&typeof e.nonceStr=="string"&&typeof e.package=="string"&&typeof e.paySign=="string"&&typeof e.appId=="string"?{kind:"wechat_jsapi",mode:"jsapi",jsapiPayParams:{appId:e.appId,timeStamp:e.timeStamp,nonceStr:e.nonceStr,package:e.package,signType:e.signType??"RSA",paySign:e.paySign}}:null}function Qr(i,t,e){return t.requestPayment(i.payParams,e)}export{q as AbortController,U as AbortSignal,F as AuthClient,g as CURRENT_JWT_KEY,Se as ENTITIES_BASE_PATH,ce as FILE_STORAGE_BASE_PATH,pe as GENERATE_UPLOAD_URL_PATH,_ as Headers,O as LOGIN_TOKEN_KEY,E as LOGIN_USER_PROFILE_KEY,gt as NvwaEdgeFunctions,yt as NvwaFileStorage,mt as NvwaHttpClient,ee as OverlayManager,H as Request,W as Response,ft as SET_AUTH_TOKEN_HEADER,N as URL,$ as URLSearchParams,Dr as createPostgrestClient,zr as getSourceLocationFromDOM,Vr as normalizePayParams,Qe as polyfill,Qr as requestPaymentFromOrderResult};
36
+ `,document.head.appendChild(t)}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(t){let e=document.createElement("div");return e.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${t}`,document.body.appendChild(e),e}updateOverlayPosition(t,e){if(!e.isConnected)return;let s=e.getBoundingClientRect(),n=window.scrollX||window.pageXOffset,i=window.scrollY||window.pageYOffset;s.width>0&&s.height>0?(t.style.left=`${s.left+n}px`,t.style.top=`${s.top+i}px`,t.style.width=`${s.width}px`,t.style.height=`${s.height}px`,t.style.display="block"):t.style.display="none"}removeOverlay(t){t&&t.parentNode&&t.parentNode.removeChild(t)}highlightElement(t,e){if(!t.isConnected)return;if(this.hoverElement===t&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,t);let o=this.createTooltip();e?o.textContent=e:o.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let h=t.getBoundingClientRect();o.style.left=`${h.left+window.scrollX}px`,o.style.top=`${h.top+window.scrollY-o.offsetHeight-8}px`,h.top<o.offsetHeight+8&&(o.style.top=`${h.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let s=this.createOverlay("hover");this.updateOverlayPosition(s,t),this.hoverOverlay=s,this.hoverElement=t;let n=()=>{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=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n);let i=this.createTooltip();e?i.textContent=e:i.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,i.style.display="block";let a=t.getBoundingClientRect();i.style.left=`${a.left+window.scrollX}px`,i.style.top=`${a.top+window.scrollY-i.offsetHeight-8}px`,a.top<i.offsetHeight+8&&(i.style.top=`${a.bottom+window.scrollY+8}px`)}selectElement(t,e){if(!t.isConnected)return;if(this.selectedElement===t&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,t);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let s=this.createOverlay("selected");this.updateOverlayPosition(s,t),this.selectedOverlay=s,this.selectedElement=t;let n=()=>{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=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n)}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 t=document.getElementById("__nvwa-inspector-overlay-style");t&&t.parentNode&&t.parentNode.removeChild(t)}};function _t(r="root"){if(typeof document>"u")return null;let t=document.getElementById(r)||document.body;if(!t)return null;let e=t.querySelector("[data-source-location]");if(e){let s=e.getAttribute("data-source-location");if(s)return s}if(t.firstElementChild){let n=t.firstElementChild.getAttribute("data-source-location");if(n)return n}return null}function Ct(r){let t=r;if(typeof t.kind=="string")return t;if(typeof t.tradeNO=="string")return{kind:"alipay_miniprogram",tradeNO:t.tradeNO};if(typeof t.clientSecret=="string")return{kind:"stripe_client_secret",clientSecret:t.clientSecret};if(typeof t.redirectUrl=="string")return{kind:"redirect_url",redirectUrl:t.redirectUrl};if(typeof t.formHtml=="string")return{kind:"alipay_page",formHtml:t.formHtml};if(typeof t.codeUrl=="string")return{kind:"wechat_native_qr",codeUrl:t.codeUrl};let e=t.jsapiPayParams??t;return typeof e.timeStamp=="string"&&typeof e.nonceStr=="string"&&typeof e.package=="string"&&typeof e.paySign=="string"&&typeof e.appId=="string"?{kind:"wechat_jsapi",mode:"jsapi",jsapiPayParams:{appId:e.appId,timeStamp:e.timeStamp,nonceStr:e.nonceStr,package:e.package,signType:e.signType??"RSA",paySign:e.paySign}}:null}function Ut(r,t,e){return t.requestPayment(r.payParams,e)}export{T as AuthClient,c as CURRENT_JWT_KEY,Q as ENTITIES_BASE_PATH,F as FILE_STORAGE_BASE_PATH,B as GENERATE_UPLOAD_URL_PATH,f as LOGIN_TOKEN_KEY,y as LOGIN_USER_PROFILE_KEY,_ as NvwaEdgeFunctions,C as NvwaFileStorage,A as NvwaHttpClient,j as OverlayManager,k as SET_AUTH_TOKEN_HEADER,Tt as createPostgrestClient,_t as getSourceLocationFromDOM,Ct as normalizePayParams,Ut as requestPaymentFromOrderResult};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nvwa-app/sdk-core",
3
- "version": "6.8.1",
3
+ "version": "6.9.0",
4
4
  "description": "NVWA跨端通用工具类核心接口",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -29,7 +29,8 @@
29
29
  "directory": "packages/sdk/core"
30
30
  },
31
31
  "dependencies": {
32
- "@nvwa-app/postgrest-js": "^2.77.0"
32
+ "@nvwa-app/nvwa-http-polyfill": "^0.1.0",
33
+ "@nvwa-app/postgrest-js": "^2.100.1"
33
34
  },
34
35
  "devDependencies": {
35
36
  "@types/node": "^24.3.0",