@agenr/agenr-plugin 1.6.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.
@@ -0,0 +1,1408 @@
1
+ import {
2
+ FormData,
3
+ blobFrom,
4
+ blobFromSync,
5
+ fetch_blob_default,
6
+ fileFrom,
7
+ fileFromSync,
8
+ file_default,
9
+ formDataToBlob,
10
+ init_esm_min,
11
+ init_fetch_blob,
12
+ init_from
13
+ } from "./chunk-SQLXP7LT.js";
14
+ import {
15
+ __esm
16
+ } from "./chunk-EAQYK3U2.js";
17
+
18
+ // ../../node_modules/.pnpm/data-uri-to-buffer@4.0.1/node_modules/data-uri-to-buffer/dist/index.js
19
+ function dataUriToBuffer(uri) {
20
+ if (!/^data:/i.test(uri)) {
21
+ throw new TypeError('`uri` does not appear to be a Data URI (must begin with "data:")');
22
+ }
23
+ uri = uri.replace(/\r?\n/g, "");
24
+ const firstComma = uri.indexOf(",");
25
+ if (firstComma === -1 || firstComma <= 4) {
26
+ throw new TypeError("malformed data: URI");
27
+ }
28
+ const meta = uri.substring(5, firstComma).split(";");
29
+ let charset = "";
30
+ let base64 = false;
31
+ const type = meta[0] || "text/plain";
32
+ let typeFull = type;
33
+ for (let i = 1; i < meta.length; i++) {
34
+ if (meta[i] === "base64") {
35
+ base64 = true;
36
+ } else if (meta[i]) {
37
+ typeFull += `;${meta[i]}`;
38
+ if (meta[i].indexOf("charset=") === 0) {
39
+ charset = meta[i].substring(8);
40
+ }
41
+ }
42
+ }
43
+ if (!meta[0] && !charset.length) {
44
+ typeFull += ";charset=US-ASCII";
45
+ charset = "US-ASCII";
46
+ }
47
+ const encoding = base64 ? "base64" : "ascii";
48
+ const data = unescape(uri.substring(firstComma + 1));
49
+ const buffer = Buffer.from(data, encoding);
50
+ buffer.type = type;
51
+ buffer.typeFull = typeFull;
52
+ buffer.charset = charset;
53
+ return buffer;
54
+ }
55
+ var dist_default;
56
+ var init_dist = __esm({
57
+ "../../node_modules/.pnpm/data-uri-to-buffer@4.0.1/node_modules/data-uri-to-buffer/dist/index.js"() {
58
+ "use strict";
59
+ dist_default = dataUriToBuffer;
60
+ }
61
+ });
62
+
63
+ // ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/errors/base.js
64
+ var FetchBaseError;
65
+ var init_base = __esm({
66
+ "../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/errors/base.js"() {
67
+ "use strict";
68
+ FetchBaseError = class extends Error {
69
+ constructor(message, type) {
70
+ super(message);
71
+ Error.captureStackTrace(this, this.constructor);
72
+ this.type = type;
73
+ }
74
+ get name() {
75
+ return this.constructor.name;
76
+ }
77
+ get [Symbol.toStringTag]() {
78
+ return this.constructor.name;
79
+ }
80
+ };
81
+ }
82
+ });
83
+
84
+ // ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/errors/fetch-error.js
85
+ var FetchError;
86
+ var init_fetch_error = __esm({
87
+ "../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/errors/fetch-error.js"() {
88
+ "use strict";
89
+ init_base();
90
+ FetchError = class extends FetchBaseError {
91
+ /**
92
+ * @param {string} message - Error message for human
93
+ * @param {string} [type] - Error type for machine
94
+ * @param {SystemError} [systemError] - For Node.js system error
95
+ */
96
+ constructor(message, type, systemError) {
97
+ super(message, type);
98
+ if (systemError) {
99
+ this.code = this.errno = systemError.code;
100
+ this.erroredSysCall = systemError.syscall;
101
+ }
102
+ }
103
+ };
104
+ }
105
+ });
106
+
107
+ // ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/is.js
108
+ var NAME, isURLSearchParameters, isBlob, isAbortSignal, isDomainOrSubdomain, isSameProtocol;
109
+ var init_is = __esm({
110
+ "../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/is.js"() {
111
+ "use strict";
112
+ NAME = Symbol.toStringTag;
113
+ isURLSearchParameters = (object) => {
114
+ return typeof object === "object" && typeof object.append === "function" && typeof object.delete === "function" && typeof object.get === "function" && typeof object.getAll === "function" && typeof object.has === "function" && typeof object.set === "function" && typeof object.sort === "function" && object[NAME] === "URLSearchParams";
115
+ };
116
+ isBlob = (object) => {
117
+ return object && typeof object === "object" && typeof object.arrayBuffer === "function" && typeof object.type === "string" && typeof object.stream === "function" && typeof object.constructor === "function" && /^(Blob|File)$/.test(object[NAME]);
118
+ };
119
+ isAbortSignal = (object) => {
120
+ return typeof object === "object" && (object[NAME] === "AbortSignal" || object[NAME] === "EventTarget");
121
+ };
122
+ isDomainOrSubdomain = (destination, original) => {
123
+ const orig = new URL(original).hostname;
124
+ const dest = new URL(destination).hostname;
125
+ return orig === dest || orig.endsWith(`.${dest}`);
126
+ };
127
+ isSameProtocol = (destination, original) => {
128
+ const orig = new URL(original).protocol;
129
+ const dest = new URL(destination).protocol;
130
+ return orig === dest;
131
+ };
132
+ }
133
+ });
134
+
135
+ // ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/body.js
136
+ import Stream, { PassThrough } from "stream";
137
+ import { types, deprecate, promisify } from "util";
138
+ import { Buffer as Buffer2 } from "buffer";
139
+ async function consumeBody(data) {
140
+ if (data[INTERNALS].disturbed) {
141
+ throw new TypeError(`body used already for: ${data.url}`);
142
+ }
143
+ data[INTERNALS].disturbed = true;
144
+ if (data[INTERNALS].error) {
145
+ throw data[INTERNALS].error;
146
+ }
147
+ const { body } = data;
148
+ if (body === null) {
149
+ return Buffer2.alloc(0);
150
+ }
151
+ if (!(body instanceof Stream)) {
152
+ return Buffer2.alloc(0);
153
+ }
154
+ const accum = [];
155
+ let accumBytes = 0;
156
+ try {
157
+ for await (const chunk of body) {
158
+ if (data.size > 0 && accumBytes + chunk.length > data.size) {
159
+ const error = new FetchError(`content size at ${data.url} over limit: ${data.size}`, "max-size");
160
+ body.destroy(error);
161
+ throw error;
162
+ }
163
+ accumBytes += chunk.length;
164
+ accum.push(chunk);
165
+ }
166
+ } catch (error) {
167
+ const error_ = error instanceof FetchBaseError ? error : new FetchError(`Invalid response body while trying to fetch ${data.url}: ${error.message}`, "system", error);
168
+ throw error_;
169
+ }
170
+ if (body.readableEnded === true || body._readableState.ended === true) {
171
+ try {
172
+ if (accum.every((c) => typeof c === "string")) {
173
+ return Buffer2.from(accum.join(""));
174
+ }
175
+ return Buffer2.concat(accum, accumBytes);
176
+ } catch (error) {
177
+ throw new FetchError(`Could not create Buffer from response body for ${data.url}: ${error.message}`, "system", error);
178
+ }
179
+ } else {
180
+ throw new FetchError(`Premature close of server response while trying to fetch ${data.url}`);
181
+ }
182
+ }
183
+ var pipeline, INTERNALS, Body, clone, getNonSpecFormDataBoundary, extractContentType, getTotalBytes, writeToStream;
184
+ var init_body = __esm({
185
+ "../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/body.js"() {
186
+ "use strict";
187
+ init_fetch_blob();
188
+ init_esm_min();
189
+ init_fetch_error();
190
+ init_base();
191
+ init_is();
192
+ pipeline = promisify(Stream.pipeline);
193
+ INTERNALS = /* @__PURE__ */ Symbol("Body internals");
194
+ Body = class {
195
+ constructor(body, {
196
+ size = 0
197
+ } = {}) {
198
+ let boundary = null;
199
+ if (body === null) {
200
+ body = null;
201
+ } else if (isURLSearchParameters(body)) {
202
+ body = Buffer2.from(body.toString());
203
+ } else if (isBlob(body)) {
204
+ } else if (Buffer2.isBuffer(body)) {
205
+ } else if (types.isAnyArrayBuffer(body)) {
206
+ body = Buffer2.from(body);
207
+ } else if (ArrayBuffer.isView(body)) {
208
+ body = Buffer2.from(body.buffer, body.byteOffset, body.byteLength);
209
+ } else if (body instanceof Stream) {
210
+ } else if (body instanceof FormData) {
211
+ body = formDataToBlob(body);
212
+ boundary = body.type.split("=")[1];
213
+ } else {
214
+ body = Buffer2.from(String(body));
215
+ }
216
+ let stream = body;
217
+ if (Buffer2.isBuffer(body)) {
218
+ stream = Stream.Readable.from(body);
219
+ } else if (isBlob(body)) {
220
+ stream = Stream.Readable.from(body.stream());
221
+ }
222
+ this[INTERNALS] = {
223
+ body,
224
+ stream,
225
+ boundary,
226
+ disturbed: false,
227
+ error: null
228
+ };
229
+ this.size = size;
230
+ if (body instanceof Stream) {
231
+ body.on("error", (error_) => {
232
+ const error = error_ instanceof FetchBaseError ? error_ : new FetchError(`Invalid response body while trying to fetch ${this.url}: ${error_.message}`, "system", error_);
233
+ this[INTERNALS].error = error;
234
+ });
235
+ }
236
+ }
237
+ get body() {
238
+ return this[INTERNALS].stream;
239
+ }
240
+ get bodyUsed() {
241
+ return this[INTERNALS].disturbed;
242
+ }
243
+ /**
244
+ * Decode response as ArrayBuffer
245
+ *
246
+ * @return Promise
247
+ */
248
+ async arrayBuffer() {
249
+ const { buffer, byteOffset, byteLength } = await consumeBody(this);
250
+ return buffer.slice(byteOffset, byteOffset + byteLength);
251
+ }
252
+ async formData() {
253
+ const ct = this.headers.get("content-type");
254
+ if (ct.startsWith("application/x-www-form-urlencoded")) {
255
+ const formData = new FormData();
256
+ const parameters = new URLSearchParams(await this.text());
257
+ for (const [name, value] of parameters) {
258
+ formData.append(name, value);
259
+ }
260
+ return formData;
261
+ }
262
+ const { toFormData } = await import("./multipart-parser-DV373IRF.js");
263
+ return toFormData(this.body, ct);
264
+ }
265
+ /**
266
+ * Return raw response as Blob
267
+ *
268
+ * @return Promise
269
+ */
270
+ async blob() {
271
+ const ct = this.headers && this.headers.get("content-type") || this[INTERNALS].body && this[INTERNALS].body.type || "";
272
+ const buf = await this.arrayBuffer();
273
+ return new fetch_blob_default([buf], {
274
+ type: ct
275
+ });
276
+ }
277
+ /**
278
+ * Decode response as json
279
+ *
280
+ * @return Promise
281
+ */
282
+ async json() {
283
+ const text = await this.text();
284
+ return JSON.parse(text);
285
+ }
286
+ /**
287
+ * Decode response as text
288
+ *
289
+ * @return Promise
290
+ */
291
+ async text() {
292
+ const buffer = await consumeBody(this);
293
+ return new TextDecoder().decode(buffer);
294
+ }
295
+ /**
296
+ * Decode response as buffer (non-spec api)
297
+ *
298
+ * @return Promise
299
+ */
300
+ buffer() {
301
+ return consumeBody(this);
302
+ }
303
+ };
304
+ Body.prototype.buffer = deprecate(Body.prototype.buffer, "Please use 'response.arrayBuffer()' instead of 'response.buffer()'", "node-fetch#buffer");
305
+ Object.defineProperties(Body.prototype, {
306
+ body: { enumerable: true },
307
+ bodyUsed: { enumerable: true },
308
+ arrayBuffer: { enumerable: true },
309
+ blob: { enumerable: true },
310
+ json: { enumerable: true },
311
+ text: { enumerable: true },
312
+ data: { get: deprecate(
313
+ () => {
314
+ },
315
+ "data doesn't exist, use json(), text(), arrayBuffer(), or body instead",
316
+ "https://github.com/node-fetch/node-fetch/issues/1000 (response)"
317
+ ) }
318
+ });
319
+ clone = (instance, highWaterMark) => {
320
+ let p1;
321
+ let p2;
322
+ let { body } = instance[INTERNALS];
323
+ if (instance.bodyUsed) {
324
+ throw new Error("cannot clone body after it is used");
325
+ }
326
+ if (body instanceof Stream && typeof body.getBoundary !== "function") {
327
+ p1 = new PassThrough({ highWaterMark });
328
+ p2 = new PassThrough({ highWaterMark });
329
+ body.pipe(p1);
330
+ body.pipe(p2);
331
+ instance[INTERNALS].stream = p1;
332
+ body = p2;
333
+ }
334
+ return body;
335
+ };
336
+ getNonSpecFormDataBoundary = deprecate(
337
+ (body) => body.getBoundary(),
338
+ "form-data doesn't follow the spec and requires special treatment. Use alternative package",
339
+ "https://github.com/node-fetch/node-fetch/issues/1167"
340
+ );
341
+ extractContentType = (body, request) => {
342
+ if (body === null) {
343
+ return null;
344
+ }
345
+ if (typeof body === "string") {
346
+ return "text/plain;charset=UTF-8";
347
+ }
348
+ if (isURLSearchParameters(body)) {
349
+ return "application/x-www-form-urlencoded;charset=UTF-8";
350
+ }
351
+ if (isBlob(body)) {
352
+ return body.type || null;
353
+ }
354
+ if (Buffer2.isBuffer(body) || types.isAnyArrayBuffer(body) || ArrayBuffer.isView(body)) {
355
+ return null;
356
+ }
357
+ if (body instanceof FormData) {
358
+ return `multipart/form-data; boundary=${request[INTERNALS].boundary}`;
359
+ }
360
+ if (body && typeof body.getBoundary === "function") {
361
+ return `multipart/form-data;boundary=${getNonSpecFormDataBoundary(body)}`;
362
+ }
363
+ if (body instanceof Stream) {
364
+ return null;
365
+ }
366
+ return "text/plain;charset=UTF-8";
367
+ };
368
+ getTotalBytes = (request) => {
369
+ const { body } = request[INTERNALS];
370
+ if (body === null) {
371
+ return 0;
372
+ }
373
+ if (isBlob(body)) {
374
+ return body.size;
375
+ }
376
+ if (Buffer2.isBuffer(body)) {
377
+ return body.length;
378
+ }
379
+ if (body && typeof body.getLengthSync === "function") {
380
+ return body.hasKnownLength && body.hasKnownLength() ? body.getLengthSync() : null;
381
+ }
382
+ return null;
383
+ };
384
+ writeToStream = async (dest, { body }) => {
385
+ if (body === null) {
386
+ dest.end();
387
+ } else {
388
+ await pipeline(body, dest);
389
+ }
390
+ };
391
+ }
392
+ });
393
+
394
+ // ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/headers.js
395
+ import { types as types2 } from "util";
396
+ import http from "http";
397
+ function fromRawHeaders(headers = []) {
398
+ return new Headers(
399
+ headers.reduce((result, value, index, array) => {
400
+ if (index % 2 === 0) {
401
+ result.push(array.slice(index, index + 2));
402
+ }
403
+ return result;
404
+ }, []).filter(([name, value]) => {
405
+ try {
406
+ validateHeaderName(name);
407
+ validateHeaderValue(name, String(value));
408
+ return true;
409
+ } catch {
410
+ return false;
411
+ }
412
+ })
413
+ );
414
+ }
415
+ var validateHeaderName, validateHeaderValue, Headers;
416
+ var init_headers = __esm({
417
+ "../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/headers.js"() {
418
+ "use strict";
419
+ validateHeaderName = typeof http.validateHeaderName === "function" ? http.validateHeaderName : (name) => {
420
+ if (!/^[\^`\-\w!#$%&'*+.|~]+$/.test(name)) {
421
+ const error = new TypeError(`Header name must be a valid HTTP token [${name}]`);
422
+ Object.defineProperty(error, "code", { value: "ERR_INVALID_HTTP_TOKEN" });
423
+ throw error;
424
+ }
425
+ };
426
+ validateHeaderValue = typeof http.validateHeaderValue === "function" ? http.validateHeaderValue : (name, value) => {
427
+ if (/[^\t\u0020-\u007E\u0080-\u00FF]/.test(value)) {
428
+ const error = new TypeError(`Invalid character in header content ["${name}"]`);
429
+ Object.defineProperty(error, "code", { value: "ERR_INVALID_CHAR" });
430
+ throw error;
431
+ }
432
+ };
433
+ Headers = class _Headers extends URLSearchParams {
434
+ /**
435
+ * Headers class
436
+ *
437
+ * @constructor
438
+ * @param {HeadersInit} [init] - Response headers
439
+ */
440
+ constructor(init) {
441
+ let result = [];
442
+ if (init instanceof _Headers) {
443
+ const raw = init.raw();
444
+ for (const [name, values] of Object.entries(raw)) {
445
+ result.push(...values.map((value) => [name, value]));
446
+ }
447
+ } else if (init == null) {
448
+ } else if (typeof init === "object" && !types2.isBoxedPrimitive(init)) {
449
+ const method = init[Symbol.iterator];
450
+ if (method == null) {
451
+ result.push(...Object.entries(init));
452
+ } else {
453
+ if (typeof method !== "function") {
454
+ throw new TypeError("Header pairs must be iterable");
455
+ }
456
+ result = [...init].map((pair) => {
457
+ if (typeof pair !== "object" || types2.isBoxedPrimitive(pair)) {
458
+ throw new TypeError("Each header pair must be an iterable object");
459
+ }
460
+ return [...pair];
461
+ }).map((pair) => {
462
+ if (pair.length !== 2) {
463
+ throw new TypeError("Each header pair must be a name/value tuple");
464
+ }
465
+ return [...pair];
466
+ });
467
+ }
468
+ } else {
469
+ throw new TypeError("Failed to construct 'Headers': The provided value is not of type '(sequence<sequence<ByteString>> or record<ByteString, ByteString>)");
470
+ }
471
+ result = result.length > 0 ? result.map(([name, value]) => {
472
+ validateHeaderName(name);
473
+ validateHeaderValue(name, String(value));
474
+ return [String(name).toLowerCase(), String(value)];
475
+ }) : void 0;
476
+ super(result);
477
+ return new Proxy(this, {
478
+ get(target, p, receiver) {
479
+ switch (p) {
480
+ case "append":
481
+ case "set":
482
+ return (name, value) => {
483
+ validateHeaderName(name);
484
+ validateHeaderValue(name, String(value));
485
+ return URLSearchParams.prototype[p].call(
486
+ target,
487
+ String(name).toLowerCase(),
488
+ String(value)
489
+ );
490
+ };
491
+ case "delete":
492
+ case "has":
493
+ case "getAll":
494
+ return (name) => {
495
+ validateHeaderName(name);
496
+ return URLSearchParams.prototype[p].call(
497
+ target,
498
+ String(name).toLowerCase()
499
+ );
500
+ };
501
+ case "keys":
502
+ return () => {
503
+ target.sort();
504
+ return new Set(URLSearchParams.prototype.keys.call(target)).keys();
505
+ };
506
+ default:
507
+ return Reflect.get(target, p, receiver);
508
+ }
509
+ }
510
+ });
511
+ }
512
+ get [Symbol.toStringTag]() {
513
+ return this.constructor.name;
514
+ }
515
+ toString() {
516
+ return Object.prototype.toString.call(this);
517
+ }
518
+ get(name) {
519
+ const values = this.getAll(name);
520
+ if (values.length === 0) {
521
+ return null;
522
+ }
523
+ let value = values.join(", ");
524
+ if (/^content-encoding$/i.test(name)) {
525
+ value = value.toLowerCase();
526
+ }
527
+ return value;
528
+ }
529
+ forEach(callback, thisArg = void 0) {
530
+ for (const name of this.keys()) {
531
+ Reflect.apply(callback, thisArg, [this.get(name), name, this]);
532
+ }
533
+ }
534
+ *values() {
535
+ for (const name of this.keys()) {
536
+ yield this.get(name);
537
+ }
538
+ }
539
+ /**
540
+ * @type {() => IterableIterator<[string, string]>}
541
+ */
542
+ *entries() {
543
+ for (const name of this.keys()) {
544
+ yield [name, this.get(name)];
545
+ }
546
+ }
547
+ [Symbol.iterator]() {
548
+ return this.entries();
549
+ }
550
+ /**
551
+ * Node-fetch non-spec method
552
+ * returning all headers and their values as array
553
+ * @returns {Record<string, string[]>}
554
+ */
555
+ raw() {
556
+ return [...this.keys()].reduce((result, key) => {
557
+ result[key] = this.getAll(key);
558
+ return result;
559
+ }, {});
560
+ }
561
+ /**
562
+ * For better console.log(headers) and also to convert Headers into Node.js Request compatible format
563
+ */
564
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")]() {
565
+ return [...this.keys()].reduce((result, key) => {
566
+ const values = this.getAll(key);
567
+ if (key === "host") {
568
+ result[key] = values[0];
569
+ } else {
570
+ result[key] = values.length > 1 ? values : values[0];
571
+ }
572
+ return result;
573
+ }, {});
574
+ }
575
+ };
576
+ Object.defineProperties(
577
+ Headers.prototype,
578
+ ["get", "entries", "forEach", "values"].reduce((result, property) => {
579
+ result[property] = { enumerable: true };
580
+ return result;
581
+ }, {})
582
+ );
583
+ }
584
+ });
585
+
586
+ // ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/is-redirect.js
587
+ var redirectStatus, isRedirect;
588
+ var init_is_redirect = __esm({
589
+ "../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/is-redirect.js"() {
590
+ "use strict";
591
+ redirectStatus = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
592
+ isRedirect = (code) => {
593
+ return redirectStatus.has(code);
594
+ };
595
+ }
596
+ });
597
+
598
+ // ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/response.js
599
+ var INTERNALS2, Response;
600
+ var init_response = __esm({
601
+ "../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/response.js"() {
602
+ "use strict";
603
+ init_headers();
604
+ init_body();
605
+ init_is_redirect();
606
+ INTERNALS2 = /* @__PURE__ */ Symbol("Response internals");
607
+ Response = class _Response extends Body {
608
+ constructor(body = null, options = {}) {
609
+ super(body, options);
610
+ const status = options.status != null ? options.status : 200;
611
+ const headers = new Headers(options.headers);
612
+ if (body !== null && !headers.has("Content-Type")) {
613
+ const contentType = extractContentType(body, this);
614
+ if (contentType) {
615
+ headers.append("Content-Type", contentType);
616
+ }
617
+ }
618
+ this[INTERNALS2] = {
619
+ type: "default",
620
+ url: options.url,
621
+ status,
622
+ statusText: options.statusText || "",
623
+ headers,
624
+ counter: options.counter,
625
+ highWaterMark: options.highWaterMark
626
+ };
627
+ }
628
+ get type() {
629
+ return this[INTERNALS2].type;
630
+ }
631
+ get url() {
632
+ return this[INTERNALS2].url || "";
633
+ }
634
+ get status() {
635
+ return this[INTERNALS2].status;
636
+ }
637
+ /**
638
+ * Convenience property representing if the request ended normally
639
+ */
640
+ get ok() {
641
+ return this[INTERNALS2].status >= 200 && this[INTERNALS2].status < 300;
642
+ }
643
+ get redirected() {
644
+ return this[INTERNALS2].counter > 0;
645
+ }
646
+ get statusText() {
647
+ return this[INTERNALS2].statusText;
648
+ }
649
+ get headers() {
650
+ return this[INTERNALS2].headers;
651
+ }
652
+ get highWaterMark() {
653
+ return this[INTERNALS2].highWaterMark;
654
+ }
655
+ /**
656
+ * Clone this response
657
+ *
658
+ * @return Response
659
+ */
660
+ clone() {
661
+ return new _Response(clone(this, this.highWaterMark), {
662
+ type: this.type,
663
+ url: this.url,
664
+ status: this.status,
665
+ statusText: this.statusText,
666
+ headers: this.headers,
667
+ ok: this.ok,
668
+ redirected: this.redirected,
669
+ size: this.size,
670
+ highWaterMark: this.highWaterMark
671
+ });
672
+ }
673
+ /**
674
+ * @param {string} url The URL that the new response is to originate from.
675
+ * @param {number} status An optional status code for the response (e.g., 302.)
676
+ * @returns {Response} A Response object.
677
+ */
678
+ static redirect(url, status = 302) {
679
+ if (!isRedirect(status)) {
680
+ throw new RangeError('Failed to execute "redirect" on "response": Invalid status code');
681
+ }
682
+ return new _Response(null, {
683
+ headers: {
684
+ location: new URL(url).toString()
685
+ },
686
+ status
687
+ });
688
+ }
689
+ static error() {
690
+ const response = new _Response(null, { status: 0, statusText: "" });
691
+ response[INTERNALS2].type = "error";
692
+ return response;
693
+ }
694
+ static json(data = void 0, init = {}) {
695
+ const body = JSON.stringify(data);
696
+ if (body === void 0) {
697
+ throw new TypeError("data is not JSON serializable");
698
+ }
699
+ const headers = new Headers(init && init.headers);
700
+ if (!headers.has("content-type")) {
701
+ headers.set("content-type", "application/json");
702
+ }
703
+ return new _Response(body, {
704
+ ...init,
705
+ headers
706
+ });
707
+ }
708
+ get [Symbol.toStringTag]() {
709
+ return "Response";
710
+ }
711
+ };
712
+ Object.defineProperties(Response.prototype, {
713
+ type: { enumerable: true },
714
+ url: { enumerable: true },
715
+ status: { enumerable: true },
716
+ ok: { enumerable: true },
717
+ redirected: { enumerable: true },
718
+ statusText: { enumerable: true },
719
+ headers: { enumerable: true },
720
+ clone: { enumerable: true }
721
+ });
722
+ }
723
+ });
724
+
725
+ // ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/get-search.js
726
+ var getSearch;
727
+ var init_get_search = __esm({
728
+ "../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/get-search.js"() {
729
+ "use strict";
730
+ getSearch = (parsedURL) => {
731
+ if (parsedURL.search) {
732
+ return parsedURL.search;
733
+ }
734
+ const lastOffset = parsedURL.href.length - 1;
735
+ const hash = parsedURL.hash || (parsedURL.href[lastOffset] === "#" ? "#" : "");
736
+ return parsedURL.href[lastOffset - hash.length] === "?" ? "?" : "";
737
+ };
738
+ }
739
+ });
740
+
741
+ // ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/referrer.js
742
+ import { isIP } from "net";
743
+ function stripURLForUseAsAReferrer(url, originOnly = false) {
744
+ if (url == null) {
745
+ return "no-referrer";
746
+ }
747
+ url = new URL(url);
748
+ if (/^(about|blob|data):$/.test(url.protocol)) {
749
+ return "no-referrer";
750
+ }
751
+ url.username = "";
752
+ url.password = "";
753
+ url.hash = "";
754
+ if (originOnly) {
755
+ url.pathname = "";
756
+ url.search = "";
757
+ }
758
+ return url;
759
+ }
760
+ function validateReferrerPolicy(referrerPolicy) {
761
+ if (!ReferrerPolicy.has(referrerPolicy)) {
762
+ throw new TypeError(`Invalid referrerPolicy: ${referrerPolicy}`);
763
+ }
764
+ return referrerPolicy;
765
+ }
766
+ function isOriginPotentiallyTrustworthy(url) {
767
+ if (/^(http|ws)s:$/.test(url.protocol)) {
768
+ return true;
769
+ }
770
+ const hostIp = url.host.replace(/(^\[)|(]$)/g, "");
771
+ const hostIPVersion = isIP(hostIp);
772
+ if (hostIPVersion === 4 && /^127\./.test(hostIp)) {
773
+ return true;
774
+ }
775
+ if (hostIPVersion === 6 && /^(((0+:){7})|(::(0+:){0,6}))0*1$/.test(hostIp)) {
776
+ return true;
777
+ }
778
+ if (url.host === "localhost" || url.host.endsWith(".localhost")) {
779
+ return false;
780
+ }
781
+ if (url.protocol === "file:") {
782
+ return true;
783
+ }
784
+ return false;
785
+ }
786
+ function isUrlPotentiallyTrustworthy(url) {
787
+ if (/^about:(blank|srcdoc)$/.test(url)) {
788
+ return true;
789
+ }
790
+ if (url.protocol === "data:") {
791
+ return true;
792
+ }
793
+ if (/^(blob|filesystem):$/.test(url.protocol)) {
794
+ return true;
795
+ }
796
+ return isOriginPotentiallyTrustworthy(url);
797
+ }
798
+ function determineRequestsReferrer(request, { referrerURLCallback, referrerOriginCallback } = {}) {
799
+ if (request.referrer === "no-referrer" || request.referrerPolicy === "") {
800
+ return null;
801
+ }
802
+ const policy = request.referrerPolicy;
803
+ if (request.referrer === "about:client") {
804
+ return "no-referrer";
805
+ }
806
+ const referrerSource = request.referrer;
807
+ let referrerURL = stripURLForUseAsAReferrer(referrerSource);
808
+ let referrerOrigin = stripURLForUseAsAReferrer(referrerSource, true);
809
+ if (referrerURL.toString().length > 4096) {
810
+ referrerURL = referrerOrigin;
811
+ }
812
+ if (referrerURLCallback) {
813
+ referrerURL = referrerURLCallback(referrerURL);
814
+ }
815
+ if (referrerOriginCallback) {
816
+ referrerOrigin = referrerOriginCallback(referrerOrigin);
817
+ }
818
+ const currentURL = new URL(request.url);
819
+ switch (policy) {
820
+ case "no-referrer":
821
+ return "no-referrer";
822
+ case "origin":
823
+ return referrerOrigin;
824
+ case "unsafe-url":
825
+ return referrerURL;
826
+ case "strict-origin":
827
+ if (isUrlPotentiallyTrustworthy(referrerURL) && !isUrlPotentiallyTrustworthy(currentURL)) {
828
+ return "no-referrer";
829
+ }
830
+ return referrerOrigin.toString();
831
+ case "strict-origin-when-cross-origin":
832
+ if (referrerURL.origin === currentURL.origin) {
833
+ return referrerURL;
834
+ }
835
+ if (isUrlPotentiallyTrustworthy(referrerURL) && !isUrlPotentiallyTrustworthy(currentURL)) {
836
+ return "no-referrer";
837
+ }
838
+ return referrerOrigin;
839
+ case "same-origin":
840
+ if (referrerURL.origin === currentURL.origin) {
841
+ return referrerURL;
842
+ }
843
+ return "no-referrer";
844
+ case "origin-when-cross-origin":
845
+ if (referrerURL.origin === currentURL.origin) {
846
+ return referrerURL;
847
+ }
848
+ return referrerOrigin;
849
+ case "no-referrer-when-downgrade":
850
+ if (isUrlPotentiallyTrustworthy(referrerURL) && !isUrlPotentiallyTrustworthy(currentURL)) {
851
+ return "no-referrer";
852
+ }
853
+ return referrerURL;
854
+ default:
855
+ throw new TypeError(`Invalid referrerPolicy: ${policy}`);
856
+ }
857
+ }
858
+ function parseReferrerPolicyFromHeader(headers) {
859
+ const policyTokens = (headers.get("referrer-policy") || "").split(/[,\s]+/);
860
+ let policy = "";
861
+ for (const token of policyTokens) {
862
+ if (token && ReferrerPolicy.has(token)) {
863
+ policy = token;
864
+ }
865
+ }
866
+ return policy;
867
+ }
868
+ var ReferrerPolicy, DEFAULT_REFERRER_POLICY;
869
+ var init_referrer = __esm({
870
+ "../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/referrer.js"() {
871
+ "use strict";
872
+ ReferrerPolicy = /* @__PURE__ */ new Set([
873
+ "",
874
+ "no-referrer",
875
+ "no-referrer-when-downgrade",
876
+ "same-origin",
877
+ "origin",
878
+ "strict-origin",
879
+ "origin-when-cross-origin",
880
+ "strict-origin-when-cross-origin",
881
+ "unsafe-url"
882
+ ]);
883
+ DEFAULT_REFERRER_POLICY = "strict-origin-when-cross-origin";
884
+ }
885
+ });
886
+
887
+ // ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/request.js
888
+ import { format as formatUrl } from "url";
889
+ import { deprecate as deprecate2 } from "util";
890
+ var INTERNALS3, isRequest, doBadDataWarn, Request, getNodeRequestOptions;
891
+ var init_request = __esm({
892
+ "../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/request.js"() {
893
+ "use strict";
894
+ init_headers();
895
+ init_body();
896
+ init_is();
897
+ init_get_search();
898
+ init_referrer();
899
+ INTERNALS3 = /* @__PURE__ */ Symbol("Request internals");
900
+ isRequest = (object) => {
901
+ return typeof object === "object" && typeof object[INTERNALS3] === "object";
902
+ };
903
+ doBadDataWarn = deprecate2(
904
+ () => {
905
+ },
906
+ ".data is not a valid RequestInit property, use .body instead",
907
+ "https://github.com/node-fetch/node-fetch/issues/1000 (request)"
908
+ );
909
+ Request = class _Request extends Body {
910
+ constructor(input, init = {}) {
911
+ let parsedURL;
912
+ if (isRequest(input)) {
913
+ parsedURL = new URL(input.url);
914
+ } else {
915
+ parsedURL = new URL(input);
916
+ input = {};
917
+ }
918
+ if (parsedURL.username !== "" || parsedURL.password !== "") {
919
+ throw new TypeError(`${parsedURL} is an url with embedded credentials.`);
920
+ }
921
+ let method = init.method || input.method || "GET";
922
+ if (/^(delete|get|head|options|post|put)$/i.test(method)) {
923
+ method = method.toUpperCase();
924
+ }
925
+ if (!isRequest(init) && "data" in init) {
926
+ doBadDataWarn();
927
+ }
928
+ if ((init.body != null || isRequest(input) && input.body !== null) && (method === "GET" || method === "HEAD")) {
929
+ throw new TypeError("Request with GET/HEAD method cannot have body");
930
+ }
931
+ const inputBody = init.body ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;
932
+ super(inputBody, {
933
+ size: init.size || input.size || 0
934
+ });
935
+ const headers = new Headers(init.headers || input.headers || {});
936
+ if (inputBody !== null && !headers.has("Content-Type")) {
937
+ const contentType = extractContentType(inputBody, this);
938
+ if (contentType) {
939
+ headers.set("Content-Type", contentType);
940
+ }
941
+ }
942
+ let signal = isRequest(input) ? input.signal : null;
943
+ if ("signal" in init) {
944
+ signal = init.signal;
945
+ }
946
+ if (signal != null && !isAbortSignal(signal)) {
947
+ throw new TypeError("Expected signal to be an instanceof AbortSignal or EventTarget");
948
+ }
949
+ let referrer = init.referrer == null ? input.referrer : init.referrer;
950
+ if (referrer === "") {
951
+ referrer = "no-referrer";
952
+ } else if (referrer) {
953
+ const parsedReferrer = new URL(referrer);
954
+ referrer = /^about:(\/\/)?client$/.test(parsedReferrer) ? "client" : parsedReferrer;
955
+ } else {
956
+ referrer = void 0;
957
+ }
958
+ this[INTERNALS3] = {
959
+ method,
960
+ redirect: init.redirect || input.redirect || "follow",
961
+ headers,
962
+ parsedURL,
963
+ signal,
964
+ referrer
965
+ };
966
+ this.follow = init.follow === void 0 ? input.follow === void 0 ? 20 : input.follow : init.follow;
967
+ this.compress = init.compress === void 0 ? input.compress === void 0 ? true : input.compress : init.compress;
968
+ this.counter = init.counter || input.counter || 0;
969
+ this.agent = init.agent || input.agent;
970
+ this.highWaterMark = init.highWaterMark || input.highWaterMark || 16384;
971
+ this.insecureHTTPParser = init.insecureHTTPParser || input.insecureHTTPParser || false;
972
+ this.referrerPolicy = init.referrerPolicy || input.referrerPolicy || "";
973
+ }
974
+ /** @returns {string} */
975
+ get method() {
976
+ return this[INTERNALS3].method;
977
+ }
978
+ /** @returns {string} */
979
+ get url() {
980
+ return formatUrl(this[INTERNALS3].parsedURL);
981
+ }
982
+ /** @returns {Headers} */
983
+ get headers() {
984
+ return this[INTERNALS3].headers;
985
+ }
986
+ get redirect() {
987
+ return this[INTERNALS3].redirect;
988
+ }
989
+ /** @returns {AbortSignal} */
990
+ get signal() {
991
+ return this[INTERNALS3].signal;
992
+ }
993
+ // https://fetch.spec.whatwg.org/#dom-request-referrer
994
+ get referrer() {
995
+ if (this[INTERNALS3].referrer === "no-referrer") {
996
+ return "";
997
+ }
998
+ if (this[INTERNALS3].referrer === "client") {
999
+ return "about:client";
1000
+ }
1001
+ if (this[INTERNALS3].referrer) {
1002
+ return this[INTERNALS3].referrer.toString();
1003
+ }
1004
+ return void 0;
1005
+ }
1006
+ get referrerPolicy() {
1007
+ return this[INTERNALS3].referrerPolicy;
1008
+ }
1009
+ set referrerPolicy(referrerPolicy) {
1010
+ this[INTERNALS3].referrerPolicy = validateReferrerPolicy(referrerPolicy);
1011
+ }
1012
+ /**
1013
+ * Clone this request
1014
+ *
1015
+ * @return Request
1016
+ */
1017
+ clone() {
1018
+ return new _Request(this);
1019
+ }
1020
+ get [Symbol.toStringTag]() {
1021
+ return "Request";
1022
+ }
1023
+ };
1024
+ Object.defineProperties(Request.prototype, {
1025
+ method: { enumerable: true },
1026
+ url: { enumerable: true },
1027
+ headers: { enumerable: true },
1028
+ redirect: { enumerable: true },
1029
+ clone: { enumerable: true },
1030
+ signal: { enumerable: true },
1031
+ referrer: { enumerable: true },
1032
+ referrerPolicy: { enumerable: true }
1033
+ });
1034
+ getNodeRequestOptions = (request) => {
1035
+ const { parsedURL } = request[INTERNALS3];
1036
+ const headers = new Headers(request[INTERNALS3].headers);
1037
+ if (!headers.has("Accept")) {
1038
+ headers.set("Accept", "*/*");
1039
+ }
1040
+ let contentLengthValue = null;
1041
+ if (request.body === null && /^(post|put)$/i.test(request.method)) {
1042
+ contentLengthValue = "0";
1043
+ }
1044
+ if (request.body !== null) {
1045
+ const totalBytes = getTotalBytes(request);
1046
+ if (typeof totalBytes === "number" && !Number.isNaN(totalBytes)) {
1047
+ contentLengthValue = String(totalBytes);
1048
+ }
1049
+ }
1050
+ if (contentLengthValue) {
1051
+ headers.set("Content-Length", contentLengthValue);
1052
+ }
1053
+ if (request.referrerPolicy === "") {
1054
+ request.referrerPolicy = DEFAULT_REFERRER_POLICY;
1055
+ }
1056
+ if (request.referrer && request.referrer !== "no-referrer") {
1057
+ request[INTERNALS3].referrer = determineRequestsReferrer(request);
1058
+ } else {
1059
+ request[INTERNALS3].referrer = "no-referrer";
1060
+ }
1061
+ if (request[INTERNALS3].referrer instanceof URL) {
1062
+ headers.set("Referer", request.referrer);
1063
+ }
1064
+ if (!headers.has("User-Agent")) {
1065
+ headers.set("User-Agent", "node-fetch");
1066
+ }
1067
+ if (request.compress && !headers.has("Accept-Encoding")) {
1068
+ headers.set("Accept-Encoding", "gzip, deflate, br");
1069
+ }
1070
+ let { agent } = request;
1071
+ if (typeof agent === "function") {
1072
+ agent = agent(parsedURL);
1073
+ }
1074
+ const search = getSearch(parsedURL);
1075
+ const options = {
1076
+ // Overwrite search to retain trailing ? (issue #776)
1077
+ path: parsedURL.pathname + search,
1078
+ // The following options are not expressed in the URL
1079
+ method: request.method,
1080
+ headers: headers[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")](),
1081
+ insecureHTTPParser: request.insecureHTTPParser,
1082
+ agent
1083
+ };
1084
+ return {
1085
+ /** @type {URL} */
1086
+ parsedURL,
1087
+ options
1088
+ };
1089
+ };
1090
+ }
1091
+ });
1092
+
1093
+ // ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/errors/abort-error.js
1094
+ var AbortError;
1095
+ var init_abort_error = __esm({
1096
+ "../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/errors/abort-error.js"() {
1097
+ "use strict";
1098
+ init_base();
1099
+ AbortError = class extends FetchBaseError {
1100
+ constructor(message, type = "aborted") {
1101
+ super(message, type);
1102
+ }
1103
+ };
1104
+ }
1105
+ });
1106
+
1107
+ // ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/index.js
1108
+ import http2 from "http";
1109
+ import https from "https";
1110
+ import zlib from "zlib";
1111
+ import Stream2, { PassThrough as PassThrough2, pipeline as pump } from "stream";
1112
+ import { Buffer as Buffer3 } from "buffer";
1113
+ async function fetch(url, options_) {
1114
+ return new Promise((resolve, reject) => {
1115
+ const request = new Request(url, options_);
1116
+ const { parsedURL, options } = getNodeRequestOptions(request);
1117
+ if (!supportedSchemas.has(parsedURL.protocol)) {
1118
+ throw new TypeError(`node-fetch cannot load ${url}. URL scheme "${parsedURL.protocol.replace(/:$/, "")}" is not supported.`);
1119
+ }
1120
+ if (parsedURL.protocol === "data:") {
1121
+ const data = dist_default(request.url);
1122
+ const response2 = new Response(data, { headers: { "Content-Type": data.typeFull } });
1123
+ resolve(response2);
1124
+ return;
1125
+ }
1126
+ const send = (parsedURL.protocol === "https:" ? https : http2).request;
1127
+ const { signal } = request;
1128
+ let response = null;
1129
+ const abort = () => {
1130
+ const error = new AbortError("The operation was aborted.");
1131
+ reject(error);
1132
+ if (request.body && request.body instanceof Stream2.Readable) {
1133
+ request.body.destroy(error);
1134
+ }
1135
+ if (!response || !response.body) {
1136
+ return;
1137
+ }
1138
+ response.body.emit("error", error);
1139
+ };
1140
+ if (signal && signal.aborted) {
1141
+ abort();
1142
+ return;
1143
+ }
1144
+ const abortAndFinalize = () => {
1145
+ abort();
1146
+ finalize();
1147
+ };
1148
+ const request_ = send(parsedURL.toString(), options);
1149
+ if (signal) {
1150
+ signal.addEventListener("abort", abortAndFinalize);
1151
+ }
1152
+ const finalize = () => {
1153
+ request_.abort();
1154
+ if (signal) {
1155
+ signal.removeEventListener("abort", abortAndFinalize);
1156
+ }
1157
+ };
1158
+ request_.on("error", (error) => {
1159
+ reject(new FetchError(`request to ${request.url} failed, reason: ${error.message}`, "system", error));
1160
+ finalize();
1161
+ });
1162
+ fixResponseChunkedTransferBadEnding(request_, (error) => {
1163
+ if (response && response.body) {
1164
+ response.body.destroy(error);
1165
+ }
1166
+ });
1167
+ if (process.version < "v14") {
1168
+ request_.on("socket", (s) => {
1169
+ let endedWithEventsCount;
1170
+ s.prependListener("end", () => {
1171
+ endedWithEventsCount = s._eventsCount;
1172
+ });
1173
+ s.prependListener("close", (hadError) => {
1174
+ if (response && endedWithEventsCount < s._eventsCount && !hadError) {
1175
+ const error = new Error("Premature close");
1176
+ error.code = "ERR_STREAM_PREMATURE_CLOSE";
1177
+ response.body.emit("error", error);
1178
+ }
1179
+ });
1180
+ });
1181
+ }
1182
+ request_.on("response", (response_) => {
1183
+ request_.setTimeout(0);
1184
+ const headers = fromRawHeaders(response_.rawHeaders);
1185
+ if (isRedirect(response_.statusCode)) {
1186
+ const location = headers.get("Location");
1187
+ let locationURL = null;
1188
+ try {
1189
+ locationURL = location === null ? null : new URL(location, request.url);
1190
+ } catch {
1191
+ if (request.redirect !== "manual") {
1192
+ reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, "invalid-redirect"));
1193
+ finalize();
1194
+ return;
1195
+ }
1196
+ }
1197
+ switch (request.redirect) {
1198
+ case "error":
1199
+ reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, "no-redirect"));
1200
+ finalize();
1201
+ return;
1202
+ case "manual":
1203
+ break;
1204
+ case "follow": {
1205
+ if (locationURL === null) {
1206
+ break;
1207
+ }
1208
+ if (request.counter >= request.follow) {
1209
+ reject(new FetchError(`maximum redirect reached at: ${request.url}`, "max-redirect"));
1210
+ finalize();
1211
+ return;
1212
+ }
1213
+ const requestOptions = {
1214
+ headers: new Headers(request.headers),
1215
+ follow: request.follow,
1216
+ counter: request.counter + 1,
1217
+ agent: request.agent,
1218
+ compress: request.compress,
1219
+ method: request.method,
1220
+ body: clone(request),
1221
+ signal: request.signal,
1222
+ size: request.size,
1223
+ referrer: request.referrer,
1224
+ referrerPolicy: request.referrerPolicy
1225
+ };
1226
+ if (!isDomainOrSubdomain(request.url, locationURL) || !isSameProtocol(request.url, locationURL)) {
1227
+ for (const name of ["authorization", "www-authenticate", "cookie", "cookie2"]) {
1228
+ requestOptions.headers.delete(name);
1229
+ }
1230
+ }
1231
+ if (response_.statusCode !== 303 && request.body && options_.body instanceof Stream2.Readable) {
1232
+ reject(new FetchError("Cannot follow redirect with body being a readable stream", "unsupported-redirect"));
1233
+ finalize();
1234
+ return;
1235
+ }
1236
+ if (response_.statusCode === 303 || (response_.statusCode === 301 || response_.statusCode === 302) && request.method === "POST") {
1237
+ requestOptions.method = "GET";
1238
+ requestOptions.body = void 0;
1239
+ requestOptions.headers.delete("content-length");
1240
+ }
1241
+ const responseReferrerPolicy = parseReferrerPolicyFromHeader(headers);
1242
+ if (responseReferrerPolicy) {
1243
+ requestOptions.referrerPolicy = responseReferrerPolicy;
1244
+ }
1245
+ resolve(fetch(new Request(locationURL, requestOptions)));
1246
+ finalize();
1247
+ return;
1248
+ }
1249
+ default:
1250
+ return reject(new TypeError(`Redirect option '${request.redirect}' is not a valid value of RequestRedirect`));
1251
+ }
1252
+ }
1253
+ if (signal) {
1254
+ response_.once("end", () => {
1255
+ signal.removeEventListener("abort", abortAndFinalize);
1256
+ });
1257
+ }
1258
+ let body = pump(response_, new PassThrough2(), (error) => {
1259
+ if (error) {
1260
+ reject(error);
1261
+ }
1262
+ });
1263
+ if (process.version < "v12.10") {
1264
+ response_.on("aborted", abortAndFinalize);
1265
+ }
1266
+ const responseOptions = {
1267
+ url: request.url,
1268
+ status: response_.statusCode,
1269
+ statusText: response_.statusMessage,
1270
+ headers,
1271
+ size: request.size,
1272
+ counter: request.counter,
1273
+ highWaterMark: request.highWaterMark
1274
+ };
1275
+ const codings = headers.get("Content-Encoding");
1276
+ if (!request.compress || request.method === "HEAD" || codings === null || response_.statusCode === 204 || response_.statusCode === 304) {
1277
+ response = new Response(body, responseOptions);
1278
+ resolve(response);
1279
+ return;
1280
+ }
1281
+ const zlibOptions = {
1282
+ flush: zlib.Z_SYNC_FLUSH,
1283
+ finishFlush: zlib.Z_SYNC_FLUSH
1284
+ };
1285
+ if (codings === "gzip" || codings === "x-gzip") {
1286
+ body = pump(body, zlib.createGunzip(zlibOptions), (error) => {
1287
+ if (error) {
1288
+ reject(error);
1289
+ }
1290
+ });
1291
+ response = new Response(body, responseOptions);
1292
+ resolve(response);
1293
+ return;
1294
+ }
1295
+ if (codings === "deflate" || codings === "x-deflate") {
1296
+ const raw = pump(response_, new PassThrough2(), (error) => {
1297
+ if (error) {
1298
+ reject(error);
1299
+ }
1300
+ });
1301
+ raw.once("data", (chunk) => {
1302
+ if ((chunk[0] & 15) === 8) {
1303
+ body = pump(body, zlib.createInflate(), (error) => {
1304
+ if (error) {
1305
+ reject(error);
1306
+ }
1307
+ });
1308
+ } else {
1309
+ body = pump(body, zlib.createInflateRaw(), (error) => {
1310
+ if (error) {
1311
+ reject(error);
1312
+ }
1313
+ });
1314
+ }
1315
+ response = new Response(body, responseOptions);
1316
+ resolve(response);
1317
+ });
1318
+ raw.once("end", () => {
1319
+ if (!response) {
1320
+ response = new Response(body, responseOptions);
1321
+ resolve(response);
1322
+ }
1323
+ });
1324
+ return;
1325
+ }
1326
+ if (codings === "br") {
1327
+ body = pump(body, zlib.createBrotliDecompress(), (error) => {
1328
+ if (error) {
1329
+ reject(error);
1330
+ }
1331
+ });
1332
+ response = new Response(body, responseOptions);
1333
+ resolve(response);
1334
+ return;
1335
+ }
1336
+ response = new Response(body, responseOptions);
1337
+ resolve(response);
1338
+ });
1339
+ writeToStream(request_, request).catch(reject);
1340
+ });
1341
+ }
1342
+ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
1343
+ const LAST_CHUNK = Buffer3.from("0\r\n\r\n");
1344
+ let isChunkedTransfer = false;
1345
+ let properLastChunkReceived = false;
1346
+ let previousChunk;
1347
+ request.on("response", (response) => {
1348
+ const { headers } = response;
1349
+ isChunkedTransfer = headers["transfer-encoding"] === "chunked" && !headers["content-length"];
1350
+ });
1351
+ request.on("socket", (socket) => {
1352
+ const onSocketClose = () => {
1353
+ if (isChunkedTransfer && !properLastChunkReceived) {
1354
+ const error = new Error("Premature close");
1355
+ error.code = "ERR_STREAM_PREMATURE_CLOSE";
1356
+ errorCallback(error);
1357
+ }
1358
+ };
1359
+ const onData = (buf) => {
1360
+ properLastChunkReceived = Buffer3.compare(buf.slice(-5), LAST_CHUNK) === 0;
1361
+ if (!properLastChunkReceived && previousChunk) {
1362
+ properLastChunkReceived = Buffer3.compare(previousChunk.slice(-3), LAST_CHUNK.slice(0, 3)) === 0 && Buffer3.compare(buf.slice(-2), LAST_CHUNK.slice(3)) === 0;
1363
+ }
1364
+ previousChunk = buf;
1365
+ };
1366
+ socket.prependListener("close", onSocketClose);
1367
+ socket.on("data", onData);
1368
+ request.on("close", () => {
1369
+ socket.removeListener("close", onSocketClose);
1370
+ socket.removeListener("data", onData);
1371
+ });
1372
+ });
1373
+ }
1374
+ var supportedSchemas;
1375
+ var init_src = __esm({
1376
+ "../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/index.js"() {
1377
+ init_dist();
1378
+ init_body();
1379
+ init_response();
1380
+ init_headers();
1381
+ init_request();
1382
+ init_fetch_error();
1383
+ init_abort_error();
1384
+ init_is_redirect();
1385
+ init_esm_min();
1386
+ init_is();
1387
+ init_referrer();
1388
+ init_from();
1389
+ supportedSchemas = /* @__PURE__ */ new Set(["data:", "http:", "https:"]);
1390
+ }
1391
+ });
1392
+ init_src();
1393
+ export {
1394
+ AbortError,
1395
+ fetch_blob_default as Blob,
1396
+ FetchError,
1397
+ file_default as File,
1398
+ FormData,
1399
+ Headers,
1400
+ Request,
1401
+ Response,
1402
+ blobFrom,
1403
+ blobFromSync,
1404
+ fetch as default,
1405
+ fileFrom,
1406
+ fileFromSync,
1407
+ isRedirect
1408
+ };