@gomusdev/web-components 1.34.0 → 1.36.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.
@@ -0,0 +1 @@
1
+ export { SvelteComponent as default } from 'svelte';
File without changes
@@ -0,0 +1,2 @@
1
+ import { default as UIForm } from '../forms/ui/generic/Form.svelte';
2
+ export declare function redeem(form: UIForm): Promise<void>;
@@ -7,12 +7,14 @@ type defineFormOptions = {
7
7
  id: string;
8
8
  fields: FormField[];
9
9
  requiredApiKeys?: string[];
10
+ submitLabel?: string;
10
11
  };
11
12
  export declare class Forms {
12
13
  #private;
13
14
  static defineForm(options: defineFormOptions): void;
14
15
  static defineFields(fields: Record<string, FieldInit>): void;
15
16
  static setRequiredApiKeys(formId: string, requiredApiKeys: string[]): void;
17
+ static getFormOptions(formId: string): any;
16
18
  static createField(key: string, required: boolean): Field;
17
19
  static getFormFields(formId: string): any;
18
20
  static getFieldInit(key: string): any;
@@ -4,6 +4,7 @@ export type TicketSegmentFilter = 'timeslot' | 'annual' | 'custom' | 'day' | 'ev
4
4
  export declare class SegmentDetails {
5
5
  preCart: {
6
6
  items: import('../../../../../../lib/models/cart/types').CartItem[];
7
+ coupons: string[];
7
8
  contingent: number;
8
9
  uid: string;
9
10
  readonly nonEmptyItems: import('../../../../../../lib/models/cart/types').CartItem[];
@@ -32,7 +33,7 @@ export declare class SegmentDetails {
32
33
  comment: null;
33
34
  reference: null;
34
35
  payment_mode_id: string;
35
- coupons: never[];
36
+ coupons: string[];
36
37
  donations: never[];
37
38
  affiliate: {};
38
39
  total: number;
@@ -43,6 +44,9 @@ export declare class SegmentDetails {
43
44
  addItem(item: import('../../../../../../lib/models/cart/types').CartItem): void;
44
45
  addItems(items: import('../../../../../../lib/models/cart/types').CartItem[]): void;
45
46
  addProducts(products: import('../../../../../../lib/models/cart/types').Product[]): void;
47
+ addCoupon(token: string): void;
48
+ removeCoupon(token: string): void;
49
+ clearCoupons(): void;
46
50
  };
47
51
  filters: TicketSegmentFilter;
48
52
  ticketSelectionDetails: TicketSelectionDetails | undefined;
@@ -7,6 +7,7 @@ export type FormConfig = {
7
7
  required: boolean;
8
8
  }[];
9
9
  beforeSubmit?: (formData: Record<string, unknown>) => void;
10
+ submitLabel?: string;
10
11
  };
11
12
  export type ConfigOptions = {
12
13
  urls?: Partial<ShopUrls>;
@@ -11250,7 +11250,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11250
11250
  };
11251
11251
  }
11252
11252
  function updateLocalStorage(cart) {
11253
- const content = JSON.stringify(cart.items || []);
11253
+ const content = JSON.stringify({ items: cart.items || [], coupons: cart.coupons || [] });
11254
11254
  localStorage.setItem("go-cart", content);
11255
11255
  return content;
11256
11256
  }
@@ -11271,23 +11271,32 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11271
11271
  }
11272
11272
  function loadFromLocalStorage(cart) {
11273
11273
  let lsItems = [];
11274
+ let lsCoupons = [];
11274
11275
  try {
11275
11276
  const content = localStorage.getItem("go-cart");
11276
11277
  if (!content) return [];
11277
- lsItems = JSON.parse(content);
11278
- if (!Array.isArray(lsItems)) {
11279
- console.dir({ lsItems, content });
11280
- throw new Error("go-cart is not an array");
11278
+ const parsed = JSON.parse(content);
11279
+ if (Array.isArray(parsed)) {
11280
+ lsItems = parsed;
11281
+ lsCoupons = [];
11282
+ } else if (typeof parsed === "object" && parsed !== null) {
11283
+ lsItems = parsed.items || [];
11284
+ lsCoupons = parsed.coupons || [];
11285
+ } else {
11286
+ console.dir({ parsed, content });
11287
+ throw new Error("go-cart has invalid format");
11281
11288
  }
11282
11289
  if (lsItems.length === 0) {
11283
11290
  cart.clearItems();
11284
- return [];
11291
+ } else {
11292
+ cart.items = lsItems.map(generateCartItem).filter(defined);
11285
11293
  }
11286
- cart.items = lsItems.map(generateCartItem).filter(defined);
11294
+ cart.clearCoupons();
11295
+ lsCoupons.forEach((coupon) => cart.addCoupon(coupon));
11287
11296
  return cart.items;
11288
11297
  } catch (e) {
11289
11298
  console.error(e);
11290
- localStorage.setItem("go-cart", JSON.stringify([]));
11299
+ localStorage.setItem("go-cart", JSON.stringify({ items: [], coupons: [] }));
11291
11300
  return [];
11292
11301
  }
11293
11302
  }
@@ -11324,8 +11333,10 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11324
11333
  let lastUuid = 0;
11325
11334
  function createCart(products, contingent = 20) {
11326
11335
  const items = proxy([]);
11336
+ const coupons = proxy([]);
11327
11337
  const cart = {
11328
11338
  items,
11339
+ coupons,
11329
11340
  contingent,
11330
11341
  // caps the total number of items in the cart
11331
11342
  uid: `cart-${lastUuid++}`,
@@ -11351,7 +11362,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11351
11362
  comment: null,
11352
11363
  reference: null,
11353
11364
  payment_mode_id: shop.settings?.defaultPaymentModeId,
11354
- coupons: [],
11365
+ coupons: this.coupons,
11355
11366
  donations: [],
11356
11367
  affiliate: {},
11357
11368
  total: this.totalPriceCents
@@ -11377,6 +11388,20 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11377
11388
  },
11378
11389
  addProducts(products2) {
11379
11390
  products2.forEach((p2) => this.addItem(createCartItem(p2)));
11391
+ },
11392
+ addCoupon(token) {
11393
+ if (!this.coupons.includes(token)) {
11394
+ this.coupons.push(token);
11395
+ }
11396
+ },
11397
+ removeCoupon(token) {
11398
+ const index2 = this.coupons.indexOf(token);
11399
+ if (index2 > -1) {
11400
+ this.coupons.splice(index2, 1);
11401
+ }
11402
+ },
11403
+ clearCoupons() {
11404
+ while (this.coupons.length > 0) this.coupons.pop();
11380
11405
  }
11381
11406
  };
11382
11407
  if (products) products.forEach((p2) => cart.addItem(createCartItem(p2)));
@@ -12564,6 +12589,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
12564
12589
  requiredFields: ["date", "ticket_ids"]
12565
12590
  });
