@nvwa-app/sdk-core 4.0.0 → 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 CHANGED
@@ -67,7 +67,7 @@ interface RequestInit$1 {
67
67
  type RequestInfo = string | {
68
68
  url?: string;
69
69
  } | URL;
70
- declare class Request {
70
+ declare class Request$1 {
71
71
  readonly url: string;
72
72
  readonly method: string;
73
73
  readonly headers: Headers;
@@ -75,7 +75,7 @@ declare class Request {
75
75
  readonly timeout?: number;
76
76
  readonly signal?: any;
77
77
  constructor(input: RequestInfo, init?: RequestInit$1);
78
- clone(): Request;
78
+ clone(): Request$1;
79
79
  toString(): string;
80
80
  }
81
81
 
@@ -228,8 +228,8 @@ declare class OverlayManager {
228
228
  declare function getSourceLocationFromDOM(rootSelector?: string): string | null;
229
229
 
230
230
  /**
231
- * Payment 客户端:供生成应用(项目侧)调用项目自己的 payment API(由 Example 提供)。
232
- * 仅封装请求形态,不涉及持久化;与 Workspace 积分充值无关。
231
+ * Payment 客户端:供生成应用(项目侧)调用项目 runtime 内置的 payment API
232
+ * 请求形态与 ProjectPaymentApi(@Rpc)一致;与 Workspace 积分充值无关。
233
233
  */
234
234
  interface CreatePaymentParams {
235
235
  /** 金额(最小单位,如分) */
@@ -279,11 +279,12 @@ declare class PaymentClient {
279
279
  private pathPrefix;
280
280
  private fetchImpl;
281
281
  constructor(baseUrl: string, pathPrefix?: string, fetchImpl?: PaymentFetch);
282
- private url;
282
+ /** RPC 风格路径:baseUrl + pathPrefix + /methodName,POST JSON body */
283
+ private rpc;
283
284
  /**
284
285
  * 获取在当前端可用的 payment provider 列表。
285
286
  * - 可传 platform:只返回在该端能完成支付的 provider(如微信小程序内仅返回 wechat-pay)。
286
- * - 若 backend 返回带 supportedPlatforms 的列表,则按 platform 在客户端过滤;否则可传 ?platform=xxx 由 backend 过滤。
287
+ * - 若 backend 返回带 supportedPlatforms 的列表,则按 platform 在客户端过滤。
287
288
  * 若 backend 未实现该接口则返回空数组。
288
289
  */
289
290
  getConfiguredProviders(options?: {
@@ -304,6 +305,138 @@ declare class PaymentClient {
304
305
  cancelOrder(orderId: number): Promise<void>;
305
306
  }
306
307
 
308
+ /**
309
+ * Auth 常量与客户端:CURRENT_JWT_KEY 供 NvwaHttpClient 使用;
310
+ * AuthClient 调用项目 runtime 的 /auth 接口(better-auth)。
311
+ */
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
+ }
326
+ interface AuthSession {
327
+ user?: AuthUser;
328
+ session?: {
329
+ token?: string;
330
+ [k: string]: unknown;
331
+ };
332
+ [k: string]: unknown;
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
+ }
355
+ interface AuthClientOptions {
356
+ /** Auth 路径,默认 "/auth"(与 runtime 的 basePath 一致) */
357
+ authPath?: string;
358
+ /** 自定义 fetch,默认全局 fetch */
359
+ fetchImpl?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
360
+ }
361
+ /**
362
+ * 项目侧 Auth 客户端:getSession、邮箱登录、登出。
363
+ * baseUrl 为项目根地址(如 "https://xxx.nvwa.app"),请求发往 baseUrl + authPath。
364
+ */
365
+ declare class AuthClient {
366
+ private baseUrl;
367
+ private authPath;
368
+ private fetchImpl;
369
+ constructor(baseUrl: string, options?: AuthClientOptions);
370
+ private url;
371
+ /**
372
+ * 获取当前 session(依赖 cookie 或 Authorization header,与 runtime 配置一致)。
373
+ */
374
+ getSession(): Promise<{
375
+ data: AuthSession | null;
376
+ error?: {
377
+ message: string;
378
+ status: number;
379
+ };
380
+ }>;
381
+ /**
382
+ * 邮箱密码登录。
383
+ */
384
+ signInWithEmail(email: string, password: string): Promise<{
385
+ data?: AuthSession;
386
+ error?: {
387
+ message: string;
388
+ status: number;
389
+ };
390
+ }>;
391
+ /**
392
+ * 登出。
393
+ */
394
+ signOut(): Promise<{
395
+ error?: {
396
+ message: string;
397
+ status: number;
398
+ };
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;
438
+ }
439
+
307
440
  interface INvwa {
308
441
  entities: PostgrestClient;
309
442
  functions: NvwaEdgeFunctions;
@@ -311,4 +444,4 @@ interface INvwa {
311
444
  skill: NvwaSkill;
312
445
  }
313
446
 
314
- export { AbortController, AbortSignal, 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, 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
@@ -67,7 +67,7 @@ interface RequestInit$1 {
67
67
  type RequestInfo = string | {
68
68
  url?: string;
69
69
  } | URL;
70
- declare class Request {
70
+ declare class Request$1 {
71
71
  readonly url: string;
72
72
  readonly method: string;
73
73
  readonly headers: Headers;
@@ -75,7 +75,7 @@ declare class Request {
75
75
  readonly timeout?: number;
76
76
  readonly signal?: any;
77
77
  constructor(input: RequestInfo, init?: RequestInit$1);
78
- clone(): Request;
78
+ clone(): Request$1;
79
79
  toString(): string;
80
80
  }
81
81
 
@@ -228,8 +228,8 @@ declare class OverlayManager {
228
228
  declare function getSourceLocationFromDOM(rootSelector?: string): string | null;
229
229
 
230
230
  /**
231
- * Payment 客户端:供生成应用(项目侧)调用项目自己的 payment API(由 Example 提供)。
232
- * 仅封装请求形态,不涉及持久化;与 Workspace 积分充值无关。
231
+ * Payment 客户端:供生成应用(项目侧)调用项目 runtime 内置的 payment API
232
+ * 请求形态与 ProjectPaymentApi(@Rpc)一致;与 Workspace 积分充值无关。
233
233
  */
234
234
  interface CreatePaymentParams {
235
235
  /** 金额(最小单位,如分) */
@@ -279,11 +279,12 @@ declare class PaymentClient {
279
279
  private pathPrefix;
280
280
  private fetchImpl;
281
281
  constructor(baseUrl: string, pathPrefix?: string, fetchImpl?: PaymentFetch);
282
- private url;
282
+ /** RPC 风格路径:baseUrl + pathPrefix + /methodName,POST JSON body */
283
+ private rpc;
283
284
  /**
284
285
  * 获取在当前端可用的 payment provider 列表。
285
286
  * - 可传 platform:只返回在该端能完成支付的 provider(如微信小程序内仅返回 wechat-pay)。
286
- * - 若 backend 返回带 supportedPlatforms 的列表,则按 platform 在客户端过滤;否则可传 ?platform=xxx 由 backend 过滤。
287
+ * - 若 backend 返回带 supportedPlatforms 的列表,则按 platform 在客户端过滤。
287
288
  * 若 backend 未实现该接口则返回空数组。
288
289
  */
289
290
  getConfiguredProviders(options?: {
@@ -304,6 +305,138 @@ declare class PaymentClient {
304
305
  cancelOrder(orderId: number): Promise<void>;
305
306
  }
306
307
 
308
+ /**
309
+ * Auth 常量与客户端:CURRENT_JWT_KEY 供 NvwaHttpClient 使用;
310
+ * AuthClient 调用项目 runtime 的 /auth 接口(better-auth)。
311
+ */
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
+ }
326
+ interface AuthSession {
327
+ user?: AuthUser;
328
+ session?: {
329
+ token?: string;
330
+ [k: string]: unknown;
331
+ };
332
+ [k: string]: unknown;
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
+ }
355
+ interface AuthClientOptions {
356
+ /** Auth 路径,默认 "/auth"(与 runtime 的 basePath 一致) */
357
+ authPath?: string;
358
+ /** 自定义 fetch,默认全局 fetch */
359
+ fetchImpl?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
360
+ }
361
+ /**
362
+ * 项目侧 Auth 客户端:getSession、邮箱登录、登出。
363
+ * baseUrl 为项目根地址(如 "https://xxx.nvwa.app"),请求发往 baseUrl + authPath。
364
+ */
365
+ declare class AuthClient {
366
+ private baseUrl;
367
+ private authPath;
368
+ private fetchImpl;
369
+ constructor(baseUrl: string, options?: AuthClientOptions);
370
+ private url;
371
+ /**
372
+ * 获取当前 session(依赖 cookie 或 Authorization header,与 runtime 配置一致)。
373
+ */
374
+ getSession(): Promise<{
375
+ data: AuthSession | null;
376
+ error?: {
377
+ message: string;
378
+ status: number;
379
+ };
380
+ }>;
381
+ /**
382
+ * 邮箱密码登录。
383
+ */
384
+ signInWithEmail(email: string, password: string): Promise<{
385
+ data?: AuthSession;
386
+ error?: {
387
+ message: string;
388
+ status: number;
389
+ };
390
+ }>;
391
+ /**
392
+ * 登出。
393
+ */
394
+ signOut(): Promise<{
395
+ error?: {
396
+ message: string;
397
+ status: number;
398
+ };
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;
438
+ }
439
+
307
440
  interface INvwa {
308
441
  entities: PostgrestClient;
309
442
  functions: NvwaEdgeFunctions;
@@ -311,4 +444,4 @@ interface INvwa {
311
444
  skill: NvwaSkill;
312
445
  }
313
446
 
314
- export { AbortController, AbortSignal, 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, 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 st=Object.create;var L=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var it=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty;var pe=(s,e)=>()=>(s&&(e=s(s=0)),e);var _=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),fe=(s,e)=>{for(var t in e)L(s,t,{get:e[t],enumerable:!0})},me=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ot(e))!at.call(s,n)&&n!==t&&L(s,n,{get:()=>e[n],enumerable:!(r=nt(e,n))||r.enumerable});return s};var lt=(s,e,t)=>(t=s!=null?st(it(s)):{},me(e||!s||!s.__esModule?L(t,"default",{value:s,enumerable:!0}):t,s)),E=s=>me(L({},"__esModule",{value:!0}),s);var h=pe(()=>{"use strict"});var x={};fe(x,{__addDisposableResource:()=>Fe,__assign:()=>N,__asyncDelegator:()=>Ie,__asyncGenerator:()=>Ae,__asyncValues:()=>Le,__await:()=>T,__awaiter:()=>Te,__classPrivateFieldGet:()=>qe,__classPrivateFieldIn:()=>Be,__classPrivateFieldSet:()=>De,__createBinding:()=>M,__decorate:()=>Pe,__disposeResources:()=>ze,__esDecorate:()=>Ee,__exportStar:()=>je,__extends:()=>we,__generator:()=>Re,__importDefault:()=>Me,__importStar:()=>ke,__makeTemplateObject:()=>Ne,__metadata:()=>$e,__param:()=>_e,__propKey:()=>Oe,__read:()=>J,__rest:()=>be,__rewriteRelativeImportExtension:()=>Ge,__runInitializers:()=>xe,__setFunctionName:()=>Se,__spread:()=>He,__spreadArray:()=>Ue,__spreadArrays:()=>Ce,__values:()=>k,default:()=>pt});function we(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 be(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 Pe(s,e,t,r){var n=arguments.length,o=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(s,e,t,r);else for(var a=s.length-1;a>=0;a--)(i=s[a])&&(o=(n<3?i(o):n>3?i(e,t,o):i(e,t))||o);return n>3&&o&&Object.defineProperty(e,t,o),o}function _e(s,e){return function(t,r){e(t,r,s)}}function Ee(s,e,t,r,n,o){function i(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&&s?r.static?s:s.prototype:null,u=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");o.push(i(P||null))};var g=(0,t[p])(a==="accessor"?{get:u.get,set:u.set}:u[c],y);if(a==="accessor"){if(g===void 0)continue;if(g===null||typeof g!="object")throw new TypeError("Object expected");(d=i(g.get))&&(u.get=d),(d=i(g.set))&&(u.set=d),(d=i(g.init))&&n.unshift(d)}else(d=i(g))&&(a==="field"?n.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),m=!0}function xe(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 Oe(s){return typeof s=="symbol"?s:"".concat(s)}function Se(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 $e(s,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,e)}function Te(s,e,t,r){function n(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function a(u){try{l(r.next(u))}catch(d){i(d)}}function c(u){try{l(r.throw(u))}catch(d){i(d)}}function l(u){u.done?o(u.value):n(u.value).then(a,c)}l((r=r.apply(s,e||[])).next())})}function Re(s,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,n,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(l){return function(u){return c([l,u])}}function c(l){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(t=0)),t;)try{if(r=1,n&&(o=l[0]&2?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[l[0]&2,o.value]),l[0]){case 0:case 1:o=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,n=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!o||l[1]>o[0]&&l[1]<o[3])){t.label=l[1];break}if(l[0]===6&&t.label<o[1]){t.label=o[1],o=l;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(l);break}o[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(s,t)}catch(u){l=[6,u],n=0}finally{r=o=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function je(s,e){for(var t in s)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&M(e,s,t)}function k(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,o=[],i;try{for(;(e===void 0||e-- >0)&&!(n=r.next()).done;)o.push(n.value)}catch(a){i={error:a}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(i)throw i.error}}return o}function He(){for(var s=[],e=0;e<arguments.length;e++)s=s.concat(J(arguments[e]));return s}function Ce(){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 o=arguments[e],i=0,a=o.length;i<a;i++,n++)r[n]=o[i];return r}function Ue(s,e,t){if(t||arguments.length===2)for(var r=0,n=e.length,o;r<n;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return s.concat(o||Array.prototype.slice.call(e))}function T(s){return this instanceof T?(this.v=s,this):new T(s)}function Ae(s,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(s,e||[]),n,o=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",i),n[Symbol.asyncIterator]=function(){return this},n;function i(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){o.push([p,b,g,P])>1||c(p,b)})},y&&(n[p]=y(n[p])))}function c(p,y){try{l(r[p](y))}catch(b){m(o[0][3],b)}}function l(p){p.value instanceof T?Promise.resolve(p.value.v).then(u,d):m(o[0][2],p)}function u(p){c("next",p)}function d(p){c("throw",p)}function m(p,y){p(y),o.shift(),o.length&&c(o[0][0],o[0][1])}}function Ie(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,o){e[n]=s[n]?function(i){return(t=!t)?{value:T(s[n](i)),done:!1}:o?o(i):i}:o}}function Le(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 k=="function"?k(s):s[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(o){t[o]=s[o]&&function(i){return new Promise(function(a,c){i=s[o](i),n(a,c,i.done,i.value)})}}function n(o,i,a,c){Promise.resolve(c).then(function(l){o({value:l,done:a})},i)}}function Ne(s,e){return Object.defineProperty?Object.defineProperty(s,"raw",{value:e}):s.raw=e,s}function ke(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"&&M(e,s,t[r]);return ut(e,s),e}function Me(s){return s&&s.__esModule?s:{default:s}}function qe(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 De(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 Be(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 Fe(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(o){return Promise.reject(o)}}),s.stack.push({value:e,dispose:r,async:t})}else t&&s.stack.push({async:!0});return e}function ze(s){function e(o){s.error=s.hasError?new dt(o,s.error,"An error was suppressed during disposal."):o,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 o=t.dispose.call(t.value);if(t.async)return r|=2,Promise.resolve(o).then(n,function(i){return e(i),n()})}else r|=1}catch(i){e(i)}if(r===1)return s.hasError?Promise.reject(s.error):Promise.resolve();if(s.hasError)throw s.error}return n()}function Ge(s,e){return typeof s=="string"&&/^\.\.?\//.test(s)?s.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,r,n,o,i){return r?e?".jsx":".js":n&&(!o||!i)?t:n+o+"."+i.toLowerCase()+"js"}):s}var z,N,M,ut,G,dt,pt,O=pe(()=>{"use strict";h();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)};N=function(){return N=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},N.apply(this,arguments)};M=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]});ut=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)};dt=typeof SuppressedError=="function"?SuppressedError:function(s,e,t){var r=new Error(t);return r.name="SuppressedError",r.error=s,r.suppressed=e,r};pt={__extends:we,__assign:N,__rest:be,__decorate:Pe,__param:_e,__esDecorate:Ee,__runInitializers:xe,__propKey:Oe,__setFunctionName:Se,__metadata:$e,__awaiter:Te,__generator:Re,__createBinding:M,__exportStar:je,__values:k,__read:J,__spread:He,__spreadArrays:Ce,__spreadArray:Ue,__await:T,__asyncGenerator:Ae,__asyncDelegator:Ie,__asyncValues:Le,__makeTemplateObject:Ne,__importStar:ke,__importDefault:Me,__classPrivateFieldGet:qe,__classPrivateFieldSet:De,__classPrivateFieldIn:Be,__addDisposableResource:Fe,__disposeResources:ze,__rewriteRelativeImportExtension:Ge}});var Y=_(V=>{"use strict";h();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=_(K=>{"use strict";h();Object.defineProperty(K,"__esModule",{value:!0});var ft=(O(),E(x)),mt=ft.__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 o=>{var i,a,c,l;let u=null,d=null,m=null,p=o.status,y=o.statusText;if(o.ok){if(this.method!=="HEAD"){let I=await o.text();I===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((i=this.headers.get("Accept"))===null||i===void 0)&&i.includes("application/vnd.pgrst.plan+text"))?d=I:d=JSON.parse(I))}let g=(a=this.headers.get("Prefer"))===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),P=(c=o.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?(u={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,m=null,p=406,y="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let g=await o.text();try{u=JSON.parse(g),Array.isArray(u)&&o.status===404&&(d=[],u=null,p=200,y="OK")}catch{o.status===404&&g===""?(p=204,y="No Content"):u={message:g}}if(u&&this.isMaybeSingle&&(!((l=u?.details)===null||l===void 0)&&l.includes("0 rows"))&&(u=null,p=200,y="OK"),u&&this.shouldThrowOnError)throw new mt.default(u)}return{error:u,data:d,count:m,status:p,statusText:y}});return this.shouldThrowOnError||(n=n.catch(o=>{var i,a,c;return{error:{message:`${(i=o?.name)!==null&&i!==void 0?i:"FetchError"}: ${o?.message}`,details:`${(a=o?.stack)!==null&&a!==void 0?a:""}`,hint:"",code:`${(c=o?.code)!==null&&c!==void 0?c:""}`},data:null,count:null,status:0,statusText:""}})),n.then(e,t)}returns(){return this}overrideTypes(){return this}};K.default=Q});var te=_(ee=>{"use strict";h();Object.defineProperty(ee,"__esModule",{value:!0});var yt=(O(),E(x)),gt=yt.__importDefault(X()),Z=class extends gt.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:o=n}={}){let i=o?`${o}.order`:"order",a=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${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 o=typeof n>"u"?"offset":`${n}.offset`,i=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(o,`${e}`),this.url.searchParams.set(i,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:n=!1,wal:o=!1,format:i="text"}={}){var a;let c=[e?"analyze":null,t?"verbose":null,r?"settings":null,n?"buffers":null,o?"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+${i}; for="${l}"; options=${c};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};ee.default=Z});var q=_(se=>{"use strict";h();Object.defineProperty(se,"__esModule",{value:!0});var vt=(O(),E(x)),wt=vt.__importDefault(te()),bt=new RegExp("[,()]"),re=class extends wt.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"&&bt.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 o="";n==="plain"?o="pl":n==="phrase"?o="ph":n==="websearch"&&(o="w");let i=r===void 0?"":`(${r})`;return this.url.searchParams.append(e,`${o}fts${i}.${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 ie=_(oe=>{"use strict";h();Object.defineProperty(oe,"__esModule",{value:!0});var Pt=(O(),E(x)),A=Pt.__importDefault(q()),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??{},o=r?"HEAD":"GET",i=!1,a=(e??"*").split("").map(c=>/\s/.test(c)&&!i?"":(c==='"'&&(i=!i),c)).join("");return this.url.searchParams.set("select",a),n&&this.headers.append("Prefer",`count=${n}`),new A.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:r=!0}={}){var n;let o="POST";if(t&&this.headers.append("Prefer",`count=${t}`),r||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let i=e.reduce((a,c)=>a.concat(Object.keys(c)),[]);if(i.length>0){let a=[...new Set(i)].map(c=>`"${c}"`);this.url.searchParams.set("columns",a.join(","))}}return new A.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:n,defaultToNull:o=!0}={}){var i;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}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let c=e.reduce((l,u)=>l.concat(Object.keys(u)),[]);if(c.length>0){let l=[...new Set(c)].map(u=>`"${u}"`);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:(i=this.fetch)!==null&&i!==void 0?i: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})}};oe.default=ne});var We=_(le=>{"use strict";h();Object.defineProperty(le,"__esModule",{value:!0});var Je=(O(),E(x)),_t=Je.__importDefault(ie()),Et=Je.__importDefault(q()),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 _t.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:o}={}){var i;let a,c=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])=>{c.searchParams.append(d,m)})):(a="POST",l=t);let u=new Headers(this.headers);return o&&u.set("Prefer",`count=${o}`),new Et.default({method:a,url:c,headers:u,schema:this.schemaName,body:l,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}};le.default=ae});var et=_(w=>{"use strict";h();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)),Ve=R.__importDefault(We());w.PostgrestClient=Ve.default;var Ye=R.__importDefault(ie());w.PostgrestQueryBuilder=Ye.default;var Qe=R.__importDefault(q());w.PostgrestFilterBuilder=Qe.default;var Ke=R.__importDefault(te());w.PostgrestTransformBuilder=Ke.default;var Xe=R.__importDefault(X());w.PostgrestBuilder=Xe.default;var Ze=R.__importDefault(Y());w.PostgrestError=Ze.default;w.default={PostgrestClient:Ve.default,PostgrestQueryBuilder:Ye.default,PostgrestFilterBuilder:Qe.default,PostgrestTransformBuilder:Ke.default,PostgrestBuilder:Xe.default,PostgrestError:Ze.default}});var $t={};fe($t,{AbortController:()=>U,AbortSignal:()=>$,ENTITIES_BASE_PATH:()=>rt,FILE_STORAGE_BASE_PATH:()=>ge,GENERATE_UPLOAD_URL_PATH:()=>ve,Headers:()=>v,NvwaEdgeFunctions:()=>D,NvwaFileStorage:()=>F,NvwaHttpClient:()=>B,NvwaSkill:()=>he,OverlayManager:()=>ue,PaymentClient:()=>de,Request:()=>H,Response:()=>C,URL:()=>j,URLSearchParams:()=>S,createPostgrestClient:()=>xt,getSourceLocationFromDOM:()=>Ot,polyfill:()=>ht});module.exports=E($t);h();h();var D=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()}};h();h();var ye="nvwa_current_jwt";h();h();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,o]=r.split("=");n&&this.append(decodeURIComponent(n),o?decodeURIComponent(o):"")}}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 o=t instanceof s?t.href:t;r=this.resolve(o,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 o=this.parseUrl(e);return`${o.protocol}//${o.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]||"",o=t[5]||"/",i=t[7]?`?${t[7]}`:"",a=t[9]?`#${t[9]}`:"";if(!r&&!n&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let c=n.match(/^([^@]*)@(.+)$/),l="",u="",d=n;if(c){let b=c[1];d=c[2];let g=b.match(/^([^:]*):?(.*)$/);g&&(l=g[1]||"",u=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:u,host:d,hostname:p,port:y,pathname:o,search:i,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()}};h();var H=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}};h();var C=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 v(s):new v}h();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]"}},U=class{constructor(){this._signal=new $}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};h();function ht(s){s.URL=j,s.URLSearchParams=S,s.Headers=v,s.Request=H,s.Response=C,s.AbortController=U,s.AbortSignal=$}var B=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(ye),n=new v(t?.headers);r&&n.set("Authorization",`Bearer ${r}`);let o=t?.method||"GET";if((o==="POST"||o==="PUT"||o==="PATCH")&&t?.body){let a=n.get("Content-Type");(!a||a.includes("text/plain"))&&n.set("Content-Type","application/json")}let i=await this.customFetch(e,{...t,headers:n});if(i.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return i}};h();var ge="/storage",ve=ge+"/generateUploadUrl",F=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+ve,{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:o}=await n.json();return{url:o.split("?")[0]}}};h();h();h();var ce=lt(et(),1),{PostgrestClient:tt,PostgrestQueryBuilder:Cr,PostgrestFilterBuilder:Ur,PostgrestTransformBuilder:Ar,PostgrestBuilder:Ir,PostgrestError:Lr}=ce.default||ce;var rt="/entities",xt=(s,e)=>new tt(s+rt,{fetch:e.fetchWithAuth.bind(e)});h();var he=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/skill/${e}/execute`,o=await(await this.http.fetchWithAuth(r,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(o.status!==200)throw new Error(o.message);return o.data}};h();var ue=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(),n=window.scrollX||window.pageXOffset,o=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(e.style.left=`${r.left+n}px`,e.style.top=`${r.top+o}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 n=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n);let o=this.createTooltip();t?o.textContent=t:o.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let i=e.getBoundingClientRect();o.style.left=`${i.left+window.scrollX}px`,o.style.top=`${i.top+window.scrollY-o.offsetHeight-8}px`,i.top<o.offsetHeight+8&&(o.style.top=`${i.bottom+window.scrollY+8}px`)}selectElement(e,t){if(!e.isConnected)return;if(this.selectedElement===e&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,e);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,e),this.selectedOverlay=r,this.selectedElement=e;let n=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let e=document.getElementById("__nvwa-inspector-overlay-style");e&&e.parentNode&&e.parentNode.removeChild(e)}};function Ot(s="root"){if(typeof document>"u")return null;let e=document.getElementById(s)||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 n=e.firstElementChild.getAttribute("data-source-location");if(n)return n}return null}h();var St=typeof fetch<"u"?fetch:(()=>{throw new Error("payment client requires fetch")})(),de=class{constructor(e,t="/functions/payment",r=St){this.baseUrl=e;this.pathPrefix=t;this.fetchImpl=r}url(e){let t=this.baseUrl.replace(/\/$/,""),r=this.pathPrefix.replace(/^\/?/,"").replace(/\/?$/,"");return`${t}/${r}/${e}`}async getConfiguredProviders(e){try{let t=e?.platform,r=t?`providers?platform=${encodeURIComponent(t)}`:"providers",n=await this.fetchImpl(this.url(r),{method:"GET"});if(!n.ok)return[];let i=(await n.json())?.providers;if(!Array.isArray(i))return[];if(i.length===0)return[];if(typeof i[0]=="string")return i;let c=i;return t?c.filter(l=>!l.supportedPlatforms||l.supportedPlatforms.includes(t)).map(l=>l.id):c.map(l=>l.id)}catch{return[]}}async createPayment(e){let t=await this.fetchImpl(this.url("create-order"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({amount:e.amount,subject:e.subject,currency:e.currency??"cny",providerId:e.providerId,metadata:e.metadata})});if(!t.ok){let i=await t.text();throw new Error(`createPayment failed: ${t.status} ${i}`)}let r=await t.json(),n=r.orderId??r.order?.id;if(n==null)throw new Error("createPayment: missing orderId in response");let o=r.codeUrl?{codeUrl:r.codeUrl}:r.formHtml||r.paymentFormHtml?{formHtml:r.formHtml??r.paymentFormHtml??""}:r.clientSecret?{clientSecret:r.clientSecret}:r;return{orderId:Number(n),payParams:o,order:r.order}}async queryOrder(e){let t=await this.fetchImpl(this.url(`get-order?orderId=${encodeURIComponent(e)}`),{method:"GET"});if(!t.ok){let c=await t.text();throw new Error(`queryOrder failed: ${t.status} ${c}`)}let r=await t.json(),o=r.order??r,i=o?.status??"pending",a=o?.id??r.orderId??e;return{orderId:Number(a),status:i,order:o}}async cancelOrder(e){let t=await this.fetchImpl(this.url("cancel-order"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({orderId:e})});if(!t.ok&&t.status!==404){let r=await t.text();throw new Error(`cancelOrder failed: ${t.status} ${r}`)}}};0&&(module.exports={AbortController,AbortSignal,ENTITIES_BASE_PATH,FILE_STORAGE_BASE_PATH,GENERATE_UPLOAD_URL_PATH,Headers,NvwaEdgeFunctions,NvwaFileStorage,NvwaHttpClient,NvwaSkill,OverlayManager,PaymentClient,Request,Response,URL,URLSearchParams,createPostgrestClient,getSourceLocationFromDOM,polyfill});
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 et=Object.create;var A=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var st=Object.getPrototypeOf,nt=Object.prototype.hasOwnProperty;var le=(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)A(s,t,{get:e[t],enumerable:!0})},ce=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of rt(e))!nt.call(s,n)&&n!==t&&A(s,n,{get:()=>e[n],enumerable:!(r=tt(e,n))||r.enumerable});return s};var it=(s,e,t)=>(t=s!=null?et(st(s)):{},ce(e||!s||!s.__esModule?A(t,"default",{value:s,enumerable:!0}):t,s)),S=s=>ce(A({},"__esModule",{value:!0}),s);import $t from"path";import{fileURLToPath as Rt}from"url";var h=le(()=>{"use strict"});var x={};ot(x,{__addDisposableResource:()=>ke,__assign:()=>k,__asyncDelegator:()=>je,__asyncGenerator:()=>Re,__asyncValues:()=>He,__await:()=>$,__awaiter:()=>Ee,__classPrivateFieldGet:()=>Ue,__classPrivateFieldIn:()=>Ne,__classPrivateFieldSet:()=>Le,__createBinding:()=>q,__decorate:()=>ye,__disposeResources:()=>Me,__esDecorate:()=>ve,__exportStar:()=>Oe,__extends:()=>fe,__generator:()=>xe,__importDefault:()=>Ie,__importStar:()=>Ae,__makeTemplateObject:()=>Ce,__metadata:()=>_e,__param:()=>ge,__propKey:()=>be,__read:()=>z,__rest:()=>me,__rewriteRelativeImportExtension:()=>qe,__runInitializers:()=>we,__setFunctionName:()=>Pe,__spread:()=>Se,__spreadArray:()=>Te,__spreadArrays:()=>$e,__values:()=>M,default:()=>dt});function fe(s,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");B(s,e);function t(){this.constructor=s}s.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function me(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 ye(s,e,t,r){var n=arguments.length,o=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(s,e,t,r);else for(var a=s.length-1;a>=0;a--)(i=s[a])&&(o=(n<3?i(o):n>3?i(e,t,o):i(e,t))||o);return n>3&&o&&Object.defineProperty(e,t,o),o}function ge(s,e){return function(t,r){e(t,r,s)}}function ve(s,e,t,r,n,o){function i(_){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&&s?r.static?s:s.prototype:null,u=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");o.push(i(_||null))};var v=(0,t[p])(a==="accessor"?{get:u.get,set:u.set}:u[c],g);if(a==="accessor"){if(v===void 0)continue;if(v===null||typeof v!="object")throw new TypeError("Object expected");(d=i(v.get))&&(u.get=d),(d=i(v.set))&&(u.set=d),(d=i(v.init))&&n.unshift(d)}else(d=i(v))&&(a==="field"?n.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),y=!0}function we(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 be(s){return typeof s=="symbol"?s:"".concat(s)}function Pe(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 _e(s,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,e)}function Ee(s,e,t,r){function n(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function a(u){try{l(r.next(u))}catch(d){i(d)}}function c(u){try{l(r.throw(u))}catch(d){i(d)}}function l(u){u.done?o(u.value):n(u.value).then(a,c)}l((r=r.apply(s,e||[])).next())})}function xe(s,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,n,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(l){return function(u){return c([l,u])}}function c(l){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(t=0)),t;)try{if(r=1,n&&(o=l[0]&2?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[l[0]&2,o.value]),l[0]){case 0:case 1:o=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,n=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!o||l[1]>o[0]&&l[1]<o[3])){t.label=l[1];break}if(l[0]===6&&t.label<o[1]){t.label=o[1],o=l;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(l);break}o[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(s,t)}catch(u){l=[6,u],n=0}finally{r=o=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Oe(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 z(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var r=t.call(s),n,o=[],i;try{for(;(e===void 0||e-- >0)&&!(n=r.next()).done;)o.push(n.value)}catch(a){i={error:a}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(i)throw i.error}}return o}function Se(){for(var s=[],e=0;e<arguments.length;e++)s=s.concat(z(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 o=arguments[e],i=0,a=o.length;i<a;i++,n++)r[n]=o[i];return r}function Te(s,e,t){if(t||arguments.length===2)for(var r=0,n=e.length,o;r<n;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return s.concat(o||Array.prototype.slice.call(e))}function $(s){return this instanceof $?(this.v=s,this):new $(s)}function Re(s,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(s,e||[]),n,o=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",i),n[Symbol.asyncIterator]=function(){return this},n;function i(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,_){o.push([p,b,v,_])>1||c(p,b)})},g&&(n[p]=g(n[p])))}function c(p,g){try{l(r[p](g))}catch(b){y(o[0][3],b)}}function l(p){p.value instanceof $?Promise.resolve(p.value.v).then(u,d):y(o[0][2],p)}function u(p){c("next",p)}function d(p){c("throw",p)}function y(p,g){p(g),o.shift(),o.length&&c(o[0][0],o[0][1])}}function je(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,o){e[n]=s[n]?function(i){return(t=!t)?{value:$(s[n](i)),done:!1}:o?o(i):i}:o}}function He(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(o){t[o]=s[o]&&function(i){return new Promise(function(a,c){i=s[o](i),n(a,c,i.done,i.value)})}}function n(o,i,a,c){Promise.resolve(c).then(function(l){o({value:l,done:a})},i)}}function Ce(s,e){return Object.defineProperty?Object.defineProperty(s,"raw",{value:e}):s.raw=e,s}function Ae(s){if(s&&s.__esModule)return s;var e={};if(s!=null)for(var t=F(s),r=0;r<t.length;r++)t[r]!=="default"&&q(e,s,t[r]);return ht(e,s),e}function Ie(s){return s&&s.__esModule?s:{default:s}}function Ue(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 Le(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 Ne(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 ke(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(o){return Promise.reject(o)}}),s.stack.push({value:e,dispose:r,async:t})}else t&&s.stack.push({async:!0});return e}function Me(s){function e(o){s.error=s.hasError?new ut(o,s.error,"An error was suppressed during disposal."):o,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 o=t.dispose.call(t.value);if(t.async)return r|=2,Promise.resolve(o).then(n,function(i){return e(i),n()})}else r|=1}catch(i){e(i)}if(r===1)return s.hasError?Promise.reject(s.error):Promise.resolve();if(s.hasError)throw s.error}return n()}function qe(s,e){return typeof s=="string"&&/^\.\.?\//.test(s)?s.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,r,n,o,i){return r?e?".jsx":".js":n&&(!o||!i)?t:n+o+"."+i.toLowerCase()+"js"}):s}var B,k,q,ht,F,ut,dt,O=le(()=>{"use strict";h();B=function(s,e){return B=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])},B(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 o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}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]});ht=Object.create?(function(s,e){Object.defineProperty(s,"default",{enumerable:!0,value:e})}):function(s,e){s.default=e},F=function(s){return F=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},F(s)};ut=typeof SuppressedError=="function"?SuppressedError:function(s,e,t){var r=new Error(t);return r.name="SuppressedError",r.error=s,r.suppressed=e,r};dt={__extends:fe,__assign:k,__rest:me,__decorate:ye,__param:ge,__esDecorate:ve,__runInitializers:we,__propKey:be,__setFunctionName:Pe,__metadata:_e,__awaiter:Ee,__generator:xe,__createBinding:q,__exportStar:Oe,__values:M,__read:z,__spread:Se,__spreadArrays:$e,__spreadArray:Te,__await:$,__asyncGenerator:Re,__asyncDelegator:je,__asyncValues:He,__makeTemplateObject:Ce,__importStar:Ae,__importDefault:Ie,__classPrivateFieldGet:Ue,__classPrivateFieldSet:Le,__classPrivateFieldIn:Ne,__addDisposableResource:ke,__disposeResources:Me,__rewriteRelativeImportExtension:qe}});var W=E(J=>{"use strict";h();Object.defineProperty(J,"__esModule",{value:!0});var G=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};J.default=G});var Q=E(Y=>{"use strict";h();Object.defineProperty(Y,"__esModule",{value:!0});var pt=(O(),S(x)),ft=pt.__importDefault(W()),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,n=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async o=>{var i,a,c,l;let u=null,d=null,y=null,p=o.status,g=o.statusText;if(o.ok){if(this.method!=="HEAD"){let C=await o.text();C===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((i=this.headers.get("Accept"))===null||i===void 0)&&i.includes("application/vnd.pgrst.plan+text"))?d=C:d=JSON.parse(C))}let v=(a=this.headers.get("Prefer"))===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),_=(c=o.headers.get("content-range"))===null||c===void 0?void 0:c.split("/");v&&_&&_.length>1&&(y=parseInt(_[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(u={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,y=null,p=406,g="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let v=await o.text();try{u=JSON.parse(v),Array.isArray(u)&&o.status===404&&(d=[],u=null,p=200,g="OK")}catch{o.status===404&&v===""?(p=204,g="No Content"):u={message:v}}if(u&&this.isMaybeSingle&&(!((l=u?.details)===null||l===void 0)&&l.includes("0 rows"))&&(u=null,p=200,g="OK"),u&&this.shouldThrowOnError)throw new ft.default(u)}return{error:u,data:d,count:y,status:p,statusText:g}});return this.shouldThrowOnError||(n=n.catch(o=>{var i,a,c;return{error:{message:`${(i=o?.name)!==null&&i!==void 0?i:"FetchError"}: ${o?.message}`,details:`${(a=o?.stack)!==null&&a!==void 0?a:""}`,hint:"",code:`${(c=o?.code)!==null&&c!==void 0?c:""}`},data:null,count:null,status:0,statusText:""}})),n.then(e,t)}returns(){return this}overrideTypes(){return this}};Y.default=V});var Z=E(X=>{"use strict";h();Object.defineProperty(X,"__esModule",{value:!0});var mt=(O(),S(x)),yt=mt.__importDefault(Q()),K=class extends yt.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:o=n}={}){let i=o?`${o}.order`:"order",a=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${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 o=typeof n>"u"?"offset":`${n}.offset`,i=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(o,`${e}`),this.url.searchParams.set(i,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:n=!1,wal:o=!1,format:i="text"}={}){var a;let c=[e?"analyze":null,t?"verbose":null,r?"settings":null,n?"buffers":null,o?"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+${i}; for="${l}"; options=${c};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};X.default=K});var D=E(te=>{"use strict";h();Object.defineProperty(te,"__esModule",{value:!0});var gt=(O(),S(x)),vt=gt.__importDefault(Z()),wt=new RegExp("[,()]"),ee=class extends vt.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"&&wt.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 o="";n==="plain"?o="pl":n==="phrase"?o="ph":n==="websearch"&&(o="w");let i=r===void 0?"":`(${r})`;return this.url.searchParams.append(e,`${o}fts${i}.${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}};te.default=ee});var ne=E(se=>{"use strict";h();Object.defineProperty(se,"__esModule",{value:!0});var bt=(O(),S(x)),H=bt.__importDefault(D()),re=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??{},o=r?"HEAD":"GET",i=!1,a=(e??"*").split("").map(c=>/\s/.test(c)&&!i?"":(c==='"'&&(i=!i),c)).join("");return this.url.searchParams.set("select",a),n&&this.headers.append("Prefer",`count=${n}`),new H.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:r=!0}={}){var n;let o="POST";if(t&&this.headers.append("Prefer",`count=${t}`),r||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let i=e.reduce((a,c)=>a.concat(Object.keys(c)),[]);if(i.length>0){let a=[...new Set(i)].map(c=>`"${c}"`);this.url.searchParams.set("columns",a.join(","))}}return new H.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:n,defaultToNull:o=!0}={}){var i;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}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let c=e.reduce((l,u)=>l.concat(Object.keys(u)),[]);if(c.length>0){let l=[...new Set(c)].map(u=>`"${u}"`);this.url.searchParams.set("columns",l.join(","))}}return new H.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(e,{count:t}={}){var r;let n="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new H.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 H.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};se.default=re});var Be=E(ie=>{"use strict";h();Object.defineProperty(ie,"__esModule",{value:!0});var De=(O(),S(x)),Pt=De.__importDefault(ne()),_t=De.__importDefault(D()),oe=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 Pt.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:o}={}){var i;let a,c=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])=>{c.searchParams.append(d,y)})):(a="POST",l=t);let u=new Headers(this.headers);return o&&u.set("Prefer",`count=${o}`),new _t.default({method:a,url:c,headers:u,schema:this.schemaName,body:l,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}};ie.default=oe});var Ye=E(w=>{"use strict";h();Object.defineProperty(w,"__esModule",{value:!0});w.PostgrestError=w.PostgrestBuilder=w.PostgrestTransformBuilder=w.PostgrestFilterBuilder=w.PostgrestQueryBuilder=w.PostgrestClient=void 0;var T=(O(),S(x)),Fe=T.__importDefault(Be());w.PostgrestClient=Fe.default;var ze=T.__importDefault(ne());w.PostgrestQueryBuilder=ze.default;var Ge=T.__importDefault(D());w.PostgrestFilterBuilder=Ge.default;var Je=T.__importDefault(Z());w.PostgrestTransformBuilder=Je.default;var We=T.__importDefault(Q());w.PostgrestBuilder=We.default;var Ve=T.__importDefault(W());w.PostgrestError=Ve.default;w.default={PostgrestClient:Fe.default,PostgrestQueryBuilder:ze.default,PostgrestFilterBuilder:Ge.default,PostgrestTransformBuilder:Je.default,PostgrestBuilder:We.default,PostgrestError:Ve.default}});h();h();var he=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()}};h();h();var ue="nvwa_current_jwt";h();h();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,o]=r.split("=");n&&this.append(decodeURIComponent(n),o?decodeURIComponent(o):"")}}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 o=t instanceof s?t.href:t;r=this.resolve(o,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 o=this.parseUrl(e);return`${o.protocol}//${o.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]||"",o=t[5]||"/",i=t[7]?`?${t[7]}`:"",a=t[9]?`#${t[9]}`:"";if(!r&&!n&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let c=n.match(/^([^@]*)@(.+)$/),l="",u="",d=n;if(c){let b=c[1];d=c[2];let v=b.match(/^([^:]*):?(.*)$/);v&&(l=v[1]||"",u=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:u,host:d,hostname:p,port:g,pathname:o,search:i,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()}};h();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}};h();var L=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=at(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 at(s){return s?new P(s):new P}h();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]"}};h();function Yt(s){s.URL=I,s.URLSearchParams=R,s.Headers=P,s.Request=U,s.Response=L,s.AbortController=N,s.AbortSignal=j}var de=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(ue),n=new P(t?.headers);r&&n.set("Authorization",`Bearer ${r}`);let o=t?.method||"GET";if((o==="POST"||o==="PUT"||o==="PATCH")&&t?.body){let a=n.get("Content-Type");(!a||a.includes("text/plain"))&&n.set("Content-Type","application/json")}let i=await this.customFetch(e,{...t,headers:n});if(i.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return i}};h();var lt="/storage",ct=lt+"/generateUploadUrl",pe=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+ct,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url: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:o}=await n.json();return{url:o.split("?")[0]}}};h();h();h();var ae=it(Ye(),1),{PostgrestClient:Qe,PostgrestQueryBuilder:Ir,PostgrestFilterBuilder:Ur,PostgrestTransformBuilder:Lr,PostgrestBuilder:Nr,PostgrestError:kr}=ae.default||ae;var Et="/entities",Br=(s,e)=>new Qe(s+Et,{fetch:e.fetchWithAuth.bind(e)});h();var Ke=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/skill/${e}/execute`,o=await(await this.http.fetchWithAuth(r,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(o.status!==200)throw new Error(o.message);return o.data}};h();var Xe=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 et=Object.create;var A=Object.defineProperty;var tt=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(),n=window.scrollX||window.pageXOffset,o=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(e.style.left=`${r.left+n}px`,e.style.top=`${r.top+o}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 n=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n);let o=this.createTooltip();t?o.textContent=t:o.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let i=e.getBoundingClientRect();o.style.left=`${i.left+window.scrollX}px`,o.style.top=`${i.top+window.scrollY-o.offsetHeight-8}px`,i.top<o.offsetHeight+8&&(o.style.top=`${i.bottom+window.scrollY+8}px`)}selectElement(e,t){if(!e.isConnected)return;if(this.selectedElement===e&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,e);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,e),this.selectedOverlay=r,this.selectedElement=e;let n=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let e=document.getElementById("__nvwa-inspector-overlay-style");e&&e.parentNode&&e.parentNode.removeChild(e)}};function Wr(s="root"){if(typeof document>"u")return null;let e=document.getElementById(s)||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 n=e.firstElementChild.getAttribute("data-source-location");if(n)return n}return null}h();var xt=typeof fetch<"u"?fetch:(()=>{throw new Error("payment client requires fetch")})(),Ze=class{constructor(e,t="/functions/payment",r=xt){this.baseUrl=e;this.pathPrefix=t;this.fetchImpl=r}url(e){let t=this.baseUrl.replace(/\/$/,""),r=this.pathPrefix.replace(/^\/?/,"").replace(/\/?$/,"");return`${t}/${r}/${e}`}async getConfiguredProviders(e){try{let t=e?.platform,r=t?`providers?platform=${encodeURIComponent(t)}`:"providers",n=await this.fetchImpl(this.url(r),{method:"GET"});if(!n.ok)return[];let i=(await n.json())?.providers;if(!Array.isArray(i))return[];if(i.length===0)return[];if(typeof i[0]=="string")return i;let c=i;return t?c.filter(l=>!l.supportedPlatforms||l.supportedPlatforms.includes(t)).map(l=>l.id):c.map(l=>l.id)}catch{return[]}}async createPayment(e){let t=await this.fetchImpl(this.url("create-order"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({amount:e.amount,subject:e.subject,currency:e.currency??"cny",providerId:e.providerId,metadata:e.metadata})});if(!t.ok){let i=await t.text();throw new Error(`createPayment failed: ${t.status} ${i}`)}let r=await t.json(),n=r.orderId??r.order?.id;if(n==null)throw new Error("createPayment: missing orderId in response");let o=r.codeUrl?{codeUrl:r.codeUrl}:r.formHtml||r.paymentFormHtml?{formHtml:r.formHtml??r.paymentFormHtml??""}:r.clientSecret?{clientSecret:r.clientSecret}:r;return{orderId:Number(n),payParams:o,order:r.order}}async queryOrder(e){let t=await this.fetchImpl(this.url(`get-order?orderId=${encodeURIComponent(e)}`),{method:"GET"});if(!t.ok){let c=await t.text();throw new Error(`queryOrder failed: ${t.status} ${c}`)}let r=await t.json(),o=r.order??r,i=o?.status??"pending",a=o?.id??r.orderId??e;return{orderId:Number(a),status:i,order:o}}async cancelOrder(e){let t=await this.fetchImpl(this.url("cancel-order"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({orderId:e})});if(!t.ok&&t.status!==404){let r=await t.text();throw new Error(`cancelOrder failed: ${t.status} ${r}`)}}};export{N as AbortController,j as AbortSignal,Et as ENTITIES_BASE_PATH,lt as FILE_STORAGE_BASE_PATH,ct as GENERATE_UPLOAD_URL_PATH,P as Headers,he as NvwaEdgeFunctions,pe as NvwaFileStorage,de as NvwaHttpClient,Ke as NvwaSkill,Xe as OverlayManager,Ze as PaymentClient,U as Request,L as Response,I as URL,R as URLSearchParams,Br as createPostgrestClient,Wr as getSourceLocationFromDOM,Yt as polyfill};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nvwa-app/sdk-core",
3
- "version": "4.0.0",
3
+ "version": "6.0.3",
4
4
  "description": "NVWA跨端通用工具类核心接口",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",