@nhost/nhost-js 0.3.9 → 0.3.10

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.es.js CHANGED
@@ -1,1293 +1,5 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- const axios$3 = require("axios");
21
- const SERVER_ERROR_CODE = 500;
22
- class HasuraAuthApi {
23
- constructor({ url = "" }) {
24
- this.url = url;
25
- this.httpClient = axios$3.create({
26
- baseURL: this.url
27
- });
28
- this.httpClient.interceptors.response.use((response) => response, (error) => {
29
- var _a, _b, _c, _d, _e, _f;
30
- return Promise.reject({
31
- message: (_d = (_c = (_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) != null ? _c : error.message) != null ? _d : JSON.stringify(error),
32
- status: (_f = (_e = error.response) == null ? void 0 : _e.status) != null ? _f : SERVER_ERROR_CODE
33
- });
34
- });
35
- }
36
- async signUpEmailPassword(params) {
37
- try {
38
- const res = await this.httpClient.post("/signup/email-password", params);
39
- return { data: res.data, error: null };
40
- } catch (error) {
41
- return { data: null, error };
42
- }
43
- }
44
- async signInEmailPassword(params) {
45
- try {
46
- const res = await this.httpClient.post("/signin/email-password", params);
47
- return { data: res.data, error: null };
48
- } catch (error) {
49
- return { data: null, error };
50
- }
51
- }
52
- async signInPasswordlessEmail(params) {
53
- try {
54
- const res = await this.httpClient.post("/signin/passwordless/email", params);
55
- return { data: res.data, error: null };
56
- } catch (error) {
57
- return { data: null, error };
58
- }
59
- }
60
- async signInPasswordlessSms(params) {
61
- try {
62
- const res = await this.httpClient.post("/signin/passwordless/sms", params);
63
- return { data: res.data, error: null };
64
- } catch (error) {
65
- return { data: null, error };
66
- }
67
- }
68
- async signInPasswordlessSmsOtp(params) {
69
- try {
70
- const res = await this.httpClient.post("/signin/passwordless/sms/otp", params);
71
- return { data: res.data, error: null };
72
- } catch (error) {
73
- return { data: null, error };
74
- }
75
- }
76
- async signOut(params) {
77
- try {
78
- await this.httpClient.post("/signout", params);
79
- return { error: null };
80
- } catch (error) {
81
- return { error };
82
- }
83
- }
84
- async refreshToken(params) {
85
- try {
86
- const res = await this.httpClient.post("/token", params);
87
- return { error: null, session: res.data };
88
- } catch (error) {
89
- return { error, session: null };
90
- }
91
- }
92
- async resetPassword(params) {
93
- try {
94
- await this.httpClient.post("/user/password/reset", params);
95
- return { error: null };
96
- } catch (error) {
97
- return { error };
98
- }
99
- }
100
- async changePassword(params) {
101
- try {
102
- await this.httpClient.post("/user/password", params, {
103
- headers: __spreadValues({}, this.generateAuthHeaders())
104
- });
105
- return { error: null };
106
- } catch (error) {
107
- return { error };
108
- }
109
- }
110
- async sendVerificationEmail(params) {
111
- try {
112
- await this.httpClient.post("/user/email/send-verification-email", params);
113
- return { error: null };
114
- } catch (error) {
115
- return { error };
116
- }
117
- }
118
- async changeEmail(params) {
119
- try {
120
- await this.httpClient.post("/user/email/change", params, {
121
- headers: __spreadValues({}, this.generateAuthHeaders())
122
- });
123
- return { error: null };
124
- } catch (error) {
125
- return { error };
126
- }
127
- }
128
- async deanonymize(params) {
129
- try {
130
- await this.httpClient.post("/user/deanonymize", params);
131
- return { error: null };
132
- } catch (error) {
133
- return { error };
134
- }
135
- }
136
- async verifyEmail(params) {
137
- try {
138
- const res = await this.httpClient.post("/user/email/verify", params);
139
- return { data: res.data, error: null };
140
- } catch (error) {
141
- return { data: null, error };
142
- }
143
- }
144
- setAccessToken(accessToken) {
145
- this.accessToken = accessToken;
146
- }
147
- generateAuthHeaders() {
148
- if (!this.accessToken) {
149
- return null;
150
- }
151
- return {
152
- Authorization: `Bearer ${this.accessToken}`
153
- };
154
- }
155
- }
156
- var queryString = {};
157
- var strictUriEncode = (str) => encodeURIComponent(str).replace(/[!'()*]/g, (x) => `%${x.charCodeAt(0).toString(16).toUpperCase()}`);
158
- var token = "%[a-f0-9]{2}";
159
- var singleMatcher = new RegExp(token, "gi");
160
- var multiMatcher = new RegExp("(" + token + ")+", "gi");
161
- function decodeComponents(components, split) {
162
- try {
163
- return decodeURIComponent(components.join(""));
164
- } catch (err) {
165
- }
166
- if (components.length === 1) {
167
- return components;
168
- }
169
- split = split || 1;
170
- var left = components.slice(0, split);
171
- var right = components.slice(split);
172
- return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right));
173
- }
174
- function decode(input) {
175
- try {
176
- return decodeURIComponent(input);
177
- } catch (err) {
178
- var tokens = input.match(singleMatcher);
179
- for (var i = 1; i < tokens.length; i++) {
180
- input = decodeComponents(tokens, i).join("");
181
- tokens = input.match(singleMatcher);
182
- }
183
- return input;
184
- }
185
- }
186
- function customDecodeURIComponent(input) {
187
- var replaceMap = {
188
- "%FE%FF": "\uFFFD\uFFFD",
189
- "%FF%FE": "\uFFFD\uFFFD"
190
- };
191
- var match = multiMatcher.exec(input);
192
- while (match) {
193
- try {
194
- replaceMap[match[0]] = decodeURIComponent(match[0]);
195
- } catch (err) {
196
- var result = decode(match[0]);
197
- if (result !== match[0]) {
198
- replaceMap[match[0]] = result;
199
- }
200
- }
201
- match = multiMatcher.exec(input);
202
- }
203
- replaceMap["%C2"] = "\uFFFD";
204
- var entries = Object.keys(replaceMap);
205
- for (var i = 0; i < entries.length; i++) {
206
- var key = entries[i];
207
- input = input.replace(new RegExp(key, "g"), replaceMap[key]);
208
- }
209
- return input;
210
- }
211
- var decodeUriComponent = function(encodedURI) {
212
- if (typeof encodedURI !== "string") {
213
- throw new TypeError("Expected `encodedURI` to be of type `string`, got `" + typeof encodedURI + "`");
214
- }
215
- try {
216
- encodedURI = encodedURI.replace(/\+/g, " ");
217
- return decodeURIComponent(encodedURI);
218
- } catch (err) {
219
- return customDecodeURIComponent(encodedURI);
220
- }
221
- };
222
- var splitOnFirst = (string, separator) => {
223
- if (!(typeof string === "string" && typeof separator === "string")) {
224
- throw new TypeError("Expected the arguments to be of type `string`");
225
- }
226
- if (separator === "") {
227
- return [string];
228
- }
229
- const separatorIndex = string.indexOf(separator);
230
- if (separatorIndex === -1) {
231
- return [string];
232
- }
233
- return [
234
- string.slice(0, separatorIndex),
235
- string.slice(separatorIndex + separator.length)
236
- ];
237
- };
238
- var filterObj = function(obj, predicate) {
239
- var ret = {};
240
- var keys = Object.keys(obj);
241
- var isArr = Array.isArray(predicate);
242
- for (var i = 0; i < keys.length; i++) {
243
- var key = keys[i];
244
- var val = obj[key];
245
- if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) {
246
- ret[key] = val;
247
- }
248
- }
249
- return ret;
250
- };
251
- (function(exports) {
252
- const strictUriEncode$1 = strictUriEncode;
253
- const decodeComponent = decodeUriComponent;
254
- const splitOnFirst$1 = splitOnFirst;
255
- const filterObject = filterObj;
256
- const isNullOrUndefined = (value) => value === null || value === void 0;
257
- const encodeFragmentIdentifier = Symbol("encodeFragmentIdentifier");
258
- function encoderForArrayFormat(options) {
259
- switch (options.arrayFormat) {
260
- case "index":
261
- return (key) => (result, value) => {
262
- const index = result.length;
263
- if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
264
- return result;
265
- }
266
- if (value === null) {
267
- return [...result, [encode(key, options), "[", index, "]"].join("")];
268
- }
269
- return [
270
- ...result,
271
- [encode(key, options), "[", encode(index, options), "]=", encode(value, options)].join("")
272
- ];
273
- };
274
- case "bracket":
275
- return (key) => (result, value) => {
276
- if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
277
- return result;
278
- }
279
- if (value === null) {
280
- return [...result, [encode(key, options), "[]"].join("")];
281
- }
282
- return [...result, [encode(key, options), "[]=", encode(value, options)].join("")];
283
- };
284
- case "colon-list-separator":
285
- return (key) => (result, value) => {
286
- if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
287
- return result;
288
- }
289
- if (value === null) {
290
- return [...result, [encode(key, options), ":list="].join("")];
291
- }
292
- return [...result, [encode(key, options), ":list=", encode(value, options)].join("")];
293
- };
294
- case "comma":
295
- case "separator":
296
- case "bracket-separator": {
297
- const keyValueSep = options.arrayFormat === "bracket-separator" ? "[]=" : "=";
298
- return (key) => (result, value) => {
299
- if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
300
- return result;
301
- }
302
- value = value === null ? "" : value;
303
- if (result.length === 0) {
304
- return [[encode(key, options), keyValueSep, encode(value, options)].join("")];
305
- }
306
- return [[result, encode(value, options)].join(options.arrayFormatSeparator)];
307
- };
308
- }
309
- default:
310
- return (key) => (result, value) => {
311
- if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
312
- return result;
313
- }
314
- if (value === null) {
315
- return [...result, encode(key, options)];
316
- }
317
- return [...result, [encode(key, options), "=", encode(value, options)].join("")];
318
- };
319
- }
320
- }
321
- function parserForArrayFormat(options) {
322
- let result;
323
- switch (options.arrayFormat) {
324
- case "index":
325
- return (key, value, accumulator) => {
326
- result = /\[(\d*)\]$/.exec(key);
327
- key = key.replace(/\[\d*\]$/, "");
328
- if (!result) {
329
- accumulator[key] = value;
330
- return;
331
- }
332
- if (accumulator[key] === void 0) {
333
- accumulator[key] = {};
334
- }
335
- accumulator[key][result[1]] = value;
336
- };
337
- case "bracket":
338
- return (key, value, accumulator) => {
339
- result = /(\[\])$/.exec(key);
340
- key = key.replace(/\[\]$/, "");
341
- if (!result) {
342
- accumulator[key] = value;
343
- return;
344
- }
345
- if (accumulator[key] === void 0) {
346
- accumulator[key] = [value];
347
- return;
348
- }
349
- accumulator[key] = [].concat(accumulator[key], value);
350
- };
351
- case "colon-list-separator":
352
- return (key, value, accumulator) => {
353
- result = /(:list)$/.exec(key);
354
- key = key.replace(/:list$/, "");
355
- if (!result) {
356
- accumulator[key] = value;
357
- return;
358
- }
359
- if (accumulator[key] === void 0) {
360
- accumulator[key] = [value];
361
- return;
362
- }
363
- accumulator[key] = [].concat(accumulator[key], value);
364
- };
365
- case "comma":
366
- case "separator":
367
- return (key, value, accumulator) => {
368
- const isArray = typeof value === "string" && value.includes(options.arrayFormatSeparator);
369
- const isEncodedArray = typeof value === "string" && !isArray && decode2(value, options).includes(options.arrayFormatSeparator);
370
- value = isEncodedArray ? decode2(value, options) : value;
371
- const newValue = isArray || isEncodedArray ? value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)) : value === null ? value : decode2(value, options);
372
- accumulator[key] = newValue;
373
- };
374
- case "bracket-separator":
375
- return (key, value, accumulator) => {
376
- const isArray = /(\[\])$/.test(key);
377
- key = key.replace(/\[\]$/, "");
378
- if (!isArray) {
379
- accumulator[key] = value ? decode2(value, options) : value;
380
- return;
381
- }
382
- const arrayValue = value === null ? [] : value.split(options.arrayFormatSeparator).map((item) => decode2(item, options));
383
- if (accumulator[key] === void 0) {
384
- accumulator[key] = arrayValue;
385
- return;
386
- }
387
- accumulator[key] = [].concat(accumulator[key], arrayValue);
388
- };
389
- default:
390
- return (key, value, accumulator) => {
391
- if (accumulator[key] === void 0) {
392
- accumulator[key] = value;
393
- return;
394
- }
395
- accumulator[key] = [].concat(accumulator[key], value);
396
- };
397
- }
398
- }
399
- function validateArrayFormatSeparator(value) {
400
- if (typeof value !== "string" || value.length !== 1) {
401
- throw new TypeError("arrayFormatSeparator must be single character string");
402
- }
403
- }
404
- function encode(value, options) {
405
- if (options.encode) {
406
- return options.strict ? strictUriEncode$1(value) : encodeURIComponent(value);
407
- }
408
- return value;
409
- }
410
- function decode2(value, options) {
411
- if (options.decode) {
412
- return decodeComponent(value);
413
- }
414
- return value;
415
- }
416
- function keysSorter(input) {
417
- if (Array.isArray(input)) {
418
- return input.sort();
419
- }
420
- if (typeof input === "object") {
421
- return keysSorter(Object.keys(input)).sort((a, b) => Number(a) - Number(b)).map((key) => input[key]);
422
- }
423
- return input;
424
- }
425
- function removeHash(input) {
426
- const hashStart = input.indexOf("#");
427
- if (hashStart !== -1) {
428
- input = input.slice(0, hashStart);
429
- }
430
- return input;
431
- }
432
- function getHash(url) {
433
- let hash = "";
434
- const hashStart = url.indexOf("#");
435
- if (hashStart !== -1) {
436
- hash = url.slice(hashStart);
437
- }
438
- return hash;
439
- }
440
- function extract(input) {
441
- input = removeHash(input);
442
- const queryStart = input.indexOf("?");
443
- if (queryStart === -1) {
444
- return "";
445
- }
446
- return input.slice(queryStart + 1);
447
- }
448
- function parseValue(value, options) {
449
- if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === "string" && value.trim() !== "")) {
450
- value = Number(value);
451
- } else if (options.parseBooleans && value !== null && (value.toLowerCase() === "true" || value.toLowerCase() === "false")) {
452
- value = value.toLowerCase() === "true";
453
- }
454
- return value;
455
- }
456
- function parse(query, options) {
457
- options = Object.assign({
458
- decode: true,
459
- sort: true,
460
- arrayFormat: "none",
461
- arrayFormatSeparator: ",",
462
- parseNumbers: false,
463
- parseBooleans: false
464
- }, options);
465
- validateArrayFormatSeparator(options.arrayFormatSeparator);
466
- const formatter = parserForArrayFormat(options);
467
- const ret = Object.create(null);
468
- if (typeof query !== "string") {
469
- return ret;
470
- }
471
- query = query.trim().replace(/^[?#&]/, "");
472
- if (!query) {
473
- return ret;
474
- }
475
- for (const param of query.split("&")) {
476
- if (param === "") {
477
- continue;
478
- }
479
- let [key, value] = splitOnFirst$1(options.decode ? param.replace(/\+/g, " ") : param, "=");
480
- value = value === void 0 ? null : ["comma", "separator", "bracket-separator"].includes(options.arrayFormat) ? value : decode2(value, options);
481
- formatter(decode2(key, options), value, ret);
482
- }
483
- for (const key of Object.keys(ret)) {
484
- const value = ret[key];
485
- if (typeof value === "object" && value !== null) {
486
- for (const k of Object.keys(value)) {
487
- value[k] = parseValue(value[k], options);
488
- }
489
- } else {
490
- ret[key] = parseValue(value, options);
491
- }
492
- }
493
- if (options.sort === false) {
494
- return ret;
495
- }
496
- return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => {
497
- const value = ret[key];
498
- if (Boolean(value) && typeof value === "object" && !Array.isArray(value)) {
499
- result[key] = keysSorter(value);
500
- } else {
501
- result[key] = value;
502
- }
503
- return result;
504
- }, Object.create(null));
505
- }
506
- exports.extract = extract;
507
- exports.parse = parse;
508
- exports.stringify = (object, options) => {
509
- if (!object) {
510
- return "";
511
- }
512
- options = Object.assign({
513
- encode: true,
514
- strict: true,
515
- arrayFormat: "none",
516
- arrayFormatSeparator: ","
517
- }, options);
518
- validateArrayFormatSeparator(options.arrayFormatSeparator);
519
- const shouldFilter = (key) => options.skipNull && isNullOrUndefined(object[key]) || options.skipEmptyString && object[key] === "";
520
- const formatter = encoderForArrayFormat(options);
521
- const objectCopy = {};
522
- for (const key of Object.keys(object)) {
523
- if (!shouldFilter(key)) {
524
- objectCopy[key] = object[key];
525
- }
526
- }
527
- const keys = Object.keys(objectCopy);
528
- if (options.sort !== false) {
529
- keys.sort(options.sort);
530
- }
531
- return keys.map((key) => {
532
- const value = object[key];
533
- if (value === void 0) {
534
- return "";
535
- }
536
- if (value === null) {
537
- return encode(key, options);
538
- }
539
- if (Array.isArray(value)) {
540
- if (value.length === 0 && options.arrayFormat === "bracket-separator") {
541
- return encode(key, options) + "[]";
542
- }
543
- return value.reduce(formatter(key), []).join("&");
544
- }
545
- return encode(key, options) + "=" + encode(value, options);
546
- }).filter((x) => x.length > 0).join("&");
547
- };
548
- exports.parseUrl = (url, options) => {
549
- options = Object.assign({
550
- decode: true
551
- }, options);
552
- const [url_, hash] = splitOnFirst$1(url, "#");
553
- return Object.assign({
554
- url: url_.split("?")[0] || "",
555
- query: parse(extract(url), options)
556
- }, options && options.parseFragmentIdentifier && hash ? { fragmentIdentifier: decode2(hash, options) } : {});
557
- };
558
- exports.stringifyUrl = (object, options) => {
559
- options = Object.assign({
560
- encode: true,
561
- strict: true,
562
- [encodeFragmentIdentifier]: true
563
- }, options);
564
- const url = removeHash(object.url).split("?")[0] || "";
565
- const queryFromUrl = exports.extract(object.url);
566
- const parsedQueryFromUrl = exports.parse(queryFromUrl, { sort: false });
567
- const query = Object.assign(parsedQueryFromUrl, object.query);
568
- let queryString2 = exports.stringify(query, options);
569
- if (queryString2) {
570
- queryString2 = `?${queryString2}`;
571
- }
572
- let hash = getHash(object.url);
573
- if (object.fragmentIdentifier) {
574
- hash = `#${options[encodeFragmentIdentifier] ? encode(object.fragmentIdentifier, options) : object.fragmentIdentifier}`;
575
- }
576
- return `${url}${queryString2}${hash}`;
577
- };
578
- exports.pick = (input, filter, options) => {
579
- options = Object.assign({
580
- parseFragmentIdentifier: true,
581
- [encodeFragmentIdentifier]: false
582
- }, options);
583
- const { url, query, fragmentIdentifier } = exports.parseUrl(input, options);
584
- return exports.stringifyUrl({
585
- url,
586
- query: filterObject(query, filter),
587
- fragmentIdentifier
588
- }, options);
589
- };
590
- exports.exclude = (input, filter, options) => {
591
- const exclusionFilter = Array.isArray(filter) ? (key) => !filter.includes(key) : (key, value) => !filter(key, value);
592
- return exports.pick(input, exclusionFilter, options);
593
- };
594
- })(queryString);
595
- const NHOST_REFRESH_TOKEN = "nhostRefreshToken";
596
- const isBrowser = () => typeof window !== "undefined";
597
- class inMemoryLocalStorage {
598
- constructor() {
599
- this.memory = {};
600
- }
601
- setItem(key, value) {
602
- this.memory[key] = value;
603
- }
604
- getItem(key) {
605
- return this.memory[key];
606
- }
607
- removeItem(key) {
608
- delete this.memory[key];
609
- }
610
- }
611
- class HasuraAuthClient {
612
- constructor({
613
- url,
614
- autoRefreshToken = true,
615
- autoLogin = true,
616
- refreshIntervalTime,
617
- clientStorage,
618
- clientStorageType = "web"
619
- }) {
620
- this.refreshIntervalTime = refreshIntervalTime;
621
- if (!clientStorage) {
622
- this.clientStorage = isBrowser() ? localStorage : new inMemoryLocalStorage();
623
- } else {
624
- this.clientStorage = clientStorage;
625
- }
626
- this.clientStorageType = clientStorageType;
627
- this.onTokenChangedFunctions = [];
628
- this.onAuthChangedFunctions = [];
629
- this.refreshInterval;
630
- this.refreshSleepCheckInterval = 0;
631
- this.refreshIntervalSleepCheckLastSample = Date.now();
632
- this.sampleRate = 2e3;
633
- this.url = url;
634
- this.autoRefreshToken = autoRefreshToken;
635
- this.initAuthLoading = true;
636
- this.session = null;
637
- this.api = new HasuraAuthApi({ url: this.url });
638
- let refreshToken = null;
639
- let autoLoginFromQueryParameters = false;
640
- if (autoLogin && isBrowser() && window.location) {
641
- const urlParams = queryString.parse(window.location.toString().split("#")[1]);
642
- if ("refreshToken" in urlParams) {
643
- refreshToken = urlParams.refreshToken;
644
- }
645
- if ("otp" in urlParams && "email" in urlParams) {
646
- const { otp, email } = urlParams;
647
- this.signIn({
648
- otp,
649
- email
650
- });
651
- autoLoginFromQueryParameters = true;
652
- }
653
- }
654
- if (!autoLoginFromQueryParameters && autoLogin) {
655
- this._autoLogin(refreshToken);
656
- } else if (refreshToken) {
657
- this._setItem(NHOST_REFRESH_TOKEN, refreshToken);
658
- }
659
- }
660
- async signUp(params) {
661
- const { email, password } = params;
662
- if (email && password) {
663
- const { data, error } = await this.api.signUpEmailPassword(params);
664
- if (error) {
665
- return { session: null, error };
666
- }
667
- if (!data) {
668
- return {
669
- session: null,
670
- error: { message: "An error occurred on sign up.", status: 500 }
671
- };
672
- }
673
- const { session } = data;
674
- if (session) {
675
- await this._setSession(session);
676
- }
677
- return { session, error: null };
678
- }
679
- return {
680
- session: null,
681
- error: { message: "Incorrect parameters", status: 500 }
682
- };
683
- }
684
- async signIn(params) {
685
- if ("provider" in params) {
686
- const { provider } = params;
687
- const providerUrl = `${this.url}/signin/provider/${provider}`;
688
- if (isBrowser()) {
689
- window.location.href = providerUrl;
690
- }
691
- return { providerUrl, provider, session: null, mfa: null, error: null };
692
- }
693
- if ("email" in params && "password" in params) {
694
- const { data, error } = await this.api.signInEmailPassword(params);
695
- if (error) {
696
- return { session: null, mfa: null, error };
697
- }
698
- if (!data) {
699
- return {
700
- session: null,
701
- mfa: null,
702
- error: { message: "Incorrect Data", status: 500 }
703
- };
704
- }
705
- const { session, mfa } = data;
706
- if (session) {
707
- await this._setSession(session);
708
- }
709
- return { session, mfa, error: null };
710
- }
711
- if ("email" in params && !("otp" in params)) {
712
- const { error } = await this.api.signInPasswordlessEmail(params);
713
- if (error) {
714
- return { session: null, mfa: null, error };
715
- }
716
- return { session: null, mfa: null, error: null };
717
- }
718
- if ("phoneNumber" in params && !("otp" in params)) {
719
- const { error } = await this.api.signInPasswordlessSms(params);
720
- if (error) {
721
- return { session: null, mfa: null, error };
722
- }
723
- return { session: null, mfa: null, error: null };
724
- }
725
- if ("otp" in params) {
726
- const { data, error } = await this.api.signInPasswordlessSmsOtp(params);
727
- if (error) {
728
- return { session: null, mfa: null, error };
729
- }
730
- if (!data) {
731
- return {
732
- session: null,
733
- mfa: null,
734
- error: { message: "Incorrect data", status: 500 }
735
- };
736
- }
737
- const { session, mfa } = data;
738
- if (session) {
739
- await this._setSession(session);
740
- }
741
- return { session, mfa, error: null };
742
- }
743
- return {
744
- session: null,
745
- mfa: null,
746
- error: { message: "Incorrect parameters", status: 500 }
747
- };
748
- }
749
- async signOut(params) {
750
- const refreshToken = await this._getItem(NHOST_REFRESH_TOKEN);
751
- this._clearSession();
752
- const { error } = await this.api.signOut({
753
- refreshToken,
754
- all: params == null ? void 0 : params.all
755
- });
756
- return { error };
757
- }
758
- async verifyEmail(params) {
759
- return await this.api.verifyEmail(params);
760
- }
761
- async resetPassword(params) {
762
- const { error } = await this.api.resetPassword(params);
763
- return { error };
764
- }
765
- async changePassword(params) {
766
- const { error } = await this.api.changePassword(params);
767
- return { error };
768
- }
769
- async sendVerificationEmail(params) {
770
- const { error } = await this.api.sendVerificationEmail(params);
771
- return { error };
772
- }
773
- async changeEmail(params) {
774
- const { error } = await this.api.changeEmail(params);
775
- return { error };
776
- }
777
- async deanonymize(params) {
778
- const { error } = await this.api.deanonymize(params);
779
- return { error };
780
- }
781
- onTokenChanged(fn) {
782
- this.onTokenChangedFunctions.push(fn);
783
- const index = this.onTokenChangedFunctions.length - 1;
784
- const unsubscribe = () => {
785
- try {
786
- this.onTokenChangedFunctions[index] = () => {
787
- };
788
- } catch {
789
- console.warn("Unable to unsubscribe onTokenChanged function. Maybe the functions is already unsubscribed?");
790
- }
791
- };
792
- return unsubscribe;
793
- }
794
- onAuthStateChanged(fn) {
795
- this.onAuthChangedFunctions.push(fn);
796
- const index = this.onAuthChangedFunctions.length - 1;
797
- const unsubscribe = () => {
798
- try {
799
- this.onAuthChangedFunctions[index] = () => {
800
- };
801
- } catch {
802
- console.warn("Unable to unsubscribe onAuthStateChanged function. Maybe you already did?");
803
- }
804
- };
805
- return unsubscribe;
806
- }
807
- isAuthenticated() {
808
- return this.session !== null;
809
- }
810
- async isAuthenticatedAsync() {
811
- return new Promise((resolve) => {
812
- if (!this.initAuthLoading) {
813
- resolve(this.isAuthenticated());
814
- } else {
815
- const unsubscribe = this.onAuthStateChanged((event, _session) => {
816
- resolve(event === "SIGNED_IN");
817
- unsubscribe();
818
- });
819
- }
820
- });
821
- }
822
- getAuthenticationStatus() {
823
- if (this.initAuthLoading)
824
- return { isAuthenticated: false, isLoading: true };
825
- return { isAuthenticated: this.session !== null, isLoading: false };
826
- }
827
- getJWTToken() {
828
- return this.getAccessToken();
829
- }
830
- getAccessToken() {
831
- if (!this.session) {
832
- return void 0;
833
- }
834
- return this.session.accessToken;
835
- }
836
- async refreshSession(refreshToken) {
837
- const refreshTokenToUse = refreshToken || await this._getItem(NHOST_REFRESH_TOKEN);
838
- if (!refreshTokenToUse) {
839
- console.warn("no refresh token found. No way of refreshing session");
840
- }
841
- return this._refreshTokens(refreshTokenToUse);
842
- }
843
- getSession() {
844
- return this.session;
845
- }
846
- getUser() {
847
- return this.session ? this.session.user : null;
848
- }
849
- async _setItem(key, value) {
850
- if (typeof value !== "string") {
851
- console.error(`value is not of type "string"`);
852
- return;
853
- }
854
- switch (this.clientStorageType) {
855
- case "web":
856
- if (typeof this.clientStorage.setItem !== "function") {
857
- console.error(`this.clientStorage.setItem is not a function`);
858
- break;
859
- }
860
- this.clientStorage.setItem(key, value);
861
- break;
862
- case "custom":
863
- case "react-native":
864
- if (typeof this.clientStorage.setItem !== "function") {
865
- console.error(`this.clientStorage.setItem is not a function`);
866
- break;
867
- }
868
- await this.clientStorage.setItem(key, value);
869
- break;
870
- case "capacitor":
871
- if (typeof this.clientStorage.set !== "function") {
872
- console.error(`this.clientStorage.set is not a function`);
873
- break;
874
- }
875
- await this.clientStorage.set({ key, value });
876
- break;
877
- case "expo-secure-storage":
878
- if (typeof this.clientStorage.setItemAsync !== "function") {
879
- console.error(`this.clientStorage.setItemAsync is not a function`);
880
- break;
881
- }
882
- this.clientStorage.setItemAsync(key, value);
883
- break;
884
- }
885
- }
886
- async _getItem(key) {
887
- switch (this.clientStorageType) {
888
- case "web":
889
- if (typeof this.clientStorage.getItem !== "function") {
890
- console.error(`this.clientStorage.getItem is not a function`);
891
- break;
892
- }
893
- return this.clientStorage.getItem(key);
894
- case "custom":
895
- case "react-native":
896
- if (typeof this.clientStorage.getItem !== "function") {
897
- console.error(`this.clientStorage.getItem is not a function`);
898
- break;
899
- }
900
- return await this.clientStorage.getItem(key);
901
- case "capacitor":
902
- if (typeof this.clientStorage.get !== "function") {
903
- console.error(`this.clientStorage.get is not a function`);
904
- break;
905
- }
906
- const res = await this.clientStorage.get({ key });
907
- return res.value;
908
- case "expo-secure-storage":
909
- if (typeof this.clientStorage.getItemAsync !== "function") {
910
- console.error(`this.clientStorage.getItemAsync is not a function`);
911
- break;
912
- }
913
- return this.clientStorage.getItemAsync(key);
914
- default:
915
- return "";
916
- }
917
- return "";
918
- }
919
- async _removeItem(key) {
920
- switch (this.clientStorageType) {
921
- case "web":
922
- if (typeof this.clientStorage.removeItem !== "function") {
923
- console.error(`this.clientStorage.removeItem is not a function`);
924
- break;
925
- }
926
- return void this.clientStorage.removeItem(key);
927
- case "custom":
928
- case "react-native":
929
- if (typeof this.clientStorage.removeItem !== "function") {
930
- console.error(`this.clientStorage.removeItem is not a function`);
931
- break;
932
- }
933
- return void this.clientStorage.removeItem(key);
934
- case "capacitor":
935
- if (typeof this.clientStorage.remove !== "function") {
936
- console.error(`this.clientStorage.remove is not a function`);
937
- break;
938
- }
939
- await this.clientStorage.remove({ key });
940
- break;
941
- case "expo-secure-storage":
942
- if (typeof this.clientStorage.deleteItemAsync !== "function") {
943
- console.error(`this.clientStorage.deleteItemAsync is not a function`);
944
- break;
945
- }
946
- this.clientStorage.deleteItemAsync(key);
947
- break;
948
- }
949
- }
950
- _autoLogin(refreshToken) {
951
- if (!isBrowser()) {
952
- return;
953
- }
954
- this._refreshTokens(refreshToken);
955
- }
956
- async _refreshTokens(paramRefreshToken) {
957
- const refreshToken = paramRefreshToken || await this._getItem(NHOST_REFRESH_TOKEN);
958
- if (!refreshToken) {
959
- setTimeout(async () => {
960
- await this._clearSession();
961
- }, 0);
962
- return;
963
- }
964
- try {
965
- const { session, error } = await this.api.refreshToken({ refreshToken });
966
- if (error && error.status === 401) {
967
- await this._clearSession();
968
- return;
969
- }
970
- if (!session)
971
- throw new Error("Invalid session data");
972
- await this._setSession(session);
973
- this.tokenChanged();
974
- } catch {
975
- }
976
- }
977
- tokenChanged() {
978
- for (const tokenChangedFunction of this.onTokenChangedFunctions) {
979
- tokenChangedFunction(this.session);
980
- }
981
- }
982
- authStateChanged({
983
- event,
984
- session
985
- }) {
986
- if (event === "SIGNED_IN" && session) {
987
- this.api.setAccessToken(session.accessToken);
988
- } else {
989
- this.api.setAccessToken(void 0);
990
- }
991
- for (const authChangedFunction of this.onAuthChangedFunctions) {
992
- authChangedFunction(event, session);
993
- }
994
- }
995
- async _clearSession() {
996
- const { isLoading, isAuthenticated } = this.getAuthenticationStatus();
997
- this.session = null;
998
- this.initAuthLoading = false;
999
- await this._removeItem(NHOST_REFRESH_TOKEN);
1000
- if (isLoading || isAuthenticated) {
1001
- clearInterval(this.refreshInterval);
1002
- clearInterval(this.refreshSleepCheckInterval);
1003
- this.authStateChanged({ event: "SIGNED_OUT", session: null });
1004
- }
1005
- }
1006
- async _setSession(session) {
1007
- const { isAuthenticated } = this.getAuthenticationStatus();
1008
- this.session = session;
1009
- await this._setItem(NHOST_REFRESH_TOKEN, session.refreshToken);
1010
- if (this.autoRefreshToken && !isAuthenticated) {
1011
- const JWTExpiresIn = session.accessTokenExpiresIn;
1012
- const refreshIntervalTime = this.refreshIntervalTime ? this.refreshIntervalTime : Math.max(1, JWTExpiresIn - 1);
1013
- this.refreshInterval = setInterval(async () => {
1014
- const refreshToken = await this._getItem(NHOST_REFRESH_TOKEN);
1015
- await this._refreshTokens(refreshToken);
1016
- }, refreshIntervalTime * 1e3);
1017
- this.refreshIntervalSleepCheckLastSample = Date.now();
1018
- this.refreshSleepCheckInterval = setInterval(async () => {
1019
- if (Date.now() - this.refreshIntervalSleepCheckLastSample >= this.sampleRate * 2) {
1020
- const refreshToken = await this._getItem(NHOST_REFRESH_TOKEN);
1021
- await this._refreshTokens(refreshToken);
1022
- }
1023
- this.refreshIntervalSleepCheckLastSample = Date.now();
1024
- }, this.sampleRate);
1025
- this.authStateChanged({ event: "SIGNED_IN", session: this.session });
1026
- }
1027
- this.initAuthLoading = false;
1028
- }
1029
- }
1030
- const axios$2 = require("axios");
1031
- class HasuraStorageApi {
1032
- constructor({ url }) {
1033
- this.url = url;
1034
- this.httpClient = axios$2.create({
1035
- baseURL: this.url
1036
- });
1037
- }
1038
- async upload(params) {
1039
- try {
1040
- const res = await this.httpClient.post("/files", params.file, {
1041
- headers: __spreadValues(__spreadValues({}, this.generateUploadHeaders(params)), this.generateAuthHeaders())
1042
- });
1043
- return { fileMetadata: res.data, error: null };
1044
- } catch (error) {
1045
- return { fileMetadata: null, error };
1046
- }
1047
- }
1048
- async getPresignedUrl(params) {
1049
- try {
1050
- const { fileId } = params;
1051
- const res = await this.httpClient.get(`/files/${fileId}/presignedurl`, {
1052
- headers: __spreadValues({}, this.generateAuthHeaders())
1053
- });
1054
- return { presignedUrl: res.data, error: null };
1055
- } catch (error) {
1056
- return { presignedUrl: null, error };
1057
- }
1058
- }
1059
- async delete(params) {
1060
- try {
1061
- const { fileId } = params;
1062
- await this.httpClient.delete(`/files/${fileId}`, {
1063
- headers: __spreadValues({}, this.generateAuthHeaders())
1064
- });
1065
- return { error: null };
1066
- } catch (error) {
1067
- return { error };
1068
- }
1069
- }
1070
- setAccessToken(accessToken) {
1071
- this.accessToken = accessToken;
1072
- }
1073
- generateUploadHeaders(params) {
1074
- const { bucketId, name, id } = params;
1075
- const uploadheaders = {};
1076
- if (bucketId) {
1077
- uploadheaders["x-nhost-bucket-id"] = bucketId;
1078
- }
1079
- if (id) {
1080
- uploadheaders["x-nhost-file-id"] = id;
1081
- }
1082
- if (name) {
1083
- uploadheaders["x-nhost-file-name"] = name;
1084
- }
1085
- return uploadheaders;
1086
- }
1087
- generateAuthHeaders() {
1088
- if (!this.accessToken) {
1089
- return null;
1090
- }
1091
- return {
1092
- Authorization: `Bearer ${this.accessToken}`
1093
- };
1094
- }
1095
- }
1096
- class HasuraStorageClient {
1097
- constructor({ url }) {
1098
- this.url = url;
1099
- this.api = new HasuraStorageApi({ url });
1100
- }
1101
- async upload(params) {
1102
- const file = new FormData();
1103
- file.append("file", params.file);
1104
- const { fileMetadata, error } = await this.api.upload(__spreadProps(__spreadValues({}, params), {
1105
- file
1106
- }));
1107
- if (error) {
1108
- return { fileMetadata: null, error };
1109
- }
1110
- if (!fileMetadata) {
1111
- return { fileMetadata: null, error: new Error("Invalid file returned") };
1112
- }
1113
- return { fileMetadata, error: null };
1114
- }
1115
- getUrl(params) {
1116
- const { fileId } = params;
1117
- return `${this.url}/files/${fileId}`;
1118
- }
1119
- async getPresignedUrl(params) {
1120
- const { presignedUrl, error } = await this.api.getPresignedUrl(params);
1121
- if (error) {
1122
- return { presignedUrl: null, error };
1123
- }
1124
- if (!presignedUrl) {
1125
- return { presignedUrl: null, error: new Error("Invalid file id") };
1126
- }
1127
- return { presignedUrl, error: null };
1128
- }
1129
- async delete(params) {
1130
- const { error } = await this.api.delete(params);
1131
- if (error) {
1132
- return { error };
1133
- }
1134
- return { error: null };
1135
- }
1136
- setAccessToken(accessToken) {
1137
- this.api.setAccessToken(accessToken);
1138
- }
1139
- }
1140
- const axios$1 = require("axios");
1141
- class NhostFunctionsClient {
1142
- constructor(params) {
1143
- const { url } = params;
1144
- this.accessToken = null;
1145
- this.instance = axios$1.create({
1146
- baseURL: url
1147
- });
1148
- }
1149
- async call(url, data, config) {
1150
- const headers = __spreadValues(__spreadValues({}, this.generateAccessTokenHeaders()), config == null ? void 0 : config.headers);
1151
- let res;
1152
- try {
1153
- res = await this.instance.post(url, data, __spreadProps(__spreadValues({}, config), { headers }));
1154
- } catch (error) {
1155
- if (error instanceof Error) {
1156
- return { res: null, error };
1157
- }
1158
- }
1159
- if (!res) {
1160
- return {
1161
- res: null,
1162
- error: new Error("Unable to make post request to funtion")
1163
- };
1164
- }
1165
- return { res, error: null };
1166
- }
1167
- setAccessToken(accessToken) {
1168
- if (!accessToken) {
1169
- this.accessToken = null;
1170
- return;
1171
- }
1172
- this.accessToken = accessToken;
1173
- }
1174
- generateAccessTokenHeaders() {
1175
- if (!this.accessToken) {
1176
- return;
1177
- }
1178
- return {
1179
- Authorization: `Bearer ${this.accessToken}`
1180
- };
1181
- }
1182
- }
1183
- const axios = require("axios");
1184
- class NhostGraphqlClient {
1185
- constructor(params) {
1186
- const { url } = params;
1187
- this.url = url;
1188
- this.accessToken = null;
1189
- this.instance = axios.create({
1190
- baseURL: url
1191
- });
1192
- }
1193
- async request(document, variables, config) {
1194
- const headers = __spreadValues(__spreadValues({}, config == null ? void 0 : config.headers), this.generateAccessTokenHeaders());
1195
- const operationName = "";
1196
- let responseData;
1197
- try {
1198
- const res = await this.instance.post("", {
1199
- operationName: operationName || void 0,
1200
- query: document,
1201
- variables
1202
- }, __spreadProps(__spreadValues({}, config), { headers }));
1203
- responseData = res.data;
1204
- } catch (error) {
1205
- if (error instanceof Error) {
1206
- return { data: null, error };
1207
- }
1208
- console.error(error);
1209
- return {
1210
- data: null,
1211
- error: new Error("Unable to get do GraphQL request")
1212
- };
1213
- }
1214
- if (typeof responseData !== "object" || Array.isArray(responseData) || responseData === null) {
1215
- return {
1216
- data: null,
1217
- error: new Error("incorrect response data from GraphQL server")
1218
- };
1219
- }
1220
- responseData = responseData;
1221
- if (responseData.errors) {
1222
- return {
1223
- data: null,
1224
- error: responseData.errors
1225
- };
1226
- }
1227
- return { data: responseData.data, error: null };
1228
- }
1229
- getUrl() {
1230
- return this.url;
1231
- }
1232
- setAccessToken(accessToken) {
1233
- if (!accessToken) {
1234
- this.accessToken = null;
1235
- return;
1236
- }
1237
- this.accessToken = accessToken;
1238
- }
1239
- generateAccessTokenHeaders() {
1240
- if (!this.accessToken) {
1241
- return;
1242
- }
1243
- return {
1244
- Authorization: `Bearer ${this.accessToken}`
1245
- };
1246
- }
1247
- }
1248
- class NhostClient {
1249
- constructor(params) {
1250
- if (!params.backendUrl)
1251
- throw new Error("Please specify a `backendUrl`. Docs: [todo]!");
1252
- const {
1253
- backendUrl,
1254
- refreshIntervalTime,
1255
- clientStorage,
1256
- clientStorageType,
1257
- autoRefreshToken,
1258
- autoLogin
1259
- } = params;
1260
- this.auth = new HasuraAuthClient({
1261
- url: `${backendUrl}/v1/auth`,
1262
- refreshIntervalTime,
1263
- clientStorage,
1264
- clientStorageType,
1265
- autoRefreshToken,
1266
- autoLogin
1267
- });
1268
- this.storage = new HasuraStorageClient({
1269
- url: `${backendUrl}/v1/storage`
1270
- });
1271
- this.functions = new NhostFunctionsClient({
1272
- url: `${backendUrl}/v1/functions`
1273
- });
1274
- this.graphql = new NhostGraphqlClient({
1275
- url: `${backendUrl}/v1/graphql`
1276
- });
1277
- this.storage.setAccessToken(this.auth.getAccessToken());
1278
- this.functions.setAccessToken(this.auth.getAccessToken());
1279
- this.graphql.setAccessToken(this.auth.getAccessToken());
1280
- this.auth.onAuthStateChanged((_event, session) => {
1281
- this.storage.setAccessToken(session == null ? void 0 : session.accessToken);
1282
- this.functions.setAccessToken(session == null ? void 0 : session.accessToken);
1283
- this.graphql.setAccessToken(session == null ? void 0 : session.accessToken);
1284
- });
1285
- this.auth.onTokenChanged((session) => {
1286
- this.storage.setAccessToken(session == null ? void 0 : session.accessToken);
1287
- this.functions.setAccessToken(session == null ? void 0 : session.accessToken);
1288
- this.graphql.setAccessToken(session == null ? void 0 : session.accessToken);
1289
- });
1290
- }
1291
- }
1292
- const createClient = (config) => new NhostClient(config);
1293
- export { NhostClient, createClient };
1
+ var or=Object.create;var oe=Object.defineProperty;var ir=Object.getOwnPropertyDescriptor;var ar=Object.getOwnPropertyNames;var ur=Object.getPrototypeOf,cr=Object.prototype.hasOwnProperty;var lr=r=>oe(r,"__esModule",{value:!0});var j=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var fr=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ar(e))!cr.call(r,n)&&(t||n!=="default")&&oe(r,n,{get:()=>e[n],enumerable:!(o=ir(e,n))||o.enumerable});return r},Pe=(r,e)=>fr(lr(oe(r!=null?or(ur(r)):{},"default",!e&&r&&r.__esModule?{get:()=>r.default,enumerable:!0}:{value:r,enumerable:!0})),r);var ce=j((bs,Ye)=>{"use strict";Ye.exports=function(e,t){return function(){for(var n=new Array(arguments.length),i=0;i<n.length;i++)n[i]=arguments[i];return e.apply(t,n)}}});var L=j((ws,tt)=>{"use strict";var En=ce(),M=Object.prototype.toString;function he(r){return M.call(r)==="[object Array]"}function le(r){return typeof r>"u"}function kn(r){return r!==null&&!le(r)&&r.constructor!==null&&!le(r.constructor)&&typeof r.constructor.isBuffer=="function"&&r.constructor.isBuffer(r)}function Cn(r){return M.call(r)==="[object ArrayBuffer]"}function Tn(r){return typeof FormData<"u"&&r instanceof FormData}function An(r){var e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(r):e=r&&r.buffer&&r.buffer instanceof ArrayBuffer,e}function On(r){return typeof r=="string"}function jn(r){return typeof r=="number"}function Ze(r){return r!==null&&typeof r=="object"}function Y(r){if(M.call(r)!=="[object Object]")return!1;var e=Object.getPrototypeOf(r);return e===null||e===Object.prototype}function Nn(r){return M.call(r)==="[object Date]"}function Rn(r){return M.call(r)==="[object File]"}function Pn(r){return M.call(r)==="[object Blob]"}function et(r){return M.call(r)==="[object Function]"}function In(r){return Ze(r)&&et(r.pipe)}function qn(r){return typeof URLSearchParams<"u"&&r instanceof URLSearchParams}function Un(r){return r.trim?r.trim():r.replace(/^\s+|\s+$/g,"")}function Ln(){return typeof navigator<"u"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window<"u"&&typeof document<"u"}function pe(r,e){if(!(r===null||typeof r>"u"))if(typeof r!="object"&&(r=[r]),he(r))for(var t=0,o=r.length;t<o;t++)e.call(null,r[t],t,r);else for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.call(null,r[n],n,r)}function fe(){var r={};function e(n,i){Y(r[i])&&Y(n)?r[i]=fe(r[i],n):Y(n)?r[i]=fe({},n):he(n)?r[i]=n.slice():r[i]=n}for(var t=0,o=arguments.length;t<o;t++)pe(arguments[t],e);return r}function Fn(r,e,t){return pe(e,function(n,i){t&&typeof n=="function"?r[i]=En(n,t):r[i]=n}),r}function Bn(r){return r.charCodeAt(0)===65279&&(r=r.slice(1)),r}tt.exports={isArray:he,isArrayBuffer:Cn,isBuffer:kn,isFormData:Tn,isArrayBufferView:An,isString:On,isNumber:jn,isObject:Ze,isPlainObject:Y,isUndefined:le,isDate:Nn,isFile:Rn,isBlob:Pn,isFunction:et,isStream:In,isURLSearchParams:qn,isStandardBrowserEnv:Ln,forEach:pe,merge:fe,extend:Fn,trim:Un,stripBOM:Bn}});var de=j((xs,nt)=>{"use strict";var J=L();function rt(r){return encodeURIComponent(r).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}nt.exports=function(e,t,o){if(!t)return e;var n;if(o)n=o(t);else if(J.isURLSearchParams(t))n=t.toString();else{var i=[];J.forEach(t,function(u,l){u===null||typeof u>"u"||(J.isArray(u)?l=l+"[]":u=[u],J.forEach(u,function(p){J.isDate(p)?p=p.toISOString():J.isObject(p)&&(p=JSON.stringify(p)),i.push(rt(l)+"="+rt(p))}))}),n=i.join("&")}if(n){var a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+n}return e}});var ot=j((Ss,st)=>{"use strict";var _n=L();function Z(){this.handlers=[]}Z.prototype.use=function(e,t,o){return this.handlers.push({fulfilled:e,rejected:t,synchronous:o?o.synchronous:!1,runWhen:o?o.runWhen:null}),this.handlers.length-1};Z.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};Z.prototype.forEach=function(e){_n.forEach(this.handlers,function(o){o!==null&&e(o)})};st.exports=Z});var at=j((Es,it)=>{"use strict";var Dn=L();it.exports=function(e,t){Dn.forEach(e,function(n,i){i!==t&&i.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[i])})}});var me=j((ks,ut)=>{"use strict";ut.exports=function(e,t,o,n,i){return e.config=t,o&&(e.code=o),e.request=n,e.response=i,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e}});var ge=j((Cs,ct)=>{"use strict";var Hn=me();ct.exports=function(e,t,o,n,i){var a=new Error(e);return Hn(a,t,o,n,i)}});var ft=j((Ts,lt)=>{"use strict";var Mn=ge();lt.exports=function(e,t,o){var n=o.config.validateStatus;!o.status||!n||n(o.status)?e(o):t(Mn("Request failed with status code "+o.status,o.config,null,o.request,o))}});var pt=j((As,ht)=>{"use strict";var ee=L();ht.exports=ee.isStandardBrowserEnv()?function(){return{write:function(t,o,n,i,a,c){var u=[];u.push(t+"="+encodeURIComponent(o)),ee.isNumber(n)&&u.push("expires="+new Date(n).toGMTString()),ee.isString(i)&&u.push("path="+i),ee.isString(a)&&u.push("domain="+a),c===!0&&u.push("secure"),document.cookie=u.join("; ")},read:function(t){var o=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return o?decodeURIComponent(o[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()});var mt=j((Os,dt)=>{"use strict";dt.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}});var vt=j((js,gt)=>{"use strict";gt.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}});var bt=j((Ns,yt)=>{"use strict";var Jn=mt(),$n=vt();yt.exports=function(e,t){return e&&!Jn(t)?$n(e,t):t}});var xt=j((Rs,wt)=>{"use strict";var ve=L(),zn=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];wt.exports=function(e){var t={},o,n,i;return e&&ve.forEach(e.split(`
2
+ `),function(c){if(i=c.indexOf(":"),o=ve.trim(c.substr(0,i)).toLowerCase(),n=ve.trim(c.substr(i+1)),o){if(t[o]&&zn.indexOf(o)>=0)return;o==="set-cookie"?t[o]=(t[o]?t[o]:[]).concat([n]):t[o]=t[o]?t[o]+", "+n:n}}),t}});var kt=j((Ps,Et)=>{"use strict";var St=L();Et.exports=St.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a"),o;function n(i){var a=i;return e&&(t.setAttribute("href",a),a=t.href),t.setAttribute("href",a),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return o=n(window.location.href),function(a){var c=St.isString(a)?n(a):a;return c.protocol===o.protocol&&c.host===o.host}}():function(){return function(){return!0}}()});var V=j((Is,Ct)=>{"use strict";function ye(r){this.message=r}ye.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};ye.prototype.__CANCEL__=!0;Ct.exports=ye});var we=j((qs,Tt)=>{"use strict";var te=L(),Vn=ft(),Gn=pt(),Wn=de(),Xn=bt(),Kn=xt(),Qn=kt(),be=ge(),Yn=G(),Zn=V();Tt.exports=function(e){return new Promise(function(o,n){var i=e.data,a=e.headers,c=e.responseType,u;function l(){e.cancelToken&&e.cancelToken.unsubscribe(u),e.signal&&e.signal.removeEventListener("abort",u)}te.isFormData(i)&&delete a["Content-Type"];var s=new XMLHttpRequest;if(e.auth){var p=e.auth.username||"",h=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";a.Authorization="Basic "+btoa(p+":"+h)}var x=Xn(e.baseURL,e.url);s.open(e.method.toUpperCase(),Wn(x,e.params,e.paramsSerializer),!0),s.timeout=e.timeout;function y(){if(!!s){var b="getAllResponseHeaders"in s?Kn(s.getAllResponseHeaders()):null,T=!c||c==="text"||c==="json"?s.responseText:s.response,m={data:T,status:s.status,statusText:s.statusText,headers:b,config:e,request:s};Vn(function(d){o(d),l()},function(d){n(d),l()},m),s=null}}if("onloadend"in s?s.onloadend=y:s.onreadystatechange=function(){!s||s.readyState!==4||s.status===0&&!(s.responseURL&&s.responseURL.indexOf("file:")===0)||setTimeout(y)},s.onabort=function(){!s||(n(be("Request aborted",e,"ECONNABORTED",s)),s=null)},s.onerror=function(){n(be("Network Error",e,null,s)),s=null},s.ontimeout=function(){var T=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",m=e.transitional||Yn.transitional;e.timeoutErrorMessage&&(T=e.timeoutErrorMessage),n(be(T,e,m.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",s)),s=null},te.isStandardBrowserEnv()){var S=(e.withCredentials||Qn(x))&&e.xsrfCookieName?Gn.read(e.xsrfCookieName):void 0;S&&(a[e.xsrfHeaderName]=S)}"setRequestHeader"in s&&te.forEach(a,function(T,m){typeof i>"u"&&m.toLowerCase()==="content-type"?delete a[m]:s.setRequestHeader(m,T)}),te.isUndefined(e.withCredentials)||(s.withCredentials=!!e.withCredentials),c&&c!=="json"&&(s.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&s.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&s.upload&&s.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(u=function(b){!s||(n(!b||b&&b.type?new Zn("canceled"):b),s.abort(),s=null)},e.cancelToken&&e.cancelToken.subscribe(u),e.signal&&(e.signal.aborted?u():e.signal.addEventListener("abort",u))),i||(i=null),s.send(i)})}});var G=j((Us,jt)=>{"use strict";var q=L(),At=at(),es=me(),ts={"Content-Type":"application/x-www-form-urlencoded"};function Ot(r,e){!q.isUndefined(r)&&q.isUndefined(r["Content-Type"])&&(r["Content-Type"]=e)}function rs(){var r;return typeof XMLHttpRequest<"u"?r=we():typeof process<"u"&&Object.prototype.toString.call(process)==="[object process]"&&(r=we()),r}function ns(r,e,t){if(q.isString(r))try{return(e||JSON.parse)(r),q.trim(r)}catch(o){if(o.name!=="SyntaxError")throw o}return(t||JSON.stringify)(r)}var re={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:rs(),transformRequest:[function(e,t){return At(t,"Accept"),At(t,"Content-Type"),q.isFormData(e)||q.isArrayBuffer(e)||q.isBuffer(e)||q.isStream(e)||q.isFile(e)||q.isBlob(e)?e:q.isArrayBufferView(e)?e.buffer:q.isURLSearchParams(e)?(Ot(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):q.isObject(e)||t&&t["Content-Type"]==="application/json"?(Ot(t,"application/json"),ns(e)):e}],transformResponse:[function(e){var t=this.transitional||re.transitional,o=t&&t.silentJSONParsing,n=t&&t.forcedJSONParsing,i=!o&&this.responseType==="json";if(i||n&&q.isString(e)&&e.length)try{return JSON.parse(e)}catch(a){if(i)throw a.name==="SyntaxError"?es(a,this,"E_JSON_PARSE"):a}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};q.forEach(["delete","get","head"],function(e){re.headers[e]={}});q.forEach(["post","put","patch"],function(e){re.headers[e]=q.merge(ts)});jt.exports=re});var Rt=j((Ls,Nt)=>{"use strict";var ss=L(),os=G();Nt.exports=function(e,t,o){var n=this||os;return ss.forEach(o,function(a){e=a.call(n,e,t)}),e}});var xe=j((Fs,Pt)=>{"use strict";Pt.exports=function(e){return!!(e&&e.__CANCEL__)}});var Ut=j((Bs,qt)=>{"use strict";var It=L(),Se=Rt(),is=xe(),as=G(),us=V();function Ee(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new us("canceled")}qt.exports=function(e){Ee(e),e.headers=e.headers||{},e.data=Se.call(e,e.data,e.headers,e.transformRequest),e.headers=It.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),It.forEach(["delete","get","head","post","put","patch","common"],function(n){delete e.headers[n]});var t=e.adapter||as.adapter;return t(e).then(function(n){return Ee(e),n.data=Se.call(e,n.data,n.headers,e.transformResponse),n},function(n){return is(n)||(Ee(e),n&&n.response&&(n.response.data=Se.call(e,n.response.data,n.response.headers,e.transformResponse))),Promise.reject(n)})}});var ke=j((_s,Lt)=>{"use strict";var _=L();Lt.exports=function(e,t){t=t||{};var o={};function n(s,p){return _.isPlainObject(s)&&_.isPlainObject(p)?_.merge(s,p):_.isPlainObject(p)?_.merge({},p):_.isArray(p)?p.slice():p}function i(s){if(_.isUndefined(t[s])){if(!_.isUndefined(e[s]))return n(void 0,e[s])}else return n(e[s],t[s])}function a(s){if(!_.isUndefined(t[s]))return n(void 0,t[s])}function c(s){if(_.isUndefined(t[s])){if(!_.isUndefined(e[s]))return n(void 0,e[s])}else return n(void 0,t[s])}function u(s){if(s in t)return n(e[s],t[s]);if(s in e)return n(void 0,e[s])}var l={url:a,method:a,data:a,baseURL:c,transformRequest:c,transformResponse:c,paramsSerializer:c,timeout:c,timeoutMessage:c,withCredentials:c,adapter:c,responseType:c,xsrfCookieName:c,xsrfHeaderName:c,onUploadProgress:c,onDownloadProgress:c,decompress:c,maxContentLength:c,maxBodyLength:c,transport:c,httpAgent:c,httpsAgent:c,cancelToken:c,socketPath:c,responseEncoding:c,validateStatus:u};return _.forEach(Object.keys(e).concat(Object.keys(t)),function(p){var h=l[p]||i,x=h(p);_.isUndefined(x)&&h!==u||(o[p]=x)}),o}});var Ce=j((Ds,Ft)=>{Ft.exports={version:"0.23.0"}});var Dt=j((Hs,_t)=>{"use strict";var cs=Ce().version,Te={};["object","boolean","number","function","string","symbol"].forEach(function(r,e){Te[r]=function(o){return typeof o===r||"a"+(e<1?"n ":" ")+r}});var Bt={};Te.transitional=function(e,t,o){function n(i,a){return"[Axios v"+cs+"] Transitional option '"+i+"'"+a+(o?". "+o:"")}return function(i,a,c){if(e===!1)throw new Error(n(a," has been removed"+(t?" in "+t:"")));return t&&!Bt[a]&&(Bt[a]=!0,console.warn(n(a," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,a,c):!0}};function ls(r,e,t){if(typeof r!="object")throw new TypeError("options must be an object");for(var o=Object.keys(r),n=o.length;n-- >0;){var i=o[n],a=e[i];if(a){var c=r[i],u=c===void 0||a(c,i,r);if(u!==!0)throw new TypeError("option "+i+" must be "+u);continue}if(t!==!0)throw Error("Unknown option "+i)}}_t.exports={assertOptions:ls,validators:Te}});var Vt=j((Ms,zt)=>{"use strict";var Jt=L(),fs=de(),Ht=ot(),Mt=Ut(),ne=ke(),$t=Dt(),$=$t.validators;function W(r){this.defaults=r,this.interceptors={request:new Ht,response:new Ht}}W.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=ne(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;t!==void 0&&$t.assertOptions(t,{silentJSONParsing:$.transitional($.boolean),forcedJSONParsing:$.transitional($.boolean),clarifyTimeoutError:$.transitional($.boolean)},!1);var o=[],n=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(e)===!1||(n=n&&h.synchronous,o.unshift(h.fulfilled,h.rejected))});var i=[];this.interceptors.response.forEach(function(h){i.push(h.fulfilled,h.rejected)});var a;if(!n){var c=[Mt,void 0];for(Array.prototype.unshift.apply(c,o),c=c.concat(i),a=Promise.resolve(e);c.length;)a=a.then(c.shift(),c.shift());return a}for(var u=e;o.length;){var l=o.shift(),s=o.shift();try{u=l(u)}catch(p){s(p);break}}try{a=Mt(u)}catch(p){return Promise.reject(p)}for(;i.length;)a=a.then(i.shift(),i.shift());return a};W.prototype.getUri=function(e){return e=ne(this.defaults,e),fs(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};Jt.forEach(["delete","get","head","options"],function(e){W.prototype[e]=function(t,o){return this.request(ne(o||{},{method:e,url:t,data:(o||{}).data}))}});Jt.forEach(["post","put","patch"],function(e){W.prototype[e]=function(t,o,n){return this.request(ne(n||{},{method:e,url:t,data:o}))}});zt.exports=W});var Wt=j((Js,Gt)=>{"use strict";var hs=V();function z(r){if(typeof r!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(n){e=n});var t=this;this.promise.then(function(o){if(!!t._listeners){var n,i=t._listeners.length;for(n=0;n<i;n++)t._listeners[n](o);t._listeners=null}}),this.promise.then=function(o){var n,i=new Promise(function(a){t.subscribe(a),n=a}).then(o);return i.cancel=function(){t.unsubscribe(n)},i},r(function(n){t.reason||(t.reason=new hs(n),e(t.reason))})}z.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};z.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};z.prototype.unsubscribe=function(e){if(!!this._listeners){var t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}};z.source=function(){var e,t=new z(function(n){e=n});return{token:t,cancel:e}};Gt.exports=z});var Kt=j(($s,Xt)=>{"use strict";Xt.exports=function(e){return function(o){return e.apply(null,o)}}});var Yt=j((zs,Qt)=>{"use strict";Qt.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var tr=j((Vs,Ae)=>{"use strict";var Zt=L(),ps=ce(),se=Vt(),ds=ke(),ms=G();function er(r){var e=new se(r),t=ps(se.prototype.request,e);return Zt.extend(t,se.prototype,e),Zt.extend(t,e),t.create=function(n){return er(ds(r,n))},t}var D=er(ms);D.Axios=se;D.Cancel=V();D.CancelToken=Wt();D.isCancel=xe();D.VERSION=Ce().version;D.all=function(e){return Promise.all(e)};D.spread=Kt();D.isAxiosError=Yt();Ae.exports=D;Ae.exports.default=D});var Oe=j((Gs,rr)=>{rr.exports=tr()});var hr=Object.create,ie=Object.defineProperty,pr=Object.getOwnPropertyDescriptor,dr=Object.getOwnPropertyNames,mr=Object.getPrototypeOf,gr=Object.prototype.hasOwnProperty,vr=r=>ie(r,"__esModule",{value:!0}),A=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),yr=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of dr(e))!gr.call(r,n)&&(t||n!=="default")&&ie(r,n,{get:()=>e[n],enumerable:!(o=pr(e,n))||o.enumerable});return r},qe=(r,e)=>yr(vr(ie(r!=null?hr(mr(r)):{},"default",!e&&r&&r.__esModule?{get:()=>r.default,enumerable:!0}:{value:r,enumerable:!0})),r),Ue=A((r,e)=>{"use strict";e.exports=function(t,o){return function(){for(var n=new Array(arguments.length),i=0;i<n.length;i++)n[i]=arguments[i];return t.apply(o,n)}}}),U=A((r,e)=>{"use strict";var t=Ue(),o=Object.prototype.toString;function n(f){return Array.isArray(f)}function i(f){return typeof f>"u"}function a(f){return f!==null&&!i(f)&&f.constructor!==null&&!i(f.constructor)&&typeof f.constructor.isBuffer=="function"&&f.constructor.isBuffer(f)}function c(f){return o.call(f)==="[object ArrayBuffer]"}function u(f){return o.call(f)==="[object FormData]"}function l(f){var C;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?C=ArrayBuffer.isView(f):C=f&&f.buffer&&c(f.buffer),C}function s(f){return typeof f=="string"}function p(f){return typeof f=="number"}function h(f){return f!==null&&typeof f=="object"}function x(f){if(o.call(f)!=="[object Object]")return!1;var C=Object.getPrototypeOf(f);return C===null||C===Object.prototype}function y(f){return o.call(f)==="[object Date]"}function S(f){return o.call(f)==="[object File]"}function b(f){return o.call(f)==="[object Blob]"}function T(f){return o.call(f)==="[object Function]"}function m(f){return h(f)&&T(f.pipe)}function g(f){return o.call(f)==="[object URLSearchParams]"}function d(f){return f.trim?f.trim():f.replace(/^\s+|\s+$/g,"")}function v(){return typeof navigator<"u"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window<"u"&&typeof document<"u"}function w(f,C){if(!(f===null||typeof f>"u"))if(typeof f!="object"&&(f=[f]),n(f))for(var R=0,I=f.length;R<I;R++)C.call(null,f[R],R,f);else for(var O in f)Object.prototype.hasOwnProperty.call(f,O)&&C.call(null,f[O],O,f)}function k(){var f={};function C(O,F){x(f[F])&&x(O)?f[F]=k(f[F],O):x(O)?f[F]=k({},O):n(O)?f[F]=O.slice():f[F]=O}for(var R=0,I=arguments.length;R<I;R++)w(arguments[R],C);return f}function E(f,C,R){return w(C,function(I,O){R&&typeof I=="function"?f[O]=t(I,R):f[O]=I}),f}function P(f){return f.charCodeAt(0)===65279&&(f=f.slice(1)),f}e.exports={isArray:n,isArrayBuffer:c,isBuffer:a,isFormData:u,isArrayBufferView:l,isString:s,isNumber:p,isObject:h,isPlainObject:x,isUndefined:i,isDate:y,isFile:S,isBlob:b,isFunction:T,isStream:m,isURLSearchParams:g,isStandardBrowserEnv:v,forEach:w,merge:k,extend:E,trim:d,stripBOM:P}}),Le=A((r,e)=>{"use strict";var t=U();function o(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(n,i,a){if(!i)return n;var c;if(a)c=a(i);else if(t.isURLSearchParams(i))c=i.toString();else{var u=[];t.forEach(i,function(s,p){s===null||typeof s>"u"||(t.isArray(s)?p=p+"[]":s=[s],t.forEach(s,function(h){t.isDate(h)?h=h.toISOString():t.isObject(h)&&(h=JSON.stringify(h)),u.push(o(p)+"="+o(h))}))}),c=u.join("&")}if(c){var l=n.indexOf("#");l!==-1&&(n=n.slice(0,l)),n+=(n.indexOf("?")===-1?"?":"&")+c}return n}}),br=A((r,e)=>{"use strict";var t=U();function o(){this.handlers=[]}o.prototype.use=function(n,i,a){return this.handlers.push({fulfilled:n,rejected:i,synchronous:a?a.synchronous:!1,runWhen:a?a.runWhen:null}),this.handlers.length-1},o.prototype.eject=function(n){this.handlers[n]&&(this.handlers[n]=null)},o.prototype.forEach=function(n){t.forEach(this.handlers,function(i){i!==null&&n(i)})},e.exports=o}),wr=A((r,e)=>{"use strict";var t=U();e.exports=function(o,n){t.forEach(o,function(i,a){a!==n&&a.toUpperCase()===n.toUpperCase()&&(o[n]=i,delete o[a])})}}),Fe=A((r,e)=>{"use strict";e.exports=function(t,o,n,i,a){return t.config=o,n&&(t.code=n),t.request=i,t.response=a,t.isAxiosError=!0,t.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},t}}),Be=A((r,e)=>{"use strict";var t=Fe();e.exports=function(o,n,i,a,c){var u=new Error(o);return t(u,n,i,a,c)}}),xr=A((r,e)=>{"use strict";var t=Be();e.exports=function(o,n,i){var a=i.config.validateStatus;!i.status||!a||a(i.status)?o(i):n(t("Request failed with status code "+i.status,i.config,null,i.request,i))}}),Sr=A((r,e)=>{"use strict";var t=U();e.exports=t.isStandardBrowserEnv()?function(){return{write:function(o,n,i,a,c,u){var l=[];l.push(o+"="+encodeURIComponent(n)),t.isNumber(i)&&l.push("expires="+new Date(i).toGMTString()),t.isString(a)&&l.push("path="+a),t.isString(c)&&l.push("domain="+c),u===!0&&l.push("secure"),document.cookie=l.join("; ")},read:function(o){var n=document.cookie.match(new RegExp("(^|;\\s*)("+o+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(o){this.write(o,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()}),Er=A((r,e)=>{"use strict";e.exports=function(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}}),kr=A((r,e)=>{"use strict";e.exports=function(t,o){return o?t.replace(/\/+$/,"")+"/"+o.replace(/^\/+/,""):t}}),Cr=A((r,e)=>{"use strict";var t=Er(),o=kr();e.exports=function(n,i){return n&&!t(i)?o(n,i):i}}),Tr=A((r,e)=>{"use strict";var t=U(),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(n){var i={},a,c,u;return n&&t.forEach(n.split(`
3
+ `),function(l){if(u=l.indexOf(":"),a=t.trim(l.substr(0,u)).toLowerCase(),c=t.trim(l.substr(u+1)),a){if(i[a]&&o.indexOf(a)>=0)return;a==="set-cookie"?i[a]=(i[a]?i[a]:[]).concat([c]):i[a]=i[a]?i[a]+", "+c:c}}),i}}),Ar=A((r,e)=>{"use strict";var t=U();e.exports=t.isStandardBrowserEnv()?function(){var o=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a"),i;function a(c){var u=c;return o&&(n.setAttribute("href",u),u=n.href),n.setAttribute("href",u),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return i=a(window.location.href),function(c){var u=t.isString(c)?a(c):c;return u.protocol===i.protocol&&u.host===i.host}}():function(){return function(){return!0}}()}),K=A((r,e)=>{"use strict";function t(o){this.message=o}t.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},t.prototype.__CANCEL__=!0,e.exports=t}),Ie=A((r,e)=>{"use strict";var t=U(),o=xr(),n=Sr(),i=Le(),a=Cr(),c=Tr(),u=Ar(),l=Be(),s=Q(),p=K();e.exports=function(h){return new Promise(function(x,y){var S=h.data,b=h.headers,T=h.responseType,m;function g(){h.cancelToken&&h.cancelToken.unsubscribe(m),h.signal&&h.signal.removeEventListener("abort",m)}t.isFormData(S)&&delete b["Content-Type"];var d=new XMLHttpRequest;if(h.auth){var v=h.auth.username||"",w=h.auth.password?unescape(encodeURIComponent(h.auth.password)):"";b.Authorization="Basic "+btoa(v+":"+w)}var k=a(h.baseURL,h.url);d.open(h.method.toUpperCase(),i(k,h.params,h.paramsSerializer),!0),d.timeout=h.timeout;function E(){if(d){var f="getAllResponseHeaders"in d?c(d.getAllResponseHeaders()):null,C=!T||T==="text"||T==="json"?d.responseText:d.response,R={data:C,status:d.status,statusText:d.statusText,headers:f,config:h,request:d};o(function(I){x(I),g()},function(I){y(I),g()},R),d=null}}if("onloadend"in d?d.onloadend=E:d.onreadystatechange=function(){!d||d.readyState!==4||d.status===0&&!(d.responseURL&&d.responseURL.indexOf("file:")===0)||setTimeout(E)},d.onabort=function(){!d||(y(l("Request aborted",h,"ECONNABORTED",d)),d=null)},d.onerror=function(){y(l("Network Error",h,null,d)),d=null},d.ontimeout=function(){var f=h.timeout?"timeout of "+h.timeout+"ms exceeded":"timeout exceeded",C=h.transitional||s.transitional;h.timeoutErrorMessage&&(f=h.timeoutErrorMessage),y(l(f,h,C.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",d)),d=null},t.isStandardBrowserEnv()){var P=(h.withCredentials||u(k))&&h.xsrfCookieName?n.read(h.xsrfCookieName):void 0;P&&(b[h.xsrfHeaderName]=P)}"setRequestHeader"in d&&t.forEach(b,function(f,C){typeof S>"u"&&C.toLowerCase()==="content-type"?delete b[C]:d.setRequestHeader(C,f)}),t.isUndefined(h.withCredentials)||(d.withCredentials=!!h.withCredentials),T&&T!=="json"&&(d.responseType=h.responseType),typeof h.onDownloadProgress=="function"&&d.addEventListener("progress",h.onDownloadProgress),typeof h.onUploadProgress=="function"&&d.upload&&d.upload.addEventListener("progress",h.onUploadProgress),(h.cancelToken||h.signal)&&(m=function(f){!d||(y(!f||f&&f.type?new p("canceled"):f),d.abort(),d=null)},h.cancelToken&&h.cancelToken.subscribe(m),h.signal&&(h.signal.aborted?m():h.signal.addEventListener("abort",m))),S||(S=null),d.send(S)})}}),Q=A((r,e)=>{"use strict";var t=U(),o=wr(),n=Fe(),i={"Content-Type":"application/x-www-form-urlencoded"};function a(s,p){!t.isUndefined(s)&&t.isUndefined(s["Content-Type"])&&(s["Content-Type"]=p)}function c(){var s;return(typeof XMLHttpRequest<"u"||typeof process<"u"&&Object.prototype.toString.call(process)==="[object process]")&&(s=Ie()),s}function u(s,p,h){if(t.isString(s))try{return(p||JSON.parse)(s),t.trim(s)}catch(x){if(x.name!=="SyntaxError")throw x}return(h||JSON.stringify)(s)}var l={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:c(),transformRequest:[function(s,p){return o(p,"Accept"),o(p,"Content-Type"),t.isFormData(s)||t.isArrayBuffer(s)||t.isBuffer(s)||t.isStream(s)||t.isFile(s)||t.isBlob(s)?s:t.isArrayBufferView(s)?s.buffer:t.isURLSearchParams(s)?(a(p,"application/x-www-form-urlencoded;charset=utf-8"),s.toString()):t.isObject(s)||p&&p["Content-Type"]==="application/json"?(a(p,"application/json"),u(s)):s}],transformResponse:[function(s){var p=this.transitional||l.transitional,h=p&&p.silentJSONParsing,x=p&&p.forcedJSONParsing,y=!h&&this.responseType==="json";if(y||x&&t.isString(s)&&s.length)try{return JSON.parse(s)}catch(S){if(y)throw S.name==="SyntaxError"?n(S,this,"E_JSON_PARSE"):S}return s}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(s){return s>=200&&s<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};t.forEach(["delete","get","head"],function(s){l.headers[s]={}}),t.forEach(["post","put","patch"],function(s){l.headers[s]=t.merge(i)}),e.exports=l}),Or=A((r,e)=>{"use strict";var t=U(),o=Q();e.exports=function(n,i,a){var c=this||o;return t.forEach(a,function(u){n=u.call(c,n,i)}),n}}),_e=A((r,e)=>{"use strict";e.exports=function(t){return!!(t&&t.__CANCEL__)}}),jr=A((r,e)=>{"use strict";var t=U(),o=Or(),n=_e(),i=Q(),a=K();function c(u){if(u.cancelToken&&u.cancelToken.throwIfRequested(),u.signal&&u.signal.aborted)throw new a("canceled")}e.exports=function(u){c(u),u.headers=u.headers||{},u.data=o.call(u,u.data,u.headers,u.transformRequest),u.headers=t.merge(u.headers.common||{},u.headers[u.method]||{},u.headers),t.forEach(["delete","get","head","post","put","patch","common"],function(s){delete u.headers[s]});var l=u.adapter||i.adapter;return l(u).then(function(s){return c(u),s.data=o.call(u,s.data,s.headers,u.transformResponse),s},function(s){return n(s)||(c(u),s&&s.response&&(s.response.data=o.call(u,s.response.data,s.response.headers,u.transformResponse))),Promise.reject(s)})}}),De=A((r,e)=>{"use strict";var t=U();e.exports=function(o,n){n=n||{};var i={};function a(h,x){return t.isPlainObject(h)&&t.isPlainObject(x)?t.merge(h,x):t.isPlainObject(x)?t.merge({},x):t.isArray(x)?x.slice():x}function c(h){if(t.isUndefined(n[h])){if(!t.isUndefined(o[h]))return a(void 0,o[h])}else return a(o[h],n[h])}function u(h){if(!t.isUndefined(n[h]))return a(void 0,n[h])}function l(h){if(t.isUndefined(n[h])){if(!t.isUndefined(o[h]))return a(void 0,o[h])}else return a(void 0,n[h])}function s(h){if(h in n)return a(o[h],n[h]);if(h in o)return a(void 0,o[h])}var p={url:u,method:u,data:u,baseURL:l,transformRequest:l,transformResponse:l,paramsSerializer:l,timeout:l,timeoutMessage:l,withCredentials:l,adapter:l,responseType:l,xsrfCookieName:l,xsrfHeaderName:l,onUploadProgress:l,onDownloadProgress:l,decompress:l,maxContentLength:l,maxBodyLength:l,transport:l,httpAgent:l,httpsAgent:l,cancelToken:l,socketPath:l,responseEncoding:l,validateStatus:s};return t.forEach(Object.keys(o).concat(Object.keys(n)),function(h){var x=p[h]||c,y=x(h);t.isUndefined(y)&&x!==s||(i[h]=y)}),i}}),He=A((r,e)=>{e.exports={version:"0.25.0"}}),Nr=A((r,e)=>{"use strict";var t=He().version,o={};["object","boolean","number","function","string","symbol"].forEach(function(a,c){o[a]=function(u){return typeof u===a||"a"+(c<1?"n ":" ")+a}});var n={};o.transitional=function(a,c,u){function l(s,p){return"[Axios v"+t+"] Transitional option '"+s+"'"+p+(u?". "+u:"")}return function(s,p,h){if(a===!1)throw new Error(l(p," has been removed"+(c?" in "+c:"")));return c&&!n[p]&&(n[p]=!0,console.warn(l(p," has been deprecated since v"+c+" and will be removed in the near future"))),a?a(s,p,h):!0}};function i(a,c,u){if(typeof a!="object")throw new TypeError("options must be an object");for(var l=Object.keys(a),s=l.length;s-- >0;){var p=l[s],h=c[p];if(h){var x=a[p],y=x===void 0||h(x,p,a);if(y!==!0)throw new TypeError("option "+p+" must be "+y);continue}if(u!==!0)throw Error("Unknown option "+p)}}e.exports={assertOptions:i,validators:o}}),Rr=A((r,e)=>{"use strict";var t=U(),o=Le(),n=br(),i=jr(),a=De(),c=Nr(),u=c.validators;function l(s){this.defaults=s,this.interceptors={request:new n,response:new n}}l.prototype.request=function(s,p){if(typeof s=="string"?(p=p||{},p.url=s):p=s||{},!p.url)throw new Error("Provided config url is not valid");p=a(this.defaults,p),p.method?p.method=p.method.toLowerCase():this.defaults.method?p.method=this.defaults.method.toLowerCase():p.method="get";var h=p.transitional;h!==void 0&&c.assertOptions(h,{silentJSONParsing:u.transitional(u.boolean),forcedJSONParsing:u.transitional(u.boolean),clarifyTimeoutError:u.transitional(u.boolean)},!1);var x=[],y=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(p)===!1||(y=y&&v.synchronous,x.unshift(v.fulfilled,v.rejected))});var S=[];this.interceptors.response.forEach(function(v){S.push(v.fulfilled,v.rejected)});var b;if(!y){var T=[i,void 0];for(Array.prototype.unshift.apply(T,x),T=T.concat(S),b=Promise.resolve(p);T.length;)b=b.then(T.shift(),T.shift());return b}for(var m=p;x.length;){var g=x.shift(),d=x.shift();try{m=g(m)}catch(v){d(v);break}}try{b=i(m)}catch(v){return Promise.reject(v)}for(;S.length;)b=b.then(S.shift(),S.shift());return b},l.prototype.getUri=function(s){if(!s.url)throw new Error("Provided config url is not valid");return s=a(this.defaults,s),o(s.url,s.params,s.paramsSerializer).replace(/^\?/,"")},t.forEach(["delete","get","head","options"],function(s){l.prototype[s]=function(p,h){return this.request(a(h||{},{method:s,url:p,data:(h||{}).data}))}}),t.forEach(["post","put","patch"],function(s){l.prototype[s]=function(p,h,x){return this.request(a(x||{},{method:s,url:p,data:h}))}}),e.exports=l}),Pr=A((r,e)=>{"use strict";var t=K();function o(n){if(typeof n!="function")throw new TypeError("executor must be a function.");var i;this.promise=new Promise(function(c){i=c});var a=this;this.promise.then(function(c){if(a._listeners){var u,l=a._listeners.length;for(u=0;u<l;u++)a._listeners[u](c);a._listeners=null}}),this.promise.then=function(c){var u,l=new Promise(function(s){a.subscribe(s),u=s}).then(c);return l.cancel=function(){a.unsubscribe(u)},l},n(function(c){a.reason||(a.reason=new t(c),i(a.reason))})}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.prototype.subscribe=function(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]},o.prototype.unsubscribe=function(n){if(this._listeners){var i=this._listeners.indexOf(n);i!==-1&&this._listeners.splice(i,1)}},o.source=function(){var n,i=new o(function(a){n=a});return{token:i,cancel:n}},e.exports=o}),Ir=A((r,e)=>{"use strict";e.exports=function(t){return function(o){return t.apply(null,o)}}}),qr=A((r,e)=>{"use strict";var t=U();e.exports=function(o){return t.isObject(o)&&o.isAxiosError===!0}}),Ur=A((r,e)=>{"use strict";var t=U(),o=Ue(),n=Rr(),i=De(),a=Q();function c(l){var s=new n(l),p=o(n.prototype.request,s);return t.extend(p,n.prototype,s),t.extend(p,s),p.create=function(h){return c(i(l,h))},p}var u=c(a);u.Axios=n,u.Cancel=K(),u.CancelToken=Pr(),u.isCancel=_e(),u.VERSION=He().version,u.all=function(l){return Promise.all(l)},u.spread=Ir(),u.isAxiosError=qr(),e.exports=u,e.exports.default=u}),Lr=A((r,e)=>{e.exports=Ur()}),Fr=A((r,e)=>{"use strict";e.exports=t=>encodeURIComponent(t).replace(/[!'()*]/g,o=>`%${o.charCodeAt(0).toString(16).toUpperCase()}`)}),Br=A((r,e)=>{"use strict";var t="%[a-f0-9]{2}",o=new RegExp(t,"gi"),n=new RegExp("("+t+")+","gi");function i(u,l){try{return decodeURIComponent(u.join(""))}catch{}if(u.length===1)return u;l=l||1;var s=u.slice(0,l),p=u.slice(l);return Array.prototype.concat.call([],i(s),i(p))}function a(u){try{return decodeURIComponent(u)}catch{for(var l=u.match(o),s=1;s<l.length;s++)u=i(l,s).join(""),l=u.match(o);return u}}function c(u){for(var l={"%FE%FF":"\uFFFD\uFFFD","%FF%FE":"\uFFFD\uFFFD"},s=n.exec(u);s;){try{l[s[0]]=decodeURIComponent(s[0])}catch{var p=a(s[0]);p!==s[0]&&(l[s[0]]=p)}s=n.exec(u)}l["%C2"]="\uFFFD";for(var h=Object.keys(l),x=0;x<h.length;x++){var y=h[x];u=u.replace(new RegExp(y,"g"),l[y])}return u}e.exports=function(u){if(typeof u!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof u+"`");try{return u=u.replace(/\+/g," "),decodeURIComponent(u)}catch{return c(u)}}}),_r=A((r,e)=>{"use strict";e.exports=(t,o)=>{if(!(typeof t=="string"&&typeof o=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(o==="")return[t];let n=t.indexOf(o);return n===-1?[t]:[t.slice(0,n),t.slice(n+o.length)]}}),Dr=A((r,e)=>{"use strict";e.exports=function(t,o){for(var n={},i=Object.keys(t),a=Array.isArray(o),c=0;c<i.length;c++){var u=i[c],l=t[u];(a?o.indexOf(u)!==-1:o(u,l,t))&&(n[u]=l)}return n}}),Hr=A(r=>{"use strict";var e=Fr(),t=Br(),o=_r(),n=Dr(),i=m=>m==null,a=Symbol("encodeFragmentIdentifier");function c(m){switch(m.arrayFormat){case"index":return g=>(d,v)=>{let w=d.length;return v===void 0||m.skipNull&&v===null||m.skipEmptyString&&v===""?d:v===null?[...d,[s(g,m),"[",w,"]"].join("")]:[...d,[s(g,m),"[",s(w,m),"]=",s(v,m)].join("")]};case"bracket":return g=>(d,v)=>v===void 0||m.skipNull&&v===null||m.skipEmptyString&&v===""?d:v===null?[...d,[s(g,m),"[]"].join("")]:[...d,[s(g,m),"[]=",s(v,m)].join("")];case"colon-list-separator":return g=>(d,v)=>v===void 0||m.skipNull&&v===null||m.skipEmptyString&&v===""?d:v===null?[...d,[s(g,m),":list="].join("")]:[...d,[s(g,m),":list=",s(v,m)].join("")];case"comma":case"separator":case"bracket-separator":{let g=m.arrayFormat==="bracket-separator"?"[]=":"=";return d=>(v,w)=>w===void 0||m.skipNull&&w===null||m.skipEmptyString&&w===""?v:(w=w===null?"":w,v.length===0?[[s(d,m),g,s(w,m)].join("")]:[[v,s(w,m)].join(m.arrayFormatSeparator)])}default:return g=>(d,v)=>v===void 0||m.skipNull&&v===null||m.skipEmptyString&&v===""?d:v===null?[...d,s(g,m)]:[...d,[s(g,m),"=",s(v,m)].join("")]}}function u(m){let g;switch(m.arrayFormat){case"index":return(d,v,w)=>{if(g=/\[(\d*)\]$/.exec(d),d=d.replace(/\[\d*\]$/,""),!g){w[d]=v;return}w[d]===void 0&&(w[d]={}),w[d][g[1]]=v};case"bracket":return(d,v,w)=>{if(g=/(\[\])$/.exec(d),d=d.replace(/\[\]$/,""),!g){w[d]=v;return}if(w[d]===void 0){w[d]=[v];return}w[d]=[].concat(w[d],v)};case"colon-list-separator":return(d,v,w)=>{if(g=/(:list)$/.exec(d),d=d.replace(/:list$/,""),!g){w[d]=v;return}if(w[d]===void 0){w[d]=[v];return}w[d]=[].concat(w[d],v)};case"comma":case"separator":return(d,v,w)=>{let k=typeof v=="string"&&v.includes(m.arrayFormatSeparator),E=typeof v=="string"&&!k&&p(v,m).includes(m.arrayFormatSeparator);v=E?p(v,m):v;let P=k||E?v.split(m.arrayFormatSeparator).map(f=>p(f,m)):v===null?v:p(v,m);w[d]=P};case"bracket-separator":return(d,v,w)=>{let k=/(\[\])$/.test(d);if(d=d.replace(/\[\]$/,""),!k){w[d]=v&&p(v,m);return}let E=v===null?[]:v.split(m.arrayFormatSeparator).map(P=>p(P,m));if(w[d]===void 0){w[d]=E;return}w[d]=[].concat(w[d],E)};default:return(d,v,w)=>{if(w[d]===void 0){w[d]=v;return}w[d]=[].concat(w[d],v)}}}function l(m){if(typeof m!="string"||m.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function s(m,g){return g.encode?g.strict?e(m):encodeURIComponent(m):m}function p(m,g){return g.decode?t(m):m}function h(m){return Array.isArray(m)?m.sort():typeof m=="object"?h(Object.keys(m)).sort((g,d)=>Number(g)-Number(d)).map(g=>m[g]):m}function x(m){let g=m.indexOf("#");return g!==-1&&(m=m.slice(0,g)),m}function y(m){let g="",d=m.indexOf("#");return d!==-1&&(g=m.slice(d)),g}function S(m){m=x(m);let g=m.indexOf("?");return g===-1?"":m.slice(g+1)}function b(m,g){return g.parseNumbers&&!Number.isNaN(Number(m))&&typeof m=="string"&&m.trim()!==""?m=Number(m):g.parseBooleans&&m!==null&&(m.toLowerCase()==="true"||m.toLowerCase()==="false")&&(m=m.toLowerCase()==="true"),m}function T(m,g){g=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},g),l(g.arrayFormatSeparator);let d=u(g),v=Object.create(null);if(typeof m!="string"||(m=m.trim().replace(/^[?#&]/,""),!m))return v;for(let w of m.split("&")){if(w==="")continue;let[k,E]=o(g.decode?w.replace(/\+/g," "):w,"=");E=E===void 0?null:["comma","separator","bracket-separator"].includes(g.arrayFormat)?E:p(E,g),d(p(k,g),E,v)}for(let w of Object.keys(v)){let k=v[w];if(typeof k=="object"&&k!==null)for(let E of Object.keys(k))k[E]=b(k[E],g);else v[w]=b(k,g)}return g.sort===!1?v:(g.sort===!0?Object.keys(v).sort():Object.keys(v).sort(g.sort)).reduce((w,k)=>{let E=v[k];return Boolean(E)&&typeof E=="object"&&!Array.isArray(E)?w[k]=h(E):w[k]=E,w},Object.create(null))}r.extract=S,r.parse=T,r.stringify=(m,g)=>{if(!m)return"";g=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},g),l(g.arrayFormatSeparator);let d=E=>g.skipNull&&i(m[E])||g.skipEmptyString&&m[E]==="",v=c(g),w={};for(let E of Object.keys(m))d(E)||(w[E]=m[E]);let k=Object.keys(w);return g.sort!==!1&&k.sort(g.sort),k.map(E=>{let P=m[E];return P===void 0?"":P===null?s(E,g):Array.isArray(P)?P.length===0&&g.arrayFormat==="bracket-separator"?s(E,g)+"[]":P.reduce(v(E),[]).join("&"):s(E,g)+"="+s(P,g)}).filter(E=>E.length>0).join("&")},r.parseUrl=(m,g)=>{g=Object.assign({decode:!0},g);let[d,v]=o(m,"#");return Object.assign({url:d.split("?")[0]||"",query:T(S(m),g)},g&&g.parseFragmentIdentifier&&v?{fragmentIdentifier:p(v,g)}:{})},r.stringifyUrl=(m,g)=>{g=Object.assign({encode:!0,strict:!0,[a]:!0},g);let d=x(m.url).split("?")[0]||"",v=r.extract(m.url),w=r.parse(v,{sort:!1}),k=Object.assign(w,m.query),E=r.stringify(k,g);E&&(E=`?${E}`);let P=y(m.url);return m.fragmentIdentifier&&(P=`#${g[a]?s(m.fragmentIdentifier,g):m.fragmentIdentifier}`),`${d}${E}${P}`},r.pick=(m,g,d)=>{d=Object.assign({parseFragmentIdentifier:!0,[a]:!1},d);let{url:v,query:w,fragmentIdentifier:k}=r.parseUrl(m,d);return r.stringifyUrl({url:v,query:n(w,g),fragmentIdentifier:k},d)},r.exclude=(m,g,d)=>{let v=Array.isArray(g)?w=>!g.includes(w):(w,k)=>!g(w,k);return r.pick(m,v,d)}}),Mr=qe(Lr()),Jr=500,$r=class{url;httpClient;accessToken;constructor({url:r=""}){this.url=r,this.httpClient=Mr.default.create({baseURL:this.url}),this.httpClient.interceptors.response.use(e=>e,e=>Promise.reject({message:e.response?.data?.message??e.message??JSON.stringify(e),status:e.response?.status??Jr}))}async signUpEmailPassword(r){try{return{data:(await this.httpClient.post("/signup/email-password",r)).data,error:null}}catch(e){return{data:null,error:e}}}async signInEmailPassword(r){try{return{data:(await this.httpClient.post("/signin/email-password",r)).data,error:null}}catch(e){return{data:null,error:e}}}async signInPasswordlessEmail(r){try{return{data:(await this.httpClient.post("/signin/passwordless/email",r)).data,error:null}}catch(e){return{data:null,error:e}}}async signInPasswordlessSms(r){try{return{data:(await this.httpClient.post("/signin/passwordless/sms",r)).data,error:null}}catch(e){return{data:null,error:e}}}async signInPasswordlessSmsOtp(r){try{return{data:(await this.httpClient.post("/signin/passwordless/sms/otp",r)).data,error:null}}catch(e){return{data:null,error:e}}}async signOut(r){try{return await this.httpClient.post("/signout",r),{error:null}}catch(e){return{error:e}}}async refreshToken(r){try{let e=await this.httpClient.post("/token",r);return{error:null,session:e.data}}catch(e){return{error:e,session:null}}}async resetPassword(r){try{return await this.httpClient.post("/user/password/reset",r),{error:null}}catch(e){return{error:e}}}async changePassword(r){try{return await this.httpClient.post("/user/password",r,{headers:{...this.generateAuthHeaders()}}),{error:null}}catch(e){return{error:e}}}async sendVerificationEmail(r){try{return await this.httpClient.post("/user/email/send-verification-email",r),{error:null}}catch(e){return{error:e}}}async changeEmail(r){try{return await this.httpClient.post("/user/email/change",r,{headers:{...this.generateAuthHeaders()}}),{error:null}}catch(e){return{error:e}}}async deanonymize(r){try{return await this.httpClient.post("/user/deanonymize",r),{error:null}}catch(e){return{error:e}}}async verifyEmail(r){try{return{data:(await this.httpClient.post("/user/email/verify",r)).data,error:null}}catch(e){return{data:null,error:e}}}setAccessToken(r){this.accessToken=r}generateAuthHeaders(){return this.accessToken?{Authorization:`Bearer ${this.accessToken}`}:null}},zr=qe(Hr()),H="nhostRefreshToken",X=()=>typeof window<"u",Vr=class{memory;constructor(){this.memory={}}setItem(r,e){this.memory[r]=e}getItem(r){return this.memory[r]}removeItem(r){delete this.memory[r]}},Me=class{api;onTokenChangedFunctions;onAuthChangedFunctions;refreshInterval;refreshIntervalTime;clientStorage;clientStorageType;url;autoRefreshToken;session;initAuthLoading;refreshSleepCheckInterval;refreshIntervalSleepCheckLastSample;sampleRate;constructor({url:r,autoRefreshToken:e=!0,autoLogin:t=!0,refreshIntervalTime:o,clientStorage:n,clientStorageType:i="web"}){this.refreshIntervalTime=o,n?this.clientStorage=n:this.clientStorage=X()?localStorage:new Vr,this.clientStorageType=i,this.onTokenChangedFunctions=[],this.onAuthChangedFunctions=[],this.refreshInterval,this.refreshSleepCheckInterval=0,this.refreshIntervalSleepCheckLastSample=Date.now(),this.sampleRate=2e3,this.url=r,this.autoRefreshToken=e,this.initAuthLoading=!0,this.session=null,this.api=new $r({url:this.url});let a=null,c=!1;if(t&&X()&&window.location){let u=zr.default.parse(window.location.toString().split("#")[1]);if("refreshToken"in u&&(a=u.refreshToken),"otp"in u&&"email"in u){let{otp:l,email:s}=u;this.signIn({otp:l,email:s}),c=!0}}!c&&t?this._autoLogin(a):a&&this._setItem(H,a)}async signUp(r){let{email:e,password:t}=r;if(e&&t){let{data:o,error:n}=await this.api.signUpEmailPassword(r);if(n)return{session:null,error:n};if(!o)return{session:null,error:{message:"An error occurred on sign up.",status:500}};let{session:i}=o;return i&&await this._setSession(i),{session:i,error:null}}return{session:null,error:{message:"Incorrect parameters",status:500}}}async signIn(r){if("provider"in r){let{provider:e}=r,t=`${this.url}/signin/provider/${e}`;return X()&&(window.location.href=t),{providerUrl:t,provider:e,session:null,mfa:null,error:null}}if("email"in r&&"password"in r){let{data:e,error:t}=await this.api.signInEmailPassword(r);if(t)return{session:null,mfa:null,error:t};if(!e)return{session:null,mfa:null,error:{message:"Incorrect Data",status:500}};let{session:o,mfa:n}=e;return o&&await this._setSession(o),{session:o,mfa:n,error:null}}if("email"in r&&!("otp"in r)){let{error:e}=await this.api.signInPasswordlessEmail(r);return e?{session:null,mfa:null,error:e}:{session:null,mfa:null,error:null}}if("phoneNumber"in r&&!("otp"in r)){let{error:e}=await this.api.signInPasswordlessSms(r);return e?{session:null,mfa:null,error:e}:{session:null,mfa:null,error:null}}if("otp"in r){let{data:e,error:t}=await this.api.signInPasswordlessSmsOtp(r);if(t)return{session:null,mfa:null,error:t};if(!e)return{session:null,mfa:null,error:{message:"Incorrect data",status:500}};let{session:o,mfa:n}=e;return o&&await this._setSession(o),{session:o,mfa:n,error:null}}return{session:null,mfa:null,error:{message:"Incorrect parameters",status:500}}}async signOut(r){let e=await this._getItem(H);this._clearSession();let{error:t}=await this.api.signOut({refreshToken:e,all:r?.all});return{error:t}}async verifyEmail(r){return await this.api.verifyEmail(r)}async resetPassword(r){let{error:e}=await this.api.resetPassword(r);return{error:e}}async changePassword(r){let{error:e}=await this.api.changePassword(r);return{error:e}}async sendVerificationEmail(r){let{error:e}=await this.api.sendVerificationEmail(r);return{error:e}}async changeEmail(r){let{error:e}=await this.api.changeEmail(r);return{error:e}}async deanonymize(r){let{error:e}=await this.api.deanonymize(r);return{error:e}}onTokenChanged(r){this.onTokenChangedFunctions.push(r);let e=this.onTokenChangedFunctions.length-1;return()=>{try{this.onTokenChangedFunctions[e]=()=>{}}catch{console.warn("Unable to unsubscribe onTokenChanged function. Maybe the functions is already unsubscribed?")}}}onAuthStateChanged(r){this.onAuthChangedFunctions.push(r);let e=this.onAuthChangedFunctions.length-1;return()=>{try{this.onAuthChangedFunctions[e]=()=>{}}catch{console.warn("Unable to unsubscribe onAuthStateChanged function. Maybe you already did?")}}}isAuthenticated(){return this.session!==null}async isAuthenticatedAsync(){return new Promise(r=>{if(!this.initAuthLoading)r(this.isAuthenticated());else{let e=this.onAuthStateChanged((t,o)=>{r(t==="SIGNED_IN"),e()})}})}getAuthenticationStatus(){return this.initAuthLoading?{isAuthenticated:!1,isLoading:!0}:{isAuthenticated:this.session!==null,isLoading:!1}}getJWTToken(){return this.getAccessToken()}getAccessToken(){if(this.session)return this.session.accessToken}async refreshSession(r){let e=r||await this._getItem(H);return e||console.warn("no refresh token found. No way of refreshing session"),this._refreshTokens(e)}getSession(){return this.session}getUser(){return this.session?this.session.user:null}async _setItem(r,e){if(typeof e!="string"){console.error('value is not of type "string"');return}switch(this.clientStorageType){case"web":if(typeof this.clientStorage.setItem!="function"){console.error("this.clientStorage.setItem is not a function");break}this.clientStorage.setItem(r,e);break;case"custom":case"react-native":if(typeof this.clientStorage.setItem!="function"){console.error("this.clientStorage.setItem is not a function");break}await this.clientStorage.setItem(r,e);break;case"capacitor":if(typeof this.clientStorage.set!="function"){console.error("this.clientStorage.set is not a function");break}await this.clientStorage.set({key:r,value:e});break;case"expo-secure-storage":if(typeof this.clientStorage.setItemAsync!="function"){console.error("this.clientStorage.setItemAsync is not a function");break}this.clientStorage.setItemAsync(r,e);break;default:break}}async _getItem(r){switch(this.clientStorageType){case"web":if(typeof this.clientStorage.getItem!="function"){console.error("this.clientStorage.getItem is not a function");break}return this.clientStorage.getItem(r);case"custom":case"react-native":if(typeof this.clientStorage.getItem!="function"){console.error("this.clientStorage.getItem is not a function");break}return await this.clientStorage.getItem(r);case"capacitor":if(typeof this.clientStorage.get!="function"){console.error("this.clientStorage.get is not a function");break}return(await this.clientStorage.get({key:r})).value;case"expo-secure-storage":if(typeof this.clientStorage.getItemAsync!="function"){console.error("this.clientStorage.getItemAsync is not a function");break}return this.clientStorage.getItemAsync(r);default:return""}return""}async _removeItem(r){switch(this.clientStorageType){case"web":if(typeof this.clientStorage.removeItem!="function"){console.error("this.clientStorage.removeItem is not a function");break}return void this.clientStorage.removeItem(r);case"custom":case"react-native":if(typeof this.clientStorage.removeItem!="function"){console.error("this.clientStorage.removeItem is not a function");break}return void this.clientStorage.removeItem(r);case"capacitor":if(typeof this.clientStorage.remove!="function"){console.error("this.clientStorage.remove is not a function");break}await this.clientStorage.remove({key:r});break;case"expo-secure-storage":if(typeof this.clientStorage.deleteItemAsync!="function"){console.error("this.clientStorage.deleteItemAsync is not a function");break}this.clientStorage.deleteItemAsync(r);break;default:break}}_autoLogin(r){!X()||this._refreshTokens(r)}async _refreshTokens(r){let e=r||await this._getItem(H);if(!e){setTimeout(async()=>{await this._clearSession()},0);return}try{let{session:t,error:o}=await this.api.refreshToken({refreshToken:e});if(o&&o.status===401){await this._clearSession();return}if(!t)throw new Error("Invalid session data");await this._setSession(t),this.tokenChanged()}catch{}}tokenChanged(){for(let r of this.onTokenChangedFunctions)r(this.session)}authStateChanged({event:r,session:e}){r==="SIGNED_IN"&&e?this.api.setAccessToken(e.accessToken):this.api.setAccessToken(void 0);for(let t of this.onAuthChangedFunctions)t(r,e)}async _clearSession(){let{isLoading:r,isAuthenticated:e}=this.getAuthenticationStatus();this.session=null,this.initAuthLoading=!1,await this._removeItem(H),(r||e)&&(clearInterval(this.refreshInterval),clearInterval(this.refreshSleepCheckInterval),this.authStateChanged({event:"SIGNED_OUT",session:null}))}async _setSession(r){let{isAuthenticated:e}=this.getAuthenticationStatus();if(this.session=r,await this._setItem(H,r.refreshToken),this.autoRefreshToken&&!e){let t=r.accessTokenExpiresIn,o=this.refreshIntervalTime?this.refreshIntervalTime:Math.max(1,t-1);this.refreshInterval=setInterval(async()=>{let n=await this._getItem(H);await this._refreshTokens(n)},o*1e3),this.refreshIntervalSleepCheckLastSample=Date.now(),this.refreshSleepCheckInterval=setInterval(async()=>{if(Date.now()-this.refreshIntervalSleepCheckLastSample>=this.sampleRate*2){let n=await this._getItem(H);await this._refreshTokens(n)}this.refreshIntervalSleepCheckLastSample=Date.now()},this.sampleRate),this.authStateChanged({event:"SIGNED_IN",session:this.session})}this.initAuthLoading=!1}};var Gr=Object.create,ae=Object.defineProperty,Wr=Object.getOwnPropertyDescriptor,Xr=Object.getOwnPropertyNames,Kr=Object.getPrototypeOf,Qr=Object.prototype.hasOwnProperty,Yr=r=>ae(r,"__esModule",{value:!0}),N=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Zr=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Xr(e))!Qr.call(r,n)&&(t||n!=="default")&&ae(r,n,{get:()=>e[n],enumerable:!(o=Wr(e,n))||o.enumerable});return r},en=(r,e)=>Zr(Yr(ae(r!=null?Gr(Kr(r)):{},"default",!e&&r&&r.__esModule?{get:()=>r.default,enumerable:!0}:{value:r,enumerable:!0})),r),$e=N((r,e)=>{"use strict";e.exports=function(t,o){return function(){for(var n=new Array(arguments.length),i=0;i<n.length;i++)n[i]=arguments[i];return t.apply(o,n)}}}),B=N((r,e)=>{"use strict";var t=$e(),o=Object.prototype.toString;function n(f){return o.call(f)==="[object Array]"}function i(f){return typeof f>"u"}function a(f){return f!==null&&!i(f)&&f.constructor!==null&&!i(f.constructor)&&typeof f.constructor.isBuffer=="function"&&f.constructor.isBuffer(f)}function c(f){return o.call(f)==="[object ArrayBuffer]"}function u(f){return typeof FormData<"u"&&f instanceof FormData}function l(f){var C;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?C=ArrayBuffer.isView(f):C=f&&f.buffer&&f.buffer instanceof ArrayBuffer,C}function s(f){return typeof f=="string"}function p(f){return typeof f=="number"}function h(f){return f!==null&&typeof f=="object"}function x(f){if(o.call(f)!=="[object Object]")return!1;var C=Object.getPrototypeOf(f);return C===null||C===Object.prototype}function y(f){return o.call(f)==="[object Date]"}function S(f){return o.call(f)==="[object File]"}function b(f){return o.call(f)==="[object Blob]"}function T(f){return o.call(f)==="[object Function]"}function m(f){return h(f)&&T(f.pipe)}function g(f){return typeof URLSearchParams<"u"&&f instanceof URLSearchParams}function d(f){return f.trim?f.trim():f.replace(/^\s+|\s+$/g,"")}function v(){return typeof navigator<"u"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window<"u"&&typeof document<"u"}function w(f,C){if(!(f===null||typeof f>"u"))if(typeof f!="object"&&(f=[f]),n(f))for(var R=0,I=f.length;R<I;R++)C.call(null,f[R],R,f);else for(var O in f)Object.prototype.hasOwnProperty.call(f,O)&&C.call(null,f[O],O,f)}function k(){var f={};function C(O,F){x(f[F])&&x(O)?f[F]=k(f[F],O):x(O)?f[F]=k({},O):n(O)?f[F]=O.slice():f[F]=O}for(var R=0,I=arguments.length;R<I;R++)w(arguments[R],C);return f}function E(f,C,R){return w(C,function(I,O){R&&typeof I=="function"?f[O]=t(I,R):f[O]=I}),f}function P(f){return f.charCodeAt(0)===65279&&(f=f.slice(1)),f}e.exports={isArray:n,isArrayBuffer:c,isBuffer:a,isFormData:u,isArrayBufferView:l,isString:s,isNumber:p,isObject:h,isPlainObject:x,isUndefined:i,isDate:y,isFile:S,isBlob:b,isFunction:T,isStream:m,isURLSearchParams:g,isStandardBrowserEnv:v,forEach:w,merge:k,extend:E,trim:d,stripBOM:P}}),ze=N((r,e)=>{"use strict";var t=B();function o(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(n,i,a){if(!i)return n;var c;if(a)c=a(i);else if(t.isURLSearchParams(i))c=i.toString();else{var u=[];t.forEach(i,function(s,p){s===null||typeof s>"u"||(t.isArray(s)?p=p+"[]":s=[s],t.forEach(s,function(h){t.isDate(h)?h=h.toISOString():t.isObject(h)&&(h=JSON.stringify(h)),u.push(o(p)+"="+o(h))}))}),c=u.join("&")}if(c){var l=n.indexOf("#");l!==-1&&(n=n.slice(0,l)),n+=(n.indexOf("?")===-1?"?":"&")+c}return n}}),tn=N((r,e)=>{"use strict";var t=B();function o(){this.handlers=[]}o.prototype.use=function(n,i,a){return this.handlers.push({fulfilled:n,rejected:i,synchronous:a?a.synchronous:!1,runWhen:a?a.runWhen:null}),this.handlers.length-1},o.prototype.eject=function(n){this.handlers[n]&&(this.handlers[n]=null)},o.prototype.forEach=function(n){t.forEach(this.handlers,function(i){i!==null&&n(i)})},e.exports=o}),rn=N((r,e)=>{"use strict";var t=B();e.exports=function(o,n){t.forEach(o,function(i,a){a!==n&&a.toUpperCase()===n.toUpperCase()&&(o[n]=i,delete o[a])})}}),Ve=N((r,e)=>{"use strict";e.exports=function(t,o,n,i,a){return t.config=o,n&&(t.code=n),t.request=i,t.response=a,t.isAxiosError=!0,t.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},t}}),Ge=N((r,e)=>{"use strict";var t=Ve();e.exports=function(o,n,i,a,c){var u=new Error(o);return t(u,n,i,a,c)}}),nn=N((r,e)=>{"use strict";var t=Ge();e.exports=function(o,n,i){var a=i.config.validateStatus;!i.status||!a||a(i.status)?o(i):n(t("Request failed with status code "+i.status,i.config,null,i.request,i))}}),sn=N((r,e)=>{"use strict";var t=B();e.exports=t.isStandardBrowserEnv()?function(){return{write:function(o,n,i,a,c,u){var l=[];l.push(o+"="+encodeURIComponent(n)),t.isNumber(i)&&l.push("expires="+new Date(i).toGMTString()),t.isString(a)&&l.push("path="+a),t.isString(c)&&l.push("domain="+c),u===!0&&l.push("secure"),document.cookie=l.join("; ")},read:function(o){var n=document.cookie.match(new RegExp("(^|;\\s*)("+o+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(o){this.write(o,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()}),on=N((r,e)=>{"use strict";e.exports=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)}}),an=N((r,e)=>{"use strict";e.exports=function(t,o){return o?t.replace(/\/+$/,"")+"/"+o.replace(/^\/+/,""):t}}),un=N((r,e)=>{"use strict";var t=on(),o=an();e.exports=function(n,i){return n&&!t(i)?o(n,i):i}}),cn=N((r,e)=>{"use strict";var t=B(),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(n){var i={},a,c,u;return n&&t.forEach(n.split(`
4
+ `),function(l){if(u=l.indexOf(":"),a=t.trim(l.substr(0,u)).toLowerCase(),c=t.trim(l.substr(u+1)),a){if(i[a]&&o.indexOf(a)>=0)return;a==="set-cookie"?i[a]=(i[a]?i[a]:[]).concat([c]):i[a]=i[a]?i[a]+", "+c:c}}),i}}),ln=N((r,e)=>{"use strict";var t=B();e.exports=t.isStandardBrowserEnv()?function(){var o=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a"),i;function a(c){var u=c;return o&&(n.setAttribute("href",u),u=n.href),n.setAttribute("href",u),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return i=a(window.location.href),function(c){var u=t.isString(c)?a(c):c;return u.protocol===i.protocol&&u.host===i.host}}():function(){return function(){return!0}}()}),Je=N((r,e)=>{"use strict";var t=B(),o=nn(),n=sn(),i=ze(),a=un(),c=cn(),u=ln(),l=Ge();e.exports=function(s){return new Promise(function(p,h){var x=s.data,y=s.headers,S=s.responseType;t.isFormData(x)&&delete y["Content-Type"];var b=new XMLHttpRequest;if(s.auth){var T=s.auth.username||"",m=s.auth.password?unescape(encodeURIComponent(s.auth.password)):"";y.Authorization="Basic "+btoa(T+":"+m)}var g=a(s.baseURL,s.url);b.open(s.method.toUpperCase(),i(g,s.params,s.paramsSerializer),!0),b.timeout=s.timeout;function d(){if(b){var w="getAllResponseHeaders"in b?c(b.getAllResponseHeaders()):null,k=!S||S==="text"||S==="json"?b.responseText:b.response,E={data:k,status:b.status,statusText:b.statusText,headers:w,config:s,request:b};o(p,h,E),b=null}}if("onloadend"in b?b.onloadend=d:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(d)},b.onabort=function(){!b||(h(l("Request aborted",s,"ECONNABORTED",b)),b=null)},b.onerror=function(){h(l("Network Error",s,null,b)),b=null},b.ontimeout=function(){var w="timeout of "+s.timeout+"ms exceeded";s.timeoutErrorMessage&&(w=s.timeoutErrorMessage),h(l(w,s,s.transitional&&s.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",b)),b=null},t.isStandardBrowserEnv()){var v=(s.withCredentials||u(g))&&s.xsrfCookieName?n.read(s.xsrfCookieName):void 0;v&&(y[s.xsrfHeaderName]=v)}"setRequestHeader"in b&&t.forEach(y,function(w,k){typeof x>"u"&&k.toLowerCase()==="content-type"?delete y[k]:b.setRequestHeader(k,w)}),t.isUndefined(s.withCredentials)||(b.withCredentials=!!s.withCredentials),S&&S!=="json"&&(b.responseType=s.responseType),typeof s.onDownloadProgress=="function"&&b.addEventListener("progress",s.onDownloadProgress),typeof s.onUploadProgress=="function"&&b.upload&&b.upload.addEventListener("progress",s.onUploadProgress),s.cancelToken&&s.cancelToken.promise.then(function(w){!b||(b.abort(),h(w),b=null)}),x||(x=null),b.send(x)})}}),ue=N((r,e)=>{"use strict";var t=B(),o=rn(),n=Ve(),i={"Content-Type":"application/x-www-form-urlencoded"};function a(s,p){!t.isUndefined(s)&&t.isUndefined(s["Content-Type"])&&(s["Content-Type"]=p)}function c(){var s;return(typeof XMLHttpRequest<"u"||typeof process<"u"&&Object.prototype.toString.call(process)==="[object process]")&&(s=Je()),s}function u(s,p,h){if(t.isString(s))try{return(p||JSON.parse)(s),t.trim(s)}catch(x){if(x.name!=="SyntaxError")throw x}return(h||JSON.stringify)(s)}var l={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:c(),transformRequest:[function(s,p){return o(p,"Accept"),o(p,"Content-Type"),t.isFormData(s)||t.isArrayBuffer(s)||t.isBuffer(s)||t.isStream(s)||t.isFile(s)||t.isBlob(s)?s:t.isArrayBufferView(s)?s.buffer:t.isURLSearchParams(s)?(a(p,"application/x-www-form-urlencoded;charset=utf-8"),s.toString()):t.isObject(s)||p&&p["Content-Type"]==="application/json"?(a(p,"application/json"),u(s)):s}],transformResponse:[function(s){var p=this.transitional,h=p&&p.silentJSONParsing,x=p&&p.forcedJSONParsing,y=!h&&this.responseType==="json";if(y||x&&t.isString(s)&&s.length)try{return JSON.parse(s)}catch(S){if(y)throw S.name==="SyntaxError"?n(S,this,"E_JSON_PARSE"):S}return s}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(s){return s>=200&&s<300}};l.headers={common:{Accept:"application/json, text/plain, */*"}},t.forEach(["delete","get","head"],function(s){l.headers[s]={}}),t.forEach(["post","put","patch"],function(s){l.headers[s]=t.merge(i)}),e.exports=l}),fn=N((r,e)=>{"use strict";var t=B(),o=ue();e.exports=function(n,i,a){var c=this||o;return t.forEach(a,function(u){n=u.call(c,n,i)}),n}}),We=N((r,e)=>{"use strict";e.exports=function(t){return!!(t&&t.__CANCEL__)}}),hn=N((r,e)=>{"use strict";var t=B(),o=fn(),n=We(),i=ue();function a(c){c.cancelToken&&c.cancelToken.throwIfRequested()}e.exports=function(c){a(c),c.headers=c.headers||{},c.data=o.call(c,c.data,c.headers,c.transformRequest),c.headers=t.merge(c.headers.common||{},c.headers[c.method]||{},c.headers),t.forEach(["delete","get","head","post","put","patch","common"],function(l){delete c.headers[l]});var u=c.adapter||i.adapter;return u(c).then(function(l){return a(c),l.data=o.call(c,l.data,l.headers,c.transformResponse),l},function(l){return n(l)||(a(c),l&&l.response&&(l.response.data=o.call(c,l.response.data,l.response.headers,c.transformResponse))),Promise.reject(l)})}}),Xe=N((r,e)=>{"use strict";var t=B();e.exports=function(o,n){n=n||{};var i={},a=["url","method","data"],c=["headers","auth","proxy","params"],u=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],l=["validateStatus"];function s(y,S){return t.isPlainObject(y)&&t.isPlainObject(S)?t.merge(y,S):t.isPlainObject(S)?t.merge({},S):t.isArray(S)?S.slice():S}function p(y){t.isUndefined(n[y])?t.isUndefined(o[y])||(i[y]=s(void 0,o[y])):i[y]=s(o[y],n[y])}t.forEach(a,function(y){t.isUndefined(n[y])||(i[y]=s(void 0,n[y]))}),t.forEach(c,p),t.forEach(u,function(y){t.isUndefined(n[y])?t.isUndefined(o[y])||(i[y]=s(void 0,o[y])):i[y]=s(void 0,n[y])}),t.forEach(l,function(y){y in n?i[y]=s(o[y],n[y]):y in o&&(i[y]=s(void 0,o[y]))});var h=a.concat(c).concat(u).concat(l),x=Object.keys(o).concat(Object.keys(n)).filter(function(y){return h.indexOf(y)===-1});return t.forEach(x,p),i}}),pn=N((r,e)=>{e.exports={name:"axios",version:"0.21.4",description:"Promise based HTTP client for the browser and node.js",main:"index.js",scripts:{test:"grunt test",start:"node ./sandbox/server.js",build:"NODE_ENV=production grunt build",preversion:"npm test",version:"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",postversion:"git push && git push --tags",examples:"node ./examples/server.js",coveralls:"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",fix:"eslint --fix lib/**/*.js"},repository:{type:"git",url:"https://github.com/axios/axios.git"},keywords:["xhr","http","ajax","promise","node"],author:"Matt Zabriskie",license:"MIT",bugs:{url:"https://github.com/axios/axios/issues"},homepage:"https://axios-http.com",devDependencies:{coveralls:"^3.0.0","es6-promise":"^4.2.4",grunt:"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1",karma:"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2",minimist:"^1.2.0",mocha:"^8.2.1",sinon:"^4.5.0","terser-webpack-plugin":"^4.2.3",typescript:"^4.0.5","url-search-params":"^0.10.0",webpack:"^4.44.2","webpack-dev-server":"^3.11.0"},browser:{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},jsdelivr:"dist/axios.min.js",unpkg:"dist/axios.min.js",typings:"./index.d.ts",dependencies:{"follow-redirects":"^1.14.0"},bundlesize:[{path:"./dist/axios.min.js",threshold:"5kB"}]}}),dn=N((r,e)=>{"use strict";var t=pn(),o={};["object","boolean","number","function","string","symbol"].forEach(function(u,l){o[u]=function(s){return typeof s===u||"a"+(l<1?"n ":" ")+u}});var n={},i=t.version.split(".");function a(u,l){for(var s=l?l.split("."):i,p=u.split("."),h=0;h<3;h++){if(s[h]>p[h])return!0;if(s[h]<p[h])return!1}return!1}o.transitional=function(u,l,s){var p=l&&a(l);function h(x,y){return"[Axios v"+t.version+"] Transitional option '"+x+"'"+y+(s?". "+s:"")}return function(x,y,S){if(u===!1)throw new Error(h(y," has been removed in "+l));return p&&!n[y]&&(n[y]=!0,console.warn(h(y," has been deprecated since v"+l+" and will be removed in the near future"))),u?u(x,y,S):!0}};function c(u,l,s){if(typeof u!="object")throw new TypeError("options must be an object");for(var p=Object.keys(u),h=p.length;h-- >0;){var x=p[h],y=l[x];if(y){var S=u[x],b=S===void 0||y(S,x,u);if(b!==!0)throw new TypeError("option "+x+" must be "+b);continue}if(s!==!0)throw Error("Unknown option "+x)}}e.exports={isOlderVersion:a,assertOptions:c,validators:o}}),mn=N((r,e)=>{"use strict";var t=B(),o=ze(),n=tn(),i=hn(),a=Xe(),c=dn(),u=c.validators;function l(s){this.defaults=s,this.interceptors={request:new n,response:new n}}l.prototype.request=function(s){typeof s=="string"?(s=arguments[1]||{},s.url=arguments[0]):s=s||{},s=a(this.defaults,s),s.method?s.method=s.method.toLowerCase():this.defaults.method?s.method=this.defaults.method.toLowerCase():s.method="get";var p=s.transitional;p!==void 0&&c.assertOptions(p,{silentJSONParsing:u.transitional(u.boolean,"1.0.0"),forcedJSONParsing:u.transitional(u.boolean,"1.0.0"),clarifyTimeoutError:u.transitional(u.boolean,"1.0.0")},!1);var h=[],x=!0;this.interceptors.request.forEach(function(d){typeof d.runWhen=="function"&&d.runWhen(s)===!1||(x=x&&d.synchronous,h.unshift(d.fulfilled,d.rejected))});var y=[];this.interceptors.response.forEach(function(d){y.push(d.fulfilled,d.rejected)});var S;if(!x){var b=[i,void 0];for(Array.prototype.unshift.apply(b,h),b=b.concat(y),S=Promise.resolve(s);b.length;)S=S.then(b.shift(),b.shift());return S}for(var T=s;h.length;){var m=h.shift(),g=h.shift();try{T=m(T)}catch(d){g(d);break}}try{S=i(T)}catch(d){return Promise.reject(d)}for(;y.length;)S=S.then(y.shift(),y.shift());return S},l.prototype.getUri=function(s){return s=a(this.defaults,s),o(s.url,s.params,s.paramsSerializer).replace(/^\?/,"")},t.forEach(["delete","get","head","options"],function(s){l.prototype[s]=function(p,h){return this.request(a(h||{},{method:s,url:p,data:(h||{}).data}))}}),t.forEach(["post","put","patch"],function(s){l.prototype[s]=function(p,h,x){return this.request(a(x||{},{method:s,url:p,data:h}))}}),e.exports=l}),Ke=N((r,e)=>{"use strict";function t(o){this.message=o}t.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},t.prototype.__CANCEL__=!0,e.exports=t}),gn=N((r,e)=>{"use strict";var t=Ke();function o(n){if(typeof n!="function")throw new TypeError("executor must be a function.");var i;this.promise=new Promise(function(c){i=c});var a=this;n(function(c){a.reason||(a.reason=new t(c),i(a.reason))})}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.source=function(){var n,i=new o(function(a){n=a});return{token:i,cancel:n}},e.exports=o}),vn=N((r,e)=>{"use strict";e.exports=function(t){return function(o){return t.apply(null,o)}}}),yn=N((r,e)=>{"use strict";e.exports=function(t){return typeof t=="object"&&t.isAxiosError===!0}}),bn=N((r,e)=>{"use strict";var t=B(),o=$e(),n=mn(),i=Xe(),a=ue();function c(l){var s=new n(l),p=o(n.prototype.request,s);return t.extend(p,n.prototype,s),t.extend(p,s),p}var u=c(a);u.Axios=n,u.create=function(l){return c(i(u.defaults,l))},u.Cancel=Ke(),u.CancelToken=gn(),u.isCancel=We(),u.all=function(l){return Promise.all(l)},u.spread=vn(),u.isAxiosError=yn(),e.exports=u,e.exports.default=u}),wn=N((r,e)=>{e.exports=bn()}),xn=en(wn()),Sn=class{url;httpClient;accessToken;constructor({url:r}){this.url=r,this.httpClient=xn.default.create({baseURL:this.url})}async upload(r){try{return{fileMetadata:(await this.httpClient.post("/files",r.file,{headers:{...this.generateUploadHeaders(r),...this.generateAuthHeaders()}})).data,error:null}}catch(e){return{fileMetadata:null,error:e}}}async getPresignedUrl(r){try{let{fileId:e}=r;return{presignedUrl:(await this.httpClient.get(`/files/${e}/presignedurl`,{headers:{...this.generateAuthHeaders()}})).data,error:null}}catch(e){return{presignedUrl:null,error:e}}}async delete(r){try{let{fileId:e}=r;return await this.httpClient.delete(`/files/${e}`,{headers:{...this.generateAuthHeaders()}}),{error:null}}catch(e){return{error:e}}}setAccessToken(r){this.accessToken=r}generateUploadHeaders(r){let{bucketId:e,name:t,id:o}=r,n={};return e&&(n["x-nhost-bucket-id"]=e),o&&(n["x-nhost-file-id"]=o),t&&(n["x-nhost-file-name"]=t),n}generateAuthHeaders(){return this.accessToken?{Authorization:`Bearer ${this.accessToken}`}:null}},Qe=class{url;api;constructor({url:r}){this.url=r,this.api=new Sn({url:r})}async upload(r){let e=new FormData;e.append("file",r.file);let{fileMetadata:t,error:o}=await this.api.upload({...r,file:e});return o?{fileMetadata:null,error:o}:t?{fileMetadata:t,error:null}:{fileMetadata:null,error:new Error("Invalid file returned")}}getUrl(r){let{fileId:e}=r;return`${this.url}/files/${e}`}async getPresignedUrl(r){let{presignedUrl:e,error:t}=await this.api.getPresignedUrl(r);return t?{presignedUrl:null,error:t}:e?{presignedUrl:e,error:null}:{presignedUrl:null,error:new Error("Invalid file id")}}async delete(r){let{error:e}=await this.api.delete(r);return e?{error:e}:{error:null}}setAccessToken(r){this.api.setAccessToken(r)}};var nr=Pe(Oe()),je=class{instance;accessToken;constructor(e){let{url:t}=e;this.accessToken=null,this.instance=nr.default.create({baseURL:t})}async call(e,t,o){let n={...this.generateAccessTokenHeaders(),...o?.headers},i;try{i=await this.instance.post(e,t,{...o,headers:n})}catch(a){if(a instanceof Error)return{res:null,error:a}}return i?{res:i,error:null}:{res:null,error:new Error("Unable to make post request to funtion")}}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){if(!!this.accessToken)return{Authorization:`Bearer ${this.accessToken}`}}};var sr=Pe(Oe()),Ne=class{url;instance;accessToken;constructor(e){let{url:t}=e;this.url=t,this.accessToken=null,this.instance=sr.default.create({baseURL:t})}async request(e,t,o){let n={...o?.headers,...this.generateAccessTokenHeaders()},i="",a;try{a=(await this.instance.post("",{operationName:i||void 0,query:e,variables:t},{...o,headers:n})).data}catch(c){return c instanceof Error?{data:null,error:c}:(console.error(c),{data:null,error:new Error("Unable to get do GraphQL request")})}return typeof a!="object"||Array.isArray(a)||a===null?{data:null,error:new Error("incorrect response data from GraphQL server")}:(a=a,a.errors?{data:null,error:a.errors}:{data:a.data,error:null})}getUrl(){return this.url}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){if(!!this.accessToken)return{Authorization:`Bearer ${this.accessToken}`}}};var Re=class{auth;storage;functions;graphql;constructor(e){if(!e.backendUrl)throw new Error("Please specify a `backendUrl`. Docs: [todo]!");let{backendUrl:t,refreshIntervalTime:o,clientStorage:n,clientStorageType:i,autoRefreshToken:a,autoLogin:c}=e;this.auth=new Me({url:`${t}/v1/auth`,refreshIntervalTime:o,clientStorage:n,clientStorageType:i,autoRefreshToken:a,autoLogin:c}),this.storage=new Qe({url:`${t}/v1/storage`}),this.functions=new je({url:`${t}/v1/functions`}),this.graphql=new Ne({url:`${t}/v1/graphql`}),this.storage.setAccessToken(this.auth.getAccessToken()),this.functions.setAccessToken(this.auth.getAccessToken()),this.graphql.setAccessToken(this.auth.getAccessToken()),this.auth.onAuthStateChanged((u,l)=>{this.storage.setAccessToken(l?.accessToken),this.functions.setAccessToken(l?.accessToken),this.graphql.setAccessToken(l?.accessToken)}),this.auth.onTokenChanged(u=>{this.storage.setAccessToken(u?.accessToken),this.functions.setAccessToken(u?.accessToken),this.graphql.setAccessToken(u?.accessToken)})}};var fo=r=>new Re(r);export{Re as NhostClient,fo as createClient};
5
+ //# sourceMappingURL=index.es.js.map