@gomusdev/web-components 1.56.1 → 1.57.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.
@@ -12635,6 +12635,14 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
12635
12635
  finalizePersonalizations(token, params) {
12636
12636
  return this.apiPost("/api/v4/annual/personalization/finalize", { body: params, params: { query: { token } } });
12637
12637
  }
12638
+ uploadPersonalizationPhoto(token, personalizationId, file) {
12639
+ const fd = new FormData();
12640
+ fd.append("file", file);
12641
+ return this.apiUpload("/api/v4/annual/personalizations/{id}/upload", {
12642
+ body: fd,
12643
+ params: { path: { id: personalizationId }, query: { token } }
12644
+ });
12645
+ }
12638
12646
  /**
12639
12647
  * Returns a reactive value that will contain the fetched data, no need to await.
12640
12648
  *
@@ -12742,6 +12750,16 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
12742
12750
  async apiDELETE(path, options) {
12743
12751
  return this.apiCall(path, { method: "DELETE", ...options });
12744
12752
  }
12753
+ async apiUpload(path, options) {
12754
+ this.#ensureApi();
12755
+ const { body, params = {} } = options;
12756
+ const ret = await this.client.POST(path, {
12757
+ body,
12758
+ params: assign(this.#defaultApiParams, { params }).params,
12759
+ bodySerializer: (b) => b
12760
+ });
12761
+ return ret;
12762
+ }
12745
12763
  async apiCall(path, options) {
12746
12764
  this.#ensureApi();
12747
12765
  const { body, params = {}, requiredFields } = options;
@@ -16023,6 +16041,28 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16023
16041
  function superRefine(fn) {
16024
16042
  return /* @__PURE__ */ _superRefine(fn);
16025
16043
  }
