@ticketapp-dev/shop-sdk 1.0.21 → 1.0.22

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 CHANGED
@@ -1,33 +1,48 @@
1
1
  import { GraphQLClient as ae } from "graphql-request";
2
- import { createSlice as We, configureStore as Ze } from "@reduxjs/toolkit";
2
+ import { createSlice as He, configureStore as Qe } from "@reduxjs/toolkit";
3
3
  import { DateTime as R } from "luxon";
4
- var Q = function() {
5
- return Q = Object.assign || function(t) {
4
+ var _ = /* @__PURE__ */ ((e) => (e.PACKAGE = "PACKAGE", e.PRODUCT = "PRODUCT", e.ADD_ONS = "ADD_ONS", e.DELIVERY = "DELIVERY", e.PICKUP = "PICKUP", e))(_ || {}), Q = /* @__PURE__ */ ((e) => (e.AdditionalEvent = "ADDITIONAL_EVENT", e.Addon = "ADDON", e.Regular = "REGULAR", e))(Q || {}), ke = /* @__PURE__ */ ((e) => (e.Active = "ACTIVE", e.Concept = "CONCEPT", e.Paused = "PAUSED", e.SoldOut = "SOLD_OUT", e))(ke || {}), De = /* @__PURE__ */ ((e) => (e.Active = "ACTIVE", e.Inactive = "INACTIVE", e))(De || {}), xe = /* @__PURE__ */ ((e) => (e.Active = "ACTIVE", e.Inactive = "INACTIVE", e.Paused = "PAUSED", e.SoldOut = "SOLD_OUT", e))(xe || {}), Ne = /* @__PURE__ */ ((e) => (e.Asc = "ASC", e.Desc = "DESC", e))(Ne || {}), be = /* @__PURE__ */ ((e) => (e.AllReserved = "ALL_RESERVED", e.Available = "AVAILABLE", e.SoldOut = "SOLD_OUT", e))(be || {}), Pe = /* @__PURE__ */ ((e) => (e.Addon = "ADDON", e.Delivery = "DELIVERY", e.Door = "DOOR", e.Friend = "FRIEND", e.Guest = "GUEST", e.Pickup = "PICKUP", e.Promoter = "PROMOTER", e.Ticket = "TICKET", e))(Pe || {}), Se = /* @__PURE__ */ ((e) => (e.FIXED = "FIXED", e.PERCENTAGE = "PERCENTAGE", e))(Se || {}), Ce = /* @__PURE__ */ ((e) => (e.AddOn = "ADD_ON", e.DeliveryOption = "DELIVERY_OPTION", e.EntranceTicket = "ENTRANCE_TICKET", e))(Ce || {}), _e = /* @__PURE__ */ ((e) => (e.Fixed = "FIXED", e.Percentage = "PERCENTAGE", e))(_e || {});
5
+ const Je = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6
+ __proto__: null,
7
+ BasketOrderType: _,
8
+ DiscountType: _e,
9
+ EventStatus: xe,
10
+ OrderItemType: Ce,
11
+ PackageItemType: Q,
12
+ PackageStatus: ke,
13
+ PackageTabType: De,
14
+ PaymentMethodFeeType: Se,
15
+ ProductStatus: be,
16
+ ProductType: Pe,
17
+ SortOrder: Ne
18
+ }, Symbol.toStringTag, { value: "Module" }));
19
+ var J = function() {
20
+ return J = Object.assign || function(t) {
6
21
  for (var n, i = 1, r = arguments.length; i < r; i++) {
7
22
  n = arguments[i];
8
23
  for (var s in n) Object.prototype.hasOwnProperty.call(n, s) && (t[s] = n[s]);
9
24
  }
10
25
  return t;
11
- }, Q.apply(this, arguments);
26
+ }, J.apply(this, arguments);
12
27
  };
13
28
  function G(e, t) {
14
29
  if (!!!e)
15
30
  throw new Error(t);
16
31
  }
