@gomusdev/web-components 1.20.0 → 1.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist-js/components/cart/mocks/gomusTicketMocks.d.ts +107 -10
  2. package/dist-js/components/cart/mocks/testCart.d.ts +1 -1
  3. package/dist-js/components/link/Link.svelte.d.ts +1 -0
  4. package/dist-js/components/link/entry.d.ts +0 -0
  5. package/dist-js/components/ticketSelection/TicketSelectionDetails.svelte.d.ts +6 -7
  6. package/dist-js/components/ticketSelection/subcomponents/calendar/lib/calendar.svelte.d.ts +24 -8
  7. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/TicketSegment.svelte.d.ts +1 -767
  8. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/TicketSegmentDetails.svelte.d.ts +1027 -0
  9. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/utils.svelte.d.ts +2 -7
  10. package/dist-js/gomus-webcomponents.css +9 -2
  11. package/dist-js/gomus-webcomponents.iife.js +752 -488
  12. package/dist-js/gomus-webcomponents.js +752 -488
  13. package/dist-js/lib/helpers/context.svelte.d.ts +1 -0
  14. package/dist-js/lib/models/cart/CartEvents.svelte.d.ts +1 -0
  15. package/dist-js/lib/models/cart/CartItem.d.ts +37 -0
  16. package/dist-js/lib/models/cart/cart.svelte.d.ts +191 -0
  17. package/dist-js/lib/models/cart/cart.svelte.spec.d.ts +1 -0
  18. package/dist-js/lib/models/cart/localStorage.spec.d.ts +1 -0
  19. package/dist-js/lib/models/cart/localStorage.svelte.d.ts +46 -0
  20. package/dist-js/lib/models/cart/selectOptions.d.ts +10 -0
  21. package/dist-js/lib/models/cart/selectOptions.spec.d.ts +1 -0
  22. package/dist-js/lib/models/cart/types.d.ts +13 -0
  23. package/dist-js/lib/models/scalePrice/UIScaledPrice.spec.d.ts +1 -0
  24. package/dist-js/lib/models/scalePrice/UIScaledPrice.svelte.d.ts +51 -0
  25. package/dist-js/lib/models/ticket/UITicket.spec.d.ts +1 -0
  26. package/dist-js/lib/{gomusTicket.svelte.d.ts → models/ticket/UITicket.svelte.d.ts} +109 -11
  27. package/dist-js/lib/stores/shop.svelte.d.ts +41 -0
  28. package/dist-js/lib/vitest/msw/handlers.d.ts +1 -1
  29. package/dist-js/mocks/MSWMocks.d.ts +3 -0
  30. package/dist-js/mocks/ScalingPricesMocks.d.ts +24 -0
  31. package/dist-js/mocks/mocks.d.ts +1324 -695
  32. package/package.json +1 -1
  33. package/dist-js/components/cart/lib/CartEvents.svelte.d.ts +0 -1
  34. package/dist-js/components/cart/lib/CartItem.d.ts +0 -135
  35. package/dist-js/components/cart/lib/cart.svelte.d.ts +0 -616
  36. package/dist-js/components/cart/lib/localStorage.svelte.d.ts +0 -146
  37. /package/dist-js/components/{cart/lib/CartEvents.spec.d.ts → donations/components/Donations.spec.d.ts} +0 -0
  38. /package/dist-js/components/{cart/lib/cart.svelte.spec.d.ts → link/Link.spec.d.ts} +0 -0
  39. /package/dist-js/components/{cart/lib/localStorage.spec.d.ts → ticketSelection/subcomponents/tickets/subcomponents/segment/TicketSegment.spec.d.ts} +0 -0
  40. /package/dist-js/lib/{gomusTicket.spec.d.ts → models/cart/CartEvents.spec.d.ts} +0 -0
@@ -5484,6 +5484,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
5484
5484
  }
5485
5485
  #data = /* @__PURE__ */ state(proxy({ value: void 0 }));
5486
5486
  error = false;
