pluga-plg 0.1.7 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "env": {
3
+ "commonjs": true,
4
+ "es6": true,
5
+ "node": true,
6
+ "jest": true
7
+ },
8
+ "extends": "airbnb-base",
9
+ "globals": {
10
+ "Atomics": "readonly",
11
+ "SharedArrayBuffer": "readonly"
12
+ },
13
+ "parserOptions": {
14
+ "ecmaVersion": 2022
15
+ },
16
+ "rules": {
17
+ "func-names": "off",
18
+ "no-await-in-loop": "off",
19
+ "no-console": "off",
20
+ "no-param-reassign": "off",
21
+ "no-restricted-syntax": "off",
22
+ "prefer-arrow-callback": "off"
23
+ }
24
+ }
package/README.md CHANGED
@@ -1,37 +1,273 @@
1
+
1
2
  # pluga-plg
2
3
 
3
4
  Pluga developer platform toolbox
4
5
 
5
- ### Erros customizados:
6
- Existem tipos específicos de erros que são tratados de diferentes maneiras dentro da plataforma da Pluga. Os detalhes sobre os tipos de erros suportados e como podem ser utilizados dentro do seu código estão descritos abaixo:
6
+ ## 📦 Setup
7
+
8
+ ```bash
9
+ npm install pluga-plg
10
+ ```
11
+ ## 🔧 Configuration
12
+
13
+ If you are using the `storageService` (>= 0.2.0), define the following in the environment:
14
+
15
+ ```env
16
+ AWS_S3_BUCKET=bucket-name
17
+ AWS_REGION=region
18
+ AWS_ACCESS_KEY_ID=access-key
19
+ AWS_SECRET_ACCESS_KEY=secret-key
20
+ ```
21
+ ## plg.errors
7
22
 
8
- #### AuthError
9
- Erro de autenticação, geralmente necessita de uma ação manual do cliente. Devem ser utilizados em casos onde problema de autenticação impede o funcionamento da integração.
23
+ ### Custom Errors:
24
+ There are specific types of errors that are handled differently within the Pluga platform. Details about the supported error types and how they can be used in your code are described below:
25
+
26
+ <details>
27
+ <summary>AuthError</summary>
28
+ Authentication error, usually requires manual action from the client. Should be used in cases where an authentication issue prevents the integration from functioning.
10
29
 
11
30
  ```javascript
12
31
  plg.errors.authError(message: String)
13
32
  ```
33
+ </details>
14
34
 
15
- #### Error
16
- Tipo genérico de erro, erros desse tipo deixam o evento em estado de falha. Devem ser utilizados quando o problema na integração exija uma correção manual por parte do cliente.
35
+ <details>
36
+ <summary>Error</summary>
37
+ Generic error type. Errors of this type put the event in a failed state. Should be used when an integration issue requires manual correction by the client.
17
38
 
18
39
  ```javascript
19
40
  plg.errors.error(message: String)
20
41
  ```
42
+ </details>
21
43
 
22
- #### RateLimitError
44
+ <details>
45
+ <summary>RateLimitError</summary>
23
46
 
24
- Erros desse tipo permitem que a Pluga realize o processamento dos eventos automaticamente em um momento futuro. Devem ser utilizados quando um recurso torna-se indisponível por conta do limite de uso por exemplo. Você deve fornecer o tempo necessário (em segundos) para que o recurso esteja disponível novamente.
47
+ Errors of this type allow Pluga to process the events automatically at a later time. Should be used when a resource becomes unavailable due to usage limits, for example. You must provide the necessary time (in seconds) for the resource to become available again.
25
48
 
26
49
  ```javascript
27
50
  plg.errors.rateLimitError(message: String, remaining: Integer(seconds))
28
51
  ```
52
+ </details>
29
53
 
30
- #### TransientError
54
+ <details>
55
+ <summary>TransientError</summary>
31
56
 
32
- Erros temporários ou transitórios que podem ocorrer por instabilidades, quedas, etc, e que não exigem nenhuma ação manual para o seu correto funcionamento. Eventos com erros desse tipo são reprocessados automaticamente pela plataforma da Pluga.
57
+ Temporary or transient errors that may occur due to instabilities, outages, etc., and do not require any manual action for proper functioning. Events with this type of error are automatically reprocessed by the Pluga platform.
33
58
 
34
59
  ```javascript
35
60
  plg.errors.transientError(message: String)
36
61
  ```
62
+ </details>
63
+
64
+ ## plg.files
65
+
66
+ ### plg.files.remote
67
+
68
+ The `files.remote` module provides integration with Amazon S3 for file management.
69
+
70
+ <details>
71
+ <summary>async upload</summary>
72
+
73
+ Send a local file to a S3 bucket.
74
+
75
+ ```
76
+ plg.files.remote.upload({ fileKey: String, filePath: String })
77
+ ```
78
+
79
+ #### Params
80
+
81
+ | Name | Type | Required | Description |
82
+ |----------|--------|-------------|-----------|
83
+ | fileKey | string | Yes | The unique key (name) for the file in the S3 bucket |
84
+ | filePath | string | Yes | The local path of the file to upload |
85
+
86
+ #### Return
87
+
88
+ ```json
89
+ {
90
+ "fileKey": "string"
91
+ }
92
+ ```
93
+
94
+ #### Errors
95
+
96
+
97
+ | type | When it occurs | Example message |
98
+ |--------------|---------------|-------------------|
99
+ | `Error` | Local path does not exist | - |
100
+ | `Error` | Internal errors in the AWS SDK | - |
101
+
102
+ </details>
103
+
104
+ <details>
105
+ <summary>async download </summary>
106
+
107
+ Download a file from an Amazon S3 bucket and save it to a local path.
108
+
109
+ ```
110
+ plg.files.remote.download({
111
+ fileKey: String,
112
+ pathToWrite: String
113
+ sizeLimit: Number
114
+ })
115
+ ```
116
+
117
+ #### Params
118
+
119
+ | Name | Type | Required | Description |
120
+ |-------------|----------|-------------|-----------|
121
+ | fileKey | string | Yes | The unique key (name) for the file in the S3 bucket |
122
+ | pathToWrite | string | Yes | Local path where the downloaded file will be saved |
123
+ | sizeLimit | number | No | Optional maximum allowed file size in bytes. If exceeded, the download will fail |
124
+
125
+ #### Return
126
+
127
+ ```json
128
+ {
129
+ "success": true
130
+ }
131
+ ```
132
+
133
+ #### Errors
134
+
135
+ | type | When it occurs | Example message |
136
+ |--------------|---------------|-------------------|
137
+ | `Error` | Local path does not exist | - |
138
+ | `Error` | Internal errors in the AWS SDK | - |
139
+ | `Error` | File exceeds size limit specified in the `sizeLimit` param | `File size limit exceeded. File size: ${fileSize} bytes, limit: ${sizeLimit} bytes.` |
140
+
141
+ </details>
142
+
143
+ <details>
144
+ <summary>async getSignedUrl</summary>
145
+
146
+ Generate a temporary signed URL to download a file from S3.
147
+
148
+ ```
149
+ plg.files.remote.getSignedUrl({
150
+ fileKey: String,
151
+ expiresIn: Number
152
+ })
153
+ ```
154
+
155
+ #### Params
156
+
157
+ | Name | Type | Required | Description |
158
+ |-----------|----------|-------------|-----------|
159
+ | fileKey | string | Yes | The unique key (name) for the file in the S3 bucket |
160
+ | expiresIn | number | No | Optional expiration time in seconds. Default: 1800 (30 minutes) |
161
+
162
+ #### Return
163
+
164
+ If the file exists:
165
+
166
+ ```json
167
+ {
168
+ "fileKey": "string",
169
+ "signedUrl": "string",
170
+ "expiresIn": "number"
171
+ }
172
+ ```
173
+
174
+ If file does not exists returns `null`
175
+
176
+ #### Errors
177
+
178
+ | type | When it occurs | Example message |
179
+ |--------------|---------------|-------------------|
180
+ | `Error` | Internal errors in the AWS SDK | - |
181
+
182
+ </details>
183
+
184
+ <details>
185
+ <summary>async fileExists </summary>
186
+
187
+ Checks if a file exists in S3 bucket.
188
+
189
+ ```
190
+ plg.files.remote.fileExists({
191
+ fileKey: String
192
+ })
193
+ ```
194
+
195
+ #### Params
196
+
197
+ | Name | Type | Required | Description |
198
+ |--------|----------|-------------|-----------|
199
+ | fileKey | string | Yes | The unique key (name) for the file in the S3 bucket |
200
+
201
+ #### Retorno
202
+
203
+ ```json
204
+ true // if the file exists
205
+ false // if the file does not exist
206
+ ```
207
+
208
+ #### Errors
209
+
210
+ | type | When it occurs | Example message |
211
+ |--------------|---------------|-------------------|
212
+ | `Error` | Internal errors in the AWS SDK, except for 404, which is treated as false | - |
213
+
214
+ </details>
215
+
216
+ ### plg.files.local
217
+
218
+ The `files.local` module enables local file handling.
219
+
220
+ <details>
221
+ <summary><strong>async downloadStream</strong></summary>
222
+
223
+ Download a file from a URL as a stream and save it locally.
224
+
225
+ ```javascript
226
+ plg.files.local.downloadStream({
227
+ pathToWrite: String,
228
+ downloadRequestParams: {
229
+ downloadUrl: String,
230
+ headers?: Object,
231
+ },
232
+ callbacks?: {
233
+ onData?: Function,
234
+ onEnd?: Function,
235
+ },
236
+ })
237
+ ```
238
+
239
+ #### Params
240
+
241
+ | Name | Type | Required | Description |
242
+ | --------------------------------- | -------- | -------- | ------------------------------------------------------------------------------------------------- |
243
+ | pathToWrite | string | Yes | Local path where the downloaded file will be saved. |
244
+ | downloadRequestParams | object | Yes | Object containing the download URL and optional HTTP headers. |
245
+ | downloadRequestParams.downloadUrl | string | Yes | Public URL used to download the file. |
246
+ | downloadRequestParams.headers | object | No | Optional HTTP headers to be sent with the download request. |
247
+ | callbacks | object | No | Optional callbacks executed during the download lifecycle. |
248
+ | callbacks.onData | function | No | Executed for each received data chunk. Receives `(dataChunk, currentDownloadedBytesCount)`. |
249
+ | callbacks.onEnd | function | No | Executed when the download finishes. If it returns a value, the promise resolves with that value. |
250
+
251
+
252
+ #### Return by default
253
+ ```json
254
+ {
255
+ "success": true
256
+ }
257
+ ```
258
+
259
+ - Note: If `onEndCallback` returns a value, the promise resolves with that value instead
260
+
261
+ #### Errors
262
+
263
+
264
+ | Type | When it occurs | Example |
265
+ | --------------------- | ------------------------------------------------------------------- | -------------------------------------------------------------- |
266
+ | `Error` | Local path to write does not exist or is not writable | — |
267
+ | `Error` | Download URL provided is not public or request fails | — |
268
+ | `onDataCallback` | Error thrown inside `callbacks.onData` | `{ "type": "onDataCallback", "error": <original error> }` |
269
+ | `onEndCallback` | Error thrown inside `callbacks.onEnd` | `{ "type": "onEndCallback", "error": <original error> }` |
270
+ | `StreamPipelineError` | Stream pipeline fails (connection drop, timeout, write error, etc.) | `{ "type": "StreamPipelineError", "error": <original error> }` |
271
+
37
272
 
