@stonecrop/graphql-client 0.2.13 → 0.2.20

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,3075 @@
1
+ function Le(e, t) {
2
+ for (var n = 0; n < t.length; n++) {
3
+ const r = t[n];
4
+ if (typeof r != "string" && !Array.isArray(r)) {
5
+ for (const i in r)
6
+ if (i !== "default" && !(i in e)) {
7
+ const s = Object.getOwnPropertyDescriptor(r, i);
8
+ s && Object.defineProperty(e, i, s.get ? s : {
9
+ enumerable: !0,
10
+ get: () => r[i]
11
+ });
12
+ }
13
+ }
14
+ }
15
+ return Object.freeze(Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }));
16
+ }
17
+ const he = JSON, Fe = (e) => e.toUpperCase(), Pe = (e) => {
18
+ const t = {};
19
+ return e.forEach((n, r) => {
20
+ t[r] = n;
21
+ }), t;
22
+ }, Be = (e, t, n) => e.document ? e : {
23
+ document: e,
24
+ variables: t,
25
+ requestHeaders: n,
26
+ signal: void 0
27
+ }, Me = (e, t, n) => e.query ? e : {
28
+ query: e,
29
+ variables: t,
30
+ requestHeaders: n,
31
+ signal: void 0
32
+ }, Ue = (e, t) => e.documents ? e : {
33
+ documents: e,
34
+ requestHeaders: t,
35
+ signal: void 0
36
+ }, Ve = (e, t, ...n) => {
37
+ const [r, i] = n;
38
+ return e.document ? e : {
39
+ url: e,
40
+ document: t,
41
+ variables: r,
42
+ requestHeaders: i,
43
+ signal: void 0
44
+ };
45
+ };
46
+ function Q(e, t) {
47
+ if (!!!e)
48
+ throw new Error(t);
49
+ }
50
+ function je(e) {
51
+ return typeof e == "object" && e !== null;
52
+ }
53
+ function qe(e, t) {
54
+ if (!!!e)
55
+ throw new Error(
56
+ t ?? "Unexpected invariant triggered."
57
+ );
58
+ }
59
+ const $e = /\r\n|[\n\r]/g;
60
+ function ae(e, t) {
61
+ let n = 0, r = 1;
62
+ for (const i of e.body.matchAll($e)) {
63
+ if (typeof i.index == "number" || qe(!1), i.index >= t)
64
+ break;
65
+ n = i.index + i[0].length, r += 1;
66
+ }
67
+ return {
68
+ line: r,
69
+ column: t + 1 - n
70
+ };
71
+ }
72
+ function Ge(e) {
73
+ return xe(
74
+ e.source,
75
+ ae(e.source, e.start)
76
+ );
77
+ }
78
+ function xe(e, t) {
79
+ const n = e.locationOffset.column - 1, r = "".padStart(n) + e.body, i = t.line - 1, s = e.locationOffset.line - 1, c = t.line + s, u = t.line === 1 ? n : 0, p = t.column + u, d = `${e.name}:${c}:${p}
80
+ `, y = r.split(/\r\n|[\n\r]/g), m = y[i];
81
+ if (m.length > 120) {
82
+ const T = Math.floor(p / 80), A = p % 80, E = [];
83
+ for (let I = 0; I < m.length; I += 80)
84
+ E.push(m.slice(I, I + 80));
85
+ return d + fe([
86
+ [`${c} |`, E[0]],
87
+ ...E.slice(1, T + 1).map((I) => ["|", I]),
88
+ ["|", "^".padStart(A)],
89
+ ["|", E[T + 1]]
90
+ ]);
91
+ }
92
+ return d + fe([
93
+ // Lines specified like this: ["prefix", "string"],
94
+ [`${c - 1} |`, y[i - 1]],
95
+ [`${c} |`, m],
96
+ ["|", "^".padStart(p)],
97
+ [`${c + 1} |`, y[i + 1]]
98
+ ]);
99
+ }
100
+ function fe(e) {
101
+ const t = e.filter(([r, i]) => i !== void 0), n = Math.max(...t.map(([r]) => r.length));
102
+ return t.map(([r, i]) => r.padStart(n) + (i ? " " + i : "")).join(`
103
+ `);
104
+ }
105
+ function He(e) {
106
+ const t = e[0];
107
+ return t == null || "kind" in t || "length" in t ? {
108
+ nodes: t,
109
+ source: e[1],
110
+ positions: e[2],
111
+ path: e[3],
112
+ originalError: e[4],
113
+ extensions: e[5]
114
+ } : t;
115
+ }
116
+ class pe extends Error {
117
+ /**
118
+ * An array of `{ line, column }` locations within the source GraphQL document
119
+ * which correspond to this error.
120
+ *
121
+ * Errors during validation often contain multiple locations, for example to
122
+ * point out two things with the same name. Errors during execution include a
123
+ * single location, the field which produced the error.
124
+ *
125
+ * Enumerable, and appears in the result of JSON.stringify().
126
+ */
127
+ /**
128
+ * An array describing the JSON-path into the execution response which
129
+ * corresponds to this error. Only included for errors during execution.
130
+ *
131
+ * Enumerable, and appears in the result of JSON.stringify().
132
+ */
133
+ /**
134
+ * An array of GraphQL AST Nodes corresponding to this error.
135
+ */
136
+ /**
137
+ * The source GraphQL document for the first location of this error.
138
+ *
139
+ * Note that if this Error represents more than one node, the source may not
140
+ * represent nodes after the first node.
141
+ */
142
+ /**
143
+ * An array of character offsets within the source GraphQL document
144
+ * which correspond to this error.
145
+ */
146
+ /**
147
+ * The original error thrown from a field resolver during execution.
148
+ */
149
+ /**
150
+ * Extension fields to add to the formatted error.
151
+ */
152
+ /**
153
+ * @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.
154
+ */
155
+ constructor(t, ...n) {
156
+ var r, i, s;
157
+ const { nodes: c, source: u, positions: p, path: d, originalError: y, extensions: m } = He(n);
158
+ super(t), this.name = "GraphQLError", this.path = d ?? void 0, this.originalError = y ?? void 0, this.nodes = ye(
159
+ Array.isArray(c) ? c : c ? [c] : void 0
160
+ );
161
+ const T = ye(
162
+ (r = this.nodes) === null || r === void 0 ? void 0 : r.map((E) => E.loc).filter((E) => E != null)
163
+ );
164
+ this.source = u ?? (T == null || (i = T[0]) === null || i === void 0 ? void 0 : i.source), this.positions = p ?? (T == null ? void 0 : T.map((E) => E.start)), this.locations = p && u ? p.map((E) => ae(u, E)) : T == null ? void 0 : T.map((E) => ae(E.source, E.start));
165
+ const A = je(
166
+ y == null ? void 0 : y.extensions
167
+ ) ? y == null ? void 0 : y.extensions : void 0;
168
+ this.extensions = (s = m ?? A) !== null && s !== void 0 ? s : /* @__PURE__ */ Object.create(null), Object.defineProperties(this, {
169
+ message: {
170
+ writable: !0,
171
+ enumerable: !0
172
+ },
173
+ name: {
174
+ enumerable: !1
175
+ },
176
+ nodes: {
177
+ enumerable: !1
178
+ },
179
+ source: {
180
+ enumerable: !1
181
+ },
182
+ positions: {
183
+ enumerable: !1
184
+ },
185
+ originalError: {
186
+ enumerable: !1
187
+ }
188
+ }), y != null && y.stack ? Object.defineProperty(this, "stack", {
189
+ value: y.stack,
190
+ writable: !0,
191
+ configurable: !0
192
+ }) : Error.captureStackTrace ? Error.captureStackTrace(this, pe) : Object.defineProperty(this, "stack", {
193
+ value: Error().stack,
194
+ writable: !0,
195
+ configurable: !0
196
+ });
197
+ }
198
+ get [Symbol.toStringTag]() {
199
+ return "GraphQLError";
200
+ }
201
+ toString() {
202
+ let t = this.message;
203
+ if (this.nodes)
204
+ for (const n of this.nodes)
205
+ n.loc && (t += `
206
+
207
+ ` + Ge(n.loc));
208
+ else if (this.source && this.locations)
209
+ for (const n of this.locations)
210
+ t += `
211
+
212
+ ` + xe(this.source, n);
213
+ return t;
214
+ }
215
+ toJSON() {
216
+ const t = {
217
+ message: this.message
218
+ };
219
+ return this.locations != null && (t.locations = this.locations), this.path != null && (t.path = this.path), this.extensions != null && Object.keys(this.extensions).length > 0 && (t.extensions = this.extensions), t;
220
+ }
221
+ }
222
+ function ye(e) {
223
+ return e === void 0 || e.length === 0 ? void 0 : e;
224
+ }
225
+ function O(e, t, n) {
226
+ return new pe(`Syntax Error: ${n}`, {
227
+ source: e,
228
+ positions: [t]
229
+ });
230
+ }
231
+ class Ye {
232
+ /**
233
+ * The character offset at which this Node begins.
234
+ */
235
+ /**
236
+ * The character offset at which this Node ends.
237
+ */
238
+ /**
239
+ * The Token at which this Node begins.
240
+ */
241
+ /**
242
+ * The Token at which this Node ends.
243
+ */
244
+ /**
245
+ * The Source document the AST represents.
246
+ */
247
+ constructor(t, n, r) {
248
+ this.start = t.start, this.end = n.end, this.startToken = t, this.endToken = n, this.source = r;
249
+ }
250
+ get [Symbol.toStringTag]() {
251
+ return "Location";
252
+ }
253
+ toJSON() {
254
+ return {
255
+ start: this.start,
256
+ end: this.end
257
+ };
258
+ }
259
+ }
260
+ class Ae {
261
+ /**
262
+ * The kind of Token.
263
+ */
264
+ /**
265
+ * The character offset at which this Node begins.
266
+ */
267
+ /**
268
+ * The character offset at which this Node ends.
269
+ */
270
+ /**
271
+ * The 1-indexed line number on which this Token appears.
272
+ */
273
+ /**
274
+ * The 1-indexed column number at which this Token begins.
275
+ */
276
+ /**
277
+ * For non-punctuation tokens, represents the interpreted value of the token.
278
+ *
279
+ * Note: is undefined for punctuation tokens, but typed as string for
280
+ * convenience in the parser.
281
+ */
282
+ /**
283
+ * Tokens exist as nodes in a double-linked-list amongst all tokens
284
+ * including ignored tokens. <SOF> is always the first node and <EOF>
285
+ * the last.
286
+ */
287
+ constructor(t, n, r, i, s, c) {
288
+ this.kind = t, this.start = n, this.end = r, this.line = i, this.column = s, this.value = c, this.prev = null, this.next = null;
289
+ }
290
+ get [Symbol.toStringTag]() {
291
+ return "Token";
292
+ }
293
+ toJSON() {
294
+ return {
295
+ kind: this.kind,
296
+ value: this.value,
297
+ line: this.line,
298
+ column: this.column
299
+ };
300
+ }
301
+ }
302
+ const Ie = {
303
+ Name: [],
304
+ Document: ["definitions"],
305
+ OperationDefinition: [
306
+ "name",
307
+ "variableDefinitions",
308
+ "directives",
309
+ "selectionSet"
310
+ ],
311
+ VariableDefinition: ["variable", "type", "defaultValue", "directives"],
312
+ Variable: ["name"],
313
+ SelectionSet: ["selections"],
314
+ Field: ["alias", "name", "arguments", "directives", "selectionSet"],
315
+ Argument: ["name", "value"],
316
+ FragmentSpread: ["name", "directives"],
317
+ InlineFragment: ["typeCondition", "directives", "selectionSet"],
318
+ FragmentDefinition: [
319
+ "name",
320
+ // Note: fragment variable definitions are deprecated and will removed in v17.0.0
321
+ "variableDefinitions",
322
+ "typeCondition",
323
+ "directives",
324
+ "selectionSet"
325
+ ],
326
+ IntValue: [],
327
+ FloatValue: [],
328
+ StringValue: [],
329
+ BooleanValue: [],
330
+ NullValue: [],
331
+ EnumValue: [],
332
+ ListValue: ["values"],
333
+ ObjectValue: ["fields"],
334
+ ObjectField: ["name", "value"],
335
+ Directive: ["name", "arguments"],
336
+ NamedType: ["name"],
337
+ ListType: ["type"],
338
+ NonNullType: ["type"],
339
+ SchemaDefinition: ["description", "directives", "operationTypes"],
340
+ OperationTypeDefinition: ["type"],
341
+ ScalarTypeDefinition: ["description", "name", "directives"],
342
+ ObjectTypeDefinition: [
343
+ "description",
344
+ "name",
345
+ "interfaces",
346
+ "directives",
347
+ "fields"
348
+ ],
349
+ FieldDefinition: ["description", "name", "arguments", "type", "directives"],
350
+ InputValueDefinition: [
351
+ "description",
352
+ "name",
353
+ "type",
354
+ "defaultValue",
355
+ "directives"
356
+ ],
357
+ InterfaceTypeDefinition: [
358
+ "description",
359
+ "name",
360
+ "interfaces",
361
+ "directives",
362
+ "fields"
363
+ ],
364
+ UnionTypeDefinition: ["description", "name", "directives", "types"],
365
+ EnumTypeDefinition: ["description", "name", "directives", "values"],
366
+ EnumValueDefinition: ["description", "name", "directives"],
367
+ InputObjectTypeDefinition: ["description", "name", "directives", "fields"],
368
+ DirectiveDefinition: ["description", "name", "arguments", "locations"],
369
+ SchemaExtension: ["directives", "operationTypes"],
370
+ ScalarTypeExtension: ["name", "directives"],
371
+ ObjectTypeExtension: ["name", "interfaces", "directives", "fields"],
372
+ InterfaceTypeExtension: ["name", "interfaces", "directives", "fields"],
373
+ UnionTypeExtension: ["name", "directives", "types"],
374
+ EnumTypeExtension: ["name", "directives", "values"],
375
+ InputObjectTypeExtension: ["name", "directives", "fields"]
376
+ }, ze = new Set(Object.keys(Ie));
377
+ function Ee(e) {
378
+ const t = e == null ? void 0 : e.kind;
379
+ return typeof t == "string" && ze.has(t);
380
+ }
381
+ var M;
382
+ (function(e) {
383
+ e.QUERY = "query", e.MUTATION = "mutation", e.SUBSCRIPTION = "subscription";
384
+ })(M || (M = {}));
385
+ var ce;
386
+ (function(e) {
387
+ e.QUERY = "QUERY", e.MUTATION = "MUTATION", e.SUBSCRIPTION = "SUBSCRIPTION", e.FIELD = "FIELD", e.FRAGMENT_DEFINITION = "FRAGMENT_DEFINITION", e.FRAGMENT_SPREAD = "FRAGMENT_SPREAD", e.INLINE_FRAGMENT = "INLINE_FRAGMENT", e.VARIABLE_DEFINITION = "VARIABLE_DEFINITION", e.SCHEMA = "SCHEMA", e.SCALAR = "SCALAR", e.OBJECT = "OBJECT", e.FIELD_DEFINITION = "FIELD_DEFINITION", e.ARGUMENT_DEFINITION = "ARGUMENT_DEFINITION", e.INTERFACE = "INTERFACE", e.UNION = "UNION", e.ENUM = "ENUM", e.ENUM_VALUE = "ENUM_VALUE", e.INPUT_OBJECT = "INPUT_OBJECT", e.INPUT_FIELD_DEFINITION = "INPUT_FIELD_DEFINITION";
388
+ })(ce || (ce = {}));
389
+ var f;
390
+ (function(e) {
391
+ e.NAME = "Name", e.DOCUMENT = "Document", e.OPERATION_DEFINITION = "OperationDefinition", e.VARIABLE_DEFINITION = "VariableDefinition", e.SELECTION_SET = "SelectionSet", e.FIELD = "Field", e.ARGUMENT = "Argument", e.FRAGMENT_SPREAD = "FragmentSpread", e.INLINE_FRAGMENT = "InlineFragment", e.FRAGMENT_DEFINITION = "FragmentDefinition", e.VARIABLE = "Variable", e.INT = "IntValue", e.FLOAT = "FloatValue", e.STRING = "StringValue", e.BOOLEAN = "BooleanValue", e.NULL = "NullValue", e.ENUM = "EnumValue", e.LIST = "ListValue", e.OBJECT = "ObjectValue", e.OBJECT_FIELD = "ObjectField", e.DIRECTIVE = "Directive", e.NAMED_TYPE = "NamedType", e.LIST_TYPE = "ListType", e.NON_NULL_TYPE = "NonNullType", e.SCHEMA_DEFINITION = "SchemaDefinition", e.OPERATION_TYPE_DEFINITION = "OperationTypeDefinition", e.SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition", e.OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition", e.FIELD_DEFINITION = "FieldDefinition", e.INPUT_VALUE_DEFINITION = "InputValueDefinition", e.INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition", e.UNION_TYPE_DEFINITION = "UnionTypeDefinition", e.ENUM_TYPE_DEFINITION = "EnumTypeDefinition", e.ENUM_VALUE_DEFINITION = "EnumValueDefinition", e.INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition", e.DIRECTIVE_DEFINITION = "DirectiveDefinition", e.SCHEMA_EXTENSION = "SchemaExtension", e.SCALAR_TYPE_EXTENSION = "ScalarTypeExtension", e.OBJECT_TYPE_EXTENSION = "ObjectTypeExtension", e.INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension", e.UNION_TYPE_EXTENSION = "UnionTypeExtension", e.ENUM_TYPE_EXTENSION = "EnumTypeExtension", e.INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension";
392
+ })(f || (f = {}));
393
+ function ue(e) {
394
+ return e === 9 || e === 32;
395
+ }
396
+ function $(e) {
397
+ return e >= 48 && e <= 57;
398
+ }
399
+ function ge(e) {
400
+ return e >= 97 && e <= 122 || // A-Z
401
+ e >= 65 && e <= 90;
402
+ }
403
+ function Oe(e) {
404
+ return ge(e) || e === 95;
405
+ }
406
+ function Je(e) {
407
+ return ge(e) || $(e) || e === 95;
408
+ }
409
+ function Qe(e) {
410
+ var t;
411
+ let n = Number.MAX_SAFE_INTEGER, r = null, i = -1;
412
+ for (let c = 0; c < e.length; ++c) {
413
+ var s;
414
+ const u = e[c], p = Xe(u);
415
+ p !== u.length && (r = (s = r) !== null && s !== void 0 ? s : c, i = c, c !== 0 && p < n && (n = p));
416
+ }
417
+ return e.map((c, u) => u === 0 ? c : c.slice(n)).slice(
418
+ (t = r) !== null && t !== void 0 ? t : 0,
419
+ i + 1
420
+ );
421
+ }
422
+ function Xe(e) {
423
+ let t = 0;
424
+ for (; t < e.length && ue(e.charCodeAt(t)); )
425
+ ++t;
426
+ return t;
427
+ }
428
+ function We(e, t) {
429
+ const n = e.replace(/"""/g, '\\"""'), r = n.split(/\r\n|[\n\r]/g), i = r.length === 1, s = r.length > 1 && r.slice(1).every((A) => A.length === 0 || ue(A.charCodeAt(0))), c = n.endsWith('\\"""'), u = e.endsWith('"') && !c, p = e.endsWith("\\"), d = u || p, y = !(t != null && t.minimize) && // add leading and trailing new lines only if it improves readability
430
+ (!i || e.length > 70 || d || s || c);
431
+ let m = "";
432
+ const T = i && ue(e.charCodeAt(0));
433
+ return (y && !T || s) && (m += `
434
+ `), m += n, (y || d) && (m += `
435
+ `), '"""' + m + '"""';
436
+ }
437
+ var a;
438
+ (function(e) {
439
+ e.SOF = "<SOF>", e.EOF = "<EOF>", e.BANG = "!", e.DOLLAR = "$", e.AMP = "&", e.PAREN_L = "(", e.PAREN_R = ")", e.SPREAD = "...", e.COLON = ":", e.EQUALS = "=", e.AT = "@", e.BRACKET_L = "[", e.BRACKET_R = "]", e.BRACE_L = "{", e.PIPE = "|", e.BRACE_R = "}", e.NAME = "Name", e.INT = "Int", e.FLOAT = "Float", e.STRING = "String", e.BLOCK_STRING = "BlockString", e.COMMENT = "Comment";
440
+ })(a || (a = {}));
441
+ class Ze {
442
+ /**
443
+ * The previously focused non-ignored token.
444
+ */
445
+ /**
446
+ * The currently focused non-ignored token.
447
+ */
448
+ /**
449
+ * The (1-indexed) line containing the current token.
450
+ */
451
+ /**
452
+ * The character offset at which the current line begins.
453
+ */
454
+ constructor(t) {
455
+ const n = new Ae(a.SOF, 0, 0, 0, 0);
456
+ this.source = t, this.lastToken = n, this.token = n, this.line = 1, this.lineStart = 0;
457
+ }
458
+ get [Symbol.toStringTag]() {
459
+ return "Lexer";
460
+ }
461
+ /**
462
+ * Advances the token stream to the next non-ignored token.
463
+ */
464
+ advance() {
465
+ return this.lastToken = this.token, this.token = this.lookahead();
466
+ }
467
+ /**
468
+ * Looks ahead and returns the next non-ignored token, but does not change
469
+ * the state of Lexer.
470
+ */
471
+ lookahead() {
472
+ let t = this.token;
473
+ if (t.kind !== a.EOF)
474
+ do
475
+ if (t.next)
476
+ t = t.next;
477
+ else {
478
+ const n = et(this, t.end);
479
+ t.next = n, n.prev = t, t = n;
480
+ }
481
+ while (t.kind === a.COMMENT);
482
+ return t;
483
+ }
484
+ }
485
+ function Ke(e) {
486
+ return e === a.BANG || e === a.DOLLAR || e === a.AMP || e === a.PAREN_L || e === a.PAREN_R || e === a.SPREAD || e === a.COLON || e === a.EQUALS || e === a.AT || e === a.BRACKET_L || e === a.BRACKET_R || e === a.BRACE_L || e === a.PIPE || e === a.BRACE_R;
487
+ }
488
+ function U(e) {
489
+ return e >= 0 && e <= 55295 || e >= 57344 && e <= 1114111;
490
+ }
491
+ function K(e, t) {
492
+ return _e(e.charCodeAt(t)) && be(e.charCodeAt(t + 1));
493
+ }
494
+ function _e(e) {
495
+ return e >= 55296 && e <= 56319;
496
+ }
497
+ function be(e) {
498
+ return e >= 56320 && e <= 57343;
499
+ }
500
+ function F(e, t) {
501
+ const n = e.source.body.codePointAt(t);
502
+ if (n === void 0)
503
+ return a.EOF;
504
+ if (n >= 32 && n <= 126) {
505
+ const r = String.fromCodePoint(n);
506
+ return r === '"' ? `'"'` : `"${r}"`;
507
+ }
508
+ return "U+" + n.toString(16).toUpperCase().padStart(4, "0");
509
+ }
510
+ function g(e, t, n, r, i) {
511
+ const s = e.line, c = 1 + n - e.lineStart;
512
+ return new Ae(t, n, r, s, c, i);
513
+ }
514
+ function et(e, t) {
515
+ const n = e.source.body, r = n.length;
516
+ let i = t;
517
+ for (; i < r; ) {
518
+ const s = n.charCodeAt(i);
519
+ switch (s) {
520
+ case 65279:
521
+ case 9:
522
+ case 32:
523
+ case 44:
524
+ ++i;
525
+ continue;
526
+ case 10:
527
+ ++i, ++e.line, e.lineStart = i;
528
+ continue;
529
+ case 13:
530
+ n.charCodeAt(i + 1) === 10 ? i += 2 : ++i, ++e.line, e.lineStart = i;
531
+ continue;
532
+ case 35:
533
+ return tt(e, i);
534
+ case 33:
535
+ return g(e, a.BANG, i, i + 1);
536
+ case 36:
537
+ return g(e, a.DOLLAR, i, i + 1);
538
+ case 38:
539
+ return g(e, a.AMP, i, i + 1);
540
+ case 40:
541
+ return g(e, a.PAREN_L, i, i + 1);
542
+ case 41:
543
+ return g(e, a.PAREN_R, i, i + 1);
544
+ case 46:
545
+ if (n.charCodeAt(i + 1) === 46 && n.charCodeAt(i + 2) === 46)
546
+ return g(e, a.SPREAD, i, i + 3);
547
+ break;
548
+ case 58:
549
+ return g(e, a.COLON, i, i + 1);
550
+ case 61:
551
+ return g(e, a.EQUALS, i, i + 1);
552
+ case 64:
553
+ return g(e, a.AT, i, i + 1);
554
+ case 91:
555
+ return g(e, a.BRACKET_L, i, i + 1);
556
+ case 93:
557
+ return g(e, a.BRACKET_R, i, i + 1);
558
+ case 123:
559
+ return g(e, a.BRACE_L, i, i + 1);
560
+ case 124:
561
+ return g(e, a.PIPE, i, i + 1);
562
+ case 125:
563
+ return g(e, a.BRACE_R, i, i + 1);
564
+ case 34:
565
+ return n.charCodeAt(i + 1) === 34 && n.charCodeAt(i + 2) === 34 ? at(e, i) : it(e, i);
566
+ }
567
+ if ($(s) || s === 45)
568
+ return nt(e, i, s);
569
+ if (Oe(s))
570
+ return ct(e, i);
571
+ throw O(
572
+ e.source,
573
+ i,
574
+ s === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : U(s) || K(n, i) ? `Unexpected character: ${F(e, i)}.` : `Invalid character: ${F(e, i)}.`
575
+ );
576
+ }
577
+ return g(e, a.EOF, r, r);
578
+ }
579
+ function tt(e, t) {
580
+ const n = e.source.body, r = n.length;
581
+ let i = t + 1;
582
+ for (; i < r; ) {
583
+ const s = n.charCodeAt(i);
584
+ if (s === 10 || s === 13)
585
+ break;
586
+ if (U(s))
587
+ ++i;
588
+ else if (K(n, i))
589
+ i += 2;
590
+ else
591
+ break;
592
+ }
593
+ return g(
594
+ e,
595
+ a.COMMENT,
596
+ t,
597
+ i,
598
+ n.slice(t + 1, i)
599
+ );
600
+ }
601
+ function nt(e, t, n) {
602
+ const r = e.source.body;
603
+ let i = t, s = n, c = !1;
604
+ if (s === 45 && (s = r.charCodeAt(++i)), s === 48) {
605
+ if (s = r.charCodeAt(++i), $(s))
606
+ throw O(
607
+ e.source,
608
+ i,
609
+ `Invalid number, unexpected digit after 0: ${F(
610
+ e,
611
+ i
612
+ )}.`
613
+ );
614
+ } else
615
+ i = ie(e, i, s), s = r.charCodeAt(i);
616
+ if (s === 46 && (c = !0, s = r.charCodeAt(++i), i = ie(e, i, s), s = r.charCodeAt(i)), (s === 69 || s === 101) && (c = !0, s = r.charCodeAt(++i), (s === 43 || s === 45) && (s = r.charCodeAt(++i)), i = ie(e, i, s), s = r.charCodeAt(i)), s === 46 || Oe(s))
617
+ throw O(
618
+ e.source,
619
+ i,
620
+ `Invalid number, expected digit but got: ${F(
621
+ e,
622
+ i
623
+ )}.`
624
+ );
625
+ return g(
626
+ e,
627
+ c ? a.FLOAT : a.INT,
628
+ t,
629
+ i,
630
+ r.slice(t, i)
631
+ );
632
+ }
633
+ function ie(e, t, n) {
634
+ if (!$(n))
635
+ throw O(
636
+ e.source,
637
+ t,
638
+ `Invalid number, expected digit but got: ${F(
639
+ e,
640
+ t
641
+ )}.`
642
+ );
643
+ const r = e.source.body;
644
+ let i = t + 1;
645
+ for (; $(r.charCodeAt(i)); )
646
+ ++i;
647
+ return i;
648
+ }
649
+ function it(e, t) {
650
+ const n = e.source.body, r = n.length;
651
+ let i = t + 1, s = i, c = "";
652
+ for (; i < r; ) {
653
+ const u = n.charCodeAt(i);
654
+ if (u === 34)
655
+ return c += n.slice(s, i), g(e, a.STRING, t, i + 1, c);
656
+ if (u === 92) {
657
+ c += n.slice(s, i);
658
+ const p = n.charCodeAt(i + 1) === 117 ? n.charCodeAt(i + 2) === 123 ? rt(e, i) : st(e, i) : ot(e, i);
659
+ c += p.value, i += p.size, s = i;
660
+ continue;
661
+ }
662
+ if (u === 10 || u === 13)
663
+ break;
664
+ if (U(u))
665
+ ++i;
666
+ else if (K(n, i))
667
+ i += 2;
668
+ else
669
+ throw O(
670
+ e.source,
671
+ i,
672
+ `Invalid character within String: ${F(
673
+ e,
674
+ i
675
+ )}.`
676
+ );
677
+ }
678
+ throw O(e.source, i, "Unterminated string.");
679
+ }
680
+ function rt(e, t) {
681
+ const n = e.source.body;
682
+ let r = 0, i = 3;
683
+ for (; i < 12; ) {
684
+ const s = n.charCodeAt(t + i++);
685
+ if (s === 125) {
686
+ if (i < 5 || !U(r))
687
+ break;
688
+ return {
689
+ value: String.fromCodePoint(r),
690
+ size: i
691
+ };
692
+ }
693
+ if (r = r << 4 | j(s), r < 0)
694
+ break;
695
+ }
696
+ throw O(
697
+ e.source,
698
+ t,
699
+ `Invalid Unicode escape sequence: "${n.slice(
700
+ t,
701
+ t + i
702
+ )}".`
703
+ );
704
+ }
705
+ function st(e, t) {
706
+ const n = e.source.body, r = me(n, t + 2);
707
+ if (U(r))
708
+ return {
709
+ value: String.fromCodePoint(r),
710
+ size: 6
711
+ };
712
+ if (_e(r) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) {
713
+ const i = me(n, t + 8);
714
+ if (be(i))
715
+ return {
716
+ value: String.fromCodePoint(r, i),
717
+ size: 12
718
+ };
719
+ }
720
+ throw O(
721
+ e.source,
722
+ t,
723
+ `Invalid Unicode escape sequence: "${n.slice(t, t + 6)}".`
724
+ );
725
+ }
726
+ function me(e, t) {
727
+ return j(e.charCodeAt(t)) << 12 | j(e.charCodeAt(t + 1)) << 8 | j(e.charCodeAt(t + 2)) << 4 | j(e.charCodeAt(t + 3));
728
+ }
729
+ function j(e) {
730
+ return e >= 48 && e <= 57 ? e - 48 : e >= 65 && e <= 70 ? e - 55 : e >= 97 && e <= 102 ? e - 87 : -1;
731
+ }
732
+ function ot(e, t) {
733
+ const n = e.source.body;
734
+ switch (n.charCodeAt(t + 1)) {
735
+ case 34:
736
+ return {
737
+ value: '"',
738
+ size: 2
739
+ };
740
+ case 92:
741
+ return {
742
+ value: "\\",
743
+ size: 2
744
+ };
745
+ case 47:
746
+ return {
747
+ value: "/",
748
+ size: 2
749
+ };
750
+ case 98:
751
+ return {
752
+ value: "\b",
753
+ size: 2
754
+ };
755
+ case 102:
756
+ return {
757
+ value: "\f",
758
+ size: 2
759
+ };
760
+ case 110:
761
+ return {
762
+ value: `
763
+ `,
764
+ size: 2
765
+ };
766
+ case 114:
767
+ return {
768
+ value: "\r",
769
+ size: 2
770
+ };
771
+ case 116:
772
+ return {
773
+ value: " ",
774
+ size: 2
775
+ };
776
+ }
777
+ throw O(
778
+ e.source,
779
+ t,
780
+ `Invalid character escape sequence: "${n.slice(
781
+ t,
782
+ t + 2
783
+ )}".`
784
+ );
785
+ }
786
+ function at(e, t) {
787
+ const n = e.source.body, r = n.length;
788
+ let i = e.lineStart, s = t + 3, c = s, u = "";
789
+ const p = [];
790
+ for (; s < r; ) {
791
+ const d = n.charCodeAt(s);
792
+ if (d === 34 && n.charCodeAt(s + 1) === 34 && n.charCodeAt(s + 2) === 34) {
793
+ u += n.slice(c, s), p.push(u);
794
+ const y = g(
795
+ e,
796
+ a.BLOCK_STRING,
797
+ t,
798
+ s + 3,
799
+ // Return a string of the lines joined with U+000A.
800
+ Qe(p).join(`
801
+ `)
802
+ );
803
+ return e.line += p.length - 1, e.lineStart = i, y;
804
+ }
805
+ if (d === 92 && n.charCodeAt(s + 1) === 34 && n.charCodeAt(s + 2) === 34 && n.charCodeAt(s + 3) === 34) {
806
+ u += n.slice(c, s), c = s + 1, s += 4;
807
+ continue;
808
+ }
809
+ if (d === 10 || d === 13) {
810
+ u += n.slice(c, s), p.push(u), d === 13 && n.charCodeAt(s + 1) === 10 ? s += 2 : ++s, u = "", c = s, i = s;
811
+ continue;
812
+ }
813
+ if (U(d))
814
+ ++s;
815
+ else if (K(n, s))
816
+ s += 2;
817
+ else
818
+ throw O(
819
+ e.source,
820
+ s,
821
+ `Invalid character within String: ${F(
822
+ e,
823
+ s
824
+ )}.`
825
+ );
826
+ }
827
+ throw O(e.source, s, "Unterminated string.");
828
+ }
829
+ function ct(e, t) {
830
+ const n = e.source.body, r = n.length;
831
+ let i = t + 1;
832
+ for (; i < r; ) {
833
+ const s = n.charCodeAt(i);
834
+ if (Je(s))
835
+ ++i;
836
+ else
837
+ break;
838
+ }
839
+ return g(
840
+ e,
841
+ a.NAME,
842
+ t,
843
+ i,
844
+ n.slice(t, i)
845
+ );
846
+ }
847
+ const ut = 10, De = 2;
848
+ function de(e) {
849
+ return ee(e, []);
850
+ }
851
+ function ee(e, t) {
852
+ switch (typeof e) {
853
+ case "string":
854
+ return JSON.stringify(e);
855
+ case "function":
856
+ return e.name ? `[function ${e.name}]` : "[function]";
857
+ case "object":
858
+ return lt(e, t);
859
+ default:
860
+ return String(e);
861
+ }
862
+ }
863
+ function lt(e, t) {
864
+ if (e === null)
865
+ return "null";
866
+ if (t.includes(e))
867
+ return "[Circular]";
868
+ const n = [...t, e];
869
+ if (ht(e)) {
870
+ const r = e.toJSON();
871
+ if (r !== e)
872
+ return typeof r == "string" ? r : ee(r, n);
873
+ } else if (Array.isArray(e))
874
+ return dt(e, n);
875
+ return pt(e, n);
876
+ }
877
+ function ht(e) {
878
+ return typeof e.toJSON == "function";
879
+ }
880
+ function pt(e, t) {
881
+ const n = Object.entries(e);
882
+ return n.length === 0 ? "{}" : t.length > De ? "[" + ft(e) + "]" : "{ " + n.map(
883
+ ([i, s]) => i + ": " + ee(s, t)
884
+ ).join(", ") + " }";
885
+ }
886
+ function dt(e, t) {
887
+ if (e.length === 0)
888
+ return "[]";
889
+ if (t.length > De)
890
+ return "[Array]";
891
+ const n = Math.min(ut, e.length), r = e.length - n, i = [];
892
+ for (let s = 0; s < n; ++s)
893
+ i.push(ee(e[s], t));
894
+ return r === 1 ? i.push("... 1 more item") : r > 1 && i.push(`... ${r} more items`), "[" + i.join(", ") + "]";
895
+ }
896
+ function ft(e) {
897
+ const t = Object.prototype.toString.call(e).replace(/^\[object /, "").replace(/]$/, "");
898
+ if (t === "Object" && typeof e.constructor == "function") {
899
+ const n = e.constructor.name;
900
+ if (typeof n == "string" && n !== "")
901
+ return n;
902
+ }
903
+ return t;
904
+ }
905
+ const yt = (
906
+ /* c8 ignore next 6 */
907
+ // FIXME: https://github.com/graphql/graphql-js/issues/2317
908
+ // eslint-disable-next-line no-undef
909
+ process.env.NODE_ENV === "production" ? function(t, n) {
910
+ return t instanceof n;
911
+ } : function(t, n) {
912
+ if (t instanceof n)
913
+ return !0;
914
+ if (typeof t == "object" && t !== null) {
915
+ var r;
916
+ const i = n.prototype[Symbol.toStringTag], s = (
917
+ // We still need to support constructor's name to detect conflicts with older versions of this library.
918
+ Symbol.toStringTag in t ? t[Symbol.toStringTag] : (r = t.constructor) === null || r === void 0 ? void 0 : r.name
919
+ );
920
+ if (i === s) {
921
+ const c = de(t);
922
+ throw new Error(`Cannot use ${i} "${c}" from another module or realm.
923
+
924
+ Ensure that there is only one instance of "graphql" in the node_modules
925
+ directory. If different versions of "graphql" are the dependencies of other
926
+ relied on modules, use "resolutions" to ensure only one version is installed.
927
+
928
+ https://yarnpkg.com/en/docs/selective-version-resolutions
929
+
930
+ Duplicate "graphql" modules cannot be used at the same time since different
931
+ versions may have different capabilities and behavior. The data from one
932
+ version used in the function from another could produce confusing and
933
+ spurious results.`);
934
+ }
935
+ }
936
+ return !1;
937
+ }
938
+ );
939
+ class Se {
940
+ constructor(t, n = "GraphQL request", r = {
941
+ line: 1,
942
+ column: 1
943
+ }) {
944
+ typeof t == "string" || Q(!1, `Body must be a string. Received: ${de(t)}.`), this.body = t, this.name = n, this.locationOffset = r, this.locationOffset.line > 0 || Q(
945
+ !1,
946
+ "line in locationOffset is 1-indexed and must be positive."
947
+ ), this.locationOffset.column > 0 || Q(
948
+ !1,
949
+ "column in locationOffset is 1-indexed and must be positive."
950
+ );
951
+ }
952
+ get [Symbol.toStringTag]() {
953
+ return "Source";
954
+ }
955
+ }
956
+ function Et(e) {
957
+ return yt(e, Se);
958
+ }
959
+ function mt(e, t) {
960
+ return new Tt(e, t).parseDocument();
961
+ }
962
+ class Tt {
963
+ constructor(t, n = {}) {
964
+ const r = Et(t) ? t : new Se(t);
965
+ this._lexer = new Ze(r), this._options = n, this._tokenCounter = 0;
966
+ }
967
+ /**
968
+ * Converts a name lex token into a name parse node.
969
+ */
970
+ parseName() {
971
+ const t = this.expectToken(a.NAME);
972
+ return this.node(t, {
973
+ kind: f.NAME,
974
+ value: t.value
975
+ });
976
+ }
977
+ // Implements the parsing rules in the Document section.
978
+ /**
979
+ * Document : Definition+
980
+ */
981
+ parseDocument() {
982
+ return this.node(this._lexer.token, {
983
+ kind: f.DOCUMENT,
984
+ definitions: this.many(
985
+ a.SOF,
986
+ this.parseDefinition,
987
+ a.EOF
988
+ )
989
+ });
990
+ }
991
+ /**
992
+ * Definition :
993
+ * - ExecutableDefinition
994
+ * - TypeSystemDefinition
995
+ * - TypeSystemExtension
996
+ *
997
+ * ExecutableDefinition :
998
+ * - OperationDefinition
999
+ * - FragmentDefinition
1000
+ *
1001
+ * TypeSystemDefinition :
1002
+ * - SchemaDefinition
1003
+ * - TypeDefinition
1004
+ * - DirectiveDefinition
1005
+ *
1006
+ * TypeDefinition :
1007
+ * - ScalarTypeDefinition
1008
+ * - ObjectTypeDefinition
1009
+ * - InterfaceTypeDefinition
1010
+ * - UnionTypeDefinition
1011
+ * - EnumTypeDefinition
1012
+ * - InputObjectTypeDefinition
1013
+ */
1014
+ parseDefinition() {
1015
+ if (this.peek(a.BRACE_L))
1016
+ return this.parseOperationDefinition();
1017
+ const t = this.peekDescription(), n = t ? this._lexer.lookahead() : this._lexer.token;
1018
+ if (n.kind === a.NAME) {
1019
+ switch (n.value) {
1020
+ case "schema":
1021
+ return this.parseSchemaDefinition();
1022
+ case "scalar":
1023
+ return this.parseScalarTypeDefinition();
1024
+ case "type":
1025
+ return this.parseObjectTypeDefinition();
1026
+ case "interface":
1027
+ return this.parseInterfaceTypeDefinition();
1028
+ case "union":
1029
+ return this.parseUnionTypeDefinition();
1030
+ case "enum":
1031
+ return this.parseEnumTypeDefinition();
1032
+ case "input":
1033
+ return this.parseInputObjectTypeDefinition();
1034
+ case "directive":
1035
+ return this.parseDirectiveDefinition();
1036
+ }
1037
+ if (t)
1038
+ throw O(
1039
+ this._lexer.source,
1040
+ this._lexer.token.start,
1041
+ "Unexpected description, descriptions are supported only on type definitions."
1042
+ );
1043
+ switch (n.value) {
1044
+ case "query":
1045
+ case "mutation":
1046
+ case "subscription":
1047
+ return this.parseOperationDefinition();
1048
+ case "fragment":
1049
+ return this.parseFragmentDefinition();
1050
+ case "extend":
1051
+ return this.parseTypeSystemExtension();
1052
+ }
1053
+ }
1054
+ throw this.unexpected(n);
1055
+ }
1056
+ // Implements the parsing rules in the Operations section.
1057
+ /**
1058
+ * OperationDefinition :
1059
+ * - SelectionSet
1060
+ * - OperationType Name? VariableDefinitions? Directives? SelectionSet
1061
+ */
1062
+ parseOperationDefinition() {
1063
+ const t = this._lexer.token;
1064
+ if (this.peek(a.BRACE_L))
1065
+ return this.node(t, {
1066
+ kind: f.OPERATION_DEFINITION,
1067
+ operation: M.QUERY,
1068
+ name: void 0,
1069
+ variableDefinitions: [],
1070
+ directives: [],
1071
+ selectionSet: this.parseSelectionSet()
1072
+ });
1073
+ const n = this.parseOperationType();
1074
+ let r;
1075
+ return this.peek(a.NAME) && (r = this.parseName()), this.node(t, {
1076
+ kind: f.OPERATION_DEFINITION,
1077
+ operation: n,
1078
+ name: r,
1079
+ variableDefinitions: this.parseVariableDefinitions(),
1080
+ directives: this.parseDirectives(!1),
1081
+ selectionSet: this.parseSelectionSet()
1082
+ });
1083
+ }
1084
+ /**
1085
+ * OperationType : one of query mutation subscription
1086
+ */
1087
+ parseOperationType() {
1088
+ const t = this.expectToken(a.NAME);
1089
+ switch (t.value) {
1090
+ case "query":
1091
+ return M.QUERY;
1092
+ case "mutation":
1093
+ return M.MUTATION;
1094
+ case "subscription":
1095
+ return M.SUBSCRIPTION;
1096
+ }
1097
+ throw this.unexpected(t);
1098
+ }
1099
+ /**
1100
+ * VariableDefinitions : ( VariableDefinition+ )
1101
+ */
1102
+ parseVariableDefinitions() {
1103
+ return this.optionalMany(
1104
+ a.PAREN_L,
1105
+ this.parseVariableDefinition,
1106
+ a.PAREN_R
1107
+ );
1108
+ }
1109
+ /**
1110
+ * VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
1111
+ */
1112
+ parseVariableDefinition() {
1113
+ return this.node(this._lexer.token, {
1114
+ kind: f.VARIABLE_DEFINITION,
1115
+ variable: this.parseVariable(),
1116
+ type: (this.expectToken(a.COLON), this.parseTypeReference()),
1117
+ defaultValue: this.expectOptionalToken(a.EQUALS) ? this.parseConstValueLiteral() : void 0,
1118
+ directives: this.parseConstDirectives()
1119
+ });
1120
+ }
1121
+ /**
1122
+ * Variable : $ Name
1123
+ */
1124
+ parseVariable() {
1125
+ const t = this._lexer.token;
1126
+ return this.expectToken(a.DOLLAR), this.node(t, {
1127
+ kind: f.VARIABLE,
1128
+ name: this.parseName()
1129
+ });
1130
+ }
1131
+ /**
1132
+ * ```
1133
+ * SelectionSet : { Selection+ }
1134
+ * ```
1135
+ */
1136
+ parseSelectionSet() {
1137
+ return this.node(this._lexer.token, {
1138
+ kind: f.SELECTION_SET,
1139
+ selections: this.many(
1140
+ a.BRACE_L,
1141
+ this.parseSelection,
1142
+ a.BRACE_R
1143
+ )
1144
+ });
1145
+ }
1146
+ /**
1147
+ * Selection :
1148
+ * - Field
1149
+ * - FragmentSpread
1150
+ * - InlineFragment
1151
+ */
1152
+ parseSelection() {
1153
+ return this.peek(a.SPREAD) ? this.parseFragment() : this.parseField();
1154
+ }
1155
+ /**
1156
+ * Field : Alias? Name Arguments? Directives? SelectionSet?
1157
+ *
1158
+ * Alias : Name :
1159
+ */
1160
+ parseField() {
1161
+ const t = this._lexer.token, n = this.parseName();
1162
+ let r, i;
1163
+ return this.expectOptionalToken(a.COLON) ? (r = n, i = this.parseName()) : i = n, this.node(t, {
1164
+ kind: f.FIELD,
1165
+ alias: r,
1166
+ name: i,
1167
+ arguments: this.parseArguments(!1),
1168
+ directives: this.parseDirectives(!1),
1169
+ selectionSet: this.peek(a.BRACE_L) ? this.parseSelectionSet() : void 0
1170
+ });
1171
+ }
1172
+ /**
1173
+ * Arguments[Const] : ( Argument[?Const]+ )
1174
+ */
1175
+ parseArguments(t) {
1176
+ const n = t ? this.parseConstArgument : this.parseArgument;
1177
+ return this.optionalMany(a.PAREN_L, n, a.PAREN_R);
1178
+ }
1179
+ /**
1180
+ * Argument[Const] : Name : Value[?Const]
1181
+ */
1182
+ parseArgument(t = !1) {
1183
+ const n = this._lexer.token, r = this.parseName();
1184
+ return this.expectToken(a.COLON), this.node(n, {
1185
+ kind: f.ARGUMENT,
1186
+ name: r,
1187
+ value: this.parseValueLiteral(t)
1188
+ });
1189
+ }
1190
+ parseConstArgument() {
1191
+ return this.parseArgument(!0);
1192
+ }
1193
+ // Implements the parsing rules in the Fragments section.
1194
+ /**
1195
+ * Corresponds to both FragmentSpread and InlineFragment in the spec.
1196
+ *
1197
+ * FragmentSpread : ... FragmentName Directives?
1198
+ *
1199
+ * InlineFragment : ... TypeCondition? Directives? SelectionSet
1200
+ */
1201
+ parseFragment() {
1202
+ const t = this._lexer.token;
1203
+ this.expectToken(a.SPREAD);
1204
+ const n = this.expectOptionalKeyword("on");
1205
+ return !n && this.peek(a.NAME) ? this.node(t, {
1206
+ kind: f.FRAGMENT_SPREAD,
1207
+ name: this.parseFragmentName(),
1208
+ directives: this.parseDirectives(!1)
1209
+ }) : this.node(t, {
1210
+ kind: f.INLINE_FRAGMENT,
1211
+ typeCondition: n ? this.parseNamedType() : void 0,
1212
+ directives: this.parseDirectives(!1),
1213
+ selectionSet: this.parseSelectionSet()
1214
+ });
1215
+ }
1216
+ /**
1217
+ * FragmentDefinition :
1218
+ * - fragment FragmentName on TypeCondition Directives? SelectionSet
1219
+ *
1220
+ * TypeCondition : NamedType
1221
+ */
1222
+ parseFragmentDefinition() {
1223
+ const t = this._lexer.token;
1224
+ return this.expectKeyword("fragment"), this._options.allowLegacyFragmentVariables === !0 ? this.node(t, {
1225
+ kind: f.FRAGMENT_DEFINITION,
1226
+ name: this.parseFragmentName(),
1227
+ variableDefinitions: this.parseVariableDefinitions(),
1228
+ typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
1229
+ directives: this.parseDirectives(!1),
1230
+ selectionSet: this.parseSelectionSet()
1231
+ }) : this.node(t, {
1232
+ kind: f.FRAGMENT_DEFINITION,
1233
+ name: this.parseFragmentName(),
1234
+ typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
1235
+ directives: this.parseDirectives(!1),
1236
+ selectionSet: this.parseSelectionSet()
1237
+ });
1238
+ }
1239
+ /**
1240
+ * FragmentName : Name but not `on`
1241
+ */
1242
+ parseFragmentName() {
1243
+ if (this._lexer.token.value === "on")
1244
+ throw this.unexpected();
1245
+ return this.parseName();
1246
+ }
1247
+ // Implements the parsing rules in the Values section.
1248
+ /**
1249
+ * Value[Const] :
1250
+ * - [~Const] Variable
1251
+ * - IntValue
1252
+ * - FloatValue
1253
+ * - StringValue
1254
+ * - BooleanValue
1255
+ * - NullValue
1256
+ * - EnumValue
1257
+ * - ListValue[?Const]
1258
+ * - ObjectValue[?Const]
1259
+ *
1260
+ * BooleanValue : one of `true` `false`
1261
+ *
1262
+ * NullValue : `null`
1263
+ *
1264
+ * EnumValue : Name but not `true`, `false` or `null`
1265
+ */
1266
+ parseValueLiteral(t) {
1267
+ const n = this._lexer.token;
1268
+ switch (n.kind) {
1269
+ case a.BRACKET_L:
1270
+ return this.parseList(t);
1271
+ case a.BRACE_L:
1272
+ return this.parseObject(t);
1273
+ case a.INT:
1274
+ return this.advanceLexer(), this.node(n, {
1275
+ kind: f.INT,
1276
+ value: n.value
1277
+ });
1278
+ case a.FLOAT:
1279
+ return this.advanceLexer(), this.node(n, {
1280
+ kind: f.FLOAT,
1281
+ value: n.value
1282
+ });
1283
+ case a.STRING:
1284
+ case a.BLOCK_STRING:
1285
+ return this.parseStringLiteral();
1286
+ case a.NAME:
1287
+ switch (this.advanceLexer(), n.value) {
1288
+ case "true":
1289
+ return this.node(n, {
1290
+ kind: f.BOOLEAN,
1291
+ value: !0
1292
+ });
1293
+ case "false":
1294
+ return this.node(n, {
1295
+ kind: f.BOOLEAN,
1296
+ value: !1
1297
+ });
1298
+ case "null":
1299
+ return this.node(n, {
1300
+ kind: f.NULL
1301
+ });
1302
+ default:
1303
+ return this.node(n, {
1304
+ kind: f.ENUM,
1305
+ value: n.value
1306
+ });
1307
+ }
1308
+ case a.DOLLAR:
1309
+ if (t)
1310
+ if (this.expectToken(a.DOLLAR), this._lexer.token.kind === a.NAME) {
1311
+ const r = this._lexer.token.value;
1312
+ throw O(
1313
+ this._lexer.source,
1314
+ n.start,
1315
+ `Unexpected variable "$${r}" in constant value.`
1316
+ );
1317
+ } else
1318
+ throw this.unexpected(n);
1319
+ return this.parseVariable();
1320
+ default:
1321
+ throw this.unexpected();
1322
+ }
1323
+ }
1324
+ parseConstValueLiteral() {
1325
+ return this.parseValueLiteral(!0);
1326
+ }
1327
+ parseStringLiteral() {
1328
+ const t = this._lexer.token;
1329
+ return this.advanceLexer(), this.node(t, {
1330
+ kind: f.STRING,
1331
+ value: t.value,
1332
+ block: t.kind === a.BLOCK_STRING
1333
+ });
1334
+ }
1335
+ /**
1336
+ * ListValue[Const] :
1337
+ * - [ ]
1338
+ * - [ Value[?Const]+ ]
1339
+ */
1340
+ parseList(t) {
1341
+ const n = () => this.parseValueLiteral(t);
1342
+ return this.node(this._lexer.token, {
1343
+ kind: f.LIST,
1344
+ values: this.any(a.BRACKET_L, n, a.BRACKET_R)
1345
+ });
1346
+ }
1347
+ /**
1348
+ * ```
1349
+ * ObjectValue[Const] :
1350
+ * - { }
1351
+ * - { ObjectField[?Const]+ }
1352
+ * ```
1353
+ */
1354
+ parseObject(t) {
1355
+ const n = () => this.parseObjectField(t);
1356
+ return this.node(this._lexer.token, {
1357
+ kind: f.OBJECT,
1358
+ fields: this.any(a.BRACE_L, n, a.BRACE_R)
1359
+ });
1360
+ }
1361
+ /**
1362
+ * ObjectField[Const] : Name : Value[?Const]
1363
+ */
1364
+ parseObjectField(t) {
1365
+ const n = this._lexer.token, r = this.parseName();
1366
+ return this.expectToken(a.COLON), this.node(n, {
1367
+ kind: f.OBJECT_FIELD,
1368
+ name: r,
1369
+ value: this.parseValueLiteral(t)
1370
+ });
1371
+ }
1372
+ // Implements the parsing rules in the Directives section.
1373
+ /**
1374
+ * Directives[Const] : Directive[?Const]+
1375
+ */
1376
+ parseDirectives(t) {
1377
+ const n = [];
1378
+ for (; this.peek(a.AT); )
1379
+ n.push(this.parseDirective(t));
1380
+ return n;
1381
+ }
1382
+ parseConstDirectives() {
1383
+ return this.parseDirectives(!0);
1384
+ }
1385
+ /**
1386
+ * ```
1387
+ * Directive[Const] : @ Name Arguments[?Const]?
1388
+ * ```
1389
+ */
1390
+ parseDirective(t) {
1391
+ const n = this._lexer.token;
1392
+ return this.expectToken(a.AT), this.node(n, {
1393
+ kind: f.DIRECTIVE,
1394
+ name: this.parseName(),
1395
+ arguments: this.parseArguments(t)
1396
+ });
1397
+ }
1398
+ // Implements the parsing rules in the Types section.
1399
+ /**
1400
+ * Type :
1401
+ * - NamedType
1402
+ * - ListType
1403
+ * - NonNullType
1404
+ */
1405
+ parseTypeReference() {
1406
+ const t = this._lexer.token;
1407
+ let n;
1408
+ if (this.expectOptionalToken(a.BRACKET_L)) {
1409
+ const r = this.parseTypeReference();
1410
+ this.expectToken(a.BRACKET_R), n = this.node(t, {
1411
+ kind: f.LIST_TYPE,
1412
+ type: r
1413
+ });
1414
+ } else
1415
+ n = this.parseNamedType();
1416
+ return this.expectOptionalToken(a.BANG) ? this.node(t, {
1417
+ kind: f.NON_NULL_TYPE,
1418
+ type: n
1419
+ }) : n;
1420
+ }
1421
+ /**
1422
+ * NamedType : Name
1423
+ */
1424
+ parseNamedType() {
1425
+ return this.node(this._lexer.token, {
1426
+ kind: f.NAMED_TYPE,
1427
+ name: this.parseName()
1428
+ });
1429
+ }
1430
+ // Implements the parsing rules in the Type Definition section.
1431
+ peekDescription() {
1432
+ return this.peek(a.STRING) || this.peek(a.BLOCK_STRING);
1433
+ }
1434
+ /**
1435
+ * Description : StringValue
1436
+ */
1437
+ parseDescription() {
1438
+ if (this.peekDescription())
1439
+ return this.parseStringLiteral();
1440
+ }
1441
+ /**
1442
+ * ```
1443
+ * SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }
1444
+ * ```
1445
+ */
1446
+ parseSchemaDefinition() {
1447
+ const t = this._lexer.token, n = this.parseDescription();
1448
+ this.expectKeyword("schema");
1449
+ const r = this.parseConstDirectives(), i = this.many(
1450
+ a.BRACE_L,
1451
+ this.parseOperationTypeDefinition,
1452
+ a.BRACE_R
1453
+ );
1454
+ return this.node(t, {
1455
+ kind: f.SCHEMA_DEFINITION,
1456
+ description: n,
1457
+ directives: r,
1458
+ operationTypes: i
1459
+ });
1460
+ }
1461
+ /**
1462
+ * OperationTypeDefinition : OperationType : NamedType
1463
+ */
1464
+ parseOperationTypeDefinition() {
1465
+ const t = this._lexer.token, n = this.parseOperationType();
1466
+ this.expectToken(a.COLON);
1467
+ const r = this.parseNamedType();
1468
+ return this.node(t, {
1469
+ kind: f.OPERATION_TYPE_DEFINITION,
1470
+ operation: n,
1471
+ type: r
1472
+ });
1473
+ }
1474
+ /**
1475
+ * ScalarTypeDefinition : Description? scalar Name Directives[Const]?
1476
+ */
1477
+ parseScalarTypeDefinition() {
1478
+ const t = this._lexer.token, n = this.parseDescription();
1479
+ this.expectKeyword("scalar");
1480
+ const r = this.parseName(), i = this.parseConstDirectives();
1481
+ return this.node(t, {
1482
+ kind: f.SCALAR_TYPE_DEFINITION,
1483
+ description: n,
1484
+ name: r,
1485
+ directives: i
1486
+ });
1487
+ }
1488
+ /**
1489
+ * ObjectTypeDefinition :
1490
+ * Description?
1491
+ * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
1492
+ */
1493
+ parseObjectTypeDefinition() {
1494
+ const t = this._lexer.token, n = this.parseDescription();
1495
+ this.expectKeyword("type");
1496
+ const r = this.parseName(), i = this.parseImplementsInterfaces(), s = this.parseConstDirectives(), c = this.parseFieldsDefinition();
1497
+ return this.node(t, {
1498
+ kind: f.OBJECT_TYPE_DEFINITION,
1499
+ description: n,
1500
+ name: r,
1501
+ interfaces: i,
1502
+ directives: s,
1503
+ fields: c
1504
+ });
1505
+ }
1506
+ /**
1507
+ * ImplementsInterfaces :
1508
+ * - implements `&`? NamedType
1509
+ * - ImplementsInterfaces & NamedType
1510
+ */
1511
+ parseImplementsInterfaces() {
1512
+ return this.expectOptionalKeyword("implements") ? this.delimitedMany(a.AMP, this.parseNamedType) : [];
1513
+ }
1514
+ /**
1515
+ * ```
1516
+ * FieldsDefinition : { FieldDefinition+ }
1517
+ * ```
1518
+ */
1519
+ parseFieldsDefinition() {
1520
+ return this.optionalMany(
1521
+ a.BRACE_L,
1522
+ this.parseFieldDefinition,
1523
+ a.BRACE_R
1524
+ );
1525
+ }
1526
+ /**
1527
+ * FieldDefinition :
1528
+ * - Description? Name ArgumentsDefinition? : Type Directives[Const]?
1529
+ */
1530
+ parseFieldDefinition() {
1531
+ const t = this._lexer.token, n = this.parseDescription(), r = this.parseName(), i = this.parseArgumentDefs();
1532
+ this.expectToken(a.COLON);
1533
+ const s = this.parseTypeReference(), c = this.parseConstDirectives();
1534
+ return this.node(t, {
1535
+ kind: f.FIELD_DEFINITION,
1536
+ description: n,
1537
+ name: r,
1538
+ arguments: i,
1539
+ type: s,
1540
+ directives: c
1541
+ });
1542
+ }
1543
+ /**
1544
+ * ArgumentsDefinition : ( InputValueDefinition+ )
1545
+ */
1546
+ parseArgumentDefs() {
1547
+ return this.optionalMany(
1548
+ a.PAREN_L,
1549
+ this.parseInputValueDef,
1550
+ a.PAREN_R
1551
+ );
1552
+ }
1553
+ /**
1554
+ * InputValueDefinition :
1555
+ * - Description? Name : Type DefaultValue? Directives[Const]?
1556
+ */
1557
+ parseInputValueDef() {
1558
+ const t = this._lexer.token, n = this.parseDescription(), r = this.parseName();
1559
+ this.expectToken(a.COLON);
1560
+ const i = this.parseTypeReference();
1561
+ let s;
1562
+ this.expectOptionalToken(a.EQUALS) && (s = this.parseConstValueLiteral());
1563
+ const c = this.parseConstDirectives();
1564
+ return this.node(t, {
1565
+ kind: f.INPUT_VALUE_DEFINITION,
1566
+ description: n,
1567
+ name: r,
1568
+ type: i,
1569
+ defaultValue: s,
1570
+ directives: c
1571
+ });
1572
+ }
1573
+ /**
1574
+ * InterfaceTypeDefinition :
1575
+ * - Description? interface Name Directives[Const]? FieldsDefinition?
1576
+ */
1577
+ parseInterfaceTypeDefinition() {
1578
+ const t = this._lexer.token, n = this.parseDescription();
1579
+ this.expectKeyword("interface");
1580
+ const r = this.parseName(), i = this.parseImplementsInterfaces(), s = this.parseConstDirectives(), c = this.parseFieldsDefinition();
1581
+ return this.node(t, {
1582
+ kind: f.INTERFACE_TYPE_DEFINITION,
1583
+ description: n,
1584
+ name: r,
1585
+ interfaces: i,
1586
+ directives: s,
1587
+ fields: c
1588
+ });
1589
+ }
1590
+ /**
1591
+ * UnionTypeDefinition :
1592
+ * - Description? union Name Directives[Const]? UnionMemberTypes?
1593
+ */
1594
+ parseUnionTypeDefinition() {
1595
+ const t = this._lexer.token, n = this.parseDescription();
1596
+ this.expectKeyword("union");
1597
+ const r = this.parseName(), i = this.parseConstDirectives(), s = this.parseUnionMemberTypes();
1598
+ return this.node(t, {
1599
+ kind: f.UNION_TYPE_DEFINITION,
1600
+ description: n,
1601
+ name: r,
1602
+ directives: i,
1603
+ types: s
1604
+ });
1605
+ }
1606
+ /**
1607
+ * UnionMemberTypes :
1608
+ * - = `|`? NamedType
1609
+ * - UnionMemberTypes | NamedType
1610
+ */
1611
+ parseUnionMemberTypes() {
1612
+ return this.expectOptionalToken(a.EQUALS) ? this.delimitedMany(a.PIPE, this.parseNamedType) : [];
1613
+ }
1614
+ /**
1615
+ * EnumTypeDefinition :
1616
+ * - Description? enum Name Directives[Const]? EnumValuesDefinition?
1617
+ */
1618
+ parseEnumTypeDefinition() {
1619
+ const t = this._lexer.token, n = this.parseDescription();
1620
+ this.expectKeyword("enum");
1621
+ const r = this.parseName(), i = this.parseConstDirectives(), s = this.parseEnumValuesDefinition();
1622
+ return this.node(t, {
1623
+ kind: f.ENUM_TYPE_DEFINITION,
1624
+ description: n,
1625
+ name: r,
1626
+ directives: i,
1627
+ values: s
1628
+ });
1629
+ }
1630
+ /**
1631
+ * ```
1632
+ * EnumValuesDefinition : { EnumValueDefinition+ }
1633
+ * ```
1634
+ */
1635
+ parseEnumValuesDefinition() {
1636
+ return this.optionalMany(
1637
+ a.BRACE_L,
1638
+ this.parseEnumValueDefinition,
1639
+ a.BRACE_R
1640
+ );
1641
+ }
1642
+ /**
1643
+ * EnumValueDefinition : Description? EnumValue Directives[Const]?
1644
+ */
1645
+ parseEnumValueDefinition() {
1646
+ const t = this._lexer.token, n = this.parseDescription(), r = this.parseEnumValueName(), i = this.parseConstDirectives();
1647
+ return this.node(t, {
1648
+ kind: f.ENUM_VALUE_DEFINITION,
1649
+ description: n,
1650
+ name: r,
1651
+ directives: i
1652
+ });
1653
+ }
1654
+ /**
1655
+ * EnumValue : Name but not `true`, `false` or `null`
1656
+ */
1657
+ parseEnumValueName() {
1658
+ if (this._lexer.token.value === "true" || this._lexer.token.value === "false" || this._lexer.token.value === "null")
1659
+ throw O(
1660
+ this._lexer.source,
1661
+ this._lexer.token.start,
1662
+ `${J(
1663
+ this._lexer.token
1664
+ )} is reserved and cannot be used for an enum value.`
1665
+ );
1666
+ return this.parseName();
1667
+ }
1668
+ /**
1669
+ * InputObjectTypeDefinition :
1670
+ * - Description? input Name Directives[Const]? InputFieldsDefinition?
1671
+ */
1672
+ parseInputObjectTypeDefinition() {
1673
+ const t = this._lexer.token, n = this.parseDescription();
1674
+ this.expectKeyword("input");
1675
+ const r = this.parseName(), i = this.parseConstDirectives(), s = this.parseInputFieldsDefinition();
1676
+ return this.node(t, {
1677
+ kind: f.INPUT_OBJECT_TYPE_DEFINITION,
1678
+ description: n,
1679
+ name: r,
1680
+ directives: i,
1681
+ fields: s
1682
+ });
1683
+ }
1684
+ /**
1685
+ * ```
1686
+ * InputFieldsDefinition : { InputValueDefinition+ }
1687
+ * ```
1688
+ */
1689
+ parseInputFieldsDefinition() {
1690
+ return this.optionalMany(
1691
+ a.BRACE_L,
1692
+ this.parseInputValueDef,
1693
+ a.BRACE_R
1694
+ );
1695
+ }
1696
+ /**
1697
+ * TypeSystemExtension :
1698
+ * - SchemaExtension
1699
+ * - TypeExtension
1700
+ *
1701
+ * TypeExtension :
1702
+ * - ScalarTypeExtension
1703
+ * - ObjectTypeExtension
1704
+ * - InterfaceTypeExtension
1705
+ * - UnionTypeExtension
1706
+ * - EnumTypeExtension
1707
+ * - InputObjectTypeDefinition
1708
+ */
1709
+ parseTypeSystemExtension() {
1710
+ const t = this._lexer.lookahead();
1711
+ if (t.kind === a.NAME)
1712
+ switch (t.value) {
1713
+ case "schema":
1714
+ return this.parseSchemaExtension();
1715
+ case "scalar":
1716
+ return this.parseScalarTypeExtension();
1717
+ case "type":
1718
+ return this.parseObjectTypeExtension();
1719
+ case "interface":
1720
+ return this.parseInterfaceTypeExtension();
1721
+ case "union":
1722
+ return this.parseUnionTypeExtension();
1723
+ case "enum":
1724
+ return this.parseEnumTypeExtension();
1725
+ case "input":
1726
+ return this.parseInputObjectTypeExtension();
1727
+ }
1728
+ throw this.unexpected(t);
1729
+ }
1730
+ /**
1731
+ * ```
1732
+ * SchemaExtension :
1733
+ * - extend schema Directives[Const]? { OperationTypeDefinition+ }
1734
+ * - extend schema Directives[Const]
1735
+ * ```
1736
+ */
1737
+ parseSchemaExtension() {
1738
+ const t = this._lexer.token;
1739
+ this.expectKeyword("extend"), this.expectKeyword("schema");
1740
+ const n = this.parseConstDirectives(), r = this.optionalMany(
1741
+ a.BRACE_L,
1742
+ this.parseOperationTypeDefinition,
1743
+ a.BRACE_R
1744
+ );
1745
+ if (n.length === 0 && r.length === 0)
1746
+ throw this.unexpected();
1747
+ return this.node(t, {
1748
+ kind: f.SCHEMA_EXTENSION,
1749
+ directives: n,
1750
+ operationTypes: r
1751
+ });
1752
+ }
1753
+ /**
1754
+ * ScalarTypeExtension :
1755
+ * - extend scalar Name Directives[Const]
1756
+ */
1757
+ parseScalarTypeExtension() {
1758
+ const t = this._lexer.token;
1759
+ this.expectKeyword("extend"), this.expectKeyword("scalar");
1760
+ const n = this.parseName(), r = this.parseConstDirectives();
1761
+ if (r.length === 0)
1762
+ throw this.unexpected();
1763
+ return this.node(t, {
1764
+ kind: f.SCALAR_TYPE_EXTENSION,
1765
+ name: n,
1766
+ directives: r
1767
+ });
1768
+ }
1769
+ /**
1770
+ * ObjectTypeExtension :
1771
+ * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
1772
+ * - extend type Name ImplementsInterfaces? Directives[Const]
1773
+ * - extend type Name ImplementsInterfaces
1774
+ */
1775
+ parseObjectTypeExtension() {
1776
+ const t = this._lexer.token;
1777
+ this.expectKeyword("extend"), this.expectKeyword("type");
1778
+ const n = this.parseName(), r = this.parseImplementsInterfaces(), i = this.parseConstDirectives(), s = this.parseFieldsDefinition();
1779
+ if (r.length === 0 && i.length === 0 && s.length === 0)
1780
+ throw this.unexpected();
1781
+ return this.node(t, {
1782
+ kind: f.OBJECT_TYPE_EXTENSION,
1783
+ name: n,
1784
+ interfaces: r,
1785
+ directives: i,
1786
+ fields: s
1787
+ });
1788
+ }
1789
+ /**
1790
+ * InterfaceTypeExtension :
1791
+ * - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
1792
+ * - extend interface Name ImplementsInterfaces? Directives[Const]
1793
+ * - extend interface Name ImplementsInterfaces
1794
+ */
1795
+ parseInterfaceTypeExtension() {
1796
+ const t = this._lexer.token;
1797
+ this.expectKeyword("extend"), this.expectKeyword("interface");
1798
+ const n = this.parseName(), r = this.parseImplementsInterfaces(), i = this.parseConstDirectives(), s = this.parseFieldsDefinition();
1799
+ if (r.length === 0 && i.length === 0 && s.length === 0)
1800
+ throw this.unexpected();
1801
+ return this.node(t, {
1802
+ kind: f.INTERFACE_TYPE_EXTENSION,
1803
+ name: n,
1804
+ interfaces: r,
1805
+ directives: i,
1806
+ fields: s
1807
+ });
1808
+ }
1809
+ /**
1810
+ * UnionTypeExtension :
1811
+ * - extend union Name Directives[Const]? UnionMemberTypes
1812
+ * - extend union Name Directives[Const]
1813
+ */
1814
+ parseUnionTypeExtension() {
1815
+ const t = this._lexer.token;
1816
+ this.expectKeyword("extend"), this.expectKeyword("union");
1817
+ const n = this.parseName(), r = this.parseConstDirectives(), i = this.parseUnionMemberTypes();
1818
+ if (r.length === 0 && i.length === 0)
1819
+ throw this.unexpected();
1820
+ return this.node(t, {
1821
+ kind: f.UNION_TYPE_EXTENSION,
1822
+ name: n,
1823
+ directives: r,
1824
+ types: i
1825
+ });
1826
+ }
1827
+ /**
1828
+ * EnumTypeExtension :
1829
+ * - extend enum Name Directives[Const]? EnumValuesDefinition
1830
+ * - extend enum Name Directives[Const]
1831
+ */
1832
+ parseEnumTypeExtension() {
1833
+ const t = this._lexer.token;
1834
+ this.expectKeyword("extend"), this.expectKeyword("enum");
1835
+ const n = this.parseName(), r = this.parseConstDirectives(), i = this.parseEnumValuesDefinition();
1836
+ if (r.length === 0 && i.length === 0)
1837
+ throw this.unexpected();
1838
+ return this.node(t, {
1839
+ kind: f.ENUM_TYPE_EXTENSION,
1840
+ name: n,
1841
+ directives: r,
1842
+ values: i
1843
+ });
1844
+ }
1845
+ /**
1846
+ * InputObjectTypeExtension :
1847
+ * - extend input Name Directives[Const]? InputFieldsDefinition
1848
+ * - extend input Name Directives[Const]
1849
+ */
1850
+ parseInputObjectTypeExtension() {
1851
+ const t = this._lexer.token;
1852
+ this.expectKeyword("extend"), this.expectKeyword("input");
1853
+ const n = this.parseName(), r = this.parseConstDirectives(), i = this.parseInputFieldsDefinition();
1854
+ if (r.length === 0 && i.length === 0)
1855
+ throw this.unexpected();
1856
+ return this.node(t, {
1857
+ kind: f.INPUT_OBJECT_TYPE_EXTENSION,
1858
+ name: n,
1859
+ directives: r,
1860
+ fields: i
1861
+ });
1862
+ }
1863
+ /**
1864
+ * ```
1865
+ * DirectiveDefinition :
1866
+ * - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations
1867
+ * ```
1868
+ */
1869
+ parseDirectiveDefinition() {
1870
+ const t = this._lexer.token, n = this.parseDescription();
1871
+ this.expectKeyword("directive"), this.expectToken(a.AT);
1872
+ const r = this.parseName(), i = this.parseArgumentDefs(), s = this.expectOptionalKeyword("repeatable");
1873
+ this.expectKeyword("on");
1874
+ const c = this.parseDirectiveLocations();
1875
+ return this.node(t, {
1876
+ kind: f.DIRECTIVE_DEFINITION,
1877
+ description: n,
1878
+ name: r,
1879
+ arguments: i,
1880
+ repeatable: s,
1881
+ locations: c
1882
+ });
1883
+ }
1884
+ /**
1885
+ * DirectiveLocations :
1886
+ * - `|`? DirectiveLocation
1887
+ * - DirectiveLocations | DirectiveLocation
1888
+ */
1889
+ parseDirectiveLocations() {
1890
+ return this.delimitedMany(a.PIPE, this.parseDirectiveLocation);
1891
+ }
1892
+ /*
1893
+ * DirectiveLocation :
1894
+ * - ExecutableDirectiveLocation
1895
+ * - TypeSystemDirectiveLocation
1896
+ *
1897
+ * ExecutableDirectiveLocation : one of
1898
+ * `QUERY`
1899
+ * `MUTATION`
1900
+ * `SUBSCRIPTION`
1901
+ * `FIELD`
1902
+ * `FRAGMENT_DEFINITION`
1903
+ * `FRAGMENT_SPREAD`
1904
+ * `INLINE_FRAGMENT`
1905
+ *
1906
+ * TypeSystemDirectiveLocation : one of
1907
+ * `SCHEMA`
1908
+ * `SCALAR`
1909
+ * `OBJECT`
1910
+ * `FIELD_DEFINITION`
1911
+ * `ARGUMENT_DEFINITION`
1912
+ * `INTERFACE`
1913
+ * `UNION`
1914
+ * `ENUM`
1915
+ * `ENUM_VALUE`
1916
+ * `INPUT_OBJECT`
1917
+ * `INPUT_FIELD_DEFINITION`
1918
+ */
1919
+ parseDirectiveLocation() {
1920
+ const t = this._lexer.token, n = this.parseName();
1921
+ if (Object.prototype.hasOwnProperty.call(ce, n.value))
1922
+ return n;
1923
+ throw this.unexpected(t);
1924
+ }
1925
+ // Core parsing utility functions
1926
+ /**
1927
+ * Returns a node that, if configured to do so, sets a "loc" field as a
1928
+ * location object, used to identify the place in the source that created a
1929
+ * given parsed object.
1930
+ */
1931
+ node(t, n) {
1932
+ return this._options.noLocation !== !0 && (n.loc = new Ye(
1933
+ t,
1934
+ this._lexer.lastToken,
1935
+ this._lexer.source
1936
+ )), n;
1937
+ }
1938
+ /**
1939
+ * Determines if the next token is of a given kind
1940
+ */
1941
+ peek(t) {
1942
+ return this._lexer.token.kind === t;
1943
+ }
1944
+ /**
1945
+ * If the next token is of the given kind, return that token after advancing the lexer.
1946
+ * Otherwise, do not change the parser state and throw an error.
1947
+ */
1948
+ expectToken(t) {
1949
+ const n = this._lexer.token;
1950
+ if (n.kind === t)
1951
+ return this.advanceLexer(), n;
1952
+ throw O(
1953
+ this._lexer.source,
1954
+ n.start,
1955
+ `Expected ${Ce(t)}, found ${J(n)}.`
1956
+ );
1957
+ }
1958
+ /**
1959
+ * If the next token is of the given kind, return "true" after advancing the lexer.
1960
+ * Otherwise, do not change the parser state and return "false".
1961
+ */
1962
+ expectOptionalToken(t) {
1963
+ return this._lexer.token.kind === t ? (this.advanceLexer(), !0) : !1;
1964
+ }
1965
+ /**
1966
+ * If the next token is a given keyword, advance the lexer.
1967
+ * Otherwise, do not change the parser state and throw an error.
1968
+ */
1969
+ expectKeyword(t) {
1970
+ const n = this._lexer.token;
1971
+ if (n.kind === a.NAME && n.value === t)
1972
+ this.advanceLexer();
1973
+ else
1974
+ throw O(
1975
+ this._lexer.source,
1976
+ n.start,
1977
+ `Expected "${t}", found ${J(n)}.`
1978
+ );
1979
+ }
1980
+ /**
1981
+ * If the next token is a given keyword, return "true" after advancing the lexer.
1982
+ * Otherwise, do not change the parser state and return "false".
1983
+ */
1984
+ expectOptionalKeyword(t) {
1985
+ const n = this._lexer.token;
1986
+ return n.kind === a.NAME && n.value === t ? (this.advanceLexer(), !0) : !1;
1987
+ }
1988
+ /**
1989
+ * Helper function for creating an error when an unexpected lexed token is encountered.
1990
+ */
1991
+ unexpected(t) {
1992
+ const n = t ?? this._lexer.token;
1993
+ return O(
1994
+ this._lexer.source,
1995
+ n.start,
1996
+ `Unexpected ${J(n)}.`
1997
+ );
1998
+ }
1999
+ /**
2000
+ * Returns a possibly empty list of parse nodes, determined by the parseFn.
2001
+ * This list begins with a lex token of openKind and ends with a lex token of closeKind.
2002
+ * Advances the parser to the next lex token after the closing token.
2003
+ */
2004
+ any(t, n, r) {
2005
+ this.expectToken(t);
2006
+ const i = [];
2007
+ for (; !this.expectOptionalToken(r); )
2008
+ i.push(n.call(this));
2009
+ return i;
2010
+ }
2011
+ /**
2012
+ * Returns a list of parse nodes, determined by the parseFn.
2013
+ * It can be empty only if open token is missing otherwise it will always return non-empty list
2014
+ * that begins with a lex token of openKind and ends with a lex token of closeKind.
2015
+ * Advances the parser to the next lex token after the closing token.
2016
+ */
2017
+ optionalMany(t, n, r) {
2018
+ if (this.expectOptionalToken(t)) {
2019
+ const i = [];
2020
+ do
2021
+ i.push(n.call(this));
2022
+ while (!this.expectOptionalToken(r));
2023
+ return i;
2024
+ }
2025
+ return [];
2026
+ }
2027
+ /**
2028
+ * Returns a non-empty list of parse nodes, determined by the parseFn.
2029
+ * This list begins with a lex token of openKind and ends with a lex token of closeKind.
2030
+ * Advances the parser to the next lex token after the closing token.
2031
+ */
2032
+ many(t, n, r) {
2033
+ this.expectToken(t);
2034
+ const i = [];
2035
+ do
2036
+ i.push(n.call(this));
2037
+ while (!this.expectOptionalToken(r));
2038
+ return i;
2039
+ }
2040
+ /**
2041
+ * Returns a non-empty list of parse nodes, determined by the parseFn.
2042
+ * This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.
2043
+ * Advances the parser to the next lex token after last item in the list.
2044
+ */
2045
+ delimitedMany(t, n) {
2046
+ this.expectOptionalToken(t);
2047
+ const r = [];
2048
+ do
2049
+ r.push(n.call(this));
2050
+ while (this.expectOptionalToken(t));
2051
+ return r;
2052
+ }
2053
+ advanceLexer() {
2054
+ const { maxTokens: t } = this._options, n = this._lexer.advance();
2055
+ if (t !== void 0 && n.kind !== a.EOF && (++this._tokenCounter, this._tokenCounter > t))
2056
+ throw O(
2057
+ this._lexer.source,
2058
+ n.start,
2059
+ `Document contains more that ${t} tokens. Parsing aborted.`
2060
+ );
2061
+ }
2062
+ }
2063
+ function J(e) {
2064
+ const t = e.value;
2065
+ return Ce(e.kind) + (t != null ? ` "${t}"` : "");
2066
+ }
2067
+ function Ce(e) {
2068
+ return Ke(e) ? `"${e}"` : e;
2069
+ }
2070
+ function Nt(e) {
2071
+ return `"${e.replace(vt, xt)}"`;
2072
+ }
2073
+ const vt = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g;
2074
+ function xt(e) {
2075
+ return At[e.charCodeAt(0)];
2076
+ }
2077
+ const At = [
2078
+ "\\u0000",
2079
+ "\\u0001",
2080
+ "\\u0002",
2081
+ "\\u0003",
2082
+ "\\u0004",
2083
+ "\\u0005",
2084
+ "\\u0006",
2085
+ "\\u0007",
2086
+ "\\b",
2087
+ "\\t",
2088
+ "\\n",
2089
+ "\\u000B",
2090
+ "\\f",
2091
+ "\\r",
2092
+ "\\u000E",
2093
+ "\\u000F",
2094
+ "\\u0010",
2095
+ "\\u0011",
2096
+ "\\u0012",
2097
+ "\\u0013",
2098
+ "\\u0014",
2099
+ "\\u0015",
2100
+ "\\u0016",
2101
+ "\\u0017",
2102
+ "\\u0018",
2103
+ "\\u0019",
2104
+ "\\u001A",
2105
+ "\\u001B",
2106
+ "\\u001C",
2107
+ "\\u001D",
2108
+ "\\u001E",
2109
+ "\\u001F",
2110
+ "",
2111
+ "",
2112
+ '\\"',
2113
+ "",
2114
+ "",
2115
+ "",
2116
+ "",
2117
+ "",
2118
+ "",
2119
+ "",
2120
+ "",
2121
+ "",
2122
+ "",
2123
+ "",
2124
+ "",
2125
+ "",
2126
+ // 2F
2127
+ "",
2128
+ "",
2129
+ "",
2130
+ "",
2131
+ "",
2132
+ "",
2133
+ "",
2134
+ "",
2135
+ "",
2136
+ "",
2137
+ "",
2138
+ "",
2139
+ "",
2140
+ "",
2141
+ "",
2142
+ "",
2143
+ // 3F
2144
+ "",
2145
+ "",
2146
+ "",
2147
+ "",
2148
+ "",
2149
+ "",
2150
+ "",
2151
+ "",
2152
+ "",
2153
+ "",
2154
+ "",
2155
+ "",
2156
+ "",
2157
+ "",
2158
+ "",
2159
+ "",
2160
+ // 4F
2161
+ "",
2162
+ "",
2163
+ "",
2164
+ "",
2165
+ "",
2166
+ "",
2167
+ "",
2168
+ "",
2169
+ "",
2170
+ "",
2171
+ "",
2172
+ "",
2173
+ "\\\\",
2174
+ "",
2175
+ "",
2176
+ "",
2177
+ // 5F
2178
+ "",
2179
+ "",
2180
+ "",
2181
+ "",
2182
+ "",
2183
+ "",
2184
+ "",
2185
+ "",
2186
+ "",
2187
+ "",
2188
+ "",
2189
+ "",
2190
+ "",
2191
+ "",
2192
+ "",
2193
+ "",
2194
+ // 6F
2195
+ "",
2196
+ "",
2197
+ "",
2198
+ "",
2199
+ "",
2200
+ "",
2201
+ "",
2202
+ "",
2203
+ "",
2204
+ "",
2205
+ "",
2206
+ "",
2207
+ "",
2208
+ "",
2209
+ "",
2210
+ "\\u007F",
2211
+ "\\u0080",
2212
+ "\\u0081",
2213
+ "\\u0082",
2214
+ "\\u0083",
2215
+ "\\u0084",
2216
+ "\\u0085",
2217
+ "\\u0086",
2218
+ "\\u0087",
2219
+ "\\u0088",
2220
+ "\\u0089",
2221
+ "\\u008A",
2222
+ "\\u008B",
2223
+ "\\u008C",
2224
+ "\\u008D",
2225
+ "\\u008E",
2226
+ "\\u008F",
2227
+ "\\u0090",
2228
+ "\\u0091",
2229
+ "\\u0092",
2230
+ "\\u0093",
2231
+ "\\u0094",
2232
+ "\\u0095",
2233
+ "\\u0096",
2234
+ "\\u0097",
2235
+ "\\u0098",
2236
+ "\\u0099",
2237
+ "\\u009A",
2238
+ "\\u009B",
2239
+ "\\u009C",
2240
+ "\\u009D",
2241
+ "\\u009E",
2242
+ "\\u009F"
2243
+ ], It = Object.freeze({});
2244
+ function gt(e, t, n = Ie) {
2245
+ const r = /* @__PURE__ */ new Map();
2246
+ for (const S of Object.values(f))
2247
+ r.set(S, Ot(t, S));
2248
+ let i, s = Array.isArray(e), c = [e], u = -1, p = [], d = e, y, m;
2249
+ const T = [], A = [];
2250
+ do {
2251
+ u++;
2252
+ const S = u === c.length, G = S && p.length !== 0;
2253
+ if (S) {
2254
+ if (y = A.length === 0 ? void 0 : T[T.length - 1], d = m, m = A.pop(), G)
2255
+ if (s) {
2256
+ d = d.slice();
2257
+ let C = 0;
2258
+ for (const [P, H] of p) {
2259
+ const Y = P - C;
2260
+ H === null ? (d.splice(Y, 1), C++) : d[Y] = H;
2261
+ }
2262
+ } else {
2263
+ d = Object.defineProperties(
2264
+ {},
2265
+ Object.getOwnPropertyDescriptors(d)
2266
+ );
2267
+ for (const [C, P] of p)
2268
+ d[C] = P;
2269
+ }
2270
+ u = i.index, c = i.keys, p = i.edits, s = i.inArray, i = i.prev;
2271
+ } else if (m) {
2272
+ if (y = s ? u : c[u], d = m[y], d == null)
2273
+ continue;
2274
+ T.push(y);
2275
+ }
2276
+ let k;
2277
+ if (!Array.isArray(d)) {
2278
+ var E, I;
2279
+ Ee(d) || Q(!1, `Invalid AST Node: ${de(d)}.`);
2280
+ const C = S ? (E = r.get(d.kind)) === null || E === void 0 ? void 0 : E.leave : (I = r.get(d.kind)) === null || I === void 0 ? void 0 : I.enter;
2281
+ if (k = C == null ? void 0 : C.call(t, d, y, m, T, A), k === It)
2282
+ break;
2283
+ if (k === !1) {
2284
+ if (!S) {
2285
+ T.pop();
2286
+ continue;
2287
+ }
2288
+ } else if (k !== void 0 && (p.push([y, k]), !S))
2289
+ if (Ee(k))
2290
+ d = k;
2291
+ else {
2292
+ T.pop();
2293
+ continue;
2294
+ }
2295
+ }
2296
+ if (k === void 0 && G && p.push([y, d]), S)
2297
+ T.pop();
2298
+ else {
2299
+ var D;
2300
+ i = {
2301
+ inArray: s,
2302
+ index: u,
2303
+ keys: c,
2304
+ edits: p,
2305
+ prev: i
2306
+ }, s = Array.isArray(d), c = s ? d : (D = n[d.kind]) !== null && D !== void 0 ? D : [], u = -1, p = [], m && A.push(m), m = d;
2307
+ }
2308
+ } while (i !== void 0);
2309
+ return p.length !== 0 ? p[p.length - 1][1] : e;
2310
+ }
2311
+ function Ot(e, t) {
2312
+ const n = e[t];
2313
+ return typeof n == "object" ? n : typeof n == "function" ? {
2314
+ enter: n,
2315
+ leave: void 0
2316
+ } : {
2317
+ enter: e.enter,
2318
+ leave: e.leave
2319
+ };
2320
+ }
2321
+ function _t(e) {
2322
+ return gt(e, Dt);
2323
+ }
2324
+ const bt = 80, Dt = {
2325
+ Name: {
2326
+ leave: (e) => e.value
2327
+ },
2328
+ Variable: {
2329
+ leave: (e) => "$" + e.name
2330
+ },
2331
+ // Document
2332
+ Document: {
2333
+ leave: (e) => h(e.definitions, `
2334
+
2335
+ `)
2336
+ },
2337
+ OperationDefinition: {
2338
+ leave(e) {
2339
+ const t = v("(", h(e.variableDefinitions, ", "), ")"), n = h(
2340
+ [
2341
+ e.operation,
2342
+ h([e.name, t]),
2343
+ h(e.directives, " ")
2344
+ ],
2345
+ " "
2346
+ );
2347
+ return (n === "query" ? "" : n + " ") + e.selectionSet;
2348
+ }
2349
+ },
2350
+ VariableDefinition: {
2351
+ leave: ({ variable: e, type: t, defaultValue: n, directives: r }) => e + ": " + t + v(" = ", n) + v(" ", h(r, " "))
2352
+ },
2353
+ SelectionSet: {
2354
+ leave: ({ selections: e }) => w(e)
2355
+ },
2356
+ Field: {
2357
+ leave({ alias: e, name: t, arguments: n, directives: r, selectionSet: i }) {
2358
+ const s = v("", e, ": ") + t;
2359
+ let c = s + v("(", h(n, ", "), ")");
2360
+ return c.length > bt && (c = s + v(`(
2361
+ `, X(h(n, `
2362
+ `)), `
2363
+ )`)), h([c, h(r, " "), i], " ");
2364
+ }
2365
+ },
2366
+ Argument: {
2367
+ leave: ({ name: e, value: t }) => e + ": " + t
2368
+ },
2369
+ // Fragments
2370
+ FragmentSpread: {
2371
+ leave: ({ name: e, directives: t }) => "..." + e + v(" ", h(t, " "))
2372
+ },
2373
+ InlineFragment: {
2374
+ leave: ({ typeCondition: e, directives: t, selectionSet: n }) => h(
2375
+ [
2376
+ "...",
2377
+ v("on ", e),
2378
+ h(t, " "),
2379
+ n
2380
+ ],
2381
+ " "
2382
+ )
2383
+ },
2384
+ FragmentDefinition: {
2385
+ leave: ({ name: e, typeCondition: t, variableDefinitions: n, directives: r, selectionSet: i }) => (
2386
+ // or removed in the future.
2387
+ `fragment ${e}${v("(", h(n, ", "), ")")} on ${t} ${v("", h(r, " "), " ")}` + i
2388
+ )
2389
+ },
2390
+ // Value
2391
+ IntValue: {
2392
+ leave: ({ value: e }) => e
2393
+ },
2394
+ FloatValue: {
2395
+ leave: ({ value: e }) => e
2396
+ },
2397
+ StringValue: {
2398
+ leave: ({ value: e, block: t }) => t ? We(e) : Nt(e)
2399
+ },
2400
+ BooleanValue: {
2401
+ leave: ({ value: e }) => e ? "true" : "false"
2402
+ },
2403
+ NullValue: {
2404
+ leave: () => "null"
2405
+ },
2406
+ EnumValue: {
2407
+ leave: ({ value: e }) => e
2408
+ },
2409
+ ListValue: {
2410
+ leave: ({ values: e }) => "[" + h(e, ", ") + "]"
2411
+ },
2412
+ ObjectValue: {
2413
+ leave: ({ fields: e }) => "{" + h(e, ", ") + "}"
2414
+ },
2415
+ ObjectField: {
2416
+ leave: ({ name: e, value: t }) => e + ": " + t
2417
+ },
2418
+ // Directive
2419
+ Directive: {
2420
+ leave: ({ name: e, arguments: t }) => "@" + e + v("(", h(t, ", "), ")")
2421
+ },
2422
+ // Type
2423
+ NamedType: {
2424
+ leave: ({ name: e }) => e
2425
+ },
2426
+ ListType: {
2427
+ leave: ({ type: e }) => "[" + e + "]"
2428
+ },
2429
+ NonNullType: {
2430
+ leave: ({ type: e }) => e + "!"
2431
+ },
2432
+ // Type System Definitions
2433
+ SchemaDefinition: {
2434
+ leave: ({ description: e, directives: t, operationTypes: n }) => v("", e, `
2435
+ `) + h(["schema", h(t, " "), w(n)], " ")
2436
+ },
2437
+ OperationTypeDefinition: {
2438
+ leave: ({ operation: e, type: t }) => e + ": " + t
2439
+ },
2440
+ ScalarTypeDefinition: {
2441
+ leave: ({ description: e, name: t, directives: n }) => v("", e, `
2442
+ `) + h(["scalar", t, h(n, " ")], " ")
2443
+ },
2444
+ ObjectTypeDefinition: {
2445
+ leave: ({ description: e, name: t, interfaces: n, directives: r, fields: i }) => v("", e, `
2446
+ `) + h(
2447
+ [
2448
+ "type",
2449
+ t,
2450
+ v("implements ", h(n, " & ")),
2451
+ h(r, " "),
2452
+ w(i)
2453
+ ],
2454
+ " "
2455
+ )
2456
+ },
2457
+ FieldDefinition: {
2458
+ leave: ({ description: e, name: t, arguments: n, type: r, directives: i }) => v("", e, `
2459
+ `) + t + (Te(n) ? v(`(
2460
+ `, X(h(n, `
2461
+ `)), `
2462
+ )`) : v("(", h(n, ", "), ")")) + ": " + r + v(" ", h(i, " "))
2463
+ },
2464
+ InputValueDefinition: {
2465
+ leave: ({ description: e, name: t, type: n, defaultValue: r, directives: i }) => v("", e, `
2466
+ `) + h(
2467
+ [t + ": " + n, v("= ", r), h(i, " ")],
2468
+ " "
2469
+ )
2470
+ },
2471
+ InterfaceTypeDefinition: {
2472
+ leave: ({ description: e, name: t, interfaces: n, directives: r, fields: i }) => v("", e, `
2473
+ `) + h(
2474
+ [
2475
+ "interface",
2476
+ t,
2477
+ v("implements ", h(n, " & ")),
2478
+ h(r, " "),
2479
+ w(i)
2480
+ ],
2481
+ " "
2482
+ )
2483
+ },
2484
+ UnionTypeDefinition: {
2485
+ leave: ({ description: e, name: t, directives: n, types: r }) => v("", e, `
2486
+ `) + h(
2487
+ ["union", t, h(n, " "), v("= ", h(r, " | "))],
2488
+ " "
2489
+ )
2490
+ },
2491
+ EnumTypeDefinition: {
2492
+ leave: ({ description: e, name: t, directives: n, values: r }) => v("", e, `
2493
+ `) + h(["enum", t, h(n, " "), w(r)], " ")
2494
+ },
2495
+ EnumValueDefinition: {
2496
+ leave: ({ description: e, name: t, directives: n }) => v("", e, `
2497
+ `) + h([t, h(n, " ")], " ")
2498
+ },
2499
+ InputObjectTypeDefinition: {
2500
+ leave: ({ description: e, name: t, directives: n, fields: r }) => v("", e, `
2501
+ `) + h(["input", t, h(n, " "), w(r)], " ")
2502
+ },
2503
+ DirectiveDefinition: {
2504
+ leave: ({ description: e, name: t, arguments: n, repeatable: r, locations: i }) => v("", e, `
2505
+ `) + "directive @" + t + (Te(n) ? v(`(
2506
+ `, X(h(n, `
2507
+ `)), `
2508
+ )`) : v("(", h(n, ", "), ")")) + (r ? " repeatable" : "") + " on " + h(i, " | ")
2509
+ },
2510
+ SchemaExtension: {
2511
+ leave: ({ directives: e, operationTypes: t }) => h(
2512
+ ["extend schema", h(e, " "), w(t)],
2513
+ " "
2514
+ )
2515
+ },
2516
+ ScalarTypeExtension: {
2517
+ leave: ({ name: e, directives: t }) => h(["extend scalar", e, h(t, " ")], " ")
2518
+ },
2519
+ ObjectTypeExtension: {
2520
+ leave: ({ name: e, interfaces: t, directives: n, fields: r }) => h(
2521
+ [
2522
+ "extend type",
2523
+ e,
2524
+ v("implements ", h(t, " & ")),
2525
+ h(n, " "),
2526
+ w(r)
2527
+ ],
2528
+ " "
2529
+ )
2530
+ },
2531
+ InterfaceTypeExtension: {
2532
+ leave: ({ name: e, interfaces: t, directives: n, fields: r }) => h(
2533
+ [
2534
+ "extend interface",
2535
+ e,
2536
+ v("implements ", h(t, " & ")),
2537
+ h(n, " "),
2538
+ w(r)
2539
+ ],
2540
+ " "
2541
+ )
2542
+ },
2543
+ UnionTypeExtension: {
2544
+ leave: ({ name: e, directives: t, types: n }) => h(
2545
+ [
2546
+ "extend union",
2547
+ e,
2548
+ h(t, " "),
2549
+ v("= ", h(n, " | "))
2550
+ ],
2551
+ " "
2552
+ )
2553
+ },
2554
+ EnumTypeExtension: {
2555
+ leave: ({ name: e, directives: t, values: n }) => h(["extend enum", e, h(t, " "), w(n)], " ")
2556
+ },
2557
+ InputObjectTypeExtension: {
2558
+ leave: ({ name: e, directives: t, fields: n }) => h(["extend input", e, h(t, " "), w(n)], " ")
2559
+ }
2560
+ };
2561
+ function h(e, t = "") {
2562
+ var n;
2563
+ return (n = e == null ? void 0 : e.filter((r) => r).join(t)) !== null && n !== void 0 ? n : "";
2564
+ }
2565
+ function w(e) {
2566
+ return v(`{
2567
+ `, X(h(e, `
2568
+ `)), `
2569
+ }`);
2570
+ }
2571
+ function v(e, t, n = "") {
2572
+ return t != null && t !== "" ? e + t + n : "";
2573
+ }
2574
+ function X(e) {
2575
+ return v(" ", e.replace(/\n/g, `
2576
+ `));
2577
+ }
2578
+ function Te(e) {
2579
+ var t;
2580
+ return (t = e == null ? void 0 : e.some((n) => n.includes(`
2581
+ `))) !== null && t !== void 0 ? t : !1;
2582
+ }
2583
+ const Ne = (e) => {
2584
+ var r, i;
2585
+ let t;
2586
+ const n = e.definitions.filter((s) => s.kind === "OperationDefinition");
2587
+ return n.length === 1 && (t = (i = (r = n[0]) == null ? void 0 : r.name) == null ? void 0 : i.value), t;
2588
+ }, re = (e) => {
2589
+ if (typeof e == "string") {
2590
+ let n;
2591
+ try {
2592
+ const r = mt(e);
2593
+ n = Ne(r);
2594
+ } catch {
2595
+ }
2596
+ return { query: e, operationName: n };
2597
+ }
2598
+ const t = Ne(e);
2599
+ return { query: _t(e), operationName: t };
2600
+ };
2601
+ class q extends Error {
2602
+ constructor(t, n) {
2603
+ const r = `${q.extractMessage(t)}: ${JSON.stringify({
2604
+ response: t,
2605
+ request: n
2606
+ })}`;
2607
+ super(r), Object.setPrototypeOf(this, q.prototype), this.response = t, this.request = n, typeof Error.captureStackTrace == "function" && Error.captureStackTrace(this, q);
2608
+ }
2609
+ static extractMessage(t) {
2610
+ var n, r;
2611
+ return ((r = (n = t.errors) == null ? void 0 : n[0]) == null ? void 0 : r.message) ?? `GraphQL Error (Code: ${t.status})`;
2612
+ }
2613
+ }
2614
+ var St = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
2615
+ function Ct(e) {
2616
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
2617
+ }
2618
+ var le = { exports: {} };
2619
+ (function(e, t) {
2620
+ var n = typeof self < "u" ? self : St, r = function() {
2621
+ function s() {
2622
+ this.fetch = !1, this.DOMException = n.DOMException;
2623
+ }
2624
+ return s.prototype = n, new s();
2625
+ }();
2626
+ (function(s) {
2627
+ (function(c) {
2628
+ var u = {
2629
+ searchParams: "URLSearchParams" in s,
2630
+ iterable: "Symbol" in s && "iterator" in Symbol,
2631
+ blob: "FileReader" in s && "Blob" in s && function() {
2632
+ try {
2633
+ return new Blob(), !0;
2634
+ } catch {
2635
+ return !1;
2636
+ }
2637
+ }(),
2638
+ formData: "FormData" in s,
2639
+ arrayBuffer: "ArrayBuffer" in s
2640
+ };
2641
+ function p(o) {
2642
+ return o && DataView.prototype.isPrototypeOf(o);
2643
+ }
2644
+ if (u.arrayBuffer)
2645
+ var d = [
2646
+ "[object Int8Array]",
2647
+ "[object Uint8Array]",
2648
+ "[object Uint8ClampedArray]",
2649
+ "[object Int16Array]",
2650
+ "[object Uint16Array]",
2651
+ "[object Int32Array]",
2652
+ "[object Uint32Array]",
2653
+ "[object Float32Array]",
2654
+ "[object Float64Array]"
2655
+ ], y = ArrayBuffer.isView || function(o) {
2656
+ return o && d.indexOf(Object.prototype.toString.call(o)) > -1;
2657
+ };
2658
+ function m(o) {
2659
+ if (typeof o != "string" && (o = String(o)), /[^a-z0-9\-#$%&'*+.^_`|~]/i.test(o))
2660
+ throw new TypeError("Invalid character in header field name");
2661
+ return o.toLowerCase();
2662
+ }
2663
+ function T(o) {
2664
+ return typeof o != "string" && (o = String(o)), o;
2665
+ }
2666
+ function A(o) {
2667
+ var l = {
2668
+ next: function() {
2669
+ var N = o.shift();
2670
+ return { done: N === void 0, value: N };
2671
+ }
2672
+ };
2673
+ return u.iterable && (l[Symbol.iterator] = function() {
2674
+ return l;
2675
+ }), l;
2676
+ }
2677
+ function E(o) {
2678
+ this.map = {}, o instanceof E ? o.forEach(function(l, N) {
2679
+ this.append(N, l);
2680
+ }, this) : Array.isArray(o) ? o.forEach(function(l) {
2681
+ this.append(l[0], l[1]);
2682
+ }, this) : o && Object.getOwnPropertyNames(o).forEach(function(l) {
2683
+ this.append(l, o[l]);
2684
+ }, this);
2685
+ }
2686
+ E.prototype.append = function(o, l) {
2687
+ o = m(o), l = T(l);
2688
+ var N = this.map[o];
2689
+ this.map[o] = N ? N + ", " + l : l;
2690
+ }, E.prototype.delete = function(o) {
2691
+ delete this.map[m(o)];
2692
+ }, E.prototype.get = function(o) {
2693
+ return o = m(o), this.has(o) ? this.map[o] : null;
2694
+ }, E.prototype.has = function(o) {
2695
+ return this.map.hasOwnProperty(m(o));
2696
+ }, E.prototype.set = function(o, l) {
2697
+ this.map[m(o)] = T(l);
2698
+ }, E.prototype.forEach = function(o, l) {
2699
+ for (var N in this.map)
2700
+ this.map.hasOwnProperty(N) && o.call(l, this.map[N], N, this);
2701
+ }, E.prototype.keys = function() {
2702
+ var o = [];
2703
+ return this.forEach(function(l, N) {
2704
+ o.push(N);
2705
+ }), A(o);
2706
+ }, E.prototype.values = function() {
2707
+ var o = [];
2708
+ return this.forEach(function(l) {
2709
+ o.push(l);
2710
+ }), A(o);
2711
+ }, E.prototype.entries = function() {
2712
+ var o = [];
2713
+ return this.forEach(function(l, N) {
2714
+ o.push([N, l]);
2715
+ }), A(o);
2716
+ }, u.iterable && (E.prototype[Symbol.iterator] = E.prototype.entries);
2717
+ function I(o) {
2718
+ if (o.bodyUsed)
2719
+ return Promise.reject(new TypeError("Already read"));
2720
+ o.bodyUsed = !0;
2721
+ }
2722
+ function D(o) {
2723
+ return new Promise(function(l, N) {
2724
+ o.onload = function() {
2725
+ l(o.result);
2726
+ }, o.onerror = function() {
2727
+ N(o.error);
2728
+ };
2729
+ });
2730
+ }
2731
+ function S(o) {
2732
+ var l = new FileReader(), N = D(l);
2733
+ return l.readAsArrayBuffer(o), N;
2734
+ }
2735
+ function G(o) {
2736
+ var l = new FileReader(), N = D(l);
2737
+ return l.readAsText(o), N;
2738
+ }
2739
+ function k(o) {
2740
+ for (var l = new Uint8Array(o), N = new Array(l.length), b = 0; b < l.length; b++)
2741
+ N[b] = String.fromCharCode(l[b]);
2742
+ return N.join("");
2743
+ }
2744
+ function C(o) {
2745
+ if (o.slice)
2746
+ return o.slice(0);
2747
+ var l = new Uint8Array(o.byteLength);
2748
+ return l.set(new Uint8Array(o)), l.buffer;
2749
+ }
2750
+ function P() {
2751
+ return this.bodyUsed = !1, this._initBody = function(o) {
2752
+ this._bodyInit = o, o ? typeof o == "string" ? this._bodyText = o : u.blob && Blob.prototype.isPrototypeOf(o) ? this._bodyBlob = o : u.formData && FormData.prototype.isPrototypeOf(o) ? this._bodyFormData = o : u.searchParams && URLSearchParams.prototype.isPrototypeOf(o) ? this._bodyText = o.toString() : u.arrayBuffer && u.blob && p(o) ? (this._bodyArrayBuffer = C(o.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : u.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(o) || y(o)) ? this._bodyArrayBuffer = C(o) : this._bodyText = o = Object.prototype.toString.call(o) : this._bodyText = "", this.headers.get("content-type") || (typeof o == "string" ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : u.searchParams && URLSearchParams.prototype.isPrototypeOf(o) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"));
2753
+ }, u.blob && (this.blob = function() {
2754
+ var o = I(this);
2755
+ if (o)
2756
+ return o;
2757
+ if (this._bodyBlob)
2758
+ return Promise.resolve(this._bodyBlob);
2759
+ if (this._bodyArrayBuffer)
2760
+ return Promise.resolve(new Blob([this._bodyArrayBuffer]));
2761
+ if (this._bodyFormData)
2762
+ throw new Error("could not read FormData body as blob");
2763
+ return Promise.resolve(new Blob([this._bodyText]));
2764
+ }, this.arrayBuffer = function() {
2765
+ return this._bodyArrayBuffer ? I(this) || Promise.resolve(this._bodyArrayBuffer) : this.blob().then(S);
2766
+ }), this.text = function() {
2767
+ var o = I(this);
2768
+ if (o)
2769
+ return o;
2770
+ if (this._bodyBlob)
2771
+ return G(this._bodyBlob);
2772
+ if (this._bodyArrayBuffer)
2773
+ return Promise.resolve(k(this._bodyArrayBuffer));
2774
+ if (this._bodyFormData)
2775
+ throw new Error("could not read FormData body as text");
2776
+ return Promise.resolve(this._bodyText);
2777
+ }, u.formData && (this.formData = function() {
2778
+ return this.text().then(we);
2779
+ }), this.json = function() {
2780
+ return this.text().then(JSON.parse);
2781
+ }, this;
2782
+ }
2783
+ var H = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
2784
+ function Y(o) {
2785
+ var l = o.toUpperCase();
2786
+ return H.indexOf(l) > -1 ? l : o;
2787
+ }
2788
+ function L(o, l) {
2789
+ l = l || {};
2790
+ var N = l.body;
2791
+ if (o instanceof L) {
2792
+ if (o.bodyUsed)
2793
+ throw new TypeError("Already read");
2794
+ this.url = o.url, this.credentials = o.credentials, l.headers || (this.headers = new E(o.headers)), this.method = o.method, this.mode = o.mode, this.signal = o.signal, !N && o._bodyInit != null && (N = o._bodyInit, o.bodyUsed = !0);
2795
+ } else
2796
+ this.url = String(o);
2797
+ if (this.credentials = l.credentials || this.credentials || "same-origin", (l.headers || !this.headers) && (this.headers = new E(l.headers)), this.method = Y(l.method || this.method || "GET"), this.mode = l.mode || this.mode || null, this.signal = l.signal || this.signal, this.referrer = null, (this.method === "GET" || this.method === "HEAD") && N)
2798
+ throw new TypeError("Body not allowed for GET or HEAD requests");
2799
+ this._initBody(N);
2800
+ }
2801
+ L.prototype.clone = function() {
2802
+ return new L(this, { body: this._bodyInit });
2803
+ };
2804
+ function we(o) {
2805
+ var l = new FormData();
2806
+ return o.trim().split("&").forEach(function(N) {
2807
+ if (N) {
2808
+ var b = N.split("="), _ = b.shift().replace(/\+/g, " "), x = b.join("=").replace(/\+/g, " ");
2809
+ l.append(decodeURIComponent(_), decodeURIComponent(x));
2810
+ }
2811
+ }), l;
2812
+ }
2813
+ function ke(o) {
2814
+ var l = new E(), N = o.replace(/\r?\n[\t ]+/g, " ");
2815
+ return N.split(/\r?\n/).forEach(function(b) {
2816
+ var _ = b.split(":"), x = _.shift().trim();
2817
+ if (x) {
2818
+ var z = _.join(":").trim();
2819
+ l.append(x, z);
2820
+ }
2821
+ }), l;
2822
+ }
2823
+ P.call(L.prototype);
2824
+ function R(o, l) {
2825
+ l || (l = {}), this.type = "default", this.status = l.status === void 0 ? 200 : l.status, this.ok = this.status >= 200 && this.status < 300, this.statusText = "statusText" in l ? l.statusText : "OK", this.headers = new E(l.headers), this.url = l.url || "", this._initBody(o);
2826
+ }
2827
+ P.call(R.prototype), R.prototype.clone = function() {
2828
+ return new R(this._bodyInit, {
2829
+ status: this.status,
2830
+ statusText: this.statusText,
2831
+ headers: new E(this.headers),
2832
+ url: this.url
2833
+ });
2834
+ }, R.error = function() {
2835
+ var o = new R(null, { status: 0, statusText: "" });
2836
+ return o.type = "error", o;
2837
+ };
2838
+ var Re = [301, 302, 303, 307, 308];
2839
+ R.redirect = function(o, l) {
2840
+ if (Re.indexOf(l) === -1)
2841
+ throw new RangeError("Invalid status code");
2842
+ return new R(null, { status: l, headers: { location: o } });
2843
+ }, c.DOMException = s.DOMException;
2844
+ try {
2845
+ new c.DOMException();
2846
+ } catch {
2847
+ c.DOMException = function(l, N) {
2848
+ this.message = l, this.name = N;
2849
+ var b = Error(l);
2850
+ this.stack = b.stack;
2851
+ }, c.DOMException.prototype = Object.create(Error.prototype), c.DOMException.prototype.constructor = c.DOMException;
2852
+ }
2853
+ function te(o, l) {
2854
+ return new Promise(function(N, b) {
2855
+ var _ = new L(o, l);
2856
+ if (_.signal && _.signal.aborted)
2857
+ return b(new c.DOMException("Aborted", "AbortError"));
2858
+ var x = new XMLHttpRequest();
2859
+ function z() {
2860
+ x.abort();
2861
+ }
2862
+ x.onload = function() {
2863
+ var V = {
2864
+ status: x.status,
2865
+ statusText: x.statusText,
2866
+ headers: ke(x.getAllResponseHeaders() || "")
2867
+ };
2868
+ V.url = "responseURL" in x ? x.responseURL : V.headers.get("X-Request-URL");
2869
+ var ne = "response" in x ? x.response : x.responseText;
2870
+ N(new R(ne, V));
2871
+ }, x.onerror = function() {
2872
+ b(new TypeError("Network request failed"));
2873
+ }, x.ontimeout = function() {
2874
+ b(new TypeError("Network request failed"));
2875
+ }, x.onabort = function() {
2876
+ b(new c.DOMException("Aborted", "AbortError"));
2877
+ }, x.open(_.method, _.url, !0), _.credentials === "include" ? x.withCredentials = !0 : _.credentials === "omit" && (x.withCredentials = !1), "responseType" in x && u.blob && (x.responseType = "blob"), _.headers.forEach(function(V, ne) {
2878
+ x.setRequestHeader(ne, V);
2879
+ }), _.signal && (_.signal.addEventListener("abort", z), x.onreadystatechange = function() {
2880
+ x.readyState === 4 && _.signal.removeEventListener("abort", z);
2881
+ }), x.send(typeof _._bodyInit > "u" ? null : _._bodyInit);
2882
+ });
2883
+ }
2884
+ return te.polyfill = !0, s.fetch || (s.fetch = te, s.Headers = E, s.Request = L, s.Response = R), c.Headers = E, c.Request = L, c.Response = R, c.fetch = te, Object.defineProperty(c, "__esModule", { value: !0 }), c;
2885
+ })({});
2886
+ })(r), r.fetch.ponyfill = !0, delete r.fetch.polyfill;
2887
+ var i = r;
2888
+ t = i.fetch, t.default = i.fetch, t.fetch = i.fetch, t.Headers = i.Headers, t.Request = i.Request, t.Response = i.Response, e.exports = t;
2889
+ })(le, le.exports);
2890
+ var Z = le.exports;
2891
+ const W = /* @__PURE__ */ Ct(Z), wt = /* @__PURE__ */ Le({
2892
+ __proto__: null,
2893
+ default: W
2894
+ }, [Z]), B = (e) => {
2895
+ let t = {};
2896
+ return e && (typeof Headers < "u" && e instanceof Headers || wt && Z.Headers && e instanceof Z.Headers ? t = Pe(e) : Array.isArray(e) ? e.forEach(([n, r]) => {
2897
+ n && r !== void 0 && (t[n] = r);
2898
+ }) : t = e), t;
2899
+ }, ve = (e) => e.replace(/([\s,]|#[^\n\r]+)+/g, " ").trim(), kt = (e) => {
2900
+ if (!Array.isArray(e.query)) {
2901
+ const r = e, i = [`query=${encodeURIComponent(ve(r.query))}`];
2902
+ return e.variables && i.push(`variables=${encodeURIComponent(r.jsonSerializer.stringify(r.variables))}`), r.operationName && i.push(`operationName=${encodeURIComponent(r.operationName)}`), i.join("&");
2903
+ }
2904
+ if (typeof e.variables < "u" && !Array.isArray(e.variables))
2905
+ throw new Error("Cannot create query with given variable type, array expected");
2906
+ const t = e, n = e.query.reduce((r, i, s) => (r.push({
2907
+ query: ve(i),
2908
+ variables: t.variables ? t.jsonSerializer.stringify(t.variables[s]) : void 0
2909
+ }), r), []);
2910
+ return `query=${encodeURIComponent(t.jsonSerializer.stringify(n))}`;
2911
+ }, Rt = (e) => async (t) => {
2912
+ const { url: n, query: r, variables: i, operationName: s, fetch: c, fetchOptions: u, middleware: p } = t, d = { ...t.headers };
2913
+ let y = "", m;
2914
+ e === "POST" ? (m = Pt(r, i, s, u.jsonSerializer), typeof m == "string" && (d["Content-Type"] = "application/json")) : y = kt({
2915
+ query: r,
2916
+ variables: i,
2917
+ operationName: s,
2918
+ jsonSerializer: u.jsonSerializer ?? he
2919
+ });
2920
+ const T = {
2921
+ method: e,
2922
+ headers: d,
2923
+ body: m,
2924
+ ...u
2925
+ };
2926
+ let A = n, E = T;
2927
+ if (p) {
2928
+ const I = await Promise.resolve(p({ ...T, url: n, operationName: s, variables: i })), { url: D, ...S } = I;
2929
+ A = D, E = S;
2930
+ }
2931
+ return y && (A = `${A}?${y}`), await c(A, E);
2932
+ };
2933
+ class Lt {
2934
+ constructor(t, n = {}) {
2935
+ this.url = t, this.requestConfig = n, this.rawRequest = async (...r) => {
2936
+ const [i, s, c] = r, u = Me(i, s, c), { headers: p, fetch: d = W, method: y = "POST", requestMiddleware: m, responseMiddleware: T, ...A } = this.requestConfig, { url: E } = this;
2937
+ u.signal !== void 0 && (A.signal = u.signal);
2938
+ const { operationName: I } = re(u.query);
2939
+ return se({
2940
+ url: E,
2941
+ query: u.query,
2942
+ variables: u.variables,
2943
+ headers: {
2944
+ ...B(oe(p)),
2945
+ ...B(u.requestHeaders)
2946
+ },
2947
+ operationName: I,
2948
+ fetch: d,
2949
+ method: y,
2950
+ fetchOptions: A,
2951
+ middleware: m
2952
+ }).then((D) => (T && T(D), D)).catch((D) => {
2953
+ throw T && T(D), D;
2954
+ });
2955
+ };
2956
+ }
2957
+ async request(t, ...n) {
2958
+ const [r, i] = n, s = Be(t, r, i), { headers: c, fetch: u = W, method: p = "POST", requestMiddleware: d, responseMiddleware: y, ...m } = this.requestConfig, { url: T } = this;
2959
+ s.signal !== void 0 && (m.signal = s.signal);
2960
+ const { query: A, operationName: E } = re(s.document);
2961
+ return se({
2962
+ url: T,
2963
+ query: A,
2964
+ variables: s.variables,
2965
+ headers: {
2966
+ ...B(oe(c)),
2967
+ ...B(s.requestHeaders)
2968
+ },
2969
+ operationName: E,
2970
+ fetch: u,
2971
+ method: p,
2972
+ fetchOptions: m,
2973
+ middleware: d
2974
+ }).then((I) => (y && y(I), I.data)).catch((I) => {
2975
+ throw y && y(I), I;
2976
+ });
2977
+ }
2978
+ // prettier-ignore
2979
+ batchRequests(t, n) {
2980
+ const r = Ue(t, n), { headers: i, ...s } = this.requestConfig;
2981
+ r.signal !== void 0 && (s.signal = r.signal);
2982
+ const c = r.documents.map(({ document: p }) => re(p).query), u = r.documents.map(({ variables: p }) => p);
2983
+ return se({
2984
+ url: this.url,
2985
+ query: c,
2986
+ // @ts-expect-error TODO reconcile batch variables into system.
2987
+ variables: u,
2988
+ headers: {
2989
+ ...B(oe(i)),
2990
+ ...B(r.requestHeaders)
2991
+ },
2992
+ operationName: void 0,
2993
+ fetch: this.requestConfig.fetch ?? W,
2994
+ method: this.requestConfig.method || "POST",
2995
+ fetchOptions: s,
2996
+ middleware: this.requestConfig.requestMiddleware
2997
+ }).then((p) => (this.requestConfig.responseMiddleware && this.requestConfig.responseMiddleware(p), p.data)).catch((p) => {
2998
+ throw this.requestConfig.responseMiddleware && this.requestConfig.responseMiddleware(p), p;
2999
+ });
3000
+ }
3001
+ setHeaders(t) {
3002
+ return this.requestConfig.headers = t, this;
3003
+ }
3004
+ /**
3005
+ * Attach a header to the client. All subsequent requests will have this header.
3006
+ */
3007
+ setHeader(t, n) {
3008
+ const { headers: r } = this.requestConfig;
3009
+ return r ? r[t] = n : this.requestConfig.headers = { [t]: n }, this;
3010
+ }
3011
+ /**
3012
+ * Change the client endpoint. All subsequent requests will send to this endpoint.
3013
+ */
3014
+ setEndpoint(t) {
3015
+ return this.url = t, this;
3016
+ }
3017
+ }
3018
+ const se = async (e) => {
3019
+ const { query: t, variables: n, fetchOptions: r } = e, i = Rt(Fe(e.method ?? "post")), s = Array.isArray(e.query), c = await i(e), u = await Bt(c, r.jsonSerializer ?? he), p = Array.isArray(u) ? !u.some(({ data: y }) => !y) : !!u.data, d = Array.isArray(u) || !u.errors || Array.isArray(u.errors) && !u.errors.length || r.errorPolicy === "all" || r.errorPolicy === "ignore";
3020
+ if (c.ok && d && p) {
3021
+ const { errors: y, ...m } = (Array.isArray(u), u), T = r.errorPolicy === "ignore" ? m : u;
3022
+ return {
3023
+ ...s ? { data: T } : T,
3024
+ headers: c.headers,
3025
+ status: c.status
3026
+ };
3027
+ } else {
3028
+ const y = typeof u == "string" ? {
3029
+ error: u
3030
+ } : u;
3031
+ throw new q(
3032
+ // @ts-expect-error TODO
3033
+ { ...y, status: c.status, headers: c.headers },
3034
+ { query: t, variables: n }
3035
+ );
3036
+ }
3037
+ };
3038
+ async function Ft(e, t, ...n) {
3039
+ const r = Ve(e, t, ...n);
3040
+ return new Lt(r.url).request({
3041
+ ...r
3042
+ });
3043
+ }
3044
+ const Pt = (e, t, n, r) => {
3045
+ const i = r ?? he;
3046
+ if (!Array.isArray(e))
3047
+ return i.stringify({ query: e, variables: t, operationName: n });
3048
+ if (typeof t < "u" && !Array.isArray(t))
3049
+ throw new Error("Cannot create request body with given variable type, array expected");
3050
+ const s = e.reduce((c, u, p) => (c.push({ query: u, variables: t ? t[p] : void 0 }), c), []);
3051
+ return i.stringify(s);
3052
+ }, Bt = async (e, t) => {
3053
+ let n;
3054
+ return e.headers.forEach((r, i) => {
3055
+ i.toLowerCase() === "content-type" && (n = r);
3056
+ }), n && (n.toLowerCase().startsWith("application/json") || n.toLowerCase().startsWith("application/graphql+json") || n.toLowerCase().startsWith("application/graphql-response+json")) ? t.parse(await e.text()) : e.text();
3057
+ }, oe = (e) => typeof e == "function" ? e() : e, Mt = (e, ...t) => e.reduce((n, r, i) => `${n}${r}${i in t ? String(t[i]) : ""}`, ""), Ut = {
3058
+ getMeta: Mt`
3059
+ query getDoctype($doctype: String!) {
3060
+ getMeta(doctype: $doctype) {
3061
+ id
3062
+ name
3063
+ workflow
3064
+ schema
3065
+ actions
3066
+ }
3067
+ }
3068
+ `
3069
+ }, Vt = {
3070
+ getMeta: async (e, t) => await Ft(t || "/graphql", Ut.getMeta, { doctype: e })
3071
+ };
3072
+ export {
3073
+ Vt as methods
3074
+ };
3075
+ //# sourceMappingURL=graphql-client.js.map