5487
+ // creates a DetailsWrapper with a static value
5488
+ static static(data) {
5489
+ const ret = new DetailsWrapper(null, null);
5490
+ ret.value = data;
5491
+ return ret;
5492
+ }
5487
5493
  load() {
5488
5494
  pollUntilTruthy(
5489
5495
  () => {
@@ -5565,6 +5571,254 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
5565
5571
  const groups = shop.settings?.multipleToursMenuItems.tour_groups[id] || [];
5566
5572
  return `/#/products/tours?category_id=${groups.join("&category_id=")}`;
5567
5573
  }
5574
+ const isArray = Array.isArray;
5575
+ const isObject$2 = (value) => {
5576
+ return !!value && value.constructor === Object;
5577
+ };
5578
+ const isString = (value) => {
5579
+ return typeof value === "string" || value instanceof String;
5580
+ };
5581
+ const isNumber = (value) => {
5582
+ try {
5583
+ return Number(value) === value;
5584
+ } catch {
5585
+ return false;
5586
+ }
5587
+ };
5588
+ function sum(array2, fn) {
5589
+ return (array2 || []).reduce((acc, item) => acc + (fn ? fn(item) : item), 0);
5590
+ }
5591
+ const sort = (array2, getter, desc = false) => {
5592
+ if (!array2)
5593
+ return [];
5594
+ const asc = (a2, b) => getter(a2) - getter(b);
5595
+ const dsc = (a2, b) => getter(b) - getter(a2);
5596
+ return array2.slice().sort(desc === true ? dsc : asc);
5597
+ };
5598
+ const alphabetical = (array2, getter, dir = "asc") => {
5599
+ if (!array2)
5600
+ return [];
5601
+ const asc = (a2, b) => `${getter(a2)}`.localeCompare(getter(b));
5602
+ const dsc = (a2, b) => `${getter(b)}`.localeCompare(getter(a2));
5603
+ return array2.slice().sort(dir === "desc" ? dsc : asc);
5604
+ };
5605
+ const iterate = (count, func, initValue) => {
5606
+ let value = initValue;
5607
+ for (let i = 1; i <= count; i++) {
5608
+ value = func(value, i);
5609
+ }
5610
+ return value;
5611
+ };
5612
+ const omit = (obj, keys2) => {
5613
+ if (!obj)
5614
+ return {};
5615
+ if (!keys2 || keys2.length === 0)
5616
+ return obj;
5617
+ return keys2.reduce(
5618
+ (acc, key) => {
5619
+ delete acc[key];
5620
+ return acc;
5621
+ },
5622
+ { ...obj }
5623
+ );
5624
+ };
5625
+ const assign = (initial, override) => {
5626
+ if (!initial || !override)
5627
+ return initial ?? override ?? {};
5628
+ return Object.entries({ ...initial, ...override }).reduce(
5629
+ (acc, [key, value]) => {
5630
+ return {
5631
+ ...acc,
5632
+ [key]: (() => {
5633
+ if (isObject$2(initial[key]))
5634
+ return assign(initial[key], value);
5635
+ return value;
5636
+ })()
5637
+ };
5638
+ },
5639
+ {}
5640
+ );
5641
+ };
5642
+ class Auth {
5643
+ #data = {
5644
+ uid: "",
5645
+ client: "",
5646
+ accessToken: "",
5647
+ expiry: 0
5648
+ // Unix time (seconds)
5649
+ };
5650
+ constructor() {
5651
+ setInterval(() => this.load(), 1e3);
5652
+ }
5653
+ customerLevel() {
5654
+ if (this.isGuest()) return 10;
5655
+ if (this.isLoggedIn()) return 20;
5656
+ return void 0;
5657
+ }
5658
+ isAuthenticated() {
5659
+ return this.#data.uid !== "";
5660
+ }
5661
+ isLoggedIn() {
5662
+ return Boolean(this.#data.uid && isEmail(this.#data.uid));
5663
+ }
5664
+ isGuest() {
5665
+ return Boolean(this.#data.uid && !isEmail(this.#data.uid));
5666
+ }
5667
+ // This should be manually called whenever we are signing out
5668
+ signOut() {
5669
+ this.#data.uid = "";
5670
+ this.#data.client = "";
5671
+ this.#data.accessToken = "";
5672
+ this.#data.expiry = 0;
5673
+ this.save();
5674
+ }
5675
+ // This happens automatically via the AuthMiddleware
5676
+ signIn(options) {
5677
+ this.#data.uid = options.uid;
5678
+ this.#data.client = options.client;
5679
+ this.#data.accessToken = options.accessToken;
5680
+ this.#data.expiry = options.expiry;
5681
+ this.save();
5682
+ }
5683
+ get data() {
5684
+ if (this.#data.expiry < Math.floor(Date.now() / 1e3)) {
5685
+ this.signOut();
5686
+ }
5687
+ return this.#data;
5688
+ }
5689
+ toString() {
5690
+ return JSON.stringify(this.#data);
5691
+ }
5692
+ save() {
5693
+ localStorage.setItem("go-auth", this.toString());
5694
+ }
5695
+ load() {
5696
+ const str = localStorage.getItem("go-auth");
5697
+ if (!str) {
5698
+ this.signOut();
5699
+ return;
5700
+ }
5701
+ const d = JSON.parse(str);
5702
+ if (!(isObject$2(d) && "uid" in d && "client" in d && "accessToken" in d && "expiry" in d)) {
5703
+ throw new Error(`(Auth.loadFromString) invalid auth json ${str}`);
5704
+ }
5705
+ this.signIn(d);
5706
+ }
5707
+ }
5708
+ const auth = new Auth();
5709
+ class AuthMiddleware {
5710
+ constructor(auth2) {
5711
+ this.auth = auth2;
5712
+ }
5713
+ /**
5714
+ * Intercepts and modifies outgoing HTTP requests by adding authentication headers.
5715
+ */
5716
+ onRequest({ request }) {
5717
+ const { uid, client: client2, accessToken, expiry } = this.auth.data;
5718
+ const h = request.headers;
5719
+ if (uid && !h.has("uid")) h.set("uid", uid);
5720
+ if (client2 && !h.has("client")) h.set("client", client2);
5721
+ if (accessToken && !h.has("access-token")) h.set("access-token", accessToken);
5722
+ if (expiry && !h.has("expiry")) h.set("expiry", String(expiry));
5723
+ if (accessToken && !h.has("token-type")) h.set("token-type", "Bearer");
5724
+ }
5725
+ /**
5726
+ * Intercepts HTTP responses and updates authentication state if new credentials are received.
5727
+ */
5728
+ onResponse({ response }) {
5729
+ const accessToken = response.headers.get("access-token");
5730
+ const client2 = response.headers.get("client");
5731
+ const uid = response.headers.get("uid");
5732
+ const expiry = parseInt(response.headers.get("expiry") || "");
5733
+ if (accessToken && client2 && uid && expiry) {
5734
+ this.auth.signIn({ uid, client: client2, accessToken, expiry });
5735
+ }
5736
+ return response;
5737
+ }
5738
+ }
5739
+ function getCookie(name) {
5740
+ if (typeof document === "undefined") {
5741
+ return void 0;
5742
+ }
5743
+ const value = `; ${document.cookie}`;
5744
+ const parts = value.split(`; ${name}=`);
5745
+ if (parts.length === 2) {
5746
+ const rawValue = parts.pop()?.split(";").shift();
5747
+ return rawValue ? decodeURIComponent(rawValue) : void 0;
5748
+ }
5749
+ return void 0;
5750
+ }
5751
+ class User {
5752
+ get isAuthenticated() {
5753
+ return this.isLoggedIn || this.isGuest;
5754
+ }
5755
+ }
5756
+ class AngularUser extends User {
5757
+ constructor() {
5758
+ super();
5759
+ }
5760
+ get isLoggedIn() {
5761
+ try {
5762
+ const raw = getCookie("auth_headers");
5763
+ if (!raw) return false;
5764
+ const auth2 = JSON.parse(raw);
5765
+ const now = Math.floor(Date.now() / 1e3);
5766
+ if (!auth2["access-token"]) return false;
5767
+ if (parseInt(auth2["expiry"], 10) < now) return false;
5768
+ return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(auth2["uid"]);
5769
+ } catch {
5770
+ return false;
5771
+ }
5772
+ }
5773
+ get isGuest() {
5774
+ if (this.isLoggedIn) return false;
5775
+ try {
5776
+ const raw = getCookie("auth_headers");
5777
+ if (!raw) return true;
5778
+ const auth2 = JSON.parse(raw);
5779
+ return typeof auth2["uid"] === "string" && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(auth2["uid"]);
5780
+ } catch {
5781
+ return true;
5782
+ }
5783
+ }
5784
+ }
5785
+ class JMBUser extends User {
5786
+ get isGuest() {
5787
+ throw new Error("Not implemented.");
5788
+ }
5789
+ get isLoggedIn() {
5790
+ throw new Error("Not implemented");
5791
+ }
5792
+ }
5793
+ const getUserProvider = (type) => {
5794
+ switch (type) {
5795
+ case "angular":
5796
+ return new AngularUser();
5797
+ case "jmb":
5798
+ return new JMBUser();
5799
+ default:
5800
+ let never = type;
5801
+ throw new Error("Unhandled shop type: " + never);
5802
+ }
5803
+ };
5804
+ function isEmpty(value) {
5805
+ return value === null || value === void 0 || typeof value === "string" && value.trim() === "";
5806
+ }
5807
+ function validateRequiredFields(body, requiredFields) {
5808
+ const errors2 = {};
5809
+ if (!requiredFields || requiredFields.length === 0) {
5810
+ return errors2;
5811
+ }
5812
+ for (const field of requiredFields) {
5813
+ if (!(field in body) || isEmpty(body[field])) {
5814
+ errors2[field] = [`Field '${field}' is required and cannot be empty`];
5815
+ }
5816
+ }
5817
+ return errors2;
5818
+ }
5819
+ function validateApiPostBody(body, requiredFields) {
5820
+ return validateRequiredFields(body, requiredFields);
5821
+ }
5568
5822
  const defaultErrorConfig = {
5569
5823
  withStackTrace: false
5570
5824
  };
@@ -6311,320 +6565,73 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
6311
6565
  nextURL = nextURL.replace(match, `;${serializePrimitiveParam(name, value)}`);
6312
6566
  continue;
6313
6567
  }
6314
- nextURL = nextURL.replace(match, style === "label" ? `.${encodeURIComponent(value)}` : encodeURIComponent(value));
6315
- }
6316
- return nextURL;
6317
- }
6318
- function defaultBodySerializer(body) {
6319
- if (body instanceof FormData) {
6320
- return body;
6321
- }
6322
- return JSON.stringify(body);
6323
- }
6324
- function createFinalURL(pathname, options) {
6325
- let finalURL = `${options.baseUrl}${pathname}`;
6326
- if (options.params?.path) {
6327
- finalURL = defaultPathSerializer(finalURL, options.params.path);
6328
- }
6329
- let search = options.querySerializer(options.params.query ?? {});
6330
- if (search.startsWith("?")) {
6331
- search = search.substring(1);
6332
- }
6333
- if (search) {
6334
- finalURL += `?${search}`;
6335
- }
6336
- return finalURL;
6337
- }
6338
- function mergeHeaders(...allHeaders) {
6339
- const finalHeaders = new Headers();
6340
- for (const h of allHeaders) {
6341
- if (!h || typeof h !== "object") {
6342
- continue;
6343
- }
6344
- const iterator = h instanceof Headers ? h.entries() : Object.entries(h);
6345
- for (const [k, v] of iterator) {
6346
- if (v === null) {
6347
- finalHeaders.delete(k);
6348
- } else if (Array.isArray(v)) {
6349
- for (const v2 of v) {
6350
- finalHeaders.append(k, v2);
6351
- }
6352
- } else if (v !== void 0) {
6353
- finalHeaders.set(k, v);
6354
- }
6355
- }
6356
- }
6357
- return finalHeaders;
6358
- }
6359
- function removeTrailingSlash(url) {
6360
- if (url.endsWith("/")) {
6361
- return url.substring(0, url.length - 1);
6362
- }
6363
- return url;
6364
- }
6365
- function client(publicApiUrl, shopUrl) {
6366
- return createClient({ baseUrl: `${publicApiUrl}`, headers: { "X-Shop-Url": shopUrl } });
6367
- }
6368
- const TICKETS_CALENDAR_ENDPOINT = "/api/v4/tickets/calendar";
6369
- const TICKET_AND_QUOTAS_ENDPOINT = "/api/v4/tickets/list_and_quotas";
6370
- const TICKETS_ENDPOINT = "/api/v4/tickets";
6371
- const SIGN_IN_ENDPOINT = "/api/v4/auth/sign_in";
6372
- const SIGN_UP_ENDPOINT = "/api/v4/auth";
6373
- const CustomerLevels = {
6374
- // NORMAL: 0,
6375
- // WIDGET: 5,
6376
- SHOP_GUEST: 10,
6377
- SHOP: 20
6378
- // CASH_POINT: 30,
6379
- };
6380
- const isArray = Array.isArray;
6381
- const isObject$2 = (value) => {
6382
- return !!value && value.constructor === Object;
6383
- };
6384
- const isString = (value) => {
6385
- return typeof value === "string" || value instanceof String;
6386
- };
6387
- const isNumber = (value) => {
6388
- try {
6389
- return Number(value) === value;
6390
- } catch {
6391
- return false;
6392
- }
6393
- };
6394
- function sum(array2, fn) {
6395
- return (array2 || []).reduce((acc, item) => acc + (fn ? fn(item) : item), 0);
6396
- }
6397
- const sort = (array2, getter, desc = false) => {
6398
- if (!array2)
6399
- return [];
6400
- const asc = (a2, b) => getter(a2) - getter(b);
6401
- const dsc = (a2, b) => getter(b) - getter(a2);
6402
- return array2.slice().sort(desc === true ? dsc : asc);
6403
- };
6404
- const alphabetical = (array2, getter, dir = "asc") => {
6405
- if (!array2)
6406
- return [];
6407
- const asc = (a2, b) => `${getter(a2)}`.localeCompare(getter(b));
6408
- const dsc = (a2, b) => `${getter(b)}`.localeCompare(getter(a2));
6409
- return array2.slice().sort(dir === "desc" ? dsc : asc);
6410
- };
6411
- const iterate = (count, func, initValue) => {
6412
- let value = initValue;
6413
- for (let i = 1; i <= count; i++) {
6414
- value = func(value, i);
6415
- }
6416
- return value;
6417
- };
6418
- const omit = (obj, keys2) => {
6419
- if (!obj)
6420
- return {};
6421
- if (!keys2 || keys2.length === 0)
6422
- return obj;
6423
- return keys2.reduce(
6424
- (acc, key) => {
6425
- delete acc[key];
6426
- return acc;
6427
- },
6428
- { ...obj }
6429
- );
6430
- };
6431
- const assign = (initial, override) => {
6432
- if (!initial || !override)
6433
- return initial ?? override ?? {};
6434
- return Object.entries({ ...initial, ...override }).reduce(
6435
- (acc, [key, value]) => {
6436
- return {
6437
- ...acc,
6438
- [key]: (() => {
6439
- if (isObject$2(initial[key]))
6440
- return assign(initial[key], value);
6441
- return value;
6442
- })()
6443
- };
6444
- },
6445
- {}
6446
- );
6447
- };
6448
- class Auth {
6449
- #data = {
6450
- uid: "",
6451
- client: "",
6452
- accessToken: "",
6453
- expiry: 0
6454
- // Unix time (seconds)
6455
- };
6456
- constructor() {
6457
- setInterval(() => this.load(), 1e3);
6458
- }
6459
- customerLevel() {
6460
- if (this.isGuest()) return 10;
6461
- if (this.isLoggedIn()) return 20;
6462
- return void 0;
6463
- }
6464
- isAuthenticated() {
6465
- return this.#data.uid !== "";
6466
- }
6467
- isLoggedIn() {
6468
- return Boolean(this.#data.uid && isEmail(this.#data.uid));
6469
- }
6470
- isGuest() {
6471
- return Boolean(this.#data.uid && !isEmail(this.#data.uid));
6472
- }
6473
- // This should be manually called whenever we are signing out
6474
- signOut() {
6475
- this.#data.uid = "";
6476
- this.#data.client = "";
6477
- this.#data.accessToken = "";
6478
- this.#data.expiry = 0;
6479
- this.save();
6480
- }
6481
- // This happens automatically via the AuthMiddleware
6482
- signIn(options) {
6483
- this.#data.uid = options.uid;
6484
- this.#data.client = options.client;
6485
- this.#data.accessToken = options.accessToken;
6486
- this.#data.expiry = options.expiry;
6487
- this.save();
6488
- }
6489
- get data() {
6490
- if (this.#data.expiry < Math.floor(Date.now() / 1e3)) {
6491
- this.signOut();
6492
- }
6493
- return this.#data;
6494
- }
6495
- toString() {
6496
- return JSON.stringify(this.#data);
6497
- }
6498
- save() {
6499
- localStorage.setItem("go-auth", this.toString());
6500
- }
6501
- load() {
6502
- const str = localStorage.getItem("go-auth");
6503
- if (!str) {
6504
- this.signOut();
6505
- return;
6506
- }
6507
- const d = JSON.parse(str);
6508
- if (!(isObject$2(d) && "uid" in d && "client" in d && "accessToken" in d && "expiry" in d)) {
6509
- throw new Error(`(Auth.loadFromString) invalid auth json ${str}`);
6510
- }
6511
- this.signIn(d);
6512
- }
6513
- }
6514
- const auth = new Auth();
6515
- class AuthMiddleware {
6516
- constructor(auth2) {
6517
- this.auth = auth2;
6518
- }
6519
- /**
6520
- * Intercepts and modifies outgoing HTTP requests by adding authentication headers.
6521
- */
6522
- onRequest({ request }) {
6523
- const { uid, client: client2, accessToken, expiry } = this.auth.data;
6524
- const h = request.headers;
6525
- if (uid && !h.has("uid")) h.set("uid", uid);
6526
- if (client2 && !h.has("client")) h.set("client", client2);
6527
- if (accessToken && !h.has("access-token")) h.set("access-token", accessToken);
6528
- if (expiry && !h.has("expiry")) h.set("expiry", String(expiry));
6529
- if (accessToken && !h.has("token-type")) h.set("token-type", "Bearer");
6530
- }
6531
- /**
6532
- * Intercepts HTTP responses and updates authentication state if new credentials are received.
6533
- */
6534
- onResponse({ response }) {
6535
- const accessToken = response.headers.get("access-token");
6536
- const client2 = response.headers.get("client");
6537
- const uid = response.headers.get("uid");
6538
- const expiry = parseInt(response.headers.get("expiry") || "");
6539
- if (accessToken && client2 && uid && expiry) {
6540
- this.auth.signIn({ uid, client: client2, accessToken, expiry });
6541
- }
6542
- return response;
6543
- }
6544
- }
6545
- function getCookie(name) {
6546
- if (typeof document === "undefined") {
6547
- return void 0;
6548
- }
6549
- const value = `; ${document.cookie}`;
6550
- const parts = value.split(`; ${name}=`);
6551
- if (parts.length === 2) {
6552
- const rawValue = parts.pop()?.split(";").shift();
6553
- return rawValue ? decodeURIComponent(rawValue) : void 0;
6554
- }
6555
- return void 0;
6556
- }
6557
- class User {
6558
- get isAuthenticated() {
6559
- return this.isLoggedIn || this.isGuest;
6560
- }
6561
- }
6562
- class AngularUser extends User {
6563
- constructor() {
6564
- super();
6565
- }
6566
- get isLoggedIn() {
6567
- try {
6568
- const raw = getCookie("auth_headers");
6569
- if (!raw) return false;
6570
- const auth2 = JSON.parse(raw);
6571
- const now = Math.floor(Date.now() / 1e3);
6572
- if (!auth2["access-token"]) return false;
6573
- if (parseInt(auth2["expiry"], 10) < now) return false;
6574
- return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(auth2["uid"]);
6575
- } catch {
6576
- return false;
6577
- }
6578
- }
6579
- get isGuest() {
6580
- if (this.isLoggedIn) return false;
6581
- try {
6582
- const raw = getCookie("auth_headers");
6583
- if (!raw) return true;
6584
- const auth2 = JSON.parse(raw);
6585
- return typeof auth2["uid"] === "string" && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(auth2["uid"]);
6586
- } catch {
6587
- return true;
6588
- }
6568
+ nextURL = nextURL.replace(match, style === "label" ? `.${encodeURIComponent(value)}` : encodeURIComponent(value));
6589
6569
  }
6570
+ return nextURL;
6590
6571
  }
6591
- class JMBUser extends User {
6592
- get isGuest() {
6593
- throw new Error("Not implemented.");
6594
- }
6595
- get isLoggedIn() {
6596
- throw new Error("Not implemented");
6572
+ function defaultBodySerializer(body) {
6573
+ if (body instanceof FormData) {
6574
+ return body;
6597
6575
  }
6576
+ return JSON.stringify(body);
6598
6577
  }
6599
- const getUserProvider = (type) => {
6600
- switch (type) {
6601
- case "angular":
6602
- return new AngularUser();
6603
- case "jmb":
6604
- return new JMBUser();
6605
- default:
6606
- let never = type;
6607
- throw new Error("Unhandled shop type: " + never);
6578
+ function createFinalURL(pathname, options) {
6579
+ let finalURL = `${options.baseUrl}${pathname}`;
6580
+ if (options.params?.path) {
6581
+ finalURL = defaultPathSerializer(finalURL, options.params.path);
6608
6582
  }
6609
- };
6610
- function isEmpty(value) {
6611
- return value === null || value === void 0 || typeof value === "string" && value.trim() === "";
6612
- }
6613
- function validateRequiredFields(body, requiredFields) {
6614
- const errors2 = {};
6615
- if (!requiredFields || requiredFields.length === 0) {
6616
- return errors2;
6583
+ let search = options.querySerializer(options.params.query ?? {});
6584
+ if (search.startsWith("?")) {
6585
+ search = search.substring(1);
6617
6586
  }
6618
- for (const field of requiredFields) {
6619
- if (!(field in body) || isEmpty(body[field])) {
6620
- errors2[field] = [`Field '${field}' is required and cannot be empty`];
6587
+ if (search) {
6588
+ finalURL += `?${search}`;
6589
+ }
6590
+ return finalURL;
6591
+ }
6592
+ function mergeHeaders(...allHeaders) {
6593
+ const finalHeaders = new Headers();
6594
+ for (const h of allHeaders) {
6595
+ if (!h || typeof h !== "object") {
6596
+ continue;
6597
+ }
6598
+ const iterator = h instanceof Headers ? h.entries() : Object.entries(h);
6599
+ for (const [k, v] of iterator) {
6600
+ if (v === null) {
6601
+ finalHeaders.delete(k);
6602
+ } else if (Array.isArray(v)) {
6603
+ for (const v2 of v) {
6604
+ finalHeaders.append(k, v2);
6605
+ }
6606
+ } else if (v !== void 0) {
6607
+ finalHeaders.set(k, v);
6608
+ }
6621
6609
  }
6622
6610
  }
6623
- return errors2;
6611
+ return finalHeaders;
6624
6612
  }
6625
- function validateApiPostBody(body, requiredFields) {
6626
- return validateRequiredFields(body, requiredFields);
6613
+ function removeTrailingSlash(url) {
6614
+ if (url.endsWith("/")) {
6615
+ return url.substring(0, url.length - 1);
6616
+ }
6617
+ return url;
6618
+ }
6619
+ function client(publicApiUrl, shopUrl) {
6620
+ return createClient({ baseUrl: `${publicApiUrl}`, headers: { "X-Shop-Url": shopUrl } });
6627
6621
  }
6622
+ const CALENDAR_ENDPOINT = "/api/v4/calendar";
6623
+ const TICKETS_CALENDAR_ENDPOINT = "/api/v4/tickets/calendar";
6624
+ const TICKET_AND_QUOTAS_ENDPOINT = "/api/v4/tickets/list_and_quotas";
6625
+ const TICKETS_ENDPOINT = "/api/v4/tickets";
6626
+ const SIGN_IN_ENDPOINT = "/api/v4/auth/sign_in";
6627
+ const SIGN_UP_ENDPOINT = "/api/v4/auth";
6628
+ const CustomerLevels = {
6629
+ // NORMAL: 0,
6630
+ // WIDGET: 5,
6631
+ SHOP_GUEST: 10,
6632
+ SHOP: 20
6633
+ // CASH_POINT: 30,
6634
+ };
6628
6635
  var util;
6629
6636
  (function(util2) {
6630
6637
  util2.assertEqual = (val) => val;
@@ -11902,6 +11909,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11902
11909
  ticketsCalendar(params) {
11903
11910
  return this.fetchAndCache(TICKETS_CALENDAR_ENDPOINT, `ticketsCalendar-${JSON.stringify(params)}`, "data", { cache: 60, query: params });
11904
11911
  }
11912
+ calendar(params) {
11913
+ return this.fetchAndCache(CALENDAR_ENDPOINT, `calendar-${JSON.stringify(params)}`, "data", { cache: 60, query: params });
11914
+ }
11905
11915
  ticketsAndQuotas(params) {
11906
11916
  return this.fetchAndCache(TICKET_AND_QUOTAS_ENDPOINT, `ticketsAndQuotas-${JSON.stringify(params)}`, "", { cache: 60, query: params });
11907
11917
  }
@@ -11963,7 +11973,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11963
11973
  options.cache ??= 1e3;
11964
11974
  options.path ??= {};
11965
11975
  if (!this.#canFetch()) {
11966
- console.warn("(fetchAndCache) Shop not loaded!");
11976
+ console.warn("(fetchAndCache) Couldn't fetch, Shop not loaded!");
11967
11977
  return get$2(this.#data)[dataKey];
11968
11978
  }
11969
11979
  const query = assign(options.query, { per_page: 1e3 });
@@ -11977,6 +11987,11 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11977
11987
  }
11978
11988
  return get$2(this.#data)[dataKey];
11979
11989
  }
11990
+ clearCache() {
11991
+ console.log("CLEAR CACHE");
11992
+ this.#fetchStatus = {};
11993
+ set(this.#data, {}, true);
11994
+ }
11980
11995
  get museums() {
11981
11996
  return this.fetchAndCache("/api/v4/museums", "museums", "museums");
11982
11997
  }
@@ -11986,6 +12001,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11986
12001
  getEvent(id) {
11987
12002
  return this.fetchAndCache(`/api/v4/events/${id}`, `single_event_${id}`, "event");
11988
12003
  }
12004
+ getEventDetailsOnDate(eventId, dateId) {
12005
+ return this.fetchAndCache(`/api/v4/events/${eventId}/dates/${dateId}`, `/api/v4/events/${eventId}/dates/${dateId}`, "date");
12006
+ }
11989
12007
  get events() {
11990
12008
  return this.fetchAndCache("/api/v4/events", "events", "events");
11991
12009
  }
@@ -12555,7 +12573,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
12555
12573
  const nanoid = /^[a-zA-Z0-9_-]{21}$/;
12556
12574
  const duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
12557
12575
  const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
12558
- const uuid$1 = (version2) => {
12576
+ const uuid$2 = (version2) => {
12559
12577
  if (!version2)
12560
12578
  return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
12561
12579
  return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version2}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
@@ -12982,9 +13000,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
12982
13000
  const v = versionMap[def.version];
12983
13001
  if (v === void 0)
12984
13002
  throw new Error(`Invalid UUID version: "${def.version}"`);
12985
- def.pattern ?? (def.pattern = uuid$1(v));
13003
+ def.pattern ?? (def.pattern = uuid$2(v));
12986
13004
  } else
12987
- def.pattern ?? (def.pattern = uuid$1());
13005
+ def.pattern ?? (def.pattern = uuid$2());
12988
13006
  $ZodStringFormat.init(inst, def);
12989
13007
  });
12990
13008
  const $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
@@ -15024,6 +15042,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15024
15042
  * @param {string[] | Record<string, string[]>} errors - Errors passed as an array or an object where keys are API field keys and values are arrays of error messages. If an array is provided, it assigns the errors directly. If an object is provided, it maps the errors to the respective fields based on their API keys.
15025
15043
  */
15026
15044
  set apiErrors(errors2) {
15045
+ get$2(this.#fields).forEach((f) => f.apiErrors = []);
15027
15046
  if (isArray(errors2)) {
15028
15047
  set(this.#apiErrors, errors2, true);
15029
15048
  return;
@@ -15072,7 +15091,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15072
15091
  const setDetails$1 = createSetDetails(KEY$3);
15073
15092
  const getDetails$1 = createGetDetails(KEY$3);
15074
15093
  function wrapInElement(host, tag, props) {
15075
- const first = host.firstElementChild;
15094
+ const first = host.firstElementChild || void 0;
15076
15095
  if (host.children?.length === 1 && first?.tagName.toLowerCase() === tag) {
15077
15096
  return first;
15078
15097
  }
@@ -15103,8 +15122,10 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15103
15122
  async function handleSubmit(event) {
15104
15123
  event.preventDefault();
15105
15124
  details.validateForm();
15106
- details?.form?.dispatchEvent(new Event("after-validation", event));
15125
+ details?.form?.dispatchEvent(new Event("go-after-validation", event));
15107
15126
  if (details.isValid) {
15127
+ console.log("hoo");
15128
+ details.apiErrors = {};
15108
15129
  details?.form?.dispatchEvent(new Event("go-submit", event));
15109
15130
  }
15110
15131
  }
@@ -15291,7 +15312,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15291
15312
  [],
15292
15313
  false
15293
15314
  ));
15294
- function dispathCartEvents() {
15315
+ function dispatchCartEvents() {
15295
15316
  let lastLength = 0;
15296
15317
  effect_root(() => {
15297
15318
  user_effect(() => {
@@ -15304,7 +15325,37 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15304
15325
  });
15305
15326
  });
15306
15327
  }
15307
- function createCartItem(ticket, options) {
15328
+ function isUIEventTicket(x) {
15329
+ return x.product_type === "Event";
15330
+ }
15331
+ let uuid$1 = 1;
15332
+ function createUIEventTicket(apiTicket, dateId, options) {
15333
+ const finalOptions = { minAvailableCapacity: 0, selectedTime: "", ...{} };
15334
+ const product = {
15335
+ product_type: "Event",
15336
+ id: dateId,
15337
+ tax_included: true,
15338
+ ...apiTicket
15339
+ };
15340
+ const uiTicket = {
15341
+ uid: uuid$1++,
15342
+ ...product,
15343
+ ...apiTicket,
15344
+ ...finalOptions,
15345
+ type: "scale",
15346
+ get max_capacity() {
15347
+ return 18;
15348
+ },
15349
+ get min_quantity() {
15350
+ return 0;
15351
+ },
15352
+ get max_quantity() {
15353
+ return 18;
15354
+ }
15355
+ };
15356
+ return uiTicket;
15357
+ }
15358
+ function createCartItem(product, options) {
15308
15359
  const finalOptions = {
15309
15360
  quantity: 0,
15310
15361
  time: "",
@@ -15312,26 +15363,56 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15312
15363
  };
15313
15364
  return {
15314
15365
  ...finalOptions,
15315
- type: "Ticket",
15316
- item: ticket,
15317
- get attributes() {
15318
- return {
15319
- id: this.item.id,
15320
- quantity: this.quantity,
15321
- time: this.time
15366
+ type: product.product_type,
15367
+ product,
15368
+ /**
15369
+ * is passed to the Order API
15370
+ */
15371
+ orderAttributes() {
15372
+ const base = {
15373
+ shipped_with_merchandise_id: null,
15374
+ shipping_mode: "email"
15322
15375
  };
15376
+ switch (this.type) {
15377
+ case "Ticket":
15378
+ return {
15379
+ id: this.product.id,
15380
+ time: this.time,
15381
+ quantity: this.quantity,
15382
+ ...base
15383
+ };
15384
+ case "Event":
15385
+ if (!isUIEventTicket(this.product)) {
15386
+ throw new Error("Event ticket is not a scale ticket");
15387
+ }
15388
+ const scaleTicket = this.product;
15389
+ return {
15390
+ id: this.product.id,
15391
+ quantities: { [scaleTicket.scale_price_id]: this.quantity },
15392
+ ...base
15393
+ };
15394
+ default:
15395
+ const exhastedChecking = this.type;
15396
+ throw new Error(`(orderAttributes) Unhandled case: ${exhastedChecking}`);
15397
+ }
15323
15398
  },
15324
15399
  get uuid() {
15325
- return this.type + "-" + this.attributes.id;
15400
+ return this.type + "-" + this.product.id + this.subId;
15401
+ },
15402
+ get subId() {
15403
+ if (isUIEventTicket(this.product)) {
15404
+ return ` (scale_price: ${this.product.scale_price_id})`;
15405
+ }
15406
+ return "";
15326
15407
  },
15327
15408
  get price_cents() {
15328
- return this.item.price_cents;
15409
+ return this.product.price_cents;
15329
15410
  },
15330
15411
  get price_formatted() {
15331
15412
  return formatCurrency(this.price_cents);
15332
15413
  },
15333
15414
  get final_price_cents() {
15334
- const taxFactor = this.item.tax_included ? 1 : 1 + this.item.vat_pct / 100;
15415
+ const taxFactor = this.product.tax_included ? 1 : 1 + this.product.vat_pct / 100;
15335
15416
  return this.price_cents * taxFactor;
15336
15417
  },
15337
15418
  get final_price_formatted() {
@@ -15346,49 +15427,26 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15346
15427
  };
15347
15428
  }
15348
15429
  let uuid = 1;
15430
+ function isUITicket(x) {
15431
+ return x.product_type === "Ticket";
15432
+ }
15349
15433
  function createUITicket(apiTicket, options) {
15350
- const finalOptions = {
15351
- minAvailableCapacity: 0,
15352
- selectedTime: "",
15353
- quantity: 0,
15354
- ...options ?? {}
15355
- };
15434
+ const finalOptions = { minAvailableCapacity: 0, selectedTime: "", ...options ?? {} };
15435
+ const product = { product_type: "Ticket", ...apiTicket };
15356
15436
  const _ = { ...apiTicket, ...finalOptions };
15357
15437
  const uiTicket = {
15358
15438
  uid: uuid++,
15439
+ ...product,
15359
15440
  ..._,
15360
- //include all from options and apiTicket
15441
+ product_type: "Ticket",
15361
15442
  type: { time_slot: "timeslot", normal: "day", annual: "annual" }[_.ticket_type],
15362
- shop_order: _.shop_order ?? 0,
15363
- get max_capacity() {
15364
- return max_capacity(this);
15365
- },
15366
- get min_quantity() {
15367
- return this.min_persons;
15368
- },
15369
- get max_quantity() {
15370
- return Math.min(this.max_persons, this.max_capacity);
15371
- }
15443
+ shop_order: _.shop_order ?? 0
15372
15444
  };
15373
15445
  return uiTicket;
15374
15446
  }
15375
15447
  function initUITimeslotTickets(tickets) {
15376
15448
  return sort(Object.values(tickets).map((ticket) => createUITicket(ticket)), (f) => f.shop_order);
15377
15449
  }
15378
- function max_capacity(ticket) {
15379
- switch (ticket.type) {
15380
- case "timeslot":
15381
- const timeslotTicket = ticket;
15382
- return (timeslotTicket.capacities ? Math.max(0, ...Object.values(timeslotTicket.capacities)) : timeslotTicket.max_persons) + ticket.quantity;
15383
- case "annual":
15384
- return ticket.max_persons;
15385
- case "day":
15386
- return ticket.max_persons;
15387
- default:
15388
- const exhastedChecking = ticket.type;
15389
- throw new Error(`(max_capacity) Unhandled case: ${exhastedChecking}`);
15390
- }
15391
- }
15392
15450
  function updateLocalStorage(cart2) {
15393
15451
  const content = JSON.stringify(cart2.items || []);
15394
15452
  localStorage.setItem("go-cart", content);
@@ -15398,12 +15456,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15398
15456
  const type = cartItem.type;
15399
15457
  switch (type) {
15400
15458
  case "Ticket":
15401
- if (cartItem.item.ticket_type === "timeslot" && !inTheFuture(cartItem.attributes.time)) return;
15402
- const ticket = createUITicket(cartItem.item, {
15403
- quantity: cartItem.attributes.quantity,
15404
- minAvailableCapacity: 0
15405
- });
15406
- return createCartItem(ticket, { time: cartItem.time, quantity: cartItem.attributes.quantity });
15459
+ if (cartItem.product.ticket_type === "timeslot" && !inTheFuture(cartItem.attributes.time)) return;
15460
+ const ticket = createUITicket(cartItem.product, { minAvailableCapacity: 0 });
15461
+ return createCartItem(ticket, { time: cartItem.time, quantity: cartItem.quantity });
15462
+ case "Event":
15463
+ const event = createUIEventTicket(cartItem.product, cartItem.id);
15464
+ return createCartItem(event, { time: cartItem.time, quantity: cartItem.quantity });
15407
15465
  default:
15408
15466
  const _exhaustiveCheck = type;
15409
15467
  throw new Error(`Unhandled case: ${_exhaustiveCheck}`);
@@ -15419,7 +15477,10 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15419
15477
  console.dir({ lsItems, content });
15420
15478
  throw new Error("go-cart is not an array");
15421
15479
  }
15422
- if (lsItems.length === 0) return [];
15480
+ if (lsItems.length === 0) {
15481
+ cart2.clearItems();
15482
+ return [];
15483
+ }
15423
15484
  cart2.items = lsItems.map(generateCartItem).filter(defined);
15424
15485
  return cart2.items;
15425
15486
  } catch (e) {
@@ -15459,10 +15520,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15459
15520
  };
15460
15521
  const defined = (x) => x !== void 0;
15461
15522
  let lastUuid = 0;
15462
- function createCart(tickets, options) {
15523
+ function createCart(products, contingent = 20) {
15463
15524
  const items = proxy([]);
15464
15525
  const cart2 = {
15465
15526
  items,
15527
+ // caps the total number of items in the cart
15528
+ contingent,
15466
15529
  uid: `cart-${lastUuid++}`,
15467
15530
  get nonEmptyItems() {
15468
15531
  return this.items.filter((i) => i.quantity > 0);
@@ -15470,16 +15533,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15470
15533
  get totalPriceCents() {
15471
15534
  return Math.max(0, sum(this.items, (item) => item.total_price_cents));
15472
15535
  },
15473
- cartData() {
15536
+ get totalQuantity() {
15537
+ return sum(this.items, (item) => item.quantity);
15538
+ },
15539
+ orderData() {
15474
15540
  return {
15475
- items: this.items.map((item) => ({
15476
- type: item.type,
15477
- attributes: {
15478
- ...item.attributes,
15479
- shipped_with_merchandise_id: null,
15480
- shipping_mode: "email"
15481
- }
15482
- })),
15541
+ items: this.items.map((item) => ({ type: item.type, attributes: item.orderAttributes() })),
15483
15542
  shipping_address_id: null,
15484
15543
  comment: null,
15485
15544
  reference: null,
@@ -15509,16 +15568,16 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15509
15568
  items2.forEach((item) => this.addItem(item));
15510
15569
  }
15511
15570
  };
15512
- if (tickets) tickets.forEach((t) => cart2.addItem(createCartItem(t)));
15571
+ if (products) products.forEach((p2) => cart2.addItem(createCartItem(p2)));
15513
15572
  return cart2;
15514
15573
  }
15515
15574
  function formatCurrency(priceCents) {
15516
15575
  priceCents = priceCents ?? 0;
15517
15576
  return new Intl.NumberFormat("de-DE", { style: "currency", currency: "EUR" }).format(priceCents / 100);
15518
15577
  }
15519
- const cart = proxy(createCart([]));
15578
+ const cart = proxy(createCart([], { syncLocalStorage: true }));
15520
15579
  syncCartToLocalStorage(cart);
15521
- dispathCartEvents();
15580
+ dispatchCartEvents();
15522
15581
  var root_2$q = /* @__PURE__ */ from_html(`<li data-go-cart-header-remove="">remove</li>`);
15523
15582
  var root_5$2 = /* @__PURE__ */ from_html(`<span class="go-cart-item-time" data-testid="cart-item-time"> </span>`);
15524
15583
  var root_4$5 = /* @__PURE__ */ from_html(`<span class="go-cart-item-date" data-testid="cart-item-date"> </span> <!>`, 1);
@@ -15587,20 +15646,20 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15587
15646
  var span_2 = root_5$2();
15588
15647
  var text_2 = child(span_2, true);
15589
15648
  reset(span_2);
15590
- template_effect(($0) => set_text(text_2, $0), [() => formatTime(get$2(cartItem).attributes.time)]);
15649
+ template_effect(($0) => set_text(text_2, $0), [() => formatTime(get$2(cartItem).time)]);
15591
15650
  append($$anchor5, span_2);
15592
15651
  };
15593
15652
  if_block(node_4, ($$render) => {
15594
- if (get$2(cartItem).item.type === "timeslot") $$render(consequent_1);
15653
+ if (get$2(cartItem).product.type === "timeslot") $$render(consequent_1);
15595
15654
  });
15596
15655
  }
15597
15656
  template_effect(($0) => set_text(text_1, $0), [
15598
- () => formatDate(get$2(cartItem).attributes.time, { month: "numeric", day: "numeric" }, shop.locale)
15657
+ () => formatDate(get$2(cartItem).time, { month: "numeric", day: "numeric" }, shop.locale)
15599
15658
  ]);
15600
15659
  append($$anchor4, fragment_2);
15601
15660
  };
15602
15661
  if_block(node_3, ($$render) => {
15603
- if (get$2(cartItem).item.type === "timeslot" && get$2(cartItem).attributes.time) $$render(consequent_2);
15662
+ if (get$2(cartItem).product.type === "timeslot" && get$2(cartItem).time) $$render(consequent_2);
15604
15663
  });
15605
15664
  }
15606
15665
  reset(li_3);
@@ -15631,7 +15690,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15631
15690
  reset(li_2);
15632
15691
  template_effect(() => {
15633
15692
  set_attribute(article, "data-testid", get$2(cartItem).uuid);
15634
- set_text(text2, get$2(cartItem).item.title);
15693
+ set_text(text2, get$2(cartItem).product.title);
15635
15694
  set_text(text_3, get$2(cartItem).final_price_formatted);
15636
15695
  set_text(text_4, get$2(cartItem).quantity);
15637
15696
  set_text(text_5, get$2(cartItem).total_price_formatted);
@@ -15718,7 +15777,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15718
15777
  form.details.apiErrors = auth2.error.errors;
15719
15778
  return;
15720
15779
  }
15721
- const checkout = await shop.checkout(cart.cartData());
15780
+ const checkout = await shop.checkout(cart.orderData());
15722
15781
  if (checkout.error) {
15723
15782
  form.details.apiErrors = checkout.error;
15724
15783
  return;
@@ -21610,7 +21669,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
21610
21669
  }
21611
21670
  }
21612
21671
  var root_2$p = /* @__PURE__ */ from_html(`<div><!></div>`);
21613
- function Calendar$2($$anchor, $$props) {
21672
+ function Calendar$1($$anchor, $$props) {
21614
21673
  push($$props, true);
21615
21674
  let child$1 = prop($$props, "child", 7), children = prop($$props, "children", 7), id = prop($$props, "id", 23, useId), ref = prop($$props, "ref", 15, null), value = prop($$props, "value", 15), onValueChange = prop($$props, "onValueChange", 7, noop), placeholder = prop($$props, "placeholder", 15), onPlaceholderChange = prop($$props, "onPlaceholderChange", 7, noop), weekdayFormat = prop($$props, "weekdayFormat", 7, "narrow"), weekStartsOn = prop($$props, "weekStartsOn", 7), pagedNavigation = prop($$props, "pagedNavigation", 7, false), isDateDisabled = prop($$props, "isDateDisabled", 7, () => false), isDateUnavailable = prop($$props, "isDateUnavailable", 7, () => false), fixedWeeks = prop($$props, "fixedWeeks", 7, false), numberOfMonths = prop($$props, "numberOfMonths", 7, 1), locale = prop($$props, "locale", 7), calendarLabel = prop($$props, "calendarLabel", 7, "Event"), disabled = prop($$props, "disabled", 7, false), readonly2 = prop($$props, "readonly", 7, false), minValue = prop($$props, "minValue", 7, void 0), maxValue = prop($$props, "maxValue", 7, void 0), preventDeselect = prop($$props, "preventDeselect", 7, false), type = prop($$props, "type", 7), disableDaysOutsideMonth = prop($$props, "disableDaysOutsideMonth", 7, true), initialFocus = prop($$props, "initialFocus", 7, false), maxDays = prop($$props, "maxDays", 7), monthFormat = prop($$props, "monthFormat", 7, "long"), yearFormat = prop($$props, "yearFormat", 7, "numeric"), restProps = /* @__PURE__ */ rest_props($$props, [
21616
21675
  "$$slots",
@@ -21924,7 +21983,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
21924
21983
  return pop($$exports);
21925
21984
  }
21926
21985
  create_custom_element(
21927
- Calendar$2,
21986
+ Calendar$1,
21928
21987
  {
21929
21988
  child: {},
21930
21989
  children: {},
@@ -29566,7 +29625,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
29566
29625
  component(node_1, () => Date_field_label, ($$anchor4, DatePicker_Label) => {
29567
29626
  DatePicker_Label($$anchor4, {
29568
29627
  get class() {
29569
- return `go-datepicker-label $${labelClass() ?? ""}`;
29628
+ return `go-datepicker-label ${labelClass() ?? ""}`;
29570
29629
  }
29571
29630
  });
29572
29631
  });
@@ -29606,7 +29665,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
29606
29665
  component(node_2, () => Date_field_input, ($$anchor4, DatePicker_Input) => {
29607
29666
  DatePicker_Input($$anchor4, {
29608
29667
  get class() {
29609
- return `go-datepicker-input $${inputClass() ?? ""}`;
29668
+ return `go-datepicker-input ${inputClass() ?? ""}`;
29610
29669
  },
29611
29670
  children,
29612
29671
  $$slots: { default: true }
@@ -30237,7 +30296,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30237
30296
  const _details = getDetails$1($$props.$$host);
30238
30297
  const details = /* @__PURE__ */ user_derived(() => _details.value);
30239
30298
  user_effect(() => {
30240
- get$2(details)?.form?.addEventListener("after-validation", () => {
30299
+ get$2(details)?.form?.addEventListener("go-after-validation", () => {
30241
30300
  set(errorsOnSubmit, errors(get$2(details)?.fields), true);
30242
30301
  });
30243
30302
  });
@@ -30378,7 +30437,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30378
30437
  console.log(`Error while evaluating when (${expression}) in go-if: ${error.message}`);
30379
30438
  }
30380
30439
  }
30381
- const validTicketSelectionFilters = ["timeslot", "day", "annual"];
30440
+ const validTicketSelectionFilters = ["timeslot", "day", "annual", "scaled-price"];
30382
30441
  let lastUId = 0;
30383
30442
  class TicketSelectionDetails {
30384
30443
  uid = lastUId++;
@@ -30396,19 +30455,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30396
30455
  set filters(value) {
30397
30456
  set(this.#filters, value, true);
30398
30457
  }
30399
- #apiFilters = /* @__PURE__ */ user_derived(() => this.filters?.map((f) => ({ day: "normal", timeslot: "timeslot", annual: "annual" })[f]));
30400
- get apiFilters() {
30401
- return get$2(this.#apiFilters);
30458
+ #eventIds = /* @__PURE__ */ state();
30459
+ get eventIds() {
30460
+ return get$2(this.#eventIds);
30402
30461
  }
30403
- set apiFilters(value) {
30404
- set(this.#apiFilters, value);
30405
- }
30406
- #eventId = /* @__PURE__ */ state();
30407
- get eventId() {
30408
- return get$2(this.#eventId);
30409
- }
30410
- set eventId(value) {
30411
- set(this.#eventId, value, true);
30462
+ set eventIds(value) {
30463
+ set(this.#eventIds, value, true);
30412
30464
  }
30413
30465
  #museumIds = /* @__PURE__ */ state();
30414
30466
  get museumIds() {
@@ -30452,24 +30504,25 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30452
30504
  set selectedTimeslot(value) {
30453
30505
  set(this.#selectedTimeslot, value, true);
30454
30506
  }
30455
- #ticketGroups = /* @__PURE__ */ state(proxy([]));
30456
- get ticketGroups() {
30457
- return get$2(this.#ticketGroups);
30507
+ #ticketSegments = /* @__PURE__ */ state(proxy([]));
30508
+ get ticketSegments() {
30509
+ return get$2(this.#ticketSegments);
30458
30510
  }
30459
- set ticketGroups(value) {
30460
- set(this.#ticketGroups, value, true);
30511
+ set ticketSegments(value) {
30512
+ set(this.#ticketSegments, value, true);
30461
30513
  }
30462
- #preCarts = /* @__PURE__ */ user_derived(() => this.ticketGroups.map((tg) => tg.preCart));
30514
+ #preCarts = /* @__PURE__ */ user_derived(() => this.ticketSegments.map((tg) => tg.preCart));
30463
30515
  get preCarts() {
30464
30516
  return get$2(this.#preCarts);
30465
30517
  }
30466
30518
  set preCarts(value) {
30467
30519
  set(this.#preCarts, value);
30468
30520
  }
30469
- addTicketGroup(ticketGroup) {
30470
- this.ticketGroups.push(ticketGroup);
30521
+ addTicketSegment(ticketGroup) {
30522
+ this.ticketSegments.push(ticketGroup);
30471
30523
  }
30472
30524
  get isTimeslotsVisible() {
30525
+ if (this.mode === "event") return false;
30473
30526
  return Boolean(this.filters?.includes("timeslot") && this.selectedDate);
30474
30527
  }
30475
30528
  get isTicketsVisible() {
@@ -30479,11 +30532,25 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30479
30532
  return Boolean(this.selectedDate);
30480
30533
  case "annual":
30481
30534
  return true;
30535
+ case "scaled-price":
30536
+ return true;
30482
30537
  case "timeslot":
30483
- return Boolean(this.selectedDate && this.selectedTimeslot);
30538
+ switch (this.mode) {
30539
+ case "event":
30540
+ return Boolean(this.selectedDate);
30541
+ case "ticket":
30542
+ return Boolean(this.selectedDate && this.selectedTimeslot);
30543
+ case "tour":
30544
+ return true;
30545
+ case void 0:
30546
+ return false;
30547
+ default:
30548
+ const exhaustedChecking2 = this.mode;
30549
+ throw new Error(`(isTicketsVisible) Unhandled case: ${exhaustedChecking2}`);
30550
+ }
30484
30551
  default:
30485
30552
  const exhaustedChecking = filter;
30486
- console.error(`(TicketSelection) Unhandled case: ${exhaustedChecking}`);
30553
+ throw new Error(`(isTicketsVisible) Unhandled case: ${exhaustedChecking}`);
30487
30554
  }
30488
30555
  };
30489
30556
  return this.filters?.some(byFilter);
@@ -30971,7 +31038,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30971
31038
  reset(ul);
30972
31039
  reset(li);
30973
31040
  reset(ol);
30974
- template_effect(($0) => set_text(text2, `Total: ${$0 ?? ""}`), [() => formatCurrency(get$2(order).total_price_cents)]);
31041
+ template_effect(($0) => set_text(text2, `Total: ${$0 ?? ""}`), [() => formatCurrency$1(get$2(order).total_price_cents)]);
30975
31042
  append($$anchor2, ol);
30976
31043
  };
30977
31044
  if_block(node, ($$render) => {
@@ -31079,12 +31146,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31079
31146
  create_custom_element(Wrapper, { host: {}, children: {} }, [], [], true);
31080
31147
  function TicketSelection($$anchor, $$props) {
31081
31148
  push($$props, true);
31082
- let mode = prop($$props, "mode", 7), filters = prop($$props, "filters", 7), eventId = prop($$props, "eventId", 7), museumIds = prop($$props, "museumIds", 7), exhibitionIds = prop($$props, "exhibitionIds", 7), ticketIds = prop($$props, "ticketIds", 7), ticketGroupIds = prop($$props, "ticketGroupIds", 7);
31149
+ let mode = prop($$props, "mode", 7), filters = prop($$props, "filters", 7), eventIds = prop($$props, "eventIds", 7), museumIds = prop($$props, "museumIds", 7), exhibitionIds = prop($$props, "exhibitionIds", 7), ticketIds = prop($$props, "ticketIds", 7), ticketGroupIds = prop($$props, "ticketGroupIds", 7);
31083
31150
  const details = new TicketSelectionDetails();
31084
31151
  user_effect(() => {
31085
31152
  details.mode = mode();
31086
31153
  details.filters = parseTokens(filters(), validTicketSelectionFilters);
31087
- details.eventId = eventId();
31154
+ details.eventIds = parseIds(eventIds());
31088
31155
  details.museumIds = parseIds(museumIds());
31089
31156
  details.exhibitionIds = parseIds(exhibitionIds());
31090
31157
  details.ticketIds = parseIds(ticketIds());
@@ -31107,11 +31174,11 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31107
31174
  filters($$value);
31108
31175
  flushSync();
31109
31176
  },
31110
- get eventId() {
31111
- return eventId();
31177
+ get eventIds() {
31178
+ return eventIds();
31112
31179
  },
31113
- set eventId($$value) {
31114
- eventId($$value);
31180
+ set eventIds($$value) {
31181
+ eventIds($$value);
31115
31182
  flushSync();
31116
31183
  },
31117
31184
  get museumIds() {
@@ -31149,7 +31216,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31149
31216
  TicketSelection,
31150
31217
  {
31151
31218
  mode: { attribute: "mode", reflect: true, type: "String" },
31152
- eventId: { attribute: "event-id", reflect: true, type: "Number" },
31219
+ eventIds: { attribute: "event-ids", reflect: true, type: "String" },
31153
31220
  ticketIds: { attribute: "ticket-ids", reflect: true, type: "String" },
31154
31221
  ticketGroupIds: { attribute: "ticket-group-ids", reflect: true, type: "String" },
31155
31222
  museumIds: { attribute: "museum-ids", reflect: true, type: "String" },
@@ -31186,7 +31253,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31186
31253
  pop();
31187
31254
  }
31188
31255
  customElements.define("go-tickets-sum", create_custom_element(TicketsSum, {}, [], [], false));
31189
- class TicketGroupDetails {
31256
+ class TicketSegmentDetails {
31190
31257
  #ticketSelectionDetails;
31191
31258
  get ticketSelectionDetails() {
31192
31259
  return get$2(this.#ticketSelectionDetails);
@@ -31201,12 +31268,19 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31201
31268
  set tickets(value) {
31202
31269
  set(this.#tickets, value, true);
31203
31270
  }
31204
- #preCart = /* @__PURE__ */ user_derived(() => createCart(this.preCartTickets()));
31271
+ #contingent = /* @__PURE__ */ state(100);
31272
+ get contingent() {
31273
+ return get$2(this.#contingent);
31274
+ }
31275
+ set contingent(value) {
31276
+ set(this.#contingent, value, true);
31277
+ }
31278
+ #preCart = /* @__PURE__ */ state(proxy(createCart()));
31205
31279
  get preCart() {
31206
31280
  return get$2(this.#preCart);
31207
31281
  }
31208
31282
  set preCart(value) {
31209
- set(this.#preCart, value);
31283
+ set(this.#preCart, value, true);
31210
31284
  }
31211
31285
  #filters = /* @__PURE__ */ state("timeslot");
31212
31286
  get filters() {
@@ -31215,6 +31289,13 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31215
31289
  set filters(value) {
31216
31290
  set(this.#filters, value, true);
31217
31291
  }
31292
+ #dateId = /* @__PURE__ */ state();
31293
+ get dateId() {
31294
+ return get$2(this.#dateId);
31295
+ }
31296
+ set dateId(value) {
31297
+ set(this.#dateId, value, true);
31298
+ }
31218
31299
  constructor(type, tsdWrapper) {
31219
31300
  this.filters = type;
31220
31301
  this.#ticketSelectionDetails = /* @__PURE__ */ user_derived(() => tsdWrapper.value);
@@ -31222,9 +31303,19 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31222
31303
  user_effect(() => {
31223
31304
  this.ticketSelectionDetails;
31224
31305
  untrack(() => {
31225
- this.ticketSelectionDetails?.addTicketGroup(this);
31306
+ this.ticketSelectionDetails?.addTicketSegment(this);
31226
31307
  });
31227
31308
  });
31309
+ user_effect(() => {
31310
+ this.preCart = createCart(this.preCartTickets(), this.contingent);
31311
+ });
31312
+ });
31313
+ }
31314
+ toString() {
31315
+ return JSON.stringify({
31316
+ tickets: this.tickets,
31317
+ filters: this.filters,
31318
+ preCart: this.preCart
31228
31319
  });
31229
31320
  }
31230
31321
  preCartTickets() {
@@ -31237,6 +31328,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31237
31328
  return this.dayTickets;
31238
31329
  case "custom":
31239
31330
  return this.tickets;
31331
+ case "scaled-price":
31332
+ return this.scaledPricesTickets;
31240
31333
  default:
31241
31334
  const exhaustiveCheck = this.filters;
31242
31335
  if (exhaustiveCheck) throw new Error(`(TicketGroup) Unhandled case: ${exhaustiveCheck}`);
@@ -31288,19 +31381,61 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31288
31381
  if (!tickets) return [];
31289
31382
  return initUITimeslotTickets(tickets);
31290
31383
  }
31384
+ get scaledPricesTickets() {
31385
+ const tsd = this.ticketSelectionDetails;
31386
+ if (!this.ensureScaledPrices()) return [];
31387
+ const eid = tsd.eventIds[0];
31388
+ const event = snapshot(shop.getEventDetailsOnDate(eid, this.dateId));
31389
+ const ret = event?.prices.map((t) => createUIEventTicket(t, this.dateId)) || [];
31390
+ const seats = {
31391
+ max_per_registration: 2,
31392
+ available: 100,
31393
+ overbook: true,
31394
+ ...event?.seats
31395
+ };
31396
+ const max_per_registration = seats.max_per_registration || seats.available;
31397
+ this.contingent = seats.overbook ? max_per_registration : Math.min(seats.available, max_per_registration);
31398
+ return ret;
31399
+ }
31400
+ ensureScaledPrices() {
31401
+ const tsd = this.ticketSelectionDetails;
31402
+ if (!tsd) {
31403
+ console.warn("(scaledPricesTickets) tsd is undefined");
31404
+ return false;
31405
+ }
31406
+ if (!tsd.eventIds?.length) {
31407
+ console.warn("(scaledPricesTickets) eventIds is undefined");
31408
+ return false;
31409
+ }
31410
+ if (!this.filters?.includes("scaled-price")) {
31411
+ console.warn("(scaledPricesTickets) filters should include scaled-price");
31412
+ return false;
31413
+ }
31414
+ if (!this.dateId) {
31415
+ console.warn("(scaledPricesTickets) date-id is not given to the go-ticket-segment");
31416
+ return false;
31417
+ }
31418
+ if (tsd.eventIds.length > 1) throw new Error("(scaledPricesTickets) currently we support only one eventId in go-ticket-selection");
31419
+ return true;
31420
+ }
31291
31421
  }
31292
31422
  const KEY = "go-ticket-segment";
31293
- const setTicketGroupDetails = createSetDetails(KEY);
31294
- const getTicketGroupDetails = createGetDetails(KEY);
31423
+ const setTicketSegmentDetails = createSetDetails(KEY);
31424
+ const getTicketSegmentDetails = createGetDetails(KEY);
31295
31425
  function TicketSegment($$anchor, $$props) {
31296
31426
  push($$props, true);
31297
- const filters = prop($$props, "filters", 7);
31427
+ const filters = prop($$props, "filters", 7), dateId = prop($$props, "dateId", 7);
31298
31428
  if (!filters()) throw new Error("filters is required");
31429
+ console.log("TicketSegment: ", filters(), "dateId: ", dateId());
31299
31430
  const tsdWrapper = getTicketSelectionDetails($$props.$$host);
31300
- const details = new TicketGroupDetails(filters(), tsdWrapper);
31301
- setTicketGroupDetails($$props.$$host, details);
31431
+ const details = new TicketSegmentDetails(filters(), tsdWrapper);
31432
+ setTicketSegmentDetails($$props.$$host, details);
31433
+ details.filters = filters();
31434
+ details.dateId = dateId();
31302
31435
  user_effect(() => {
31303
31436
  details.filters = filters();
31437
+ details.dateId = dateId();
31438
+ console.log("SET DATEID,", dateId());
31304
31439
  });
31305
31440
  var $$exports = {
31306
31441
  details,
@@ -31310,11 +31445,27 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31310
31445
  set filters($$value) {
31311
31446
  filters($$value);
31312
31447
  flushSync();
31448
+ },
31449
+ get dateId() {
31450
+ return dateId();
31451
+ },
31452
+ set dateId($$value) {
31453
+ dateId($$value);
31454
+ flushSync();
31313
31455
  }
31314
31456
  };
31315
31457
  return pop($$exports);
31316
31458
  }
31317
- customElements.define("go-ticket-segment", create_custom_element(TicketSegment, { filters: {} }, [], ["details"], false));
31459
+ customElements.define("go-ticket-segment", create_custom_element(
31460
+ TicketSegment,
31461
+ {
31462
+ dateId: { attribute: "date-id", reflect: true, type: "Number" },
31463
+ filters: {}
31464
+ },
31465
+ [],
31466
+ ["details"],
31467
+ false
31468
+ ));
31318
31469
  function updateSelectedTickets(ci, target, tsd) {
31319
31470
  if (!tsd) {
31320
31471
  console.warn("tsd is undefined");
@@ -31322,22 +31473,34 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31322
31473
  }
31323
31474
  const el = target;
31324
31475
  ci.quantity = parseInt(el.value);
31325
- ci.time = selectedTime(ci.item, tsd);
31476
+ ci.time = selectedTime(ci.product, tsd);
31326
31477
  }
31327
- function selectedTime(ticket, tsd) {
31328
- switch (ticket.type) {
31329
- case "timeslot":
31330
- if (!tsd.selectedTimeslot) {
31331
- throw new Error("(selectedTime) selected timeslot is undefined");
31478
+ function selectedTime(product, tsd) {
31479
+ switch (product.product_type) {
31480
+ case "Ticket":
31481
+ if (!isUITicket(product)) {
31482
+ throw new Error("(selectedTime) this should not happen");
31332
31483
  }
31333
- return tsd.selectedTimeslot;
31334
- case "annual":
31335
- return berlinNowISO();
31336
- case "day":
31337
- return dayTicketSelectedTime(tsd);
31484
+ const ticket = product;
31485
+ switch (ticket.type) {
31486
+ case "timeslot":
31487
+ if (!tsd.selectedTimeslot) {
31488
+ throw new Error("(selectedTime) selected timeslot is undefined");
31489
+ }
31490
+ return tsd.selectedTimeslot;
31491
+ case "annual":
31492
+ return berlinNowISO();
31493
+ case "day":
31494
+ return dayTicketSelectedTime(tsd);
31495
+ default:
31496
+ const exhaustedChecking2 = ticket.type;
31497
+ throw new Error(`(selectedTime) Unhandled Ticket Type: ${exhaustedChecking2}`);
31498
+ }
31499
+ case "Event":
31500
+ return "";
31338
31501
  default:
31339
- const exhaustedChecking = ticket.type;
31340
- throw new Error(`(selectedTime) Unhandled case: ${exhaustedChecking}`);
31502
+ const exhaustedChecking = product.product_type;
31503
+ throw new Error(`(selectedTime) Unhandled product type: ${exhaustedChecking}`);
31341
31504
  }
31342
31505
  }
31343
31506
  function berlinNowISO() {
@@ -31351,35 +31514,70 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31351
31514
  }
31352
31515
  return $11d87f3f76e88657$export$84c95a83c799e074(tsd.selectedDate, "Europe/Berlin").toString().slice(0, -15);
31353
31516
  }
31354
- function generateQuantityOptions(ticket) {
31355
- const minQuantity = ticket.min_quantity || 1;
31356
- const maxQuantity = ticket.max_quantity;
31357
- if (maxQuantity < minQuantity) {
31358
- return [{ value: 0, label: "0" }];
31517
+ function selectOptions(cart2, item) {
31518
+ let min2 = 0;
31519
+ let max2 = cart2.contingent;
31520
+ switch (item.type) {
31521
+ case "Ticket":
31522
+ if (!isUITicket(item.product)) {
31523
+ throw new Error("(selectOptionsImpl) impossible");
31524
+ }
31525
+ min2 = Math.max(min2, 1, item.product.min_persons);
31526
+ max2 = Math.min(max2, item.product.max_persons, ticketsMaxCapacity(item.product));
31527
+ break;
31528
+ case "Event":
31529
+ break;
31530
+ default:
31531
+ const Unhandled = item.type;
31532
+ throw new Error(`(selectOptionsImpl) Unhandled case: ${Unhandled}`);
31533
+ }
31534
+ return { min: min2, max: max2 };
31535
+ }
31536
+ function generateQuantityOptions(cart2, item) {
31537
+ const { min: min2, max: max2 } = selectOptions(cart2, item);
31538
+ if (max2 < min2) {
31539
+ throw new Error("(generateQuantityOptions) max must be greater than min");
31359
31540
  }
31360
31541
  const options = [{ value: 0, label: "0" }];
31361
- for (let quantity = minQuantity; quantity <= maxQuantity; quantity++) {
31362
- options.push({ value: quantity, label: quantity.toString() });
31542
+ for (let quantity = min2; quantity <= max2; quantity++) {
31543
+ if (quantity == 0) continue;
31544
+ options.push({
31545
+ value: quantity,
31546
+ label: quantity.toString()
31547
+ });
31363
31548
  }
31364
31549
  return options;
31365
31550
  }
31551
+ function ticketsMaxCapacity(ticket) {
31552
+ switch (ticket.type) {
31553
+ case "timeslot":
31554
+ const timeslotTicket = ticket;
31555
+ return timeslotTicket.capacities ? Math.max(0, ...Object.values(timeslotTicket.capacities)) : timeslotTicket.max_persons;
31556
+ case "annual":
31557
+ return ticket.max_persons;
31558
+ case "day":
31559
+ return ticket.max_persons;
31560
+ default:
31561
+ const exhastedChecking = ticket.type;
31562
+ throw new Error(`(max_capacity) Unhandled case: ${exhastedChecking}`);
31563
+ }
31564
+ }
31366
31565
  var root_2$2 = /* @__PURE__ */ from_html(`<option> </option>`);
31367
31566
  var root_1$2 = /* @__PURE__ */ from_html(`<select></select>`);
31368
31567
  var root_4 = /* @__PURE__ */ from_html(`<li><article data-go-ticket=""><ul><li data-go-tickets-title=""> </li> <li data-go-tickets-description=""><!></li> <li data-go-tickets-price=""> </li> <li data-go-tickets-quality=""><!></li></ul></article></li>`);
31369
31568
  var root_3$1 = /* @__PURE__ */ from_html(`<ol data-testid="tickets"><li data-go-tickets-header="" data-testid="tickets-header"><ul><li data-go-tickets-title="">Title</li> <li data-go-tickets-description="">Description</li> <li data-go-tickets-price="">Price</li> <li data-go-tickets-quality="">Quantity</li></ul></li> <!></ol>`);
31370
31569
  function Body($$anchor, $$props) {
31371
31570
  push($$props, true);
31372
- const select = ($$anchor2, ci = noop$1) => {
31373
- const ticket = /* @__PURE__ */ user_derived(() => ci().item);
31571
+ const select = ($$anchor2, cart2 = noop$1, item = noop$1) => {
31374
31572
  var select_1 = root_1$2();
31375
- select_1.__change = (e) => updateSelectedTickets(ci(), e.target, get$2(details)?.ticketSelectionDetails);
31376
- each(select_1, 21, () => generateQuantityOptions(get$2(ticket)), index$1, ($$anchor3, quantity) => {
31573
+ select_1.__change = (e) => updateSelectedTickets(item(), e.target, get$2(details)?.ticketSelectionDetails);
31574
+ each(select_1, 21, () => generateQuantityOptions(cart2(), item()), index$1, ($$anchor3, quantity) => {
31377
31575
  var option = root_2$2();
31378
31576
  var text2 = child(option, true);
31379
31577
  reset(option);
31380
31578
  var option_value = {};
31381
31579
  template_effect(() => {
31382
- set_selected(option, ci().quantity === get$2(quantity).value);
31580
+ set_selected(option, item().quantity === get$2(quantity).value);
31383
31581
  set_text(text2, get$2(quantity).label);
31384
31582
  if (option_value !== (option_value = get$2(quantity).value)) {
31385
31583
  option.value = (option.__value = get$2(quantity).value) ?? "";
@@ -31390,7 +31588,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31390
31588
  reset(select_1);
31391
31589
  append($$anchor2, select_1);
31392
31590
  };
31393
- const _details = getTicketGroupDetails($$props.$$host);
31591
+ const _details = getTicketSegmentDetails($$props.$$host);
31394
31592
  const details = /* @__PURE__ */ user_derived(() => _details.value);
31395
31593
  const anyItems = /* @__PURE__ */ user_derived(() => get$2(details)?.preCart?.items.length && get$2(details)?.preCart?.items.length > 0);
31396
31594
  var fragment = comment();
@@ -31408,21 +31606,21 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31408
31606
  reset(li_1);
31409
31607
  var li_2 = sibling(li_1, 2);
31410
31608
  var node_2 = child(li_2);
31411
- html$2(node_2, () => get$2(ci).item.description);
31609
+ html$2(node_2, () => get$2(ci).product.description);
31412
31610
  reset(li_2);
31413
31611
  var li_3 = sibling(li_2, 2);
31414
31612
  var text_2 = child(li_3, true);
31415
31613
  reset(li_3);
31416
31614
  var li_4 = sibling(li_3, 2);
31417
31615
  var node_3 = child(li_4);
31418
- select(node_3, () => get$2(ci));
31616
+ select(node_3, () => get$2(details)?.preCart, () => get$2(ci));
31419
31617
  reset(li_4);
31420
31618
  reset(ul);
31421
31619
  reset(article);
31422
31620
  reset(li);
31423
31621
  template_effect(() => {
31424
31622
  set_attribute(article, "data-testid", get$2(ci).uuid);
31425
- set_text(text_1, get$2(ci).item.title);
31623
+ set_text(text_1, get$2(ci).product.title);
31426
31624
  set_text(text_2, get$2(ci).price_formatted);
31427
31625
  });
31428
31626
  append($$anchor3, li);
@@ -31441,7 +31639,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31441
31639
  customElements.define("go-ticket-segment-body", create_custom_element(Body, {}, [], [], false));
31442
31640
  function Sum($$anchor, $$props) {
31443
31641
  push($$props, true);
31444
- const _details = getTicketGroupDetails($$props.$$host);
31642
+ const _details = getTicketSegmentDetails($$props.$$host);
31445
31643
  const details = /* @__PURE__ */ user_derived(() => _details.value);
31446
31644
  next();
31447
31645
  var text2 = text$1();
@@ -31602,7 +31800,14 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31602
31800
  }
31603
31801
  delegate(["change"]);
31604
31802
  customElements.define("go-timeslots", create_custom_element(Timeslots, {}, [], ["details"], false));
31605
- let Calendar$1 = class Calendar {
31803
+ class Calendar {
31804
+ #details = /* @__PURE__ */ state();
31805
+ get details() {
31806
+ return get$2(this.#details);
31807
+ }
31808
+ set details(value) {
31809
+ set(this.#details, value, true);
31810
+ }
31606
31811
  #startAt = /* @__PURE__ */ state(proxy($14e0f24ef4ac5c92$export$d0bdf45af03a6ea3($14e0f24ef4ac5c92$export$aa8b41735afcabd2())));
31607
31812
  get startAt() {
31608
31813
  return get$2(this.#startAt);
@@ -31617,6 +31822,26 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31617
31822
  set selected(value) {
31618
31823
  set(this.#selected, value, true);
31619
31824
  }
31825
+ get dates() {
31826
+ if (!this.details) {
31827
+ console.warn("(Calendar) details is undefined");
31828
+ return void 0;
31829
+ }
31830
+ switch (this.details.mode) {
31831
+ case "ticket":
31832
+ return this.ticketsDates();
31833
+ case "event":
31834
+ return this.eventsDates();
31835
+ case "tour":
31836
+ throw new Error("(Calendar) Tour mode not supported");
31837
+ case void 0:
31838
+ console.error("(Calendar) Mode is undefined");
31839
+ return void 0;
31840
+ default:
31841
+ const exhaustedChecking = this.details.mode;
31842
+ throw new Error(`(Calendar) Unhandled case: ${exhaustedChecking}`);
31843
+ }
31844
+ }
31620
31845
  isDateDisabled(date2) {
31621
31846
  return date2.compare($14e0f24ef4ac5c92$export$d0bdf45af03a6ea3($14e0f24ef4ac5c92$export$aa8b41735afcabd2())) < 0;
31622
31847
  }
@@ -31626,33 +31851,40 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31626
31851
  }
31627
31852
  return false;
31628
31853
  }
31629
- };
31630
- class TicketsCalendar extends Calendar$1 {
31631
- #details = /* @__PURE__ */ state();
31632
- get details() {
31633
- return get$2(this.#details);
31634
- }
31635
- set details(value) {
31636
- set(this.#details, value, true);
31637
- }
31638
- #params = /* @__PURE__ */ user_derived(() => ({
31639
- by_bookable: true,
31640
- "by_ticket_types[]": this.details?.apiFilters,
31641
- "by_ticket_ids[]": this.details?.ticketIds,
31642
- "by_ticket_group_ids[]": this.details?.ticketGroupIds,
31643
- "by_museum_ids[]": this.details?.museumIds,
31644
- "by_exhibition_ids[]": this.details?.exhibitionIds,
31645
- start_at: this.startAt.set({ day: 1 }).toString(),
31646
- end_at: this.startAt.add({ months: 1 }).set({ day: 14 }).toString()
31647
- }));
31648
- get params() {
31649
- return get$2(this.#params);
31854
+ // @ts-ignore
31855
+ apiFilters() {
31856
+ return this.details?.filters?.map((f) => ({
31857
+ day: "normal",
31858
+ timeslot: "time_slot",
31859
+ annual: "annual",
31860
+ "scaled-price": "scaled_price"
31861
+ })[f]);
31862
+ }
31863
+ params() {
31864
+ if (!this.details) return {};
31865
+ const params = {
31866
+ by_bookable: true,
31867
+ // This should give a type error, but it doesn't because we are using by_ticket_types[] which the type doesn't know
31868
+ // we filter out undefined values
31869
+ //@ts-ignore
31870
+ "by_ticket_types[]": this.apiFilters,
31871
+ "by_ticket_ids[]": this.details.ticketIds,
31872
+ "by_ticket_group_ids[]": this.details.ticketGroupIds,
31873
+ "by_museum_ids[]": this.details.museumIds,
31874
+ "by_exhibition_ids[]": this.details.exhibitionIds,
31875
+ "by_event_ids[]": this.details.eventIds,
31876
+ // these logic are there to minimize fetches
31877
+ start_at: this.startAt.set({ day: 1 }).toString(),
31878
+ end_at: this.startAt.add({ months: 1 }).set({ day: 14 }).toString()
31879
+ };
31880
+ return params;
31650
31881
  }
31651
- set params(value) {
31652
- set(this.#params, value);
31882
+ eventsDates() {
31883
+ const ret = shop.calendar(this.params());
31884
+ return ret;
31653
31885
  }
31654
- get dates() {
31655
- const ret = shop.ticketsCalendar(this.params);
31886
+ ticketsDates() {
31887
+ const ret = shop.ticketsCalendar(this.params());
31656
31888
  return ret;
31657
31889
  }
31658
31890
  }
@@ -31839,7 +32071,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31839
32071
  });
31840
32072
  append($$anchor2, fragment);
31841
32073
  };
31842
- component(node, () => Calendar$2, ($$anchor2, Calendar_Root) => {
32074
+ component(node, () => Calendar$1, ($$anchor2, Calendar_Root) => {
31843
32075
  Calendar_Root($$anchor2, {
31844
32076
  weekdayFormat: "long",
31845
32077
  fixedWeeks: true,
@@ -31875,15 +32107,18 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31875
32107
  }
31876
32108
  create_custom_element(CalendarUI, { calendarClass: {} }, [], ["details"], true);
31877
32109
  var root$1 = /* @__PURE__ */ from_html(`<div data-calendar-wrapper=""><!></div>`);
31878
- function Calendar($$anchor, $$props) {
32110
+ function Calendar_1($$anchor, $$props) {
31879
32111
  push($$props, true);
31880
- const ticketsCalendar = new TicketsCalendar();
32112
+ const ticketsCalendar = new Calendar();
31881
32113
  const details = ticketsCalendar;
31882
32114
  const _ticketSelectionDetails = getTicketSelectionDetails($$props.$$host);
31883
32115
  const ticketSelectionDetails = /* @__PURE__ */ user_derived(() => _ticketSelectionDetails.value);
31884
32116
  user_effect(() => {
31885
32117
  ticketsCalendar.details = get$2(ticketSelectionDetails);
31886
- if (get$2(ticketSelectionDetails)) get$2(ticketSelectionDetails).selectedDate = void 0;
32118
+ if (get$2(ticketSelectionDetails)) {
32119
+ get$2(ticketSelectionDetails).mode;
32120
+ get$2(ticketSelectionDetails).selectedDate = void 0;
32121
+ }
31887
32122
  });
31888
32123
  let wrapper = /* @__PURE__ */ state(void 0);
31889
32124
  onMount(() => {
@@ -31903,7 +32138,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31903
32138
  });
31904
32139
  };
31905
32140
  if_block(node, ($$render) => {
31906
- if (get$2(ticketSelectionDetails)?.mode === "ticket" && !get$2(ticketSelectionDetails).filters?.includes("annual")) $$render(consequent);
32141
+ if (get$2(ticketSelectionDetails)?.isCalendarVisible) $$render(consequent);
31907
32142
  });
31908
32143
  }
31909
32144
  reset(div);
@@ -31911,7 +32146,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31911
32146
  append($$anchor, div);
31912
32147
  return pop($$exports);
31913
32148
  }
31914
- customElements.define("go-calendar", create_custom_element(Calendar, {}, [], ["details"], false));
32149
+ customElements.define("go-calendar", create_custom_element(Calendar_1, {}, [], ["details"], false));
31915
32150
  class Details {
31916
32151
  #ticketSelectionDetails;
31917
32152
  get ticketSelectionDetails() {
@@ -31935,7 +32170,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31935
32170
  }
31936
32171
  const preCarts = this.ticketSelectionDetails.preCarts;
31937
32172
  const newItems = preCarts.flatMap((pc) => {
31938
- return pc.nonEmptyItems.map((i) => createCartItem(i.item, { quantity: i.quantity, time: i.time }));
32173
+ return pc.nonEmptyItems.map((i) => createCartItem(i.product, { quantity: i.quantity, time: i.time }));
31939
32174
  });
31940
32175
  cart.addItems(newItems);
31941
32176
  preCarts.forEach((pc) => pc.items.forEach((i) => i.quantity = 0));
@@ -31972,4 +32207,33 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31972
32207
  }
31973
32208
  delegate(["click"]);
31974
32209
  customElements.define("go-add-to-cart-button", create_custom_element(AddToCartButton, {}, [], ["details"], false));
32210
+ function Link($$anchor, $$props) {
32211
+ push($$props, true);
32212
+ const to = prop($$props, "to", 7);
32213
+ const href = /* @__PURE__ */ user_derived(() => go.config.urls[to()]);
32214
+ const a2 = wrapInElement($$props.$$host, "a");
32215
+ user_effect(() => {
32216
+ if (!get$2(href)) {
32217
+ console.warn(`[go-link] No URL found for route "${to()}".`);
32218
+ a2.removeAttribute("href");
32219
+ return;
32220
+ }
32221
+ a2.setAttribute("href", get$2(href)());
32222
+ });
32223
+ a2.addEventListener("click", (e) => {
32224
+ e.preventDefault();
32225
+ go.config.navigateTo(go.config.urls[to()]());
32226
+ });
32227
+ var $$exports = {
32228
+ get to() {
32229
+ return to();
32230
+ },
32231
+ set to($$value) {
32232
+ to($$value);
32233
+ flushSync();
32234
+ }
32235
+ };
32236
+ return pop($$exports);
32237
+ }
32238
+ customElements.define("go-link", create_custom_element(Link, { to: { attribute: "to", reflect: true, type: "String" } }, [], [], false));
31975
32239
  })();