273
+ </details>
@@ -0,0 +1,45 @@
1
+ const axios = require('../../../lib/axios');
2
+ const AxiosService = require('../../../lib/files/local/axiosService');
3
+
4
+ jest.mock('../../../lib/axios');
5
+
6
+ describe('AxiosService', () => {
7
+ let service;
8
+
9
+ beforeEach(() => {
10
+ jest.clearAllMocks();
11
+ service = new AxiosService();
12
+ });
13
+
14
+ it('downloads a file as stream using axios', async () => {
15
+ const fakeStream = { fake: 'stream' };
16
+
17
+ axios.mockResolvedValue({
18
+ data: fakeStream,
19
+ });
20
+
21
+ const params = {
22
+ downloadRequestParams: {
23
+ downloadUrl: 'https://example.com/file.txt',
24
+ headers: {
25
+ Authorization: 'Bearer token',
26
+ },
27
+ },
28
+ };
29
+
30
+ const result = await service.download(params);
31
+
32
+ expect(axios).toHaveBeenCalledWith({
33
+ method: 'get',
34
+ url: 'https://example.com/file.txt',
35
+ responseType: 'stream',
36
+ headers: {
37
+ Authorization: 'Bearer token',
38
+ },
39
+ });
40
+
41
+ expect(result).toEqual({
42
+ stream: fakeStream,
43
+ });
44
+ });
45
+ });
@@ -0,0 +1,151 @@
1
+ const fs = require('fs');
2
+ const {
3
+ S3Client,
4
+ PutObjectCommand,
5
+ GetObjectCommand,
6
+ } = require('@aws-sdk/client-s3');
7
+ const { getSignedUrl } = require('@aws-sdk/s3-request-presigner');
8
+ const { PassThrough } = require('stream');
9
+
10
+ const S3Service = require('../../../lib/files/remote/s3Service');
11
+
12
+ jest.mock('fs', () => ({
13
+ createReadStream: jest.fn(),
14
+ }));
15
+
16
+ jest.mock('@aws-sdk/client-s3', () => ({
17
+ S3Client: jest.fn(),
18
+ PutObjectCommand: jest.fn((params) => params),
19
+ GetObjectCommand: jest.fn((params) => params),
20
+ HeadObjectCommand: jest.fn((params) => params),
21
+ }));
22
+
23
+ jest.mock('@aws-sdk/s3-request-presigner', () => ({
24
+ getSignedUrl: jest.fn(),
25
+ }));
26
+
27
+ describe('S3Service', () => {
28
+ let mockSend;
29
+ let s3Service;
30
+
31
+ beforeEach(() => {
32
+ jest.clearAllMocks();
33
+
34
+ mockSend = jest.fn();
35
+ S3Client.mockImplementation(() => ({ send: mockSend }));
36
+
37
+ s3Service = new S3Service({
38
+ client: new S3Client(),
39
+ bucket: 'foo-bucket',
40
+ });
41
+ });
42
+
43
+ describe('upload', () => {
44
+ it('uploads file to S3', async () => {
45
+ const mockStream = {};
46
+ fs.createReadStream.mockReturnValue(mockStream);
47
+ mockSend.mockResolvedValue({});
48
+
49
+ const result = await s3Service.upload({
50
+ fileKey: 'foo',
51
+ filePath: '/tmp/bar',
52
+ });
53
+
54
+ expect(fs.createReadStream).toHaveBeenCalledWith('/tmp/bar');
55
+ expect(PutObjectCommand).toHaveBeenCalledWith({
56
+ Bucket: 'foo-bucket',
57
+ Key: 'foo',
58
+ Body: mockStream,
59
+ });
60
+ expect(result).toEqual({ fileKey: 'foo' });
61
+ });
62
+ });
63
+
64
+ describe('download', () => {
65
+ it('downloads and writes file to disk', async () => {
66
+ const mockReadStream = new PassThrough();
67
+ mockReadStream.end('foo bar');
68
+
69
+ mockSend.mockResolvedValue({
70
+ Body: mockReadStream,
71
+ ContentLength: 100,
72
+ });
73
+
74
+ const result = await s3Service.download({
75
+ fileKey: 'foo',
76
+ });
77
+
78
+ expect(GetObjectCommand).toHaveBeenCalledWith({
79
+ Bucket: 'foo-bucket',
80
+ Key: 'foo',
81
+ });
82
+
83
+ expect(result).toEqual({
84
+ stream: mockReadStream,
85
+ });
86
+ });
87
+
88
+ it('throws error when size exceeds limit', async () => {
89
+ mockSend.mockResolvedValue({
90
+ Body: {},
91
+ ContentLength: 9999,
92
+ });
93
+
94
+ await expect(
95
+ s3Service.download({
96
+ fileKey: 'foo',
97
+ pathToWrite: '/tmp/y',
98
+ sizeLimit: 10,
99
+ }),
100
+ ).rejects.toThrow('File size limit exceeded');
101
+ });
102
+ });
103
+
104
+ describe('fileExists', () => {
105
+ it('returns true if file exists', async () => {
106
+ mockSend.mockResolvedValue({});
107
+
108
+ const exists = await s3Service.fileExists({ fileKey: 'foo' });
109
+
110
+ expect(exists).toBe(true);
111
+ });
112
+
113
+ it('returns false if file does not exist', async () => {
114
+ const error = new Error('Not found');
115
+ error.name = 'NotFound';
116
+ mockSend.mockRejectedValue(error);
117
+
118
+ const exists = await s3Service.fileExists({ fileKey: 'foo' });
119
+
120
+ expect(exists).toBe(false);
121
+ });
122
+ });
123
+
124
+ describe('getSignedUrl', () => {
125
+ it('returns signedUrl if file exists', async () => {
126
+ mockSend.mockResolvedValue({});
127
+ getSignedUrl.mockResolvedValue('http://signed-url.com');
128
+
129
+ const result = await s3Service.getSignedUrl({
130
+ fileKey: 'foo',
131
+ expiresIn: 123,
132
+ });
133
+
134
+ expect(result).toEqual({
135
+ fileKey: 'foo',
136
+ signedUrl: 'http://signed-url.com',
137
+ expiresIn: 123,
138
+ });
139
+ });
140
+
141
+ it('returns null if file does not exist', async () => {
142
+ const error = new Error('Not found');
143
+ error.name = 'NotFound';
144
+ mockSend.mockRejectedValue(error);
145
+
146
+ const result = await s3Service.getSignedUrl({ fileKey: 'foo' });
147
+
148
+ expect(result).toBeNull();
149
+ });
150
+ });
151
+ });
@@ -0,0 +1,89 @@
1
+ const StorageService = require('../../lib/files/storageService');
2
+
3
+ describe('Storage service', () => {
4
+ let client;
5
+ let service;
6
+ const params = { foo: 'bar ' };
7
+ const successResp = { success: true };
8
+ let streamFileWriter;
9
+
10
+ beforeEach(() => {
11
+ client = {
12
+ upload: jest.fn(),
13
+ download: jest.fn(),
14
+ fileExists: jest.fn(),
15
+ getSignedUrl: jest.fn(),
16
+ };
17
+
18
+ service = new StorageService(client);
19
+ });
20
+
21
+ beforeEach(() => {
22
+ client = {
23
+ upload: jest.fn(),
24
+ download: jest.fn(),
25
+ getSignedUrl: jest.fn(),
26
+ fileExists: jest.fn(),
27
+ };
28
+
29
+ streamFileWriter = {
30
+ writeToDisk: jest.fn(),
31
+ };
32
+
33
+ service = new StorageService(client, streamFileWriter);
34
+ });
35
+
36
+ describe('upload', () => {
37
+ it('delegates upload to client', async () => {
38
+ client.upload.mockResolvedValue(successResp);
39
+
40
+ const response = await service.upload(params);
41
+
42
+ expect(client.upload).toHaveBeenCalledWith(params);
43
+
44
+ expect(response).toEqual(successResp);
45
+ });
46
+ });
47
+
48
+ describe('download', () => {
49
+ it('downloads stream from client and writes it to disk', async () => {
50
+ const stream = { fake: 'stream' };
51
+ const expectedResult = { success: true };
52
+
53
+ client.download.mockReturnValue({ stream });
54
+ streamFileWriter.writeToDisk.mockResolvedValue(expectedResult);
55
+
56
+ const result = await service.download(params);
57
+
58
+ expect(client.download).toHaveBeenCalledWith(params);
59
+ expect(streamFileWriter.writeToDisk).toHaveBeenCalledWith({
60
+ stream,
61
+ ...params,
62
+ });
63
+ expect(result).toBe(expectedResult);
64
+ });
65
+ });
66
+
67
+ describe('fileExists', () => {
68
+ it('delegates fileExists to client', async () => {
69
+ client.fileExists.mockResolvedValue(successResp);
70
+
71
+ const response = await service.fileExists(params);
72
+
73
+ expect(client.fileExists).toHaveBeenCalledWith(params);
74
+ expect(response).toBe(successResp);
75
+ });
76
+ });
77
+
78
+ describe('getSignedUrl', () => {
79
+ it('delegates getSignedUrl to client', async () => {
80
+ client.getSignedUrl.mockResolvedValue(successResp);
81
+
82
+ const response = await service.getSignedUrl(params);
83
+
84
+ expect(client.getSignedUrl).toHaveBeenCalledWith(params);
85
+
86
+ expect(response).toEqual(successResp);
87
+ });
88
+ });
89
+ });
@@ -0,0 +1,137 @@
1
+ const fs = require('fs');
2
+ const { PassThrough } = require('stream');
3
+
4
+ const StreamFileWriter = require('../../lib/files/streamFileWriter');
5
+
6
+ jest.mock('fs', () => ({
7
+ createWriteStream: jest.fn(),
8
+ }));
9
+
10
+ describe('Stream file writer', () => {
11
+ it('writes stream to disk successfully without callbacks', async () => {
12
+ const readStream = new PassThrough();
13
+ readStream.end('hello');
14
+
15
+ const writeStream = new PassThrough();
16
+ fs.createWriteStream.mockReturnValue(writeStream);
17
+
18
+ const result = await StreamFileWriter.writeToDisk({
19
+ stream: readStream,
20
+ pathToWrite: '/tmp/file.txt',
21
+ });
22
+
23
+ expect(fs.createWriteStream).toHaveBeenCalledWith('/tmp/file.txt');
24
+ expect(result).toEqual({ success: true });
25
+ });
26
+
27
+ describe('Callbacks', () => {
28
+ it('calls onData callback with accumulated bytes', async () => {
29
+ const readStream = new PassThrough();
30
+ const writeStream = new PassThrough();
31
+ fs.createWriteStream.mockReturnValue(writeStream);
32
+
33
+ const onData = jest.fn();
34
+
35
+ const promise = StreamFileWriter.writeToDisk({
36
+ stream: readStream,
37
+ pathToWrite: '/tmp/file.txt',
38
+ callbacks: { onData },
39
+ });
40
+
41
+ readStream.write(Buffer.from('foo'));
42
+ readStream.write(Buffer.from('bar'));
43
+ readStream.end();
44
+
45
+ await promise;
46
+
47
+ expect(onData).toHaveBeenNthCalledWith(1, expect.any(Buffer), 3);
48
+ expect(onData).toHaveBeenNthCalledWith(2, expect.any(Buffer), 6);
49
+ });
50
+
51
+ it('resolves with onEnd return value when provided', async () => {
52
+ const readStream = new PassThrough();
53
+ readStream.end('done');
54
+
55
+ const writeStream = new PassThrough();
56
+ fs.createWriteStream.mockReturnValue(writeStream);
57
+
58
+ const onEnd = jest.fn(() => ({ finished: true }));
59
+
60
+ const result = await StreamFileWriter.writeToDisk({
61
+ stream: readStream,
62
+ pathToWrite: '/tmp/file.txt',
63
+ callbacks: { onEnd },
64
+ });
65
+
66
+ expect(onEnd).toHaveBeenCalled();
67
+ expect(result).toEqual({ finished: true });
68
+ });
69
+ });
70
+
71
+ describe('Errors', () => {
72
+ it('throws typed error when onData throws', async () => {
73
+ const readStream = new PassThrough();
74
+ const writeStream = new PassThrough();
75
+ fs.createWriteStream.mockReturnValue(writeStream);
76
+
77
+ const onData = jest.fn(() => {
78
+ throw new Error('onData failed');
79
+ });
80
+
81
+ const promise = StreamFileWriter.writeToDisk({
82
+ stream: readStream,
83
+ pathToWrite: '/tmp/file.txt',
84
+ callbacks: { onData },
85
+ });
86
+
87
+ readStream.write(Buffer.from('boom'));
88
+
89
+ await expect(promise).rejects.toMatchObject({
90
+ type: 'onDataCallback',
91
+ });
92
+ });
93
+
94
+ it('throws typed error when onEnd throws', async () => {
95
+ const readStream = new PassThrough();
96
+ readStream.end('done');
97
+
98
+ const writeStream = new PassThrough();
99
+ fs.createWriteStream.mockReturnValue(writeStream);
100
+
101
+ const onEnd = jest.fn(() => {
102
+ throw new Error('onEnd failed');
103
+ });
104
+
105
+ await expect(
106
+ StreamFileWriter.writeToDisk({
107
+ stream: readStream,
108
+ pathToWrite: '/tmp/file.txt',
109
+ callbacks: { onEnd },
110
+ }),
111
+ ).rejects.toMatchObject({
112
+ type: 'onEndCallback',
113
+ });
114
+
115
+ expect(onEnd).toHaveBeenCalled();
116
+ });
117
+
118
+ it('wraps pipeline errors with StreamPipelineError', async () => {
119
+ const readStream = new PassThrough();
120
+
121
+ const writeStream = new PassThrough();
122
+ fs.createWriteStream.mockReturnValue(writeStream);
123
+
124
+ const pipelineError = new Error('pipeline failed');
125
+ writeStream.destroy(pipelineError);
126
+
127
+ await expect(
128
+ StreamFileWriter.writeToDisk({
129
+ stream: readStream,
130
+ pathToWrite: '/tmp/file.txt',
131
+ }),
132
+ ).rejects.toMatchObject({
133
+ type: 'StreamPipelineError',
134
+ });
135
+ });
136
+ });
137
+ });
package/index.js CHANGED
@@ -1,9 +1,11 @@
1
1
  const axios = require('./lib/axios');