16044
+ function _instanceof(cls, params = {}) {
16045
+ const inst = new ZodCustom({
16046
+ type: "custom",
16047
+ check: "custom",
16048
+ fn: (data) => data instanceof cls,
16049
+ abort: true,
16050
+ ...normalizeParams(params)
16051
+ });
16052
+ inst._zod.bag.Class = cls;
16053
+ inst._zod.check = (payload) => {
16054
+ if (!(payload.value instanceof cls)) {
16055
+ payload.issues.push({
16056
+ code: "invalid_type",
16057
+ expected: cls.name,
16058
+ input: payload.value,
16059
+ inst,
16060
+ path: [...inst._zod.def.path ?? []]
16061
+ });
16062
+ }
16063
+ };
16064
+ return inst;
16065
+ }
16026
16066
  var allFields = {
16027
16067
  salutation: {
16028
16068
  key: "salutation",
@@ -16209,6 +16249,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16209
16249
  description: "",
16210
16250
  autocomplete: "off"
16211
16251
  },
16252
+ photo: {
16253
+ key: "photo",
16254
+ apiKey: "file",
16255
+ type: "file",
16256
+ label: "ticket.annual.personalization.form.photo",
16257
+ placeholder: "",
16258
+ description: "",
16259
+ autocomplete: "off",
16260
+ validator: _instanceof(File)
16261
+ },
16212
16262
  paymentMode: {
16213
16263
  key: "paymentMode",
16214
16264
  apiKey: "payment_mode_id",
@@ -16244,6 +16294,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16244
16294
  function defaultValue(fieldType) {
16245
16295
  if (fieldType === "checkbox") {
16246
16296
  return false;
16297
+ } else if (fieldType === "file") {
16298
+ return null;
16247
16299
  } else {
16248
16300
  return "";
16249
16301
  }
@@ -16252,7 +16304,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16252
16304
  field.errors = [];
16253
16305
  if (!field.validator) {
16254
16306
  if (field.required) {
16255
- if (field.value === false || field.value === "") field.errors = field.value ? [] : [`common.fieldErrors.required`];
16307
+ const empty2 = field.value === false || field.value === "" || field.value === null || field.value === void 0;
16308
+ if (empty2) field.errors = [`common.fieldErrors.required`];
16256
16309
  }
16257
16310
  return;
16258
16311
  }
@@ -16359,6 +16412,33 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16359
16412
  if (!isValid2) {
16360
16413
  return;
16361
16414
  }
16415
+ if (details.ticketSale?.photo_mandatory === "mandatory") {
16416
+ const uploads = personalizationForms.map(async (detail, index2) => {
16417
+ const personalizationId = details.ticketSale.personalizations[index2].id;
16418
+ const photoField = detail.fields.find((f) => f.key === "photo");
16419
+ const file = photoField?.value;
16420
+ if (!(file instanceof File)) {
16421
+ return {
16422
+ ok: false,
16423
+ error: "ticket.annual.personalization.photo.missing"
16424
+ };
16425
+ }
16426
+ const result2 = await shop.uploadPersonalizationPhoto(token(), personalizationId, file);
16427
+ if (result2.error) {
16428
+ return {
16429
+ ok: false,
16430
+ error: result2.error.error ?? "ticket.annual.personalization.photo.upload_failed"
16431
+ };
16432
+ }
16433
+ return { ok: true, error: "" };
16434
+ });
16435
+ const results = await Promise.all(uploads);
16436
+ const firstFailure = results.find((r2) => !r2.ok);
16437
+ if (firstFailure) {
16438
+ form.details.apiErrors = [firstFailure.error];
16439
+ return;
16440
+ }
16441
+ }
16362
16442
  const body = {
16363
16443
  personalization: {
16364
16444
  ticket_sale_id: details.ticketSaleId,
@@ -16495,7 +16575,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16495
16575
  if (!Number.isNaN(+x) && x.trim() !== "") return +x;
16496
16576
  return x;
16497
16577
  }
16498
- const validFields = this.fields.filter((f) => f !== void 0).filter((f) => f.value !== "");
16578
+ const validFields = this.fields.filter((f) => f !== void 0).filter((f) => f.type !== "file").filter((f) => f.value !== "");
16499
16579
  const ret = Object.fromEntries(validFields.map((f) => [f.apiKey, coerce2(f.value)]));
16500
16580
  return ret;
16501
16581
  }
@@ -16955,8 +17035,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16955
17035
  var root_6$3 = /* @__PURE__ */ from_html(`<span class="go-cart-item-price-discounted"> </span>`);
16956
17036
  var root_7$4 = /* @__PURE__ */ from_html(`<span> </span>`);
16957
17037
  var root_9$4 = /* @__PURE__ */ from_html(`<option> </option>`);
16958
- var root_8$2 = /* @__PURE__ */ from_html(`<select class="go-cart-item-select"></select>`);
16959
- var root_10$2 = /* @__PURE__ */ from_html(`<li class="go-cart-item-remove"><button>⨉</button></li>`);
17038
+ var root_8$3 = /* @__PURE__ */ from_html(`<select class="go-cart-item-select"></select>`);
17039
+ var root_10$1 = /* @__PURE__ */ from_html(`<li class="go-cart-item-remove"><button>⨉</button></li>`);
16960
17040
  var root_1$i = /* @__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>`);
16961
17041
  function Item$1($$anchor, $$props) {
16962
17042
  push($$props, true);
@@ -17111,7 +17191,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17111
17191
  append($$anchor3, span_2);
17112
17192
  };
17113
17193
  var alternate_2 = ($$anchor3) => {
17114
- var select = root_8$2();
17194
+ var select = root_8$3();
17115
17195
  select.__change = (e) => update(e.target);
17116
17196
  each(select, 21, () => generateQuantityOptions(get$2(capacity).min, get$2(capacity).max, { floor: 1 }), (q) => q.value, ($$anchor4, q) => {
17117
17197
  var option2 = root_9$4();
@@ -17140,7 +17220,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17140
17220
  var node_5 = sibling(li_2, 2);
17141
17221
  {
17142
17222
  var consequent_4 = ($$anchor3) => {
17143
- var li_3 = root_10$2();
17223
+ var li_3 = root_10$1();
17144
17224
  var button = child(li_3);
17145
17225
  button.__click = del;
17146
17226
  reset(li_3);
@@ -31150,7 +31230,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
31150
31230
  var root_4$4 = /* @__PURE__ */ from_html(`<!> <!>`, 1);
31151
31231
  var root_9$2 = /* @__PURE__ */ from_html(`<!> <!> <!>`, 1);
31152
31232
  var root_11$3 = /* @__PURE__ */ from_html(`<!> <!>`, 1);
31153
- var root_8$1 = /* @__PURE__ */ from_html(`<!> <!>`, 1);
31233
+ var root_8$2 = /* @__PURE__ */ from_html(`<!> <!>`, 1);
31154
31234
  var root_1$b = /* @__PURE__ */ from_html(`<!> <!> <!>`, 1);
31155
31235
  function DatePicker_1($$anchor, $$props) {
31156
31236
  push($$props, true);
@@ -31295,7 +31375,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
31295
31375
  const children = ($$anchor6, $$arg0) => {
31296
31376
  let months = () => $$arg0?.().months;
31297
31377
  let weekdays = () => $$arg0?.().weekdays;
31298
- var fragment_8 = root_8$1();
31378
+ var fragment_8 = root_8$2();
31299
31379
  var node_10 = first_child(fragment_8);
31300
31380
  component(node_10, () => Calendar_header, ($$anchor7, DatePicker_Header) => {
31301
31381
  DatePicker_Header($$anchor7, {
@@ -31455,17 +31535,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
31455
31535
  var root_2$6 = /* @__PURE__ */ from_html(`<span class="go-field-star" aria-hidden="true">*</span>`);
31456
31536
  var root_1$a = /* @__PURE__ */ from_html(` <!>`, 1);
31457
31537
  var root_3$6 = /* @__PURE__ */ from_html(`<label><!></label> <input/>`, 1);
31458
- var root_4$3 = /* @__PURE__ */ from_html(`<label><input/> <span class="go-checkbox-label"><!></span></label>`);
31459
- var root_7$2 = /* @__PURE__ */ from_html(`<img src="" alt=""/> <option> </option>`, 1);
31460
- var root_6$1 = /* @__PURE__ */ from_html(`<option disabled hidden="" selected> </option> <!>`, 1);
31538
+ var root_5 = /* @__PURE__ */ from_html(`<figure role="status" aria-live="polite"><img class="go-file-preview"/> <figcaption class="go-file-preview-caption"> </figcaption></figure>`);
31539
+ var root_4$3 = /* @__PURE__ */ from_html(`<label><!></label> <input/> <!>`, 1);
31540
+ var root_6$1 = /* @__PURE__ */ from_html(`<label><input/> <span class="go-checkbox-label"><!></span></label>`);
31541
+ var root_9$1 = /* @__PURE__ */ from_html(`<img src="" alt=""/> <option> </option>`, 1);
31542
+ var root_8$1 = /* @__PURE__ */ from_html(`<option disabled hidden="" selected> </option> <!>`, 1);
31461
31543
  var select_content = /* @__PURE__ */ from_html(`<!>`, 1);
31462
- var root_5 = /* @__PURE__ */ from_html(`<label><!></label> <select><!></select>`, 1);
31463
- var root_12$1 = /* @__PURE__ */ from_html(`<img style="width: 60px" aria-hidden="true"/>`);
31464
- var root_11$2 = /* @__PURE__ */ from_html(`<span class="go-payment-mode-icons"></span>`);
31465
- var root_10$1 = /* @__PURE__ */ from_html(`<label><input type="radio"/> <!></label>`);
31466
- var root_9$1 = /* @__PURE__ */ from_html(`<fieldset role="radiogroup"><legend><!></legend> <!></fieldset>`);
31467
- var root_15 = /* @__PURE__ */ from_html(`<label> <input/></label>`);
31468
- var root_13 = /* @__PURE__ */ from_html(`<fieldset><legend><!></legend> <!></fieldset>`);
31544
+ var root_7$2 = /* @__PURE__ */ from_html(`<label><!></label> <select><!></select>`, 1);
31545
+ var root_14 = /* @__PURE__ */ from_html(`<img style="width: 60px" aria-hidden="true"/>`);
31546
+ var root_13 = /* @__PURE__ */ from_html(`<span class="go-payment-mode-icons"></span>`);
31547
+ var root_12$1 = /* @__PURE__ */ from_html(`<label><input type="radio"/> <!></label>`);
31548
+ var root_11$2 = /* @__PURE__ */ from_html(`<fieldset role="radiogroup"><legend><!></legend> <!></fieldset>`);
31549
+ var root_17 = /* @__PURE__ */ from_html(`<label> <input/></label>`);
31550
+ var root_15 = /* @__PURE__ */ from_html(`<fieldset><legend><!></legend> <!></fieldset>`);
31469
31551
  function InputAndLabel($$anchor, $$props) {
31470
31552
  push($$props, true);
31471
31553
  const labelText = ($$anchor2) => {
@@ -31515,11 +31597,73 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
31515
31597
  bind_value(input_1, () => field().value, ($$value) => field(field().value = $$value, true));
31516
31598
  append($$anchor2, fragment_1);
31517
31599
  };
31518
- const checkbox = ($$anchor2) => {
31519
- var label_2 = root_4$3();
31520
- var input_2 = child(label_2);
31600
+ const file = ($$anchor2) => {
31601
+ var fragment_2 = root_4$3();
31602
+ var label_2 = first_child(fragment_2);
31603
+ var node_2 = child(label_2);
31604
+ labelText(node_2);
31605
+ reset(label_2);
31606
+ var input_2 = sibling(label_2, 2);
31607
+ var event_handler = (e) => {
31608
+ const files = e.currentTarget.files;
31609
+ field(field().value = files && files[0] ? files[0] : null, true);
31610
+ if (get$2(details)) get$2(details).validateField(field());
31611
+ else field().validate();
31612
+ };
31521
31613
  attribute_effect(
31522
31614
  input_2,
31615
+ () => ({
31616
+ ...get$2(fieldAttributes),
31617
+ ...restProps,
31618
+ class: inputClass(),
31619
+ type: "file",
31620
+ accept: "image/*",
31621
+ name: field().key,
31622
+ onchange: event_handler
31623
+ }),
31624
+ void 0,
31625
+ void 0,
31626
+ void 0,
31627
+ void 0,
31628
+ true
31629
+ );
31630
+ var node_3 = sibling(input_2, 2);
31631
+ {
31632
+ var consequent_1 = ($$anchor3) => {
31633
+ var figure = root_5();
31634
+ var img = child(figure);
31635
+ var figcaption = sibling(img, 2);
31636
+ var text_1 = child(figcaption, true);
31637
+ reset(figcaption);
31638
+ reset(figure);
31639
+ template_effect(
31640
+ ($0) => {
31641
+ set_attribute(figure, "data-field-preview", field().key);
31642
+ set_attribute(img, "src", get$2(filePreviewUrl));
31643
+ set_attribute(img, "alt", $0);
31644
+ set_text(text_1, field().value.name);
31645
+ },
31646
+ [
31647
+ () => shop.t("forms.file.preview_alt") || "User uploaded photo"
31648
+ ]
31649
+ );
31650
+ append($$anchor3, figure);
31651
+ };
31652
+ if_block(node_3, ($$render) => {
31653
+ if (get$2(filePreviewUrl) && field().value instanceof File) $$render(consequent_1);
31654
+ });
31655
+ }
31656
+ template_effect(() => {
31657
+ set_class(label_2, 1, clsx(labelClass()));
31658
+ set_attribute(label_2, "for", get$2(inputId));
31659
+ });
31660
+ append($$anchor2, fragment_2);
31661
+ };
31662
+ const checkbox = ($$anchor2) => {
31663
+ var label_3 = root_6$1();
31664
+ var input_3 = child(label_3);
31665
+ attribute_effect(
31666
+ input_3,
31523
31667
  () => ({
31524
31668
  ...get$2(fieldAttributes),
31525
31669
  ...restProps,
@@ -31533,17 +31677,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
31533
31677
  void 0,
31534
31678
  true
31535
31679
  );
31536
- var span_1 = sibling(input_2, 2);
31537
- var node_2 = child(span_1);
31538
- labelText(node_2);
31680
+ var span_1 = sibling(input_3, 2);
31681
+ var node_4 = child(span_1);
31682
+ labelText(node_4);
31539
31683
  reset(span_1);
31540
- reset(label_2);
31684
+ reset(label_3);
31541
31685
  template_effect(() => {
31542
- set_class(label_2, 1, clsx(labelClass()));
31543
- set_attribute(label_2, "for", get$2(inputId));
31686
+ set_class(label_3, 1, clsx(labelClass()));
31687
+ set_attribute(label_3, "for", get$2(inputId));
31544
31688
  });
31545
31689
  bind_checked(
31546
- input_2,
31690
+ input_3,
31547
31691
  () => {
31548
31692
  return field().value === true;
31549
31693
  },
@@ -31551,15 +31695,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
31551
31695
  field(field().value = value, true);
31552
31696
  }
31553
31697
  );
31554
- append($$anchor2, label_2);
31698
+ append($$anchor2, label_3);
31555
31699
  };
31556
31700
  const select = ($$anchor2) => {
31557
- var fragment_2 = root_5();
31558
- var label_3 = first_child(fragment_2);
31559
- var node_3 = child(label_3);
31560
- labelText(node_3);
31561
- reset(label_3);
31562
- var select_1 = sibling(label_3, 2);
31701
+ var fragment_3 = root_7$2();
31702
+ var label_4 = first_child(fragment_3);
31703
+ var node_5 = child(label_4);
31704
+ labelText(node_5);
31705
+ reset(label_4);
31706
+ var select_1 = sibling(label_4, 2);
31563
31707
  attribute_effect(select_1, () => ({
31564
31708
  ...get$2(fieldAttributes),
31565
31709
  ...restProps,
@@ -31568,45 +31712,45 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
31568
31712
  }));
31569
31713
  customizable_select(select_1, () => {
31570
31714
  var anchor = child(select_1);
31571
- var fragment_3 = select_content();
31572
- var node_4 = first_child(fragment_3);
31715
+ var fragment_4 = select_content();
31716
+ var node_6 = first_child(fragment_4);
31573
31717
  {
31574
- var consequent_1 = ($$anchor3) => {
31575
- var fragment_4 = root_6$1();
31576
- var option_1 = first_child(fragment_4);
31577
- var text_1 = child(option_1, true);
31718
+ var consequent_2 = ($$anchor3) => {
31719
+ var fragment_5 = root_8$1();
31720
+ var option_1 = first_child(fragment_5);
31721
+ var text_2 = child(option_1, true);
31578
31722
  reset(option_1);
31579
31723
  option_1.value = option_1.__value = "";
31580
- var node_5 = sibling(option_1, 2);
31581
- each(node_5, 17, () => field().options(), (option2) => option2.value, ($$anchor4, option2) => {
31582
- var fragment_5 = root_7$2();
31583
- var option_2 = sibling(first_child(fragment_5), 2);
31584
- var text_2 = child(option_2, true);
31724
+ var node_7 = sibling(option_1, 2);
31725
+ each(node_7, 17, () => field().options(), (option2) => option2.value, ($$anchor4, option2) => {
31726
+ var fragment_6 = root_9$1();
31727
+ var option_2 = sibling(first_child(fragment_6), 2);
31728
+ var text_3 = child(option_2, true);
31585
31729
  reset(option_2);
31586
31730
  var option_2_value = {};
31587
31731
  template_effect(() => {
31588
- set_text(text_2, get$2(option2).label);
31732
+ set_text(text_3, get$2(option2).label);
31589
31733
  if (option_2_value !== (option_2_value = get$2(option2).value)) {
31590
31734
  option_2.value = (option_2.__value = get$2(option2).value) ?? "";
31591
31735
  }
31592
31736
  });
31593
- append($$anchor4, fragment_5);
31737
+ append($$anchor4, fragment_6);
31594
31738
  });
31595
- template_effect(($0) => set_text(text_1, $0), [() => shop.t("common.choose")]);
31596
- append($$anchor3, fragment_4);
31739
+ template_effect(($0) => set_text(text_2, $0), [() => shop.t("common.choose")]);
31740
+ append($$anchor3, fragment_5);
31597
31741
  };
31598
- if_block(node_4, ($$render) => {
31599
- if (field().options) $$render(consequent_1);
31742
+ if_block(node_6, ($$render) => {
31743
+ if (field().options) $$render(consequent_2);
31600
31744
  });
31601
31745
  }
31602
- append(anchor, fragment_3);
31746
+ append(anchor, fragment_4);
31603
31747
  });
31604
31748
  template_effect(() => {
31605
- set_class(label_3, 1, clsx(labelClass()));
31606
- set_attribute(label_3, "for", get$2(inputId));
31749
+ set_class(label_4, 1, clsx(labelClass()));
31750
+ set_attribute(label_4, "for", get$2(inputId));
31607
31751
  });
31608
31752
  bind_select_value(select_1, () => field().value, ($$value) => field(field().value = $$value, true));
31609
- append($$anchor2, fragment_2);
31753
+ append($$anchor2, fragment_3);
31610
31754
  };
31611
31755
  const date2 = ($$anchor2) => {
31612
31756
  DatePicker_1($$anchor2, {
@@ -31629,48 +31773,48 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
31629
31773
  };
31630
31774
  const paymentMode = ($$anchor2) => {
31631
31775
  const modes = /* @__PURE__ */ user_derived(() => shop.payment_modes ? Object.values(shop.payment_modes) : []);
31632
- var fieldset = root_9$1();
31776
+ var fieldset = root_11$2();
31633
31777
  var legend = child(fieldset);
31634
- var node_6 = child(legend);
31635
- labelText(node_6);
31778
+ var node_8 = child(legend);
31779
+ labelText(node_8);
31636
31780
  reset(legend);
31637
- var node_7 = sibling(legend, 2);
31638
- each(node_7, 17, () => get$2(modes), (mode) => mode.id, ($$anchor3, mode) => {
31639
- var label_4 = root_10$1();
31640
- var input_3 = child(label_4);
31641
- remove_input_defaults(input_3);
31642
- input_3.__change = () => {
31781
+ var node_9 = sibling(legend, 2);
31782
+ each(node_9, 17, () => get$2(modes), (mode) => mode.id, ($$anchor3, mode) => {
31783
+ var label_5 = root_12$1();
31784
+ var input_4 = child(label_5);
31785
+ remove_input_defaults(input_4);
31786
+ input_4.__change = () => {
31643
31787
  field(field().value = String(get$2(mode).id), true);
31644
31788
  };
31645
- var node_8 = sibling(input_3, 2);
31789
+ var node_10 = sibling(input_4, 2);
31646
31790
  {
31647
- var consequent_2 = ($$anchor4) => {
31648
- var span_2 = root_11$2();
31791
+ var consequent_3 = ($$anchor4) => {
31792
+ var span_2 = root_13();
31649
31793
  each(span_2, 20, () => get$2(mode).icons, (icon) => icon, ($$anchor5, icon) => {
31650
31794
  const url = /* @__PURE__ */ user_derived(() => CDN_PATH + icon + ".svg");
31651
- var img = root_12$1();
31795
+ var img_1 = root_14();
31652
31796
  template_effect(() => {
31653
- set_class(img, 1, clsx(icon));
31654
- set_attribute(img, "src", get$2(url));
31655
- set_attribute(img, "alt", icon + " icon");
31797
+ set_class(img_1, 1, clsx(icon));
31798
+ set_attribute(img_1, "src", get$2(url));
31799
+ set_attribute(img_1, "alt", icon + " icon");
31656
31800
  });
31657
- append($$anchor5, img);
31801
+ append($$anchor5, img_1);
31658
31802
  });
31659
31803
  reset(span_2);
31660
31804
  append($$anchor4, span_2);
31661
31805
  };
31662
- if_block(node_8, ($$render) => {
31663
- if (get$2(mode).icons.length > 0) $$render(consequent_2);
31806
+ if_block(node_10, ($$render) => {
31807
+ if (get$2(mode).icons.length > 0) $$render(consequent_3);
31664
31808
  });
31665
31809
  }
31666
- reset(label_4);
31810
+ reset(label_5);
31667
31811
  template_effect(
31668
31812
  ($0, $1, $2) => {
31669
- set_attribute(input_3, "name", field().key);
31670
- set_value(input_3, $0);
31671
- set_checked(input_3, $1);
31672
- set_attribute(input_3, "hidden", get$2(modes).length === 1);
31673
- set_attribute(input_3, "aria-label", $2);
31813
+ set_attribute(input_4, "name", field().key);
31814
+ set_value(input_4, $0);
31815
+ set_checked(input_4, $1);
31816
+ set_attribute(input_4, "hidden", get$2(modes).length === 1);
31817
+ set_attribute(input_4, "aria-label", $2);
31674
31818
  },
31675
31819
  [
31676
31820
  () => String(get$2(mode).id),
@@ -31678,7 +31822,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
31678
31822
  () => shop.t(`cart.paymentMode.ariaLabel.${get$2(mode).name.toLowerCase()}`)
31679
31823
  ]
31680
31824
  );
31681
- append($$anchor3, label_4);
31825
+ append($$anchor3, label_5);
31682
31826
  });
31683
31827
  reset(fieldset);
31684
31828
  template_effect(() => {
@@ -31688,22 +31832,22 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
31688
31832
  append($$anchor2, fieldset);
31689
31833
  };
31690
31834
  const radio = ($$anchor2) => {
31691
- var fieldset_1 = root_13();
31835
+ var fieldset_1 = root_15();
31692
31836
  var legend_1 = child(fieldset_1);
31693
- var node_9 = child(legend_1);
31694
- labelText(node_9);
31837
+ var node_11 = child(legend_1);
31838
+ labelText(node_11);
31695
31839
  reset(legend_1);
31696
- var node_10 = sibling(legend_1, 2);
31840
+ var node_12 = sibling(legend_1, 2);
31697
31841
  {
31698
- var consequent_3 = ($$anchor3) => {
31699
- var fragment_7 = comment();
31700
- var node_11 = first_child(fragment_7);
31701
- each(node_11, 17, () => field().options, index$1, ($$anchor4, option2) => {
31702
- var label_5 = root_15();
31703
- var text_3 = child(label_5);
31704
- var input_4 = sibling(text_3);
31842
+ var consequent_4 = ($$anchor3) => {
31843
+ var fragment_8 = comment();
31844
+ var node_13 = first_child(fragment_8);
31845
+ each(node_13, 17, () => field().options, index$1, ($$anchor4, option2) => {
31846
+ var label_6 = root_17();
31847
+ var text_4 = child(label_6);
31848
+ var input_5 = sibling(text_4);
31705
31849
  attribute_effect(
31706
- input_4,
31850
+ input_5,
31707
31851
  () => ({
31708
31852
  ...get$2(fieldAttributes),
31709
31853
  ...restProps,
@@ -31716,19 +31860,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
31716
31860
  void 0,
31717
31861
  true
31718
31862
  );
31719
- reset(label_5);
31863
+ reset(label_6);
31720
31864
  template_effect(() => {
31721
- set_class(label_5, 1, clsx(labelClass()));
31722
- set_attribute(label_5, "for", get$2(inputId) + get$2(option2));
31723
- set_text(text_3, `${get$2(option2) ?? ""} `);
31865
+ set_class(label_6, 1, clsx(labelClass()));
31866
+ set_attribute(label_6, "for", get$2(inputId) + get$2(option2));
31867
+ set_text(text_4, `${get$2(option2) ?? ""} `);
31724
31868
  });
31725
- bind_value(input_4, () => field().value, ($$value) => field(field().value = $$value, true));
31726
- append($$anchor4, label_5);
31869
+ bind_value(input_5, () => field().value, ($$value) => field(field().value = $$value, true));
31870
+ append($$anchor4, label_6);
31727
31871
  });
31728
- append($$anchor3, fragment_7);
31872
+ append($$anchor3, fragment_8);
31729
31873
  };
31730
- if_block(node_10, ($$render) => {
31731
- if (field().options) $$render(consequent_3);
31874
+ if_block(node_12, ($$render) => {
31875
+ if (field().options) $$render(consequent_4);
31732
31876
  });
31733
31877
  }
31734
31878
  reset(fieldset_1);
@@ -31760,6 +31904,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
31760
31904
  select,
31761
31905
  radio,
31762
31906
  date: date2,
31907
+ file,
31763
31908
  textarea: null,
31764
31909
  paymentMode
31765
31910
  };
@@ -31781,6 +31926,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
31781
31926
  }));
31782
31927
  let label = /* @__PURE__ */ user_derived(() => shop.t(field().label) || field().label);
31783
31928
  const CDN_PATH = `https://cdn.shop.platform.gomus.de/`;
31929
+ let filePreviewUrl = /* @__PURE__ */ state(null);
31930
+ user_effect(() => {
31931
+ const value = field().value;
31932
+ if (value instanceof File && value.type.startsWith("image/")) {
31933
+ const url = URL.createObjectURL(value);
31934
+ set(filePreviewUrl, url, true);
31935
+ return () => {
31936
+ URL.revokeObjectURL(url);
31937
+ set(filePreviewUrl, null);
31938
+ };
31939
+ }
31940
+ set(filePreviewUrl, null);
31941
+ });
31784
31942
  var $$exports = {
31785
31943
  get field() {
31786
31944
  return field();
@@ -31818,20 +31976,20 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
31818
31976
  flushSync();
31819
31977
  }
31820
31978
  };
31821
- var fragment_8 = comment();
31822
- var node_12 = first_child(fragment_8);
31979
+ var fragment_9 = comment();
31980
+ var node_14 = first_child(fragment_9);
31823
31981
  {
31824
- var consequent_4 = ($$anchor2) => {
31825
- var fragment_9 = comment();
31826
- var node_13 = first_child(fragment_9);
31827
- snippet(node_13, () => get$2(snippet$1));
31828
- append($$anchor2, fragment_9);
31982
+ var consequent_5 = ($$anchor2) => {
31983
+ var fragment_10 = comment();
31984
+ var node_15 = first_child(fragment_10);
31985
+ snippet(node_15, () => get$2(snippet$1));
31986
+ append($$anchor2, fragment_10);
31829
31987
  };
31830
- if_block(node_12, ($$render) => {
31831
- if (get$2(snippet$1)) $$render(consequent_4);
31988
+ if_block(node_14, ($$render) => {
31989
+ if (get$2(snippet$1)) $$render(consequent_5);
31832
31990
  });
31833
31991
  }
31834
- append($$anchor, fragment_8);
31992
+ append($$anchor, fragment_9);
31835
31993
  return pop($$exports);
31836
31994
  }
31837
31995
  delegate(["change"]);
@@ -12635,6 +12635,14 @@ class Shop {
12635
12635
  finalizePersonalizations(token, params) {
12636
12636
  return this.apiPost("/api/v4/annual/personalization/finalize", { body: params, params: { query: { token } } });
12637
12637
  }
12638
+ uploadPersonalizationPhoto(token, personalizationId, file) {
12639
+ const fd = new FormData();
12640
+ fd.append("file", file);
12641
+ return this.apiUpload("/api/v4/annual/personalizations/{id}/upload", {
12642
+ body: fd,
12643
+ params: { path: { id: personalizationId }, query: { token } }
12644
+ });
12645
+ }
12638
12646
  /**
12639
12647
  * Returns a reactive value that will contain the fetched data, no need to await.
12640
12648
  *
@@ -12742,6 +12750,16 @@ class Shop {
12742
12750
  async apiDELETE(path, options) {
12743
12751
  return this.apiCall(path, { method: "DELETE", ...options });
12744
12752
  }
12753
+ async apiUpload(path, options) {
12754
+ this.#ensureApi();
12755
+ const { body, params = {} } = options;
12756
+ const ret = await this.client.POST(path, {
12757
+ body,
12758
+ params: assign(this.#defaultApiParams, { params }).params,
12759
+ bodySerializer: (b) => b
12760
+ });
12761
+ return ret;
12762
+ }
12745
12763
  async apiCall(path, options) {
12746
12764
  this.#ensureApi();
12747
12765
  const { body, params = {}, requiredFields } = options;
@@ -16023,6 +16041,28 @@ function refine(fn, _params = {}) {
16023
16041
  function superRefine(fn) {
16024
16042
  return /* @__PURE__ */ _superRefine(fn);
16025
16043
  }
16044
+ function _instanceof(cls, params = {}) {
16045
+ const inst = new ZodCustom({
16046
+ type: "custom",
16047
+ check: "custom",
16048
+ fn: (data) => data instanceof cls,
16049
+ abort: true,
16050
+ ...normalizeParams(params)
16051
+ });
16052
+ inst._zod.bag.Class = cls;
16053
+ inst._zod.check = (payload) => {
16054
+ if (!(payload.value instanceof cls)) {
16055
+ payload.issues.push({
16056
+ code: "invalid_type",
16057
+ expected: cls.name,
16058
+ input: payload.value,
16059
+ inst,
16060
+ path: [...inst._zod.def.path ?? []]
16061
+ });
16062
+ }
16063
+ };
16064
+ return inst;
16065
+ }
16026
16066
  var allFields = {
16027
16067
  salutation: {
16028
16068
  key: "salutation",
@@ -16209,6 +16249,16 @@ var allFields = {
16209
16249
  description: "",
16210
16250
  autocomplete: "off"
16211
16251
  },
16252
+ photo: {
16253
+ key: "photo",
16254
+ apiKey: "file",
16255
+ type: "file",
16256
+ label: "ticket.annual.personalization.form.photo",
16257
+ placeholder: "",
16258
+ description: "",
16259
+ autocomplete: "off",
16260
+ validator: _instanceof(File)
16261
+ },
16212
16262
  paymentMode: {
16213
16263
  key: "paymentMode",
16214
16264
  apiKey: "payment_mode_id",
@@ -16244,6 +16294,8 @@ function createField(data, required) {
16244
16294
  function defaultValue(fieldType) {
16245
16295
  if (fieldType === "checkbox") {
16246
16296
  return false;
16297
+ } else if (fieldType === "file") {
16298
+ return null;
16247
16299
  } else {
16248
16300
  return "";
16249
16301
  }
@@ -16252,7 +16304,8 @@ function validateField(field) {
16252
16304
  field.errors = [];
16253
16305
  if (!field.validator) {
16254
16306
  if (field.required) {
16255
- if (field.value === false || field.value === "") field.errors = field.value ? [] : [`common.fieldErrors.required`];
16307
+ const empty2 = field.value === false || field.value === "" || field.value === null || field.value === void 0;
16308
+ if (empty2) field.errors = [`common.fieldErrors.required`];
16256
16309
  }
16257
16310
  return;
16258
16311
  }
@@ -16359,6 +16412,33 @@ function AnnualTicketPersonalizationForm($$anchor, $$props) {
16359
16412
  if (!isValid2) {
16360
16413
  return;
16361
16414
  }
16415
+ if (details.ticketSale?.photo_mandatory === "mandatory") {
16416
+ const uploads = personalizationForms.map(async (detail, index2) => {
16417
+ const personalizationId = details.ticketSale.personalizations[index2].id;
16418
+ const photoField = detail.fields.find((f) => f.key === "photo");
16419
+ const file = photoField?.value;
16420
+ if (!(file instanceof File)) {
16421
+ return {
16422
+ ok: false,
16423
+ error: "ticket.annual.personalization.photo.missing"
16424
+ };
16425
+ }
16426
+ const result2 = await shop.uploadPersonalizationPhoto(token(), personalizationId, file);
16427
+ if (result2.error) {
16428
+ return {
16429
+ ok: false,
16430
+ error: result2.error.error ?? "ticket.annual.personalization.photo.upload_failed"
16431
+ };
16432
+ }
16433
+ return { ok: true, error: "" };
16434
+ });
16435
+ const results = await Promise.all(uploads);
16436
+ const firstFailure = results.find((r2) => !r2.ok);
16437
+ if (firstFailure) {
16438
+ form.details.apiErrors = [firstFailure.error];
16439
+ return;
16440
+ }
16441
+ }
16362
16442
  const body = {
16363
16443
  personalization: {
16364
16444
  ticket_sale_id: details.ticketSaleId,
@@ -16495,7 +16575,7 @@ class FormDetails {
16495
16575
  if (!Number.isNaN(+x) && x.trim() !== "") return +x;
16496
16576
  return x;
16497
16577
  }
16498
- const validFields = this.fields.filter((f) => f !== void 0).filter((f) => f.value !== "");
16578
+ const validFields = this.fields.filter((f) => f !== void 0).filter((f) => f.type !== "file").filter((f) => f.value !== "");
16499
16579
  const ret = Object.fromEntries(validFields.map((f) => [f.apiKey, coerce2(f.value)]));
16500
16580
  return ret;
16501
16581
  }
@@ -16955,8 +17035,8 @@ var root_5$2 = /* @__PURE__ */ from_html(`<s class="go-cart-item-price-original"
16955
17035
  var root_6$3 = /* @__PURE__ */ from_html(`<span class="go-cart-item-price-discounted"> </span>`);
16956
17036
  var root_7$4 = /* @__PURE__ */ from_html(`<span> </span>`);
16957
17037
  var root_9$4 = /* @__PURE__ */ from_html(`<option> </option>`);
16958
- var root_8$2 = /* @__PURE__ */ from_html(`<select class="go-cart-item-select"></select>`);
16959
- var root_10$2 = /* @__PURE__ */ from_html(`<li class="go-cart-item-remove"><button>⨉</button></li>`);
17038
+ var root_8$3 = /* @__PURE__ */ from_html(`<select class="go-cart-item-select"></select>`);
17039
+ var root_10$1 = /* @__PURE__ */ from_html(`<li class="go-cart-item-remove"><button>⨉</button></li>`);
16960
17040
  var root_1$i = /* @__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>`);
16961
17041
  function Item$1($$anchor, $$props) {
16962
17042
  push($$props, true);
@@ -17111,7 +17191,7 @@ function Item$1($$anchor, $$props) {
17111
17191
  append($$anchor3, span_2);
17112
17192
  };
17113
17193
  var alternate_2 = ($$anchor3) => {
17114
- var select = root_8$2();
17194
+ var select = root_8$3();
17115
17195
  select.__change = (e) => update(e.target);
17116
17196
  each(select, 21, () => generateQuantityOptions(get$2(capacity).min, get$2(capacity).max, { floor: 1 }), (q) => q.value, ($$anchor4, q) => {
17117
17197
  var option2 = root_9$4();
@@ -17140,7 +17220,7 @@ function Item$1($$anchor, $$props) {
17140
17220
  var node_5 = sibling(li_2, 2);
17141
17221
  {
17142
17222
  var consequent_4 = ($$anchor3) => {
17143
- var li_3 = root_10$2();
17223
+ var li_3 = root_10$1();
17144
17224
  var button = child(li_3);
17145
17225
  button.__click = del;
17146
17226
  reset(li_3);
@@ -31150,7 +31230,7 @@ create_custom_element(Date_picker_trigger, { ref: {}, onkeydown: {} }, [], [], {
31150
31230
  var root_4$4 = /* @__PURE__ */ from_html(`<!> <!>`, 1);
31151
31231
  var root_9$2 = /* @__PURE__ */ from_html(`<!> <!> <!>`, 1);
31152
31232
  var root_11$3 = /* @__PURE__ */ from_html(`<!> <!>`, 1);
31153
- var root_8$1 = /* @__PURE__ */ from_html(`<!> <!>`, 1);
31233
+ var root_8$2 = /* @__PURE__ */ from_html(`<!> <!>`, 1);
31154
31234
  var root_1$b = /* @__PURE__ */ from_html(`<!> <!> <!>`, 1);
31155
31235
  function DatePicker_1($$anchor, $$props) {
31156
31236
  push($$props, true);
@@ -31295,7 +31375,7 @@ function DatePicker_1($$anchor, $$props) {
31295
31375
  const children = ($$anchor6, $$arg0) => {
31296
31376
  let months = () => $$arg0?.().months;
31297
31377
  let weekdays = () => $$arg0?.().weekdays;
31298
- var fragment_8 = root_8$1();
31378
+ var fragment_8 = root_8$2();
31299
31379
  var node_10 = first_child(fragment_8);
31300
31380
  component(node_10, () => Calendar_header, ($$anchor7, DatePicker_Header) => {
31301
31381
  DatePicker_Header($$anchor7, {
@@ -31455,17 +31535,19 @@ create_custom_element(
31455
31535
  var root_2$6 = /* @__PURE__ */ from_html(`<span class="go-field-star" aria-hidden="true">*</span>`);
31456
31536
  var root_1$a = /* @__PURE__ */ from_html(` <!>`, 1);
31457
31537
  var root_3$6 = /* @__PURE__ */ from_html(`<label><!></label> <input/>`, 1);
31458
- var root_4$3 = /* @__PURE__ */ from_html(`<label><input/> <span class="go-checkbox-label"><!></span></label>`);
31459
- var root_7$2 = /* @__PURE__ */ from_html(`<img src="" alt=""/> <option> </option>`, 1);
31460
- var root_6$1 = /* @__PURE__ */ from_html(`<option disabled hidden="" selected> </option> <!>`, 1);
31538
+ var root_5 = /* @__PURE__ */ from_html(`<figure role="status" aria-live="polite"><img class="go-file-preview"/> <figcaption class="go-file-preview-caption"> </figcaption></figure>`);
31539
+ var root_4$3 = /* @__PURE__ */ from_html(`<label><!></label> <input/> <!>`, 1);
31540
+ var root_6$1 = /* @__PURE__ */ from_html(`<label><input/> <span class="go-checkbox-label"><!></span></label>`);
31541
+ var root_9$1 = /* @__PURE__ */ from_html(`<img src="" alt=""/> <option> </option>`, 1);
31542
+ var root_8$1 = /* @__PURE__ */ from_html(`<option disabled hidden="" selected> </option> <!>`, 1);
31461
31543
  var select_content = /* @__PURE__ */ from_html(`<!>`, 1);
31462
- var root_5 = /* @__PURE__ */ from_html(`<label><!></label> <select><!></select>`, 1);
31463
- var root_12$1 = /* @__PURE__ */ from_html(`<img style="width: 60px" aria-hidden="true"/>`);
31464
- var root_11$2 = /* @__PURE__ */ from_html(`<span class="go-payment-mode-icons"></span>`);
31465
- var root_10$1 = /* @__PURE__ */ from_html(`<label><input type="radio"/> <!></label>`);
31466
- var root_9$1 = /* @__PURE__ */ from_html(`<fieldset role="radiogroup"><legend><!></legend> <!></fieldset>`);
31467
- var root_15 = /* @__PURE__ */ from_html(`<label> <input/></label>`);
31468
- var root_13 = /* @__PURE__ */ from_html(`<fieldset><legend><!></legend> <!></fieldset>`);
31544
+ var root_7$2 = /* @__PURE__ */ from_html(`<label><!></label> <select><!></select>`, 1);
31545
+ var root_14 = /* @__PURE__ */ from_html(`<img style="width: 60px" aria-hidden="true"/>`);
31546
+ var root_13 = /* @__PURE__ */ from_html(`<span class="go-payment-mode-icons"></span>`);
31547
+ var root_12$1 = /* @__PURE__ */ from_html(`<label><input type="radio"/> <!></label>`);
31548
+ var root_11$2 = /* @__PURE__ */ from_html(`<fieldset role="radiogroup"><legend><!></legend> <!></fieldset>`);
31549
+ var root_17 = /* @__PURE__ */ from_html(`<label> <input/></label>`);
31550
+ var root_15 = /* @__PURE__ */ from_html(`<fieldset><legend><!></legend> <!></fieldset>`);
31469
31551
  function InputAndLabel($$anchor, $$props) {
31470
31552
  push($$props, true);
31471
31553
  const labelText = ($$anchor2) => {
@@ -31515,11 +31597,73 @@ function InputAndLabel($$anchor, $$props) {
31515
31597
  bind_value(input_1, () => field().value, ($$value) => field(field().value = $$value, true));
31516
31598
  append($$anchor2, fragment_1);
31517
31599
  };
31518
- const checkbox = ($$anchor2) => {
31519
- var label_2 = root_4$3();
31520
- var input_2 = child(label_2);
31600
+ const file = ($$anchor2) => {
31601
+ var fragment_2 = root_4$3();
31602
+ var label_2 = first_child(fragment_2);
31603
+ var node_2 = child(label_2);
31604
+ labelText(node_2);
31605
+ reset(label_2);
31606
+ var input_2 = sibling(label_2, 2);
31607
+ var event_handler = (e) => {
31608
+ const files = e.currentTarget.files;
31609
+ field(field().value = files && files[0] ? files[0] : null, true);
31610
+ if (get$2(details)) get$2(details).validateField(field());
31611
+ else field().validate();
31612
+ };
31521
31613
  attribute_effect(
31522
31614
  input_2,
31615
+ () => ({
31616
+ ...get$2(fieldAttributes),
31617
+ ...restProps,
31618
+ class: inputClass(),
31619
+ type: "file",
31620
+ accept: "image/*",
31621
+ name: field().key,
31622
+ onchange: event_handler
31623
+ }),
31624
+ void 0,
31625
+ void 0,
31626
+ void 0,
31627
+ void 0,
31628
+ true
31629
+ );
31630
+ var node_3 = sibling(input_2, 2);
31631
+ {
31632
+ var consequent_1 = ($$anchor3) => {
31633
+ var figure = root_5();
31634
+ var img = child(figure);
31635
+ var figcaption = sibling(img, 2);
31636
+ var text_1 = child(figcaption, true);
31637
+ reset(figcaption);
31638
+ reset(figure);
31639
+ template_effect(
31640
+ ($0) => {
31641
+ set_attribute(figure, "data-field-preview", field().key);
31642
+ set_attribute(img, "src", get$2(filePreviewUrl));
31643
+ set_attribute(img, "alt", $0);
31644
+ set_text(text_1, field().value.name);
31645
+ },
31646
+ [
31647
+ () => shop.t("forms.file.preview_alt") || "User uploaded photo"
31648
+ ]
31649
+ );
31650
+ append($$anchor3, figure);
31651
+ };
31652
+ if_block(node_3, ($$render) => {
31653
+ if (get$2(filePreviewUrl) && field().value instanceof File) $$render(consequent_1);
31654
+ });
31655
+ }
31656
+ template_effect(() => {
31657
+ set_class(label_2, 1, clsx(labelClass()));
31658
+ set_attribute(label_2, "for", get$2(inputId));
31659
+ });
31660
+ append($$anchor2, fragment_2);
31661
+ };
31662
+ const checkbox = ($$anchor2) => {
31663
+ var label_3 = root_6$1();
31664
+ var input_3 = child(label_3);
31665
+ attribute_effect(
31666
+ input_3,
31523
31667
  () => ({
31524
31668
  ...get$2(fieldAttributes),
31525
31669
  ...restProps,
@@ -31533,17 +31677,17 @@ function InputAndLabel($$anchor, $$props) {
31533
31677
  void 0,
31534
31678
  true
31535
31679
  );
31536
- var span_1 = sibling(input_2, 2);
31537
- var node_2 = child(span_1);
31538
- labelText(node_2);
31680
+ var span_1 = sibling(input_3, 2);
31681
+ var node_4 = child(span_1);
31682
+ labelText(node_4);
31539
31683
  reset(span_1);
31540
- reset(label_2);
31684
+ reset(label_3);
31541
31685
  template_effect(() => {
31542
- set_class(label_2, 1, clsx(labelClass()));
31543
- set_attribute(label_2, "for", get$2(inputId));
31686
+ set_class(label_3, 1, clsx(labelClass()));
31687
+ set_attribute(label_3, "for", get$2(inputId));
31544
31688
  });
31545
31689
  bind_checked(
31546
- input_2,
31690
+ input_3,
31547
31691
  () => {
31548
31692
  return field().value === true;
31549
31693
  },
@@ -31551,15 +31695,15 @@ function InputAndLabel($$anchor, $$props) {
31551
31695
  field(field().value = value, true);
31552
31696
  }
31553
31697
  );
31554
- append($$anchor2, label_2);
31698
+ append($$anchor2, label_3);
31555
31699
  };
31556
31700
  const select = ($$anchor2) => {
31557
- var fragment_2 = root_5();
31558
- var label_3 = first_child(fragment_2);
31559
- var node_3 = child(label_3);
31560
- labelText(node_3);
31561
- reset(label_3);
31562
- var select_1 = sibling(label_3, 2);
31701
+ var fragment_3 = root_7$2();
31702
+ var label_4 = first_child(fragment_3);
31703
+ var node_5 = child(label_4);
31704
+ labelText(node_5);
31705
+ reset(label_4);
31706
+ var select_1 = sibling(label_4, 2);
31563
31707
  attribute_effect(select_1, () => ({
31564
31708
  ...get$2(fieldAttributes),
31565
31709
  ...restProps,
@@ -31568,45 +31712,45 @@ function InputAndLabel($$anchor, $$props) {
31568
31712
  }));
31569
31713
  customizable_select(select_1, () => {
31570
31714
  var anchor = child(select_1);
31571
- var fragment_3 = select_content();
31572
- var node_4 = first_child(fragment_3);
31715
+ var fragment_4 = select_content();
31716
+ var node_6 = first_child(fragment_4);
31573
31717
  {
31574
- var consequent_1 = ($$anchor3) => {
31575
- var fragment_4 = root_6$1();
31576
- var option_1 = first_child(fragment_4);
31577
- var text_1 = child(option_1, true);
31718
+ var consequent_2 = ($$anchor3) => {
31719
+ var fragment_5 = root_8$1();
31720
+ var option_1 = first_child(fragment_5);
31721
+ var text_2 = child(option_1, true);
31578
31722
  reset(option_1);
31579
31723
  option_1.value = option_1.__value = "";
31580
- var node_5 = sibling(option_1, 2);
31581
- each(node_5, 17, () => field().options(), (option2) => option2.value, ($$anchor4, option2) => {
31582
- var fragment_5 = root_7$2();
31583
- var option_2 = sibling(first_child(fragment_5), 2);
31584
- var text_2 = child(option_2, true);
31724
+ var node_7 = sibling(option_1, 2);
31725
+ each(node_7, 17, () => field().options(), (option2) => option2.value, ($$anchor4, option2) => {
31726
+ var fragment_6 = root_9$1();
31727
+ var option_2 = sibling(first_child(fragment_6), 2);
31728
+ var text_3 = child(option_2, true);
31585
31729
  reset(option_2);
31586
31730
  var option_2_value = {};
31587
31731
  template_effect(() => {
31588
- set_text(text_2, get$2(option2).label);
31732
+ set_text(text_3, get$2(option2).label);
31589
31733
  if (option_2_value !== (option_2_value = get$2(option2).value)) {
31590
31734
  option_2.value = (option_2.__value = get$2(option2).value) ?? "";
31591
31735
  }
31592
31736
  });
31593
- append($$anchor4, fragment_5);
31737
+ append($$anchor4, fragment_6);
31594
31738
  });
31595
- template_effect(($0) => set_text(text_1, $0), [() => shop.t("common.choose")]);
31596
- append($$anchor3, fragment_4);
31739
+ template_effect(($0) => set_text(text_2, $0), [() => shop.t("common.choose")]);
31740
+ append($$anchor3, fragment_5);
31597
31741
  };
31598
- if_block(node_4, ($$render) => {
31599
- if (field().options) $$render(consequent_1);
31742
+ if_block(node_6, ($$render) => {
31743
+ if (field().options) $$render(consequent_2);
31600
31744
  });
31601
31745
  }
31602
- append(anchor, fragment_3);
31746
+ append(anchor, fragment_4);
31603
31747
  });
31604
31748
  template_effect(() => {
31605
- set_class(label_3, 1, clsx(labelClass()));
31606
- set_attribute(label_3, "for", get$2(inputId));
31749
+ set_class(label_4, 1, clsx(labelClass()));
31750
+ set_attribute(label_4, "for", get$2(inputId));
31607
31751
  });
31608
31752
  bind_select_value(select_1, () => field().value, ($$value) => field(field().value = $$value, true));
31609
- append($$anchor2, fragment_2);
31753
+ append($$anchor2, fragment_3);
31610
31754
  };
31611
31755
  const date2 = ($$anchor2) => {
31612
31756
  DatePicker_1($$anchor2, {
@@ -31629,48 +31773,48 @@ function InputAndLabel($$anchor, $$props) {
31629
31773
  };
31630
31774
  const paymentMode = ($$anchor2) => {
31631
31775
  const modes = /* @__PURE__ */ user_derived(() => shop.payment_modes ? Object.values(shop.payment_modes) : []);
31632
- var fieldset = root_9$1();
31776
+ var fieldset = root_11$2();
31633
31777
  var legend = child(fieldset);
31634
- var node_6 = child(legend);
31635
- labelText(node_6);
31778
+ var node_8 = child(legend);
31779
+ labelText(node_8);
31636
31780
  reset(legend);
31637
- var node_7 = sibling(legend, 2);
31638
- each(node_7, 17, () => get$2(modes), (mode) => mode.id, ($$anchor3, mode) => {
31639
- var label_4 = root_10$1();
31640
- var input_3 = child(label_4);
31641
- remove_input_defaults(input_3);
31642
- input_3.__change = () => {
31781
+ var node_9 = sibling(legend, 2);
31782
+ each(node_9, 17, () => get$2(modes), (mode) => mode.id, ($$anchor3, mode) => {
31783
+ var label_5 = root_12$1();
31784
+ var input_4 = child(label_5);
31785
+ remove_input_defaults(input_4);
31786
+ input_4.__change = () => {
31643
31787
  field(field().value = String(get$2(mode).id), true);
31644
31788
  };
31645
- var node_8 = sibling(input_3, 2);
31789
+ var node_10 = sibling(input_4, 2);
31646
31790
  {
31647
- var consequent_2 = ($$anchor4) => {
31648
- var span_2 = root_11$2();
31791
+ var consequent_3 = ($$anchor4) => {
31792
+ var span_2 = root_13();
31649
31793
  each(span_2, 20, () => get$2(mode).icons, (icon) => icon, ($$anchor5, icon) => {
31650
31794
  const url = /* @__PURE__ */ user_derived(() => CDN_PATH + icon + ".svg");
31651
- var img = root_12$1();
31795
+ var img_1 = root_14();
31652
31796
  template_effect(() => {
31653
- set_class(img, 1, clsx(icon));
31654
- set_attribute(img, "src", get$2(url));
31655
- set_attribute(img, "alt", icon + " icon");
31797
+ set_class(img_1, 1, clsx(icon));
31798
+ set_attribute(img_1, "src", get$2(url));
31799
+ set_attribute(img_1, "alt", icon + " icon");
31656
31800
  });
31657
- append($$anchor5, img);
31801
+ append($$anchor5, img_1);
31658
31802
  });
31659
31803
  reset(span_2);
31660
31804
  append($$anchor4, span_2);
31661
31805
  };
31662
- if_block(node_8, ($$render) => {
31663
- if (get$2(mode).icons.length > 0) $$render(consequent_2);
31806
+ if_block(node_10, ($$render) => {
31807
+ if (get$2(mode).icons.length > 0) $$render(consequent_3);
31664
31808
  });
31665
31809
  }
31666
- reset(label_4);
31810
+ reset(label_5);
31667
31811
  template_effect(
31668
31812
  ($0, $1, $2) => {
31669
- set_attribute(input_3, "name", field().key);
31670
- set_value(input_3, $0);
31671
- set_checked(input_3, $1);
31672
- set_attribute(input_3, "hidden", get$2(modes).length === 1);
31673
- set_attribute(input_3, "aria-label", $2);
31813
+ set_attribute(input_4, "name", field().key);
31814
+ set_value(input_4, $0);
31815
+ set_checked(input_4, $1);
31816
+ set_attribute(input_4, "hidden", get$2(modes).length === 1);
31817
+ set_attribute(input_4, "aria-label", $2);
31674
31818
  },
31675
31819
  [
31676
31820
  () => String(get$2(mode).id),
@@ -31678,7 +31822,7 @@ function InputAndLabel($$anchor, $$props) {
31678
31822
  () => shop.t(`cart.paymentMode.ariaLabel.${get$2(mode).name.toLowerCase()}`)
31679
31823
  ]
31680
31824
  );
31681
- append($$anchor3, label_4);
31825
+ append($$anchor3, label_5);
31682
31826
  });
31683
31827
  reset(fieldset);
31684
31828
  template_effect(() => {
@@ -31688,22 +31832,22 @@ function InputAndLabel($$anchor, $$props) {
31688
31832
  append($$anchor2, fieldset);
31689
31833
  };
31690
31834
  const radio = ($$anchor2) => {
31691
- var fieldset_1 = root_13();
31835
+ var fieldset_1 = root_15();
31692
31836
  var legend_1 = child(fieldset_1);
31693
- var node_9 = child(legend_1);
31694
- labelText(node_9);
31837
+ var node_11 = child(legend_1);
31838
+ labelText(node_11);
31695
31839
  reset(legend_1);
31696
- var node_10 = sibling(legend_1, 2);
31840
+ var node_12 = sibling(legend_1, 2);
31697
31841
  {
31698
- var consequent_3 = ($$anchor3) => {
31699
- var fragment_7 = comment();
31700
- var node_11 = first_child(fragment_7);
31701
- each(node_11, 17, () => field().options, index$1, ($$anchor4, option2) => {
31702
- var label_5 = root_15();
31703
- var text_3 = child(label_5);
31704
- var input_4 = sibling(text_3);
31842
+ var consequent_4 = ($$anchor3) => {
31843
+ var fragment_8 = comment();
31844
+ var node_13 = first_child(fragment_8);
31845
+ each(node_13, 17, () => field().options, index$1, ($$anchor4, option2) => {
31846
+ var label_6 = root_17();
31847
+ var text_4 = child(label_6);
31848
+ var input_5 = sibling(text_4);
31705
31849
  attribute_effect(
31706
- input_4,
31850
+ input_5,
31707
31851
  () => ({
31708
31852
  ...get$2(fieldAttributes),
31709
31853
  ...restProps,
@@ -31716,19 +31860,19 @@ function InputAndLabel($$anchor, $$props) {
31716
31860
  void 0,
31717
31861
  true
31718
31862
  );
31719
- reset(label_5);
31863
+ reset(label_6);
31720
31864
  template_effect(() => {
31721
- set_class(label_5, 1, clsx(labelClass()));
31722
- set_attribute(label_5, "for", get$2(inputId) + get$2(option2));
31723
- set_text(text_3, `${get$2(option2) ?? ""} `);
31865
+ set_class(label_6, 1, clsx(labelClass()));
31866
+ set_attribute(label_6, "for", get$2(inputId) + get$2(option2));
31867
+ set_text(text_4, `${get$2(option2) ?? ""} `);
31724
31868
  });
31725
- bind_value(input_4, () => field().value, ($$value) => field(field().value = $$value, true));
31726
- append($$anchor4, label_5);
31869
+ bind_value(input_5, () => field().value, ($$value) => field(field().value = $$value, true));
31870
+ append($$anchor4, label_6);
31727
31871
  });
31728
- append($$anchor3, fragment_7);
31872
+ append($$anchor3, fragment_8);
31729
31873
  };
31730
- if_block(node_10, ($$render) => {
31731
- if (field().options) $$render(consequent_3);
31874
+ if_block(node_12, ($$render) => {
31875
+ if (field().options) $$render(consequent_4);
31732
31876
  });
31733
31877
  }
31734
31878
  reset(fieldset_1);
@@ -31760,6 +31904,7 @@ function InputAndLabel($$anchor, $$props) {
31760
31904
  select,
31761
31905
  radio,
31762
31906
  date: date2,
31907
+ file,
31763
31908
  textarea: null,
31764
31909
  paymentMode
31765
31910
  };
@@ -31781,6 +31926,19 @@ function InputAndLabel($$anchor, $$props) {
31781
31926
  }));
31782
31927
  let label = /* @__PURE__ */ user_derived(() => shop.t(field().label) || field().label);
31783
31928
  const CDN_PATH = `https://cdn.shop.platform.gomus.de/`;
31929
+ let filePreviewUrl = /* @__PURE__ */ state(null);
31930
+ user_effect(() => {
31931
+ const value = field().value;
31932
+ if (value instanceof File && value.type.startsWith("image/")) {
31933
+ const url = URL.createObjectURL(value);
31934
+ set(filePreviewUrl, url, true);
31935
+ return () => {
31936
+ URL.revokeObjectURL(url);
31937
+ set(filePreviewUrl, null);
31938
+ };
31939
+ }
31940
+ set(filePreviewUrl, null);
31941
+ });
31784
31942
  var $$exports = {
31785
31943
  get field() {
31786
31944
  return field();
@@ -31818,20 +31976,20 @@ function InputAndLabel($$anchor, $$props) {
31818
31976
  flushSync();
31819
31977
  }
31820
31978
  };
31821
- var fragment_8 = comment();
31822
- var node_12 = first_child(fragment_8);
31979
+ var fragment_9 = comment();
31980
+ var node_14 = first_child(fragment_9);
31823
31981
  {
31824
- var consequent_4 = ($$anchor2) => {
31825
- var fragment_9 = comment();
31826
- var node_13 = first_child(fragment_9);
31827
- snippet(node_13, () => get$2(snippet$1));
31828
- append($$anchor2, fragment_9);
31982
+ var consequent_5 = ($$anchor2) => {
31983
+ var fragment_10 = comment();
31984
+ var node_15 = first_child(fragment_10);
31985
+ snippet(node_15, () => get$2(snippet$1));
31986
+ append($$anchor2, fragment_10);
31829
31987
  };
31830
- if_block(node_12, ($$render) => {
31831
- if (get$2(snippet$1)) $$render(consequent_4);
31988
+ if_block(node_14, ($$render) => {
31989
+ if (get$2(snippet$1)) $$render(consequent_5);
31832
31990
  });
31833
31991
  }
31834
- append($$anchor, fragment_8);
31992
+ append($$anchor, fragment_9);
31835
31993
  return pop($$exports);
31836
31994
  }
31837
31995
  delegate(["change"]);
@@ -1,6 +1,6 @@
1
1
  import { FullAutoFill } from 'svelte/elements';
2
2
  import { ZodType } from 'zod';
3
- export type FieldType = 'input' | 'text' | 'email' | 'password' | 'search' | 'tel' | 'url' | 'number' | 'checkbox' | 'select' | 'radio' | 'textarea' | 'date' | 'paymentMode';
3
+ export type FieldType = 'input' | 'text' | 'email' | 'password' | 'search' | 'tel' | 'url' | 'number' | 'checkbox' | 'select' | 'radio' | 'textarea' | 'date' | 'file' | 'paymentMode';
4
4
  export interface Field {
5
5
  key: string;
6
6
  apiKey?: string;
@@ -11,7 +11,7 @@ export interface Field {
11
11
  value: string | number;
12
12
  label: string;
13
13
  }[];
14
- value: string | boolean;
14
+ value: string | boolean | File | null;
15
15
  required: boolean;
16
16
  description: string | undefined;
17
17
  autocomplete: FullAutoFill;
@@ -9,7 +9,7 @@ export declare class FormDetails {
9
9
  */
10
10
  successMessage: string | undefined;
11
11
  get formData(): Record<string, string | number | boolean>;
12
- fieldValue(key: string): string | boolean | undefined;
12
+ fieldValue(key: string): string | boolean | File | null | undefined;
13
13
  get apiErrors(): string[] | Record<string, string[]>;
14
14
  /**
15
15
  * Sets API errors for the current instance.
@@ -6,7 +6,7 @@ import { Auth } from '../../../lib/stores/auth.svelte.ts';
6
6
  import { User } from '../../../lib/stores/user.svelte.ts';
7
7
  import { OpenApiClient } from '@gomus/api';
8
8
  import { TicketsAndQuotasParams, TicketsCalendarParams, TicketsParams } from '@gomus/api/lib/types.ts';
9
- import { CapacitiesResponse, CheckoutParams, CheckoutResponse, Country, Event, Exhibition, FinalizePersonalizationParams, FinalizePersonalizationResponse, LocaleOptions, Merchandise, Museum, PasswordResetResponse, PasswordUpdateResponse, PostCartParams, PostCartResponse, Salutation, ShopType, SignInParams, SignInResponse, SignUpParams, SignUpResponse, Tour, ValidateTokenResponse } from '@gomus/types';
9
+ import { CapacitiesResponse, CheckoutParams, CheckoutResponse, Country, Event, Exhibition, FinalizePersonalizationParams, FinalizePersonalizationResponse, LocaleOptions, Merchandise, Museum, PasswordResetResponse, PasswordUpdateResponse, PostCartParams, PostCartResponse, Salutation, ShopType, SignInParams, SignInResponse, SignUpParams, SignUpResponse, Tour, UploadPersonalizationPhotoResponse, ValidateTokenResponse } from '@gomus/types';
10
10
  export type ShopKind = 'angular' | 'jmb';
11
11
  export declare class Shop {
12
12
  #private;
@@ -489,6 +489,7 @@ export declare class Shop {
489
489
  ticket_sales: import('@gomus/types').components["schemas"]["ticket_sale_personalization"][];
490
490
  } | undefined;
491
491
  finalizePersonalizations(token: string, params: FinalizePersonalizationParams): Promise<FinalizePersonalizationResponse>;
492
+ uploadPersonalizationPhoto(token: string, personalizationId: number, file: File): Promise<UploadPersonalizationPhotoResponse>;
492
493
  /**
493
494
  * Returns a reactive value that will contain the fetched data, no need to await.
494
495
  *
@@ -802,6 +803,10 @@ export declare class Shop {
802
803
  params?: Record<string, unknown>;
803
804
  requiredFields?: string[];
804
805
  }): Promise<T>;
806
+ apiUpload<T>(path: string, options: {
807
+ body: FormData;
808
+ params?: Record<string, unknown>;
809
+ }): Promise<T>;
805
810
  apiCall<T>(path: string, options: {
806
811
  method: 'POST' | 'PUT' | 'DELETE';
807
812
  body: Record<string, any>;
@@ -10,6 +10,9 @@ export declare const MSWMocks: {
10
10
  mockSalutations: () => void;
11
11
  mockLocales: () => void;
12
12
  mockAnnualOrder: () => void;
13
+ mockAnnualOrderWithRequiredPhoto: () => void;
14
+ mockPersonalizationPhotoUpload: () => void;
15
+ mockPersonalizationPhotoUploadFailure: () => void;
13
16
  mockCountries: () => void;
14
17
  mockPersonalizationFormSubmit: () => void;
15
18
  tickets: {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "Giantmonkey GmbH"
5
5
  },
6
6
  "license": "MIT",
7
- "version": "1.56.1",
7
+ "version": "1.57.0",
8
8
  "type": "module",
9
9
  "main": "./dist-js/gomus-webcomponents.iife.js",
10
10
  "module": "./dist-js/gomus-webcomponents.iife.js",