@gomusdev/web-components 1.15.0 → 1.16.1

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.
@@ -5432,29 +5432,86 @@ function create_custom_element(Component, props_definition, slots, exports, use_
5432
5432
  Class;
5433
5433
  return Class;
5434
5434
  }
5435
+ function wait(ms) {
5436
+ return new Promise((resolve) => setTimeout(resolve, ms));
5437
+ }
5438
+ function isEmail(email2) {
5439
+ return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email2);
5440
+ }
5441
+ function isBoolean(value) {
5442
+ return typeof value === "boolean";
5443
+ }
5444
+ function pollUntilTruthy(callback, maxDuration = 1e3) {
5445
+ return new Promise((resolve, reject) => {
5446
+ const startTime = Date.now();
5447
+ const interval = 20;
5448
+ const poll = () => {
5449
+ try {
5450
+ const result = callback();
5451
+ if (result) {
5452
+ resolve(result);
5453
+ return;
5454
+ }
5455
+ if (Date.now() - startTime >= maxDuration) {
5456
+ reject(new Error("Timeout reached without truthy value"));
5457
+ return;
5458
+ }
5459
+ setTimeout(poll, interval);
5460
+ } catch (error) {
5461
+ reject(error);
5462
+ }
5463
+ };
5464
+ poll();
5465
+ });
5466
+ }
5435
5467
  function createSetDetails(KEY2) {
5436
5468
  return function(host, details) {
5437
5469
  if (host) {
5438
5470
  host.addEventListener(KEY2, (e) => {
5439
5471
  e.stopPropagation();
5440
- e.detail.data = details;
5472
+ e.detail.value = details;
5441
5473
  });
5474
+ } else {
5475
+ throw new Error("(createSetDetails) Host is undefined, You are probably trying to use this in a non-web-component context.");
5442
5476
  }
5443
- setContext(KEY2, details);
5444
5477
  };
5445
5478
  }