2
2
  const errors = require('./lib/errors');
3
- const package = require('./package.json');
3
+ const files = require('./lib/files');
4
+ const packge = require('./package.json');
4
5
 
5
6
  module.exports = {
6
- axios: axios,
7
- errors: errors,
8
- version: package.version,
7
+ axios,
8
+ errors,
9
+ files,
10
+ version: packge.version,
9
11
  };
@@ -1,4 +1,4 @@
1
- const axios = require('./axios.min');
1
+ const axios = require('axios');
2
2
 
3
3
  const instance = axios.create();
4
4
  module.exports = instance;
@@ -0,0 +1,7 @@
1
+ const local = require('./local');
2
+ const remote = require('./remote');
3
+
4
+ module.exports = {
5
+ local,
6
+ remote,
7
+ };
@@ -0,0 +1,19 @@
1
+ /* eslint-disable class-methods-use-this */
2
+ const axios = require('../../axios');
3
+
4
+ class AxiosService {
5
+ async download({
6
+ downloadRequestParams: { downloadUrl, headers },
7
+ }) {
8
+ const res = await axios({
9
+ method: 'get',
10
+ url: downloadUrl,
11
+ responseType: 'stream',
12
+ headers,
13
+ });
14
+
15
+ return { stream: res.data };
16
+ }
17
+ }
18
+
19
+ module.exports = AxiosService;
@@ -0,0 +1,10 @@
1
+ const StorageService = require('../storageService');
2
+ const AxiosService = require('./axiosService');
3
+
4
+ const service = new StorageService(new AxiosService());
5
+
6
+ async function downloadStream(params) {
7
+ return service.download(params);
8
+ }
9
+
10
+ module.exports = { downloadStream };
@@ -0,0 +1,7 @@
1
+ const StorageService = require('../storageService');
2
+ const S3Service = require('./s3Service');
3
+
4
+ const s3Service = new S3Service();
5
+ const storageService = new StorageService(s3Service);
6
+
7
+ module.exports = storageService;
@@ -0,0 +1,93 @@
1
+ /* eslint-disable class-methods-use-this */
2
+ const fs = require('fs');
3
+ const {
4
+ S3Client,
5
+ PutObjectCommand,
6
+ GetObjectCommand,
7
+ HeadObjectCommand,
8
+ } = require('@aws-sdk/client-s3');
9
+ const { getSignedUrl } = require('@aws-sdk/s3-request-presigner');
10
+
11
+ class S3Service {
12
+ #DEFAULT_URL_EXPIRATION_IN_SECONDS = 30 * 60;
13
+
14
+ #client;
15
+
16
+ #bucket;
17
+
18
+ constructor({ client = null, bucket = null } = {}) {
19
+ this.#bucket = bucket || process.env.AWS_S3_BUCKET;
20
+ this.#client = client || new S3Client({
21
+ region: process.env.AWS_REGION,
22
+ credentials: {
23
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID,
24
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
25
+ },
26
+ });
27
+ }
28
+
29
+ async upload({ fileKey, filePath }) {
30
+ const fileStream = fs.createReadStream(filePath);
31
+ await this.#runCommand(
32
+ new PutObjectCommand({
33
+ Bucket: this.#bucket,
34
+ Key: fileKey,
35
+ Body: fileStream,
36
+ }),
37
+ );
38
+ return { fileKey };
39
+ }
40
+
41
+ async download({ fileKey, sizeLimit }) {
42
+ const file = await this.#runCommand(
43
+ new GetObjectCommand({ Bucket: this.#bucket, Key: fileKey }),
44
+ );
45
+
46
+ this.#validateSize(file.ContentLength, sizeLimit);
47
+ return { stream: file.Body };
48
+ }
49
+
50
+ async getSignedUrl({ fileKey, expiresIn = this.#DEFAULT_URL_EXPIRATION_IN_SECONDS }) {
51
+ if (await this.fileExists({ fileKey })) {
52
+ const command = new GetObjectCommand({ Bucket: this.#bucket, Key: fileKey });
53
+ const url = await getSignedUrl(this.#client, command, { expiresIn });
54
+ return { fileKey, signedUrl: url, expiresIn };
55
+ }
56
+ return null;
57
+ }
58
+
59
+ async fileExists({ fileKey }) {
60
+ try {
61
+ await this.#runCommand(new HeadObjectCommand({ Bucket: this.#bucket, Key: fileKey }));
62
+ return true;
63
+ } catch (error) {
64
+ if (error.name === 'NotFound' || error.$metadata?.httpStatusCode === 404) {
65
+ return false;
66
+ }
67
+ throw error;
68
+ }
69
+ }
70
+
71
+ #validateSize(fileSize, sizeLimit) {
72
+ if (!sizeLimit) return;
73
+ if (fileSize != null && fileSize > sizeLimit) {
74
+ throw new Error('File size limit exceeded');
75
+ }
76
+ }
77
+
78
+ #writeStreamToDisk(readStream, pathToWrite) {
79
+ return new Promise((resolve, reject) => {
80
+ const writeStream = fs.createWriteStream(pathToWrite);
81
+ readStream
82
+ .pipe(writeStream)
83
+ .on('finish', resolve)
84
+ .on('error', reject);
85
+ });
86
+ }
87
+
88
+ async #runCommand(command) {
89
+ return this.#client.send(command);
90
+ }
91
+ }
92
+
93
+ module.exports = S3Service;
@@ -0,0 +1,31 @@
1
+ const StreamFileWriter = require('./streamFileWriter');
2
+
3
+ class StorageService {
4
+ #client;
5
+
6
+ #streamFileWriter;
7
+
8
+ constructor(client, streamFileWriter = StreamFileWriter) {
9
+ this.#client = client;
10
+ this.#streamFileWriter = streamFileWriter;
11
+ }
12
+
13
+ async upload(params) {
14
+ return this.#client.upload(params);
15
+ }
16
+
17
+ async download(params) {
18
+ const { stream } = this.#client.download(params);
19
+ return this.#streamFileWriter.writeToDisk({ stream, ...params });
20
+ }
21
+
22
+ async getSignedUrl(params) {
23
+ return this.#client.getSignedUrl(params);
24
+ }
25
+
26
+ async fileExists(params) {
27
+ return this.#client.fileExists(params);
28
+ }
29
+ }
30
+
31
+ module.exports = StorageService;
@@ -0,0 +1,88 @@
1
+ /* eslint-disable class-methods-use-this */
2
+ const fs = require('fs');
3
+ const { pipeline } = require('stream');
4
+ const { promisify } = require('util');
5
+
6
+ const pipelineAsync = promisify(pipeline);
7
+
8
+ const Errors = {
9
+ ON_DATA: 'onDataCallback',
10
+ ON_END: 'onEndCallback',
11
+ PIPELINE: 'StreamPipelineError',
12
+ };
13
+
14
+ class StreamFileWriter {
15
+ static async writeToDisk({ stream, pathToWrite, callbacks = {} }) {
16
+ const writableStream = fs.createWriteStream(pathToWrite);
17
+ let callbackError = null;
18
+
19
+ if (callbacks.onData) {
20
+ this.#attachOnData(stream, callbacks.onData, (err) => {
21
+ callbackError = err;
22
+ });
23
+ }
24
+
25
+ try {
26
+ await pipelineAsync(stream, writableStream);
27
+
28
+ this.#throwIfCallbackFailed(callbackError);
29
+
30
+ return callbacks.onEnd
31
+ ? this.#handleOnEnd(callbacks.onEnd)
32
+ : { success: true };
33
+ } catch (err) {
34
+ this.#throwIfCallbackFailed(callbackError);
35
+
36
+ throw this.#normalizePipelineError(err);
37
+ }
38
+ }
39
+
40
+ static #attachOnData(stream, onData, reportCallbackError) {
41
+ let downloadedBytes = 0;
42
+
43
+ const onDataHandler = (chunk) => {
44
+ downloadedBytes += chunk.length;
45
+
46
+ try {
47
+ onData(chunk, downloadedBytes);
48
+ } catch (err) {
49
+ reportCallbackError(
50
+ this.#buildError(Errors.ON_DATA, err),
51
+ );
52
+
53
+ stream.off('data', onDataHandler);
54
+ stream.destroy(err);
55
+ }
56
+ };
57
+
58
+ stream.on('data', onDataHandler);
59
+ }
60
+
61
+ static #handleOnEnd(onEnd) {
62
+ try {
63
+ return onEnd() ?? { success: true };
64
+ } catch (err) {
65
+ throw this.#buildError(Errors.ON_END, err);
66
+ }
67
+ }
68
+
69
+ static #throwIfCallbackFailed(callbackError) {
70
+ if (callbackError) {
71
+ throw callbackError;
72
+ }
73
+ }
74
+
75
+ static #normalizePipelineError(err) {
76
+ if (err?.type && err?.error) {
77
+ return err;
78
+ }
79
+
80
+ return this.#buildError(Errors.PIPELINE, err);
81
+ }
82
+
83
+ static #buildError(type, error) {
84
+ return { type, error };
85
+ }
86
+ }
87
+
88
+ module.exports = StreamFileWriter;
package/package.json CHANGED
@@ -1,13 +1,28 @@
1
1
  {
2
2
  "name": "pluga-plg",
3
- "version": "0.1.7",
3
+ "version": "0.2.0",
4
4
  "description": "Pluga developer platform toolbox",
5
5
  "main": "index.js",
6
6
  "author": "Pluga <tech@pluga.co> (pluga.co)",
7
7
  "contributors": [
8
8
  "Leonardo Camelo (github.com/leocamelo)",
9
9
  "Renan Machado (github.com/renanmac)",
10
- "Alexandre Camillo (github.com/alexandrecamillo)"
10
+ "Alexandre Camillo (github.com/alexandrecamillo)",
11
+ "Mayara Araujo (github.com/mayaraujom)"
11
12
  ],
12
- "license": "MIT"
13
+ "license": "MIT",
14
+ "dependencies": {
15
+ "@aws-sdk/client-s3": "^3.934.0",
16
+ "@aws-sdk/s3-request-presigner": "^3.934.0",
17
+ "axios": "^1.7.4"
18
+ },
19
+ "scripts": {
20
+ "test": "jest"
21
+ },
22
+ "devDependencies": {
23
+ "jest": "^30.2.0",
24
+ "eslint": "8.56.0",
25
+ "eslint-config-airbnb-base": "15.0.0",
26
+ "eslint-plugin-import": "2.29.1"
27
+ }
13
28
  }
