@gomusdev/web-components 1.15.0 → 1.16.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.
@@ -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));
@@ -30427,14 +30489,21 @@ const getTicketSelectionDetails = createGetDetails(KEY$1);
30427
30489
  function If($$anchor, $$props) {
30428
30490
  push($$props, true);
30429
30491
  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;
30492
+ const _ticketSelectionDetails = getTicketSelectionDetails($$props.$$host);
30493
+ const ticketSelectionDetails = /* @__PURE__ */ user_derived(() => _ticketSelectionDetails.value);
30494
+ const _formDetails = getDetails($$props.$$host);
30495
+ const formDetails = /* @__PURE__ */ user_derived(() => _formDetails.value);
30496
+ let data = /* @__PURE__ */ user_derived(() => ({
30497
+ ticketSelection: get$2(ticketSelectionDetails),
30498
+ formData: get$2(formDetails)?.formData,
30499
+ cart
30500
+ }));
30501
+ const _setData = (_data) => {
30502
+ set(data, _data);
30503
+ };
30504
+ const _getData = () => {
30505
+ return get$2(data);
30506
+ };
30438
30507
  let evaluatedWhen = /* @__PURE__ */ user_derived(() => evaluateExpression(when(), get$2(data)));
30439
30508
  let content = null;
30440
30509
  user_effect(() => {
@@ -30453,21 +30522,9 @@ function If($$anchor, $$props) {
30453
30522
  }
30454
30523
  }
30455
30524
  });
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
30525
  var $$exports = {
30465
- get data() {
30466
- return get$2(data);
30467
- },
30468
- set data($$value) {
30469
- set(data, proxy($$value));
30470
- },
30526
+ _setData,
30527
+ _getData,
30471
30528
  get when() {
30472
30529
  return when();
30473
30530
  },
@@ -30492,7 +30549,7 @@ customElements.define("go-if", create_custom_element(
30492
30549
  then: { attribute: "then", reflect: true, type: "String" }
30493
30550
  },
30494
30551
  [],
30495
- ["data"],
30552
+ ["_setData", "_getData"],
30496
30553
  false
30497
30554
  ));