5479
+ class DetailsWrapper {
5480
+ constructor(host, KEY2, pollDuration = 1e3) {
5481
+ this.host = host;
5482
+ this.KEY = KEY2;
5483
+ this.pollDuration = pollDuration;
5484
+ }
5485
+ #data = /* @__PURE__ */ state(proxy({ value: void 0 }));
5486
+ error = false;
5487
+ load() {
5488
+ pollUntilTruthy(
5489
+ () => {
5490
+ this.host.dispatchEvent(new CustomEvent(this.KEY, { detail: this, bubbles: true }));
5491
+ return this.value;
5492
+ },
5493
+ this.pollDuration
5494
+ ).then(() => {
5495
+ }, () => {
5496
+ this.error = true;
5497
+ console.warn("(createGetDetails) could not load data for:", this.KEY);
5498
+ });
5499
+ }
5500
+ get value() {
5501
+ return get$2(this.#data).value;
5502
+ }
5503
+ set value(newValue) {
5504
+ get$2(this.#data).value = newValue;
5505
+ }
5506
+ }
5446
5507
  function createGetDetails(KEY2) {
5447
- return function(host) {
5508
+ return function(host, options = { pollDuration: 1e3 }) {
5448
5509
  if (host) {
5449
- const container = proxy({ data: void 0 });
5450
- if (!host.isConnected) {
5451
- console.error("(createGetDetails) Host is not mounted");
5452
- return void 0;
5453
- }
5454
- host.dispatchEvent(new CustomEvent(KEY2, { detail: container, bubbles: true }));
5455
- return container.data;
5510
+ const details = new DetailsWrapper(host, KEY2, options.pollDuration);
5511
+ details.load(options.pollDuration);
5512
+ return details;
5456
5513
  } else {
5457
- return getContext(KEY2);
5514
+ throw new Error("(createGetDetails) Host is undefined, You are probably trying to use this in a non-web-component context.");
5458
5515
  }
5459
5516
  };
5460
5517
  }
@@ -5508,39 +5565,6 @@ function toursGroupUrl(id) {
5508
5565
  const groups = shop.settings?.multipleToursMenuItems.tour_groups[id] || [];
5509
5566
  return `/#/products/tours?category_id=${groups.join("&category_id=")}`;
5510
5567
  }
5511
- function wait(ms) {
5512
- return new Promise((resolve) => setTimeout(resolve, ms));
5513
- }
5514
- function isEmail(email2) {
5515
- return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email2);
5516
- }
5517
- function isBoolean(value) {
5518
- return typeof value === "boolean";
5519
- }
5520
- function pollUntilTruthy(callback) {
5521
- return new Promise((resolve, reject) => {
5522
- const startTime = Date.now();
5523
- const maxDuration = 1e3;
5524
- const interval = 20;
5525
- const poll = () => {
5526
- try {
5527
- const result = callback();
5528
- if (result) {
5529
- resolve(result);
5530
- return;
5531
- }
5532
- if (Date.now() - startTime >= maxDuration) {
5533
- resolve(void 0);
5534
- return;
5535
- }
5536
- setTimeout(poll, interval);
5537
- } catch (error) {
5538
- reject(error);
5539
- }
5540
- };
5541
- poll();
5542
- });
5543
- }
5544
5568
  const defaultErrorConfig = {
5545
5569
  withStackTrace: false
5546
5570
  };
@@ -11898,6 +11922,9 @@ class Shop {
11898
11922
  if (!asGuest) requiredFields.push("password", "password_confirmation");
11899
11923
  return this.apiPost(SIGN_UP_ENDPOINT, { body: params, requiredFields });
11900
11924
  }
11925
+ passwordReset(params) {
11926
+ return this.apiPost("/api/v4/auth/password", { body: params, requiredFields: ["email"] });
11927
+ }
11901
11928
  checkout(params) {
11902
11929
  return this.apiPost(`/api/v4/orders`, { body: params, requiredFields: ["items", "total"] });
11903
11930
  }
@@ -14961,6 +14988,13 @@ class FormDetails {
14961
14988
  set isValid(value) {
14962
14989
  set(this.#isValid, value);
14963
14990
  }
14991
+ #successMessage = /* @__PURE__ */ state();
14992
+ get successMessage() {
14993
+ return get$2(this.#successMessage);
14994
+ }
14995
+ set successMessage(value) {
14996
+ set(this.#successMessage, value, true);
14997
+ }
14964
14998
  get formData() {
14965
14999
  function coerce2(x) {
14966
15000
  if (isNumber(x) || isBoolean(x)) return x;
@@ -14968,7 +15002,7 @@ class FormDetails {
14968
15002
  if (!Number.isNaN(+x) && x.trim() !== "") return +x;
14969
15003
  return x;
14970
15004
  }
14971
- const validFields = this.fields.filter((f) => f !== void 0).filter((f) => f.value !== "");
15005
+ const validFields = get$2(this.#fields).filter((f) => f !== void 0).filter((f) => f.value !== "");
14972
15006
  const ret = Object.fromEntries(validFields.map((f) => [f.apiKey, coerce2(f.value)]));
14973
15007
  return ret;
14974
15008
  }
@@ -15025,7 +15059,7 @@ class FormDetails {
15025
15059
  return get$2(this.#fields);
15026
15060
  }
15027
15061
  }
15028
- const KEY$2 = "go-request-form";
15062
+ const KEY$2 = "go-form-details";
15029
15063
  const setDetails = createSetDetails(KEY$2);
15030
15064
  const getDetails = createGetDetails(KEY$2);
15031
15065
  function wrapInElement(host, tag, props) {
@@ -15115,6 +15149,48 @@ customElements.define("go-form", create_custom_element(
15115
15149
  false
15116
15150
  ));
15117
15151
  var root$8 = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
15152
+ function PasswordReset($$anchor, $$props) {
15153
+ push($$props, true);
15154
+ let form;
15155
+ let custom2 = prop($$props, "custom", 7, false);
15156
+ Forms.defineForm({
15157
+ id: "passwordReset",
15158
+ fields: [{ key: "email", required: true }]
15159
+ });
15160
+ async function passwordReset() {
15161
+ if (!form) {
15162
+ throw new Error("(go-password-reset: form not found");
15163
+ }
15164
+ const result = await shop.passwordReset(form.details.formData);
15165
+ if (result.data) {
15166
+ $$props.$$host.dispatchEvent(new Event("go-success", { bubbles: true, composed: true }));
15167
+ form.details.successMessage = result.data.message;
15168
+ form.details.apiErrors = [];
15169
+ } else {
15170
+ form.details.apiErrors = result.error.errors;
15171
+ }
15172
+ }
15173
+ onMount(() => {
15174
+ $$props.$$host.addEventListener("go-submit", passwordReset);
15175
+ });
15176
+ var $$exports = {
15177
+ get custom() {
15178
+ return custom2();
15179
+ },
15180
+ set custom($$value = false) {
15181
+ custom2($$value);
15182
+ flushSync();
15183
+ }
15184
+ };
15185
+ var go_form = root$8();
15186
+ set_custom_element_data(go_form, "formId", "passwordReset");
15187
+ template_effect(() => set_custom_element_data(go_form, "custom", custom2()));
15188
+ bind_this(go_form, ($$value) => form = $$value, () => form);
15189
+ append($$anchor, go_form);
15190
+ return pop($$exports);
15191
+ }
15192
+ customElements.define("go-password-reset", create_custom_element(PasswordReset, { custom: {} }, [], [], false));
15193
+ var root$7 = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
15118
15194
  function SignIn($$anchor, $$props) {
15119
15195
  push($$props, true);
15120
15196
  let form;
@@ -15139,7 +15215,7 @@ function SignIn($$anchor, $$props) {
15139
15215
  onMount(() => {
15140
15216
  $$props.$$host.addEventListener("go-submit", signIn);
15141
15217
  });
15142
- var go_form = root$8();
15218
+ var go_form = root$7();
15143
15219
  set_custom_element_data(go_form, "formId", "signIn");
15144
15220
  bind_this(go_form, ($$value) => form = $$value, () => form);
15145
15221
  append($$anchor, go_form);
@@ -15154,7 +15230,7 @@ customElements.define("go-sign-in", create_custom_element(
15154
15230
  [],
15155
15231
  false
15156
15232
  ));
15157
- var root$7 = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
15233
+ var root$6 = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
15158
15234
  function SignUp($$anchor, $$props) {
15159
15235
  push($$props, true);
15160
15236
  Forms.defineForm({
@@ -15191,7 +15267,7 @@ function SignUp($$anchor, $$props) {
15191
15267
  onMount(() => {
15192
15268
  $$props.$$host.addEventListener("go-submit", signUp);
15193
15269
  });
15194
- var go_form = root$7();
15270
+ var go_form = root$6();
15195
15271
  set_custom_element_data(go_form, "formId", "signUp");
15196
15272
  bind_this(go_form, ($$value) => form = $$value, () => form);
15197
15273
  append($$anchor, go_form);
@@ -28024,7 +28100,7 @@ function Date_field_hidden_input($$anchor, $$props) {
28024
28100
  }
28025
28101
  create_custom_element(Date_field_hidden_input, {}, [], [], true);
28026
28102
  var root_2$b = /* @__PURE__ */ from_html(`<div><!></div>`);
28027
- var root$6 = /* @__PURE__ */ from_html(`<!> <!>`, 1);
28103
+ var root$5 = /* @__PURE__ */ from_html(`<!> <!>`, 1);
28028
28104
  function Date_field_input($$anchor, $$props) {
28029
28105
  const uid = props_id();
28030
28106
  push($$props, true);
@@ -28082,7 +28158,7 @@ function Date_field_input($$anchor, $$props) {
28082
28158
  flushSync();
28083
28159
  }
28084
28160
  };
28085
- var fragment = root$6();
28161
+ var fragment = root$5();
28086
28162
  var node = first_child(fragment);
28087
28163
  {
28088
28164
  var consequent = ($$anchor2) => {
@@ -29888,10 +29964,8 @@ function InputAndLabel($$anchor, $$props) {
29888
29964
  "inputClass",
29889
29965
  "host"
29890
29966
  ]);
29891
- let details = /* @__PURE__ */ state(void 0);
29892
- onMount(async () => {
29893
- set(details, await pollUntilTruthy(() => getDetails(host())), true);
29894
- });
29967
+ const _details = getDetails(host());
29968
+ const details = /* @__PURE__ */ user_derived(() => _details.value);
29895
29969
  const map = {
29896
29970
  input,
29897
29971
  text: input,
@@ -29992,16 +30066,18 @@ create_custom_element(
29992
30066
  var root_1$6 = /* @__PURE__ */ from_html(`<span> </span>`);
29993
30067
  var root_3$3 = /* @__PURE__ */ from_html(`<li> </li>`);
29994
30068
  var root_2$5 = /* @__PURE__ */ from_html(`<ul class="go-field-errors" role="alert"></ul>`);
29995
- var root$5 = /* @__PURE__ */ from_html(`<!> <!> <!>`, 1);
30069
+ var root$4 = /* @__PURE__ */ from_html(`<!> <!> <!>`, 1);
29996
30070
  function Field($$anchor, $$props) {
29997
30071
  push($$props, true);
29998
30072
  let key = prop($$props, "key", 7), required = prop($$props, "required", 7, false), labelClass = prop($$props, "labelClass", 7), inputClass = prop($$props, "inputClass", 7);
29999
30073
  let field = /* @__PURE__ */ state(proxy(Forms.createField(key(), required())));
30000
- let details = /* @__PURE__ */ state(void 0);
30001
- onMount(async () => {
30002
- set(details, await pollUntilTruthy(() => getDetails($$props.$$host)), true);
30003
- if (!get$2(details)) throw new Error(`Could not find a parent form. Make sure the field is inside a <go-form> or <go-form-details> component.`);
30004
- get$2(details).addField(get$2(field));
30074
+ const _details = getDetails($$props.$$host);
30075
+ const details = /* @__PURE__ */ user_derived(() => _details.value);
30076
+ user_effect(() => {
30077
+ if (!get$2(details)) return;
30078
+ untrack(() => {
30079
+ get$2(details).addField(get$2(field));
30080
+ });
30005
30081
  });
30006
30082
  const getField = () => get$2(field);
30007
30083
  let allErrors = /* @__PURE__ */ user_derived(() => get$2(field) ? [...get$2(field).errors, ...get$2(field).apiErrors] : []);
@@ -30054,7 +30130,7 @@ function Field($$anchor, $$props) {
30054
30130
  flushSync();
30055
30131
  }
30056
30132
  };
30057
- var fragment = root$5();
30133
+ var fragment = root$4();
30058
30134
  var node = first_child(fragment);
30059
30135
  InputAndLabel(node, {
30060
30136
  get describedById() {
@@ -30127,11 +30203,9 @@ customElements.define("go-field", create_custom_element(
30127
30203
  var root_1$5 = /* @__PURE__ */ from_html(`<go-field></go-field>`, 2);
30128
30204
  function AllFields($$anchor, $$props) {
30129
30205
  push($$props, true);
30130
- let details = /* @__PURE__ */ state(void 0);
30206
+ let _details = getDetails($$props.$$host);
30207
+ let details = /* @__PURE__ */ user_derived(() => _details.value);
30131
30208
  let allFields2 = /* @__PURE__ */ user_derived(() => get$2(details) ? Forms.getFormFields(get$2(details)?.formId) : []);
30132
- onMount(async () => {
30133
- set(details, getDetails($$props.$$host), true);
30134
- });
30135
30209
  var fragment = comment();
30136
30210
  var node = first_child(fragment);
30137
30211
  each(node, 17, () => get$2(allFields2), index$1, ($$anchor2, field) => {
@@ -30151,10 +30225,8 @@ var root_5 = /* @__PURE__ */ from_html(`<p aria-hidden="true"> </p>`);
30151
30225
  var root_1$4 = /* @__PURE__ */ from_html(`<div><!> <!> <!></div>`);
30152
30226
  function ErrorsFeedback($$anchor, $$props) {
30153
30227
  push($$props, true);
30154
- let details = /* @__PURE__ */ state(void 0);
30155
- onMount(async () => {
30156
- set(details, await pollUntilTruthy(() => getDetails($$props.$$host)), true);
30157
- });
30228
+ const _details = getDetails($$props.$$host);
30229
+ const details = /* @__PURE__ */ user_derived(() => _details.value);
30158
30230
  user_effect(() => {
30159
30231
  get$2(details)?.form?.addEventListener("after-validation", () => {
30160
30232
  set(errorsOnSubmit, errors(get$2(details)?.fields), true);
@@ -30220,16 +30292,16 @@ function ErrorsFeedback($$anchor, $$props) {
30220
30292
  append($$anchor2, div);
30221
30293
  };
30222
30294
  if_block(node, ($$render) => {
30223
- if (get$2(errorsRealtime) > 0 || get$2(errorsOnSubmit) > 0 || get$2(generalApiErrors)) $$render(consequent_3);
30295
+ if (get$2(errorsRealtime) > 0 || get$2(errorsOnSubmit) > 0 || get$2(generalApiErrors).length > 0) $$render(consequent_3);
30224
30296
  });
30225
30297
  }
30226
30298
  append($$anchor, fragment);
30227
30299
  pop();
30228
30300
  }
30229
30301
  customElements.define("go-errors-feedback", create_custom_element(ErrorsFeedback, {}, [], [], false));
30230
- var root$4 = /* @__PURE__ */ from_html(`<div class="go-form-feedback"><!></div>`);
30302
+ var root$3 = /* @__PURE__ */ from_html(`<div class="go-form-feedback"><!></div>`);
30231
30303
  function FormFeedback($$anchor, $$props) {
30232
- var div = root$4();
30304
+ var div = root$3();
30233
30305
  var node = child(div);
30234
30306
  slot(node, $$props, "default", {});
30235
30307
  reset(div);
@@ -30239,9 +30311,7 @@ customElements.define("go-form-feedback", create_custom_element(FormFeedback, {}
30239
30311
  function Submit($$anchor, $$props) {
30240
30312
  push($$props, true);
30241
30313
  let buttonClass = prop($$props, "buttonClass", 7, "");
30242
- let details = /* @__PURE__ */ state(void 0);
30243
30314
  onMount(() => {
30244
- set(details, getDetails($$props.$$host), true);
30245
30315
  wrapInElement($$props.$$host, "button", { type: "submit", class: buttonClass() });
30246
30316
  });
30247
30317
  var $$exports = {
@@ -30264,38 +30334,30 @@ customElements.define("go-submit", create_custom_element(
30264
30334
  [],
30265
30335
  false
30266
30336
  ));
30267
- var root_1$3 = /* @__PURE__ */ from_html(`<p>Form submitted successfully!</p>`);
30268
- var root$3 = /* @__PURE__ */ from_html(`<div aria-live="assertive"><!></div>`);
30337
+ var root_1$3 = /* @__PURE__ */ from_html(`<div aria-live="assertive"> </div>`);
30269
30338
  function SuccessFeedback($$anchor, $$props) {
30270
30339
  push($$props, true);
30271
- let details = /* @__PURE__ */ state(void 0);
30272
- onMount(() => {
30273
- set(details, getDetails($$props.$$host), true);
30274
- });
30275
- let show = /* @__PURE__ */ state(false);
30276
- user_effect(() => {
30277
- if (!get$2(details)?.form) return;
30278
- untrack(() => {
30279
- get$2(details)?.form?.addEventListener("success", () => {
30280
- set(show, errors(get$2(details)?.fields) === 0);
30281
- });
30282
- });
30283
- });
30284
- var div = root$3();
30285
- let classes;
30286
- var node = child(div);
30340
+ const _details = getDetails($$props.$$host);
30341
+ const details = /* @__PURE__ */ user_derived(() => _details.value);
30342
+ var fragment = comment();
30343
+ var node = first_child(fragment);
30287
30344
  {
30288
30345
  var consequent = ($$anchor2) => {
30289
- var p2 = root_1$3();
30290
- append($$anchor2, p2);
30346
+ var div = root_1$3();
30347
+ let classes;
30348
+ var text2 = child(div, true);
30349
+ reset(div);
30350
+ template_effect(() => {
30351
+ classes = set_class(div, 1, "go-success-feedback go-feedback", null, classes, { "is-successful": get$2(details).successMessage });
30352
+ set_text(text2, get$2(details)?.successMessage);
30353
+ });
30354
+ append($$anchor2, div);
30291
30355
  };
30292
30356
  if_block(node, ($$render) => {
30293
- if (get$2(show)) $$render(consequent);
30357
+ if (get$2(details)?.successMessage) $$render(consequent);
30294
30358
  });
30295
30359
  }
30296
- reset(div);
30297
- template_effect(() => classes = set_class(div, 1, "go-success-feedback go-feedback", null, classes, { "is-successful": get$2(show) }));
30298
- append($$anchor, div);
30360
+ append($$anchor, fragment);
30299
30361
  pop();
30300
30362
  }
30301
30363
  customElements.define("go-success-feedback", create_custom_element(SuccessFeedback, {}, [], [], false));
@@ -30304,7 +30366,6 @@ function evaluateExpression(expression, data) {
30304
30366
  const func = new Function("data", `return ${expression};`);
30305
30367
  return func(data);
30306
30368
  } catch (error) {
30307
- throw new Error(`Error while evaluating when (${expression}) in go-if: ${error.message}`);
30308
30369
  }
30309
30370
  }
30310
30371
  const validTicketSelectionFilters = ["timeslot", "day", "annual"];
@@ -30427,14 +30488,21 @@ const getTicketSelectionDetails = createGetDetails(KEY$1);
30427
30488
  function If($$anchor, $$props) {
30428
30489
  push($$props, true);
30429
30490
  let when = prop($$props, "when", 7), then = prop($$props, "then", 7, "show");
30430
- const data = /* @__PURE__ */ state(proxy({}));
30431
- get$2(data).ticketSelection = getTicketSelectionDetails($$props.$$host);
30432
- let formDetails = /* @__PURE__ */ state(void 0);
30433
- user_effect(() => {
30434
- if (!get$2(formDetails)) return;
30435
- get$2(data).formData = get$2(formDetails).formData;
30436
- });
30437
- get$2(data).cart = cart;
30491
+ const _ticketSelectionDetails = getTicketSelectionDetails($$props.$$host);
30492
+ const ticketSelectionDetails = /* @__PURE__ */ user_derived(() => _ticketSelectionDetails.value);
30493
+ const _formDetails = getDetails($$props.$$host);
30494
+ const formDetails = /* @__PURE__ */ user_derived(() => _formDetails.value);
30495
+ let data = /* @__PURE__ */ user_derived(() => ({
30496
+ ticketSelection: get$2(ticketSelectionDetails),
30497
+ formData: get$2(formDetails)?.formData,
30498
+ cart
30499
+ }));
30500
+ const _setData = (_data) => {
30501
+ set(data, _data);
30502
+ };
30503
+ const _getData = () => {
30504
+ return get$2(data);
30505
+ };
30438
30506
  let evaluatedWhen = /* @__PURE__ */ user_derived(() => evaluateExpression(when(), get$2(data)));
30439
30507
  let content = null;
30440
30508
  user_effect(() => {
@@ -30453,21 +30521,9 @@ function If($$anchor, $$props) {
30453
30521
  }
30454
30522
  }
30455
30523
  });
30456
- onMount(async () => {
30457
- try {
30458
- set(formDetails, await pollUntilTruthy(() => getDetails($$props.$$host)), true);
30459
- } catch (error) {
30460
- console.error("(IF) Error fetching form details:", error);
30461
- console.error("Stack trace:", error instanceof Error ? error.stack : "No stack trace available");
30462
- }
30463
- });
30464
30524
  var $$exports = {
30465
- get data() {
30466
- return get$2(data);
30467
- },
30468
- set data($$value) {
30469
- set(data, proxy($$value));
30470
- },
30525
+ _setData,
30526
+ _getData,
30471
30527
  get when() {
30472
30528
  return when();
30473
30529
  },
@@ -30492,7 +30548,7 @@ customElements.define("go-if", create_custom_element(
30492
30548
  then: { attribute: "then", reflect: true, type: "String" }
30493
30549
  },
30494
30550
  [],
30495
- ["data"],
30551
+ ["_setData", "_getData"],
30496
30552
  false
30497
30553
  ));
30498
30554
  function GomusInit($$anchor, $$props) {
@@ -30760,9 +30816,10 @@ customElements.define("go-ticket-selection", create_custom_element(
30760
30816
  ));
30761
30817
  function Tickets($$anchor, $$props) {
30762
30818
  push($$props, true);
30763
- const ticketSelectionDetails = getTicketSelectionDetails($$props.$$host);
30819
+ const _tsd = getTicketSelectionDetails($$props.$$host);
30820
+ const tsd = /* @__PURE__ */ user_derived(() => _tsd.value);
30764
30821
  user_effect(() => {
30765
- if (!ticketSelectionDetails?.isTicketsVisible) {
30822
+ if (!get$2(tsd)?.isTicketsVisible) {
30766
30823
  $$props.$$host.style.display = "none";
30767
30824
  } else {
30768
30825
  $$props.$$host.style.display = "block";
@@ -30773,18 +30830,24 @@ function Tickets($$anchor, $$props) {
30773
30830
  customElements.define("go-tickets", create_custom_element(Tickets, {}, [], [], false));
30774
30831
  function TicketsSum($$anchor, $$props) {
30775
30832
  push($$props, true);
30776
- const tsd = getTicketSelectionDetails($$props.$$host);
30777
- if (!tsd) console.error("Ticket Sum must be inside a Ticket Selection Details");
30778
- let val = /* @__PURE__ */ user_derived(() => sum(tsd?.preCarts || [], (c) => c.totalPriceCents));
30779
- var $$exports = { tsd };
30833
+ const _tsd = getTicketSelectionDetails($$props.$$host);
30834
+ const tsd = /* @__PURE__ */ user_derived(() => _tsd.value);
30835
+ let val = /* @__PURE__ */ user_derived(() => sum(get$2(tsd)?.preCarts || [], (c) => c.totalPriceCents));
30780
30836
  next();
30781
30837
  var text2 = text$1();
30782
30838
  template_effect(($0) => set_text(text2, $0), [() => formatCurrency(get$2(val))]);
30783
30839
  append($$anchor, text2);
30784
- return pop($$exports);
30840
+ pop();
30785
30841
  }
30786
- customElements.define("go-tickets-sum", create_custom_element(TicketsSum, {}, [], ["tsd"], false));
30842
+ customElements.define("go-tickets-sum", create_custom_element(TicketsSum, {}, [], [], false));
30787
30843
  class TicketGroupDetails {
30844
+ #ticketSelectionDetails;
30845
+ get ticketSelectionDetails() {
30846
+ return get$2(this.#ticketSelectionDetails);
30847
+ }
30848
+ set ticketSelectionDetails(value) {
30849
+ set(this.#ticketSelectionDetails, value);
30850
+ }
30788
30851
  #tickets = /* @__PURE__ */ state(proxy([]));
30789
30852
  get tickets() {
30790
30853
  return get$2(this.#tickets);
@@ -30806,17 +30869,17 @@ class TicketGroupDetails {
30806
30869
  set filters(value) {
30807
30870
  set(this.#filters, value, true);
30808
30871
  }
30809
- #ticketSelectionDetails = /* @__PURE__ */ state();
30810
- get ticketSelectionDetails() {
30811
- return get$2(this.#ticketSelectionDetails);
30812
- }
30813
- set ticketSelectionDetails(value) {
30814
- set(this.#ticketSelectionDetails, value, true);
30815
- }
30816
- constructor(type, ticketSelectionDetails) {
30872
+ constructor(type, tsdWrapper) {
30817
30873
  this.filters = type;
30818
- this.ticketSelectionDetails = ticketSelectionDetails;
30819
- this.ticketSelectionDetails.addTicketGroup(this);
30874
+ this.#ticketSelectionDetails = /* @__PURE__ */ user_derived(() => tsdWrapper.value);
30875
+ effect_root(() => {
30876
+ user_effect(() => {
30877
+ this.ticketSelectionDetails;
30878
+ untrack(() => {
30879
+ this.ticketSelectionDetails?.addTicketGroup(this);
30880
+ });
30881
+ });
30882
+ });
30820
30883
  }
30821
30884
  preCartTickets() {
30822
30885
  switch (this.filters) {
@@ -30886,10 +30949,9 @@ const getTicketGroupDetails = createGetDetails(KEY);
30886
30949
  function TicketSegment($$anchor, $$props) {
30887
30950
  push($$props, true);
30888
30951
  const filters = prop($$props, "filters", 7);
30889
- const ticketSelectionDetails = getTicketSelectionDetails($$props.$$host);
30890
30952
  if (!filters()) throw new Error("filters is required");
30891
- if (!ticketSelectionDetails) throw new Error("Ticket Segment should be an ancestor of a Ticket Selection Details element");
30892
- const details = new TicketGroupDetails(filters(), ticketSelectionDetails);
30953
+ const tsdWrapper = getTicketSelectionDetails($$props.$$host);
30954
+ const details = new TicketGroupDetails(filters(), tsdWrapper);
30893
30955
  setTicketGroupDetails($$props.$$host, details);
30894
30956
  user_effect(() => {
30895
30957
  details.filters = filters();
@@ -30964,7 +31026,7 @@ function Body($$anchor, $$props) {
30964
31026
  const select = ($$anchor2, ci = noop$1) => {
30965
31027
  const ticket = /* @__PURE__ */ user_derived(() => ci().item);
30966
31028
  var select_1 = root_1$2();
30967
- select_1.__change = (e) => updateSelectedTickets(ci(), e.target, tsd);
31029
+ select_1.__change = (e) => updateSelectedTickets(ci(), e.target, get$2(details)?.ticketSelectionDetails);
30968
31030
  each(select_1, 21, () => generateQuantityOptions(get$2(ticket)), index$1, ($$anchor3, quantity) => {
30969
31031
  var option = root_2$2();
30970
31032
  var text2 = child(option, true);
@@ -30982,18 +31044,16 @@ function Body($$anchor, $$props) {
30982
31044
  reset(select_1);
30983
31045
  append($$anchor2, select_1);
30984
31046
  };
30985
- let details = getTicketGroupDetails($$props.$$host);
30986
- if (!details) {
30987
- throw new Error("Ticket Group Body must be inside a Ticket Group");
30988
- }
30989
- let tsd = details.ticketSelectionDetails;
31047
+ const _details = getTicketGroupDetails($$props.$$host);
31048
+ const details = /* @__PURE__ */ user_derived(() => _details.value);
31049
+ const anyItems = /* @__PURE__ */ user_derived(() => get$2(details)?.preCart?.items.length && get$2(details)?.preCart?.items.length > 0);
30990
31050
  var fragment = comment();
30991
31051
  var node = first_child(fragment);
30992
31052
  {
30993
31053
  var consequent = ($$anchor2) => {
30994
31054
  var ol = root_3$1();
30995
31055
  var node_1 = sibling(child(ol), 2);
30996
- each(node_1, 17, () => details?.preCart.items, index$1, ($$anchor3, ci) => {
31056
+ each(node_1, 17, () => get$2(details)?.preCart.items, index$1, ($$anchor3, ci) => {
30997
31057
  var li = root_4();
30998
31058
  var article = child(li);
30999
31059
  var ul = child(article);
@@ -31025,7 +31085,7 @@ function Body($$anchor, $$props) {
31025
31085
  append($$anchor2, ol);
31026
31086
  };
31027
31087
  if_block(node, ($$render) => {
31028
- if (details?.preCart.items.length > 0) $$render(consequent);
31088
+ if (get$2(anyItems)) $$render(consequent);
31029
31089
  });
31030
31090
  }
31031
31091
  append($$anchor, fragment);
@@ -31035,16 +31095,15 @@ delegate(["change"]);
31035
31095
  customElements.define("go-ticket-segment-body", create_custom_element(Body, {}, [], [], false));
31036
31096
  function Sum($$anchor, $$props) {
31037
31097
  push($$props, true);
31038
- const details = getTicketGroupDetails($$props.$$host);
31039
- if (!details) console.warn("TicketGroupSum: details not found");
31040
- var $$exports = { details };
31098
+ const _details = getTicketGroupDetails($$props.$$host);
31099
+ const details = /* @__PURE__ */ user_derived(() => _details.value);
31041
31100
  next();
31042
31101
  var text2 = text$1();
31043
- template_effect(() => set_text(text2, details?.preCart.totalFormatted));
31102
+ template_effect(() => set_text(text2, get$2(details)?.preCart.totalFormatted));
31044
31103
  append($$anchor, text2);
31045
- return pop($$exports);
31104
+ pop();
31046
31105
  }
31047
- customElements.define("go-ticket-segment-sum", create_custom_element(Sum, {}, [], ["details"], false));
31106
+ customElements.define("go-ticket-segment-sum", create_custom_element(Sum, {}, [], [], false));
31048
31107
  function createTimeSlotEntriesFromTicket(ticket) {
31049
31108
  return Object.keys(ticket.capacities).map((startAt) => {
31050
31109
  return {
@@ -31094,15 +31153,19 @@ function generateAvailableTimeSlots(tickets, quotas) {
31094
31153
  return combineSlots(quotaSlots);
31095
31154
  }
31096
31155
  let Details$1 = class Details {
31097
- #ticketSelectionDetails = /* @__PURE__ */ state();
31098
- get ticketSelectionDetails() {
31099
- return get$2(this.#ticketSelectionDetails);
31156
+ #tsd;
31157
+ get tsd() {
31158
+ return get$2(this.#tsd);
31100
31159
  }
31101
- set ticketSelectionDetails(value) {
31102
- set(this.#ticketSelectionDetails, value, true);
31160
+ set tsd(value) {
31161
+ set(this.#tsd, value);
31162
+ }
31163
+ constructor(tsdWrapper) {
31164
+ if (!tsdWrapper) return;
31165
+ this.#tsd = /* @__PURE__ */ user_derived(() => tsdWrapper.value);
31103
31166
  }
31104
31167
  get timeslots() {
31105
- const tsd = this.ticketSelectionDetails;
31168
+ const tsd = this.tsd;
31106
31169
  if (!tsd) return [];
31107
31170
  const date2 = tsd.selectedDate;
31108
31171
  if (!date2) return [];
@@ -31135,11 +31198,11 @@ var root_1$1 = /* @__PURE__ */ from_html(`<ul data-testid="timeslots" data-go-ti
31135
31198
  function Timeslots($$anchor, $$props) {
31136
31199
  push($$props, true);
31137
31200
  const binding_group = [];
31138
- const details = new Details$1();
31139
- details.ticketSelectionDetails = getTicketSelectionDetails($$props.$$host);
31201
+ const _tsd = getTicketSelectionDetails($$props.$$host);
31202
+ const details = new Details$1(_tsd);
31140
31203
  const change = (e) => {
31141
31204
  e.target.dispatchEvent(new CustomEvent("go-timeslot-select", {
31142
- detail: { selected: details.ticketSelectionDetails.selectedTimeslot },
31205
+ detail: { selected: details.tsd.selectedTimeslot },
31143
31206
  bubbles: true,
31144
31207
  composed: true
31145
31208
  }));
@@ -31151,7 +31214,7 @@ function Timeslots($$anchor, $$props) {
31151
31214
  var consequent = ($$anchor2) => {
31152
31215
  var ul = root_1$1();
31153
31216
  each(ul, 20, () => details.timeslots, (timeslot) => timeslot, ($$anchor3, timeslot) => {
31154
- const selected = /* @__PURE__ */ user_derived(() => details.ticketSelectionDetails?.selectedTimeslot === timeslot.startAt);
31217
+ const selected = /* @__PURE__ */ user_derived(() => details.tsd?.selectedTimeslot === timeslot.startAt);
31155
31218
  var li = root_2$1();
31156
31219
  var label = child(li);
31157
31220
  var text2 = child(label);
@@ -31175,9 +31238,9 @@ function Timeslots($$anchor, $$props) {
31175
31238
  input,
31176
31239
  () => {
31177
31240
  timeslot.startAt;
31178
- return details.ticketSelectionDetails.selectedTimeslot;
31241
+ return details.tsd.selectedTimeslot;
31179
31242
  },
31180
- ($$value) => details.ticketSelectionDetails.selectedTimeslot = $$value
31243
+ ($$value) => details.tsd.selectedTimeslot = $$value
31181
31244
  );
31182
31245
  append($$anchor3, li);
31183
31246
  });
@@ -31185,7 +31248,7 @@ function Timeslots($$anchor, $$props) {
31185
31248
  append($$anchor2, ul);
31186
31249
  };
31187
31250
  if_block(node, ($$render) => {
31188
- if (details.ticketSelectionDetails && details.ticketSelectionDetails.filters?.includes("timeslot")) $$render(consequent);
31251
+ if (details.tsd && details.tsd.filters?.includes("timeslot")) $$render(consequent);
31189
31252
  });
31190
31253
  }
31191
31254
  append($$anchor, fragment);
@@ -31468,11 +31531,11 @@ create_custom_element(CalendarUI, { calendarClass: {} }, [], ["details"], true);
31468
31531
  var root$1 = /* @__PURE__ */ from_html(`<div data-calendar-wrapper=""><!></div>`);
31469
31532
  function Calendar2($$anchor, $$props) {
31470
31533
  push($$props, true);
31471
- let ticketSelectionDetails = /* @__PURE__ */ state(void 0);
31472
31534
  const ticketsCalendar = new TicketsCalendar();
31473
31535
  const details = ticketsCalendar;
31474
- onMount(() => {
31475
- set(ticketSelectionDetails, getTicketSelectionDetails($$props.$$host), true);
31536
+ const _ticketSelectionDetails = getTicketSelectionDetails($$props.$$host);
31537
+ const ticketSelectionDetails = /* @__PURE__ */ user_derived(() => _ticketSelectionDetails.value);
31538
+ user_effect(() => {
31476
31539
  ticketsCalendar.details = get$2(ticketSelectionDetails);
31477
31540
  if (get$2(ticketSelectionDetails)) get$2(ticketSelectionDetails).selectedDate = void 0;
31478
31541
  });
@@ -31504,12 +31567,16 @@ function Calendar2($$anchor, $$props) {
31504
31567
  }
31505
31568
  customElements.define("go-calendar", create_custom_element(Calendar2, {}, [], ["details"], false));
31506
31569
  class Details2 {
31507
- #ticketSelectionDetails = /* @__PURE__ */ state();
31570
+ #ticketSelectionDetails;
31508
31571
  get ticketSelectionDetails() {
31509
31572
  return get$2(this.#ticketSelectionDetails);
31510
31573
  }
31511
31574
  set ticketSelectionDetails(value) {
31512
- set(this.#ticketSelectionDetails, value, true);
31575
+ set(this.#ticketSelectionDetails, value);
31576
+ }
31577
+ constructor(tsdWrapper) {
31578
+ if (!tsdWrapper) return;
31579
+ this.#ticketSelectionDetails = /* @__PURE__ */ user_derived(() => tsdWrapper.value);
31513
31580
  }
31514
31581
  addToCart() {
31515
31582
  if (!cart) {
@@ -31539,8 +31606,8 @@ class Details2 {
31539
31606
  var root = /* @__PURE__ */ from_html(`<button data-add-to-cart-button="" data-testid="go-add-to-cart-button__button">Add to cart</button>`);
31540
31607
  function AddToCartButton($$anchor, $$props) {
31541
31608
  push($$props, true);
31542
- const details = new Details2();
31543
- details.ticketSelectionDetails = getTicketSelectionDetails($$props.$$host);
31609
+ const _tsd = getTicketSelectionDetails($$props.$$host);
31610
+ const details = new Details2(_tsd);
31544
31611
  var $$exports = { details };
31545
31612
  var button = root();
31546
31613
  button.__click = () => details.addToCart();