@nvwa-app/sdk-core 5.0.1 → 6.0.3
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 +74 -7
- package/dist/index.d.ts +74 -7
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -310,19 +310,48 @@ declare class PaymentClient {
|
|
|
310
310
|
* AuthClient 调用项目 runtime 的 /auth 接口(better-auth)。
|
|
311
311
|
*/
|
|
312
312
|
declare const CURRENT_JWT_KEY = "nvwa_current_jwt";
|
|
313
|
+
declare const LOGIN_TOKEN_KEY = "nvwa_login_token";
|
|
314
|
+
declare const LOGIN_USER_PROFILE_KEY = "nvwa_user_profile";
|
|
315
|
+
interface AuthUser {
|
|
316
|
+
id: string;
|
|
317
|
+
name?: string;
|
|
318
|
+
email?: string;
|
|
319
|
+
username?: string;
|
|
320
|
+
displayUsername?: string;
|
|
321
|
+
phoneNumber?: string;
|
|
322
|
+
role?: string;
|
|
323
|
+
image?: string;
|
|
324
|
+
[k: string]: unknown;
|
|
325
|
+
}
|
|
313
326
|
interface AuthSession {
|
|
314
|
-
user?:
|
|
315
|
-
id: string;
|
|
316
|
-
email?: string;
|
|
317
|
-
name?: string;
|
|
318
|
-
[k: string]: unknown;
|
|
319
|
-
};
|
|
327
|
+
user?: AuthUser;
|
|
320
328
|
session?: {
|
|
321
329
|
token?: string;
|
|
322
330
|
[k: string]: unknown;
|
|
323
331
|
};
|
|
324
332
|
[k: string]: unknown;
|
|
325
333
|
}
|
|
334
|
+
interface AuthResult {
|
|
335
|
+
data?: {
|
|
336
|
+
user?: AuthUser;
|
|
337
|
+
token?: string;
|
|
338
|
+
session?: {
|
|
339
|
+
token?: string;
|
|
340
|
+
};
|
|
341
|
+
};
|
|
342
|
+
error?: {
|
|
343
|
+
message: string;
|
|
344
|
+
status: number;
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
interface SignUpBody {
|
|
348
|
+
email: string;
|
|
349
|
+
name: string;
|
|
350
|
+
password: string;
|
|
351
|
+
username?: string;
|
|
352
|
+
displayUsername?: string;
|
|
353
|
+
image?: string;
|
|
354
|
+
}
|
|
326
355
|
interface AuthClientOptions {
|
|
327
356
|
/** Auth 路径,默认 "/auth"(与 runtime 的 basePath 一致) */
|
|
328
357
|
authPath?: string;
|
|
@@ -368,6 +397,44 @@ declare class AuthClient {
|
|
|
368
397
|
status: number;
|
|
369
398
|
};
|
|
370
399
|
}>;
|
|
400
|
+
/**
|
|
401
|
+
* 注册(邮箱 + 用户名等)。
|
|
402
|
+
*/
|
|
403
|
+
signUp(body: SignUpBody): Promise<AuthResult>;
|
|
404
|
+
/**
|
|
405
|
+
* 获取 JWT。可选传入当前 Bearer token(如 uniapp 从 storage 取)。
|
|
406
|
+
*/
|
|
407
|
+
getToken(bearerToken?: string): Promise<{
|
|
408
|
+
data?: {
|
|
409
|
+
token: string;
|
|
410
|
+
};
|
|
411
|
+
error?: {
|
|
412
|
+
message: string;
|
|
413
|
+
status: number;
|
|
414
|
+
};
|
|
415
|
+
}>;
|
|
416
|
+
/**
|
|
417
|
+
* 用户名密码登录。
|
|
418
|
+
*/
|
|
419
|
+
signInWithUsername(username: string, password: string): Promise<AuthResult>;
|
|
420
|
+
/**
|
|
421
|
+
* 手机号密码登录。
|
|
422
|
+
*/
|
|
423
|
+
signInWithPhoneNumber(phoneNumber: string, password: string, rememberMe?: boolean): Promise<AuthResult>;
|
|
424
|
+
/**
|
|
425
|
+
* 发送手机号验证码。
|
|
426
|
+
*/
|
|
427
|
+
sendPhoneNumberOtp(phoneNumber: string): Promise<{
|
|
428
|
+
error?: {
|
|
429
|
+
message: string;
|
|
430
|
+
status: number;
|
|
431
|
+
};
|
|
432
|
+
}>;
|
|
433
|
+
/**
|
|
434
|
+
* 手机号验证码登录/验证。
|
|
435
|
+
*/
|
|
436
|
+
verifyPhoneNumber(phoneNumber: string, code: string): Promise<AuthResult>;
|
|
437
|
+
private postJson;
|
|
371
438
|
}
|
|
372
439
|
|
|
373
440
|
interface INvwa {
|
|
@@ -377,4 +444,4 @@ interface INvwa {
|
|
|
377
444
|
skill: NvwaSkill;
|
|
378
445
|
}
|
|
379
446
|
|
|
380
|
-
export { AbortController, AbortSignal, AuthClient, type AuthClientOptions, type AuthSession, CURRENT_JWT_KEY, type CreatePaymentParams, type CreatePaymentResponse, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, Headers, type HoverInspectorMessage, type HttpMethod, type HttpUploadFileResponse, type INvwa, type IframeSourceLocationMessage, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, NvwaSkill, type OrderStatus, OverlayManager, type PayParams, PaymentClient, type PaymentFetch, type PaymentOrderStatus, type PaymentPlatform, Request$1 as Request, type RequestInfo, type RequestInit$1 as RequestInit, Response$1 as Response, type ResponseInit, type SkillExecuteResponse, URL$1 as URL, URLSearchParams, createPostgrestClient, getSourceLocationFromDOM, polyfill };
|
|
447
|
+
export { AbortController, AbortSignal, AuthClient, type AuthClientOptions, type AuthResult, type AuthSession, type AuthUser, CURRENT_JWT_KEY, type CreatePaymentParams, type CreatePaymentResponse, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, Headers, type HoverInspectorMessage, type HttpMethod, type HttpUploadFileResponse, type INvwa, type IframeSourceLocationMessage, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, NvwaSkill, type OrderStatus, OverlayManager, type PayParams, PaymentClient, type PaymentFetch, type PaymentOrderStatus, type PaymentPlatform, Request$1 as Request, type RequestInfo, type RequestInit$1 as RequestInit, Response$1 as Response, type ResponseInit, type SignUpBody, type SkillExecuteResponse, URL$1 as URL, URLSearchParams, createPostgrestClient, getSourceLocationFromDOM, polyfill };
|
package/dist/index.d.ts
CHANGED
|
@@ -310,19 +310,48 @@ declare class PaymentClient {
|
|
|
310
310
|
* AuthClient 调用项目 runtime 的 /auth 接口(better-auth)。
|
|
311
311
|
*/
|
|
312
312
|
declare const CURRENT_JWT_KEY = "nvwa_current_jwt";
|
|
313
|
+
declare const LOGIN_TOKEN_KEY = "nvwa_login_token";
|
|
314
|
+
declare const LOGIN_USER_PROFILE_KEY = "nvwa_user_profile";
|
|
315
|
+
interface AuthUser {
|
|
316
|
+
id: string;
|
|
317
|
+
name?: string;
|
|
318
|
+
email?: string;
|
|
319
|
+
username?: string;
|
|
320
|
+
displayUsername?: string;
|
|
321
|
+
phoneNumber?: string;
|
|
322
|
+
role?: string;
|
|
323
|
+
image?: string;
|
|
324
|
+
[k: string]: unknown;
|
|
325
|
+
}
|
|
313
326
|
interface AuthSession {
|
|
314
|
-
user?:
|
|
315
|
-
id: string;
|
|
316
|
-
email?: string;
|
|
317
|
-
name?: string;
|
|
318
|
-
[k: string]: unknown;
|
|
319
|
-
};
|
|
327
|
+
user?: AuthUser;
|
|
320
328
|
session?: {
|
|
321
329
|
token?: string;
|
|
322
330
|
[k: string]: unknown;
|
|
323
331
|
};
|
|
324
332
|
[k: string]: unknown;
|
|
325
333
|
}
|
|
334
|
+
interface AuthResult {
|
|
335
|
+
data?: {
|
|
336
|
+
user?: AuthUser;
|
|
337
|
+
token?: string;
|
|
338
|
+
session?: {
|
|
339
|
+
token?: string;
|
|
340
|
+
};
|
|
341
|
+
};
|
|
342
|
+
error?: {
|
|
343
|
+
message: string;
|
|
344
|
+
status: number;
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
interface SignUpBody {
|
|
348
|
+
email: string;
|
|
349
|
+
name: string;
|
|
350
|
+
password: string;
|
|
351
|
+
username?: string;
|
|
352
|
+
displayUsername?: string;
|
|
353
|
+
image?: string;
|
|
354
|
+
}
|
|
326
355
|
interface AuthClientOptions {
|
|
327
356
|
/** Auth 路径,默认 "/auth"(与 runtime 的 basePath 一致) */
|
|
328
357
|
authPath?: string;
|
|
@@ -368,6 +397,44 @@ declare class AuthClient {
|
|
|
368
397
|
status: number;
|
|
369
398
|
};
|
|
370
399
|
}>;
|
|
400
|
+
/**
|
|
401
|
+
* 注册(邮箱 + 用户名等)。
|
|
402
|
+
*/
|
|
403
|
+
signUp(body: SignUpBody): Promise<AuthResult>;
|
|
404
|
+
/**
|
|
405
|
+
* 获取 JWT。可选传入当前 Bearer token(如 uniapp 从 storage 取)。
|
|
406
|
+
*/
|
|
407
|
+
getToken(bearerToken?: string): Promise<{
|
|
408
|
+
data?: {
|
|
409
|
+
token: string;
|
|
410
|
+
};
|
|
411
|
+
error?: {
|
|
412
|
+
message: string;
|
|
413
|
+
status: number;
|
|
414
|
+
};
|
|
415
|
+
}>;
|
|
416
|
+
/**
|
|
417
|
+
* 用户名密码登录。
|
|
418
|
+
*/
|
|
419
|
+
signInWithUsername(username: string, password: string): Promise<AuthResult>;
|
|
420
|
+
/**
|
|
421
|
+
* 手机号密码登录。
|
|
422
|
+
*/
|
|
423
|
+
signInWithPhoneNumber(phoneNumber: string, password: string, rememberMe?: boolean): Promise<AuthResult>;
|
|
424
|
+
/**
|
|
425
|
+
* 发送手机号验证码。
|
|
426
|
+
*/
|
|
427
|
+
sendPhoneNumberOtp(phoneNumber: string): Promise<{
|
|
428
|
+
error?: {
|
|
429
|
+
message: string;
|
|
430
|
+
status: number;
|
|
431
|
+
};
|
|
432
|
+
}>;
|
|
433
|
+
/**
|
|
434
|
+
* 手机号验证码登录/验证。
|
|
435
|
+
*/
|
|
436
|
+
verifyPhoneNumber(phoneNumber: string, code: string): Promise<AuthResult>;
|
|
437
|
+
private postJson;
|
|
371
438
|
}
|
|
372
439
|
|
|
373
440
|
interface INvwa {
|
|
@@ -377,4 +444,4 @@ interface INvwa {
|
|
|
377
444
|
skill: NvwaSkill;
|
|
378
445
|
}
|
|
379
446
|
|
|
380
|
-
export { AbortController, AbortSignal, AuthClient, type AuthClientOptions, type AuthSession, CURRENT_JWT_KEY, type CreatePaymentParams, type CreatePaymentResponse, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, Headers, type HoverInspectorMessage, type HttpMethod, type HttpUploadFileResponse, type INvwa, type IframeSourceLocationMessage, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, NvwaSkill, type OrderStatus, OverlayManager, type PayParams, PaymentClient, type PaymentFetch, type PaymentOrderStatus, type PaymentPlatform, Request$1 as Request, type RequestInfo, type RequestInit$1 as RequestInit, Response$1 as Response, type ResponseInit, type SkillExecuteResponse, URL$1 as URL, URLSearchParams, createPostgrestClient, getSourceLocationFromDOM, polyfill };
|
|
447
|
+
export { AbortController, AbortSignal, AuthClient, type AuthClientOptions, type AuthResult, type AuthSession, type AuthUser, CURRENT_JWT_KEY, type CreatePaymentParams, type CreatePaymentResponse, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, Headers, type HoverInspectorMessage, type HttpMethod, type HttpUploadFileResponse, type INvwa, type IframeSourceLocationMessage, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, NvwaSkill, type OrderStatus, OverlayManager, type PayParams, PaymentClient, type PaymentFetch, type PaymentOrderStatus, type PaymentPlatform, Request$1 as Request, type RequestInfo, type RequestInit$1 as RequestInit, Response$1 as Response, type ResponseInit, type SignUpBody, type SkillExecuteResponse, URL$1 as URL, URLSearchParams, createPostgrestClient, getSourceLocationFromDOM, polyfill };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var nt=Object.create;var L=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var at=Object.getPrototypeOf,lt=Object.prototype.hasOwnProperty;var me=(s,e)=>()=>(s&&(e=s(s=0)),e);var _=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),ye=(s,e)=>{for(var t in e)L(s,t,{get:e[t],enumerable:!0})},ge=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ot(e))!lt.call(s,n)&&n!==t&&L(s,n,{get:()=>e[n],enumerable:!(r=it(e,n))||r.enumerable});return s};var ct=(s,e,t)=>(t=s!=null?nt(at(s)):{},ge(e||!s||!s.__esModule?L(t,"default",{value:s,enumerable:!0}):t,s)),E=s=>ge(L({},"__esModule",{value:!0}),s);var c=me(()=>{"use strict"});var x={};ye(x,{__addDisposableResource:()=>ze,__assign:()=>M,__asyncDelegator:()=>Le,__asyncGenerator:()=>Ue,__asyncValues:()=>Ne,__await:()=>T,__awaiter:()=>Re,__classPrivateFieldGet:()=>De,__classPrivateFieldIn:()=>Fe,__classPrivateFieldSet:()=>Be,__createBinding:()=>D,__decorate:()=>_e,__disposeResources:()=>Ge,__esDecorate:()=>xe,__exportStar:()=>Ae,__extends:()=>be,__generator:()=>je,__importDefault:()=>qe,__importStar:()=>Me,__makeTemplateObject:()=>ke,__metadata:()=>Te,__param:()=>Ee,__propKey:()=>Se,__read:()=>V,__rest:()=>Pe,__rewriteRelativeImportExtension:()=>Je,__runInitializers:()=>Oe,__setFunctionName:()=>$e,__spread:()=>Ce,__spreadArray:()=>Ie,__spreadArrays:()=>He,__values:()=>q,default:()=>mt});function be(s,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");J(s,e);function t(){this.constructor=s}s.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Pe(s,e){var t={};for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&e.indexOf(r)<0&&(t[r]=s[r]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(s);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(s,r[n])&&(t[r[n]]=s[r[n]]);return t}function _e(s,e,t,r){var n=arguments.length,i=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(s,e,t,r);else for(var a=s.length-1;a>=0;a--)(o=s[a])&&(i=(n<3?o(i):n>3?o(e,t,i):o(e,t))||i);return n>3&&i&&Object.defineProperty(e,t,i),i}function Ee(s,e){return function(t,r){e(t,r,s)}}function xe(s,e,t,r,n,i){function o(P){if(P!==void 0&&typeof P!="function")throw new TypeError("Function expected");return P}for(var a=r.kind,u=a==="getter"?"get":a==="setter"?"set":"value",l=!e&&s?r.static?s:s.prototype:null,h=e||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,m=!1,p=t.length-1;p>=0;p--){var y={};for(var b in r)y[b]=b==="access"?{}:r[b];for(var b in r.access)y.access[b]=r.access[b];y.addInitializer=function(P){if(m)throw new TypeError("Cannot add initializers after decoration has completed");i.push(o(P||null))};var g=(0,t[p])(a==="accessor"?{get:h.get,set:h.set}:h[u],y);if(a==="accessor"){if(g===void 0)continue;if(g===null||typeof g!="object")throw new TypeError("Object expected");(d=o(g.get))&&(h.get=d),(d=o(g.set))&&(h.set=d),(d=o(g.init))&&n.unshift(d)}else(d=o(g))&&(a==="field"?n.unshift(d):h[u]=d)}l&&Object.defineProperty(l,r.name,h),m=!0}function Oe(s,e,t){for(var r=arguments.length>2,n=0;n<e.length;n++)t=r?e[n].call(s,t):e[n].call(s);return r?t:void 0}function Se(s){return typeof s=="symbol"?s:"".concat(s)}function $e(s,e,t){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(s,"name",{configurable:!0,value:t?"".concat(t," ",e):e})}function Te(s,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,e)}function Re(s,e,t,r){function n(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(h){try{l(r.next(h))}catch(d){o(d)}}function u(h){try{l(r.throw(h))}catch(d){o(d)}}function l(h){h.done?i(h.value):n(h.value).then(a,u)}l((r=r.apply(s,e||[])).next())})}function je(s,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,n,i,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return u([l,h])}}function u(l){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(t=0)),t;)try{if(r=1,n&&(i=l[0]&2?n.return:l[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,l[1])).done)return i;switch(n=0,i&&(l=[l[0]&2,i.value]),l[0]){case 0:case 1:i=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,n=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!i||l[1]>i[0]&&l[1]<i[3])){t.label=l[1];break}if(l[0]===6&&t.label<i[1]){t.label=i[1],i=l;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(l);break}i[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(s,t)}catch(h){l=[6,h],n=0}finally{r=i=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Ae(s,e){for(var t in s)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&D(e,s,t)}function q(s){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&s[e],r=0;if(t)return t.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&r>=s.length&&(s=void 0),{value:s&&s[r++],done:!s}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function V(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var r=t.call(s),n,i=[],o;try{for(;(e===void 0||e-- >0)&&!(n=r.next()).done;)i.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(o)throw o.error}}return i}function Ce(){for(var s=[],e=0;e<arguments.length;e++)s=s.concat(V(arguments[e]));return s}function He(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var r=Array(s),n=0,e=0;e<t;e++)for(var i=arguments[e],o=0,a=i.length;o<a;o++,n++)r[n]=i[o];return r}function Ie(s,e,t){if(t||arguments.length===2)for(var r=0,n=e.length,i;r<n;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return s.concat(i||Array.prototype.slice.call(e))}function T(s){return this instanceof T?(this.v=s,this):new T(s)}function Ue(s,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(s,e||[]),n,i=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),n[Symbol.asyncIterator]=function(){return this},n;function o(p){return function(y){return Promise.resolve(y).then(p,d)}}function a(p,y){r[p]&&(n[p]=function(b){return new Promise(function(g,P){i.push([p,b,g,P])>1||u(p,b)})},y&&(n[p]=y(n[p])))}function u(p,y){try{l(r[p](y))}catch(b){m(i[0][3],b)}}function l(p){p.value instanceof T?Promise.resolve(p.value.v).then(h,d):m(i[0][2],p)}function h(p){u("next",p)}function d(p){u("throw",p)}function m(p,y){p(y),i.shift(),i.length&&u(i[0][0],i[0][1])}}function Le(s){var e,t;return e={},r("next"),r("throw",function(n){throw n}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(n,i){e[n]=s[n]?function(o){return(t=!t)?{value:T(s[n](o)),done:!1}:i?i(o):o}:i}}function Ne(s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=s[Symbol.asyncIterator],t;return e?e.call(s):(s=typeof q=="function"?q(s):s[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(i){t[i]=s[i]&&function(o){return new Promise(function(a,u){o=s[i](o),n(a,u,o.done,o.value)})}}function n(i,o,a,u){Promise.resolve(u).then(function(l){i({value:l,done:a})},o)}}function ke(s,e){return Object.defineProperty?Object.defineProperty(s,"raw",{value:e}):s.raw=e,s}function Me(s){if(s&&s.__esModule)return s;var e={};if(s!=null)for(var t=W(s),r=0;r<t.length;r++)t[r]!=="default"&&D(e,s,t[r]);return pt(e,s),e}function qe(s){return s&&s.__esModule?s:{default:s}}function De(s,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?s!==e||!r:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(s):r?r.value:e.get(s)}function Be(s,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?s!==e||!n:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(s,t):n?n.value=t:e.set(s,t),t}function Fe(s,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof s=="function"?e===s:s.has(e)}function ze(s,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var r,n;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=e[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=e[Symbol.dispose],t&&(n=r)}if(typeof r!="function")throw new TypeError("Object not disposable.");n&&(r=function(){try{n.call(this)}catch(i){return Promise.reject(i)}}),s.stack.push({value:e,dispose:r,async:t})}else t&&s.stack.push({async:!0});return e}function Ge(s){function e(i){s.error=s.hasError?new ft(i,s.error,"An error was suppressed during disposal."):i,s.hasError=!0}var t,r=0;function n(){for(;t=s.stack.pop();)try{if(!t.async&&r===1)return r=0,s.stack.push(t),Promise.resolve().then(n);if(t.dispose){var i=t.dispose.call(t.value);if(t.async)return r|=2,Promise.resolve(i).then(n,function(o){return e(o),n()})}else r|=1}catch(o){e(o)}if(r===1)return s.hasError?Promise.reject(s.error):Promise.resolve();if(s.hasError)throw s.error}return n()}function Je(s,e){return typeof s=="string"&&/^\.\.?\//.test(s)?s.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,r,n,i,o){return r?e?".jsx":".js":n&&(!i||!o)?t:n+i+"."+o.toLowerCase()+"js"}):s}var J,M,D,pt,W,ft,mt,O=me(()=>{"use strict";c();J=function(s,e){return J=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])},J(s,e)};M=function(){return M=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},M.apply(this,arguments)};D=Object.create?(function(s,e,t,r){r===void 0&&(r=t);var n=Object.getOwnPropertyDescriptor(e,t);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(s,r,n)}):(function(s,e,t,r){r===void 0&&(r=t),s[r]=e[t]});pt=Object.create?(function(s,e){Object.defineProperty(s,"default",{enumerable:!0,value:e})}):function(s,e){s.default=e},W=function(s){return W=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},W(s)};ft=typeof SuppressedError=="function"?SuppressedError:function(s,e,t){var r=new Error(t);return r.name="SuppressedError",r.error=s,r.suppressed=e,r};mt={__extends:be,__assign:M,__rest:Pe,__decorate:_e,__param:Ee,__esDecorate:xe,__runInitializers:Oe,__propKey:Se,__setFunctionName:$e,__metadata:Te,__awaiter:Re,__generator:je,__createBinding:D,__exportStar:Ae,__values:q,__read:V,__spread:Ce,__spreadArrays:He,__spreadArray:Ie,__await:T,__asyncGenerator:Ue,__asyncDelegator:Le,__asyncValues:Ne,__makeTemplateObject:ke,__importStar:Me,__importDefault:qe,__classPrivateFieldGet:De,__classPrivateFieldSet:Be,__classPrivateFieldIn:Fe,__addDisposableResource:ze,__disposeResources:Ge,__rewriteRelativeImportExtension:Je}});var K=_(Q=>{"use strict";c();Object.defineProperty(Q,"__esModule",{value:!0});var Y=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};Q.default=Y});var ee=_(Z=>{"use strict";c();Object.defineProperty(Z,"__esModule",{value:!0});var yt=(O(),E(x)),gt=yt.__importDefault(K()),X=class{constructor(e){var t,r;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(r=e.isMaybeSingle)!==null&&r!==void 0?r:!1,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let r=this.fetch,n=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{var o,a,u,l;let h=null,d=null,m=null,p=i.status,y=i.statusText;if(i.ok){if(this.method!=="HEAD"){let U=await i.text();U===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((o=this.headers.get("Accept"))===null||o===void 0)&&o.includes("application/vnd.pgrst.plan+text"))?d=U:d=JSON.parse(U))}let g=(a=this.headers.get("Prefer"))===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),P=(u=i.headers.get("content-range"))===null||u===void 0?void 0:u.split("/");g&&P&&P.length>1&&(m=parseInt(P[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(h={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,m=null,p=406,y="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let g=await i.text();try{h=JSON.parse(g),Array.isArray(h)&&i.status===404&&(d=[],h=null,p=200,y="OK")}catch{i.status===404&&g===""?(p=204,y="No Content"):h={message:g}}if(h&&this.isMaybeSingle&&(!((l=h?.details)===null||l===void 0)&&l.includes("0 rows"))&&(h=null,p=200,y="OK"),h&&this.shouldThrowOnError)throw new gt.default(h)}return{error:h,data:d,count:m,status:p,statusText:y}});return this.shouldThrowOnError||(n=n.catch(i=>{var o,a,u;return{error:{message:`${(o=i?.name)!==null&&o!==void 0?o:"FetchError"}: ${i?.message}`,details:`${(a=i?.stack)!==null&&a!==void 0?a:""}`,hint:"",code:`${(u=i?.code)!==null&&u!==void 0?u:""}`},data:null,count:null,status:0,statusText:""}})),n.then(e,t)}returns(){return this}overrideTypes(){return this}};Z.default=X});var se=_(re=>{"use strict";c();Object.defineProperty(re,"__esModule",{value:!0});var vt=(O(),E(x)),wt=vt.__importDefault(ee()),te=class extends wt.default{select(e){let t=!1,r=(e??"*").split("").map(n=>/\s/.test(n)&&!t?"":(n==='"'&&(t=!t),n)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:n,referencedTable:i=n}={}){let o=i?`${i}.order`:"order",a=this.url.searchParams.get(o);return this.url.searchParams.set(o,`${a?`${a},`:""}${e}.${t?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:r=t}={}){let n=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(n,`${e}`),this}range(e,t,{foreignTable:r,referencedTable:n=r}={}){let i=typeof n>"u"?"offset":`${n}.offset`,o=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(i,`${e}`),this.url.searchParams.set(o,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:n=!1,wal:i=!1,format:o="text"}={}){var a;let u=[e?"analyze":null,t?"verbose":null,r?"settings":null,n?"buffers":null,i?"wal":null].filter(Boolean).join("|"),l=(a=this.headers.get("Accept"))!==null&&a!==void 0?a:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${o}; for="${l}"; options=${u};`),o==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};re.default=te});var B=_(ie=>{"use strict";c();Object.defineProperty(ie,"__esModule",{value:!0});var bt=(O(),E(x)),Pt=bt.__importDefault(se()),_t=new RegExp("[,()]"),ne=class extends Pt.default{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){let r=Array.from(new Set(t)).map(n=>typeof n=="string"&&_t.test(n)?`"${n}"`:`${n}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:n}={}){let i="";n==="plain"?i="pl":n==="phrase"?i="ph":n==="websearch"&&(i="w");let o=r===void 0?"":`(${r})`;return this.url.searchParams.append(e,`${i}fts${o}.${t}`),this}match(e){return Object.entries(e).forEach(([t,r])=>{this.url.searchParams.append(t,`eq.${r}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t,referencedTable:r=t}={}){let n=r?`${r}.or`:"or";return this.url.searchParams.append(n,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}};ie.default=ne});var le=_(ae=>{"use strict";c();Object.defineProperty(ae,"__esModule",{value:!0});var Et=(O(),E(x)),I=Et.__importDefault(B()),oe=class{constructor(e,{headers:t={},schema:r,fetch:n}){this.url=e,this.headers=new Headers(t),this.schema=r,this.fetch=n}select(e,t){let{head:r=!1,count:n}=t??{},i=r?"HEAD":"GET",o=!1,a=(e??"*").split("").map(u=>/\s/.test(u)&&!o?"":(u==='"'&&(o=!o),u)).join("");return this.url.searchParams.set("select",a),n&&this.headers.append("Prefer",`count=${n}`),new I.default({method:i,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:r=!0}={}){var n;let i="POST";if(t&&this.headers.append("Prefer",`count=${t}`),r||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let o=e.reduce((a,u)=>a.concat(Object.keys(u)),[]);if(o.length>0){let a=[...new Set(o)].map(u=>`"${u}"`);this.url.searchParams.set("columns",a.join(","))}}return new I.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:n,defaultToNull:i=!0}={}){var o;let a="POST";if(this.headers.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),t!==void 0&&this.url.searchParams.set("on_conflict",t),n&&this.headers.append("Prefer",`count=${n}`),i||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let u=e.reduce((l,h)=>l.concat(Object.keys(h)),[]);if(u.length>0){let l=[...new Set(u)].map(h=>`"${h}"`);this.url.searchParams.set("columns",l.join(","))}}return new I.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}update(e,{count:t}={}){var r;let n="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new I.default({method:n,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch})}delete({count:e}={}){var t;let r="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new I.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};ae.default=oe});var Ve=_(ue=>{"use strict";c();Object.defineProperty(ue,"__esModule",{value:!0});var We=(O(),E(x)),xt=We.__importDefault(le()),Ot=We.__importDefault(B()),ce=class s{constructor(e,{headers:t={},schema:r,fetch:n}={}){this.url=e,this.headers=new Headers(t),this.schemaName=r,this.fetch=n}from(e){let t=new URL(`${this.url}/${e}`);return new xt.default(t,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new s(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:r=!1,get:n=!1,count:i}={}){var o;let a,u=new URL(`${this.url}/rpc/${e}`),l;r||n?(a=r?"HEAD":"GET",Object.entries(t).filter(([d,m])=>m!==void 0).map(([d,m])=>[d,Array.isArray(m)?`{${m.join(",")}}`:`${m}`]).forEach(([d,m])=>{u.searchParams.append(d,m)})):(a="POST",l=t);let h=new Headers(this.headers);return i&&h.set("Prefer",`count=${i}`),new Ot.default({method:a,url:u,headers:h,schema:this.schemaName,body:l,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};ue.default=ce});var tt=_(w=>{"use strict";c();Object.defineProperty(w,"__esModule",{value:!0});w.PostgrestError=w.PostgrestBuilder=w.PostgrestTransformBuilder=w.PostgrestFilterBuilder=w.PostgrestQueryBuilder=w.PostgrestClient=void 0;var R=(O(),E(x)),Ye=R.__importDefault(Ve());w.PostgrestClient=Ye.default;var Qe=R.__importDefault(le());w.PostgrestQueryBuilder=Qe.default;var Ke=R.__importDefault(B());w.PostgrestFilterBuilder=Ke.default;var Xe=R.__importDefault(se());w.PostgrestTransformBuilder=Xe.default;var Ze=R.__importDefault(ee());w.PostgrestBuilder=Ze.default;var et=R.__importDefault(K());w.PostgrestError=et.default;w.default={PostgrestClient:Ye.default,PostgrestQueryBuilder:Qe.default,PostgrestFilterBuilder:Ke.default,PostgrestTransformBuilder:Xe.default,PostgrestBuilder:Ze.default,PostgrestError:et.default}});var Rt={};ye(Rt,{AbortController:()=>H,AbortSignal:()=>$,AuthClient:()=>N,CURRENT_JWT_KEY:()=>k,ENTITIES_BASE_PATH:()=>st,FILE_STORAGE_BASE_PATH:()=>ve,GENERATE_UPLOAD_URL_PATH:()=>we,Headers:()=>v,NvwaEdgeFunctions:()=>F,NvwaFileStorage:()=>G,NvwaHttpClient:()=>z,NvwaSkill:()=>de,OverlayManager:()=>pe,PaymentClient:()=>fe,Request:()=>A,Response:()=>C,URL:()=>j,URLSearchParams:()=>S,createPostgrestClient:()=>St,getSourceLocationFromDOM:()=>$t,polyfill:()=>dt});module.exports=E(Rt);c();c();var F=class{constructor(e,t=""){this.http=e,this.baseUrl=t.replace(/\/$/,"")}async invoke(e,t){let r=this.baseUrl?`${this.baseUrl}/functions/${e}`:`/functions/${e}`;return await(await this.http.fetch(r,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};c();c();var k="nvwa_current_jwt",ut=typeof fetch<"u"?fetch:(()=>{throw new Error("AuthClient requires fetch")})(),N=class{constructor(e,t={}){this.baseUrl=e.replace(/\/$/,""),this.authPath=(t.authPath??"/auth").replace(/^\//,""),this.fetchImpl=t.fetchImpl??ut}url(e){return`${`${this.baseUrl}/${this.authPath}`.replace(/\/+/g,"/")}/${e.replace(/^\//,"")}`}async getSession(){try{let e=await this.fetchImpl(this.url("session"),{method:"GET",credentials:"include"});return e.ok?{data:await e.json()}:{data:null,error:{message:await e.text()||e.statusText,status:e.status}}}catch(e){return{data:null,error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithEmail(e,t){try{let r=await this.fetchImpl(this.url("sign-in/email"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:e,password:t})}),n=await r.text();return r.ok?{data:n?JSON.parse(n):void 0}:{error:{message:n||r.statusText,status:r.status}}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let e=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:"include"});return e.ok?{}:{error:{message:await e.text()||e.statusText,status:e.status}}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}};c();c();var v=class s{constructor(e){this.headerMap=new Map;if(e){if(e instanceof s)e.forEach((t,r)=>this.set(r,t));else if(Array.isArray(e))for(let[t,r]of e)this.set(t,String(r));else if(typeof e=="object")for(let t of Object.keys(e))this.set(t,String(e[t]))}}append(e,t){let r=e.toLowerCase(),n=this.headerMap.get(r);this.headerMap.set(r,n?`${n}, ${t}`:t)}set(e,t){this.headerMap.set(e.toLowerCase(),String(t))}get(e){let t=this.headerMap.get(e.toLowerCase());return t??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[t,r]of this.headerMap.entries())e(r,t,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},S=class s{constructor(e){this.params=new Map;if(e){if(typeof e=="string")this.parseString(e);else if(e instanceof s)this.params=new Map(e.params);else if(Array.isArray(e))for(let[t,r]of e)this.append(t,r);else if(e&&typeof e=="object")for(let[t,r]of Object.entries(e))this.set(t,r)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let t=e.split("&");for(let r of t)if(r){let[n,i]=r.split("=");n&&this.append(decodeURIComponent(n),i?decodeURIComponent(i):"")}}append(e,t){let r=this.params.get(e)||[];r.push(t),this.params.set(e,r)}delete(e){this.params.delete(e)}get(e){let t=this.params.get(e);return t?t[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,t){this.params.set(e,[t])}sort(){let e=Array.from(this.params.entries()).sort(([t],[r])=>t.localeCompare(r));this.params=new Map(e)}toString(){let e=[];for(let[t,r]of this.params.entries())for(let n of r)e.push(`${encodeURIComponent(t)}=${encodeURIComponent(n)}`);return e.join("&")}forEach(e){for(let[t,r]of this.params.entries())for(let n of r)e(n,t,this)}keys(){return this.params.keys()}values(){let e=[];for(let t of this.params.values())e.push(...t);return e[Symbol.iterator]()}entries(){let e=[];for(let[t,r]of this.params.entries())for(let n of r)e.push([t,n]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},j=class s{constructor(e,t){let r;if(e instanceof s)r=e.href;else if(t){let i=t instanceof s?t.href:t;r=this.resolve(i,e)}else r=e;let n=this.parseUrl(r);this.href=r,this.origin=`${n.protocol}//${n.host}`,this.protocol=n.protocol,this.username=n.username,this.password=n.password,this.host=n.host,this.hostname=n.hostname,this.port=n.port,this.pathname=n.pathname,this.search=n.search,this.searchParams=new S(n.search),this.hash=n.hash}resolve(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(t.startsWith("//"))return`${this.parseUrl(e).protocol}${t}`;if(t.startsWith("/")){let i=this.parseUrl(e);return`${i.protocol}//${i.host}${t}`}let r=this.parseUrl(e),n=r.pathname.endsWith("/")?r.pathname:r.pathname+"/";return`${r.protocol}//${r.host}${n}${t}`}parseUrl(e){let t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)throw new TypeError("Invalid URL");let r=t[2]||"",n=t[4]||"",i=t[5]||"/",o=t[7]?`?${t[7]}`:"",a=t[9]?`#${t[9]}`:"";if(!r&&!n&&!i.startsWith("/")&&!i.includes("/")&&!i.includes("."))throw new TypeError("Invalid URL");let u=n.match(/^([^@]*)@(.+)$/),l="",h="",d=n;if(u){let b=u[1];d=u[2];let g=b.match(/^([^:]*):?(.*)$/);g&&(l=g[1]||"",h=g[2]||"")}let m=d.match(/^([^:]+):?(\d*)$/),p=m?m[1]:d,y=m&&m[2]?m[2]:"";return{protocol:r?`${r}:`:"",username:l,password:h,host:d,hostname:p,port:y,pathname:i,search:o,hash:a}}toString(){let e=this.searchParams.toString(),t=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${t}${this.hash}`}toJSON(){return this.toString()}};c();var A=class s{constructor(e,t){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(t?.method||"GET").toUpperCase(),this.headers=t?.headers instanceof v?t.headers:new v(t?.headers),this.body=t?.body,this.timeout=t?.timeout,this.signal=t?.signal||void 0}clone(){return new s(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};c();var C=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=ht(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function ht(s){return s?new v(s):new v}c();var $=class{constructor(){this._aborted=!1;this.listeners=new Set;this.onabort=null}get aborted(){return this._aborted}_trigger(){if(!this._aborted){if(this._aborted=!0,typeof this.onabort=="function")try{this.onabort()}catch{}for(let e of Array.from(this.listeners))try{e()}catch{}this.listeners.clear()}}addEventListener(e,t){if(this._aborted){try{t()}catch{}return}this.listeners.add(t)}removeEventListener(e,t){this.listeners.delete(t)}toString(){return"[object AbortSignal]"}},H=class{constructor(){this._signal=new $}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};c();function dt(s){s.URL=j,s.URLSearchParams=S,s.Headers=v,s.Request=A,s.Response=C,s.AbortController=H,s.AbortSignal=$}var z=class{constructor(e,t,r){console.log("NvwaHttpClient constructor",e,t,r),this.storage=e,this.customFetch=t,this.handleUnauthorized=r}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let r=await this.storage.get(k),n=new v(t?.headers);r&&n.set("Authorization",`Bearer ${r}`);let i=t?.method||"GET";if((i==="POST"||i==="PUT"||i==="PATCH")&&t?.body){let a=n.get("Content-Type");(!a||a.includes("text/plain"))&&n.set("Content-Type","application/json")}let o=await this.customFetch(e,{...t,headers:n});if(o.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return o}};c();var ve="/storage",we=ve+"/generateUploadUrl",G=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+we,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=await t.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let n=await this.http.fetch(r,{method:"PUT",body:e,headers:new v({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:i}=await n.json();return{url:i.split("?")[0]}}};c();c();c();var he=ct(tt(),1),{PostgrestClient:rt,PostgrestQueryBuilder:Ir,PostgrestFilterBuilder:Ur,PostgrestTransformBuilder:Lr,PostgrestBuilder:Nr,PostgrestError:kr}=he.default||he;var st="/entities",St=(s,e)=>new rt(s+st,{fetch:e.fetchWithAuth.bind(e)});c();var de=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/skill/${e}/execute`,i=await(await this.http.fetchWithAuth(r,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(i.status!==200)throw new Error(i.message);return i.data}};c();var pe=class{constructor(){this.hoverOverlay=null;this.selectedOverlay=null;this.tooltip=null;this.hoverElement=null;this.selectedElement=null;this.hoverUpdateHandler=null;this.selectedUpdateHandler=null;this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let e=document.createElement("style");e.id="__nvwa-inspector-overlay-style",e.textContent=`
|
|
1
|
+
"use strict";var ot=Object.create;var L=Object.defineProperty;var at=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var ut=Object.getPrototypeOf,ct=Object.prototype.hasOwnProperty;var me=(n,e)=>()=>(n&&(e=n(n=0)),e);var _=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),ye=(n,e)=>{for(var t in e)L(n,t,{get:e[t],enumerable:!0})},ge=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of lt(e))!ct.call(n,s)&&s!==t&&L(n,s,{get:()=>e[s],enumerable:!(r=at(e,s))||r.enumerable});return n};var ht=(n,e,t)=>(t=n!=null?ot(ut(n)):{},ge(e||!n||!n.__esModule?L(t,"default",{value:n,enumerable:!0}):t,n)),E=n=>ge(L({},"__esModule",{value:!0}),n);var u=me(()=>{"use strict"});var x={};ye(x,{__addDisposableResource:()=>ze,__assign:()=>M,__asyncDelegator:()=>ke,__asyncGenerator:()=>Ne,__asyncValues:()=>Me,__await:()=>$,__awaiter:()=>je,__classPrivateFieldGet:()=>Fe,__classPrivateFieldIn:()=>Je,__classPrivateFieldSet:()=>Ge,__createBinding:()=>D,__decorate:()=>xe,__disposeResources:()=>We,__esDecorate:()=>Se,__exportStar:()=>Ie,__extends:()=>_e,__generator:()=>Ue,__importDefault:()=>Be,__importStar:()=>De,__makeTemplateObject:()=>qe,__metadata:()=>Ae,__param:()=>Oe,__propKey:()=>$e,__read:()=>Y,__rest:()=>Ee,__rewriteRelativeImportExtension:()=>Ye,__runInitializers:()=>Te,__setFunctionName:()=>Re,__spread:()=>Ce,__spreadArray:()=>Le,__spreadArrays:()=>He,__values:()=>q,default:()=>gt});function _e(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");z(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Ee(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t}function xe(n,e,t,r){var s=arguments.length,i=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(n,e,t,r);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(i=(s<3?o(i):s>3?o(e,t,i):o(e,t))||i);return s>3&&i&&Object.defineProperty(e,t,i),i}function Oe(n,e){return function(t,r){e(t,r,n)}}function Se(n,e,t,r,s,i){function o(P){if(P!==void 0&&typeof P!="function")throw new TypeError("Function expected");return P}for(var a=r.kind,c=a==="getter"?"get":a==="setter"?"set":"value",l=!e&&n?r.static?n:n.prototype:null,h=e||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,m=!1,p=t.length-1;p>=0;p--){var y={};for(var b in r)y[b]=b==="access"?{}:r[b];for(var b in r.access)y.access[b]=r.access[b];y.addInitializer=function(P){if(m)throw new TypeError("Cannot add initializers after decoration has completed");i.push(o(P||null))};var g=(0,t[p])(a==="accessor"?{get:h.get,set:h.set}:h[c],y);if(a==="accessor"){if(g===void 0)continue;if(g===null||typeof g!="object")throw new TypeError("Object expected");(d=o(g.get))&&(h.get=d),(d=o(g.set))&&(h.set=d),(d=o(g.init))&&s.unshift(d)}else(d=o(g))&&(a==="field"?s.unshift(d):h[c]=d)}l&&Object.defineProperty(l,r.name,h),m=!0}function Te(n,e,t){for(var r=arguments.length>2,s=0;s<e.length;s++)t=r?e[s].call(n,t):e[s].call(n);return r?t:void 0}function $e(n){return typeof n=="symbol"?n:"".concat(n)}function Re(n,e,t){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(n,"name",{configurable:!0,value:t?"".concat(t," ",e):e})}function Ae(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)}function je(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(h){try{l(r.next(h))}catch(d){o(d)}}function c(h){try{l(r.throw(h))}catch(d){o(d)}}function l(h){h.done?i(h.value):s(h.value).then(a,c)}l((r=r.apply(n,e||[])).next())})}function Ue(n,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,s,i,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return c([l,h])}}function c(l){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(t=0)),t;)try{if(r=1,s&&(i=l[0]&2?s.return:l[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,l[1])).done)return i;switch(s=0,i&&(l=[l[0]&2,i.value]),l[0]){case 0:case 1:i=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,s=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!i||l[1]>i[0]&&l[1]<i[3])){t.label=l[1];break}if(l[0]===6&&t.label<i[1]){t.label=i[1],i=l;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(l);break}i[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(h){l=[6,h],s=0}finally{r=i=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Ie(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&D(e,n,t)}function q(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],r=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Y(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var r=t.call(n),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(o)throw o.error}}return i}function Ce(){for(var n=[],e=0;e<arguments.length;e++)n=n.concat(Y(arguments[e]));return n}function He(){for(var n=0,e=0,t=arguments.length;e<t;e++)n+=arguments[e].length;for(var r=Array(n),s=0,e=0;e<t;e++)for(var i=arguments[e],o=0,a=i.length;o<a;o++,s++)r[s]=i[o];return r}function Le(n,e,t){if(t||arguments.length===2)for(var r=0,s=e.length,i;r<s;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return n.concat(i||Array.prototype.slice.call(e))}function $(n){return this instanceof $?(this.v=n,this):new $(n)}function Ne(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),s,i=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(p){return function(y){return Promise.resolve(y).then(p,d)}}function a(p,y){r[p]&&(s[p]=function(b){return new Promise(function(g,P){i.push([p,b,g,P])>1||c(p,b)})},y&&(s[p]=y(s[p])))}function c(p,y){try{l(r[p](y))}catch(b){m(i[0][3],b)}}function l(p){p.value instanceof $?Promise.resolve(p.value.v).then(h,d):m(i[0][2],p)}function h(p){c("next",p)}function d(p){c("throw",p)}function m(p,y){p(y),i.shift(),i.length&&c(i[0][0],i[0][1])}}function ke(n){var e,t;return e={},r("next"),r("throw",function(s){throw s}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(s,i){e[s]=n[s]?function(o){return(t=!t)?{value:$(n[s](o)),done:!1}:i?i(o):o}:i}}function Me(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof q=="function"?q(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(i){t[i]=n[i]&&function(o){return new Promise(function(a,c){o=n[i](o),s(a,c,o.done,o.value)})}}function s(i,o,a,c){Promise.resolve(c).then(function(l){i({value:l,done:a})},o)}}function qe(n,e){return Object.defineProperty?Object.defineProperty(n,"raw",{value:e}):n.raw=e,n}function De(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t=W(n),r=0;r<t.length;r++)t[r]!=="default"&&D(e,n,t[r]);return mt(e,n),e}function Be(n){return n&&n.__esModule?n:{default:n}}function Fe(n,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(n):r?r.value:e.get(n)}function Ge(n,e,t,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 e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(n,t):s?s.value=t:e.set(n,t),t}function Je(n,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof n=="function"?e===n:n.has(e)}function ze(n,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var r,s;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=e[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=e[Symbol.dispose],t&&(s=r)}if(typeof r!="function")throw new TypeError("Object not disposable.");s&&(r=function(){try{s.call(this)}catch(i){return Promise.reject(i)}}),n.stack.push({value:e,dispose:r,async:t})}else t&&n.stack.push({async:!0});return e}function We(n){function e(i){n.error=n.hasError?new yt(i,n.error,"An error was suppressed during disposal."):i,n.hasError=!0}var t,r=0;function s(){for(;t=n.stack.pop();)try{if(!t.async&&r===1)return r=0,n.stack.push(t),Promise.resolve().then(s);if(t.dispose){var i=t.dispose.call(t.value);if(t.async)return r|=2,Promise.resolve(i).then(s,function(o){return e(o),s()})}else r|=1}catch(o){e(o)}if(r===1)return n.hasError?Promise.reject(n.error):Promise.resolve();if(n.hasError)throw n.error}return s()}function Ye(n,e){return typeof n=="string"&&/^\.\.?\//.test(n)?n.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,r,s,i,o){return r?e?".jsx":".js":s&&(!i||!o)?t:s+i+"."+o.toLowerCase()+"js"}):n}var z,M,D,mt,W,yt,gt,O=me(()=>{"use strict";u();z=function(n,e){return z=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])},z(n,e)};M=function(){return M=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},M.apply(this,arguments)};D=Object.create?(function(n,e,t,r){r===void 0&&(r=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,r,s)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]});mt=Object.create?(function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}):function(n,e){n.default=e},W=function(n){return W=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},W(n)};yt=typeof SuppressedError=="function"?SuppressedError:function(n,e,t){var r=new Error(t);return r.name="SuppressedError",r.error=n,r.suppressed=e,r};gt={__extends:_e,__assign:M,__rest:Ee,__decorate:xe,__param:Oe,__esDecorate:Se,__runInitializers:Te,__propKey:$e,__setFunctionName:Re,__metadata:Ae,__awaiter:je,__generator:Ue,__createBinding:D,__exportStar:Ie,__values:q,__read:Y,__spread:Ce,__spreadArrays:He,__spreadArray:Le,__await:$,__asyncGenerator:Ne,__asyncDelegator:ke,__asyncValues:Me,__makeTemplateObject:qe,__importStar:De,__importDefault:Be,__classPrivateFieldGet:Fe,__classPrivateFieldSet:Ge,__classPrivateFieldIn:Je,__addDisposableResource:ze,__disposeResources:We,__rewriteRelativeImportExtension:Ye}});var Q=_(V=>{"use strict";u();Object.defineProperty(V,"__esModule",{value:!0});var K=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};V.default=K});var ee=_(Z=>{"use strict";u();Object.defineProperty(Z,"__esModule",{value:!0});var vt=(O(),E(x)),wt=vt.__importDefault(Q()),X=class{constructor(e){var t,r;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(r=e.isMaybeSingle)!==null&&r!==void 0?r:!1,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let r=this.fetch,s=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{var o,a,c,l;let h=null,d=null,m=null,p=i.status,y=i.statusText;if(i.ok){if(this.method!=="HEAD"){let H=await i.text();H===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((o=this.headers.get("Accept"))===null||o===void 0)&&o.includes("application/vnd.pgrst.plan+text"))?d=H:d=JSON.parse(H))}let g=(a=this.headers.get("Prefer"))===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),P=(c=i.headers.get("content-range"))===null||c===void 0?void 0:c.split("/");g&&P&&P.length>1&&(m=parseInt(P[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(h={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,m=null,p=406,y="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let g=await i.text();try{h=JSON.parse(g),Array.isArray(h)&&i.status===404&&(d=[],h=null,p=200,y="OK")}catch{i.status===404&&g===""?(p=204,y="No Content"):h={message:g}}if(h&&this.isMaybeSingle&&(!((l=h?.details)===null||l===void 0)&&l.includes("0 rows"))&&(h=null,p=200,y="OK"),h&&this.shouldThrowOnError)throw new wt.default(h)}return{error:h,data:d,count:m,status:p,statusText:y}});return this.shouldThrowOnError||(s=s.catch(i=>{var o,a,c;return{error:{message:`${(o=i?.name)!==null&&o!==void 0?o:"FetchError"}: ${i?.message}`,details:`${(a=i?.stack)!==null&&a!==void 0?a:""}`,hint:"",code:`${(c=i?.code)!==null&&c!==void 0?c:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}returns(){return this}overrideTypes(){return this}};Z.default=X});var se=_(re=>{"use strict";u();Object.defineProperty(re,"__esModule",{value:!0});var bt=(O(),E(x)),Pt=bt.__importDefault(ee()),te=class extends Pt.default{select(e){let t=!1,r=(e??"*").split("").map(s=>/\s/.test(s)&&!t?"":(s==='"'&&(t=!t),s)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:s,referencedTable:i=s}={}){let o=i?`${i}.order`:"order",a=this.url.searchParams.get(o);return this.url.searchParams.set(o,`${a?`${a},`:""}${e}.${t?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:r=t}={}){let s=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:r,referencedTable:s=r}={}){let i=typeof s>"u"?"offset":`${s}.offset`,o=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(i,`${e}`),this.url.searchParams.set(o,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:s=!1,wal:i=!1,format:o="text"}={}){var a;let c=[e?"analyze":null,t?"verbose":null,r?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),l=(a=this.headers.get("Accept"))!==null&&a!==void 0?a:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${o}; for="${l}"; options=${c};`),o==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};re.default=te});var B=_(ie=>{"use strict";u();Object.defineProperty(ie,"__esModule",{value:!0});var _t=(O(),E(x)),Et=_t.__importDefault(se()),xt=new RegExp("[,()]"),ne=class extends Et.default{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){let r=Array.from(new Set(t)).map(s=>typeof s=="string"&&xt.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:s}={}){let i="";s==="plain"?i="pl":s==="phrase"?i="ph":s==="websearch"&&(i="w");let o=r===void 0?"":`(${r})`;return this.url.searchParams.append(e,`${i}fts${o}.${t}`),this}match(e){return Object.entries(e).forEach(([t,r])=>{this.url.searchParams.append(t,`eq.${r}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t,referencedTable:r=t}={}){let s=r?`${r}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}};ie.default=ne});var le=_(ae=>{"use strict";u();Object.defineProperty(ae,"__esModule",{value:!0});var Ot=(O(),E(x)),C=Ot.__importDefault(B()),oe=class{constructor(e,{headers:t={},schema:r,fetch:s}){this.url=e,this.headers=new Headers(t),this.schema=r,this.fetch=s}select(e,t){let{head:r=!1,count:s}=t??{},i=r?"HEAD":"GET",o=!1,a=(e??"*").split("").map(c=>/\s/.test(c)&&!o?"":(c==='"'&&(o=!o),c)).join("");return this.url.searchParams.set("select",a),s&&this.headers.append("Prefer",`count=${s}`),new C.default({method:i,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:r=!0}={}){var s;let i="POST";if(t&&this.headers.append("Prefer",`count=${t}`),r||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let o=e.reduce((a,c)=>a.concat(Object.keys(c)),[]);if(o.length>0){let a=[...new Set(o)].map(c=>`"${c}"`);this.url.searchParams.set("columns",a.join(","))}}return new C.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:s,defaultToNull:i=!0}={}){var o;let a="POST";if(this.headers.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),t!==void 0&&this.url.searchParams.set("on_conflict",t),s&&this.headers.append("Prefer",`count=${s}`),i||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let c=e.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 C.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}update(e,{count:t}={}){var r;let s="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new C.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch})}delete({count:e}={}){var t;let r="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new C.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};ae.default=oe});var Ve=_(ce=>{"use strict";u();Object.defineProperty(ce,"__esModule",{value:!0});var Ke=(O(),E(x)),St=Ke.__importDefault(le()),Tt=Ke.__importDefault(B()),ue=class n{constructor(e,{headers:t={},schema:r,fetch:s}={}){this.url=e,this.headers=new Headers(t),this.schemaName=r,this.fetch=s}from(e){let t=new URL(`${this.url}/${e}`);return new St.default(t,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new n(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:r=!1,get:s=!1,count:i}={}){var o;let a,c=new URL(`${this.url}/rpc/${e}`),l;r||s?(a=r?"HEAD":"GET",Object.entries(t).filter(([d,m])=>m!==void 0).map(([d,m])=>[d,Array.isArray(m)?`{${m.join(",")}}`:`${m}`]).forEach(([d,m])=>{c.searchParams.append(d,m)})):(a="POST",l=t);let h=new Headers(this.headers);return i&&h.set("Prefer",`count=${i}`),new Tt.default({method:a,url:c,headers:h,schema:this.schemaName,body:l,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};ce.default=ue});var st=_(w=>{"use strict";u();Object.defineProperty(w,"__esModule",{value:!0});w.PostgrestError=w.PostgrestBuilder=w.PostgrestTransformBuilder=w.PostgrestFilterBuilder=w.PostgrestQueryBuilder=w.PostgrestClient=void 0;var R=(O(),E(x)),Qe=R.__importDefault(Ve());w.PostgrestClient=Qe.default;var Xe=R.__importDefault(le());w.PostgrestQueryBuilder=Xe.default;var Ze=R.__importDefault(B());w.PostgrestFilterBuilder=Ze.default;var et=R.__importDefault(se());w.PostgrestTransformBuilder=et.default;var tt=R.__importDefault(ee());w.PostgrestBuilder=tt.default;var rt=R.__importDefault(Q());w.PostgrestError=rt.default;w.default={PostgrestClient:Qe.default,PostgrestQueryBuilder:Xe.default,PostgrestFilterBuilder:Ze.default,PostgrestTransformBuilder:et.default,PostgrestBuilder:tt.default,PostgrestError:rt.default}});var jt={};ye(jt,{AbortController:()=>I,AbortSignal:()=>T,AuthClient:()=>N,CURRENT_JWT_KEY:()=>k,ENTITIES_BASE_PATH:()=>it,FILE_STORAGE_BASE_PATH:()=>be,GENERATE_UPLOAD_URL_PATH:()=>Pe,Headers:()=>v,LOGIN_TOKEN_KEY:()=>ve,LOGIN_USER_PROFILE_KEY:()=>we,NvwaEdgeFunctions:()=>F,NvwaFileStorage:()=>J,NvwaHttpClient:()=>G,NvwaSkill:()=>de,OverlayManager:()=>pe,PaymentClient:()=>fe,Request:()=>j,Response:()=>U,URL:()=>A,URLSearchParams:()=>S,createPostgrestClient:()=>$t,getSourceLocationFromDOM:()=>Rt,polyfill:()=>ft});module.exports=E(jt);u();u();var F=class{constructor(e,t=""){this.http=e,this.baseUrl=t.replace(/\/$/,"")}async invoke(e,t){let r=this.baseUrl?`${this.baseUrl}/functions/${e}`:`/functions/${e}`;return await(await this.http.fetch(r,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};u();u();var k="nvwa_current_jwt",ve="nvwa_login_token",we="nvwa_user_profile",dt=typeof fetch<"u"?fetch:(()=>{throw new Error("AuthClient requires fetch")})(),N=class{constructor(e,t={}){this.baseUrl=e.replace(/\/$/,""),this.authPath=(t.authPath??"/auth").replace(/^\//,""),this.fetchImpl=t.fetchImpl??dt}url(e){return`${`${this.baseUrl}/${this.authPath}`.replace(/\/+/g,"/")}/${e.replace(/^\//,"")}`}async getSession(){try{let e=await this.fetchImpl(this.url("session"),{method:"GET",credentials:"include"});return e.ok?{data:await e.json()}:{data:null,error:{message:await e.text()||e.statusText,status:e.status}}}catch(e){return{data:null,error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithEmail(e,t){try{let r=await this.fetchImpl(this.url("sign-in/email"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:e,password:t})}),s=await r.text();return r.ok?{data:s?JSON.parse(s):void 0}:{error:{message:s||r.statusText,status:r.status}}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let e=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:"include"});return e.ok?{}:{error:{message:await e.text()||e.statusText,status:e.status}}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signUp(e){return this.postJson("sign-up/email",e)}async getToken(e){try{let t={};e&&(t.Authorization=`Bearer ${e}`);let r=await this.fetchImpl(this.url("token"),{method:"GET",credentials:"include",...Object.keys(t).length?{headers:t}:{}}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let i=s?JSON.parse(s):void 0;return{data:i?.token!=null?{token:i.token}:void 0}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signInWithUsername(e,t){return this.postJson("sign-in/username",{username:e,password:t})}async signInWithPhoneNumber(e,t,r){return this.postJson("sign-in/phone-number",{phoneNumber:e,password:t,rememberMe:r})}async sendPhoneNumberOtp(e){let t=await this.postJson("phone-number/send-otp",{phoneNumber:e});return t.error?{error:t.error}:{}}async verifyPhoneNumber(e,t){return this.postJson("phone-number/verify",{phoneNumber:e,code:t})}async postJson(e,t){try{let r=await this.fetchImpl(this.url(e),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(t)}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let i=s?JSON.parse(s):void 0;return{data:i?.data??i??void 0}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}};u();u();var v=class n{constructor(e){this.headerMap=new Map;if(e){if(e instanceof n)e.forEach((t,r)=>this.set(r,t));else if(Array.isArray(e))for(let[t,r]of e)this.set(t,String(r));else if(typeof e=="object")for(let t of Object.keys(e))this.set(t,String(e[t]))}}append(e,t){let r=e.toLowerCase(),s=this.headerMap.get(r);this.headerMap.set(r,s?`${s}, ${t}`:t)}set(e,t){this.headerMap.set(e.toLowerCase(),String(t))}get(e){let t=this.headerMap.get(e.toLowerCase());return t??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[t,r]of this.headerMap.entries())e(r,t,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},S=class n{constructor(e){this.params=new Map;if(e){if(typeof e=="string")this.parseString(e);else if(e instanceof n)this.params=new Map(e.params);else if(Array.isArray(e))for(let[t,r]of e)this.append(t,r);else if(e&&typeof e=="object")for(let[t,r]of Object.entries(e))this.set(t,r)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let t=e.split("&");for(let r of t)if(r){let[s,i]=r.split("=");s&&this.append(decodeURIComponent(s),i?decodeURIComponent(i):"")}}append(e,t){let r=this.params.get(e)||[];r.push(t),this.params.set(e,r)}delete(e){this.params.delete(e)}get(e){let t=this.params.get(e);return t?t[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,t){this.params.set(e,[t])}sort(){let e=Array.from(this.params.entries()).sort(([t],[r])=>t.localeCompare(r));this.params=new Map(e)}toString(){let e=[];for(let[t,r]of this.params.entries())for(let s of r)e.push(`${encodeURIComponent(t)}=${encodeURIComponent(s)}`);return e.join("&")}forEach(e){for(let[t,r]of this.params.entries())for(let s of r)e(s,t,this)}keys(){return this.params.keys()}values(){let e=[];for(let t of this.params.values())e.push(...t);return e[Symbol.iterator]()}entries(){let e=[];for(let[t,r]of this.params.entries())for(let s of r)e.push([t,s]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},A=class n{constructor(e,t){let r;if(e instanceof n)r=e.href;else if(t){let i=t instanceof n?t.href:t;r=this.resolve(i,e)}else r=e;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(s.search),this.hash=s.hash}resolve(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(t.startsWith("//"))return`${this.parseUrl(e).protocol}${t}`;if(t.startsWith("/")){let i=this.parseUrl(e);return`${i.protocol}//${i.host}${t}`}let r=this.parseUrl(e),s=r.pathname.endsWith("/")?r.pathname:r.pathname+"/";return`${r.protocol}//${r.host}${s}${t}`}parseUrl(e){let t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)throw new TypeError("Invalid URL");let r=t[2]||"",s=t[4]||"",i=t[5]||"/",o=t[7]?`?${t[7]}`:"",a=t[9]?`#${t[9]}`:"";if(!r&&!s&&!i.startsWith("/")&&!i.includes("/")&&!i.includes("."))throw new TypeError("Invalid URL");let c=s.match(/^([^@]*)@(.+)$/),l="",h="",d=s;if(c){let b=c[1];d=c[2];let g=b.match(/^([^:]*):?(.*)$/);g&&(l=g[1]||"",h=g[2]||"")}let m=d.match(/^([^:]+):?(\d*)$/),p=m?m[1]:d,y=m&&m[2]?m[2]:"";return{protocol:r?`${r}:`:"",username:l,password:h,host:d,hostname:p,port:y,pathname:i,search:o,hash:a}}toString(){let e=this.searchParams.toString(),t=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${t}${this.hash}`}toJSON(){return this.toString()}};u();var j=class n{constructor(e,t){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(t?.method||"GET").toUpperCase(),this.headers=t?.headers instanceof v?t.headers:new v(t?.headers),this.body=t?.body,this.timeout=t?.timeout,this.signal=t?.signal||void 0}clone(){return new n(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};u();var U=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=pt(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function pt(n){return n?new v(n):new v}u();var T=class{constructor(){this._aborted=!1;this.listeners=new Set;this.onabort=null}get aborted(){return this._aborted}_trigger(){if(!this._aborted){if(this._aborted=!0,typeof this.onabort=="function")try{this.onabort()}catch{}for(let e of Array.from(this.listeners))try{e()}catch{}this.listeners.clear()}}addEventListener(e,t){if(this._aborted){try{t()}catch{}return}this.listeners.add(t)}removeEventListener(e,t){this.listeners.delete(t)}toString(){return"[object AbortSignal]"}},I=class{constructor(){this._signal=new T}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};u();function ft(n){n.URL=A,n.URLSearchParams=S,n.Headers=v,n.Request=j,n.Response=U,n.AbortController=I,n.AbortSignal=T}var G=class{constructor(e,t,r){console.log("NvwaHttpClient constructor",e,t,r),this.storage=e,this.customFetch=t,this.handleUnauthorized=r}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let r=await this.storage.get(k),s=new v(t?.headers);r&&s.set("Authorization",`Bearer ${r}`);let i=t?.method||"GET";if((i==="POST"||i==="PUT"||i==="PATCH")&&t?.body){let a=s.get("Content-Type");(!a||a.includes("text/plain"))&&s.set("Content-Type","application/json")}let o=await this.customFetch(e,{...t,headers:s});if(o.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return o}};u();var be="/storage",Pe=be+"/generateUploadUrl",J=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+Pe,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=await t.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:e,headers:new v({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:i}=await s.json();return{url:i.split("?")[0]}}};u();u();u();var he=ht(st(),1),{PostgrestClient:nt,PostgrestQueryBuilder:Lr,PostgrestFilterBuilder:Nr,PostgrestTransformBuilder:kr,PostgrestBuilder:Mr,PostgrestError:qr}=he.default||he;var it="/entities",$t=(n,e)=>new nt(n+it,{fetch:e.fetchWithAuth.bind(e)});u();var de=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/skill/${e}/execute`,i=await(await this.http.fetchWithAuth(r,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(i.status!==200)throw new Error(i.message);return i.data}};u();var pe=class{constructor(){this.hoverOverlay=null;this.selectedOverlay=null;this.tooltip=null;this.hoverElement=null;this.selectedElement=null;this.hoverUpdateHandler=null;this.selectedUpdateHandler=null;this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let e=document.createElement("style");e.id="__nvwa-inspector-overlay-style",e.textContent=`
|
|
2
2
|
.__nvwa-inspector-overlay {
|
|
3
3
|
position: absolute;
|
|
4
4
|
pointer-events: none;
|
|
@@ -30,4 +30,4 @@
|
|
|
30
30
|
max-width: 400px;
|
|
31
31
|
word-break: break-all;
|
|
32
32
|
}
|
|
33
|
-
`,document.head.appendChild(e)}createTooltip(){return this.tooltip?this.tooltip:(this.tooltip=document.createElement("div"),this.tooltip.id="__nvwa-inspector-tooltip",document.body.appendChild(this.tooltip),this.tooltip)}createOverlay(e){let t=document.createElement("div");return t.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${e}`,document.body.appendChild(t),t}updateOverlayPosition(e,t){if(!t.isConnected)return;let r=t.getBoundingClientRect(),
|
|
33
|
+
`,document.head.appendChild(e)}createTooltip(){return this.tooltip?this.tooltip:(this.tooltip=document.createElement("div"),this.tooltip.id="__nvwa-inspector-tooltip",document.body.appendChild(this.tooltip),this.tooltip)}createOverlay(e){let t=document.createElement("div");return t.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${e}`,document.body.appendChild(t),t}updateOverlayPosition(e,t){if(!t.isConnected)return;let r=t.getBoundingClientRect(),s=window.scrollX||window.pageXOffset,i=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(e.style.left=`${r.left+s}px`,e.style.top=`${r.top+i}px`,e.style.width=`${r.width}px`,e.style.height=`${r.height}px`,e.style.display="block"):e.style.display="none"}removeOverlay(e){e&&e.parentNode&&e.parentNode.removeChild(e)}highlightElement(e,t){if(!e.isConnected)return;if(this.hoverElement===e&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,e);let a=this.createTooltip();t?a.textContent=t:a.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,a.style.display="block";let c=e.getBoundingClientRect();a.style.left=`${c.left+window.scrollX}px`,a.style.top=`${c.top+window.scrollY-a.offsetHeight-8}px`,c.top<a.offsetHeight+8&&(a.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,e),this.hoverOverlay=r,this.hoverElement=e;let s=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s);let i=this.createTooltip();t?i.textContent=t:i.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,i.style.display="block";let o=e.getBoundingClientRect();i.style.left=`${o.left+window.scrollX}px`,i.style.top=`${o.top+window.scrollY-i.offsetHeight-8}px`,o.top<i.offsetHeight+8&&(i.style.top=`${o.bottom+window.scrollY+8}px`)}selectElement(e,t){if(!e.isConnected)return;if(this.selectedElement===e&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,e);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,e),this.selectedOverlay=r,this.selectedElement=e;let s=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let e=document.getElementById("__nvwa-inspector-overlay-style");e&&e.parentNode&&e.parentNode.removeChild(e)}};function Rt(n="root"){if(typeof document>"u")return null;let e=document.getElementById(n)||document.body;if(!e)return null;let t=e.querySelector("[data-source-location]");if(t){let r=t.getAttribute("data-source-location");if(r)return r}if(e.firstElementChild){let s=e.firstElementChild.getAttribute("data-source-location");if(s)return s}return null}u();var At=typeof fetch<"u"?fetch:(()=>{throw new Error("payment client requires fetch")})(),fe=class{constructor(e,t="/functions/payment",r=At){this.baseUrl=e;this.pathPrefix=t;this.fetchImpl=r}async rpc(e,t){let r=this.baseUrl.replace(/\/$/,""),s=this.pathPrefix.replace(/^\/?/,"").replace(/\/$/,""),i=`${r}/${s}/${e}`,o=await this.fetchImpl(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!o.ok){let a=await o.text();throw new Error(`${e} failed: ${o.status} ${a}`)}if(!(o.status===204||!o.body))return await o.json()}async getConfiguredProviders(e){try{let r=(await this.rpc("getConfiguredProviders",{}))?.providers;if(!Array.isArray(r))return[];if(r.length===0)return[];if(typeof r[0]=="string")return r;let i=r,o=e?.platform;return o?i.filter(a=>!a.supportedPlatforms||a.supportedPlatforms.includes(o)).map(a=>a.id):i.map(a=>a.id)}catch{return[]}}async createPayment(e){let t=await this.rpc("createOrder",{amount:e.amount,subject:e.subject,currency:e.currency??"cny",providerId:e.providerId,metadata:e.metadata});if(t.orderId==null)throw new Error("createPayment: missing orderId in response");return t}async queryOrder(e){let t=await this.rpc("getOrder",{orderId:e});return{orderId:t.orderId??e,status:t.status??"pending",order:t.order}}async cancelOrder(e){await this.rpc("cancelOrder",{orderId: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,NvwaSkill,OverlayManager,PaymentClient,Request,Response,URL,URLSearchParams,createPostgrestClient,getSourceLocationFromDOM,polyfill});
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var tt=Object.create;var H=Object.defineProperty;var rt=Object.getOwnPropertyDescriptor;var st=Object.getOwnPropertyNames;var nt=Object.getPrototypeOf,it=Object.prototype.hasOwnProperty;var ue=(s,e)=>()=>(s&&(e=s(s=0)),e);var E=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),ot=(s,e)=>{for(var t in e)H(s,t,{get:e[t],enumerable:!0})},he=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of st(e))!it.call(s,n)&&n!==t&&H(s,n,{get:()=>e[n],enumerable:!(r=rt(e,n))||r.enumerable});return s};var at=(s,e,t)=>(t=s!=null?tt(nt(s)):{},he(e||!s||!s.__esModule?H(t,"default",{value:s,enumerable:!0}):t,s)),S=s=>he(H({},"__esModule",{value:!0}),s);import Rt from"path";import{fileURLToPath as At}from"url";var c=ue(()=>{"use strict"});var x={};ot(x,{__addDisposableResource:()=>Me,__assign:()=>k,__asyncDelegator:()=>Ae,__asyncGenerator:()=>je,__asyncValues:()=>Ce,__await:()=>T,__awaiter:()=>xe,__classPrivateFieldGet:()=>Le,__classPrivateFieldIn:()=>ke,__classPrivateFieldSet:()=>Ne,__createBinding:()=>q,__decorate:()=>ge,__disposeResources:()=>qe,__esDecorate:()=>we,__exportStar:()=>Se,__extends:()=>me,__generator:()=>Oe,__importDefault:()=>Ue,__importStar:()=>Ie,__makeTemplateObject:()=>He,__metadata:()=>Ee,__param:()=>ve,__propKey:()=>Pe,__read:()=>J,__rest:()=>ye,__rewriteRelativeImportExtension:()=>De,__runInitializers:()=>be,__setFunctionName:()=>_e,__spread:()=>Te,__spreadArray:()=>Re,__spreadArrays:()=>$e,__values:()=>M,default:()=>ft});function me(s,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");z(s,e);function t(){this.constructor=s}s.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function ye(s,e){var t={};for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&e.indexOf(r)<0&&(t[r]=s[r]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(s);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(s,r[n])&&(t[r[n]]=s[r[n]]);return t}function ge(s,e,t,r){var n=arguments.length,i=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(s,e,t,r);else for(var a=s.length-1;a>=0;a--)(o=s[a])&&(i=(n<3?o(i):n>3?o(e,t,i):o(e,t))||i);return n>3&&i&&Object.defineProperty(e,t,i),i}function ve(s,e){return function(t,r){e(t,r,s)}}function we(s,e,t,r,n,i){function o(_){if(_!==void 0&&typeof _!="function")throw new TypeError("Function expected");return _}for(var a=r.kind,u=a==="getter"?"get":a==="setter"?"set":"value",l=!e&&s?r.static?s:s.prototype:null,h=e||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,y=!1,p=t.length-1;p>=0;p--){var g={};for(var b in r)g[b]=b==="access"?{}:r[b];for(var b in r.access)g.access[b]=r.access[b];g.addInitializer=function(_){if(y)throw new TypeError("Cannot add initializers after decoration has completed");i.push(o(_||null))};var v=(0,t[p])(a==="accessor"?{get:h.get,set:h.set}:h[u],g);if(a==="accessor"){if(v===void 0)continue;if(v===null||typeof v!="object")throw new TypeError("Object expected");(d=o(v.get))&&(h.get=d),(d=o(v.set))&&(h.set=d),(d=o(v.init))&&n.unshift(d)}else(d=o(v))&&(a==="field"?n.unshift(d):h[u]=d)}l&&Object.defineProperty(l,r.name,h),y=!0}function be(s,e,t){for(var r=arguments.length>2,n=0;n<e.length;n++)t=r?e[n].call(s,t):e[n].call(s);return r?t:void 0}function Pe(s){return typeof s=="symbol"?s:"".concat(s)}function _e(s,e,t){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(s,"name",{configurable:!0,value:t?"".concat(t," ",e):e})}function Ee(s,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,e)}function xe(s,e,t,r){function n(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(h){try{l(r.next(h))}catch(d){o(d)}}function u(h){try{l(r.throw(h))}catch(d){o(d)}}function l(h){h.done?i(h.value):n(h.value).then(a,u)}l((r=r.apply(s,e||[])).next())})}function Oe(s,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,n,i,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return u([l,h])}}function u(l){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(t=0)),t;)try{if(r=1,n&&(i=l[0]&2?n.return:l[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,l[1])).done)return i;switch(n=0,i&&(l=[l[0]&2,i.value]),l[0]){case 0:case 1:i=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,n=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!i||l[1]>i[0]&&l[1]<i[3])){t.label=l[1];break}if(l[0]===6&&t.label<i[1]){t.label=i[1],i=l;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(l);break}i[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(s,t)}catch(h){l=[6,h],n=0}finally{r=i=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Se(s,e){for(var t in s)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&q(e,s,t)}function M(s){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&s[e],r=0;if(t)return t.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&r>=s.length&&(s=void 0),{value:s&&s[r++],done:!s}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function J(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var r=t.call(s),n,i=[],o;try{for(;(e===void 0||e-- >0)&&!(n=r.next()).done;)i.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(o)throw o.error}}return i}function Te(){for(var s=[],e=0;e<arguments.length;e++)s=s.concat(J(arguments[e]));return s}function $e(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var r=Array(s),n=0,e=0;e<t;e++)for(var i=arguments[e],o=0,a=i.length;o<a;o++,n++)r[n]=i[o];return r}function Re(s,e,t){if(t||arguments.length===2)for(var r=0,n=e.length,i;r<n;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return s.concat(i||Array.prototype.slice.call(e))}function T(s){return this instanceof T?(this.v=s,this):new T(s)}function je(s,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(s,e||[]),n,i=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),n[Symbol.asyncIterator]=function(){return this},n;function o(p){return function(g){return Promise.resolve(g).then(p,d)}}function a(p,g){r[p]&&(n[p]=function(b){return new Promise(function(v,_){i.push([p,b,v,_])>1||u(p,b)})},g&&(n[p]=g(n[p])))}function u(p,g){try{l(r[p](g))}catch(b){y(i[0][3],b)}}function l(p){p.value instanceof T?Promise.resolve(p.value.v).then(h,d):y(i[0][2],p)}function h(p){u("next",p)}function d(p){u("throw",p)}function y(p,g){p(g),i.shift(),i.length&&u(i[0][0],i[0][1])}}function Ae(s){var e,t;return e={},r("next"),r("throw",function(n){throw n}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(n,i){e[n]=s[n]?function(o){return(t=!t)?{value:T(s[n](o)),done:!1}:i?i(o):o}:i}}function Ce(s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=s[Symbol.asyncIterator],t;return e?e.call(s):(s=typeof M=="function"?M(s):s[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(i){t[i]=s[i]&&function(o){return new Promise(function(a,u){o=s[i](o),n(a,u,o.done,o.value)})}}function n(i,o,a,u){Promise.resolve(u).then(function(l){i({value:l,done:a})},o)}}function He(s,e){return Object.defineProperty?Object.defineProperty(s,"raw",{value:e}):s.raw=e,s}function Ie(s){if(s&&s.__esModule)return s;var e={};if(s!=null)for(var t=G(s),r=0;r<t.length;r++)t[r]!=="default"&&q(e,s,t[r]);return dt(e,s),e}function Ue(s){return s&&s.__esModule?s:{default:s}}function Le(s,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?s!==e||!r:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(s):r?r.value:e.get(s)}function Ne(s,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?s!==e||!n:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(s,t):n?n.value=t:e.set(s,t),t}function ke(s,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof s=="function"?e===s:s.has(e)}function Me(s,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var r,n;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=e[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=e[Symbol.dispose],t&&(n=r)}if(typeof r!="function")throw new TypeError("Object not disposable.");n&&(r=function(){try{n.call(this)}catch(i){return Promise.reject(i)}}),s.stack.push({value:e,dispose:r,async:t})}else t&&s.stack.push({async:!0});return e}function qe(s){function e(i){s.error=s.hasError?new pt(i,s.error,"An error was suppressed during disposal."):i,s.hasError=!0}var t,r=0;function n(){for(;t=s.stack.pop();)try{if(!t.async&&r===1)return r=0,s.stack.push(t),Promise.resolve().then(n);if(t.dispose){var i=t.dispose.call(t.value);if(t.async)return r|=2,Promise.resolve(i).then(n,function(o){return e(o),n()})}else r|=1}catch(o){e(o)}if(r===1)return s.hasError?Promise.reject(s.error):Promise.resolve();if(s.hasError)throw s.error}return n()}function De(s,e){return typeof s=="string"&&/^\.\.?\//.test(s)?s.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,r,n,i,o){return r?e?".jsx":".js":n&&(!i||!o)?t:n+i+"."+o.toLowerCase()+"js"}):s}var z,k,q,dt,G,pt,ft,O=ue(()=>{"use strict";c();z=function(s,e){return z=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])},z(s,e)};k=function(){return k=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},k.apply(this,arguments)};q=Object.create?(function(s,e,t,r){r===void 0&&(r=t);var n=Object.getOwnPropertyDescriptor(e,t);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(s,r,n)}):(function(s,e,t,r){r===void 0&&(r=t),s[r]=e[t]});dt=Object.create?(function(s,e){Object.defineProperty(s,"default",{enumerable:!0,value:e})}):function(s,e){s.default=e},G=function(s){return G=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},G(s)};pt=typeof SuppressedError=="function"?SuppressedError:function(s,e,t){var r=new Error(t);return r.name="SuppressedError",r.error=s,r.suppressed=e,r};ft={__extends:me,__assign:k,__rest:ye,__decorate:ge,__param:ve,__esDecorate:we,__runInitializers:be,__propKey:Pe,__setFunctionName:_e,__metadata:Ee,__awaiter:xe,__generator:Oe,__createBinding:q,__exportStar:Se,__values:M,__read:J,__spread:Te,__spreadArrays:$e,__spreadArray:Re,__await:T,__asyncGenerator:je,__asyncDelegator:Ae,__asyncValues:Ce,__makeTemplateObject:He,__importStar:Ie,__importDefault:Ue,__classPrivateFieldGet:Le,__classPrivateFieldSet:Ne,__classPrivateFieldIn:ke,__addDisposableResource:Me,__disposeResources:qe,__rewriteRelativeImportExtension:De}});var Y=E(V=>{"use strict";c();Object.defineProperty(V,"__esModule",{value:!0});var W=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};V.default=W});var X=E(K=>{"use strict";c();Object.defineProperty(K,"__esModule",{value:!0});var mt=(O(),S(x)),yt=mt.__importDefault(Y()),Q=class{constructor(e){var t,r;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(r=e.isMaybeSingle)!==null&&r!==void 0?r:!1,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let r=this.fetch,n=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{var o,a,u,l;let h=null,d=null,y=null,p=i.status,g=i.statusText;if(i.ok){if(this.method!=="HEAD"){let C=await i.text();C===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((o=this.headers.get("Accept"))===null||o===void 0)&&o.includes("application/vnd.pgrst.plan+text"))?d=C:d=JSON.parse(C))}let v=(a=this.headers.get("Prefer"))===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),_=(u=i.headers.get("content-range"))===null||u===void 0?void 0:u.split("/");v&&_&&_.length>1&&(y=parseInt(_[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(h={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,y=null,p=406,g="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let v=await i.text();try{h=JSON.parse(v),Array.isArray(h)&&i.status===404&&(d=[],h=null,p=200,g="OK")}catch{i.status===404&&v===""?(p=204,g="No Content"):h={message:v}}if(h&&this.isMaybeSingle&&(!((l=h?.details)===null||l===void 0)&&l.includes("0 rows"))&&(h=null,p=200,g="OK"),h&&this.shouldThrowOnError)throw new yt.default(h)}return{error:h,data:d,count:y,status:p,statusText:g}});return this.shouldThrowOnError||(n=n.catch(i=>{var o,a,u;return{error:{message:`${(o=i?.name)!==null&&o!==void 0?o:"FetchError"}: ${i?.message}`,details:`${(a=i?.stack)!==null&&a!==void 0?a:""}`,hint:"",code:`${(u=i?.code)!==null&&u!==void 0?u:""}`},data:null,count:null,status:0,statusText:""}})),n.then(e,t)}returns(){return this}overrideTypes(){return this}};K.default=Q});var te=E(ee=>{"use strict";c();Object.defineProperty(ee,"__esModule",{value:!0});var gt=(O(),S(x)),vt=gt.__importDefault(X()),Z=class extends vt.default{select(e){let t=!1,r=(e??"*").split("").map(n=>/\s/.test(n)&&!t?"":(n==='"'&&(t=!t),n)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:n,referencedTable:i=n}={}){let o=i?`${i}.order`:"order",a=this.url.searchParams.get(o);return this.url.searchParams.set(o,`${a?`${a},`:""}${e}.${t?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:r=t}={}){let n=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(n,`${e}`),this}range(e,t,{foreignTable:r,referencedTable:n=r}={}){let i=typeof n>"u"?"offset":`${n}.offset`,o=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(i,`${e}`),this.url.searchParams.set(o,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:n=!1,wal:i=!1,format:o="text"}={}){var a;let u=[e?"analyze":null,t?"verbose":null,r?"settings":null,n?"buffers":null,i?"wal":null].filter(Boolean).join("|"),l=(a=this.headers.get("Accept"))!==null&&a!==void 0?a:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${o}; for="${l}"; options=${u};`),o==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};ee.default=Z});var D=E(se=>{"use strict";c();Object.defineProperty(se,"__esModule",{value:!0});var wt=(O(),S(x)),bt=wt.__importDefault(te()),Pt=new RegExp("[,()]"),re=class extends bt.default{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){let r=Array.from(new Set(t)).map(n=>typeof n=="string"&&Pt.test(n)?`"${n}"`:`${n}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:n}={}){let i="";n==="plain"?i="pl":n==="phrase"?i="ph":n==="websearch"&&(i="w");let o=r===void 0?"":`(${r})`;return this.url.searchParams.append(e,`${i}fts${o}.${t}`),this}match(e){return Object.entries(e).forEach(([t,r])=>{this.url.searchParams.append(t,`eq.${r}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t,referencedTable:r=t}={}){let n=r?`${r}.or`:"or";return this.url.searchParams.append(n,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}};se.default=re});var oe=E(ie=>{"use strict";c();Object.defineProperty(ie,"__esModule",{value:!0});var _t=(O(),S(x)),A=_t.__importDefault(D()),ne=class{constructor(e,{headers:t={},schema:r,fetch:n}){this.url=e,this.headers=new Headers(t),this.schema=r,this.fetch=n}select(e,t){let{head:r=!1,count:n}=t??{},i=r?"HEAD":"GET",o=!1,a=(e??"*").split("").map(u=>/\s/.test(u)&&!o?"":(u==='"'&&(o=!o),u)).join("");return this.url.searchParams.set("select",a),n&&this.headers.append("Prefer",`count=${n}`),new A.default({method:i,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:r=!0}={}){var n;let i="POST";if(t&&this.headers.append("Prefer",`count=${t}`),r||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let o=e.reduce((a,u)=>a.concat(Object.keys(u)),[]);if(o.length>0){let a=[...new Set(o)].map(u=>`"${u}"`);this.url.searchParams.set("columns",a.join(","))}}return new A.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:n,defaultToNull:i=!0}={}){var o;let a="POST";if(this.headers.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),t!==void 0&&this.url.searchParams.set("on_conflict",t),n&&this.headers.append("Prefer",`count=${n}`),i||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let u=e.reduce((l,h)=>l.concat(Object.keys(h)),[]);if(u.length>0){let l=[...new Set(u)].map(h=>`"${h}"`);this.url.searchParams.set("columns",l.join(","))}}return new A.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}update(e,{count:t}={}){var r;let n="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new A.default({method:n,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch})}delete({count:e}={}){var t;let r="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new A.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};ie.default=ne});var Fe=E(le=>{"use strict";c();Object.defineProperty(le,"__esModule",{value:!0});var Be=(O(),S(x)),Et=Be.__importDefault(oe()),xt=Be.__importDefault(D()),ae=class s{constructor(e,{headers:t={},schema:r,fetch:n}={}){this.url=e,this.headers=new Headers(t),this.schemaName=r,this.fetch=n}from(e){let t=new URL(`${this.url}/${e}`);return new Et.default(t,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new s(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:r=!1,get:n=!1,count:i}={}){var o;let a,u=new URL(`${this.url}/rpc/${e}`),l;r||n?(a=r?"HEAD":"GET",Object.entries(t).filter(([d,y])=>y!==void 0).map(([d,y])=>[d,Array.isArray(y)?`{${y.join(",")}}`:`${y}`]).forEach(([d,y])=>{u.searchParams.append(d,y)})):(a="POST",l=t);let h=new Headers(this.headers);return i&&h.set("Prefer",`count=${i}`),new xt.default({method:a,url:u,headers:h,schema:this.schemaName,body:l,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};le.default=ae});var Qe=E(w=>{"use strict";c();Object.defineProperty(w,"__esModule",{value:!0});w.PostgrestError=w.PostgrestBuilder=w.PostgrestTransformBuilder=w.PostgrestFilterBuilder=w.PostgrestQueryBuilder=w.PostgrestClient=void 0;var $=(O(),S(x)),ze=$.__importDefault(Fe());w.PostgrestClient=ze.default;var Ge=$.__importDefault(oe());w.PostgrestQueryBuilder=Ge.default;var Je=$.__importDefault(D());w.PostgrestFilterBuilder=Je.default;var We=$.__importDefault(te());w.PostgrestTransformBuilder=We.default;var Ve=$.__importDefault(X());w.PostgrestBuilder=Ve.default;var Ye=$.__importDefault(Y());w.PostgrestError=Ye.default;w.default={PostgrestClient:ze.default,PostgrestQueryBuilder:Ge.default,PostgrestFilterBuilder:Je.default,PostgrestTransformBuilder:We.default,PostgrestBuilder:Ve.default,PostgrestError:Ye.default}});c();c();var de=class{constructor(e,t=""){this.http=e,this.baseUrl=t.replace(/\/$/,"")}async invoke(e,t){let r=this.baseUrl?`${this.baseUrl}/functions/${e}`:`/functions/${e}`;return await(await this.http.fetch(r,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};c();c();var F="nvwa_current_jwt",lt=typeof fetch<"u"?fetch:(()=>{throw new Error("AuthClient requires fetch")})(),B=class{constructor(e,t={}){this.baseUrl=e.replace(/\/$/,""),this.authPath=(t.authPath??"/auth").replace(/^\//,""),this.fetchImpl=t.fetchImpl??lt}url(e){return`${`${this.baseUrl}/${this.authPath}`.replace(/\/+/g,"/")}/${e.replace(/^\//,"")}`}async getSession(){try{let e=await this.fetchImpl(this.url("session"),{method:"GET",credentials:"include"});return e.ok?{data:await e.json()}:{data:null,error:{message:await e.text()||e.statusText,status:e.status}}}catch(e){return{data:null,error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithEmail(e,t){try{let r=await this.fetchImpl(this.url("sign-in/email"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:e,password:t})}),n=await r.text();return r.ok?{data:n?JSON.parse(n):void 0}:{error:{message:n||r.statusText,status:r.status}}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let e=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:"include"});return e.ok?{}:{error:{message:await e.text()||e.statusText,status:e.status}}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}};c();c();var P=class s{constructor(e){this.headerMap=new Map;if(e){if(e instanceof s)e.forEach((t,r)=>this.set(r,t));else if(Array.isArray(e))for(let[t,r]of e)this.set(t,String(r));else if(typeof e=="object")for(let t of Object.keys(e))this.set(t,String(e[t]))}}append(e,t){let r=e.toLowerCase(),n=this.headerMap.get(r);this.headerMap.set(r,n?`${n}, ${t}`:t)}set(e,t){this.headerMap.set(e.toLowerCase(),String(t))}get(e){let t=this.headerMap.get(e.toLowerCase());return t??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[t,r]of this.headerMap.entries())e(r,t,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},R=class s{constructor(e){this.params=new Map;if(e){if(typeof e=="string")this.parseString(e);else if(e instanceof s)this.params=new Map(e.params);else if(Array.isArray(e))for(let[t,r]of e)this.append(t,r);else if(e&&typeof e=="object")for(let[t,r]of Object.entries(e))this.set(t,r)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let t=e.split("&");for(let r of t)if(r){let[n,i]=r.split("=");n&&this.append(decodeURIComponent(n),i?decodeURIComponent(i):"")}}append(e,t){let r=this.params.get(e)||[];r.push(t),this.params.set(e,r)}delete(e){this.params.delete(e)}get(e){let t=this.params.get(e);return t?t[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,t){this.params.set(e,[t])}sort(){let e=Array.from(this.params.entries()).sort(([t],[r])=>t.localeCompare(r));this.params=new Map(e)}toString(){let e=[];for(let[t,r]of this.params.entries())for(let n of r)e.push(`${encodeURIComponent(t)}=${encodeURIComponent(n)}`);return e.join("&")}forEach(e){for(let[t,r]of this.params.entries())for(let n of r)e(n,t,this)}keys(){return this.params.keys()}values(){let e=[];for(let t of this.params.values())e.push(...t);return e[Symbol.iterator]()}entries(){let e=[];for(let[t,r]of this.params.entries())for(let n of r)e.push([t,n]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},I=class s{constructor(e,t){let r;if(e instanceof s)r=e.href;else if(t){let i=t instanceof s?t.href:t;r=this.resolve(i,e)}else r=e;let n=this.parseUrl(r);this.href=r,this.origin=`${n.protocol}//${n.host}`,this.protocol=n.protocol,this.username=n.username,this.password=n.password,this.host=n.host,this.hostname=n.hostname,this.port=n.port,this.pathname=n.pathname,this.search=n.search,this.searchParams=new R(n.search),this.hash=n.hash}resolve(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(t.startsWith("//"))return`${this.parseUrl(e).protocol}${t}`;if(t.startsWith("/")){let i=this.parseUrl(e);return`${i.protocol}//${i.host}${t}`}let r=this.parseUrl(e),n=r.pathname.endsWith("/")?r.pathname:r.pathname+"/";return`${r.protocol}//${r.host}${n}${t}`}parseUrl(e){let t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)throw new TypeError("Invalid URL");let r=t[2]||"",n=t[4]||"",i=t[5]||"/",o=t[7]?`?${t[7]}`:"",a=t[9]?`#${t[9]}`:"";if(!r&&!n&&!i.startsWith("/")&&!i.includes("/")&&!i.includes("."))throw new TypeError("Invalid URL");let u=n.match(/^([^@]*)@(.+)$/),l="",h="",d=n;if(u){let b=u[1];d=u[2];let v=b.match(/^([^:]*):?(.*)$/);v&&(l=v[1]||"",h=v[2]||"")}let y=d.match(/^([^:]+):?(\d*)$/),p=y?y[1]:d,g=y&&y[2]?y[2]:"";return{protocol:r?`${r}:`:"",username:l,password:h,host:d,hostname:p,port:g,pathname:i,search:o,hash:a}}toString(){let e=this.searchParams.toString(),t=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${t}${this.hash}`}toJSON(){return this.toString()}};c();var U=class s{constructor(e,t){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(t?.method||"GET").toUpperCase(),this.headers=t?.headers instanceof P?t.headers:new P(t?.headers),this.body=t?.body,this.timeout=t?.timeout,this.signal=t?.signal||void 0}clone(){return new s(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};c();var L=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=ct(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function ct(s){return s?new P(s):new P}c();var j=class{constructor(){this._aborted=!1;this.listeners=new Set;this.onabort=null}get aborted(){return this._aborted}_trigger(){if(!this._aborted){if(this._aborted=!0,typeof this.onabort=="function")try{this.onabort()}catch{}for(let e of Array.from(this.listeners))try{e()}catch{}this.listeners.clear()}}addEventListener(e,t){if(this._aborted){try{t()}catch{}return}this.listeners.add(t)}removeEventListener(e,t){this.listeners.delete(t)}toString(){return"[object AbortSignal]"}},N=class{constructor(){this._signal=new j}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};c();function Kt(s){s.URL=I,s.URLSearchParams=R,s.Headers=P,s.Request=U,s.Response=L,s.AbortController=N,s.AbortSignal=j}var pe=class{constructor(e,t,r){console.log("NvwaHttpClient constructor",e,t,r),this.storage=e,this.customFetch=t,this.handleUnauthorized=r}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let r=await this.storage.get(F),n=new P(t?.headers);r&&n.set("Authorization",`Bearer ${r}`);let i=t?.method||"GET";if((i==="POST"||i==="PUT"||i==="PATCH")&&t?.body){let a=n.get("Content-Type");(!a||a.includes("text/plain"))&&n.set("Content-Type","application/json")}let o=await this.customFetch(e,{...t,headers:n});if(o.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return o}};c();var ut="/storage",ht=ut+"/generateUploadUrl",fe=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+ht,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=await t.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let n=await this.http.fetch(r,{method:"PUT",body:e,headers:new P({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:i}=await n.json();return{url:i.split("?")[0]}}};c();c();c();var ce=at(Qe(),1),{PostgrestClient:Ke,PostgrestQueryBuilder:Lr,PostgrestFilterBuilder:Nr,PostgrestTransformBuilder:kr,PostgrestBuilder:Mr,PostgrestError:qr}=ce.default||ce;var Ot="/entities",zr=(s,e)=>new Ke(s+Ot,{fetch:e.fetchWithAuth.bind(e)});c();var Xe=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/skill/${e}/execute`,i=await(await this.http.fetchWithAuth(r,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(i.status!==200)throw new Error(i.message);return i.data}};c();var Ze=class{constructor(){this.hoverOverlay=null;this.selectedOverlay=null;this.tooltip=null;this.hoverElement=null;this.selectedElement=null;this.hoverUpdateHandler=null;this.selectedUpdateHandler=null;this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let e=document.createElement("style");e.id="__nvwa-inspector-overlay-style",e.textContent=`
|
|
1
|
+
var tt=Object.create;var C=Object.defineProperty;var rt=Object.getOwnPropertyDescriptor;var st=Object.getOwnPropertyNames;var nt=Object.getPrototypeOf,it=Object.prototype.hasOwnProperty;var ce=(n,e)=>()=>(n&&(e=n(n=0)),e);var E=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),ot=(n,e)=>{for(var t in e)C(n,t,{get:e[t],enumerable:!0})},he=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of st(e))!it.call(n,s)&&s!==t&&C(n,s,{get:()=>e[s],enumerable:!(r=rt(e,s))||r.enumerable});return n};var at=(n,e,t)=>(t=n!=null?tt(nt(n)):{},he(e||!n||!n.__esModule?C(t,"default",{value:n,enumerable:!0}):t,n)),S=n=>he(C({},"__esModule",{value:!0}),n);import jt from"path";import{fileURLToPath as Ct}from"url";var u=ce(()=>{"use strict"});var x={};ot(x,{__addDisposableResource:()=>Me,__assign:()=>k,__asyncDelegator:()=>je,__asyncGenerator:()=>Ae,__asyncValues:()=>Ue,__await:()=>T,__awaiter:()=>xe,__classPrivateFieldGet:()=>Le,__classPrivateFieldIn:()=>ke,__classPrivateFieldSet:()=>Ne,__createBinding:()=>q,__decorate:()=>ye,__disposeResources:()=>qe,__esDecorate:()=>we,__exportStar:()=>Se,__extends:()=>me,__generator:()=>Oe,__importDefault:()=>He,__importStar:()=>Ie,__makeTemplateObject:()=>Ce,__metadata:()=>Ee,__param:()=>ve,__propKey:()=>Pe,__read:()=>z,__rest:()=>ge,__rewriteRelativeImportExtension:()=>De,__runInitializers:()=>be,__setFunctionName:()=>_e,__spread:()=>Te,__spreadArray:()=>Re,__spreadArrays:()=>$e,__values:()=>M,default:()=>gt});function me(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");G(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function ge(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t}function ye(n,e,t,r){var s=arguments.length,i=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(n,e,t,r);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(i=(s<3?o(i):s>3?o(e,t,i):o(e,t))||i);return s>3&&i&&Object.defineProperty(e,t,i),i}function ve(n,e){return function(t,r){e(t,r,n)}}function we(n,e,t,r,s,i){function o(_){if(_!==void 0&&typeof _!="function")throw new TypeError("Function expected");return _}for(var a=r.kind,c=a==="getter"?"get":a==="setter"?"set":"value",l=!e&&n?r.static?n:n.prototype:null,h=e||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,g=!1,p=t.length-1;p>=0;p--){var y={};for(var b in r)y[b]=b==="access"?{}:r[b];for(var b in r.access)y.access[b]=r.access[b];y.addInitializer=function(_){if(g)throw new TypeError("Cannot add initializers after decoration has completed");i.push(o(_||null))};var v=(0,t[p])(a==="accessor"?{get:h.get,set:h.set}:h[c],y);if(a==="accessor"){if(v===void 0)continue;if(v===null||typeof v!="object")throw new TypeError("Object expected");(d=o(v.get))&&(h.get=d),(d=o(v.set))&&(h.set=d),(d=o(v.init))&&s.unshift(d)}else(d=o(v))&&(a==="field"?s.unshift(d):h[c]=d)}l&&Object.defineProperty(l,r.name,h),g=!0}function be(n,e,t){for(var r=arguments.length>2,s=0;s<e.length;s++)t=r?e[s].call(n,t):e[s].call(n);return r?t:void 0}function Pe(n){return typeof n=="symbol"?n:"".concat(n)}function _e(n,e,t){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(n,"name",{configurable:!0,value:t?"".concat(t," ",e):e})}function Ee(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)}function xe(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(h){try{l(r.next(h))}catch(d){o(d)}}function c(h){try{l(r.throw(h))}catch(d){o(d)}}function l(h){h.done?i(h.value):s(h.value).then(a,c)}l((r=r.apply(n,e||[])).next())})}function Oe(n,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,s,i,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return c([l,h])}}function c(l){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(t=0)),t;)try{if(r=1,s&&(i=l[0]&2?s.return:l[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,l[1])).done)return i;switch(s=0,i&&(l=[l[0]&2,i.value]),l[0]){case 0:case 1:i=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,s=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!i||l[1]>i[0]&&l[1]<i[3])){t.label=l[1];break}if(l[0]===6&&t.label<i[1]){t.label=i[1],i=l;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(l);break}i[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(h){l=[6,h],s=0}finally{r=i=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Se(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&q(e,n,t)}function M(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],r=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function z(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var r=t.call(n),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(o)throw o.error}}return i}function Te(){for(var n=[],e=0;e<arguments.length;e++)n=n.concat(z(arguments[e]));return n}function $e(){for(var n=0,e=0,t=arguments.length;e<t;e++)n+=arguments[e].length;for(var r=Array(n),s=0,e=0;e<t;e++)for(var i=arguments[e],o=0,a=i.length;o<a;o++,s++)r[s]=i[o];return r}function Re(n,e,t){if(t||arguments.length===2)for(var r=0,s=e.length,i;r<s;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return n.concat(i||Array.prototype.slice.call(e))}function T(n){return this instanceof T?(this.v=n,this):new T(n)}function Ae(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),s,i=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(p){return function(y){return Promise.resolve(y).then(p,d)}}function a(p,y){r[p]&&(s[p]=function(b){return new Promise(function(v,_){i.push([p,b,v,_])>1||c(p,b)})},y&&(s[p]=y(s[p])))}function c(p,y){try{l(r[p](y))}catch(b){g(i[0][3],b)}}function l(p){p.value instanceof T?Promise.resolve(p.value.v).then(h,d):g(i[0][2],p)}function h(p){c("next",p)}function d(p){c("throw",p)}function g(p,y){p(y),i.shift(),i.length&&c(i[0][0],i[0][1])}}function je(n){var e,t;return e={},r("next"),r("throw",function(s){throw s}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(s,i){e[s]=n[s]?function(o){return(t=!t)?{value:T(n[s](o)),done:!1}:i?i(o):o}:i}}function Ue(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof M=="function"?M(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(i){t[i]=n[i]&&function(o){return new Promise(function(a,c){o=n[i](o),s(a,c,o.done,o.value)})}}function s(i,o,a,c){Promise.resolve(c).then(function(l){i({value:l,done:a})},o)}}function Ce(n,e){return Object.defineProperty?Object.defineProperty(n,"raw",{value:e}):n.raw=e,n}function Ie(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t=J(n),r=0;r<t.length;r++)t[r]!=="default"&&q(e,n,t[r]);return ft(e,n),e}function He(n){return n&&n.__esModule?n:{default:n}}function Le(n,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(n):r?r.value:e.get(n)}function Ne(n,e,t,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 e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(n,t):s?s.value=t:e.set(n,t),t}function ke(n,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof n=="function"?e===n:n.has(e)}function Me(n,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var r,s;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=e[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=e[Symbol.dispose],t&&(s=r)}if(typeof r!="function")throw new TypeError("Object not disposable.");s&&(r=function(){try{s.call(this)}catch(i){return Promise.reject(i)}}),n.stack.push({value:e,dispose:r,async:t})}else t&&n.stack.push({async:!0});return e}function qe(n){function e(i){n.error=n.hasError?new mt(i,n.error,"An error was suppressed during disposal."):i,n.hasError=!0}var t,r=0;function s(){for(;t=n.stack.pop();)try{if(!t.async&&r===1)return r=0,n.stack.push(t),Promise.resolve().then(s);if(t.dispose){var i=t.dispose.call(t.value);if(t.async)return r|=2,Promise.resolve(i).then(s,function(o){return e(o),s()})}else r|=1}catch(o){e(o)}if(r===1)return n.hasError?Promise.reject(n.error):Promise.resolve();if(n.hasError)throw n.error}return s()}function De(n,e){return typeof n=="string"&&/^\.\.?\//.test(n)?n.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,r,s,i,o){return r?e?".jsx":".js":s&&(!i||!o)?t:s+i+"."+o.toLowerCase()+"js"}):n}var G,k,q,ft,J,mt,gt,O=ce(()=>{"use strict";u();G=function(n,e){return G=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])},G(n,e)};k=function(){return k=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},k.apply(this,arguments)};q=Object.create?(function(n,e,t,r){r===void 0&&(r=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,r,s)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]});ft=Object.create?(function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}):function(n,e){n.default=e},J=function(n){return J=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},J(n)};mt=typeof SuppressedError=="function"?SuppressedError:function(n,e,t){var r=new Error(t);return r.name="SuppressedError",r.error=n,r.suppressed=e,r};gt={__extends:me,__assign:k,__rest:ge,__decorate:ye,__param:ve,__esDecorate:we,__runInitializers:be,__propKey:Pe,__setFunctionName:_e,__metadata:Ee,__awaiter:xe,__generator:Oe,__createBinding:q,__exportStar:Se,__values:M,__read:z,__spread:Te,__spreadArrays:$e,__spreadArray:Re,__await:T,__asyncGenerator:Ae,__asyncDelegator:je,__asyncValues:Ue,__makeTemplateObject:Ce,__importStar:Ie,__importDefault:He,__classPrivateFieldGet:Le,__classPrivateFieldSet:Ne,__classPrivateFieldIn:ke,__addDisposableResource:Me,__disposeResources:qe,__rewriteRelativeImportExtension:De}});var K=E(Y=>{"use strict";u();Object.defineProperty(Y,"__esModule",{value:!0});var W=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};Y.default=W});var X=E(Q=>{"use strict";u();Object.defineProperty(Q,"__esModule",{value:!0});var yt=(O(),S(x)),vt=yt.__importDefault(K()),V=class{constructor(e){var t,r;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(r=e.isMaybeSingle)!==null&&r!==void 0?r:!1,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let r=this.fetch,s=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{var o,a,c,l;let h=null,d=null,g=null,p=i.status,y=i.statusText;if(i.ok){if(this.method!=="HEAD"){let U=await i.text();U===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((o=this.headers.get("Accept"))===null||o===void 0)&&o.includes("application/vnd.pgrst.plan+text"))?d=U:d=JSON.parse(U))}let v=(a=this.headers.get("Prefer"))===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),_=(c=i.headers.get("content-range"))===null||c===void 0?void 0:c.split("/");v&&_&&_.length>1&&(g=parseInt(_[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(h={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,g=null,p=406,y="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let v=await i.text();try{h=JSON.parse(v),Array.isArray(h)&&i.status===404&&(d=[],h=null,p=200,y="OK")}catch{i.status===404&&v===""?(p=204,y="No Content"):h={message:v}}if(h&&this.isMaybeSingle&&(!((l=h?.details)===null||l===void 0)&&l.includes("0 rows"))&&(h=null,p=200,y="OK"),h&&this.shouldThrowOnError)throw new vt.default(h)}return{error:h,data:d,count:g,status:p,statusText:y}});return this.shouldThrowOnError||(s=s.catch(i=>{var o,a,c;return{error:{message:`${(o=i?.name)!==null&&o!==void 0?o:"FetchError"}: ${i?.message}`,details:`${(a=i?.stack)!==null&&a!==void 0?a:""}`,hint:"",code:`${(c=i?.code)!==null&&c!==void 0?c:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}returns(){return this}overrideTypes(){return this}};Q.default=V});var te=E(ee=>{"use strict";u();Object.defineProperty(ee,"__esModule",{value:!0});var wt=(O(),S(x)),bt=wt.__importDefault(X()),Z=class extends bt.default{select(e){let t=!1,r=(e??"*").split("").map(s=>/\s/.test(s)&&!t?"":(s==='"'&&(t=!t),s)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:s,referencedTable:i=s}={}){let o=i?`${i}.order`:"order",a=this.url.searchParams.get(o);return this.url.searchParams.set(o,`${a?`${a},`:""}${e}.${t?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:r=t}={}){let s=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:r,referencedTable:s=r}={}){let i=typeof s>"u"?"offset":`${s}.offset`,o=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(i,`${e}`),this.url.searchParams.set(o,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:s=!1,wal:i=!1,format:o="text"}={}){var a;let c=[e?"analyze":null,t?"verbose":null,r?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),l=(a=this.headers.get("Accept"))!==null&&a!==void 0?a:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${o}; for="${l}"; options=${c};`),o==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};ee.default=Z});var D=E(se=>{"use strict";u();Object.defineProperty(se,"__esModule",{value:!0});var Pt=(O(),S(x)),_t=Pt.__importDefault(te()),Et=new RegExp("[,()]"),re=class extends _t.default{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){let r=Array.from(new Set(t)).map(s=>typeof s=="string"&&Et.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:s}={}){let i="";s==="plain"?i="pl":s==="phrase"?i="ph":s==="websearch"&&(i="w");let o=r===void 0?"":`(${r})`;return this.url.searchParams.append(e,`${i}fts${o}.${t}`),this}match(e){return Object.entries(e).forEach(([t,r])=>{this.url.searchParams.append(t,`eq.${r}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t,referencedTable:r=t}={}){let s=r?`${r}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}};se.default=re});var oe=E(ie=>{"use strict";u();Object.defineProperty(ie,"__esModule",{value:!0});var xt=(O(),S(x)),j=xt.__importDefault(D()),ne=class{constructor(e,{headers:t={},schema:r,fetch:s}){this.url=e,this.headers=new Headers(t),this.schema=r,this.fetch=s}select(e,t){let{head:r=!1,count:s}=t??{},i=r?"HEAD":"GET",o=!1,a=(e??"*").split("").map(c=>/\s/.test(c)&&!o?"":(c==='"'&&(o=!o),c)).join("");return this.url.searchParams.set("select",a),s&&this.headers.append("Prefer",`count=${s}`),new j.default({method:i,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:r=!0}={}){var s;let i="POST";if(t&&this.headers.append("Prefer",`count=${t}`),r||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let o=e.reduce((a,c)=>a.concat(Object.keys(c)),[]);if(o.length>0){let a=[...new Set(o)].map(c=>`"${c}"`);this.url.searchParams.set("columns",a.join(","))}}return new j.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:s,defaultToNull:i=!0}={}){var o;let a="POST";if(this.headers.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),t!==void 0&&this.url.searchParams.set("on_conflict",t),s&&this.headers.append("Prefer",`count=${s}`),i||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let c=e.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 j.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}update(e,{count:t}={}){var r;let s="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new j.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch})}delete({count:e}={}){var t;let r="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new j.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};ie.default=ne});var Fe=E(le=>{"use strict";u();Object.defineProperty(le,"__esModule",{value:!0});var Be=(O(),S(x)),Ot=Be.__importDefault(oe()),St=Be.__importDefault(D()),ae=class n{constructor(e,{headers:t={},schema:r,fetch:s}={}){this.url=e,this.headers=new Headers(t),this.schemaName=r,this.fetch=s}from(e){let t=new URL(`${this.url}/${e}`);return new Ot.default(t,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new n(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:r=!1,get:s=!1,count:i}={}){var o;let a,c=new URL(`${this.url}/rpc/${e}`),l;r||s?(a=r?"HEAD":"GET",Object.entries(t).filter(([d,g])=>g!==void 0).map(([d,g])=>[d,Array.isArray(g)?`{${g.join(",")}}`:`${g}`]).forEach(([d,g])=>{c.searchParams.append(d,g)})):(a="POST",l=t);let h=new Headers(this.headers);return i&&h.set("Prefer",`count=${i}`),new St.default({method:a,url:c,headers:h,schema:this.schemaName,body:l,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};le.default=ae});var Ve=E(w=>{"use strict";u();Object.defineProperty(w,"__esModule",{value:!0});w.PostgrestError=w.PostgrestBuilder=w.PostgrestTransformBuilder=w.PostgrestFilterBuilder=w.PostgrestQueryBuilder=w.PostgrestClient=void 0;var $=(O(),S(x)),Ge=$.__importDefault(Fe());w.PostgrestClient=Ge.default;var Je=$.__importDefault(oe());w.PostgrestQueryBuilder=Je.default;var ze=$.__importDefault(D());w.PostgrestFilterBuilder=ze.default;var We=$.__importDefault(te());w.PostgrestTransformBuilder=We.default;var Ye=$.__importDefault(X());w.PostgrestBuilder=Ye.default;var Ke=$.__importDefault(K());w.PostgrestError=Ke.default;w.default={PostgrestClient:Ge.default,PostgrestQueryBuilder:Je.default,PostgrestFilterBuilder:ze.default,PostgrestTransformBuilder:We.default,PostgrestBuilder:Ye.default,PostgrestError:Ke.default}});u();u();var de=class{constructor(e,t=""){this.http=e,this.baseUrl=t.replace(/\/$/,"")}async invoke(e,t){let r=this.baseUrl?`${this.baseUrl}/functions/${e}`:`/functions/${e}`;return await(await this.http.fetch(r,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};u();u();var F="nvwa_current_jwt",lt="nvwa_login_token",ut="nvwa_user_profile",ct=typeof fetch<"u"?fetch:(()=>{throw new Error("AuthClient requires fetch")})(),B=class{constructor(e,t={}){this.baseUrl=e.replace(/\/$/,""),this.authPath=(t.authPath??"/auth").replace(/^\//,""),this.fetchImpl=t.fetchImpl??ct}url(e){return`${`${this.baseUrl}/${this.authPath}`.replace(/\/+/g,"/")}/${e.replace(/^\//,"")}`}async getSession(){try{let e=await this.fetchImpl(this.url("session"),{method:"GET",credentials:"include"});return e.ok?{data:await e.json()}:{data:null,error:{message:await e.text()||e.statusText,status:e.status}}}catch(e){return{data:null,error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithEmail(e,t){try{let r=await this.fetchImpl(this.url("sign-in/email"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:e,password:t})}),s=await r.text();return r.ok?{data:s?JSON.parse(s):void 0}:{error:{message:s||r.statusText,status:r.status}}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let e=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:"include"});return e.ok?{}:{error:{message:await e.text()||e.statusText,status:e.status}}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signUp(e){return this.postJson("sign-up/email",e)}async getToken(e){try{let t={};e&&(t.Authorization=`Bearer ${e}`);let r=await this.fetchImpl(this.url("token"),{method:"GET",credentials:"include",...Object.keys(t).length?{headers:t}:{}}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let i=s?JSON.parse(s):void 0;return{data:i?.token!=null?{token:i.token}:void 0}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signInWithUsername(e,t){return this.postJson("sign-in/username",{username:e,password:t})}async signInWithPhoneNumber(e,t,r){return this.postJson("sign-in/phone-number",{phoneNumber:e,password:t,rememberMe:r})}async sendPhoneNumberOtp(e){let t=await this.postJson("phone-number/send-otp",{phoneNumber:e});return t.error?{error:t.error}:{}}async verifyPhoneNumber(e,t){return this.postJson("phone-number/verify",{phoneNumber:e,code:t})}async postJson(e,t){try{let r=await this.fetchImpl(this.url(e),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(t)}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let i=s?JSON.parse(s):void 0;return{data:i?.data??i??void 0}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}};u();u();var P=class n{constructor(e){this.headerMap=new Map;if(e){if(e instanceof n)e.forEach((t,r)=>this.set(r,t));else if(Array.isArray(e))for(let[t,r]of e)this.set(t,String(r));else if(typeof e=="object")for(let t of Object.keys(e))this.set(t,String(e[t]))}}append(e,t){let r=e.toLowerCase(),s=this.headerMap.get(r);this.headerMap.set(r,s?`${s}, ${t}`:t)}set(e,t){this.headerMap.set(e.toLowerCase(),String(t))}get(e){let t=this.headerMap.get(e.toLowerCase());return t??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[t,r]of this.headerMap.entries())e(r,t,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},R=class n{constructor(e){this.params=new Map;if(e){if(typeof e=="string")this.parseString(e);else if(e instanceof n)this.params=new Map(e.params);else if(Array.isArray(e))for(let[t,r]of e)this.append(t,r);else if(e&&typeof e=="object")for(let[t,r]of Object.entries(e))this.set(t,r)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let t=e.split("&");for(let r of t)if(r){let[s,i]=r.split("=");s&&this.append(decodeURIComponent(s),i?decodeURIComponent(i):"")}}append(e,t){let r=this.params.get(e)||[];r.push(t),this.params.set(e,r)}delete(e){this.params.delete(e)}get(e){let t=this.params.get(e);return t?t[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,t){this.params.set(e,[t])}sort(){let e=Array.from(this.params.entries()).sort(([t],[r])=>t.localeCompare(r));this.params=new Map(e)}toString(){let e=[];for(let[t,r]of this.params.entries())for(let s of r)e.push(`${encodeURIComponent(t)}=${encodeURIComponent(s)}`);return e.join("&")}forEach(e){for(let[t,r]of this.params.entries())for(let s of r)e(s,t,this)}keys(){return this.params.keys()}values(){let e=[];for(let t of this.params.values())e.push(...t);return e[Symbol.iterator]()}entries(){let e=[];for(let[t,r]of this.params.entries())for(let s of r)e.push([t,s]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},I=class n{constructor(e,t){let r;if(e instanceof n)r=e.href;else if(t){let i=t instanceof n?t.href:t;r=this.resolve(i,e)}else r=e;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 R(s.search),this.hash=s.hash}resolve(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(t.startsWith("//"))return`${this.parseUrl(e).protocol}${t}`;if(t.startsWith("/")){let i=this.parseUrl(e);return`${i.protocol}//${i.host}${t}`}let r=this.parseUrl(e),s=r.pathname.endsWith("/")?r.pathname:r.pathname+"/";return`${r.protocol}//${r.host}${s}${t}`}parseUrl(e){let t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)throw new TypeError("Invalid URL");let r=t[2]||"",s=t[4]||"",i=t[5]||"/",o=t[7]?`?${t[7]}`:"",a=t[9]?`#${t[9]}`:"";if(!r&&!s&&!i.startsWith("/")&&!i.includes("/")&&!i.includes("."))throw new TypeError("Invalid URL");let c=s.match(/^([^@]*)@(.+)$/),l="",h="",d=s;if(c){let b=c[1];d=c[2];let v=b.match(/^([^:]*):?(.*)$/);v&&(l=v[1]||"",h=v[2]||"")}let g=d.match(/^([^:]+):?(\d*)$/),p=g?g[1]:d,y=g&&g[2]?g[2]:"";return{protocol:r?`${r}:`:"",username:l,password:h,host:d,hostname:p,port:y,pathname:i,search:o,hash:a}}toString(){let e=this.searchParams.toString(),t=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${t}${this.hash}`}toJSON(){return this.toString()}};u();var H=class n{constructor(e,t){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(t?.method||"GET").toUpperCase(),this.headers=t?.headers instanceof P?t.headers:new P(t?.headers),this.body=t?.body,this.timeout=t?.timeout,this.signal=t?.signal||void 0}clone(){return new n(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};u();var L=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=ht(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function ht(n){return n?new P(n):new P}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 e of Array.from(this.listeners))try{e()}catch{}this.listeners.clear()}}addEventListener(e,t){if(this._aborted){try{t()}catch{}return}this.listeners.add(t)}removeEventListener(e,t){this.listeners.delete(t)}toString(){return"[object AbortSignal]"}},N=class{constructor(){this._signal=new A}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};u();function Zt(n){n.URL=I,n.URLSearchParams=R,n.Headers=P,n.Request=H,n.Response=L,n.AbortController=N,n.AbortSignal=A}var pe=class{constructor(e,t,r){console.log("NvwaHttpClient constructor",e,t,r),this.storage=e,this.customFetch=t,this.handleUnauthorized=r}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let r=await this.storage.get(F),s=new P(t?.headers);r&&s.set("Authorization",`Bearer ${r}`);let i=t?.method||"GET";if((i==="POST"||i==="PUT"||i==="PATCH")&&t?.body){let a=s.get("Content-Type");(!a||a.includes("text/plain"))&&s.set("Content-Type","application/json")}let o=await this.customFetch(e,{...t,headers:s});if(o.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return o}};u();var dt="/storage",pt=dt+"/generateUploadUrl",fe=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+pt,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=await t.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:e,headers:new P({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:i}=await s.json();return{url:i.split("?")[0]}}};u();u();u();var ue=at(Ve(),1),{PostgrestClient:Qe,PostgrestQueryBuilder:kr,PostgrestFilterBuilder:Mr,PostgrestTransformBuilder:qr,PostgrestBuilder:Dr,PostgrestError:Br}=ue.default||ue;var Tt="/entities",zr=(n,e)=>new Qe(n+Tt,{fetch:e.fetchWithAuth.bind(e)});u();var Xe=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/skill/${e}/execute`,i=await(await this.http.fetchWithAuth(r,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(i.status!==200)throw new Error(i.message);return i.data}};u();var Ze=class{constructor(){this.hoverOverlay=null;this.selectedOverlay=null;this.tooltip=null;this.hoverElement=null;this.selectedElement=null;this.hoverUpdateHandler=null;this.selectedUpdateHandler=null;this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let e=document.createElement("style");e.id="__nvwa-inspector-overlay-style",e.textContent=`
|
|
2
2
|
.__nvwa-inspector-overlay {
|
|
3
3
|
position: absolute;
|
|
4
4
|
pointer-events: none;
|
|
@@ -30,4 +30,4 @@ var tt=Object.create;var H=Object.defineProperty;var rt=Object.getOwnPropertyDes
|
|
|
30
30
|
max-width: 400px;
|
|
31
31
|
word-break: break-all;
|
|
32
32
|
}
|
|
33
|
-
`,document.head.appendChild(e)}createTooltip(){return this.tooltip?this.tooltip:(this.tooltip=document.createElement("div"),this.tooltip.id="__nvwa-inspector-tooltip",document.body.appendChild(this.tooltip),this.tooltip)}createOverlay(e){let t=document.createElement("div");return t.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${e}`,document.body.appendChild(t),t}updateOverlayPosition(e,t){if(!t.isConnected)return;let r=t.getBoundingClientRect(),
|
|
33
|
+
`,document.head.appendChild(e)}createTooltip(){return this.tooltip?this.tooltip:(this.tooltip=document.createElement("div"),this.tooltip.id="__nvwa-inspector-tooltip",document.body.appendChild(this.tooltip),this.tooltip)}createOverlay(e){let t=document.createElement("div");return t.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${e}`,document.body.appendChild(t),t}updateOverlayPosition(e,t){if(!t.isConnected)return;let r=t.getBoundingClientRect(),s=window.scrollX||window.pageXOffset,i=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(e.style.left=`${r.left+s}px`,e.style.top=`${r.top+i}px`,e.style.width=`${r.width}px`,e.style.height=`${r.height}px`,e.style.display="block"):e.style.display="none"}removeOverlay(e){e&&e.parentNode&&e.parentNode.removeChild(e)}highlightElement(e,t){if(!e.isConnected)return;if(this.hoverElement===e&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,e);let a=this.createTooltip();t?a.textContent=t:a.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,a.style.display="block";let c=e.getBoundingClientRect();a.style.left=`${c.left+window.scrollX}px`,a.style.top=`${c.top+window.scrollY-a.offsetHeight-8}px`,c.top<a.offsetHeight+8&&(a.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,e),this.hoverOverlay=r,this.hoverElement=e;let s=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s);let i=this.createTooltip();t?i.textContent=t:i.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,i.style.display="block";let o=e.getBoundingClientRect();i.style.left=`${o.left+window.scrollX}px`,i.style.top=`${o.top+window.scrollY-i.offsetHeight-8}px`,o.top<i.offsetHeight+8&&(i.style.top=`${o.bottom+window.scrollY+8}px`)}selectElement(e,t){if(!e.isConnected)return;if(this.selectedElement===e&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,e);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,e),this.selectedOverlay=r,this.selectedElement=e;let s=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let e=document.getElementById("__nvwa-inspector-overlay-style");e&&e.parentNode&&e.parentNode.removeChild(e)}};function Qr(n="root"){if(typeof document>"u")return null;let e=document.getElementById(n)||document.body;if(!e)return null;let t=e.querySelector("[data-source-location]");if(t){let r=t.getAttribute("data-source-location");if(r)return r}if(e.firstElementChild){let s=e.firstElementChild.getAttribute("data-source-location");if(s)return s}return null}u();var $t=typeof fetch<"u"?fetch:(()=>{throw new Error("payment client requires fetch")})(),et=class{constructor(e,t="/functions/payment",r=$t){this.baseUrl=e;this.pathPrefix=t;this.fetchImpl=r}async rpc(e,t){let r=this.baseUrl.replace(/\/$/,""),s=this.pathPrefix.replace(/^\/?/,"").replace(/\/$/,""),i=`${r}/${s}/${e}`,o=await this.fetchImpl(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!o.ok){let a=await o.text();throw new Error(`${e} failed: ${o.status} ${a}`)}if(!(o.status===204||!o.body))return await o.json()}async getConfiguredProviders(e){try{let r=(await this.rpc("getConfiguredProviders",{}))?.providers;if(!Array.isArray(r))return[];if(r.length===0)return[];if(typeof r[0]=="string")return r;let i=r,o=e?.platform;return o?i.filter(a=>!a.supportedPlatforms||a.supportedPlatforms.includes(o)).map(a=>a.id):i.map(a=>a.id)}catch{return[]}}async createPayment(e){let t=await this.rpc("createOrder",{amount:e.amount,subject:e.subject,currency:e.currency??"cny",providerId:e.providerId,metadata:e.metadata});if(t.orderId==null)throw new Error("createPayment: missing orderId in response");return t}async queryOrder(e){let t=await this.rpc("getOrder",{orderId:e});return{orderId:t.orderId??e,status:t.status??"pending",order:t.order}}async cancelOrder(e){await this.rpc("cancelOrder",{orderId:e})}};export{N as AbortController,A as AbortSignal,B as AuthClient,F as CURRENT_JWT_KEY,Tt as ENTITIES_BASE_PATH,dt as FILE_STORAGE_BASE_PATH,pt as GENERATE_UPLOAD_URL_PATH,P as Headers,lt as LOGIN_TOKEN_KEY,ut as LOGIN_USER_PROFILE_KEY,de as NvwaEdgeFunctions,fe as NvwaFileStorage,pe as NvwaHttpClient,Xe as NvwaSkill,Ze as OverlayManager,et as PaymentClient,H as Request,L as Response,I as URL,R as URLSearchParams,zr as createPostgrestClient,Qr as getSourceLocationFromDOM,Zt as polyfill};
|