12566
12591
  }
12592
+ getCouponSaleByBarcode(token) {
12593
+ return this.fetchAndCache(`/api/v4/coupon_sales/barcode/${token}`, `coupon_sale_barcode_${token}`, "coupon_sale");
12594
+ }
12567
12595
  getEventDetailsOnDate(eventId, dateId) {
12568
12596
  return this.fetchAndCache(`/api/v4/events/${eventId}/dates/${dateId}`, `/api/v4/events/${eventId}/dates/${dateId}`, "date");
12569
12597
  }
@@ -15339,6 +15367,15 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15339
15367
  description: "",
15340
15368
  autocomplete: "off",
15341
15369
  validator: string().date()
15370
+ },
15371
+ token: {
15372
+ key: "token",
15373
+ apiKey: "id",
15374
+ type: "text",
15375
+ label: "cart.coupon.form.code",
15376
+ placeholder: "",
15377
+ description: "",
15378
+ autocomplete: "off"
15342
15379
  }
15343
15380
  };
15344
15381
  function createField(data, required) {
@@ -15383,7 +15420,11 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15383
15420
  }
15384
15421
  const _Forms = class _Forms {
15385
15422
  static defineForm(options) {
15386
- go.defineConfig({ forms: { [options.id]: { fields: options.fields } } });
15423
+ go.defineConfig({
15424
+ forms: {
15425
+ [options.id]: { fields: options.fields, submitLabel: options.submitLabel }
15426
+ }
15427
+ });
15387
15428
  }
15388
15429
  static defineFields(fields) {
15389
15430
  go.defineConfig({ fields });
@@ -15391,6 +15432,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15391
15432
  static setRequiredApiKeys(formId, requiredApiKeys) {
15392
15433
  __privateGet(_Forms, _requiredApiKeysMap)[formId] = requiredApiKeys;
15393
15434
  }
15435
+ static getFormOptions(formId) {
15436
+ return go.config.forms[formId];
15437
+ }
15394
15438
  static createField(key, required) {
15395
15439
  const init2 = _Forms.getFieldInit(key);
15396
15440
  if (!init2) {
@@ -15727,7 +15771,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15727
15771
  host.replaceChildren(element);
15728
15772
  return element;
15729
15773
  }
15730
- var root_1$i = /* @__PURE__ */ from_html(`<go-all-fields></go-all-fields> <go-form-feedback><go-errors-feedback></go-errors-feedback> <go-success-feedback></go-success-feedback></go-form-feedback> <go-submit>Submit</go-submit>`, 3);
15774
+ var root_1$i = /* @__PURE__ */ from_html(`<go-all-fields></go-all-fields> <go-form-feedback><go-errors-feedback></go-errors-feedback> <go-success-feedback></go-success-feedback></go-form-feedback> <go-submit> </go-submit>`, 3);
15731
15775
  function Form($$anchor, $$props) {
15732
15776
  push($$props, true);
15733
15777
  let formId = prop($$props, "formId", 7), custom2 = prop($$props, "custom", 7);
@@ -15773,7 +15817,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15773
15817
  var fragment_1 = root_1$i();
15774
15818
  var go_all_fields = first_child(fragment_1);
15775
15819
  var go_form_feedback = sibling(go_all_fields, 2);
15776
- sibling(go_form_feedback, 2);
15820
+ var go_submit = sibling(go_form_feedback, 2);
15821
+ var text2 = child(go_submit, true);
15822
+ reset(go_submit);
15823
+ template_effect(($0) => set_text(text2, $0), [
15824
+ () => shop.t(Forms.getFormOptions(formId())?.submitLabel || "Submit")
15825
+ ]);
15777
15826
  append($$anchor2, fragment_1);
15778
15827
  };
15779
15828
  if_block(node, ($$render) => {
@@ -15793,12 +15842,13 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15793
15842
  ["details"],
15794
15843
  false
15795
15844
  ));
15796
- var root$b = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
15845
+ var root$c = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
15797
15846
  function PasswordReset($$anchor, $$props) {
15798
15847
  push($$props, true);
15799
15848
  let custom2 = prop($$props, "custom", 7, false);
15800
15849
  Forms.defineForm({
15801
15850
  id: "passwordReset",
15851
+ submitLabel: "user.passwordReset.actions.requestPasswordReset",
15802
15852
  fields: [{ key: "email", required: true }]
15803
15853
  });
15804
15854
  async function passwordReset(event2) {
@@ -15822,7 +15872,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15822
15872
  flushSync();
15823
15873
  }
15824
15874
  };
15825
- var go_form = root$b();
15875
+ var go_form = root$c();
15826
15876
  set_custom_element_data(go_form, "formId", "passwordReset");
15827
15877
  template_effect(() => set_custom_element_data(go_form, "custom", custom2()));
15828
15878
  event("submit", go_form, passwordReset);
@@ -15830,11 +15880,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15830
15880
  return pop($$exports);
15831
15881
  }
15832
15882
  customElements.define("go-password-reset", create_custom_element(PasswordReset, { custom: {} }, [], [], false));
15833
- var root$a = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
15883
+ var root$b = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
15834
15884
  function SignIn($$anchor, $$props) {
15835
15885
  push($$props, true);
15836
15886
  Forms.defineForm({
15837
15887
  id: "signIn",
15888
+ submitLabel: "common.actions.login",
15838
15889
  fields: [
15839
15890
  { key: "email", required: true },
15840
15891
  { key: "password", required: true }
@@ -15850,7 +15901,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15850
15901
  details.apiErrors = result.error.errors;
15851
15902
  }
15852
15903
  }
15853
- var go_form = root$a();
15904
+ var go_form = root$b();
15854
15905
  set_custom_element_data(go_form, "formId", "signIn");
15855
15906
  event("submit", go_form, signIn);
15856
15907
  append($$anchor, go_form);
@@ -15865,11 +15916,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15865
15916
  [],
15866
15917
  false
15867
15918
  ));
15868
- var root$9 = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
15919
+ var root$a = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
15869
15920
  function SignUp($$anchor, $$props) {
15870
15921
  push($$props, true);
15871
15922
  Forms.defineForm({
15872
15923
  id: "signUp",
15924
+ submitLabel: "common.actions.register",
15873
15925
  fields: [
15874
15926
  // { id: 'salutation', required: false },
15875
15927
  { key: "firstName", required: true },
@@ -15897,7 +15949,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15897
15949
  details.apiErrors = result.error.errors;
15898
15950
  }
15899
15951
  }
15900
- var go_form = root$9();
15952
+ var go_form = root$a();
15901
15953
  set_custom_element_data(go_form, "formId", "signUp");
15902
15954
  event("submit", go_form, signUp);
15903
15955
  append($$anchor, go_form);
@@ -15913,7 +15965,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15913
15965
  false
15914
15966
  ));
15915
15967
  var root_1$h = /* @__PURE__ */ from_html(`<span class="go-cart-item-date" data-testid="cart-item-date"> </span><span class="go-cart-item-time" data-testid="cart-item-time"> </span>`, 1);
15916
- var root$8 = /* @__PURE__ */ from_html(`<li data-go-cart-item-title=""><span class="go-cart-item-title" data-testid="cart-item-title"><span class="go-cart-item-title-event-title"> </span><span class="go-cart-item-title-ticket-title"> </span></span><!></li>`);
15968
+ var root$9 = /* @__PURE__ */ from_html(`<li data-go-cart-item-title=""><span class="go-cart-item-title" data-testid="cart-item-title"><span class="go-cart-item-title-event-title"> </span><span class="go-cart-item-title-ticket-title"> </span></span><!></li>`);
15917
15969
  function Event$2($$anchor, $$props) {
15918
15970
  push($$props, true);
15919
15971
  let cartItem = prop($$props, "cartItem", 7);
@@ -15928,7 +15980,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15928
15980
  flushSync();
15929
15981
  }
15930
15982
  };
15931
- var li = root$8();
15983
+ var li = root$9();
15932
15984
  var span = child(li);
15933
15985
  var span_1 = child(span);
15934
15986
  var text2 = child(span_1, true);
@@ -15974,7 +16026,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15974
16026
  create_custom_element(Event$2, { cartItem: {} }, [], [], true);
15975
16027
  var root_2$q = /* @__PURE__ */ from_html(`<span class="go-cart-item-time" data-testid="cart-item-time"> </span>`);
15976
16028
  var root_1$g = /* @__PURE__ */ from_html(`<span class="go-cart-item-date" data-testid="cart-item-date"> </span> <!>`, 1);
15977
- var root$7 = /* @__PURE__ */ from_html(`<li data-go-cart-item-title=""><span class="go-cart-item-title" data-testid="cart-item-title"> </span> <!></li>`);
16029
+ var root$8 = /* @__PURE__ */ from_html(`<li data-go-cart-item-title=""><span class="go-cart-item-title" data-testid="cart-item-title"> </span> <!></li>`);
15978
16030
  function Ticket($$anchor, $$props) {
15979
16031
  push($$props, true);
15980
16032
  let cartItem = prop($$props, "cartItem", 7);
@@ -15987,7 +16039,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15987
16039
  flushSync();
15988
16040
  }
15989
16041
  };
