@debugged-development/ticketapp-sdk 0.0.3

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