30498
30555
  function GomusInit($$anchor, $$props) {
@@ -30760,9 +30817,10 @@ customElements.define("go-ticket-selection", create_custom_element(
30760
30817
  ));
30761
30818
  function Tickets($$anchor, $$props) {
30762
30819
  push($$props, true);
30763
- const ticketSelectionDetails = getTicketSelectionDetails($$props.$$host);
30820
+ const _tsd = getTicketSelectionDetails($$props.$$host);
30821
+ const tsd = /* @__PURE__ */ user_derived(() => _tsd.value);
30764
30822
  user_effect(() => {
30765
- if (!ticketSelectionDetails?.isTicketsVisible) {
30823
+ if (!get$2(tsd)?.isTicketsVisible) {
30766
30824
  $$props.$$host.style.display = "none";
30767
30825
  } else {
30768
30826
  $$props.$$host.style.display = "block";
@@ -30773,18 +30831,24 @@ function Tickets($$anchor, $$props) {
30773
30831
  customElements.define("go-tickets", create_custom_element(Tickets, {}, [], [], false));
30774
30832
  function TicketsSum($$anchor, $$props) {
30775
30833
  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 };
30834
+ const _tsd = getTicketSelectionDetails($$props.$$host);
30835
+ const tsd = /* @__PURE__ */ user_derived(() => _tsd.value);
30836
+ let val = /* @__PURE__ */ user_derived(() => sum(get$2(tsd)?.preCarts || [], (c) => c.totalPriceCents));
30780
30837
  next();
30781
30838
  var text2 = text$1();
30782
30839
  template_effect(($0) => set_text(text2, $0), [() => formatCurrency(get$2(val))]);
30783
30840
  append($$anchor, text2);
30784
- return pop($$exports);
30841
+ pop();
30785
30842
  }
30786
- customElements.define("go-tickets-sum", create_custom_element(TicketsSum, {}, [], ["tsd"], false));
30843
+ customElements.define("go-tickets-sum", create_custom_element(TicketsSum, {}, [], [], false));
30787
30844
  class TicketGroupDetails {
30845
+ #ticketSelectionDetails;
30846
+ get ticketSelectionDetails() {
30847
+ return get$2(this.#ticketSelectionDetails);
30848
+ }
30849
+ set ticketSelectionDetails(value) {
30850
+ set(this.#ticketSelectionDetails, value);
30851
+ }
30788
30852
  #tickets = /* @__PURE__ */ state(proxy([]));
30789
30853
  get tickets() {
30790
30854
  return get$2(this.#tickets);
@@ -30806,17 +30870,17 @@ class TicketGroupDetails {
30806
30870
  set filters(value) {
30807
30871
  set(this.#filters, value, true);
30808
30872
  }
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) {
30873
+ constructor(type, tsdWrapper) {
30817
30874
  this.filters = type;
30818
- this.ticketSelectionDetails = ticketSelectionDetails;
30819
- this.ticketSelectionDetails.addTicketGroup(this);
30875
+ this.#ticketSelectionDetails = /* @__PURE__ */ user_derived(() => tsdWrapper.value);
30876
+ effect_root(() => {
30877
+ user_effect(() => {
30878
+ this.ticketSelectionDetails;
30879
+ untrack(() => {
30880
+ this.ticketSelectionDetails?.addTicketGroup(this);
30881
+ });
30882
+ });
30883
+ });
30820
30884
  }
30821
30885
  preCartTickets() {
30822
30886
  switch (this.filters) {
@@ -30886,10 +30950,9 @@ const getTicketGroupDetails = createGetDetails(KEY);
30886
30950
  function TicketSegment($$anchor, $$props) {
30887
30951
  push($$props, true);
30888
30952
  const filters = prop($$props, "filters", 7);
30889
- const ticketSelectionDetails = getTicketSelectionDetails($$props.$$host);
30890
30953
  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);
30954
+ const tsdWrapper = getTicketSelectionDetails($$props.$$host);
30955
+ const details = new TicketGroupDetails(filters(), tsdWrapper);
30893
30956
  setTicketGroupDetails($$props.$$host, details);
30894
30957
  user_effect(() => {
30895
30958
  details.filters = filters();
@@ -30964,7 +31027,7 @@ function Body($$anchor, $$props) {
30964
31027
  const select = ($$anchor2, ci = noop$1) => {
30965
31028
  const ticket = /* @__PURE__ */ user_derived(() => ci().item);
30966
31029
  var select_1 = root_1$2();
30967
- select_1.__change = (e) => updateSelectedTickets(ci(), e.target, tsd);
31030
+ select_1.__change = (e) => updateSelectedTickets(ci(), e.target, get$2(details)?.ticketSelectionDetails);
30968
31031
  each(select_1, 21, () => generateQuantityOptions(get$2(ticket)), index$1, ($$anchor3, quantity) => {
30969
31032
  var option = root_2$2();
30970
31033
  var text2 = child(option, true);
@@ -30982,18 +31045,16 @@ function Body($$anchor, $$props) {
30982
31045
  reset(select_1);
30983
31046
  append($$anchor2, select_1);
30984
31047
  };
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;
31048
+ const _details = getTicketGroupDetails($$props.$$host);
31049
+ const details = /* @__PURE__ */ user_derived(() => _details.value);
31050
+ const anyItems = /* @__PURE__ */ user_derived(() => get$2(details)?.preCart?.items.length && get$2(details)?.preCart?.items.length > 0);
30990
31051
  var fragment = comment();
30991
31052
  var node = first_child(fragment);
30992
31053
  {
30993
31054
  var consequent = ($$anchor2) => {
30994
31055
  var ol = root_3$1();
30995
31056
  var node_1 = sibling(child(ol), 2);
30996
- each(node_1, 17, () => details?.preCart.items, index$1, ($$anchor3, ci) => {
31057
+ each(node_1, 17, () => get$2(details)?.preCart.items, index$1, ($$anchor3, ci) => {
30997
31058
  var li = root_4();
30998
31059
  var article = child(li);
30999
31060
  var ul = child(article);
@@ -31025,7 +31086,7 @@ function Body($$anchor, $$props) {
31025
31086
  append($$anchor2, ol);
31026
31087
  };
31027
31088
  if_block(node, ($$render) => {
31028
- if (details?.preCart.items.length > 0) $$render(consequent);
31089
+ if (get$2(anyItems)) $$render(consequent);
31029
31090
  });
31030
31091
  }
31031
31092
  append($$anchor, fragment);
@@ -31035,16 +31096,15 @@ delegate(["change"]);
31035
31096
  customElements.define("go-ticket-segment-body", create_custom_element(Body, {}, [], [], false));
31036
31097
  function Sum($$anchor, $$props) {
31037
31098
  push($$props, true);
31038
- const details = getTicketGroupDetails($$props.$$host);
31039
- if (!details) console.warn("TicketGroupSum: details not found");
31040
- var $$exports = { details };
31099
+ const _details = getTicketGroupDetails($$props.$$host);
31100
+ const details = /* @__PURE__ */ user_derived(() => _details.value);
31041
31101
  next();
31042
31102
  var text2 = text$1();
31043
- template_effect(() => set_text(text2, details?.preCart.totalFormatted));
31103
+ template_effect(() => set_text(text2, get$2(details)?.preCart.totalFormatted));
31044
31104
  append($$anchor, text2);
31045
- return pop($$exports);
31105
+ pop();
31046
31106
  }
31047
- customElements.define("go-ticket-segment-sum", create_custom_element(Sum, {}, [], ["details"], false));
31107
+ customElements.define("go-ticket-segment-sum", create_custom_element(Sum, {}, [], [], false));
31048
31108
  function createTimeSlotEntriesFromTicket(ticket) {
31049
31109
  return Object.keys(ticket.capacities).map((startAt) => {
31050
31110
  return {
@@ -31094,15 +31154,19 @@ function generateAvailableTimeSlots(tickets, quotas) {
31094
31154
  return combineSlots(quotaSlots);
31095
31155
  }
31096
31156
  let Details$1 = class Details {
31097
- #ticketSelectionDetails = /* @__PURE__ */ state();
31098
- get ticketSelectionDetails() {
31099
- return get$2(this.#ticketSelectionDetails);
31157
+ #tsd;
31158
+ get tsd() {
31159
+ return get$2(this.#tsd);
31100
31160
  }
31101
- set ticketSelectionDetails(value) {
31102
- set(this.#ticketSelectionDetails, value, true);
31161
+ set tsd(value) {
31162
+ set(this.#tsd, value);
31163
+ }
31164
+ constructor(tsdWrapper) {
31165
+ if (!tsdWrapper) return;
31166
+ this.#tsd = /* @__PURE__ */ user_derived(() => tsdWrapper.value);
31103
31167
  }
31104
31168
  get timeslots() {
31105
- const tsd = this.ticketSelectionDetails;
31169
+ const tsd = this.tsd;
31106
31170
  if (!tsd) return [];
31107
31171
  const date2 = tsd.selectedDate;
31108
31172
  if (!date2) return [];
@@ -31135,11 +31199,11 @@ var root_1$1 = /* @__PURE__ */ from_html(`<ul data-testid="timeslots" data-go-ti
31135
31199
  function Timeslots($$anchor, $$props) {
31136
31200
  push($$props, true);
31137
31201
  const binding_group = [];
31138
- const details = new Details$1();
31139
- details.ticketSelectionDetails = getTicketSelectionDetails($$props.$$host);
31202
+ const _tsd = getTicketSelectionDetails($$props.$$host);
31203
+ const details = new Details$1(_tsd);
31140
31204
  const change = (e) => {
31141
31205
  e.target.dispatchEvent(new CustomEvent("go-timeslot-select", {
31142
- detail: { selected: details.ticketSelectionDetails.selectedTimeslot },
31206
+ detail: { selected: details.tsd.selectedTimeslot },
31143
31207
  bubbles: true,
31144
31208
  composed: true
31145
31209
  }));
@@ -31151,7 +31215,7 @@ function Timeslots($$anchor, $$props) {
31151
31215
  var consequent = ($$anchor2) => {
31152
31216
  var ul = root_1$1();
31153
31217
  each(ul, 20, () => details.timeslots, (timeslot) => timeslot, ($$anchor3, timeslot) => {
31154
- const selected = /* @__PURE__ */ user_derived(() => details.ticketSelectionDetails?.selectedTimeslot === timeslot.startAt);
31218
+ const selected = /* @__PURE__ */ user_derived(() => details.tsd?.selectedTimeslot === timeslot.startAt);
31155
31219
  var li = root_2$1();
31156
31220
  var label = child(li);
31157
31221
  var text2 = child(label);
@@ -31175,9 +31239,9 @@ function Timeslots($$anchor, $$props) {
31175
31239
  input,
31176
31240
  () => {
31177
31241
  timeslot.startAt;
31178
- return details.ticketSelectionDetails.selectedTimeslot;
31242
+ return details.tsd.selectedTimeslot;
31179
31243
  },
31180
- ($$value) => details.ticketSelectionDetails.selectedTimeslot = $$value
31244
+ ($$value) => details.tsd.selectedTimeslot = $$value
31181
31245
  );
31182
31246
  append($$anchor3, li);
31183
31247
  });
@@ -31185,7 +31249,7 @@ function Timeslots($$anchor, $$props) {
31185
31249
  append($$anchor2, ul);
31186
31250
  };
31187
31251
  if_block(node, ($$render) => {
31188
- if (details.ticketSelectionDetails && details.ticketSelectionDetails.filters?.includes("timeslot")) $$render(consequent);
31252
+ if (details.tsd && details.tsd.filters?.includes("timeslot")) $$render(consequent);
31189
31253
  });
31190
31254
  }
31191
31255
  append($$anchor, fragment);
@@ -31468,11 +31532,11 @@ create_custom_element(CalendarUI, { calendarClass: {} }, [], ["details"], true);
31468
31532
  var root$1 = /* @__PURE__ */ from_html(`<div data-calendar-wrapper=""><!></div>`);
31469
31533
  function Calendar2($$anchor, $$props) {
31470
31534
  push($$props, true);
31471
- let ticketSelectionDetails = /* @__PURE__ */ state(void 0);
31472
31535
  const ticketsCalendar = new TicketsCalendar();
31473
31536
  const details = ticketsCalendar;
31474
- onMount(() => {
31475
- set(ticketSelectionDetails, getTicketSelectionDetails($$props.$$host), true);
31537
+ const _ticketSelectionDetails = getTicketSelectionDetails($$props.$$host);
31538
+ const ticketSelectionDetails = /* @__PURE__ */ user_derived(() => _ticketSelectionDetails.value);
31539
+ user_effect(() => {
31476
31540
  ticketsCalendar.details = get$2(ticketSelectionDetails);
31477
31541
  if (get$2(ticketSelectionDetails)) get$2(ticketSelectionDetails).selectedDate = void 0;
31478
31542
  });
@@ -31504,12 +31568,16 @@ function Calendar2($$anchor, $$props) {
31504
31568
  }
31505
31569
  customElements.define("go-calendar", create_custom_element(Calendar2, {}, [], ["details"], false));
31506
31570
  class Details2 {
31507
- #ticketSelectionDetails = /* @__PURE__ */ state();
31571
+ #ticketSelectionDetails;
31508
31572
  get ticketSelectionDetails() {
31509
31573
  return get$2(this.#ticketSelectionDetails);
31510
31574
  }
31511
31575
  set ticketSelectionDetails(value) {
31512
- set(this.#ticketSelectionDetails, value, true);
31576
+ set(this.#ticketSelectionDetails, value);
31577
+ }
31578
+ constructor(tsdWrapper) {
31579
+ if (!tsdWrapper) return;
31580
+ this.#ticketSelectionDetails = /* @__PURE__ */ user_derived(() => tsdWrapper.value);
31513
31581
  }
31514
31582
  addToCart() {
31515
31583
  if (!cart) {
@@ -31539,8 +31607,8 @@ class Details2 {
31539
31607
  var root = /* @__PURE__ */ from_html(`<button data-add-to-cart-button="" data-testid="go-add-to-cart-button__button">Add to cart</button>`);
31540
31608
  function AddToCartButton($$anchor, $$props) {
31541
31609
  push($$props, true);
31542
- const details = new Details2();
31543
- details.ticketSelectionDetails = getTicketSelectionDetails($$props.$$host);
31610
+ const _tsd = getTicketSelectionDetails($$props.$$host);
31611
+ const details = new Details2(_tsd);
31544
31612
  var $$exports = { details };
31545
31613
  var button = root();
31546
31614
  button.__click = () => details.addToCart();