15990
- var li = root$7();
16042
+ var li = root$8();
15991
16043
  var span = child(li);
15992
16044
  var text2 = child(span, true);
15993
16045
  reset(span);
@@ -16214,6 +16266,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
16214
16266
  let cart = /* @__PURE__ */ user_derived(() => shop.cart);
16215
16267
  Forms.defineForm({
16216
16268
  id: "checkoutGuest",
16269
+ submitLabel: "cart.detail.actions.checkout",
16217
16270
  fields: [
16218
16271
  { key: "firstName", required: true },
16219
16272
  { key: "lastName", required: true },
@@ -16256,6 +16309,61 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
16256
16309
  return pop($$exports);
16257
16310
  }
16258
16311
  customElements.define("go-checkout-form", create_custom_element(CheckoutForm, { custom: {} }, [], [], false));
16312
+ enable_legacy_mode_flag();
16313
+ async function redeem(form) {
16314
+ if (!form) {
16315
+ throw new Error("(go-coupon-redemption): form not found");
16316
+ }
16317
+ if (!shop.cart) {
16318
+ throw new Error("(go-coupon-redemption): cart not found");
16319
+ }
16320
+ const result = await shop.asyncFetch(() => shop.getCouponSaleByBarcode(form.details.formData.id));
16321
+ if (result?.is_valid && result.is_voucher_for) {
16322
+ const tickets = await shop.asyncFetch(
16323
+ () => shop.tickets({
16324
+ // @ts-ignore - api supports filter even if schema doesn't yet.
16325
+ "by_ticket_ids[]": [result.is_voucher_for]
16326
+ })
16327
+ );
16328
+ const ticket = tickets.find((t) => t.id === result.is_voucher_for);
16329
+ if (!ticket) {
16330
+ form.details.apiErrors ??= [];
16331
+ form.details.apiErrors = [shop.t("cart.coupon.form.errors.error")];
16332
+ return;
16333
+ }
16334
+ const voucherTicket = { ...ticket, price_cents: 0 };
16335
+ shop.cart.addItem(createCartItem(createUITicket(voucherTicket), { quantity: 1 }));
16336
+ const token = form.details.formData.id;
16337
+ shop.cart.addCoupon(token);
16338
+ const tokenField = form.details.fields.find((f) => f.key === "token");
16339
+ if (tokenField) {
16340
+ tokenField.value = "";
16341
+ form.dispatchEvent(new Event("go-success", { bubbles: true, composed: true }));
16342
+ }
16343
+ } else {
16344
+ form.details.apiErrors ??= [];
16345
+ form.details.apiErrors = [shop.t("cart.coupon.form.errors.notValid")];
16346
+ }
16347
+ }
16348
+ var root$7 = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
16349
+ function CouponRedemption($$anchor, $$props) {
16350
+ push($$props, false);
16351
+ Forms.defineForm({
16352
+ id: "couponRedemption",
16353
+ submitLabel: "cart.coupon.form.submit",
16354
+ fields: [{ key: "token", required: true }]
16355
+ });
16356
+ async function redeem$1(e) {
16357
+ await redeem(e.target);
16358
+ }
16359
+ init();
16360
+ var go_form = root$7();
16361
+ set_custom_element_data(go_form, "formId", "couponRedemption");
16362
+ event("submit", go_form, redeem$1);
16363
+ append($$anchor, go_form);
16364
+ pop();
16365
+ }
16366
+ customElements.define("go-coupon-redemption", create_custom_element(CouponRedemption, {}, [], [], false));
16259
16367
  function isFunction$1(value) {
16260
16368
  return typeof value === "function";
16261
16369
  }
@@ -22382,7 +22490,6 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
22382
22490
  return pop($$exports);
22383
22491
  }
22384
22492
  create_custom_element(Calendar_prev_button, { children: {}, child: {}, id: {}, ref: {}, tabindex: {} }, [], [], true);
22385
- enable_legacy_mode_flag();
22386
22493
  var root_1$e = /* @__PURE__ */ from_html(`<input/>`);
22387
22494
  var root_2$c = /* @__PURE__ */ from_html(`<input/>`);
22388
22495
  function Hidden_input($$anchor, $$props) {
@@ -30218,6 +30325,39 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30218
30325
  [],
30219
30326
  false
30220
30327
  ));