17
- function et(e) {
32
+ function Xe(e) {
18
33
  return typeof e == "object" && e !== null;
19
34
  }
20
- function tt(e, t) {
35
+ function Ke(e, t) {
21
36
  if (!!!e)
22
37
  throw new Error(
23
38
  "Unexpected invariant triggered."
24
39
  );
25
40
  }
26
- const nt = /\r\n|[\n\r]/g;
41
+ const We = /\r\n|[\n\r]/g;
27
42
  function re(e, t) {
28
43
  let n = 0, i = 1;
29
- for (const r of e.body.matchAll(nt)) {
30
- if (typeof r.index == "number" || tt(!1), r.index >= t)
44
+ for (const r of e.body.matchAll(We)) {
45
+ if (typeof r.index == "number" || Ke(!1), r.index >= t)
31
46
  break;
32
47
  n = r.index + r[0].length, i += 1;
33
48
  }
@@ -36,13 +51,13 @@ function re(e, t) {
36
51
  column: t + 1 - n
37
52
  };
38
53
  }
39
- function rt(e) {
40
- return ke(
54
+ function Ze(e) {
55
+ return Le(
41
56
  e.source,
42
57
  re(e.source, e.start)
43
58
  );
44
59
  }
45
- function ke(e, t) {
60
+ function Le(e, t) {
46
61
  const n = e.locationOffset.column - 1, i = "".padStart(n) + e.body, r = t.line - 1, s = e.locationOffset.line - 1, o = t.line + s, u = t.line === 1 ? n : 0, h = t.column + u, p = `${e.name}:${o}:${h}
47
62
  `, c = i.split(/\r\n|[\n\r]/g), m = c[r];
48
63
  if (m.length > 120) {
@@ -69,7 +84,7 @@ function pe(e) {
69
84
  return t.map(([i, r]) => i.padStart(n) + (r ? " " + r : "")).join(`
70
85
  `);
71
86
  }
72
- function it(e) {
87
+ function et(e) {
73
88
  const t = e[0];
74
89
  return t == null || "kind" in t || "length" in t ? {
75
90
  nodes: t,
@@ -121,7 +136,7 @@ class ce extends Error {
121
136
  */
122
137
  constructor(t, ...n) {
123
138
  var i, r, s;
124
- const { nodes: o, source: u, positions: h, path: p, originalError: c, extensions: m } = it(n);
139
+ const { nodes: o, source: u, positions: h, path: p, originalError: c, extensions: m } = et(n);
125
140
  super(t), this.name = "GraphQLError", this.path = p ?? void 0, this.originalError = c ?? void 0, this.nodes = he(
126
141
  Array.isArray(o) ? o : o ? [o] : void 0
127
142
  );
@@ -129,7 +144,7 @@ class ce extends Error {
129
144
  (i = this.nodes) === null || i === void 0 ? void 0 : i.map((I) => I.loc).filter((I) => I != null)
130
145
  );
131
146
  this.source = u ?? (g == null || (r = g[0]) === null || r === void 0 ? void 0 : r.source), this.positions = h ?? g?.map((I) => I.start), this.locations = h && u ? h.map((I) => re(u, I)) : g?.map((I) => re(I.source, I.start));
132
- const y = et(
147
+ const y = Xe(
133
148
  c?.extensions
134
149
  ) ? c?.extensions : void 0;
135
150
  this.extensions = (s = m ?? y) !== null && s !== void 0 ? s : /* @__PURE__ */ Object.create(null), Object.defineProperties(this, {
@@ -171,12 +186,12 @@ class ce extends Error {
171
186
  for (const n of this.nodes)
172
187
  n.loc && (t += `
173
188
 
174
- ` + rt(n.loc));
189
+ ` + Ze(n.loc));
175
190
  else if (this.source && this.locations)
176
191
  for (const n of this.locations)
177
192
  t += `
178
193
 
179
- ` + ke(this.source, n);
194
+ ` + Le(this.source, n);
180
195
  return t;
181
196
  }
182
197
  toJSON() {
@@ -195,7 +210,7 @@ function A(e, t, n) {
195
210
  positions: [t]
196
211
  });
197
212
  }
198
- class st {
213
+ class tt {
199
214
  /**
200
215
  * The character offset at which this Node begins.
201
216
  */
@@ -224,7 +239,7 @@ class st {
224
239
  };
225
240
  }
226
241
  }
227
- class De {
242
+ class Re {
228
243
  /**
229
244
  * The kind of Token.
230
245
  */
@@ -266,7 +281,7 @@ class De {
266
281
  };
267
282
  }
268
283
  }
269
- const xe = {
284
+ const Fe = {
270
285
  Name: [],
271
286
  Document: ["definitions"],
272
287
  OperationDefinition: [
@@ -353,10 +368,10 @@ const xe = {
353
368
  ArgumentCoordinate: ["name", "fieldName", "argumentName"],
354
369
  DirectiveCoordinate: ["name"],
355
370
  DirectiveArgumentCoordinate: ["name", "argumentName"]
356
- }, ot = new Set(Object.keys(xe));
371
+ }, nt = new Set(Object.keys(Fe));
357
372
  function fe(e) {
358
373
  const t = e?.kind;
359
- return typeof t == "string" && ot.has(t);
374
+ return typeof t == "string" && nt.has(t);
360
375
  }
361
376
  var w;
362
377
  (function(e) {
@@ -376,22 +391,22 @@ function se(e) {
376
391
  function M(e) {
377
392
  return e >= 48 && e <= 57;
378
393
  }
379
- function Ne(e) {
394
+ function we(e) {
380
395
  return e >= 97 && e <= 122 || // A-Z
381
396
  e >= 65 && e <= 90;
382
397
  }
383
- function be(e) {
384
- return Ne(e) || e === 95;
398
+ function $e(e) {
399
+ return we(e) || e === 95;
385
400
  }
386
- function at(e) {
387
- return Ne(e) || M(e) || e === 95;
401
+ function rt(e) {
402
+ return we(e) || M(e) || e === 95;
388
403
  }
389
- function ct(e) {
404
+ function it(e) {
390
405
  var t;
391
406
  let n = Number.MAX_SAFE_INTEGER, i = null, r = -1;
392
407
  for (let o = 0; o < e.length; ++o) {
393
408
  var s;
394
- const u = e[o], h = dt(u);
409
+ const u = e[o], h = st(u);
395
410
  h !== u.length && (i = (s = i) !== null && s !== void 0 ? s : o, r = o, o !== 0 && h < n && (n = h));
396
411
  }
397
412
  return e.map((o, u) => u === 0 ? o : o.slice(n)).slice(
@@ -399,13 +414,13 @@ function ct(e) {
399
414
  r + 1
400
415
  );
401
416
  }
402
- function dt(e) {
417
+ function st(e) {
403
418
  let t = 0;
404
419
  for (; t < e.length && se(e.charCodeAt(t)); )
405
420
  ++t;
406
421
  return t;
407
422
  }
408
- function ut(e, t) {
423
+ function ot(e, t) {
409
424
  const n = e.replace(/"""/g, '\\"""'), i = n.split(/\r\n|[\n\r]/g), r = i.length === 1, s = i.length > 1 && i.slice(1).every((y) => y.length === 0 || se(y.charCodeAt(0))), o = n.endsWith('\\"""'), u = e.endsWith('"') && !o, h = e.endsWith("\\"), p = u || h, c = (
410
425
  // add leading and trailing new lines only if it improves readability
411
426
  !r || e.length > 70 || p || s || o
@@ -420,7 +435,7 @@ var a;
420
435
  (function(e) {
421
436
  e.SOF = "<SOF>", e.EOF = "<EOF>", e.BANG = "!", e.DOLLAR = "$", e.AMP = "&", e.PAREN_L = "(", e.PAREN_R = ")", e.DOT = ".", e.SPREAD = "...", e.COLON = ":", e.EQUALS = "=", e.AT = "@", e.BRACKET_L = "[", e.BRACKET_R = "]", e.BRACE_L = "{", e.PIPE = "|", e.BRACE_R = "}", e.NAME = "Name", e.INT = "Int", e.FLOAT = "Float", e.STRING = "String", e.BLOCK_STRING = "BlockString", e.COMMENT = "Comment";
422
437
  })(a || (a = {}));
423
- class lt {
438
+ class at {
424
439
  /**
425
440
  * The previously focused non-ignored token.
426
441
  */
@@ -434,7 +449,7 @@ class lt {
434
449
  * The character offset at which the current line begins.
435
450
  */
436
451
  constructor(t) {
437
- const n = new De(a.SOF, 0, 0, 0, 0);
452
+ const n = new Re(a.SOF, 0, 0, 0, 0);
438
453
  this.source = t, this.lastToken = n, this.token = n, this.line = 1, this.lineStart = 0;
439
454
  }
440
455
  get [Symbol.toStringTag]() {
@@ -457,26 +472,26 @@ class lt {
457
472
  if (t.next)
458
473
  t = t.next;
459
474
  else {
460
- const n = ht(this, t.end);
475
+ const n = dt(this, t.end);
461
476
  t.next = n, n.prev = t, t = n;
462
477
  }
463
478
  while (t.kind === a.COMMENT);
464
479
  return t;
465
480
  }
466
481
  }
467
- function pt(e) {
482
+ function ct(e) {
468
483
  return e === a.BANG || e === a.DOLLAR || e === a.AMP || e === a.PAREN_L || e === a.PAREN_R || e === a.DOT || e === a.SPREAD || e === a.COLON || e === a.EQUALS || e === a.AT || e === a.BRACKET_L || e === a.BRACKET_R || e === a.BRACE_L || e === a.PIPE || e === a.BRACE_R;
469
484
  }
470
485
  function $(e) {
471
486
  return e >= 0 && e <= 55295 || e >= 57344 && e <= 1114111;
472
487
  }
473
488
  function K(e, t) {
474
- return Pe(e.charCodeAt(t)) && Se(e.charCodeAt(t + 1));
489
+ return Be(e.charCodeAt(t)) && Ue(e.charCodeAt(t + 1));
475
490
  }
476
- function Pe(e) {
491
+ function Be(e) {
477
492
  return e >= 55296 && e <= 56319;
478
493
  }
479
- function Se(e) {
494
+ function Ue(e) {
480
495
  return e >= 56320 && e <= 57343;
481
496
  }
482
497
  function F(e, t) {
@@ -491,9 +506,9 @@ function F(e, t) {
491
506
  }
492
507
  function v(e, t, n, i, r) {
493
508
  const s = e.line, o = 1 + n - e.lineStart;
494
- return new De(t, n, i, s, o, r);
509
+ return new Re(t, n, i, s, o, r);
495
510
  }
496
- function ht(e, t) {
511
+ function dt(e, t) {
497
512
  const n = e.source.body, i = n.length;
498
513
  let r = t;
499
514
  for (; r < i; ) {
@@ -534,7 +549,7 @@ function ht(e, t) {
534
549
  continue;
535
550
  // Comment
536
551
  case 35:
537
- return ft(e, r);
552
+ return ut(e, r);
538
553
  // Token ::
539
554
  // - Punctuator
540
555
  // - Name
@@ -575,12 +590,12 @@ function ht(e, t) {
575
590
  return v(e, a.BRACE_R, r, r + 1);
576
591
  // StringValue
577
592
  case 34:
578
- return n.charCodeAt(r + 1) === 34 && n.charCodeAt(r + 2) === 34 ? vt(e, r) : gt(e, r);
593
+ return n.charCodeAt(r + 1) === 34 && n.charCodeAt(r + 2) === 34 ? gt(e, r) : pt(e, r);
579
594
  }
580
595
  if (M(s) || s === 45)
581
- return mt(e, r, s);
582
- if (be(s))
583
- return At(e, r);
596
+ return lt(e, r, s);
597
+ if ($e(s))
598
+ return It(e, r);
584
599
  throw A(
585
600
  e.source,
586
601
  r,
@@ -589,7 +604,7 @@ function ht(e, t) {
589
604
  }
590
605
  return v(e, a.EOF, i, i);
591
606
  }
592
- function ft(e, t) {
607
+ function ut(e, t) {
593
608
  const n = e.source.body, i = n.length;
594
609
  let r = t + 1;
595
610
  for (; r < i; ) {
@@ -611,7 +626,7 @@ function ft(e, t) {
611
626
  n.slice(t + 1, r)
612
627
  );
613
628
  }
614
- function mt(e, t, n) {
629
+ function lt(e, t, n) {
615
630
  const i = e.source.body;
616
631
  let r = t, s = n, o = !1;
617
632
  if (s === 45 && (s = i.charCodeAt(++r)), s === 48) {
@@ -626,7 +641,7 @@ function mt(e, t, n) {
626
641
  );
627
642
  } else
628
643
  r = ee(e, r, s), s = i.charCodeAt(r);
629
- if (s === 46 && (o = !0, s = i.charCodeAt(++r), r = ee(e, r, s), s = i.charCodeAt(r)), (s === 69 || s === 101) && (o = !0, s = i.charCodeAt(++r), (s === 43 || s === 45) && (s = i.charCodeAt(++r)), r = ee(e, r, s), s = i.charCodeAt(r)), s === 46 || be(s))
644
+ if (s === 46 && (o = !0, s = i.charCodeAt(++r), r = ee(e, r, s), s = i.charCodeAt(r)), (s === 69 || s === 101) && (o = !0, s = i.charCodeAt(++r), (s === 43 || s === 45) && (s = i.charCodeAt(++r)), r = ee(e, r, s), s = i.charCodeAt(r)), s === 46 || $e(s))
630
645
  throw A(
631
646
  e.source,
632
647
  r,
@@ -659,7 +674,7 @@ function ee(e, t, n) {
659
674
  ++r;
660
675
  return r;
661
676
  }
662
- function gt(e, t) {
677
+ function pt(e, t) {
663
678
  const n = e.source.body, i = n.length;
664
679
  let r = t + 1, s = r, o = "";
665
680
  for (; r < i; ) {
@@ -668,7 +683,7 @@ function gt(e, t) {
668
683
  return o += n.slice(s, r), v(e, a.STRING, t, r + 1, o);
669
684
  if (u === 92) {
670
685
  o += n.slice(s, r);
671
- const h = n.charCodeAt(r + 1) === 117 ? n.charCodeAt(r + 2) === 123 ? It(e, r) : Et(e, r) : yt(e, r);
686
+ const h = n.charCodeAt(r + 1) === 117 ? n.charCodeAt(r + 2) === 123 ? ht(e, r) : ft(e, r) : mt(e, r);
672
687
  o += h.value, r += h.size, s = r;
673
688
  continue;
674
689
  }
@@ -690,7 +705,7 @@ function gt(e, t) {
690
705
  }
691
706
  throw A(e.source, r, "Unterminated string.");
692
707
  }
693
- function It(e, t) {
708
+ function ht(e, t) {
694
709
  const n = e.source.body;
695
710
  let i = 0, r = 3;
696
711
  for (; r < 12; ) {
@@ -715,16 +730,16 @@ function It(e, t) {
715
730
  )}".`
716
731
  );
717
732
  }
718
- function Et(e, t) {
733
+ function ft(e, t) {
719
734
  const n = e.source.body, i = me(n, t + 2);
720
735
  if ($(i))
721
736
  return {
722
737
  value: String.fromCodePoint(i),
723
738
  size: 6
724
739
  };
725
- if (Pe(i) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) {
740
+ if (Be(i) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) {
726
741
  const r = me(n, t + 8);
727
- if (Se(r))
742
+ if (Ue(r))
728
743
  return {
729
744
  value: String.fromCodePoint(i, r),
730
745
  size: 12
@@ -742,7 +757,7 @@ function me(e, t) {
742
757
  function V(e) {
743
758
  return e >= 48 && e <= 57 ? e - 48 : e >= 65 && e <= 70 ? e - 55 : e >= 97 && e <= 102 ? e - 87 : -1;
744
759
  }
745
- function yt(e, t) {
760
+ function mt(e, t) {
746
761
  const n = e.source.body;
747
762
  switch (n.charCodeAt(t + 1)) {
748
763
  case 34:
@@ -796,7 +811,7 @@ function yt(e, t) {
796
811
  )}".`
797
812
  );
798
813
  }
799
- function vt(e, t) {
814
+ function gt(e, t) {
800
815
  const n = e.source.body, i = n.length;
801
816
  let r = e.lineStart, s = t + 3, o = s, u = "";
802
817
  const h = [];
@@ -810,7 +825,7 @@ function vt(e, t) {
810
825
  t,
811
826
  s + 3,
812
827
  // Return a string of the lines joined with U+000A.
813
- ct(h).join(`
828
+ it(h).join(`
814
829
  `)
815
830
  );
816
831
  return e.line += h.length - 1, e.lineStart = r, c;
@@ -839,12 +854,12 @@ function vt(e, t) {
839
854
  }
840
855
  throw A(e.source, s, "Unterminated string.");
841
856
  }
842
- function At(e, t) {
857
+ function It(e, t) {
843
858
  const n = e.source.body, i = n.length;
844
859
  let r = t + 1;
845
860
  for (; r < i; ) {
846
861
  const s = n.charCodeAt(r);
847
- if (at(s))
862
+ if (rt(s))
848
863
  ++r;
849
864
  else
850
865
  break;
@@ -857,7 +872,7 @@ function At(e, t) {
857
872
  n.slice(t, r)
858
873
  );
859
874
  }
860
- const Tt = 10, Ce = 2;
875
+ const Et = 10, Ve = 2;
861
876
  function de(e) {
862
877
  return W(e, []);
863
878
  }
@@ -868,45 +883,45 @@ function W(e, t) {
868
883
  case "function":
869
884
  return e.name ? `[function ${e.name}]` : "[function]";
870
885
  case "object":
871
- return Ot(e, t);
886
+ return yt(e, t);
872
887
  default:
873
888
  return String(e);
874
889
  }
875
890
  }
876
- function Ot(e, t) {
891
+ function yt(e, t) {
877
892
  if (e === null)
878
893
  return "null";
879
894
  if (t.includes(e))
880
895
  return "[Circular]";
881
896
  const n = [...t, e];
882
- if (kt(e)) {
897
+ if (vt(e)) {
883
898
  const i = e.toJSON();
884
899
  if (i !== e)
885
900
  return typeof i == "string" ? i : W(i, n);
886
901
  } else if (Array.isArray(e))
887
- return xt(e, n);
888
- return Dt(e, n);
902
+ return Tt(e, n);
903
+ return At(e, n);
889
904
  }
890
- function kt(e) {
905
+ function vt(e) {
891
906
  return typeof e.toJSON == "function";
892
907
  }
893
- function Dt(e, t) {
908
+ function At(e, t) {
894
909
  const n = Object.entries(e);
895
- return n.length === 0 ? "{}" : t.length > Ce ? "[" + Nt(e) + "]" : "{ " + n.map(
910
+ return n.length === 0 ? "{}" : t.length > Ve ? "[" + Ot(e) + "]" : "{ " + n.map(
896
911
  ([r, s]) => r + ": " + W(s, t)
897
912
  ).join(", ") + " }";
898
913
  }
899
- function xt(e, t) {
914
+ function Tt(e, t) {
900
915
  if (e.length === 0)
901
916
  return "[]";
902
- if (t.length > Ce)
917
+ if (t.length > Ve)
903
918
  return "[Array]";
904
- const n = Math.min(Tt, e.length), i = e.length - n, r = [];
919
+ const n = Math.min(Et, e.length), i = e.length - n, r = [];
905
920
  for (let s = 0; s < n; ++s)
906
921
  r.push(W(e[s], t));
907
922
  return i === 1 ? r.push("... 1 more item") : i > 1 && r.push(`... ${i} more items`), "[" + r.join(", ") + "]";
908
923
  }
909
- function Nt(e) {
924
+ function Ot(e) {
910
925
  const t = Object.prototype.toString.call(e).replace(/^\[object /, "").replace(/]$/, "");
911
926
  if (t === "Object" && typeof e.constructor == "function") {
912
927
  const n = e.constructor.name;
@@ -915,11 +930,11 @@ function Nt(e) {
915
930
  }
916
931
  return t;
917
932
  }
918
- const bt = globalThis.process && // eslint-disable-next-line no-undef
919
- process.env.NODE_ENV === "production", Pt = (
933
+ const kt = globalThis.process && // eslint-disable-next-line no-undef
934
+ process.env.NODE_ENV === "production", Dt = (
920
935
  /* c8 ignore next 6 */
921
936
  // FIXME: https://github.com/graphql/graphql-js/issues/2317
922
- bt ? function(t, n) {
937
+ kt ? function(t, n) {
923
938
  return t instanceof n;
924
939
  } : function(t, n) {
925
940
  if (t instanceof n)
@@ -949,7 +964,7 @@ spurious results.`);
949
964
  return !1;
950
965
  }
951
966
  );
952
- class _e {
967
+ class Me {
953
968
  constructor(t, n = "GraphQL request", i = {
954
969
  line: 1,
955
970
  column: 1
@@ -966,24 +981,24 @@ class _e {
966
981
  return "Source";
967
982
  }
968
983
  }
969
- function St(e) {
970
- return Pt(e, _e);
984
+ function xt(e) {
985
+ return Dt(e, Me);
971
986
  }
972
- function Ct(e, t) {
973
- const n = new _t(e, t), i = n.parseDocument();
987
+ function Nt(e, t) {
988
+ const n = new bt(e, t), i = n.parseDocument();
974
989
  return Object.defineProperty(i, "tokenCount", {
975
990
  enumerable: !1,
976
991
  value: n.tokenCount
977
992
  }), i;
978
993
  }
979
- class _t {
994
+ class bt {
980
995
  constructor(t, n = {}) {
981
996
  const { lexer: i, ...r } = n;
982
997
  if (i)
983
998
  this._lexer = i;
984
999
  else {
985
- const s = St(t) ? t : new _e(t);
986
- this._lexer = new lt(s);
1000
+ const s = xt(t) ? t : new Me(t);
1001
+ this._lexer = new at(s);
987
1002
  }
988
1003
  this._options = r, this._tokenCounter = 0;
989
1004
  }
@@ -2001,7 +2016,7 @@ class _t {
2001
2016
  * given parsed object.
2002
2017
  */
2003
2018
  node(t, n) {
2004
- return this._options.noLocation !== !0 && (n.loc = new st(
2019
+ return this._options.noLocation !== !0 && (n.loc = new tt(
2005
2020
  t,
2006
2021
  this._lexer.lastToken,
2007
2022
  this._lexer.source
@@ -2024,7 +2039,7 @@ class _t {
2024
2039
  throw A(
2025
2040
  this._lexer.source,
2026
2041
  n.start,
2027
- `Expected ${Le(t)}, found ${z(n)}.`
2042
+ `Expected ${qe(t)}, found ${z(n)}.`
2028
2043
  );
2029
2044
  }
2030
2045
  /**
@@ -2134,19 +2149,19 @@ class _t {
2134
2149
  }
2135
2150
  function z(e) {
2136
2151
  const t = e.value;
2137
- return Le(e.kind) + (t != null ? ` "${t}"` : "");
2152
+ return qe(e.kind) + (t != null ? ` "${t}"` : "");
2138
2153
  }
2139
- function Le(e) {
2140
- return pt(e) ? `"${e}"` : e;
2154
+ function qe(e) {
2155
+ return ct(e) ? `"${e}"` : e;
2141
2156
  }
2142
- function Lt(e) {
2143
- return `"${e.replace(Rt, Ft)}"`;
2157
+ function Pt(e) {
2158
+ return `"${e.replace(St, Ct)}"`;
2144
2159
  }
2145
- const Rt = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g;
2146
- function Ft(e) {
2147
- return wt[e.charCodeAt(0)];
2160
+ const St = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g;
2161
+ function Ct(e) {
2162
+ return _t[e.charCodeAt(0)];
2148
2163
  }
2149
- const wt = [
2164
+ const _t = [
2150
2165
  "\\u0000",
2151
2166
  "\\u0001",
2152
2167
  "\\u0002",
@@ -2312,11 +2327,11 @@ const wt = [
2312
2327
  "\\u009D",
2313
2328
  "\\u009E",
2314
2329
  "\\u009F"
2315
- ], $t = Object.freeze({});
2316
- function Bt(e, t, n = xe) {
2330
+ ], Lt = Object.freeze({});
2331
+ function Rt(e, t, n = Fe) {
2317
2332
  const i = /* @__PURE__ */ new Map();
2318
2333
  for (const k of Object.values(l))
2319
- i.set(k, Ut(t, k));
2334
+ i.set(k, Ft(t, k));
2320
2335
  let r, s = Array.isArray(e), o = [e], u = -1, h = [], p = e, c, m;
2321
2336
  const g = [], y = [];
2322
2337
  do {
@@ -2347,7 +2362,7 @@ function Bt(e, t, n = xe) {
2347
2362
  var I, O;
2348
2363
  fe(p) || G(!1, `Invalid AST Node: ${de(p)}.`);
2349
2364
  const N = k ? (I = i.get(p.kind)) === null || I === void 0 ? void 0 : I.leave : (O = i.get(p.kind)) === null || O === void 0 ? void 0 : O.enter;
2350
- if (T = N?.call(t, p, c, m, g, y), T === $t)
2365
+ if (T = N?.call(t, p, c, m, g, y), T === Lt)
2351
2366
  break;
2352
2367
  if (T === !1) {
2353
2368
  if (!k) {
@@ -2377,7 +2392,7 @@ function Bt(e, t, n = xe) {
2377
2392
  } while (r !== void 0);
2378
2393
  return h.length !== 0 ? h[h.length - 1][1] : e;
2379
2394
  }
2380
- function Ut(e, t) {
2395
+ function Ft(e, t) {
2381
2396
  const n = e[t];
2382
2397
  return typeof n == "object" ? n : typeof n == "function" ? {
2383
2398
  enter: n,
@@ -2387,10 +2402,10 @@ function Ut(e, t) {
2387
2402
  leave: e.leave
2388
2403
  };
2389
2404
  }
2390
- function Vt(e) {
2391
- return Bt(e, qt);
2405
+ function wt(e) {
2406
+ return Rt(e, Bt);
2392
2407
  }
2393
- const Mt = 80, qt = {
2408
+ const $t = 80, Bt = {
2394
2409
  Name: {
2395
2410
  leave: (e) => e.value
2396
2411
  },
@@ -2431,7 +2446,7 @@ const Mt = 80, qt = {
2431
2446
  leave({ alias: e, name: t, arguments: n, directives: i, selectionSet: r }) {
2432
2447
  const s = f("", e, ": ") + t;
2433
2448
  let o = s + f("(", d(n, ", "), ")");
2434
- return o.length > Mt && (o = s + f(`(
2449
+ return o.length > $t && (o = s + f(`(
2435
2450
  `, Y(d(n, `
2436
2451
  `)), `
2437
2452
  )`)), d([o, d(i, " "), r], " ");
@@ -2476,7 +2491,7 @@ const Mt = 80, qt = {
2476
2491
  leave: ({ value: e }) => e
2477
2492
  },
2478
2493
  StringValue: {
2479
- leave: ({ value: e, block: t }) => t ? ut(e) : Lt(e)
2494
+ leave: ({ value: e, block: t }) => t ? ot(e) : Pt(e)
2480
2495
  },
2481
2496
  BooleanValue: {
2482
2497
  leave: ({ value: e }) => e ? "true" : "false"
@@ -2677,26 +2692,26 @@ function te(e) {
2677
2692
  return (t = e?.some((n) => n.includes(`
2678
2693
  `))) !== null && t !== void 0 ? t : !1;
2679
2694
  }
2680
- var H = /* @__PURE__ */ new Map(), oe = /* @__PURE__ */ new Map(), Re = !0, J = !1;
2681
- function Fe(e) {
2695
+ var H = /* @__PURE__ */ new Map(), oe = /* @__PURE__ */ new Map(), ze = !0, X = !1;
2696
+ function je(e) {
2682
2697
  return e.replace(/[\s,]+/g, " ").trim();
2683
2698
  }
2684
- function zt(e) {
2685
- return Fe(e.source.body.substring(e.start, e.end));
2699
+ function Ut(e) {
2700
+ return je(e.source.body.substring(e.start, e.end));
2686
2701
  }
2687
- function jt(e) {
2702
+ function Vt(e) {
2688
2703
  var t = /* @__PURE__ */ new Set(), n = [];
2689
2704
  return e.definitions.forEach(function(i) {
2690
2705
  if (i.kind === "FragmentDefinition") {
2691
- var r = i.name.value, s = zt(i.loc), o = oe.get(r);
2692
- o && !o.has(s) ? Re && console.warn("Warning: fragment with name " + r + ` already exists.
2706
+ var r = i.name.value, s = Ut(i.loc), o = oe.get(r);
2707
+ o && !o.has(s) ? ze && console.warn("Warning: fragment with name " + r + ` already exists.
2693
2708
  graphql-tag enforces all fragment names across your application to be unique; read more about
2694
2709
  this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`) : o || oe.set(r, o = /* @__PURE__ */ new Set()), o.add(s), t.has(s) || (t.add(s), n.push(i));
2695
2710
  } else
2696
2711
  n.push(i);
2697
- }), Q(Q({}, e), { definitions: n });
2712
+ }), J(J({}, e), { definitions: n });
2698
2713
  }
2699
- function Gt(e) {
2714
+ function Mt(e) {
2700
2715
  var t = new Set(e.definitions);
2701
2716
  t.forEach(function(i) {
2702
2717
  i.loc && delete i.loc, Object.keys(i).forEach(function(r) {
@@ -2707,16 +2722,16 @@ function Gt(e) {
2707
2722
  var n = e.loc;
2708
2723
  return n && (delete n.startToken, delete n.endToken), e;
2709
2724
  }
2710
- function Yt(e) {
2711
- var t = Fe(e);
2725
+ function qt(e) {
2726
+ var t = je(e);
2712
2727
  if (!H.has(t)) {
2713
- var n = Ct(e, {
2714
- experimentalFragmentVariables: J,
2715
- allowLegacyFragmentVariables: J
2728
+ var n = Nt(e, {
2729
+ experimentalFragmentVariables: X,
2730
+ allowLegacyFragmentVariables: X
2716
2731
  });
2717
2732
  if (!n || n.kind !== "Document")
2718
2733
  throw new Error("Not a valid GraphQL document.");
2719
- H.set(t, Gt(jt(n)));
2734
+ H.set(t, Mt(Vt(n)));
2720
2735
  }
2721
2736
  return H.get(t);
2722
2737
  }
@@ -2727,187 +2742,920 @@ function E(e) {
2727
2742
  var i = e[0];
2728
2743
  return t.forEach(function(r, s) {
2729
2744
  r && r.kind === "Document" ? i += r.loc.source.body : i += r, i += e[s + 1];
2730
- }), Yt(i);
2745
+ }), qt(i);
2731
2746
  }
2732
- function Ht() {
2747
+ function zt() {
2733
2748
  H.clear(), oe.clear();
2734
2749
  }
2735
- function Qt() {
2736
- Re = !1;
2750
+ function jt() {
2751
+ ze = !1;
2737
2752
  }
2738
- function Jt() {
2739
- J = !0;
2753
+ function Gt() {
2754
+ X = !0;
2740
2755
  }
2741
- function Xt() {
2742
- J = !1;
2756
+ function Yt() {
2757
+ X = !1;
2743
2758
  }
2744
2759
  var U = {
2745
2760
  gql: E,
2746
- resetCaches: Ht,
2747
- disableFragmentWarnings: Qt,
2748
- enableExperimentalFragmentVariables: Jt,
2749
- disableExperimentalFragmentVariables: Xt
2761
+ resetCaches: zt,
2762
+ disableFragmentWarnings: jt,
2763
+ enableExperimentalFragmentVariables: Gt,
2764
+ disableExperimentalFragmentVariables: Yt
2750
2765
  };
2751
2766
  (function(e) {
2752
2767
  e.gql = U.gql, e.resetCaches = U.resetCaches, e.disableFragmentWarnings = U.disableFragmentWarnings, e.enableExperimentalFragmentVariables = U.enableExperimentalFragmentVariables, e.disableExperimentalFragmentVariables = U.disableExperimentalFragmentVariables;
2753
2768
  })(E || (E = {}));
2754
2769
  E.default = E;
2755
- const Kt = E`
2756
- query EventOverviewPage($organizationId: ID!, $hostingIds: [String!], $trackerId: String, $filterEventStatuses: [EventStatus!], $dateRange: DateRangeInput, $page: PageInput, $sorts: [SortInput!], $searchTerm: String, $priceRange: PriceRangeInput) {
2757
- findAllPublicEventByOrganizationId(
2758
- id: $organizationId
2759
- hostingIds: $hostingIds
2760
- trackerLinkId: $trackerId
2761
- filterEventStatuses: $filterEventStatuses
2762
- date: $dateRange
2763
- page: $page
2764
- sorts: $sorts
2765
- searchTerm: $searchTerm
2766
- priceRange: $priceRange
2767
- ) {
2768
- data {
2769
- id
2770
- name
2771
- icon
2772
- banner
2773
- description
2774
- addonDescription
2775
- startSalesAt
2776
- endSalesAt
2777
- startAt
2778
- endAt
2779
- timezone
2780
- slug
2781
- status
2782
- location {
2783
- id
2784
- name
2785
- address
2770
+ const Ht = E`
2771
+ query findActiveOrderById($id: String) {
2772
+ findOrder(id: $id) {
2773
+ id
2774
+ soldAt
2775
+ mainBooker {
2776
+ gender
2777
+ country
2778
+ residence
2779
+ firstName
2780
+ lastName
2781
+ email
2782
+ age
2783
+ extraInfo {
2784
+ value
2785
+ key
2786
2786
  }
2787
- infoDescription
2788
- startingPrice
2789
2787
  }
2790
- count
2791
- }
2792
- }
2793
- `, Wt = E`
2794
- query EventDetailPage($eventId: ID!) {
2795
- findPublicEventById(id: $eventId) {
2796
- id
2797
- name
2798
- icon
2799
- banner
2800
- description
2801
- addonDescription
2802
- startAt
2803
- endAt
2804
- startSalesAt
2805
- endSalesAt
2806
- facebookPixelId
2807
- timezone
2808
- slug
2809
- status
2810
- location {
2788
+ soldByUser {
2789
+ id
2790
+ firstName
2791
+ lastName
2792
+ avatar
2793
+ }
2794
+ organization {
2811
2795
  id
2812
2796
  name
2813
- address
2797
+ paymentBanner
2814
2798
  }
2815
- infoDescription
2816
- maxAmountOfTicketsPerOrder
2817
- }
2818
- }
2819
- `, Zt = E`
2820
- query findProductsByEventId($eventId: ID!, $promoCode: String, $trackerId: String, $productTypes: [ProductType!]) {
2821
- findPublicProductsByEventId(
2822
- eventId: $eventId
2823
- promoCode: $promoCode
2824
- trackerLinkId: $trackerId
2825
- filterProductTypes: $productTypes
2826
- ) {
2827
- id
2828
- icon
2829
- name
2830
- description
2831
2799
  currency
2832
- price
2833
- depositPrice
2834
- discountPrice
2835
- serviceFee
2836
- type
2837
- startSalesAt
2838
- endSalesAt
2839
- category {
2800
+ discount {
2801
+ code
2802
+ type
2803
+ amount
2804
+ maxAmount
2805
+ }
2806
+ items {
2840
2807
  id
2808
+ price
2841
2809
  name
2842
- description
2843
- order
2810
+ depositPrice
2811
+ originalPrice
2812
+ serviceFee
2813
+ amount
2814
+ amountPending
2815
+ expiredAt
2816
+ type
2817
+ event {
2818
+ id
2819
+ name
2820
+ startAt
2821
+ endAt
2822
+ timezone
2823
+ icon
2824
+ banner
2825
+ location {
2826
+ id
2827
+ name
2828
+ address
2829
+ }
2830
+ }
2831
+ product {
2832
+ id
2833
+ name
2834
+ icon
2835
+ description
2836
+ type
2837
+ discountPrice
2838
+ promoterDiscountPrice
2839
+ maxAmountOfAddons
2840
+ minAmountOfAddons
2841
+ }
2842
+ packageItem {
2843
+ id
2844
+ type
2845
+ package {
2846
+ id
2847
+ name
2848
+ }
2849
+ }
2850
+ seats {
2851
+ seatsIoId
2852
+ label
2853
+ }
2844
2854
  }
2845
- status
2846
- maxAmountOfAddons
2847
- minAmountOfAddons
2848
- seatsCategory
2849
- maxAmountPerOrder
2850
- showEndSalesAtTag
2851
2855
  }
2852
2856
  }
2853
- `, en = (e, t, n, i) => e();
2854
- function tn(e, t = en) {
2855
- return {
2856
- EventOverviewPage(n, i, r) {
2857
- return t((s) => e.request({ document: Kt, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "EventOverviewPage", "query", n);
2858
- },
2859
- EventDetailPage(n, i, r) {
2860
- return t((s) => e.request({ document: Wt, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "EventDetailPage", "query", n);
2861
- },
2862
- findProductsByEventId(n, i, r) {
2863
- return t((s) => e.request({ document: Zt, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "findProductsByEventId", "query", n);
2864
- }
2865
- };
2857
+ `, Qt = E`
2858
+ mutation addToOrder($orderId: ID!, $productId: ID!, $shopId: ID, $additionalData: AdditionalDataInput, $trackerId: ID, $amount: Int) {
2859
+ reserveProduct(
2860
+ input: {orderId: $orderId, productId: $productId, additionalData: $additionalData, trackerId: $trackerId, shopId: $shopId, amountToIncrease: $amount}
2861
+ ) {
2862
+ orderId
2863
+ expiredAt
2864
+ amountReserved
2865
+ }
2866
2866
  }
2867
- function nn(e) {
2868
- const t = /(query|mutation|subscription)\s+(\w+)/.exec(e);
2869
- if (!t) return { type: "unknown" };
2870
- const n = t[1], i = t[2];
2871
- return { type: n, name: i };
2867
+ `, Jt = E`
2868
+ mutation removeFromOrder($orderId: ID!, $productId: ID!, $additionalData: AdditionalDataInput, $amount: Int) {
2869
+ releaseProduct(
2870
+ input: {orderId: $orderId, productId: $productId, additionalData: $additionalData, amountToRelease: $amount}
2871
+ ) {
2872
+ orderId
2873
+ amountReleased
2874
+ }
2872
2875
  }
2873
- async function rn(e) {
2874
- if (typeof globalThis < "u" && globalThis.crypto?.subtle) {
2875
- const n = new TextEncoder().encode(e), i = await globalThis.crypto.subtle.digest("SHA-256", n);
2876
- return Array.from(new Uint8Array(i)).map((r) => r.toString(16).padStart(2, "0")).join("");
2876
+ `, Xt = E`
2877
+ mutation configurePackage($orderId: ID!, $packageId: ID!, $amount: Int!, $items: [ReservedItem!]!, $shopId: ID, $trackerId: ID) {
2878
+ configurePackage(
2879
+ input: {orderId: $orderId, shopId: $shopId, trackerId: $trackerId, packageId: $packageId, amount: $amount, items: $items}
2880
+ ) {
2881
+ orderId
2882
+ expiredAt
2883
+ amountReserved
2877
2884
  }
2878
- try {
2879
- const { createHash: t } = await import("./__vite-browser-external-l0sNRNKZ.js");
2880
- return t("sha256").update(e).digest("hex");
2881
- } catch {
2882
- throw new Error("SHA-256 is not available in this environment");
2885
+ }
2886
+ `, Kt = E`
2887
+ mutation reserveAdditionalPackageItem($amount: Int!, $orderId: ID!, $packageId: ID!, $eventId: ID!, $packageItemId: ID!) {
2888
+ reserveAdditionalPackageItem(
2889
+ input: {amount: $amount, eventId: $eventId, orderId: $orderId, packageId: $packageId, packageItemId: $packageItemId}
2890
+ ) {
2891
+ orderId
2892
+ expiredAt
2893
+ amountReserved
2883
2894
  }
2884
2895
  }
2885
- function sn(e) {
2886
- const t = { "content-type": "application/json" };
2887
- if (e)
2888
- for (const [n, i] of Object.entries(e))
2889
- typeof i < "u" && (t[n] = String(i));
2890
- return t;
2896
+ `, Wt = E`
2897
+ mutation configureOrderDeliveryOption($orderId: ID!, $productId: ID) {
2898
+ configureDeliveryOption(input: {orderId: $orderId, productId: $productId})
2891
2899
  }
2892
- function ge(e, t) {
2893
- return e?.length ? e.some((n) => t.includes(n?.extensions?.code) || t.includes(n?.message)) : !1;
2900
+ `, Zt = E`
2901
+ mutation createOrderCustomer($orderId: ID!, $countryCode: String, $customer: CreateCustomerInput!) {
2902
+ createOrderCustomer(
2903
+ input: {id: $orderId, countryCode: $countryCode, customer: $customer}
2904
+ )
2894
2905
  }
2895
- function Ie(e, t, n, i, r) {
2896
- const s = new Error(e);
2897
- return s.response = { data: r.json?.data, errors: r.json?.errors, status: r.status }, s.request = { query: t, variables: n, operationName: i }, s.graphQLErrors = r.json?.errors, s;
2906
+ `, en = E`
2907
+ mutation deleteOrder($orderId: ID!) {
2908
+ cancelOrder(id: $orderId)
2898
2909
  }
2899
- function ne(e, t, n, i, r) {
2910
+ `, tn = (e, t, n, i) => e();
2911
+ function nn(e, t = tn) {
2912
+ return {
2913
+ findActiveOrderById(n, i, r) {
2914
+ return t((s) => e.request({ document: Ht, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "findActiveOrderById", "query", n);
2915
+ },
2916
+ addToOrder(n, i, r) {
2917
+ return t((s) => e.request({ document: Qt, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "addToOrder", "mutation", n);
2918
+ },
2919
+ removeFromOrder(n, i, r) {
2920
+ return t((s) => e.request({ document: Jt, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "removeFromOrder", "mutation", n);
2921
+ },
2922
+ configurePackage(n, i, r) {
2923
+ return t((s) => e.request({ document: Xt, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "configurePackage", "mutation", n);
2924
+ },
2925
+ reserveAdditionalPackageItem(n, i, r) {
2926
+ return t((s) => e.request({ document: Kt, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "reserveAdditionalPackageItem", "mutation", n);
2927
+ },
2928
+ configureOrderDeliveryOption(n, i, r) {
2929
+ return t((s) => e.request({ document: Wt, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "configureOrderDeliveryOption", "mutation", n);
2930
+ },
2931
+ createOrderCustomer(n, i, r) {
2932
+ return t((s) => e.request({ document: Zt, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "createOrderCustomer", "mutation", n);
2933
+ },
2934
+ deleteOrder(n, i, r) {
2935
+ return t((s) => e.request({ document: en, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "deleteOrder", "mutation", n);
2936
+ }
2937
+ };
2938
+ }
2939
+ const ge = {
2940
+ order: null,
2941
+ processing: !1,
2942
+ error: null
2943
+ }, Ge = He({
2944
+ name: "basket",
2945
+ initialState: ge,
2946
+ reducers: {
2947
+ setProcessing: (e, t) => {
2948
+ e.processing = t.payload;
2949
+ },
2950
+ setError: (e, t) => {
2951
+ e.error = t.payload;
2952
+ },
2953
+ setOrder: (e, t) => {
2954
+ e.order = t.payload;
2955
+ },
2956
+ initializeOrder: (e, t) => {
2957
+ e.order || (e.order = {
2958
+ id: t.payload.id,
2959
+ currency: t.payload.currency,
2960
+ items: [],
2961
+ expiredAt: t.payload.expiredAt
2962
+ });
2963
+ },
2964
+ addProduct: (e, t) => {
2965
+ const { input: n, amountReserved: i, expiredAt: r } = t.payload;
2966
+ if (!e.order)
2967
+ return;
2968
+ const s = e.order.items.findIndex((o) => n.seat ? o.id === n.id && o.seats?.some((u) => u.id === n.seat?.id) : o.id === n.id);
2969
+ if (s >= 0)
2970
+ e.order.items[s].amount += i;
2971
+ else {
2972
+ const o = {
2973
+ id: n.id,
2974
+ type: "PRODUCT",
2975
+ name: n.name,
2976
+ amount: i,
2977
+ price: n.price,
2978
+ depositPrice: n.depositPrice,
2979
+ serviceFee: n.serviceFee,
2980
+ originalPrice: n.price,
2981
+ seats: n.seat ? [{ id: n.seat.id, label: n.seat.label }] : void 0
2982
+ };
2983
+ e.order.items.push(o);
2984
+ }
2985
+ e.order.expiredAt = r;
2986
+ },
2987
+ removeProduct: (e, t) => {
2988
+ if (!e.order) return;
2989
+ const { id: n, amountReleased: i, seatId: r } = t.payload, s = e.order.items.findIndex(
2990
+ (o) => o.type === "PRODUCT" && o.id === n
2991
+ );
2992
+ if (s !== -1) {
2993
+ const o = e.order.items[s];
2994
+ if (o.amount -= i, o.amount <= 0)
2995
+ e.order.items.splice(s, 1);
2996
+ else if (o.seats && r) {
2997
+ const u = o.seats.findIndex((h) => h.id === r);
2998
+ u !== -1 && o.seats.splice(u, 1);
2999
+ }
3000
+ }
3001
+ e.order.items.length === 0 && (e.order = null);
3002
+ },
3003
+ configurePackage: (e, t) => {
3004
+ const { input: n, amountReserved: i, expiredAt: r } = t.payload;
3005
+ e.order || (e.order = {
3006
+ id: "",
3007
+ currency: n.currency,
3008
+ items: [],
3009
+ expiredAt: r
3010
+ });
3011
+ const s = e.order.items.find(
3012
+ (o) => o.type === "PACKAGE" && o.id === n.id
3013
+ );
3014
+ s ? (s.amount = i, s.packageItems = n.items) : e.order.items.push({
3015
+ id: n.id,
3016
+ type: "PACKAGE",
3017
+ name: n.name,
3018
+ amount: i,
3019
+ price: n.discountPrice ?? n.price,
3020
+ depositPrice: n.depositPrice,
3021
+ originalPrice: n.price,
3022
+ serviceFee: n.serviceFee,
3023
+ packageItems: n.items
3024
+ });
3025
+ },
3026
+ reserveAdditionalPackageItem: (e, t) => {
3027
+ const { input: n, amountReserved: i, expiredAt: r } = t.payload;
3028
+ e.order || (e.order = {
3029
+ id: "",
3030
+ currency: n.currency,
3031
+ items: [],
3032
+ expiredAt: r
3033
+ });
3034
+ const s = e.order.items.findIndex(
3035
+ (u) => u.id === n.packageItemId
3036
+ ), o = e.order.items[s];
3037
+ o ? (o.amount = i, o.packageItems = [
3038
+ {
3039
+ packageItemId: n.packageItemId,
3040
+ eventId: n.eventId,
3041
+ name: n.name,
3042
+ startAt: n.startAt,
3043
+ endAt: n.endAt
3044
+ }
3045
+ ], o.amount === 0 && e.order.items.splice(s, 1)) : e.order.items.push({
3046
+ id: n.packageItemId,
3047
+ type: _.ADD_ONS,
3048
+ name: n.name,
3049
+ amount: i,
3050
+ price: n.discountPrice ?? n.price,
3051
+ depositPrice: n.depositPrice,
3052
+ originalPrice: n.price,
3053
+ serviceFee: n.serviceFee,
3054
+ packageItems: [
3055
+ {
3056
+ packageItemId: n.packageItemId,
3057
+ eventId: n.eventId,
3058
+ name: n.name,
3059
+ startAt: n.startAt,
3060
+ endAt: n.endAt
3061
+ }
3062
+ ]
3063
+ });
3064
+ },
3065
+ configureDelivery: (e, t) => {
3066
+ if (!e.order) return;
3067
+ const n = t.payload, i = e.order.items.findIndex(
3068
+ (r) => r.type === "DELIVERY"
3069
+ );
3070
+ if (n)
3071
+ if (i !== -1) {
3072
+ const r = e.order.items[i];
3073
+ r.id = n.id, r.name = n.name, r.price = n.price, r.serviceFee = n.serviceFee;
3074
+ } else
3075
+ e.order.items.push({
3076
+ id: n.id,
3077
+ type: "PRODUCT",
3078
+ name: n.name,
3079
+ amount: 1,
3080
+ price: n.price,
3081
+ originalPrice: n.price,
3082
+ serviceFee: n.serviceFee
3083
+ });
3084
+ else i !== -1 && e.order.items.splice(i, 1);
3085
+ },
3086
+ configureCustomer: (e, t) => {
3087
+ e.order && (e.order.customer = t.payload);
3088
+ },
3089
+ clearBasket: () => ge
3090
+ }
3091
+ }), {
3092
+ setProcessing: C,
3093
+ initializeOrder: j,
3094
+ addProduct: Ie,
3095
+ removeProduct: rn,
3096
+ configurePackage: Ee,
3097
+ configureDelivery: sn,
3098
+ configureCustomer: ye,
3099
+ reserveAdditionalPackageItem: on,
3100
+ clearBasket: ve
3101
+ } = Ge.actions;
3102
+ class an {
3103
+ orderIdKey = "ORDER_ID";
3104
+ config;
3105
+ sdk;
3106
+ store;
3107
+ constructor(t) {
3108
+ this.config = t, this.store = Qe({
3109
+ reducer: {
3110
+ basket: Ge.reducer
3111
+ }
3112
+ }), this.sdk = nn(new ae(t.apiUrl)), this.restoreOrderFromSession().then(() => {
3113
+ this.debugLog("Restore order from session");
3114
+ });
3115
+ }
3116
+ // Store functions
3117
+ subscribe(t) {
3118
+ return this.store.subscribe(t);
3119
+ }
3120
+ getCurrentOrder() {
3121
+ const t = this.getState();
3122
+ if (!t.order)
3123
+ return null;
3124
+ const n = t.order.items.reduce((i, r) => i + (r.amount || 0), 0);
3125
+ return {
3126
+ ...t.order,
3127
+ count: n
3128
+ };
3129
+ }
3130
+ getSelectedPackageEvent() {
3131
+ return this.getState().order?.items.flatMap((n) => n.packageItems?.map((i) => i.eventId) ?? []) ?? [];
3132
+ }
3133
+ // Basket update functions
3134
+ async addProduct(t) {
3135
+ this.store.dispatch(C(!0));
3136
+ try {
3137
+ const i = this.getState().order?.id ?? sessionStorage.getItem(this.orderIdKey) ?? this.generateOrderId();
3138
+ this.debugLog("Adding product", {
3139
+ productId: t.id,
3140
+ orderId: i,
3141
+ amount: t.amount,
3142
+ seat: t.seat
3143
+ });
3144
+ const r = await this.sdk.addToOrder({
3145
+ productId: t.id,
3146
+ orderId: i,
3147
+ additionalData: t.seat ? {
3148
+ seat: {
3149
+ seatId: t.seat.id,
3150
+ seatLabel: t.seat.label,
3151
+ holdToken: t.seat.holdToken
3152
+ }
3153
+ } : null,
3154
+ trackerId: this.config.trackerId,
3155
+ shopId: this.config.shopId,
3156
+ amount: t.amount
3157
+ });
3158
+ if (r?.reserveProduct) {
3159
+ const { orderId: s, expiredAt: o, amountReserved: u } = r.reserveProduct;
3160
+ this.debugLog("Product added successfully", r.reserveProduct), sessionStorage.setItem(this.orderIdKey, i), this.store.dispatch(
3161
+ j({
3162
+ id: s,
3163
+ currency: t.currency,
3164
+ expiredAt: o
3165
+ })
3166
+ ), this.store.dispatch(
3167
+ Ie({
3168
+ input: t,
3169
+ amountReserved: u,
3170
+ expiredAt: o
3171
+ })
3172
+ );
3173
+ }
3174
+ } catch (n) {
3175
+ throw this.debugLog("Error adding product", n), this.handleError(n), n;
3176
+ } finally {
3177
+ this.store.dispatch(C(!1));
3178
+ }
3179
+ }
3180
+ async removeProduct(t) {
3181
+ const i = this.getState().order;
3182
+ if (i) {
3183
+ this.store.dispatch(C(!0));
3184
+ try {
3185
+ this.debugLog("Removing product", {
3186
+ productId: t.id,
3187
+ orderId: i.id,
3188
+ amount: t.amount
3189
+ });
3190
+ const r = await this.sdk.removeFromOrder({
3191
+ productId: t.id,
3192
+ orderId: i.id,
3193
+ additionalData: t.seat ? {
3194
+ seat: {
3195
+ seatId: t.seat.id,
3196
+ seatLabel: t.seat.label
3197
+ }
3198
+ } : null,
3199
+ amount: t.amount
3200
+ });
3201
+ if (r?.releaseProduct) {
3202
+ const { amountReleased: s } = r.releaseProduct;
3203
+ this.debugLog("Product removed successfully", r.releaseProduct), this.store.dispatch(
3204
+ rn({
3205
+ id: t.id,
3206
+ amountReleased: s,
3207
+ seatId: t.seat?.id
3208
+ })
3209
+ );
3210
+ const o = this.getState();
3211
+ (!o.order || o.order.items.length === 0) && (this.debugLog("Basket is now empty, cancelling order and clearing session"), await this.cancelOrder());
3212
+ }
3213
+ } catch (r) {
3214
+ throw this.debugLog("Error removing product", r), this.handleError(r), r;
3215
+ } finally {
3216
+ this.store.dispatch(C(!1));
3217
+ }
3218
+ }
3219
+ }
3220
+ async configurePackage(t) {
3221
+ this.store.dispatch(C(!0));
3222
+ try {
3223
+ const i = this.store.getState().basket.order?.id ?? sessionStorage.getItem(this.orderIdKey) ?? this.generateOrderId(), r = t.items.map((o) => ({
3224
+ packageItemId: o.packageItemId,
3225
+ eventId: o.eventId
3226
+ }));
3227
+ this.debugLog("Configuring package", {
3228
+ packageId: t.id,
3229
+ orderId: i,
3230
+ amount: t.amount,
3231
+ items: r,
3232
+ shopId: this.config.shopId
3233
+ });
3234
+ const s = await this.sdk.configurePackage({
3235
+ trackerId: this.config.trackerId,
3236
+ shopId: this.config.shopId,
3237
+ packageId: t.id,
3238
+ orderId: i,
3239
+ amount: t.amount,
3240
+ items: r
3241
+ });
3242
+ if (this.debugLog("Configure package response", s), s?.configurePackage && s.configurePackage.amountReserved > 0) {
3243
+ const { orderId: o, expiredAt: u, amountReserved: h } = s.configurePackage;
3244
+ return this.debugLog("Package configured successfully"), sessionStorage.setItem(this.orderIdKey, i), this.store.dispatch(
3245
+ j({
3246
+ id: o,
3247
+ currency: t.currency,
3248
+ expiredAt: u
3249
+ })
3250
+ ), this.store.dispatch(
3251
+ Ee({
3252
+ input: t,
3253
+ amountReserved: h,
3254
+ expiredAt: u
3255
+ })
3256
+ ), null;
3257
+ } else
3258
+ return this.debugLog("Package configuration failed - no amount reserved"), { error: "Failed to configure package - no items reserved" };
3259
+ } catch (n) {
3260
+ return this.debugLog("Error configuring package", n), this.handleError(n), { error: n };
3261
+ } finally {
3262
+ this.store.dispatch(C(!1));
3263
+ }
3264
+ }
3265
+ async configureDelivery(t) {
3266
+ this.store.dispatch(C(!0));
3267
+ try {
3268
+ this.store.dispatch(sn(t));
3269
+ } catch (n) {
3270
+ throw this.debugLog("Error setting delivery", n), this.handleError(n), n;
3271
+ } finally {
3272
+ this.store.dispatch(C(!1));
3273
+ }
3274
+ }
3275
+ async configureCustomer(t) {
3276
+ const i = this.getState().order;
3277
+ if (!i)
3278
+ throw new Error("No active order. Add items to basket first.");
3279
+ this.debugLog("Creating/replacing customer", { orderId: i.id, email: t.email });
3280
+ try {
3281
+ const r = await this.sdk.createOrderCustomer({
3282
+ orderId: i.id,
3283
+ customer: t
3284
+ });
3285
+ this.debugLog("Customer set successfully", r), this.store.dispatch(ye(t));
3286
+ } catch (r) {
3287
+ throw this.debugLog("Failed to set customer", r), new Error(`Failed to set customer: ${r.message}`);
3288
+ }
3289
+ }
3290
+ async reserveAdditionalPackageItem(t) {
3291
+ this.store.dispatch(C(!0));
3292
+ try {
3293
+ const i = this.store.getState().basket.order?.id ?? sessionStorage.getItem(this.orderIdKey) ?? this.generateOrderId();
3294
+ this.debugLog("reserve additional packageItem", {
3295
+ orderId: i,
3296
+ eventId: t.eventId,
3297
+ amount: t.amount,
3298
+ packageId: t.packageId,
3299
+ packageItemId: t.packageItemId
3300
+ });
3301
+ const r = await this.sdk.reserveAdditionalPackageItem({
3302
+ orderId: i,
3303
+ eventId: t.eventId,
3304
+ amount: t.amount,
3305
+ packageId: t.packageId,
3306
+ packageItemId: t.packageItemId
3307
+ });
3308
+ if (this.debugLog("reserve additional packageItem", r), r?.reserveAdditionalPackageItem && r.reserveAdditionalPackageItem.amountReserved > 0) {
3309
+ const { orderId: s, expiredAt: o, amountReserved: u } = r.reserveAdditionalPackageItem;
3310
+ return this.debugLog("Reserve configured successfully"), sessionStorage.setItem(this.orderIdKey, i), this.store.dispatch(
3311
+ j({
3312
+ id: s,
3313
+ currency: t.currency,
3314
+ expiredAt: o
3315
+ })
3316
+ ), this.store.dispatch(
3317
+ on({
3318
+ input: t,
3319
+ amountReserved: u,
3320
+ expiredAt: o
3321
+ })
3322
+ ), null;
3323
+ } else
3324
+ return this.debugLog("Package configuration failed - no amount reserved"), { error: "Failed to configure package - no items reserved" };
3325
+ } catch (n) {
3326
+ return this.debugLog("Error configuring package", n), this.handleError(n), { error: n };
3327
+ } finally {
3328
+ this.store.dispatch(C(!1));
3329
+ }
3330
+ }
3331
+ // Cancel and clear order functions
3332
+ async cancelOrder() {
3333
+ const t = sessionStorage.getItem(this.orderIdKey);
3334
+ t && (this.debugLog("Cancelling order", { orderId: t }), await this.sdk.deleteOrder({ orderId: t }), this.clearOrderFromSession(), this.debugLog("Order cancelled successfully"));
3335
+ }
3336
+ clearOrderFromSession() {
3337
+ this.debugLog("Clearing order from session"), sessionStorage.removeItem(this.orderIdKey), this.store.dispatch(ve());
3338
+ }
3339
+ // Private functions for fetching the current order from a session
3340
+ async restoreOrderFromSession() {
3341
+ const t = sessionStorage.getItem(this.orderIdKey);
3342
+ if (t) {
3343
+ this.debugLog("Found existing order ID in session, restoring...", { orderId: t });
3344
+ try {
3345
+ await this.fetchOrder(t), this.debugLog("Order restored successfully");
3346
+ } catch (n) {
3347
+ this.debugLog("Failed to restore order, clearing session", n), this.clearOrderFromSession();
3348
+ }
3349
+ }
3350
+ }
3351
+ async fetchOrder(t) {
3352
+ this.debugLog("Fetching order from server", { orderId: t });
3353
+ try {
3354
+ const n = await this.sdk.findActiveOrderById({ id: t });
3355
+ if (!n?.findOrder) {
3356
+ this.debugLog("Order not found"), this.clearOrderFromSession();
3357
+ return;
3358
+ }
3359
+ const i = n.findOrder;
3360
+ this.debugLog("Order fetched successfully", i);
3361
+ const r = i.items, s = r.filter((c) => c.product != null && c.amount > 0).map((c) => {
3362
+ let m = _.PRODUCT;
3363
+ return c.product.type === "PROMOTER" ? m = _.ADD_ONS : c.product.type === "PICKUP" ? m = _.PICKUP : c.product.type === "DELIVERY" && (m = _.DELIVERY), {
3364
+ id: c.product.id,
3365
+ type: m,
3366
+ name: c.product.name,
3367
+ icon: c.product.icon,
3368
+ description: c.product.description,
3369
+ amount: c.amount,
3370
+ price: c.price ?? 0,
3371
+ depositPrice: c.depositPrice ?? 0,
3372
+ originalPrice: c.originalPrice ?? 0,
3373
+ serviceFee: c.serviceFee ?? 0,
3374
+ seats: c.seats?.map((g) => ({
3375
+ id: g.id,
3376
+ label: g.label
3377
+ }))
3378
+ };
3379
+ }), o = r.filter((c) => c.packageItem != null && c.amount > 0).reduce((c, m) => {
3380
+ const {
3381
+ packageItem: g,
3382
+ event: y,
3383
+ amount: I,
3384
+ price: O,
3385
+ serviceFee: x,
3386
+ depositPrice: k,
3387
+ originalPrice: L
3388
+ } = m, T = g.package.id;
3389
+ c[T] ? (c[T].price += O ?? 0, c[T].serviceFee += x ?? 0, c[T].originalPrice += L ?? 0, c[T].depositPrice += k ?? O ?? 0) : c[T] = {
3390
+ id: T,
3391
+ type: _.PACKAGE,
3392
+ name: g.package.name,
3393
+ amount: I,
3394
+ price: O ?? 0,
3395
+ serviceFee: x ?? 0,
3396
+ depositPrice: k ?? O ?? 0,
3397
+ originalPrice: L ?? 0,
3398
+ packageItems: []
3399
+ };
3400
+ const N = R.fromISO(y.startAt, {
3401
+ zone: y.timezone
3402
+ }), D = R.fromISO(y.endAt, {
3403
+ zone: y.timezone
3404
+ });
3405
+ return c[T].packageItems.push({
3406
+ packageItemId: g.id,
3407
+ eventId: y.id,
3408
+ name: y.name,
3409
+ startAt: N.toJSDate().toISOString(),
3410
+ endAt: D.toJSDate().toISOString()
3411
+ }), c;
3412
+ }, {}), u = [
3413
+ ...s,
3414
+ ...Object.values(o)
3415
+ ];
3416
+ if (u.length === 0) {
3417
+ this.debugLog("All order items have zero or negative amounts, clearing session"), this.clearOrderFromSession();
3418
+ return;
3419
+ }
3420
+ const h = r.filter((c) => c.amount > 0).map((c) => new Date(c.expiredAt).getTime());
3421
+ if (h.length === 0) {
3422
+ this.debugLog("No valid items with expiration times, clearing session"), this.clearOrderFromSession();
3423
+ return;
3424
+ }
3425
+ const p = R.fromMillis(Math.min(...h));
3426
+ this.store.dispatch(ve()), this.store.dispatch(
3427
+ j({
3428
+ id: i.id,
3429
+ currency: i.currency,
3430
+ expiredAt: p.toJSDate().toISOString()
3431
+ })
3432
+ ), u.forEach((c) => {
3433
+ c.type === _.PACKAGE ? this.store.dispatch(
3434
+ Ee({
3435
+ input: {
3436
+ id: c.id,
3437
+ name: c.name,
3438
+ currency: i.currency,
3439
+ price: c.originalPrice ?? 0,
3440
+ depositPrice: c.depositPrice,
3441
+ serviceFee: c.serviceFee ?? 0,
3442
+ amount: c.amount,
3443
+ items: c.packageItems || []
3444
+ },
3445
+ amountReserved: c.amount,
3446
+ expiredAt: p.toJSDate().toISOString()
3447
+ })
3448
+ ) : this.store.dispatch(
3449
+ Ie({
3450
+ input: {
3451
+ id: c.id,
3452
+ name: c.name,
3453
+ price: c.originalPrice,
3454
+ depositPrice: c.depositPrice,
3455
+ serviceFee: c.serviceFee,
3456
+ currency: i.currency,
3457
+ amount: c.amount
3458
+ },
3459
+ amountReserved: c.amount,
3460
+ expiredAt: p.toJSDate().toISOString()
3461
+ })
3462
+ );
3463
+ }), i.mainBooker && (this.debugLog("Order has customer (mainBooker)", i.mainBooker), this.store.dispatch(
3464
+ ye({
3465
+ firstName: i.mainBooker.firstName ?? void 0,
3466
+ lastName: i.mainBooker.lastName ?? void 0,
3467
+ email: i.mainBooker.email ?? void 0,
3468
+ age: i.mainBooker.age ?? void 0,
3469
+ gender: i.mainBooker.gender ?? void 0,
3470
+ residence: i.mainBooker.residence ?? void 0,
3471
+ extraInfo: i.mainBooker.extraInfo ?? void 0
3472
+ })
3473
+ )), this.debugLog("Order state fully synced", this.getState());
3474
+ } catch (n) {
3475
+ throw this.debugLog("Error fetching order", n), n;
3476
+ }
3477
+ }
3478
+ // Private helper functions
3479
+ generateOrderId() {
3480
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
3481
+ const n = Math.random() * 16 | 0;
3482
+ return (t === "x" ? n : n & 3 | 8).toString(16);
3483
+ });
3484
+ }
3485
+ debugLog(t, n) {
3486
+ this.config.debug && console.log(`[BasketService] ${t}`, n || "");
3487
+ }
3488
+ handleError(t) {
3489
+ const n = t;
3490
+ if (n.graphQLErrors && n.graphQLErrors.length > 0) {
3491
+ const i = n.graphQLErrors[0];
3492
+ i.extensions?.status === "RATE_LIMIT" && console.error("Rate Limit reached"), i.extensions?.status === "SOLD_OUT" && console.error("Product sold out");
3493
+ }
3494
+ if (n.response?.errors && n.response.errors.length > 0) {
3495
+ const i = n.response.errors[0];
3496
+ console.error("GraphQL Error:", i.message), i.extensions?.code && console.error("Error Code:", i.extensions.code);
3497
+ }
3498
+ }
3499
+ getState() {
3500
+ return this.store.getState().basket;
3501
+ }
3502
+ }
3503
+ const cn = E`
3504
+ query EventOverviewPage($organizationId: ID!, $hostingIds: [String!], $trackerId: String, $filterEventStatuses: [EventStatus!], $dateRange: DateRangeInput, $page: PageInput, $sorts: [SortInput!], $searchTerm: String, $priceRange: PriceRangeInput) {
3505
+ findAllPublicEventByOrganizationId(
3506
+ id: $organizationId
3507
+ hostingIds: $hostingIds
3508
+ trackerLinkId: $trackerId
3509
+ filterEventStatuses: $filterEventStatuses
3510
+ date: $dateRange
3511
+ page: $page
3512
+ sorts: $sorts
3513
+ searchTerm: $searchTerm
3514
+ priceRange: $priceRange
3515
+ ) {
3516
+ data {
3517
+ id
3518
+ name
3519
+ icon
3520
+ banner
3521
+ description
3522
+ addonDescription
3523
+ startSalesAt
3524
+ endSalesAt
3525
+ startAt
3526
+ endAt
3527
+ timezone
3528
+ slug
3529
+ status
3530
+ location {
3531
+ id
3532
+ name
3533
+ address
3534
+ }
3535
+ infoDescription
3536
+ startingPrice
3537
+ }
3538
+ count
3539
+ }
3540
+ }
3541
+ `, dn = E`
3542
+ query EventDetailPage($eventId: ID!) {
3543
+ findPublicEventById(id: $eventId) {
3544
+ id
3545
+ name
3546
+ icon
3547
+ banner
3548
+ description
3549
+ addonDescription
3550
+ startAt
3551
+ endAt
3552
+ startSalesAt
3553
+ endSalesAt
3554
+ facebookPixelId
3555
+ timezone
3556
+ slug
3557
+ status
3558
+ location {
3559
+ id
3560
+ name
3561
+ address
3562
+ }
3563
+ infoDescription
3564
+ maxAmountOfTicketsPerOrder
3565
+ }
3566
+ }
3567
+ `, un = E`
3568
+ query findProductsByEventId($eventId: ID!, $promoCode: String, $trackerId: String, $productTypes: [ProductType!]) {
3569
+ findPublicProductsByEventId(
3570
+ eventId: $eventId
3571
+ promoCode: $promoCode
3572
+ trackerLinkId: $trackerId
3573
+ filterProductTypes: $productTypes
3574
+ ) {
3575
+ id
3576
+ icon
3577
+ name
3578
+ description
3579
+ currency
3580
+ price
3581
+ depositPrice
3582
+ discountPrice
3583
+ serviceFee
3584
+ type
3585
+ startSalesAt
3586
+ endSalesAt
3587
+ category {
3588
+ id
3589
+ name
3590
+ description
3591
+ order
3592
+ }
3593
+ status
3594
+ maxAmountOfAddons
3595
+ minAmountOfAddons
3596
+ seatsCategory
3597
+ maxAmountPerOrder
3598
+ showEndSalesAtTag
3599
+ }
3600
+ }
3601
+ `, ln = (e, t, n, i) => e();
3602
+ function pn(e, t = ln) {
3603
+ return {
3604
+ EventOverviewPage(n, i, r) {
3605
+ return t((s) => e.request({ document: cn, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "EventOverviewPage", "query", n);
3606
+ },
3607
+ EventDetailPage(n, i, r) {
3608
+ return t((s) => e.request({ document: dn, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "EventDetailPage", "query", n);
3609
+ },
3610
+ findProductsByEventId(n, i, r) {
3611
+ return t((s) => e.request({ document: un, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "findProductsByEventId", "query", n);
3612
+ }
3613
+ };
3614
+ }
3615
+ function hn(e) {
3616
+ const t = /(query|mutation|subscription)\s+(\w+)/.exec(e);
3617
+ if (!t) return { type: "unknown" };
3618
+ const n = t[1], i = t[2];
3619
+ return { type: n, name: i };
3620
+ }
3621
+ async function fn(e) {
3622
+ if (typeof globalThis < "u" && globalThis.crypto?.subtle) {
3623
+ const n = new TextEncoder().encode(e), i = await globalThis.crypto.subtle.digest("SHA-256", n);
3624
+ return Array.from(new Uint8Array(i)).map((r) => r.toString(16).padStart(2, "0")).join("");
3625
+ }
3626
+ try {
3627
+ const { createHash: t } = await import("./__vite-browser-external-l0sNRNKZ.js");
3628
+ return t("sha256").update(e).digest("hex");
3629
+ } catch {
3630
+ throw new Error("SHA-256 is not available in this environment");
3631
+ }
3632
+ }
3633
+ function mn(e) {
3634
+ const t = { "content-type": "application/json" };
3635
+ if (e)
3636
+ for (const [n, i] of Object.entries(e))
3637
+ typeof i < "u" && (t[n] = String(i));
3638
+ return t;
3639
+ }
3640
+ function Ae(e, t) {
3641
+ return e?.length ? e.some((n) => t.includes(n?.extensions?.code) || t.includes(n?.message)) : !1;
3642
+ }
3643
+ function Te(e, t, n, i, r) {
3644
+ const s = new Error(e);
3645
+ return s.response = { data: r.json?.data, errors: r.json?.errors, status: r.status }, s.request = { query: t, variables: n, operationName: i }, s.graphQLErrors = r.json?.errors, s;
3646
+ }
3647
+ function ne(e, t, n, i, r) {
2900
3648
  if (r.json?.errors?.length)
2901
- throw Ie(`GraphQL request failed${e ? ` (${e})` : ""}`, t, n, i, r);
3649
+ throw Te(`GraphQL request failed${e ? ` (${e})` : ""}`, t, n, i, r);
2902
3650
  if (typeof r.json?.data > "u")
2903
- throw Ie("GraphQL request failed: no data received", t, n, i, r);
3651
+ throw Te("GraphQL request failed: no data received", t, n, i, r);
2904
3652
  return r.json.data;
2905
3653
  }
2906
3654
  class ue extends ae {
2907
3655
  async request(t, ...n) {
2908
3656
  let i = t, r, s, o;
2909
3657
  t && typeof t == "object" && "document" in t ? (i = t.document, r = t.variables, s = t.requestHeaders, o = t.signal) : (r = n[0], s = n[1]);
2910
- const u = typeof i == "string" ? i : Vt(i), { type: h, name: p } = nn(u), c = await rn(u), m = r ?? {}, g = this.url ?? this.endpoint ?? "", y = sn(s), I = async (D) => {
3658
+ const u = typeof i == "string" ? i : wt(i), { type: h, name: p } = hn(u), c = await fn(u), m = r ?? {}, g = this.url ?? this.endpoint ?? "", y = mn(s), I = async (D) => {
2911
3659
  const b = await fetch(g, { method: "POST", headers: y, body: JSON.stringify(D), signal: o });
2912
3660
  let P = null;
2913
3661
  try {
@@ -2918,8 +3666,8 @@ class ue extends ae {
2918
3666
  return { status: b.status, json: P };
2919
3667
  }, O = async (D) => {
2920
3668
  const b = new URLSearchParams();
2921
- for (const [Ke, q] of Object.entries(D))
2922
- typeof q > "u" || b.set(Ke, typeof q == "string" ? q : JSON.stringify(q));
3669
+ for (const [Ye, q] of Object.entries(D))
3670
+ typeof q > "u" || b.set(Ye, typeof q == "string" ? q : JSON.stringify(q));
2923
3671
  const P = g.includes("?") ? "&" : "?", B = `${g}${P}${b.toString()}`, le = await fetch(B, { method: "GET", headers: y, signal: o });
2924
3672
  let Z = null;
2925
3673
  try {
@@ -2933,11 +3681,11 @@ class ue extends ae {
2933
3681
  variables: m,
2934
3682
  extensions: { persistedQuery: { version: 1, sha256Hash: c } }
2935
3683
  }, k = async (D, b, P) => {
2936
- if (ge(D.json?.errors, ["PERSISTED_QUERY_NOT_FOUND", "PersistedQueryNotFound"])) {
3684
+ if (Ae(D.json?.errors, ["PERSISTED_QUERY_NOT_FOUND", "PersistedQueryNotFound"])) {
2937
3685
  const B = await b();
2938
3686
  return ne("APQ register", u, m, p, B);
2939
3687
  }
2940
- if (ge(D.json?.errors, ["PERSISTED_QUERY_NOT_SUPPORTED"])) {
3688
+ if (Ae(D.json?.errors, ["PERSISTED_QUERY_NOT_SUPPORTED"])) {
2941
3689
  const B = await P();
2942
3690
  return ne("no APQ support", u, m, p, B);
2943
3691
  }
@@ -2951,11 +3699,11 @@ class ue extends ae {
2951
3699
  return k(L, () => I({ ...x, query: u }), () => I({ operationName: p, variables: m, query: u }));
2952
3700
  }
2953
3701
  }
2954
- class we {
3702
+ class gn {
2955
3703
  config;
2956
3704
  sdk;
2957
3705
  constructor(t) {
2958
- this.config = t, this.sdk = tn(new ue(t.apiUrl));
3706
+ this.config = t, this.sdk = pn(new ue(t.apiUrl));
2959
3707
  }
2960
3708
  async fetchEvents(t = {}) {
2961
3709
  try {
@@ -3106,7 +3854,7 @@ class we {
3106
3854
  this.config.debug && console.log(`[EventService:${this.config.organizationId}] ${t}`, n || "");
3107
3855
  }
3108
3856
  }
3109
- const on = E`
3857
+ const In = E`
3110
3858
  query findPaymentMethods($orderId: ID!, $orderItemId: String, $amountOfTickets: Int, $paymentMethodId: String) {
3111
3859
  findPaymentDetails(
3112
3860
  orderId: $orderId
@@ -3134,26 +3882,26 @@ const on = E`
3134
3882
  paymentSpesificTransactionFee
3135
3883
  }
3136
3884
  }
3137
- `, an = E`
3885
+ `, En = E`
3138
3886
  mutation createDigitalPayment($input: CreateDigitalOrderPaymentInput!) {
3139
3887
  createDigitalOrderPayment(input: $input)
3140
3888
  }
3141
- `, cn = (e, t, n, i) => e();
3142
- function dn(e, t = cn) {
3889
+ `, yn = (e, t, n, i) => e();
3890
+ function vn(e, t = yn) {
3143
3891
  return {
3144
3892
  findPaymentMethods(n, i, r) {
3145
- return t((s) => e.request({ document: on, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "findPaymentMethods", "query", n);
3893
+ return t((s) => e.request({ document: In, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "findPaymentMethods", "query", n);
3146
3894
  },
3147
3895
  createDigitalPayment(n, i, r) {
3148
- return t((s) => e.request({ document: an, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "createDigitalPayment", "mutation", n);
3896
+ return t((s) => e.request({ document: En, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "createDigitalPayment", "mutation", n);
3149
3897
  }
3150
3898
  };
3151
3899
  }
3152
- class $e {
3900
+ class An {
3153
3901
  config;
3154
3902
  sdk;
3155
3903
  constructor(t) {
3156
- this.config = t, this.sdk = dn(new ae(t.apiUrl));
3904
+ this.config = t, this.sdk = vn(new ae(t.apiUrl));
3157
3905
  }
3158
3906
  async getPaymentDetails(t) {
3159
3907
  this.debugLog("Fetching payment methods", t);
@@ -3227,7 +3975,7 @@ class $e {
3227
3975
  this.config.debug && console.log(`[PaymentService] ${t}`, n || "");
3228
3976
  }
3229
3977
  }
3230
- const un = E`
3978
+ const Tn = E`
3231
3979
  query findAllPublicPackagesByOrganizationId($organizationId: ID!) {
3232
3980
  findAllPublicPackagesByOrganizationId(organizationId: $organizationId) {
3233
3981
  data {
@@ -3249,975 +3997,223 @@ const un = E`
3249
3997
  serviceFee
3250
3998
  }
3251
3999
  }
3252
- count
3253
- }
3254
- }
3255
- `, ln = E`
3256
- query findPublicPackageById($packageId: ID!) {
3257
- findPublicPackageById(id: $packageId) {
3258
- id
3259
- slug
3260
- status
3261
- name
3262
- description
3263
- shortTitle
3264
- shortDescription
3265
- startAvailabilityAt
3266
- endAvailabilityAt
3267
- maxAmountOfPersonsPerOrder
3268
- icon
3269
- banner
3270
- currency
3271
- amountOfEvents
3272
- amountOfAddons
3273
- prices {
3274
- price
3275
- deposit
3276
- discount
3277
- serviceFee
3278
- }
3279
- }
3280
- }
3281
- `, pn = E`
3282
- query findPublicItemsByPackageId($packageId: ID!, $types: [PackageItemType!], $page: PageInput) {
3283
- findPublicItemsByPackageId(packageId: $packageId, types: $types, page: $page) {
3284
- data {
3285
- id
3286
- name
3287
- description
3288
- type
3289
- price
3290
- depositPrice
3291
- discountPrice
3292
- serviceFee
3293
- banner
3294
- package {
3295
- id
3296
- name
3297
- }
3298
- activeEvents {
3299
- id
3300
- name
3301
- startAt
3302
- endAt
3303
- timezone
3304
- icon
3305
- banner
3306
- location {
3307
- id
3308
- name
3309
- address
3310
- }
3311
- }
3312
- }
3313
- count
3314
- }
3315
- }
3316
- `, hn = (e, t, n, i) => e();
3317
- function fn(e, t = hn) {
3318
- return {
3319
- findAllPublicPackagesByOrganizationId(n, i, r) {
3320
- return t((s) => e.request({ document: un, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "findAllPublicPackagesByOrganizationId", "query", n);
3321
- },
3322
- findPublicPackageById(n, i, r) {
3323
- return t((s) => e.request({ document: ln, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "findPublicPackageById", "query", n);
3324
- },
3325
- findPublicItemsByPackageId(n, i, r) {
3326
- return t((s) => e.request({ document: pn, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "findPublicItemsByPackageId", "query", n);
3327
- }
3328
- };
3329
- }
3330
- class Be {
3331
- config;
3332
- sdk;
3333
- constructor(t) {
3334
- this.config = t, this.sdk = fn(new ue(t.apiUrl));
3335
- }
3336
- debugLog(t, n) {
3337
- this.config.debug && console.log(`[PackageService] ${t}`, n || "");
3338
- }
3339
- async getPackages(t = {}) {
3340
- try {
3341
- let n;
3342
- t.page && (n = {
3343
- index: t.page.index ?? 0,
3344
- size: t.page.size ?? 20
3345
- }), this.debugLog("Fetching public packages", {
3346
- organizationId: this.config.organizationId,
3347
- page: n,
3348
- tab: t.tab,
3349
- statuses: t.statuses
3350
- });
3351
- const i = await this.sdk.findAllPublicPackagesByOrganizationId({
3352
- organizationId: this.config.organizationId
3353
- });
3354
- if (i?.findAllPublicPackagesByOrganizationId) {
3355
- const r = i.findAllPublicPackagesByOrganizationId;
3356
- return this.debugLog("Public packages fetched", {
3357
- count: r.count,
3358
- dataLength: r.data.length
3359
- }), r;
3360
- }
3361
- return null;
3362
- } catch (n) {
3363
- throw this.debugLog("Error fetching public packages", n), n;
3364
- }
3365
- }
3366
- async getPackage(t) {
3367
- try {
3368
- this.debugLog("Fetching public packages", {
3369
- packageId: t
3370
- });
3371
- const n = await this.sdk.findPublicPackageById({ packageId: t });
3372
- if (n?.findPublicPackageById) {
3373
- const i = n.findPublicPackageById;
3374
- return this.debugLog("Public package fetched"), i;
3375
- }
3376
- return null;
3377
- } catch (n) {
3378
- throw this.debugLog("Error fetching public packages", n), n;
3379
- }
3380
- }
3381
- async getPackageItems(t, n = [X.Regular, X.AdditionalEvent]) {
3382
- try {
3383
- this.debugLog("Fetching public package items", { packageId: t, types: n });
3384
- const i = await this.sdk.findPublicItemsByPackageId({
3385
- packageId: t,
3386
- types: n,
3387
- page: { index: 0, size: 100 }
3388
- });
3389
- if (i?.findPublicItemsByPackageId) {
3390
- const r = i.findPublicItemsByPackageId;
3391
- return this.debugLog("Public package items fetched", {
3392
- count: r.count,
3393
- dataLength: r.data.length
3394
- }), r;
3395
- }
3396
- return null;
3397
- } catch (i) {
3398
- throw this.debugLog("Error fetching public package items", i), i;
3399
- }
3400
- }
3401
- }
3402
- const mn = E`
3403
- query findAllPublicCategoriesByOrganizationId($organizationId: ID!, $dateRange: DateRangeInput) {
3404
- findAllPublicHostingsByOrganizationId(id: $organizationId) {
3405
- data {
3406
- id
3407
- name
3408
- icon
3409
- amountOfActiveEvents(input: $dateRange)
3410
- }
3411
- count
3412
- }
3413
- }
3414
- `, gn = E`
3415
- query findPublicCategoryById($hostingId: ID!, $dateRange: DateRangeInput) {
3416
- findPublicHostingById(id: $hostingId) {
3417
- id
3418
- name
3419
- icon
3420
- amountOfActiveEvents(input: $dateRange)
3421
- }
3422
- }
3423
- `, In = (e, t, n, i) => e();
3424
- function En(e, t = In) {
3425
- return {
3426
- findAllPublicCategoriesByOrganizationId(n, i, r) {
3427
- return t((s) => e.request({ document: mn, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "findAllPublicCategoriesByOrganizationId", "query", n);
3428
- },
3429
- findPublicCategoryById(n, i, r) {
3430
- return t((s) => e.request({ document: gn, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "findPublicCategoryById", "query", n);
3431
- }
3432
- };
3433
- }
3434
- class Ue {
3435
- config;
3436
- sdk;
3437
- constructor(t) {
3438
- this.config = t, this.sdk = En(new ue(t.apiUrl));
3439
- }
3440
- debugLog(t, n) {
3441
- this.config.debug && console.log(`[CategoryService] ${t}`, n || "");
3442
- }
3443
- async getCategories(t) {
3444
- try {
3445
- this.debugLog("Fetching all categories", { organizationId: this.config.organizationId });
3446
- const n = await this.sdk.findAllPublicCategoriesByOrganizationId({ organizationId: this.config.organizationId, dateRange: t });
3447
- if (n?.findAllPublicHostingsByOrganizationId) {
3448
- const i = n.findAllPublicHostingsByOrganizationId;
3449
- return this.debugLog("Categories fetched", { count: i.count, dataLength: i.data.length }), i.data.map((r) => ({ id: r.id, name: r.name, icon: r.icon, activeEvents: r.amountOfActiveEvents }));
3450
- }
3451
- return [];
3452
- } catch (n) {
3453
- throw this.debugLog("Error fetching categories", n), n;
3454
- }
3455
- }
3456
- async getCategory(t) {
3457
- try {
3458
- this.debugLog("Fetching category", { categoryId: t });
3459
- const n = await this.sdk.findPublicCategoryById({ hostingId: t });
3460
- if (n?.findPublicHostingById) {
3461
- const i = n.findPublicHostingById;
3462
- return this.debugLog("Category fetched", i), { id: i.id, name: i.name, icon: i.icon, activeEvents: i.amountOfActiveEvents };
3463
- }
3464
- return null;
3465
- } catch (n) {
3466
- throw this.debugLog("Error fetching category", n), n;
3467
- }
3468
- }
3469
- }
3470
- var _ = /* @__PURE__ */ ((e) => (e.PACKAGE = "PACKAGE", e.PRODUCT = "PRODUCT", e.ADD_ONS = "ADD_ONS", e.DELIVERY = "DELIVERY", e.PICKUP = "PICKUP", e))(_ || {}), X = /* @__PURE__ */ ((e) => (e.AdditionalEvent = "ADDITIONAL_EVENT", e.Addon = "ADDON", e.Regular = "REGULAR", e))(X || {}), Ve = /* @__PURE__ */ ((e) => (e.Active = "ACTIVE", e.Concept = "CONCEPT", e.Paused = "PAUSED", e.SoldOut = "SOLD_OUT", e))(Ve || {}), Me = /* @__PURE__ */ ((e) => (e.Active = "ACTIVE", e.Inactive = "INACTIVE", e))(Me || {}), qe = /* @__PURE__ */ ((e) => (e.Active = "ACTIVE", e.Inactive = "INACTIVE", e.Paused = "PAUSED", e.SoldOut = "SOLD_OUT", e))(qe || {}), ze = /* @__PURE__ */ ((e) => (e.Asc = "ASC", e.Desc = "DESC", e))(ze || {}), je = /* @__PURE__ */ ((e) => (e.AllReserved = "ALL_RESERVED", e.Available = "AVAILABLE", e.SoldOut = "SOLD_OUT", e))(je || {}), Ge = /* @__PURE__ */ ((e) => (e.Addon = "ADDON", e.Delivery = "DELIVERY", e.Door = "DOOR", e.Friend = "FRIEND", e.Guest = "GUEST", e.Pickup = "PICKUP", e.Promoter = "PROMOTER", e.Ticket = "TICKET", e))(Ge || {}), Ye = /* @__PURE__ */ ((e) => (e.FIXED = "FIXED", e.PERCENTAGE = "PERCENTAGE", e))(Ye || {}), He = /* @__PURE__ */ ((e) => (e.AddOn = "ADD_ON", e.DeliveryOption = "DELIVERY_OPTION", e.EntranceTicket = "ENTRANCE_TICKET", e))(He || {}), Qe = /* @__PURE__ */ ((e) => (e.Fixed = "FIXED", e.Percentage = "PERCENTAGE", e))(Qe || {});
3471
- const yn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3472
- __proto__: null,
3473
- BasketOrderType: _,
3474
- BasketService: Xe,
3475
- CategoryService: Ue,
3476
- DiscountType: Qe,
3477
- EventService: we,
3478
- EventStatus: qe,
3479
- OrderItemType: He,
3480
- PackageItemType: X,
3481
- PackageService: Be,
3482
- PackageStatus: Ve,
3483
- PackageTabType: Me,
3484
- PaymentMethodFeeType: Ye,
3485
- PaymentService: $e,
3486
- ProductStatus: je,
3487
- ProductType: Ge,
3488
- SortOrder: ze
3489
- }, Symbol.toStringTag, { value: "Module" })), vn = E`
3490
- query findActiveOrderById($id: String) {
3491
- findOrder(id: $id) {
3492
- id
3493
- soldAt
3494
- mainBooker {
3495
- gender
3496
- country
3497
- residence
3498
- firstName
3499
- lastName
3500
- email
3501
- age
3502
- extraInfo {
3503
- value
3504
- key
3505
- }
3506
- }
3507
- soldByUser {
3508
- id
3509
- firstName
3510
- lastName
3511
- avatar
3512
- }
3513
- organization {
3514
- id
3515
- name
3516
- paymentBanner
3517
- }
4000
+ count
4001
+ }
4002
+ }
4003
+ `, On = E`
4004
+ query findPublicPackageById($packageId: ID!) {
4005
+ findPublicPackageById(id: $packageId) {
4006
+ id
4007
+ slug
4008
+ status
4009
+ name
4010
+ description
4011
+ shortTitle
4012
+ shortDescription
4013
+ startAvailabilityAt
4014
+ endAvailabilityAt
4015
+ maxAmountOfPersonsPerOrder
4016
+ icon
4017
+ banner
3518
4018
  currency
3519
- discount {
3520
- code
3521
- type
3522
- amount
3523
- maxAmount
4019
+ amountOfEvents
4020
+ amountOfAddons
4021
+ prices {
4022
+ price
4023
+ deposit
4024
+ discount
4025
+ serviceFee
3524
4026
  }
3525
- items {
4027
+ }
4028
+ }
4029
+ `, kn = E`
4030
+ query findPublicItemsByPackageId($packageId: ID!, $types: [PackageItemType!], $page: PageInput) {
4031
+ findPublicItemsByPackageId(packageId: $packageId, types: $types, page: $page) {
4032
+ data {
3526
4033
  id
3527
- price
3528
4034
  name
4035
+ description
4036
+ type
4037
+ price
3529
4038
  depositPrice
3530
- originalPrice
4039
+ discountPrice
3531
4040
  serviceFee
3532
- amount
3533
- amountPending
3534
- expiredAt
3535
- type
3536
- event {
4041
+ banner
4042
+ package {
3537
4043
  id
3538
4044
  name
3539
- startAt
3540
- endAt
3541
- timezone
3542
- icon
3543
- banner
3544
- location {
3545
- id
3546
- name
3547
- address
3548
- }
3549
4045
  }
3550
- product {
4046
+ activeEvents {
3551
4047
  id
3552
4048
  name
4049
+ startAt
4050
+ endAt
4051
+ timezone
3553
4052
  icon
3554
- description
3555
- type
3556
- discountPrice
3557
- promoterDiscountPrice
3558
- maxAmountOfAddons
3559
- minAmountOfAddons
3560
- }
3561
- packageItem {
3562
- id
3563
- type
3564
- package {
3565
- id
3566
- name
3567
- }
3568
- }
3569
- seats {
3570
- seatsIoId
3571
- label
3572
- }
3573
- }
3574
- }
3575
- }
3576
- `, An = E`
3577
- mutation addToOrder($orderId: ID!, $productId: ID!, $shopId: ID, $additionalData: AdditionalDataInput, $trackerId: ID, $amount: Int) {
3578
- reserveProduct(
3579
- input: {orderId: $orderId, productId: $productId, additionalData: $additionalData, trackerId: $trackerId, shopId: $shopId, amountToIncrease: $amount}
3580
- ) {
3581
- orderId
3582
- expiredAt
3583
- amountReserved
3584
- }
3585
- }
3586
- `, Tn = E`
3587
- mutation removeFromOrder($orderId: ID!, $productId: ID!, $additionalData: AdditionalDataInput, $amount: Int) {
3588
- releaseProduct(
3589
- input: {orderId: $orderId, productId: $productId, additionalData: $additionalData, amountToRelease: $amount}
3590
- ) {
3591
- orderId
3592
- amountReleased
3593
- }
3594
- }
3595
- `, On = E`
3596
- mutation configurePackage($orderId: ID!, $packageId: ID!, $amount: Int!, $items: [ReservedItem!]!, $shopId: ID, $trackerId: ID) {
3597
- configurePackage(
3598
- input: {orderId: $orderId, shopId: $shopId, trackerId: $trackerId, packageId: $packageId, amount: $amount, items: $items}
3599
- ) {
3600
- orderId
3601
- expiredAt
3602
- amountReserved
3603
- }
3604
- }
3605
- `, kn = E`
3606
- mutation reserveAdditionalPackageItem($amount: Int!, $orderId: ID!, $packageId: ID!, $eventId: ID!, $packageItemId: ID!) {
3607
- reserveAdditionalPackageItem(
3608
- input: {amount: $amount, eventId: $eventId, orderId: $orderId, packageId: $packageId, packageItemId: $packageItemId}
3609
- ) {
3610
- orderId
3611
- expiredAt
3612
- amountReserved
3613
- }
3614
- }
3615
- `, Dn = E`
3616
- mutation configureOrderDeliveryOption($orderId: ID!, $productId: ID) {
3617
- configureDeliveryOption(input: {orderId: $orderId, productId: $productId})
3618
- }
3619
- `, xn = E`
3620
- mutation createOrderCustomer($orderId: ID!, $countryCode: String, $customer: CreateCustomerInput!) {
3621
- createOrderCustomer(
3622
- input: {id: $orderId, countryCode: $countryCode, customer: $customer}
3623
- )
3624
- }
3625
- `, Nn = E`
3626
- mutation deleteOrder($orderId: ID!) {
3627
- cancelOrder(id: $orderId)
3628
- }
3629
- `, bn = (e, t, n, i) => e();
3630
- function Pn(e, t = bn) {
3631
- return {
3632
- findActiveOrderById(n, i, r) {
3633
- return t((s) => e.request({ document: vn, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "findActiveOrderById", "query", n);
3634
- },
3635
- addToOrder(n, i, r) {
3636
- return t((s) => e.request({ document: An, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "addToOrder", "mutation", n);
3637
- },
3638
- removeFromOrder(n, i, r) {
3639
- return t((s) => e.request({ document: Tn, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "removeFromOrder", "mutation", n);
3640
- },
3641
- configurePackage(n, i, r) {
3642
- return t((s) => e.request({ document: On, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "configurePackage", "mutation", n);
3643
- },
3644
- reserveAdditionalPackageItem(n, i, r) {
3645
- return t((s) => e.request({ document: kn, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "reserveAdditionalPackageItem", "mutation", n);
3646
- },
3647
- configureOrderDeliveryOption(n, i, r) {
3648
- return t((s) => e.request({ document: Dn, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "configureOrderDeliveryOption", "mutation", n);
3649
- },
3650
- createOrderCustomer(n, i, r) {
3651
- return t((s) => e.request({ document: xn, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "createOrderCustomer", "mutation", n);
3652
- },
3653
- deleteOrder(n, i, r) {
3654
- return t((s) => e.request({ document: Nn, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "deleteOrder", "mutation", n);
3655
- }
3656
- };
3657
- }
3658
- const Ee = {
3659
- order: null,
3660
- processing: !1,
3661
- error: null
3662
- }, Je = We({
3663
- name: "basket",
3664
- initialState: Ee,
3665
- reducers: {
3666
- setProcessing: (e, t) => {
3667
- e.processing = t.payload;
3668
- },
3669
- setError: (e, t) => {
3670
- e.error = t.payload;
3671
- },
3672
- setOrder: (e, t) => {
3673
- e.order = t.payload;
3674
- },
3675
- initializeOrder: (e, t) => {
3676
- e.order || (e.order = {
3677
- id: t.payload.id,
3678
- currency: t.payload.currency,
3679
- items: [],
3680
- expiredAt: t.payload.expiredAt
3681
- });
3682
- },
3683
- addProduct: (e, t) => {
3684
- const { input: n, amountReserved: i, expiredAt: r } = t.payload;
3685
- if (!e.order)
3686
- return;
3687
- const s = e.order.items.findIndex((o) => n.seat ? o.id === n.id && o.seats?.some((u) => u.id === n.seat?.id) : o.id === n.id);
3688
- if (s >= 0)
3689
- e.order.items[s].amount += i;
3690
- else {
3691
- const o = {
3692
- id: n.id,
3693
- type: "PRODUCT",
3694
- name: n.name,
3695
- amount: i,
3696
- price: n.price,
3697
- depositPrice: n.depositPrice,
3698
- serviceFee: n.serviceFee,
3699
- originalPrice: n.price,
3700
- seats: n.seat ? [{ id: n.seat.id, label: n.seat.label }] : void 0
3701
- };
3702
- e.order.items.push(o);
3703
- }
3704
- e.order.expiredAt = r;
3705
- },
3706
- removeProduct: (e, t) => {
3707
- if (!e.order) return;
3708
- const { id: n, amountReleased: i, seatId: r } = t.payload, s = e.order.items.findIndex(
3709
- (o) => o.type === "PRODUCT" && o.id === n
3710
- );
3711
- if (s !== -1) {
3712
- const o = e.order.items[s];
3713
- if (o.amount -= i, o.amount <= 0)
3714
- e.order.items.splice(s, 1);
3715
- else if (o.seats && r) {
3716
- const u = o.seats.findIndex((h) => h.id === r);
3717
- u !== -1 && o.seats.splice(u, 1);
3718
- }
3719
- }
3720
- e.order.items.length === 0 && (e.order = null);
3721
- },
3722
- configurePackage: (e, t) => {
3723
- const { input: n, amountReserved: i, expiredAt: r } = t.payload;
3724
- e.order || (e.order = {
3725
- id: "",
3726
- currency: n.currency,
3727
- items: [],
3728
- expiredAt: r
3729
- });
3730
- const s = e.order.items.find(
3731
- (o) => o.type === "PACKAGE" && o.id === n.id
3732
- );
3733
- s ? (s.amount = i, s.packageItems = n.items) : e.order.items.push({
3734
- id: n.id,
3735
- type: "PACKAGE",
3736
- name: n.name,
3737
- amount: i,
3738
- price: n.discountPrice ?? n.price,
3739
- depositPrice: n.depositPrice,
3740
- originalPrice: n.price,
3741
- serviceFee: n.serviceFee,
3742
- packageItems: n.items
3743
- });
3744
- },
3745
- reserveAdditionalPackageItem: (e, t) => {
3746
- const { input: n, amountReserved: i, expiredAt: r } = t.payload;
3747
- e.order || (e.order = {
3748
- id: "",
3749
- currency: n.currency,
3750
- items: [],
3751
- expiredAt: r
3752
- });
3753
- const s = e.order.items.findIndex(
3754
- (u) => u.id === n.packageItemId
3755
- ), o = e.order.items[s];
3756
- o ? (o.amount = i, o.packageItems = [
3757
- {
3758
- packageItemId: n.packageItemId,
3759
- eventId: n.eventId,
3760
- name: n.name,
3761
- startAt: n.startAt,
3762
- endAt: n.endAt
4053
+ banner
4054
+ location {
4055
+ id
4056
+ name
4057
+ address
3763
4058
  }
3764
- ], o.amount === 0 && e.order.items.splice(s, 1)) : e.order.items.push({
3765
- id: n.packageItemId,
3766
- type: _.ADD_ONS,
3767
- name: n.name,
3768
- amount: i,
3769
- price: n.discountPrice ?? n.price,
3770
- depositPrice: n.depositPrice,
3771
- originalPrice: n.price,
3772
- serviceFee: n.serviceFee,
3773
- packageItems: [
3774
- {
3775
- packageItemId: n.packageItemId,
3776
- eventId: n.eventId,
3777
- name: n.name,
3778
- startAt: n.startAt,
3779
- endAt: n.endAt
3780
- }
3781
- ]
3782
- });
3783
- },
3784
- configureDelivery: (e, t) => {
3785
- if (!e.order) return;
3786
- const n = t.payload, i = e.order.items.findIndex(
3787
- (r) => r.type === "DELIVERY"
3788
- );
3789
- if (n)
3790
- if (i !== -1) {
3791
- const r = e.order.items[i];
3792
- r.id = n.id, r.name = n.name, r.price = n.price, r.serviceFee = n.serviceFee;
3793
- } else
3794
- e.order.items.push({
3795
- id: n.id,
3796
- type: "PRODUCT",
3797
- name: n.name,
3798
- amount: 1,
3799
- price: n.price,
3800
- originalPrice: n.price,
3801
- serviceFee: n.serviceFee
3802
- });
3803
- else i !== -1 && e.order.items.splice(i, 1);
4059
+ }
4060
+ }
4061
+ count
4062
+ }
4063
+ }
4064
+ `, Dn = (e, t, n, i) => e();
4065
+ function xn(e, t = Dn) {
4066
+ return {
4067
+ findAllPublicPackagesByOrganizationId(n, i, r) {
4068
+ return t((s) => e.request({ document: Tn, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "findAllPublicPackagesByOrganizationId", "query", n);
3804
4069
  },
3805
- configureCustomer: (e, t) => {
3806
- e.order && (e.order.customer = t.payload);
4070
+ findPublicPackageById(n, i, r) {
4071
+ return t((s) => e.request({ document: On, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "findPublicPackageById", "query", n);
3807
4072
  },
3808
- clearBasket: () => Ee
3809
- }
3810
- }), {
3811
- setProcessing: C,
3812
- initializeOrder: j,
3813
- addProduct: ye,
3814
- removeProduct: Sn,
3815
- configurePackage: ve,
3816
- configureDelivery: Cn,
3817
- configureCustomer: Ae,
3818
- reserveAdditionalPackageItem: _n,
3819
- clearBasket: Te
3820
- } = Je.actions;
3821
- class Xe {
3822
- orderIdKey = "ORDER_ID";
4073
+ findPublicItemsByPackageId(n, i, r) {
4074
+ return t((s) => e.request({ document: kn, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "findPublicItemsByPackageId", "query", n);
4075
+ }
4076
+ };
4077
+ }
4078
+ class Nn {
3823
4079
  config;
3824
4080
  sdk;
3825
- store;
3826
4081
  constructor(t) {
3827
- this.config = t, this.store = Ze({
3828
- reducer: {
3829
- basket: Je.reducer
3830
- }
3831
- }), this.sdk = Pn(new ae(t.apiUrl)), this.restoreOrderFromSession().then(() => {
3832
- this.debugLog("Restore order from session");
3833
- });
3834
- }
3835
- // Store functions
3836
- subscribe(t) {
3837
- return this.store.subscribe(t);
3838
- }
3839
- getCurrentOrder() {
3840
- const t = this.getState();
3841
- if (!t.order)
3842
- return null;
3843
- const n = t.order.items.reduce((i, r) => i + (r.amount || 0), 0);
3844
- return {
3845
- ...t.order,
3846
- count: n
3847
- };
4082
+ this.config = t, this.sdk = xn(new ue(t.apiUrl));
3848
4083
  }
3849
- getSelectedPackageEvent() {
3850
- return this.getState().order?.items.flatMap((n) => n.packageItems?.map((i) => i.eventId) ?? []) ?? [];
4084
+ debugLog(t, n) {
4085
+ this.config.debug && console.log(`[PackageService] ${t}`, n || "");
3851
4086
  }
3852
- // Basket update functions
3853
- async addProduct(t) {
3854
- this.store.dispatch(C(!0));
4087
+ async getPackages(t = {}) {
3855
4088
  try {
3856
- const i = this.getState().order?.id ?? sessionStorage.getItem(this.orderIdKey) ?? this.generateOrderId();
3857
- this.debugLog("Adding product", {
3858
- productId: t.id,
3859
- orderId: i,
3860
- amount: t.amount,
3861
- seat: t.seat
4089
+ let n;
4090
+ t.page && (n = {
4091
+ index: t.page.index ?? 0,
4092
+ size: t.page.size ?? 20
4093
+ }), this.debugLog("Fetching public packages", {
4094
+ organizationId: this.config.organizationId,
4095
+ page: n,
4096
+ tab: t.tab,
4097
+ statuses: t.statuses
3862
4098
  });
3863
- const r = await this.sdk.addToOrder({
3864
- productId: t.id,
3865
- orderId: i,
3866
- additionalData: t.seat ? {
3867
- seat: {
3868
- seatId: t.seat.id,
3869
- seatLabel: t.seat.label,
3870
- holdToken: t.seat.holdToken
3871
- }
3872
- } : null,
3873
- trackerId: this.config.trackerId,
3874
- shopId: this.config.shopId,
3875
- amount: t.amount
4099
+ const i = await this.sdk.findAllPublicPackagesByOrganizationId({
4100
+ organizationId: this.config.organizationId
3876
4101
  });
3877
- if (r?.reserveProduct) {
3878
- const { orderId: s, expiredAt: o, amountReserved: u } = r.reserveProduct;
3879
- this.debugLog("Product added successfully", r.reserveProduct), sessionStorage.setItem(this.orderIdKey, i), this.store.dispatch(
3880
- j({
3881
- id: s,
3882
- currency: t.currency,
3883
- expiredAt: o
3884
- })
3885
- ), this.store.dispatch(
3886
- ye({
3887
- input: t,
3888
- amountReserved: u,
3889
- expiredAt: o
3890
- })
3891
- );
4102
+ if (i?.findAllPublicPackagesByOrganizationId) {
4103
+ const r = i.findAllPublicPackagesByOrganizationId;
4104
+ return this.debugLog("Public packages fetched", {
4105
+ count: r.count,
4106
+ dataLength: r.data.length
4107
+ }), r;
3892
4108
  }
4109
+ return null;
3893
4110
  } catch (n) {
3894
- throw this.debugLog("Error adding product", n), this.handleError(n), n;
3895
- } finally {
3896
- this.store.dispatch(C(!1));
3897
- }
3898
- }
3899
- async removeProduct(t) {
3900
- const i = this.getState().order;
3901
- if (i) {
3902
- this.store.dispatch(C(!0));
3903
- try {
3904
- this.debugLog("Removing product", {
3905
- productId: t.id,
3906
- orderId: i.id,
3907
- amount: t.amount
3908
- });
3909
- const r = await this.sdk.removeFromOrder({
3910
- productId: t.id,
3911
- orderId: i.id,
3912
- additionalData: t.seat ? {
3913
- seat: {
3914
- seatId: t.seat.id,
3915
- seatLabel: t.seat.label
3916
- }
3917
- } : null,
3918
- amount: t.amount
3919
- });
3920
- if (r?.releaseProduct) {
3921
- const { amountReleased: s } = r.releaseProduct;
3922
- this.debugLog("Product removed successfully", r.releaseProduct), this.store.dispatch(
3923
- Sn({
3924
- id: t.id,
3925
- amountReleased: s,
3926
- seatId: t.seat?.id
3927
- })
3928
- );
3929
- const o = this.getState();
3930
- (!o.order || o.order.items.length === 0) && (this.debugLog("Basket is now empty, cancelling order and clearing session"), await this.cancelOrder());
3931
- }
3932
- } catch (r) {
3933
- throw this.debugLog("Error removing product", r), this.handleError(r), r;
3934
- } finally {
3935
- this.store.dispatch(C(!1));
3936
- }
4111
+ throw this.debugLog("Error fetching public packages", n), n;
3937
4112
  }
3938
4113
  }
3939
- async configurePackage(t) {
3940
- this.store.dispatch(C(!0));
4114
+ async getPackage(t) {
3941
4115
  try {
3942
- const i = this.store.getState().basket.order?.id ?? sessionStorage.getItem(this.orderIdKey) ?? this.generateOrderId(), r = t.items.map((o) => ({
3943
- packageItemId: o.packageItemId,
3944
- eventId: o.eventId
3945
- }));
3946
- this.debugLog("Configuring package", {
3947
- packageId: t.id,
3948
- orderId: i,
3949
- amount: t.amount,
3950
- items: r,
3951
- shopId: this.config.shopId
3952
- });
3953
- const s = await this.sdk.configurePackage({
3954
- trackerId: this.config.trackerId,
3955
- shopId: this.config.shopId,
3956
- packageId: t.id,
3957
- orderId: i,
3958
- amount: t.amount,
3959
- items: r
4116
+ this.debugLog("Fetching public packages", {
4117
+ packageId: t
3960
4118
  });
3961
- if (this.debugLog("Configure package response", s), s?.configurePackage && s.configurePackage.amountReserved > 0) {
3962
- const { orderId: o, expiredAt: u, amountReserved: h } = s.configurePackage;
3963
- return this.debugLog("Package configured successfully"), sessionStorage.setItem(this.orderIdKey, i), this.store.dispatch(
3964
- j({
3965
- id: o,
3966
- currency: t.currency,
3967
- expiredAt: u
3968
- })
3969
- ), this.store.dispatch(
3970
- ve({
3971
- input: t,
3972
- amountReserved: h,
3973
- expiredAt: u
3974
- })
3975
- ), null;
3976
- } else
3977
- return this.debugLog("Package configuration failed - no amount reserved"), { error: "Failed to configure package - no items reserved" };
3978
- } catch (n) {
3979
- return this.debugLog("Error configuring package", n), this.handleError(n), { error: n };
3980
- } finally {
3981
- this.store.dispatch(C(!1));
3982
- }
3983
- }
3984
- async configureDelivery(t) {
3985
- this.store.dispatch(C(!0));
3986
- try {
3987
- this.store.dispatch(Cn(t));
4119
+ const n = await this.sdk.findPublicPackageById({ packageId: t });
4120
+ if (n?.findPublicPackageById) {
4121
+ const i = n.findPublicPackageById;
4122
+ return this.debugLog("Public package fetched"), i;
4123
+ }
4124
+ return null;
3988
4125
  } catch (n) {
3989
- throw this.debugLog("Error setting delivery", n), this.handleError(n), n;
3990
- } finally {
3991
- this.store.dispatch(C(!1));
3992
- }
3993
- }
3994
- async configureCustomer(t) {
3995
- const i = this.getState().order;
3996
- if (!i)
3997
- throw new Error("No active order. Add items to basket first.");
3998
- this.debugLog("Creating/replacing customer", { orderId: i.id, email: t.email });
3999
- try {
4000
- const r = await this.sdk.createOrderCustomer({
4001
- orderId: i.id,
4002
- customer: t
4003
- });
4004
- this.debugLog("Customer set successfully", r), this.store.dispatch(Ae(t));
4005
- } catch (r) {
4006
- throw this.debugLog("Failed to set customer", r), new Error(`Failed to set customer: ${r.message}`);
4126
+ throw this.debugLog("Error fetching public packages", n), n;
4007
4127
  }
4008
4128
  }
4009
- async reserveAdditionalPackageItem(t) {
4010
- this.store.dispatch(C(!0));
4129
+ async getPackageItems(t, n = [Q.Regular, Q.AdditionalEvent]) {
4011
4130
  try {
4012
- const i = this.store.getState().basket.order?.id ?? sessionStorage.getItem(this.orderIdKey) ?? this.generateOrderId();
4013
- this.debugLog("reserve additional packageItem", {
4014
- orderId: i,
4015
- eventId: t.eventId,
4016
- amount: t.amount,
4017
- packageId: t.packageId,
4018
- packageItemId: t.packageItemId
4019
- });
4020
- const r = await this.sdk.reserveAdditionalPackageItem({
4021
- orderId: i,
4022
- eventId: t.eventId,
4023
- amount: t.amount,
4024
- packageId: t.packageId,
4025
- packageItemId: t.packageItemId
4131
+ this.debugLog("Fetching public package items", { packageId: t, types: n });
4132
+ const i = await this.sdk.findPublicItemsByPackageId({
4133
+ packageId: t,
4134
+ types: n,
4135
+ page: { index: 0, size: 100 }
4026
4136
  });
4027
- if (this.debugLog("reserve additional packageItem", r), r?.reserveAdditionalPackageItem && r.reserveAdditionalPackageItem.amountReserved > 0) {
4028
- const { orderId: s, expiredAt: o, amountReserved: u } = r.reserveAdditionalPackageItem;
4029
- return this.debugLog("Reserve configured successfully"), sessionStorage.setItem(this.orderIdKey, i), this.store.dispatch(
4030
- j({
4031
- id: s,
4032
- currency: t.currency,
4033
- expiredAt: o
4034
- })
4035
- ), this.store.dispatch(
4036
- _n({
4037
- input: t,
4038
- amountReserved: u,
4039
- expiredAt: o
4040
- })
4041
- ), null;
4042
- } else
4043
- return this.debugLog("Package configuration failed - no amount reserved"), { error: "Failed to configure package - no items reserved" };
4044
- } catch (n) {
4045
- return this.debugLog("Error configuring package", n), this.handleError(n), { error: n };
4046
- } finally {
4047
- this.store.dispatch(C(!1));
4137
+ if (i?.findPublicItemsByPackageId) {
4138
+ const r = i.findPublicItemsByPackageId;
4139
+ return this.debugLog("Public package items fetched", {
4140
+ count: r.count,
4141
+ dataLength: r.data.length
4142
+ }), r;
4143
+ }
4144
+ return null;
4145
+ } catch (i) {
4146
+ throw this.debugLog("Error fetching public package items", i), i;
4048
4147
  }
4049
4148
  }
4050
- // Cancel and clear order functions
4051
- async cancelOrder() {
4052
- const t = sessionStorage.getItem(this.orderIdKey);
4053
- t && (this.debugLog("Cancelling order", { orderId: t }), await this.sdk.deleteOrder({ orderId: t }), this.clearOrderFromSession(), this.debugLog("Order cancelled successfully"));
4149
+ }
4150
+ const bn = E`
4151
+ query findAllPublicCategoriesByOrganizationId($organizationId: ID!, $dateRange: DateRangeInput) {
4152
+ findAllPublicHostingsByOrganizationId(id: $organizationId) {
4153
+ data {
4154
+ id
4155
+ name
4156
+ icon
4157
+ amountOfActiveEvents(input: $dateRange)
4158
+ }
4159
+ count
4054
4160
  }
4055
- clearOrderFromSession() {
4056
- this.debugLog("Clearing order from session"), sessionStorage.removeItem(this.orderIdKey), this.store.dispatch(Te());
4161
+ }
4162
+ `, Pn = E`
4163
+ query findPublicCategoryById($hostingId: ID!, $dateRange: DateRangeInput) {
4164
+ findPublicHostingById(id: $hostingId) {
4165
+ id
4166
+ name
4167
+ icon
4168
+ amountOfActiveEvents(input: $dateRange)
4057
4169
  }
4058
- // Private functions for fetching the current order from a session
4059
- async restoreOrderFromSession() {
4060
- const t = sessionStorage.getItem(this.orderIdKey);
4061
- if (t) {
4062
- this.debugLog("Found existing order ID in session, restoring...", { orderId: t });
4063
- try {
4064
- await this.fetchOrder(t), this.debugLog("Order restored successfully");
4065
- } catch (n) {
4066
- this.debugLog("Failed to restore order, clearing session", n), this.clearOrderFromSession();
4067
- }
4170
+ }
4171
+ `, Sn = (e, t, n, i) => e();
4172
+ function Cn(e, t = Sn) {
4173
+ return {
4174
+ findAllPublicCategoriesByOrganizationId(n, i, r) {
4175
+ return t((s) => e.request({ document: bn, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "findAllPublicCategoriesByOrganizationId", "query", n);
4176
+ },
4177
+ findPublicCategoryById(n, i, r) {
4178
+ return t((s) => e.request({ document: Pn, variables: n, requestHeaders: { ...i, ...s }, signal: r }), "findPublicCategoryById", "query", n);
4068
4179
  }
4180
+ };
4181
+ }
4182
+ class _n {
4183
+ config;
4184
+ sdk;
4185
+ constructor(t) {
4186
+ this.config = t, this.sdk = Cn(new ue(t.apiUrl));
4069
4187
  }
4070
- async fetchOrder(t) {
4071
- this.debugLog("Fetching order from server", { orderId: t });
4188
+ debugLog(t, n) {
4189
+ this.config.debug && console.log(`[CategoryService] ${t}`, n || "");
4190
+ }
4191
+ async getCategories(t) {
4072
4192
  try {
4073
- const n = await this.sdk.findActiveOrderById({ id: t });
4074
- if (!n?.findOrder) {
4075
- this.debugLog("Order not found"), this.clearOrderFromSession();
4076
- return;
4077
- }
4078
- const i = n.findOrder;
4079
- this.debugLog("Order fetched successfully", i);
4080
- const r = i.items, s = r.filter((c) => c.product != null && c.amount > 0).map((c) => {
4081
- let m = _.PRODUCT;
4082
- return c.product.type === "PROMOTER" ? m = _.ADD_ONS : c.product.type === "PICKUP" ? m = _.PICKUP : c.product.type === "DELIVERY" && (m = _.DELIVERY), {
4083
- id: c.product.id,
4084
- type: m,
4085
- name: c.product.name,
4086
- icon: c.product.icon,
4087
- description: c.product.description,
4088
- amount: c.amount,
4089
- price: c.price ?? 0,
4090
- depositPrice: c.depositPrice ?? 0,
4091
- originalPrice: c.originalPrice ?? 0,
4092
- serviceFee: c.serviceFee ?? 0,
4093
- seats: c.seats?.map((g) => ({
4094
- id: g.id,
4095
- label: g.label
4096
- }))
4097
- };
4098
- }), o = r.filter((c) => c.packageItem != null && c.amount > 0).reduce((c, m) => {
4099
- const {
4100
- packageItem: g,
4101
- event: y,
4102
- amount: I,
4103
- price: O,
4104
- serviceFee: x,
4105
- depositPrice: k,
4106
- originalPrice: L
4107
- } = m, T = g.package.id;
4108
- c[T] ? (c[T].price += O ?? 0, c[T].serviceFee += x ?? 0, c[T].originalPrice += L ?? 0, c[T].depositPrice += k ?? O ?? 0) : c[T] = {
4109
- id: T,
4110
- type: _.PACKAGE,
4111
- name: g.package.name,
4112
- amount: I,
4113
- price: O ?? 0,
4114
- serviceFee: x ?? 0,
4115
- depositPrice: k ?? O ?? 0,
4116
- originalPrice: L ?? 0,
4117
- packageItems: []
4118
- };
4119
- const N = R.fromISO(y.startAt, {
4120
- zone: y.timezone
4121
- }), D = R.fromISO(y.endAt, {
4122
- zone: y.timezone
4123
- });
4124
- return c[T].packageItems.push({
4125
- packageItemId: g.id,
4126
- eventId: y.id,
4127
- name: y.name,
4128
- startAt: N.toJSDate().toISOString(),
4129
- endAt: D.toJSDate().toISOString()
4130
- }), c;
4131
- }, {}), u = [
4132
- ...s,
4133
- ...Object.values(o)
4134
- ];
4135
- if (u.length === 0) {
4136
- this.debugLog("All order items have zero or negative amounts, clearing session"), this.clearOrderFromSession();
4137
- return;
4138
- }
4139
- const h = r.filter((c) => c.amount > 0).map((c) => new Date(c.expiredAt).getTime());
4140
- if (h.length === 0) {
4141
- this.debugLog("No valid items with expiration times, clearing session"), this.clearOrderFromSession();
4142
- return;
4193
+ this.debugLog("Fetching all categories", { organizationId: this.config.organizationId });
4194
+ const n = await this.sdk.findAllPublicCategoriesByOrganizationId({ organizationId: this.config.organizationId, dateRange: t });
4195
+ if (n?.findAllPublicHostingsByOrganizationId) {
4196
+ const i = n.findAllPublicHostingsByOrganizationId;
4197
+ return this.debugLog("Categories fetched", { count: i.count, dataLength: i.data.length }), i.data.map((r) => ({ id: r.id, name: r.name, icon: r.icon, activeEvents: r.amountOfActiveEvents }));
4143
4198
  }
4144
- const p = R.fromMillis(Math.min(...h));
4145
- this.store.dispatch(Te()), this.store.dispatch(
4146
- j({
4147
- id: i.id,
4148
- currency: i.currency,
4149
- expiredAt: p.toJSDate().toISOString()
4150
- })
4151
- ), u.forEach((c) => {
4152
- c.type === _.PACKAGE ? this.store.dispatch(
4153
- ve({
4154
- input: {
4155
- id: c.id,
4156
- name: c.name,
4157
- currency: i.currency,
4158
- price: c.originalPrice ?? 0,
4159
- depositPrice: c.depositPrice,
4160
- serviceFee: c.serviceFee ?? 0,
4161
- amount: c.amount,
4162
- items: c.packageItems || []
4163
- },
4164
- amountReserved: c.amount,
4165
- expiredAt: p.toJSDate().toISOString()
4166
- })
4167
- ) : this.store.dispatch(
4168
- ye({
4169
- input: {
4170
- id: c.id,
4171
- name: c.name,
4172
- price: c.originalPrice,
4173
- depositPrice: c.depositPrice,
4174
- serviceFee: c.serviceFee,
4175
- currency: i.currency,
4176
- amount: c.amount
4177
- },
4178
- amountReserved: c.amount,
4179
- expiredAt: p.toJSDate().toISOString()
4180
- })
4181
- );
4182
- }), i.mainBooker && (this.debugLog("Order has customer (mainBooker)", i.mainBooker), this.store.dispatch(
4183
- Ae({
4184
- firstName: i.mainBooker.firstName ?? void 0,
4185
- lastName: i.mainBooker.lastName ?? void 0,
4186
- email: i.mainBooker.email ?? void 0,
4187
- age: i.mainBooker.age ?? void 0,
4188
- gender: i.mainBooker.gender ?? void 0,
4189
- residence: i.mainBooker.residence ?? void 0,
4190
- extraInfo: i.mainBooker.extraInfo ?? void 0
4191
- })
4192
- )), this.debugLog("Order state fully synced", this.getState());
4199
+ return [];
4193
4200
  } catch (n) {
4194
- throw this.debugLog("Error fetching order", n), n;
4201
+ throw this.debugLog("Error fetching categories", n), n;
4195
4202
  }
4196
4203
  }
4197
- // Private helper functions
4198
- generateOrderId() {
4199
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
4200
- const n = Math.random() * 16 | 0;
4201
- return (t === "x" ? n : n & 3 | 8).toString(16);
4202
- });
4203
- }
4204
- debugLog(t, n) {
4205
- this.config.debug && console.log(`[BasketService] ${t}`, n || "");
4206
- }
4207
- handleError(t) {
4208
- const n = t;
4209
- if (n.graphQLErrors && n.graphQLErrors.length > 0) {
4210
- const i = n.graphQLErrors[0];
4211
- i.extensions?.status === "RATE_LIMIT" && console.error("Rate Limit reached"), i.extensions?.status === "SOLD_OUT" && console.error("Product sold out");
4212
- }
4213
- if (n.response?.errors && n.response.errors.length > 0) {
4214
- const i = n.response.errors[0];
4215
- console.error("GraphQL Error:", i.message), i.extensions?.code && console.error("Error Code:", i.extensions.code);
4204
+ async getCategory(t) {
4205
+ try {
4206
+ this.debugLog("Fetching category", { categoryId: t });
4207
+ const n = await this.sdk.findPublicCategoryById({ hostingId: t });
4208
+ if (n?.findPublicHostingById) {
4209
+ const i = n.findPublicHostingById;
4210
+ return this.debugLog("Category fetched", i), { id: i.id, name: i.name, icon: i.icon, activeEvents: i.amountOfActiveEvents };
4211
+ }
4212
+ return null;
4213
+ } catch (n) {
4214
+ throw this.debugLog("Error fetching category", n), n;
4216
4215
  }
4217
4216
  }
4218
- getState() {
4219
- return this.store.getState().basket;
4220
- }
4221
4217
  }
4222
4218
  const Ln = "https://api.ticketapp.com/graphql", Oe = "TIC_TRACKER_ID";
4223
4219
  class $n {
@@ -4227,10 +4223,10 @@ class $n {
4227
4223
  package;
4228
4224
  category;
4229
4225
  // Attach selected public types to the SDK class
4230
- static Types = yn;
4226
+ static Types = Je;
4231
4227
  constructor(t) {
4232
4228
  const { organizationId: n, debug: i = !1, apiUrl: r = Ln } = t, s = this.getOrInitTrackerId();
4233
- this.basket = new Xe({ debug: i, apiUrl: r, shopId: t.shopId, trackerId: s }), this.event = new we({ organizationId: n, debug: i, apiUrl: r, trackerId: s }), this.payment = new $e({ debug: i, apiUrl: r }), this.package = new Be({ organizationId: n, debug: i, apiUrl: r }), this.category = new Ue({ organizationId: n, debug: i, apiUrl: r });
4229
+ this.basket = new an({ debug: i, apiUrl: r, shopId: t.shopId, trackerId: s }), this.event = new gn({ organizationId: n, debug: i, apiUrl: r, trackerId: s }), this.payment = new An({ debug: i, apiUrl: r }), this.package = new Nn({ organizationId: n, debug: i, apiUrl: r }), this.category = new _n({ organizationId: n, debug: i, apiUrl: r });
4234
4230
  }
4235
4231
  // Resolve tracker id from (in order): explicit config, URL query, or session storage
4236
4232
  // Persist to session when found via config or URL for subsequent page loads
@@ -4262,20 +4258,15 @@ class $n {
4262
4258
  }
4263
4259
  export {
4264
4260
  _ as BasketOrderType,
4265
- Xe as BasketService,
4266
- Ue as CategoryService,
4267
- Qe as DiscountType,
4268
- we as EventService,
4269
- qe as EventStatus,
4270
- He as OrderItemType,
4271
- X as PackageItemType,
4272
- Be as PackageService,
4273
- Ve as PackageStatus,
4274
- Me as PackageTabType,
4275
- Ye as PaymentMethodFeeType,
4276
- $e as PaymentService,
4277
- je as ProductStatus,
4278
- Ge as ProductType,
4279
- ze as SortOrder,
4261
+ _e as DiscountType,
4262
+ xe as EventStatus,
4263
+ Ce as OrderItemType,
4264
+ Q as PackageItemType,
4265
+ ke as PackageStatus,
4266
+ De as PackageTabType,
4267
+ Se as PaymentMethodFeeType,
4268
+ be as ProductStatus,
4269
+ Pe as ProductType,
4270
+ Ne as SortOrder,
4280
4271
  $n as TicketappSDK
4281
4272
  };