@gomusdev/web-components 4.5.0 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.6.0 (2026-07-14)
4
+
5
+ ### Features
6
+
7
+ * **go:** add go.api.getCustomerMemberships to the window API
8
+
9
+ ### Bug Fixes
10
+
11
+ * **cart:** harden annual-ticket / service-voucher redemption
12
+
3
13
  ## 4.5.0 (2026-07-13)
4
14
 
5
15
  ### Features
@@ -12279,6 +12279,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
12279
12279
  if (isUITour(this.product)) segments.push(`tour: ${this.product.instanceKey}`);
12280
12280
  if (this.display?.discounted) segments.push("discounted");
12281
12281
  if (isMantleTicket(this.product) && this.mantle?.key) segments.push(`mantle_key: ${this.mantle.key}`);
12282
+ if (this.voucher?.code) segments.push(`voucher_code: ${this.voucher.code}`);
12282
12283
  return segments.length > 0 ? ` (${segments.join(", ")})` : "";
12283
12284
  },
12284
12285
  toString() {
@@ -12369,7 +12370,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
12369
12370
  return createCartItem(createUITicket(cartItem.product, { selectedTime: cartItem.product.selectedTime }), {
12370
12371
  time: cartItem.time,
12371
12372
  quantity: cartItem.quantity,
12372
- mantle: cartItem.mantle
12373
+ mantle: cartItem.mantle,
12374
+ voucher: cartItem.voucher
12373
12375
  });
12374
12376
  case "Event":
12375
12377
  if (!isStillValid(cartItem)) return;
@@ -12517,6 +12519,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
12517
12519
  },
12518
12520
  deleteItem(item) {
12519
12521
  for (let i = this.items.length - 1; i >= 0; i--) if (this.items[i].uuid === item.uuid) this.items.splice(i, 1);
12522
+ if (item?.voucher?.code && !this.items.some((i) => i.voucher?.code === item.voucher.code)) this.removeCoupon(item.voucher.code);
12520
12523
  },