@@ -1,2 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).axios=t()}(this,(function(){"use strict";function e(e){var r,n;function o(r,n){try{var a=e[r](n),s=a.value,u=s instanceof t;Promise.resolve(u?s.v:s).then((function(t){if(u){var n="return"===r?"return":"next";if(!s.k||t.done)return o(n,t);t=e[n](t).value}i(a.done?"return":"normal",t)}),(function(e){o("throw",e)}))}catch(e){i("throw",e)}}function i(e,t){switch(e){case"return":r.resolve({value:t,done:!0});break;case"throw":r.reject(t);break;default:r.resolve({value:t,done:!1})}(r=r.next)?o(r.key,r.arg):n=null}this._invoke=function(e,t){return new Promise((function(i,a){var s={key:e,arg:t,resolve:i,reject:a,next:null};n?n=n.next=s:(r=n=s,o(e,t))}))},"function"!=typeof e.return&&(this.return=void 0)}function t(e,t){this.v=e,this.k=t}function r(e){var r={},n=!1;function o(r,o){return n=!0,o=new Promise((function(t){t(e[r](o))})),{done:!1,value:new t(o,1)}}return r["undefined"!=typeof Symbol&&Symbol.iterator||"@@iterator"]=function(){return this},r.next=function(e){return n?(n=!1,e):o("next",e)},"function"==typeof e.throw&&(r.throw=function(e){if(n)throw n=!1,e;return o("throw",e)}),"function"==typeof e.return&&(r.return=function(e){return n?(n=!1,e):o("return",e)}),r}function n(e){var t,r,n,i=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,n=Symbol.iterator);i--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new o(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function o(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return o=function(e){this.s=e,this.n=e.next},o.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Promise.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Promise.reject(e):t(r.apply(this.s,arguments))}},new o(e)}function i(e){return new t(e,0)}function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach((function(t){y(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function u(){u=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function f(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(e){f=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=t&&t.prototype instanceof m?t:m,a=Object.create(i.prototype),s=new P(n||[]);return o(a,"_invoke",{value:T(e,r,s)}),a}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var p="suspendedStart",d="executing",v="completed",y={};function m(){}function b(){}function g(){}var w={};f(w,a,(function(){return this}));var E=Object.getPrototypeOf,O=E&&E(E(L([])));O&&O!==r&&n.call(O,a)&&(w=O);var S=g.prototype=m.prototype=Object.create(w);function x(e){["next","throw","return"].forEach((function(t){f(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function r(o,i,a,s){var u=h(e[o],e,i);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(f).then((function(e){c.value=e,a(c)}),(function(e){return r("throw",e,a,s)}))}s(u.arg)}var i;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return i=i?i.then(o,o):o()}})}function T(t,r,n){var o=p;return function(i,a){if(o===d)throw new Error("Generator is already running");if(o===v){if("throw"===i)throw a;return{value:e,done:!0}}for(n.method=i,n.arg=a;;){var s=n.delegate;if(s){var u=k(s,n);if(u){if(u===y)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var c=h(t,r,n);if("normal"===c.type){if(o=n.done?v:"suspendedYield",c.arg===y)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=v,n.method="throw",n.arg=c.arg)}}}function k(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,k(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=h(o,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var a=i.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function L(t){if(t||""===t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(typeof t+" is not iterable")}return b.prototype=g,o(S,"constructor",{value:g,configurable:!0}),o(g,"constructor",{value:b,configurable:!0}),b.displayName=f(g,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,f(e,c,"GeneratorFunction")),e.prototype=Object.create(S),e},t.awrap=function(e){return{__await:e}},x(R.prototype),f(R.prototype,s,(function(){return this})),t.AsyncIterator=R,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new R(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},x(S),f(S,c,"Generator"),f(S,a,(function(){return this})),f(S,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=L,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(A),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return s.type="throw",s.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;A(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function c(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function f(e){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(e)}function l(e,t,r,n,o,i,a){try{var s=e[i](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,o)}function h(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function a(e){l(i,n,o,a,s,"next",e)}function s(e){l(i,n,o,a,s,"throw",e)}a(void 0)}))}}function p(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,c(n.key),n)}}function v(e,t,r){return t&&d(e.prototype,t),r&&d(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function y(e,t,r){return(t=c(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m(e,t){return g(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||E(e,t)||S()}function b(e){return function(e){if(Array.isArray(e))return O(e)}(e)||w(e)||E(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e){if(Array.isArray(e))return e}function w(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function E(e,t){if(e){if("string"==typeof e)return O(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?O(e,t):void 0}}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function S(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function x(e,t){return function(){return e.apply(t,arguments)}}e.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},e.prototype.next=function(e){return this._invoke("next",e)},e.prototype.throw=function(e){return this._invoke("throw",e)},e.prototype.return=function(e){return this._invoke("return",e)};var R,T=Object.prototype.toString,k=Object.getPrototypeOf,j=(R=Object.create(null),function(e){var t=T.call(e);return R[t]||(R[t]=t.slice(8,-1).toLowerCase())}),A=function(e){return e=e.toLowerCase(),function(t){return j(t)===e}},P=function(e){return function(t){return f(t)===e}},L=Array.isArray,N=P("undefined");var _=A("ArrayBuffer");var C=P("string"),F=P("function"),U=P("number"),B=function(e){return null!==e&&"object"===f(e)},D=function(e){if("object"!==j(e))return!1;var t=k(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},I=A("Date"),q=A("File"),M=A("Blob"),z=A("FileList"),H=A("URLSearchParams"),J=m(["ReadableStream","Request","Response","Headers"].map(A),4),W=J[0],G=J[1],K=J[2],V=J[3];function X(e,t){var r,n,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=o.allOwnKeys,a=void 0!==i&&i;if(null!=e)if("object"!==f(e)&&(e=[e]),L(e))for(r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else{var s,u=a?Object.getOwnPropertyNames(e):Object.keys(e),c=u.length;for(r=0;r<c;r++)s=u[r],t.call(null,e[s],s,e)}}function $(e,t){t=t.toLowerCase();for(var r,n=Object.keys(e),o=n.length;o-- >0;)if(t===(r=n[o]).toLowerCase())return r;return null}var Y="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,Q=function(e){return!N(e)&&e!==Y};var Z,ee=(Z="undefined"!=typeof Uint8Array&&k(Uint8Array),function(e){return Z&&e instanceof Z}),te=A("HTMLFormElement"),re=function(e){var t=Object.prototype.hasOwnProperty;return function(e,r){return t.call(e,r)}}(),ne=A("RegExp"),oe=function(e,t){var r=Object.getOwnPropertyDescriptors(e),n={};X(r,(function(r,o){var i;!1!==(i=t(r,o,e))&&(n[o]=i||r)})),Object.defineProperties(e,n)},ie="abcdefghijklmnopqrstuvwxyz",ae="0123456789",se={DIGIT:ae,ALPHA:ie,ALPHA_DIGIT:ie+ie.toUpperCase()+ae};var ue,ce,fe,le,he=A("AsyncFunction"),pe=(ue="function"==typeof setImmediate,ce=F(Y.postMessage),ue?setImmediate:ce?(fe="axios@".concat(Math.random()),le=[],Y.addEventListener("message",(function(e){var t=e.source,r=e.data;t===Y&&r===fe&&le.length&&le.shift()()}),!1),function(e){le.push(e),Y.postMessage(fe,"*")}):function(e){return setTimeout(e)}),de="undefined"!=typeof queueMicrotask?queueMicrotask.bind(Y):"undefined"!=typeof process&&process.nextTick||pe,ve={isArray:L,isArrayBuffer:_,isBuffer:function(e){return null!==e&&!N(e)&&null!==e.constructor&&!N(e.constructor)&&F(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:function(e){var t;return e&&("function"==typeof FormData&&e instanceof FormData||F(e.append)&&("formdata"===(t=j(e))||"object"===t&&F(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&_(e.buffer)},isString:C,isNumber:U,isBoolean:function(e){return!0===e||!1===e},isObject:B,isPlainObject:D,isReadableStream:W,isRequest:G,isResponse:K,isHeaders:V,isUndefined:N,isDate:I,isFile:q,isBlob:M,isRegExp:ne,isFunction:F,isStream:function(e){return B(e)&&F(e.pipe)},isURLSearchParams:H,isTypedArray:ee,isFileList:z,forEach:X,merge:function e(){for(var t=Q(this)&&this||{},r=t.caseless,n={},o=function(t,o){var i=r&&$(n,o)||o;D(n[i])&&D(t)?n[i]=e(n[i],t):D(t)?n[i]=e({},t):L(t)?n[i]=t.slice():n[i]=t},i=0,a=arguments.length;i<a;i++)arguments[i]&&X(arguments[i],o);return n},extend:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=n.allOwnKeys;return X(t,(function(t,n){r&&F(t)?e[n]=x(t,r):e[n]=t}),{allOwnKeys:o}),e},trim:function(e){return e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e},inherits:function(e,t,r,n){e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:function(e,t,r,n){var o,i,a,s={};if(t=t||{},null==e)return t;do{for(i=(o=Object.getOwnPropertyNames(e)).length;i-- >0;)a=o[i],n&&!n(a,e,t)||s[a]||(t[a]=e[a],s[a]=!0);e=!1!==r&&k(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:j,kindOfTest:A,endsWith:function(e,t,r){e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;var n=e.indexOf(t,r);return-1!==n&&n===r},toArray:function(e){if(!e)return null;if(L(e))return e;var t=e.length;if(!U(t))return null;for(var r=new Array(t);t-- >0;)r[t]=e[t];return r},forEachEntry:function(e,t){for(var r,n=(e&&e[Symbol.iterator]).call(e);(r=n.next())&&!r.done;){var o=r.value;t.call(e,o[0],o[1])}},matchAll:function(e,t){for(var r,n=[];null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:te,hasOwnProperty:re,hasOwnProp:re,reduceDescriptors:oe,freezeMethods:function(e){oe(e,(function(t,r){if(F(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;var n=e[r];F(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=function(){throw Error("Can not rewrite read-only method '"+r+"'")}))}))},toObjectSet:function(e,t){var r={},n=function(e){e.forEach((function(e){r[e]=!0}))};return L(e)?n(e):n(String(e).split(t)),r},toCamelCase:function(e){return e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,r){return t.toUpperCase()+r}))},noop:function(){},toFiniteNumber:function(e,t){return null!=e&&Number.isFinite(e=+e)?e:t},findKey:$,global:Y,isContextDefined:Q,ALPHABET:se,generateString:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:se.ALPHA_DIGIT,r="",n=t.length;e--;)r+=t[Math.random()*n|0];return r},isSpecCompliantForm:function(e){return!!(e&&F(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:function(e){var t=new Array(10);return function e(r,n){if(B(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[n]=r;var o=L(r)?[]:{};return X(r,(function(t,r){var i=e(t,n+1);!N(i)&&(o[r]=i)})),t[n]=void 0,o}}return r}(e,0)},isAsyncFn:he,isThenable:function(e){return e&&(B(e)||F(e))&&F(e.then)&&F(e.catch)},setImmediate:pe,asap:de};function ye(e,t,r,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o)}ve.inherits(ye,Error,{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:ve.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var me=ye.prototype,be={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((function(e){be[e]={value:e}})),Object.defineProperties(ye,be),Object.defineProperty(me,"isAxiosError",{value:!0}),ye.from=function(e,t,r,n,o,i){var a=Object.create(me);return ve.toFlatObject(e,a,(function(e){return e!==Error.prototype}),(function(e){return"isAxiosError"!==e})),ye.call(a,e.message,t,r,n,o),a.cause=e,a.name=e.name,i&&Object.assign(a,i),a};function ge(e){return ve.isPlainObject(e)||ve.isArray(e)}function we(e){return ve.endsWith(e,"[]")?e.slice(0,-2):e}function Ee(e,t,r){return e?e.concat(t).map((function(e,t){return e=we(e),!r&&t?"["+e+"]":e})).join(r?".":""):t}var Oe=ve.toFlatObject(ve,{},null,(function(e){return/^is[A-Z]/.test(e)}));function Se(e,t,r){if(!ve.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;var n=(r=ve.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!ve.isUndefined(t[e])}))).metaTokens,o=r.visitor||c,i=r.dots,a=r.indexes,s=(r.Blob||"undefined"!=typeof Blob&&Blob)&&ve.isSpecCompliantForm(t);if(!ve.isFunction(o))throw new TypeError("visitor must be a function");function u(e){if(null===e)return"";if(ve.isDate(e))return e.toISOString();if(!s&&ve.isBlob(e))throw new ye("Blob is not supported. Use a Buffer instead.");return ve.isArrayBuffer(e)||ve.isTypedArray(e)?s&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function c(e,r,o){var s=e;if(e&&!o&&"object"===f(e))if(ve.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else if(ve.isArray(e)&&function(e){return ve.isArray(e)&&!e.some(ge)}(e)||(ve.isFileList(e)||ve.endsWith(r,"[]"))&&(s=ve.toArray(e)))return r=we(r),s.forEach((function(e,n){!ve.isUndefined(e)&&null!==e&&t.append(!0===a?Ee([r],n,i):null===a?r:r+"[]",u(e))})),!1;return!!ge(e)||(t.append(Ee(o,r,i),u(e)),!1)}var l=[],h=Object.assign(Oe,{defaultVisitor:c,convertValue:u,isVisitable:ge});if(!ve.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!ve.isUndefined(r)){if(-1!==l.indexOf(r))throw Error("Circular reference detected in "+n.join("."));l.push(r),ve.forEach(r,(function(r,i){!0===(!(ve.isUndefined(r)||null===r)&&o.call(t,r,ve.isString(i)?i.trim():i,n,h))&&e(r,n?n.concat(i):[i])})),l.pop()}}(e),t}function xe(e){var t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function Re(e,t){this._pairs=[],e&&Se(e,this,t)}var Te=Re.prototype;function ke(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function je(e,t,r){if(!t)return e;var n,o=r&&r.encode||ke,i=r&&r.serialize;if(n=i?i(t,r):ve.isURLSearchParams(t)?t.toString():new Re(t,r).toString(o)){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e}Te.append=function(e,t){this._pairs.push([e,t])},Te.toString=function(e){var t=e?function(t){return e.call(this,t,xe)}:xe;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var Ae,Pe=function(){function e(){p(this,e),this.handlers=[]}return v(e,[{key:"use",value:function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}},{key:"eject",value:function(e){this.handlers[e]&&(this.handlers[e]=null)}},{key:"clear",value:function(){this.handlers&&(this.handlers=[])}},{key:"forEach",value:function(e){ve.forEach(this.handlers,(function(t){null!==t&&e(t)}))}}]),e}(),Le={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Ne={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Re,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},_e="undefined"!=typeof window&&"undefined"!=typeof document,Ce=(Ae="undefined"!=typeof navigator&&navigator.product,_e&&["ReactNative","NativeScript","NS"].indexOf(Ae)<0),Fe="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Ue=_e&&window.location.href||"http://localhost",Be=s(s({},Object.freeze({__proto__:null,hasBrowserEnv:_e,hasStandardBrowserWebWorkerEnv:Fe,hasStandardBrowserEnv:Ce,origin:Ue})),Ne);function De(e){function t(e,r,n,o){var i=e[o++];if("__proto__"===i)return!0;var a=Number.isFinite(+i),s=o>=e.length;return i=!i&&ve.isArray(n)?n.length:i,s?(ve.hasOwnProp(n,i)?n[i]=[n[i],r]:n[i]=r,!a):(n[i]&&ve.isObject(n[i])||(n[i]=[]),t(e,r,n[i],o)&&ve.isArray(n[i])&&(n[i]=function(e){var t,r,n={},o=Object.keys(e),i=o.length;for(t=0;t<i;t++)n[r=o[t]]=e[r];return n}(n[i])),!a)}if(ve.isFormData(e)&&ve.isFunction(e.entries)){var r={};return ve.forEachEntry(e,(function(e,n){t(function(e){return ve.matchAll(/\w+|\[(\w*)]/g,e).map((function(e){return"[]"===e[0]?"":e[1]||e[0]}))}(e),n,r,0)})),r}return null}var Ie={transitional:Le,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){var r,n=t.getContentType()||"",o=n.indexOf("application/json")>-1,i=ve.isObject(e);if(i&&ve.isHTMLForm(e)&&(e=new FormData(e)),ve.isFormData(e))return o?JSON.stringify(De(e)):e;if(ve.isArrayBuffer(e)||ve.isBuffer(e)||ve.isStream(e)||ve.isFile(e)||ve.isBlob(e)||ve.isReadableStream(e))return e;if(ve.isArrayBufferView(e))return e.buffer;if(ve.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Se(e,new Be.classes.URLSearchParams,Object.assign({visitor:function(e,t,r,n){return Be.isNode&&ve.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((r=ve.isFileList(e))||n.indexOf("multipart/form-data")>-1){var a=this.env&&this.env.FormData;return Se(r?{"files[]":e}:e,a&&new a,this.formSerializer)}}return i||o?(t.setContentType("application/json",!1),function(e,t,r){if(ve.isString(e))try{return(t||JSON.parse)(e),ve.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||Ie.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(ve.isResponse(e)||ve.isReadableStream(e))return e;if(e&&ve.isString(e)&&(r&&!this.responseType||n)){var o=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(e){if(o){if("SyntaxError"===e.name)throw ye.from(e,ye.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Be.classes.FormData,Blob:Be.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ve.forEach(["delete","get","head","post","put","patch"],(function(e){Ie.headers[e]={}}));var qe=Ie,Me=ve.toObjectSet(["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"]),ze=Symbol("internals");function He(e){return e&&String(e).trim().toLowerCase()}function Je(e){return!1===e||null==e?e:ve.isArray(e)?e.map(Je):String(e)}function We(e,t,r,n,o){return ve.isFunction(n)?n.call(this,t,r):(o&&(t=r),ve.isString(t)?ve.isString(n)?-1!==t.indexOf(n):ve.isRegExp(n)?n.test(t):void 0:void 0)}var Ge=function(e,t){function r(e){p(this,r),e&&this.set(e)}return v(r,[{key:"set",value:function(e,t,r){var n=this;function o(e,t,r){var o=He(t);if(!o)throw new Error("header name must be a non-empty string");var i=ve.findKey(n,o);(!i||void 0===n[i]||!0===r||void 0===r&&!1!==n[i])&&(n[i||t]=Je(e))}var i=function(e,t){return ve.forEach(e,(function(e,r){return o(e,r,t)}))};if(ve.isPlainObject(e)||e instanceof this.constructor)i(e,t);else if(ve.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))i(function(e){var t,r,n,o={};return e&&e.split("\n").forEach((function(e){n=e.indexOf(":"),t=e.substring(0,n).trim().toLowerCase(),r=e.substring(n+1).trim(),!t||o[t]&&Me[t]||("set-cookie"===t?o[t]?o[t].push(r):o[t]=[r]:o[t]=o[t]?o[t]+", "+r:r)})),o}(e),t);else if(ve.isHeaders(e)){var a,s=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=E(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}(e.entries());try{for(s.s();!(a=s.n()).done;){var u=m(a.value,2),c=u[0];o(u[1],c,r)}}catch(e){s.e(e)}finally{s.f()}}else null!=e&&o(t,e,r);return this}},{key:"get",value:function(e,t){if(e=He(e)){var r=ve.findKey(this,e);if(r){var n=this[r];if(!t)return n;if(!0===t)return function(e){for(var t,r=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;t=n.exec(e);)r[t[1]]=t[2];return r}(n);if(ve.isFunction(t))return t.call(this,n,r);if(ve.isRegExp(t))return t.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}},{key:"has",value:function(e,t){if(e=He(e)){var r=ve.findKey(this,e);return!(!r||void 0===this[r]||t&&!We(0,this[r],r,t))}return!1}},{key:"delete",value:function(e,t){var r=this,n=!1;function o(e){if(e=He(e)){var o=ve.findKey(r,e);!o||t&&!We(0,r[o],o,t)||(delete r[o],n=!0)}}return ve.isArray(e)?e.forEach(o):o(e),n}},{key:"clear",value:function(e){for(var t=Object.keys(this),r=t.length,n=!1;r--;){var o=t[r];e&&!We(0,this[o],o,e,!0)||(delete this[o],n=!0)}return n}},{key:"normalize",value:function(e){var t=this,r={};return ve.forEach(this,(function(n,o){var i=ve.findKey(r,o);if(i)return t[i]=Je(n),void delete t[o];var a=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(function(e,t,r){return t.toUpperCase()+r}))}(o):String(o).trim();a!==o&&delete t[o],t[a]=Je(n),r[a]=!0})),this}},{key:"concat",value:function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return(e=this.constructor).concat.apply(e,[this].concat(r))}},{key:"toJSON",value:function(e){var t=Object.create(null);return ve.forEach(this,(function(r,n){null!=r&&!1!==r&&(t[n]=e&&ve.isArray(r)?r.join(", "):r)})),t}},{key:Symbol.iterator,value:function(){return Object.entries(this.toJSON())[Symbol.iterator]()}},{key:"toString",value:function(){return Object.entries(this.toJSON()).map((function(e){var t=m(e,2);return t[0]+": "+t[1]})).join("\n")}},{key:Symbol.toStringTag,get:function(){return"AxiosHeaders"}}],[{key:"from",value:function(e){return e instanceof this?e:new this(e)}},{key:"concat",value:function(e){for(var t=new this(e),r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return n.forEach((function(e){return t.set(e)})),t}},{key:"accessor",value:function(e){var t=(this[ze]=this[ze]={accessors:{}}).accessors,r=this.prototype;function n(e){var n=He(e);t[n]||(!function(e,t){var r=ve.toCamelCase(" "+t);["get","set","has"].forEach((function(n){Object.defineProperty(e,n+r,{value:function(e,r,o){return this[n].call(this,t,e,r,o)},configurable:!0})}))}(r,e),t[n]=!0)}return ve.isArray(e)?e.forEach(n):n(e),this}}]),r}();Ge.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),ve.reduceDescriptors(Ge.prototype,(function(e,t){var r=e.value,n=t[0].toUpperCase()+t.slice(1);return{get:function(){return r},set:function(e){this[n]=e}}})),ve.freezeMethods(Ge);var Ke=Ge;function Ve(e,t){var r=this||qe,n=t||r,o=Ke.from(n.headers),i=n.data;return ve.forEach(e,(function(e){i=e.call(r,i,o.normalize(),t?t.status:void 0)})),o.normalize(),i}function Xe(e){return!(!e||!e.__CANCEL__)}function $e(e,t,r){ye.call(this,null==e?"canceled":e,ye.ERR_CANCELED,t,r),this.name="CanceledError"}function Ye(e,t,r){var n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new ye("Request failed with status code "+r.status,[ye.ERR_BAD_REQUEST,ye.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}function Qe(e,t){e=e||10;var r,n=new Array(e),o=new Array(e),i=0,a=0;return t=void 0!==t?t:1e3,function(s){var u=Date.now(),c=o[a];r||(r=u),n[i]=s,o[i]=u;for(var f=a,l=0;f!==i;)l+=n[f++],f%=e;if((i=(i+1)%e)===a&&(a=(a+1)%e),!(u-r<t)){var h=c&&u-c;return h?Math.round(1e3*l/h):void 0}}}function Ze(e,t){var r,n,o=0,i=1e3/t,a=function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now();o=i,r=null,n&&(clearTimeout(n),n=null),e.apply(null,t)};return[function(){for(var e=Date.now(),t=e-o,s=arguments.length,u=new Array(s),c=0;c<s;c++)u[c]=arguments[c];t>=i?a(u,e):(r=u,n||(n=setTimeout((function(){n=null,a(r)}),i-t)))},function(){return r&&a(r)}]}ve.inherits($e,ye,{__CANCEL__:!0});var et=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3,n=0,o=Qe(50,250);return Ze((function(r){var i=r.loaded,a=r.lengthComputable?r.total:void 0,s=i-n,u=o(s);n=i;var c=y({loaded:i,total:a,progress:a?i/a:void 0,bytes:s,rate:u||void 0,estimated:u&&a&&i<=a?(a-i)/u:void 0,event:r,lengthComputable:null!=a},t?"download":"upload",!0);e(c)}),r)},tt=function(e,t){var r=null!=e;return[function(n){return t[0]({lengthComputable:r,total:e,loaded:n})},t[1]]},rt=function(e){return function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return ve.asap((function(){return e.apply(void 0,r)}))}},nt=Be.hasStandardBrowserEnv?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function n(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=n(window.location.href),function(t){var r=ve.isString(t)?n(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0},ot=Be.hasStandardBrowserEnv?{write:function(e,t,r,n,o,i){var a=[e+"="+encodeURIComponent(t)];ve.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),ve.isString(n)&&a.push("path="+n),ve.isString(o)&&a.push("domain="+o),!0===i&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}};function it(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}var at=function(e){return e instanceof Ke?s({},e):e};function st(e,t){t=t||{};var r={};function n(e,t,r){return ve.isPlainObject(e)&&ve.isPlainObject(t)?ve.merge.call({caseless:r},e,t):ve.isPlainObject(t)?ve.merge({},t):ve.isArray(t)?t.slice():t}function o(e,t,r){return ve.isUndefined(t)?ve.isUndefined(e)?void 0:n(void 0,e,r):n(e,t,r)}function i(e,t){if(!ve.isUndefined(t))return n(void 0,t)}function a(e,t){return ve.isUndefined(t)?ve.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function s(r,o,i){return i in t?n(r,o):i in e?n(void 0,r):void 0}var u={url:i,method:i,data:i,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:s,headers:function(e,t){return o(at(e),at(t),!0)}};return ve.forEach(Object.keys(Object.assign({},e,t)),(function(n){var i=u[n]||o,a=i(e[n],t[n],n);ve.isUndefined(a)&&i!==s||(r[n]=a)})),r}var ut,ct,ft=function(e){var t,r,n=st({},e),o=n.data,i=n.withXSRFToken,a=n.xsrfHeaderName,s=n.xsrfCookieName,u=n.headers,c=n.auth;if(n.headers=u=Ke.from(u),n.url=je(it(n.baseURL,n.url),e.params,e.paramsSerializer),c&&u.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),ve.isFormData(o))if(Be.hasStandardBrowserEnv||Be.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if(!1!==(t=u.getContentType())){var f=t?t.split(";").map((function(e){return e.trim()})).filter(Boolean):[],l=g(r=f)||w(r)||E(r)||S(),h=l[0],p=l.slice(1);u.setContentType([h||"multipart/form-data"].concat(b(p)).join("; "))}if(Be.hasStandardBrowserEnv&&(i&&ve.isFunction(i)&&(i=i(n)),i||!1!==i&&nt(n.url))){var d=a&&s&&ot.read(s);d&&u.set(a,d)}return n},lt="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,r){var n,o,i,a,s,u=ft(e),c=u.data,f=Ke.from(u.headers).normalize(),l=u.responseType,h=u.onUploadProgress,p=u.onDownloadProgress;function d(){a&&a(),s&&s(),u.cancelToken&&u.cancelToken.unsubscribe(n),u.signal&&u.signal.removeEventListener("abort",n)}var v=new XMLHttpRequest;function y(){if(v){var n=Ke.from("getAllResponseHeaders"in v&&v.getAllResponseHeaders());Ye((function(e){t(e),d()}),(function(e){r(e),d()}),{data:l&&"text"!==l&&"json"!==l?v.response:v.responseText,status:v.status,statusText:v.statusText,headers:n,config:e,request:v}),v=null}}if(v.open(u.method.toUpperCase(),u.url,!0),v.timeout=u.timeout,"onloadend"in v?v.onloadend=y:v.onreadystatechange=function(){v&&4===v.readyState&&(0!==v.status||v.responseURL&&0===v.responseURL.indexOf("file:"))&&setTimeout(y)},v.onabort=function(){v&&(r(new ye("Request aborted",ye.ECONNABORTED,e,v)),v=null)},v.onerror=function(){r(new ye("Network Error",ye.ERR_NETWORK,e,v)),v=null},v.ontimeout=function(){var t=u.timeout?"timeout of "+u.timeout+"ms exceeded":"timeout exceeded",n=u.transitional||Le;u.timeoutErrorMessage&&(t=u.timeoutErrorMessage),r(new ye(t,n.clarifyTimeoutError?ye.ETIMEDOUT:ye.ECONNABORTED,e,v)),v=null},void 0===c&&f.setContentType(null),"setRequestHeader"in v&&ve.forEach(f.toJSON(),(function(e,t){v.setRequestHeader(t,e)})),ve.isUndefined(u.withCredentials)||(v.withCredentials=!!u.withCredentials),l&&"json"!==l&&(v.responseType=u.responseType),p){var b=m(et(p,!0),2);i=b[0],s=b[1],v.addEventListener("progress",i)}if(h&&v.upload){var g=m(et(h),2);o=g[0],a=g[1],v.upload.addEventListener("progress",o),v.upload.addEventListener("loadend",a)}(u.cancelToken||u.signal)&&(n=function(t){v&&(r(!t||t.type?new $e(null,e,v):t),v.abort(),v=null)},u.cancelToken&&u.cancelToken.subscribe(n),u.signal&&(u.signal.aborted?n():u.signal.addEventListener("abort",n)));var w,E,O=(w=u.url,(E=/^([-+\w]{1,25})(:?\/\/|:)/.exec(w))&&E[1]||"");O&&-1===Be.protocols.indexOf(O)?r(new ye("Unsupported protocol "+O+":",ye.ERR_BAD_REQUEST,e)):v.send(c||null)}))},ht=function(e,t){var r,n=new AbortController,o=function(e){if(!r){r=!0,a();var t=e instanceof Error?e:this.reason;n.abort(t instanceof ye?t:new $e(t instanceof Error?t.message:t))}},i=t&&setTimeout((function(){o(new ye("timeout ".concat(t," of ms exceeded"),ye.ETIMEDOUT))}),t),a=function(){e&&(i&&clearTimeout(i),i=null,e.forEach((function(e){e&&(e.removeEventListener?e.removeEventListener("abort",o):e.unsubscribe(o))})),e=null)};e.forEach((function(e){return e&&e.addEventListener&&e.addEventListener("abort",o)}));var s=n.signal;return s.unsubscribe=a,[s,function(){i&&clearTimeout(i),i=null}]},pt=u().mark((function e(t,r){var n,o,i;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.byteLength,r&&!(n<r)){e.next=5;break}return e.next=4,t;case 4:return e.abrupt("return");case 5:o=0;case 6:if(!(o<n)){e.next=13;break}return i=o+r,e.next=10,t.slice(o,i);case 10:o=i,e.next=6;break;case 13:case"end":return e.stop()}}),e)})),dt=function(){var t,o=(t=u().mark((function e(t,o,a){var s,c,f,l,h,p;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s=!1,c=!1,e.prev=2,l=n(t);case 4:return e.next=6,i(l.next());case 6:if(!(s=!(h=e.sent).done)){e.next=27;break}if(p=h.value,e.t0=r,e.t1=n,e.t2=pt,!ArrayBuffer.isView(p)){e.next=15;break}e.t3=p,e.next=18;break;case 15:return e.next=17,i(a(String(p)));case 17:e.t3=e.sent;case 18:return e.t4=e.t3,e.t5=o,e.t6=(0,e.t2)(e.t4,e.t5),e.t7=(0,e.t1)(e.t6),e.t8=i,e.delegateYield((0,e.t0)(e.t7,e.t8),"t9",24);case 24:s=!1,e.next=4;break;case 27:e.next=33;break;case 29:e.prev=29,e.t10=e.catch(2),c=!0,f=e.t10;case 33:if(e.prev=33,e.prev=34,!s||null==l.return){e.next=38;break}return e.next=38,i(l.return());case 38:if(e.prev=38,!c){e.next=41;break}throw f;case 41:return e.finish(38);case 42:return e.finish(33);case 43:case"end":return e.stop()}}),e,null,[[2,29,33,43],[34,,38,42]])})),function(){return new e(t.apply(this,arguments))});return function(e,t,r){return o.apply(this,arguments)}}(),vt=function(e,t,r,n,o){var i,a=dt(e,t,o),s=0,c=function(e){i||(i=!0,n&&n(e))};return new ReadableStream({pull:function(e){return h(u().mark((function t(){var n,o,i,f,l;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,a.next();case 3:if(n=t.sent,o=n.done,i=n.value,!o){t.next=10;break}return c(),e.close(),t.abrupt("return");case 10:f=i.byteLength,r&&(l=s+=f,r(l)),e.enqueue(new Uint8Array(i)),t.next=19;break;case 15:throw t.prev=15,t.t0=t.catch(0),c(t.t0),t.t0;case 19:case"end":return t.stop()}}),t,null,[[0,15]])})))()},cancel:function(e){return c(e),a.return()}},{highWaterMark:2})},yt="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,mt=yt&&"function"==typeof ReadableStream,bt=yt&&("function"==typeof TextEncoder?(ut=new TextEncoder,function(e){return ut.encode(e)}):function(){var e=h(u().mark((function e(t){return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=Uint8Array,e.next=3,new Response(t).arrayBuffer();case 3:return e.t1=e.sent,e.abrupt("return",new e.t0(e.t1));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),gt=function(e){try{for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return!!e.apply(void 0,r)}catch(e){return!1}},wt=mt&&gt((function(){var e=!1,t=new Request(Be.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})),Et=mt&&gt((function(){return ve.isReadableStream(new Response("").body)})),Ot={stream:Et&&function(e){return e.body}};yt&&(ct=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((function(e){!Ot[e]&&(Ot[e]=ve.isFunction(ct[e])?function(t){return t[e]()}:function(t,r){throw new ye("Response type '".concat(e,"' is not supported"),ye.ERR_NOT_SUPPORT,r)})})));var St=function(){var e=h(u().mark((function e(t){return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=t){e.next=2;break}return e.abrupt("return",0);case 2:if(!ve.isBlob(t)){e.next=4;break}return e.abrupt("return",t.size);case 4:if(!ve.isSpecCompliantForm(t)){e.next=8;break}return e.next=7,new Request(t).arrayBuffer();case 7:case 14:return e.abrupt("return",e.sent.byteLength);case 8:if(!ve.isArrayBufferView(t)&&!ve.isArrayBuffer(t)){e.next=10;break}return e.abrupt("return",t.byteLength);case 10:if(ve.isURLSearchParams(t)&&(t+=""),!ve.isString(t)){e.next=15;break}return e.next=14,bt(t);case 15:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),xt=function(){var e=h(u().mark((function e(t,r){var n;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ve.toFiniteNumber(t.getContentLength()),e.abrupt("return",null==n?St(r):n);case 2:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),Rt=yt&&function(){var e=h(u().mark((function e(t){var r,n,o,i,a,c,f,l,h,p,d,v,y,b,g,w,E,O,S,x,R,T,k,j,A,P,L,N,_,C,F,U,B,D,I,q,M;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=ft(t),n=r.url,o=r.method,i=r.data,a=r.signal,c=r.cancelToken,f=r.timeout,l=r.onDownloadProgress,h=r.onUploadProgress,p=r.responseType,d=r.headers,v=r.withCredentials,y=void 0===v?"same-origin":v,b=r.fetchOptions,p=p?(p+"").toLowerCase():"text",g=a||c||f?ht([a,c],f):[],w=m(g,2),E=w[0],O=w[1],R=function(){!S&&setTimeout((function(){E&&E.unsubscribe()})),S=!0},e.prev=4,e.t0=h&&wt&&"get"!==o&&"head"!==o,!e.t0){e.next=11;break}return e.next=9,xt(d,i);case 9:e.t1=T=e.sent,e.t0=0!==e.t1;case 11:if(!e.t0){e.next=15;break}k=new Request(n,{method:"POST",body:i,duplex:"half"}),ve.isFormData(i)&&(j=k.headers.get("content-type"))&&d.setContentType(j),k.body&&(A=tt(T,et(rt(h))),P=m(A,2),L=P[0],N=P[1],i=vt(k.body,65536,L,N,bt));case 15:return ve.isString(y)||(y=y?"include":"omit"),x=new Request(n,s(s({},b),{},{signal:E,method:o.toUpperCase(),headers:d.normalize().toJSON(),body:i,duplex:"half",credentials:y})),e.next=19,fetch(x);case 19:return _=e.sent,C=Et&&("stream"===p||"response"===p),Et&&(l||C)&&(F={},["status","statusText","headers"].forEach((function(e){F[e]=_[e]})),U=ve.toFiniteNumber(_.headers.get("content-length")),B=l&&tt(U,et(rt(l),!0))||[],D=m(B,2),I=D[0],q=D[1],_=new Response(vt(_.body,65536,I,(function(){q&&q(),C&&R()}),bt),F)),p=p||"text",e.next=25,Ot[ve.findKey(Ot,p)||"text"](_,t);case 25:return M=e.sent,!C&&R(),O&&O(),e.next=30,new Promise((function(e,r){Ye(e,r,{data:M,headers:Ke.from(_.headers),status:_.status,statusText:_.statusText,config:t,request:x})}));case 30:return e.abrupt("return",e.sent);case 33:if(e.prev=33,e.t2=e.catch(4),R(),!e.t2||"TypeError"!==e.t2.name||!/fetch/i.test(e.t2.message)){e.next=38;break}throw Object.assign(new ye("Network Error",ye.ERR_NETWORK,t,x),{cause:e.t2.cause||e.t2});case 38:throw ye.from(e.t2,e.t2&&e.t2.code,t,x);case 39:case"end":return e.stop()}}),e,null,[[4,33]])})));return function(t){return e.apply(this,arguments)}}(),Tt={http:null,xhr:lt,fetch:Rt};ve.forEach(Tt,(function(e,t){if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));var kt=function(e){return"- ".concat(e)},jt=function(e){return ve.isFunction(e)||null===e||!1===e},At=function(e){for(var t,r,n=(e=ve.isArray(e)?e:[e]).length,o={},i=0;i<n;i++){var a=void 0;if(r=t=e[i],!jt(t)&&void 0===(r=Tt[(a=String(t)).toLowerCase()]))throw new ye("Unknown adapter '".concat(a,"'"));if(r)break;o[a||"#"+i]=r}if(!r){var s=Object.entries(o).map((function(e){var t=m(e,2),r=t[0],n=t[1];return"adapter ".concat(r," ")+(!1===n?"is not supported by the environment":"is not available in the build")}));throw new ye("There is no suitable adapter to dispatch the request "+(n?s.length>1?"since :\n"+s.map(kt).join("\n"):" "+kt(s[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return r};function Pt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new $e(null,e)}function Lt(e){return Pt(e),e.headers=Ke.from(e.headers),e.data=Ve.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),At(e.adapter||qe.adapter)(e).then((function(t){return Pt(e),t.data=Ve.call(e,e.transformResponse,t),t.headers=Ke.from(t.headers),t}),(function(t){return Xe(t)||(Pt(e),t&&t.response&&(t.response.data=Ve.call(e,e.transformResponse,t.response),t.response.headers=Ke.from(t.response.headers))),Promise.reject(t)}))}var Nt="1.7.4",_t={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){_t[e]=function(r){return f(r)===e||"a"+(t<1?"n ":" ")+e}}));var Ct={};_t.transitional=function(e,t,r){function n(e,t){return"[Axios v1.7.4] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,o,i){if(!1===e)throw new ye(n(o," has been removed"+(t?" in "+t:"")),ye.ERR_DEPRECATED);return t&&!Ct[o]&&(Ct[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,o,i)}};var Ft={assertOptions:function(e,t,r){if("object"!==f(e))throw new ye("options must be an object",ye.ERR_BAD_OPTION_VALUE);for(var n=Object.keys(e),o=n.length;o-- >0;){var i=n[o],a=t[i];if(a){var s=e[i],u=void 0===s||a(s,i,e);if(!0!==u)throw new ye("option "+i+" must be "+u,ye.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new ye("Unknown option "+i,ye.ERR_BAD_OPTION)}},validators:_t},Ut=Ft.validators,Bt=function(){function e(t){p(this,e),this.defaults=t,this.interceptors={request:new Pe,response:new Pe}}var t;return v(e,[{key:"request",value:(t=h(u().mark((function e(t,r){var n,o;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._request(t,r);case 3:return e.abrupt("return",e.sent);case 6:if(e.prev=6,e.t0=e.catch(0),e.t0 instanceof Error){Error.captureStackTrace?Error.captureStackTrace(n={}):n=new Error,o=n.stack?n.stack.replace(/^.+\n/,""):"";try{e.t0.stack?o&&!String(e.t0.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(e.t0.stack+="\n"+o):e.t0.stack=o}catch(e){}}throw e.t0;case 10:case"end":return e.stop()}}),e,this,[[0,6]])}))),function(e,r){return t.apply(this,arguments)})},{key:"_request",value:function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{};var r=t=st(this.defaults,t),n=r.transitional,o=r.paramsSerializer,i=r.headers;void 0!==n&&Ft.assertOptions(n,{silentJSONParsing:Ut.transitional(Ut.boolean),forcedJSONParsing:Ut.transitional(Ut.boolean),clarifyTimeoutError:Ut.transitional(Ut.boolean)},!1),null!=o&&(ve.isFunction(o)?t.paramsSerializer={serialize:o}:Ft.assertOptions(o,{encode:Ut.function,serialize:Ut.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase();var a=i&&ve.merge(i.common,i[t.method]);i&&ve.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete i[e]})),t.headers=Ke.concat(a,i);var s=[],u=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(u=u&&e.synchronous,s.unshift(e.fulfilled,e.rejected))}));var c,f=[];this.interceptors.response.forEach((function(e){f.push(e.fulfilled,e.rejected)}));var l,h=0;if(!u){var p=[Lt.bind(this),void 0];for(p.unshift.apply(p,s),p.push.apply(p,f),l=p.length,c=Promise.resolve(t);h<l;)c=c.then(p[h++],p[h++]);return c}l=s.length;var d=t;for(h=0;h<l;){var v=s[h++],y=s[h++];try{d=v(d)}catch(e){y.call(this,e);break}}try{c=Lt.call(this,d)}catch(e){return Promise.reject(e)}for(h=0,l=f.length;h<l;)c=c.then(f[h++],f[h++]);return c}},{key:"getUri",value:function(e){return je(it((e=st(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}]),e}();ve.forEach(["delete","get","head","options"],(function(e){Bt.prototype[e]=function(t,r){return this.request(st(r||{},{method:e,url:t,data:(r||{}).data}))}})),ve.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,o){return this.request(st(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}Bt.prototype[e]=t(),Bt.prototype[e+"Form"]=t(!0)}));var Dt=Bt,It=function(){function e(t){if(p(this,e),"function"!=typeof t)throw new TypeError("executor must be a function.");var r;this.promise=new Promise((function(e){r=e}));var n=this;this.promise.then((function(e){if(n._listeners){for(var t=n._listeners.length;t-- >0;)n._listeners[t](e);n._listeners=null}})),this.promise.then=function(e){var t,r=new Promise((function(e){n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},t((function(e,t,o){n.reason||(n.reason=new $e(e,t,o),r(n.reason))}))}return v(e,[{key:"throwIfRequested",value:function(){if(this.reason)throw this.reason}},{key:"subscribe",value:function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}},{key:"unsubscribe",value:function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}}}],[{key:"source",value:function(){var t;return{token:new e((function(e){t=e})),cancel:t}}}]),e}(),qt=It;var Mt={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Mt).forEach((function(e){var t=m(e,2),r=t[0],n=t[1];Mt[n]=r}));var zt=Mt;var Ht=function e(t){var r=new Dt(t),n=x(Dt.prototype.request,r);return ve.extend(n,Dt.prototype,r,{allOwnKeys:!0}),ve.extend(n,r,null,{allOwnKeys:!0}),n.create=function(r){return e(st(t,r))},n}(qe);return Ht.Axios=Dt,Ht.CanceledError=$e,Ht.CancelToken=qt,Ht.isCancel=Xe,Ht.VERSION=Nt,Ht.toFormData=Se,Ht.AxiosError=ye,Ht.Cancel=Ht.CanceledError,Ht.all=function(e){return Promise.all(e)},Ht.spread=function(e){return function(t){return e.apply(null,t)}},Ht.isAxiosError=function(e){return ve.isObject(e)&&!0===e.isAxiosError},Ht.mergeConfig=st,Ht.AxiosHeaders=Ke,Ht.formToJSON=function(e){return De(ve.isHTMLForm(e)?new FormData(e):e)},Ht.getAdapter=At,Ht.HttpStatusCode=zt,Ht.default=Ht,Ht}));
2
- //# sourceMappingURL=axios.min.js.map