30328
+ function Link($$anchor, $$props) {
30329
+ push($$props, true);
30330
+ const to = prop($$props, "to", 7);
30331
+ const href = /* @__PURE__ */ user_derived(() => go.config.urls[to()]);
30332
+ const a2 = wrapInElement($$props.$$host, "a");
30333
+ user_effect(() => {
30334
+ if (!get$2(href)) {
30335
+ console.warn(`[go-link] No URL found for route "${to()}".`);
30336
+ a2.removeAttribute("href");
30337
+ return;
30338
+ }
30339
+ a2.setAttribute("href", get$2(href)());
30340
+ });
30341
+ a2.addEventListener("click", (e) => {
30342
+ e.preventDefault();
30343
+ if (!go.config.urls[to()]) {
30344
+ console.warn(`[go-link] No URL found for route "${to()}". You can define it with go.config.urls.${to()} = () => 'https://example.com/my-route'`);
30345
+ return;
30346
+ }
30347
+ go.config.navigateTo(go.config.urls[to()]());
30348
+ });
30349
+ var $$exports = {
30350
+ get to() {
30351
+ return to();
30352
+ },
30353
+ set to($$value) {
30354
+ to($$value);
30355
+ flushSync();
30356
+ }
30357
+ };
30358
+ return pop($$exports);
30359
+ }
30360
+ customElements.define("go-link", create_custom_element(Link, { to: { attribute: "to", reflect: true, type: "String" } }, [], [], false));
30221
30361
  class OrderDetails {
30222
30362
  #token = /* @__PURE__ */ state();
30223
30363
  get token() {
@@ -32058,39 +32198,6 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
32058
32198
  }
32059
32199
  delegate(["click"]);
32060
32200
  customElements.define("go-add-to-cart-button", create_custom_element(AddToCartButton, {}, [], ["details"], false));
32061
- function Link($$anchor, $$props) {
32062
- push($$props, true);
32063
- const to = prop($$props, "to", 7);
32064
- const href = /* @__PURE__ */ user_derived(() => go.config.urls[to()]);
32065
- const a2 = wrapInElement($$props.$$host, "a");
32066
- user_effect(() => {
32067
- if (!get$2(href)) {
32068
- console.warn(`[go-link] No URL found for route "${to()}".`);
32069
- a2.removeAttribute("href");
32070
- return;
32071
- }
32072
- a2.setAttribute("href", get$2(href)());
32073
- });
32074
- a2.addEventListener("click", (e) => {
32075
- e.preventDefault();
32076
- if (!go.config.urls[to()]) {
32077
- console.warn(`[go-link] No URL found for route "${to()}". You can define it with go.config.urls.${to()} = () => 'https://example.com/my-route'`);
32078
- return;
32079
- }
32080
- go.config.navigateTo(go.config.urls[to()]());
32081
- });
32082
- var $$exports = {
32083
- get to() {
32084
- return to();
32085
- },
32086
- set to($$value) {
32087
- to($$value);
32088
- flushSync();
32089
- }
32090
- };
32091
- return pop($$exports);
32092
- }
32093
- customElements.define("go-link", create_custom_element(Link, { to: { attribute: "to", reflect: true, type: "String" } }, [], [], false));
32094
32201
  var root$1 = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
32095
32202
  function Password($$anchor, $$props) {
32096
32203
  push($$props, false);
@@ -11250,7 +11250,7 @@ function createCartItem(product, options) {
11250
11250
  };
11251
11251
  }
11252
11252
  function updateLocalStorage(cart) {
11253
- const content = JSON.stringify(cart.items || []);
11253
+ const content = JSON.stringify({ items: cart.items || [], coupons: cart.coupons || [] });
11254
11254
  localStorage.setItem("go-cart", content);
11255
11255
  return content;
11256
11256
  }
@@ -11271,23 +11271,32 @@ function generateCartItem(cartItem) {
11271
11271
  }
11272
11272
  function loadFromLocalStorage(cart) {
11273
11273
  let lsItems = [];
11274
+ let lsCoupons = [];
11274
11275
  try {
11275
11276
  const content = localStorage.getItem("go-cart");
11276
11277
  if (!content) return [];
11277
- lsItems = JSON.parse(content);
11278
- if (!Array.isArray(lsItems)) {
11279
- console.dir({ lsItems, content });
11280
- throw new Error("go-cart is not an array");
11278
+ const parsed = JSON.parse(content);
11279
+ if (Array.isArray(parsed)) {
11280
+ lsItems = parsed;
11281
+ lsCoupons = [];
11282
+ } else if (typeof parsed === "object" && parsed !== null) {
11283
+ lsItems = parsed.items || [];
11284
+ lsCoupons = parsed.coupons || [];
11285
+ } else {
11286
+ console.dir({ parsed, content });
11287
+ throw new Error("go-cart has invalid format");
11281
11288
  }
11282
11289
  if (lsItems.length === 0) {
11283
11290
  cart.clearItems();
11284
- return [];
11291
+ } else {
11292
+ cart.items = lsItems.map(generateCartItem).filter(defined);
11285
11293
  }
11286
- cart.items = lsItems.map(generateCartItem).filter(defined);
11294
+ cart.clearCoupons();
11295
+ lsCoupons.forEach((coupon) => cart.addCoupon(coupon));
11287
11296
  return cart.items;
11288
11297
  } catch (e) {
11289
11298
  console.error(e);
11290
- localStorage.setItem("go-cart", JSON.stringify([]));
11299
+ localStorage.setItem("go-cart", JSON.stringify({ items: [], coupons: [] }));
11291
11300
  return [];
11292
11301
  }
11293
11302
  }
@@ -11324,8 +11333,10 @@ const defined = (x) => x !== void 0;
11324
11333
  let lastUuid = 0;
11325
11334
  function createCart(products, contingent = 20) {
11326
11335
  const items = proxy([]);
11336
+ const coupons = proxy([]);
11327
11337
  const cart = {
11328
11338
  items,
11339
+ coupons,
11329
11340
  contingent,
11330
11341
  // caps the total number of items in the cart
11331
11342
  uid: `cart-${lastUuid++}`,
@@ -11351,7 +11362,7 @@ function createCart(products, contingent = 20) {
11351
11362
  comment: null,
11352
11363
  reference: null,
11353
11364
  payment_mode_id: shop.settings?.defaultPaymentModeId,
11354
- coupons: [],
11365
+ coupons: this.coupons,
11355
11366
  donations: [],
11356
11367
  affiliate: {},
11357
11368
  total: this.totalPriceCents
@@ -11377,6 +11388,20 @@ function createCart(products, contingent = 20) {
11377
11388
  },
11378
11389
  addProducts(products2) {
11379
11390
  products2.forEach((p2) => this.addItem(createCartItem(p2)));
11391
+ },
11392
+ addCoupon(token) {
11393
+ if (!this.coupons.includes(token)) {
11394
+ this.coupons.push(token);
11395
+ }
11396
+ },
11397
+ removeCoupon(token) {
11398
+ const index2 = this.coupons.indexOf(token);
11399
+ if (index2 > -1) {
11400
+ this.coupons.splice(index2, 1);
11401
+ }
11402
+ },
11403
+ clearCoupons() {
11404
+ while (this.coupons.length > 0) this.coupons.pop();
11380
11405
  }
11381
11406
  };
11382
11407
  if (products) products.forEach((p2) => cart.addItem(createCartItem(p2)));
@@ -12564,6 +12589,9 @@ class Shop {
12564
12589
  requiredFields: ["date", "ticket_ids"]
12565
12590
  });
12566
12591
  }
12592
+ getCouponSaleByBarcode(token) {
12593
+ return this.fetchAndCache(`/api/v4/coupon_sales/barcode/${token}`, `coupon_sale_barcode_${token}`, "coupon_sale");
12594
+ }
12567
12595
  getEventDetailsOnDate(eventId, dateId) {
12568
12596
  return this.fetchAndCache(`/api/v4/events/${eventId}/dates/${dateId}`, `/api/v4/events/${eventId}/dates/${dateId}`, "date");
12569
12597
  }
@@ -15339,6 +15367,15 @@ var allFields = {
15339
15367
  description: "",
15340
15368
  autocomplete: "off",
15341
15369
  validator: string().date()
15370
+ },
15371
+ token: {
15372
+ key: "token",
15373
+ apiKey: "id",
15374
+ type: "text",
15375
+ label: "cart.coupon.form.code",
15376
+ placeholder: "",
15377
+ description: "",
15378
+ autocomplete: "off"
15342
15379
  }
15343
15380
  };
15344
15381
  function createField(data, required) {
@@ -15383,7 +15420,11 @@ function validateField(field) {
15383
15420
  }
15384
15421
  const _Forms = class _Forms {
15385
15422
  static defineForm(options) {
15386
- go.defineConfig({ forms: { [options.id]: { fields: options.fields } } });
15423
+ go.defineConfig({
15424
+ forms: {
15425
+ [options.id]: { fields: options.fields, submitLabel: options.submitLabel }
15426
+ }
15427
+ });
15387
15428
  }
15388
15429
  static defineFields(fields) {
15389
15430
  go.defineConfig({ fields });
@@ -15391,6 +15432,9 @@ const _Forms = class _Forms {
15391
15432
  static setRequiredApiKeys(formId, requiredApiKeys) {
15392
15433
  __privateGet(_Forms, _requiredApiKeysMap)[formId] = requiredApiKeys;
15393
15434
  }
15435
+ static getFormOptions(formId) {
15436
+ return go.config.forms[formId];
15437
+ }
15394
15438
  static createField(key, required) {
15395
15439
  const init2 = _Forms.getFieldInit(key);
15396
15440
  if (!init2) {
@@ -15727,7 +15771,7 @@ function wrapInElement(host, tag, props) {
15727
15771
  host.replaceChildren(element);
15728
15772
  return element;
15729
15773
  }
15730
- var root_1$i = /* @__PURE__ */ from_html(`<go-all-fields></go-all-fields> <go-form-feedback><go-errors-feedback></go-errors-feedback> <go-success-feedback></go-success-feedback></go-form-feedback> <go-submit>Submit</go-submit>`, 3);
15774
+ var root_1$i = /* @__PURE__ */ from_html(`<go-all-fields></go-all-fields> <go-form-feedback><go-errors-feedback></go-errors-feedback> <go-success-feedback></go-success-feedback></go-form-feedback> <go-submit> </go-submit>`, 3);
15731
15775
  function Form($$anchor, $$props) {
15732
15776
  push($$props, true);
15733
15777
  let formId = prop($$props, "formId", 7), custom2 = prop($$props, "custom", 7);
@@ -15773,7 +15817,12 @@ function Form($$anchor, $$props) {
15773
15817
  var fragment_1 = root_1$i();
15774
15818
  var go_all_fields = first_child(fragment_1);
15775
15819
  var go_form_feedback = sibling(go_all_fields, 2);
15776
- sibling(go_form_feedback, 2);
15820
+ var go_submit = sibling(go_form_feedback, 2);
15821
+ var text2 = child(go_submit, true);
15822
+ reset(go_submit);
15823
+ template_effect(($0) => set_text(text2, $0), [
15824
+ () => shop.t(Forms.getFormOptions(formId())?.submitLabel || "Submit")
15825
+ ]);
15777
15826
  append($$anchor2, fragment_1);
15778
15827
  };
15779
15828
  if_block(node, ($$render) => {
@@ -15793,12 +15842,13 @@ customElements.define("go-form", create_custom_element(
15793
15842
  ["details"],
15794
15843
  false
15795
15844
  ));
15796
- var root$b = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
15845
+ var root$c = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
15797
15846
  function PasswordReset($$anchor, $$props) {
15798
15847
  push($$props, true);
15799
15848
  let custom2 = prop($$props, "custom", 7, false);
15800
15849
  Forms.defineForm({
15801
15850
  id: "passwordReset",
15851
+ submitLabel: "user.passwordReset.actions.requestPasswordReset",
15802
15852
  fields: [{ key: "email", required: true }]
15803
15853
  });
15804
15854
  async function passwordReset(event2) {
@@ -15822,7 +15872,7 @@ function PasswordReset($$anchor, $$props) {
15822
15872
  flushSync();
15823
15873
  }
15824
15874
  };
15825
- var go_form = root$b();
15875
+ var go_form = root$c();
15826
15876
  set_custom_element_data(go_form, "formId", "passwordReset");
15827
15877
  template_effect(() => set_custom_element_data(go_form, "custom", custom2()));
15828
15878
  event("submit", go_form, passwordReset);
@@ -15830,11 +15880,12 @@ function PasswordReset($$anchor, $$props) {
15830
15880
  return pop($$exports);
15831
15881
  }
15832
15882
  customElements.define("go-password-reset", create_custom_element(PasswordReset, { custom: {} }, [], [], false));
15833
- var root$a = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
15883
+ var root$b = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
15834
15884
  function SignIn($$anchor, $$props) {
15835
15885
  push($$props, true);
15836
15886
  Forms.defineForm({
15837
15887
  id: "signIn",
15888
+ submitLabel: "common.actions.login",
15838
15889
  fields: [
15839
15890
  { key: "email", required: true },
15840
15891
  { key: "password", required: true }
@@ -15850,7 +15901,7 @@ function SignIn($$anchor, $$props) {
15850
15901
  details.apiErrors = result.error.errors;
15851
15902
  }
15852
15903
  }
15853
- var go_form = root$a();
15904
+ var go_form = root$b();
15854
15905
  set_custom_element_data(go_form, "formId", "signIn");
15855
15906
  event("submit", go_form, signIn);
15856
15907
  append($$anchor, go_form);
@@ -15865,11 +15916,12 @@ customElements.define("go-sign-in", create_custom_element(
15865
15916
  [],
15866
15917
  false
15867
15918
  ));
15868
- var root$9 = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
15919
+ var root$a = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
15869
15920
  function SignUp($$anchor, $$props) {
15870
15921
  push($$props, true);
15871
15922
  Forms.defineForm({
15872
15923
  id: "signUp",
15924
+ submitLabel: "common.actions.register",
15873
15925
  fields: [
15874
15926
  // { id: 'salutation', required: false },
15875
15927
  { key: "firstName", required: true },
@@ -15897,7 +15949,7 @@ function SignUp($$anchor, $$props) {
15897
15949
  details.apiErrors = result.error.errors;
15898
15950
  }
15899
15951
  }
15900
- var go_form = root$9();
15952
+ var go_form = root$a();
15901
15953
  set_custom_element_data(go_form, "formId", "signUp");
15902
15954
  event("submit", go_form, signUp);
15903
15955
  append($$anchor, go_form);
@@ -15913,7 +15965,7 @@ customElements.define("go-sign-up", create_custom_element(
15913
15965
  false
15914
15966
  ));
15915
15967
  var root_1$h = /* @__PURE__ */ from_html(`<span class="go-cart-item-date" data-testid="cart-item-date"> </span><span class="go-cart-item-time" data-testid="cart-item-time"> </span>`, 1);
15916
- var root$8 = /* @__PURE__ */ from_html(`<li data-go-cart-item-title=""><span class="go-cart-item-title" data-testid="cart-item-title"><span class="go-cart-item-title-event-title"> </span><span class="go-cart-item-title-ticket-title"> </span></span><!></li>`);
15968
+ var root$9 = /* @__PURE__ */ from_html(`<li data-go-cart-item-title=""><span class="go-cart-item-title" data-testid="cart-item-title"><span class="go-cart-item-title-event-title"> </span><span class="go-cart-item-title-ticket-title"> </span></span><!></li>`);
15917
15969
  function Event$2($$anchor, $$props) {
15918
15970
  push($$props, true);
15919
15971
  let cartItem = prop($$props, "cartItem", 7);
@@ -15928,7 +15980,7 @@ function Event$2($$anchor, $$props) {
15928
15980
  flushSync();
15929
15981
  }
15930
15982
  };
15931
- var li = root$8();
15983
+ var li = root$9();
15932
15984
  var span = child(li);
15933
15985
  var span_1 = child(span);
15934
15986
  var text2 = child(span_1, true);
@@ -15974,7 +16026,7 @@ function Event$2($$anchor, $$props) {
15974
16026
  create_custom_element(Event$2, { cartItem: {} }, [], [], true);
15975
16027
  var root_2$q = /* @__PURE__ */ from_html(`<span class="go-cart-item-time" data-testid="cart-item-time"> </span>`);
15976
16028
  var root_1$g = /* @__PURE__ */ from_html(`<span class="go-cart-item-date" data-testid="cart-item-date"> </span> <!>`, 1);
15977
- var root$7 = /* @__PURE__ */ from_html(`<li data-go-cart-item-title=""><span class="go-cart-item-title" data-testid="cart-item-title"> </span> <!></li>`);
16029
+ var root$8 = /* @__PURE__ */ from_html(`<li data-go-cart-item-title=""><span class="go-cart-item-title" data-testid="cart-item-title"> </span> <!></li>`);
15978
16030
  function Ticket($$anchor, $$props) {
15979
16031
  push($$props, true);
15980
16032
  let cartItem = prop($$props, "cartItem", 7);
@@ -15987,7 +16039,7 @@ function Ticket($$anchor, $$props) {
15987
16039
  flushSync();
15988
16040
  }
15989
16041
  };
15990
- var li = root$7();
16042
+ var li = root$8();
15991
16043
  var span = child(li);
15992
16044
  var text2 = child(span, true);
15993
16045
  reset(span);
@@ -16214,6 +16266,7 @@ function CheckoutForm($$anchor, $$props) {
16214
16266
  let cart = /* @__PURE__ */ user_derived(() => shop.cart);
16215
16267
  Forms.defineForm({
16216
16268
  id: "checkoutGuest",
16269
+ submitLabel: "cart.detail.actions.checkout",
16217
16270
  fields: [
16218
16271
  { key: "firstName", required: true },
16219
16272
  { key: "lastName", required: true },
@@ -16256,6 +16309,61 @@ function CheckoutForm($$anchor, $$props) {
16256
16309
  return pop($$exports);
16257
16310
  }
16258
16311
  customElements.define("go-checkout-form", create_custom_element(CheckoutForm, { custom: {} }, [], [], false));
16312
+ enable_legacy_mode_flag();
16313
+ async function redeem(form) {
16314
+ if (!form) {
16315
+ throw new Error("(go-coupon-redemption): form not found");
16316
+ }
16317
+ if (!shop.cart) {
16318
+ throw new Error("(go-coupon-redemption): cart not found");
16319
+ }
16320
+ const result = await shop.asyncFetch(() => shop.getCouponSaleByBarcode(form.details.formData.id));
16321
+ if (result?.is_valid && result.is_voucher_for) {
16322
+ const tickets = await shop.asyncFetch(
16323
+ () => shop.tickets({
16324
+ // @ts-ignore - api supports filter even if schema doesn't yet.
16325
+ "by_ticket_ids[]": [result.is_voucher_for]
16326
+ })
16327
+ );
16328
+ const ticket = tickets.find((t) => t.id === result.is_voucher_for);
16329
+ if (!ticket) {
16330
+ form.details.apiErrors ??= [];
16331
+ form.details.apiErrors = [shop.t("cart.coupon.form.errors.error")];
16332
+ return;
16333
+ }
16334
+ const voucherTicket = { ...ticket, price_cents: 0 };
16335
+ shop.cart.addItem(createCartItem(createUITicket(voucherTicket), { quantity: 1 }));
16336
+ const token = form.details.formData.id;
16337
+ shop.cart.addCoupon(token);
16338
+ const tokenField = form.details.fields.find((f) => f.key === "token");
16339
+ if (tokenField) {
16340
+ tokenField.value = "";
16341
+ form.dispatchEvent(new Event("go-success", { bubbles: true, composed: true }));
16342
+ }
16343
+ } else {
16344
+ form.details.apiErrors ??= [];
16345
+ form.details.apiErrors = [shop.t("cart.coupon.form.errors.notValid")];
16346
+ }
16347
+ }
16348
+ var root$7 = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
16349
+ function CouponRedemption($$anchor, $$props) {
16350
+ push($$props, false);
16351
+ Forms.defineForm({
16352
+ id: "couponRedemption",
16353
+ submitLabel: "cart.coupon.form.submit",
16354
+ fields: [{ key: "token", required: true }]
16355
+ });
16356
+ async function redeem$1(e) {
16357
+ await redeem(e.target);
16358
+ }
16359
+ init();
16360
+ var go_form = root$7();
16361
+ set_custom_element_data(go_form, "formId", "couponRedemption");
16362
+ event("submit", go_form, redeem$1);
16363
+ append($$anchor, go_form);
16364
+ pop();
16365
+ }
16366
+ customElements.define("go-coupon-redemption", create_custom_element(CouponRedemption, {}, [], [], false));
16259
16367
  function isFunction$1(value) {
16260
16368
  return typeof value === "function";
16261
16369
  }
@@ -22382,7 +22490,6 @@ function Calendar_prev_button($$anchor, $$props) {
22382
22490
  return pop($$exports);
22383
22491
  }
22384
22492
  create_custom_element(Calendar_prev_button, { children: {}, child: {}, id: {}, ref: {}, tabindex: {} }, [], [], true);
22385
- enable_legacy_mode_flag();
22386
22493
  var root_1$e = /* @__PURE__ */ from_html(`<input/>`);
22387
22494
  var root_2$c = /* @__PURE__ */ from_html(`<input/>`);
22388
22495
  function Hidden_input($$anchor, $$props) {
@@ -30218,6 +30325,39 @@ customElements.define("go-init", create_custom_element(
30218
30325
  [],
30219
30326
  false
30220
30327
  ));
30328
+ function Link($$anchor, $$props) {
30329
+ push($$props, true);
30330
+ const to = prop($$props, "to", 7);
30331
+ const href = /* @__PURE__ */ user_derived(() => go.config.urls[to()]);
30332
+ const a2 = wrapInElement($$props.$$host, "a");
30333
+ user_effect(() => {
30334
+ if (!get$2(href)) {
30335
+ console.warn(`[go-link] No URL found for route "${to()}".`);
30336
+ a2.removeAttribute("href");
30337
+ return;
30338
+ }
30339
+ a2.setAttribute("href", get$2(href)());
30340
+ });
30341
+ a2.addEventListener("click", (e) => {
30342
+ e.preventDefault();
30343
+ if (!go.config.urls[to()]) {
30344
+ console.warn(`[go-link] No URL found for route "${to()}". You can define it with go.config.urls.${to()} = () => 'https://example.com/my-route'`);
30345
+ return;
30346
+ }
30347
+ go.config.navigateTo(go.config.urls[to()]());
30348
+ });
30349
+ var $$exports = {
30350
+ get to() {
30351
+ return to();
30352
+ },
30353
+ set to($$value) {
30354
+ to($$value);
30355
+ flushSync();
30356
+ }
30357
+ };
30358
+ return pop($$exports);
30359
+ }
30360
+ customElements.define("go-link", create_custom_element(Link, { to: { attribute: "to", reflect: true, type: "String" } }, [], [], false));
30221
30361
  class OrderDetails {
30222
30362
  #token = /* @__PURE__ */ state();
30223
30363
  get token() {
@@ -32058,39 +32198,6 @@ function AddToCartButton($$anchor, $$props) {
32058
32198
  }
32059
32199
  delegate(["click"]);
32060
32200
  customElements.define("go-add-to-cart-button", create_custom_element(AddToCartButton, {}, [], ["details"], false));
32061
- function Link($$anchor, $$props) {
32062
- push($$props, true);
32063
- const to = prop($$props, "to", 7);
32064
- const href = /* @__PURE__ */ user_derived(() => go.config.urls[to()]);
32065
- const a2 = wrapInElement($$props.$$host, "a");
32066
- user_effect(() => {
32067
- if (!get$2(href)) {
32068
- console.warn(`[go-link] No URL found for route "${to()}".`);
32069
- a2.removeAttribute("href");
32070
- return;
32071
- }
32072
- a2.setAttribute("href", get$2(href)());
32073
- });
32074
- a2.addEventListener("click", (e) => {
32075
- e.preventDefault();
32076
- if (!go.config.urls[to()]) {
32077
- console.warn(`[go-link] No URL found for route "${to()}". You can define it with go.config.urls.${to()} = () => 'https://example.com/my-route'`);
32078
- return;
32079
- }
32080
- go.config.navigateTo(go.config.urls[to()]());
32081
- });
32082
- var $$exports = {
32083
- get to() {
32084
- return to();
32085
- },
32086
- set to($$value) {
32087
- to($$value);
32088
- flushSync();
32089
- }
32090
- };
32091
- return pop($$exports);
32092
- }
32093
- customElements.define("go-link", create_custom_element(Link, { to: { attribute: "to", reflect: true, type: "String" } }, [], [], false));
32094
32201
  var root$1 = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
32095
32202
  function Password($$anchor, $$props) {
32096
32203
  push($$props, false);
@@ -2,6 +2,7 @@ import { CartItem, Product } from './types.ts';
2
2
  export type Cart = ReturnType<typeof createCart>;
3
3
  export declare function createCart(products?: Product[], contingent?: number): {
4
4
  items: CartItem[];
5
+ coupons: string[];
5
6
  contingent: number;
6
7
  uid: string;
7
8
  readonly nonEmptyItems: CartItem[];
@@ -33,7 +34,7 @@ export declare function createCart(products?: Product[], contingent?: number): {
33
34
  comment: null;
34
35
  reference: null;
35
36
  payment_mode_id: string;
36
- coupons: never[];
37
+ coupons: string[];
37
38
  donations: never[];
38
39
  affiliate: {};
39
40
  total: number;
@@ -44,10 +45,14 @@ export declare function createCart(products?: Product[], contingent?: number): {
44
45
  addItem(item: CartItem): void;
45
46
  addItems(items: CartItem[]): void;
46
47
  addProducts(products: Product[]): void;
48
+ addCoupon(token: string): void;
49
+ removeCoupon(token: string): void;
50
+ clearCoupons(): void;
47
51
  };
48
52
  export declare function formatCurrency(priceCents: number): string;
49
53
  export declare function createMainCart(): {
50
54
  items: CartItem[];
55
+ coupons: string[];
51
56
  contingent: number;
52
57
  uid: string;
53
58
  readonly nonEmptyItems: CartItem[];
@@ -79,7 +84,7 @@ export declare function createMainCart(): {
79
84
  comment: null;
80
85
  reference: null;
81
86
  payment_mode_id: string;
82
- coupons: never[];
87
+ coupons: string[];
83
88
  donations: never[];
84
89
  affiliate: {};
85
90
  total: number;
@@ -90,4 +95,7 @@ export declare function createMainCart(): {
90
95
  addItem(item: CartItem): void;
91
96
  addItems(items: CartItem[]): void;
92
97
  addProducts(products: Product[]): void;
98
+ addCoupon(token: string): void;
99
+ removeCoupon(token: string): void;
100
+ clearCoupons(): void;
93
101
  };
@@ -88,6 +88,7 @@ export declare class Shop {
88
88
  };
89
89
  get cart(): {
90
90
  items: import('../models/cart/types').CartItem[];
91
+ coupons: string[];
91
92
  contingent: number;
92
93
  uid: string;
93
94
  readonly nonEmptyItems: import('../models/cart/types').CartItem[];
@@ -116,7 +117,7 @@ export declare class Shop {
116
117
  comment: null;
117
118
  reference: null;
118
119
  payment_mode_id: string;
119
- coupons: never[];
120
+ coupons: string[];
120
121
  donations: never[];
121
122
  affiliate: {};
122
123
  total: number;
@@ -127,6 +128,9 @@ export declare class Shop {
127
128
  addItem(item: import('../models/cart/types').CartItem): void;
128
129
  addItems(items: import('../models/cart/types').CartItem[]): void;
129
130
  addProducts(products: import('../models/cart/types').Product[]): void;
131
+ addCoupon(token: string): void;
132
+ removeCoupon(token: string): void;
133
+ clearCoupons(): void;
130
134
  } | undefined;
131
135
  get auth(): Auth;
132
136
  get currentUser(): User | undefined;
@@ -508,6 +512,14 @@ export declare class Shop {
508
512
  content: Record<string, never>;
509
513
  };
510
514
  getTicketCapacities(date: string, ticketIds: number[]): Promise<CapacitiesResponse>;
515
+ getCouponSaleByBarcode(token: string): {
516
+ id: number;
517
+ is_valid: boolean;
518
+ is_voucher_for: number | null;
519
+ value_cents: number;
520
+ value_action: string | null;
521
+ value: number | null;
522
+ };
511
523
  getEventDetailsOnDate(eventId: number, dateId: number): {
512
524
  id?: number;
513
525
  event_id?: number;
@@ -1094,6 +1094,7 @@ export declare const UIAnnualTicketMocks: {
1094
1094
  export declare const CartMocks: {
1095
1095
  cartOneItem: () => {
1096
1096
  items: import('../lib/models/cart/types').CartItem[];
1097
+ coupons: string[];
1097
1098
  contingent: number;
1098
1099
  uid: string;
1099
1100
  readonly nonEmptyItems: import('../lib/models/cart/types').CartItem[];
@@ -1122,7 +1123,7 @@ export declare const CartMocks: {
1122
1123
  comment: null;
1123
1124
  reference: null;
1124
1125
  payment_mode_id: string;
1125
- coupons: never[];
1126
+ coupons: string[];
1126
1127
  donations: never[];
1127
1128
  affiliate: {};
1128
1129
  total: number;
@@ -1133,9 +1134,13 @@ export declare const CartMocks: {
1133
1134
  addItem(item: import('../lib/models/cart/types').CartItem): void;
1134
1135
  addItems(items: import('../lib/models/cart/types').CartItem[]): void;
1135
1136
  addProducts(products: import('../lib/models/cart/types').Product[]): void;
1137
+ addCoupon(token: string): void;
1138
+ removeCoupon(token: string): void;
1139
+ clearCoupons(): void;
1136
1140
  };
1137
1141
  cartTwoItems: () => {
1138
1142
  items: import('../lib/models/cart/types').CartItem[];
1143
+ coupons: string[];
1139
1144
  contingent: number;
1140
1145
  uid: string;
1141
1146
  readonly nonEmptyItems: import('../lib/models/cart/types').CartItem[];
@@ -1164,7 +1169,7 @@ export declare const CartMocks: {
1164
1169
  comment: null;
1165
1170
  reference: null;
1166
1171
  payment_mode_id: string;
1167
- coupons: never[];
1172
+ coupons: string[];
1168
1173
  donations: never[];
1169
1174
  affiliate: {};
1170
1175
  total: number;
@@ -1175,9 +1180,13 @@ export declare const CartMocks: {
1175
1180
  addItem(item: import('../lib/models/cart/types').CartItem): void;
1176
1181
  addItems(items: import('../lib/models/cart/types').CartItem[]): void;
1177
1182
  addProducts(products: import('../lib/models/cart/types').Product[]): void;
1183
+ addCoupon(token: string): void;
1184
+ removeCoupon(token: string): void;
1185
+ clearCoupons(): void;
1178
1186
  };
1179
1187
  cartThreeItems: () => {
1180
1188
  items: import('../lib/models/cart/types').CartItem[];
1189
+ coupons: string[];
1181
1190
  contingent: number;
1182
1191
  uid: string;
1183
1192
  readonly nonEmptyItems: import('../lib/models/cart/types').CartItem[];
@@ -1206,7 +1215,7 @@ export declare const CartMocks: {
1206
1215
  comment: null;
1207
1216
  reference: null;
1208
1217
  payment_mode_id: string;
1209
- coupons: never[];
1218
+ coupons: string[];
1210
1219
  donations: never[];
1211
1220
  affiliate: {};
1212
1221
  total: number;
@@ -1217,6 +1226,9 @@ export declare const CartMocks: {
1217
1226
  addItem(item: import('../lib/models/cart/types').CartItem): void;
1218
1227
  addItems(items: import('../lib/models/cart/types').CartItem[]): void;
1219
1228
  addProducts(products: import('../lib/models/cart/types').Product[]): void;
1229
+ addCoupon(token: string): void;
1230
+ removeCoupon(token: string): void;
1231
+ clearCoupons(): void;
1220
1232
  };
1221
1233
  };
1222
1234
  export declare const CartItemMocks: {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "Giantmonkey GmbH"
5
5
  },
6
6
  "license": "MIT",
7
- "version": "1.34.0",
7
+ "version": "1.36.0",
8
8
  "type": "module",
9
9
  "main": "./dist-js/gomus-webcomponents.iife.js",
10
10
  "module": "./dist-js/gomus-webcomponents.iife.js",