12521
12524
  addItem(item) {
12522
12525
  const existingItem = this.items.find((i) => i.uuid === item.uuid);
@@ -12535,7 +12538,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
12535
12538
  removeCoupon(code) {
12536
12539
  const upper = code.toUpperCase();
12537
12540
  const index = this.coupons.findIndex((c) => c.code === upper);
12538
- if (index > -1) this.coupons.splice(index, 1);
12541
+ if (index > -1) {
12542
+ const [removed] = this.coupons.splice(index, 1);
12543
+ if (removed.kind === "serviceVoucher") {
12544
+ for (let i = this.items.length - 1; i >= 0; i--) if (this.items[i].voucher?.code === upper) this.items.splice(i, 1);
12545
+ }
12546
+ }
12539
12547
  },
12540
12548
  clearCoupons() {
12541
12549
  while (this.coupons.length > 0) this.coupons.pop();
@@ -13633,6 +13641,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13633
13641
  var MEMBERSHIP_ACTIVATION_ENDPOINT = "/api/v4/customer/memberships/activate";
13634
13642
  var ORDERS_ENDPOINT = "/api/v4/orders";
13635
13643
  var CUSTOMER_ADDRESSES_ENDPOINT = "/api/v4/customer/customer_addresses";
13644
+ var CUSTOMER_MEMBERSHIPS_ENDPOINT = "/api/v4/customer/memberships";
13636
13645
  //#endregion
13637
13646
  //#region ../../packages/gomus-api/lib/customerLevels.ts
13638
13647
  var CustomerLevels = {
@@ -13758,6 +13767,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13758
13767
  if (!this.auth.data.accessToken) return NOT_SIGNED_IN;
13759
13768
  return this.fetchAndCache(CUSTOMER_ADDRESSES_ENDPOINT, "customerAddresses", "", { cache: 5 });
13760
13769
  }
13770
+ getCustomerMemberships() {
13771
+ if (!this.auth.data.accessToken) return NOT_SIGNED_IN;
13772
+ return this.fetchAndCache(CUSTOMER_MEMBERSHIPS_ENDPOINT, "customerMemberships", "", { cache: 5 });
13773
+ }
13761
13774
  ticketsCalendar(params) {
13762
13775
  return this.fetchAndCache(TICKETS_CALENDAR_ENDPOINT, `ticketsCalendar-${JSON.stringify(params)}`, "data", {
13763
13776
  cache: 60,
@@ -13955,7 +13968,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13955
13968
  });
13956
13969
  }
13957
13970
  getCouponSaleByBarcode(token) {
13958
- return this.fetchAndCache(`/api/v4/coupon_sales/barcode/${token}`, `coupon_sale_barcode_${token}`, "coupon_sale");
13971
+ return this.fetchAndCache(`/api/v4/coupon_sales/barcode/${token}`, `coupon_sale_barcode_${token}`, "coupon_sale", { cache: 0 });
13959
13972
  }
13960
13973
  getCoupons() {
13961
13974
  return this.fetchAndCache("/api/v4/coupons", "coupons", "coupons", { query: {
@@ -15214,8 +15227,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15214
15227
  }
15215
15228
  function createDisplayCartItem(cartItem, attrs) {
15216
15229
  const quantity = isUITour(cartItem.product) ? 1 : resolveApiQuantity(attrs);
15217
- const displayPrice = attrs.price_cents ?? cartItem.product.price_cents;
15218
15230
  const originalPrice = cartItem.product.price_cents;
15231
+ const displayPrice = originalPrice === 0 ? 0 : attrs.price_cents ?? originalPrice;
15219
15232
  const discounted = displayPrice < originalPrice;
15220
15233
  return createCartItem({
15221
15234
  ...cartItem.product,
@@ -15223,6 +15236,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15223
15236
  }, {
15224
15237
  quantity,
15225
15238
  time: cartItem.time,
15239
+ voucher: cartItem.voucher,
15226
15240
  mantle: cartItem.mantle,
15227
15241
  display: {
15228
15242
  discounted,
@@ -17836,10 +17850,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17836
17850
  var root$47 = /* @__PURE__ */ from_html(`<s class="go-cart-item-price-original"> </s> <span class="go-cart-item-price-discounted"> </span>`, 1);
17837
17851
  var root_1$15 = /* @__PURE__ */ from_html(`<span class="go-cart-item-price-discounted"> </span>`);
17838
17852
  var root_2$11 = /* @__PURE__ */ from_html(`<span data-testid="cart-item-participant-count"> </span>`);
17839
- var root_3$8 = /* @__PURE__ */ from_html(`<span> </span>`);
17840
- var root_4$4 = /* @__PURE__ */ from_html(`<li class="go-cart-item-remove"><button class="go-cart-remove">⨉</button></li>`);
17841
- var root_5$2 = /* @__PURE__ */ from_html(`<ul class="go-sub-tickets" role="list"></ul>`);
17842
- var root_6$2 = /* @__PURE__ */ from_html(`<article class="go-cart-item-content"><ul><li class="go-cart-item-title-container"><!></li> <li class="go-cart-item-price"><!></li> <li class="go-cart-item-count"><!></li> <!> <li class="go-cart-item-sum"> </li></ul></article> <!>`, 1);
17853
+ var root_3$8 = /* @__PURE__ */ from_html(`<span data-testid="cart-item-voucher-quantity"> </span>`);
17854
+ var root_4$4 = /* @__PURE__ */ from_html(`<span> </span>`);
17855
+ var root_5$2 = /* @__PURE__ */ from_html(`<li class="go-cart-item-remove"><button class="go-cart-remove">⨉</button></li>`);
17856
+ var root_6$2 = /* @__PURE__ */ from_html(`<ul class="go-sub-tickets" role="list"></ul>`);
17857
+ var root_7$2 = /* @__PURE__ */ from_html(`<article class="go-cart-item-content"><ul><li class="go-cart-item-title-container"><!></li> <li class="go-cart-item-price"><!></li> <li class="go-cart-item-count"><!></li> <!> <li class="go-cart-item-sum"> </li></ul></article> <!>`, 1);
17843
17858
  function Item$1($$anchor, $$props) {
17844
17859
  push($$props, true);
17845
17860
  let displayItem = prop($$props, "displayItem", 7), displayCart = prop($$props, "displayCart", 7), preview = prop($$props, "preview", 7);
@@ -17904,8 +17919,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17904
17919
  };
17905
17920
  var fragment = comment();
17906
17921
  var node = first_child(fragment);
17907
- var consequent_9 = ($$anchor) => {
17908
- var fragment_1 = root_6$2();
17922
+ var consequent_10 = ($$anchor) => {
17923
+ var fragment_1 = root_7$2();
17909
17924
  var article = first_child(fragment_1);
17910
17925
  var ul = child(article);
17911
17926
  var li = child(ul);
@@ -17981,6 +17996,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17981
17996
  template_effect(() => set_text(text_4, displayItem().quantity));
17982
17997
  append($$anchor, span_3);
17983
17998
  };
17999
+ var consequent_7 = ($$anchor) => {
18000
+ var span_4 = root_4$4();
18001
+ var text_5 = child(span_4, true);
18002
+ reset(span_4);
18003
+ template_effect(() => set_text(text_5, displayItem().quantity));
18004
+ append($$anchor, span_4);
18005
+ };
17984
18006
  var alternate_1 = ($$anchor) => {
17985
18007
  {
17986
18008
  let $0 = /* @__PURE__ */ user_derived(() => displayItem().quantity ?? 0);
@@ -18004,13 +18026,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18004
18026
  };
18005
18027
  if_block(node_3, ($$render) => {
18006
18028
  if (displayItem().product.type === "Tour") $$render(consequent_5);
18007
- else if (preview()) $$render(consequent_6, 1);
18029
+ else if (displayItem().voucher?.code) $$render(consequent_6, 1);
18030
+ else if (preview()) $$render(consequent_7, 2);
18008
18031
  else $$render(alternate_1, -1);
18009
18032
  });
18010
18033
  reset(li_2);
18011
18034
  var node_4 = sibling(li_2, 2);
18012
- var consequent_7 = ($$anchor) => {
18013
- var li_3 = root_4$4();
18035
+ var consequent_8 = ($$anchor) => {
18036
+ var li_3 = root_5$2();
18014
18037
  var button = child(li_3);
18015
18038
  reset(li_3);
18016
18039
  template_effect(($0) => set_attribute(button, "aria-label", $0), [() => shop.t("cart.item.remove")]);
@@ -18018,16 +18041,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18018
18041
  append($$anchor, li_3);
18019
18042
  };
18020
18043
  if_block(node_4, ($$render) => {
18021
- if (!preview()) $$render(consequent_7);
18044
+ if (!preview()) $$render(consequent_8);
18022
18045
  });
18023
18046
  var li_4 = sibling(node_4, 2);
18024
- var text_5 = child(li_4, true);
18047
+ var text_6 = child(li_4, true);
18025
18048
  reset(li_4);
18026
18049
  reset(ul);
18027
18050
  reset(article);
18028
18051
  var node_5 = sibling(article, 2);
18029
- var consequent_8 = ($$anchor) => {
18030
- var ul_1 = root_5$2();
18052
+ var consequent_9 = ($$anchor) => {
18053
+ var ul_1 = root_6$2();
18031
18054
  each(ul_1, 21, () => subTicketDefs(get$2(mantleProduct)), (sub) => sub.id, ($$anchor, sub) => {
18032
18055
  {
18033
18056
  let $0 = /* @__PURE__ */ user_derived(() => displayItem().mantle?.composition?.[get$2(sub).id] ?? 0);
@@ -18053,13 +18076,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18053
18076
  append($$anchor, ul_1);
18054
18077
  };
18055
18078
  if_block(node_5, ($$render) => {
18056
- if (get$2(mantleProduct)) $$render(consequent_8);
18079
+ if (get$2(mantleProduct)) $$render(consequent_9);
18057
18080
  });
18058
- template_effect(($0) => set_text(text_5, $0), [() => formatCurrency(displayItem().total_price_cents)]);
18081
+ template_effect(($0) => set_text(text_6, $0), [() => formatCurrency(displayItem().total_price_cents)]);
18059
18082
  append($$anchor, fragment_1);
18060
18083
  };
18061
18084
  if_block(node, ($$render) => {
18062
- if (get$2(capacity)) $$render(consequent_9);
18085
+ if (get$2(capacity)) $$render(consequent_10);
18063
18086
  });
18064
18087
  append($$anchor, fragment);
18065
18088
  return pop($$exports);
@@ -18502,15 +18525,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18502
18525
  return { success: true };
18503
18526
  }
18504
18527
  async function applyVoucher(token, couponSale) {
18505
- const ticket = (await shop.asyncFetch(() => shop.tickets({ "by_ticket_ids[]": [couponSale.is_voucher_for] }))).find((t) => t.id === couponSale.is_voucher_for);
18528
+ const code = token.toUpperCase();
18529
+ if (shop.cart.coupons.some((c) => c.code === code)) return { success: true };
18530
+ const tickets = await shop.asyncFetch(() => shop.tickets({ "by_ticket_ids[]": [couponSale.is_voucher_for] }));
18531
+ const ticket = Array.isArray(tickets) ? tickets.find((t) => t.id === couponSale.is_voucher_for) : void 0;
18506
18532
  if (!ticket) return fail([shop.t("cart.coupon.form.errors.error")]);
18507
18533
  const voucherTicket = {
18508
18534
  ...ticket,
18509
18535
  price_cents: 0
18510
18536
  };
18511
- shop.cart.addItem(createCartItem(createUITicket(voucherTicket), { quantity: 1 }));
18537
+ shop.cart.addItem(createCartItem(createUITicket(voucherTicket), {
18538
+ quantity: 1,
18539
+ voucher: { code }
18540
+ }));
18512
18541
  shop.cart.addCoupon({
18513
- code: token,
18542
+ code,
18514
18543
  kind: "serviceVoucher"
18515
18544
  });
18516
18545
  return { success: true };
@@ -38212,6 +38241,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
38212
38241
  getCustomerAddresses: async () => {
38213
38242
  await ensureShopReady();
38214
38243
  return shop.asyncFetch(() => shop.getCustomerAddresses());
38244
+ },
38245
+ getCustomerMemberships: async () => {
38246
+ await ensureShopReady();
38247
+ return shop.asyncFetch(() => shop.getCustomerMemberships());
38215
38248
  }
38216
38249
  },
38217
38250
  cart: { addTour: async (options) => {
@@ -12278,6 +12278,7 @@ function createCartItem(product, options) {
12278
12278
  if (isUITour(this.product)) segments.push(`tour: ${this.product.instanceKey}`);
12279
12279
  if (this.display?.discounted) segments.push("discounted");
12280
12280
  if (isMantleTicket(this.product) && this.mantle?.key) segments.push(`mantle_key: ${this.mantle.key}`);
12281
+ if (this.voucher?.code) segments.push(`voucher_code: ${this.voucher.code}`);
12281
12282
  return segments.length > 0 ? ` (${segments.join(", ")})` : "";
12282
12283
  },
12283
12284
  toString() {
@@ -12368,7 +12369,8 @@ function generateCartItem(cartItem) {
12368
12369
  return createCartItem(createUITicket(cartItem.product, { selectedTime: cartItem.product.selectedTime }), {
12369
12370
  time: cartItem.time,
12370
12371
  quantity: cartItem.quantity,
12371
- mantle: cartItem.mantle
12372
+ mantle: cartItem.mantle,
12373
+ voucher: cartItem.voucher
12372
12374
  });
12373
12375
  case "Event":
12374
12376
  if (!isStillValid(cartItem)) return;
@@ -12516,6 +12518,7 @@ function createCart(products, contingent = 20) {
12516
12518
  },
12517
12519
  deleteItem(item) {
12518
12520
  for (let i = this.items.length - 1; i >= 0; i--) if (this.items[i].uuid === item.uuid) this.items.splice(i, 1);
12521
+ if (item?.voucher?.code && !this.items.some((i) => i.voucher?.code === item.voucher.code)) this.removeCoupon(item.voucher.code);
12519
12522
  },
12520
12523
  addItem(item) {
12521
12524
  const existingItem = this.items.find((i) => i.uuid === item.uuid);
@@ -12534,7 +12537,12 @@ function createCart(products, contingent = 20) {
12534
12537
  removeCoupon(code) {
12535
12538
  const upper = code.toUpperCase();
12536
12539
  const index = this.coupons.findIndex((c) => c.code === upper);
12537
- if (index > -1) this.coupons.splice(index, 1);
12540
+ if (index > -1) {
12541
+ const [removed] = this.coupons.splice(index, 1);
12542
+ if (removed.kind === "serviceVoucher") {
12543
+ for (let i = this.items.length - 1; i >= 0; i--) if (this.items[i].voucher?.code === upper) this.items.splice(i, 1);
12544
+ }
12545
+ }
12538
12546
  },
12539
12547
  clearCoupons() {
12540
12548
  while (this.coupons.length > 0) this.coupons.pop();
@@ -13632,6 +13640,7 @@ var WITHDRAWAL_ENDPOINT = "/api/v4/orders/withdrawals";
13632
13640
  var MEMBERSHIP_ACTIVATION_ENDPOINT = "/api/v4/customer/memberships/activate";
13633
13641
  var ORDERS_ENDPOINT = "/api/v4/orders";
13634
13642
  var CUSTOMER_ADDRESSES_ENDPOINT = "/api/v4/customer/customer_addresses";
13643
+ var CUSTOMER_MEMBERSHIPS_ENDPOINT = "/api/v4/customer/memberships";
13635
13644
  //#endregion
13636
13645
  //#region ../../packages/gomus-api/lib/customerLevels.ts
13637
13646
  var CustomerLevels = {
@@ -13757,6 +13766,10 @@ var Shop = class {
13757
13766
  if (!this.auth.data.accessToken) return NOT_SIGNED_IN;
13758
13767
  return this.fetchAndCache(CUSTOMER_ADDRESSES_ENDPOINT, "customerAddresses", "", { cache: 5 });
13759
13768
  }
13769
+ getCustomerMemberships() {
13770
+ if (!this.auth.data.accessToken) return NOT_SIGNED_IN;
13771
+ return this.fetchAndCache(CUSTOMER_MEMBERSHIPS_ENDPOINT, "customerMemberships", "", { cache: 5 });
13772
+ }
13760
13773
  ticketsCalendar(params) {
13761
13774
  return this.fetchAndCache(TICKETS_CALENDAR_ENDPOINT, `ticketsCalendar-${JSON.stringify(params)}`, "data", {
13762
13775
  cache: 60,
@@ -13954,7 +13967,7 @@ var Shop = class {
13954
13967
  });
13955
13968
  }
13956
13969
  getCouponSaleByBarcode(token) {
13957
- return this.fetchAndCache(`/api/v4/coupon_sales/barcode/${token}`, `coupon_sale_barcode_${token}`, "coupon_sale");
13970
+ return this.fetchAndCache(`/api/v4/coupon_sales/barcode/${token}`, `coupon_sale_barcode_${token}`, "coupon_sale", { cache: 0 });
13958
13971
  }
13959
13972
  getCoupons() {
13960
13973
  return this.fetchAndCache("/api/v4/coupons", "coupons", "coupons", { query: {
@@ -15213,8 +15226,8 @@ function createDisplayCart(baseCart, apiItems) {
15213
15226
  }
15214
15227
  function createDisplayCartItem(cartItem, attrs) {
15215
15228
  const quantity = isUITour(cartItem.product) ? 1 : resolveApiQuantity(attrs);
15216
- const displayPrice = attrs.price_cents ?? cartItem.product.price_cents;
15217
15229
  const originalPrice = cartItem.product.price_cents;
15230
+ const displayPrice = originalPrice === 0 ? 0 : attrs.price_cents ?? originalPrice;
15218
15231
  const discounted = displayPrice < originalPrice;
15219
15232
  return createCartItem({
15220
15233
  ...cartItem.product,
@@ -15222,6 +15235,7 @@ function createDisplayCartItem(cartItem, attrs) {
15222
15235
  }, {
15223
15236
  quantity,
15224
15237
  time: cartItem.time,
15238
+ voucher: cartItem.voucher,
15225
15239
  mantle: cartItem.mantle,
15226
15240
  display: {
15227
15241
  discounted,
@@ -17835,10 +17849,11 @@ create_custom_element(SubRow, {
17835
17849
  var root$47 = /* @__PURE__ */ from_html(`<s class="go-cart-item-price-original"> </s> <span class="go-cart-item-price-discounted"> </span>`, 1);
17836
17850
  var root_1$15 = /* @__PURE__ */ from_html(`<span class="go-cart-item-price-discounted"> </span>`);
17837
17851
  var root_2$11 = /* @__PURE__ */ from_html(`<span data-testid="cart-item-participant-count"> </span>`);
17838
- var root_3$8 = /* @__PURE__ */ from_html(`<span> </span>`);
17839
- var root_4$4 = /* @__PURE__ */ from_html(`<li class="go-cart-item-remove"><button class="go-cart-remove">⨉</button></li>`);
17840
- var root_5$2 = /* @__PURE__ */ from_html(`<ul class="go-sub-tickets" role="list"></ul>`);
17841
- var root_6$2 = /* @__PURE__ */ from_html(`<article class="go-cart-item-content"><ul><li class="go-cart-item-title-container"><!></li> <li class="go-cart-item-price"><!></li> <li class="go-cart-item-count"><!></li> <!> <li class="go-cart-item-sum"> </li></ul></article> <!>`, 1);
17852
+ var root_3$8 = /* @__PURE__ */ from_html(`<span data-testid="cart-item-voucher-quantity"> </span>`);
17853
+ var root_4$4 = /* @__PURE__ */ from_html(`<span> </span>`);
17854
+ var root_5$2 = /* @__PURE__ */ from_html(`<li class="go-cart-item-remove"><button class="go-cart-remove">⨉</button></li>`);
17855
+ var root_6$2 = /* @__PURE__ */ from_html(`<ul class="go-sub-tickets" role="list"></ul>`);
17856
+ var root_7$2 = /* @__PURE__ */ from_html(`<article class="go-cart-item-content"><ul><li class="go-cart-item-title-container"><!></li> <li class="go-cart-item-price"><!></li> <li class="go-cart-item-count"><!></li> <!> <li class="go-cart-item-sum"> </li></ul></article> <!>`, 1);
17842
17857
  function Item$1($$anchor, $$props) {
17843
17858
  push($$props, true);
17844
17859
  let displayItem = prop($$props, "displayItem", 7), displayCart = prop($$props, "displayCart", 7), preview = prop($$props, "preview", 7);
@@ -17903,8 +17918,8 @@ function Item$1($$anchor, $$props) {
17903
17918
  };
17904
17919
  var fragment = comment();
17905
17920
  var node = first_child(fragment);
17906
- var consequent_9 = ($$anchor) => {
17907
- var fragment_1 = root_6$2();
17921
+ var consequent_10 = ($$anchor) => {
17922
+ var fragment_1 = root_7$2();
17908
17923
  var article = first_child(fragment_1);
17909
17924
  var ul = child(article);
17910
17925
  var li = child(ul);
@@ -17980,6 +17995,13 @@ function Item$1($$anchor, $$props) {
17980
17995
  template_effect(() => set_text(text_4, displayItem().quantity));
17981
17996
  append($$anchor, span_3);
17982
17997
  };
17998
+ var consequent_7 = ($$anchor) => {
17999
+ var span_4 = root_4$4();
18000
+ var text_5 = child(span_4, true);
18001
+ reset(span_4);
18002
+ template_effect(() => set_text(text_5, displayItem().quantity));
18003
+ append($$anchor, span_4);
18004
+ };
17983
18005
  var alternate_1 = ($$anchor) => {
17984
18006
  {
17985
18007
  let $0 = /* @__PURE__ */ user_derived(() => displayItem().quantity ?? 0);
@@ -18003,13 +18025,14 @@ function Item$1($$anchor, $$props) {
18003
18025
  };
18004
18026
  if_block(node_3, ($$render) => {
18005
18027
  if (displayItem().product.type === "Tour") $$render(consequent_5);
18006
- else if (preview()) $$render(consequent_6, 1);
18028
+ else if (displayItem().voucher?.code) $$render(consequent_6, 1);
18029
+ else if (preview()) $$render(consequent_7, 2);
18007
18030
  else $$render(alternate_1, -1);
18008
18031
  });
18009
18032
  reset(li_2);
18010
18033
  var node_4 = sibling(li_2, 2);
18011
- var consequent_7 = ($$anchor) => {
18012
- var li_3 = root_4$4();
18034
+ var consequent_8 = ($$anchor) => {
18035
+ var li_3 = root_5$2();
18013
18036
  var button = child(li_3);
18014
18037
  reset(li_3);
18015
18038
  template_effect(($0) => set_attribute(button, "aria-label", $0), [() => shop.t("cart.item.remove")]);
@@ -18017,16 +18040,16 @@ function Item$1($$anchor, $$props) {
18017
18040
  append($$anchor, li_3);
18018
18041
  };
18019
18042
  if_block(node_4, ($$render) => {
18020
- if (!preview()) $$render(consequent_7);
18043
+ if (!preview()) $$render(consequent_8);
18021
18044
  });
18022
18045
  var li_4 = sibling(node_4, 2);
18023
- var text_5 = child(li_4, true);
18046
+ var text_6 = child(li_4, true);
18024
18047
  reset(li_4);
18025
18048
  reset(ul);
18026
18049
  reset(article);
18027
18050
  var node_5 = sibling(article, 2);
18028
- var consequent_8 = ($$anchor) => {
18029
- var ul_1 = root_5$2();
18051
+ var consequent_9 = ($$anchor) => {
18052
+ var ul_1 = root_6$2();
18030
18053
  each(ul_1, 21, () => subTicketDefs(get$2(mantleProduct)), (sub) => sub.id, ($$anchor, sub) => {
18031
18054
  {
18032
18055
  let $0 = /* @__PURE__ */ user_derived(() => displayItem().mantle?.composition?.[get$2(sub).id] ?? 0);
@@ -18052,13 +18075,13 @@ function Item$1($$anchor, $$props) {
18052
18075
  append($$anchor, ul_1);
18053
18076
  };
18054
18077
  if_block(node_5, ($$render) => {
18055
- if (get$2(mantleProduct)) $$render(consequent_8);
18078
+ if (get$2(mantleProduct)) $$render(consequent_9);
18056
18079
  });
18057
- template_effect(($0) => set_text(text_5, $0), [() => formatCurrency(displayItem().total_price_cents)]);
18080
+ template_effect(($0) => set_text(text_6, $0), [() => formatCurrency(displayItem().total_price_cents)]);
18058
18081
  append($$anchor, fragment_1);
18059
18082
  };
18060
18083
  if_block(node, ($$render) => {
18061
- if (get$2(capacity)) $$render(consequent_9);
18084
+ if (get$2(capacity)) $$render(consequent_10);
18062
18085
  });
18063
18086
  append($$anchor, fragment);
18064
18087
  return pop($$exports);
@@ -18501,15 +18524,21 @@ function applyValueCoupon(token, valueCents) {
18501
18524
  return { success: true };
18502
18525
  }
18503
18526
  async function applyVoucher(token, couponSale) {
18504
- const ticket = (await shop.asyncFetch(() => shop.tickets({ "by_ticket_ids[]": [couponSale.is_voucher_for] }))).find((t) => t.id === couponSale.is_voucher_for);
18527
+ const code = token.toUpperCase();
18528
+ if (shop.cart.coupons.some((c) => c.code === code)) return { success: true };
18529
+ const tickets = await shop.asyncFetch(() => shop.tickets({ "by_ticket_ids[]": [couponSale.is_voucher_for] }));
18530
+ const ticket = Array.isArray(tickets) ? tickets.find((t) => t.id === couponSale.is_voucher_for) : void 0;
18505
18531
  if (!ticket) return fail([shop.t("cart.coupon.form.errors.error")]);
18506
18532
  const voucherTicket = {
18507
18533
  ...ticket,
18508
18534
  price_cents: 0
18509
18535
  };
18510
- shop.cart.addItem(createCartItem(createUITicket(voucherTicket), { quantity: 1 }));
18536
+ shop.cart.addItem(createCartItem(createUITicket(voucherTicket), {
18537
+ quantity: 1,
18538
+ voucher: { code }
18539
+ }));
18511
18540
  shop.cart.addCoupon({
18512
- code: token,
18541
+ code,
18513
18542
  kind: "serviceVoucher"
18514
18543
  });
18515
18544
  return { success: true };
@@ -38211,6 +38240,10 @@ var go = {
38211
38240
  getCustomerAddresses: async () => {
38212
38241
  await ensureShopReady();
38213
38242
  return shop.asyncFetch(() => shop.getCustomerAddresses());
38243
+ },
38244
+ getCustomerMemberships: async () => {
38245
+ await ensureShopReady();
38246
+ return shop.asyncFetch(() => shop.getCustomerMemberships());
38214
38247
  }
38215
38248
  },
38216
38249
  cart: { addTour: async (options) => {